示例#1
0
 /** {@inheritDoc} */
 public function beforeSave()
 {
     $q = $this->modx->newQuery($this->classKey);
     $q->where(array('tab:=' => $this->getProperty('tab')));
     $this->object->fromArray(array('rank' => $this->modx->getCount('up2Fields', $q)));
     return parent::beforeSave();
 }
示例#2
0
 public function beforeSave()
 {
     $formId = $this->getProperty('form_id');
     $label = $this->getProperty('label');
     $type = $this->getProperty('type');
     $default = $this->getProperty('default');
     if (empty($label)) {
         $this->addFieldError('label', $this->modx->lexicon('formz.field_err_ns'));
     } else {
         if ($this->doesAlreadyExist(array('label' => $label, 'form_id' => $formId))) {
             $this->addFieldError('label', $this->modx->lexicon('formz.field_err_ae'));
         }
     }
     switch ($type) {
         case 'select':
         case 'checkbox':
         case 'radio':
             $values = $this->getProperty('values');
             $this->validationType = false;
             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();
 }
示例#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->doesAlreadyExist(array('tag' => $name, 'group' => $group))) {
             $this->addFieldError('tag', $this->modx->lexicon('tagger.err.tag_name_ae'));
         }
     }
     if (!empty($alias)) {
         $alias = $this->object->cleanAlias($alias);
         if ($this->doesAlreadyExist(array('alias' => $alias, 'group' => $group))) {
             $this->addFieldError('alias', $this->modx->lexicon('tagger.err.tag_alias_ae'));
         }
     }
     return parent::beforeSave();
 }
示例#4
0
 /** {@inheritDoc} */
 public function beforeSave()
 {
     $data = $this->modx->currencyrate->calcData($this->object->toArray());
     $data['rank'] = $this->modx->getCount($this->classKey);
     $this->object->fromArray($data);
     return parent::beforeSave();
 }
示例#5
0
 public function beforeSave()
 {
     // Setting creator and time created
     $this->object->set('createdby', $this->modx->user->get('id'));
     $this->object->set('createdon', date('Y-m-d H:i:s', time()));
     return parent::beforeSave();
 }
示例#6
0
 public function beforeSave()
 {
     if (!$this->object->get('name')) {
         return 'Please, type project name';
     }
     return parent::beforeSave();
 }
示例#7
0
 /**
  * {@inheritDoc}
  * @return boolean
  */
 public function beforeSave()
 {
     $this->addProfile();
     $this->addUserGroups();
     $this->validator = new modUserValidation($this, $this->object, $this->profile);
     $this->validator->validate();
     return parent::beforeSave();
 }
示例#8
0
 public function beforeSave()
 {
     if ($this->doesAlreadyExist(array('principal' => $this->getProperty('principal'), 'principal_class' => 'modUserGroup', 'target' => $this->getProperty('target'), 'policy' => $this->getProperty('policy'), 'context_key' => $this->getProperty('context_key')))) {
         $this->addFieldError('target', $this->modx->lexicon('access_source_err_ae'));
     }
     $this->object->set('principal_class', 'modUserGroup');
     return parent::beforeSave();
 }
示例#9
0
 public function beforeSave()
 {
     $menuIndex = $this->modx->getCount($this->classKey, array('parent' => $this->getProperty('parent')));
     $this->object->set('menuindex', $menuIndex);
     $this->object->set('action', $this->getProperty('action_id'));
     $this->object->set('text', $this->getProperty('text'));
     return parent::beforeSave();
 }
示例#10
0
 public function beforeSave()
 {
     $name = $this->getProperty('persons_name');
     if (empty($name)) {
         $this->addFieldError('persons_name', $this->modx->lexicon('Specify'));
     }
     return parent::beforeSave();
 }
示例#11
0
 public function beforeSave()
 {
     /* User and Server info */
     $data = array('ip_address' => $_SERVER['REMOTE_ADDR'], 'server_name' => $_SERVER['SERVER_NAME'], 'server_address' => $_SERVER['SERVER_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'request_time' => $_SERVER['REQUEST_TIME']);
     // set data and time created
     $this->object->set('senton', date('Y-m-d H:i:s', time()));
     $this->object->set('data', serialize($data));
     return parent::beforeSave();
 }
示例#12
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();
 }
示例#13
0
 /** {@inheritDoc} */
 public function beforeSave()
 {
     $this->object->fromArray(array('rank' => $this->modx->getCount('up2TypeProfile')));
     // default
     if ($this->modx->userprofile2->getProfileTypeDefault() > 0) {
         $this->object->fromArray(array('default' => 0));
     }
     return parent::beforeSave();
 }
示例#14
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();
 }
示例#15
0
 public function beforeSave()
 {
     $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::beforeSave();
 }
示例#16
0
 public function beforeSave()
 {
     $uloginid = $this->getProperty('uloginid');
     if ($this->doesAlreadyExist(array('uloginid' => $uloginid))) {
         $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();
 }
示例#17
0
 /**
  * {@inheritDoc}
  * @return boolean
  */
 public function beforeSave()
 {
     $this->addProfile();
     $sudo = $this->getProperty('sudo', null);
     if ($sudo !== null) {
         $this->object->setSudo(!empty($sudo));
     }
     $this->validator = new modUserValidation($this, $this->object, $this->profile);
     $this->validator->validate();
     return parent::beforeSave();
 }
示例#18
0
 public function beforeSave()
 {
     $c = array('target' => $this->object->get('target'), 'principal_class' => $this->object->get('principal_class'), 'principal' => $this->object->get('principal'), 'authority' => $this->object->get('authority'), 'policy' => $this->object->get('policy'));
     if ($this->getProperty('context_key')) {
         $c['context_key'] = $this->getProperty('context_key');
     }
     if ($this->doesAlreadyExist($c)) {
         return $this->modx->lexicon($this->objectType . '_err_ae');
     }
     return parent::beforeSave();
 }
示例#19
0
 public function beforeSave()
 {
     /*
         Если указан ID диалоговой ветки, то пытаемся ее получить
     */
     if ($thread_id = (int) $this->getProperty('thread_id')) {
         // Если ветка не была получена, то ошибка
         if (!($thread = $this->object->getOne('Thread'))) {
             return 'Не была получена диалоговая ветка';
         }
         // else
         // Иначе устанавливаем голосу id и класс целевого объекта
         $this->object->fromArray(array("target_id" => $thread->get('target_id'), "target_class" => $thread->get('target_class')));
         /*
             Пометка. На этом этапе хорошо бы проверять права на голосование за этот объект
         */
     } else {
         if (!($target_id = (int) $this->getProperty('target_id'))) {
             return 'Не был получен ID целевого  объекта';
         } else {
             if (!($target_class = $this->getProperty('target_class'))) {
                 return 'Не был получен класс целевого объекта';
             } else {
                 if (!($thread = $this->object->getOne('Thread', array("target_id" => $target_id, "target_class" => $target_class))) and !$this->modx->getCount($target_class, $target_id)) {
                     return "Не был получен целевой объект";
                 }
             }
         }
     }
     /*
         Если есть объект диалоговой ветки,
         обновляем рейтинг, а так же счетчики общего числа голосов
     */
     if ($thread) {
         $thread->set('rating', $thread->get('rating') + $this->getProperty('vote_value'));
         if ($this->getProperty('vote_direction') == '1') {
             $thread->set('positive_votes', $thread->get('positive_votes') + 1);
         } else {
             if ($this->getProperty('vote_direction') == '-1') {
                 $thread->set('negative_votes', $thread->get('negative_votes') + 1);
             } else {
                 $thread->set('neutral_votes', $thread->get('neutral_votes') + 1);
             }
         }
     }
     // Проверяем, чтобы этот пользователь еще не голосовал
     $q = $this->modx->newQuery($this->classKey, array("user_id" => $this->getProperty('user_id'), "target_id" => $this->object->get('target_id'), "target_class" => $this->object->get('target_class')));
     $q->select(array("id"));
     $q->limit(1);
     if ($s = $q->prepare() and $this->modx->getValue($s)) {
         return "Вы не можете голосовать дважды за один и тот же объект";
     }
     return parent::beforeSave();
 }
示例#20
0
 public function beforeSave()
 {
     $name = $this->getProperty('name');
     if (empty($name)) {
         $this->addFieldError('name', $this->modx->lexicon('role_err_ns_name'));
     }
     if ($this->alreadyExists($name)) {
         $this->addFieldError('name', $this->modx->lexicon('role_err_ae'));
     }
     return parent::beforeSave();
 }
示例#21
0
 public function beforeSave()
 {
     $name = $this->getProperty('name');
     if (empty($name)) {
         $this->addFieldError('name', $this->modx->lexicon('gallery.album_err_ns_name'));
     }
     $this->object->set('createdby', $this->modx->user->get('id'));
     $total = $this->modx->getCount('galAlbum');
     $this->object->set('rank', (int) $total);
     return parent::beforeSave();
 }
示例#22
0
 public function beforeSave()
 {
     $name = $this->getProperty('name');
     if (empty($name)) {
         $this->addFieldError('name', $this->modx->lexicon('widget_err_ns_name'));
     } else {
         if ($this->doesAlreadyExist(array('name' => $name))) {
             $this->addFieldError('name', $this->modx->lexicon('widget_err_ae_name', array('name' => $name)));
         }
     }
     return parent::beforeSave();
 }
示例#23
0
 /**
  * Before saving, we check if the name is filled and/or already exists.
  * @return bool
  */
 public function beforeSave()
 {
     $name = $this->getProperty('label');
     if (empty($name)) {
         $this->addFieldError('label', $this->modx->lexicon('clientconfig.clientconfigmenu_err_ns_label'));
     } else {
         if ($this->doesAlreadyExist(array('label' => $name))) {
             $this->addFieldError('label', $this->modx->lexicon('clientconfig.clientconfigmenu_err_ae'));
         }
     }
     return parent::beforeSave();
 }
示例#24
0
 public function beforeSave()
 {
     $filename = $this->getProperty('filename');
     $group = $this->getProperty('group');
     if (empty($filename)) {
         $this->addFieldError('filename', $this->modx->lexicon('modxminify.err.item_name_ns'));
     }
     if ($this->doesAlreadyExist(array('filename' => $filename, 'group' => $group))) {
         $this->addFieldError('filename', $this->modx->lexicon('modxminify.err.item_name_ae'));
     }
     return parent::beforeSave();
 }
 public function beforeSave()
 {
     $name = $this->getProperty('name');
     if (empty($name)) {
         $this->addFieldError('name', $this->modx->lexicon('setinputoptions.err.group_name_ns'));
     } else {
         if ($this->doesAlreadyExist(array('name' => $name))) {
             $this->addFieldError('name', $this->modx->lexicon('setinputoptions.err.group_name_ae'));
         }
     }
     return parent::beforeSave();
 }
示例#26
0
 public function beforeSave()
 {
     $name = $this->getProperty('name');
     if (empty($name)) {
         $this->addFieldError('name', $this->modx->lexicon('Specify'));
     } else {
         if ($this->doesAlreadyExist(array('name' => $name))) {
             $this->addFieldError('name', $this->modx->lexicon('simplecrm.contact_err_ae'));
         }
     }
     return parent::beforeSave();
 }
示例#27
0
 public function beforeSave()
 {
     if (!($packageid = intval($this->getProperty('packageid'))) or !($sourceid = intval($this->getProperty('sourceid')))) {
         return false;
     }
     if ($this->modx->getObject($this->classKey, array('packageid' => $packageid, 'sourceid' => $sourceid))) {
         return "Media source for this package already exists";
     }
     $this->object->set('packageid', $packageid);
     $this->object->set('sourceid', $sourceid);
     return parent::beforeSave();
 }
示例#28
0
 public function beforeSave()
 {
     if (empty($this->modx->request)) {
         $this->modx->getRequest();
     }
     $raw = $this->object->get('raw');
     if (!($url = $this->object->createFile($raw))) {
         return $this->failure($this->modx->lexicon('uf_err_save'));
     }
     $this->object->set('raw', '');
     $this->object->fromArray(array('createdon' => date('Y-m-d H:i:s'), 'createdby' => empty($this->modx->user->id) && !empty($_SESSION['uid']) ? $_SESSION['uid'] : $this->modx->user->id, 'ip' => $this->modx->request->getClientIp(), 'url' => $url, 'parent' => 0, 'size' => strlen($raw)));
     return parent::beforeSave();
 }
示例#29
0
 public function beforeSave()
 {
     $name = $this->getProperty('name');
     if (empty($name)) {
         $this->addFieldError('name', $this->modx->lexicon('resource_group_ns_name'));
     }
     if ($this->doesAlreadyExist(array('name' => $name))) {
         $this->addFieldError('name', $this->modx->lexicon('resource_group_err_ae'));
     }
     $this->setCheckbox('access_admin');
     $this->setCheckbox('access_anon');
     $this->setCheckbox('access_parallel');
     return parent::beforeSave();
 }
示例#30
0
 public function beforeSave()
 {
     $context = $this->modx->getObject('modContext', $this->getProperty('target'));
     if (!$context) {
         $this->addFieldError('target', $this->modx->lexicon('context_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')))) {
         $this->addFieldError('target', $this->modx->lexicon($this->objectType . '_err_ae'));
     }
     $this->object->set('principal_class', 'modUserGroup');
     return parent::beforeSave();
 }