Esempio n. 1
0
 /**
  * Показ и обработка формы приглаешний
  *
  * @return unknown
  */
 protected function EventInvite()
 {
     if (!Config::Get('general.reg.invite')) {
         return parent::EventNotFound();
     }
     $this->sMenuItemSelect = 'invite';
     $this->sMenuSubItemSelect = '';
     $this->Viewer_AddHtmlTitle($this->Lang_Get('settings_menu_invite'));
     if (isPost('submit_invite')) {
         $this->Security_ValidateSendForm();
         $bError = false;
         if (!$this->ACL_CanSendInvite($this->oUserCurrent) and !$this->oUserCurrent->isAdministrator()) {
             $this->Message_AddError($this->Lang_Get('settings_invite_available_no'), $this->Lang_Get('error'));
             $bError = true;
         }
         if (!func_check(getRequest('invite_mail'), 'mail')) {
             $this->Message_AddError($this->Lang_Get('settings_invite_mail_error'), $this->Lang_Get('error'));
             $bError = true;
         }
         if (!$bError) {
             $oInvite = $this->User_GenerateInvite($this->oUserCurrent);
             $this->Notify_SendInvite($this->oUserCurrent, getRequest('invite_mail'), $oInvite);
             $this->Message_AddNoticeSingle($this->Lang_Get('settings_invite_submit_ok'));
         }
     }
     $this->Viewer_Assign('iCountInviteAvailable', $this->User_GetCountInviteAvailable($this->oUserCurrent));
     $this->Viewer_Assign('iCountInviteUsed', $this->User_GetCountInviteUsed($this->oUserCurrent->getId()));
 }
Esempio n. 2
0
 /**
  * Обработка ajax запроса на отправку 
  * повторного приглашения вступить в закрытый блог
  */
 protected function AjaxReBlogInvite()
 {
     $this->Viewer_SetResponseAjax();
     $sUserId = getRequest('idUser', null, 'post');
     $sBlogId = getRequest('idBlog', null, 'post');
     /**
      * Если пользователь не авторизирован, возвращаем ошибку
      */
     if (!$this->User_IsAuthorization()) {
         $this->Message_AddErrorSingle($this->Lang_Get('need_authorization'), $this->Lang_Get('error'));
         return;
     }
     $this->oUserCurrent = $this->User_GetUserCurrent();
     /**
      * Проверяем существование блога
      */
     if (!($oBlog = $this->Blog_GetBlogById($sBlogId))) {
         $this->Message_AddErrorSingle($this->Lang_Get('system_error'), $this->Lang_Get('error'));
         return;
     }
     if (!($oUser = $this->User_GetUserById($sUserId)) or $oUser->getActivate() != 1) {
         $this->Message_AddErrorSingle($this->Lang_Get('system_error'), $this->Lang_Get('error'));
         return;
     }
     /**
      * Проверяем, имеет ли право текущий пользователь добавлять invite в blog
      */
     $oBlogUser = $this->Blog_GetBlogUserByBlogIdAndUserId($oBlog->getId(), $this->oUserCurrent->getId());
     $bIsAdministratorBlog = $oBlogUser ? $oBlogUser->getIsAdministrator() : false;
     if ($oBlog->getOwnerId() != $this->oUserCurrent->getId() and !$this->oUserCurrent->isAdministrator() and !$bIsAdministratorBlog) {
         $this->Message_AddErrorSingle($this->Lang_Get('system_error'), $this->Lang_Get('error'));
         return;
     }
     $oBlogUser = $this->Blog_GetBlogUserByBlogIdAndUserId($oBlog->getId(), $oUser->getId());
     if ($oBlogUser->getUserRole() == ModuleBlog::BLOG_USER_ROLE_INVITE) {
         $this->SendBlogInvite($oBlog, $oUser);
         $this->Message_AddNoticeSingle($this->Lang_Get('blog_user_invite_add_ok', array('login' => $oUser->getLogin())), $this->Lang_Get('attention'));
     } else {
         $this->Message_AddErrorSingle($this->Lang_Get('system_error'), $this->Lang_Get('error'));
     }
 }
Esempio n. 3
0
 /**
  * Обработка редактирования топика
  *
  * @param unknown_type $oTopic
  * @return unknown
  */
 protected function SubmitEdit($oTopic)
 {
     /**
      * Проверка корректности полей формы
      */
     if (!$this->checkTopicFields($oTopic)) {
         return false;
     }
     /**
      * Определяем в какой блог делаем запись
      */
     $iBlogId = getRequest('blog_id');
     if ($iBlogId == 0) {
         $oBlog = $this->Blog_GetPersonalBlogByUserId($oTopic->getUserId());
     } else {
         $oBlog = $this->Blog_GetBlogById($iBlogId);
     }
     /**
      * Если блог не определен выдаем предупреждение
      */
     if (!$oBlog) {
         $this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_unknown'), $this->Lang_Get('error'));
         return false;
     }
     /**
      * Проверяем права на постинг в блог
      */
     if (!$this->ACL_IsAllowBlog($oBlog, $this->oUserCurrent)) {
         $this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_noallow'), $this->Lang_Get('error'));
         return false;
     }
     /**
      * Проверяем разрешено ли постить топик по времени
      */
     if (isPost('submit_topic_publish') and !$oTopic->getPublishDraft() and !$this->ACL_CanPostTopicTime($this->oUserCurrent)) {
         $this->Message_AddErrorSingle($this->Lang_Get('topic_time_limit'), $this->Lang_Get('error'));
         return;
     }
     /**
      * Сохраняем старое значение идентификатора блога
      */
     $sBlogIdOld = $oTopic->getBlogId();
     /**
      * Теперь можно смело редактировать топик
      */
     $oTopic->setBlogId($oBlog->getId());
     $oTopic->setText(htmlspecialchars(getRequest('topic_text')));
     $oTopic->setTextShort(htmlspecialchars(getRequest('topic_text')));
     $oTopic->setTextSource(getRequest('topic_text'));
     $oTopic->setTags(getRequest('topic_tags'));
     $oTopic->setUserIp(func_getIp());
     /**
      * изменяем вопрос/ответы только если еще никто не голосовал
      */
     if ($oTopic->getQuestionCountVote() == 0) {
         $oTopic->setTitle(getRequest('topic_title'));
         $oTopic->clearQuestionAnswer();
         foreach (getRequest('answer', array()) as $sAnswer) {
             $oTopic->addQuestionAnswer($sAnswer);
         }
     }
     $oTopic->setTextHash(md5($oTopic->getType() . $oTopic->getText() . $oTopic->getTitle()));
     /**
      * Проверяем топик на уникальность
      */
     if ($oTopicEquivalent = $this->Topic_GetTopicUnique($this->oUserCurrent->getId(), $oTopic->getTextHash())) {
         if ($oTopicEquivalent->getId() != $oTopic->getId()) {
             $this->Message_AddErrorSingle($this->Lang_Get('topic_create_text_error_unique'), $this->Lang_Get('error'));
             return false;
         }
     }
     /**
      * Публикуем или сохраняем в черновиках
      */
     $bSendNotify = false;
     if (isset($_REQUEST['submit_topic_publish'])) {
         $oTopic->setPublish(1);
         if ($oTopic->getPublishDraft() == 0) {
             $oTopic->setPublishDraft(1);
             $oTopic->setDateAdd(date("Y-m-d H:i:s"));
             $bSendNotify = true;
         }
     } else {
         $oTopic->setPublish(0);
     }
     /**
      * Принудительный вывод на главную
      */
     if ($this->ACL_IsAllowPublishIndex($this->oUserCurrent)) {
         if (getRequest('topic_publish_index')) {
             $oTopic->setPublishIndex(1);
         } else {
             $oTopic->setPublishIndex(0);
         }
     }
     /**
      * Запрет на комментарии к топику
      */
     $oTopic->setForbidComment(0);
     if (getRequest('topic_forbid_comment')) {
         $oTopic->setForbidComment(1);
     }
     $this->Hook_Run('topic_edit_before', array('oTopic' => $oTopic, 'oBlog' => $oBlog));
     /**
      * Сохраняем топик
      */
     if ($this->Topic_UpdateTopic($oTopic)) {
         $this->Hook_Run('topic_edit_after', array('oTopic' => $oTopic, 'oBlog' => $oBlog, 'bSendNotify' => &$bSendNotify));
         /**
          * Обновляем данные в комментариях, если топик был перенесен в новый блог
          */
         if ($sBlogIdOld != $oTopic->getBlogId()) {
             $this->Comment_UpdateTargetParentByTargetId($oTopic->getBlogId(), 'topic', $oTopic->getId());
             $this->Comment_UpdateTargetParentByTargetIdOnline($oTopic->getBlogId(), 'topic', $oTopic->getId());
         }
         /**
          * Обновляем количество топиков в блоге
          */
         if ($sBlogIdOld != $oTopic->getBlogId()) {
             $this->Blog_RecalculateCountTopicByBlogId($sBlogIdOld);
         }
         $this->Blog_RecalculateCountTopicByBlogId($oTopic->getBlogId());
         /**
          * Добавляем событие в ленту
          */
         $this->Stream_write($oTopic->getUserId(), 'add_topic', $oTopic->getId(), $oTopic->getPublish() && $oBlog->getType() != 'close');
         /**
          * Рассылаем о новом топике подписчикам блога
          */
         if ($bSendNotify) {
             $this->Topic_SendNotifyTopicNew($oBlog, $oTopic, $this->oUserCurrent);
         }
         if (!$oTopic->getPublish() and !$this->oUserCurrent->isAdministrator() and $this->oUserCurrent->getId() != $oTopic->getUserId()) {
             Router::Location($oBlog->getUrlFull());
         }
         Router::Location($oTopic->getUrl());
     } else {
         $this->Message_AddErrorSingle($this->Lang_Get('system_error'));
         return Router::Action('error');
     }
 }
Esempio n. 4
0
 /**
  * Добавление нового участника разговора (ajax)
  *
  * @return null
  */
 public function AjaxAddTalkUser()
 {
     $this->Viewer_SetResponseAjax();
     $sUsers = getRequest('users', null, 'post');
     $idTalk = getRequest('idTalk', null, 'post');
     // Если пользователь не авторизирован, возвращаем ошибку
     if (!$this->User_IsAuthorization()) {
         $this->Message_AddErrorSingle($this->Lang_Get('need_authorization'), $this->Lang_Get('error'));
         return;
     }
     // Если разговор не найден, или пользователь не является его автором (или админом),
     // возвращаем ошибку
     if (!($oTalk = $this->Talk_GetTalkById($idTalk)) || $oTalk->getUserId() != $this->oUserCurrent->getId() && !$this->oUserCurrent->isAdministrator()) {
         $this->Message_AddErrorSingle($this->Lang_Get('talk_not_found'), $this->Lang_Get('error'));
         return;
     }
     // Получаем список всех участников разговора
     $aTalkUsers = $oTalk->getTalkUsers();
     $aUsers = explode(',', $sUsers);
     // Получаем список пользователей, которые не принимают письма
     $aUserInBlacklist = $this->Talk_GetBlacklistByTargetId($this->oUserCurrent->getId());
     // Обрабатываем добавление по каждому переданному логину пользователя
     foreach ($aUsers as $sUser) {
         $sUser = trim($sUser);
         if ($sUser == '') {
             continue;
         }
         // Попытка добавить себя
         if (strtolower($sUser) == strtolower($this->oUserCurrent->getLogin())) {
             $aResult[] = array('bStateError' => true, 'sMsgTitle' => $this->Lang_Get('error'), 'sMsg' => $this->Lang_Get('talk_speaker_add_self'));
             continue;
         }
         if (($oUser = $this->User_GetUserByLogin($sUser)) && $oUser->getActivate() == 1) {
             if (!in_array($oUser->getId(), $aUserInBlacklist)) {
                 if (array_key_exists($oUser->getId(), $aTalkUsers)) {
                     switch ($aTalkUsers[$oUser->getId()]->getUserActive()) {
                         // Если пользователь ранее был удален админом разговора,
                         // то добавляем его снова
                         case ModuleTalk::TALK_USER_DELETE_BY_AUTHOR:
                             if ($this->Talk_AddTalkUser(Engine::GetEntity('Talk_TalkUser', array('talk_id' => $idTalk, 'user_id' => $oUser->getId(), 'date_last' => null, 'talk_user_active' => ModuleTalk::TALK_USER_ACTIVE)))) {
                                 $this->Notify_SendTalkNew($oUser, $this->oUserCurrent, $oTalk);
                                 $aResult[] = array('bStateError' => false, 'sMsgTitle' => $this->Lang_Get('attention'), 'sMsg' => $this->Lang_Get('talk_speaker_add_ok', array('login', $sUser)), 'sUserId' => $oUser->getId(), 'sUserLogin' => $oUser->getLogin(), 'sUserLink' => $oUser->getUserWebPath());
                                 $bState = true;
                             } else {
                                 $aResult[] = array('bStateError' => true, 'sMsgTitle' => $this->Lang_Get('error'), 'sMsg' => $this->Lang_Get('system_error'));
                             }
                             break;
                             // Если пользователь является активным участником разговора,
                             // возвращаем ошибку
                         // Если пользователь является активным участником разговора,
                         // возвращаем ошибку
                         case ModuleTalk::TALK_USER_ACTIVE:
                             $aResult[] = array('bStateError' => true, 'sMsgTitle' => $this->Lang_Get('error'), 'sMsg' => $this->Lang_Get('talk_speaker_user_already_exist', array('login' => $sUser)));
                             break;
                             // Если пользователь удалил себя из разговора самостоятельно,
                             // то блокируем повторное добавление
                         // Если пользователь удалил себя из разговора самостоятельно,
                         // то блокируем повторное добавление
                         case ModuleTalk::TALK_USER_DELETE_BY_SELF:
                             $aResult[] = array('bStateError' => true, 'sMsgTitle' => $this->Lang_Get('error'), 'sMsg' => $this->Lang_Get('talk_speaker_delete_by_self', array('login' => $sUser)));
                             break;
                         default:
                             $aResult[] = array('bStateError' => true, 'sMsgTitle' => $this->Lang_Get('error'), 'sMsg' => $this->Lang_Get('system_error'));
                     }
                 } elseif ($this->Talk_AddTalkUser(Engine::GetEntity('Talk_TalkUser', array('talk_id' => $idTalk, 'user_id' => $oUser->getId(), 'date_last' => null, 'talk_user_active' => ModuleTalk::TALK_USER_ACTIVE)))) {
                     $this->Notify_SendTalkNew($oUser, $this->oUserCurrent, $oTalk);
                     $aResult[] = array('bStateError' => false, 'sMsgTitle' => $this->Lang_Get('attention'), 'sMsg' => $this->Lang_Get('talk_speaker_add_ok', array('login', $sUser)), 'sUserId' => $oUser->getId(), 'sUserLogin' => $oUser->getLogin(), 'sUserLink' => $oUser->getUserWebPath());
                     $bState = true;
                 } else {
                     $aResult[] = array('bStateError' => true, 'sMsgTitle' => $this->Lang_Get('error'), 'sMsg' => $this->Lang_Get('system_error'));
                 }
             } else {
                 // Добавляем пользователь не принимает сообщения
                 $aResult[] = array('bStateError' => true, 'sMsgTitle' => $this->Lang_Get('error'), 'sMsg' => $this->Lang_Get('talk_user_in_blacklist', array('login' => $sUser)));
             }
         } else {
             // Пользователь не найден в базе данных или не активен
             $aResult[] = array('bStateError' => true, 'sMsgTitle' => $this->Lang_Get('error'), 'sMsg' => $this->Lang_Get('user_not_found', array('login' => $sUser)));
         }
     }
     // Передаем во вьевер массив результатов обработки по каждому пользователю
     $this->Viewer_AssignAjax('aUsers', $aResult);
 }
Esempio n. 5
0
 /**
  * Обработка редактирования топика
  *
  * @param unknown_type $oTopic
  * @return unknown
  */
 protected function SubmitEdit($oTopic)
 {
     /**
      * Проверка корректности полей формы
      */
     if (!$this->checkTopicFields()) {
         return false;
     }
     /**
      * Определяем в какой блог делаем запись
      */
     $iBlogId = getRequest('blog_id');
     if ($iBlogId == 0) {
         $oBlog = $this->Blog_GetPersonalBlogByUserId($oTopic->getUserId());
     } else {
         $oBlog = $this->Blog_GetBlogById($iBlogId);
     }
     /**
      * Если блог не определен выдаем предупреждение
      */
     if (!$oBlog) {
         $this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_unknown'), $this->Lang_Get('error'));
         return false;
     }
     /**
      * Проверяем права на постинг в блог
      */
     if (!$this->ACL_IsAllowBlog($oBlog, $this->oUserCurrent)) {
         $this->Message_AddErrorSingle($this->Lang_Get('topic_create_blog_error_noallow'), $this->Lang_Get('error'));
         return false;
     }
     /**
      * Проверяем разрешено ли постить топик по времени
      */
     if (isPost('submit_topic_publish') and !$oTopic->getPublishDraft() and !$this->ACL_CanPostTopicTime($this->oUserCurrent)) {
         $this->Message_AddErrorSingle($this->Lang_Get('topic_time_limit'), $this->Lang_Get('error'));
         return;
     }
     /**
      * Теперь можно смело редактировать топик
      */
     $oTopic->setBlogId($oBlog->getId());
     $oTopic->setTitle(getRequest('topic_title'));
     $oTopic->setText(htmlspecialchars(getRequest('topic_text')));
     $oTopic->setTextShort(htmlspecialchars(getRequest('topic_text')));
     $oTopic->setTextSource(getRequest('topic_text'));
     $oTopic->setLinkUrl(getRequest('topic_link_url'));
     $oTopic->setTags(getRequest('topic_tags'));
     $oTopic->setUserIp(func_getIp());
     $oTopic->setTextHash(md5($oTopic->getType() . $oTopic->getText() . $oTopic->getLinkUrl()));
     /**
      * Проверяем топик на уникальность
      */
     if ($oTopicEquivalent = $this->Topic_GetTopicUnique($this->oUserCurrent->getId(), $oTopic->getTextHash())) {
         if ($oTopicEquivalent->getId() != $oTopic->getId()) {
             $this->Message_AddErrorSingle($this->Lang_Get('topic_create_text_error_unique'), $this->Lang_Get('error'));
             return false;
         }
     }
     /**
      * Публикуем или сохраняем в черновиках
      */
     $bSendNotify = false;
     if (isset($_REQUEST['submit_topic_publish'])) {
         $oTopic->setPublish(1);
         if ($oTopic->getPublishDraft() == 0) {
             $oTopic->setPublishDraft(1);
             $oTopic->setDateAdd(date("Y-m-d H:i:s"));
             $bSendNotify = true;
         }
     } else {
         $oTopic->setPublish(0);
     }
     /**
      * Принудительный вывод на главную
      */
     if ($this->oUserCurrent->isAdministrator()) {
         if (getRequest('topic_publish_index')) {
             $oTopic->setPublishIndex(1);
         } else {
             $oTopic->setPublishIndex(0);
         }
     }
     /**
      * Запрет на комментарии к топику
      */
     $oTopic->setForbidComment(0);
     if (getRequest('topic_forbid_comment')) {
         $oTopic->setForbidComment(1);
     }
     $this->Hook_Run('topic_edit_before', array('oTopic' => $oTopic, 'oBlog' => $oBlog));
     /**
      * Сохраняем топик
      */
     if ($this->Topic_UpdateTopic($oTopic)) {
         $this->Hook_Run('topic_edit_after', array('oTopic' => $oTopic, 'oBlog' => $oBlog, 'bSendNotify' => &$bSendNotify));
         /**
          * Рассылаем о новом топике подписчикам блога
          */
         if ($bSendNotify) {
             $this->Topic_SendNotifyTopicNew($oBlog, $oTopic, $this->oUserCurrent);
         }
         if (!$oTopic->getPublish() and !$this->oUserCurrent->isAdministrator() and $this->oUserCurrent->getId() != $oTopic->getUserId()) {
             Router::Location($oBlog->getUrlFull());
         }
         Router::Location($oTopic->getUrl());
     } else {
         $this->Message_AddErrorSingle($this->Lang_Get('system_error'));
         return Router::Action('error');
     }
 }
Esempio n. 6
0
 /**
  * Получает список блогов в которые может постить юзер
  *
  * @param unknown_type $oUser	 
  * @return unknown
  */
 public function GetBlogsAllowByUser($oUser)
 {
     if ($oUser->isAdministrator()) {
         return $this->GetBlogs();
     } else {
         $aAllowBlogsUser = $this->GetBlogsByOwnerId($oUser->getId());
         $aBlogUsers = $this->GetBlogUsersByUserId($oUser->getId());
         foreach ($aBlogUsers as $oBlogUser) {
             $oBlog = $oBlogUser->getBlog();
             if ($this->ACL_CanAddTopic($oUser, $oBlog) or $oBlogUser->getIsAdministrator() or $oBlogUser->getIsModerator()) {
                 $aAllowBlogsUser[$oBlog->getId()] = $oBlog;
             }
         }
         return $aAllowBlogsUser;
     }
 }