/** * Writes the group data into persistence (MySQL for now). * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { parent::writeToPersistence(); $sql_fields = "\n\t\t\tlabel_prg='" . SensitiveIO::sanitizeSQLString($this->_label) . "',\n\t\t\tdescription_prg='" . SensitiveIO::sanitizeSQLString($this->_description) . "',\n\t\t\tprofile_prg='" . SensitiveIO::sanitizeSQLString(parent::getId()) . "'\n\t\t"; if ($this->_groupId) { $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tprofilesUsersGroups\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_prg='" . $this->_groupId . "'\n\t\t\t"; } else { $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tprofilesUsersGroups\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields; } $q = new CMS_query($sql); if ($q->hasError()) { return false; } elseif (!$this->_groupId) { $this->_groupId = $q->getLastInsertedID(); } /* Delete all records and re-insert the good ones */ $sql = "\n\t\t\tdelete from\n\t\t\t\tprofileUsersByGroup\n\t\t\twhere\n\t\t\t\tgroupId_gu='" . $this->_groupId . "'\n\t\t"; $q = new CMS_query($sql); if (is_array($this->_users) && $this->_users) { $sql = ''; foreach ($this->_users as $user) { $sql .= $sql ? ', ' : ''; $sql .= "('" . $this->_groupId . "' ,'" . $user . "') "; } $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tprofileUsersByGroup (groupId_gu, userId_gu)\n\t\t\t\tvalues \n\t\t\t\t\t" . $sql; $q = new CMS_query($sql); } //Clear polymod cache //CMS_cache::clearTypeCacheByMetas('polymod', array('resource' => 'users')); CMS_cache::clearTypeCache('polymod'); return true; }
/** * Writes the profile Data into persistence (MySQL for now). * * @return boolean true on success, false on failure * @access public */ function writeProfileToPersistence() { return parent::writeToPersistence(); }
if ($isUser) { if ($profile->getUserId() == ROOT_PROFILEUSER_ID) { $disableFields = 'disabled:true,'; $disableFieldsDesc = "<br /><br />" . $cms_language->getJSMessage(MESSAGE_PAGE_USER_ADMINISTRATOR); } else { //if user belongs to groups, all fields are disabled $disableFields = sizeof(CMS_profile_usersGroupsCatalog::getGroupsOfUser($profile, true)) ? 'disabled:true,' : ''; $disableFieldsDesc = ''; if ($disableFields) { $disableFieldsDesc = "<br /><br />" . $cms_language->getJSMessage(MESSAGE_PAGE_USER_RIGHT); } } } $adminTab = ''; // Admin clearance rows $admins = CMS_profile::getAllAdminClearances(); foreach ($admins as $level => $messages) { if ($cms_user->hasAdminClearance($level)) { $checked = $profile->hasAdminClearance($level) ? 'checked:true,' : ''; $adminTab .= "{\n\t\t\t" . $disableFields . "\n\t\t\t" . $checked . "\n\t\t\tboxLabel: \t'<span ext:qtip=\"" . $cms_language->getJSMessage($messages['description']) . "\" class=\"atm-help\">" . $cms_language->getJSMessage($messages['label']) . "</span>',\n\t\t\tname: \t\t'admin[]',\n\t\t\tinputValue:\t'" . $level . "',\n\t\t\tlisteners:\t{'check':function(checkbox, checked){\n\t\t\t\t//enable or disable others checkboxes if admin check if touched\n\t\t\t\tif (checkbox.getRawValue() == 1) {\n\t\t\t\t\tvar form = Ext.getCmp('userAdminPanel-{$profileId}');\n\t\t\t\t\tvar checkboxes = form.findByType('checkbox');\n\t\t\t\t\tfor(var i = 0, checklen = checkboxes.length; i < checklen; i++) {\n\t\t\t\t\t\tif (checkboxes[i].getRawValue() != 1) {\n\t\t\t\t\t\t\tif (checked) {\n\t\t\t\t\t\t\t\tcheckboxes[i].disable();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcheckboxes[i].enable();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}}\n\t\t},"; } } $adminTab = io::substr($adminTab, 0, -1); $adminTabSubmit = ''; if (!$disableFields) { $adminTabSubmit = ",buttons:[{\n\t\ttext:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_SAVE)}',\n\t\ticonCls:\t\t'atm-pic-validate',\n\t\txtype:\t\t\t'button',\n\t\tname:\t\t\t'submitAdmin',\n\t\thandler:\t\tfunction() {\n\t\t\tvar form = Ext.getCmp('userAdminPanel-{$profileId}').getForm();\n\t\t\tform.submit({params:{\n\t\t\t\taction:\t\t'admin-rights',\n\t\t\t\tuserId:\t\t'{$userId}',\n\t\t\t\tgroupId:\t'{$groupId}'\n\t\t\t}});\n\t\t}\n\t}]"; } $jscontent = <<<END \tvar adminWindow = Ext.getCmp('{$winId}'); \t \t//create center panel
$disableFieldsDesc = ''; if ($disableFields) { $disableFieldsDesc = "{\n\t\t\t\tcls:\t'atm-text-alert',\n\t\t\t\thtml:\t'{$cms_language->getJSMessage(MESSAGE_PAGE_NO_RIGHTS_MODIFY)}'\n\t\t\t},"; } } } else { $disableFields = false; $disableFieldsDesc = ''; if ($profile->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { $disableFields = true; $moduleClearance = CLEARANCE_MODULE_EDIT; $disableFieldsDesc = "{\n\t\t\tcls:\t'atm-text-alert',\n\t\t\thtml:\t'{$cms_language->getJSMessage(MESSAGE_PAGE_GROUP_ADMINISTRATOR_MODULE)}'\n\t\t},"; } } //Module clearances $allclearances = CMS_profile::getAllModuleClearances(); $moduleAccess = ''; foreach ($allclearances as $clearance => $messages) { $standardDisableNone = false; if ($moduleCodename == MOD_STANDARD_CODENAME && $clearance == CLEARANCE_PAGE_NONE) { $standardDisableNone = true; } $moduleAccess .= "{\n\t\tboxLabel:\t\t'<span ext:qtip=\"" . $cms_language->getJSMessage($messages['description']) . "\" class=\"atm-help\">" . $cms_language->getJSMessage($messages['label']) . "</span>',\n\t\tname:\t\t\t'{$moduleCodename}-access-{$profileId}',\n\t\t" . ($clearance == CLEARANCE_MODULE_NONE ? "id:'{$moduleCodename}-access-{$profileId}'," : '') . "\n\t\tinputValue:\t\t" . $clearance . ",\n\t\tchecked:\t\t" . ($moduleClearance == $clearance ? 'true' : 'false') . ",\n\t\tdisabled:\t\t" . ($standardDisableNone || $disableFields || !$cms_user->hasModuleClearance($moduleCodename, $clearance) ? 'true' : 'false') . "\n\t},"; } //validations clearance $moduleAccess .= "{\n\tboxLabel:\t\t'<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_AUTH_VALIDATION_USER_ADMINISTRATOR) . "\" class=\"atm-help\">" . $cms_language->getJSMessage(MESSAGE_PAGE_VALIDATION_RIGHTS) . "</span>',\n\tid:\t\t\t\t'{$moduleCodename}-validate-{$profileId}',\n\tinputValue:\t\t'1',\n\txtype:\t\t\t'checkbox',\n\tchecked:\t\t" . ($profile->hasValidationClearance($moduleCodename) ? 'true' : 'false') . ",\n\tdisabled:\t\t" . ($disableFields || !$cms_user->hasValidationClearance($moduleCodename) ? 'true' : 'false') . "\n}"; $moduleAccessSubmit = ''; if (!$disableFields) { $moduleAccessSubmit = ",buttons:[{\n\t\ttext:\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_SAVE) . "',\n\t\ticonCls:\t\t'atm-pic-validate',\n\t\txtype:\t\t\t'button',\n\t\tanchor:\t\t\t'',\n\t\thandler:\t\tfunction() {\n\t\t\tvar access = Ext.getCmp('{$moduleCodename}-access-{$profileId}');\n\t\t\tvar validation = Ext.getCmp('{$moduleCodename}-validate-{$profileId}');\n\t\t\tAutomne.server.call('{$controler}', Ext.emptyFn, {\n\t\t\t\tuserId:\t\t\t'{$userId}',\n\t\t\t\tgroupId:\t\t'{$groupId}',\n\t\t\t\taction:\t\t\t'module-rights',\n\t\t\t\taccess:\t\t\taccess.getGroupValue(),\n\t\t\t\tvalidation:\t\t(validation.getValue() ? 1 : 0),\n\t\t\t\tmodule:\t\t\t'{$moduleCodename}'\n\t\t\t});\n\t\t}\n\t}]"; } $maxDepth = sensitiveIO::isPositiveInteger(CMS_session::getSessionVar("modules_clearances_max_depth")) ? CMS_session::getSessionVar("modules_clearances_max_depth") : 3;