예제 #1
0
 /**
  * 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;
 }
예제 #2
0
    /**
     * Get array of contacts data by Email
     *
     * @param string $data
     * @return array of CMS_profile_user
     * @access public
     */
    static function getByEmail($data)
    {
        if (!SensitiveIO::isValidEmail($data)) {
            CMS_grandFather::raiseError('$data must be a valid email : ' . $data);
            return array();
        }
        $aUsers = array();
        //create the request to look for the data
        $sql = 'select `id_cd` 
			from `contactDatas`
			where `email_cd` = "' . sensitiveIO::sanitizeSQLString($data) . '"';
        //launching the request
        $q = new CMS_query($sql);
        //checking if ok and looping on results
        if (!$q->hasError()) {
            while (($oTmpUserId = $q->getValue("id_cd")) !== false) {
                //creating the user and filling the data
                $oTmpUser = CMS_profile_usersCatalog::getByID($oTmpUserId);
                if (!$oTmpUser->hasError()) {
                    $oTmpUser->getContactData();
                    if (!$oTmpUser->hasError()) {
                        $aUsers[] = $oTmpUser;
                    }
                }
            }
            unset($oTmpUser, $oTmpUserId);
        }
        return $aUsers;
    }
 public static function countByCodename($codename, $id = null)
 {
     $sql = 'SELECT count(*) as count from mod_object_oembed_definition where codename_mood = "' . io::sanitizeSQLString($codename) . '"';
     if ($id) {
         $sql .= ' AND id_mood <> ' . $id;
     }
     $query = new CMS_query($sql);
     $data = array_pop($query->getAll());
     return (int) $data['count'];
 }
 /**
  * Returns a resourceValidation object instance from a DB id or from GetValidationByID function if exists.
  * Static function.
  *
  * @param integer $id the id of the saved object
  * @return resourceValidation the instance unserialized, false if not found.
  * @access public
  */
 static function getValidationInstance($id, $user = false)
 {
     if (!SensitiveIO::isPositiveInteger($id) && base64_decode($id) && $user) {
         //load validation form encoded ID (new validations system)
         $decodedID = explode('||', base64_decode($id));
         $module = CMS_modulesCatalog::getByCodename($decodedID[0]);
         $editions = $decodedID[1];
         $resourceID = $decodedID[2];
         if (isset($module) && isset($editions) && isset($resourceID)) {
             return $module->getValidationByID($resourceID, $user, $editions);
         }
     }
     $sql = "\n\t\t\tselect\n\t\t\t\tserializedObject_rv as data\n\t\t\tfrom\n\t\t\t\tresourceValidations\n\t\t\twhere\n\t\t\t\tid_rv='" . $id . "'\n\t\t";
     $q = new CMS_query($sql);
     if ($q->getNumRows()) {
         $instance = unserialize(stripslashes($q->getValue("data")));
         $instance->setID($id);
         return $instance;
     } else {
         parent::raiseError("Unknown id : " . $id);
         return false;
     }
 }
 /**
  * Returns the action for the given user on this icr / datastrip
  * @param integer $uid        the user id
  * @param string $icr         the ICR identifier
  * @param string $datastripId the datastrip identifier
  * @return mixed              the action or NULL
  */
 public static function getData($campaignId)
 {
     $sql = 'SELECT data from mod_mailjet where campaignId = ' . $campaignId . ';';
     $query = new CMS_query($sql);
     $res = $query->getAll();
     if (isset($res[0])) {
         return json_decode($res[0]['data'], true);
     }
     return null;
 }
예제 #6
0
 /**
  * Return options tag list (for a select tag) of all float values for this field
  *
  * @param array $values : parameters values array(parameterName => parameterValue) in :
  *     selected : the float value which is selected (optional)
  * @param multidimentionnal array $tags : xml2Array content of atm-function tag (nothing for this one)
  * @return string : options tag list
  * @access public
  */
 function selectOptions($values, $tags)
 {
     $return = "";
     $fieldID = $this->_field->getID();
     $allValues = array();
     $status = $this->_public ? 'public' : 'edited';
     // Search all values for this field
     $sql = "select\n                   distinct value\n               from\n                   mod_subobject_string_" . $status . "\n               where\n                   objectFieldID='" . $fieldID . "'\n\t\t";
     $q = new CMS_query($sql);
     while (($value = $q->getValue('value')) !== false) {
         if ($value) {
             $allValues[$value] = $value;
         }
     }
     if (is_array($allValues) && $allValues) {
         natsort($allValues);
         foreach ($allValues as $id => $label) {
             $selected = $id == $values['selected'] ? ' selected="selected"' : '';
             $return .= '<option title="' . io::htmlspecialchars($label) . '" value="' . $id . '"' . $selected . '>' . $label . '</option>';
         }
     }
     return $return;
 }
예제 #7
0
$installed = false;
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) {
 /**
  * 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;
 }
예제 #9
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;
 }
예제 #10
0
 /**
  * Duplicate this block
  * Used to duplicate a CMS_page.
  *
  * @param CMS_page $destinationPage, the page receiving a copy of this block
  * @param boolean $public The precision needed for USERSPACE location
  * @return CMS_block object
  */
 function duplicate(&$destinationPage, $public = false)
 {
     if (SensitiveIO::isPositiveInteger($this->_dbID)) {
         $table = $this->_getDataTableName(RESOURCE_LOCATION_USERSPACE, $public);
         $str_set = "\n\t\t\t\t\tpage='" . $destinationPage->getID() . "',\n\t\t\t\t\tclientSpaceID='" . $this->_clientSpaceID . "',\n\t\t\t\t\trowID='" . $this->_rowID . "',\n\t\t\t\t\tblockID='" . $this->_tagID . "',\n\t\t\t\t\ttype='CMS_block_cms_forms',\n\t\t\t\t\tvalue='" . SensitiveIO::sanitizeSQLString(serialize($this->_value)) . "'\n\t\t\t";
         $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\t" . $table . "\n\t\t\t\tset\n\t\t\t\t\t" . $str_set . "\n\t\t\t";
         $q = new CMS_query($sql);
         if (!$q->hasError()) {
             //Table Edition
             $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\t" . $this->_getDataTableName(RESOURCE_LOCATION_EDITION, false) . "\n\t\t\t\t\tset\n\t\t\t\t\t\tid='" . $id . "',\n\t\t\t\t\t\t" . $str_set . "\n\t\t\t\t";
             $q = new CMS_query($sql);
             return !$q->hasError();
         } else {
             $this->raiseError("Duplicate, insertion failed: " . $sql);
         }
     } else {
         $this->raiseError("Duplicate, object does not have a DB ID, not initialized");
     }
     return false;
 }
예제 #11
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;
                 }
             }
         }
     }
 }
예제 #12
0
 /**
  * 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;
 }
예제 #13
0
 /**
  * Return an echapped input to use into an SQL query
  *
  * @param string $input The string to echap
  * @return string echapped query
  * @access public
  */
 static function echap($input)
 {
     try {
         $db = is_array(self::$_connection) ? current(self::$_connection) : new PDO(APPLICATION_DB_DSN, APPLICATION_DB_USER, APPLICATION_DB_PASSWORD, array(PDO::ATTR_PERSISTENT => APPLICATION_DB_PERSISTENT_CONNNECTION, PDO::ERRMODE_EXCEPTION => true, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
     } catch (PDOException $e) {
         CMS_query::raiseError($e->getMessage());
         exit;
     }
     return io::substr($db->quote($input), 1, -1);
 }
 /**
  * Writes these clearances into persistence (MySQL for now).
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function writeToPersistence()
 {
     if ($this->_profileID && is_a($this->_categoriesClearances, "CMS_stack")) {
         $err = 0;
         // Delete old clearances
         $sql = "\n\t\t\t\tdelete\n\t\t\t\tfrom\n\t\t\t\t\tmodulesCategories_clearances\n\t\t\t\twhere\n\t\t\t\t\tprofile_mcc='" . $this->_profileID . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->hasError()) {
             $err++;
             $this->raiseError("Error on sql statement : " . var_dump($sql));
         }
         // Insert new ones
         $elements = $this->_categoriesClearances->getElements();
         if (is_array($elements) && $elements) {
             $values = '';
             foreach ($elements as $v) {
                 $values .= $values ? ',' : '';
                 $values .= "('" . $this->_profileID . "', '" . $v[0] . "', '" . $v[1] . "')";
             }
             $sql = "\n\t\t\t\t\tinsert into modulesCategories_clearances\n\t\t\t\t\t\t(profile_mcc, category_mcc, clearance_mcc)\n\t\t\t\t\tvalues " . $values . "\n\t\t\t\t";
             $q = new CMS_query($sql);
             if ($q->hasError()) {
                 $err++;
                 $this->raiseError("Error on sql statement : " . var_dump($sql));
             }
         }
         return !$err ? true : false;
     }
 }
예제 #15
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;
 }
예제 #16
0
 /**
  * Writes the clientSpace into persistence (MySQL for now).
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function writeToPersistence()
 {
     if ($this->_templateID && $this->_tagID) {
         $table = "mod_standard_clientSpaces";
         $table .= $this->_editionMode ? "_edition" : "_edited";
         //delete from table
         $sql = "\n\t\t\t\tdelete from\n\t\t\t\t\t" . $table . "\n\t\t\t\twhere\n\t\t\t\t\ttemplate_cs='" . $this->_templateID . "'\n\t\t\t\t\tand tagID_cs='" . SensitiveIO::sanitizeSQLString($this->_tagID) . "'\n\t\t\t";
         $q = new CMS_query($sql);
         //insert new rows datas if any
         if (is_array($this->_rows) && $this->_rows) {
             $sql = "insert into\n\t\t\t\t\t\t\t" . $table . "\n\t\t\t\t\t\t\t(`template_cs`, `tagID_cs`, `rowsDefinition_cs`, `type_cs`, `order_cs`) \n\t\t\t\t\t\tVALUES ";
             $count = 0;
             foreach ($this->_rows as $order => $row) {
                 if (SensitiveIO::isPositiveInteger($row->getID())) {
                     $sql .= $count ? ',' : '';
                     $sql .= "('" . $this->_templateID . "', '" . SensitiveIO::sanitizeSQLString($this->_tagID) . "', '" . SensitiveIO::sanitizeSQLString($row->getTagID()) . "', '" . $row->getID() . "', '" . $order . "')";
                     $count++;
                 }
             }
             $q = new CMS_query($sql);
             if ($q->hasError()) {
                 return false;
             }
         }
         return true;
     }
     return false;
 }
예제 #17
0
파일: log.php 프로젝트: davidmottet/automne
 /**
  * Write to persistence
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function writeToPersistence()
 {
     $sql_fields = "\n\t\t\t\tuser_log='" . SensitiveIO::sanitizeSQLString($this->_user->getUserId()) . "',\n\t\t\t\taction_log='" . SensitiveIO::sanitizeSQLString($this->_action) . "',\n\t\t\t\tdatetime_log='" . SensitiveIO::sanitizeSQLString($this->_datetime->getDBValue()) . "',\n\t\t\t\ttextData_log='" . SensitiveIO::sanitizeSQLString($this->_textData) . "',\n\t\t\t\tlabel_log='" . SensitiveIO::sanitizeSQLString($this->_label) . "',\n\t\t\t\tmodule_log='" . SensitiveIO::sanitizeSQLString($this->_module) . "',\n\t\t\t\tresource_log='" . SensitiveIO::sanitizeSQLString($this->_resource) . "',\n\t\t\t\trsAfterLocation_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getLocation()) . "',\n\t\t\t\trsAfterProposedFor_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getProposedFor()) . "',\n\t\t\t\trsAfterEditions_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getEditions()) . "',\n\t\t\t\trsAfterValidationsRefused_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getValidationRefused()) . "',\n\t\t\t\trsAfterPublication_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getPublication()) . "'\t\n\t\t\t";
     if ($this->_id) {
         $sql = "\n\t\t\t\t\tupdate\n\t\t\t\t\t\tlog\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $sql_fields . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_log='" . $this->_id . "'\n\t\t\t\t";
     } else {
         $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\tlog\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $sql_fields;
     }
     $q = new CMS_query($sql);
     if ($q->hasError()) {
         return false;
     } else {
         $this->_id = $q->getLastInsertedID();
     }
     return true;
 }
예제 #18
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;
 }
예제 #19
0
 /**
  * Get all form fields
  * 
  * @param integer $formID : the form id for wanted fields
  * @param boolean $outputobjects : return array of CMS_forms_field instead of array of ids (default : false)
  * @param boolean $withDesactivedFields : add desactived fields to returned list (default : false)
  * @access public
  * @return array of CMS_forms_field
  */
 function getAll($formID, $outputobjects = false, $withDesactivedFields = false)
 {
     if (!sensitiveIO::isPositiveInteger($formID)) {
         $this->raiseError("FormID must be a positive integer : " . $formID);
         return false;
     }
     $sql = "\n\t\t\tselect\n\t\t\t\tid_fld as id\n\t\t\tfrom\n\t\t\t\tmod_cms_forms_fields\n\t\t\twhere\n\t\t\t\tform_fld='" . $formID . "'\n\t\t";
     if (!$withDesactivedFields) {
         $sql .= " and active_fld = '1'";
     }
     $sql .= " order by order_fld asc";
     $q = new CMS_query($sql);
     $return = array();
     while ($id = $q->getValue('id')) {
         if ($outputobjects) {
             $return[$id] = new CMS_forms_field($id);
         } else {
             $return[$id] = $id;
         }
     }
     return $return;
 }
예제 #20
0
 /**
  * Writes the template into persistence (MySQL for now).
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function writeToPersistence()
 {
     $sql_fields = "\n\t\t\tlabel_pt='" . SensitiveIO::sanitizeSQLString($this->_label) . "',\n\t\t\timage_pt='" . SensitiveIO::sanitizeSQLString($this->_image) . "',\n\t\t\tdefinitionFile_pt='" . SensitiveIO::sanitizeSQLString($this->_definitionFile) . "',\n\t\t\tgroupsStack_pt='" . SensitiveIO::sanitizeSQLString($this->_groups->getTextDefinition()) . "',\n\t\t\tmodulesStack_pt='" . SensitiveIO::sanitizeSQLString($this->_modules->getTextDefinition()) . "',\n\t\t\tinUse_pt='" . $this->_useable . "',\n\t\t\tdescription_pt='" . SensitiveIO::sanitizeSQLString($this->_description) . "',\n\t\t\twebsitesdenied_pt='" . SensitiveIO::sanitizeSQLString($this->_websitesdenied->getTextDefinition()) . "',\n\t\t\tprivate_pt='" . $this->_private . "',\n\t\t\tprintingCSOrder_pt='" . SensitiveIO::sanitizeSQLString(implode(";", $this->_printingClientSpaces)) . "'\n\t\t";
     if ($this->_id) {
         // Some changes must be applied
         // to all private templates similar to this one using same xml file
         if ($this->_definitionFile) {
             $sql = "\n\t\t\t\t\tupdate\n\t\t\t\t\t\tpageTemplates\n\t\t\t\t\tset\n\t\t\t\t\t\tlabel_pt='" . SensitiveIO::sanitizeSQLString($this->_label) . "',\n\t\t\t\t\t\timage_pt='" . SensitiveIO::sanitizeSQLString($this->_image) . "',\n\t\t\t\t\t\tgroupsStack_pt='" . SensitiveIO::sanitizeSQLString($this->_groups->getTextDefinition()) . "',\n\t\t\t\t\t\tmodulesStack_pt='" . SensitiveIO::sanitizeSQLString($this->_modules->getTextDefinition()) . "',\n\t\t\t\t\t\tprintingCSOrder_pt='" . SensitiveIO::sanitizeSQLString(implode(";", $this->_printingClientSpaces)) . "'\n\t\t\t\t\twhere\n\t\t\t\t\t\tdefinitionFile_pt like '" . SensitiveIO::sanitizeSQLString($this->_definitionFile) . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
         }
         $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tpageTemplates\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_pt='" . $this->_id . "'\n\t\t\t";
     } else {
         $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tpageTemplates\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields;
     }
     $q = new CMS_query($sql);
     //pr($sql);
     if ($q->hasError()) {
         return false;
     } elseif (!$this->_id) {
         $this->_id = $q->getLastInsertedID();
     }
     return true;
 }
예제 #21
0
 /**
  * Writes the module into persistence (MySQL for now).
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function writeToPersistence()
 {
     $sql_fields = "\n\t\t\tlabel_mod='" . SensitiveIO::sanitizeSQLString($this->_labelMessageID) . "',\n\t\t\tcodename_mod='" . SensitiveIO::sanitizeSQLString($this->_codename) . "',\n\t\t\tadministrationFrontend_mod='" . SensitiveIO::sanitizeSQLString($this->_administrationFrontend) . "',\n\t\t\thasParameters_mod='" . SensitiveIO::sanitizeSQLString($this->_hasParameters) . "',\n\t\t\tisPolymod_mod='" . SensitiveIO::sanitizeSQLString($this->_isPolymod) . "'\n\t\t";
     if ($this->_id) {
         $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tmodules\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_mod='" . $this->_id . "'\n\t\t\t";
     } else {
         $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tmodules\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields;
     }
     $q = new CMS_query($sql);
     if ($q->hasError()) {
         return false;
     } elseif (!$this->_id) {
         $this->_id = $q->getLastInsertedID();
     }
     //create module files for module
     $this->createModuleFiles();
     return true;
 }
예제 #22
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;
 }
예제 #23
0
 /**
  * Writes the page into persistence (MySQL for now), along with base data.
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function writeToPersistence()
 {
     parent::writeToPersistence();
     $isNew = $this->_pageID === NULL;
     // Inform modules of the page creation
     $modules = CMS_modulesCatalog::getAll('id');
     foreach ($modules as $codename => $module) {
         if (method_exists($module, 'pagePreSave')) {
             $module->pagePreSave($this, $isNew);
         }
     }
     //save page data
     $sql_fields = "\n\t\t\tresource_pag='" . parent::getID() . "',\n\t\t\tremindedEditorsStack_pag='" . SensitiveIO::sanitizeSQLString($this->_remindedEditors->getTextDefinition()) . "',\n\t\t\tlastReminder_pag='" . $this->_lastReminder->getDBValue() . "',\n\t\t\ttemplate_pag='" . $this->_templateID . "',\n\t\t\tlastFileCreation_pag='" . $this->_lastFileCreation->getDBValue() . "',\n\t\t\turl_pag='" . SensitiveIO::sanitizeSQLString($this->_pageURL) . "',\n\t\t\tprotected_pag='" . ($this->_protected ? 1 : 0) . "',\n\t\t\thttps_pag='" . ($this->_https ? 1 : 0) . "'\n\t\t";
     if ($this->_pageID) {
         $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tpages\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_pag='" . $this->_pageID . "'\n\t\t\t";
     } else {
         $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tpages\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields;
     }
     $q = new CMS_query($sql);
     if ($q->hasError()) {
         return false;
     } elseif (!$this->_pageID) {
         $this->_pageID = $q->getLastInsertedID();
     }
     //save base data if modified
     if ($this->_editedBaseData) {
         $sql_fields = "\n\t\t\t\tpage_pbd='" . $this->_pageID . "',\n\t\t\t\ttitle_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["title"]) . "',\n\t\t\t\tlinkTitle_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["linkTitle"]) . "',\n\t\t\t\tkeywords_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["keywords"]) . "',\n\t\t\t\tdescription_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["description"]) . "',\n\t\t\t\treminderPeriodicity_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["reminderPeriodicity"]) . "',\n\t\t\t\treminderOn_pbd='" . $this->_editedBaseData["reminderOn"]->getDBValue() . "',\n\t\t\t\treminderOnMessage_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["reminderOnMessage"]) . "',\n\t\t\t\tcategory_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["category"]) . "',\n\t\t\t\tauthor_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["author"]) . "',\n\t\t\t\treplyto_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["replyto"]) . "',\n\t\t\t\tcopyright_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["copyright"]) . "',\n\t\t\t\tlanguage_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["language"]) . "',\n\t\t\t\trobots_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["robots"]) . "',\n\t\t\t\tpragma_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["pragma"]) . "',\n\t\t\t\trefresh_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["refresh"]) . "',\n\t\t\t\tredirect_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["redirect"]->getTextDefinition()) . "',\n\t\t\t\trefreshUrl_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["refreshUrl"]) . "',\n\t\t\t\tmetas_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["metas"]) . "',\n\t\t\t\tcodename_pbd='" . SensitiveIO::sanitizeSQLString($this->_editedBaseData["codename"]) . "'\n\t\t\t";
         if ($this->_baseDataID) {
             $sql = "\n\t\t\t\t\tupdate\n\t\t\t\t\t\tpagesBaseData_edited\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $sql_fields . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_pbd='" . $this->_baseDataID . "'\n\t\t\t\t";
         } else {
             $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\tpagesBaseData_edited\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $sql_fields;
         }
         $q = new CMS_query($sql);
         if (!$q->hasError() && !$this->_baseDataID) {
             $this->_baseDataID = $q->getLastInsertedID();
         }
     }
     // Inform modules of the page creation
     $modules = CMS_modulesCatalog::getAll('id');
     foreach ($modules as $codename => $module) {
         if (method_exists($module, 'pagePostSave')) {
             $module->pagePostSave($this, $isNew);
         }
     }
     return true;
 }
예제 #24
0
 /**
  * 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);
     }
 }
예제 #25
0
 /**
  * Writes the resource into persistence (MySQL for now).
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function writeToPersistence()
 {
     $this->_status->writeToPersistence();
     $sql_fields = "\n\t\t\tstatus_res='" . $this->_status->getID() . "',\n\t\t\teditorsStack_res='" . SensitiveIO::sanitizeSQLString($this->_editors->getTextDefinition()) . "'\n\t\t";
     if ($this->_id) {
         $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tresources\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_res='" . $this->_id . "'\n\t\t\t";
     } else {
         $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tresources\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields;
     }
     $q = new CMS_query($sql);
     if ($q->hasError()) {
         return false;
     } elseif (!$this->_id) {
         $this->_id = $q->getLastInsertedID();
     }
     return true;
 }
예제 #26
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;
 }
예제 #27
0
 /**
  * Duplicate this block
  * Used to duplicate a CMS_page.
  *
  * @param CMS_page $destinationPage, the page receiving a copy of this block
  * @param boolean $public The precision needed for USERSPACE location
  * @return CMS_block object
  */
 function duplicate(&$destinationPage, $public = false)
 {
     if (SensitiveIO::isPositiveInteger($this->_dbID) && $this->_file) {
         $table = $this->_getDataTableName(RESOURCE_LOCATION_USERSPACE, $public);
         //Copy linked file
         //In new file name, delete reference to old page and add refernce to new one
         $_newFilename = "p" . $destinationPage->getID() . io::substr($this->_file, io::strpos($this->_file, "_"), io::strlen($this->_file));
         if (@is_file(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_file) && @copy(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_file, PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newFilename) && @chmod(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newFilename, octdec(FILES_CHMOD))) {
             //Public
             if ($public) {
                 if (!@copy(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $this->_file, PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newFilename) || !@chmod(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newFilename, octdec(FILES_CHMOD))) {
                     $this->raiseError("Duplicate, copy of new file failed : " . PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newFilename);
                 }
             }
             $_newEnlargedFilename = '';
             //With enlarged file
             if ($this->_enlargedFile != '') {
                 $_newEnlargedFilename = "p" . $destinationPage->getID() . io::substr($this->_enlargedFile, io::strpos($this->_enlargedFile, "_"), io::strlen($this->_enlargedFile));
                 //Edited
                 if (!@copy(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_enlargedFile, PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newEnlargedFilename) || !@chmod(PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newEnlargedFilename, octdec(FILES_CHMOD))) {
                     $this->raiseError("Duplicate, copy of new enlarged file failed : " . PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $_newEnlargedFilename);
                 }
                 //Public
                 if ($public) {
                     if (!@copy(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $this->_enlargedFile, PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newEnlargedFilename) || !@chmod(PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newEnlargedFilename, octdec(FILES_CHMOD))) {
                         $this->raiseError("Duplicate, copy of new enlarged file failed : " . PATH_MODULES_FILES_STANDARD_FS . "/public/" . $_newEnlargedFilename);
                     }
                 }
             }
             //Save new datas
             $str_set = "\n\t\t\t\t\t\tpage='" . $destinationPage->getID() . "',\n\t\t\t\t\t\tclientSpaceID='" . $this->_clientSpaceID . "',\n\t\t\t\t\t\trowID='" . $this->_rowID . "',\n\t\t\t\t\t\tblockID='" . $this->_tagID . "',\n\t\t\t\t\t\tlabel='" . SensitiveIO::sanitizeSQLString(SensitiveIO::stripPHPTags($this->_label)) . "',\n\t\t\t\t\t\tfile='" . SensitiveIO::sanitizeSQLString(SensitiveIO::stripPHPTags($_newFilename)) . "',\n\t\t\t\t\t\texternalLink='" . SensitiveIO::sanitizeSQLString(SensitiveIO::stripPHPTags($this->_externalLink)) . "',\n\t\t\t\t\t\tenlargedFile='" . SensitiveIO::sanitizeSQLString(SensitiveIO::stripPHPTags($_newEnlargedFilename)) . "'\n\t\t\t\t";
             $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\t" . $table . "\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $str_set . "\n\t\t\t\t";
             $q = new CMS_query($sql);
             if (!$q->hasError()) {
                 //Table Edition
                 $sql = "\n\t\t\t\t\t\tinsert into\n\t\t\t\t\t\t\t" . $this->_getDataTableName(RESOURCE_LOCATION_EDITION, false) . "\n\t\t\t\t\t\tset\n\t\t\t\t\t\t\tid='" . $q->getLastInsertedID() . "',\n\t\t\t\t\t\t\t" . $str_set . "\n\t\t\t\t\t";
                 $q = new CMS_query($sql);
                 return !$q->hasError();
             } else {
                 $this->raiseError("Duplicate, SQL insertion of new filename failed : " . $sql);
             }
         } else {
             $this->raiseError("Duplicate, copy of file failed :" . PATH_MODULES_FILES_STANDARD_FS . "/edited/" . $this->_file);
         }
     }
     return false;
 }
예제 #28
0
파일: row.php 프로젝트: davidmottet/automne
 /**
  * Writes the row into persistence (MySQL for now).
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function writeToPersistence()
 {
     if (!$this->_uuid) {
         $this->_uuid = io::uuid();
     }
     $sql_fields = "\n\t\t\tlabel_row='" . SensitiveIO::sanitizeSQLString($this->_label) . "',\n\t\t\tdefinitionFile_row='" . SensitiveIO::sanitizeSQLString($this->_definitionFile) . "',\n\t\t\tmodulesStack_row='" . $this->_modules->getTextDefinition() . "',\n\t\t\tgroupsStack_row='" . SensitiveIO::sanitizeSQLString($this->_groups->getTextDefinition()) . "',\n\t\t\tuseable_row='" . SensitiveIO::sanitizeSQLString($this->_useable) . "',\n\t\t\tdescription_row='" . SensitiveIO::sanitizeSQLString($this->_description) . "',\n\t\t\ttplfilter_row='" . SensitiveIO::sanitizeSQLString(implode(';', $this->_tplfilter)) . "',\n\t\t\timage_row='" . SensitiveIO::sanitizeSQLString($this->_image) . "',\n\t\t\tuuid_row='" . SensitiveIO::sanitizeSQLString($this->_uuid) . "'\n\t\t";
     if ($this->_id) {
         $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tmod_standard_rows\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_row='" . $this->_id . "'\n\t\t\t";
     } else {
         $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tmod_standard_rows\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t";
     }
     //pr($sql);
     $q = new CMS_query($sql);
     if ($q->hasError()) {
         return false;
     } elseif (!$this->_id) {
         $this->_id = $q->getLastInsertedID();
     }
     return true;
 }
 /**
  * Check if item is deleted
  *
  * @param integer $itemID The item ID to check as deleted
  * @return boolean true if ite is deleted, false otherwise
  */
 function isDeletedItem($itemID)
 {
     static $deletedItems;
     if (!isset($deletedItems[$itemID])) {
         //set deleted status to item
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\t1\n\t\t\t\tfrom\n\t\t\t\t\tmod_object_polyobjects\n\t\t\t\twhere\n\t\t\t\t\tid_moo = '" . sensitiveIO::sanitizeSQLString($itemID) . "'\n\t\t\t\t\tand deleted_moo = '1'\n\t\t\t";
         $q = new CMS_query($sql);
         $deletedItems[$itemID] = $q->getNumRows() ? true : false;
     }
     return $deletedItems[$itemID];
 }
예제 #30
0
 /**
  * Destroy this object, in DB and filesystem if needed
  * Destroy title label also
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function destroy()
 {
     if ($this->_fieldID) {
         //delete all files of objects for this field
         $module = CMS_poly_object_catalog::getModuleCodenameForField($this->_fieldID);
         $filesDir = new CMS_file(PATH_MODULES_FILES_FS . '/' . $module, CMS_file::FILE_SYSTEM, CMS_file::TYPE_DIRECTORY);
         if ($filesDir->exists()) {
             //search all files of this field
             $filesList = $filesDir->getFileList(PATH_MODULES_FILES_FS . '/' . $module . '/*_f' . $this->_fieldID . '_*');
             //then delete them
             foreach ($filesList as $aFile) {
                 if (!CMS_file::deleteFile($aFile['name'])) {
                     $this->raiseError("Can't delete file " . $aFile['name'] . " for field : " . $this->_fieldID);
                     return false;
                 }
             }
         }
         //delete all datas of objects for this field
         $tables = array('mod_subobject_date_deleted', 'mod_subobject_date_edited', 'mod_subobject_date_public', 'mod_subobject_integer_deleted', 'mod_subobject_integer_edited', 'mod_subobject_integer_public', 'mod_subobject_string_deleted', 'mod_subobject_string_edited', 'mod_subobject_string_public', 'mod_subobject_text_deleted', 'mod_subobject_text_edited', 'mod_subobject_text_public');
         foreach ($tables as $aTable) {
             $sql = "\n\t\t\t\t\tdelete from\n\t\t\t\t\t\t" . $aTable . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tobjectFieldID = '" . $this->_fieldID . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
             if ($q->hasError()) {
                 $this->raiseError("Can't delete datas of table " . $aTable . " for field : " . $this->_fieldID);
                 return false;
             }
         }
         //delete title label object
         if (sensitiveIO::IsPositiveInteger($this->_objectFieldValues["labelID"])) {
             $label = new CMS_object_i18nm($this->_objectFieldValues["labelID"]);
             $label->destroy();
         }
         //delete field DB record
         $sql = "\n\t\t\t\tdelete from\n\t\t\t\t\tmod_object_field \n\t\t\t\twhere\n\t\t\t\t\tid_mof='" . $this->_fieldID . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->hasError()) {
             $this->raiseError("Can't delete datas of table mod_object_field for field : " . $this->_fieldID);
             return false;
         }
         //unset fields catalog in cache
         CMS_cache::clearTypeCache('atm-polymod-structure');
         //Clear polymod cache
         //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => CMS_poly_object_catalog::getModuleCodenameForField($this->_fieldID)));
         CMS_cache::clearTypeCache('polymod');
     }
     //unset fields catalog in cache
     CMS_cache::clearTypeCacheByMetas('atm-polymod-structure', array('type' => 'fields'));
     //finally destroy object instance
     unset($this);
     return true;
 }