예제 #1
0
 /**
  * Constructor.
  * initializes the linxCondition.
  *
  * @param string $property The page property we're gonna test. Only a set of these are available here.
  * @param string $operator The comparison operator serving to test the condition.
  * @param string $tagContent The tag content.
  * @return void
  * @access public
  */
 function __construct($tag)
 {
     $authorized_properties = array("rank", "title", "id", "lvl", "father", "website", "codename");
     $property = $tag->getAttribute('property');
     $operator = $tag->getAttribute('operator');
     if (SensitiveIO::isInSet($property, $authorized_properties)) {
         $this->_pageProperty = $property;
         $this->_operator = io::decodeEntities(io::decodeEntities(io::decodeEntities($operator)));
         $values = $tag->getElementsByTagName('value');
         if ($values->length > 0) {
             $value = $values->item(0);
             //if value type is "nodeproperty", we must parse the inner content to find a nodespec tag
             if ($value->hasAttribute("type") && $value->getAttribute("type") == "nodeproperty") {
                 $this->_valueIsScalar = false;
                 $this->_valueNodespecProperty = $value->getAttribute("property");
                 $nodespecs = $value->getElementsByTagName('nodespec');
                 if ($nodespecs->length > 0) {
                     $nodespec = $nodespecs->item(0);
                     $this->_valueNodespec = CMS_linxNodespec::createNodespec($nodespec);
                 }
             } else {
                 $this->_valueScalar = $value->nodeValue;
             }
         } else {
             $this->raiseError("Malformed innerContent");
             return;
         }
     } else {
         $this->raiseError("Unknown property : " . $property);
     }
 }
예제 #2
0
 /**
  * Constructor.
  * initializes the linxDisplay.
  *
  * @param string $innerContent The tag content.
  * @return void
  * @access public
  */
 function __construct($type, $value, $relativeOffset, $crosswebsite = false, $website = '')
 {
     $authorized_types = array("node", "relative", "codename");
     $authorized_string_values = array("self", "brother", "father", "root");
     $this->_crosswebsite = $crosswebsite;
     if (!SensitiveIO::isInSet($type, $authorized_types)) {
         $this->raiseError("Type unknown : " . $type);
         return;
     }
     if ($type == 'node' && !SensitiveIO::isPositiveInteger($value)) {
         $this->raiseError("Bad value for 'node' type : " . $value);
         return;
     }
     if ($type == 'relative' && !SensitiveIO::isInSet($value, $authorized_string_values)) {
         $this->raiseError("Bad value for 'relative' type : " . $value);
         return;
     }
     if ($type == 'codename' && strtolower(io::sanitizeAsciiString($value)) != $value) {
         $this->raiseError("Bad value for 'codename' type : " . $value);
         return;
     }
     if ($type == 'codename' && strtolower(io::sanitizeAsciiString($website)) != $website) {
         $this->raiseError("Bad value for 'website' : " . $website);
         return;
     }
     $this->_type = $type;
     $this->_value = $value;
     $this->_website = $website;
     if ($this->_type == 'relative') {
         $this->_relativeOffset = $relativeOffset;
     }
 }
예제 #3
0
 /**
  * Sets the type of link
  *
  * @param integer $type The type to set
  * @return boolean true on success, false on failure
  * @access public
  */
 function setLink($linkName, $linkType, $linkValue)
 {
     if (!SensitiveIO::isInSet($type, CMS_resource::getAllLinkTypes())) {
         $this->raiseError("Type not in the valid set");
         return false;
     }
     $this->_linkType = $type;
     return true;
 }
 /**
  * Process the module validations. Note that the EMails sent to either the transferred validator or the editors were sent before.
  *
  * @param CMS_resourceValidation $resourceValidation The resource validation to process
  * @param integer $result The result of the validation process. See VALIDATION_OPTION constants
  * @return boolean true on success, false on failure to process
  * @access public
  */
 function processValidation($resourceValidation, $result, $lastValidation = true)
 {
     if (!CMS_poly_object_catalog::hasPrimaryResource($this->getCodename())) {
         $this->raiseError("Module have not any primary resource !");
         return false;
     }
     if (!$resourceValidation instanceof CMS_resourceValidation) {
         $this->raiseError("ResourceValidation is not a valid CMS_resourceValidation object");
         return false;
     }
     if (!SensitiveIO::isInSet($result, CMS_resourceValidation::getAllValidationOptions())) {
         $this->raiseError("ProcessValidation : result is not a valid validation option");
         return false;
     }
     //Tell the resource of the changes
     $resource = $resourceValidation->getResource();
     $editions = $resourceValidation->getEditions();
     //add a call to all modules for validation specific treatment
     $modulesCodes = new CMS_modulesCodes();
     //add a call to modules after validation
     $modulesCodes->getModulesCodes(MODULE_TREATMENT_BEFORE_VALIDATION_TREATMENT, '', $resource, array('result' => $result, 'lastvalidation' => $lastValidation, 'module' => $this->_codename));
     switch ($result) {
         case VALIDATION_OPTION_REFUSE:
             //validation was refused, adjust the array of validations refused
             $all_editions = CMS_resourceStatus::getAllEditions();
             foreach ($all_editions as $aEdition) {
                 if ($aEdition & $editions) {
                     if (RESOURCE_EDITION_LOCATION & $aEdition && $resource->getProposedLocation() == RESOURCE_LOCATION_DELETED) {
                         $resource->removeProposedLocation();
                     } else {
                         $resource->addValidationRefused($aEdition);
                     }
                 }
             }
             break;
         case VALIDATION_OPTION_ACCEPT:
             //if one of the edition was the location, only treat this one. Move the data.
             if ($editions & RESOURCE_EDITION_LOCATION) {
                 if ($resource->getLocation() == RESOURCE_LOCATION_USERSPACE) {
                     //pulling resource out of USERSPACE
                     switch ($resource->getProposedLocation()) {
                         case RESOURCE_LOCATION_DELETED:
                             $locationTo = RESOURCE_DATA_LOCATION_DELETED;
                             break;
                     }
                     //first, move edited
                     $this->_changeDataLocation($resource, RESOURCE_DATA_LOCATION_EDITED, $locationTo);
                     //then delete public
                     $this->_changeDataLocation($resource, RESOURCE_DATA_LOCATION_PUBLIC, RESOURCE_DATA_LOCATION_DEVNULL);
                     //mark item as deleted
                     CMS_modulePolymodValidation::markDeletedItem($resource->getID());
                 } else {
                     if ($resource->getProposedLocation() == RESOURCE_LOCATION_USERSPACE) {
                         //Pushing resource to USERSPACE
                         switch ($resource->getLocation()) {
                             case RESOURCE_LOCATION_DELETED:
                                 $locationFrom = RESOURCE_DATA_LOCATION_DELETED;
                                 break;
                         }
                         //if resource was published, copy data to public table
                         if ($resource->getPublication() != RESOURCE_PUBLICATION_NEVERVALIDATED) {
                             $this->_changeDataLocation($resource, $locationFrom, RESOURCE_DATA_LOCATION_PUBLIC, true);
                         }
                         //move data from its location to edited
                         $this->_changeDataLocation($resource, $locationFrom, RESOURCE_DATA_LOCATION_EDITED);
                     } else {
                         //the move entirely takes place outside of USERSPACE (archived to deleted hopefully)
                         switch ($resource->getLocation()) {
                             case RESOURCE_LOCATION_DELETED:
                                 $locationFrom = RESOURCE_DATA_LOCATION_DELETED;
                                 break;
                         }
                         switch ($resource->getProposedLocation()) {
                             case RESOURCE_LOCATION_DELETED:
                                 $locationTo = RESOURCE_DATA_LOCATION_DELETED;
                                 break;
                         }
                         $this->_changeDataLocation($resource, $locationFrom, $locationTo);
                         if ($locationTo == RESOURCE_DATA_LOCATION_DELETED) {
                             //mark item as deleted
                             CMS_modulePolymodValidation::markDeletedItem($resource->getID());
                         }
                     }
                 }
                 $resource->validateProposedLocation();
             } else {
                 $all_editions = CMS_resourceStatus::getAllEditions();
                 $this->_changeDataLocation($resource, RESOURCE_DATA_LOCATION_EDITED, RESOURCE_DATA_LOCATION_PUBLIC, true);
                 foreach ($all_editions as $aEdition) {
                     if ($aEdition & $editions) {
                         $resource->validateEdition($aEdition);
                     }
                 }
             }
             break;
     }
     //if resource is a polyobject, we need to save only it resource (parent) status
     if (!$resource instanceof CMS_poly_object) {
         $resource->writeToPersistence();
     } else {
         $resource->writeToPersistence(false);
         //Clear polymod cache
         //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $this->_codename));
         CMS_cache::clearTypeCache('polymod');
     }
     $modulesCodes->getModulesCodes(MODULE_TREATMENT_AFTER_VALIDATION_TREATMENT, '', $resource, array('result' => $result, 'lastvalidation' => $lastValidation, 'module' => $this->_codename));
     return true;
 }
예제 #5
0
 /**
  * Gets the URL of a link towards a file managed by this application
  *
  * @param boolean $withPath If false, only returns the filename
  * @param string $module If false, only returns the filename
  * @param string $dataLocation Where does the data lies ? See CMS_resource constants
  * @param integer $relativeTo Can be web root or filesystem relative, see base constants
  * @param boolean $withFilename Should the function return the filename too or only the path ?
  * @return string The file
  * @access public
  */
 function getFileLink($withPath = false, $module = MOD_STANDARD_CODENAME, $dataLocation = RESOURCE_DATA_LOCATION_EDITED, $relativeTo = PATH_RELATIVETO_WEBROOT, $withFilename = true)
 {
     if ($withPath) {
         if (class_exists("CMS_resource")) {
             if (!SensitiveIO::isInSet($dataLocation, CMS_resource::getAllDataLocations()) || $dataLocation == RESOURCE_DATA_LOCATION_DEVNULL) {
                 $this->raiseError("DataLocation not in the valid set : " . $dataLocation);
                 return false;
             }
         } else {
             $dataLocation = RESOURCE_DATA_LOCATION_PUBLIC;
         }
         // Prepare module folder name
         $module = $module != '' ? $module . '/' : '';
         // Prepare full path
         switch ($relativeTo) {
             case PATH_RELATIVETO_WEBROOT:
                 $path = PATH_MODULES_FILES_WR . "/" . $module . $dataLocation;
                 break;
             case PATH_RELATIVETO_FILESYSTEM:
                 $path = PATH_MODULES_FILES_FS . "/" . $module . $dataLocation;
                 break;
         }
         if ($withFilename) {
             return $path . "/" . $this->_fileLink;
         } else {
             return $path;
         }
     } else {
         return $this->_fileLink;
     }
 }
예제 #6
0
 /**
  * Get the page content for the specified visualization mode and language.
  *
  * @return string The content of the page.
  * @access public
  */
 function getContent(&$language, $visualizationMode = false)
 {
     if (!$language instanceof CMS_language || !SensitiveIO::isInSet($visualizationMode, CMS_page::getAllVisualizationModes())) {
         $this->raiseError("Language must be a valid language and visualization mode in the set of possibles");
         return false;
     }
     $this->_checkTemplate();
     if ($this->_template) {
         //get parsed content definition from template (including CS block contents)
         $definition = $this->_template->getContent($language, $this, $visualizationMode);
         //instanciate modules treatments for page content tags
         $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_PAGECONTENT_TAGS, $visualizationMode, $this);
         $modulesTreatment->setTreatmentParameters(array("language" => $language));
         $modulesTreatment->setDefinition($definition);
         $content = $modulesTreatment->treatContent(true);
         //instanciate modules treatments for page header tags
         $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_PAGEHEADER_TAGS, $visualizationMode, $this);
         $modulesTreatment->setTreatmentParameters(array("language" => $language, 'replaceVars' => true));
         $modulesTreatment->setDefinition($content);
         $content = $modulesTreatment->treatContent(true);
         /*if ($visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC_INDEXABLE) {
         			//eval() the PHP code
         			$content = sensitiveIO::evalPHPCode($content);
         			return $content;
         		}*/
         //include modules header codes on top of output file
         $modulesCodes = new CMS_modulesCodes();
         $headerInclude = $modulesCodes->getModulesCodes(MODULE_TREATMENT_PAGECONTENT_HEADER_CODE, $visualizationMode, $this);
         if (is_array($headerInclude) && $headerInclude) {
             $content = implode("\n", $headerInclude) . $content;
         }
         //include modules footers codes on bottom of output file
         $footerInclude = $modulesCodes->getModulesCodes(MODULE_TREATMENT_PAGECONTENT_FOOTER_CODE, $visualizationMode, $this);
         if (is_array($footerInclude) && $footerInclude) {
             $content .= implode("\n", $footerInclude);
         }
         //replace {{pageID}} tag in all page content.
         $content = str_replace('{{pageID}}', $this->getID(), $content);
         if ($visualizationMode != PAGE_VISUALMODE_HTML_PUBLIC && $visualizationMode != PAGE_VISUALMODE_PRINT) {
             //eval() the PHP code
             $content = sensitiveIO::evalPHPCode($content);
         }
         return $content;
     } else {
         return false;
     }
 }
예제 #7
0
 /**
  * Deletes the block from a location (public, archived, deleted, edited)
  *
  * @param integer $pageID The page which contains the client space, DB ID
  * @param integer $clientSpaceID The client space which contains the row, DB ID
  * @param integer $rowID The row which contains the block, DB ID
  * @param integer $location The location we want to completly remove the block from
  * @param boolean $public The precision needed for USERSPACE location
  * @param boolean $withfile : delete the attached file if any (default : false)
  * @return boolean true on success, false on failure
  * @access public
  */
 function delFromLocation($pageID, $clientSpaceID, $rowID, $location, $public = false, $withfile = false)
 {
     if (!SensitiveIO::isInSet($location, CMS_resourceStatus::getAllLocations())) {
         $this->raiseError("DelFromLocation was given a bad location");
         return false;
     }
     if ($withfile) {
         $data = $this->getRawData($pageID, $clientSpaceID, $rowID, $location, $public);
         $link = new CMS_href($data["value"]);
         if ($link->getLinkType() == RESOURCE_LINK_TYPE_FILE) {
             //get file path
             $file = $link->getFileLink(true, MOD_STANDARD_CODENAME, $location, PATH_RELATIVETO_FILESYSTEM, true);
             if (file_exists($file)) {
                 @unlink($file);
             }
         }
     }
     $table = $this->_getDataTableName($location, $public);
     $sql = "\n\t\t\tdelete from\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);
     return true;
 }
예제 #8
0
 /**
  * Changes The page data (in the DB) from one location to another.
  *
  * @param CMS_page $resource The resource concerned by the data location change
  * @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 true, data is not deleted from the original location
  * @return void
  * @access private
  */
 protected function _changeDataLocation($resource, $locationFrom, $locationTo, $copyOnly = false)
 {
     if (!$resource instanceof CMS_resource) {
         $this->raiseError("Resource is not a CMS_resource");
         return false;
     }
     if (!SensitiveIO::isInSet($locationFrom, CMS_resource::getAllDataLocations()) || !SensitiveIO::isInSet($locationTo, CMS_resource::getAllDataLocations())) {
         $this->raiseError("Locations are not in the set");
         return false;
     }
     return true;
 }
예제 #9
0
    /**
     * Get All Groups
     * Static function
     *
     * @return array(string)
     * @access public
     */
    static function getAllGroups($returnStack = false, $reset = false)
    {
        static $rowGroups;
        if (!isset($rowGroups) || $reset) {
            $rowGroups = array();
            $sql = '
				select distinct
					groupsStack_row
				from
					mod_standard_rows
			';
            $q = new CMS_query($sql);
            while ($data = $q->getArray()) {
                $groupStackString = $data["groupsStack_row"];
                $groupStack = new CMS_stack();
                $groupStack->setTextDefinition($groupStackString);
                foreach ($groupStack->getElements() as $group) {
                    if (!SensitiveIO::isInSet($group[0], $rowGroups) && $group[0]) {
                        $rowGroups[] = $group[0];
                    }
                }
            }
        }
        //sort groups
        natcasesort($rowGroups);
        if ($returnStack) {
            $stack = new CMS_stack();
            $stack->setValuesByAtom(1);
            foreach ($rowGroups as $rowGroup) {
                $stack->add($rowGroup);
            }
            return $stack;
        } else {
            return $rowGroups;
        }
    }
예제 #10
0
 /**
  * Gets the pages directory. It's derived from the label
  *
  * @param string $relativeTo Can be PATH_RELATIVETO_WEBROOT for relative to website root, or PATH_RELATIVETO_FILESYSTEM for relative to filesystem root
  * @return string The pages directory.
  * @access public
  */
 function getPagesPath($relativeTo)
 {
     if ($this->_codename) {
         if (SensitiveIO::isInSet($relativeTo, array(PATH_RELATIVETO_WEBROOT, PATH_RELATIVETO_FILESYSTEM))) {
             $relative = $relativeTo == PATH_RELATIVETO_WEBROOT ? PATH_PAGES_WR : PATH_PAGES_FS;
             if ($this->_isMain) {
                 if (!is_dir(PATH_PAGES_FS)) {
                     if (!CMS_file::makeDir(PATH_PAGES_FS)) {
                         $this->raiseError('Can\'t create pages dir : ' . PATH_PAGES_FS);
                     }
                 }
                 return $relative;
             } else {
                 if (!is_dir(PATH_PAGES_FS . "/" . io::sanitizeAsciiString($this->_codename))) {
                     if (!CMS_file::makeDir(PATH_PAGES_FS . "/" . io::sanitizeAsciiString($this->_codename))) {
                         $this->raiseError('Can\'t create pages dir : ' . PATH_PAGES_FS . '/' . io::sanitizeAsciiString($this->_codename));
                     }
                 }
                 return $relative . '/' . io::sanitizeAsciiString($this->_codename);
             }
         } else {
             $this->raiseError("Can't give pages path relative to anything other than WR or FS");
             return false;
         }
     } else {
         return false;
     }
 }
예제 #11
0
 /**
  * Move the clientSpaces data from one location to another for a template
  *
  * @param integer $tagID the tag ID of the client space tag
  * @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
  * @param boolean $forceblank If set to false, the page will be checked before removing all content of the clientspace to alert user and get confirmation. In this case, method return false until this parameter is set to true
  * @return boolean true on success, false on failure
  * @access public
  */
 static function moveClientSpaces($templateID, $locationFrom, $locationTo, $copyOnly = false, $forceblank = 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;
     }
     switch ($locationFrom) {
         case RESOURCE_DATA_LOCATION_ARCHIVED:
             $table_from = "mod_standard_clientSpaces_archived";
             break;
         case RESOURCE_DATA_LOCATION_DELETED:
             $table_from = "mod_standard_clientSpaces_deleted";
             break;
         case RESOURCE_DATA_LOCATION_PUBLIC:
             $table_from = "mod_standard_clientSpaces_public";
             break;
         case RESOURCE_DATA_LOCATION_EDITED:
             $table_from = "mod_standard_clientSpaces_edited";
             break;
         case RESOURCE_DATA_LOCATION_EDITION:
             $table_from = "mod_standard_clientSpaces_edition";
             break;
     }
     switch ($locationTo) {
         case RESOURCE_DATA_LOCATION_ARCHIVED:
             $table_to = "mod_standard_clientSpaces_archived";
             break;
         case RESOURCE_DATA_LOCATION_DELETED:
             $table_to = "mod_standard_clientSpaces_deleted";
             break;
         case RESOURCE_DATA_LOCATION_PUBLIC:
             $table_to = "mod_standard_clientSpaces_public";
             break;
         case RESOURCE_DATA_LOCATION_EDITED:
             $table_to = "mod_standard_clientSpaces_edited";
             break;
         case RESOURCE_DATA_LOCATION_EDITION:
             $table_to = "mod_standard_clientSpaces_edition";
             break;
     }
     //check for blank page
     if (!$forceblank && $locationFrom == RESOURCE_DATA_LOCATION_EDITION && $locationTo == RESOURCE_DATA_LOCATION_EDITED) {
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\tcount(*) as c\n\t\t\t\tfrom\n\t\t\t\t\t" . $table_from . "\n\t\t\t\twhere\n\t\t\t\t\ttemplate_cs='" . $templateID . "'";
         $q = new CMS_query($sql);
         if ($q->getValue('c') == 0) {
             $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\tcount(*) as c\n\t\t\t\t\tfrom\n\t\t\t\t\t\t" . $table_to . "\n\t\t\t\t\twhere\n\t\t\t\t\t\ttemplate_cs='" . $templateID . "'";
             $q = new CMS_query($sql);
             if ($q->getValue('c') != 0) {
                 return false;
             }
         }
     }
     //delete all in the destination table just incase and insert
     if ($locationTo != RESOURCE_DATA_LOCATION_DEVNULL) {
         $sql = "\n\t\t\t\tdelete from\n\t\t\t\t\t" . $table_to . "\n\t\t\t\twhere\n\t\t\t\t\ttemplate_cs='" . $templateID . "'\n\t\t\t";
         $q = new CMS_query($sql);
         $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\t" . $table_to . "\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\t" . $table_from . "\n\t\t\t\t\twhere\n\t\t\t\t\t\ttemplate_cs='" . $templateID . "'\n\t\t\t";
         $q = new CMS_query($sql);
     }
     if (!$copyOnly) {
         //delete from the starting table
         $sql = "\n\t\t\t\tdelete from\n\t\t\t\t\t" . $table_from . "\n\t\t\t\twhere\n\t\t\t\t\ttemplate_cs='" . $templateID . "'\n\t\t\t";
         $q = new CMS_query($sql);
     }
     return true;
 }
예제 #12
0
 /**
  * Deletes an edition off the validations refused.
  *
  * @param integer $edition the edition to del from the validations refused
  * @return boolean true on success, false on failure.
  * @access public
  */
 function delValidationRefused($edition)
 {
     if (SensitiveIO::isInSet($edition, $this->getAllEditions())) {
         if ($this->hasValidationRefused($edition)) {
             $this->_validationsRefused -= $edition;
         }
         return true;
     } else {
         $this->raiseError("Unknown edition : " . $edition);
         return false;
     }
 }
예제 #13
0
    /**
     * Get All Groups
     * Static function
     *
     * @return array(string)
     * @access public
     */
    static function getAllGroups($returnStack = false)
    {
        static $templateGroups;
        if (!isset($templateGroups)) {
            $templateGroups = array();
            $sql = '
				select distinct
					groupsStack_pt
				from
					pageTemplates
				where 
					private_pt=0
			';
            $q = new CMS_query($sql);
            while ($data = $q->getArray()) {
                $groupStackString = $data["groupsStack_pt"];
                $groupStack = new CMS_stack();
                $groupStack->setTextDefinition($groupStackString);
                foreach ($groupStack->getElements() as $group) {
                    if (!SensitiveIO::isInSet($group[0], $templateGroups) && $group[0]) {
                        $templateGroups[] = $group[0];
                    }
                }
            }
        }
        //sort groups
        natcasesort($templateGroups);
        if ($returnStack) {
            $stack = new CMS_stack();
            $stack->setValuesByAtom(1);
            foreach ($templateGroups as $tplGroup) {
                $stack->add($tplGroup);
            }
            return $stack;
        } else {
            return $templateGroups;
        }
    }
예제 #14
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;
 }
예제 #15
0
 /**
  * Add group to user and write to persistence immediately
  * The method has to update user's profile and group relationship
  *
  * @var CMS_profile_user $user
  * @return true on success, false on failure
  * @access public
  */
 function addToUserAndWriteToPersistence(&$user, $writeUser = true)
 {
     if (is_a($user, "CMS_profile_user") && !$user->hasError()) {
         //Get current user groups ids
         $userGroupIds = CMS_profile_usersGroupsCatalog::getGroupsOfUser($user, true, true);
         //if user has no group, we must clear his profile before
         if (!$userGroupIds) {
             //reset profile clearances
             $user->resetClearances();
         }
         // Update user profile
         $user->addPageClearances(parent::getPageClearances());
         $user->addModuleClearances(parent::getModuleClearances());
         $user->addModuleCategoriesClearancesStack(parent::getModuleCategoriesClearancesStack());
         $user->addValidationClearances(parent::getValidationClearances());
         $user->addAdminClearance(parent::getAdminClearance());
         $user->addTemplateGroupsDenied(parent::getTemplateGroupsDenied());
         $user->addRowGroupsDenied(parent::getRowGroupsDenied());
         $user->setActive(true);
         if ($writeUser) {
             $user->writeToPersistence();
         }
         if (!$user->hasError()) {
             if (!SensitiveIO::isInSet($user->getUserId(), $this->_users)) {
                 // Insert this user in group
                 $this->_users[] = $user->getUserId();
                 $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\tprofileUsersByGroup\n\t\t\t\t\tset\n\t\t\t\t\t\tgroupId_gu='" . $this->_groupId . "' ,\n\t\t\t\t\t\tuserId_gu='" . $user->getUserID() . "'\n\t\t\t\t\t";
                 $q = new CMS_query($sql);
                 if ($q->hasError()) {
                     $this->raiseError('Insertion failed');
                 } else {
                     return true;
                 }
             } else {
                 return true;
             }
         } else {
             $this->raiseError('User error when adding group values');
         }
     } else {
         $this->raiseError('Incorrect user given');
     }
     return false;
 }
예제 #16
0
 /**
  * Deletes the block from a location (public, archived, deleted, edited)
  *
  * @param integer $pageID The page which contains the client space, DB ID
  * @param integer $clientSpaceID The client space which contains the row, DB ID
  * @param integer $rowID The row which contains the block, DB ID
  * @param integer $location The location we want to completly remove the block from
  * @param boolean $public The precision needed for USERSPACE location
  * @return boolean true on success, false on failure
  * @access public
  */
 function delFromLocation($pageID, $clientSpaceID, $rowID, $location, $public = false)
 {
     if (!SensitiveIO::isInSet($location, CMS_resourceStatus::getAllLocations())) {
         $this->raiseError("DelFromLocation was given a bad location");
         return false;
     }
     $table = $this->_getDataTableName($location, $public);
     $sql = "\n\t\t\tdelete from\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);
     return true;
 }
 /**
  * Moves position of a category in list, with given offset
  * 
  * @access public
  * @param CMS_moduleCategory $siblingCategory 
  * @param integer $moveOffset values 1 or -1 expected
  * @return boolean true on succes, false on failure
  */
 static function moveCategoryOrder(&$siblingCategory, $moveOffset)
 {
     // Checks : pages must be CMS_moduleCategory and offset in (1, -1)
     if (!$siblingCategory instanceof CMS_moduleCategory) {
         CMS_grandFather::raiseError("Category to move not valid.");
         return false;
     }
     if (!SensitiveIO::isInSet($moveOffset, array(1, -1))) {
         CMS_grandFather::raiseError("Offset must be 1 or -1");
         return false;
     }
     // Find the siblings to switch order
     $parent = $siblingCategory->getParent();
     // Use this function to compact of siblings order
     if (!$parent instanceof CMS_moduleCategory || !CMS_moduleCategories_catalog::compactSiblingsOrder($parent->getID())) {
         CMS_grandFather::raiseError("Reordering siblings failed for category " . $parent->getID());
         return false;
     }
     $siblings = $parent->getSiblings();
     $sibling_to_move_left = false;
     $sibling_to_move_right = false;
     $lastSibling = false;
     foreach ($siblings as $aSibling) {
         if ($moveOffset == 1 && $lastSibling && $lastSibling->getID() == $siblingCategory->getID()) {
             $sibling_to_move_left = $aSibling;
             $sibling_to_move_right = $siblingCategory;
             break;
         }
         if ($moveOffset == -1 && $lastSibling && $aSibling->getID() == $siblingCategory->getID()) {
             $sibling_to_move_left = $siblingCategory;
             $sibling_to_move_right = $lastSibling;
             break;
         }
         $lastSibling = $aSibling;
     }
     if ($sibling_to_move_left && $sibling_to_move_right) {
         //move the siblings order
         $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tmodulesCategories\n\t\t\t\tset\n\t\t\t\t\torder_mca=order_mca - 1\n\t\t\t\twhere\n\t\t\t\t\tid_mca='" . $sibling_to_move_left->getID() . "'\n\t\t\t";
         $q = new CMS_query($sql);
         $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tmodulesCategories\n\t\t\t\tset\n\t\t\t\t\torder_mca=order_mca + 1\n\t\t\t\twhere\n\t\t\t\t\tid_mca='" . $sibling_to_move_right->getID() . "'\n\t\t\t";
         $q = new CMS_query($sql);
         //Clear polymod cache
         //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $sibling_to_move_right->getAttribute('moduleCodename')));
         CMS_cache::clearTypeCache('polymod');
         return true;
     } else {
         CMS_grandFather::raiseError("Move impossible (first or last sibling to move, or parent and sibling not related");
         return false;
     }
 }
예제 #18
0
파일: row.php 프로젝트: davidmottet/automne
 /**
  * Sets the image. Can be empty. Must have the gif, jpg, jpeg or png extension.
  *
  * @param string $image the image to set
  * @return boolean true on success, false on failure.
  * @access public
  */
 function setImage($image = 'nopicto.gif')
 {
     if (!trim($image)) {
         $image = 'nopicto.gif';
     }
     $extension = io::substr($image, strrpos($image, ".") + 1);
     if (SensitiveIO::isInSet(io::strtolower($extension), array("jpg", "jpeg", "gif", "png"))) {
         $this->_image = $image;
         return true;
     } else {
         $this->_image = 'nopicto.gif';
         return true;
     }
 }
예제 #19
0
    $pageLink = $_GET["encodedPageLink"] ? base64_decode($_GET["encodedPageLink"]) : $_GET["pageLink"];
    $heading = $_GET["heading"];
    $frame = $_GET["frame"];
    if ($pageLink == 'false' && $_GET["encodedOnClick"]) {
        $onClick = base64_decode($_GET["encodedOnClick"]);
    }
}
$linkTarget = '_self';
//($_GET["linkTarget"]) ? $_GET["linkTarget"]:"main";
//root : Must be set
if (!$startRoot) {
    die("Tree : root page not defined");
}
//pageProperty : must be inside the page_properties array
$page_properties = array("last_creation_date", "template");
if ($pageProperty && !SensitiveIO::isInSet($pageProperty, $page_properties)) {
    die("Tree : unknown page property");
}
$dialog = new CMS_dialog();
if ($hideMenu) {
    $dialog->setMenu(false);
}
//add title
$title = $title ? SensitiveIO::sanitizeHTMLString($title) : $cms_language->getMessage(MESSAGE_PAGE_TITLE);
$pageTitle = $frame && !$onClick ? '<a href="' . CMS_session::getSessionVar('treeHref') . '" target="_self" class="admin_frame">' . $title . '</a>' : $title;
$dialog->setTitle($pageTitle);
$dialog->changeColor();
//add message if any
if ($cms_message) {
    $dialog->setActionMessage($cms_message);
}
예제 #20
0
 /**
  * Constructor.
  * initializes the linx.
  *
  * @param string $type The linx type
  * @param string $tagContent The tag content.
  * @param CMS_page $page The page we're parsing
  * @param boolean $publicTree Does the linx must be calculated in the public or edited tree ?
  * @return void
  * @access public
  */
 function __construct($type, $tagContent, $page, $publicTree = false, $args = array())
 {
     if (!SensitiveIO::isInSet($type, CMS_linxesCatalog::getAllTypes())) {
         $this->raiseError("Constructor has an unknown type : " . $type);
         return;
     } elseif (!is_a($page, "CMS_page")) {
         $this->raiseError("Constructor was not given a valid CMS_page");
         return;
     } else {
         $this->_args = $args;
         $this->_type = $type;
         //Hack for shorthand writing of atm-linx
         //<atm-linx type="direct" node="pageID"> ... </atm-linx>
         //<atm-linx type="direct" codename="pageCodename"> ... </atm-linx>
         if ((isset($this->_args['node']) || isset($this->_args['codename'])) && $this->_type == 'direct') {
             $tag = new CMS_XMLTag('atm-linx', $this->_args);
             $tag->setTextContent($tagContent);
             $tagContent = '<atm-linx type="direct">' . '<selection ' . (isset($this->_args['crosswebsite']) ? ' crosswebsite="' . $this->_args['crosswebsite'] . '"' : '') . '>';
             if (isset($this->_args['node'])) {
                 $tagContent .= '<start><nodespec type="node" value="' . $this->_args['node'] . '" /></start>';
                 //remove useless node argument
                 unset($this->_args['node']);
             } else {
                 $tagContent .= '<start><nodespec type="codename" value="' . $this->_args['codename'] . '" /></start>';
                 //remove useless node argument
                 unset($this->_args['codename']);
             }
             $tagContent .= '</selection>' . '<display>' . '<htmltemplate>' . $tag->getInnerContent() . '</htmltemplate>' . '</display>' . '</atm-linx>';
         }
         $this->_page = $page;
         $this->_publicTree = $publicTree;
         $domdocument = new CMS_DOMDocument();
         try {
             $domdocument->loadXML($tagContent);
         } catch (DOMException $e) {
             $this->raiseError('Malformed atm-linx content in page ' . $page->getID() . ' : ' . $e->getMessage() . "\n" . $tagContent, true);
             return false;
         }
         $selections = $domdocument->getElementsByTagName('selection');
         if ($selections->length > 0) {
             $selection = $selections->item(0);
             //parse the selection for nodespecs and condition
             if (!$this->_parseSelection($selection)) {
                 $this->raiseError();
                 return;
             }
         }
         $noselections = $domdocument->getElementsByTagName('noselection');
         if ($noselections->length > 0) {
             $this->_noselection = $noselections->item(0);
         }
         $displays = $domdocument->getElementsByTagName('display');
         //get the displays objects
         $unsortedDisplays = array();
         foreach ($displays as $display) {
             $unsortedDisplays[] = new CMS_linxDisplay($display);
         }
         //put the default display (the one with no condition) at the end of the array
         $default = false;
         foreach ($unsortedDisplays as $dsp) {
             if ($dsp->hasCondition() && !$default) {
                 $this->_displays[] = $dsp;
             } else {
                 $default = $dsp;
             }
         }
         if ($default) {
             $this->_displays[] = $default;
         }
     }
 }
예제 #21
0
 /**
  * Get the default language.
  *
  * @param boolean guessFromNavigator : try to guess default user language from HTTP_ACCEPT_LANGUAGE (default : false)
  * @return CMS_language The default language
  * @access public
  */
 static function getDefaultLanguage($guessFromNavigator = false)
 {
     if ($guessFromNavigator) {
         //load language object from get value if any
         if (isset($_GET["language"]) && SensitiveIO::isInSet($_GET["language"], array_keys(CMS_languagesCatalog::getAllLanguages()))) {
             $language = CMS_languagesCatalog::getByCode($_GET["language"]);
             if ($language) {
                 return $language;
             }
         } elseif (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && SensitiveIO::isInSet(io::substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2), array_keys(CMS_languagesCatalog::getAllLanguages()))) {
             $language = CMS_languagesCatalog::getByCode(io::substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2));
             if ($language) {
                 return $language;
             }
         }
     }
     return CMS_languagesCatalog::getByCode(APPLICATION_DEFAULT_LANGUAGE);
 }
예제 #22
0
 /**
  * Get the content of the template for the specified page and visualization mode.
  * Doesn't translates the atm-linx tags.
  *
  * @param CMS_language $language The language of the administration frontend (for FORM visualization mode)
  * @param CMS_page $page The page we want the content of
  * @param integer $visualizationMode The visualization mode of the page
  * @return string the content
  * @access private
  */
 function getContent(&$language, &$page, $visualizationMode)
 {
     if (!$page instanceof CMS_page || !SensitiveIO::isInSet($visualizationMode, CMS_page::getAllvisualizationModes())) {
         $this->raiseError("Page must be a CMS_page and visualization mode in the possibles");
         return false;
     }
     $returnIndexableContent = false;
     if ($visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC_INDEXABLE) {
         $visualizationMode = PAGE_VISUALMODE_PRINT;
         $returnIndexableContent = true;
     }
     $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_CLIENTSPACE_TAGS, $visualizationMode, $this);
     $modulesTreatment->setTreatmentParameters(array("page" => $page, "language" => $language));
     if ($this->_parseDefinitionFile($modulesTreatment) === true) {
         if ($visualizationMode == PAGE_VISUALMODE_PRINT || $returnIndexableContent) {
             $data = '';
             $tags = $modulesTreatment->getTags(array(), true);
             foreach ($tags as $tag) {
                 $data .= $modulesTreatment->treatWantedTag($tag);
             }
         } else {
             $data = $modulesTreatment->treatContent(true);
         }
         //if we only need indexable content, return data here without any treatment on template
         if ($returnIndexableContent) {
             return '<html><body>' . $data . '</body></html>';
         }
         //separate processing for PRINT visualmode
         if ($visualizationMode == PAGE_VISUALMODE_PRINT) {
             //now put the data inside the template
             $template_data = file_get_contents(PATH_PRINT_TEMPLATES_FS);
             //we need to remove doctype if any
             $template_data = preg_replace('#<!doctype[^>]*>#siU', '', $template_data);
             return '<?php /* Template [' . str_replace(PATH_TEMPLATES_FS . '/', '', PATH_PRINT_TEMPLATES_FS) . '] */?>' . str_replace("{{data}}", $data, $template_data);
         } else {
             return '<?php /* Template [' . $this->getLabel() . ' - ' . $this->getDefinitionFile() . '] */?>' . $data;
         }
         return false;
     } else {
         return false;
     }
 }
예제 #23
0
 /**
  * add Page Clearances
  *
  * @param integer $pageId pageid 
  * @param integer $clearance clearance to add
  * @param boolean $overwrite if true overwrites previous clearance
  * @return void
  * @access public
  */
 function addPageClearance($pageId, $clearance, $overwrite)
 {
     if (!SensitiveIO::isInSet($clearance, $this->getAllPageClearances())) {
         $this->raiseError("Invalid Page Clearance: " . $clearance);
     } else {
         if (!SensitiveIO::isPositiveInteger($pageId)) {
             $this->raiseError("Invalid Page Id Clearance: " . $pageId);
         } else {
             if ($this->_pageClearances->getElementsWithOneValue($pageId, 1)) {
                 if ($overwrite) {
                     $this->_pageClearances->delAllWithOneValue($pageId, 1);
                     $this->_pageClearances->add($pageId, $clearance);
                 }
             } else {
                 $this->_pageClearances->add($pageId, $clearance);
             }
         }
     }
 }
예제 #24
0
 /**
  * Deletes the block from a location (public, archived, deleted, edited)
  *
  * @param integer $pageID The page which contains the client space, DB ID
  * @param integer $clientSpaceID The client space which contains the row, DB ID
  * @param integer $rowID The row which contains the block, DB ID
  * @param integer $location The location we want to completly remove the block from
  * @param boolean $public The precision needed for USERSPACE location
  * @param boolean $withfile : delete the attached file if any (default : false)
  * @return boolean true on success, false on failure
  * @access public
  */
 function delFromLocation($pageID, $clientSpaceID, $rowID, $location, $public = false, $withfile = false)
 {
     if (!SensitiveIO::isInSet($location, CMS_resourceStatus::getAllLocations())) {
         $this->raiseError("DelFromLocation was given a bad location");
         return false;
     }
     if ($withfile) {
         $data = $this->getRawData($pageID, $clientSpaceID, $rowID, $location, $public);
         $folder = $this->_getFolderName($location, $public);
         if ($data['file']) {
             //get folder for files
             if (file_exists(PATH_MODULES_FILES_STANDARD_FS . '/' . $folder . '/' . $data['file'])) {
                 @unlink(PATH_MODULES_FILES_STANDARD_FS . '/' . $folder . '/' . $data['file']);
             }
         }
         if ($data['enlargedFile']) {
             //get folder for files
             if (file_exists(PATH_MODULES_FILES_STANDARD_FS . '/' . $folder . '/' . $data['enlargedFile'])) {
                 @unlink(PATH_MODULES_FILES_STANDARD_FS . '/' . $folder . '/' . $data['enlargedFile']);
             }
         }
         if ($data['externalLink']) {
             $link = new CMS_href($data["externalLink"]);
             $file = $link->getFileLink(true, MOD_STANDARD_CODENAME, $folder, PATH_RELATIVETO_FILESYSTEM);
             if (file_exists($file)) {
                 @unlink($file);
             }
         }
     }
     $table = $this->_getDataTableName($location, $public);
     $sql = "\n\t\t\tdelete from\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);
     return true;
 }
예제 #25
0
 /**
  * Compares two dates using the given operator.
  * Static function.
  *
  * @param CMS_date $date1 The leftmost date of the comparison
  * @param CMS_date $date2 The rightmost date of the comparison
  * @param string $operator the comparison operator. Can be one of ==,>=,>,<=,<
  * @return boolean true if the comparison is true, false otherwise
  * @access public
  */
 static function compare($date1, $date2, $operator)
 {
     $allowed_operators = array("==", ">=", ">", "<", "<=");
     if (SensitiveIO::isInSet($operator, $allowed_operators)) {
         $func_body = sprintf('if (%s %s %s) { return true ; } else { return false ; }', $date1->getTimestamp(), $operator, $date2->getTimestamp());
         $func = create_function('', $func_body);
         if (!$func) {
             return false;
         }
         return $func();
     } else {
         return false;
     }
 }
예제 #26
0
 /**
  * Writes the block data into persistence (destroys previous and insert new)
  *
  * @param integer $pageID The page which contains the client space, DB ID
  * @param integer $clientSpaceID The client space which contains the row, DB ID
  * @param integer $rowID The row which contains the block, DB ID
  * @param integer $location The location we want to completly remove the block from
  * @param boolean $public The precision needed for USERSPACE location
  * @param array(mixed=>mixed) $data The data indexed by data type (value, file, alt_tag, ...), 
  * @return boolean true on success, false on failure
  * @access public
  */
 function writeToPersistence($pageID, $clientSpaceID, $rowID, $location, $public, $data)
 {
     if (!SensitiveIO::isInSet($location, CMS_resourceStatus::getAllLocations())) {
         $this->raiseError("writeToPersistence was given a bad location");
         return false;
     }
 }
예제 #27
0
 /**
  * Change a sibling order. Add the RESOURCE_EDITION_SIBLINGSORDER edition to the father.
  * Static function.
  *
  * @param CMS_page $sibling The sibling page to move
  * @param integer $moveOffset The move offset : 1 to move it to the right, -1 to the left. No other values permitted.
  * @param CMS_profile_user $user The user operating the change.
  * @return boolean true on success, false on failure
  * @access public
  */
 static function changeSiblingOrder(&$sibling, $moveOffset, &$user)
 {
     //checks : pages must be CMS_pages and offset in (1, -1)
     if (!is_a($sibling, "CMS_page")) {
         CMS_grandFather::raiseError("Page must be instance of CMS_page");
         return false;
     }
     if (!SensitiveIO::isInSet($moveOffset, array(1, -1))) {
         CMS_grandFather::raiseError("Offset must be 1 or -1");
         return false;
     }
     // Find the siblings to switch order
     $father = CMS_tree::getAncestor($sibling, 1);
     // Use this function to compact of siblings order
     if (!CMS_tree::compactSiblingOrder($father)) {
         CMS_grandFather::raiseError("Reordering siblings failed for page " . $father->getID());
         return false;
     }
     $siblings = CMS_tree::getSiblings($father);
     $sibling_to_move_left = false;
     $sibling_to_move_right = false;
     $lastSibling = false;
     foreach ($siblings as $aSibling) {
         if ($moveOffset == 1 && $lastSibling && $lastSibling->getID() == $sibling->getID()) {
             $sibling_to_move_left = $aSibling;
             $sibling_to_move_right = $sibling;
             break;
         }
         if ($moveOffset == -1 && $lastSibling && $aSibling->getID() == $sibling->getID()) {
             $sibling_to_move_left = $sibling;
             $sibling_to_move_right = $lastSibling;
             break;
         }
         $lastSibling = $aSibling;
     }
     if ($sibling_to_move_left && $sibling_to_move_right) {
         //move the siblings order
         $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tlinx_tree_edited\n\t\t\t\tset\n\t\t\t\t\torder_ltr=order_ltr - 1\n\t\t\t\twhere\n\t\t\t\t\tsibling_ltr='" . $sibling_to_move_left->getID() . "'\n\t\t\t";
         $q = new CMS_query($sql);
         $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tlinx_tree_edited\n\t\t\t\tset\n\t\t\t\t\torder_ltr=order_ltr + 1\n\t\t\t\twhere\n\t\t\t\t\tsibling_ltr='" . $sibling_to_move_right->getID() . "'\n\t\t\t";
         $q = new CMS_query($sql);
         //set the father status editions
         $father->addEdition(RESOURCE_EDITION_SIBLINGSORDER, $user);
         $father->writeToPersistence();
         return true;
     } else {
         CMS_grandFather::raiseError("Move impossible (first or last sibling to move, or father and sibling not related");
         return false;
     }
 }