Пример #1
0
 public function executeDelete(sfWebRequest $request)
 {
     $request->checkCSRFProtection();
     $this->forward404Unless($forum = ForumPeer::retrieveByPk($request->getParameter('id')), sprintf('Object forum does not exist (%s).', $request->getParameter('id')));
     $forum->delete();
     $this->redirect('forums/index');
 }
Пример #2
0
 /**
  * The component to display a single forum (i.e. the threads in it)
  */
 public function executeShowForum()
 {
     $this->category = CategoryPeer::retrieveByPK($this->forumID);
     if ($this->category == NULL) {
         $this->category = ForumPeer::retrieveByPK($this->forumID);
     }
     $c = ThreadPeer::getCriteriaForCategory($this->forumID);
     $pager = new sfPropelPager('Thread', 10);
     $pager->setCriteria($c);
     $pager->setPage($this->getRequestParameter('page', 1));
     $pager->init();
     $raykuPager = new RaykuPagerRenderer($pager);
     $raykuPager->setBaseUrl('@view_page?forum_id=' . $this->category->getId());
     $this->raykuPager = $raykuPager;
 }
Пример #3
0
    public function executeExpertReplyThread()
    {
        $connection = RaykuCommon::getDatabaseConnection();
        $c = new Criteria();
        $c->add(ForumPeer::TYPE, 0);
        $this->publicforums = ForumPeer::doSelect($c);
        $this->allcategories = CategoryPeer::doSelect($c = new Criteria());
        $this->forum = $this->getRequestParameter('forum_id');
        $this->thread = ThreadPeer::retrieveByPK($this->getRequestParameter('thread_id'));
        $c = new Criteria();
        $c->add(PostPeer::THREAD_ID, $this->thread->getId());
        $this->post = PostPeer::doSelectOne($c);
        $user = $this->getUser()->getRaykuUser();
        if ($this->getRequestParameter('post_edit_content') != '') {
            $threadId = $this->getRequestParameter('thread_id');
            $_thread = ThreadPeer::retrieveByPK($threadId);
            $_thread->setTitle($this->getRequestParameter('post_edit_title'));
            $_thread->save();
            $v = new Criteria();
            $v->add(PostPeer::THREAD_ID, $threadId);
            $v->addAscendingOrderByColumn(PostPeer::ID);
            $post = PostPeer::doSelectOne($v);
            $post->setContent($this->getRequestParameter('post_edit_content'));
            $post->save();
            return $this->redirect('@view_thread?thread_id=' . $threadId);
        }
        if ($this->getRequestParameter('post_body') != '') {
            if ($this->getRequestParameter('final_id') != '') {
                $_quick_reply = '';
                $_post_id = $this->getRequestParameter('final_id');
                $_Post = PostPeer::retrieveByPK($_post_id);
                $_User = UserPeer::retrieveByPK($_Post->getPosterId());
                $_quick_reply .= "<div style='margin-left:20px'><em><strong>Quote from " . $_User->getUsername() . "</strong></em><br><br>";
                $_explode_post = explode("*^-", $_Post->getContent());
                if (count($_explode_post) > 1) {
                    $_quick_reply .= $_explode_post[1];
                } else {
                    $_quick_reply .= $_Post->getContent();
                }
                $_quick_reply .= "</div>";
                $_post_body_msg = $this->getRequestParameter('post_body');
                $_quick_reply .= $_post_body_msg;
                $user->makeNewPost($this->getRequestParameter('thread_id'), $_quick_reply);
                ///////////////////updating the ip of the user
                $post_id = mysql_fetch_row(mysql_query("SELECT max(id) from post limit 0,1", $connection));
                mysql_query("update post set \tuser_ip='" . $_SERVER['REMOTE_ADDR'] . "' where id=" . $post_id[0] . "", $connection);
                ///////////////////updating the ip of the user
            } else {
                $user->makeNewPost($this->getRequestParameter('thread_id'), $this->getRequestParameter('post_body'));
                ///////////////////updating the ip of the user
                $post_id = mysql_fetch_row(mysql_query("SELECT max(id) from post limit 0,1", $connection));
                mysql_query("update post set \tuser_ip='" . $_SERVER['REMOTE_ADDR'] . "' where id=" . $post_id[0] . "", $connection);
                ///////////////////updating the ip of the user
            }
            if ($this->getUser()->getRaykuUser()->getType() == '5') {
                $c = new Criteria();
                $c->add(ThreadPeer::ID, $this->getRequestParameter('thread_id'));
                $thread = ThreadPeer::doSelectOne($c);
                $c = new Criteria();
                $c->add(UserPeer::ID, $thread->getPosterId());
                $user = UserPeer::doSelectOne($c);
                if ($thread->getNotifyPm() == '1') {
                    $subject = 'Expert Response for your Question';
                    $body = 'Hi there, <br><br>
							A Rayku expert, "' . $this->getUser()->getRaykuUser()->getName() . '" has just responsed to your question, "' . $thread->getTitle() . '" on the question boards. Take a look!<br><br>
							Rayku Administration';
                    //Grab the user object
                    $currentuser = UserPeer::retrieveByPK($this->getUser()->getRaykuUserId());
                    //Send the message
                    $currentuser->sendMessage($user->getId(), $subject, $body);
                }
                if ($thread->getNotifyEmail() == '1') {
                    $this->mail = new sfMail();
                    //Set the to, from, and subject headers
                    $this->mail->addAddress($user->getEmail());
                    $this->mail->setFrom('Expert <' . $this->getUser()->getRaykuUser()->getEmail() . '>');
                    $this->mail->setSubject('Expert Response to your Question');
                    $this->mail->setBody('Hi there,<br>
							A Rayku expert, "' . $this->getUser()->getRaykuUser()->getName() . '", has just responded to your question (below) on the question boards. Take a look!<br><br>
							' . $thread->getTitle() . '');
                    $this->mail->send();
                }
            }
            return $this->redirect('@view_thread?thread_id=' . $this->thread->getId());
        }
    }
Пример #4
0
 public function getForumId()
 {
     $c = new Criteria();
     $c->add(ForumPeer::ENTITY_ID, $this->getId());
     $c->add(ForumPeer::TYPE, Forum::TYPE_USER_FORUM);
     $forum = ForumPeer::doSelectOne($c);
     return $forum->getId();
 }
Пример #5
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = ForumPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDescription($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setType($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setEntityId($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setTopOrBottom($arr[$keys[5]]);
     }
 }
Пример #6
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(ForumPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(ForumPeer::DATABASE_NAME);
         $criteria->add(ForumPeer::ID, $pks, Criteria::IN);
         $objs = ForumPeer::doSelect($criteria, $con);
     }
     return $objs;
 }