* */ 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 = ""; } ?>
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 = ''; $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 ''));" > |
*
"; print_r($tab_folders); echo "";*/ $tab_folders = $this->getOrphan($tab_folders); $tmp = Array(); for ($compteur =0; $compteur
"; 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
"; 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; $compteur
"; 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."
"; 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 "