本文整理汇总了PHP中modObjectUpdateProcessor类的典型用法代码示例。如果您正苦于以下问题:PHP modObjectUpdateProcessor类的具体用法?PHP modObjectUpdateProcessor怎么用?PHP modObjectUpdateProcessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了modObjectUpdateProcessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fireAfterSaveEvent
public function fireAfterSaveEvent()
{
// Clear the cache:
$cacheRefreshOptions = array('system_settings' => array());
$this->modx->cacheManager->refresh($cacheRefreshOptions);
return parent::fireAfterSaveEvent();
}
示例2: 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();
}
示例3: beforeSave
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();
}
示例4: 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();
}
示例5: 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();
}
示例6: initialize
public function initialize()
{
if (!$this->getProperty('username')) {
return 'Не указан пользователь';
}
return parent::initialize();
}
示例7: afterSave
public function afterSave()
{
$this->updateTranslations($this->getProperties());
$this->refreshURIs();
$this->clearCache();
return parent::afterSave();
}
示例8: beforeSave
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();
}
示例9: afterSave
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();
}
示例10: beforeSave
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();
}
示例11: 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();
}
示例12: initialize
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();
}
示例13: beforeSet
public function beforeSet()
{
$this->setCheckbox('uri', false);
$this->setCheckbox('override', false);
$this->setCheckbox('active', false);
return parent::beforeSet();
}
示例14: 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();
}
示例15: beforeSave
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();
}