protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $this->conn = $databaseManager->getDatabase('doctrine')->getDoctrineConnection(); $communityIds = $this->getCommunityIds(); for ($i=0; $i < $options['communitynumber']; ++$i) { $communityId = $this->fetchRandomCommunityId($communityIds); $topicIds = $this->getTopicIds($communityId); $memberIds = $this->getMemberIds($communityId); for ($j=0; $j < $options['topicnumber']; ++$j) { for ($k=0; $k < $options['number']; ++$k) { $ctc = new CommunityTopicComment(); $ctc->setMemberId(self::fetchRandomMemberId($memberIds)); $ctc->setCommunityTopicId(self::fetchRandomTopicId($topicIds)); $ctc->setBody('body'); $ctc->save(); $ctc->free(); $this->logSection('created a community topic comment', sprintf("%s", $communityId)); } } } }
public function insert(SimpleXMLElement $xml) { $member = Doctrine::getTable('Member')->find($this->getMemberIdByUrl((string) $xml->author->uri)); if (!$member) { return false; } $comment = new CommunityTopicComment(); $comment->setMember($member); $comment->setCommunityTopic($this->getParentObject()); $comment->setBody((string) $xml->content); $comment->save(); return $comment; }
public function executePost(sfWebRequest $request) { $this->forward400If('' === (string) $request['body'], 'body parameter is not specified.'); if ($limit = sfConfig::get('app_smt_comment_post_limit')) { $this->forward400If(mb_strlen($request['body']) > $limit, 'body parameter is too long'); } $comment = new CommunityTopicComment(); $comment->setMemberId($this->member->getId()); $comment->setCommunityTopicId($request['community_topic_id']); $this->forward400If(false === $comment->getCommunityTopic()->isCreatableCommunityTopicComment($this->member->getId()), 'you are not allowed to create comments on this topic'); $comment->setBody($request['body']); $comment->save(); $this->comment = $comment; }
public function executeCreate(opMailRequest $request) { $member = $this->getRoute()->getMember(); if (!$member) { return sfView::NONE; } $topic = Doctrine::getTable('CommunityTopic')->find($request['id']); if (!$topic || !$topic->isCreatableCommunityTopicComment($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 CommunityTopicComment(); $topicComment->setCommunityTopic($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 CommunityTopicCommentImage(); $image->setCommunityTopicComment($topicComment); $image->setFile($file); $image->setNumber($number); $image->save(); } opCommunityTopicToolkit::sendNotificationMail($topic->getCommunity(), $topic->getId(), 'topic', $topicComment->getMember()->getName(), $topic->getName(), $topicComment->getBody()); return sfView::NONE; }