/** {@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(); }
/** * @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 beforeSet() { $clientId = $this->getProperty('client_id'); if (empty($clientId)) { $this->addFieldError('client_id', $this->modx->lexicon('oauth2server.err.clients.client_id_empty')); } $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); } return parent::beforeSet(); }
/** {@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 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(); }
/** {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 beforeSet() { $this->setCheckbox('uri', false); $this->setCheckbox('override', false); $this->setCheckbox('active', false); return parent::beforeSet(); }
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} * @return boolean */ public function beforeSet() { $this->setCheckbox('blocked'); $this->setCheckbox('active'); $this->setCheckbox('sudo'); 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(); }
public function beforeSet() { // Setup to allow PK change $oldName = $this->getProperty('previous_text'); $newName = $this->getProperty('text'); if (empty($newName)) { return $this->modx->lexicon($this->objectType . '_err_ns'); } $this->setProperty('newName', $newName); if ($oldName && $oldName != $newName) { $this->isRename = true; $this->setProperty('text', $oldName); } /* verify action */ $action_id = $this->getProperty('action_id'); if (!isset($action_id)) { return $this->modx->lexicon('action_err_ns'); } /* verify parent */ $parent = $this->getProperty('parent', null); if (!empty($parent)) { $parent = $this->modx->getObject($this->classKey, $parent); if (empty($parent)) { return $this->modx->lexicon($this->objectType . '_parent_err_nf'); } } 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(); }
public function beforeSet() { $history = $this->modx->newObject('ShopOrderHistory', $this->object->toArray()); $history->set('order_id', $this->object->get('id')); // print_r($history->toArray()); $this->object->addMany($history); return parent::beforeSet(); }
/** {@inheritDoc} */ public function beforeSet() { foreach (array('status', 'parent') as $v) { $this->{$v} = $this->object->get($v); } //$valid = $this->object->validate(); return parent::beforeSet(); }
/** * @return bool|null|string */ public function beforeSet() { $time = time() - strtotime($this->object->get('createdon')); $ip = $this->modx->request->getClientIp(); if (!$this->modx->getCount('TicketThread', array('name' => $this->getProperty('thread'), 'deleted' => 0, 'closed' => 0))) { return $this->modx->lexicon('ticket_err_wrong_thread'); } elseif ($this->modx->user->isAuthenticated($this->modx->context->key) && $this->object->get('createdby') != $this->modx->user->id) { return $this->modx->lexicon('ticket_comment_err_wrong_user'); } elseif (!$this->modx->user->isAuthenticated($this->modx->context->key)) { if (!$this->getProperty('allowGuest') || !$this->getProperty('allowGuestEdit')) { return $this->modx->lexicon('ticket_comment_err_guest_edit'); } elseif ($this->object->get('ip') != $ip['ip']) { return $this->modx->lexicon('ticket_comment_err_wrong_guest_ip'); } } elseif ($this->modx->getCount('TicketComment', array('parent' => $this->object->get('id')))) { return $this->modx->lexicon('ticket_comment_err_has_replies'); } elseif ($time >= $this->modx->getOption('tickets.comment_edit_time', null, 600)) { return $this->modx->lexicon('ticket_comment_err_no_time'); } elseif ($this->object->get('deleted')) { return $this->modx->lexicon('ticket_err_deleted_comment'); } elseif (!$this->object->get('published')) { return $this->modx->lexicon('ticket_err_unpublished_comment'); } // Required fields $requiredFields = array_map('trim', explode(',', $this->getProperty('requiredFields', 'name,email'))); foreach ($requiredFields as $field) { $value = $this->modx->stripTags(trim($this->getProperty($field))); if (empty($value)) { $value = $this->object->get($field); } if ($field == 'email' && !preg_match('/.+@.+\\..+/i', $value)) { $this->setProperty('email', ''); $this->addFieldError($field, $this->modx->lexicon('ticket_comment_err_email')); } else { if ($field == 'email') { $value = strtolower($value); } $this->setProperty($field, $value); } } if (!($text = trim($this->getProperty('text')))) { return $this->modx->lexicon('ticket_comment_err_empty'); } if (!$this->getProperty('email') && $this->modx->user->isAuthenticated($this->modx->context->key)) { return $this->modx->lexicon('ticket_comment_err_no_email'); } // Additional properties $properties = $this->getProperties(); $add = array(); $meta = $this->modx->getFieldMeta('TicketComment'); foreach ($properties as $k => $v) { if (!isset($meta[$k])) { $add[$k] = $this->modx->stripTags($v); } } $this->properties = array('text' => $text, 'raw' => $this->getProperty('raw'), 'name' => $this->getProperty('name'), 'email' => $this->getProperty('email'), 'properties' => !empty($add) ? $add : $this->object->get('properties')); return parent::beforeSet(); }
public function beforeSet() { if ($slug = $this->getProperty('slug')) { $this->modx->modxtalks->config['slug'] = $slug; } /** * Check context */ $this->context = trim($this->getProperty('ctx')); 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; } // Check Comment Content $content = trim($this->getProperty('content')); if (empty($content)) { $this->failure($this->modx->lexicon('modxtalks.empty_content')); return false; } elseif (!is_string($content)) { $this->failure($this->modx->lexicon('modxtalks.bad_content')); return false; } elseif (mb_strlen($content, 'UTF-8') < 2) { $this->failure($this->modx->lexicon('modxtalks.bad_content_length', array('length' => 2))); return false; } /** * Set comments data */ $this->properties = array('editTime' => time(), 'editUserId' => $this->modx->user->id, 'content' => $content); /** * If users is moderator */ if ($this->modx->modxtalks->isModerator()) { return parent::beforeSet(); } /** * Check user permission to edit comment */ $userId = $this->object->userId; if (!$this->modx->user->isAuthenticated($this->context)) { $this->failure($this->modx->lexicon('modxtalks.edit_permission')); return false; } // Check comment owner if ($this->modx->user->id != $userId) { $this->failure($this->modx->lexicon('modxtalks.edit_permission')); return false; } // Check time for edit comment if (time() - $this->object->time > $this->modx->modxtalks->config['edit_time']) { $this->failure($this->modx->lexicon('modxtalks.edit_timeout', array('seconds' => $this->modx->getOption('modxtalks.edit_time')))); return false; } return parent::beforeSet(); }
/** * @return bool */ public function beforeSet() { $id = (int) $this->getProperty('id_client'); $name = trim($this->getProperty('firstname')); if (empty($id)) { return $this->modx->lexicon('bbb_client_err_ns'); } return parent::beforeSet(); }
/** {inheritDoc} */ public function beforeSet() { $properties = $this->getProperties(); foreach ($properties as $k => $v) { $properties[$k] = $this->modx->msDiscount->sanitize($k, $v); } $this->setProperties($properties); return parent::beforeSet(); }
public function beforeSet() { $id = (int) $this->getProperty('id'); if ($id != $this->object->id) { return "ID документа не совпадает"; } // else $this->setProperties($this->object->toArray()); return parent::beforeSet(); }
/** {@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(); }
/** {inheritDoc} */ public function beforeSet() { $required = array('relation'); foreach ($required as $v) { if ($this->getProperty($v) == '') { $this->modx->error->addField($v, $this->modx->lexicon('msd_err_ns')); } } return parent::beforeSet(); }
function beforeSet() { if (!$this->getProperty('start')) { $this->setProperty('start', null); } if (!$this->getProperty('end')) { $this->setProperty('end', null); } return parent::beforeSet(); }
/** {@inheritDoc} */ public function beforeSet() { $name_ru = trim($this->getProperty('name_ru')); if (empty($name_ru)) { $this->modx->error->addField('name_ru', $this->modx->lexicon('gl_err_ae')); } if ($this->getProperty('default')) { $this->setProperty('active', 1); } return parent::beforeSet(); }
/** {@inheritDoc} */ public function beforeSet() { $id = (int) $this->getProperty('id'); if (empty($id)) { return $this->modx->lexicon('gl_err_ns'); } $name_ru = trim($this->getProperty('name_ru')); if (empty($name_ru)) { $this->modx->error->addField('name_ru', $this->modx->lexicon('gl_err_ae')); } return parent::beforeSet(); }
public function beforeSet() { $name = $this->getProperty('name'); if (empty($name)) { $this->addFieldError('name', $this->modx->lexicon('setinputoptions.err.item_name_ns')); } else { if ($this->modx->getCount($this->classKey, array('name' => $name)) && $this->object->name != $name) { $this->addFieldError('name', $this->modx->lexicon('setinputoptions.err.item_name_ae')); } } return parent::beforeSet(); }
/** {@inheritDoc} */ public function beforeSet() { if ($this->modx->getObject('up2TypeProfile', array('name' => $this->getProperty('name'), 'id:!=' => $this->getProperty('id')))) { $this->modx->error->addField('name', $this->modx->lexicon('vp_err_ae')); } // default if ($this->getProperty('default')) { if ($this->modx->userprofile2->getProfileTypeDefault() > 0) { $this->unsetProperty('default'); } } 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(); }
/** * 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->modx->getCount($this->classKey, array('key' => $key, 'AND:id:!=' => $this->object->get('id'))) > 0) { $this->addFieldError('key', $this->modx->lexicon('clientconfig.cgsetting_err_ae_key')); } } $this->setCheckbox('is_required', true); return parent::beforeSet(); }
public function beforeSet() { $context = $this->getProperty('context_key'); if (empty($context)) { $this->setProperty('context_key', NULL); } $context = $this->getProperty('context_key'); // 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 $this->modx->parser->processElementTags('', $target, true, true); if (!empty($target)) { if (!strpos($target, '://')) { $target = $this->modx->getOption('site_url') . ($target == '/' ? '' : $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(); }
/** * @return bool */ public function beforeSet() { $id = (int) $this->getProperty('id'); $name = trim($this->getProperty('name')); if (empty($id)) { return $this->modx->lexicon('messenger_item_err_ns'); } if (empty($name)) { $this->modx->error->addField('name', $this->modx->lexicon('messenger_item_err_name')); } elseif ($this->modx->getCount($this->classKey, array('name' => $name, 'id:!=' => $id))) { $this->modx->error->addField('name', $this->modx->lexicon('messenger_item_err_ae')); } return parent::beforeSet(); }