$cms_message .= $cms_message ? '<br />' . $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGENERATION_ERROR, array($regenerror)) : $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGENERATION_ERROR, array($regenerror)); } } } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_NO_PAGES_FOUND); } } } break; case 'restart-scripts': CMS_scriptsManager::startScript(true); $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE); break; case 'stop-scripts': CMS_scriptsManager::clearScripts(); CMS_scriptsManager::startScript(true); $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE); break; case 'clear-scripts': CMS_scriptsManager::clearScripts(); $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE); break; default: CMS_grandFather::raiseError('Unknown action to do ...'); $view->show(); break; } //set user message if any if ($cms_message) { $view->setActionMessage($cms_message); }
/** * 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; } } }
/** * Current object pass the validation process * * @param integer : the validation status * @param CMS_poly_object : the reference of the object currently validated * @return boolean * @access public */ function afterValidation($validationResult, &$validatedObject) { $params = $this->getParamsValues(); // Check if sending is done by validation, if object validation is accepted, object is in user space, and fieldValue is checked if ($params['sendEmailOn'] == self::OBJECT_EMAIL_PARAMETER_SEND_ON_VALIDATION && $validationResult == VALIDATION_OPTION_ACCEPT && $validatedObject->isInUserSpace() && $this->_subfieldValues[0]->getValue() == 1) { $module = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID()); //add script to send email for user if needed CMS_scriptsManager::addScript($module, array('task' => 'emailNotification', 'field' => $this->_field->getID(), 'object' => $validatedObject->getID())); //then launch scripts execution CMS_scriptsManager::startScript(); } return true; }
/** * Submit pages to the regenerator. The first argument can either be a single page ID or an array of those. * * @param mixed $pages If it's a scalar, it's a page ID, else an array of pages IDs * @param integer $fromScratch Is the submission concerning a full from scratch regeneration (true) or a regeneration from linx files (false) ? * @param boolean $dontLaunchRegenerator to avoid multiple launch of the regenerator during multiple validation only the last page validation launch the script * @return void * @access public */ static function submitToRegenerator($pages, $fromScratch, $dontLaunchRegenerator = false) { $fs = $fromScratch ? true : false; if (!is_array($pages)) { $pages = array($pages); } //get all scripts for standard module if (!class_exists('CMS_module_standard')) { CMS_grandFather::raiseError("Can not found standard module"); return false; } $scripts = CMS_scriptsManager::getScripts(MOD_STANDARD_CODENAME); $pagesToRegen = array(); foreach ($scripts as $scriptID => $script) { $pagesToRegen[$script['pageid']] = array('fromscratch' => $script['fromscratch'], 'script' => $scriptID); } foreach ($pages as $page) { if (isset($pagesToRegen[$page])) { //is existant script need to be updated ? $actual_fs = $pagesToRegen[$page]['fromscratch']; if (!$actual_fs && $fs) { $parameters = array('pageid' => $page, 'fromscratch' => $fs); CMS_scriptsManager::addScript(MOD_STANDARD_CODENAME, $parameters, $pagesToRegen[$page]['script']); } } else { //add script $parameters = array('pageid' => $page, 'fromscratch' => $fs); CMS_scriptsManager::addScript(MOD_STANDARD_CODENAME, $parameters); } } if (!$dontLaunchRegenerator) { //then, launch the regenerator script CMS_scriptsManager::startScript(); } }