. */ /** * @brief Action : Document postindexing * * Open a modal box to displays the postindexing form. Used by the core (manage_action.php page). * * @file * @author Yves Christian Kpakpo * @date $date$ * @version $Revision$ * @ingroup apps */ /** * $confirm bool false */ $confirm = false; /** * $etapes array Contains only one etap : form */ $etapes = array('form'); /** * $frm_width Width of the modal (empty) */ $frm_width=''; /** * $frm_height Height of the modal (empty) */ $frm_height = ''; /** * $mode_form Mode of the modal : fullscreen */ $mode_form = 'fullscreen'; function reserve_docs() { 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"); $func = new functions(); $db = new dbquery(); $postindexing = new postindexing(); $request= new request; //DEBUG!!!!!! $debug = false; //Clean Up !! unset($_SESSION['postindexing']['resid_pointeur']); unset($_SESSION['postindexing']['work']); unset($_SESSION['postindexing']['res_actif']); //Get the table if(!empty($_SESSION['current_basket']['view'])) { $table = $_SESSION['current_basket']['view']; } else { $table = $_SESSION['current_basket']['table']; } //Initialize time values $timestamp = time(); $max_video_time = $timestamp + ($_SESSION['postindexing']['max_time'] * 60); //Release user's expired documents $postindexing->release_user_docs($_SESSION['current_basket']['table']); $select2[$table]= array(); //Toutes les "Where Clause" dans un tableau $where_tab2 = array(); $where_tab2[] = " ( (video_batch is null) or (video_batch is not null and video_user = '".$_SESSION['user']['UserId']."') or ( (video_batch is not null and video_user <> '".$_SESSION['user']['UserId']."' and video_time < ".$timestamp.") ) )"; $where_tab2[] = stripslashes($_SESSION['current_basket']['clause']); $where2 = implode(' and ', $where_tab2); //Les champs a recuperer array_push($select2[$table], "res_id", "status"); $orderstr2 = ' order by creation_date asc'; $tab2=$request->select($select2, $where2, $orderstr2, $_SESSION['config']['databasetype'], $_SESSION['config']['databasesearchlimit'], false, "", "", "", false); //$request->show(); //Keep the number of available doc to postindex $_SESSION['postindexing']['nb_docs'] = count($tab2); //If the user still got ressources to postindex $select[$table]= array(); array_push($select[$table],"res_id"); $where_already_reserved = " ( (video_batch is not null and video_user = '".$_SESSION['user']['UserId']."' and video_time > ".$timestamp.") ) and ".stripslashes($_SESSION['current_basket']['clause']); $groupby = ''; $tab1 = array(); $tab1 = $request->select($select, $where_already_reserved, $groupby, $_SESSION['config']['databasetype'], false, "", "", "", false); //$request->show(); //Debug if ($debug) { $debug_msg .= "Initialisation de la reservation
"; $debug_msg .= $select.' '.$where_already_reserved; $debug_msg .= "
NB DOCS IN BASKET: ". $_SESSION['postindexing']['nb_docs']."
";//DEBUG $debug_msg .= "NB DOCS ALREADY RESERVED: ".count($tab1)."
";//DEBUG $debug_msg .= "MAX DOCS TO RESERVE: ".$_SESSION['postindexing']['max_files']."
";//DEBUG } if ((count($tab1) < $_SESSION['postindexing']['max_files']) && (count($tab1) < $_SESSION['postindexing']['nb_docs']) ) { //Number of ressources to add to complète the max batch files $max_files = $_SESSION['postindexing']['max_files'] - count($tab1) ; //Debug if ($debug) { $debug_msg .= "
Complément de reservation
"; $debug_msg .= "NB DOCS TO COMPLETE RESERVATION: ".$max_files."
";//DEBUG } //new workbatch $workbatch = $postindexing->get_workbatch(); $_SESSION['postindexing']['workbatch'] = $workbatch; //Creation if the sql statement for reservation $where = " ( (video_batch is null) or (video_batch is not null and video_user = '".$_SESSION['user']['UserId']."' and video_time < ".$timestamp.") or ( (video_batch is not null and video_user <> '".$_SESSION['user']['UserId']."') and (video_batch is not null and video_time < ".$timestamp.") ) ) and ".stripslashes($_SESSION['current_basket']['clause']); //Subquery if($_SESSION['config']['databasetype'] == "SQLSERVER") { $sqlReservation = "SELECT TOP ".$max_files." res_id from ".$table." WHERE ".$where." ORDER BY res_id ASC"; } elseif($_SESSION['config']['databasetype'] == "MYSQL") { $sqlReservation = "SELECT res_id from ".$table." WHERE ".$where." ORDER BY res_id ASC LIMIT 0,".$max_files." "; } elseif($_SESSION['config']['databasetype'] == "POSTGRESQL") { $sqlReservation = "SELECT res_id from ".$table." WHERE ".$where." ORDER BY res_id ASC OFFSET 0 LIMIT ".$max_files; } elseif($_SESSION['config']['databasetype'] == "ORACLE") { $sqlReservation = "SELECT res_id from ".$table." WHERE ".$where." AND ROWNUM <= ".$max_files." ORDER BY res_id ASC"; } //Get down on it!! $db->connect(); $theSqlQuery = "update ".$_SESSION['current_basket']['table']." set video_user = '".$_SESSION['user']['UserId']."' , video_batch = ".$workbatch." , video_time = ".$max_video_time." where res_id in (".$sqlReservation .")"; $db->query($theSqlQuery); //Debug if ($debug) { $debug_msg .= "
Requete de reservation (mise a jour)
"; $debug_msg .= $theSqlQuery; } } //Documents à videocoder $_SESSION['postindexing']['docs'] = array(); $_SESSION['postindexing']['docs'] = $postindexing->get_user_reserved_doc($_SESSION['current_basket']['table']); //Nombre de documents à videocoder $_SESSION['postindexing']['nb_total'] = count($_SESSION['postindexing']['docs']); //On initialise le compteur de document validé $_SESSION['postindexing']['work'] = 0 ; //Reset of the Info box if (isset($_SESSION['postindexing']['showHideBox'])) { unset($_SESSION['postindexing']['showHideBox']); } //$func->show_array($tab_res); //Debug if ($debug) { $debug_msg .= "
NB RESERVED DOCS: ".$_SESSION['postindexing']['nb_total']."
";//DEBUG //exit; return $debug_msg; } } /** * Returns the validation form text * * @param $values Array Contains the res_id of the document to validate * @param $path_manage_action String Path to the PHP file called in Ajax * @param $id_action String Action identifier * @param $table String Table * @param $module String Origin of the action * @param $coll_id String Collection identifier * @param $mode String Action mode 'mass' or 'page' * @return String The form content text **/ function get_form_txt($values, $path_manage_action, $id_action, $table, $module, $coll_id, $mode ) { $frm_str =''; //If not already reserved // if ($_SESSION['postindexing']['already_reserved'] === false) // { $frm_str .= reserve_docs(); // } //Iframe with the page $frm_str = ''; $frm_str .= ''; return addslashes($frm_str); } ?>