* */ class indexing_searching_app extends dbquery { function __construct() { parent::__construct(); } public function is_filetype_allowed($ext) { if(file_exists($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."extensions.xml")) { $path = $_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."extensions.xml"; } else { $path = 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."extensions.xml"; } $xmlconfig = simplexml_load_file($path); $ext_list = array(); $i = 0; foreach($xmlconfig->FORMAT as $FORMAT) { $ext_list[$i] = array("name" => (string) $FORMAT->name, "mime" => (string) $FORMAT->mime); $i++; } $type_state = false; for($i=0;$iFORMAT as $FORMAT) { if(strtoupper($ext) == (string) $FORMAT->name) { if( $FORMAT->index_frame_show == "true") { return true; } else { return false; } } } return false; } public function filetypes_showed_indexation() { if(file_exists($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."extensions.xml")) { $path = $_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."extensions.xml"; } else { $path = 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."extensions.xml"; } $xmlconfig = simplexml_load_file($path); $ext_list = array(); foreach($xmlconfig->FORMAT as $FORMAT) { if((string) $FORMAT->index_frame_show == "true") { array_push($ext_list,(string) $FORMAT->name); } } return $ext_list; } public function get_mime_type($ext) { if(file_exists($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."extensions.xml")) { $path = $_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."extensions.xml"; } else { $path = 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."extensions.xml"; } $xmlconfig = simplexml_load_file($path); $ext_list = array(); $i = 0; foreach($xmlconfig->FORMAT as $FORMAT) { $ext_list[$i] = array("name" => (string) $FORMAT->name, "mime" => (string) $FORMAT->mime); $i++; } for($i=0;$iretrieve_table_from_coll($coll_id); $view = $sec->retrieve_view_from_coll_id($coll_id); $ind_coll = $sec->get_ind_collection($coll_id); $table_ext = $_SESSION['collections'][$ind_coll]['extensions'][0]; if(!$table) { $_SESSION['error'] .= _COLL_HAS_NO_TABLE; } if(!empty($_SESSION['error'])) { //$_SESSION['error_page'] = $_SESSION['error']; $error = $_SESSION['error']; $_SESSION['error']= ''; ?> connect(); $request->query("select category_id from ".$view." where ".$where); $res = $request->fetch_object(); $cat_id = $res->category_id; if(empty($cat_id) || !isset($cat_id)) { $cat_id = 'empty'; } // Simple cases foreach(array_keys($post) as $key) { if($_ENV['categories'][$cat_id][$key]['modify'] == true) { if($_ENV['categories'][$cat_id][$key]['mandatory'] == true && $post[$key] == '' ) { $_SESSION['error'] .= $_ENV['categories'][$cat_id][$key]['label'].' '._IS_EMPTY.'
'; } if($_ENV['categories'][$cat_id][$key]['type_form'] == 'date' && !empty($post[$key]) && preg_match($_ENV['date_pattern'],$post[$key])== 0) { $_SESSION['error'] .= $_ENV['categories'][$cat_id][$key]['label']." "._WRONG_FORMAT."
"; } else if($_ENV['categories'][$cat_id][$key]['type_field'] == 'date' && $_ENV['categories'][$cat_id][$key]['table'] <> 'none' && !empty($post[$key])) { if($_ENV['categories'][$cat_id][$key]['table'] == 'res') { array_push($data_res, array('column' => $key, 'value' => $func->format_date_db($post[$key]), 'type' => "date")); } else if($_ENV['categories'][$cat_id][$key]['table'] == 'coll_ext') { array_push($data_ext, array('column' => $key, 'value' => $func->format_date_db($post[$key]), 'type' => "date")); } } if($_ENV['categories'][$cat_id][$key]['type_form'] == 'integer' && preg_match("/^[0-9]+$/",$post[$key])== 0) { $_SESSION['error'] .= $_ENV['categories'][$cat_id][$key]['label']." "._WRONG_FORMAT."
"; } else if($_ENV['categories'][$cat_id][$key]['type_field'] == 'integer' && $_ENV['categories'][$cat_id][$key]['table'] <> 'none' && $post[$key] != '') { if($_ENV['categories'][$cat_id][$key]['table'] == 'res') { array_push($data_res, array('column' => $key, 'value' => $post[$key], 'type' => "integer")); } else if($_ENV['categories'][$cat_id][$key]['table'] == 'coll_ext') { array_push($data_ext, array('column' => $key, 'value' => $post[$key], 'type' => "integer")); } } if($_ENV['categories'][$cat_id][$key]['type_form'] == 'radio' && !empty($post[$key]) && !in_array($post[$key], $_ENV['categories'][$cat_id][$key]['values'])) { $_SESSION['error'] .= $_ENV['categories'][$cat_id][$key]['label']." "._WRONG_FORMAT."
"; } if($_ENV['categories'][$cat_id][$key]['type_field'] == 'string' && $_ENV['categories'][$cat_id][$key]['table'] <> 'none' && !empty($post[$key])) { if($_ENV['categories'][$cat_id][$key]['table'] == 'res') { array_push($data_res, array('column' => $key, 'value' => $func->protect_string_db($post[$key]), 'type' => "string")); } else if($_ENV['categories'][$cat_id][$key]['table'] == 'coll_ext') { array_push($data_ext, array('column' => $key, 'value' => $func->protect_string_db($post[$key]), 'type' => "string")); } } } } require_once('apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_types.php'); $type = new types(); $type_id = $post['type_id']; $indexes = $type->get_indexes($type_id,$coll_id, 'minimal'); $val_indexes = array(); for($i=0; $icheck_indexes($type_id, $coll_id,$val_indexes ); if($test_type) { $data_res = $type->fill_data_array($type_id, $coll_id, $val_indexes, $data_res); } ///////////////////////// Other cases if($core->is_module_loaded('folder')) { $request->connect(); $request->query("select folders_system_id from ".$table." where res_id = ".$id_to_update); $res = $request->fetch_object(); $old_folder_id = $res->folders_system_id; $market = ''; if(isset($post['market'])) { $market = $post['market']; } $project_id = ''; $market_id = ''; if(isset($_ENV['categories'][$cat_id]['other_cases']['market']) && $_ENV['categories'][$cat_id]['other_cases']['market']['mandatory'] == true ) { if(empty($market) ) { $_SESSION['error'] .= $_ENV['categories'][$cat_id]['other_cases']['market']['label'].' '._IS_EMPTY.'
'; } } if(!empty($market) ) { if(!preg_match('/\([0-9]+\)$/', $market)) { $_SESSION['error'] .= $_ENV['categories'][$cat_id]['other_cases']['market']['label']." "._WRONG_FORMAT."
"; } $market_id = str_replace(')', '', substr($market, strrpos($market,'(')+1)); $request->query("select folders_system_id from ".$_SESSION['tablename']['fold_folders']." where folders_system_id = ".$market_id); if($request->nb_result() == 0) { $_SESSION['error'] .= _MARKET.' '.$market_id.' '._UNKNOWN.'
'; } } $project = ''; if(isset($post['project'])) { $project = $post['project']; } if(isset($_ENV['categories'][$cat_id]['other_cases']['project']) && $_ENV['categories'][$cat_id]['other_cases']['project']['mandatory'] == true) { if(empty($project)) { $_SESSION['error'] .= $_ENV['categories'][$cat_id]['other_cases']['project']['label'].' '._IS_EMPTY.'
'; } } if(!empty($project) ) { if(!preg_match('/\([0-9]+\)$/', $project)) { $_SESSION['error'] .= $_ENV['categories'][$cat_id]['other_cases']['project']['label']." "._WRONG_FORMAT."
"; } $project_id = str_replace(')', '', substr($project, strrpos($project,'(')+1)); $request->query("select folders_system_id from ".$_SESSION['tablename']['fold_folders']." where folders_system_id = ".$project_id); if($request->nb_result() == 0) { $_SESSION['error'] .= _MARKET.' '.$project_id.' '._UNKNOWN.'
'; } } if(!empty($project_id) && !empty($market_id)) { $request->query("select folders_system_id from ".$_SESSION['tablename']['fold_folders']." where folders_system_id = ".$market_id." and parent_id = ".$project_id); if($request->nb_result() == 0) { $_SESSION['error'] .= _INCOMPATIBILITY_MARKET_PROJECT.'
'; } } if(empty($_SESSION['error'])) { $folder_id = ''; if(!empty($market_id)) { $folder_id = $market_id; } else if(!empty($project_id)) { $folder_id = $project_id; } if(!empty($folder_id)) { array_push($data_res, array('column' => 'folders_system_id', 'value' => $folder_id, 'type' => "integer")); } else { array_push($data_res, array('column' => 'folders_system_id', 'value' => 'NULL', 'type' => "integer")); } if($folder_id <> $old_folder_id && $_SESSION['history']['folderup']) { require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php"); $hist = new history(); $hist->add($_SESSION['tablename']['fold_folders'], $folder_id, "UP", _DOC_NUM.$id_to_update._ADDED_TO_FOLDER, $_SESSION['config']['databasetype'],'apps'); if(isset($old_folder_id) && !empty($old_folder_id)) { $hist->add($_SESSION['tablename']['fold_folders'], $old_folder_id, "UP", _DOC_NUM.$id_to_update._DELETED_FROM_FOLDER, $_SESSION['config']['databasetype'],'apps'); } } } } if($core->is_module_loaded('physical_archive')) { // Arbox id $box_id = ''; if(isset($post['arbox_id'])) { $box_id = $post['arbox_id']; } if(isset($_ENV['categories'][$cat_id]['other_cases']['arbox_id']) && $_ENV['categories'][$cat_id]['other_cases']['arbox_id']['mandatory'] == true) { if($box_id == false) { $_SESSION['error'] .= _NO_BOX_SELECTED.'
'; } } if($box_id != false && preg_match('/^[0-9]+$/', $box_id)) { require_once('modules'.DIRECTORY_SEPARATOR.'physical_archive'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_modules_tools.php'); $physical_archive = new physical_archive(); $pa_return_value = $physical_archive->load_box_db($box_id, $cat_id, $_SESSION['user']['UserId']); if ($pa_return_value == false) { $_SESSION['error'] .= _ERROR_TO_INDEX_NEW_BATCH_WITH_PHYSICAL_ARCHIVE.'
'; } else { array_push($data_res, array('column' => 'arbox_id', 'value' => $box_id, 'type' => "integer")); array_push($data_res, array('column' => 'arbatch_id', 'value' => $pa_return_value, 'type' => "integer")); } } } //$this->show_array($post); if(empty($_SESSION['error'])) { $type->inits_opt_indexes($coll_id, $id_to_update); //$request->show_array($data_res); //exit(); $request->update($table, $data_res, $where, $_SESSION['config']['databasetype']); if(count($data_ext) > 0) { $request->update($table_ext, $data_ext, $where, $_SESSION['config']['databasetype']); } $_SESSION['error'] = _INDEX_UPDATED." (".strtolower(_NUM).$id_to_update.")"; $hist->add($table, $id_to_update, "UP", $_SESSION['error'], $_SESSION['config']['databasetype'],'apps'); } //$_SESSION['error_page'] = $_SESSION['error']; $error = $_SESSION['error']; $_SESSION['error']= ''; ?> retrieve_table_from_coll($coll_id); if(!$table) { $_SESSION['error'] .= _COLL_HAS_NO_TABLE; } if(!empty($_SESSION['error'])) { //$_SESSION['error_page'] = $_SESSION['error']; ?> 'status', 'value' => 'DEL', 'type' => 'string')); $where = "res_id = ".$id_to_delete; $request->update($table, $data, $where, $_SESSION['config']['databasetype']); $_SESSION['error'] = _DOC_DELETED." ("._NUM." : ".$id_to_delete.")"; if($_SESSION['history']['res_del']) { require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php"); $hist = new history(); $hist->add($table, $id_to_delete, "DEL", $_SESSION['error'], $_SESSION['config']['databasetype'],'indexing_searching'); } } } public function update_doc_status($idDoc, $coll_id, $status) { require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_security.php"); $sec = new security(); $table = $sec->retrieve_table_from_coll($coll_id); if(!$table) { $_SESSION['error'] .= _COLL_HAS_NO_TABLE; } if(!empty($_SESSION['error'])) { ?> 'status', 'value' => $status, 'type' => 'string')); $where = "res_id = ".$idDoc; $request->update($table, $data, $where, $_SESSION['config']['databasetype']); $_SESSION['error'] = _UPDATE_DOC_STATUS." ("._NUM." : ".$idDoc.") "._TO." ".$status; require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_history.php"); $hist = new history(); $hist->add($table, $idDoc, $status, $_SESSION['error'], $_SESSION['config']['databasetype'],'indexing_searching'); } } public function send_criteria_data($param) { /*list_criteres = Array ("num_courrier" => Array (label => "reference courrier', parametres => Array ( ...), type => "text", ), "date courrier" => array*/ //$this->show_array($param); $options_criteria_list = ''; $json_tab = ''; foreach($param as $key => $value) { $json_tab .= "'".$key."' : {"; //echo 'key '.$key."
val "; //$this->show_array($value); $options_criteria_list .= ''; $json_tab .= $this->json_line($key,$value['type'],$value['param']); $json_tab .= '} ,'; } $json_tab = preg_replace("/,$/", '', $json_tab); $tab = array($options_criteria_list, $json_tab ); return $tab; } private function json_line($id, $field_type, $param) { $str = ''; $init = "'label' : '".addslashes($param['field_label'])."', 'value' :'"; $end = "'"; //$hidden = ''; if($field_type == 'input_text') { $str = $init.''.$end; } /*elseif($field_type == 'contact') { $str = ''; $str .=''; $str .=''; $str .= '
'._INTERNAL.''._EXTERNAL.'
'; $str = addslashes($str); $str = $init.$str.''.$end; }*/ else if($field_type == 'textarea') { $str = $init.''.$end; } elseif($field_type == 'date_range') { $str = $init.addslashes(_SINCE).' : ' .addslashes(_FOR).' : '; $str .= ''.$end; } elseif($field_type == 'num_range') { $str = $init.addslashes(_NUM_BETWEEN).' : ' .addslashes(_AND).' : '; $str .= ''.$end; } elseif($field_type == 'select_simple') { $str = $init.''; $str .= ''.$end; } elseif($field_type == 'select_multiple') { $str .= ''.$param['label_title'].' :'; $str .= ''; $str .= ''; $str .= ''; $str .= "
"._SELECT_ALL.''; $str .= ''; $str .= ''; $str .= '
'; $str .= '
'; $str .= ''; $str .= ''; $str .= ''; $str .= "
"._SELECT_ALL.''; $str .= ''; $str .= ''; $str = addslashes($str); $str = $init.''.$str.'
'.$end; } elseif($field_type == 'checkbox') { $str = $init.''; $tmp_ids = ''; for($i=0; $i < count($param['checkbox_data']);$i=$i+2) { $tmp_ids .= $param['checkbox_data'][$i]['ID'].','; $str .= ''; if(isset($param['checkbox_data'][$i+1]['ID'])) { $tmp_ids .= $param['checkbox_data'][$i+1]['ID'].','; $str .= ''; $str .= ''; } else { $str .= ''; } $str .= ''; } $tmp_ids = preg_replace('/,$/', '', $tmp_ids ); $str .= '
'.addslashes($param['checkbox_data'][$i]['LABEL']).''.addslashes($param['checkbox_data'][$i+1]['LABEL']).''.addslashes($param['checkbox_data'][$i]['LABEL']).'
'; $str .= ''.$end; } elseif($field_type == 'address') { $str = $init.''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; if(isset($param['address_data']['DISTRICTS'])) { $str .= ''; $str .= ''; $str .= ''; } $str .= '
'.$param['address_data']['NUM']['LABEL'].''.$param['address_data']['ROAD']['LABEL'].'
'.$param['address_data']['CP']['LABEL'].''.$param['address_data']['CITY']['LABEL'].'
'.$param['address_data']['DISTRICTS']['LABEL'].''; $str .= ''; $str .= '
'.$end; } elseif($field_type == 'simple_list_or_input_text') { // td open in the showing function (js) $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; // td close in the showing function (js) $str = addslashes($str); $str = $init.$str.$end; } elseif($field_type == 'inputs_in_2_col') { $str = $init.''; $tmp = ""; for($i=0; $i'; if ($i%2 == 1 && $i!=0) // impair { echo '' ; } else { if($i+1 == count($param['input_ids'])) { echo ''; } } } $tmp = preg_replace('/,$/', '', $tmp); $str .= '
 
'; $str .= ''.$end; } elseif($field_type == 'select_or_other_data') { // td open in the showing function (js) $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= ''; $str .= '
'; $str .= ''; $str .= '
'; $str .= ''; $str .= ''; $str .= '
'; // td close in the showing function (js) $str = addslashes($str); $str = $init.$str.$end; } else { } return $str; } public function get_process_data($coll_id, $res_id) { require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_security.php"); $sec =new security(); $view = $sec->retrieve_view_from_coll_id($coll_id); if(empty($view)) { $view = $sec->retrieve_table_from_coll($coll_id); } $db = new dbquery(); $db->connect(); $db->query("select answer_type_bitmask, process_notes, other_answer_desc from ".$view." where res_id = ".$res_id); $res = $db->fetch_object(); $bitmask = $res->answer_type_bitmask; $process_notes = $db->show_string($res->process_notes); $other_answer_desc = $db->show_string($res->other_answer_desc); $contact = false; $mail = false; $AR = false; $fax = false; $email = false; $other = false; $no_answer = false; if($bitmask == '000000' || $bitmask == '') { $no_answer = true; } else { /** * Answer type bitmask * 0 0 0 0 0 0 * | | | | | |_ Simple Mail * | | | | |___ Registered mail * | | | |_____ Direct Contact * | | |_______ Email * | |_________ Fax * |___________ Other Answer **/ if($bitmask[0] == '1') { $other = true; } if($bitmask[1] == '1') { $fax = true; } if($bitmask[2] == '1') { $email = true; } if($bitmask[3] == '1') { $contact = true; } if($bitmask[4] == '1') { $AR = true; } if($bitmask[5] == '1') { $mail = true; } } return array('process_notes' => $process_notes, 'direct_contact' => $contact, 'simple_mail' => $mail, 'registered_mail' => $AR, 'fax' => $fax, 'email' => $email, 'no_answer' => $no_answer, 'other' => $other, 'other_answer_desc' => $other_answer_desc); } } ?>