Exemple #1
0
 /**
  * Constructor.
  * initializes the toolbar if the id is given.
  *
  * @param integer $id DB id
  * @return void
  * @access public
  */
 function __construct($id = 0, &$user)
 {
     if (!is_a($user, 'CMS_profile_user') || $user->hasError()) {
         $this->raiseError("User is not a valid CMS_profile_user");
         return;
     }
     $this->_user = $user;
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\ttoolbars\n\t\t\t\twhere\n\t\t\t\t\tid_tool='{$id}'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_id = $id;
             $this->_code = $data["code_tool"];
             $this->_label = $data["label_tool"];
             $this->_toolbarElements = explode('|', $data["elements_tool"]);
         } else {
             $this->raiseError("Unknown ID :" . $id);
         }
     } else {
         $this->_toolbarElements = array_keys($this->_elements);
     }
 }
 /**
  * Return a recursive structure for all objects of a given module based on objects definition
  *
  * @param string $module the module codename
  * @param boolean $withObjectInfos returned structure contain objects infos (default false)
  * @return multidimensionnal array : the recursive structure of all objects of the given module
  * @access public
  * @static
  */
 function getModuleStructure($module, $withObjectInfos = false)
 {
     $sql = "select\n\t\t\t\t\tobject_id_mof as objectID,\n\t\t\t\t\ttype_mof as fieldType,\n\t\t\t\t\tid_mof as fieldID\n\t\t\t\tfrom\n\t\t\t\t\tmod_object_definition,\n\t\t\t\t\tmod_object_field\n\t\t\t\twhere\n\t\t\t\t\tid_mod = object_id_mof\n\t\t\t\torder by objectID, order_mof\n\t\t";
     //SQL where clause removed when add cross modules link into objects
     /*module_mod='".sensitiveIO::sanitizeSQLString($module)."'
     		and */
     $q = new CMS_query($sql);
     $flatStructure = array();
     if ($q->getNumRows()) {
         while ($r = $q->getArray()) {
             $flatStructure['object' . $r['objectID']]['field' . $r['fieldID']] = $r['fieldType'];
         }
     }
     //append objects without fields
     $sql = "select\n\t\t\t\t\tid_mod as objectID\n\t\t\t\tfrom\n\t\t\t\t\tmod_object_definition\n\t\t\t\torder by objectID\n\t\t";
     $q = new CMS_query($sql);
     if ($q->getNumRows()) {
         while ($r = $q->getArray()) {
             if (!isset($flatStructure['object' . $r['objectID']])) {
                 $flatStructure['object' . $r['objectID']] = array();
             }
         }
     }
     if ($withObjectInfos) {
         $objectInfos = array();
     }
     $structure = CMS_poly_module_structure::_createRecursiveStructure($flatStructure, $flatStructure, $objectInfos);
     if ($withObjectInfos) {
         $structure['objectInfos'] = $objectInfos;
     }
     return $structure;
 }
 /**
  * Constructor.
  * initialize object.
  *
  * @param integer $id DB id
  * @param array $dbValues DB values
  * @return void
  * @access public
  */
 function __construct($id = 0, $dbValues = array())
 {
     $datas = array();
     if ($id && !$dbValues) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer : " . $id);
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_object_plugin_definition\n\t\t\t\twhere\n\t\t\t\t\tid_mowd='" . $id . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $datas = $q->getArray();
         } else {
             $this->raiseError("Unknown ID :" . $id);
             return;
         }
     } elseif (is_array($dbValues) && $dbValues) {
         $datas = $dbValues;
     }
     if (is_array($datas) && $datas) {
         $this->_ID = (int) $datas['id_mowd'];
         $this->_objectValues["objectID"] = (int) $datas['object_id_mowd'];
         $this->_objectValues["labelID"] = (int) $datas['label_id_mowd'];
         $this->_objectValues["descriptionID"] = (int) $datas['description_id_mowd'];
         $this->_objectValues["query"] = $datas['query_mowd'] ? unserialize($datas['query_mowd']) : array();
         $this->_objectValues["definition"] = $datas['definition_mowd'];
         $this->_objectValues["compiledDefinition"] = $datas['compiled_definition_mowd'];
         $this->_objectValues["uuid"] = isset($datas['uuid_mowd']) ? $datas['uuid_mowd'] : '';
         //for compatibility with version < 0.97
         if ($this->_objectValues["definition"] && !$this->_objectValues["compiledDefinition"]) {
             $this->compileDefinition();
             $this->writeToPersistence();
         }
     }
 }
 public static function getDefinitionsForObject($objectid)
 {
     $sql = 'SELECT * from mod_object_oembed_definition where objectdefinition_mood = "' . io::sanitizeSQLString($objectid) . '"';
     $query = new CMS_query($sql);
     $defs = array();
     while ($data = $query->getArray()) {
         $defs[] = self::getObj($data);
     }
     return $defs;
 }
 /**
  * Constructor.
  * initialize object.
  *
  * @param integer $id DB id
  * @param array $dbValues DB values
  * @return void
  * @access public
  */
 function __construct($id = 0, $dbValues = array())
 {
     $datas = array();
     if ($id && !$dbValues) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer : " . $id);
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_object_rss_definition\n\t\t\t\twhere\n\t\t\t\t\tid_mord='" . $id . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $datas = $q->getArray();
         } else {
             $this->raiseError("Unknown ID :" . $id);
             return;
         }
     } elseif (is_array($dbValues) && $dbValues) {
         $datas = $dbValues;
     }
     if (is_array($datas) && $datas) {
         $this->_ID = (int) $datas['id_mord'];
         $this->_objectValues["objectID"] = (int) $datas['object_id_mord'];
         $this->_objectValues["labelID"] = (int) $datas['label_id_mord'];
         $this->_objectValues["descriptionID"] = (int) $datas['description_id_mord'];
         $this->_objectValues["link"] = $datas['link_mord'];
         $this->_objectValues["author"] = $datas['author_mord'];
         $this->_objectValues["copyright"] = $datas['copyright_mord'];
         $this->_objectValues["namespaces"] = $datas['namespaces_mord'];
         $this->_objectValues["categories"] = $datas['categories_mord'];
         $this->_objectValues["ttl"] = (int) $datas['ttl_mord'];
         $this->_objectValues["email"] = $datas['email_mord'];
         $this->_objectValues["definition"] = $datas['definition_mord'];
         $this->_objectValues["compiledDefinition"] = $datas['compiled_definition_mord'];
         $this->_objectValues["lastCompilation"] = new CMS_date();
         $this->_objectValues["lastCompilation"]->setFromDBValue($datas['last_compilation_mord']);
         $this->_objectValues["uuid"] = isset($datas['uuid_mord']) ? $datas['uuid_mord'] : '';
     } else {
         $this->_objectValues["lastCompilation"] = new CMS_date();
     }
     //check for last compilation date (recompile Feed each day)
     if ($this->_objectValues["compiledDefinition"]) {
         $lastCompilation = $this->_objectValues["lastCompilation"];
         $lastCompilation->moveDate('+1 day');
         $today = new CMS_date();
         $today->setNow();
         if (CMS_date::compare($today, $lastCompilation, '>')) {
             $this->compileDefinition();
             $this->writeToPersistence();
         }
     }
 }
Exemple #6
0
 /**
  * Constructor.
  * initializes the resource if the id is given
  *
  * @param integer $id DB id
  * @return void
  * @access public
  */
 function CMS_resource($id = 0)
 {
     if ($id) {
         if (SensitiveIO::isPositiveInteger($id)) {
             $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\t*\n\t\t\t\t\tfrom\n\t\t\t\t\t\tresources,\n\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_res='{$id}'\n\t\t\t\t\t\tand status_res=id_rs\n\t\t\t\t";
             $q = new CMS_query($sql);
             if ($q->getNumRows()) {
                 $data = $q->getArray();
                 $this->_id = $id;
                 $this->_status = new CMS_resourceStatus($data);
                 if ($this->_status->hasError()) {
                     $this->raiseError("Unfound status :" . $data["status_res"]);
                     return;
                 }
                 //build editors stack. If stack is malformed, it's a minor error, so proceed.
                 $this->_editors = new CMS_stack();
                 if (!$this->_editors->setTextDefinition($data["editorsStack_res"])) {
                     $this->raiseError("Editors stack malformed");
                     $this->_editors->emptyStack();
                 }
             } else {
                 $this->raiseError("Unknown ID :" . $id);
             }
         } elseif (is_array($id)) {
             $data = $id;
             $this->_id = $data["id_res"];
             $this->_status = new CMS_resourceStatus($data);
             if ($this->_status->hasError()) {
                 $this->raiseError("Unfound status :" . $data["status_res"]);
                 return;
             }
             //build editors stack. If stack is malformed, it's a minor error, so proceed.
             $this->_editors = new CMS_stack();
             if (!$this->_editors->setTextDefinition($data["editorsStack_res"])) {
                 $this->raiseError("Editors stack malformed");
                 $this->_editors->emptyStack();
             }
         } else {
             $this->raiseError("Id is not a positive integer nor array");
             return;
         }
     } else {
         $this->_status = new CMS_resourceStatus();
         $this->_editors = new CMS_stack();
     }
 }
Exemple #7
0
 /**
  * Constructor
  * 
  * @access public
  * @param integer $id
  * @return void 
  */
 function __construct($id = 0)
 {
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_cms_forms_records\n\t\t\t\twhere\n\t\t\t\t\tid_rec='" . $id . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_recordID = $id;
             $this->_fieldID = $data["field_rec"];
             $this->_senderID = $data["sending_rec"];
             $this->_value = $data["value_rec"];
         } else {
             $this->raiseError("Unknown ID :" . $id);
         }
     }
 }
 /**
  * Constructor.
  * initialize object.
  *
  * @param integer $id DB id
  * @param array $dbValues DB values
  * @return void
  * @access public
  */
 function __construct($id = 0, $dbValues = array())
 {
     $datas = array();
     if ($id && !$dbValues) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer : " . $id);
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_object_field,\n\t\t\t\t\tmod_object_definition\n\t\t\t\twhere\n\t\t\t\t\tid_mof='" . $id . "'\n\t\t\t\t\tand object_id_mof = id_mod\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $datas = $q->getArray();
         } else {
             $this->raiseError("Unknown ID :" . $id);
             return;
         }
     } elseif (is_array($dbValues) && $dbValues) {
         $datas = $dbValues;
     }
     if (is_array($datas) && $datas) {
         //set parent values
         parent::__construct($datas['object_id_mof'], $datas);
         //set field values
         $this->_fieldID = (int) $datas['id_mof'];
         $this->_objectFieldValues["objectID"] = (int) $datas['object_id_mof'];
         $this->_objectFieldValues["labelID"] = (int) $datas['label_id_mof'];
         $this->_objectFieldValues["descriptionID"] = (int) $datas['desc_id_mof'];
         $this->_objectFieldValues["type"] = $datas['type_mof'];
         $this->_objectFieldValues["order"] = (int) $datas['order_mof'];
         $this->_objectFieldValues["system"] = $datas['system_mof'] ? true : false;
         $this->_objectFieldValues["required"] = $datas['required_mof'] ? true : false;
         $this->_objectFieldValues["indexable"] = $datas['indexable_mof'] ? true : false;
         $this->_objectFieldValues["searchlist"] = $datas['searchlist_mof'] ? true : false;
         $this->_objectFieldValues["searchable"] = $datas['searchable_mof'] ? true : false;
         $this->_objectFieldValues["params"] = $datas['params_mof'] ? unserialize($datas['params_mof']) : array();
         $this->_objectFieldValues["uuid"] = isset($datas['uuid_mof']) ? $datas['uuid_mof'] : '';
     } else {
         parent::__construct(0, array());
     }
 }
Exemple #9
0
 /**
  * Constructor.
  * initialize object.
  *
  * @param integer $id DB id
  * @param array $dbValues DB values
  * @return void
  * @access public
  */
 function __construct($id = 0, $dbValues = array())
 {
     static $i18nm;
     //load available languages
     $this->getAvailableLanguages();
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer : " . $id);
             return;
         }
         if (!isset($i18nm[$id])) {
             if ($id && !$dbValues) {
                 $sql = "\n\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t*\n\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\tmod_object_i18nm\n\t\t\t\t\t\twhere\n\t\t\t\t\t\t\tid_i18nm ='" . $id . "'\n\t\t\t\t\t";
                 $q = new CMS_query($sql);
                 if ($q->getNumRows()) {
                     $this->_ID = $id;
                     while ($arr = $q->getArray()) {
                         $this->_values[$arr["code_i18nm"]] = $arr['value_i18nm'];
                         $this->_DBKnown[] = $arr["code_i18nm"];
                     }
                 } else {
                     $this->raiseError("Unknown ID :" . $id);
                     return;
                 }
             } elseif ($id && is_array($dbValues) && $dbValues) {
                 $this->_ID = $id;
                 foreach ($dbValues as $code => $value) {
                     $this->_values[$code] = $value;
                     $this->_DBKnown[] = $code;
                 }
             }
             $i18nm[$id] = $this;
         } else {
             //$this = $GLOBALS["polyModule"]["i18nm"][$id];
             $this->_ID = $id;
             $this->_values = $i18nm[$id]->_values;
             $this->_DBKnown = $i18nm[$id]->_DBKnown;
         }
     }
 }
Exemple #10
0
 /**
  * activates the script function.
  *
  * @return void
  * @access public
  */
 function activate()
 {
     parent::activate();
     if ($_SERVER['argv']['1'] == '-s' && SensitiveIO::isPositiveInteger($_SERVER['argv']['2'])) {
         // SUB-SCRIPT : Processes one script task
         @ini_set('max_execution_time', SUB_SCRIPT_TIME_OUT);
         //set max execution time for sub script
         @set_time_limit(SUB_SCRIPT_TIME_OUT);
         //set the PHP timeout for sub script
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tregenerator\n\t\t\t\twhere\n\t\t\t\t\tid_reg = '" . $_SERVER['argv']['2'] . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             //send script informations to process manager
             $this->_processManager->setParameters($data['module_reg'], $data['parameters_reg']);
             //instanciate script module
             $module = CMS_modulesCatalog::getByCodename($data['module_reg']);
             //then send script task to module (return task title by reference)
             $task = $module->scriptTask(unserialize($data['parameters_reg']));
             //delete the current script task
             $sql_delete = "\n\t\t\t\t\tdelete\n\t\t\t\t\tfrom\n\t\t\t\t\t\tregenerator\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_reg='" . $data['id_reg'] . "'";
             $q = new CMS_query($sql_delete);
             if ($this->_debug) {
                 $this->raiseError($this->_processManager->getPIDFilePath() . " : task " . $_SERVER['argv']['2'] . " seems " . (!$task ? 'NOT ' : '') . "done !");
                 $this->raiseError($this->_processManager->getPIDFilePath() . " : PID file exists ? " . @file_exists($this->_processManager->getPIDFilePath()));
             }
             $fpath = $this->_processManager->getPIDFilePath() . '.ok';
             if (@touch($fpath) && @chmod($fpath, octdec(FILES_CHMOD))) {
                 $f = @fopen($fpath, 'a');
                 if (!@fwrite($f, 'Script OK')) {
                     $this->raiseError($this->_processManager->getPIDFilePath() . " : Can't write into file: " . $fpath);
                 }
                 @fclose($f);
             } else {
                 $this->raiseError($this->_processManager->getPIDFilePath() . " : Can't create file: " . $fpath);
             }
         }
     } else {
         // MASTER SCRIPT : Processes all sub-scripts
         @ini_set('max_execution_time', MASTER_SCRIPT_TIME_OUT);
         //set max execution time for master script
         @set_time_limit(MASTER_SCRIPT_TIME_OUT);
         //set the PHP timeout  for master script
         //max simultaneous scripts
         $maxScripts = $_SERVER['argv']['2'];
         $scriptsArray = array();
         //send script informations to process manager
         $this->_processManager->setParameters(processManager::MASTER_SCRIPT_NAME, '');
         //the sql script which selects one script task at a time
         $sql_select = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tregenerator\n\t\t\t\tlimit\n\t\t\t\t\t" . $maxScripts . "\n\t\t\t";
         //and now, launch all sub-scripts until table is empty.
         while (true) {
             //get scripts
             $q = new CMS_query($sql_select);
             if ($q->getNumRows()) {
                 while (count($scriptsArray) < $maxScripts && ($data = $q->getArray())) {
                     // Launch sub-process
                     if (!APPLICATION_IS_WINDOWS) {
                         // On unix system
                         $sub_system = PATH_PACKAGES_FS . "/scripts/script.php -s " . $data["id_reg"] . " > /dev/null 2>&1 &";
                         if (!defined('PATH_PHP_CLI_UNIX') || !PATH_PHP_CLI_UNIX) {
                             CMS_patch::executeCommand("cd " . PATH_REALROOT_FS . "; php " . $sub_system, $error);
                             if ($error) {
                                 CMS_grandFather::raiseError('Error during execution of sub script command (cd ' . PATH_REALROOT_FS . '; php ' . $sub_system . '), please check your configuration : ' . $error);
                                 return false;
                             }
                         } else {
                             CMS_patch::executeCommand("cd " . PATH_REALROOT_FS . "; " . PATH_PHP_CLI_UNIX . " " . $sub_system, $error);
                             if ($error) {
                                 CMS_grandFather::raiseError('Error during execution of sub script command (cd ' . PATH_REALROOT_FS . '; ' . PATH_PHP_CLI_UNIX . ' ' . $sub_system . '), please check your configuration : ' . $error);
                                 return false;
                             }
                         }
                         $PIDfile = $this->_processManager->getTempPath() . "/" . SCRIPT_CODENAME . "_" . $data["id_reg"];
                         if ($this->_debug) {
                             $this->raiseError(processManager::MASTER_SCRIPT_NAME . " : Executes system(" . $sub_system . ")");
                         }
                         //sleep a little
                         @sleep(SLEEP_TIME);
                     } else {
                         // On windows system
                         //Create the BAT file
                         $command = '@echo off' . "\r\n" . '@start /B /BELOWNORMAL ' . realpath(PATH_PHP_CLI_WINDOWS) . ' ' . realpath(PATH_PACKAGES_FS . '\\scripts\\script.php') . ' -s ' . $data["id_reg"];
                         if (!@touch(realpath(PATH_WINDOWS_BIN_FS) . DIRECTORY_SEPARATOR . "sub_script.bat")) {
                             $this->raiseError(processManager::MASTER_SCRIPT_NAME . " : Create file error : sub_script.bat");
                         }
                         $replace = array('program files (x86)' => 'progra~2', 'program files' => 'progra~1', 'documents and settings' => 'docume~1');
                         $command = str_ireplace(array_keys($replace), $replace, $command);
                         $fh = fopen(realpath(PATH_WINDOWS_BIN_FS . DIRECTORY_SEPARATOR . "sub_script.bat"), "wb");
                         if (is_resource($fh)) {
                             if (!fwrite($fh, $command, io::strlen($command))) {
                                 CMS_grandFather::raiseError(processManager::MASTER_SCRIPT_NAME . " : Save file error : sub_script.bat");
                             }
                             fclose($fh);
                         }
                         $WshShell = new COM("WScript.Shell");
                         $oExec = $WshShell->Run(str_ireplace(array_keys($replace), $replace, realpath(PATH_WINDOWS_BIN_FS . '\\sub_script.bat')), 0, false);
                         $PIDfile = $this->_processManager->getTempPath() . DIRECTORY_SEPARATOR . SCRIPT_CODENAME . "_" . $data["id_reg"];
                         //sleep a little
                         @sleep(SLEEP_TIME);
                     }
                     if ($this->_debug) {
                         $this->raiseError(processManager::MASTER_SCRIPT_NAME . " : script : " . $data["id_reg"] . " - sub_system : " . $sub_system);
                     }
                     $scriptsArray[] = array("PID" => $PIDfile, "startTime" => CMS_stats::getmicrotime(), "scriptID" => $data["id_reg"], "scriptDatas" => $data);
                 }
             } else {
                 // no more scripts to process
                 // > delete all temporary files
                 // > end script
                 if (APPLICATION_IS_WINDOWS) {
                     $files = glob(realpath($this->_processManager->getTempPath()) . DIRECTORY_SEPARATOR . SCRIPT_CODENAME . '*.ok', GLOB_NOSORT);
                     if (is_array($files)) {
                         foreach ($files as $file) {
                             if (!CMS_file::deleteFile($file)) {
                                 $this->raiseError("Can't delete file " . $file);
                                 return false;
                             }
                         }
                     }
                 } else {
                     $tmpDir = dir($this->_processManager->getTempPath());
                     while (false !== ($file = $tmpDir->read())) {
                         if (io::strpos($file, SCRIPT_CODENAME) !== false) {
                             @unlink($this->_processManager->getTempPath() . '/' . $file);
                         }
                     }
                 }
                 break;
             }
             while (true) {
                 @sleep(SLEEP_TIME);
                 //wait a little to check sub_scripts
                 $break = false;
                 $timeStop = CMS_stats::getmicrotime();
                 if ($this->_debug) {
                     $this->raiseError(processManager::MASTER_SCRIPT_NAME . " Scripts in progress : " . sizeof($scriptsArray));
                 }
                 foreach ($scriptsArray as $nb => $aScript) {
                     if ($this->_debug) {
                         $this->raiseError(processManager::MASTER_SCRIPT_NAME . " PID : " . $aScript["PID"] . " - time : " . ($timeStop - $aScript["startTime"]));
                     }
                     $ok = '';
                     $ok = is_file($aScript["PID"] . '.ok');
                     if ($ok) {
                         //$break = true;
                         if ($this->_debug) {
                             $this->raiseError(processManager::MASTER_SCRIPT_NAME . " Script : " . $aScript["PID"] . " OK !");
                         }
                         unset($scriptsArray[$nb]);
                     } elseif ($timeStop - $aScript["startTime"] >= SUB_SCRIPT_TIME_OUT) {
                         if ($this->_debug) {
                             $this->raiseError(processManager::MASTER_SCRIPT_NAME . " : Script : " . $aScript["PID"] . " NOT OK !");
                         }
                         $this->raiseError(processManager::MASTER_SCRIPT_NAME . ' : Error on task : ' . $aScript["scriptID"] . ' ... skip it. Task parameters : ' . print_r($aScript['scriptDatas'], true));
                         //$break = true;
                         unset($scriptsArray[$nb]);
                         //delete the script in error from task list
                         $q_del = "\n\t\t\t\t\t\t\t\tdelete\n\t\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\t\tregenerator\n\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\tid_reg='" . $aScript["scriptID"] . "'";
                         $q_del = new CMS_query($q_del);
                     }
                 }
                 if (!$scriptsArray) {
                     break;
                 }
             }
         }
     }
 }
Exemple #11
0
 /**
  * Constructor
  * 
  * @access public
  * @param integer $id
  * @return void 
  */
 function __construct($id = 0, $formID = false)
 {
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_cms_forms_fields\n\t\t\t\twhere\n\t\t\t\t\tid_fld='" . $id . "'\n\t\t\t";
         if (sensitiveIO::isPositiveInteger($formID)) {
             $sql .= " and form_fld='" . $formID . "' ";
         }
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_fieldID = $id;
             if (SensitiveIO::isPositiveInteger($formID)) {
                 $this->_formID = $formID;
             }
             if (SensitiveIO::isPositiveInteger($data["form_fld"])) {
                 $this->_formID = $data["form_fld"];
             }
             $this->_label = $data["label_fld"];
             $this->_type = $data["type_fld"];
             $this->_options = unserialize($data["options_fld"]);
             $this->_name = $data["name_fld"];
             $this->_required = $data["required_fld"] ? true : false;
             $this->_active = $data["active_fld"] ? true : false;
             $this->_value = $data["defaultValue_fld"];
             $this->_dataValidation = $data["dataValidation_fld"];
             $this->_order = $data["order_fld"];
             $this->_params = unserialize($data["params_fld"]);
         } else {
             $this->raiseError("Unknown ID :" . $id);
             /*
             				if (SensitiveIO::isPositiveInteger($formID)) {
             					$this->_formID = $formID;
             				}
             				if (SensitiveIO::isPositiveInteger($id)) {
             					$this->_fieldID = $id;
             				}*/
         }
     } else {
         if (SensitiveIO::isPositiveInteger($formID)) {
             $this->_formID = $formID;
         }
     }
 }
Exemple #12
0
 /**
  * Constructor.
  *
  * @return void
  * @access public
  */
 function __construct($id = 0, $user = false)
 {
     // Loads up CMS_log with Id from database or with DB array
     if ($id) {
         if (SensitiveIO::isPositiveInteger($id)) {
             $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\t*\n\t\t\t\t\tfrom\n\t\t\t\t\t\tlog\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_log='" . $id . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
             if ($q->getNumRows()) {
                 $this->_id = $id;
                 $data = $q->getArray();
             } else {
                 $this->raiseError("Unknown DB ID : " . $id);
                 return;
             }
         } elseif (is_array($id)) {
             $data = $id;
             $this->_id = $data['id_log'];
         } else {
             $this->raiseError("Id is not a positive integer nor array");
             return;
         }
         if (is_array($data) && $data) {
             if ($user === false) {
                 $this->_user = new CMS_profile_user($data["user_log"]);
             } else {
                 $this->_user = $user;
             }
             $this->_action = $data["action_log"];
             $date = new CMS_date();
             $date->setFromDBValue($data["datetime_log"]);
             $this->_datetime = $date;
             $this->_textData = $data["textData_log"];
             $this->_label = $data["label_log"];
             $this->_module = $data["module_log"];
             $this->_resource = $data["resource_log"];
             // Create resource objects and populate
             $this->_resourceStatusAfter = new CMS_resourceStatus();
             $this->_resourceStatusAfter->setDebug(false);
             $this->_resourceStatusAfter->setLog(false);
             $this->_resourceStatusAfter->setLocation($data["rsAfterLocation_log"]);
             $this->_resourceStatusAfter->setProposedFor($data["rsAfterProposedFor_log"]);
             $this->_resourceStatusAfter->setAllEditions($data["rsAfterEditions_log"]);
             $this->_resourceStatusAfter->setAllValidationsRefused($data["rsAfterValidationsRefused_log"]);
             $this->_resourceStatusAfter->setPublication($data["rsAfterPublication_log"]);
             //specific draft status
             if ($this->_action == CMS_log::LOG_ACTION_RESOURCE_EDIT_DRAFT) {
                 $this->_resourceStatusAfter->setDraft(true);
             }
         }
     } else {
         $this->_user = new CMS_profile_user();
         $this->_resourceStatusAfter = new CMS_resourceStatus();
         $this->_datetime = new CMS_date();
     }
 }
 /**
  * Get all groups labels
  *
  * @return array(id => label) groups label
  * @access public
  * @static
  */
 static function getGroupsLabels()
 {
     $sql = "\n\t\t\tselect\n\t\t\t\tid_prg as id,\n\t\t\t\tlabel_prg as label\n\t\t\tfrom\n\t\t\t\tprofilesUsersGroups\n\t\t\torder by \n\t\t\t\tlabel_prg asc\n\t\t";
     $q = new CMS_query($sql);
     $groupsLabel = array();
     if ($q->getNumRows()) {
         while ($r = $q->getArray()) {
             $groupsLabel[$r['id']] = $r['label'];
         }
     }
     return $groupsLabel;
 }
Exemple #14
0
 /**
  * Constructor.
  * initializes the template if the id is given.
  *
  * @param integer $id DB id
  * @return void
  * @access public
  */
 function __construct($id = 0)
 {
     $this->_groups = new CMS_stack();
     $this->_modules = new CMS_stack();
     $this->_websitesdenied = new CMS_stack();
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tpageTemplates\n\t\t\t\twhere\n\t\t\t\t\tid_pt='{$id}'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_id = $id;
             $this->_label = $data["label_pt"];
             $this->_image = $data["image_pt"];
             $this->_definitionFile = $data["definitionFile_pt"];
             $this->_groups->setTextDefinition($data["groupsStack_pt"]);
             $this->_modules->setTextDefinition($data["modulesStack_pt"]);
             $this->_useable = $data["inUse_pt"];
             $this->_private = $data["private_pt"];
             $this->_printingClientSpaces = trim($data["printingCSOrder_pt"]) ? explode(";", $data["printingCSOrder_pt"]) : array();
             $this->_description = $data["description_pt"];
             $this->_websitesdenied->setTextDefinition($data["websitesdenied_pt"]);
         } else {
             $this->raiseError("Unknown ID :" . $id);
         }
     }
 }
Exemple #15
0
while ($r = $q->getArray()) {
    if ($r["Field"] == "namespaces_mord") {
        $installed = true;
    }
}
if (!$installed) {
    if (CMS_patch::executeSqlScript(PATH_MAIN_FS . '/sql/updates/v421-to-v422.sql', true)) {
        CMS_patch::executeSqlScript(PATH_MAIN_FS . '/sql/updates/v421-to-v422.sql', false);
        $content .= 'Database successfuly updated (add Namespaces to RSS definitions)<br/>';
    } else {
        $content .= 'Error during database update ! Script ' . PATH_MAIN_FS . '/sql/updates/v421-to-v422.sql must be executed manualy<br/>';
    }
}
$sql = "select 1 from mod_object_oembed_definition";
$q = new CMS_query($sql);
$installed = is_array($q->getArray());
if (!$installed) {
    if (CMS_patch::executeSqlScript(PATH_MAIN_FS . '/sql/updates/mod_object_oembed_definition.sql', true)) {
        CMS_patch::executeSqlScript(PATH_MAIN_FS . '/sql/updates/mod_object_oembed_definition.sql', false);
        $content .= 'Database successfuly updated (add Oembed definitions table)<br/>';
    } else {
        $content .= 'Error during database update ! Script ' . PATH_MAIN_FS . '/sql/updates/mod_object_oembed_definition.sql must be executed manualy<br/>';
    }
}
// END UPDATE FROM 4.2.1 TO 4.2.2
//Update Automne messages
$files = glob(PATH_MAIN_FS . "/sql/messages/*/*.sql", GLOB_NOSORT);
if (is_array($files)) {
    $content .= "Start update of Automne messages ...<br />";
    foreach ($files as $file) {
        if (file_exists($file) && CMS_patch::executeSqlScript($file, true)) {
Exemple #16
0
 /**
  * Get all searched objects (and subobjects) values
  * 
  * @access private
  * @return array of values array(objectID => array(objectFieldID => array(objectSubfieldId => array(sql datas))))
  */
 protected function _getObjectValues()
 {
     $datas = array();
     // Prepare conditions
     if (is_array($this->_sortedResultsIds) && $this->_sortedResultsIds) {
         $where = " where objectID in (" . implode($this->_sortedResultsIds, ',');
         if (is_array($this->_resultsSubObjectsIds) && $this->_resultsSubObjectsIds) {
             $where .= "," . implode($this->_resultsSubObjectsIds, ',');
         }
         $where .= ")";
     }
     $statusSuffix = $this->_public ? "_public" : "_edited";
     $sql = "select\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_subobject_text" . $statusSuffix . "\n\t\t\t\t\t{$where}\n\t\t\tunion distinct\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_subobject_integer" . $statusSuffix . "\n\t\t\t\t\t{$where}\n\t\t\tunion distinct\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_subobject_string" . $statusSuffix . "\n\t\t\t\t\t{$where}\n\t\t\tunion distinct\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_subobject_date" . $statusSuffix . "\n\t\t\t\t\t{$where}\n\t\t\t\t";
     $q = new CMS_query($sql);
     //pr($sql);
     if (!$q->hasError()) {
         //create multidimentionnal array of results values
         while ($arr = $q->getArray()) {
             $datas[$arr["objectID"]][$arr["objectFieldID"]][$arr["objectSubFieldID"]] = $arr;
         }
     }
     return $datas;
 }
Exemple #17
0
 /**
  * Gets the data in array mode.
  *
  * @param integer $pageID The page DB ID which contains the client space
  * @param integer $clientSpaceID The client space DB ID which contains the row
  * @param integer $rowID The row DB ID which contains the block
  * @param integer $location The location of the page
  * @param boolean $public The needed precision for USERSPACE location
  * @return array(mixed=>mixed) The data indexed by data type (value, file, alt_tag, ...), or false on failure (table not found)
  * @access public
  */
 function getRawData($pageID, $clientSpaceID, $rowID, $location, $public)
 {
     parent::getRawData($pageID, $clientSpaceID, $rowID, $location, $public);
     $table = $this->_getDataTableName($location, $public);
     if (!$table) {
         $this->raiseError("Unknown table");
         return false;
     }
     $sql = "\n\t\t\tselect\n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\t" . $table . "\n\t\t\twhere\n\t\t\t\tpage='" . $pageID . "'\n\t\t\t\tand clientSpaceID='" . $clientSpaceID . "'\n\t\t\t\tand rowID='" . $rowID . "'\n\t\t\t\tand blockID='" . $this->_tagID . "'\n\t\t";
     $q = new CMS_query($sql);
     if (!$q->hasError()) {
         if ($q->getNumRows()) {
             $r = $q->getArray();
             $r['value'] = unserialize($r['value']);
             $this->_dbID = $r["id"];
             $this->_pageID = $r["page"];
             $this->_clientSpaceID = $r["clientSpaceID"];
             $this->_rowID = $r["rowID"];
             $this->_tagID = $r["blockID"];
             $this->_value = $r["value"];
             return $r;
         } else {
             return array("value" => array());
         }
     } else {
         return false;
     }
 }
 /**
  * Move the data of a resource from one data location to another.
  * May be used by every module, provided it respects the naming rules described in the modules HOWTO
  *
  * @param CMS_module $module The module who  want its data moved
  * @param string $tablesPrefix The prefix of the tables containing the data
  * @param string $resourceIDFieldName The name of the field containing the resource ID
  * @param integer $resourceID The DB ID of the resource whose data we want to move
  * @param string $locationFrom The starting location, among the available RESOURCE_DATA_LOCATION
  * @param string $locationTo The ending location, among  the available RESOURCE_DATA_LOCATION
  * @param boolean $copyOnly If set to true, the deletion from the originating tables and dirs won't occur
  * @return boolean true on success, false on failure
  * @access public
  */
 static function moveResourceData(&$module, $tablesPrefix, $resourceIDFieldName, $resourceID, $locationFrom, $locationTo, $copyOnly = false)
 {
     if (!is_a($module, "CMS_module")) {
         CMS_grandFather::raiseError("Module is not a CMS_module");
         return false;
     }
     if (!SensitiveIO::isInSet($locationFrom, CMS_resource::getAllDataLocations()) || !SensitiveIO::isInSet($locationTo, CMS_resource::getAllDataLocations())) {
         CMS_grandFather::raiseError("Locations are not in the set");
         return false;
     }
     //get the tables : named PREFIXXXXX_public
     $sql = "show tables";
     $q = new CMS_query($sql);
     $tables_prefixes = array();
     while ($data = $q->getArray()) {
         if (preg_match("#" . $tablesPrefix . "(.*)_public#", $data[0])) {
             $tables_prefixes[] = io::substr($data[0], 0, strrpos($data[0], "_") + 1);
         }
     }
     foreach ($tables_prefixes as $table_prefix) {
         //delete all in the destination table just incase and insert
         if ($locationTo != RESOURCE_DATA_LOCATION_DEVNULL) {
             $sql = "\n\t\t\t\t\tdelete from\n\t\t\t\t\t\t" . $table_prefix . $locationTo . "\n\t\t\t\t\twhere\n\t\t\t\t\t\t" . $resourceIDFieldName . "='" . $resourceID . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
             $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\t" . $table_prefix . $locationTo . "\n\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t*\n\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t" . $table_prefix . $locationFrom . "\n\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t" . $resourceIDFieldName . "='" . $resourceID . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
         }
         if (!$copyOnly) {
             //delete from the starting table
             $sql = "\n\t\t\t\t\tdelete from\n\t\t\t\t\t\t" . $table_prefix . $locationFrom . "\n\t\t\t\t\twhere\n\t\t\t\t\t\t" . $resourceIDFieldName . "='" . $resourceID . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
         }
     }
     //second, move the files
     $locationFromDir = new CMS_file(PATH_MODULES_FILES_FS . "/" . $module->getCodename() . "/" . $locationFrom, CMS_file::FILE_SYSTEM, CMS_file::TYPE_DIRECTORY);
     //cut here if the locationFromDir doesn't exists. That means the module doesn't have files
     if (!$locationFromDir->exists()) {
         return true;
     }
     if ($locationTo != RESOURCE_DATA_LOCATION_DEVNULL) {
         $locationToDir = new CMS_file(PATH_MODULES_FILES_FS . "/" . $module->getCodename() . "/" . $locationTo, CMS_file::FILE_SYSTEM, CMS_file::TYPE_DIRECTORY);
         //cut here if the locationToDir doesn't exists.
         if (!$locationToDir->exists()) {
             CMS_grandFather::raiseError("LocationToDir does not exists : " . PATH_MODULES_FILES_FS . "/" . $module->getCodename() . "/" . $locationTo);
             return false;
         }
         //delete all files of the locationToDir
         $files = glob(PATH_MODULES_FILES_FS . "/" . $module->getCodename() . "/" . $locationTo . '/r' . $resourceID . '_*', GLOB_NOSORT);
         if (is_array($files)) {
             foreach ($files as $file) {
                 if (!CMS_file::deleteFile($file)) {
                     CMS_grandFather::raiseError("Can't delete file " . $file);
                     return false;
                 }
             }
         }
         //then copy or move them to the locationToDir
         $files = glob(PATH_MODULES_FILES_FS . "/" . $module->getCodename() . "/" . $locationFrom . '/r' . $resourceID . '_*', GLOB_NOSORT);
         if (is_array($files)) {
             foreach ($files as $file) {
                 $to = str_replace('/' . $locationFrom . '/', '/' . $locationTo . '/', $file);
                 if ($copyOnly) {
                     if (!CMS_file::copyTo($file, $to)) {
                         CMS_grandFather::raiseError("Can't copy file " . $file . " to " . $to);
                         return false;
                     }
                 } else {
                     if (!CMS_file::moveTo($file, $to)) {
                         CMS_grandFather::raiseError("Can't move file " . $file . " to " . $to);
                         return false;
                     }
                 }
                 //then chmod new file
                 CMS_file::chmodFile(FILES_CHMOD, $to);
             }
         }
     }
     //cleans the initial dir if not a copy
     if (!$copyOnly) {
         //then get all files of the locationFromDir
         $files = glob(PATH_MODULES_FILES_FS . "/" . $module->getCodename() . "/" . $locationFrom . '/r' . $resourceID . '_*', GLOB_NOSORT);
         if (is_array($files)) {
             foreach ($files as $file) {
                 if (!CMS_file::deleteFile($file)) {
                     CMS_grandFather::raiseError("Can't delete file " . $file);
                     return false;
                 }
             }
         }
     }
     return true;
 }
 /**
  * Set module codename
  *
  * @param string $moduleCodename, the module to get categories related to
  * @return CMS_stack
  * @access public
  */
 function getCategoriesClearances($moduleCodename = false)
 {
     static $getCategoriesClearances;
     // Limit output to one module
     if ($moduleCodename) {
         if (!isset($getCategoriesClearances[$moduleCodename]) || !isset($getCategoriesClearances[$moduleCodename][$this->_profileID]) || !is_a($getCategoriesClearances[$moduleCodename][$this->_profileID], 'CMS_stack')) {
             $stack = new CMS_stack();
             if (!$this->_isAdmin) {
                 $sql = "\n\t\t\t\t\t\tselect\n\t\t\t\t\t\t\tcategory_mcc as categoryID,\n\t\t\t\t\t\t\tclearance_mcc as clearance\n\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\tmodulesCategories_clearances,\n\t\t\t\t\t\t\tmodulesCategories\n\t\t\t\t\t\twhere\n\t\t\t\t\t\t\tid_mca=category_mcc\n\t\t\t\t\t\t\tand module_mca = '" . SensitiveiO::sanitizeSQLString($moduleCodename) . "'\n\t\t\t\t\t\t\tand profile_mcc='" . $this->_profileID . "'\n\t\t\t\t\t\t\tand parent_mca != '" . CMS_moduleCategory::LINEAGE_PARK_POSITION . "'\n\t\t\t\t\t";
             } else {
                 $sql = "\n\t\t\t\t\t\tselect\n\t\t\t\t\t\t\tid_mca as categoryID\n\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\tmodulesCategories\n\t\t\t\t\t\twhere\n\t\t\t\t\t\t\tparent_mca = '0'\n\t\t\t\t\t\t\tand module_mca = '" . SensitiveiO::sanitizeSQLString($moduleCodename) . "'";
             }
             $q = new CMS_query($sql);
             while ($datas = $q->getArray()) {
                 $clearance = !$this->_isAdmin ? $datas['clearance'] : CLEARANCE_MODULE_MANAGE;
                 $stack->add($datas['categoryID'], $clearance);
             }
             $getCategoriesClearances[$moduleCodename][$this->_profileID] = $stack;
         } else {
             $stack = $getCategoriesClearances[$moduleCodename][$this->_profileID];
         }
         return $stack;
     } else {
         return $this->_categoriesClearances;
     }
 }
Exemple #20
0
 /**
  * Get all edited blocks found for a given page
  * Detect all blocks
  * Sends an array of all blocks of given page
  * 
  * @param CMS_page $page the page we want data from
  * @param boolean $public, if only public datas are concerned
  * @return array of CMS_block
  */
 function getAllBlocksForPage(&$page, $public = false)
 {
     $_blocks = array();
     //@var : array ( array(Table prefix, Class name) )
     $_blockTypes = array(array('blocksRawDatas', false), array('blocksImages', 'CMS_block_image'), array('blocksFlashes', 'CMS_block_flash'), array('blocksFiles', 'CMS_block_file'), array('blocksTexts', 'CMS_block_text'), array('blocksVarchars', 'CMS_block_varchar'));
     //Rotate all block types availables
     foreach ($_blockTypes as $b) {
         $table = $public ? $b[0] . '_public' : $b[0] . '_edited';
         $class = $b[1];
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\t" . $table . "\n\t\t\t\twhere\n\t\t\t\t\tpage=" . $page->getID() . "\n\t\t\t\t";
         $q = new CMS_query($sql);
         while ($r = $q->getArray()) {
             if (isset($r['type']) && $r['type'] && class_exists($r['type'])) {
                 $_blocks[] = new $r['type']($r['id'], RESOURCE_LOCATION_USERSPACE, $public);
             } elseif ($class && class_exists($class)) {
                 $_blocks[] = new $class($r['id'], RESOURCE_LOCATION_USERSPACE, $public);
             }
         }
     }
     return $_blocks;
 }
Exemple #21
0
 /**
  * Initialize rows depending on location user space
  *
  * @param integer $location The location we want tag definition from
  * @param boolean $public The precision needed for USERSPACE location
  * @return string The table name
  * @access public
  */
 protected function _checkRows($location = RESOURCE_LOCATION_USERSPACE, $public = false)
 {
     if ($this->_templateID && $this->_tagID) {
         if (!SensitiveIO::isPositiveInteger($this->_templateID)) {
             $this->raiseError("id is not a positive integer");
             return;
         }
         $this->_rows = array();
         $table = $this->_getDataTableName($location, $public);
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\t" . $table . "\n\t\t\t\twhere\n\t\t\t\t\ttemplate_cs='" . SensitiveIO::sanitizeSQLString($this->_templateID) . "'\n\t\t\t\t\tand tagID_cs='" . SensitiveIO::sanitizeSQLString($this->_tagID) . "'\n\t\t\t\t\tand type_cs != 0\n\t\t\t\torder by \n\t\t\t\t\torder_cs asc\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             while ($data = $q->getArray()) {
                 $this->_rows[$data['order_cs']] = new CMS_row($data["type_cs"], $data["rowsDefinition_cs"]);
             }
         }
     }
 }
Exemple #22
0
 /**
  * Get all form records datas
  * 
  * @param boolean $withDesactivedFields : add desactived fields to returned result (default : false)
  * @access public
  * @return multidimentionnal array
  */
 function getAllRecordDatas($withDesactivedFields = false, $withDate = false)
 {
     $sql = "\n\t\t\tselect\n\t\t\t\tfield_rec,\n\t\t\t\tvalue_rec,\n\t\t\t\tsending_rec";
     if ($withDate) {
         $sql .= ", dateInserted_snd";
     }
     $sql .= "\n\t\t\tfrom\n\t\t\t\tmod_cms_forms_fields,\n\t\t\t\tmod_cms_forms_records";
     if ($withDate) {
         $sql .= ", mod_cms_forms_senders";
     }
     $sql .= "\n\t\t\twhere\n\t\t\t\tform_fld = '" . $this->getID() . "'\n\t\t\t\tand id_fld = field_rec\n\t\t\t\tand type_fld != 'submit'\n\t\t\t";
     if ($withDate) {
         $sql .= " and id_snd = sending_rec";
     }
     if (!$withDesactivedFields) {
         $sql .= " and active_fld = '1' ";
     }
     $sql .= "\n\t\t\torder by\n\t\t\t\tsending_rec,\n\t\t\t\torder_fld\n\t\t";
     $q = new CMS_query($sql);
     $result = array();
     while ($r = $q->getArray()) {
         if ($withDate) {
             $result[$r['sending_rec']][0] = $r['dateInserted_snd'];
         }
         $result[$r['sending_rec']][$r['field_rec']] = $r['value_rec'];
     }
     return $result;
 }
Exemple #23
0
 /**
  * Check that the base data is loaded (edited base data can't be loaded from DELETED or ARCHIVED locations)
  *
  * @param boolean $public Is it the public or edited base data we want ?
  * @return boolean true on success, false on failure (because users can't edit the data)
  * @access private
  */
 protected function _checkBaseData($public = false)
 {
     $var = $public ? "_publicBaseData" : "_editedBaseData";
     if (!$this->{$var}) {
         //can't have edited base data when page is in DELETED or ARCHIVED locations
         if (!$public && ($this->_status->getLocation() == RESOURCE_LOCATION_ARCHIVED || $this->_status->getLocation() == RESOURCE_LOCATION_DELETED)) {
             //$this->raiseError('Page '.$this->getID().' : Can\'t get edited base data from DELETED or ARCHIVED locations');
             return false;
         }
         $this->{$var} = array();
         $this->{$var}["title"] = '';
         $this->{$var}["linkTitle"] = '';
         $this->{$var}["keywords"] = '';
         $this->{$var}["description"] = '';
         $this->{$var}["reminderPeriodicity"] = '';
         $this->{$var}["reminderOnMessage"] = '';
         $this->{$var}["category"] = '';
         $this->{$var}["author"] = '';
         $this->{$var}["replyto"] = '';
         $this->{$var}["copyright"] = '';
         $this->{$var}["language"] = '';
         $this->{$var}["robots"] = '';
         $this->{$var}["pragma"] = '';
         $this->{$var}["refresh"] = '';
         $this->{$var}["refreshUrl"] = '';
         $this->{$var}["metas"] = '';
         $this->{$var}["codename"] = '';
         $this->{$var}["reminderOn"] = new CMS_date();
         $this->{$var}["redirect"] = new CMS_href();
         switch ($this->_status->getLocation()) {
             case RESOURCE_LOCATION_ARCHIVED:
                 $table = "pagesBaseData_archived";
                 break;
             case RESOURCE_LOCATION_DELETED:
                 $table = "pagesBaseData_deleted";
                 break;
             case RESOURCE_LOCATION_USERSPACE:
             default:
                 $table = $public ? "pagesBaseData_public" : "pagesBaseData_edited";
                 break;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\t" . $table . "\n\t\t\t\twhere\n\t\t\t\t\tpage_pbd='" . $this->_pageID . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_baseDataID = $data["id_pbd"];
             $this->{$var}["title"] = $data["title_pbd"];
             $this->{$var}["linkTitle"] = $data["linkTitle_pbd"];
             $this->{$var}["keywords"] = $data["keywords_pbd"];
             $this->{$var}["description"] = $data["description_pbd"];
             $this->{$var}["reminderPeriodicity"] = $data["reminderPeriodicity_pbd"];
             $this->{$var}["reminderOn"]->setFromDBValue($data["reminderOn_pbd"]);
             $this->{$var}["reminderOnMessage"] = $data["reminderOnMessage_pbd"];
             $this->{$var}["category"] = $data["category_pbd"];
             $this->{$var}["author"] = $data["author_pbd"];
             $this->{$var}["replyto"] = $data["replyto_pbd"];
             $this->{$var}["copyright"] = $data["copyright_pbd"];
             $this->{$var}["language"] = $data["language_pbd"];
             $this->{$var}["robots"] = $data["robots_pbd"];
             $this->{$var}["pragma"] = $data["pragma_pbd"];
             $this->{$var}["refresh"] = $data["refresh_pbd"];
             $this->{$var}["refreshUrl"] = $data["refreshUrl_pbd"];
             $this->{$var}["metas"] = $data["metas_pbd"];
             $this->{$var}["redirect"] = new CMS_href($data["redirect_pbd"]);
             $this->{$var}["codename"] = $data["codename_pbd"];
         }
     }
     return true;
 }
Exemple #24
0
 /**
  * Constructor.
  *
  * @param integer $id the DB ID of the row
  * @param string $tagID the XML Tag ID of the row (if instansiated from the tag)
  * @return void
  * @access public
  */
 function __construct($id = 0, $tagID = false)
 {
     $this->_tagID = $tagID;
     $this->_modules = new CMS_stack();
     $this->_groups = new CMS_stack();
     if ($id) {
         if (!SensitiveIO::isPositiveInteger($id)) {
             $this->raiseError("Id is not a positive integer");
             return;
         }
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_standard_rows\n\t\t\t\twhere\n\t\t\t\t\tid_row='{$id}'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $data = $q->getArray();
             $this->_id = $id;
             $this->_label = $data["label_row"];
             $this->_groups->setTextDefinition($data["groupsStack_row"]);
             $this->_definitionFile = $data["definitionFile_row"];
             $this->_modules->setTextDefinition($data["modulesStack_row"]);
             $this->_image = $data["image_row"] ? $data["image_row"] : $this->_image;
             $this->_useable = $data["useable_row"] ? true : false;
             $this->_description = $data["description_row"];
             $this->_tplfilter = trim($data["tplfilter_row"]) ? explode(';', $data["tplfilter_row"]) : array();
             $this->_uuid = $data["uuid_row"];
         } else {
             $this->raiseError("Unknown id :" . $id);
         }
     }
 }
Exemple #25
0
 /**
  * Constructor.
  * initializes the module if the codename is given
  *
  * @param string $codename The module codename
  * @return void
  * @access public
  */
 function CMS_module($datas = '')
 {
     static $modules;
     if (is_string($datas)) {
         $codename = $datas;
         if ($codename) {
             if (isset($modules[$codename])) {
                 $this->_id = $modules[$codename]->_id;
                 $this->_labelMessageID = $modules[$codename]->_labelMessageID;
                 $this->_codename = $modules[$codename]->_codename;
                 $this->_administrationFrontend = $modules[$codename]->_administrationFrontend;
                 $this->_hasParameters = $modules[$codename]->_hasParameters;
                 $this->_isPolymod = $modules[$codename]->_isPolymod;
             } else {
                 $sql = "\n\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t*\n\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\tmodules\n\t\t\t\t\t\twhere\n\t\t\t\t\t\t\tcodename_mod='" . SensitiveIO::sanitizeSQLString($codename) . "'\n\t\t\t\t\t";
                 $q = new CMS_query($sql);
                 if ($q->getNumRows()) {
                     $data = $q->getArray();
                     $this->_id = $data["id_mod"];
                     $this->_labelMessageID = $data["label_mod"];
                     $this->_codename = $data["codename_mod"];
                     $this->_administrationFrontend = $data["administrationFrontend_mod"];
                     $this->_hasParameters = $data["hasParameters_mod"];
                     $this->_isPolymod = $data["isPolymod_mod"];
                     $modules[$codename] = $this;
                 } else {
                     $this->raiseError("Unknown codename : " . SensitiveIO::sanitizeAsciiString($codename));
                 }
             }
         }
     } else {
         if (is_array($datas)) {
             $codename = $datas["codename_mod"];
             $this->_id = $datas["id_mod"];
             $this->_labelMessageID = $datas["label_mod"];
             $this->_codename = $datas["codename_mod"];
             $this->_administrationFrontend = $datas["administrationFrontend_mod"];
             $this->_hasParameters = $datas["hasParameters_mod"];
             $this->_isPolymod = $datas["isPolymod_mod"];
             $modules[$codename] = $this;
         } else {
             parent::raiseError("Unknown datas type : " . gettype($datas));
             return false;
         }
     }
 }
Exemple #26
0
 /**
  * Proceed to serach and returns the array of results, null if none 
  * found. All search options had been set yet.
  * 
  * @access public
  * @return array(CMS_resources_cms_news)
  */
 function search()
 {
     $items = array();
     if (!$this->_sql) {
         $this->_buildSQL();
     }
     $sql = str_replace('{{select}}', implode($this->_select, ','), $this->_sql);
     if ($this->_itemsPerPage > 0) {
         $sql .= "\n\t\t\tlimit\n\t\t\t\t" . $this->_page * $this->_itemsPerPage . ", " . $this->_itemsPerPage . "";
     }
     $q = new CMS_query($sql);
     if (!$q->getNumRows()) {
         return $items;
     }
     while ($data = $q->getArray()) {
         $obj = CMS_module_cms_forms::getResourceByID($data[0]);
         if (!$obj->hasError()) {
             $items[] = $obj;
         }
     }
     return $items;
 }
Exemple #27
0
 /**
  * Gets the data in array mode.
  *
  * @param integer $pageID The page DB ID which contains the client space
  * @param integer $clientSpaceID The client space DB ID which contains the row
  * @param integer $rowID The row DB ID which contains the block
  * @param integer $location The location of the page
  * @param boolean $public The needed precision for USERSPACE location
  * @return array(mixed=>mixed) The data indexed by data type (value, file, alt_tag, ...), or false on failure (table not found)
  * @access public
  */
 function getRawData($pageID, $clientSpaceID, $rowID, $location, $public)
 {
     parent::getRawData($pageID, $clientSpaceID, $rowID, $location, $public);
     $table = $this->_getDataTableName($location, $public);
     if (!$table) {
         $this->raiseError("Unknown table");
         return false;
     }
     $sql = "\n\t\t\tselect\n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\t" . $table . "\n\t\t\twhere\n\t\t\t\tpage='" . $pageID . "'\n\t\t\t\tand clientSpaceID='" . $clientSpaceID . "'\n\t\t\t\tand rowID='" . $rowID . "'\n\t\t\t\tand blockID='" . $this->_tagID . "'\n\t\t";
     $q = new CMS_query($sql);
     if (!$q->hasError()) {
         if ($q->getNumRows()) {
             return $q->getArray();
         } else {
             return array("file" => "", "enlargedFile" => "", "label" => "", "externalLink" => "");
         }
     } else {
         return false;
     }
 }
 /**
  * Run queued scripts.
  * This method is used when background scripts are not used.
  * It process a number of scripts defined by REGENERATION_THREADS constant
  *
  * @return void
  * @access public
  * @static
  */
 static function runQueuedScripts()
 {
     //the sql which selects scripts to regenerate at a time
     $sql_select = "\n\t\t\tselect\n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\tregenerator\n\t\t\tlimit\n\t\t\t\t" . sensitiveIO::sanitizeSQLString(REGENERATION_THREADS) . "\n\t\t";
     $q = new CMS_query($sql_select);
     $modules = array();
     while ($data = $q->getArray()) {
         //instanciate script module
         if (!isset($modules[$data['module_reg']])) {
             $modules[$data['module_reg']] = CMS_modulesCatalog::getByCodename($data['module_reg']);
         }
         //then send script task to module (return task title by reference)
         $task = $modules[$data['module_reg']]->scriptTask(unserialize($data['parameters_reg']));
         //delete the current script task
         $sql_delete = "\n\t\t\t\tdelete\n\t\t\t\tfrom\n\t\t\t\t\tregenerator\n\t\t\t\twhere\n\t\t\t\t\tid_reg='" . $data['id_reg'] . "'";
         $q_delete = new CMS_query($sql_delete);
     }
 }
 /**
  * Gets a validation for a given item
  *
  * @param integer $itemID The item we want the validations for
  * @param CMS_user $user The user we want the validations for
  * @param integer $getEditionType The validation type we want.
  *  by default function return RESOURCE_EDITION_LOCATION then RESOURCE_EDITION_CONTENT then RESOURCE_EDITION_SIBLINGSORDER
  * @return array(CMS_resourceValidation) The resourceValidations objects, false if none found for the given user.
  * @access public
  */
 function getValidationByID($itemID, &$user, $getEditionType = false)
 {
     if (!$user instanceof CMS_profile_user) {
         $this->raiseError("User is not a valid CMS_profile_user object");
         return false;
     }
     if (!$user->hasValidationClearance($this->_codename)) {
         return false;
     }
     if (CMS_poly_object_catalog::hasPrimaryResource($this->getCodename())) {
         //get object type ID
         $objectID = CMS_poly_object_catalog::getPrimaryResourceObjectType($this->getCodename());
         //get viewvable objects list for current user
         if (CMS_poly_object_catalog::objectHasCategories($objectID)) {
             $objects = CMS_poly_object_catalog::getAllObjects($objectID, false, array(), false);
             //$where = (is_array($objects) && $objects) ? ' and objectID in ('.implode(',',$objects).')' : '';
             if (is_array($objects) && $objects) {
                 $where = ' and objectID in (' . implode(',', $objects) . ')';
             } else {
                 return false;
             }
         } else {
             $where = '';
         }
         $this->getPrimaryResourceDefinition();
         if (!$getEditionType) {
             $getEditionType = RESOURCE_EDITION_LOCATION + RESOURCE_EDITION_CONTENT;
         }
         $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\tobjectID as id,\n\t\t\t\t\t\tlocation_rs as location,\n\t\t\t\t\t\tproposedFor_rs as proposedFor,\n\t\t\t\t\t\tvalidationsRefused_rs as validationsRefused,\n\t\t\t\t\t\teditions_rs as editions,\n\t\t\t\t\t\tmod_subobject_integer_edited.id as fieldID\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_subobject_integer_edited,\n\t\t\t\t\t\tmod_object_polyobjects,\n\t\t\t\t\t\tresources,\n\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectID = '" . $itemID . "'\n\t\t\t\t\t\tand value = id_res\n\t\t\t\t\t\tand object_type_id_moo = '" . $objectID . "'\n\t\t\t\t\t\tand id_moo = objectID\n\t\t\t\t\t\tand objectFieldID = 0\n\t\t\t\t\t\tand objectSubFieldID = 0\n\t\t\t\t\t\tand status_res = id_rs\n\t\t\t\t\t\t{$where}\n\t\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows() >= 1) {
             $r = $q->getArray();
             $id = $r["id"];
             //here, this is an ugly hack to resolve a strange bug (multiple resources for an unique object).
             //not time to found the real cause for now ...
             if ($q->getNumRows() > 1) {
                 while ($exceptionFiledID = $q->getValue('fieldID')) {
                     $sql_delete = "delete from mod_subobject_integer_edited where id = '" . $exceptionFiledID . "'";
                     $q_delete = new CMS_query($sql_delete);
                 }
             }
             //search the type of edition
             //RESOURCE_EDITION_LOCATION
             if ($r["location"] == RESOURCE_LOCATION_USERSPACE && $r["proposedFor"] != 0 && !($r["validationsRefused"] & RESOURCE_EDITION_LOCATION) && $getEditionType & RESOURCE_EDITION_LOCATION) {
                 $language = $user->getLanguage();
                 $item = $this->getResourceByID($id);
                 $validation = new CMS_resourceValidation($this->_codename, RESOURCE_EDITION_LOCATION, $item);
                 if (!$validation->hasError()) {
                     $validation->setValidationTypeLabel($language->getMessage(self::MESSAGE_MOD_POLYMOD_VALIDATION_LOCATIONCHANGE, array($this->_primaryResourceObjectDefinition->getLabel($language)), MOD_POLYMOD_CODENAME));
                     $validation->setValidationLabel($language->getMessage(self::MESSAGE_MOD_POLYMOD_VALIDATION_LOCATIONCHANGE_OFRESOURCE, array($this->_primaryResourceObjectDefinition->getLabel($language)), MOD_POLYMOD_CODENAME) . " " . io::decodeEntities($item->{$this->_resourceNameMethod}()));
                     $validation->setValidationShortLabel(io::decodeEntities($item->{$this->_resourceNameMethod}()));
                     $previzURL = $item->getPrevizPageURL();
                     if ($previzURL) {
                         $validation->addHelpUrl($language->getMessage(self::MESSAGE_PAGE_ACTION_PREVIZ), $previzURL);
                     }
                     $validation->setEditorsStack($item->getEditorsStack());
                     return $validation;
                 } else {
                     return false;
                 }
                 //RESOURCE_EDITION_CONTENT
             } elseif ($r["location"] == RESOURCE_LOCATION_USERSPACE && $r["proposedFor"] == 0 && ($r["editions"] & RESOURCE_EDITION_CONTENT && !($r["validationsRefused"] & RESOURCE_EDITION_CONTENT)) && $getEditionType & RESOURCE_EDITION_CONTENT) {
                 $language = $user->getLanguage();
                 $editions = $r["editions"];
                 //RESOURCE_EDITION_CONTENT
                 $item = $this->getResourceByID($id);
                 $validation = new CMS_resourceValidation($this->_codename, $editions, $item);
                 if (!$validation->hasError()) {
                     $validation->setValidationTypeLabel($language->getMessage(self::MESSAGE_MOD_POLYMOD_VALIDATION_EDITION, array($this->_primaryResourceObjectDefinition->getLabel($language)), MOD_POLYMOD_CODENAME));
                     $validation->setValidationLabel($language->getMessage(self::MESSAGE_MOD_POLYMOD_VALIDATION_EDITION_OFRESOURCE, array($this->_primaryResourceObjectDefinition->getLabel($language)), MOD_POLYMOD_CODENAME) . " " . io::decodeEntities($item->{$this->_resourceNameMethod}()));
                     $validation->setValidationShortLabel(io::decodeEntities($item->{$this->_resourceNameMethod}()));
                     $previzURL = $item->getPrevizPageURL();
                     if ($previzURL) {
                         $validation->addHelpUrl($language->getMessage(self::MESSAGE_PAGE_ACTION_PREVIZ), $previzURL);
                     }
                     $validation->setEditorsStack($item->getEditorsStack());
                     return $validation;
                 } else {
                     return false;
                 }
             }
         } elseif ($q->getNumRows() == 0) {
             return false;
         } else {
             $this->raiseError("Can't have more than one item for a given ID");
             return false;
         }
     } else {
         return false;
     }
 }
Exemple #30
0
 /**
  * Get all the aliases for a given name
  *
  * @param string $name The name to get aliases of
  * @param boolean $returnObject function return array of id or array of CMS_resource_cms_aliases (default)
  * @return array
  * @access public
  * @static
  */
 static function getByName($name, $returnObject = true)
 {
     if (!$name || $name != sensitiveIO::sanitizeAsciiString($name, '@')) {
         return array();
     }
     $sql = "\n\t\t\tselect\n\t\t\t\tid_ma\n\t\t\tfrom\n\t\t\t\tmod_cms_aliases\n\t\t\twhere \n\t\t\t\talias_ma='" . io::sanitizeSQLString($name) . "'\n\t\t\torder by id_ma asc";
     $q = new CMS_query($sql);
     $result = array();
     while ($arr = $q->getArray()) {
         if ($returnObject) {
             $alias = CMS_module_cms_aliases::getByID($arr["id_ma"]);
             if ($alias && !$alias->hasError()) {
                 $result[$arr["id_ma"]] = $alias;
             }
         } else {
             $result[$arr["id_ma"]] = $arr["id_ma"];
         }
     }
     return $result;
 }