/**
  * Returns all the resource validations the user can do
  * Static function.
  *
  * @param CMS_user $user The user we want the validations of
  * @param string $module_codebame The module codename we want the validations of, if ommitted, validations for all the modules will be returned
  * @return array(string=>CMS_resourceValidation) The validations to do, indexed by module codename
  * @access public
  */
 static function getValidations(&$user, $module_codename = false)
 {
     if (!is_a($user, "CMS_user")) {
         parent::raiseError("User is not a valid CMS_user object");
         return;
     }
     if ($module_codename) {
         if (!($module = CMS_resourceModulesCatalog::getByCodename($codename))) {
             return;
         }
     }
     if ($module) {
         $modules = array($module);
     } else {
         $modules = CMS_modulesCatalog::getAll();
     }
     $validations = array();
     foreach ($modules as $aModule) {
         if (!$user->hasValidationClearance($aModule->getID())) {
             continue;
         }
         $validations_to_add = $aModule->getValidations($user);
         if ($validations_to_add) {
             $validations[$aModule->getCodename()] = $validations_to_add;
         }
     }
     return $validations;
 }
Beispiel #2
0
 /**
  * Constructor.
  * initializes object.
  * @param integer $treatmentMode The current treatment mode (see constants in cms_rc.php for accepted values).
  * @param integer $visualizationMode The current visualization mode (see constants in cms_rc.php for accepted values).
  * @param object $treatedObject The reference object to treat.
  *
  * @return void
  * @access public
  */
 function __construct($treatmentMode, $visualizationMode, &$treatedObject)
 {
     $this->_treatmentMode = $treatmentMode;
     $this->_visualizationMode = $visualizationMode;
     $this->_treatedObject =& $treatedObject;
     $this->_modules = CMS_modulesCatalog::getAll("id");
     foreach ($this->_modules as $codename => $aModule) {
         $moduleTreatment = $aModule->getWantedTags($this->_treatmentMode, $this->_visualizationMode, $this->_treatedObject);
         if ($treatmentMode == MODULE_TREATMENT_PAGECONTENT_TAGS && isset($moduleTreatment['atm-meta-tags'])) {
             $this->raiseError("Tag atm-meta-tags must be treated in MODULE_TREATMENT_PAGEHEADER_TAGS mode. Module " . $codename . " try to use atm-meta-tags in MODULE_TREATMENT_PAGECONTENT_TAGS mode which is deprecated since Automne V4.0.0RC3. Edit file " . $codename . ".php and change MODULE_TREATMENT_PAGECONTENT_TAGS by MODULE_TREATMENT_PAGEHEADER_TAGS in methods getWantedTags and treatWantedTag for tag atm-meta-tags");
             unset($moduleTreatment['atm-meta-tags']);
         }
         if (is_array($moduleTreatment) && $moduleTreatment) {
             //if module return tags, save it.
             $this->_modulesTreatment[$codename] = $moduleTreatment;
         } else {
             //else remove useless modules from list
             unset($this->_modules[$codename]);
         }
     }
     return true;
 }
Beispiel #3
0
 /**
  * Delete object and values.
  * If object is a primary resource, this deletion is submitted to validation and an email is sent to validators.
  *
  * @param boolean $hardDelete : completely destroy object and associated resource if any. After this, this object will no longer exists at all. Default : false.
  * /!\ if object is a primary resource, no validation will be queried to validators, object will be directly destroyed from all locations. /!\
  * @return boolean true on success, false on failure
  * @access public
  */
 function delete($hardDelete = false)
 {
     global $cms_user;
     //get Object definition
     $objectDef = $this->getObjectDefinition();
     //get module codename
     $polyModuleCodename = $objectDef->getValue('module');
     //if object is not a primary resource
     if ($this->_objectResourceStatus != 1 || $hardDelete) {
         $forceSecondaryRessourcePublication = false;
         if ($this->_objectResourceStatus == 2 && !$hardDelete) {
             //if this object is a secondary resource, primary items which uses this object must be updated
             //get all primary resource associated
             $primaryItems = CMS_poly_object_catalog::getPrimaryItemsWhichUsesSecondaryItem($this->_ID, true, false);
             if ($primaryItems) {
                 foreach ($primaryItems as $primaryItem) {
                     $primaryItem->writeToPersistence();
                 }
             } else {
                 $forceSecondaryRessourcePublication = true;
             }
         }
         //if object is not a secondary resource, delete public datas, else preserve it : it will be deleted on primary resource validation
         if ($this->_objectResourceStatus != 2 || $this->_objectResourceStatus == 2 && $forceSecondaryRessourcePublication || $hardDelete) {
             //delete datas from public locations
             CMS_modulePolymodValidation::moveResourceData($polyModuleCodename, $this->getID(), RESOURCE_DATA_LOCATION_PUBLIC, RESOURCE_DATA_LOCATION_DEVNULL);
             if (!$hardDelete) {
                 //mark item as deleted
                 CMS_modulePolymodValidation::markDeletedItem($this->getID());
             } else {
                 //destroy poly_object reference
                 $sql = "delete from mod_object_polyobjects where id_moo = '" . $this->getID() . "'";
                 new CMS_query($sql);
             }
         }
         if ($this->_objectResourceStatus != 1 && $this->_objectResourceStatus != 2 || $this->_objectResourceStatus == 2 && $forceSecondaryRessourcePublication) {
             $modulesCodes = new CMS_modulesCodes();
             //add a call to all modules for before validation specific treatment
             $modulesCodes->getModulesCodes(MODULE_TREATMENT_BEFORE_VALIDATION_TREATMENT, '', $this, array('result' => VALIDATION_OPTION_ACCEPT, 'lastvalidation' => true, 'module' => $polyModuleCodename, 'action' => 'delete'));
         }
         if (!$hardDelete) {
             //move resource datas from edited to deleted location
             CMS_modulePolymodValidation::moveResourceData($polyModuleCodename, $this->getID(), RESOURCE_DATA_LOCATION_EDITED, RESOURCE_DATA_LOCATION_DELETED);
         } else {
             //delete datas from edited locations
             CMS_modulePolymodValidation::moveResourceData($polyModuleCodename, $this->getID(), RESOURCE_DATA_LOCATION_EDITED, RESOURCE_DATA_LOCATION_DEVNULL);
         }
         if ($this->_objectResourceStatus != 1 && $this->_objectResourceStatus != 2 || $this->_objectResourceStatus == 2 && $forceSecondaryRessourcePublication) {
             //add a call to all modules for after validation specific treatment
             $modulesCodes->getModulesCodes(MODULE_TREATMENT_AFTER_VALIDATION_TREATMENT, '', $this, array('result' => VALIDATION_OPTION_ACCEPT, 'lastvalidation' => true, 'module' => $polyModuleCodename, 'action' => 'delete'));
         }
         if ($this->_objectResourceStatus == 1 && $hardDelete) {
             //delete associated resource
             parent::destroy();
         }
         //Log action
         $log = new CMS_log();
         $language = $cms_user->getLanguage();
         $log->logMiscAction(CMS_log::LOG_ACTION_RESOURCE_DELETE, $cms_user, 'Item \'' . $this->getLabel() . '\' (' . $objectDef->getLabel($language) . ')', $polyModuleCodename);
         if ($hardDelete) {
             unset($this);
         }
         //Clear polymod cache
         //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $polyModuleCodename));
         CMS_cache::clearTypeCache('polymod');
         return true;
     } else {
         //change the article proposed location and send emails to all the validators
         if ($this->setProposedLocation(RESOURCE_LOCATION_DELETED, $cms_user)) {
             parent::writeToPersistence();
             if (APPLICATION_ENFORCES_WORKFLOW) {
                 if (!NO_APPLICATION_MAIL) {
                     //get editors
                     $editors = $this->getEditors();
                     $editorsIds = array();
                     foreach ($editors as $editor) {
                         $editorsIds[] = $editor->getUserId();
                     }
                     $validators = CMS_profile_usersCatalog::getValidators($polyModuleCodename);
                     foreach ($validators as $validator) {
                         //add script to send email for validator if needed
                         CMS_scriptsManager::addScript($polyModuleCodename, array('task' => 'emailNotification', 'object' => $this->getID(), 'validator' => $validator->getUserId(), 'type' => 'delete', 'editors' => $editorsIds));
                     }
                     //then launch scripts execution
                     CMS_scriptsManager::startScript();
                 }
             } else {
                 $validation = new CMS_resourceValidation($polyModuleCodename, RESOURCE_EDITION_LOCATION, $this);
                 $mod = CMS_modulesCatalog::getByCodename($polyModuleCodename);
                 $mod->processValidation($validation, VALIDATION_OPTION_ACCEPT);
             }
             //Log action
             $log = new CMS_log();
             $language = $cms_user->getLanguage();
             $log->logResourceAction(CMS_log::LOG_ACTION_RESOURCE_DELETE, $cms_user, $polyModuleCodename, $this->getStatus(), 'Item \'' . $this->getLabel() . '\' (' . $objectDef->getLabel($language) . ')', $this);
             //Clear polymod cache
             //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $polyModuleCodename));
             CMS_cache::clearTypeCache('polymod');
             return true;
         } else {
             return false;
         }
     }
 }
Beispiel #4
0
    } else {
        $content .= 'Error during database update ! Script ' . PATH_MAIN_FS . '/sql/updates/v413-to-v420-6.sql must be executed manualy<br/>';
    }
}
//remove APPLICATION LDAP AUTH from standard_rc.xml
$standard = CMS_modulesCatalog::getByCodename(MOD_STANDARD_CODENAME);
$params = $standard->getParameters(false, true, true);
if (isset($params['APPLICATION_LDAP_AUTH'])) {
    unset($params['APPLICATION_LDAP_AUTH']);
    $standard->setAndWriteParameters($params);
    $content .= 'Remove LDAP parameter from standard module.<br /><br />';
}
//END UPDATE FROM 4.1.3 TO 4.2.0
//START UPDATE FROM 4.2.0 TO 4.2.1
//remove APPLICATION ALLOW_IMAGES_IN_WYSIWYG from standard_rc.xml
$standard = CMS_modulesCatalog::getByCodename(MOD_STANDARD_CODENAME);
$params = $standard->getParameters(false, true, true);
if (isset($params['ALLOW_IMAGES_IN_WYSIWYG'])) {
    unset($params['ALLOW_IMAGES_IN_WYSIWYG']);
    $standard->setAndWriteParameters($params);
    $content .= 'Remove Wysiwyg image parameter from standard module.<br /><br />';
}
//END UPDATE FROM 4.2.0 TO 4.2.1
// START UPDATE FROM 4.2.1 TO 4.2.2
#add namespaces to RSS mod_object_rss_definition
$sql = "show columns from mod_object_rss_definition";
$q = new CMS_query($sql);
$installed = false;
while ($r = $q->getArray()) {
    if ($r["Field"] == "namespaces_mord") {
        $installed = true;
Beispiel #5
0
 /**
  * Parse the definition file as to get the client spaces
  *
  * @param CMS_modulesTags $modulesTreatment tags object treatment
  * @return string The error string from the parser, false if no error
  * @access private
  */
 protected function _parseDefinitionFile(&$modulesTreatment, $convert = null)
 {
     global $cms_language;
     if (!$this->_definitionFile) {
         return false;
     }
     $filename = PATH_TEMPLATES_FS . "/" . $this->_definitionFile;
     $tpl = new CMS_file(PATH_TEMPLATES_FS . "/" . $this->_definitionFile);
     if (!$tpl->exists()) {
         $this->raiseError('Can not found template file ' . PATH_TEMPLATES_FS . "/" . $this->_definitionFile);
         return false;
     }
     $definition = $tpl->readContent();
     //we need to remove doctype if any
     $definition = trim(preg_replace('#<!doctype[^>]*>#siU', '', $definition));
     $modulesTreatment->setDefinition($definition);
     //get client spaces modules codename
     $this->_clientSpacesTags = $modulesTreatment->getTags(array('atm-clientspace'), true);
     if (is_array($this->_clientSpacesTags)) {
         $modules = array();
         foreach ($this->_clientSpacesTags as $cs_tag) {
             if ($cs_tag->getAttribute("module")) {
                 $modules[] = $cs_tag->getAttribute("module");
             }
         }
         $blocks = $modulesTreatment->getTags(array('block'), true);
         foreach ($blocks as $block) {
             if ($block->getAttribute("module")) {
                 $modules[] = $block->getAttribute("module");
             } else {
                 return $cms_language->getMessage(self::MESSAGE_TPL_SYNTAX_ERROR, array($cms_language->getMessage(self::MESSAGE_BLOCK_SYNTAX_ERROR)));
             }
         }
         $modules = array_unique($modules);
         $this->_modules->emptyStack();
         foreach ($modules as $module) {
             $this->_modules->add($module);
         }
         if ($convert !== null) {
             $tplConverted = false;
             foreach ($modules as $moduleCodename) {
                 if (CMS_modulesCatalog::isPolymod($moduleCodename)) {
                     $tplConverted = true;
                     $module = CMS_modulesCatalog::getByCodename($moduleCodename);
                     $definition = $module->convertDefinitionString($definition, $convert == self::CONVERT_TO_HUMAN);
                 }
             }
             if ($tplConverted) {
                 //check definition parsing
                 $parsing = new CMS_polymod_definition_parsing($definition, true, CMS_polymod_definition_parsing::CHECK_PARSING_MODE);
                 $errors = $parsing->getParsingError();
                 if ($errors) {
                     return $cms_language->getMessage(self::MESSAGE_TPL_SYNTAX_ERROR, array($errors));
                 }
                 $filename = $this->getDefinitionFile();
                 $file = new CMS_file(PATH_TEMPLATES_FS . "/" . $filename);
                 $file->setContent($definition);
                 $file->writeToPersistence();
             }
         }
         return true;
     } else {
         $this->raiseError("Malformed definition file : " . $this->_definitionFile . "<br />" . $modulesTreatment->getParsingError());
         return $modulesTreatment->getParsingError();
     }
 }
 /**
  * Replace vars like {object:field:type} or {var|session|request|page:name:type}. Called during definition compilation
  *
  * @param string $text : the text which need to be replaced
  * @param boolean reverse : reverse single and double quotes useage (default is false : double quotes)
  * @param array $optionalReplacement : optionnal replacement to do
  * @param boolean $cleanNotMatches : remove vars without matches
  * @param mixed $matchCallback : function name or array(object classname, object method) which represent a valid callback function to execute on matches
  * @return text : the text replaced
  * @access public
  */
 function preReplaceVars($text, $reverse = false, $cleanNotMatches = false, $matchCallback = array('CMS_polymod_definition_parsing', 'encloseString'), $returnMatchedVarsArray = false)
 {
     static $replacements;
     //if no text => return
     if (!$text || !trim($text)) {
         return $text;
     }
     //substitute simple replacement values
     $preReplaceCount = 0;
     $text = preg_replace("#{([a-zA-Z]+)}#", '@@@\\1@@@', $text, -1, $preReplaceCount);
     $count = 1;
     //loop on text for vars to replace if any
     while (preg_match_all("#{[^{}\n]+}#", $text, $matches) && $count) {
         $matches = array_unique($matches[0]);
         //get all tags handled by modules
         if (!$replacements) {
             //create replacement array
             $replacements = array();
             $modules = CMS_modulesCatalog::getAll("id");
             foreach ($modules as $codename => $aModule) {
                 $moduleReplacements = $aModule->getModuleReplacements();
                 if (is_array($moduleReplacements) && $moduleReplacements) {
                     foreach ($moduleReplacements as $pattern => $replacement) {
                         $replacements[$pattern] = $replacement;
                     }
                 }
             }
         }
         $replace = $replacements;
         //pr($matches);
         if ($reverse) {
             $reversedReplace = array();
             foreach ($replace as $key => $value) {
                 $reversedReplace[str_replace("'", "\\\\'", $key)] = $value;
             }
             $replace = $reversedReplace;
         }
         $count = 0;
         $matchesValues = preg_replace(array_keys($replace), $replace, $matches, -1, $count);
         //create vars conversion table
         $replace = array();
         if ($matchesValues) {
             if (isset($this->_parameters['module'])) {
                 $externalReferences = CMS_poly_object_catalog::getFieldsReferencesUsage($this->_parameters['module']);
             } else {
                 $externalReferences = CMS_poly_object_catalog::getFieldsReferencesUsage();
             }
             foreach ($matches as $key => $match) {
                 //record external references for cache reference
                 if ($externalReferences) {
                     foreach ($externalReferences as $id => $type) {
                         if (strpos($match, '[\'fields\'][' . $id . ']') !== false || strpos($match, '[\\\'fields\\\'][' . $id . ']') !== false) {
                             //CMS_grandFather::log(print_r($this->_elements, true));
                             $this->_elements = array_merge_recursive($type, (array) $this->_elements);
                             //CMS_grandFather::log(print_r($this->_elements, true));
                         }
                     }
                 }
                 //record used pages for cache reference
                 if (strpos($match, '{page:') !== false) {
                     $this->_elements['module'][] = MOD_STANDARD_CODENAME;
                 }
                 //record used users for cache reference
                 if (strpos($match, '{user:'******'resource'][] = 'users';
                 }
                 if ($match != $matchesValues[$key]) {
                     $matchValue = $matchesValues[$key];
                 } else {
                     $matchValue = null;
                 }
                 //apply callback if any to value
                 if (isset($matchValue)) {
                     if ($matchCallback !== false) {
                         if (is_callable($matchCallback)) {
                             $replace[$match] = call_user_func($matchCallback, $matchValue, $reverse);
                         } else {
                             CMS_grandFather::raiseError("Unknown callback function : " . $matchCallback);
                             return false;
                         }
                     } else {
                         $replace[$match] = $matchValue;
                     }
                 } elseif ($cleanNotMatches) {
                     $replace[$match] = '';
                 }
             }
         }
         //return matched vars if needed
         if ($returnMatchedVarsArray) {
             //substitute simple replacement values
             if ($preReplaceCount) {
                 $replace = preg_replace("#\\@\\@\\@([a-zA-Z]+)\\@\\@\\@#", '{\\1}', $replace);
             }
             return $replace;
         } else {
             //then replace variables in text and return it
             $text = str_replace(array_keys($replace), $replace, $text);
         }
     }
     //substitute simple replacement values
     if ($preReplaceCount) {
         $text = preg_replace("#\\@\\@\\@([a-zA-Z]+)\\@\\@\\@#", '{\\1}', $text);
     }
     return $text;
 }
Beispiel #7
0
define("MESSAGE_PAGE_VERSION", 542);
define("MESSAGE_PAGE_ABOUT_MESSAGE", 672);
define("MESSAGE_TOOLBAR_HELP_MESSAGE", 673);
define("MESSAGE_PAGE_TITLE", 644);
//load interface instance
$view = CMS_view::getInstance();
//set default display mode for this page
$view->setDisplayMode(CMS_view::SHOW_RAW);
//This file is an admin file. Interface must be secure
$view->setSecure();
if (!defined('MOD_POLYMOD_CODENAME')) {
    define('MOD_POLYMOD_CODENAME', 'polymod');
}
//show version number
$lastUpdate = AUTOMNE_LASTUPDATE ? date($cms_language->getDateFormat() . ' - H:i:s', AUTOMNE_LASTUPDATE) : $cms_language->getMessage(MESSAGE_PAGE_NEVER);
$modules = CMS_modulesCatalog::getAll();
$modulesInfo = '<ul>';
foreach ($modules as $module) {
    if (!$module->isPolymod() && $module->getCodename() != MOD_STANDARD_CODENAME) {
        $modulesInfo .= '<li>' . $module->getLabel($cms_language);
        if (file_exists(PATH_MODULES_FS . '/' . $module->getCodename() . '/VERSION')) {
            $modulesInfo .= ' - ' . $cms_language->getMessage(MESSAGE_PAGE_VERSION) . ' : ' . file_get_contents(PATH_MODULES_FS . '/' . $module->getCodename() . '/VERSION');
        }
        if ($module->getCodename() == 'mail' && file_exists(PATH_MODULES_FS . '/mailing/VERSION')) {
            $modulesInfo .= ' - ' . $cms_language->getMessage(MESSAGE_PAGE_VERSION) . ' : ' . file_get_contents(PATH_MODULES_FS . '/mailing/VERSION');
        }
        $modulesInfo .= '</li>';
    }
}
$modulesInfo .= '</ul>';
//Scripts content
Beispiel #8
0
 /**
  * Get Module
  *
  * @return CMS_module
  * @access public
  */
 function getModule()
 {
     if ($this->_module) {
         return CMS_modulesCatalog::getByCodename($this->_module);
     } else {
         return false;
     }
 }
Beispiel #9
0
 /**
  * Constructor.
  * initializes object.
  *
  * @return void
  * @access public
  */
 function __construct()
 {
     //get all modules
     $this->_modules = CMS_modulesCatalog::getAll("id");
 }
Beispiel #10
0
 /**
  * Get field parameters as an array structure used for export
  *
  * @return array : the object array structure
  * @access public
  */
 public function asArray()
 {
     $aParameters = parent::asArray();
     $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
     $module = CMS_modulesCatalog::getByCodename($moduleCodename);
     //convert definitions
     $aParameters['emailSubject'] = $module->convertDefinitionString($aParameters['emailSubject'], true);
     $aParameters['emailBody']['html'] = $module->convertDefinitionString($aParameters['emailBody']['html'], true);
     $aParameters['emailBody']['pageURL'] = $module->convertDefinitionString($aParameters['emailBody']['pageURL'], true);
     return $aParameters;
 }
Beispiel #11
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;
     }
     //look for block parameters requirement
     $this->_lookForBlockParameters();
     $this->_hasParameters = $data && is_array($data["value"]) && $data["value"] ? true : false;
     //build the HTML
     switch ($visualizationMode) {
         case PAGE_VISUALMODE_PRINT:
         case PAGE_VISUALMODE_HTML_PUBLIC:
             if ($this->_hasParameters && $this->_musthaveParameters || !$this->_musthaveParameters) {
                 return $this->_createDatasFromDefinition($data["value"], $page, $visualizationMode, CMS_polymod_definition_parsing::OUTPUT_PHP);
             }
             break;
         case PAGE_VISUALMODE_HTML_EDITED:
         case PAGE_VISUALMODE_HTML_EDITION:
             if ($this->_hasParameters && $this->_musthaveParameters || !$this->_musthaveParameters) {
                 return $this->_createDatasFromDefinition($data["value"], $page, $visualizationMode, CMS_polymod_definition_parsing::OUTPUT_PHP);
             }
             break;
         case PAGE_VISUALMODE_FORM:
             global $cms_user;
             $module = CMS_modulesCatalog::getByCodename($this->_attributes['module']);
             $this->_administrable = $module->hasAdmin() && $cms_user->hasModuleClearance($this->_attributes['module'], CLEARANCE_MODULE_EDIT);
             $this->_editable = $this->_canhasParameters && $cms_user->hasModuleClearance($this->_attributes['module'], CLEARANCE_MODULE_EDIT);
             if ($this->_hasParameters && $this->_musthaveParameters || !$this->_musthaveParameters) {
                 $this->_hasContent = true;
                 $form_data = $this->_createDatasFromDefinition($data["value"], $page, $visualizationMode, CMS_polymod_definition_parsing::OUTPUT_PHP);
             } else {
                 $this->_hasContent = false;
                 $form_data = '<img src="' . PATH_ADMIN_MODULES_WR . '/polymod/block.gif" alt="X" title="X" />';
             }
             return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             break;
         case PAGE_VISUALMODE_CLIENTSPACES_FORM:
             $this->_hasContent = $this->_editable = $this->_administrable = false;
             $form_data = '<img src="' . PATH_ADMIN_MODULES_WR . '/polymod/block.gif" alt="X" title="X" />';
             return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             break;
     }
     return;
 }
 /**
  * Data access method : get the resource object
  *
  * @return CMS_resource The resource object, i.e. the subclassed resource object. Return false on failure to retrieve it.
  * @access public
  */
 function getResource()
 {
     if ($module = CMS_modulesCatalog::getByCodename($this->_moduleCodename)) {
         return $module->getResourceByID($this->_resourceID);
     } else {
         return false;
     }
 }
 /**
  * Parse the content of a template for module parameters and returns the content.
  * Usually used by the getData() function to handle template files and feed them with module parameters
  *
  * @param string $filename The filename of the template, located in the templates directory
  * @return string the data from the rows.
  * @access private
  */
 protected function _parseTemplateForParameters($filename)
 {
     $module = CMS_modulesCatalog::getByCodename($this->_attributes["module"]);
     if (!$module instanceof CMS_module) {
         $this->raiseError("No module defined for the clientspace");
         return false;
     }
     $parameters = $module->getParameters();
     $templateFile = new CMS_file(PATH_TEMPLATES_FS . "/" . $filename);
     if ($templateFile->exists()) {
         $cdata = $templateFile->getContent();
         //no need to be complicated if no parameters
         if (!$parameters) {
             return $cdata;
         }
         //"parse" template for parameters. No XML parsing (PHP code produces strange results)
         //MUST wipe out the linefeeds, because pcre's stop at them !!!
         $cdata_pcre = str_replace("\n", "§§", $cdata);
         while (true) {
             unset($regs);
             preg_match('/(.*)(<module-param [^>]*\\/>)(.*)/', $cdata_pcre, $regs);
             if (isset($regs[2])) {
                 $param_value = '';
                 $domdocument = new CMS_DOMDocument();
                 try {
                     $domdocument->loadXML('<dummy>' . $regs[2] . '</dummy>');
                 } catch (DOMException $e) {
                     $this->raiseError('Parse error during search for module-param parameters : ' . $e->getMessage() . " :\n" . io::htmlspecialchars($regs[2]));
                     return false;
                 }
                 $paramsTags = $domdocument->getElementsByTagName('module-param');
                 foreach ($paramsTags as $paramTag) {
                     $param_value = str_replace("\n", "§§", $parameters[$paramTag->getAttribute("name")]);
                 }
                 $cdata_pcre = $regs[1] . $param_value . $regs[3];
             } else {
                 break;
             }
         }
         $cdata = str_replace("§§", "\n", $cdata_pcre);
         return $cdata;
     } else {
         $this->raiseError("Template " . $filename . " isn't readable");
         return false;
     }
 }
Beispiel #14
0
 /**
  * Do patch installation
  *
  * @param array of install command to do, view documentation for format
  *  This array MUST be checked before by checkInstall method to ensure it format is as correct as possible
  * @param array of excluded commands
  * @return void
  * @access public
  */
 function doInstall(&$array, $excludeCommand = array(), $stopOnErrors = true)
 {
     if (is_array($array)) {
         foreach ($array as $line => $aInstallCheck) {
             $line++;
             //to have the correct line number
             $installParams = array_map("trim", explode("\t", $aInstallCheck));
             if ($installParams[0] != 'ex') {
                 $originalFile = isset($installParams[1]) ? PATH_REALROOT_FS . $installParams[1] : PATH_REALROOT_FS;
                 $patchFile = isset($installParams[1]) ? PATH_TMP_FS . $installParams[1] : PATH_TMP_FS;
             }
             if (!in_array($installParams[0], $excludeCommand)) {
                 //launch installation request
                 switch ($installParams[0]) {
                     case ">":
                         //add or update a file or folder
                         //copy file or folder
                         if (CMS_FILE::copyTo($patchFile, $originalFile)) {
                             $this->_verbose(' -> File ' . $patchFile . ' successfully copied to ' . $originalFile);
                         } else {
                             $this->_report('Error during copy of ' . $patchFile . ' to ' . $originalFile, true);
                             if ($stopOnErrors) {
                                 return;
                             }
                         }
                         if (!isset($installParams[2])) {
                             break;
                         }
                     case "ch":
                         //execute chmod
                         $filesNOK = $this->applyChmod($installParams[2], $originalFile);
                         if (!$filesNOK) {
                             switch ($installParams[2]) {
                                 case 'r':
                                     $this->_verbose(' -> File(s) ' . $originalFile . ' are readable.');
                                     break;
                                 case 'w':
                                     $this->_verbose(' -> File(s) ' . $originalFile . ' are writable.');
                                     break;
                                 case 'x':
                                     $this->_verbose(' -> File(s) ' . $originalFile . ' are executable.');
                                     break;
                                 default:
                                     $this->_verbose(' -> File(s) ' . $originalFile . ' successfully chmoded with value ' . $installParams[2]);
                                     break;
                             }
                         } else {
                             $this->_report('Error during chmod operation of ' . $originalFile . '. Can\'t apply chmod value \'' . $installParams[2] . '\' on files :<br />' . $filesNOK . '<br />', true);
                             //do not stop on chmod error : only report them
                             //if ($stopOnErrors) return;
                         }
                         break;
                     case "<":
                         //delete a file or folder (recursively)
                         if (file_exists($originalFile) && CMS_FILE::deleteFile($originalFile)) {
                             $this->_verbose(' -> File ' . $originalFile . ' successfully deleted');
                         } else {
                             $this->_verbose(' -> Cannot delete ' . $originalFile . '. It does not exists.');
                         }
                         break;
                     case "+":
                         //concatenate module xml file
                         //load destination module parameters
                         $module = CMS_modulesCatalog::getByCodename($installParams[2]);
                         $moduleParameters = $module->getParameters(false, true);
                         //load the XML data of the source the files
                         $sourceXML = new CMS_file($patchFile);
                         $domdocument = new CMS_DOMDocument();
                         try {
                             $domdocument->loadXML($sourceXML->readContent("string"));
                         } catch (DOMException $e) {
                         }
                         $paramsTags = $domdocument->getElementsByTagName('param');
                         $sourceParameters = array();
                         foreach ($paramsTags as $aTag) {
                             $name = $aTag->hasAttribute('name') ? $aTag->getAttribute('name') : '';
                             $type = $aTag->hasAttribute('type') ? $aTag->getAttribute('type') : '';
                             $sourceParameters[$name] = array(CMS_DOMDocument::DOMElementToString($aTag, true), $type);
                         }
                         //merge the two tables of parameters
                         $resultParameters = array_merge($sourceParameters, $moduleParameters);
                         //set new parameters to the module
                         if ($module->setAndWriteParameters($resultParameters)) {
                             $this->_verbose(' -> File ' . $patchFile . ' successfully merged with module ' . $installParams[2] . ' parameters');
                         } else {
                             $this->_report('Error during merging of ' . $patchFile . ' with module ' . $installParams[2] . ' parameters', true);
                             if ($stopOnErrors) {
                                 return;
                             }
                         }
                         break;
                     case "x":
                         //execute SQL or PHP file
                         //exec sql script with help of some phpMyAdmin classes
                         if (io::substr($patchFile, -4, 4) == '.sql') {
                             if ($this->executeSqlScript($patchFile)) {
                                 $this->_verbose(' -> File ' . $patchFile . ' successfully executed');
                             } else {
                                 $this->_report('Error during execution of ' . $patchFile, true);
                                 if ($stopOnErrors) {
                                     return;
                                 }
                             }
                         } elseif (io::substr($patchFile, -4, 4) == '.php') {
                             //exec php script
                             $executionReturn = $this->executePhpScript($patchFile);
                             if ($executionReturn === false) {
                                 $this->_report('Error during execution of ' . $patchFile, true);
                                 if ($stopOnErrors) {
                                     return;
                                 }
                             } else {
                                 $executionReturn = $executionReturn ? ' -> Return :<br /><div style="border:1px;background-color:#000080;color:#C0C0C0;padding:5px;">' . $executionReturn . '</div><br />' : '';
                                 $this->_report(' -> File ' . $patchFile . ' executed<br />' . $executionReturn);
                             }
                         }
                         break;
                     case "co":
                         //execute change owner
                         $filesNOK = $this->changeOwner($installParams[2], $originalFile);
                         if (!$filesNOK) {
                             $this->_verbose(' -> Owner of file(s) ' . $originalFile . ' successfully changed to ' . $installParams[2]);
                         } else {
                             $this->_report('Error during operation on ' . $originalFile . '. Can\'t change owner to \'' . $installParams[2] . '\' on files :<br />' . $filesNOK . '<br />', true);
                             if ($stopOnErrors) {
                                 return;
                             }
                         }
                         break;
                     case "cg":
                         //execute change group
                         $filesNOK = $this->changeGroup($installParams[2], $originalFile);
                         if (!$filesNOK) {
                             $this->_verbose(' -> Group of file(s) ' . $originalFile . ' successfully changed to ' . $installParams[2]);
                         } else {
                             $this->_report('Error during operation on ' . $originalFile . '. Can\'t change group to \'' . $installParams[2] . '\' on files :<br />' . $filesNOK . '<br />', true);
                             if ($stopOnErrors) {
                                 return;
                             }
                         }
                         break;
                     case "rc":
                         $this->automneGeneralScript();
                         break;
                     case "htaccess":
                         $installParams[1] = io::substr($installParams[1], -1) == '/' ? io::substr($installParams[1], 0, -1) : $installParams[1];
                         $pathes = glob(PATH_REALROOT_FS . $installParams[1]);
                         if ($pathes) {
                             foreach ($pathes as $path) {
                                 if ($installParams[2] == 'root' && file_exists($path . '/.htaccess')) {
                                     //for root file, if already exists, only replace ErrorDocument instructions to set correct path
                                     $htaccessFile = new CMS_file($path . '/.htaccess');
                                     $lines = $htaccessFile->readContent('array', '');
                                     foreach ($lines as $key => $line) {
                                         if (substr($line, 0, 13) == 'ErrorDocument') {
                                             list($errorDoc, $code, $file) = preg_split("/[\\s]+/", $line);
                                             if ($code == '404') {
                                                 $lines[$key] = 'ErrorDocument 404 ' . PATH_REALROOT_WR . '/404.php' . "\n";
                                             } elseif ($code == '403') {
                                                 $lines[$key] = 'ErrorDocument 403 ' . PATH_REALROOT_WR . '/403.php' . "\n";
                                             }
                                         }
                                     }
                                     $htaccessFile->setContent(implode('', $lines), false);
                                     if ($htaccessFile->writeToPersistence()) {
                                         $this->_report('File ' . $path . '/.htaccess (' . $installParams[2] . ') successfully updated');
                                     } else {
                                         $this->_report('Error during operation on ' . $path . '/.htaccess. Can\'t write file.<br />', true);
                                     }
                                 } else {
                                     if (is_dir($path) && CMS_file::makeWritable($path)) {
                                         if (CMS_file::copyTo(PATH_HTACCESS_FS . '/htaccess_' . $installParams[2], $path . '/.htaccess')) {
                                             CMS_file::chmodFile(FILES_CHMOD, $path . '/.htaccess');
                                             $this->_report('File ' . $path . '/.htaccess (' . $installParams[2] . ') successfully writen');
                                         } else {
                                             $this->_report('Error during operation on ' . $path . '/.htaccess. Can\'t write file.<br />', true);
                                             if ($stopOnErrors) {
                                                 return;
                                             }
                                         }
                                     } else {
                                         $this->_report('Error during operation. ' . $path . ' must be a writable directory.<br />', true);
                                         if ($stopOnErrors) {
                                             return;
                                         }
                                     }
                                 }
                             }
                         }
                         break;
                     default:
                         if (io::substr($installParams[0], 0, 1) != '#') {
                             $this->raiseError("Unknown parameter : " . $installParams[0]);
                             return false;
                         }
                         break;
                 }
             } else {
                 $this->_report('Error during operation of "' . $aInstallCheck . '". Command execution is not allowed.<br />', true);
                 if ($stopOnErrors) {
                     return;
                 }
             }
         }
     } else {
         $this->raiseError("Param must be an array");
         return false;
     }
     //at end of any patch process, update Automne subversion to force reload of JS and CSS cache from client
     if (@file_put_contents(PATH_MAIN_FS . "/SUBVERSION", time()) !== false) {
         CMS_file::chmodFile(FILES_CHMOD, PATH_MAIN_FS . "/SUBVERSION");
     }
 }
Beispiel #15
0
 /**
  * Clear a type cache
  *
  * @param string $type : the cache type to clear
  * @return boolean
  * @access public
  * @static
  */
 function clearTypeCache($type)
 {
     $type = io::sanitizeAsciiString($type);
     if (!$type) {
         CMS_grandFather::raiseError('$type must be a valid cache type');
         return false;
     }
     if (is_dir(PATH_CACHE_FS . '/' . $type)) {
         // First we'll check all modules to see if one of them implements a clearTypeCache method
         $modules = CMS_modulesCatalog::getAll('id');
         $cleared = false;
         foreach ($modules as $codename => $module) {
             if (method_exists($module, 'clearTypeCache')) {
                 $cleared = $module->clearTypeCache($type);
             }
         }
         // No module deleted the cache, use automne standard cache clear
         if (!$cleared) {
             //delete all type cache
             if (!CMS_file::deltree(PATH_CACHE_FS . '/' . $type, false, true)) {
                 CMS_grandFather::raiseError('Cannot clear cache for type ' . $type);
                 return false;
             }
         }
     }
     return true;
 }
Beispiel #16
0
 /**
  * Automne autoload handler
  *
  * @return true
  * @access public
  */
 static function autoload($classname)
 {
     static $classes, $modules;
     if (!isset($classes)) {
         $classes = array('cms_stack' => PATH_PACKAGES_FS . '/common/stack.php', 'cms_contactdata' => PATH_PACKAGES_FS . '/common/contactdata.php', 'cms_contactdatas_catalog' => PATH_PACKAGES_FS . '/common/contactdatascatalog.php', 'cms_href' => PATH_PACKAGES_FS . '/common/href.php', 'cms_log_catalog' => PATH_PACKAGES_FS . '/common/logcatalog.php', 'cms_log' => PATH_PACKAGES_FS . '/common/log.php', 'cms_languagescatalog' => PATH_PACKAGES_FS . '/common/languagescatalog.php', 'cms_actions' => PATH_PACKAGES_FS . '/common/actions.php', 'cms_action' => PATH_PACKAGES_FS . '/common/action.php', 'cms_search' => PATH_PACKAGES_FS . '/common/search.php', 'cms_contactdatas_catalog' => PATH_PACKAGES_FS . '/common/contactdatascatalog.php', 'cms_email' => PATH_PACKAGES_FS . '/common/email.php', 'cms_emailscatalog' => PATH_PACKAGES_FS . '/common/emailscatalog.php', 'cms_query' => PATH_PACKAGES_FS . '/common/query.php', 'cms_date' => PATH_PACKAGES_FS . '/common/date.php', 'cms_language' => PATH_PACKAGES_FS . '/common/language.php', 'cms_oembed' => PATH_PACKAGES_FS . '/common/oembed.php', 'sensitiveio' => PATH_PACKAGES_FS . '/common/sensitiveio.php', 'io' => PATH_PACKAGES_FS . '/common/sensitiveio.php', 'cms_context' => PATH_PACKAGES_FS . '/dialogs/context.php', 'cms_wysiwyg_toolbar' => PATH_PACKAGES_FS . '/dialogs/toolbar.php', 'cms_dialog' => PATH_PACKAGES_FS . '/dialogs/dialog.php', 'cms_jsdialog' => PATH_PACKAGES_FS . '/dialogs/jsdialog.php', 'cms_view' => PATH_PACKAGES_FS . '/dialogs/view.php', 'cms_submenus' => PATH_PACKAGES_FS . '/dialogs/submenus.php', 'cms_submenu' => PATH_PACKAGES_FS . '/dialogs/submenu.php', 'cms_dialog_listboxes' => PATH_PACKAGES_FS . '/dialogs/dialoglistboxes.php', 'cms_dialog_href' => PATH_PACKAGES_FS . '/dialogs/dialoghref.php', 'cms_fileupload_dialog' => PATH_PACKAGES_FS . '/dialogs/fileupload.php', 'cms_loadingdialog' => PATH_PACKAGES_FS . '/dialogs/loadingDialog.php', 'cms_texteditor' => PATH_PACKAGES_FS . '/dialogs/texteditor.php', 'cms_stats' => PATH_PACKAGES_FS . '/dialogs/stats.php', 'cms_patch' => PATH_PACKAGES_FS . '/files/patch.php', 'cms_file' => PATH_PACKAGES_FS . '/files/filesManagement.php', 'cms_archive' => PATH_PACKAGES_FS . '/files/archive.php', 'cms_gzip_file' => PATH_PACKAGES_FS . '/files/archive-gzip.php', 'cms_tar_file' => PATH_PACKAGES_FS . '/files/archive-tar.php', 'cms_zip_file' => PATH_PACKAGES_FS . '/files/archive-zip.php', 'cms_fileupload' => PATH_PACKAGES_FS . '/files/fileupload.php', 'cms_cache' => PATH_PACKAGES_FS . '/files/cache.php', 'cms_image' => PATH_PACKAGES_FS . '/files/image.php', 'cms_module' => PATH_MODULES_FS . '/module.php', 'cms_modulescodes' => PATH_MODULES_FS . '/modulesCodes.php', 'cms_modulevalidation' => PATH_MODULES_FS . '/moduleValidation.php', 'cms_superresource' => PATH_MODULES_FS . '/super_resource.php', 'cms_modulecategory' => PATH_MODULES_FS . '/modulecategory.php', 'cms_modulescatalog' => PATH_MODULES_FS . '/modulescatalog.php', 'cms_modulecategories_catalog' => PATH_MODULES_FS . '/modulecategoriescatalog.php', 'cms_modulestags' => PATH_MODULES_FS . '/modulesTags.php', 'cms_moduleclientspace' => PATH_MODULES_FS . '/moduleclientspace.php', 'cms_superresource' => PATH_MODULES_FS . '/super_resource.php', 'cms_polymod' => PATH_MODULES_FS . '/polymod.php', 'cms_modulepolymodvalidation' => PATH_MODULES_FS . '/modulePolymodValidation.php', 'cms_module_export' => PATH_MODULES_FS . '/export.php', 'cms_module_import' => PATH_MODULES_FS . '/import.php', 'cms_rowscatalog' => PATH_MODULES_FS . '/standard/rowscatalog.php', 'cms_row' => PATH_MODULES_FS . '/standard/row.php', 'cms_block' => PATH_MODULES_FS . '/standard/block.php', 'cms_block_file' => PATH_MODULES_FS . '/standard/blockfile.php', 'cms_block_flash' => PATH_MODULES_FS . '/standard/blockflash.php', 'cms_block_image' => PATH_MODULES_FS . '/standard/blockimage.php', 'cms_blockscatalog' => PATH_MODULES_FS . '/standard/blockscatalog.php', 'cms_block_text' => PATH_MODULES_FS . '/standard/blocktext.php', 'cms_block_varchar' => PATH_MODULES_FS . '/standard/blockvarchar.php', 'cms_block_link' => PATH_MODULES_FS . '/standard/blocklink.php', 'cms_moduleclientspace_standard' => PATH_MODULES_FS . '/standard/clientspace.php', 'cms_moduleclientspace_standard_catalog' => PATH_MODULES_FS . '/standard/clientspacescatalog.php', 'cms_xmltag_admin' => PATH_MODULES_FS . '/standard/tags/admin.php', 'cms_xmltag_noadmin' => PATH_MODULES_FS . '/standard/tags/noadmin.php', 'cms_xmltag_edit' => PATH_MODULES_FS . '/standard/tags/edit.php', 'cms_xmltag_noedit' => PATH_MODULES_FS . '/standard/tags/noedit.php', 'cms_xmltag_title' => PATH_MODULES_FS . '/standard/tags/title.php', 'cms_xmltag_page' => PATH_MODULES_FS . '/standard/tags/page.php', 'cms_xmltag_website' => PATH_MODULES_FS . '/standard/tags/website.php', 'cms_xmltag_anchor' => PATH_MODULES_FS . '/standard/tags/anchor.php', 'cms_xmltag_header' => PATH_MODULES_FS . '/standard/tags/header.php', 'cms_xmltag_redirect' => PATH_MODULES_FS . '/standard/tags/redirect.php', 'cms_xmltag_xml' => PATH_MODULES_FS . '/standard/tags/xml.php', 'cms_xmltag_js_add' => PATH_MODULES_FS . '/standard/tags/js-add.php', 'cms_xmltag_css_add' => PATH_MODULES_FS . '/standard/tags/css-add.php', 'cms_linxescatalog' => PATH_PACKAGES_FS . '/pageContent/linxescatalog.php', 'cms_xml2array' => PATH_PACKAGES_FS . '/pageContent/xml2Array.php', 'cms_linx' => PATH_PACKAGES_FS . '/pageContent/linx.php', 'cms_linxcondition' => PATH_PACKAGES_FS . '/pageContent/linxcondition.php', 'cms_linxdisplay' => PATH_PACKAGES_FS . '/pageContent/linxdisplay.php', 'cms_linxnodespec' => PATH_PACKAGES_FS . '/pageContent/linxnodespec.php', 'cms_xmltag' => PATH_PACKAGES_FS . '/pageContent/xmltag.php', 'cms_xmlparser' => PATH_PACKAGES_FS . '/pageContent/xmlparser.php', 'cms_domdocument' => PATH_PACKAGES_FS . '/pageContent/xmldomdocument.php', 'cms_array2xml' => PATH_PACKAGES_FS . '/pageContent/array2Xml.php', 'cms_array2csv' => PATH_PACKAGES_FS . '/pageContent/array2csv.php', 'processmanager' => PATH_PACKAGES_FS . '/scripts/backgroundScript/processmanager.php', 'backgroundscript' => PATH_PACKAGES_FS . '/scripts/backgroundScript/backgroundscript.php', 'cms_scriptsmanager' => PATH_PACKAGES_FS . '/scripts/scriptsmanager.php', 'cms_tree' => PATH_PACKAGES_FS . '/tree/tree.php', 'cms_page' => PATH_PACKAGES_FS . '/tree/page.php', 'cms_pagetemplatescatalog' => PATH_PACKAGES_FS . '/tree/pagetemplatescatalog.php', 'cms_pagetemplate' => PATH_PACKAGES_FS . '/tree/pagetemplate.php', 'cms_websitescatalog' => PATH_PACKAGES_FS . '/tree/websitescatalog.php', 'cms_website' => PATH_PACKAGES_FS . '/tree/website.php', 'cms_profile_user' => PATH_PACKAGES_FS . '/user/profileuser.php', 'cms_profile' => PATH_PACKAGES_FS . '/user/profile.php', 'cms_modulecategoriesclearances' => PATH_PACKAGES_FS . '/user/profilemodulecategoriesclearances.php', 'cms_profile_userscatalog' => PATH_PACKAGES_FS . '/user/profileuserscatalog.php', 'cms_profile_usersgroupscatalog' => PATH_PACKAGES_FS . '/user/profileusersgroupscatalog.php', 'cms_profile_usersgroup' => PATH_PACKAGES_FS . '/user/profileusersgroup.php', 'cms_session' => PATH_PACKAGES_FS . '/user/session.php', 'cms_auth' => PATH_PACKAGES_FS . '/user/auth.php', 'cms_resource' => PATH_PACKAGES_FS . '/workflow/resource.php', 'cms_resourcestatus' => PATH_PACKAGES_FS . '/workflow/resourcestatus.php', 'cms_resourcevalidationinfo' => PATH_PACKAGES_FS . '/workflow/resourcevalidationinfo.php', 'cms_resourcevalidation' => PATH_PACKAGES_FS . '/workflow/resourcevalidation.php', 'cms_resourcevalidationscatalog' => PATH_PACKAGES_FS . '/workflow/resourcevalidationscatalog.php', 'fckeditor' => PATH_MAIN_FS . '/fckeditor/fckeditor.php', 'ckeditor' => PATH_MAIN_FS . '/ckeditor/ckeditor.php', 'jsmin' => PATH_MAIN_FS . '/jsmin/jsmin.php', 'cssmin' => PATH_MAIN_FS . '/cssmin/cssmin.php', 'phpexcel' => PATH_MAIN_FS . '/phpexcel/PHPExcel.php', 'phpexcel_iofactory' => PATH_MAIN_FS . '/phpexcel/PHPExcel/IOFactory.php', 'lessc' => PATH_MAIN_FS . '/lessphp/lessc.inc.php');
     }
     $file = '';
     if (isset($classes[strtolower($classname)])) {
         $file = $classes[strtolower($classname)];
     } elseif (strpos($classname, 'CMS_module_') === 0) {
         //modules lazy loading
         if (file_exists(PATH_MODULES_FS . '/' . substr($classname, 11) . '.php')) {
             $file = PATH_MODULES_FS . '/' . substr($classname, 11) . '.php';
         } else {
             //here, we need to stop
             return false;
         }
     }
     if (!$file) {
         //Zend Framework
         if (substr(strtolower($classname), 0, 5) == 'zend_') {
             chdir(PATH_MAIN_FS);
             require_once PATH_MAIN_FS . '/Zend/Loader/Autoloader.php';
             if (!Zend_Loader_Autoloader::autoload($classname)) {
                 return false;
             }
             /*only for stats*/
             if (STATS_DEBUG) {
                 CMS_stats::$filesLoaded++;
             }
             if (STATS_DEBUG && VIEW_SQL) {
                 CMS_stats::$filesTable[] = array('class' => $classname, 'from' => io::getCallInfos(3));
                 CMS_stats::$memoryTable[] = array('class' => $classname, 'memory' => memory_get_usage(), 'peak' => memory_get_peak_usage());
             }
             return true;
         }
         //try modules Autoload
         if (!isset($modules)) {
             $modules = CMS_modulesCatalog::getAll("id");
         }
         $polymodDone = false;
         foreach ($modules as $codename => $module) {
             if ((!$polymodDone && $module->isPolymod() || !$module->isPolymod()) && method_exists($module, 'load')) {
                 if (!$polymodDone && $module->isPolymod()) {
                     $polymodDone = true;
                 }
                 $file = $module->load($classname);
             } elseif ($polymodDone && $module->isPolymod()) {
                 unset($modules[$codename]);
             }
             if ($file) {
                 break;
             }
         }
         //in case this website do not use any polymod module
         if (!$polymodDone && !$file) {
             require_once PATH_MODULES_FS . '/polymod.php';
             $file = CMS_polymod::load($classname);
         }
     }
     if ($file) {
         require_once $file;
         /*only for stats*/
         if (defined('STATS_DEBUG') && defined('VIEW_SQL')) {
             if (STATS_DEBUG) {
                 CMS_stats::$filesLoaded++;
             }
             if (STATS_DEBUG && VIEW_SQL) {
                 CMS_stats::$filesTable[] = array('file' => $file, 'class' => $classname, 'from' => io::getCallInfos(3));
                 CMS_stats::$memoryTable[] = array('file' => $file, 'class' => $classname, 'memory' => memory_get_usage(), 'peak' => memory_get_peak_usage());
             }
         }
     }
 }
Beispiel #17
0
 /**
  * Sets the definition from a string. Must write the definition to file and try to parse it
  * The file must be in a specific directory : PATH_TEMPLATES_ROWS_FS (see constants from rc file)
  *
  * @param string $definition The definition
  * @param boolean $haltOnPolymodParsing Stop setting definition if error on polymod parsing are found (default : true)
  * @return boolean true on success, false on failure
  * @access public
  */
 function setDefinition($definition, $haltOnPolymodParsing = true)
 {
     global $cms_language;
     $defXML = new CMS_DOMDocument();
     try {
         $defXML->loadXML($definition);
     } catch (DOMException $e) {
         return $cms_language->getMessage(self::MESSAGE_PAGE_ROW_SYNTAX_ERROR, array($e->getMessage()));
     }
     $blocks = $defXML->getElementsByTagName('block');
     $modules = array();
     foreach ($blocks as $block) {
         if ($block->hasAttribute("module")) {
             $modules[] = $block->getAttribute("module");
         } else {
             return $cms_language->getMessage(self::MESSAGE_PAGE_ROW_SYNTAX_ERROR, array($cms_language->getMessage(self::MESSAGE_PAGE_BLOCK_SYNTAX_ERROR)));
         }
     }
     $modules = array_unique($modules);
     $this->_modules->emptyStack();
     foreach ($modules as $module) {
         $this->_modules->add($module);
     }
     //check if rows use a polymod block, if so pass to module for variables conversion
     $rowConverted = false;
     foreach ($this->getModules(false) as $moduleCodename) {
         if (CMS_modulesCatalog::isPolymod($moduleCodename)) {
             $rowConverted = true;
             $module = CMS_modulesCatalog::getByCodename($moduleCodename);
             $definition = $module->convertDefinitionString($definition, false);
         }
     }
     if ($rowConverted) {
         //check definition parsing
         $parsing = new CMS_polymod_definition_parsing($definition, true, CMS_polymod_definition_parsing::CHECK_PARSING_MODE);
         $errors = $parsing->getParsingError();
         if ($errors && $haltOnPolymodParsing) {
             return $cms_language->getMessage(self::MESSAGE_PAGE_ROW_SYNTAX_ERROR, array($errors));
         }
     }
     $filename = $this->getDefinitionFileName();
     if (!$filename) {
         //must write it to persistence to have its ID
         if (!$this->_id) {
             $this->writeToPersistence();
         }
         //build the filename
         $filename = "r" . $this->_id . "_" . SensitiveIO::sanitizeAsciiString($this->_label) . ".xml";
     }
     $rowFile = new CMS_file(PATH_TEMPLATES_ROWS_FS . "/" . $filename);
     $rowFile->setContent($definition);
     $rowFile->writeToPersistence();
     $this->_definitionFile = $filename;
     return true;
 }
Beispiel #18
0
 /**
  * Import module from given array datas
  *
  * @param array $data The module datas to import
  * @param array $params The import parameters.
  *		array(
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 static function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     $return = true;
     foreach ($data as $moduleDatas) {
         if (!isset($moduleDatas['codename'])) {
             $infos .= 'Missing codename ...' . "\n";
             return false;
         }
         //check if module exists
         $codenames = CMS_modulesCatalog::getAllCodenames();
         //instanciate module
         $importType = '';
         if (isset($codenames[$moduleDatas['codename']])) {
             if (!isset($params['update']) || $params['update'] == true) {
                 $module = CMS_modulesCatalog::getByCodename($moduleDatas['codename']);
                 $infos .= 'Get Module ' . $module->getLabel($cms_language) . ' for update...' . "\n";
                 $importType = ' (Update)';
             } else {
                 $infos .= 'Module already exists and parameter does not allow to update it ...' . "\n";
                 return false;
             }
         } else {
             if (!isset($params['create']) || $params['create'] == true) {
                 $infos .= 'Create new module for imported datas...' . "\n";
                 $importType = ' (Creation)';
                 if (isset($moduleDatas['polymod']) && $moduleDatas['polymod']) {
                     $module = new CMS_polymod();
                 } else {
                     $module = new CMS_module();
                 }
             } else {
                 $infos .= 'Module does not exists and parameter does not allow to create it ...' . "\n";
                 return false;
             }
         }
         if ($module->fromArray($moduleDatas, $params, $cms_language, $idsRelation, $infos)) {
             $return &= true;
             $infos .= 'Module "' . $module->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
         } else {
             $return = false;
             $infos .= 'Error during import of module ' . $moduleDatas['codename'] . $importType . "\n";
         }
     }
     return $return;
 }
Beispiel #19
0
            }
            break;
        case 'users':
            $users = CMS_profile_usersCatalog::getAll(false, false, true, array('id_pru' => array_keys($results)));
            foreach ($users as $user) {
                $items[] = $user->getJSonDescription($cms_user, $cms_language, false);
            }
            break;
        case 'groups':
            $groups = CMS_profile_usersGroupsCatalog::search('', '', false, array_keys($results));
            foreach ($groups as $group) {
                $items[] = $group->getJSonDescription($cms_user, $cms_language, false);
            }
            break;
        default:
            $module = CMS_modulesCatalog::getByCodename($type);
            $items = $module->getSearchResults(array_keys($results), $cms_user);
            break;
    }
    //set each results items as right position
    foreach ($items as $item) {
        if ($item['id']) {
            $resultsDatas['results'][$results[$item['id']]] = $item;
            //rewrite id to avoid overwrite
            $resultsDatas['results'][$results[$item['id']]]['id'] = md5($type . $item['id']);
        }
    }
}
//sort results by position
ksort($resultsDatas['results'], SORT_NUMERIC);
//pr($resultsDatas['results']);
Beispiel #20
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;
     }
 }
Beispiel #21
0
 /**
  * Export module datas
  * 
  * @param string $format, the export format in : php (default), xml, patch
  * @return mixed : the exported datas
  */
 function export($format = 'php')
 {
     $aExport = array();
     if ($this->_hasExport) {
         //force default language loading to overwrite user language
         global $cms_language;
         $oModule = CMS_modulesCatalog::getByCodename($this->_module);
         if (!$oModule->hasError()) {
             $aModule = $oModule->asArray($this->_parameters, $files);
             //append files to exported module datas
             $aModule['files'] = array();
             if ($files) {
                 $aModule['files'] = $files;
             }
             //create export datas
             $aExport = array('version' => AUTOMNE_VERSION, 'language' => $cms_language->getCode(), 'description' => isset($this->_parameters['description']) ? $this->_parameters['description'] : '', 'modules' => array($aModule));
         }
         $return = '';
         switch ($format) {
             case 'php':
                 $return = $aExport;
                 break;
             case 'xml':
                 $array2Xml = new CMS_array2Xml($aExport, "export");
                 $return = $array2Xml->getXMLString();
                 break;
             case 'patch':
                 //create patch datas
                 $archiveFile = PATH_TMP_FS . '/' . $this->_module . '-' . date('Ymd-His') . '.tgz';
                 $archive = new CMS_gzip_file(substr($archiveFile, strlen(PATH_REALROOT_FS) + 1));
                 $archive->set_options(array('basedir' => PATH_REALROOT_FS . '/'));
                 if (isset($aExport['modules'])) {
                     foreach ($aExport['modules'] as $moduleDatas) {
                         if (isset($moduleDatas['files'])) {
                             foreach ($moduleDatas['files'] as $file) {
                                 if (file_exists(PATH_REALROOT_FS . $file)) {
                                     $archive->add_files(array(substr($file, 1)));
                                 }
                             }
                         }
                     }
                 }
                 $array2Xml = new CMS_array2Xml($aExport, "export");
                 $sOutput = $array2Xml->getXMLString();
                 $datas = new CMS_file(PATH_REALROOT_FS . '/export.xml');
                 $datas->setContent($sOutput);
                 $datas->writeToPersistence();
                 $archive->add_files(array('export.xml'));
                 //create archive
                 if ($archive->create_archive()) {
                     $return = $archiveFile;
                 } else {
                     $this->raiseError('Error during archive creation ...');
                 }
                 //delete tmp file
                 $datas->delete();
                 break;
             default:
                 $this->raiseError('Unknown format : ' . $format);
                 return false;
                 break;
         }
     }
     return $return;
 }
Beispiel #22
0
if (!$cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_EDIT) || !$cms_user->hasModuleClearance(MOD_CMS_FORMS_CODENAME, CLEARANCE_MODULE_EDIT)) {
    die('No rigths on page or module ...');
    exit;
}
//ARGUMENTS CHECK
if (!$cs || !$rowTag || !$rowId || !$blockId) {
    die("Data missing.");
}
/*
$cms_block = new CMS_block_cms_forms();
$cms_block->initializeFromBasicAttributes($_POST["block"]);
*/
//instanciate block
$cms_block = new CMS_block_polymod();
$cms_block->initializeFromID($blockId, $rowId);
$cms_module = CMS_modulesCatalog::getByCodename(MOD_CMS_FORMS_CODENAME);
// Language
if (isset($_REQUEST["items_language"])) {
    CMS_session::setSessionVar("items_language", $_REQUEST["items_language"]);
} elseif (CMS_session::getSessionVar("items_language") == '') {
    CMS_session::setSessionVar("items_language", $cms_module->getParameters("default_language"));
}
$items_language = new CMS_language(CMS_session::getSessionVar("items_language"));
//
// Get default search options
//
// Get search options from posted datas
if ($_POST["cms_action"] == 'search') {
    CMS_session::setSessionVar("items_ctg", $_POST["items_ctg"]);
}
//Action management
Beispiel #23
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;
                 }
             }
         }
     }
 }
Beispiel #24
0
        if (sizeof($new_parameters)) {
            $module->setAndWriteParameters($new_parameters);
        }
        $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
        $parameters = $module->getParameters(false, true);
        break;
    case 'delete_module':
        if ($module->destroy()) {
            $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
        } else {
            $cms_message = 'Error during module deletion ...';
        }
        unset($module);
        unset($modules);
        unset($moduleCodename);
        $modules = CMS_modulesCatalog::getAll("label", false, true);
        break;
}
$content = '';
$dialog->setTitle($cms_language->getMessage(MESSAGE_PAGE_TITLE_APPLICATIONS) . " :: " . $cms_language->getMessage(MESSAGE_PAGE_TITLE), 'picto_modules.gif');
//Show a list of all modules
if (!sizeof($modules)) {
    $content .= $cms_language->getMessage(MESSAGE_PAGE_EMPTY_SET) . "<br /><br />";
    $content .= '
	<form action="polymod_mod.php" method="post">
	<input type="submit" class="admin_input_submit" value="' . $cms_language->getMessage(MESSAGE_PAGE_ACTION_NEW) . '" />
	</form><br />';
} else {
    $content .= '
	<form action="' . $_SERVER["SCRIPT_NAME"] . '" method="post">
		' . $cms_language->getMessage(MESSAGE_PAGE_CHOOSE_MODULE) . ' :
Beispiel #25
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;
 }
    /**
     * get HTML admin (used to enter object values in admin)
     *
     * @param CMS_language $language, the current admin language
     * @param string prefixname : the prefix to use for post names
     * @return string : the html admin
     * @access public
     */
    function getHTMLAdmin($fieldID, $language, $prefixName)
    {
        global $cms_user;
        $params = $this->getParamsValues();
        //is this field mandatory ?
        $mandatory = $this->_field->getValue('required') ? '<span class="atm-red">*</span> ' : '';
        $desc = $this->getFieldDescription($language);
        if (POLYMOD_DEBUG) {
            $values = array();
            foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                if (is_object($this->_subfieldValues[$subFieldID])) {
                    $values[$subFieldID] = sensitiveIO::ellipsis(strip_tags($this->_subfieldValues[$subFieldID]->getValue()), 50);
                }
            }
            $desc .= $desc ? '<br />' : '';
            $desc .= '<span class="atm-red">Field : ' . $fieldID . ' - Value(s) : <ul>';
            foreach ($values as $subFieldID => $value) {
                $desc .= '<li>' . $subFieldID . '&nbsp;:&nbsp;' . $value . '</li>';
            }
            $desc .= '</ul></span>';
        }
        $label = $desc ? '<span class="atm-help" ext:qtip="' . io::htmlspecialchars($desc) . '">' . $mandatory . $this->getFieldLabel($language) . '</span>' : $mandatory . $this->getFieldLabel($language);
        $listId = 'list' . md5(mt_rand() . microtime());
        $listId2 = 'list' . md5(mt_rand() . microtime());
        if ($params['editable']) {
            //get object definition
            $objectDef = $this->getObjectDefinition();
            $associatedItems = array();
            foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                if (is_object($this->_subfieldValues[$subFieldID])) {
                    $associatedItems[$this->_subfieldValues[$subFieldID]->getValue()] = $this->_subfieldValues[$subFieldID]->getValue();
                }
            }
            $items = array();
            $editURL = PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/item.php';
            $associateURL = PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/associate-items.php';
            $searchURL = PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/search.php';
            $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
            if (!$cms_user->hasModuleClearance($moduleCodename, CLEARANCE_MODULE_EDIT)) {
                define("MESSAGE_ERROR_MODULE_RIGHTS", 570);
                $module = CMS_modulesCatalog::getByCodename($moduleCodename);
                $items[] = array('width' => '100%', 'layout' => 'fit', 'border' => false, 'bodyStyle' => 'margin:5px 0 3px 0', 'html' => $language->getMessage(MESSAGE_ERROR_MODULE_RIGHTS, array($module->getLabel($language))));
            } else {
                $items[] = array('width' => '100%', 'layout' => 'fit', 'border' => false, 'bodyStyle' => 'margin:5px 0 3px 0', 'html' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_LIST_ZONE, array($objectDef->getObjectLabel($language)), MOD_POLYMOD_CODENAME));
                $items[] = array('xtype' => "multiselect2", 'hideLabel' => true, 'id' => $listId2, 'name' => 'polymodFieldsValue[list' . $prefixName . $this->_field->getID() . '_0]', 'allowBlank' => !$this->_field->getValue('required'), 'valueField' => 'id', 'displayField' => 'label', 'tpl' => sensitiveIO::sanitizeJSString('<tpl for="rows">
						<dl>
							<tpl for="parent.columns">
								<dt style="width:100%;text-align:{align};white-space:normal;" class="MultiselectDD">
									<div unselectable="on" class="atm-result x-unselectable" id="object-{parent.id}">
										<div class="atm-title">
											<table>
												<tr>
													<td class="atm-label" ext:qtip="ID: {parent.id}">{parent.status}&nbsp;{parent.label}</td>
													<td class="atm-pubrange">{parent.pubrange}</td>
													<td class="atm-drag">&nbsp;</td>
												</tr>
											</table>
										</div>
										<div class="atm-description">{parent.description}<div style="clear:both;height:1px;">&nbsp;</div></div>
									</div>
								</dt>
							</tpl>
							<div class="x-clear"></div>
						</dl>
	                </tpl>'), 'store' => array('xtype' => 'atmJsonstore', 'root' => 'results', 'totalProperty' => 'total', 'url' => $searchURL, 'id' => 'id', 'remoteSort' => true, 'baseParams' => array('module' => $moduleCodename, 'objectId' => $this->_objectID), 'fields' => array('id', 'status', 'pubrange', 'label', 'description', 'locked', 'deleted', 'previz', 'edit')), 'value' => implode(',', $associatedItems), 'width' => 'auto', 'height' => 'auto', 'cls' => 'x-list-body', 'tbar' => array(!$params['doNotUseExternalSubObjects'] ? array('text' => $language->getMessage(self::MESSAGE_PAGE_ACTION_ASSOCIATE), 'tooltip' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_CHOOSE_ELEMENT, array($objectDef->getObjectLabel($language)), MOD_POLYMOD_CODENAME), 'handler' => sensitiveIO::sanitizeJSString('function(button){
								var windowId = \'module' . $moduleCodename . 'AssociateWindow\';
								/*create window element*/
								var window = new Automne.Window({
									id:				windowId,
									objectId:		\'\',
									autoLoad:		{
										url:			\'' . $associateURL . '\',
										params:			{
											winId:			windowId,
											module:			\'' . $moduleCodename . '\',
											type:			\'' . $this->_objectID . '\'
										},
										nocache:		true,
										scope:			this
									},
									modal:			true,
									width:			750,
									height:			580,
									animateTarget:	button,
									listeners:{\'close\':function(window){
										var cmp = Ext.getCmp(\'' . $listId2 . '\');
										if (window.selectedItems && window.selectedItems.split) {
											var values = cmp.getRawValue();
											var items = window.selectedItems.split(\',\');
											for (var i = 0, itemsLen = items.length; i < itemsLen; i++) {
												if (values.indexOf(items[i]) === -1) {
													values.unshift(items[i]);
												}
											}
											cmp.setValue(values.join(cmp.delimiter));
										}
									}}
								});
								/*display window*/
								window.show(button.getEl());
							}', false, false), 'scope' => 'this') : '', array('text' => $language->getMessage(self::MESSAGE_PAGE_ACTION_DESASSOCIATE), 'tooltip' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_DISASSOCIATE_ELEMENT, false, MOD_POLYMOD_CODENAME), 'handler' => sensitiveIO::sanitizeJSString('function(button){
								var cmp = Ext.getCmp(\'' . $listId2 . '\');
								var selected = cmp.view.getSelectedRecords();
								if (!selected.length || selected.length > 1) {
									Automne.message.popup({
										msg: 				\'' . $language->getJSMessage(self::MESSAGE_MULTI_OBJECT_SELECT_BEFORE, false, MOD_POLYMOD_CODENAME) . '\',
										buttons: 			Ext.MessageBox.OKCANCEL,
										animEl: 			button.getEl(),
										closable: 			false,
										icon: 				Ext.MessageBox.INFO
									});
									return;
								}
								Automne.message.popup({
									msg: 				\'' . io::htmlspecialchars($language->getMessage(self::MESSAGE_PAGE_ACTION_DESASSOCIATE_CONFIRM, array($objectDef->getObjectLabel($language)), MOD_POLYMOD_CODENAME)) . '\',
									buttons: 			Ext.MessageBox.OKCANCEL,
									animEl: 			button.getEl(),
									closable: 			false,
									icon: 				Ext.MessageBox.WARNING,
									scope:				this,
									fn: 				function (button) {
										if (button == \'ok\') {
											var cmp = Ext.getCmp(\'' . $listId2 . '\');
											var selected = cmp.view.getSelectedRecords();
											if (!selected.length || selected.length > 1) {
												return;
											}
											var objectId = selected[0].id;
											var values = cmp.getRawValue();
											values.remove(objectId);
											cmp.setValue(values.join(cmp.delimiter));
											if (\'' . $listId . '\') {
												var list = Ext.getCmp(\'' . $listId . '\');
												if (list) {
													list.store.baseParams.removeIds = values.join(cmp.delimiter);
													list.store.load();
												}
											}
										}
									}
								});
							}', false, false), 'scope' => 'this'), '->', array('text' => $language->getMessage(self::MESSAGE_PAGE_ACTION_MODIFIY), 'tooltip' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_EDIT_ELEMENT, false, MOD_POLYMOD_CODENAME), 'iconCls' => 'atm-pic-modify', 'handler' => sensitiveIO::sanitizeJSString('function(button){
								var cmp = Ext.getCmp(\'' . $listId2 . '\');
								var selected = cmp.view.getSelectedRecords();
								if (!selected.length || selected.length > 1) {
									Automne.message.popup({
										msg: 				\'' . $language->getJSMessage(self::MESSAGE_MULTI_OBJECT_SELECT_BEFORE, false, MOD_POLYMOD_CODENAME) . '\',
										buttons: 			Ext.MessageBox.OKCANCEL,
										animEl: 			button.getEl(),
										closable: 			false,
										icon: 				Ext.MessageBox.INFO
									});
									return;
								}
								var objectId = selected[0].id;
								var windowId = \'module' . $moduleCodename . 'EditWindow\'+objectId;
								/*create window element*/
								var window = new Automne.Window({
									id:				windowId,
									objectId:		objectId,
									autoLoad:		{
										url:			\'' . $editURL . '\',
										params:			{
											winId:			windowId,
											module:			\'' . $moduleCodename . '\',
											type:			\'' . $this->_objectID . '\',
											item:			objectId
										},
										nocache:		true,
										scope:			this
									},
									modal:			true,
									width:			750,
									height:			580,
									animateTarget:	button,
									listeners:{\'close\':function(window){
										var cmp = Ext.getCmp(\'' . $listId2 . '\');
										cmp.store.reload();
									}}
								});
								/*display window*/
								window.show(button.getEl());
							}', false, false), 'scope' => 'this'), array('text' => $language->getMessage(self::MESSAGE_PAGE_ACTION_NEW), 'tooltip' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_CREATE_ZONE, array($objectDef->getObjectLabel($language)), MOD_POLYMOD_CODENAME), 'iconCls' => 'atm-pic-add', 'handler' => sensitiveIO::sanitizeJSString('function(button){
								var objectId = \'create' . $moduleCodename . $this->_objectID . '\';
								var windowId = \'module' . $moduleCodename . 'EditWindow\'+objectId;
								/*create window element*/
								var window = new Automne.Window({
									id:				windowId,
									objectId:		\'\',
									autoLoad:		{
										url:			\'' . $editURL . '\',
										params:			{
											winId:			windowId,
											module:			\'' . $moduleCodename . '\',
											type:			\'' . $this->_objectID . '\'
										},
										nocache:		true,
										scope:			this
									},
									modal:			true,
									width:			750,
									height:			580,
									animateTarget:	button,
									listeners:{\'close\':function(window){
										var cmp = Ext.getCmp(\'' . $listId2 . '\');
										if (window.objectId) {
											var values = cmp.getRawValue();
											values.unshift(window.objectId);
											cmp.setValue(values.join(cmp.delimiter));
										}
									}}
								});
								/*display window*/
								window.show(button.getEl());
							}', false, false), 'scope' => 'this')), 'ddReorder' => true);
            }
            $return = array('title' => $label, 'xtype' => 'fieldset', 'autoHeight' => true, 'layout' => 'form', 'defaults' => array('anchor' => '97%'), 'items' => $items);
            return $return;
        } else {
            $return = array('allowBlank' => !$this->_field->getValue('required'), 'fieldLabel' => $label, 'name' => 'polymodFieldsValue[list' . $prefixName . $this->_field->getID() . '_0]');
            //get searched objects conditions
            $searchedObjects = is_array($params['searchedObjects']) ? $params['searchedObjects'] : array();
            $objectsNames = CMS_poly_object_catalog::getListOfNamesForObject($this->_objectID, false, $searchedObjects);
            $associatedItems = $availableItems = array();
            if (is_array($objectsNames) && $objectsNames) {
                foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                    if (is_object($this->_subfieldValues[$subFieldID])) {
                        $associatedItems[$this->_subfieldValues[$subFieldID]->getValue()] = $this->_subfieldValues[$subFieldID]->getValue();
                    }
                }
                foreach ($objectsNames as $id => $name) {
                    $availableItems[] = array($id, $name);
                }
            } else {
                $availableItems[] = array('', $language->getMessage(self::MESSAGE_EMPTY_OBJECTS_SET));
                $return['disabled'] = true;
            }
            /*$return['xtype'] 			= 'multiselect';
            		$return['dataFields'] 		= array('id', 'label');
            		$return['data'] 			= $availableItems;
            		$return['value'] 			= implode(',',$associatedItems);
            		$return['valueField'] 		= "id";
            		$return['displayField'] 	= "label";
            		$return['width'] 			= '100%';*/
            $return['xtype'] = 'superboxselect';
            $return['dataFields'] = array('id', 'label');
            $return['store'] = $availableItems;
            $return['mode'] = 'local';
            $return['value'] = implode(',', $associatedItems);
            $return['valueField'] = "id";
            $return['displayField'] = "label";
            $return['width'] = '100%';
            $return['stackItems'] = true;
            return $return;
        }
    }
Beispiel #27
0
 }
 //CHECKS user has module clearance
 if (!$cms_user->hasModuleClearance($codename, CLEARANCE_MODULE_EDIT)) {
     CMS_grandFather::raiseError('Error, user has no rights on module : ' . $codename);
     break;
 }
 //ARGUMENTS CHECK
 if (!$cs || !$rowTag || !$rowId || !$blockId) {
     CMS_grandFather::raiseError('Data missing ...');
     break;
 }
 //instanciate block
 $cms_block = new CMS_block_polymod();
 $cms_block->initializeFromID($blockId, $rowId);
 //instanciate block module
 $cms_module = CMS_modulesCatalog::getByCodename($codename);
 //get block datas if any
 $data = $cms_block->getRawData($cms_page->getID(), $cs, $rowTag, RESOURCE_LOCATION_EDITION, false);
 //get block parameters requirements
 $blockParamsDefinition = $cms_block->getBlockParametersRequirement($data["value"], $cms_page, true);
 //instanciate row
 $row = new CMS_row($rowId);
 //checks and assignments
 $formok = true;
 if (isset($blockParamsDefinition['search'])) {
     if (sizeof($blockParamsDefinition['search'])) {
         foreach ($blockParamsDefinition['search'] as $searchName => $searchParams) {
             foreach ($searchParams as $paramType => $paramValue) {
                 switch ($paramType) {
                     case 'keywords':
                     case 'category':
Beispiel #28
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);
     }
 }
Beispiel #29
0
                    $selected = $field->getValue("type") == $anObjectType->getID() ? ' selected="selected"' : '';
                    $content .= '<option value="' . $anObjectType->getID() . '"' . $selected . ' title="' . htmlspecialchars($anObjectType->getDescription($cms_language)) . '">' . $anObjectType->getObjectLabel($cms_language) . ' (' . $objectModule->getLabel($cms_language) . ')</option>';
                }
            }
        }
        $content .= '</optgroup>';
    }
    if (sizeof($poly_types) > 1) {
        $content .= '<optgroup label="' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_MULTI) . ' ' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_POLY_OBJECTS) . '">';
        //multi poly objects
        foreach ($poly_types as $anObjectType) {
            //a poly object can't use itself or can't use an object who already use itself (infinite loop)
            if ($object->getID() != $anObjectType->getID() && !in_array($anObjectType->getID(), $objectUseage)) {
                //load fields objects for object
                $objectFields = CMS_poly_object_catalog::getFieldsDefinition($anObjectType->getID());
                $objectModule = CMS_modulesCatalog::getByCodename(CMS_poly_object_catalog::getModuleCodenameForObjectType($anObjectType->getID()));
                //a poly object can't be empty
                if (sizeof($objectFields)) {
                    $selected = $field->getValue("type") == 'multi|' . $anObjectType->getID() ? ' selected="selected"' : '';
                    $content .= '<option value="multi|' . $anObjectType->getID() . '"' . $selected . ' title="' . htmlspecialchars($anObjectType->getDescription($cms_language)) . '">' . $anObjectType->getObjectLabel($cms_language) . ' (' . $objectModule->getLabel($cms_language) . ')</option>';
                }
            }
        }
        $content .= '</optgroup>';
    }
    $content .= '
			</select>';
} else {
    $content .= '
			<strong>' . $typeObject->getObjectLabel($cms_language) . '</strong>
			<input type="hidden" name="type" value="' . $field->getValue("type") . '" />';
Beispiel #30
0
        }
    }
}
//if no plugin available, display error and quit
if (!sizeof($availablePlugin)) {
    //messages
    $cms_message = $cms_language->getMessage(MESSAGE_PAGE_ERROR_NO_PLUGIN, false, MOD_POLYMOD_CODENAME);
    $view->setActionMessage($cms_message);
    $view->show();
}
$items = '';
$activeTab = 0;
$url = PATH_ADMIN_MODULES_WR . '/polymod/item-selector.php';
$pluginControler = PATH_ADMIN_MODULES_WR . '/polymod/items-controler.php';
foreach ($availablePlugin as $aPolyModuleCodename => $pluginDefinitions) {
    $polymodule = CMS_modulesCatalog::getByCodename($aPolyModuleCodename);
    if ($polymodule) {
        foreach ($pluginDefinitions as $id => $pluginDefinition) {
            $items .= $items ? ',' : '';
            $objectWinId = 'module' . $aPolyModuleCodename . '-' . $id . 'Plugin';
            if ($pluginDefinition->needSelection() && !$content && $selectedPluginID != $id) {
                $disabled = 'disabled:true,';
                $label = '<span ext:qtip="' . sensitiveIO::sanitizeJSString($polymodule->getLabel($cms_language) . ' : ' . $pluginDefinition->getDescription($cms_language) . '<br /><br /><strong>' . $cms_language->getMessage(MESSAGE_PAGE_TAB_DISABLED_SELECT_TEXT, false, MOD_POLYMOD_CODENAME)) . '</strong>">' . sensitiveIO::sanitizeJSString($pluginDefinition->getLabel($cms_language)) . '</span>';
            } elseif (!$pluginDefinition->needSelection() && $content && $selectedPluginID != $id) {
                $disabled = 'disabled:true,';
                $label = '<span ext:qtip="' . sensitiveIO::sanitizeJSString($polymodule->getLabel($cms_language) . ' : ' . $pluginDefinition->getDescription($cms_language) . '<br /><br /><strong>' . $cms_language->getMessage(MESSAGE_PAGE_TAB_DISABLED_NO_SELECT_TEXT, false, MOD_POLYMOD_CODENAME)) . '</strong>">' . sensitiveIO::sanitizeJSString($pluginDefinition->getLabel($cms_language)) . '</span>';
            } else {
                if ($selectedPluginID == $id || $activeTab === 0) {
                    $activeTab = $objectWinId;
                }
                $disabled = '';