示例#1
0
 /** {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');
     foreach ($required as $v) {
         if ($this->getProperty($v) == '') {
             $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)))) {
             $this->modx->error->addField($v, $this->modx->lexicon('msd_err_ae'));
         }
     }
     $active = $this->getProperty('active');
     $this->setProperty('active', !empty($active) && $active != 'false');
     return parent::beforeSet();
 }
示例#2
0
 /** {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', 'coupons');
     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)))) {
             $this->modx->error->addField($v, $this->modx->lexicon('msd_err_ae'));
         }
     }
     $prefix = $this->getProperty('prefix');
     if (!empty($prefix) && !preg_match('#[A-Z0-9]{5}#i', $prefix)) {
         $this->modx->error->addField('prefix', $this->modx->lexicon('msd_err_prefix'));
     } else {
         $this->setProperty('prefix', strtoupper($prefix));
     }
     return parent::beforeSet();
 }
示例#3
0
 public function beforeSave()
 {
     if (!$this->object->get('name')) {
         return 'Please, type project name';
     }
     return parent::beforeSave();
 }
示例#4
0
 public function beforeSet()
 {
     $optionId = $this->getProperty('option_id');
     if (empty($optionId)) {
         return $this->modx->lexicon($this->objectType . '_err_ns');
     }
     $categoryId = $this->getProperty('category_id');
     if (empty($categoryId)) {
         return $this->modx->lexicon('ms2_category_err_ns');
     }
     $unique = array('option_id' => $optionId, 'category_id' => $categoryId);
     if ($this->doesAlreadyExist($unique)) {
         return $this->modx->lexicon($this->objectType . '_err_ae', $unique);
     }
     $this->option = $this->modx->getObject('msOption', $optionId);
     if (!$this->option) {
         return $this->modx->lexicon($this->objectType . '_err_nf');
     }
     $category = $this->modx->getObject('msCategory', $categoryId);
     if (!$category) {
         return $this->modx->lexicon('ms2_category_err_nf');
     }
     $this->object->set('option_id', $optionId);
     $this->object->set('category_id', $categoryId);
     $rank = $this->modx->getCount($this->classKey, array('category_id' => $categoryId));
     $this->object->set('rank', $rank);
     return parent::beforeSet();
 }
示例#5
0
 /** {@inheritDoc} */
 public function beforeSave()
 {
     $q = $this->modx->newQuery($this->classKey);
     $q->where(array('tab:=' => $this->getProperty('tab')));
     $this->object->fromArray(array('rank' => $this->modx->getCount('up2Fields', $q)));
     return parent::beforeSave();
 }
示例#6
0
 /** {@inheritDoc} */
 public function initialize()
 {
     if (!$this->modx->hasPermission($this->permission)) {
         return $this->modx->lexicon('access_denied');
     }
     return parent::initialize();
 }
示例#7
0
 public function beforeSave()
 {
     // Setting creator and time created
     $this->object->set('createdby', $this->modx->user->get('id'));
     $this->object->set('createdon', date('Y-m-d H:i:s', time()));
     return parent::beforeSave();
 }
 public function beforeSet()
 {
     $this->setCheckbox('uri', false);
     $this->setCheckbox('override', false);
     $this->setCheckbox('active', false);
     return parent::beforeSet();
 }
示例#9
0
 public function afterSave()
 {
     $contexts = $this->getProperty('access_contexts', '');
     $contexts = is_array($contexts) ? $contexts : explode(',', $contexts);
     $contexts = array_unique($contexts);
     if (!empty($contexts)) {
         $flush = false;
         if ($this->getProperty('access_admin')) {
             if ($this->addAdminAccess($contexts)) {
                 $flush = true;
             }
         }
         if ($this->getProperty('access_anon')) {
             if ($this->addAnonymousAccess($contexts)) {
                 $flush = true;
             }
         }
         if ($this->getProperty('access_parallel')) {
             if ($this->addParallelUserGroup($contexts)) {
                 $flush = true;
             }
         }
         $userGroups = $this->getProperty('access_usergroups');
         if (!empty($userGroups)) {
             $userGroups = is_array($userGroups) ? $userGroups : explode(',', $userGroups);
             if ($this->addOtherUserGroups($userGroups, $contexts)) {
                 $flush = true;
             }
         }
         if ($flush) {
             $this->flushPermissions();
         }
     }
     return parent::afterSave();
 }
示例#10
0
 public function afterSave()
 {
     $categories = $this->getCategories();
     $categories = $this->object->setCategories($categories);
     $this->object->set('categories', $categories);
     return parent::afterSave();
 }
示例#11
0
 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->doesAlreadyExist(array('tag' => $name, 'group' => $group))) {
             $this->addFieldError('tag', $this->modx->lexicon('tagger.err.tag_name_ae'));
         }
     }
     if (!empty($alias)) {
         $alias = $this->object->cleanAlias($alias);
         if ($this->doesAlreadyExist(array('alias' => $alias, 'group' => $group))) {
             $this->addFieldError('alias', $this->modx->lexicon('tagger.err.tag_alias_ae'));
         }
     }
     return parent::beforeSave();
 }
 public function initialize()
 {
     if (!($this->historyFile = $this->modx->msrevaluation->process())) {
         $this->failure($this->modx->msrevaluation->error);
     }
     return parent::initialize();
 }
示例#13
0
 public function afterSave()
 {
     /** @var xPDOFileCache $provider */
     $provider = $this->modx->cacheManager->getCacheProvider('oauth2server');
     $provider->flush();
     return parent::afterSave();
 }
 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();
 }
示例#15
0
 /** {@inheritDoc} */
 public function beforeSave()
 {
     $data = $this->modx->currencyrate->calcData($this->object->toArray());
     $data['rank'] = $this->modx->getCount($this->classKey);
     $this->object->fromArray($data);
     return parent::beforeSave();
 }
示例#16
0
 /**
  * @return bool
  */
 public function beforeSet()
 {
     $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))) {
         $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;
     }
     if ($type != 'grp') {
         $this->setProperty('priority', 0);
     }
     $this->setProperty('weight', $weight);
     $this->setProperty('principal_type', $type);
     $this->setProperty('principal', $principal);
     return parent::beforeSet();
 }
示例#17
0
 public function afterSave()
 {
     $this->setContexts();
     if ($this->modx->hasPermission('usergroup_user_edit')) {
         $this->setResourceGroups();
     }
     return parent::afterSave();
 }
示例#18
0
 /**
  * {@inheritDoc}
  * @return boolean
  */
 public function initialize()
 {
     $this->context = $this->modx->getContext($this->getProperty('fk'));
     if (empty($this->context)) {
         return $this->modx->lexicon('setting_err_nf');
     }
     return parent::initialize();
 }
示例#19
0
 public function beforeSave()
 {
     $name = $this->getProperty('persons_name');
     if (empty($name)) {
         $this->addFieldError('persons_name', $this->modx->lexicon('Specify'));
     }
     return parent::beforeSave();
 }
示例#20
0
 /**
  * {@inheritDoc}
  * @return boolean
  */
 public function initialize()
 {
     $name = $this->getProperty('name');
     if (empty($name)) {
         $this->addFieldError('name', $this->modx->lexicon('virtunewsletter.category_err_ns_name'));
     }
     return parent::initialize();
 }
示例#21
0
 public function initialize()
 {
     $classKey = $this->getProperty('class_key');
     if (empty($classKey)) {
         $this->setProperty('class_key', 'sources.modFileMediaSource');
     }
     return parent::initialize();
 }
示例#22
0
 public function beforeSave()
 {
     if ($this->doesAlreadyExist(array('principal' => $this->getProperty('principal'), 'principal_class' => 'modUserGroup', 'target' => $this->getProperty('target'), 'policy' => $this->getProperty('policy'), 'context_key' => $this->getProperty('context_key')))) {
         $this->addFieldError('target', $this->modx->lexicon('access_source_err_ae'));
     }
     $this->object->set('principal_class', 'modUserGroup');
     return parent::beforeSave();
 }
示例#23
0
 public function afterSave()
 {
     $widgets = $this->getProperty('widgets', null);
     if ($widgets != null) {
         $this->assignWidgets($widgets);
     }
     return parent::afterSave();
 }
示例#24
0
 public function afterSave()
 {
     $this->saveRequired();
     if ($this->validationType) {
         $this->saveValidation();
     }
     return parent::afterSave();
 }
示例#25
0
 public function beforeSet()
 {
     $subscribe = $this->modx->getObject('modUser', array('username' => $this->getProperty('username')))->get('id');
     $this->setProperty('subscriberid', $subscribe);
     $this->unsetProperty('username');
     $this->unsetProperty('ctx');
     $this->unsetProperty('society_action');
     return parent::beforeSet();
 }
示例#26
0
 /** {@inheritDoc} */
 public function beforeSave()
 {
     $this->object->fromArray(array('rank' => $this->modx->getCount('up2TypeProfile')));
     // default
     if ($this->modx->userprofile2->getProfileTypeDefault() > 0) {
         $this->object->fromArray(array('default' => 0));
     }
     return parent::beforeSave();
 }
示例#27
0
 public function beforeSave()
 {
     $this->object->set('constraint_class', 'modResource');
     $actionId = $this->getProperty('action_id', null);
     if ($actionId !== null) {
         $this->object->set('action', $actionId);
     }
     return parent::beforeSave();
 }
示例#28
0
 public function beforeSave()
 {
     /* User and Server info */
     $data = array('ip_address' => $_SERVER['REMOTE_ADDR'], 'server_name' => $_SERVER['SERVER_NAME'], 'server_address' => $_SERVER['SERVER_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'request_time' => $_SERVER['REQUEST_TIME']);
     // set data and time created
     $this->object->set('senton', date('Y-m-d H:i:s', time()));
     $this->object->set('data', serialize($data));
     return parent::beforeSave();
 }
示例#29
0
 /**
  * @return bool
  */
 public function beforeSet()
 {
     $name = trim($this->getProperty('resource_id'));
     if (empty($name)) {
         $this->modx->error->addField('resource_id', $this->modx->lexicon('maxposterix_car_err_name'));
     } elseif ($this->modx->getCount($this->classKey, array('name' => $name))) {
         $this->modx->error->addField('resource_id', $this->modx->lexicon('maxposterix_car_err_ae'));
     }
     return parent::beforeSet();
 }
示例#30
0
 /**
  * @return bool
  */
 public function beforeSet()
 {
     $name = trim($this->getProperty('name'));
     if (empty($name)) {
         $this->modx->error->addField('name', $this->modx->lexicon('promocode_item_err_name'));
     } elseif ($this->modx->getCount($this->classKey, array('name' => $name))) {
         $this->modx->error->addField('name', $this->modx->lexicon('promocode_item_err_ae'));
     }
     return parent::beforeSet();
 }