Пример #1
0
 /**
  * Create the modResource object for manipulation
  * @return string|modResource
  */
 public function initialize()
 {
     /* get the class_key to determine classKey and resourceDir */
     $classKey = $this->getProperty('class_key', 'modDocument');
     $this->classKey = !empty($classKey) ? $classKey : 'modDocument';
     $initialized = parent::initialize();
     if (!$initialized) {
         return $this->modx->lexicon('resource_err_create');
     }
     if (!$this->object instanceof $this->classKey) {
         return $this->modx->lexicon('resource_err_class', array('class' => $this->classKey));
     }
     return $initialized;
 }
Пример #2
0
 public function initialize()
 {
     // Проверяем наличие публикаций за сегодняшний день.
     # if(!$this->modx->hasPermission('modxclub.create_unlimited_topics')){
     #     $time = strtotime(date('Y-m-d'));
     #     $q = $this->modx->newQuery($this->classKey);
     #     $q->where(array(
     #         "createdby"     => $this->modx->user->id,
     #         "createdon:>"   => $time,
     #     ));
     #     if($this->modx->getCount($this->classKey, $q)){
     #         return "Вам нельзя публиковать более одной публикации в день";
     #     }
     # }
     if (!($fullname = $this->modx->user->Profile->fullname)) {
         return "У вас не заполнено ФИО. Пожалуйста, обновите профиль.";
     }
     $this->setDefaultProperties(array("tv14" => $fullname, "published" => 0, "clearCache" => 1));
     $this->setProperties(array("parent" => 86844, "template" => 2, "links_follow" => 0));
     if ($notices = $this->getProperty('notices') and !is_array($notices)) {
         $notices = array_map('trim', explode(",", $notices));
         $this->setProperty('notices', $notices);
     }
     if (!$this->getProperty('pagetitle')) {
         $this->addFielderror('pagetitle', "Не заполнен заголовок публикации");
     }
     $ok = parent::initialize();
     if ($ok !== true) {
         return $ok;
     }
     /*
         Устанавливаем автоподстановку Тегов <br /> для Джевикса
     */
     $this->modx->setOption('modjevix.AutoBrMode', true);
     return !$this->hasErrors();
 }
Пример #3
0
 public function initialize()
 {
     $this->setProperties(array('class_key' => 'SocietyTopic'));
     if (!$this->getProperty('pagetitle')) {
         $this->addFieldError('pagetitle', "Не указано название топика");
     }
     if (!$this->getProperty('content')) {
         $this->addFieldError('content', "Не заполнен текст топика");
     }
     /*if(!$blogs = $this->getProperty('blogs')){
           $this->addFieldError('blogs', "В какой блог публикуем топик?");
       }
       else */
     $blogs = $this->getProperty('blogs');
     if ($blogs && !is_array($blogs)) {
         $blogs = explode(',', $blogs);
         $blogs = array_map('trim', $blogs);
         $this->setProperty('blogs', $blogs);
     }
     if ($this->hasErrors()) {
         return 'Проверьте правильность заполнения данных';
     }
     return parent::initialize();
 }
Пример #4
0
 public function initialize()
 {
     $this->setProperties(array('class_key' => 'SocietyBlog'));
     return parent::initialize();
 }