public function fireAfterSaveEvent() { // Clear the cache: $cacheRefreshOptions = array('system_settings' => array()); $this->modx->cacheManager->refresh($cacheRefreshOptions); return parent::fireAfterSaveEvent(); }
/** {@inheritDoc} */ public function beforeSet() { if ($this->modx->getObject('up2Tabs', array('tab' => $this->getProperty('tab'), 'type' => $this->getProperty('type'), 'id:!=' => $this->getProperty('id')))) { $this->modx->error->addField('tab', $this->modx->lexicon('vp_err_ae')); } return parent::beforeSet(); }
public function beforeSave() { // Setting creator and time created $this->object->set('editedby', $this->modx->user->get('id')); $this->object->set('editedon', date('Y-m-d H:i:s', time())); return parent::beforeSave(); }
public function beforeSet() { if ($this->modx->getObject('mSkladProductProperty', array('source' => $this->getProperty('source'), 'id:!=' => $this->getProperty('id')))) { $this->modx->error->addField('source', $this->modx->lexicon('msklad_err_ae')); } return parent::beforeSet(); }
/** * Override in your derivative class to do functionality before save() is run * @return boolean */ public function beforeSet() { if ($this->merged) { $smarttagTagresources = $this->merged->getMany('Tagresources'); if ($smarttagTagresources) { $params = array(); foreach ($smarttagTagresources as $smarttagTagresource) { $params[] = array('tag_id' => $this->object->get('id'), 'tmplvar_id' => $smarttagTagresource->get('tmplvar_id'), 'resource_id' => $smarttagTagresource->get('resource_id')); } $this->modx->removeCollection('smarttagTagresources', array('tag_id' => $this->merged->get('id'))); foreach ($params as $param) { $smarttagTagresource = $this->modx->newObject('smarttagTagresources'); $smarttagTagresource->fromArray($param, '', true, true); if ($smarttagTagresource->save() === false) { $this->modx->log(modX::LOG_LEVEL_ERROR, __FILE__ . ' '); $this->modx->log(modX::LOG_LEVEL_ERROR, __METHOD__ . ' '); $this->modx->log(modX::LOG_LEVEL_ERROR, __LINE__ . ': Could not save new data ' . print_r($param, 1)); } else { $this->updateTVResourceValue($smarttagTagresource); } } } } $smarttagTagresources = $this->object->getMany('Tagresources'); if ($smarttagTagresources) { foreach ($smarttagTagresources as $smarttagTagresource) { $this->updateTVResourceValue($smarttagTagresource); } } return parent::beforeSave(); }
public function initialize() { if (!$this->getProperty('username')) { return 'Не указан пользователь'; } return parent::initialize(); }
public function afterSave() { $this->updateTranslations($this->getProperties()); $this->refreshURIs(); $this->clearCache(); return parent::afterSave(); }
public function beforeSave() { $name = $this->getProperty('name'); $alias = $this->getProperty('alias'); if (empty($name)) { $this->addFieldError('name', $this->modx->lexicon('tagger.err.group_name_ns')); } else { if ($this->modx->getCount($this->classKey, array('name' => $name)) && $this->object->name != $name) { $this->addFieldError('name', $this->modx->lexicon('tagger.err.group_name_ae')); } } $fieldType = $this->getProperty('field_type'); $showAutotag = (int) $this->getProperty('show_autotag', 0); if ($fieldType != 'tagger-field-tags') { $this->object->set('show_autotag', 0); } if ($showAutotag != 1) { $this->object->set('hide_input', 0); } if (!empty($alias)) { $alias = $this->object->cleanAlias($alias); if ($this->modx->getCount($this->classKey, array('alias' => $alias, 'id:!=' => $this->object->id)) > 0) { $this->addFieldError('alias', $this->modx->lexicon('tagger.err.group_alias_ae')); } else { $this->object->set('alias', $alias); } } return parent::beforeSave(); }
public function afterSave() { /* now store the permissions into the modAccessPermission table */ /* and cache the data into the policy table */ $permissions = $this->getProperty('permissions', null); if ($permissions !== null) { $permissions = is_array($permissions) ? $permissions : $this->modx->fromJSON($permissions); /* first erase all prior permissions */ $oldPermissions = $this->object->getMany('Permissions'); /** @var modAccessPermission $permission */ foreach ($oldPermissions as $permission) { $permission->remove(); } $added = array(); foreach ($permissions as $permissionArray) { if (in_array($permissionArray['name'], $added)) { continue; } $permission = $this->modx->newObject('modAccessPermission'); $permission->set('template', $this->object->get('id')); $permission->set('name', $permissionArray['name']); $permission->set('description', $permissionArray['description']); $permission->set('value', true); $permission->save(); $added[] = $permissionArray['name']; } } return parent::afterSave(); }
public function beforeSave() { $policyId = $this->getProperty('policy'); $principalId = $this->getProperty('principal'); $target = $this->getProperty('target'); if ($principalId == null) { $this->addFieldError('principal', $this->modx->lexicon('usergroup_err_ns')); } if (empty($policyId)) { $this->addFieldError('policy', $this->modx->lexicon('access_policy_err_ns')); } /* validate for invalid data */ if (!empty($target)) { /** @var modMediaSource $mediaSource */ $mediaSource = $this->modx->getObject('sources.modMediaSource', $target); if (empty($mediaSource)) { $this->addFieldError('target', $this->modx->lexicon('source_err_nf')); } if (!$mediaSource->checkPolicy('view')) { $this->addFieldError('target', $this->modx->lexicon('access_denied')); } } $policy = $this->modx->getObject('modAccessPolicy', $policyId); if (empty($policy)) { $this->addFieldError('policy', $this->modx->lexicon('access_policy_err_nf')); } $alreadyExists = $this->modx->getObject('modAccessCategory', array('principal' => $principalId, 'principal_class' => 'modUserGroup', 'target' => $target, 'policy' => $policyId, 'context_key' => $this->getProperty('context_key'), 'id:!=' => $this->object->get('id'))); if ($alreadyExists) { $this->addFieldError('context_key', $this->modx->lexicon('access_source_err_ae')); } $this->object->set('principal_class', 'modUserGroup'); return parent::beforeSave(); }
public function beforeSet() { $content = ''; $classKey = $this->getProperty('class_key'); switch ($classKey) { case 'sSnippetTask': $content = $this->getProperty('snippet-content'); if (empty($content)) { $this->addFieldError('snippet-content', $this->modx->lexicon('scheduler.error.no-snippet-content')); return false; } break; case 'sProcessorTask': $content = $this->getProperty('processor-content'); if (empty($content)) { $this->addFieldError('processor-content', $this->modx->lexicon('scheduler.error.no-processor-content')); return false; } break; case 'sFileTask': default: $content = $this->getProperty('file-content'); if (empty($content)) { $this->addFieldError('file-content', $this->modx->lexicon('scheduler.error.no-file-content')); return false; } break; } $this->setProperty('content', $content); return parent::beforeSet(); }
public function initialize() { $user_code = $this->getProperty('user_code'); //check if code not empty if (empty($user_code) or $user_code == '') { return $this->modx->lexicon('ep_sms_code_is_empty'); } $query = $this->modx->newQuery('epValidateNum'); /*get row with select all from max row with max createdon */ $query->select('id as id,createdon as createdon,code as code,validate as validate,phone as phone'); $query->limit(1); $query->sortby('createdon', 'desc'); $query->where(array('user_id:=' => $this->modx->user->id)); //get data array if ($query->prepare() && $query->stmt->execute()) { $this->data = $query->stmt->fetch(PDO::FETCH_ASSOC); } //check for current code validate status for this user if ($this->data['validate'] == 1) { return $this->modx->lexicon('ep_sms_validate_already_done'); } //if code is correct - set update time and validate status if ($this->data['code'] == $user_code) { $this->setProperties(array('validate' => 1, 'updatedon' => date('Y-m-d H:i:s'), 'id' => $this->data['id'])); } else { return $this->modx->lexicon('ep_sms_check_code_wrong'); } return parent::initialize(); }
public function beforeSet() { $this->setCheckbox('uri', false); $this->setCheckbox('override', false); $this->setCheckbox('active', false); return parent::beforeSet(); }
/** * @return bool */ public function beforeSet() { $id = (int) $this->getProperty('id'); $rid = $this->getProperty('rid'); list($type, $principal) = explode('-', $this->getProperty('principal')); if ($this->modx->getCount($this->classKey, array('rid' => $rid, 'principal_type' => $type, 'principal' => $principal, 'id:!=' => $id))) { $this->modx->error->addField('principal', $this->modx->lexicon('admintools_permissions_err_ae')); return parent::beforeSet(); } switch ($type) { case 'all': $weight = 0; break; case 'gst': $weight = 1; break; case 'grp': $weight = 10; break; case 'usr': $weight = 100; break; default: $weight = 0; break; } if ($type != 'grp') { $this->setProperty('priority', 0); } $this->setProperty('weight', $weight); $this->setProperty('principal_type', $type); $this->setProperty('principal', $principal); return parent::beforeSet(); }
public function beforeSave() { $hasLayout = (bool) $this->getProperty('haslayout'); $this->object->set('haslayout', $hasLayout); $controller = $this->getProperty('controller'); if (empty($controller)) { $this->addFieldError('controller', $this->modx->lexicon('controller_err_ns')); } /* verify parent */ $parent = $this->getProperty('parent', null); if (!empty($parent)) { $parent = $this->modx->getObject('modAction', $parent); if (empty($parent)) { $this->addFieldError('parent', $this->modx->lexicon('action_parent_err_nf')); } } /* verify namespace */ $namespace = $this->getProperty('namespace'); if (empty($namespace)) { $this->addFieldError('namespace', $this->modx->lexicon('namespace_err_nf')); } $namespace = $this->modx->getObject('modNamespace', $namespace); if (empty($namespace)) { $this->addFieldError('namespace', $this->modx->lexicon('namespace_err_nf')); } return parent::beforeSave(); }
/** {@inheritDoc} */ public function initialize() { if (!$this->modx->hasPermission($this->permission)) { return $this->modx->lexicon('access_denied'); } return parent::initialize(); }
/** {@inheritDoc} */ public function beforeSet() { $id = (int) $this->getProperty('id'); if (empty($id)) { return $this->modx->lexicon('currencyrate_err_ns'); } $name = trim($this->getProperty('name')); if (empty($name)) { $this->modx->error->addField('name', $this->modx->lexicon('currencyrate_err_ae')); } $numcode = trim($this->getProperty('numcode')); if (empty($numcode)) { $this->modx->error->addField('numcode', $this->modx->lexicon('currencyrate_err_ae')); } $charcode = trim($this->getProperty('charcode')); if (empty($numcode)) { $this->modx->error->addField('charcode', $this->modx->lexicon('currencyrate_err_ae')); } if ($this->modx->getCount($this->classKey, array('numcode' => $numcode, 'id:!=' => $id))) { $this->modx->error->addField('numcode', $this->modx->lexicon('currencyrate_err_ae')); } if ($this->modx->getCount($this->classKey, array('charcode' => $charcode, 'id:!=' => $id))) { $this->modx->error->addField('charcode', $this->modx->lexicon('currencyrate_err_ae')); } return parent::beforeSet(); }
public function beforeSave() { /*print_r($this->object->toArray()); exit;*/ return parent::beforeSave(); }
/** * {@inheritDoc} * * @return mixed */ public function afterSave() { if ($this->refreshURIs) { $this->modx->call('modResource', 'refreshURIs', array(&$this->modx)); } return parent::afterSave(); }
public function logManagerAction() { if ($this->logSaveAction) { return parent::logManagerAction(); } return; }
public function afterSave() { if ($this->modx->hasPermission('usergroup_user_edit')) { $this->addUsers(); } return parent::afterSave(); }
public function initialize() { // Sanitize post data $this->unsetProperty('comments_count'); //$this->unsetProperty('createdon'); $this->unsetProperty('editedon'); if (!($thread_id = (int) $this->getProperty('thread_id'))) { /* Если не была получена ветка, то пытаемся ее создать */ if (!($response = $this->modx->runProcessor('society/web/threads/get', array("target_id" => $this->getProperty("target_id"), "target_class" => $this->getProperty("target_class", "modResource")), array("processors_path" => dirname(dirname(dirname(dirname(__FILE__)))) . '/')))) { $error = "Ошибка выполнения запроса"; $this->modx->log(xPDO::LOG_LEVEL_ERROR, "[- " . __CLASS__ . " -] {$error}"); $this->modx->log(xPDO::LOG_LEVEL_ERROR, "[- " . __CLASS__ . " -] " . print_r($this->getProperties(), true)); return $error; } // else if ($response->isError() or !($thread_data = $response->getObject())) { if (!($error = $response->getMessage())) { $error = "Не были получены данные ветви диалога"; } $this->modx->log(xPDO::LOG_LEVEL_ERROR, "[- " . __CLASS__ . " -] {$error}"); $this->modx->log(xPDO::LOG_LEVEL_ERROR, "[- " . __CLASS__ . " -] " . print_r($response->getResponse(), true)); $this->modx->log(xPDO::LOG_LEVEL_ERROR, "[- " . __CLASS__ . " -] " . print_r($this->getProperties(), true)); return $error; } //else $thread_id = $thread_data['id']; } $this->setProperty('id', $thread_id); return parent::initialize(); }
public function beforeSave() { $name = $this->getProperty('tag'); $group = $this->getProperty('group'); $alias = $this->getProperty('alias'); if (empty($name) || empty($group)) { if (empty($group)) { $this->addFieldError('group', $this->modx->lexicon('tagger.err.group_name_ns')); } if (empty($name)) { $this->addFieldError('tag', $this->modx->lexicon('tagger.err.tag_name_ns')); } } else { if ($this->object->group != $group) { $this->addFieldError('group', $this->modx->lexicon('tagger.err.tag_group_changed')); } if ($this->modx->getCount($this->classKey, array('tag' => $name, 'group' => $group, 'id:!=' => $this->object->id)) > 0) { $this->addFieldError('tag', $this->modx->lexicon('tagger.err.tag_name_ae')); } } if (!empty($alias)) { $alias = $this->object->cleanAlias($alias); if ($this->modx->getCount($this->classKey, array('alias' => $alias, 'group' => $group, 'id:!=' => $this->object->id)) > 0) { $this->addFieldError('alias', $this->modx->lexicon('tagger.err.tag_alias_ae')); } else { $this->object->set('alias', $alias); } } return parent::beforeSave(); }
public function beforeSet() { if ($this->modx->getObject('msLink', array('name' => $this->getProperty('name'), 'id:!=' => $this->getProperty('id')))) { $this->modx->error->addField('name', $this->modx->lexicon('ms2_err_ae')); } return parent::beforeSet(); }
/** {@inheritDoc} */ public function beforeSet() { $id = (int) $this->getProperty('id'); if (empty($id)) { return $this->modx->lexicon('mlmsystem_err_ns'); } $name = trim($this->getProperty('name')); if (empty($name)) { $this->modx->error->addField('name', $this->modx->lexicon('mlmsystem_err_ae')); } $field = trim($this->getProperty('field')); if (empty($field)) { $this->modx->error->addField('field', $this->modx->lexicon('mlmsystem_err_ae')); } $class = trim($this->getProperty('class')); if (empty($class)) { $this->modx->error->addField('class', $this->modx->lexicon('mlmsystem_err_ae')); } $mode = trim($this->getProperty('mode')); if (empty($mode)) { $this->modx->error->addField('mode', $this->modx->lexicon('mlmsystem_err_ae')); } if ($this->modx->getCount($this->classKey, array('class' => $class, 'field' => $field, 'id:!=' => $id))) { $this->modx->error->addField('name', $this->modx->lexicon('mlmsystem_err_ae')); } return parent::beforeSet(); }
/** {inheritDoc} */ public function beforeSet() { /** @var msDiscount $msDiscount */ $msDiscount = $this->modx->getService('msDiscount'); $properties = $this->getProperties(); foreach ($properties as $k => $v) { $properties[$k] = $msDiscount->sanitize($k, $v); } $this->setProperties($properties); $required = array('name', 'discount'); foreach ($required as $v) { $value = trim($this->getProperty($v)); if (empty($value) || $value == '0%') { $this->modx->error->addField($v, $this->modx->lexicon('msd_err_ns')); } } $unique = array('name'); foreach ($unique as $v) { if ($this->modx->getCount($this->classKey, array($v => $this->getProperty($v), 'id:!=' => $this->object->id))) { $this->modx->error->addField($v, $this->modx->lexicon('msd_err_ae')); } } $coupons = $this->getProperty('coupons'); if ($coupons < $this->object->get('coupons')) { $this->unsetProperty('coupons'); } $this->unsetProperty('prefix'); return parent::beforeSet(); }
public function afterSave() { /** @var xPDOFileCache $provider */ $provider = $this->modx->cacheManager->getCacheProvider('oauth2server'); $provider->flush(); return parent::afterSave(); }
public function beforeSave() { $name = $this->getProperty('name'); if (empty($name)) { $this->addFieldError('name', $this->modx->lexicon('role_err_ns_name')); } return parent::beforeSave(); }
public function afterSave() { $this->saveRequired(); if ($this->validationType) { $this->saveValidation(); } return parent::afterSave(); }
public function beforeSave() { if ($this->object->get('recipient') != $this->modx->user->get('id')) { return $this->modx->lexicon($this->objectType . '_err_nfs'); } $this->object->set('read', true); return parent::beforeSave(); }