* */ class folders extends dbquery { private $the_start; function __construct() { // configure the sql argument order by if(isset($_GET['start'])) { $this->the_start = strip_tags($_GET['start']); } else { $this->the_start = 0; } } /** * Alphabetical list of the fileplans * * @param string $page page name */ public function fileplanslistletters($page = "fileplans") { // List all the alphabet letter to view the doc types who are starting with the letter if(isset($_GET['show'])) { if($_GET['show'] == "false") { $show = "&show=false"; } else { $show = ""; } } else { $show = ""; } ?>

: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z -

connect(); $this->query("select count(*) as total from ".$table_name." ".$where); $nb_total_1 = $this->fetch_object(); $nb_total = $nb_total_1->total; // define the defaults values $nb_pages = ceil($nb_total/$nb_show); $link = "index.php?page=".$page_name."&start=".$this->the_start."&order=".$this->orderby.$what; if($nb_pages > 1) { $next_start = 0; $page_list1 = '

'; $lastpage = 0; for($i = 0;$i <> $nb_pages; $i++) { $page_name = $i + 1; $the_line = $i + 1; if($this->the_start == $next_start) { $page_list1 .= ""; $page_list2 .= ""; } else { $page_list1 .= ""; $page_list2 .= ""; } $next_start = $next_start + $nb_show; $lastpage = $next_start; } $lastpage = $lastpage - $nb_show; $previous = ""; $next = ""; if($this->the_start > 0) { $start_prev = $this->the_start - $nb_show; $previous = ''; } if($this->the_start <> $lastpage) { $start_next = $this->the_start + $nb_show; $next = ''; } $page_list1 = $page_list1.""; $page_list2 = $page_list2.""; if($previous <> '' || $next <> '') { if(empty($previous)) { $previous = " "; } if(empty($next)) { $next = " "; } $page_list1 .= $previous." ".$next.'

'; $page_list2 .= $previous." ".$next.'

'; } } if (empty($where)) { $this->query("select FILEPLAN_ID, FILEPLAN_DESCRIPTION, FILEPLAN_OWNER from ".$table_name." where SHARED_FILEPLAN = 'Y' order by FILEPLAN_DESCRIPTION asc limit ".$this->the_start.",".$nb_show); } else { $this->query("select FILEPLAN_ID, FILEPLAN_DESCRIPTION, FILEPLAN_OWNER from ".$table_name." ".$where." and SHARED_FILEPLAN = 'Y' order by FILEPLAN_DESCRIPTION asc limit ".$this->the_start.",".$nb_show); } echo '

'.$title.'

'; $this->fileplanslistletters(); echo $page_list1; ?> fetch_object()) { if($color == ' class="col"') { $color = ''; } else { $color = ' class="col"'; } $id = $desc = $owner = ""; $id = $line->FILEPLAN_ID; $desc = $line->FILEPLAN_DESCRIPTION; $owner = $line->FILEPLAN_OWNER; //echo $id.'->'.$desc.'
'; $userInfos = array(); $userInfos = $func->infouser($owner); ?> >
'));" >
clearfileplaninfos(); } /** * Form to add or modify a fileplan * * @param string $mode up or add * @param string $id identifier of the fileplan to modify */ public function formfileplan($mode , $id = "", $fid="") { $func = new functions(); $state = true; if(!isset($_SESSION['m_admin']['fileplan'])) { $this->clearfileplaninfos(); } if( $mode <> "add" && empty($_SESSION['error'])) { $this->connect(); $this->query("select * from ".$_SESSION['tablename']['fileplans']." where FILEPLAN_ID = '".$id."'"); if($this->nb_result() == 0) { $_SESSION['error'] = _FILEPLAN.' '._UNKNOWN; $state = false; } else { $_SESSION['m_admin']['fileplan'] = array(); $line = $this->fetch_object(); $_SESSION['m_admin']['fileplan']['ID'] = $line->FILEPLAN_ID; $_SESSION['m_admin']['fileplan']['LABEL'] = trim($line->FILEPLAN_DESCRIPTION); $_SESSION['m_admin']['fileplan']['OWNER'] = trim($line->FILEPLAN_OWNER); } } ?>

*

drawRoot($id, $fid, "index.php?page=fileplan_up&id=".$id."&", "perso"); $this->buildTreeView($_GET['action'], $id, "perso", "index.php?page=fileplan_up&id=".$id, $fid, $_GET['do'], $folder_parents); ?>

"; } $_SESSION['m_admin']['fileplan']['LABEL'] = $func->wash($_REQUEST['fileplan_name'], "no", _THE_WORDING); $_SESSION['m_admin']['fileplan']['LABEL'] = trim(stripslashes($_SESSION['m_admin']['fileplan']['LABEL'])); if($_REQUEST['mode'] == "up") { $_SESSION['m_admin']['fileplan']['ID'] = $func->wash($_REQUEST['fileplan_id'], "no", _ID); } } /** * Update the database with the fileplans data * */ public function upfileplan() { $this->fileplaninfo(); if(!empty($_SESSION['error'])) { if($_REQUEST['mode'] == "up") { if(!empty($_SESSION['m_admin']['fileplan']['ID'])) { header("location: index.php?page=fileplan_up&id=".$_SESSION['m_admin']['fileplan']['ID']); exit; } else { header("location: index.php?page=fileplans"); exit; } } elseif($_REQUEST['mode'] == "add" ) { header("location: index.php?page=fileplan_add"); exit; } } else { $this->connect(); if( $_REQUEST['mode'] <> "add") { /*if($description == 'monplandeclassement') { $_SESSION['error'] = $description.' '._DEFAULT_LABEL; return false; }*/ $this->query("update `".$_SESSION['tablename']['fileplans']."` set FILEPLAN_DESCRIPTION = '".addslashes($_SESSION['m_admin']['fileplan']['LABEL'])."' where FILEPLAN_ID = '".$_SESSION['m_admin']['fileplan']['ID']."'"); if($_REQUEST['mode'] == "up") { $_SESSION['info'] = _FILEPLAN_UPDATED; if($_SESSION['history']['fileplansup'] == "true") { require_once("class_history.php"); $history = new history(); $history->add($_SESSION['tablename']['fileplans'], $_SESSION['m_admin']['fileplan']['ID'],"UP",_FILEPLAN_UPDATED." : ".$_SESSION['m_admin']['fileplan']['LABEL']); } } $this->clearfileplaninfos(); header("location: index.php?page=fileplans"); exit; } else { $this->query("select FILEPLAN_DESCRIPTION from ".$_SESSION['tablename']['fileplans']." where FILEPLAN_DESCRIPTION = '".addslashes($_SESSION['m_admin']['fileplan']['LABEL'])."' and FILEPLAN_OWNER = '".$_SESSION['user']['UserId']."'"); if($this->nb_result() > 0) { $_SESSION['error'] = $_SESSION['m_admin']['fileplan']['LABEL'].' '._ALREADY_EXISTS; header("location: index.php?page=fileplan_add"); exit; } else { if( $_REQUEST['mode'] == "add") { $this->query("INSERT INTO ".$_SESSION['tablename']['fileplans']." ( FILEPLAN_DESCRIPTION, FILEPLAN_OWNER, CREATION_DATE, SHARED_FILEPLAN) VALUES ( '".addslashes($_SESSION['m_admin']['fileplan']['LABEL'])."', '".$_SESSION['user']['UserId']."', now(), 'Y')"); //Get the last id $this->query("select FILEPLAN_ID from ".$_SESSION['tablename']['fileplans']." where FILEPLAN_DESCRIPTION = '".addslashes($_SESSION['m_admin']['fileplan']['LABEL'])."' and FILEPLAN_OWNER = '".$_SESSION['user']['UserId']."'"); $res = $this->fetch_object(); $_SESSION['m_admin']['fileplan']['ID'] = $res->FILEPLAN_ID; if($_SESSION['history']['fileplansadd'] == "true") { require_once("class_history.php"); $history = new history(); $history->add($_SESSION['tablename']['fileplans'], $_SESSION['m_admin']['fileplan']['ID'],"ADD", _FILEPLAN_ADDED." : ".$_SESSION['m_admin']['fileplan']['LABEL']); } } $_SESSION['info'] = _FILEPLAN_ADDED; } $_SESSION['error'] = ""; } if ($_REQUEST['mode'] == "add") { $url = "index.php?page=fileplan_up&id=".$_SESSION['m_admin']['fileplan']['ID']."&folder_id=-1"; } $this->clearfileplaninfos(); header("location: ".$url); exit; } } /** * delete a fileplan in the database * * @param string $fileplan_id fileplan identifier */ public function delfileplan($fileplan_id) { if(!empty($_SESSION['error'])) { header("location: index.php?page=fileplans"); exit; } else { $this->connect(); $this->query("select FILEPLAN_ID, FILEPLAN_DESCRIPTION from ".$_SESSION['tablename']['fileplans']." where FILEPLAN_ID = ".$fileplan_id); if($this->nb_result() == 0) { $_SESSION['error'] = _FILEPLAN.' '._UNKNOWN; header("location: index.php?page=fileplans"); exit; } else { $res = $this->fetch_object(); $label = $res->LABEL; //Supprimer les dossiers du plan de classment $this->query("select FOLDER_ID from ".$_SESSION['tablename']['folders']." where FILEPLAN_ID = ".$fileplan_id." and USER_ID = '".$_SESSION['user']['UserId']."'"); $conn = new dbquery(); $conn->connect(); while($line = $this->fetch_object()) { $folder_id = $line->FOLDER_ID; //On supprime!! $conn->query("delete from ".$_SESSION['tablename']['folderscope']." where FOLDER_ID = '".$folder_id."'"); $conn->query("delete from ".$_SESSION['tablename']['folderres']." where FOLDER_ID = '".$folder_id."'"); $conn->query("delete from ".$_SESSION['tablename']['folders']." where FOLDER_ID = '".$folder_id."' and USER_ID = '".$_SESSION['user']['UserId']."'"); } //Supprimer le plan de classement $this->query("delete from ".$_SESSION['tablename']['fileplans']." where FILEPLAN_ID = ".$fileplan_id); if($_SESSION['history']['fileplansdel']) { require_once("class_history.php"); $users = new history(); $users->add($_SESSION['tablename']['fileplans'], $id,"DEL",_FILEPLAN_DELETION." : ".$label); } $_SESSION['info'] = _FILEPLAN_DELETED; header("location: index.php?page=fileplans"); exit; } } } public function fileplanIsEmpty ($fileplan_id) { $isEmpty = false; $this->connect(); $this->query("select FILEPLAN_ID, FOLDER_ID from ".$_SESSION['tablename']['folders']." where FILEPLAN_ID = ".$fileplan_id); if($this->nb_result() == 0) { $isEmpty = true; return $isEmpty; } else { $tab_folder = array(); while ($line = $this->fetch_object()) { $tab_folder[] = $line->FOLDER_ID; } return $tab_folder; } } public function fileplanOwner($fileplan_id, $user_id) { $isOwner = false; if ($_SESSION['user']['admin'] == true) { $isOwner = true; return $isOwner; } if(!empty($fileplan_id)) { $this->connect(); $this->query("select FILEPLAN_ID from ".$_SESSION['tablename']['fileplans']." where FILEPLAN_ID = ".$fileplan_id." and FILEPLAN_OWNER = '".$user_id."'"); if($this->nb_result() != 0) { $isOwner = true; } } return $isOwner; } //Function used by the other bellow recursively to help to check //if the folder that`s being opened is son of the one being displayed. private function checkParents($fileplan_id, $folder_id, $folder_current, &$folder_parents) { $conn = new dbquery(); $conn->connect(); $conn->query("select * from ".$_SESSION['tablename']['folders']." where FILEPLAN_ID = '".$fileplan_id ."' and FOLDER_ID = '".$folder_id ."' and USER_ID = '".$_SESSION['user']['UserId']."' order by DESCRIPTION"); $nb_total = $conn->nb_result(); if ($nb_total != 0) { while($res = $conn->fetch_object()) { $folder_parents[]=$res->FOLDER_ID; $this->checkParents($fileplan_id, $res->PARENT_ID, $folder_current, $folder_parents); } } } //Function used to check if the folder that`s being opened //is son of the one being displayed. private function openFolder($fileplan_id, $folder_id, $folder_current) { $this->checkParents($fileplan_id, $folder_id, $folder_current, $folder_parents); if (is_array($folder_parents)) { if (in_array($folder_current, $folder_parents)) { return true; } } } //Calculates and organize the hierarchy of the opened folders private function drawBlanksIntersecs($folder_id, $parent_id) { $conn1 = new dbquery(); $conn1->connect(); $conn2 = new dbquery(); $conn2->connect(); $conn3 = new dbquery(); $conn3->connect(); if($parent_id==""){ $parent_id=-1; } if ($idframe == "perso") { $conn1->query("select FOLDER_ID, PARENT_ID from ".$_SESSION['tablename']['folders']." where PARENT_ID = ".$folder_id); } else { $value = "'".$_SESSION['user']['services'][0]['ID']."'"; for ($cpt=1; $cpt < count($_SESSION['user']['services']); $cpt++) { $value = $value.", '".$_SESSION['user']['services'][$cpt]['ID']."'"; } $conn1->query("SELECT * FROM ".$_SESSION['tablename']['folderscope']." fds, ".$_SESSION['tablename']['folders']." fol, ".$_SESSION['tablename']['fileplans']." fil WHERE fds.folder_id = fol.folder_id" ." AND fol.folder_id = ".$parent_id ." AND fil.fileplan_id = fol.fileplan_id" ." AND fol.shared_folder = 'Y'" ." AND ((scope = 'user' AND value = '".$_SESSION['user']['UserId']."')" ." OR (scope = 'all')" ." OR (scope = 'entity' AND value in (".$value."))" ." OR (scope = 'entities' AND value in (".$value.")))" ." GROUP BY fil.fileplan_id, fol.folder_id, fileplan_description"); } $res = $conn1->fetch_object(); $parent_id = $res->FOLDER_ID; //echo "valeur initiale parent : ".$parent_id."
"; $nb_total = $conn1->nb_result(); if ($nb_total != 0) { $is_last=0; } else { $is_last=1; } /*if(!empty($res->PARENT_ID) and ($res->PARENT_ID!=-1)) { /*$conn2->query("select FOLDER_ID, PARENT_ID from ".$_SESSION['tablename']['folders']." where FOLDER_ID = ".$res->PARENT_ID); $conn2->show(); $res2 = $conn2->fetch_object();*/ /*$conn3->query("select FOLDER_ID, PARENT_ID from ".$_SESSION['tablename']['folders']." where PARENT_ID = ".$res2->FOLDER_ID." order by DESCRIPTION"); $res3 = $conn3->fetch_object(); $nb_total = $conn1->nb_result(); $i=0; $is_last = 1; if ($nb_total != 0) { while ($res = $conn1->fetch_object()) { $i++; if ($res->FOLDER_ID == $parent_id ) { $is_last=1; } else { $is_last=0; } } }*/ //echo $is_last.": ".$parent_id." / "; //if ($parent_id != -1) if(!empty($res->PARENT_ID) and ($res->PARENT_ID!=-1)) { $this->drawBlanksIntersecs($parent_id, $res->PARENT_ID); if ($is_last == 1) { echo "\n"; } elseif ($is_last == 0) { echo "\n"; } } } //} //Function that builds the tree from root to the last opened folder //public function buildTreeView($action, $fileplan_id, $idframe, $link, $folder_id=-1, $do='', $folder_parents=-1,$depth=0,$parent_last=0) public function buildTreeView($action, $fileplan_id, $idframe, $link, $folder_id, $do='', $folder_parents,$depth=0,$parent_last=0) { $value = "'".$_SESSION['user']['services'][0]['ID']."'"; for ($cpt=1; $cpt < count($_SESSION['user']['services']); $cpt++) { $value = $value.", '".$_SESSION['user']['services'][$cpt]['ID']."'"; } if(isset($fileplan_id) && !empty($fileplan_id)){ $conn = new dbquery(); $conn->connect(); if ($idframe == "perso") { $conn->query("select * from ".$_SESSION['tablename']['folders']." where FILEPLAN_ID = ".$fileplan_id." order by DESCRIPTION"); } elseif ($idframe == "partage") { $conn->query("SELECT * FROM ".$_SESSION['tablename']['folderscope']." fds, ".$_SESSION['tablename']['folders']." fol, ".$_SESSION['tablename']['fileplans']." fil WHERE fds.folder_id = fol.folder_id" ." AND fol.fileplan_id = ".$fileplan_id ." AND fil.fileplan_id = fol.fileplan_id" ." AND fol.shared_folder = 'Y'" ." AND ((scope = 'user' AND value = '".$_SESSION['user']['UserId']."')" ." OR (scope = 'all')" ." OR (scope = 'entity' AND value in (".$value."))" ." OR (scope = 'entities' AND value in (".$value.")))" ." GROUP BY fol.folder_id, fileplan_description" ." ORDER BY fol.parent_id"); } else { $conn->query("SELECT * FROM ".$_SESSION['tablename']['folderscope']." fds, ".$_SESSION['tablename']['folders']." fol, ".$_SESSION['tablename']['fileplans']." fil WHERE fds.folder_id = fol.folder_id" ." AND fol.fileplan_id = ".$fileplan_id ." AND write_right = 'Y'" ." AND fil.fileplan_id = fol.fileplan_id" ." AND fol.shared_folder = 'Y'" ." AND ((scope = 'user' AND value = '".$_SESSION['user']['UserId']."')" ." OR (scope = 'all')" ." OR (scope = 'entity' AND value in (".$value."))" ." OR (scope = 'entities' AND value in (".$value.")))" ." GROUP BY fol.folder_id, fileplan_description" ." ORDER BY fol.parent_id"); } $tab_folders = array(); $conn2 = new dbquery(); $conn2->connect(); $depth++; $i=1; while ($parent = $conn->fetch_object()) { array_push($tab_folders, array("FI" => $fileplan_id, "Folder" => $parent->FOLDER_ID, "Parent" => $parent->PARENT_ID, "Label" => $parent->DESCRIPTION, "Process" => 'N')); echo "\n"; echo "\n"; /*if ($parent->PARENT_ID !=-1) { $this->drawBlanksIntersecs($parent->FOLDER_ID, $parent->PARENT_ID); }*/ /*if ($idframe == "perso") { $conn2->query("select * from ".$_SESSION['tablename']['folders']." where FILEPLAN_ID = ".$fileplan_id." and PARENT_ID = ".$parent->FOLDER_ID." and USER_ID = '".$_SESSION['user']['UserId']."' order by DESCRIPTION"); } else { $value = "'".$_SESSION['user']['services'][0]['ID']."'"; for ($cpt=1; $cpt < count($_SESSION['user']['services']); $cpt++) { $value = $value.", '".$_SESSION['user']['services'][$cpt]['ID']."'"; } $conn2->query("SELECT * FROM ".$_SESSION['tablename']['folderscope']." fds, ".$_SESSION['tablename']['folders']." fol, ".$_SESSION['tablename']['fileplans']." fil WHERE fds.folder_id = fol.folder_id" ." AND PARENT_ID = ".$parent->FOLDER_ID ." AND fol.fileplan_id = ".$fileplan_id ." AND fil.fileplan_id = fol.fileplan_id" ." AND fol.shared_folder = 'Y'" ." AND ((scope = 'user' AND value = '".$_SESSION['user']['UserId']."')" ." OR (scope = 'all')" ." OR (scope = 'entities' AND value in (".$value.")))" ." GROUP BY fol.folder_id, fileplan_description" ." ORDER BY fol.parent_id"); }*/ /*if ($conn2->nb_result() != 0) { if ($action == "expand" && $this->openFolder($fileplan_id, $folder_id, $parent->FOLDER_ID)) { echo "PARENT_ID."\">"; if ($conn->nb_result() == $i) { echo "\n"; } else { echo "\n"; } } else { echo "FOLDER_ID."\">"; //$class="class=\"folderSelect\""; if ($conn->nb_result() == $i) { echo "\n"; } else { echo "\n"; } } } else { //$class="class=\"folderSelect\""; if ($conn2->nb_result() == $i) { echo "\n"; } else { echo "\n"; } }*/ /*if ($action=="expand" && $this->openFolder($fileplan_id, $folder_id, $parent->FOLDER_ID)) { if ((isset($do) && !empty($do)) && ($do == "CUT" || $do == "COPY") && ($parent->FOLDER_ID == $folder_id)) { $class="class=\"folderDo\""; } else { $class="class=\"folderSelect\""; } //echo '->'.$parent->FOLDER_ID; //Scope $scope = $this->getScope($parent->FOLDER_ID); if ($scope['scope'] =='NONE') { $folderImg = 'folderOpen.gif'; } else { $folderImg = 'folderSharedOpen.gif'; } echo "\n"; } else if ($action=="" && $this->openFolder($fileplan_id, $folder_id, $parent->FOLDER_ID)) { if ((isset($do) && !empty($do)) && ($do == "CUT" || $do == "COPY") && ($parent->FOLDER_ID == $folder_id)) { $class="class=\"folderDo\""; }else { $class="class=\"folderSelect\""; } //echo '-->'.$folder_id; //Scope $scope = $this->getScope($folder_id); if ($scope['scope'] =='NONE') { $folderImg = 'folderClosed.gif'; } else { $folderImg = 'folderSharedClosed.gif'; } echo "\n"; } else { //echo '--->'.$parent->FOLDER_ID; $scope = $this->getScope($parent->FOLDER_ID); if ($scope['scope'] =='NONE') { $folderImg = 'folderClosed.gif'; } else { $folderImg = 'folderSharedClosed.gif'; } $class=""; echo "\n"; }*/ //echo ""; //Here you can change where the link of the folder points too. //You really should to edit it... /*echo "FOLDER_ID."\" >"; echo "  ".stripslashes($parent->DESCRIPTION)." (".$this->countDoc ($parent->FOLDER_ID).")   "; echo "\n"; echo "\n"; if ($action=="expand" && $this->openFolder($fileplan_id, $folder_id, $parent->FOLDER_ID)) { $this->buildTreeView($action, $fileplan_id, $folder_id, $link, $do, $parent->FOLDER_ID, $depth, $parent_last); } $i++;*/ } /*echo "
";
			print_r($tab_folders);
			echo "
";*/ $tab_folders = $this->getOrphan($tab_folders); $tmp = Array(); for ($compteur =0; $compteur $tab_folders[$compteur]['Folder'], "label" => $tab_folders[$compteur]['Label']." (".$this->countDoc($tab_folders[$compteur]['Folder']).")", "children" => $this->getChild($tab_folders[$compteur]['Folder'], $tab_folders) ) ); } } ?>
\n .MaarchTreeRoot li:last-child {\n background-image: url(img/img_tree/line2.gif) !important;\n }\n .MaarchTreeRoot li{\n background-image: url(img/img_tree/line3.gif) !important;\n }\n .mt_selected > span {\n background-color: inherit !important;\n } \n";*/ /*echo "
";
			print_r($tab_folders);
			echo "
";*/ } } //Function to find if there is a child public function getChild($folder_id, $tab_folders) { $tab_children=array(); for ($compteur =0; $compteur $tab_folders[$compteur]['Folder'], "label" => $tab_folders[$compteur]['Label']." (".$this->countDoc($tab_folders[$compteur]['Folder']).")", "children" => $this->getChild($tab_folders[$compteur]['Folder'], $tab_folders) ) ); } } return $tab_children; } //Function to get if the folder has a parent in the table public function getOrphan($tab_folders) { for ($compteur =0; $compteur -1) { if(!($this->isParentExists($tab_folders[$compteur]['Parent'], $tab_folders))) { $tab_folders[$compteur]['Parent'] = $this->checkDbParent($tab_folders[$compteur]['Parent'], $tab_folders); if ($tab_folders[$compteur]['Parent'] == "") { $tab_folders[$compteur]['Parent'] = -1; } } } } return($tab_folders); } //Function to get is the parent exists in the table public function isParentExists($parent, $tab_folders){ for ($compteur =0; $compteurconnect(); $conn->query("select parent_id from ".$_SESSION['tablename']['folders']." where folder_id = ".$current_parent); $line = $conn->fetch_object(); if($line->parent_id <> -1) { for ($compteur =0; $compteurparent_id) { return $line->parent_id;break; } } $this->checkDbParent($line->parent_id, $tab_folders); } else { return -1; } } //Function to select folders to copy /* public function toCut($folder_id, $do) { $tab_folder_deletion = array(); $this->connect(); $this->query("select * from ".$_SESSION['tablename']['folders']." where FOLDER_ID = '".$folder_id."' and USER_ID = '".$_SESSION['user']['UserId']."'"); //$this->show(); if ($this->nb_result() == 0) { $_SESSION['error'] = _FOLDER_MISSING; } else { array_push( $tab_folder_deletion, array( "Folder"=> $line->FOLDER_ID, "Parent" => $parent->PARENT_ID "Label" => $line->DESCRIPTION, "children" => $this->getChild($tab_folders[$compteur]['Folder'], $tab_folders) ) ); echo "
";
			print_r($tab_folder_deletion);
			echo "
"; return $tab_folder_deletion; } } */ //Function to add folder public function addFolder($description, $folder_parents=-1, $fileplan, $idframe) { $folderId = ''; $exist = $this->folderAlreadyExists($description, $fileplan, $folder_parents); if($exist === true) { $_SESSION['error'] = $description.' '._ALREADY_EXISTS; return false; } else { if($idframe == "perso") { $shared_folder = 'N'; } else $shared_folder = 'Y'; $this->query("INSERT INTO ".$_SESSION['tablename']['folders']." ( DESCRIPTION, FILEPLAN_ID, USER_ID, PARENT_ID, SHARED_FOLDER) VALUES ('".addslashes($description)."', ".$fileplan.", '".$_SESSION['user']['UserId']."', '".$folder_parents."', '".$shared_folder."')"); //$this->show();exit; $_SESSION['info'] = _FOLDER_ADDED; //Recupere le last ID $this->query("select FOLDER_ID as LAST_ID from ".$_SESSION['tablename']['folders']." where DESCRIPTION = '".addslashes($description)."' and FILEPLAN_ID = '".$fileplan."' and PARENT_ID = '".$folder_parents."'"); $line = $this->fetch_object(); $folderId = $line->LAST_ID; if($_SESSION['history']['folderadd'] == "true") { require_once("class_history.php"); $hist = new history(); $hist->add($_SESSION['tablename']['folders'], $folder_id, "ADD", _FOLDER_ADDED); } return $folderId; } } //Function to update folder public function upFolder($folder_id, $description) { $this->query("select PARENT_ID from ".$_SESSION['tablename']['folders']." where FOLDER_ID = '".$folder_id."' and USER_ID = '".$_SESSION['user']['UserId']."'"); //$this->show(); if ($this->nb_result() == 0) { $_SESSION['error'] = _FOLDER_MISSING; } else { $this->query("update ".$_SESSION['tablename']['folders']." set DESCRIPTION = '".addslashes($description)."' where USER_ID = '".$_SESSION['user']['UserId']."' and FOLDER_ID = '".$folder_id."'"); //$this->show();exit; $_SESSION['info'] = _FOLDER_MODIFIED; // if($_SESSION['history']['folderup'] == "true") { require("class_history.php"); $hist = new history(); $hist->add($_SESSION['tablename']['folders'], $folder_id, "UP", _FOLDER_MODIFIED); } } } //Function to delete folder public function delFolder($fileplan_id, $folder_id, $mode) { $this->query("select FOLDER_ID, PARENT_ID, DESCRIPTION from ".$_SESSION['tablename']['folders']." where FOLDER_ID = '".$folder_id."' and FILEPLAN_ID = ".$fileplan_id." and USER_ID = '".$_SESSION['user']['UserId']."'"); //$this->show(); if ($this->nb_result() == 0) { $_SESSION['error'] = _FOLDER_MISSING; } else { if ($mode == "FLH") { $this->query("delete from ".$_SESSION['tablename']['folderres']." where FOLDER_ID = '".$folder_id."'"); $_SESSION['info'] = _FOLDER_FLUSHED; if($_SESSION['history']['folderdel'] == "true") { require_once("class_history.php"); $hist = new history(); $hist->add($_SESSION['tablename']['folders'], $folder_id, "DEL", _FOLDER_FLUSHED); } return $folder_id; } elseif ($mode == "DEL") { $parent = ""; //On recuper le parent pour pouvoir se positionner dessus apres suppression $line = $this->fetch_object(); $parent = $line->PARENT_ID; $tab_folders_to_delete = array(); if ($this->nb_result() <> 0) { array_push($tab_folders_to_delete, array("Folder" => $line->FOLDER_ID, "Parent" => $line->PARENT_ID, "Label" => $line->DESCRIPTION)); if ($this->folderToDelete($tab_folders_to_delete)==true) { //On supprime à niveau n on verra pour la recursivité hein!! $this->query("delete from ".$_SESSION['tablename']['folders']." where USER_ID = '".$_SESSION['user']['UserId']."' and FOLDER_ID = '".$folder_id."'"); $this->query("delete from ".$_SESSION['tablename']['folderres']." where FOLDER_ID = '".$folder_id."'"); $this->query("delete from ".$_SESSION['tablename']['folderscope']." where FOLDER_ID = '".$folder_id."'"); $_SESSION['info'] = _FOLDER_DELETED; } if($_SESSION['history']['folderdel'] == "true") { require_once("class_history.php"); $hist = new history(); $hist->add($_SESSION['tablename']['folders'], $folder_id, "DEL", _FOLDER_DELETED); } return $parent; } } } } //This function creates a table for folders to delete public function folderToDelete($tab_folders_to_delete) { for ($compteur =0; $compteurquery("select * from ".$_SESSION['tablename']['folders']." where PARENT_ID = ".$tab_folders_to_delete[$compteur]['Folder']." and USER_ID = '".$_SESSION['user']['UserId']."'"); $this->show(); while($line = $this->fetch_object()) { array_push($tab_folders_to_delete, array("Folder" => $line->FOLDER_ID, "Parent" => $line->PARENT_ID, "Label" => $line->DESCRIPTION)); } echo "
";
			print_r($tab_folders_to_delete);
			echo "
"; $this->query("delete from ".$_SESSION['tablename']['folders']." where USER_ID = '".$_SESSION['user']['UserId']."' and FOLDER_ID = '".$tab_folders_to_delete[$compteur]['Folder']."'"); $this->query("delete from ".$_SESSION['tablename']['folderres']." where FOLDER_ID = '".$tab_folders_to_delete[$compteur]['Folder']."'"); $this->query("delete from ".$_SESSION['tablename']['folderscope']." where FOLDER_ID = '".$tab_folders_to_delete[$compteur]['Folder']."'"); } return true; } //This function put document into folder public function putFolder($folder_id, $res_id) { $tab_resid = array(); if (empty($folder_id)) { $_SESSION['error'] = _FOLDER_MISSING; } elseif (empty($res_id)) { $_SESSION['error'] = _GED_NUM_MISSING; } if (empty ($_SESSION['error'])) { if($folder_id == -1) { $_SESSION['error'] = _CANT_CLASSIFIED_ON_ROOT; } else { $conn = new dbquery(); $conn->connect(); $conn->query("select * from ".$_SESSION['tablename']['folders']." where FOLDER_ID = ".$folder_id); //$conn->show(); if ($conn->nb_result() == 0) { $_SESSION['error'] = _FOLDER_MISSING; } else { $conn->query("select * from ".$_SESSION['tablename']['folderres']." where FOLDER_ID = '".$folder_id."' and RES_ID = '".$res_id."'"); if ($conn->nb_result() >0) { $_SESSION['error'] .= _NUM." ".$res_id.": "._MAIL_ALREADY_CLASSIFIED."
"; } else { $conn->query("INSERT INTO ".$_SESSION['tablename']['folderres']." ( FOLDER_ID, RES_ID) VALUES ('".$folder_id."', '".$res_id."')"); //$_SESSION['info'] = _MAIL_CLASSIFIED; if($_SESSION['history']['folderput'] == "true") { require_once("class_history.php"); $hist = new history(); $hist->add($_SESSION['tablename']['folders'], $folder_id, "DEL", _MAIL_CLASSIFIED." ".$res_id); } } } } } } //This function gets the information oft the copied or cuted folder public function getFolder($folder_id, $do) { $tab_folder = array(); $this->connect(); $this->query("select * from ".$_SESSION['tablename']['folders']." where FOLDER_ID = '".$folder_id."' and USER_ID = '".$_SESSION['user']['UserId']."'"); //$this->show(); if ($this->nb_result() == 0) { $_SESSION['error'] = _FOLDER_MISSING; } else { $line = $this->fetch_object(); $tab_folder['ACTION'] = $do; $tab_folder['ID'] = $line->FOLDER_ID; $tab_folder['DESCRIPTION'] = $line->DESCRIPTION; $tab_folder['PARENT_ID'] = $line->PARENT_ID; /*echo "
";
			print_r($tab_folder);
			echo "
";*/ return $tab_folder; } } //Function to copy or cut folders public function moveFolder($tab_folder, $fileplan_id, $folder_id) { if (empty($folder_id)) { $_SESSION['error'] = _FOLDER_MISSING; exit; } $this->connect(); $this->query("select * from ".$_SESSION['tablename']['folders']." where FOLDER_ID = '".$folder_id."' and USER_ID = '".$_SESSION['user']['UserId']."'"); //$this->show(); if ($this->nb_result() == 0 && $folder_id != -1) { $_SESSION['error'] = _FOLDER_MISSING; } else { if ($tab_folder['ACTION'] == "CUT") { if ($tab_folder['ID'] == $folder_id) { $_SESSION['error'] = _CANT_MOVE_FOLDER_HIMSELF; } else { //On verifie si un classeur portant le même non n'existe pas déja $exist = $this->folderAlreadyExists($tab_folder['DESCRIPTION'], $fileplan_id, $folder_id); if($exist === true) { $_SESSION['error'] = $tab_folder['DESCRIPTION'].' '._ALREADY_EXISTS; } else { $this->query("select FOLDER_ID from ".$_SESSION['tablename']['folders']." where PARENT_ID = '".$tab_folder['ID']."' and USER_ID = '".$_SESSION['user']['UserId']."'"); $line = $this->fetch_object(); $child_folder = $line->FOLDER_ID; if ($folder_id == $child_folder) { $_SESSION['error'] = _CANT_MOVE_FOLDER_IN_CHILD; } else { $this->query("UPDATE ".$_SESSION['tablename']['folders']." SET PARENT_ID = '".$folder_id."' where FILEPLAN_ID = '".$fileplan_id."' and FOLDER_ID = '".$tab_folder['ID']."' and USER_ID = '".$_SESSION['user']['UserId']."'"); $_SESSION['info'] = _FOLDER_MOVED; if($_SESSION['history']['foldermove'] == "true") { require_once("class_history.php"); $hist = new history(); $hist->add($_SESSION['tablename']['folders'], $folder_id, "UP", _FOLDER_MOVED); } } } } } elseif ($tab_folder['ACTION'] == "COPY") { //Verifier si ce classeur a des sous classeurs $this->query("select * from ".$_SESSION['tablename']['folders']." where PARENT_ID = '".$tab_folder['ID']."' and USER_ID = '".$_SESSION['user']['UserId']."'"); $this->show(); //on ne deplace qu'un classeur à la fois if ($this->nb_result() == 0) { //On verifie si un classeur portant le même non n'existe pas déja $exist = $this->folderAlreadyExists($tab_folder['DESCRIPTION'], $fileplan_id, $folder_id); if($exist === true) { $_SESSION['error'] = $tab_folder['DESCRIPTION'].' '._ALREADY_EXISTS; } else { //On crée le nouveau classeur $this->query("INSERT INTO ".$_SESSION['tablename']['folders']." ( FILEPLAN_ID, DESCRIPTION, USER_ID, PARENT_ID) VALUES ('".$fileplan_id."', '".addslashes($tab_folder['DESCRIPTION'])."', '".$_SESSION['user']['UserId']."', '".$folder_id."')"); //$this->show(); //Recupere le last ID $this->query("select FOLDER_ID from ".$_SESSION['tablename']['folders']." where DESCRIPTION = '".addslashes($tab_folder['DESCRIPTION'])."' and FILEPLAN_ID = '".$fileplan_id."' and PARENT_ID = '".$folder_id."'"); $line = $this->fetch_object(); $last_id = $line->FOLDER_ID; //On lui remet les bonnes propriétés (partagé...) $scope = $this->getScope($folder_id); //Recupere les courriers classés $this->query("select RES_ID from ".$_SESSION['tablename']['folderres']." where FOLDER_ID = ".$tab_folder['ID']); //$this->show(); //Les copies dans le nouveau classeur if ($this->nb_result() > 0) { while ($line = $this->fetch_object()) { $this->query("INSERT INTO ".$_SESSION['tablename']['folderres']." ( RES_ID, FOLDER_ID) VALUES ('".$line->RES_ID."', '".$last_id."')"); } } $_SESSION['info'] = _FOLDER_COPIED; if($_SESSION['history']['foldermove'] == "true") { require_once("class_history.php"); $hist = new history(); $hist->add($_SESSION['tablename']['folders'], $folder_id, "UP", _FOLDER_COPIED); } } } else { $_SESSION['error'] = _MOVE_ONLY_ONE_FOLDER; } } } $tab_folder = array(); } //Function to draw the Root of The treeview //If the root is empty, the picture is not the same public function drawRoot($fileplan_id, $folder_id, $link, $idframe) { $conn = new dbquery(); $conn->connect(); /* if (!isset($fileplan_id) || empty($fileplan_id)){ $_SESSION['info'] = _NO_PERSONAL_FILEPLAN; echo "

".$_SESSION['info']."

"; } */ if(isset($fileplan_id) && !empty($fileplan_id)) { if ($idframe == "perso") { $conn->query("select * from ".$_SESSION['tablename']['folders']." tbl_fol, ".$_SESSION['tablename']['fileplans']." tbl_file where tbl_file.FILEPLAN_ID = ".$fileplan_id." and PARENT_ID = '-1' and USER_ID = '".$_SESSION['user']['UserId']."' order by DESCRIPTION"); } else { $conn->query("SELECT * FROM ".$_SESSION['tablename']['fileplans']." fil WHERE fil.fileplan_id = ".$fileplan_id); } $line = $conn->fetch_object(); echo "\n"; echo "\n"; if ( (isset($folder_id) && !empty($folder_id)) || $folder_id ==-1) { $class="class=\"folderSelect\""; } else { $class=""; } if ($idframe == "perso") echo ""; else echo ""; if ($conn->nb_result() == 0) { echo "\n"; } else { echo "\n"; } echo "    ".$line->FILEPLAN_DESCRIPTION.""; echo " \n"; echo "\n"; } } public function countDoc($folder_id) { $count_doc = 0; $conn = new dbquery(); $conn->connect(); $conn->query("select count(*) as TOTAL from ".$_SESSION['tablename']['folderres']." where FOLDER_ID = '".$folder_id."'"); //$conn->show(); $line = $conn->fetch_object(); $count_doc = $line->TOTAL; return $count_doc; } public function addScope($folderId) { $choix = 'none'; $values = $rw = array(); $conn = new dbquery(); $conn->connect(); if (isset($_REQUEST['chosenAccess'])) { $choix = $_REQUEST['chosenAccess']; } else { $choix = ""; } switch ($choix) { case "all": $scope = 'ALL'; $values[] = '*'; if ($_REQUEST['readWrite']) { $rw[] = '*'; } break; case "": $scope = 'ALL'; $values[] = '*'; $rw[] = '*'; break; case "entity": $scope = 'ENTITY'; $values[] = $_SESSION['user']['department']; if ($_REQUEST['readWrite']) { $rw[] = $_SESSION['user']['department']; } break; case "entities": $scope = 'ENTITIES'; if ($_REQUEST['chosenServices']) { $values = $_REQUEST['chosenServices']; } if ($_REQUEST['readWrite']) { $rw = $_REQUEST['readWrite']; } break; case "users": $scope = 'USER'; if ($_REQUEST['chosenUsers']) { $values = $_REQUEST['chosenUsers']; } if ($_REQUEST['readWrite']) { $rw = $_REQUEST['readWrite']; } break; case "none": $conn->query("delete from ".$_SESSION['tablename']['folderscope']." where FOLDER_ID = ".$folderId); break; } //echo $scope;print_r($values); if (count($values) >0) { $conn->query("delete from ".$_SESSION['tablename']['folderscope']." where FOLDER_ID = ".$folderId); for($i=0;$iquery("INSERT INTO ".$_SESSION['tablename']['folderscope']." (FOLDER_ID, SCOPE, VALUE, WRITE_RIGHT) VALUES (".$folderId.", '".$scope."', '".$values[$i]."', '".$write."')"); } //Mise à jour de l'historique if($_SESSION['history']['folderadd']) { require_once("class_history.php"); $hist = new history(); $hist->add($_SESSION['folders'], $folderId ,"ADD", _FOLDER_ADDITION); } } } public function getScope($folderId) { $values = array(); $scopeId = 'NONE'; $this->connect(); //Scope $this->query("select SCOPE, VALUE, WRITE_RIGHT from ".$_SESSION['tablename']['folderscope']." where FOLDER_ID = ".$folderId); $values['values'] = array(); $values['readWrite'] = array(); while ($line = $this->fetch_object()) { array_push($values['values'], $line->VALUE); if($line->WRITE_RIGHT == 'Y') { array_push($values['readWrite'], $line->VALUE); } $scopeId = $line->SCOPE; } $values['scope']= $scopeId; return $values; } public function getUserSharedFolders() { $folders = array(); $this->connect(); $this->query("select distinct FOLDER_ID from ".$_SESSION['tablename']['folderscope']." where VALUE in( '*', '".$_SESSION['user']['UserId']."', '".$_SESSION['user']['department']."')"); //$this->show(); while ($line = $this->fetch_object()) { array_push($folders, $line->FOLDER_ID); } return $folders; } public function getFolderLabel($folderId) { $this->connect(); $this->query("select DESCRIPTION from ".$_SESSION['tablename']['folders']." where FOLDER_ID = '".$folderId."'"); $line = $this->fetch_object(); return $line->DESCRIPTION; } public function folderAlreadyExists($label, $fileplan_id, $folder_id) { $exists = false; $this->query("select DESCRIPTION from ".$_SESSION['tablename']['folders']." where DESCRIPTION = '".addslashes($label)."' and FILEPLAN_ID = '".$fileplan_id."' and PARENT_ID = '".$folder_id."'"); if($this->nb_result() > 0) { $exists = true; } return $exists; } public function getFolderOwner($folderId) { $this->connect(); $this->query("select USER_ID from ".$_SESSION['tablename']['folders']." where FOLDER_ID = '".$folderId."'"); $line = $this->fetch_object(); return $line->USER_ID; } } ?>