Esempio n. 1
0
 /**
  * Builds order statement with a key and its value
  * The key can be a known string or it can be a field id, this method will create statements in consequence
  *
  * @access public
  * @param string $key name of statement to set
  * @param string $direction , the direction to give (asc or desc, default is asc)
  * @return void or false if an error occured
  */
 function addOrderCondition($type, $direction = 'asc', $operator = false)
 {
     if (!$type || !in_array($direction, array('asc', 'desc'))) {
         return;
     }
     $value = array('direction' => $direction, 'operator' => $operator);
     switch ($type) {
         case "objectID":
             $this->_orderConditions['objectID'] = $value;
             break;
             if ($this->_object->isPrimaryResource()) {
                 $this->_orderConditions['publication date after'] = $value;
             }
             break;
         case "publication date after":
             // Date start
         // Date start
         case "publication date before":
         case "publication date start":
         case "publication date end":
             if ($this->_object->isPrimaryResource()) {
                 $this->_orderConditions[$type] = $value;
             }
             break;
         case "random":
             // Random ordering
             $this->_orderConditions['random'] = $value;
             break;
         case "relevance":
             // Only if ASE module exists
             if (class_exists('CMS_module_ase') && CMS_module_ase::isActive()) {
                 $this->_orderConditions['relevance'] = $value;
             } else {
                 $this->raiseError('Sorting by relevance is not active if module ASE does not exists ... ');
                 return false;
             }
             break;
         default:
             if (sensitiveIO::IsPositiveInteger($type)) {
                 $this->_orderConditions[$type] = $value;
                 break;
             }
             $this->raiseError('Unknown type : ' . $type);
             return false;
             break;
     }
 }
 /**
  * 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 string $module, The module codename
  * @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, $resourceID, $locationFrom, $locationTo, $copyOnly = false)
 {
     //get all datas locations
     $locations = CMS_resource::getAllDataLocations();
     if (!in_array($locationFrom, $locations)) {
         CMS_grandFather::raiseError("LocationFrom is not a valid location : " . $locationFrom);
         return false;
     }
     if (!in_array($locationTo, $locations)) {
         CMS_grandFather::raiseError("LocationTo is not a valid location : " . $locationTo);
         return false;
     }
     if (!sensitiveIO::IsPositiveInteger($resourceID)) {
         CMS_grandFather::raiseError("ResourceID must be a positive integer : " . $resourceID);
         return false;
     }
     //first move DB datas
     $tables_prefixes = array('mod_subobject_date_', 'mod_subobject_integer_', 'mod_subobject_string_', 'mod_subobject_text_');
     foreach ($tables_prefixes as $table_prefix) {
         //delete all in the destination table and insert new ones
         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\tobjectID='" . $resourceID . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
             $sql = "\n\t\t\t\t\treplace 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\tobjectID='" . $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\tobjectID='" . $resourceID . "'\n\t\t\t\t";
             $q = new CMS_query($sql);
         }
     }
     //second, move the files
     $locationFromDir = new CMS_file(PATH_MODULES_FILES_FS . "/" . $module . "/" . $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 . "/" . $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 . "/" . $locationTo);
             return false;
         }
         //delete all files of the locationToDir
         $files = glob(PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationTo . '/r' . $resourceID . '_*', GLOB_NOSORT);
         if (is_array($files)) {
             foreach ($files as $file) {
                 if (!CMS_file::deleteFile($file)) {
                     $this->raiseError("Can't delete file " . $file);
                     return false;
                 }
             }
         }
         //then copy or move them to the locationToDir
         $files = glob(PATH_MODULES_FILES_FS . "/" . $module . "/" . $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)) {
                         $this->raiseError("Can't copy file " . $file . " to " . $to);
                         return false;
                     }
                 } else {
                     if (!CMS_file::moveTo($file, $to)) {
                         $this->raiseError("Can't move file " . $file . " to " . $to);
                         return false;
                     }
                 }
                 //then chmod new file
                 CMS_file::chmodFile(FILES_CHMOD, $to);
             }
         }
     } else {
         //then get all files of the locationFromDir
         $files = glob(PATH_MODULES_FILES_FS . "/" . $module . "/" . $locationFrom . '/r' . $resourceID . '_*', GLOB_NOSORT);
         if (is_array($files)) {
             foreach ($files as $file) {
                 if (!CMS_file::deleteFile($file)) {
                     $this->raiseError("Can't delete file " . $file);
                     return false;
                 }
             }
         }
     }
     return true;
 }
Esempio n. 3
0
 /**
  * Gets the data in HTML mode.
  *
  * @param CMS_language &$language The language of the administration frontend
  * @param CMS_page &$page The page which contains the client space
  * @param CMS_clientSpace &$clientSpace The client space which contains the row
  * @param CMS_row &$row The row which contains the block
  * @param integer $visualizationMode The visualization mode used
  * @return string the HTML data
  * @access public
  */
 function getData(&$language, &$page, &$clientSpace, &$row, $visualizationMode)
 {
     parent::getData($language, $page, $clientSpace, $row, $visualizationMode);
     //get the data
     switch ($visualizationMode) {
         case PAGE_VISUALMODE_HTML_PUBLIC:
         case PAGE_VISUALMODE_PRINT:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_USERSPACE, true);
             break;
         case PAGE_VISUALMODE_HTML_EDITED:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_USERSPACE, false);
             break;
         case PAGE_VISUALMODE_HTML_EDITION:
         case PAGE_VISUALMODE_FORM:
         case PAGE_VISUALMODE_CLIENTSPACES_FORM:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_EDITION, false);
             break;
     }
     //build the HTML
     switch ($visualizationMode) {
         case PAGE_VISUALMODE_HTML_PUBLIC:
         case PAGE_VISUALMODE_PRINT:
             if (isset($data["value"]['formID']) && sensitiveIO::IsPositiveInteger($data["value"]['formID'])) {
                 //call cms_forms clientspace content
                 $cs = new CMS_moduleClientspace(array("module" => MOD_CMS_FORMS_CODENAME, "id" => "cms_forms", "type" => "formular", "formID" => $data["value"]['formID']));
                 $html = $cs->getClientspaceData(MOD_CMS_FORMS_CODENAME, new CMS_date(), $page, $visualizationMode);
                 if ($visualizationMode != PAGE_VISUALMODE_PRINT) {
                     //save in global var the page ID who need this module so we can add the header module code later.
                     $GLOBALS[MOD_CMS_FORMS_CODENAME]["pageUseModule"][$this->_pageID][] = $data["value"]['formID'];
                 }
                 return str_replace("{{data}}", $html, $this->_definition);
             }
             break;
         case PAGE_VISUALMODE_HTML_EDITED:
         case PAGE_VISUALMODE_HTML_EDITION:
             if ($data && isset($data["value"]['formID']) && sensitiveIO::IsPositiveInteger($data["value"]['formID'])) {
                 //call cms_forms clientspace content
                 $cs = new CMS_moduleClientspace(array("module" => MOD_CMS_FORMS_CODENAME, "id" => "cms_forms", "type" => "formular", "formID" => $data["value"]['formID']));
                 //$html = $cs->getClientspaceData(MOD_CMS_FORMS_CODENAME, new CMS_date(), $page, $visualizationMode);
                 $form = new CMS_forms_formular($data["value"]['formID']);
                 $html = $form->getContent(CMS_forms_formular::REMOVE_FORM_SUBMIT);
                 return str_replace("{{data}}", $html, $this->_definition);
             }
             break;
         case PAGE_VISUALMODE_FORM:
             if ($data && isset($data["value"]['formID']) && sensitiveIO::IsPositiveInteger($data["value"]['formID'])) {
                 $form = new CMS_forms_formular($data["value"]['formID']);
                 $html = $form->getContent(CMS_forms_formular::REMOVE_FORM_SUBMIT);
             } else {
                 $html = '<img src="' . PATH_MODULES_FILES_WR . '/' . MOD_CMS_FORMS_CODENAME . '/demo.gif" alt="X" title="X" />';
             }
             $form_data = str_replace("{{data}}", $html, $this->_definition);
             $this->_hasContent = $data && isset($data["value"]['formID']) ? true : false;
             $this->_editable = true;
             global $cms_user;
             $module = CMS_modulesCatalog::getByCodename(MOD_CMS_FORMS_CODENAME);
             $this->_administrable = $module->hasAdmin() && $cms_user->hasModuleClearance(MOD_CMS_FORMS_CODENAME, CLEARANCE_MODULE_EDIT);
             return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             break;
         case PAGE_VISUALMODE_CLIENTSPACES_FORM:
             $this->_hasContent = $this->_editable = $this->_administrable = false;
             $html = '<img src="' . PATH_MODULES_FILES_WR . '/' . MOD_CMS_FORMS_CODENAME . '/demo.gif" alt="X" title="X" />';
             $form_data = str_replace("{{data}}", $html, $this->_definition);
             return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             break;
     }
 }
Esempio n. 4
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;
 }
Esempio n. 5
0
 case 'deleteObject':
     if ($object->destroy()) {
         unset($object);
         unset($objectID);
         //unset fields catalog in cache
         CMS_cache::clearTypeCacheByMetas('atm-polymod-structure', array('type' => 'fields'));
         $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
     } else {
         $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_DELETE_OBJECT_ERROR);
     }
     break;
 case "delete":
     $field = new CMS_poly_object_field($_POST["field"]);
     if (!$field->hasError() && $field->destroy()) {
         //then reload object
         if (sensitiveIO::IsPositiveInteger($objectID)) {
             $object = new CMS_poly_object_definition($objectID);
         }
         $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
     } else {
         $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_DELETE_FIELD_ERROR);
     }
     break;
 case 'deleteRSS':
     $RSSDefinition = new CMS_poly_rss_definitions($_POST['RSSDefinition']);
     $RSSDefinition->destroy();
     $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
     break;
 case 'deletePlugin':
     $pluginDefinition = new CMS_poly_plugin_definitions($_POST['pluginDefinition']);
     $pluginDefinition->destroy();
Esempio n. 6
0
        $view->show();
    }
}
if (!isset($cms_page) || !is_object($cms_page)) {
    CMS_grandFather::raiseError('Error, can\'t get a valid page to work with.');
    $view->show();
}
//check if page is useable (public or edited at least)
if (!$cms_page->isUseable() || $followRedirect) {
    if (!$cms_page->isUseable()) {
        //page is deleted, go to root
        $cms_page = CMS_tree::getRoot();
    }
    //redirect to subpage if any redirection exists
    $redirectlink = $cms_page->getRedirectLink(true);
    while ($redirectlink->hasValidHREF() && sensitiveIO::IsPositiveInteger($redirectlink->getInternalLink())) {
        $cms_page = new CMS_page($redirectlink->getInternalLink());
        $redirectlink = $cms_page->getRedirectLink(true);
    }
    $pageId = $cms_page->getID();
}
pr('View page : ' . $cms_page->getID() . ($reload ? ' (Force reload queried by interface)' : ''));
//set page into user context
CMS_session::setPage($cms_page);
//for the page, create all javascript informations needed
$hasPreviz = $hasPublic = $hasDraft = $isEditable = $hasLock = $hasRedirect = false;
//which panels can be seen by user (according to his rights)
//this array represent the order of each panel (left to right)
$userPanels = array('search' => array('type' => 'searchPanel', 'visible' => true), 'tree' => array('type' => 'winPanel', 'visible' => false), 'favorite' => array('type' => 'favoritePanel', 'visible' => $cms_user->hasModuleClearance(MOD_STANDARD_CODENAME, CLEARANCE_MODULE_VIEW)), 'action' => array('type' => 'menuPanel', 'visible' => false), 'add' => array('type' => 'winPanel', 'visible' => false), 'properties' => array('type' => 'winPanel', 'visible' => false), 'edit' => array('type' => 'framePanel', 'visible' => false), 'edited' => array('type' => 'framePanel', 'visible' => false), 'public' => array('type' => 'framePanel', 'visible' => true), 'nopages' => array('type' => 'framePanel', 'visible' => false), 'norights' => array('type' => 'framePanel', 'visible' => false));
//check for public page
if ($cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_VIEW)) {
Esempio n. 7
0
 /**
  * Return sub tree of a given category
  *
  * @param array $values : parameters values array(parameterName => parameterValue) in :
  * 	root : the category id to get subtree. If none set, use the defined root category for field
  *		maxlevel : the maximum number of level to get (optional)
  *		selected : the current selected category id (optional)
  * 	usedcategories : display only used categories (optional, default : true)
  * @param multidimentionnal array $tags : xml2Array content of atm-function tag
  * 	<item>...{lvl}...{id}...{label}...{sublevel}...</item>
  * 	<itemselected>...{lvl}...{id}...{label}...{sublevel}...</itemselected>
  * 	<template>...{sublevel}...</template>
  * @return string : the sub tree of the given category
  * @access public
  */
 function categoriesTree($values, $tags)
 {
     global $cms_user, $cms_language;
     if (!isset($values['usedcategories']) || $values['usedcategories'] == 'true' || $values['usedcategories'] == '1') {
         $restrictToUsedCategories = true;
     } else {
         $restrictToUsedCategories = false;
     }
     $return = "";
     $params = $this->getParamsValues();
     if ((!isset($values['root']) || !sensitiveIO::isPositiveInteger($values['root'])) && (!isset($params['rootCategory']) || !sensitiveIO::IsPositiveInteger($params['rootCategory']))) {
         $this->raiseError("Root value parameter must be a valid category ID");
         return false;
     } elseif ((!isset($values['root']) || !sensitiveIO::isPositiveInteger($values['root'])) && (isset($params['rootCategory']) && sensitiveIO::IsPositiveInteger($params['rootCategory']))) {
         $values['root'] = $params['rootCategory'];
     }
     $usedCategories = $this->getAllUsedCategoriesForField();
     if (!$usedCategories) {
         return $return;
     }
     $xml2Array = new CMS_XML2Array();
     $itemPattern = $xml2Array->getXMLInTag($tags, 'item');
     $templatePattern = $xml2Array->getXMLInTag($tags, 'template');
     $selectedPattern = $xml2Array->getXMLInTag($tags, 'itemselected');
     $maxlevel = isset($values['maxlevel']) ? (int) $values['maxlevel'] : 0;
     if (isset($values['selected'])) {
         $selectedIDs = is_array($values['selected']) ? $values['selected'] : array($values['selected']);
     } else {
         $selectedIDs = array();
     }
     //$disableCategories = isset($values['disable']) ? explode(';',$values['disable']) : array();
     $disableCategories = array();
     if (isset($values['disable'])) {
         $disableCategories = explode(';', $values['disable']);
         if (count($disableCategories) == 1) {
             $disableCategories = explode(',', $values['disable']);
         }
     }
     if (!$itemPattern) {
         $this->raiseError("No 'item' tag found or tag empty");
         return false;
     }
     if (!$templatePattern) {
         $this->raiseError("No 'template' tag found or tag empty");
         return false;
     }
     $module = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
     if (isset($values['editableonly']) && ($values['editableonly'] == 'true' || $values['editableonly'] == '1')) {
         $viewvableCategoriesForProfile = CMS_moduleCategories_catalog::getViewvableCategoriesForProfile($cms_user, $module, true, CLEARANCE_MODULE_EDIT, true);
     } else {
         $viewvableCategoriesForProfile = CMS_moduleCategories_catalog::getViewvableCategoriesForProfile($cms_user, $module, true);
     }
     if ($restrictToUsedCategories || is_array($disableCategories) && $disableCategories) {
         //unset unused categories (keep categories parents in lineage)
         $usedCategoriesTree = array();
         foreach ($usedCategories as $usedCategory) {
             if (isset($viewvableCategoriesForProfile[$usedCategory]) && $viewvableCategoriesForProfile[$usedCategory]) {
                 $usedCategoriesTree = array_merge($usedCategoriesTree, explode(';', $viewvableCategoriesForProfile[$usedCategory]));
             }
         }
         $usedCategoriesTree = array_flip(array_unique($usedCategoriesTree));
         foreach ($viewvableCategoriesForProfile as $catID => $lineage) {
             //restrict to used categories
             if ($restrictToUsedCategories) {
                 if (!isset($usedCategoriesTree[$catID])) {
                     unset($viewvableCategoriesForProfile[$catID]);
                 }
             }
             // Disable categories
             if (is_array($disableCategories) && $disableCategories) {
                 $lineageTab = explode(';', $lineage);
                 foreach ($disableCategories as $disableCategory) {
                     if (SensitiveIO::isPositiveInteger($disableCategory)) {
                         if (in_array($disableCategory, $lineageTab)) {
                             unset($viewvableCategoriesForProfile[$catID]);
                         }
                     }
                 }
             }
         }
     }
     $rootLineage = CMS_moduleCategories_catalog::getLineageOfCategoryAsString($values['root'], $separator = ";");
     //old method, seems buggy, keep it for now
     //$rootLineage = ($viewvableCategoriesForProfile[$values['root']]) ? $viewvableCategoriesForProfile[$values['root']] : $values['root'];
     //create recursive categories array
     foreach ($viewvableCategoriesForProfile as $catID => $lineage) {
         //this must be ^...;rootID;...$ or ^rootID;...$
         if (io::strpos($lineage, ';' . $values['root'] . ';') !== false || io::strpos($lineage, $values['root'] . ';') === 0) {
             $lineage = preg_replace('#^' . $rootLineage . ';#', '', $lineage);
             $ln = sensitiveIO::sanitizeExecCommand('if (!isset($nLevelArray[' . str_replace(';', '][', $lineage) . '])) $nLevelArray[' . str_replace(';', '][', $lineage) . '] =  array();');
             eval($ln);
         }
     }
     //pr($nLevelArray);
     if (isset($nLevelArray) && is_array($nLevelArray) && $nLevelArray) {
         $return = $this->_createCategoriesTree($nLevelArray, $itemPattern, $templatePattern, $selectedPattern, $maxlevel, $selectedIDs);
     }
     return $return;
 }
 /**
  * Destroy this object in DB
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function destroy()
 {
     if ($this->_ID) {
         //first delete old polyobject references
         $sql = "\n\t\t\t\tdelete from\n\t\t\t\t\tmod_object_polyobjects\n\t\t\t\twhere\n\t\t\t\t\tobject_type_id_moo = '" . $this->_ID . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->hasError()) {
             $this->raiseError("Can't delete datas of table mod_object_polyobjects for object : " . $this->_ID);
             return false;
         }
         //second delete object label and description
         if (sensitiveIO::IsPositiveInteger($this->getValue("labelID"))) {
             $label = new CMS_object_i18nm($this->getValue("labelID"));
             $label->destroy();
         }
         if (sensitiveIO::IsPositiveInteger($this->getValue("descriptionID"))) {
             $description = new CMS_object_i18nm($this->getValue("labelID"));
             $description->destroy();
         }
         //third, delete object definition datas
         $sql = "\n\t\t\t\tdelete from\n\t\t\t\t\tmod_object_definition\n\t\t\t\twhere\n\t\t\t\t\tid_mod = '" . $this->_ID . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->hasError()) {
             $this->raiseError("Can't delete datas of table mod_object_definition for object : " . $this->_ID);
             return false;
         }
         //unset objects catalog in cache
         CMS_cache::clearTypeCacheByMetas('atm-polymod-structure', array('type' => 'object'));
         //Clear polymod cache
         //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $this->_objectValues["module"]));
         CMS_cache::clearTypeCache('polymod');
     }
     unset($this);
     return true;
 }
Esempio n. 9
0
 /**
  * Sets the DB object ID of the instance.
  *
  * @param integer $objectID the DB object id to set
  * @return boolean true on success, false on failure
  * @access public
  */
 function setObjectID($objectID)
 {
     if (!sensitiveIO::IsPositiveInteger($objectID)) {
         $this->raiseError("ObjectID must be a positive integer :" . $objectID);
         return false;
     }
     $this->_objectID = $objectID;
     return true;
 }
 /**
  * Destroy this object in DB
  *
  * @return boolean true on success, false on failure
  * @access public
  */
 function destroy()
 {
     if ($this->_ID) {
         //first delete definition
         $sql = "\n\t\t\t\tdelete from\n\t\t\t\t\tmod_object_plugin_definition\n\t\t\t\twhere\n\t\t\t\t\tid_mowd = '" . $this->_ID . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->hasError()) {
             $this->raiseError("Can't delete datas of table mod_object_polyobjects for object : " . $this->_ID);
             return false;
         }
         //second delete object label and description
         if (sensitiveIO::IsPositiveInteger($this->getValue("labelID"))) {
             $label = new CMS_object_i18nm($this->getValue("labelID"));
             $label->destroy();
         }
         if (sensitiveIO::IsPositiveInteger($this->getValue("descriptionID"))) {
             $description = new CMS_object_i18nm($this->getValue("labelID"));
             $description->destroy();
         }
         //Clear polymod cache
         //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => CMS_poly_object_catalog::getModuleCodenameForObjectType($this->getValue('objectID'))));
         CMS_cache::clearTypeCache('polymod');
         //unset polymod structure in cache
         CMS_cache::clearTypeCache('atm-polymod-structure');
     }
     unset($this);
     return true;
 }
Esempio n. 11
0
 /**
  * Return a valid page for a given URL
  *
  * @param string $pageUrl the page URL
  * @param boolean $useDomain : use queried domain to found root page associated (default : true)
  * @return CMS_page if page found, false otherwise
  * @access public
  */
 static function analyseURL($pageUrl, $useDomain = true)
 {
     if (strpos($pageUrl, PATH_FORBIDDEN_WR) === 0 || strpos($pageUrl, PATH_SPECIAL_PAGE_NOT_FOUND_WR) === 0) {
         return false;
     }
     $requestedPageId = null;
     $urlinfo = @parse_url($pageUrl);
     if (isset($urlinfo['path'])) {
         $pathinfo = pathinfo($urlinfo['path']);
         $basename = isset($pathinfo['filename']) ? $pathinfo['filename'] : $pathinfo['basename'];
     }
     //if extension exists and is not PHP, return
     if (isset($pathinfo['extension']) && $pathinfo['extension'] && $pathinfo['extension'] != 'php') {
         return false;
     }
     if (isset($urlinfo['query'])) {
         $querystring = $urlinfo['query'];
     }
     //if basename found try to get page id
     if (isset($urlinfo['path']) && $urlinfo['path'] != PATH_REALROOT_WR . '/' && $basename && (isset($pathinfo['extension']) && strtolower($pathinfo['extension']) == 'php' || !isset($pathinfo['extension']))) {
         //search page id in basename (declare matching patterns by order of research)
         $patterns[] = "#^([0-9]+)-#U";
         // for request like id-page_title.php
         $patterns[] = "#^print-([0-9]+)-#U";
         // for request like print-id-page_title.php
         $patterns[] = "#_([0-9]+)_\$#U";
         // for request like _id_id_.php : old V3 style url
         $patterns[] = "#^([0-9]+)\$#U";
         // for request like id
         $count = 0;
         while (!preg_match($patterns[$count], $basename, $requestedPageId) && $count + 1 < sizeof($patterns)) {
             $count++;
         }
         if (isset($requestedPageId[1]) && sensitiveIO::IsPositiveInteger($requestedPageId[1]) && CMS_tree::getPageValue($requestedPageId[1], 'exists')) {
             //try to instanciate the requested page
             $cms_page = CMS_tree::getPageByID($requestedPageId[1]);
             if ($cms_page && !$cms_page->hasError()) {
                 return $cms_page;
             }
         }
     }
     if ($useDomain) {
         $httpHost = @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) ? @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST'];
         //search page id by domain address
         $domain = isset($urlinfo['host']) ? $urlinfo['host'] : $httpHost;
         $domainfound = CMS_websitesCatalog::getWebsiteFromDomain($domain, isset($urlinfo['path']) && $urlinfo['path'] != PATH_REALROOT_WR . '/' ? $urlinfo['path'] : '');
         if (is_object($domainfound)) {
             $cms_page = $domainfound->getRoot();
             if ($cms_page && !$cms_page->hasError()) {
                 return $cms_page;
             }
         }
     }
     //query modules to get page from them
     $modules = CMS_modulesCatalog::getAll();
     foreach ($modules as $module) {
         if (method_exists($module, 'getPageFromURL')) {
             $cms_page = $module->getPageFromURL($pageUrl, $useDomain);
             if ($cms_page) {
                 return $cms_page;
             }
         }
     }
     return false;
 }