示例#1
0
 static function getForExpertCategoryUserId($user_id)
 {
     $c = new Criteria();
     $c->add(ExpertCategoryPeer::USER_ID, $user_id);
     $c->addJoin(ExpertCategoryPeer::CATEGORY_ID, CategoryPeer::ID);
     return CategoryPeer::doSelect($c);
 }
示例#2
0
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(CategoryPeer::ID, $pks, Criteria::IN);
         $objs = CategoryPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
示例#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 executeProductCategoriesList()
 {
     $this->setLayout(false);
     $c = new Criteria();
     $this->categories = CategoryPeer::doSelect($c);
     $prodNum = array();
     foreach ($this->categories as $cat) {
         $id = $cat->getId();
         $products = Document::getChildrenOf($cat, "Product", false);
         // count ACTIVE childrens
         $cnt = 0;
         foreach ($products as $product) {
             if ($product->getPublicationStatus() == UtilsHelper::STATUS_ACTIVE) {
                 $cnt++;
             }
         }
         $prodNum[$id] = $cnt;
     }
     $this->prodNum = $prodNum;
     $this->currentId = $this->getRequestParameter("Category_id");
 }
示例#5
0
 public function executeCategories()
 {
     $this->user = $this->getRequestParameter('userid');
     $c = new Criteria();
     $c->addJoin(CategoryPeer::ID, ExpertCategoryPeer::CATEGORY_ID, Criteria::JOIN);
     $c->add(ExpertCategoryPeer::USER_ID, $this->getRequestParameter('userid'));
     $this->usercategories = CategoryPeer::doSelect($c);
     $cat = new Criteria();
     $subSelect = "category.id NOT IN (\n\t\t\tSELECT\n\t\t\t\t  category_id\n\t\t\tFROM\n\t\t\t\t  expert_category\n\t\t\tWHERE\n\t\t\t\t expert_category.user_id = " . $this->getRequestParameter('userid') . "\n\t\t\t)";
     $cat->add(CategoryPeer::ID, $subSelect, Criteria::CUSTOM);
     $this->unjoinedcategories = CategoryPeer::doSelect($cat);
 }
示例#6
0
 /**
  * Gets an array of Category objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this Category has previously been saved, it will retrieve
  * related CategorysRelatedByParentId from storage. If this Category is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array Category[]
  * @throws     PropelException
  */
 public function getCategorysRelatedByParentId($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(CategoryPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collCategorysRelatedByParentId === null) {
         if ($this->isNew()) {
             $this->collCategorysRelatedByParentId = array();
         } else {
             $criteria->add(CategoryPeer::PARENT_ID, $this->id);
             CategoryPeer::addSelectColumns($criteria);
             $this->collCategorysRelatedByParentId = CategoryPeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(CategoryPeer::PARENT_ID, $this->id);
             CategoryPeer::addSelectColumns($criteria);
             if (!isset($this->lastCategoryRelatedByParentIdCriteria) || !$this->lastCategoryRelatedByParentIdCriteria->equals($criteria)) {
                 $this->collCategorysRelatedByParentId = CategoryPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastCategoryRelatedByParentIdCriteria = $criteria;
     return $this->collCategorysRelatedByParentId;
 }
示例#7
0
    ?>
    <?php 
}
?>
    <div class="expert"><strong>Post:</strong></div>
    <div class="spacer"></div>
    <?php 
echo textarea_tag('post_body', '', array('style' => 'height: 130px; width: 100%;'));
?>
    <div class="spacer"></div>
    <?php 
if (empty($threadID)) {
    ?>
    <?php 
    $c = new Criteria();
    $categories = CategoryPeer::doSelect($c);
    ?>
    <div class="expert"><strong>Select category :</strong></div>
    <div class="spacer"></div>
    <select name="category_id">
      <?php 
    foreach ($categories as $categorie) {
        ?>
      <option value="<?php 
        echo $categorie->getId();
        ?>
">
      <?php 
        echo $categorie->getName();
        ?>
      </option>