Example #1
0
 /**
  * Action to display login page
  */
 public function executeIndex()
 {
     $connection = RaykuCommon::getDatabaseConnection();
     if ($this->getRequestParameter('username') == null) {
         $this->redirect("/dashboard");
     }
     $c = new Criteria();
     $c->add(UserPeer::USERNAME, $this->getRequestParameter('username'));
     $user = UserPeer::doSelectOne($c);
     $this->user = $user;
     $this->tutor_id = $user->getId();
     $c = new Criteria();
     $c->addJoin(ExpertCategoryPeer::USER_ID, UserTutorPeer::USERID, Criteria::INNER_JOIN);
     $rankexperts = ExpertCategoryPeer::doSelect($c);
     $rankUsers = array();
     $ji = 0;
     $eachExpertOnlyOnce = array();
     $rankScore = array();
     /**
      * @todo this loop parses all experts only to later use only one of them in template - fix this 
      */
     foreach ($rankexperts as $exp) {
         if (in_array($exp->getUserId(), $eachExpertOnlyOnce)) {
             continue;
         }
         $eachExpertOnlyOnce[] = $exp->getUserId();
         $query = mysql_query("select * from user_score where user_id=" . $exp->getUserId(), $connection) or die(mysql_error());
         $score = mysql_fetch_assoc($query);
         if ($score['score'] != 0) {
             $dv = new Criteria();
             $dv->add(UserPeer::ID, $exp->getUserId());
             $_thisUser = UserPeer::doSelectOne($dv);
             $rankUsers[$ji] = array("score" => $score['score'], "userid" => $exp->getUserId(), "createdat" => $_thisUser->getCreatedAt());
             $ji++;
         }
     }
     asort($rankUsers);
     arsort($rankUsers);
     $this->rankUsers = $rankUsers;
     //////////////////////////////
     if (!empty($_GET['expert_id'])) {
         $_expert_id = !empty($_GET['expert_id']) ? $_GET['expert_id'] : 0;
         $userId = $this->getUser()->getRaykuUserId();
         if ($_expert_id) {
             $query = mysql_query("select * from expert_subscribers where expert_id = " . $_expert_id . " and user_id =" . $userId, $connection) or die(mysql_error());
             if (mysql_num_rows($query) == 0) {
                 $_query = mysql_query("insert into expert_subscribers(expert_id, user_id) values(" . $_expert_id . ", " . $userId . ")", $connection) or die("Error--->" . mysql_error());
                 $queryScore = mysql_query("select * from user_score where user_id =" . $_expert_id, $connection) or die(mysql_error());
                 $rowScore = mysql_fetch_assoc($queryScore);
                 $newScore = '';
                 $newScore = $rowScore['score'] + 10;
                 mysql_query("update user_score set score = " . $newScore . " where user_id =" . $_expert_id, $connection) or die(mysql_error());
             }
         }
         $this->redirect("/tutor/" . $user->getUsername());
     }
     if ($this->getRequestParameter('content') != null) {
         $this->expertid = $this->getUser()->getRaykuUser()->getId();
         $this->expertusr = $this->getUser()->getRaykuUser()->getUsername();
         $this->content = $this->getRequestParameter('content');
         $c = new Criteria();
         $c->add(ExpertsPromoTextPeer::EXP_ID, $this->expertid);
         $expertstext = ExpertsPromoTextPeer::doSelectOne($c);
         if ($expertstext != null) {
             $expertstext->setContent($this->content);
             $expertstext->save();
         } else {
             $promo = new ExpertsPromoText();
             $promo->setExpId($this->expertid);
             $promo->setContent($this->content);
             $promo->save();
         }
     }
     $this->expert = $user;
     $f = new Criteria();
     $f->add(PostPeer::POSTER_ID, $user->getId());
     $f->add(PostPeer::BEST_RESPONSE, '1');
     $f->addDescendingOrderByColumn('ID');
     $this->bestResponses = PostPeer::doSelect($f);
     $f->setLimit(6);
     $this->best_responses = PostPeer::doSelect($f);
     $expertId = $user->getId();
     $userId = $this->getUser()->getRaykuUserId();
     $this->currentUser = $this->getUser()->getRaykuUser();
     // last n whiteboard sessions
     $cLastSessions = new Criteria();
     if ($userId != $expertId) {
         $cPublicA = $cLastSessions->getNewCriterion(WhiteboardChatPeer::EXPERT_ID, $expertId);
         $cPublicB = $cLastSessions->getNewCriterion(WhiteboardChatPeer::IS_PUBLIC, true);
         $cPublicC = $cLastSessions->getNewCriterion(WhiteboardChatPeer::ASKER_ID, $userId);
         $cPublicB->addOr($cPublicC);
         $cPublicA->addAnd($cPublicB);
     } else {
         $cPublicA = $cLastSessions->getNewCriterion(WhiteboardChatPeer::EXPERT_ID, $userId);
         $cPublicB = $cLastSessions->getNewCriterion(WhiteboardChatPeer::ASKER_ID, $userId);
         $cPublicA->addOr($cPublicB);
     }
     $cLastSessions->add($cPublicA);
     $cLastSessions->add(WhiteboardChatPeer::STARTED_AT, null, Criteria::ISNOTNULL);
     $cLastSessions->addDescendingOrderByColumn(WhiteboardChatPeer::ID);
     $this->totalSessions = WhiteboardChatPeer::doSelect($cLastSessions);
     $cLastSessions->setLimit(3);
     $this->lastSessions = WhiteboardChatPeer::doSelect($cLastSessions);
 }
Example #2
0
      <h3>How I add value?
<?php 
        $_currentUserId = $currentUser->getId();
        if ($expert->getId() == $_currentUserId) {
            ?>
    <a id="promotionalText" href="#promotionalMsg" >[edit]</a>
        <?php 
        }
    }
    ?>
      </h3>
      <?php 
}
$c = new Criteria();
$c->add(ExpertsPromoTextPeer::EXP_ID, $expert->getId());
$promotext = ExpertsPromoTextPeer::doSelectOne($c);
?>
      <?php 
if ($promotext != NULL) {
    echo $promotext->getContent();
} elseif ($expert->isTutorStatusEnabled()) {
    ?>
      <p>Welcome to my portfolio profile. I am a new expert at Rayku so you may not be able to see much on this page. Though, if you have a question that's within my field, I'm sure I can help you out!<br />
        <br />
        If I'm online, connect with me! If not, feel free to leave me a message and I'll get back to you. </p>
      <?php 
}
?>
    </div>
    <!--add value box ends-->
    <div style="display: none;">
Example #3
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 = ExpertsPromoTextPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setExpId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setContent($arr[$keys[2]]);
     }
 }
Example #4
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(ExpertsPromoTextPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(ExpertsPromoTextPeer::DATABASE_NAME);
         $criteria->add(ExpertsPromoTextPeer::ID, $pks, Criteria::IN);
         $objs = ExpertsPromoTextPeer::doSelect($criteria, $con);
     }
     return $objs;
 }