public function beforeSave() { $this->object->set('class_key', 'GridContainer'); $this->object->set('hide_children_in_tree', true); $this->object->set('cacheable', true); $this->object->set('isfolder', true); $properties = $this->getProperties(); $settings = $this->object->getProperties('gridclasskey'); foreach ($properties as $k => $v) { if (substr($k, 0, 22) == 'gridclasskey-property-') { $key = substr($k, 22); if ($v === 'false') { $v = 0; } elseif ($v === 'true') { $v = 1; } if ($key === 'fields') { $v = json_decode($v, TRUE); } $settings[$key] = $v; } } $this->object->setProperties($settings, 'gridclasskey'); return parent::beforeSave(); }
public function beforeSave() { $cansave = $this->getRelatedObject(); if ($cansave != true) { return $cansave; } return parent::beforeSave(); }
public function beforeSave() { $topic =& $this->object; # $topic->fromArray(array( # "published" => 1, # "publishedon" => time(), # "createdby" => $this->modx->user->id, # )); // Устанавливаем теги # if($topic_tags = $this->getProperty('topic_tags', array())){ # $tags = array(); # # if(!is_array($topic_tags)){ # $topic_tags = array_map('trim', explode(',', $topic_tags)); # } # # foreach($topic_tags as & $tag){ # $tag = strip_tags($tag); # $newTag = $this->modx->newObject('SocietyTopicTag', array( # "tag" => $tag, # "active" => 1, # )); # $tags[] = $newTag; # } # # $topic->Tags = $tags; # } $ok = parent::beforeSave(); if ($ok !== true) { return $ok; } $validator = new modWebSocietyTopicsValidator($this); $ok = $validator->validate(); if ($ok !== true) { return $ok; } # print '<pre>'; # print_r($this->object->toArray()); # exit; # return "Debug"; return !$this->hasErrors(); }
public function beforeSave() { $properties = $this->getProperties(); // Проходимся по каждому указанному блогу if ($blogs = $this->getProperty('blogs')) { $BlogTopics = array(); foreach ((array) $blogs as $blog_id) { // Проверяем получение блога if (!($blog = $this->modx->getObject('SocietyBlog', (int) $blog_id)) or !$blog instanceof SocietyBlog) { // print_r($blog->toArray()); return 'Не был получен указанный блог'; } // else // Устанавливаем связку Блог-Топик $BlogTopic = $this->modx->newObject('SocietyBlogTopic'); $BlogTopic->addOne($blog); $BlogTopics[] = $BlogTopic; } $this->object->addMany($BlogTopics); } // Проверяем блоги топика if (!($TopicBlogs = $this->object->TopicBlogs)) { return "Не был указан ни один блог"; } // Иначе проверяем права на блог foreach ($this->object->TopicBlogs as $TopicBlog) { $blog = $TopicBlog->Blog; if (!$blog instanceof SocietyBlog) { return "Публиковать топики можно только в блоги"; } $ok = $this->checkBlogAccess($blog); if ($ok !== true) { return $ok; } } // Добавляем атрибуты топика $attributes = $this->modx->newObject('SocietyTopicAttributes', $properties); $this->object->addOne($attributes); return parent::beforeSave(); }
public function beforeSave() { $afterSave = parent::beforeSave(); // Make sure this is not saved anywhere it shouldn't be $parent = $this->modx->getObject('modResource', $this->object->get('parent')); if ($parent) { $this->modx->log(1, print_r($parent->toArray(), true)); } /* if ($parent) { $this->object->setProperties($container->getProperties('articles'),'articles'); } */ // $this->isPublishing = $this->object->isDirty('published') && $this->object->get('published'); return $afterSave; }
/** {@inheritDoc} */ public function beforeSave() { $this->object->set('isfolder', 0); return parent::beforeSave(); }
/** * Override modResourceCreateProcessor::beforeSave to provide archiving * * {@inheritDoc} * @return boolean */ public function beforeSave() { $beforeSave = parent::beforeSave(); if (!$this->parentResource) { $this->parentResource = $this->object->getOne('Parent'); } if ($this->object->get('published')) { if (!$this->setArchiveUri()) { $this->modx->log(modX::LOG_LEVEL_ERROR, 'Failed to set URI for new Article.'); } } /** @var ArticlesContainer $container */ $container = $this->modx->getObject('ArticlesContainer', $this->object->get('parent')); if ($container) { $settings = $container->getProperties('articles'); $this->object->setProperties($settings, 'articles'); $this->object->set('richtext', !isset($settings['articlesRichtext']) || !empty($settings['articlesRichtext'])); } $this->isPublishing = $this->object->isDirty('published') && $this->object->get('published'); return $beforeSave; }
/** * Override modResourceCreateProcessor::afterSave to provide custom functionality, saving the container settings to a * custom field in the manager * {@inheritDoc} * @return boolean */ public function beforeSave() { $properties = $this->getProperties(); $settings = $this->object->getProperties('articles'); $notificationServices = array(); foreach ($properties as $k => $v) { if (substr($k, 0, 8) == 'setting_') { $key = substr($k, 8); if ($v === 'false') { $v = 0; } if ($v === 'true') { $v = 1; } switch ($key) { case 'notifyTwitter': if ($v) { $notificationServices[] = 'twitter'; } break; case 'notifyTwitterConsumerKey': if (!empty($v)) { $v = $this->object->encrypt($v); } break; case 'notifyTwitterConsumerKeySecret': if (!empty($v)) { $v = $this->object->encrypt($v); } break; case 'notifyFacebook': if ($v) { $notificationServices[] = 'facebook'; } break; } $settings[$key] = $v; } } $settings['notificationServices'] = implode(',', $notificationServices); $this->object->setProperties($settings, 'articles'); $this->object->set('class_key', 'ArticlesContainer'); $this->object->set('cacheable', true); $this->object->set('isfolder', true); return parent::beforeSave(); }
/** * Override modResourceUpdateProcessor::beforeSave to provide custom functionality, saving settings for the container * to a custom field in the DB * {@inheritDoc} * @return boolean */ public function beforeSave() { $raw = $this->getProperties(); // <-- this will have raw values $properties = $this->object->getProperties('moxycart'); //<-- we need to update these values $this->object->set('class_key', 'Store'); //$this->modx->log(1,'beforeSave raw values: '.print_r($raw,true)); //$this->modx->log(1,'beforeSave raw POST values: '.print_r($_POST,true)); $properties['product_type'] = $this->modx->getOption('product_type', $raw); $properties['product_template'] = $this->modx->getOption('product_template', $raw); $properties['track_inventory'] = $this->modx->getOption('track_inventory', $raw) == 'Yes' ? 1 : 0; $properties['sort_order'] = $this->modx->getOption('sort_order', $raw); $properties['qty_alert'] = $this->modx->getOption('qty_alert', $raw); $this->object->setProperties($properties, 'moxycart'); return parent::beforeSave(); }