/**
  * Returns a resourceValidation object instance from a DB id or from GetValidationByID function if exists.
  * Static function.
  *
  * @param integer $id the id of the saved object
  * @return resourceValidation the instance unserialized, false if not found.
  * @access public
  */
 static function getValidationInstance($id, $user = false)
 {
     if (!SensitiveIO::isPositiveInteger($id) && base64_decode($id) && $user) {
         //load validation form encoded ID (new validations system)
         $decodedID = explode('||', base64_decode($id));
         $module = CMS_modulesCatalog::getByCodename($decodedID[0]);
         $editions = $decodedID[1];
         $resourceID = $decodedID[2];
         if (isset($module) && isset($editions) && isset($resourceID)) {
             return $module->getValidationByID($resourceID, $user, $editions);
         }
     }
     $sql = "\n\t\t\tselect\n\t\t\t\tserializedObject_rv as data\n\t\t\tfrom\n\t\t\t\tresourceValidations\n\t\t\twhere\n\t\t\t\tid_rv='" . $id . "'\n\t\t";
     $q = new CMS_query($sql);
     if ($q->getNumRows()) {
         $instance = unserialize(stripslashes($q->getValue("data")));
         $instance->setID($id);
         return $instance;
     } else {
         parent::raiseError("Unknown id : " . $id);
         return false;
     }
 }
示例#2
0
if (!$page) {
    header('HTTP/1.x 404 Not Found', true, 404);
    exit;
}
$oembedDefinition = CMS_polymod_oembed_definition_catalog::getByCodename($page->getCodename());
if (!$oembedDefinition) {
    header('HTTP/1.x 404 Not Found', true, 404);
    exit;
}
$pageLang = $page->getLanguage(true);
$cms_language = new CMS_language($pageLang);
define('CURRENT_PAGE', $page->getID());
$website = $page->getWebsite();
$htmlDefinition = $oembedDefinition->getHtml();
$module = CMS_poly_object_catalog::getModuleCodenameForObjectType($oembedDefinition->getObjectdefinition());
$polymodModule = CMS_modulesCatalog::getByCodename($module);
$transformedDefinition = $polymodModule->convertDefinitionString($htmlDefinition, false);
$parameters = array();
$parameters['module'] = CMS_poly_object_catalog::getModuleCodenameForObjectType($oembedDefinition->getObjectdefinition());
$parameters['objectID'] = $oembedDefinition->getObjectdefinition();
$parameters['public'] = true;
$parameters['cache'] = false;
$parameters['pageID'] = CURRENT_PAGE;
$definitionParsing = new CMS_polymod_definition_parsing($transformedDefinition, true, CMS_polymod_definition_parsing::BLOCK_PARAM_MODE, $parameters['module']);
$compiledDefinition = $definitionParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_PHP, $parameters);
$urlParts = parse_url($url);
if (!isset($urlParts['query'])) {
    die("Incorrect parameters");
}
parse_str($urlParts['query']);
$parameterName = $oembedDefinition->getParameter();
示例#3
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;
示例#4
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();
     }
 }
示例#5
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;
 }
示例#6
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']);
示例#7
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 = '';
示例#8
0
    /**
     * 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;
        }
    }
示例#9
0
 /**
  * select all running scripts from scriptsStatuses Table and check PID files.
  *
  * @return array
  * @access public
  */
 function getRunningScript()
 {
     //check temporary dir for orchan PID files
     //get temporary path
     $tempPath = CMS_file::getTmpPath();
     //computes the directory to put files in
     $tempDir = @dir($tempPath);
     if (!is_object($tempDir)) {
         return array();
     }
     //script application label
     $scriptAppLbl = processManager::getAppCode();
     //Automatic list of directory content
     //Displayed in alphabetical order (noted on Windows platforms)
     $PIDFiles = array();
     while (false !== ($file = $tempDir->read())) {
         if (stripos($file, $scriptAppLbl) !== false && io::strpos($file, ".ok") === false) {
             $PIDFiles[] = $file;
         }
     }
     //check the table
     $sql = "\n\t\t\tselect\n\t\t\t\t*\n\t\t\tfrom\n\t\t\t\tscriptsStatuses\n\t\t\torder by launchDate_ss\n\t\t\t";
     $q = new CMS_query($sql);
     $scripts = array();
     $modules = array();
     while ($data = $q->getArray()) {
         $PIDFileStatus = 0;
         if (array_search($data["scriptName_ss"], $PIDFiles) !== false) {
             $process = new processManager($data["scriptName_ss"]);
             if (@is_file($process->getPIDFilePath() . ".ok")) {
                 $PIDFileStatus = 3;
             } else {
                 $PIDFileStatus = 1;
             }
             $key = array_search($data["scriptName_ss"], $PIDFiles);
             unset($PIDFiles[$key]);
         }
         $scriptTitle = '';
         //instanciate module if not exists
         if (isset($data['module_ss']) && $data['module_ss'] != self::MASTER_SCRIPT_NAME) {
             if (!isset($modules[$data['module_ss']])) {
                 $modules[$data['module_ss']] = CMS_modulesCatalog::getByCodename($data['module_ss']);
             }
             if (is_object($modules[$data['module_ss']])) {
                 $scriptTitle = $modules[$data['module_ss']]->scriptInfo(unserialize($data['parameters_ss']));
             } else {
                 $scriptTitle = 'Error : script module not set';
             }
         } elseif ($data['module_ss'] == self::MASTER_SCRIPT_NAME) {
             $scriptTitle = self::MASTER_SCRIPT_NAME;
         } else {
             $scriptTitle = 'Error : script module not set';
         }
         $script = array("Title" => $scriptTitle, "Date" => $data["launchDate_ss"], "PIDFile" => $PIDFileStatus);
         $scripts[] = $script;
     }
     //add orphan PIDFiles to the report
     foreach ($PIDFiles as $anOrphanPIDFile) {
         $script = array("Title" => str_replace('_', ' ', str_replace('bgscript_', '', $anOrphanPIDFile)), "Date" => '', "PIDFile" => '2');
         $scripts[] = $script;
     }
     return $scripts;
 }
//checks rights
if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
    header("Location: " . PATH_ADMIN_SPECIAL_ENTRY_WR . "?cms_message_id=" . MESSAGE_PAGE_CLEARANCE_ERROR . "&" . session_name() . "=" . session_id());
    exit;
}
//load page objects and vars
$moduleCodename = io::request("moduleCodename");
$objectDefitionId = io::request("objectdefinition");
$objectDefinition = CMS_poly_object_catalog::getObjectDefinition($objectDefitionId);
$oembedDefinitionId = io::request("definition");
$oembedDefinition = CMS_polymod_oembed_definition_catalog::getById($oembedDefinitionId);
if (!$oembedDefinition) {
    $oembedDefinition = new CMS_polymod_oembed_definition();
}
if ($moduleCodename) {
    $polymod = CMS_modulesCatalog::getByCodename($moduleCodename);
}
$cms_message = "";
switch ($_POST["cms_action"]) {
    case "validate":
        $oembedDefinition->setObjectdefinition(io::post('objectdefinition'));
        $oembedDefinition->setCodename(io::post('codename'));
        $oembedDefinition->setHtml(io::post('html'));
        $oembedDefinition->setParameter(io::post('parameter'));
        $oembedDefinition->setLabel(io::post('label'));
        if ($oembedDefinition->validate()) {
            $oembedDefinition->writeToPersistence();
        } else {
            $errors = $oembedDefinition->getValidationFailures();
            foreach ($errors as $error) {
                $cms_message .= "\n" . $error;
 /**
  * Import module from given array datas
  *
  * @param array $data The module datas to import
  * @param array $params The import parameters.
  *		array(
  *				module	=> false|true : the module to create categories (required)
  *				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)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for categories importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for categories importation : ' . $params['module'] . "\n";
         return false;
     }
     $return = true;
     foreach ($data as $categoryDatas) {
         $importType = '';
         if (isset($categoryDatas['uuid']) && ($id = CMS_moduleCategories_catalog::categoryExists($params['module'], $categoryDatas['uuid']))) {
             //category already exist : load it if we can update it
             if (!isset($params['update']) || $params['update'] == true) {
                 $category = CMS_moduleCategories_catalog::getByID($id);
                 $importType = ' (Update)';
             }
         } else {
             //create new category if we can
             if (!isset($params['create']) || $params['create'] == true) {
                 //if category to create has parent, try to get it
                 if (isset($categoryDatas['parent']) && $categoryDatas['parent']) {
                     //check for uuid translation
                     if (isset($idsRelation['categories-uuid'][$categoryDatas['parent']])) {
                         $categoryDatas['parent'] = $idsRelation['categories-uuid'][$categoryDatas['parent']];
                     }
                     //parent already exist : load it
                     $parentId = CMS_moduleCategories_catalog::categoryExists($params['module'], $categoryDatas['parent']);
                 }
                 if (isset($categoryDatas['root']) && $categoryDatas['root']) {
                     //check for uuid translation
                     if (isset($idsRelation['categories-uuid'][$categoryDatas['root']])) {
                         $categoryDatas['root'] = $idsRelation['categories-uuid'][$categoryDatas['root']];
                     }
                     //root already exist : load it
                     $rootId = CMS_moduleCategories_catalog::categoryExists($params['module'], $categoryDatas['root']);
                 }
                 //create category
                 $category = new CMS_moduleCategory(0, $cms_language);
                 $importType = ' (Creation)';
                 //set module
                 $category->setAttribute('moduleCodename', $params['module']);
                 if (isset($rootId)) {
                     $category->setAttribute('rootID', $rootId);
                 }
                 if (isset($parentId)) {
                     $category->setAttribute('parentID', $parentId);
                 }
             }
         }
         if (isset($category)) {
             if ($category->fromArray($categoryDatas, $params, $cms_language, $idsRelation, $infos)) {
                 $return &= true;
                 $infos .= 'Category "' . $category->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
             } else {
                 $return = false;
                 $infos .= 'Error during import of category ' . $categoryDatas['id'] . $importType . "\n";
             }
         }
     }
     return $return;
 }
示例#12
0
 /**
  * Import module objects from given array datas
  *
  * @param array $data The module datas to import
  * @param array $params The import parameters.
  *		array(
  *				module	=> false|true : the module to create categories (required)
  *				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)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for objects importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for objects importation : ' . $params['module'] . "\n";
         return false;
     }
     $return = true;
     //first create missing objects to get relation ids
     foreach ($data as $objectDatas) {
         if (!isset($objectDatas['uuid']) || !CMS_poly_object_catalog::objectExists($params['module'], $objectDatas['uuid'])) {
             //create new object if we can
             if (!isset($params['create']) || $params['create'] == true) {
                 //create object
                 $object = new CMS_poly_object_definition();
                 //set module
                 $object->setValue('module', $params['module']);
                 //set uuid
                 $object->setUuid($objectDatas['uuid']);
                 //write object to persistence to get relations ids
                 $object->writeToPersistence();
                 //set id translation
                 if (isset($objectDatas['id']) && $objectDatas['id']) {
                     // && $object->getID() != $objectDatas['id']) {
                     // Fix for bug #3157 : in some cases the imported object will have the same id has the newly created,
                     // we still need the relation table otherwise it will fail to link to the new object
                     $idsRelation['objects'][$objectDatas['id']] = $object->getID();
                 }
                 //set uuid translation
                 if (isset($objectDatas['uuid']) && $objectDatas['uuid'] && $object->getValue('uuid') != $objectDatas['uuid']) {
                     $idsRelation['objects-uuid'][$objectDatas['uuid']] = $object->getValue('uuid');
                 }
             }
         } elseif (isset($objectDatas['uuid']) && isset($objectDatas['id'])) {
             //get relation between imported object id and local id
             $id = CMS_poly_object_catalog::objectExists($params['module'], $objectDatas['uuid']);
             if (io::isPositiveInteger($id)) {
                 $idsRelation['objects'][$objectDatas['id']] = $id;
             }
         }
     }
     //then import objects datas
     foreach ($data as $objectDatas) {
         $importType = '';
         if (isset($objectDatas['uuid']) && ($id = CMS_poly_object_catalog::objectExists($params['module'], $objectDatas['uuid']))) {
             //object already exist : load it if we can update it
             if (!isset($params['update']) || $params['update'] == true) {
                 $object = CMS_poly_object_catalog::getObjectDefinition($id);
                 $importType = ' (Update)';
                 //set id translation
                 $idsRelation['objects'][$objectDatas['id']] = $id;
             }
         } else {
             //check for translated id
             if (isset($objectDatas['id']) && isset($idsRelation['objects'][$objectDatas['id']])) {
                 //object exists with a translated id
                 $objectDatas['id'] = $idsRelation['objects'][$objectDatas['id']];
                 //load translated object
                 $object = CMS_poly_object_catalog::getObjectDefinition($objectDatas['id']);
                 $importType = ' (Creation)';
             }
             //check for translated uuid
             if (isset($objectDatas['uuid']) && isset($idsRelation['objects-uuid'][$objectDatas['uuid']])) {
                 //object exists with a translated uuid
                 $objectDatas['uuid'] = $idsRelation['objects-uuid'][$objectDatas['uuid']];
                 //load translated object
                 if ($id = CMS_poly_object_catalog::objectExists($params['module'], $objectDatas['uuid'])) {
                     $object = CMS_poly_object_catalog::getObjectDefinition($id);
                     $importType = ' (Creation)';
                 }
             }
         }
         if (isset($object)) {
             if ($object->fromArray($objectDatas, $params, $cms_language, $idsRelation, $infos)) {
                 $return &= true;
                 $infos .= 'Object "' . $object->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
             } else {
                 $return = false;
                 $infos .= 'Error during import of object ' . $objectDatas['id'] . $importType . "\n";
             }
         }
     }
     return $return;
 }
示例#13
0
 /**
  * Get the representation instance, from the tag name
  * What is needed ?
  * - $args = array("template"=>template_db_id) and attributes contain "id" key along with value for client spaces
  * - attributes contain "id" and "type" keys along with values for rows
  * - attributes contain "id" and "type" keys along with values for blocks
  *
  * @param array(mixed) $args The arguments needed to instanciate the representation
  * @return object An instanciated object of the correct class.
  * @access public
  */
 function getRepresentationInstance($args = false)
 {
     //if it's a module tag, ask the representation to the module
     if (isset($this->_attributes["module"]) && $this->_attributes["module"]) {
         //Get the module
         $module = CMS_modulesCatalog::getByCodename($this->_attributes["module"]);
         if ($module instanceof CMS_module) {
             //get the instance from the module
             $instance = $module->getTagRepresentation($this, $args);
             if (is_object($instance)) {
                 return $instance;
             } else {
                 //module didn't returned a valid object instance
                 return false;
             }
         } else {
             //the modules catalog didn't returned a module object
             return false;
         }
     }
     switch ($this->_name) {
         case "atm-linx":
             if ($this->_attributes["type"] && $args["page"] && isset($args["publicTree"])) {
                 $linxArgs = array();
                 $linxArgs['id'] = isset($this->_attributes["id"]) ? $this->_attributes["id"] : false;
                 $linxArgs['class'] = isset($this->_attributes["class"]) ? $this->_attributes["class"] : false;
                 if (isset($this->_attributes["node"]) && io::isPositiveInteger($this->_attributes["node"])) {
                     $linxArgs['node'] = $this->_attributes["node"];
                 }
                 if (isset($this->_attributes["codename"]) && $this->_attributes["codename"]) {
                     $linxArgs['codename'] = $this->_attributes["codename"];
                 }
                 return new CMS_linx($this->_attributes["type"], $this->getContent(), $args["page"], $args["publicTree"], $linxArgs);
             } else {
                 return false;
             }
             break;
     }
 }
示例#14
0
				<td background="' . PATH_ADMIN_IMAGES_WR . '/tiret_h.gif" align="right"><img src="' . PATH_ADMIN_IMAGES_WR . '/pix_trans.gif" width="1" height="1" border="0" alt="-" /></td>
				<td width="36" height="36"><img src="' . PATH_ADMIN_IMAGES_WR . '/rond_hd.gif" border="0" alt="-" /></td>
			</tr>
			<tr>
				<td width="36" valign="top" background="' . PATH_ADMIN_IMAGES_WR . '/tiret_g.gif"><img src="' . PATH_ADMIN_IMAGES_WR . '/pix_trans.gif" width="1" height="1" border="0" alt="-" /></td>
				<td colspan="2" rowspan="2" class="admin" align="center">
					<dialog-title type="admin_h2">' . ucfirst($cms_language->getMessage(MESSAGE_PAGE_VALIDATIONS_PENDING)) . '</dialog-title>';
    if ($modules_validations && sizeof($modules_validations)) {
        $content .= '
			<table width="100%" border="0" cellpadding="2" cellspacing="2">';
        foreach ($modules_validations as $module_codename => $module_validations) {
            //if module is not standard, echo its name, the number of validations to do and a link to its admin frontend
            if ($module_codename == MOD_STANDARD_CODENAME) {
                $mod_label = $cms_language->getMessage(MESSAGE_PAGE_STANDARD_MODULE_LABEL);
            } else {
                $mod = CMS_modulesCatalog::getByCodename($module_codename);
                $mod_label = $mod->getLabel($cms_language);
            }
            $content .= '
				<tr>
					<td height="10"><img src="' . PATH_ADMIN_IMAGES_WR . '/pix_trans.gif" width="1" height="1" border="0" /></td>
				</tr>
				<tr>
					<th class="admin">' . $mod_label . '</th>
				</tr>
			';
            //sort the validations by type label
            $validations_sorted = array();
            foreach ($module_validations as $validation) {
                $validations_sorted[$validation->getValidationTypeLabel()][] = $validation;
            }
示例#15
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;
     }
 }
示例#16
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;
         }
     }
 }
示例#17
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
示例#18
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");
     }
 }
示例#19
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);
     }
 }
示例#20
0
 /**
  * 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;
     }
 }
示例#21
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;
 }
示例#22
0
 /**
  * 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;
     }
 }
示例#23
0
 /**
  * Get Module
  *
  * @return CMS_module
  * @access public
  */
 function getModule()
 {
     if ($this->_module) {
         return CMS_modulesCatalog::getByCodename($this->_module);
     } else {
         return false;
     }
 }
示例#24
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;
 }
示例#25
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;
                 }
             }
         }
     }
 }
示例#26
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;
 }
示例#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':
示例#28
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;
 }
示例#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") . '" />';
示例#30
0
 /**
  * Import row from given array datas
  *
  * @param array $data The module datas to import
  * @param array $params The import parameters.
  *		array(
  *				module	=> false|true : the module to create categories (required)
  *				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
  */
 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for categories importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for categories importation : ' . $params['module'] . "\n";
         return false;
     }
     if (!$this->getID() && CMS_moduleCategories_catalog::uuidExists($data['uuid'])) {
         //check imported uuid. If categories does not have an Id, the uuid must be unique or must be regenerated
         $uuid = io::uuid();
         //store old uuid relation
         $idsRelation['categories-uuid'][$data['uuid']] = $uuid;
         $data['uuid'] = $uuid;
     }
     //set category uuid if not exists
     if (!$this->_uuid) {
         $this->_uuid = $data['uuid'];
     }
     if (!isset($params['files']) || $params['files'] == true) {
         if (isset($data['icon'])) {
             $icon = $data['icon'];
             if ($icon && file_exists(PATH_TMP_FS . $icon)) {
                 //destroy old file if any
                 if ($this->getIconPath(false, PATH_RELATIVETO_WEBROOT, true)) {
                     @unlink($this->getIconPath(true, PATH_RELATIVETO_FILESYSTEM, true));
                     $this->setAttribute('icon', '');
                 }
                 //move and rename uploaded file
                 $filename = PATH_TMP_FS . $icon;
                 $basename = pathinfo($filename, PATHINFO_BASENAME);
                 if (!$this->getID()) {
                     //need item ID
                     $this->writeToPersistence();
                 }
                 //create file path
                 $path = $this->getIconPath(true, PATH_RELATIVETO_FILESYSTEM, false) . '/';
                 $extension = pathinfo($icon, PATHINFO_EXTENSION);
                 $newBasename = "cat-" . $this->getID() . "-icon." . $extension;
                 $newFilename = $path . '/' . $newBasename;
                 if (CMS_file::moveTo($filename, $newFilename)) {
                     CMS_file::chmodFile(FILES_CHMOD, $newFilename);
                     //set it
                     $this->setAttribute('icon', $newBasename);
                 }
             } elseif (!$icon) {
                 //destroy old file if any
                 if ($this->getIconPath(false, PATH_RELATIVETO_WEBROOT, true)) {
                     @unlink($this->getIconPath(true, PATH_RELATIVETO_FILESYSTEM, true));
                     $this->setAttribute('icon', '');
                 }
             }
         }
     }
     if (isset($data['labels'])) {
         foreach ($data['labels'] as $language => $label) {
             $this->setLabel($label, $language);
         }
     }
     if (isset($data['descriptions'])) {
         foreach ($data['descriptions'] as $language => $desc) {
             $this->setDescription($desc, $language);
         }
     }
     if (!isset($params['files']) || $params['files'] == true) {
         if (isset($data['files']) && is_array($data['files'])) {
             foreach ($data['files'] as $language => $file) {
                 if ($file && file_exists(PATH_TMP_FS . $file)) {
                     //destroy old file if any
                     if ($this->getFilePath($language, false, PATH_RELATIVETO_WEBROOT, true)) {
                         @unlink($this->getFilePath($language, true, PATH_RELATIVETO_FILESYSTEM, true));
                         $this->setFile('', $language);
                     }
                     //move and rename uploaded file
                     $filename = PATH_TMP_FS . $file;
                     $basename = pathinfo($filename, PATHINFO_BASENAME);
                     if (!$this->getID()) {
                         //need item ID
                         $this->writeToPersistence();
                     }
                     //create file path
                     $path = $this->getFilePath($language, true, PATH_RELATIVETO_FILESYSTEM, false) . '/';
                     $extension = pathinfo($file, PATHINFO_EXTENSION);
                     $newBasename = "cat-" . $this->getID() . "-file-" . $language . "." . $extension;
                     $newFilename = $path . '/' . $newBasename;
                     if (CMS_file::moveTo($filename, $newFilename)) {
                         CMS_file::chmodFile(FILES_CHMOD, $newFilename);
                         //set it
                         $this->setFile($newBasename, $language);
                     }
                 } elseif (!$file) {
                     //destroy old file if any
                     if ($this->getFilePath($language, false, PATH_RELATIVETO_WEBROOT, true)) {
                         @unlink($this->getFilePath($language, true, PATH_RELATIVETO_FILESYSTEM, true));
                         $this->setFile('', $language);
                     }
                 }
             }
         }
     }
     //write object
     if (!$this->writeToPersistence()) {
         $infos .= 'Error : can not write category ...' . "\n";
         return false;
     }
     //if current category id has changed from imported id, set relation
     if (isset($data['id']) && $data['id'] && $this->getID() != $data['id']) {
         $idsRelation['categories'][$data['id']] = $this->getID();
         if (isset($data['uuid']) && $data['uuid']) {
             $idsRelation['categories'][$data['uuid']] = $this->getID();
         }
     }
     //set category order
     if (isset($data['order']) && $data['order']) {
         CMS_moduleCategories_catalog::moveCategoryIndex($this, $data['order']);
     }
     //set categories childs
     if (isset($data['childs']) && $data['childs']) {
         return CMS_moduleCategories_catalog::fromArray($data['childs'], $params, $cms_language, $idsRelation, $infos);
     }
     return true;
 }