/** * 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(WhiteboardSessionPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(WhiteboardSessionPeer::DATABASE_NAME); $criteria->add(WhiteboardSessionPeer::ID, $pks, Criteria::IN); $objs = WhiteboardSessionPeer::doSelect($criteria, $con); } return $objs; }
public function isWBSessionActive() { $criteria = new Criteria(); $criteria->add(WhiteboardSessionPeer::USER_ID, $this->getId()); $criteria->addDescendingOrderByColumn(WhiteboardSessionPeer::LAST_ACTIVITY); $lastSession = WhiteboardSessionPeer::doSelectOne($criteria); return $lastSession && $lastSession->stillActive(); }
public function execute($request) { RaykuCommon::getDatabaseConnection(); $currentUser = $this->getUser()->getRaykuUser(); $userId = $currentUser->getId(); $time = time(); $_SESSION["_modelbox"] = 0; @setcookie('_popupclose', '', time() - 300, '/', sfConfig::get('app_cookies_domain')); if (@$_SESSION['modelPopupOpen']) { unset($_SESSION['modelPopupOpen']); if ($_SESSION['popup_session']) { unset($_SESSION['popup_session']); } } $details = explode(",", $_REQUEST['details']); if (count($details) > 4) { $details[2] = base64_decode($details[2]); $peer = new StudentQuestionPeer(); $studentQuestion = $peer->retrieveByPk($this->getRequestParameter('questionId')); $questionId = $this->getRequestParameter('questionId'); $sessionService = new WhiteboardSessionService(); $session = $sessionService->connect($userId, $questionId); mysql_query("delete from user_expert where user_id = " . $userId) or die(mysql_error()); $this->getResponse()->setCookie('sessionToken', $session->getToken(), time() + 3600, '/', sfConfig::get('app_cookies_domain')); $expertId = $details[0]; $raykuCharge = $this->getRaykuCharge($expertId); $this->getResponse()->setCookie("raykuCharge", $raykuCharge, time() + 3600, '/', sfConfig::get('app_cookies_domain')); // redirect to rayku whiteboard $this->redirect(sfConfig::get('app_whiteboard_url') . '/'); } else { $criteria = new Criteria(); $criteria->add(WhiteboardSessionPeer::CHAT_ID, $details[1]); $tutorSession = WhiteboardSessionPeer::doSelectOne($criteria); $studentQuestion = $tutorSession->getStudentQuestion(); $student = $studentQuestion->getStudent(); $tutor = $studentQuestion->getTutor(); $this->getResponse()->setCookie('ratingExpertId', $tutor->getId(), time() + 3600, '/', sfConfig::get('app_cookies_domain')); $this->getResponse()->setCookie('ratingUserId', $student->getId(), time() + 3600, '/', sfConfig::get('app_cookies_domain')); $this->getResponse()->setCookie("askerpoints", $student->getPoints(), time() + 3600, '/', sfConfig::get('app_cookies_domain')); $this->getResponse()->setCookie("loginname", $student->getUsername(), time() + 3600, '/', sfConfig::get('app_cookies_domain')); $this->getResponse()->setCookie("check_nick", $student->getUsername(), time() + 3600, '/', sfConfig::get('app_cookies_domain')); $this->getResponse()->setCookie("chatid", $tutorSession->getChatId(), time() + 3600, '/', sfConfig::get('app_cookies_domain')); $sessionService = new WhiteboardSessionService(); $studentSession = $sessionService->connect($student->getId(), $studentQuestion->getId()); $studentSession->setChatId($tutorSession->getChatId()); $studentSession->save(); $this->getResponse()->setCookie("sessionToken", $studentSession->getToken(), time() + 3600, '/', sfConfig::get('app_cookies_domain')); $_record_id = $details[0]; $_queryRecord = mysql_query("select * from sendmessage where id = " . $_record_id . " ") or die(mysql_error()); if (mysql_num_rows($_queryRecord)) { $row = mysql_fetch_array($_queryRecord); $raykuCharge = $this->getRaykuCharge($row['expert_id']); $this->getResponse()->setCookie("raykuCharge", $raykuCharge, time() + 3600, '/', sfConfig::get('app_cookies_domain')); $this->getResponse()->setCookie("newredirect", 1, time() + 100, '/', sfConfig::get('app_cookies_domain')); $this->getResponse()->setCookie("redirection", "", time() - 600, '/', sfConfig::get('app_cookies_domain')); $this->getResponse()->setCookie("forumsub", "", time() - 600, '/', sfConfig::get('app_cookies_domain')); if (!empty($userId)) { mysql_query("insert into popup_close(user_id) values(" . $userId . ")") or die("error3" . mysql_error()); } if (!empty($details[0])) { mysql_query("delete from sendmessage where id = " . $details[0]) or die("error4" . mysql_error()); } // redirect to rayku whiteboard $this->redirect(sfConfig::get('app_whiteboard_url') . '/'); } else { $this->redirect('/dashboard'); } } }
/** * 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 = WhiteboardSessionPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setQuestionId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setUserId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setType($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setToken($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setChatId($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setLastActivity($arr[$keys[6]]); } }
</div> <div class="cn-column-four"> <p class="cn-pricepermin" align="center" style="margin-top:10px"> <?php $query = mysql_query("select * from popup_close where user_id=" . $newOne['userid']) or die(mysql_error()); $newFlag = ''; if (mysql_num_rows($query) > 0) { $newFlag = 1; } else { $newFlag = 2; } if ($onlinecheck == "online") { $criteria = new Criteria(); $criteria->add(WhiteboardSessionPeer::USER_ID, $newOne['userid']); $criteria->addDescendingOrderByColumn(WhiteboardSessionPeer::LAST_ACTIVITY); $lastSession = WhiteboardSessionPeer::doSelectOne($criteria); if ($lastSession != null && $lastSession->stillActive()) { ?> <a href="/message/compose/<?php echo $experts->getUsername(); ?> "><img alt="in session" src="<?php echo image_path('em-busy.jpg', false); ?> "></a> <?php } else { $_count_online_user += 1; $totcook = @$_COOKIE['cooktotal']; $w = 1; for ($u = 1; $u <= $totcook; $u++) {
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this User is new, it will return * an empty collection; or if this User has previously * been saved, it will retrieve related WhiteboardSessions from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in User. */ public function getWhiteboardSessionsJoinStudentQuestion($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { if ($criteria === null) { $criteria = new Criteria(UserPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collWhiteboardSessions === null) { if ($this->isNew()) { $this->collWhiteboardSessions = array(); } else { $criteria->add(WhiteboardSessionPeer::USER_ID, $this->id); $this->collWhiteboardSessions = WhiteboardSessionPeer::doSelectJoinStudentQuestion($criteria, $con, $join_behavior); } } else { // 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(WhiteboardSessionPeer::USER_ID, $this->id); if (!isset($this->lastWhiteboardSessionCriteria) || !$this->lastWhiteboardSessionCriteria->equals($criteria)) { $this->collWhiteboardSessions = WhiteboardSessionPeer::doSelectJoinStudentQuestion($criteria, $con, $join_behavior); } } $this->lastWhiteboardSessionCriteria = $criteria; return $this->collWhiteboardSessions; }