public function addsfSimpleForumTopic(sfSimpleForumTopic $l) { $this->collsfSimpleForumTopics[] = $l; $l->setsfSimpleForumPost($this); }
$databaseManager = new sfDatabaseManager(); $databaseManager->initialize(); $con = Propel::getConnection(); // cleanup database sfSimpleForumCategoryPeer::doDeleteAll(); sfSimpleForumForumPeer::doDeleteAll(); sfSimpleForumPostPeer::doDeleteAll(); // Now we can start to test $t = new lime_test(34, new lime_output_color()); // Initialization $cat = new sfSimpleForumCategory(); $cat->save(); $forum = new sfSimpleForumForum(); $forum->setCategoryId($cat->getId()); $forum->save(); $topic = new sfSimpleForumTopic(); $topic->setTitle('This is a test'); $topic->setsfSimpleForumForum($forum); $topic->save(); $user0 = new sfGuardUser(); $user0->setUsername('me'); $user0->setPassword('me'); $user0->save(); $user1 = new sfGuardUser(); $user1->setUsername('foo'); $user1->setPassword('foo'); $user1->save(); $user2 = new sfGuardUser(); $user2->setUsername('bar'); $user2->setPassword('bar'); $user2->save();
/** * Selects a collection of sfSimpleForumPost objects pre-filled with related topic and forum objects. * * @return array Array of sfSimpleForumPost objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinTopicAndForum(Criteria $c, $con = null) { foreach (sfMixer::getCallables('BasesfSimpleForumPostPeer:doSelectJoinAllExcept:doSelectJoinAllExcept') as $callable) { call_user_func($callable, 'BasesfSimpleForumPostPeer', $c, $con); } $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } sfSimpleForumPostPeer::addSelectColumns($c); $startcol2 = sfSimpleForumPostPeer::NUM_COLUMNS - sfSimpleForumPostPeer::NUM_LAZY_LOAD_COLUMNS + 1; sfSimpleForumTopicPeer::addSelectColumns($c); $startcol3 = $startcol2 + sfSimpleForumTopicPeer::NUM_COLUMNS; sfSimpleForumForumPeer::addSelectColumns($c); $startcol4 = $startcol3 + sfSimpleForumForumPeer::NUM_COLUMNS; $c->addJoin(sfSimpleForumPostPeer::TOPIC_ID, sfSimpleForumTopicPeer::ID); $c->addJoin(sfSimpleForumPostPeer::FORUM_ID, sfSimpleForumForumPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $post = new sfSimpleForumPost(); $post->hydrate($rs); $topic = new sfSimpleForumTopic(); $topic->hydrate($rs, $startcol2); $newObject = true; foreach ($results as $temp_post) { $existing_topic = $temp_post->getsfSimpleForumTopic(); if ($existing_topic->getPrimaryKey() === $topic->getPrimaryKey()) { $newObject = false; $existing_topic->addsfSimpleForumPost($post); break; } } if ($newObject) { $topic->initsfSimpleForumPosts(); $topic->addsfSimpleForumPost($post); } $forum = new sfSimpleForumForum(); $forum->hydrate($rs, $startcol3); $newObject = true; foreach ($results as $temp_post) { $existing_forum = $temp_post->getsfSimpleForumForum(); if ($existing_forum->getPrimaryKey() === $forum->getPrimaryKey()) { $newObject = false; $existing_forum->addsfSimpleForumPost($post); break; } } if ($newObject) { $forum->initsfSimpleForumPosts(); $forum->addsfSimpleForumPost($post); } $results[] = $post; } return $results; }
protected function sendAbuseEmail(sfSimpleForumTopic $topic) { $this->getContext()->getConfiguration()->loadHelpers(array('I18N')); $mailFrom = sfConfig::get('app_sfSimpleForumPlugin_from_email', '*****@*****.**'); $mailTo = sfConfig::get('app_sfSimpleForumPlugin_admin_email', null); if ($mailTo === null) { return; } $mailBody = $this->getPartial('sfSimpleForum/abuse_mail', array('topic' => $topic)); $message = $this->getMailer()->compose($mailFrom, $mailTo, __('An abuse was reported for topic "%1%"', array("%1%" => $topic->getTitle()), 'sfSimpleForum'), $mailBody)->setContentType('text/html'); $this->getMailer()->send($message); }
public function executeAddTopic() { $forum = sfSimpleForumForumPeer::retrieveByStrippedName($this->getRequestParameter('forum_name')); $this->forward404Unless($forum); $topic = new sfSimpleForumTopic(); $topic->setsfSimpleForumForum($forum); $topic->setTitle($this->getRequestParameter('title')); $topic->setUserId(sfSimpleForumTools::getConnectedUserId()); if ($this->getUser()->hasCredential('moderator')) { $topic->setIsSticked($this->getRequestParameter('is_sticked', 0)); $topic->setIsLocked($this->getRequestParameter('is_locked', 0)); } $topic->save(); $post = new sfSimpleForumPost(); $post->setContent($this->getRequestParameter('body')); $post->setUserId(sfSimpleForumTools::getConnectedUserId()); $post->setsfSimpleForumTopic($topic); $post->save(); $this->redirectToPost($post); }