*/ require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php"); require_once("modules".DIRECTORY_SEPARATOR."postindexing".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_modules_tools.php"); $core_tools = new core_tools(); $core_tools->load_lang(); $request= new request; $func = new functions(); $postindexing = new postindexing(); $db = new dbquery(); if(!empty($_SESSION['current_basket']['view'])) { $table = $_SESSION['current_basket']['view']; } else { $table = $_SESSION['current_basket']['table']; } //*************** CONTROL OF INDEXATION ***************// $_SESSION['postindexing']['field'] = array(); $_SESSION['data'] = array(); $_SESSION['postindexing']['data'] = array(); //Only in not finish if(!isset($_REQUEST['finish'])) { $indexes = $postindexing->get_postindexing_indexes(); //$db->show_array($indexes); $db->show_array($_REQUEST); exit; foreach(array_keys($indexes) as $key) { $field = $indexes[$key]['column']; if(!empty($_REQUEST[$field])) { // Checks type indexes if($indexes[$key]['type'] == 'date') { $date_pattern = "/^[0-3][0-9]-[0-1][0-9]-[1-2][0-9][0-9][0-9]$/"; if(preg_match( $date_pattern, $_REQUEST[$field]) == 0) { $_SESSION['error'] .= $indexes[$key]['label']."
"._WRONG_FORMAT.".
"; } } else if($indexes[$key]['type'] == 'string') { $_REQUEST[$field] = $func->wash($_REQUEST[$field], "no", $indexes[$key]['label']); } else if($indexes[$key]['type'] == 'float') { $_REQUEST[$field] = $func->wash($_REQUEST[$field], "float", $indexes[$key]['label']); //Replace comma by point to avoid insert/update error in database $_REQUEST[$field] = str_replace(',', '.', $_REQUEST[$field]); } else if($indexes[$key]['type'] == 'integer') { $_REQUEST[$field] = $func->wash($_REQUEST[$field], "num", $indexes[$key]['label']); } //Check if values in list exist if(isset($indexes[$key]['values']) && count($indexes[$key]['values']) > 0) { $found = false; for($i=0; $i < count($indexes[$key]['values']); $i++) { if($_REQUEST[$field] == $indexes[$key]['values'][$i]['id']) { $found = true; break; } } if(!$found) { $_SESSION['error'] .= $indexes[$key]['label'].": "._ITEM_NOT_IN_LIST.".
"; } } $_SESSION['postindexing']['field'][$field] = $_REQUEST[$field]; array_push($_SESSION['data'], array('column' => $field, 'value' => $func->protect_string_db($_REQUEST[$field]), 'type' => $indexes[$key]['type'])); } else // Checks the manadatory indexes { if($indexes[$key]['mandatory'] == 'true') { $_SESSION['error'] .= $indexes[$key]['label']." "._MANDATORY.".
"; } } } //Lets treat! if(!empty($_SESSION['error']) && !isset($_REQUEST['reject'])) { header("location: ".$_SESSION['config']['businessappurl']."index.php?display=true&module=postindexing&page=index_video"); } else { //If i valid data if (isset($_REQUEST['valid'])) { //Faire un hash des informations récuprées ... $hash = $postindexing->encrypt_array($_SESSION['postindexing']['field']); //... si elles ont été modifiées. if($_REQUEST['hash'] <> $hash) { $lib_action = _VIDEO_UPDATED; array_push($_SESSION['data'], array('column' => 'status', 'value' => $func->protect_string_db($_SESSION['postindexing']['status_update']), 'type' => 'string')); } else { //Reinitialiser le tableau pour ne mettre à jour que le status $_SESSION['data'] = array(); $lib_action = _VIDEO_VALIDATED; array_push($_SESSION['data'], array('column' => 'status', 'value' => $func->protect_string_db($_SESSION['postindexing']['status_valid']), 'type' => 'string')); } } elseif(isset($_REQUEST['reject'])) //If reject { //Reinitialiser le tableau pour ne mettre à jour que le status $_SESSION['data'] = array(); //Vu qu'on ne gere pas les erreurs en cas de rejet $_SESSION['error'] = ''; $lib_action = _VIDEO_REJECTED; array_push($_SESSION['data'], array('column' => 'status', 'value' => $func->protect_string_db($_SESSION['postindexing']['status_reject']), 'type' => 'string')); } //Mettre à jour les status et les infos if (count($_SESSION['data']) > 0) { //Update doc $where = "res_id = ".$_SESSION['postindexing']['res_actif']; $request->update($_SESSION['current_basket']['table'], $_SESSION['data'], $where, $_SESSION['config']['databasetype']); //History if($_SESSION['history']['resup'] == "true") { require_once("core/class/class_history.php"); $hist = new history(); $hist->add($table, $_SESSION['postindexing']['res_actif'], "UP", _INDEX_UPDATED." (".strtolower(_NUM).$_SESSION['postindexing']['res_actif']."".$lib_action.")", $_SESSION['config']['databasetype'],'postindexing'); } } //Update work number $_SESSION['postindexing']['work'] = $_SESSION['postindexing']['work'] + 1; //Nexxxxttttt!!!!!! if(count($_SESSION['postindexing']['docs']) == ($_SESSION['postindexing']['resid_pointeur'] + 1))//Si on est a la fin du tableau de document { //On revient au début $_SESSION['postindexing']['resid_pointeur'] = 0; } elseif (count($_SESSION['postindexing']['docs']) == $_SESSION['postindexing']['work'])//Si on est arrivé a la fin des documents { //On revient au début $_SESSION['postindexing']['resid_pointeur'] = 0; //On reinitialise le nombre de documents validés $_SESSION['postindexing']['work'] = 0; //Un petit message $_SESSION['info'] = _VIDEO_RES_FINISH; } else //on est ensemble!! { //On repasse au document suivant $_SESSION['postindexing']['resid_pointeur'] = $_SESSION['postindexing']['resid_pointeur'] + 1; } //echo $_SESSION['postindexing']['res_actif']; //$func->show_array($_SESSION['data']); //$func->show_array($_SESSION['postindexing']['data']); header("location: ".$_SESSION['config']['businessappurl']."index.php?display=true&module=postindexing&page=index_video"); } } elseif(isset($_REQUEST['finish'])) { //Release all the doc of actual user $postindexing->release_user_docs($_SESSION['current_basket']['table'], $_SESSION['user']['UserId']); //Close an d go back to the doc list ?>