. */ /** * @brief Script called by an ajax object to process the document type change during indexing (index_mlb.php), process limit date calcul and possible services from apps or module * * @file change_doctype.php * @author Claire Figueras * @date $date$ * @version $Revision$ * @ingroup indexing_searching_mlb */ require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_security.php"); require_once('apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR."class_types.php"); $db = new dbquery(); $core = new core_tools(); $core->load_lang(); $type = new types(); if(!isset($_REQUEST['type_id']) || empty($_REQUEST['type_id'])) { $_SESSION['error'] = _DOCTYPE.' '._IS_EMPTY; echo "{status : 1, error_txt : '".addslashes($_SESSION['error'])."'}"; exit(); } if(!isset($_REQUEST['id_action']) || empty($_REQUEST['id_action'])) { $_SESSION['error'] = _ACTION_ID.' '._IS_EMPTY; echo "{status : 1, error_txt : '".addslashes($_SESSION['error'])."'}"; exit(); } $id_action = $_REQUEST['id_action']; if(isset($_REQUEST['res_id']) && !empty($_REQUEST['res_id']) && isset($_REQUEST['coll_id']) && !empty($_REQUEST['coll_id'])) { $res_id = $_REQUEST['res_id']; $coll_id = $_REQUEST['coll_id']; } // Process limit date calcul if ($core->service_is_enabled('param_mlb_doctypes')) //Bug fix if delay process is disabled in services { $db->connect(); $db->query("select process_delay from ".$_SESSION['tablename']['mlb_doctype_ext']." where type_id = ".$_REQUEST['type_id']); //$db->show(); if($db->nb_result() == 0) { $_SESSION['error'] = _NO_DOCTYPE_IN_DB; echo "{status : 2, error_txt : '".addslashes($_SESSION['error'])."'}"; exit(); } $res = $db->fetch_object(); $delay = $res->process_delay; } $mandatory_indexes = $type->get_mandatory_indexes($_REQUEST['type_id'], 'letterbox_coll'); $indexes = $type->get_indexes($_REQUEST['type_id'], 'letterbox_coll'); $opt_indexes = ''; if (preg_match("/MSIE 6.0/", $_SERVER["HTTP_USER_AGENT"])) { $browser_ie = true; $display_value = 'block'; } elseif(preg_match('/msie/i', $_SERVER["HTTP_USER_AGENT"]) && !preg_match('/opera/i', $HTTP_USER_AGENT) ) { $browser_ie = true; $display_value = 'block'; } else { $browser_ie = false; $display_value = 'table-row'; } $opt_indexes = ''; if(count($indexes) > 0) { if(isset($res_id) && isset($coll_id)) { $sec = new security(); $table = $sec->retrieve_table_from_coll($coll_id); if(!empty($table)) { $fields = 'res_id '; foreach(array_keys($indexes) as $key) { $fields .= ', '.$key; } $db->query("select ".$fields." from ".$table." where res_id = ".$res_id); $values_fields = $db->fetch_object(); } } $opt_indexes .= ''; foreach(array_keys($indexes) as $key) { //echo $key.' '; $mandatory = false; if(in_array($key, $mandatory_indexes)) { $mandatory = true; } $opt_indexes .= ''; $opt_indexes.=''; $opt_indexes .=''; $opt_indexes .=''; //$opt_indexes .=''; } else { $opt_indexes .=''; $opt_indexes .= '* '; } //$opt_indexes .= ';">* '; $opt_indexes .= ''; } $opt_indexes .= '
 '; if($indexes[$key]['type_field'] == 'input') { if($indexes[$key]['type'] == 'date') { $opt_indexes .=''; } else { $opt_indexes .= ''; } } else { $opt_indexes .= ''; } $opt_indexes .=''; if($mandatory) { $opt_indexes .=''; //$opt_indexes .= 'inline'; $opt_indexes .= '*  
'; } if(!$core->is_module_loaded('alert_diffusion')) { $_SESSION['error'] = _MODULE.' alert_diffusion '._IS_MISSING; echo "{status : 3, error_txt : '".addslashes($_SESSION['error'])."'}"; exit(); } $services = '['; $_SESSION['indexing_services'] = array(); $_SESSION['indexing_type_id'] = $_REQUEST['type_id']; // Module and apps services $core->execute_modules_services($_SESSION['modules_services'], 'change_doctype.php', 'include'); $core->execute_app_services($_SESSION['app_services'], 'change_doctype.php', 'include'); for($i=0;$i< count($_SESSION['indexing_services']);$i++) { $services .= "{ script : '".$_SESSION['indexing_services'][$i]['script']."', function_to_execute : '".$_SESSION['indexing_services'][$i]['function_to_execute']."', arguments : '["; for($j=0;$j 0) { require_once('modules'.DIRECTORY_SEPARATOR.'alert_diffusion'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_alert_engine.php'); $alert_engine = new alert_engine(); $date = $alert_engine->date_max_treatment($delay, false); $process_date = $db->dateformat($date, '-'); echo "{status : 0, process_date : '".trim($process_date)."', opt_indexes : '".addslashes($opt_indexes)."', services : ".$services."}"; exit(); } else { echo "{status : 1, opt_indexes : '".addslashes($opt_indexes)."', services : ".$services."}"; exit(); } ?>