* */ /** * Class AdminActions : Contains all the specific functions of action admin * * @author Claire Figueras * @license GPL * @package Maarch LetterBox 2.0 * @version 2.0 */ class AdminActions extends dbquery { /** * Redefinition of the LetterBox object constructor */ function __construct() { parent::__construct(); } /** * Return the action data in sessions vars * * @param string $mode add or up */ public function actioninfo($mode) { // return the user information in sessions vars $func = new functions(); if($_REQUEST['mode'] == "up") { $_SESSION['m_admin']['action']['ID'] = $func->wash($_REQUEST['id'], "no", _ID." "); } $_SESSION['m_admin']['action']['LABEL'] = $func->wash($_REQUEST['label'], "no", _DESC." ", 'yes', 0, 255); if(empty($_REQUEST['action_page'])) { $_SESSION['m_admin']['action']['ID_STATUS'] = $func->wash($_REQUEST['status'], "no", _STATUS." ", 'yes', 0, 10); } else { $_SESSION['m_admin']['action']['ID_STATUS'] = trim($_REQUEST['status']); } if(empty($_REQUEST['status'])) { $_SESSION['m_admin']['action']['ACTION_PAGE'] = $func->wash($_REQUEST['action_page'], "no", _ACTION_PAGE." ", 'yes', 0, 255); } else { $_SESSION['m_admin']['action']['ACTION_PAGE'] = trim($_REQUEST['action_page']); } $_SESSION['m_admin']['action']['KEYWORD'] = $_REQUEST['keyword']; $_SESSION['m_admin']['action']['FLAG_CREATE'] = 'N'; if($_SESSION['m_admin']['action']['ACTION_PAGE'] <> "") { for($i=0; $iwash($_REQUEST['history'], "no", _HISTORY." "); $_SESSION['m_admin']['action']['order'] = $_REQUEST['order']; $_SESSION['m_admin']['action']['order_field'] = $_REQUEST['order_field']; $_SESSION['m_admin']['action']['what'] = $_REQUEST['what']; $_SESSION['m_admin']['action']['start'] = $_REQUEST['start']; } /** * Add ou modify action in the database * * @param string $mode up or add */ public function addupaction($mode) { // add ou modify users in the database $this->actioninfo($mode); $order = $_SESSION['m_admin']['action']['order']; $order_field = $_SESSION['m_admin']['action']['order_field']; $what = $_SESSION['m_admin']['action']['what']; $start = $_SESSION['m_admin']['action']['start']; if(!empty($_SESSION['error'])) { if($mode == "up") { if(!empty($_SESSION['m_admin']['action']['ID'])) { header("location: ".$_SESSION['config']['businessappurl']."index.php?page=action_up&id=".$_SESSION['m_admin']['action']['ID']."&admin=action"); exit; } else { header("location: ".$_SESSION['config']['businessappurl']."index.php?page=action&admin=action&order=".$order."&order_field=".$order_field."&start=".$start."&what=".$what); exit; } } if($mode == "add") { header("location: ".$_SESSION['config']['businessappurl']."index.php?page=action_add&admin=action"); exit; } } else { $this->connect(); if($mode == "add") { $this->query("INSERT INTO ".$_SESSION['tablename']['actions']." ( label_action, id_status, action_page, history, keyword, create_id) VALUES ( '".$this->protect_string_db($_SESSION['m_admin']['action']['LABEL'])."', '".$this->protect_string_db($_SESSION['m_admin']['action']['ID_STATUS'])."', '".$this->protect_string_db($_SESSION['m_admin']['action']['ACTION_PAGE'])."', '".$this->protect_string_db($_SESSION['m_admin']['action']['HISTORY'])."', '".$this->protect_string_db($_SESSION['m_admin']['action']['KEYWORD'])."', '".$this->protect_string_db($_SESSION['m_admin']['action']['FLAG_CREATE'])."' )"); if($_SESSION['history']['actionadd']) { $this->query("select id from ".$_SESSION['tablename']['actions']." where label_action = '".$this->protect_string_db($_SESSION['m_admin']['action']['LABEL'])."' and id_status = '".$this->protect_string_db($_SESSION['m_admin']['action']['ID_STATUS'])."' and action_page = '".$this->protect_string_db($_SESSION['m_admin']['action']['ACTION_PAGE'])."' and history = '".$this->protect_string_db($_SESSION['m_admin']['action']['HISTORY'])."' and keyword = '".$this->protect_string_db($_SESSION['m_admin']['action']['KEYWORD'])."' and create_id = '".$this->protect_string_db($_SESSION['m_admin']['action']['FLAG_CREATE'])."'"); $res = $this->fetch_object(); $id = $res->id; require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'); $hist = new history(); $hist->add($_SESSION['tablename']['actions'], $id,"ADD",'actionadd',_ACTION_ADDED.' : '.$this->protect_string_db($_SESSION['m_admin']['action']['LABEL']), $_SESSION['config']['databasetype']); } $_SESSION['error'] = _ACTION_ADDED.' : '.$_SESSION['m_admin']['action']['LABEL']; $this->clearactioninfos(); header("location: ".$_SESSION['config']['businessappurl']."index.php?page=action&admin=action&order=".$order."&order_field=".$order_field."&start=".$start."&what=".$what); exit(); } elseif($mode == "up") { $this->query("update ".$_SESSION['tablename']['actions']." set label_action = '".$this->protect_string_db($_SESSION['m_admin']['action']['LABEL'])."', id_status = '".$this->protect_string_db($_SESSION['m_admin']['action']['ID_STATUS'])."', action_page = '".$this->protect_string_db($_SESSION['m_admin']['action']['ACTION_PAGE'])."', history = '".$this->protect_string_db($_SESSION['m_admin']['action']['HISTORY'])."', keyword = '".$this->protect_string_db($_SESSION['m_admin']['action']['KEYWORD'])."', create_id = '".$this->protect_string_db($_SESSION['m_admin']['action']['FLAG_CREATE'])."' where id = ".$_SESSION['m_admin']['action']['ID'].""); if($_SESSION['history']['actionup']) { require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'); $hist = new history(); $hist->add($_SESSION['tablename']['actions'], $_SESSION['m_admin']['action']['ID'],"UP",'actionup',_ACTION_MODIFIED.' : '.$this->protect_string_db($_SESSION['m_admin']['action']['LABEL']), $_SESSION['config']['databasetype']); } $_SESSION['error'] = _ACTION_MODIFIED.' : '.$_SESSION['m_admin']['action']['LABEL']; $this->clearactioninfos(); header("location: ".$_SESSION['config']['businessappurl']."index.php?page=action&admin=action&order=".$order."&order_field=".$order_field."&start=".$start."&what=".$what); exit(); } } } /** * Form to modify a action * * @param $string $mode up or add * @param int $id $id of the action to change */ public function formaction($mode,$id = "") { $func = new functions(); $state = true; if(!isset($_SESSION['m_admin']['action'])) { $this->clearactioninfos(); } if( $mode <> "add") { $this->connect(); $this->query("select * from ".$_SESSION['tablename']['actions']." where id = '".$id."'"); if($this->nb_result() == 0) { $_SESSION['error'] = _THE_ACTION.' '._ALREADY_EXISTS; $state = false; } else { $_SESSION['m_admin']['action'] = array(); $line = $this->fetch_object(); $_SESSION['m_admin']['action']['ID'] = $line->id; $_SESSION['m_admin']['action']['LABEL'] = $this->show_string($line->label_action); $_SESSION['m_admin']['action']['ID_STATUS'] = $this->show_string($line->id_status); $_SESSION['m_admin']['action']['IS_SYSTEM'] = $this->show_string($line->is_system); $_SESSION['m_admin']['action']['ACTION_PAGE'] = $this->show_string($line->action_page); $_SESSION['m_admin']['action']['HISTORY'] = $this->show_string($line->history); $_SESSION['m_admin']['action']['KEYWORD'] = $line->keyword; } } else if($mode == 'add') { $_SESSION['m_admin']['action']['IS_SYSTEM'] = 'N'; $_SESSION['m_admin']['action']['HISTORY'] = 'Y'; } $this->connect(); $this->query("select * from ".$_SESSION['tablename']['status']." order by label_status"); $arr_status = array(); if($this->nb_result() > 0) { while($res = $this->fetch_object()) { array_push($arr_status, array('id' => $res->id, 'label' => $res->label_status, 'is_system' => $res->is_system, 'img_filename' => $res->img_filename, 'module' => $res->maarch_module, 'can_be_searched' => $res->can_be_searched, 'can_be_modified' => $res->can_be_modified)); } } ?>




"._THE_ACTION." "._UNKOWN."



"; } else { ?>
" class="forms addforms">

'._DO_NOT_MODIFY_UNLESS_EXPERT.'

'; } ?>

/> />

connect(); $this->query("select id from ".$_SESSION['tablename']['actions']." where id = '".$id."'"); if($this->nb_result() == 0) { $_SESSION['error'] = _THE_ACTION.' '._UNKNOWN; header("location: ".$_SESSION['config']['businessappurl']."index.php?page=action&admin=action&order=".$order."&order_field=".$order_field."&start=".$start."&what=".$what); exit; } else { $res = $this->fetch_object(); $label = $res->LABEL; $this->query("delete from ".$_SESSION['tablename']['actions']." where id = '".$id."'"); if($_SESSION['history']['actiondel']) { require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_history.php'); $hist = new history(); $hist->add($_SESSION['tablename']['actions'], $id,"DEL",'actiondel',_ACTION_DELETED.' : '.$id, $_SESSION['config']['databasetype']); } $_SESSION['error'] = _ACTION_DELETED; header("location: ".$_SESSION['config']['businessappurl']."index.php?page=action&admin=action&order=".$order."&order_field=".$order_field."&start=".$start."&what=".$what); exit; } } } } ?>