. */ /** * @brief Action : Process a document * * Open a modal box to displays the process form, make the form checks and loads the result in database. * Used by the core (manage_action.php page). * * @file * @author Claire Figueras * @author Laurent Giovannoni * @date $date$ * @version $Revision$ * @ingroup apps */ /** * $confirm bool false */ $confirm = false; /** * $etapes array Contains 2 etaps : form and status (order matters) */ $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'; include('apps/' . $_SESSION['config']['app_id']. '/definition_mail_categories.php'); /** * Returns the indexing form text * * @param $values Array Contains the res_id of the document to process * @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) { //DECLARATIONS require_once('core/class/class_security.php'); require_once('modules/basket/class/class_modules_tools.php'); require_once('core/class/class_request.php'); require_once('apps/' . $_SESSION['config']['app_id'] . '/class/class_types.php'); require_once('apps/' . $_SESSION['config']['app_id'] . '/class/class_indexing_searching_app.php'); require_once('apps/' . $_SESSION['config']['app_id'] . '/class/class_chrono.php'); //INSTANTIATE $type = new types(); $sec = new security(); $core_tools = new core_tools(); $b = new basket(); $is = new indexing_searching_app(); $cr = new chrono(); $db = new Database(); $data = array(); $indexes = array(); //INITIALIZE $frm_str = ''; $_SESSION['req'] = "action"; $res_id = $values[0]; $doctypes = $type->getArrayTypes($coll_id); $params_data = array('show_folder' => true); $data = get_general_data($coll_id, $res_id, 'full', $params_data); $_SESSION['save_list']['fromProcess'] = "true"; $_SESSION['count_view_baskets'] = 0; $chrono_number = $cr->get_chrono_number($res_id, $sec->retrieve_view_from_table($table)); $_SESSION['doc_id'] = $res_id; //LAUNCH DOCLOCKER $docLockerCustomPath = 'apps/maarch_entreprise/actions/docLocker.php'; $docLockerPath = $_SESSION['config']['businessappurl'] . '/actions/docLocker.php'; if (is_file($docLockerCustomPath)){ require_once $docLockerCustomPath; }else if (is_file($docLockerPath)){ require_once $docLockerPath; }else{ exit("can't find docLocker.php"); } $docLocker = new docLocker($res_id); if (!$docLocker->canOpen()) { $docLockerscriptError = ''; return $docLockerscriptError; } // DocLocker constantly $frm_str .= ''; $docLocker->lock(); if (isset($data['type_id'])) { $indexes = $type->get_indexes($data['type_id']['value'], $coll_id); $fields = 'res_id'; foreach (array_keys($indexes) as $key) { $fields .= ',' . $key; } $stmt = $db->query("SELECT " . $fields . " FROM " . $table . " WHERE res_id = ?", array($res_id)); $values_fields = $stmt->fetchObject(); //print_r($indexes); } if ($core_tools->is_module_loaded('entities')) { require_once('modules/entities/class/class_manage_listdiff.php'); $listdiff = new diffusion_list(); $roles = $listdiff->list_difflist_roles(); $_SESSION['process']['diff_list'] = $listdiff->get_listinstance($res_id, false, $coll_id); $_SESSION['process']['difflist_type'] = $listdiff->get_difflist_type($_SESSION['process']['diff_list']['object_type']); } //Load multicontacts $query = "SELECT c.firstname, c.lastname, c.society, c.contact_id, c.ca_id "; $query .= "FROM view_contacts c, contacts_res cres "; $query .= "WHERE cres.coll_id = 'letterbox_coll' AND cres.res_id = ? AND cast (c.contact_id as varchar) = cres.contact_id AND c.ca_id = cres.address_id "; $query .= "GROUP BY c.firstname, c.lastname, c.society, c.contact_id, c.ca_id"; $stmt = $db->query($query, array($res_id)); $nbContacts = 0; $frameContacts = ""; $frameContacts = "{"; while($res = $stmt->fetchObject()){ $nbContacts = $nbContacts + 1; $firstname = str_replace("'","\'", $res->firstname); $firstname = str_replace('"'," ", $firstname); $lastname = str_replace("'","\'", $res->lastname); $lastname = str_replace('"'," ", $lastname); $society = str_replace("'","\'", $res->society); $society = str_replace('"'," ", $society); $frameContacts .= "'contact ".$nbContacts."' : '" . functions::xssafe($firstname) . " " . functions::xssafe($lastname) . " " . functions::xssafe($society) . " (contact)', "; } $query = "select u.firstname, u.lastname, u.user_id "; $query .= "from users u, contacts_res cres "; $query .= "where cres.coll_id = 'letterbox_coll' AND cres.res_id = ? AND cast (u.user_id as varchar) = cres.contact_id "; $query .= "GROUP BY u.firstname, u.lastname, u.user_id"; $stmt = $db->query($query, array($res_id)); while($res = $stmt->fetchObject()){ $nbContacts = $nbContacts + 1; $firstname = str_replace("'","\'", $res->firstname); $firstname = str_replace('"'," ", $firstname); $lastname = str_replace("'","\'", $res->lastname); $lastname = str_replace('"'," ", $lastname); $frameContacts .= "'contact ".$nbContacts."' : '" . functions::xssafe($firstname) . " " . functions::xssafe($lastname) . " (utilisateur)', "; } $frameContacts = substr($frameContacts, 0, -2); $frameContacts .= "}"; //_ID_TO_DISPLAY ? if(_ID_TO_DISPLAY == 'res_id'){ $frm_str .= '

' . _PROCESS . _LETTER_NUM . $res_id; $frm_str .= '

'; }else{ $frm_str .= '

' . _PROCESS . _DOCUMENT . ' ' . $chrono_number; $frm_str .= '

'; } $frm_str .=''; $frm_str .=''; /* * ******************************* LEFT PART ************************************* */ $frm_str .= ''; $frm_str .= ''; // ****************************** RIGHT PART *******************************************/ $frm_str .= ''; //EXTRA SCRIPT $frm_str .= ''; return addslashes($frm_str); } /** * Checks the action form * * @param $form_id String Identifier of the form to check * @param $values Array Values of the form * @return Bool true if no error, false otherwise **/ function check_form($form_id,$values) { $db = new Database(); $core = new core_tools(); $check = true; $folder = ''; $folder_id = ''; $foldertype_id = ''; if ($core->is_module_loaded('folder')) { if (!empty($folder)) { $folder_id = $folder; $stmt = $db->query("SELECT folders_system_id FROM ".$_SESSION['tablename']['fold_folders']." WHERE folders_system_id = ?", array($folder_id)); if ($stmt->rowCount() == 0) { $_SESSION['action_error'] = _FOLDER.' '.$folder_id.' '._UNKNOWN; return false; } } if (!empty($res_id) && !empty($coll_id) && !empty($folder_id)) { require_once('core'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_security.php'); $sec = new security(); $table = $sec->retrieve_table_from_coll($coll_id); if (empty($table)) { $_SESSION['action_error'] .= _COLLECTION.' '._UNKNOWN; return false; } $stmt = $db->query("SELECT type_id FROM ".$table." WHERE res_id = ?", array($res_id)); $res = $stmt->fetchObject(); $type_id = $res->type_id; $stmt = $db->query("SELECT foldertype_id FROM ".$_SESSION['tablename']['fold_folders']." WHERE folders_system_id = ?", array($folder_id)); $res = $stmt->fetchObject(); $foldertype_id = $res->foldertype_id; $stmt = $db->query("SELECT fdl.foldertype_id FROM ".$_SESSION['tablename']['fold_foldertypes_doctypes_level1'] ." fdl, ".$_SESSION['tablename']['doctypes'] ." d WHERE d.doctypes_first_level_id = fdl.doctypes_first_level_id and fdl.foldertype_id = ? and d.type_id = ?", array($foldertype_id, $type_id)); if ($stmt->rowCount() == 0) { $_SESSION['action_error'] .= _ERROR_COMPATIBILITY_FOLDER; return false; } } } return $check; } /** * Action of the form : loads the index in the db * * @param $arr_id Array Not used here * @param $history String Log the action in history table or not * @param $id_action String Action identifier * @param $label_action String Action label * @param $status String Not used here * @param $coll_id String Collection identifier * @param $table String Table * @param $values_form String Values of the form to load * @return false or an array * $data['result'] : res_id of the new file followed by # * $data['history_msg'] : Log complement (empty by default) **/ function manage_form($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table, $values_form) { if (empty($values_form) || count($arr_id) < 1 || empty($coll_id)) { return false; } require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_security.php"); $sec = new security(); $db = new Database(); $core = new core_tools(); $res_table = $sec->retrieve_table_from_coll($coll_id); $ind = $sec->get_ind_collection($coll_id); $table = $_SESSION['collections'][$ind]['extensions'][0]; $other_txt = ''; $process_notes = ''; $folder = ''; $thesaurusList = ''; for ($j=0; $jis_module_loaded('tags')) { $tags_list = explode('__', $tags); include_once("modules" . DIRECTORY_SEPARATOR . "tags" . DIRECTORY_SEPARATOR . "tags_update.php"); } //THESAURUS if ($core->is_module_loaded('thesaurus')) { require_once 'modules' . DIRECTORY_SEPARATOR . 'thesaurus' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_modules_tools.php'; $thesaurus = new thesaurus(); $thesaurus->updateResThesaurusList($thesaurusList,$arr_id[0]); } //FOLDERS if ($core->is_module_loaded('folder') && ($core->test_service('associate_folder', 'folder',false) == 1)) { $folder_id = ''; $old_folder_id = ''; //get old folder ID $stmt = $db->query("SELECT folders_system_id FROM ".$res_table." WHERE res_id = ?", array($arr_id[0])); $res = $stmt->fetchObject(); $old_folder_id = $res->folders_system_id; if (!empty($folder)) { $folder_id = $folder; 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", 'folderup', _DOC_NUM.$arr_id[0]._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", 'folderup', _DOC_NUM.$arr_id[0]._DELETED_FROM_FOLDER, $_SESSION['config']['databasetype'],'apps'); } } $db->query("UPDATE ".$res_table." SET folders_system_id = ? WHERE res_id = ? ", array($folder_id, $arr_id[0])); } else if(empty($folder) && !empty($old_folder_id)) { //Delete folder reference in res_X $db->query("UPDATE ".$res_table." SET folders_system_id = NULL WHERE res_id = ?", array($arr_id[0])); } } //DIFFLIST if ($core->is_module_loaded('entities') && count($_SESSION['redirect']['diff_list']) == 0) { require_once('modules/entities/class/class_manage_listdiff.php'); $list = new diffusion_list(); $params = array('mode'=> 'listinstance', 'table' => $_SESSION['tablename']['ent_listinstance'], 'coll_id' => $coll_id, 'res_id' => $arr_id[0], 'user_id' => $_SESSION['user']['UserId'], 'concat_list' => true, 'only_cc' => true); $list->load_list_db($_SESSION['process']['diff_list'], $params); //pb enchainement avec action redirect } //$_SESSION['process']['diff_list'] = array(); $_SESSION['redirect']['diff_list'] = array(); unset($_SESSION['redirection']); unset($_SESSION['redirect']); $db->query("UPDATE ".$table." SET answer_type_bitmask = ?, process_notes = ?, other_answer_desc = ? WHERE res_id= ?", array($bitmask, $process_notes, $other_txt, $arr_id[0])); return array('result' => $arr_id[0].'#', 'history_msg' => ''); } function manage_unlock($arr_id, $history, $id_action, $label_action, $status, $coll_id, $table) { $db = new Database(); $result = ''; for ($i=0; $iquery("UPDATE ".$table. " SET video_user = '', video_time = 0 WHERE res_id = ?", array($arr_id[$i])); } return array('result' => $result, 'history_msg' => ''); }