예제 #1
0
파일: PostPeer.php 프로젝트: noose/Planeta
 public static function getNewestTimestamp(Blog $blog)
 {
     $c = new Criteria();
     $c->addDescendingOrderByColumn(PostPeer::CREATED_AT);
     $c->add(PostPeer::BLOG_ID, $blog->getId());
     $post = PostPeer::doSelectOne($c);
     return $post ? $post->getCreatedAt(null) : 0;
 }
예제 #2
0
파일: PostPeer.php 프로젝트: rayku/rayku
 static function getFirstForThreadId($thread_id)
 {
     $c = new Criteria();
     $c->add(PostPeer::THREAD_ID, $thread_id);
     $c->addAscendingOrderByColumn(PostPeer::ID);
     $c->setLimit(1);
     return PostPeer::doSelectOne($c);
 }
예제 #3
0
파일: Thread.php 프로젝트: rayku/rayku
 /**
  * Gets the most recent post in the thread and stores it in $this->lastPost.
  * If it has already been stored, it doesn't fetch it again.
  * 
  * @return Post
  */
 public function getLastPost()
 {
     //If no lastPost is stored
     if (!$this->lastPost) {
         //Grab it
         $c = new Criteria();
         $c->add(PostPeer::THREAD_ID, $this->getId());
         $c->addDescendingOrderByColumn(PostPeer::UPDATED_AT);
         $this->lastPost = PostPeer::doSelectOne($c);
     }
     //Return it
     return $this->lastPost;
 }
예제 #4
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());
        }
    }
예제 #5
0
파일: _showThread.php 프로젝트: rayku/rayku
<div style="display: none;">
		<div id="inline1" style="width:630px;height:650px;overflow:auto;padding:25px" align="left">


 <div class="body-main">
    <div class="qa">
      <div class="ta">
<?php 
$_thread = explode("/", $_SERVER['REQUEST_URI']);
$_thread_id = $_thread[3];
$thread = ThreadPeer::retrieveByPK($_thread_id);
$c = new Criteria();
$c->add(PostPeer::THREAD_ID, $thread->getId());
$c->addAscendingOrderByColumn(PostPeer::ID);
$post = PostPeer::doSelectOne($c);
$logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id'];
if (!empty($logedUserId)) {
    $c = new Criteria();
    $c->add(UserPeer::ID, $logedUserId);
    $actionCheck = UserPeer::doSelectOne($c);
    if ($actionCheck->getType() == '5') {
        echo form_tag('@expertreply_thread?forum_id=' . $thread->getCategoryId() . '&thread_id=' . $thread->getId());
    } else {
        echo form_tag('@userreply_thread?forum_id=' . $thread->getCategoryId() . '&thread_id=' . $thread->getId());
    }
}
?>


예제 #6
0
 public function executeStats()
 {
     $stats = array();
     $c = new Criteria();
     // readers_cnt
     $date = date('Y-m-d', strtotime('-1 day'));
     $c->clear();
     $c->add(ReaderPeer::DATE, $date);
     $readers = ReaderPeer::doSelectOne($c);
     $cnt = $readers ? $readers->getCnt() : 0;
     $tcnt = $cnt % 100;
     $str = '';
     if ($tcnt == 1) {
         $str = 'osoba';
     } else {
         if ($tcnt >= 12 && $tcnt <= 14) {
             $str = 'osób';
         } else {
             if ($tcnt % 10 > 1 && $tcnt % 10 < 5) {
                 $str = 'osoby';
             } else {
                 $str = 'osób';
             }
         }
     }
     $stats['reader_cnt'] = $cnt == 0 ? 'brak danych' : sprintf('%d %s', $cnt, $str);
     // blog_cnt
     $c->clear();
     $c->add(BlogPeer::APPROVED, true);
     $stats['blog_cnt'] = BlogPeer::doCount($c);
     // post_cnt
     $c->clear();
     $c->add(PostPeer::DELETED, false);
     $stats['post_cnt'] = PostPeer::doCount($c);
     // month_avg
     $c->clear();
     $c->addAscendingOrderByColumn(PostPeer::CREATED_AT);
     $post = PostPeer::doSelectOne($c);
     $ots = $post ? $post->getCreatedAt(null) : time();
     $years = date('Y') - date('Y', $ots);
     $months = $years * 12 + (date('n') - date('n', $ots));
     $stats['month_avg'] = $months > 0 ? round($stats['post_cnt'] / $months) : 0;
     // assign
     $this->stats = $stats;
 }