Ejemplo n.º 1
0
 /**
  * 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();
 }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
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->object->group != $group) {
             $this->addFieldError('group', $this->modx->lexicon('tagger.err.tag_group_changed'));
         }
         if ($this->modx->getCount($this->classKey, array('tag' => $name, 'group' => $group, 'id:!=' => $this->object->id)) > 0) {
             $this->addFieldError('tag', $this->modx->lexicon('tagger.err.tag_name_ae'));
         }
     }
     if (!empty($alias)) {
         $alias = $this->object->cleanAlias($alias);
         if ($this->modx->getCount($this->classKey, array('alias' => $alias, 'group' => $group, 'id:!=' => $this->object->id)) > 0) {
             $this->addFieldError('alias', $this->modx->lexicon('tagger.err.tag_alias_ae'));
         } else {
             $this->object->set('alias', $alias);
         }
     }
     return parent::beforeSave();
 }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
 public function beforeSave()
 {
     $label = $this->getProperty('label');
     $type = $this->getProperty('type');
     $default = $this->getProperty('default');
     switch ($type) {
         case 'select':
         case 'checkbox':
         case 'radio':
             $values = $this->getProperty('values');
             break;
         default:
             // textbox
             $values = '';
             $this->validationType = true;
     }
     $settings = array('label' => $label);
     if (!empty($default)) {
         $settings['default'] = $default;
     }
     if (!empty($values)) {
         $settings['values'] = $values;
     }
     $this->object->set('settings', $this->modx->toJSON($settings));
     return parent::beforeSave();
 }
Ejemplo n.º 6
0
 public function beforeSave()
 {
     /*print_r($this->object->toArray());
       
       exit;*/
     return parent::beforeSave();
 }
Ejemplo n.º 7
0
 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();
 }
Ejemplo n.º 8
0
 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();
 }
Ejemplo n.º 9
0
 public function beforeSave()
 {
     $this->verifyNamespace();
     $this->checkForBooleanValue();
     $this->refreshURIs = $this->checkForRefreshURIs();
     return parent::beforeSave();
 }
Ejemplo n.º 10
0
 public function beforeSave()
 {
     $active = $this->getProperty('active', null);
     if ($active !== null) {
         $this->object->set('active', (bool) $active);
     }
     return parent::beforeSave();
 }
Ejemplo n.º 11
0
 public function beforeSave()
 {
     if ($this->object->get('recipient') != $this->modx->user->get('id')) {
         return $this->modx->lexicon($this->objectType . '_err_nfs');
     }
     $this->object->set('read', true);
     return parent::beforeSave();
 }
Ejemplo n.º 12
0
 public function beforeSave()
 {
     $name = $this->getProperty('name');
     if (empty($name)) {
         $this->addFieldError('name', $this->modx->lexicon('role_err_ns_name'));
     }
     return parent::beforeSave();
 }
Ejemplo n.º 13
0
 public function beforeSave()
 {
     $this->setProfile();
     $this->setRemoteData();
     $this->validator = new modUserValidation($this, $this->object, $this->profile);
     $this->validator->validate();
     return parent::beforeSave();
 }
Ejemplo n.º 14
0
 /**
  * @return bool
  */
 public function beforeSave()
 {
     $text = $this->getProperty('text');
     /** @var Tickets $Tickets */
     if ($Tickets = $this->modx->getService('Tickets')) {
         $this->object->fromArray(array('editedon' => time(), 'editedby' => $this->modx->user->id, 'text' => $Tickets->Jevix($text, 'Comment'), 'raw' => $text));
     }
     return parent::beforeSave();
 }
Ejemplo n.º 15
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();
 }
Ejemplo n.º 16
0
 /** {inheritDoc} */
 public function beforeSave()
 {
     /** @var modProcessorResponse $response */
     $response = $this->modx->runProcessor('security/group/update', $this->getProperties());
     if ($response->isError()) {
         return $response->response;
     }
     return parent::beforeSave();
 }
Ejemplo n.º 17
0
 public function beforeSave()
 {
     if (!$this->verifyIdentity()) {
         return "Неверный ключ или пароль был изменен ранее";
     }
     // else
     $this->eraseCache();
     $this->object->Profile->set('password', $this->getProperty('password'));
     return parent::beforeSave();
 }
Ejemplo n.º 18
0
 public function beforeSave()
 {
     /* проверка на кружева */
     if ($this->parent != $this->getProperty('parent', $this->object->get('parent'))) {
         if (!$this->MlmSystem->Tools->checkClientParent($this->object, $this->getProperty('parent'))) {
             $this->addFieldError('parent', $this->MlmSystem->lexicon('err_parent'));
         }
     }
     return parent::beforeSave();
 }
Ejemplo n.º 19
0
 public function beforeSave()
 {
     $name = $this->getProperty('name');
     if (empty($name)) {
         $this->addFieldError('name', $this->modx->lexicon('namespace_err_ns_name'));
     }
     $this->object->set('name', $name);
     $this->object->set('path', trim($this->object->get('path')));
     return parent::beforeSave();
 }
Ejemplo n.º 20
0
 public function beforeSave()
 {
     // pass timing
     $timing = $this->getProperty('timing', 0);
     if (empty($timing)) {
         $this->addFieldError('timing', $this->modx->lexicon('scheduler.error.no-timing'));
     }
     $this->object->setTiming($timing, false);
     return parent::beforeSave();
 }
Ejemplo n.º 21
0
 public function beforeSave()
 {
     $uloginid = $this->getProperty('uloginid');
     $id = $this->getProperty('id');
     if ($exist = $this->doesAlreadyExist(array('uloginid' => $uloginid, 'id:!=' => $id))) {
         $this->addFieldError('uloginid', $this->modx->lexicon('ulogin.widget_err_ae'));
         //        } elseif (empty($uloginid)) {
         //            $this->addFieldError('uloginid',$this->modx->lexicon('ulogin.widget_err_ns_uloginid'));
     }
     return parent::beforeSave();
 }
Ejemplo n.º 22
0
 public function beforeSave()
 {
     /** @var modResource $parent */
     $parent = $this->modx->getObject('modResource', $this->object->parent);
     if ($parent && $parent->class_key == 'CollectionContainer') {
         $this->object->set('show_in_tree', 0);
     } else {
         $this->object->set('show_in_tree', 1);
     }
     return parent::beforeSave();
 }
Ejemplo n.º 23
0
 /** {@inheritDoc} */
 public function beforeSave()
 {
     if ($this->object->get('status') != $this->status) {
         $change_status = $this->modx->miniShop2->changeOrderStatus($this->object->get('id'), $this->object->get('status'));
         if ($change_status !== true) {
             return $change_status;
         }
     }
     $this->object->set('updatedon', time());
     return parent::beforeSave();
 }
Ejemplo n.º 24
0
 /**
  * @return bool
  */
 public function beforeSave()
 {
     $this->object->set('published', 1);
     $properties = $this->object->get('properties');
     if (array_key_exists('was_published', $properties)) {
         unset($properties['was_published']);
         $this->object->set('properties', $properties);
         $this->_sendEmails = true;
     }
     return parent::beforeSave();
 }
Ejemplo n.º 25
0
 public function beforeSave()
 {
     /* sanity checks - strip out iframe/javascript */
     $body = $this->getProperty('body');
     $body = preg_replace("/<script(.*)<\\/script>/i", '', $body);
     $body = preg_replace("/<iframe(.*)<\\/iframe>/i", '', $body);
     $body = preg_replace("/<iframe(.*)\\/>/i", '', $body);
     $body = nl2br($body);
     $this->object->set('editedon', strftime('%Y-%m-%d %H:%M:%S'));
     $this->object->set('body', $body);
     return parent::beforeSave();
 }
Ejemplo n.º 26
0
 /** {@inheritDoc} */
 public function beforeSave()
 {
     $fieldName = $this->getProperty('field_name', null);
     $fieldValue = $this->getProperty('field_value', null);
     if (!is_null($fieldName) && !is_null($fieldValue)) {
         $array = $this->object->toArray();
         if (isset($array[$fieldName])) {
             $this->object->fromArray(array($fieldName => $fieldValue));
         }
     }
     return parent::beforeSave();
 }
Ejemplo n.º 27
0
 public function beforeSave()
 {
     $binary = $this->getProperty('binary', null);
     if ($binary !== null) {
         $this->object->set('binary', (bool) $binary);
     }
     $name = $this->getProperty('name');
     if (empty($name)) {
         $this->addFieldError('name', $this->modx->lexicon('content_type_err_ns_name'));
     }
     $this->refreshURIs = $this->object->isDirty('file_extensions') && $this->modx->getCount('modResource', array('content_type' => $this->object->get('id')));
     return parent::beforeSave();
 }
Ejemplo n.º 28
0
 public function beforeSave()
 {
     $name = $this->getProperty('name');
     $alias = $this->getProperty('alias');
     $resourceid = $this->getProperty('resourceid');
     if (empty($name)) {
         $this->addFieldError('name', $this->modx->lexicon('field_required'));
     }
     if (empty($alias) && empty($resourceid)) {
         $this->addFieldError('alias', $this->modx->lexicon('customrequest.configs_err_ns_alias_resourceid'));
         $this->addFieldError('resourceid', $this->modx->lexicon('customrequest.configs_err_ns_alias_resourceid'));
     }
     return parent::beforeSave();
 }
Ejemplo n.º 29
0
 public function beforeSave()
 {
     /* now store the permissions into the modAccessPermission table */
     /* and cache the data into the policy table */
     $permissions = $this->getProperty('permissions', null);
     if ($permissions !== null) {
         $permData = array();
         $permissions = is_array($permissions) ? $permissions : $this->modx->fromJSON($permissions);
         foreach ($permissions as $permissionArray) {
             $permData[$permissionArray['name']] = $permissionArray['enabled'] ? true : false;
         }
         $this->object->set('data', $permData);
     }
     return parent::beforeSave();
 }
Ejemplo n.º 30
0
 public function beforeSave()
 {
     $resourceGroup = $this->modx->getObject('modResourceGroup', $this->getProperty('target'));
     if (!$resourceGroup) {
         $this->addFieldError('target', $this->modx->lexicon('resource_group_err_nf'));
     }
     $policy = $this->modx->getObject('modAccessPolicy', $this->getProperty('policy'));
     if (!$policy) {
         $this->addFieldError('policy', $this->modx->lexicon('access_policy_err_nf'));
     }
     if ($this->doesAlreadyExist(array('principal' => $this->object->get('principal'), 'principal_class' => 'modUserGroup', 'target' => $this->object->get('target'), 'policy' => $this->object->get('policy'), 'context_key' => $this->object->get('context_key'), 'id:!=' => $this->object->get($this->primaryKeyField)))) {
         $this->addFieldError('target', $this->modx->lexicon($this->objectType . '_err_ae'));
     }
     return parent::beforeSave();
 }