public function beforeSet()
 {
     $this->setCheckbox('uri', false);
     $this->setCheckbox('override', false);
     $this->setCheckbox('active', false);
     return parent::beforeSet();
 }
 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();
 }
示例#3
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();
 }
示例#4
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();
 }
 public function beforeSet()
 {
     if (!$this->getProperty('raw')) {
         return $this->failure($this->modx->lexicon('uf_err_content'));
     }
     return parent::beforeSet();
 }
示例#6
0
 public function beforeSet()
 {
     $group = $this->getProperty('group');
     $items = $this->modx->getCollection($this->classKey, array('group' => $group));
     $this->setProperty('position', count($items));
     return parent::beforeSet();
 }
示例#7
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();
 }
示例#8
0
 public function beforeSet()
 {
     $clientId = $this->getProperty('client_id');
     if (empty($clientId)) {
         $this->addFieldError('client_id', $this->modx->lexicon('oauth2server.err.clients.client_id_empty'));
     }
     $exists = $this->modx->getCount('OAuth2ServerClients', array('client_id' => $clientId));
     if ($exists > 0) {
         $this->addFieldError('client_id', $this->modx->lexicon('oauth2server.err.clients.client_id_exists'));
     }
     $clientSecret = $this->getProperty('client_secret');
     if (empty($clientSecret)) {
         $bytes = openssl_random_pseudo_bytes(20);
         $hex = bin2hex($bytes);
         $this->setProperty('client_secret', $hex);
     }
     $redirectUri = $this->getProperty('redirect_uri');
     if (empty($redirectUri)) {
         $this->addFieldError('redirect_uri', $this->modx->lexicon('oauth2server.err.clients.redirect_uri_empty'));
     }
     $grantTypes = $this->getProperty('grant_types');
     if (empty($grantTypes)) {
         $this->setProperty('grant_types', NULL);
     }
     $scope = $this->getProperty('scope');
     if (empty($scope)) {
         $this->setProperty('scope', NULL);
     }
     $userId = $this->getProperty('user_id');
     $modxUser = $this->modx->user->get('id');
     if (empty($userId)) {
         $this->setProperty('user_id', $modxUser);
     }
     return parent::beforeSet();
 }
 public function beforeSet()
 {
     // link
     $action = $this->getProperty('action_id');
     if (empty($action)) {
         $this->setProperty('action_id', null);
     } else {
         $this->setProperty('action', $action);
     }
     $handler = $this->getProperty('handler');
     if (empty($handler)) {
         $this->setProperty('handler', null);
     }
     $link = $this->getProperty('link');
     if (empty($link)) {
         $this->setProperty('link', null);
     }
     // icon
     $icon = $this->getProperty('icon');
     if (empty($icon)) {
         $this->setProperty('icon', null);
     }
     $iconms = $this->getProperty('icon_ms');
     if (empty($iconms)) {
         $this->setProperty('icon_ms', null);
     }
     $iconfile = $this->getProperty('icon_file');
     if (empty($iconfile)) {
         $this->setProperty('icon_file', null);
     }
     return parent::beforeSet();
 }
示例#10
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();
 }
示例#11
0
 public function beforeSet()
 {
     $name = $this->getProperty('name');
     if ($this->doesAlreadyExist(array('name' => $name))) {
         $this->addFieldError('name', $this->modx->lexicon('propertyset_err_ns_name'));
     }
     return parent::beforeSet();
 }
示例#12
0
 public function beforeSet()
 {
     $this->setDefaultProperties(array('target' => 0, 'principal_class' => 'modUserGroup', 'principal' => 0, 'authority' => 9999, 'policy' => 0));
     if (!$this->getProperty('target') || !$this->getProperty('principal_class')) {
         return $this->modx->lexicon($this->objectType . '_err_create_md');
     }
     return parent::beforeSet();
 }
示例#13
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();
 }
示例#14
0
 /** {@inheritDoc} */
 public function beforeSet()
 {
     foreach (array('domain', 'resource') as $key) {
         ${$key} = trim($this->getProperty($key));
         if (empty(${$key})) {
             $this->modx->error->addField($key, $this->modx->lexicon('subdomainsfolder_err_ae'));
         }
     }
     return parent::beforeSet();
 }
 public function beforeSet()
 {
     $headers = $this->modx->fromJSON($this->getProperty('headers', '[]'));
     $this->object->set('headers', $headers);
     $binary = $this->getProperty('binary', null);
     if ($binary !== null) {
         $this->object->set('binary', $binary == 'true');
     }
     return parent::beforeSet();
 }
示例#16
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();
 }
 public function beforeSet()
 {
     $items = $this->modx->getCollection($this->classKey, array('group' => $this->getProperty('group'), 'softDelete' => false));
     //Set a default alias
     if (!$this->getProperty('alias')) {
         $this->setProperty('alias', strtolower(str_replace(" ", "-", $this->getProperty('name'))));
     }
     $this->setProperty('position', count($items));
     return parent::beforeSet();
 }
示例#18
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();
 }
示例#19
0
 /**
  * @return bool
  */
 public function beforeSet()
 {
     $title = trim($this->getProperty('title'));
     if (empty($title)) {
         $this->modx->error->addField('title', $this->modx->lexicon('pisma_newsletters_err_title'));
     } elseif ($this->modx->getCount($this->classKey, array('title' => $title))) {
         $this->modx->error->addField('title', $this->modx->lexicon('pisma_newsletters_err_ae'));
     }
     return parent::beforeSet();
 }
示例#20
0
 public function beforeSet()
 {
     $context = $this->getProperty('context_key');
     if (empty($context)) {
         $this->setProperty('context_key', NULL);
     }
     $context = $this->getProperty('context_key');
     // check if pattern & context combi not already exists
     $exists = $this->modx->getObject('modRedirect', array('pattern' => $this->getProperty('pattern'), 'context_key' => $context));
     if (!empty($exists) && is_object($exists)) {
         $this->addFieldError('pattern', $this->modx->lexicon('redirector.' . (empty($context) ? 'redirect_err_ae_pattern' : 'redirect_err_ae_patctx'), array('context' => $context)));
     }
     // check if pattern is an existing resource
     $criteria = array('uri' => $this->getProperty('pattern'), 'published' => true, 'deleted' => false);
     if (!empty($context)) {
         $criteria['context_key'] = $context;
     }
     $resource = $this->modx->getObject('modResource', $criteria);
     if (!empty($resource) && is_object($resource)) {
         $this->addFieldError('pattern', $this->modx->lexicon('redirector.redirect_err_ae_uri', array('id' => $resource->get('id'), 'context' => $resource->get('context_key'))));
     }
     // check if target is a NON existing resource
     $target = $this->getProperty('target');
     if (strpos($target, '$') === false) {
         // parse link & MODX tags
         if (stripos($target, '[[') !== false) {
             $this->modx->parser->processElementTags('', $target, true, true);
         }
         if (!empty($target)) {
             // checking full links
             if (strpos($target, '://') !== false) {
                 $headers = @get_headers($target);
                 if (empty($headers)) {
                     $this->addFieldError('target', $this->modx->lexicon('redirector.redirect_err_ne_target'));
                 }
             } else {
                 $criteria = array('uri' => $target);
                 if (!empty($context)) {
                     $criteria['context_key'] = $context;
                 }
                 $resource = $this->modx->getObject('modResource', $criteria);
                 if (empty($resource) || !is_object($resource)) {
                     // check if could be a file?
                     $basePath = $this->modx->getOption('base_path');
                     if (!file_exists($basePath . $target)) {
                         $this->addFieldError('target', $this->modx->lexicon('redirector.redirect_err_ne_target'));
                     }
                 }
             }
         } else {
             $this->addFieldError('target', $this->modx->lexicon('redirector.redirect_err_ne_target'));
         }
     }
     return parent::beforeSet();
 }
示例#21
0
 public function beforeSet()
 {
     $name = $this->getProperty('name');
     if (empty($name)) {
         $this->addFieldError('name', $this->modx->lexicon('policy_template_err_name_ns'));
     }
     if ($this->doesAlreadyExist(array('name' => $name))) {
         $this->addFieldError('name', $this->modx->lexicon('policy_template_err_ae', array('name' => $name)));
     }
     return parent::beforeSet();
 }
示例#22
0
 /** {inheritDoc} */
 public function beforeSet()
 {
     $required = array('sale_id', 'group_id', 'type');
     foreach ($required as $v) {
         if ($this->getProperty($v) == '') {
             $this->modx->error->addField($v, $this->modx->lexicon('msd_err_ns'));
         }
     }
     $this->object->fromArray($this->getProperties(), '', true, true);
     return parent::beforeSet();
 }
示例#23
0
 public function beforeSet()
 {
     $key = $this->getProperty('key');
     if (empty($key)) {
         $this->addFieldError('key', $this->modx->lexicon($this->objectType . '_err_name_ns'));
     }
     if ($this->doesAlreadyExist(array('key' => $key))) {
         $this->addFieldError('key', $this->modx->lexicon($this->objectType . '_err_ae', array('key' => $key)));
     }
     return parent::beforeSet();
 }
示例#24
0
 /**
  * @return bool
  */
 public function beforeSet()
 {
     $data = $this->getProperties();
     $user_id = $data['user_id'];
     $fp = $data['fingerprint'];
     if (empty($fp)) {
         $this->modx->error->addField('fp_error', $this->modx->lexicon('identifyx_item_err_fingerprint'));
     } elseif ($this->modx->getCount($this->classKey, array('user_id' => $user_id, 'fingerprint' => $fp))) {
         $this->modx->runProcessor('userDataUpdateProcessor', $data);
     }
     return parent::beforeSet();
 }
示例#25
0
 /**
  * @return bool
  */
 public function beforeSet()
 {
     $username = trim($this->getProperty('username'));
     if (empty($username)) {
         $this->modx->error->addField('username', $this->modx->lexicon('fleetmanager_item_err_username'));
     }
     $userhandle = trim($this->getProperty('handle'));
     if (empty($userhandle)) {
         $this->modx->error->addField('handle', $this->modx->lexicon('fleetmanager_item_err_handle'));
     }
     return parent::beforeSet();
 }
示例#26
0
 public function beforeSet()
 {
     /**
      * @var integer Comment ID
      */
     $id = (int) $this->getProperty('id');
     /**
      * Check comment ID
      */
     if (!$id) {
         $this->failure($this->modx->lexicon('modxtalks.post_err_ns'));
         return false;
     }
     /**
      * Check for comment presents
      */
     if (!($comment = $this->modx->getObject('modxTalksPost', array('id' => $id)))) {
         $this->failure($this->modx->lexicon('modxtalks.post_err_nf'));
         return false;
     }
     $userInfo = $comment->getUserData();
     /**
      * Email Address
      */
     $email = $userInfo['email'];
     /**
      * @var string Context key
      */
     $this->context = trim($this->getProperty('ctx'));
     /**
      * Check context
      */
     if (empty($this->context)) {
         $this->failure($this->modx->lexicon('modxtalks.empty_context'));
         return false;
     } elseif (!$this->modx->getCount('modContext', $this->context)) {
         $this->failure($this->modx->lexicon('modxtalks.bad_context'));
         return false;
     }
     if (!$this->modx->modxtalks->isModerator()) {
         $this->failure($this->modx->lexicon('modxtalks.edit_permission'));
         return false;
     }
     /**
      * If Email Address already banned
      */
     if ($this->doesAlreadyExist(array('email' => $email))) {
         $this->failure($this->modx->lexicon('modxtalks.email_already_banned'));
         return false;
     }
     $this->properties = array('email' => $email, 'date' => time());
     return parent::beforeSet();
 }
示例#27
0
 public function beforeSet()
 {
     $url = $this->getProperty('url');
     if (empty($url)) {
         $this->addFieldError('url', $this->modx->lexicon('urlhistory.item_err_ns_url'));
     } else {
         if ($this->doesAlreadyExist(array('url' => $url))) {
             $this->addFieldError('url', $this->modx->lexicon('urlhistory.item_err_ae'));
         }
     }
     return parent::beforeSet();
 }
示例#28
0
 /**
  * @return bool
  */
 public function beforeSet()
 {
     $threadId = $this->getProperty('thread');
     if (!($this->thread = $this->modx->getObject('ecThread', $threadId))) {
         $this->modx->error->addField('thread', $this->modx->lexicon('ec_message_err_thread'));
     }
     $now = date('Y-m-d H:i:s');
     $this->setProperties(array('createdon' => $now, 'createdby' => $this->modx->user->isAuthenticated($this->modx->context->key) ? $this->modx->user->id : 0, 'editedon' => null, 'editedby' => 0));
     if ($this->getProperty('published')) {
         $this->setProperties(array('publishedon' => $now, 'publishedby' => $this->modx->user->isAuthenticated($this->modx->context->key) ? $this->modx->user->id : 0));
     }
     return parent::beforeSet();
 }
 public function beforeSet()
 {
     $data = array();
     $dataJson = $this->getProperty('data', '');
     if (!empty($dataJson)) {
         $dataArray = $this->modx->fromJSON($dataJson);
         foreach ($dataArray as $entry) {
             $data[$entry['key']] = $entry['value'];
         }
     }
     $this->setProperty('data', !empty($data) ? $data : null);
     return parent::beforeSet();
 }
示例#30
0
 /**
  * Before setting, we check if the name is filled and/or already exists. Also checkboxes.
  * @return bool
  */
 public function beforeSet()
 {
     $key = $this->getProperty('key');
     if (empty($key)) {
         $this->addFieldError('key', $this->modx->lexicon('clientconfig.cgsetting_err_ns_key'));
     } else {
         if ($this->doesAlreadyExist(array('key' => $key))) {
             $this->addFieldError('key', $this->modx->lexicon('clientconfig.cgsetting_err_ae_key'));
         }
     }
     /* Set is_required checkbox */
     $this->setCheckbox('is_required', true);
     return parent::beforeSet();
 }