public function save($con = null)
 {
     $result = parent::save($con);
     if ($this->isNew()) {
         opCommunityTopicToolkit::sendNotificationMail($result->getCommunity(), $result->getId(), 'topic', $result->getMember()->getName(), $result->getName(), $result->getBody());
     }
     return $result;
 }
 public function save($con = null)
 {
     $communityTopicComment = parent::save($con);
     $communityTopic = $communityTopicComment->getCommunityTopic();
     $communityTopic->setUpdatedAt($communityTopicComment->getCreatedAt());
     $communityTopic->save();
     if ($this->isNew()) {
         opCommunityTopicToolkit::sendNotificationMail($communityTopic->getCommunity(), $communityTopic->getId(), 'topic', $communityTopicComment->getMember()->getName(), $communityTopic->getName(), $communityTopicComment->getBody());
     }
     return $communityTopicComment;
 }
 public function getSearchQuery($communityId = null, $target = null, $keyword = null)
 {
     $q = $this->createQuery();
     if ('all' !== $target && $communityId) {
         $q->where('community_id = ?', $communityId);
     }
     if (!is_null($keyword)) {
         $values = preg_split('/[\\s ]+/u', $keyword);
         foreach ($values as $value) {
             if (method_exists($q, 'escapePattern')) {
                 $value = $q->escapePattern($value);
             }
             $q->andWhere('(name LIKE ? OR body LIKE ?)', array('%' . $value . '%', '%' . $value . '%'));
         }
     }
     $q->andWhereIn('community_id', opCommunityTopicToolkit::getPublicCommunityIdList())->orderBy('updated_at DESC');
     return $q;
 }
Example #4
0
 public function executeCreate(opMailRequest $request)
 {
     $member = $this->getRoute()->getMember();
     if (!$member) {
         return sfView::NONE;
     }
     $topic = Doctrine::getTable('CommunityEvent')->find($request['id']);
     if (!$topic || !$topic->isCreatableCommunityEventComment($member->id)) {
         return sfView::NONE;
     }
     if ($topic->member_id !== $member->id) {
         $relation = Doctrine::getTable('MemberRelationship')->retrieveByFromAndTo($topic->member_id, $member->id);
         if ($relation && $relation->getIsAccessBlock()) {
             return sfView::NONE;
         }
     }
     $mailMessage = $request->getMailMessage();
     $validator = new opValidatorString(array('rtrim' => true));
     try {
         $body = $validator->clean($mailMessage->getContent());
     } catch (Exception $e) {
         return sfView::ERROR;
     }
     $topicComment = new CommunityEventComment();
     $topicComment->setCommunityEvent($topic);
     $topicComment->setMember($member);
     $topicComment->setBody($body);
     $topicComment->save();
     $num = (int) sfConfig::get('app_community_topic_comment_max_image_file_num', 3);
     $files = $this->getImageFiles($mailMessage, $num);
     $number = 0;
     foreach ($files as $file) {
         $number++;
         $image = new CommunityEventCommentImage();
         $image->setCommunityEventComment($topicComment);
         $image->setFile($file);
         $image->setNumber($number);
         $image->save();
     }
     opCommunityTopicToolkit::sendNotificationMail($topic->getCommunity(), $topic->getId(), 'event', $topicComment->getMember()->getName(), $topic->getName(), $topicComment->getBody());
     return sfView::NONE;
 }