* */ class postindexing extends dbquery { /** * Build Maarch module tables into sessions vars with a xml configuration file */ public function build_modules_tables() { if(file_exists($_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR."modules".DIRECTORY_SEPARATOR."postindexing".DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."config.xml")) { $path = $_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'].DIRECTORY_SEPARATOR."modules".DIRECTORY_SEPARATOR."postindexing".DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."config.xml"; } else { $path = "modules".DIRECTORY_SEPARATOR."postindexing".DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."config.xml"; } $path_lang = 'apps'.DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.$_SESSION['config']['lang'].'.php'; $xmlconfig = simplexml_load_file($path); $PARAMETERS = $xmlconfig->PARAMETERS; unset($_SESSION['postindexing']); $_SESSION['postindexing'] = array(); $_SESSION['postindexing']['max_time'] = (string) $PARAMETERS->max_time; $_SESSION['postindexing']['max_files'] = (string) $PARAMETERS->max_files; $_SESSION['postindexing']['buffer'] = (string) $PARAMETERS->buffer; $_SESSION['postindexing']['status_valid'] = (string) $PARAMETERS->status_valid; $_SESSION['postindexing']['status_reject'] = (string) $PARAMETERS->status_reject; $_SESSION['postindexing']['status_update'] = (string) $PARAMETERS->status_update; $_SESSION['postindexing']['folder_status_update'] = (string) $PARAMETERS->folder_status_update; $_SESSION['postindexing']['category'] = array(); $CATEGORY = $xmlconfig->CATEGORY; $label = (string) $CATEGORY->label; if (!empty($label) && defined($label) && constant($label) <> NULL) { $label = constant($label); } $_SESSION['postindexing']['category'][(string)$CATEGORY ->id] = $label; $TABLENAME = $xmlconfig->TABLENAME; $_SESSION['tablename']['view_admin_postindexing'] = (string) $TABLENAME->view_admin_postindexing; $_SESSION['tablename']['postindexing_collection'] = (string) $TABLENAME->postindexing_collection; } //load the index available by collection public function load_module_var_session() { } public function encrypt_array($str_array) { $hash = ''; if (count($str_array) > 0) { $tmp = ''; foreach ($str_array as $value) { $tmp .= trim($value); } $hash = md5($tmp); } return $hash; } public function get_workbatch () { $this->connect(); // $workbatch = 0; $this->query("select param_value_int from ".$_SESSION['tablename']['param']." where id = 'postindexing_workbatch'"); $line = $this->fetch_object(); $workbatch = (string)$line->param_value_int; $inc_workbatch = $workbatch +1; $this->query("update ".$_SESSION['tablename']['param']." set param_value_int = '".$inc_workbatch."' where id = 'postindexing_workbatch'"); return $workbatch; } /** * */ public function release_expired_docs($table) { if(!empty($table)) { $timestamp = time(); $this->connect(); $this->query("select distinct res_id from ".$table." where video_batch is not null and video_time < ".$timestamp); //$this->show(); $db = new dbquery(); $db->connect(); while($line = $this->fetch_object()) { $res_id = $line->res_id; $db->query("update ".$table." set video_batch = NULL , video_time = NULL where res_id = ".$res_id); } } } public function release_user_docs($table) { if(!empty($table)) { $timestamp = time(); $this->connect(); $this->query("update ".$table." set video_batch = NULL , video_time = NULL where video_user = '".$_SESSION['user']['UserId']."'"); } } public function get_user_reserved_doc($table) { $tab_resid = array(); if(!empty($table)) { $this->connect(); $this->query("select distinct res_id from ".$table." where video_batch is not null and video_user = '".$_SESSION['user']['UserId']."'"); //$this->show(); while($line = $this->fetch_object()) { $res_id = $line->res_id; if($this->check_reserved_time($res_id, $table)) { $tab_resid[] = $res_id; } } } return $tab_resid; } private function check_reserved_time($res_id, $table) { if(!empty($table) && !empty($res_id)) { $db = new dbquery(); $db->connect(); $db->query("select video_user, video_time from ".$table." where res_id = ".$res_id); //$db->show(); $res = $db->fetch_object(); $timestamp = time(); $maxtime = $res->video_time; $video_user = $res-> video_user; //echo "TIME: ".$timestamp.'/'.$maxtime; if($timestamp > $maxtime) { $db2 = new dbquery(); $db2->connect(); $db2->query("update ".$table." set video_batch = NULL , video_user = NULL where res_id = ".$res_id); return false; } else // Reserved time not yet expired { if($video_user == $_SESSION['user']['UserId'] || empty($video_user)) { return true; } else { return false; } } } else { return false; } } /** * * */ public function already_reserved($table) { $reserved = false; if(!empty($table)) { $timestamp = time(); $db = new dbquery(); $db->connect(); $db->query("select res_id from ".$table." where video_batch is not null and video_user = '".$_SESSION['user']['UserId']."' and video_time > ".$timestamp); //$db->show(); exit; if ($db->nb_result() > 0) { $reserved = true; } } return $reserved; } /** * Is folder locked? * @param folder_id : string */ public function folder_is_locked($folder_id) { $is_locked = false; if (isset($folder_id) && !empty($folder_id)) { $this->connect(); $this->query("select video_status from ".$_SESSION['tablename']['fold_folders']." where folders_system_id = ".$folder_id); $res = $this->fetch_object(); if ($res->video_status == 'LCK') { $is_locked = true; } } return $is_locked; } /** * Unlock current folder * */ public function unlock_current_folder() { //Unlock folder if (isset($_SESSION['postindexing']['folder_system_id']) && !empty($_SESSION['postindexing']['folder_system_id'])) { $this->connect(); $this->query("update ".$_SESSION['tablename']['fold_folders']." set video_status = NULL, video_user = NULL where folders_system_id = ".$_SESSION['postindexing']['folder_system_id']); unset($_SESSION['postindexing']['folder_system_id']); } } /** * Unlock user folder * */ public function unlock_user_folder() { //Unlock folder $this->connect(); $this->query("update ".$_SESSION['tablename']['fold_folders']." set video_status = NULL, video_user = NULL where video_user = '".$_SESSION['user']['UserId']."'"); } /** * Release folder from postindexing * */ public function update_status_folder($folder_id, $status) { //update status $this->connect(); $this->query("update ".$_SESSION['tablename']['fold_folders']." set status = '".$status."' where folders_system_id = ".$folder_id); } /** * Shox information box in postindexing form * */ public function show_info() { ?>
';
}
else
{
echo '
';
}
//PREVIOUS BUFFER
if(
($_SESSION['postindexing']['resid_pointeur'] + 1) >= $_SESSION['postindexing']['buffer']
&& (count($_SESSION['postindexing']['docs']) > $_SESSION['postindexing']['buffer'])
)
{
echo '
';
}
else
{
echo '
';
}
//PREVIOUS
if($_SESSION['postindexing']['resid_pointeur'] > 0)
{
echo '
';
}
else
{
echo '
';
}
//NEXT
if($_SESSION['postindexing']['resid_pointeur'] < ($_SESSION['postindexing']['nb_total'] - 1 ))
{
echo '
';
}
else
{
echo '
';
}
//NEXT BUFFER
if($_SESSION['postindexing']['resid_pointeur'] < (count($_SESSION['postindexing']['docs']) - $_SESSION['postindexing']['buffer']))
{
echo '
';
}
else
{
echo '
';
}
//LAST
if($_SESSION['postindexing']['resid_pointeur'] < count($_SESSION['postindexing']['docs']) - 1)
{
echo '
';
}
else
{
echo '
';
}
}
if (!isset($_SESSION['postindexing']['showHideBox']))
{
$_SESSION['postindexing']['showHideBox'] = 'true';
}
?>