本文整理汇总了PHP中modObjectUpdateProcessor::beforeSet方法的典型用法代码示例。如果您正苦于以下问题:PHP modObjectUpdateProcessor::beforeSet方法的具体用法?PHP modObjectUpdateProcessor::beforeSet怎么用?PHP modObjectUpdateProcessor::beforeSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modObjectUpdateProcessor
的用法示例。
在下文中一共展示了modObjectUpdateProcessor::beforeSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSet
/** {@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();
}
示例2: 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();
}
示例3: 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();
}
示例4: 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();
}
示例5: 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();
}
示例6: 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();
}
示例7: beforeSet
public function beforeSet()
{
$this->setCheckbox('uri', false);
$this->setCheckbox('override', false);
$this->setCheckbox('active', false);
return parent::beforeSet();
}
示例8: beforeSet
/**
* {@inheritDoc}
* @return boolean
*/
public function beforeSet()
{
$this->setCheckbox('blocked');
$this->setCheckbox('active');
$this->setCheckbox('sudo');
return parent::beforeSet();
}
示例9: 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();
}
示例10: 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();
}
示例11: 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();
}
示例12: 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();
}
示例13: beforeSet
/** {@inheritDoc} */
public function beforeSet()
{
foreach (array('status', 'parent') as $v) {
$this->{$v} = $this->object->get($v);
}
//$valid = $this->object->validate();
return parent::beforeSet();
}
示例14: 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();
}
示例15: 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();
}