* */ /** * Class types: Contains all the function to manage the doctypes * * @author Claire Figueras * @license GPL * @package Maarch LetterBox 2.3 * @version 1.1 */ class types extends dbquery { /** * Redefinition of the types object constructor : configure the sql argument order by */ function __construct() { // configure the sql argument order by if(isset($_GET['start'])) { $this->the_start = strip_tags($_GET['start']); } else { $this->the_start = 0; } if(isset($_GET['order'])) { $this->orderby = strip_tags($_GET['order']); } else { $this->orderby = "labelasc"; } $this->sqlorderby = ""; if($this->orderby == "labelasc") { $this->sqlorderby = "order by DESCRIPTION asc"; } if($this->orderby == "labeldesc") { $this->sqlorderby = "order by DESCRIPTION desc"; } if($this->orderby == "idasc") { $this->sqlorderby = "order by TYPE_ID asc"; } if($this->orderby == "iddesc") { $this->sqlorderby = "order by TYPE_ID desc"; } if($this->orderby == "statusasc") { $this->sqlorderby = "order by ENABLED asc"; } if($this->orderby == "statusdesc") { $this->sqlorderby = "order by ENABLED desc"; } if($this->orderby == "userasc") { $this->sqlorderby = "order by CUSTOM_T2 asc"; } if($this->orderby == "userdesc") { $this->sqlorderby = "order by USER_ID desc"; } } /** * List all the alphabet letter to view the doc types who are starting with the letter * * @param string $page "types" by default */ public function typelistletters($page = "types") { // 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 = ""; } ?>

" class="button" /> '; } ?>

: 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 = $ref_page.".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++) { $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.'

'; } } $this->query("select * from ".$table_name." ".$where." ".$this->sqlorderby." limit ".$this->the_start.",".$nb_show); echo '

'.$title.'

'; $this->typelistletters(); echo $page_list1; ?> fetch_object()) { if($color == ' class="col"') { $color = ''; } else { $color = ' class="col"'; } ?> >
TYPE_ID; ?> show($line->DESCRIPTION); ?> ENABLED == "N") { echo ''._NOT_ENABLED.''; } elseif($line->ENABLED == "Y") { echo ''._ENABLED.''; } ?> show($line->RES_TABLE); for($i=0; $i < count($_SESSION['ressources']); $i++) { if($_SESSION['ressources'][$i]['tablename'] == $tmp) { $table = $_SESSION['ressources'][$i]['comment']; break; } } echo $table; ?> ENABLED == "Y") { echo ''._MODIFY.''; } ?> ENABLED == "N") { echo ''._AUTHORIZE.''; } else { echo " "; } ?>
cleartypeinfos(); } /** * Form to add, modify or propose a doc type * * @param string $mode val, up or prop * @param integer $id type identifier, empty by default */ public function formtype($mode,$id = "") { // form to add, modify or proposale a doc type $func = new functions(); include('doctypes_bitmask.php'); $action_bitmask = 0; $state = true; if(!isset($_SESSION['m_admin']['doctypes'])) { $this->cleartypeinfos(); } if($mode <> "prop" && $mode <> "add" && empty($_SESSION['error'])) { $this->connect(); $this->query("select * from ".$_SESSION['tablename']['doctypes']." where TYPE_ID = '".$id."'"); if($this->nb_result() == 0) { $_SESSION['error'] = _DOCTYPE.' '._ALREADY_EXISTS; $state = false; } else { $_SESSION['m_admin']['doctypes'] = array(); $line = $this->fetch_object(); $_SESSION['m_admin']['doctypes']['TYPE_ID'] = $line->TYPE_ID; $_SESSION['m_admin']['doctypes']['LABEL'] = $line->DESCRIPTION; $_SESSION['m_admin']['doctypes']['VALIDATE'] = $line->ENABLED; $_SESSION['m_admin']['doctypes']['USER_ID'] = $line->CUSTOM_T2; $_SESSION['m_admin']['doctypes']['DATE'] = $line->CUSTOM_T3; $_SESSION['m_admin']['doctypes']['TABLE'] = $line->RES_TABLE; $_SESSION['m_admin']['doctypes']['DELAI_TRAITEMENT'] = $line->DELAI_TRAITEMENT; $_SESSION['m_admin']['doctypes']['DELAI_RELANCE1'] = $line->DELAI_RELANCE1; $_SESSION['m_admin']['doctypes']['DELAI_RELANCE2'] = $line->DELAI_RELANCE2; $_SESSION['m_admin']['doctypes']['GENERATE'] = $line->GENERATE; $_SESSION['m_admin']['doctypes']['MODEL'] = $line->MODEL; $_SESSION['m_admin']['doctypes']['ACTION_BITMASK'] = $line->ACTION_BITMASK; $action_bitmask = $_SESSION['m_admin']['doctypes']['ACTION_BITMASK']; //updated by lgi for oo_generate if ($_SESSION['config']['oo_generate'] == 'true') { $_SESSION['m_admin']['doctypes']['GENERATE'] = 'N'; } } } ?>




"._DOCTYPE.' '._UNKOWN."



"; } else { ?>

"prop" && $mode <> "add") { echo $func->show($_SESSION['m_admin']['doctypes']['TYPE_ID']); ?> *

*

*

'true') { ?> ';

*

*

*



check_right($action_bitmask , $_ENV['doctypes_bitmask'][$k]['ID'])){ echo 'checked="checked"'; } ?> /> '; } ?>

"; } $_SESSION['m_admin']['doctypes']['LABEL'] = $func->wash($_POST['label'], "no", _THE_WORDING); $_SESSION['m_admin']['doctypes']['TYPE_ID'] = $func->wash($_POST['id'], "no", _ID); $_SESSION['m_admin']['doctypes']['TABLE'] = $func->wash($_POST['restable'], "no", _THE_TABLE); $_SESSION['m_admin']['doctypes']['DELAI_TRAITEMENT'] = $func->wash($_POST['traitement'], "num", _THE_PROCESS_LIMIT); $_SESSION['m_admin']['doctypes']['DELAI_RELANCE1'] = $func->wash($_POST['relance1'], "num", _THE_FIRST_WARNING); $_SESSION['m_admin']['doctypes']['DELAI_RELANCE2'] = $func->wash($_POST['relance2'], "num", _THE_SECOND_WARNING); $_SESSION['m_admin']['doctypes']['GENERATE'] = $_SESSION['temp_admin']['GENERATE']; $_SESSION['m_admin']['doctypes']['MODEL'] = $_SESSION['temp_admin']['MODEL_ID']; /*echo "
";
		print_r($_REQUEST);
		echo "
";*/ include('doctypes_bitmask.php'); $action_bitmask = 0; for($i=0;$i"; if($_REQUEST['action_bitmask'.$i] == 'true') { $action_bitmask = $this->set_right($action_bitmask, $_ENV['doctypes_bitmask'][$i]['ID'] ); } } $_SESSION['m_admin']['doctypes']['ACTION_BITMASK'] = $action_bitmask; if($_SESSION['m_admin']['doctypes']['ACTION_BITMASK'] == 0) { $_SESSION['error'] .= _MUST_CHOOSE_AT_LEAST_ONE_ACTION; } //echo "result bitmask : ".$action_bitmask."
"; //exit; } /** * Modify, add or validate a doctype */ public function uptypes() { // modify, add or validate a doctype $this->typesinfo(); if(!empty($_SESSION['error'])) { if($_POST['mode'] == "up") { if(!empty($_SESSION['m_admin']['doctypes']['TYPE_ID'])) { header("location: index.php?page=types_up&id=".$_SESSION['m_admin']['doctypes']['TYPE_ID']); exit; } else { header("location: index.php?page=types"); exit; } } elseif($_POST['mode'] == "val") { if(!empty($_SESSION['m_admin']['doctypes']['TYPE_ID'])) { header("location: index.php?page=types_validate&id=".$_SESSION['m_admin']['doctypes']['TYPE_ID']); exit; } else { header("location: index.php?page=types"); exit; } } elseif($_POST['mode'] == "prop" ) { header("location: index.php?page=types_prop"); exit; } elseif($_POST['mode'] == "add" ) { header("location: index.php?page=types_add"); exit; } } else { $this->connect(); if($_POST['mode'] <> "prop" && $_POST['mode'] <> "add") { $this->query("update `".$_SESSION['tablename']['doctypes']."` set `DESCRIPTION` = '".addslashes($_SESSION['m_admin']['doctypes']['LABEL'])."' , `ENABLED` = 'Y', `RES_TABLE` = '".$_SESSION['m_admin']['doctypes']['TABLE']."', DELAI_TRAITEMENT = ".$_SESSION['m_admin']['doctypes']['DELAI_TRAITEMENT'].", DELAI_RELANCE1 = ".$_SESSION['m_admin']['doctypes']['DELAI_RELANCE1'].", DELAI_RELANCE2 = ".$_SESSION['m_admin']['doctypes']['DELAI_RELANCE2'].", GENERATE = '".$_SESSION['m_admin']['doctypes']['GENERATE']."', MODEL = '".$_SESSION['m_admin']['doctypes']['MODEL']."', ACTION_BITMASK = ".$_SESSION['m_admin']['doctypes']['ACTION_BITMASK']." where TYPE_ID = '".$_SESSION['m_admin']['doctypes']['TYPE_ID']."'"); if($_POST['mode'] == "up") { $_SESSION['error'] = _DOCTYPE_UPDATED; if($_SESSION['history']['doctypesup'] == "true") { require_once("class_history.php"); $users = new history(); $users->add($_SESSION['tablename']['doctypes'], $_SESSION['m_admin']['doctypes']['TYPE_ID'],"UP",_DOCTYPE_UPDATE." : ".$_SESSION['m_admin']['doctypes']['LABEL']); } } $this->cleartypeinfos(); header("location: index.php?page=types"); exit; } else { $this->query("select TYPE_ID from `".$_SESSION['tablename']['doctypes']."` where TYPE_ID = '".$_SESSION['m_admin']['doctypes']['TYPE_ID']."'"); if($this->nb_result() > 0) { $_SESSION['error'] = _THE_DOCTYPE.' '.$_SESSION['m_admin']['doctypes']['TYPE_ID'].' '._ALREADY_EXISTS; header("location: index.php?page=types"); exit; } else { require_once("class_history.php"); $users = new history(); if( $_POST['mode'] == "add") { $this->query("INSERT INTO `".$_SESSION['tablename']['doctypes']."` ( `RES_TABLE` , `TYPE_ID` , `DESCRIPTION` , `DELAI_TRAITEMENT` , `DELAI_RELANCE1` , `DELAI_RELANCE2` , `ENABLED` , `CUSTOM_T2` , `CUSTOM_T3`, `GENERATE` , `MODEL`, `ACTION_BITMASK`) VALUES ('".$_SESSION['m_admin']['doctypes']['TABLE']."','".$_SESSION['m_admin']['doctypes']['TYPE_ID']."', '".$_SESSION['m_admin']['doctypes']['LABEL']."','".$_SESSION['m_admin']['doctypes']['DELAI_TRAITEMENT']."', '".$_SESSION['m_admin']['doctypes']['DELAI_RELANCE1']."', '".$_SESSION['m_admin']['doctypes']['DELAI_RELANCE2']."','Y', '".$_SESSION['user']['UserId']."', '".date("Y")."-".date("m")."-".date("d")." ".date("H:i:s")."' , '".$_SESSION['m_admin']['doctypes']['GENERATE']."', '".$_SESSION['m_admin']['doctypes']['MODEL']."', ".$_SESSION['m_admin']['doctypes']['ACTION_BITMASK']." )"); if($_SESSION['history']['doctypesadd'] == "true") { $users->add($_SESSION['tablename']['doctypes'], $_SESSION['m_admin']['doctypes']['TYPE_ID'],"ADD", _DOCTYPE_ADDED." : ".$_SESSION['m_admin']['doctypes']['LABEL']); } } else { $this->query("INSERT INTO `".$_SESSION['tablename']['doctypes']."` ( `RES_TABLE` , `TYPE_ID` , `DESCRIPTION` , `DELAI_TRAITEMENT` , `DELAI_RELANCE1` , `DELAI_RELANCE2` , `ENABLED` , `CUSTOM_T2` , `CUSTOM_T3` ) VALUES ('".$_SESSION['m_admin']['doctypes']['TABLE']."','".$_SESSION['m_admin']['doctypes']['TYPE_ID']."', '".$_SESSION['m_admin']['doctypes']['LABEL']."','".$_SESSION['m_admin']['doctypes']['DELAI_TRAITEMENT']."', '".$_SESSION['m_admin']['doctypes']['DELAI_RELANCE1']."', '".$_SESSION['m_admin']['doctypes']['DELAI_RELANCE2']."','Y', '".$_SESSION['user']['UserId']."', '".date("Y")."-".date("m")."-".date("d")." ".date("H:i:s")."' , '".$_SESSION['m_admin']['doctypes']['GENERATE']."', '".$_SESSION['m_admin']['doctypes']['MODEL']."', ".$_SESSION['m_admin']['doctypes']['ACTION_BITMASK'].")"); if($_SESSION['history']['doctypesprop'] == "true") { $users->add($_SESSION['tablename']['doctypes'], $_SESSION['m_admin']['doctypes']['TYPE_ID'],"PROP", _DOCTYPE_ADDED." : ".$_SESSION['m_admin']['doctypes']['LABEL']); } } $_SESSION['error'] = ""; } if ($_POST['mode'] == "add") { $url = "index.php?page=types"; } else { $url = "types_prop_finish.php?id=".$_SESSION['m_admin']['doctypes']['TYPE_ID']."&label=".$_SESSION['m_admin']['doctypes']['LABEL']; } $this->cleartypeinfos(); header("location: ".$url); exit; } } } /** * Clear the session variable for the doctypes */ private function cleartypeinfos() { // clear the session variable for the doctypes $_SESSION['m_admin']['doctypes'] = array(); $_SESSION['m_admin']['doctypes']['TYPE_ID'] = ""; $_SESSION['m_admin']['doctypes']['LABEL'] = ""; $_SESSION['m_admin']['doctypes']['VALIDATE'] = ""; $_SESSION['m_admin']['doctypes']['USER_ID'] = ""; $_SESSION['m_admin']['doctypes']['DATE'] = ""; $_SESSION['m_admin']['doctypes']['JUSTIFICATION'] = ""; $_SESSION['m_admin']['doctypes']['TABLE'] = ""; $_SESSION['m_admin']['doctypes']['DELAI_TRAITEMENT'] = 21; $_SESSION['m_admin']['doctypes']['DELAI_RELANCE1'] = 14; $_SESSION['m_admin']['doctypes']['DELAI_RELANCE2'] = 1; $_SESSION['m_admin']['doctypes']['GENERATE'] = ""; $_SESSION['m_admin']['doctypes']['MODEL'] = ""; $_SESSION['m_admin']['doctypes']['ACTION_BITMASK'] = ""; } /** * Delete a doc type * * @param integer $id doctype indentifier */ public function deltypes($id) { // delete a doc type $this->connect(); $this->query("select DESCRIPTION from ".$_SESSION['tablename']['doctypes']." where TYPE_ID = '".$id."'"); if($this->nb_result() == 0) { $_SESSION['error'] = _DOCTYPE.' '._UNKNOWN; header("location: index.php?page=types"); exit; } else { $info = $this->fetch_object(); $this->query("delete from ".$_SESSION['tablename']['doctypes']." where TYPE_ID = '".$id."'"); require_once("class_history.php"); $users = new history(); $users->add($_SESSION['tablename']['doctypes'], $id,"DEL",_DOCTYPE_DELETION." : ".$info->DESCRIPTION); $_SESSION['error'] = _DELETED_DOCTYPE; header("location: index.php?page=types"); exit; } } /** * check right on a bitmask * * @param integer $int_to_check bitmask to check * @param boolean $right right to check */ function check_right($int_to_check, $right) { if($int_to_check & $right) { return true; } else { return false; } } /** * set right on a bitmask * * @param integer $int_to_set bitmask to set * @param boolean $right right to set */ function set_right($int_to_set = 0, $right) { return $int_to_set | $right; } } ?>