Exemplo n.º 1
0
 /** {@inheritDoc} */
 public function afterSave()
 {
     if ($this->object->alias == 'empty-resource-alias') {
         $this->object->set('alias', $this->object->id);
         $this->object->save();
     }
     // Updating resourceMap before OnDocSaveForm event
     $results = $this->modx->cacheManager->generateContext($this->object->context_key);
     $this->modx->context->resourceMap = $results['resourceMap'];
     $this->modx->context->aliasMap = $results['aliasMap'];
     return parent::afterSave();
 }
 public function afterSave()
 {
     $collectionsTemplate = (int) $this->getProperty('collections_template');
     $config = $this->modx->getObject('CollectionSetting', array('collection' => $this->object->id));
     if (!$config) {
         $config = $this->modx->newObject('CollectionSetting');
         $config->set('collection', $this->object->id);
     }
     $config->set('template', $collectionsTemplate);
     $config->save();
     return parent::afterSave();
 }
Exemplo n.º 3
0
 /**
  * Override modResourceCreateProcessor::afterSave to provide custom functionality, saving the container settings to a
  * custom field in the manager
  * {@inheritDoc}
  * @return boolean
  */
 public function afterSave()
 {
     //$this->modx->log(1, __FILE__ . print_r($this->object->toArray(), true));
     $this->object->set('class_key', 'Taxonomy');
     $this->object->set('cacheable', true);
     $this->object->set('isfolder', true);
     return parent::afterSave();
 }
Exemplo n.º 4
0
 /**
  * Override modResourceCreateProcessor::afterSave to force certain attributes.
  * @return boolean
  */
 public function afterSave()
 {
     $this->object->set('class_key', 'Term');
     $this->object->set('cacheable', true);
     $this->object->set('isfolder', true);
     return parent::afterSave();
 }
Exemplo n.º 5
0
 /**
  * @return mixed
  */
 public function afterSave()
 {
     $uri = $this->object->get('uri');
     $new_uri = str_replace('%id', $this->object->get('id'), $uri);
     if ($uri != $new_uri) {
         $this->object->set('uri', $new_uri);
         $this->object->save();
     }
     // Updating resourceMap before OnDocSaveForm event
     $results = $this->modx->cacheManager->generateContext($this->object->context_key, array('cache_context_settings' => false));
     $this->modx->context->resourceMap = $results['resourceMap'];
     $this->modx->context->aliasMap = $results['aliasMap'];
     if ($this->_sendEmails && $this->modx->context->key == 'mgr') {
         $this->sendTicketMails();
     }
     return parent::afterSave();
 }
Exemplo n.º 6
0
 public function afterSave()
 {
     $this->setProperty('clearCache', true);
     return parent::afterSave();
 }
Exemplo n.º 7
0
 public function afterSave()
 {
     $afterSave = parent::afterSave();
     $this->saveTemplateVariables();
     $this->clearContainerCache();
     if ($this->isPublishing) {
         $this->object->notifyUpdateServices();
         $this->object->sendNotifications();
     }
     return $afterSave;
 }
 /**
  * Override modResourceCreateProcessor::afterSave to provide custom functionality
  * {@inheritDoc}
  * @return boolean
  */
 public function afterSave()
 {
     $this->addContainerId();
     $this->removeFromArchivistIds();
     $this->setProperty('clearCache', true);
     return parent::afterSave();
 }
Exemplo n.º 9
0
 public function afterSave()
 {
     parent::afterSave();
     $topic =& $this->object;
     $can_send_notices = $this->modx->hasPermission('modxclub.send_notices');
     $no_send_emails = $this->getProperty('no_send_emails', false);
     $site_name = $this->modx->getOption('site_name');
     $use_delayed_emails = $this->modx->getOption('modsociety.use_delayed_emails', null, false);
     // Обновляем псевдоним
     # $topic->alias .= " " . $topic->id;
     # $topic->save();
     $this->modx->cacheManager->refresh();
     /*
         Рассылаем уведомления
     */
     if (empty($this->modx->smarty)) {
         $this->modx->invokeEvent('OnHandleRequest');
     }
     $this->modx->smarty->assign('topic', $topic->toArray());
     // Кому уже отправлялось, чтобы не отправлять повторно
     // Сразу добавляем и того, кто пишет
     $sended_to = array($this->modx->user->id);
     #
     # // Не используем этот объект запроса, а только его клоны
     # $users_query = $this->modx->newQuery('modUser');
     #
     # $users_query->distinct();
     #
     # $users_query->innerJoin('modUserProfile', 'Profile');
     # $users_query->leftJoin('SocietyNoticeUser', 'Notices');
     # $users_query->leftJoin('SocietyNoticeType', 'NoticeType', "NoticeType.target = 'modResource' AND NoticeType.id = Notices.notice_id");
     #
     # $users_query->where(array(
     #     "active"    => 1,
     #     "Profile.blocked"   => 0,
     #     "id:not in" => $sended_to,
     # ));
     #
     # $users_query->where(array(
     #     "Profile.blockeduntil"    => 0,
     #     "OR:Profile.blockeduntil:<" => time(),
     # ));
     // Отправляем всем, кто подписан на топики или по выбранный уровням уведомлений
     # if($can_send_notices && !$no_send_emails){
     #     $sended_to = array_unique($sended_to);
     #     $q = clone($users_query);
     #
     #     if($sended_to){
     #         $q->where(array(
     #             "id:not in"    => $sended_to,
     #         ));
     #     }
     #
     #     if(
     #         $notices = $this->getProperty('notices')
     #         AND is_array($notices)
     #     ){
     #         $q->where(array(
     #             "NoticeType.id:in"   => $notices,
     #         ));
     #     }
     #     else{
     #         $q->where(array(
     #             "NoticeType.type"   => "new_topic",
     #         ));
     #     }
     #
     #     # if($users = $this->modx->getCollection('modUser', $q)){
     #         # foreach($users as $user){
     #         foreach($this->modx->getIterator('modUser', $q) as $user){
     #             if($topic->checkPolicy('view', null, $user)){
     #                 $this->modx->smarty->assign('auth_user_id', $user->id);
     #                 $message = $this->modx->smarty->fetch('messages/society/new_topic/subscribers.tpl');
     #                 $subject = "Новый топик на сайте {$site_name}";
     #                 /*
     #                     Пытаемся записать в отложенную рассылку
     #                 */
     #                 if(
     #                     !$use_delayed_emails
     #                     OR !$emailmessage = $this->modx->newObject('SocietyEmailMessage', array(
     #                         "user_id"   => $user->id,
     #                         "subject"   => $subject,
     #                         "message"   => $message,
     #                     ))
     #                     OR !$emailmessage->save()
     #                 ){
     #                     $user->sendEmail($message, array(
     #                         "subject"   => $subject,
     #                     ));
     #                     $this->modx->mail->reset();
     #                 }
     #
     #                 $sended_to[] = $user->id;
     #             }
     #             # else{
     #             #     // Если нет права на топик, сразу добавляем в исключения
     #             #     $sended_to[] = $user->id;
     #             # }
     #         }
     #         $this->modx->smarty->assign('auth_user_id', false);
     #     # }
     # }
     // 1. Администрации
     $q = $this->modx->newQuery('modUser');
     $q->innerJoin('modUserProfile', 'Profile');
     $q->innerJoin('modUserGroupMember', 'UserGroupMembers');
     $q->where(array("active" => 1, "Profile.blocked" => 0, "UserGroupMembers.user_group" => 7, "id:not in" => $sended_to));
     if ($users = $this->modx->getCollection('modUser', $q)) {
         $message = $this->modx->smarty->fetch('messages/society/new_topic/administration.tpl');
         foreach ($users as $user) {
             $user->sendEmail($message, array("subject" => "Новый топик на сайте {$site_name}"));
             $this->modx->mail->reset();
         }
     }
     return true;
 }