static function getOneForExpertCategoryUserId($user_id) { $c = new Criteria(); $c->add(ExpertCategoryPeer::USER_ID, $user_id); $c->addJoin(ExpertCategoryPeer::CATEGORY_ID, CategoryPeer::ID); return CategoryPeer::doSelectOne($c); }
/** * all members database */ public function execute($request) { RaykuCommon::getDatabaseConnection(); $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id']; $currentUser = $this->getUser()->getRaykuUser(); $userId = $currentUser->getId(); $this->userId = $currentUser->getId(); /* Clearing Cookies if($_COOKIE['onoff'] != 1) { for($u=$_COOKIE['cookcount'];$u>=1;$u--) { $cookname = 'tutor_'.$u; setcookie($cookname,'', time()-3600, "/"); } setcookie("tutorcount",'', time()-3600, "/"); setcookie("cookcount",'', time()-3600, "/"); } /* Clearing Cookies */ $time = time(); if (!empty($_POST['hidden'])) { $count = count($_POST['checkbox']); /* Clearing Cookies */ for ($u = $_COOKIE['cookcount']; $u >= 1; $u--) { $cookname = 'tutor_' . $u; $this->getResponse()->setCookie($cookname, '', time() - 3600, '/', sfConfig::get('app_cookies_domain')); } $this->getResponse()->setCookie("tutorcount", '', time() - 3600, '/', sfConfig::get('app_cookies_domain')); $this->getResponse()->setCookie("cookcount", '', time() - 3600, '/', sfConfig::get('app_cookies_domain')); /* Clearing Cookies */ if ($count == 4) { $close = 46000; $_SESSION['connected_tutors'] = 4; } if ($count == 3) { $close = 46000; $_SESSION['connected_tutors'] = 3; } else { if ($count == 2) { $close = 61000; $_SESSION['connected_tutors'] = 2; } else { if ($count == 1) { $close = 61000; $_SESSION['connected_tutors'] = 1; } else { $close = 61000; $_SESSION['connected_tutors'] = 1; } } } $j = 0; for ($i = 0; $i < $count; $i++) { mysql_query("INSERT INTO `user_expert` (`user_id`, `checked_id`, `category_id`, `question`, `exe_order`, `time`, status, close) VALUES ('" . $userId . "', '" . $_POST['checkbox'][$i] . "', '5', 'To be discussed','" . ++$j . "', '" . $time . "', 1, " . $close . ") ") or die(mysql_error()); } /* Notify same tutor again */ $l = 0; $source = 'tutorlist'; mysql_query("DELETE FROM `student_questions` WHERE user_id=" . $userId . ""); for ($i = 0; $i < $count; $i++) { mysql_query("INSERT INTO `student_questions` (`user_id`, `checked_id`, `category_id`, `question`, `exe_order`, `time`, status, close, source) VALUES ('" . $userId . "', '" . $_POST['checkbox'][$i] . "', '5', 'To be discussed','" . ++$l . "', '" . $time . "', 1, " . $close . ", '" . $source . "') ") or die(mysql_error()); } setcookie("asker_que", $_SESSION['question'], time() + 600, "/", sfConfig::get('app_cookies_domain')); $this->getResponse()->setCookie("redirection", 1, time() + 600, '/', sfConfig::get('app_cookies_domain')); $this->getResponse()->setCookie("forumsub", 1, time() + 600, '/', sfConfig::get('app_cookies_domain')); $this->redirect('expertmanager/connect'); } $this->cat = $this->getRequestParameter('category'); $this->course_id = $this->getRequestParameter('course'); if (empty($this->course_id)) { $this->course_id = 1; } if (empty($this->cat)) { $this->cat = 1; } $queryPoints = mysql_query("select * from user where id=" . $userId) or die("Error In rate" . mysql_error()); if (mysql_num_rows($queryPoints) > 0) { $rowPoints = mysql_fetch_assoc($queryPoints); $_points = $rowPoints['points']; } $c = new Criteria(); $c->addJoin(ExpertCategoryPeer::USER_ID, UserTutorPeer::USERID, Criteria::INNER_JOIN); if ($this->cat == 5) { $experts = ExpertCategoryPeer::doSelect($c); } else { $c->add(ExpertCategoryPeer::CATEGORY_ID, $this->cat); $experts = ExpertCategoryPeer::doSelect($c); } $newUser = array(); $i = 0; $eachExpertOnlyOnce = array(); foreach ($experts as $exp) { if (in_array($exp->getUserId(), $eachExpertOnlyOnce)) { continue; } $eachExpertOnlyOnce[] = $exp->getUserId(); $_queryCourse = mysql_query("select * from expert_course where user_id =" . $exp->getUserId() . " and category_id = 1 and course_id = " . $this->course_id . " ") or die("Er-1-->" . mysql_error()); if (mysql_num_rows($_queryCourse) > 0) { $query = mysql_query("select * from user_score where user_id=" . $exp->getUserId()) or die(mysql_error()); $score = mysql_fetch_assoc($query); if ($score['score'] != 0) { if (false) { //$_points == '' || $_points == '0.00' Temporary hack $emptyRCquery = mysql_query("select * from user_rate where userid=" . $exp->getUserId() . " and (rate = 0.00 || rate = 0) ") or die("Error In rate" . mysql_error()); if (mysql_num_rows($emptyRCquery) > 0) { $dv = new Criteria(); $dv->add(UserPeer::ID, $exp->getUserId()); $_thisUser = UserPeer::doSelectOne($dv); $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt()); $i++; } } else { $dv = new Criteria(); $dv->add(UserPeer::ID, $exp->getUserId()); $_thisUser = UserPeer::doSelectOne($dv); $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt()); $i++; } } } } asort($newUser); arsort($newUser); $this->rankCheckUsers = $newUser; ////if no online expert available redirecting to the board page $onlineusers = array(); $offlineusers = array(); $newOnlineUser = array(); $newOfflineUser = array(); $j = 0; $k = 0; $facebookResponse = BotServiceProvider::createFor(sfConfig::get('app_facebook_url') . "/tutor")->getContent(); $facebookUsers = json_decode($facebookResponse, true); $botResponse = BotServiceProvider::createFor(sfConfig::get('app_notification_bot_url') . "/tutor")->getContent(); $botUsers = json_decode($botResponse, true); foreach ($newUser as $new) { $a = new Criteria(); $a->add(UserPeer::ID, $new['userid']); $users_online = UserPeer::doSelectOne($a); $onlinecheck = ''; if ($users_online->isOnline()) { $onlinecheck = "online"; } if (empty($onlinecheck)) { $userGtalk = $users_online->getUserGtalk(); if ($userGtalk) { $onlinecheck = BotServiceProvider::createFor(sfConfig::get('app_rayku_url') . ':' . sfConfig::get('app_g_chat_port') . '/status/' . $userGtalk->getGtalkid())->getContent(); } } if ((empty($onlinecheck) || $onlinecheck != "online") && is_array($facebookUsers)) { $fb_query = mysql_query("select * from user_fb where userid=" . $new['userid']) or die(mysql_error()); if (mysql_num_rows($fb_query) > 0) { $fbRow = mysql_fetch_assoc($fb_query); $fb_username = $fbRow['fb_username']; foreach ($facebookUsers as $key => $user) { if ($user['username'] == $fb_username) { $onlinecheck = 'online'; break; } } } } if ((empty($onlinecheck) || $onlinecheck != "online") && is_array($botUsers)) { foreach ($botUsers as $key => $_user) { if ($_user['email'] == $users_online->getEmail()) { $onlinecheck = 'online'; break; } } } if ($onlinecheck == "online") { $onlineusers[$j] = $new['userid']; $newOnlineUser[$j] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']); $j++; } elseif ($users_online->isOnline()) { $newOnlineUser[$j] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']); $onlineusers[$j] = $new['userid']; $j++; } else { $newOfflineUser[$k] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']); $offlineusers[$k] = $new['userid']; $k++; } } $this->newOnlineUser = $newOnlineUser; $this->newOfflineUser = $newOfflineUser; $this->_checkOnlineUsers = $onlineusers; ///////////////////////////////////////////////////// if (isset($_COOKIE["onoff"]) && $_COOKIE["onoff"] == 1) { if (!empty($_COOKIE["school"])) { $cookieSchool = array(); $m = 0; foreach ($newOnlineUser as $new) { $b = new Criteria(); $b->add(UserPeer::ID, $new['userid']); $schoolusers = UserPeer::doSelectOne($b); $mail = explode("@", $schoolusers->getEmail()); $newMail = explode(".", $mail[1]); if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) { $cookieSchool[$m] = $new; $m++; } } $this->expert_cats = $cookieSchool; } else { $this->expert_cats = $newOnlineUser; } } else { if (isset($_COOKIE["onoff"]) && $_COOKIE["onoff"] == 2) { if (!empty($_COOKIE["school"])) { $cookieSchool = array(); $m = 0; foreach ($newOfflineUser as $new) { $b = new Criteria(); $b->add(UserPeer::ID, $new['userid']); $schoolusers = UserPeer::doSelectOne($b); $mail = explode("@", $schoolusers->getEmail()); $newMail = explode(".", $mail[1]); if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) { $cookieSchool[$m] = $new; $m++; } } $this->expert_cats = $cookieSchool; } else { $this->expert_cats = $newOfflineUser; } } else { if (!empty($_COOKIE["school"])) { $cookieSchool = array(); $m = 0; foreach ($newUser as $new) { $b = new Criteria(); $b->add(UserPeer::ID, $new['userid']); $schoolusers = UserPeer::doSelectOne($b); $mail = explode("@", $schoolusers->getEmail()); $newMail = explode(".", $mail[1]); if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) { $cookieSchool[$m] = $new; $m++; } } $this->expert_cats = $cookieSchool; } else { $this->expert_cats = $newUser; } } } $this->tutorsCount = count($this->expert_cats); $c = new Criteria(); $c->add(CategoryPeer::ID, $this->cat); $this->e = CategoryPeer::doSelectOne($c); }
public function getCategory(PropelPDO $con = null) { if ($this->aCategory === null && $this->category_id !== null) { $c = new Criteria(CategoryPeer::DATABASE_NAME); $c->add(CategoryPeer::ID, $this->category_id); $this->aCategory = CategoryPeer::doSelectOne($c, $con); } return $this->aCategory; }
<?php /* * This file is part of the symfony package. * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ $app = 'frontend'; $fixtures = 'fixtures/fixtures.yml'; if (!(include dirname(__FILE__) . '/../bootstrap/functional.php')) { return; } $b = new sfTestFunctional(new sfBrowser(), null, array('propel' => 'sfTesterPropel')); ArticlePeer::doDeleteAll(); $c = CategoryPeer::doSelectOne(new Criteria()); $hash = spl_object_hash($c); $b->get('/pooling/addArticleButDontSave/category_id/' . $c->getId())->with('propel')->check('Article', null, 0)->get('/pooling/addArticleAndSave/category_id/' . $c->getId())->with('propel')->check('Article', null, 1);
public function execute($request) { $connection = RaykuCommon::getDatabaseConnection(); $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id']; $currentUser = $this->getUser()->getRaykuUser(); $userId = $currentUser->getId(); $this->userId = $currentUser->getId(); $time = time(); if (empty($_SESSION["course_id"])) { $_SESSION["course_id"] = '1'; } $this->cat = $this->getRequestParameter('category'); $this->course_id = $this->getRequestParameter('course'); if (empty($this->course_id)) { if (!empty($_SESSION['course_id'])) { $this->course_id = $_SESSION['course_id']; } else { $this->course_id = 1; } } else { $_SESSION['course_id'] = $this->course_id; } if (empty($this->cat)) { if (!empty($_SESSION['subject'])) { $this->cat = $_SESSION['subject']; } else { $this->cat = 1; } } else { $_SESSION['subject'] = $this->cat; } $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id']; $c = new Criteria(); $c->addJoin(ExpertCategoryPeer::USER_ID, UserTutorPeer::USERID, Criteria::INNER_JOIN); if ($this->cat == 5) { $experts = ExpertCategoryPeer::doSelect($c); } else { $c->add(ExpertCategoryPeer::CATEGORY_ID, $this->cat); $experts = ExpertCategoryPeer::doSelect($c); } $queryPoints = mysql_query("select * from user where id = " . $userId, $connection) or die("Error In rate" . mysql_error()); if (mysql_num_rows($queryPoints) > 0) { $rowPoints = mysql_fetch_assoc($queryPoints); $_points = $rowPoints['points']; } $newUser = array(); $i = 0; $eachExpertOnlyOnce = array(); foreach ($experts as $exp) { if ($userId != $exp->getUserId()) { if (in_array($exp->getUserId(), $eachExpertOnlyOnce)) { continue; } $eachExpertOnlyOnce[] = $exp->getUserId(); /* Testing - Student match with Tutors */ $_queryCourse = ''; $tutorsq = mysql_query("select * from tutor_profile where category = 1 and user_id = " . $exp->getUserId() . "", $connection) or die("Er-1-->" . mysql_error()); $tutors = mysql_fetch_array($tutorsq); $tutor = ''; $tutor = explode("-", $tutors['course_id']); if (in_array($_SESSION["course_id"], $tutor)) { $_queryCourse = mysql_query("select * from tutor_profile where category = 1 and user_id = " . $exp->getUserId() . "", $connection) or die("Er-1-->" . mysql_error()); //echo "select * from tutor_profile where category = 1 and user_id = ".$exp->getUserId().""; } if (@mysql_num_rows($_queryCourse) > 0) { $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) { if ($_points == '' || $_points == '0.00') { $emptyRCquery = mysql_query("select * from user_rate where userid = " . $exp->getUserId() . " and (rate = 0.00 || rate = 0) ", $connection) or die("Error In rate" . mysql_error()); if (mysql_num_rows($emptyRCquery) > 0) { $dv = new Criteria(); $dv->add(UserPeer::ID, $exp->getUserId()); $_thisUser = UserPeer::doSelectOne($dv); $rankUsersFinal[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt()); $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt()); $i++; } } else { $dv = new Criteria(); $dv->add(UserPeer::ID, $exp->getUserId()); $_thisUser = UserPeer::doSelectOne($dv); $rankUsersFinal[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt()); $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt()); $i++; } } } } } asort($newUser); arsort($newUser); asort($rankUsersFinal); arsort($rankUsersFinal); $this->rankCheckUsers = $rankUsersFinal; ////if no online expert available redirecting to the board page // // ant-edit remove for now $onlineusers = array(); $offlineusers = array(); $newOnlineUser = array(); $newOfflineUser = array(); $j = 0; $k = 0; // $facebookTutors = BotServiceProvider::createFor("http://facebook.rayku.com/tutor")->getContent(); // $onlineTutorsByNotificationBot = BotServiceProvider::createFor("http://notification-bot.rayku.com/tutor")->getContent(); foreach ($newUser as $new) { $a = new Criteria(); $a->add(UserPeer::ID, $new['userid']); $users_online = UserPeer::doSelectOne($a); $onlinecheck = ''; if ($users_online->isOnline()) { $onlinecheck = "online"; } // ant-edit remove for now if (empty($onlinecheck)) { $userGtalk = $users_online->getUserGtalk(); if ($userGtalk) { $onlinecheck = BotServiceProvider::createFor(sfConfig::get('app_rayku_url') . ':' . sfConfig::get('app_g_chat_port') . '/status/' . $userGtalk->getGtalkid())->getContent(); // echo 'hello ' . $onlinecheck ; } } // if (empty($onlinecheck) || ($onlinecheck != "online")) { // $userFb = UserFbPeer::retrieveByUserId($new['userid']); // if ($userFb) { // $fb_username = $userFb->getFbUsername(); // $Users = json_decode($facebookTutors, true); // foreach ($Users as $key => $user) { // if ($user['username'] == $fb_username) { // $onlinecheck = 'online'; // break; // } // } // } // } // if (empty($onlinecheck) || ($onlinecheck != "online")) { // $_Users = json_decode($onlineTutorsByNotificationBot, true); // foreach ($_Users as $key => $_user) { // if ($_user['email'] == $users_online->getEmail()) { // $onlinecheck = 'online'; // break; // } // } // } if ($onlinecheck == "online") { $onlineusers[$j] = $new['userid']; $newOnlineUser[$j] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']); $j++; } elseif ($users_online->isOnline()) { $newOnlineUser[$j] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']); $onlineusers[$j] = $new['userid']; $j++; } else { $newOfflineUser[$k] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']); $offlineusers[$k] = $new['userid']; $k++; } } $this->newOnlineUser = $newOnlineUser; $this->newOfflineUser = $newOfflineUser; $this->_checkOnlineUsers = $onlineusers; if (count($onlineusers) < 1) { $this->redirect('/forum/newthread/' . $_SESSION['subject'] . '?exp_online = 1'); } $onoff = isset($_COOKIE["onoff"]) ? $_COOKIE["onoff"] : null; if ($onoff == 1) { if (!empty($_COOKIE["school"])) { $cookieSchool = array(); $m = 0; foreach ($newOnlineUser as $new) { $b = new Criteria(); $b->add(UserPeer::ID, $new['userid']); $schoolusers = UserPeer::doSelectOne($b); $mail = explode("@", $schoolusers->getEmail()); $newMail = explode(".", $mail[1]); if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) { $cookieSchool[$m] = $new; $m++; } } $this->expert_cats = $cookieSchool; } else { $this->expert_cats = $newOnlineUser; } } else { if ($onoff == 2) { if (!empty($_COOKIE["school"])) { $cookieSchool = array(); $m = 0; foreach ($newOfflineUser as $new) { $b = new Criteria(); $b->add(UserPeer::ID, $new['userid']); $schoolusers = UserPeer::doSelectOne($b); $mail = explode("@", $schoolusers->getEmail()); $newMail = explode(".", $mail[1]); if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) { $cookieSchool[$m] = $new; $m++; } } $this->expert_cats = $cookieSchool; } else { $this->expert_cats = $newOfflineUser; } } else { if (!empty($_COOKIE["school"])) { $cookieSchool = array(); $m = 0; foreach ($newUser as $new) { $b = new Criteria(); $b->add(UserPeer::ID, $new['userid']); $schoolusers = UserPeer::doSelectOne($b); $mail = explode("@", $schoolusers->getEmail()); $newMail = explode(".", $mail[1]); if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) { $cookieSchool[$m] = $new; $m++; } } $this->expert_cats = $cookieSchool; } else { $this->expert_cats = $newUser; } } } $this->tutorsCount = count($this->expert_cats); $c = new Criteria(); $c->add(CategoryPeer::ID, $this->cat); $this->e = CategoryPeer::doSelectOne($c); }
public function execute($request) { $connection = RaykuCommon::getDatabaseConnection(); $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id']; $currentUser = $this->getUser()->getRaykuUser(); $userId = $currentUser->getId(); $this->userId = $currentUser->getId(); $time = time(); $this->cat = $this->getRequestParameter('category'); $this->course_id = $this->getRequestParameter('course'); if (empty($this->course_id)) { if (!empty($_SESSION['course_id'])) { $this->course_id = $_SESSION['course_id']; } else { $this->course_id = 1; } } else { $_SESSION['course_id'] = $this->course_id; } if (empty($this->cat)) { if (!empty($_SESSION['subject'])) { $this->cat = $_SESSION['subject']; } else { $this->cat = 1; } } else { $_SESSION['subject'] = $this->cat; } if (empty($_SESSION["course_id"])) { $_SESSION["course_id"] = '1'; } /* Quick Registration Users - Listing Tutors */ if ($this->studentFromQuickRegistrationAskingAQuestion()) { $_dash_question = ''; $_dash_course_id = ''; $_school = ''; $_dash_education = ''; $_dash_code_id = ''; $_dash_year = ''; $_SESSION['subject'] = 1; $_dash_education = $_SESSION['edu']; $_dash_course_id = $_SESSION['course_id']; if ($_dash_course_id) { $queryCname = mysql_query("select * from courses where id ='" . $_dash_course_id . "'", $connection) or die(mysql_error()); $rowCoursename = mysql_fetch_array($queryCname); $_SESSION['course_name_sess'] = $rowCoursename['course_name']; } if (strtolower($_SESSION['year']) != "Choose year") { $_dash_year = trim($_SESSION['year']); } elseif (strtolower($_SESSION['grade']) != "Choose grade") { $_dash_year = trim($_SESSION['grade']); } $c = new Criteria(); $c->add(UserQuestionTagPeer::CATEGORY_ID, 1); $c->add(UserQuestionTagPeer::USER_ID, $userId); $c->add(UserQuestionTagPeer::COURSE_ID, $_dash_course_id); $c->add(UserQuestionTagPeer::COURSE_CODE, $_dash_code_id); $c->add(UserQuestionTagPeer::EDUCATION, $_dash_education); $c->add(UserQuestionTagPeer::SCHOOL, $_school); $c->add(UserQuestionTagPeer::YEAR, $_dash_year); $userQuestionTag = UserQuestionTagPeer::doSelectOne($c); if ($userQuestionTag) { $userQuestionTag->delete(); } $userQuestionTag = new UserQuestionTag(); $userQuestionTag->setUserId($userId); $userQuestionTag->setCategoryId(1); $userQuestionTag->setCourseId($_dash_course_id); $userQuestionTag->setCourseCode($_dash_code_id); $userQuestionTag->setEducation($_dash_education); $userQuestionTag->setSchool($_school); $userQuestionTag->setYear($_dash_year); $userQuestionTag->setQuestion($_SESSION['question']); $userQuestionTag->save(); } else { if ($this->loggedStudentAsksAQuestion()) { $_dash_question = ''; $_dash_course_id = ''; $_school = ''; $_dash_education = ''; $_dash_code_id = ''; $_dash_year = ''; $_dash_question = $_POST['question']; $_SESSION['question'] = $_dash_question; $_SESSION['subject'] = 1; if (!empty($_POST['course_category_hidden'])) { $course_name = trim($_POST['course_category_hidden']); $_SESSION['course_name_sess'] = $course_name; $_queryCourse = mysql_query("select * from courses where course_name ='" . $course_name . "' ", $connection) or die(mysql_error()); $_rowCourse = mysql_fetch_assoc($_queryCourse); $_dash_course_id = $_rowCourse['id']; $_SESSION["course_id"] = $_dash_course_id; } $_dash_education = $_POST['edu']; /* Student Confirmation */ $_SESSION['edu'] = $_dash_education; if (strtolower($_POST['year_hidden']) != "choose year") { $_dash_year = trim($_POST['year_hidden']); /* student confirmation */ $_SESSION['year'] = $_dash_year; } elseif (strtolower($_POST['grade_hidden']) != "choose grade") { $_dash_year = trim($_POST['grade_hidden']); /* student confirmation */ $_SESSION['grade'] = $_dash_year; } $c = new Criteria(); $c->add(UserQuestionTagPeer::CATEGORY_ID, 1); $c->add(UserQuestionTagPeer::USER_ID, $userId); $c->add(UserQuestionTagPeer::COURSE_ID, $_dash_course_id); $c->add(UserQuestionTagPeer::COURSE_CODE, $_dash_code_id); $c->add(UserQuestionTagPeer::EDUCATION, $_dash_education); $c->add(UserQuestionTagPeer::SCHOOL, $_school); $c->add(UserQuestionTagPeer::YEAR, $_dash_year); $userQuestionTag = UserQuestionTagPeer::doSelectOne($c); if ($userQuestionTag) { $userQuestionTag->delete(); } $userQuestionTag = new UserQuestionTag(); $userQuestionTag->setUserId($userId); $userQuestionTag->setCategoryId(1); $userQuestionTag->setCourseId($_dash_course_id); $userQuestionTag->setCourseCode($_dash_code_id); $userQuestionTag->setEducation($_dash_education); $userQuestionTag->setSchool($_school); $userQuestionTag->setYear($_dash_year); $userQuestionTag->setQuestion($_POST['question']); $userQuestionTag->save(); } } /** * @todo - below block of code could be extracted to separate action */ if (!empty($_POST['hidden'])) { $count = count($_POST['checkbox']); /* Clearing Cookies */ if (isset($_COOKIE['cookcount'])) { for ($u = $_COOKIE['cookcount']; $u >= 1; $u--) { $cookname = 'expert_' . $u; setcookie($cookname, '', time() - 3600, "/", sfConfig::get('app_cookies_domain')); } } setcookie("expertscount", '', time() - 3600, "/", sfConfig::get('app_cookies_domain')); setcookie("cooktotal", '', time() - 3600, "/", sfConfig::get('app_cookies_domain')); /* Clearing Cookies */ if ($count == 4) { $close = 46000; $_SESSION['connected_tutors'] = 4; } else { if ($count == 3) { $close = 46000; $_SESSION['connected_tutors'] = 3; } else { if ($count == 2) { $close = 61000; $_SESSION['connected_tutors'] = 2; } else { if ($count == 1) { $close = 61000; $_SESSION['connected_tutors'] = 1; } else { $close = 61000; $_SESSION['connected_tutors'] = 1; } } } } $j = 0; $c = new Criteria(); $c->add(UserQuestionTagPeer::USER_ID, $userId); $c->addDescendingOrderByColumn(UserQuestionTagPeer::ID); $userQuestionTag = UserQuestionTagPeer::doSelectOne($c); $course_code = ''; $year = ''; $course_id = '1'; $school = ''; if ($userQuestionTag) { $course_id = $userQuestionTag->getCourseId(); $course_code = $userQuestionTag->getCourseCode(); $year = $userQuestionTag->getYear(); $school = $userQuestionTag->getSchool(); if ($userQuestionTag->getEducation() == 2) { $school = "High School"; } } // this is where the sql injection error is happening, fix this // escape single quotes for ($i = 0; $i < $count; $i++) { mysql_query("INSERT INTO `user_expert` (`user_id`, `checked_id`, `category_id`, course_id, `question`, `exe_order`, `time`,course_code, year, school, status, close) VALUES ('" . mysql_real_escape_string($userId) . "', '" . mysql_real_escape_string($_POST['checkbox'][$i]) . "', " . mysql_real_escape_string($this->cat) . ", " . mysql_real_escape_string($course_id) . ",'" . mysql_real_escape_string($_SESSION['question']) . "','" . mysql_real_escape_string(++$j) . "', '" . mysql_real_escape_string($time) . "', '" . mysql_real_escape_string($course_code) . "', '" . mysql_real_escape_string($year) . "', '" . mysql_real_escape_string($school) . "', 1, " . mysql_real_escape_string($close) . ") ", $connection) or die("Error In Insert-->" . mysql_error()); } /* Notify same tutor again */ $l = 0; $source = 'expertmanager'; mysql_query("DELETE FROM `student_questions` WHERE user_id = " . $userId . "", $connection); for ($i = 0; $i < $count; $i++) { $question = new StudentQuestion(); $question->setStudentId($userId); $question->setTutorId($_POST['checkbox'][$i]); $question->setCategoryId($this->cat); $question->setCourseId($course_id); $question->setQuestion($_SESSION['question']); $question->setExeOrder(++$l); $question->setTime($time); $question->setCourseCode($course_code); $question->setYear($year); $question->setSchool($school); $question->setStatus(1); $question->setClose($close); $question->setSource($source); $question->save(); } setcookie("asker_que", urldecode($_SESSION['question']), time() + 600, "/", sfConfig::get('app_cookies_domain')); $this->getResponse()->setCookie("redirection", 1, time() + 600, '/', sfConfig::get('app_cookies_domain')); $this->getResponse()->setCookie("forumsub", $_SESSION['subject'], time() + 600, '/', sfConfig::get('app_cookies_domain')); $this->redirect('expertmanager/connect'); } $logedUserId = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id']; $c = new Criteria(); $c->addJoin(ExpertCategoryPeer::USER_ID, UserTutorPeer::USERID, Criteria::INNER_JOIN); if ($this->cat == 5) { $experts = ExpertCategoryPeer::doSelect($c); } else { $c->add(ExpertCategoryPeer::CATEGORY_ID, $this->cat); $experts = ExpertCategoryPeer::doSelect($c); } $queryPoints = mysql_query("select * from user where id = " . $userId, $connection) or die("Error In rate" . mysql_error()); if (mysql_num_rows($queryPoints) > 0) { $rowPoints = mysql_fetch_assoc($queryPoints); $_points = $rowPoints['points']; } $newUser = array(); $i = 0; $eachExpertOnlyOnce = array(); foreach ($experts as $exp) { if ($userId != $exp->getUserId()) { if (in_array($exp->getUserId(), $eachExpertOnlyOnce)) { continue; } $eachExpertOnlyOnce[] = $exp->getUserId(); $_queryCourse = ''; $tutorsq = mysql_query("select * from tutor_profile where category = 1 and user_id = " . $exp->getUserId() . "", $connection) or die("Er-1-->" . mysql_error()); $tutors = mysql_fetch_array($tutorsq); $tutor = ''; $tutor = explode("-", $tutors['course_id']); if (in_array($_SESSION["course_id"], $tutor)) { $_queryCourse = mysql_query("select * from tutor_profile where category = 1 and user_id = " . $exp->getUserId() . "", $connection) or die("Er-1-->" . mysql_error()); } if ($_queryCourse && mysql_num_rows($_queryCourse) > 0) { $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) { if ($_points == '' || $_points == '0.00') { $emptyRCquery = mysql_query("select * from user_rate where userid = " . $exp->getUserId() . " and (rate = 0.00 || rate = 0) ", $connection) or die("Error In rate" . mysql_error()); if (mysql_num_rows($emptyRCquery) > 0) { $dv = new Criteria(); $dv->add(UserPeer::ID, $exp->getUserId()); $_thisUser = UserPeer::doSelectOne($dv); $rankUsersFinal[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt()); $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt()); $i++; } } else { $dv = new Criteria(); $dv->add(UserPeer::ID, $exp->getUserId()); $_thisUser = UserPeer::doSelectOne($dv); $rankUsersFinal[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt()); $newUser[$i] = array("score" => $score['score'], "userid" => $exp->getUserId(), "category" => $this->cat, "createdat" => $_thisUser->getCreatedAt()); $i++; } } } } } asort($newUser); arsort($newUser); asort($rankUsersFinal); arsort($rankUsersFinal); $this->rankCheckUsers = $rankUsersFinal; ////if no online expert available redirecting to the board page // // ant-edit get rid of adding notification bots right now $onlineusers = array(); $offlineusers = array(); $newOnlineUser = array(); $newOfflineUser = array(); $j = 0; $k = 0; // $facebookTutors = BotServiceProvider::createFor("http://facebook.rayku.com/tutor")->getContent(); // $onlineTutorsByNotificationBot = BotServiceProvider::createFor("http://notification-bot.rayku.com/tutor")->getContent(); // $Users = json_decode($facebookTutors, true); // $_Users = json_decode($onlineTutorsByNotificationBot, true); //Iterate through every user and check if they are online (either on fb gchat local rayku etc... foreach ($newUser as $new) { $a = new Criteria(); $a->add(UserPeer::ID, $new['userid']); $users_online = UserPeer::doSelectOne($a); $onlinecheck = ''; if ($users_online->isOnline()) { $onlinecheck = "online"; } // // ant-edit get rid of gtalk users for now if (empty($onlinecheck)) { $userGtalk = $users_online->getUserGtalk(); if ($userGtalk) { $onlinecheck = BotServiceProvider::createFor(sfConfig::get('app_rayku_url') . ':' . sfConfig::get('app_g_chat_port') . '/status/' . $userGtalk->getGtalkid())->getContent(); } } // if ((empty($onlinecheck) || ($onlinecheck != "online")) && is_array($Users)) { // $userFb = UserFbPeer::retrieveByUserId($new['userid']); // if ($userFb) { // $fb_username = $userFb->getFbUsername(); // foreach ($Users as $key => $user) { // if ($user['username'] == $fb_username) { // $onlinecheck = 'online'; // break; // } // } // } // } // if ((empty($onlinecheck) || ($onlinecheck != "online")) && is_array($_Users)) { // foreach ($_Users as $key => $_user) { // if ($_user['email'] == $users_online->getEmail()) { // $onlinecheck = 'online'; // break; // } // } // } //if user was online then store ; if ($onlinecheck == "online") { $onlineusers[$j] = $new['userid']; $newOnlineUser[$j] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']); $j++; } elseif ($users_online->isOnline()) { $newOnlineUser[$j] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']); $onlineusers[$j] = $new['userid']; $j++; } else { $newOfflineUser[$k] = array("score" => $new['score'], "userid" => $new['userid'], "category" => $new['category'], "createdat" => $new['createdat']); $offlineusers[$k] = $new['userid']; $k++; } } $this->newOnlineUser = $newOnlineUser; $this->newOfflineUser = $newOfflineUser; $this->_checkOnlineUsers = $onlineusers; if (count($onlineusers) < 1) { $this->redirect('http://' . RaykuCommon::getCurrentHttpDomain() . '/forum/newthread/' . $_SESSION['subject'] . '?exp_online = 1'); } $onoff = isset($_COOKIE['onoff']) ? $_COOKIE['onoff'] : null; if ($onoff == 1) { if (!empty($_COOKIE["school"])) { $cookieSchool = array(); $m = 0; foreach ($newOnlineUser as $new) { $b = new Criteria(); $b->add(UserPeer::ID, $new['userid']); $schoolusers = UserPeer::doSelectOne($b); $mail = explode("@", $schoolusers->getEmail()); $newMail = explode(".", $mail[1]); if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) { $cookieSchool[$m] = $new; $m++; } } $this->expert_cats = $cookieSchool; } else { $this->expert_cats = $newOnlineUser; } } else { if ($onoff == 2) { if (!empty($_COOKIE["school"])) { $cookieSchool = array(); $m = 0; foreach ($newOfflineUser as $new) { $b = new Criteria(); $b->add(UserPeer::ID, $new['userid']); $schoolusers = UserPeer::doSelectOne($b); $mail = explode("@", $schoolusers->getEmail()); $newMail = explode(".", $mail[1]); if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) { $cookieSchool[$m] = $new; $m++; } } $this->expert_cats = $cookieSchool; } else { $this->expert_cats = $newOfflineUser; } } else { if (!empty($_COOKIE["school"])) { $cookieSchool = array(); $m = 0; foreach ($newUser as $new) { $b = new Criteria(); $b->add(UserPeer::ID, $new['userid']); $schoolusers = UserPeer::doSelectOne($b); $mail = explode("@", $schoolusers->getEmail()); $newMail = explode(".", $mail[1]); if ($newMail[0] == $_COOKIE["school"] || $newMail[1] == $_COOKIE["school"]) { $cookieSchool[$m] = $new; $m++; } } $this->expert_cats = $cookieSchool; } else { $this->expert_cats = $newUser; } } } $this->tutorsCount = count($this->expert_cats); $c = new Criteria(); $c->add(CategoryPeer::ID, $this->cat); $this->e = CategoryPeer::doSelectOne($c); }
/*$c=new Criteria(); $c->add(PostPeer::THREAD_ID,$latestqn->getId()); $post=PostPeer::doSelectOne($c); */ ?> <?php echo link_to($latestqn->getTitle(), '@view_thread?thread_id=' . $latestqn->getId() . '&page=1', array('class' => 'question', 'style' => 'background-repeat:no-repeat')); ?> <?php $co = new Criteria(); $co->add(PostPeer::THREAD_ID, $latestqn->getId()); $replycount = PostPeer::doCount($co); ?> <?php $fo = new Criteria(); $fo->add(CategoryPeer::ID, $latestqn->getCategoryId()); $categorie = CategoryPeer::doSelectOne($fo); ?> <?php $u = new Criteria(); $u->add(UserPeer::ID, $latestqn->getPosterId()); $user = UserPeer::doSelectOne($u); ?> <div class="det"> <span> <?php echo $replycount - 1; ?> Responses </span><br /> Question Asked by <?php echo link_to($user->getName(), sfConfig::get('app_rayku_url') . '/expertmanager/portfolio/' . $user->getUsername()); ?> </div> <?php
/** * Get the associated Category object * * @param PropelPDO Optional Connection object. * @return Category The associated Category object. * @throws PropelException */ public function getCategory(PropelPDO $con = null) { if ($this->aCategory === null && $this->category_id !== null) { $c = new Criteria(CategoryPeer::DATABASE_NAME); $c->add(CategoryPeer::ID, $this->category_id); $this->aCategory = CategoryPeer::doSelectOne($c, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aCategory->addUserQuestionTags($this); */ } return $this->aCategory; }