Ejemplo n.º 1
0
 public function executeAddArticleAndSave(sfWebRequest $request)
 {
     $article = new Article();
     $article->setTitle(__METHOD__ . '()');
     $category = CategoryPeer::retrieveByPK($request->getParameter('category_id'));
     $category->addArticle($article);
     $category->save();
     return sfView::NONE;
 }
 public function executeListArticle(sfWebRequest $request)
 {
     $this->categories = CategoryPeer::getActiveCategories();
     $this->current_category = CategoryPeer::retrieveByPK($request->getParameter('id'));
     $this->forward404If(!$this->current_category);
     $this->articles = ArticlePeer::getActiveArticles($this->current_category->getId());
     $this->paths = array();
     $this->paths[] = array('text' => $this->current_category->getName(), 'link' => $this->getController()->genUrl('sophiaStore/listArticle?id=' . $this->current_category->getId()));
     $pager = new sfPropelPager('Article', 10);
     $pager->setCriteria(new Criteria());
     $pager->setPage($this->getRequestParameter('page', 1));
     $pager->init();
     $this->pager = $pager;
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
 public function executeNewThread()
 {
     $this->User = $this->getUser()->getRaykuUser();
     if (!empty($_COOKIE['redirection'])) {
         $this->getResponse()->setCookie("redirection", "", time() - 600, '/', sfConfig::get('app_cookies_domain'));
     }
     $c = new Criteria();
     $c->add(ForumPeer::TYPE, 0);
     $this->publicforums = ForumPeer::doSelect($c);
     $this->category = CategoryPeer::retrieveByPK($this->getRequestParameter('forum_id'));
     if (!$this->category instanceof Category) {
         $this->category = ForumPeer::retrieveByPK($this->getRequestParameter('forum_id'));
     }
     $this->allcategories = CategoryPeer::doSelect($c = new Criteria());
     $user = $this->getUser()->getRaykuUser();
     if ($this->getRequestParameter('thread_title') != '') {
         $theard_title_len = strlen($this->getRequestParameter('thread_title'));
         $theard_body_len = strlen(strip_tags($this->getRequestParameter('post_body')));
         if ($theard_title_len >= 10 and $theard_body_len >= 10) {
             $school_grade = $this->getRequestParameter('school_grade');
             $tags = $this->getRequestParameter('tags');
             $arrayoftags = explode(',', $tags);
             foreach ($arrayoftags as $tag) {
                 if ($tag == 'I') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'a') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'about') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'an') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'are') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'as') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'at') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'be') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'by') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'com') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'de') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'en') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'for') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'from') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'how') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'in') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'is') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'it') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'la') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'of') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'on') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'or') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'that') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'the') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'this') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'to') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'was') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'what') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'when') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'where') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'who') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'will') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'with') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'und') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'the') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
                 if ($tag == 'www') {
                     $this->msg = $tag . ' is a stop word, please add the proper tag';
                     return sfView::SUCCESS;
                 }
             }
             $thread = $user->makeNewThread($this->getRequestParameter('forum_id'), $this->getRequestParameter('thread_title'), $this->getRequestParameter('post_body'), $this->getRequestParameter('forum_id'), $this->getRequestParameter('notify_email'), $this->getRequestParameter('notify_pm'), $this->getRequestParameter('tags'), $this->getRequestParameter('school_grade'), $this->getRequestParameter('stickie'));
             $l = new Criteria();
             $l->addDescendingOrderByColumn(PostPeer::ID);
             $l->setLimit(1);
             $latest = PostPeer::doSelect($l);
             $stickie = 0;
             if ($this->getRequestParameter('stickie') == 1) {
                 $stickie = 1;
             }
             ///////////////////updating the ip of the user
             $connection = RaykuCommon::getDatabaseConnection();
             mysql_query("update thread set user_ip='" . $_SERVER['REMOTE_ADDR'] . "', stickie = " . $stickie . " where id=" . $latest[0]->getThreadId() . "", $connection);
             ///////////////////updating the ip of the user
             return $this->redirect('@view_thread?thread_id=' . $latest[0]->getThreadId());
         } else {
             if ($theard_title_len < 10) {
                 $this->title_error = "Title should be more than 10 characters";
             }
             if ($theard_body_len < 10) {
                 $this->desc_error = "Description should be more than 10 characters";
             }
         }
     }
 }
Ejemplo n.º 5
0
 public function getCategory($con = null)
 {
     if ($this->aCategory === null && $this->category_id !== null) {
         include_once 'lib/model/om/BaseCategoryPeer.php';
         $this->aCategory = CategoryPeer::retrieveByPK($this->category_id, $con);
     }
     return $this->aCategory;
 }
Ejemplo n.º 6
0
 private function subscribeExpertToCategories($categories, User $user)
 {
     if (!is_array($categories)) {
         return;
     }
     foreach ($categories as $categoryid) {
         $category = CategoryPeer::retrieveByPK($categoryid);
         if (!$category) {
             continue;
         }
         $expertcat = new ExpertCategory();
         $expertcat->setUser($user);
         $expertcat->setCategory($category);
         $expertcat->save();
     }
 }
Ejemplo n.º 7
0
 public function getCategory($con = null)
 {
     if ($this->aCategory === null && $this->category_id !== null) {
         $this->aCategory = CategoryPeer::retrieveByPK($this->category_id, $con);
     }
     return $this->aCategory;
 }