public function executeAjaxGivePoints() { $c = new Criteria(); $c->add(UserPeer::USERNAME, $this->getRequestParameter('username')); $user = UserPeer::doSelectOne($c); $user->sendPointsFromAdmin($this->getRequestParameter('points')); }
public function executeIndex(sfWebRequest $request) { if ($this->getRequest()->getMethod() == sfRequest::POST) { $username = $request->getParameter('username'); $password = $request->getParameter('password'); $password = Login::EncryptPassword($password); // Get Record From Database $c = new Criteria(); $c->add(UserPeer::USER, $username); $c->add(UserPeer::PASSWORD, $password); $user = UserPeer::doSelectOne($c); //Set Global Attributes if ($user) { //$this->getUser ()->setFlash ( 'SUCCESS_MESSAGE', Constant::LOGIN_OK ); sfContext::getInstance()->getUser()->setAttribute('USER_ID', $user->getId()); sfContext::getInstance()->getUser()->setAttribute('USERNAME', $user->getUser()); sfContext::getInstance()->getUser()->setAttribute('NAME', $user->getEmployee()->getName()); sfContext::getInstance()->getUser()->setAttribute('ROLE', $user->getRole()); sfContext::getInstance()->getUser()->setAttribute('LOGGED_IN', true); sfContext::getInstance()->getUser()->setAuthenticated(true); $this->redirect('Home/index'); } else { $this->getUser()->setFlash('ERROR_MESSAGE', Constant::LOGIN_INVALID_USER_EMAIL_PASSWORD); sfContext::getInstance()->getUser()->setAuthenticated(false); } } // end if }
static function getUserByLoginAndPassowrd($login, $psw) { $c = new Criteria(); $c->add(UserPeer::LOGIN, $login); $c->add(UserPeer::PSW, $psw); return UserPeer::doSelectOne($c); }
public function validateLogin() { $result = false; if ($login = $this->getRequestParameter('login')) { $password = $this->getRequestParameter('password'); $c = new Criteria(); $c->add(UserPeer::LOGIN, $login); $user = UserPeer::doSelectOne($c); if ($user) { if ($user->getPublicationStatus() != "ACTIVE") { UtilsHelper::setFlashMsg(UtilsHelper::Localize("user.Not-active", $culture), UtilsHelper::MSG_INFO); } elseif (sha1($user->getSalt() . $password) == $user->getSha1Password()) { $this->getUser()->setAttribute('pass', $password); $this->getUser()->signIn($user); // redirect to dashboard $this->showDashboard(); $result = true; } else { UtilsHelper::setFlashMsg(UtilsHelper::Localize("user.Wrong-login", $culture), UtilsHelper::MSG_ERROR); } } else { UtilsHelper::setFlashMsg(UtilsHelper::Localize("user.Wrong-login", $culture), UtilsHelper::MSG_ERROR); } } else { if ($this->getUser()->isAuthenticated()) { // redirect to dashboard $this->showDashboard(); } } }
public function execute(&$value, &$error) { $password_param = $this->getParameter('password'); sfContext::getInstance()->getLogger()->info("{myLoginValidator} password_param {$password_param}"); $password = $this->getContext()->getRequest()->getParameter($password_param); $login = $value; sfContext::getInstance()->getLogger()->info("{myLoginValidator} validate login:{$value}, password: {$password}"); // anonymous is not a real user if ($login == 'anonymous') { $error = $this->getParameter('login_error'); return false; } $c = new Criteria(); $c->add(UserPeer::LOGIN, $login); $user = UserPeer::doSelectOne($c); // nickname exists? if ($user) { // password is OK? if ($password == $user->getPassword()) { $this->getContext()->getUser()->setAuthenticated(true); return true; } } $error = $this->getParameter('login_error'); return false; }
public function executePasswordRequest() { if ($this->getRequest()->getMethod() != sfRequest::POST) { // display the form return sfView::SUCCESS; } // handle the form submission $c = new Criteria(); $c->add(UserPeer::EMAIL, $this->getRequestParameter('email')); $user = UserPeer::doSelectOne($c); // email exists? if ($user) { // set new random password $password = substr(md5(rand(100000, 999999)), 0, 6); $user->setPassword($password); $this->getRequest()->setAttribute('password', $password); $this->getRequest()->setAttribute('nickname', $user->getNickname()); $raw_email = $this->sendEmail('mail', 'sendPassword'); //$this->getLogger()->debug($raw_email); // save new password $user->save(); return 'MailSent'; } else { $this->getRequest()->setError('email', 'There is no Registry user with this email address. Please try again'); return sfView::SUCCESS; } }
public function execute($filterChain) { // execute this filter only once if ($this->isFirstCall()) { $user = sfContext::getInstance()->getUser(); if (!$user->isAuthenticated()) { $cookie = $this->getContext()->getRequest()->getCookie('rayku'); if ($cookie) { $value = unserialize(base64_decode($cookie)); $c = new Criteria(); $c->add(UserPeer::COOKIE_KEY, $value[0]); $c->add(UserPeer::USERNAME, $value[1]); $raykuUser = UserPeer::doSelectOne($c); if ($raykuUser instanceof User) { // sign in StatsD::increment("login.remember_me_success"); $user->signIn($raykuUser); } else { StatsD::increment("login.remember_me_failure"); } } } } // Execute next filter $filterChain->execute(); }
public function execute(&$value, &$error) { $id = $this->getContext()->getRequest()->getParameter('id'); $name = $value; $c = new Criteria(); $c->add(UserPeer::USERNAME, $name); $user = UserPeer::doSelectOne($c); $condition = true; if ($user) { if ($id && $id == $user->getId()) { $condition = true; } else { $error = 'User ' . $user->getUsername() . ' already Exist.'; $condition = false; } } $roles = RolePeer::doSelect(new Criteria()); $found = false; foreach ($roles as $role) { if ($this->getContext()->getRequest()->getParameter($role->getName(), 0) == 1) { $found = true; } } if (!$found) { $error = 'Please select atleast one role'; $condition = false; } return $condition; }
public function executeRaykupoints() { $this->amount = $this->getRequestParameter('amount'); $this->currentpoints = $this->getRequestParameter('raykupoints'); $expert_id = $this->getUSer()->getRaykuUserId(); $c = new Criteria(); $c->add(UserPeer::ID, $this->getUser()->getRaykuUserId()); $user = UserPeer::doSelectOne($c); $points = $user->getPoints() + $this->currentpoints; $user->setPoints($points); $user->save(); $expertsdebit = new ExpertsDebitDetails(); $expertsdebit->setExpertId($expert_id); $expertsdebit->setAmount($this->amount); $expertsdebit->setTime(date('Y-m-d H:i:s')); $expertsdebit->save(); $c = new Criteria(); $c->add(ExpertsFinalCreditPeer::EXPERT_ID, $expert_id); $current = ExpertsFinalCreditPeer::doSelectOne($c); if ($current != NULL) { $finalamount = $current->getAmount() - $this->amount; $current->setAmount($finalamount); $current->save(); } }
public function executeLogin(sfWebRequest $request) { if ($this->getUser()->isAuthenticated()) { $this->redirect('default/index'); } if ($request->isMethod('post')) { $login = $request->getParameter('login'); $psw = $request->getParameter('psw'); $c = new Criteria(); $c->add(UserPeer::LOGIN, $login); $c->add(UserPeer::PSW, $psw); $user = UserPeer::doSelectOne($c); if (false == empty($user)) { $this->getUser()->setAuthenticated(true); $this->getUser()->addCredentials($user->getStatus()); $this->getUser()->setCulture('ru_UA'); $this->getUser()->setAttribute('user', $user); if (!empty($remember)) { $data = array('login' => $user->getLogin(), 'email' => $user->getEmail(), 'psw' => $user->getPsw(), 'status' => $user->getStatus()); $values = base64_encode(serialize($data)); $this->getResponse()->setCookie('user', $values, time() + 2592000); $this->redirect('default/index'); } else { $this->redirect('default/index'); } } } }
public static function authenticate($login, $password) { $passwordHash = sha1($password); $c = new Criteria(); $c->add(UserPeer::LOGIN, $login, Criteria::EQUAL); $c->addAnd(UserPeer::PASSWORD_HASH, $passwordHash, Criteria::EQUAL); $c->addAnd(UserPeer::IS_ACTIVE, true, Criteria::EQUAL); $c->addAnd(UserPeer::IS_MEMBER, true, Criteria::EQUAL); $user = UserPeer::doSelectOne($c); return $user; }
public static function getUserForLogin($email, $pass) { $c = new Criteria(); $c->add(UserPeer::EMAIL, $email); $c->add(UserPeer::PASSWORD, md5($pass)); $userDb = UserPeer::doSelectOne($c); if ($userDb) { return self::_toUser($userDb); } return null; }
/** * AJAX action to send a message */ public function executeSend() { //Grab the user object $user = $this->getUser()->getRaykuUser(); //Pull a User object for the recipient $c = new Criteria(); $c->add(UserPeer::USERNAME, $this->getRequestParameter('name')); $recipient = UserPeer::doSelectOne($c); //Send the message $user->sendMessage($recipient->getId(), $this->getRequestParameter('subject'), $this->getRequestParameter('body')); $this->getUser()->addNotice('Your private message has been successfully sent'); $this->redirect('message/index'); }
public function executeUpdate() { $jira = new sfJiraPlugin($this->getUser()->getProfile()->getJiraLogin(), $this->getUser()->getProfile()->getJiraPassword()); $aProjects = $jira->getProjects(); foreach ($aProjects as $project) { #var_dump( $project ); $c = new Criteria(); $c->add(ProjectPeer::USER_ID, $this->getUser()->getProfile()->getId()); $c->add(ProjectPeer::KEY, $project->key); $p = ProjectPeer::doSelectOne($c); $c = new Criteria(); $c->add(UserPeer::JIRA_LOGIN, $project->lead); $u = UserPeer::doSelectOne($c); if (empty($p)) { $p = new Project(); $p->setKey($project->key); $p->setLeadId(!empty($u) ? $u->getId() : null); $p->setUserId($this->getUser()->getProfile()->getId()); $p->setName($project->name); $p->setUpdated(date('r')); $p->save(); } $issues = $jira->getIssuesForProject($p->getKey()); foreach ($issues as $issue) { #die($p->getKey()); if ($issue->assignee == $this->getUser()->getProfile()->getJiraLogin()) { $c = new Criteria(); $c->add(TaskPeer::KEY, $issue->key); $t = TaskPeer::doSelectOne($c); if (empty($t)) { $c = new Criteria(); $c->add(UserPeer::JIRA_LOGIN, $issue->reporter); $u = UserPeer::doSelectOne($c); $t = new Task(); $t->setProjectId($p->getId()); $t->setTitle($issue->summary); $t->setDescription($issue->description); $t->setKey($issue->key); $t->setUpdated(date('r')); $t->setStatusId($issue->status); $t->setPriorityId($issue->priority); $t->setLeadId(!empty($u) ? $u->getId() : null); $t->save(); } } } } $this->redirect('@homepage'); return sfView::NONE; }
/** * Execute this validator. * * @param mixed A file or parameter value/array. * @param error An error message reference. * * @return bool true, if this validator executes successfully, otherwise * false. */ public function execute(&$value, &$error) { $this->getContext()->getRequest()->setAttribute('newaccount', true); $login = $value; $c = new Criteria(); $c->add(UserPeer::NICKNAME, $login); $user = UserPeer::doSelectOne($c); // nickname exists? if ($user) { $error = $this->getParameterHolder()->get('newaccount_error'); return false; } return true; }
public function executeEdit() { $c = new Criteria(); $c->add(UserPeer::USERNAME, $this->getUser()->getAttribute('username')); $user = UserPeer::doSelectOne($c); //$this->personal = PersonalPeer::retrieveByPk($this->getRequestParameter('id')); $c = new Criteria(); $c->add(PersonalPeer::USER_ID, $user->getId()); $this->personal = PersonalPeer::doSelectOne($c); $this->forward404Unless($this->personal); $this->privacyoptions = array('1' => 'Myself', '2' => 'My Friends', '3' => 'IT BHU', '4' => 'Everyone'); $this->salutations = array('Mr' => 'Mr', 'Miss' => 'Miss', 'Mrs' => 'Mrs', 'Ms' => 'Ms', 'Dr' => 'Dr', 'Prof' => 'Prof'); $this->gender = array('Female' => 'Female', 'Male' => 'Male'); $this->mstatus = array(' ' => 'Select', 'Single' => 'Single', 'Married' => 'Married'); }
public function execute(&$value, &$error) { $id = $this->getContext()->getRequest()->getParameter('id'); $name = $value; $c = new Criteria(); $c->add(UserPeer::USERNAME, $name); $user = UserPeer::doSelectOne($c); if ($user) { if ($id && $id == $user->getId()) { return true; } $error = 'Username ' . $user->getUsername() . ' already Exist.'; return false; } return true; }
/** * Executes index action */ public function executeIndex() { unset($_SESSION['dash_hidden']); unset($_SESSION['subject']); unset($_SESSION['edu']); unset($_SESSION['course_id']); unset($_SESSION['name']); unset($_SESSION['course_code']); unset($_SESSION['year']); unset($_SESSION['grade']); unset($_SESSION['question']); if (!empty($_COOKIE["timer"])) { $this->redirect('/dashboard/rating'); } $connection = RaykuCommon::getDatabaseConnection(); /* @var $raykuUser User */ $raykuUser = $this->getUser()->getRaykuUser(); $c = new Criteria(); $c->addJoin(ExpertCategoryPeer::USER_ID, UserTutorPeer::USERID, Criteria::INNER_JOIN); $rankexperts = ExpertCategoryPeer::doSelect($c); $rankUsers = array(); $ji = 0; $eachExpertOnlyOnce = array(); 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; $queryScore = mysql_query("select * from user_score where user_id =" . $raykuUser->getId() . " and score >= 125 and status = 0", $connection) or die(mysql_error()); $this->changeUserType = null; if (mysql_num_rows($queryScore) > 0) { $this->changeUserType = 1; } }
public function executeSiteview() { $username = $this->getRequestParameter('un'); $c = new Criteria(); $c->add(UserPeer::USERNAME, $username); $user = UserPeer::doSelectOne($c); $tabid = $this->getRequestParameter('tid'); $c = new Criteria(); $c->add(PepuserPeer::USER_ID, $user->getId()); $c->addJoin(PepuserPeer::PEPPAGE_ID, PeppagePeer::ID); $c->addAscendingOrderByColumn(PeppagePeer::SEQUENCE); $homepage = PepuserPeer::doSelectOne($c); if (!$tabid) { $tabid = $homepage->getPeppageId(); } $this->peppage = PeppagePeer::retrieveByPK($tabid); }
public function executeLogin() { $referer = @$_SERVER['HTTP_REFERER']; if (!strstr($referer, 'panel') || !strstr($referer, "?")) { $referer = null; } $this->getUser()->setAttribute('referer', $referer); $this->setLayout("panel"); if ($this->getRequestParameter("submit")) { if ($this->getRequestParameter("login") && $this->getRequestParameter("password")) { $subscriber_pass = $this->getRequestParameter('password'); $subscriber_login = $this->getRequestParameter('login'); $c = new Criteria(); $c->add(UserPeer::LOGIN, $subscriber_login); $subscriber = UserPeer::doSelectOne($c); if ($subscriber) { if ($subscriber->getBackend() != 1) { // $this->getRequest()->setError('login_error', 'Your have no access to site admisnistration'); UtilsHelper::setBackendMsg('Your have no access to site admisnistration', "info"); } elseif ($subscriber->getPublicationStatus() != UtilsHelper::STATUS_ACTIVE) { // $this->getRequest()->setError('login_error', 'Your account is not active'); UtilsHelper::setBackendMsg('Your account is not active', "info"); } elseif (sha1($subscriber->getSalt() . $subscriber_pass) == $subscriber->getSha1Password()) { $this->getUser()->signIn($subscriber); $this->user = $subscriber; //exit("referer ".$_SERVER['HTTP_REFERER']); $this->redirect($this->getUser()->getAttribute("referer")); } else { // $this->getRequest()->setError('login_error', 'Wrong password'); UtilsHelper::setBackendMsg('Wrong username or password', "error"); } } else { UtilsHelper::setBackendMsg('Wrong username or password', "error"); } } else { // $this->getRequest()->setError('login_error', 'Please, enter username and password'); UtilsHelper::setBackendMsg('Please, enter username and password', "info"); } } else { if ($subscriber = $this->getUser()->getAttribute('forceAutoLogAsAdmin')) { $this->getUser()->signIn($subscriber); $this->getUser()->setAttribute('forceAutoLogAsAdmin', null); $this->redirect("http://" . $_SERVER['HTTP_HOST'] . "/admin/index.php?refresh=" . $this->getRequestParameter('refresh')); } } }
public function executeLogin(sfWebRequest $request) { $arr = array(); if ($request->hasParameter('username') && $request->hasParameter('password')) { $c = new Criteria(); $c->add(UserPeer::ID, $request->getParameter('username')); $c->add(UserPeer::PASSWORD, md5($request->getParameter('password'))); if (UserPeer::doSelectOne($c)) { $arr["result"] = true; $arr["message"] = "OK"; $this->renderText(json_encode($arr)); return sfView::NONE; } } $arr["result"] = false; $arr["message"] = "Username or password invalid"; $this->renderText(json_encode($arr)); return sfView::NONE; }
public function executeEdit() { //$userid = $this->getRequestParameter('id'); $username = $this->getUser()->getAttribute('username'); $c = new Criteria(); $c->add(UserPeer::USERNAME, $username); $user = UserPeer::doSelectOne($c); $userid = $user->getId(); $c = new Criteria(); $c->add(AddressPeer::USER_ID, $userid); $c->add(AddressPeer::TYPE, '0'); $this->address1 = AddressPeer::doSelectOne($c); if (!$this->address1) { $this->address1 = new Address(); } $c = new Criteria(); $c->add(AddressPeer::USER_ID, $userid); $c->add(AddressPeer::TYPE, '1'); $this->address2 = AddressPeer::doSelectOne($c); if (!$this->address2) { $this->address2 = new Address(); } $c = new Criteria(); $c->add(AddressPeer::USER_ID, $userid); $c->add(AddressPeer::TYPE, '2'); $this->address3 = AddressPeer::doSelectOne($c); if (!$this->address3) { $this->address3 = new Address(); } $this->userid = $userid; $this->privacyoptions = array('1' => 'Myself', '2' => 'Friends', '3' => 'IT BHU', '4' => 'Everyone'); //Country $c = new Criteria(); $c->addAscendingOrderByColumn('name'); $countries = CountryPeer::doSelect($c); $options = array(); $options[] = 'Select'; foreach ($countries as $country) { $options[$country->getId()] = $country->getName(); } $this->countryoptions = $options; }
public function execute(&$value, &$error) { $password_param = $this->getParameter('password'); $password = $this->getContext()->getRequest()->getParameter($password_param); $username_param = $this->getParameter('username'); $username = $this->getContext()->getRequest()->getParameter($username_param); $login = $value; $c = new Criteria(); #die( $username); $c->add(UserPeer::EMAIL, $username); $admin = UserPeer::doSelectOne($c); if ($admin) { #die( $admin->getPassword() .' ' . md5( $password ) ); if ($admin->getPassword() == md5($password)) { $this->getContext()->getUser()->signIn($admin); return true; } } $error = $this->getParameterHolder()->get('login_error'); return false; }
public function execute(&$value, &$error) { $password_param = $this->getParameter('password'); $password = $this->getContext()->getRequest()->getParameter($password_param); $login = $value; // anonymous is not a real user if ($login == 'anonymous') { $error = $this->getParameter('login_error'); return false; } $c = new Criteria(); $c->add(UserPeer::NICKNAME, $login); $user = UserPeer::doSelectOne($c); // nickname exists? if ($user) { // password is OK? if (sha1($user->getSalt() . $password) == $user->getSha1Password()) { $this->getContext()->getUser()->signIn($user); return true; } } $error = $this->getParameter('login_error'); return false; }
public function executeLogin(sfWebRequest $request) { $username = $request->getParameter('username'); $user_password = $request->getParameter('password'); //Should be with a validator if (!$username or !$user_password) { $this->getUser()->setFlash('error', 'You must provide Username / Password'); } // Getting the user object $c = new Criteria(); $c->add(UserPeer::LOGIN, $username); $user = UserPeer::doSelectOne($c); // Check the user in db if ($user) { $password = new Password($user_password); if ($user->checkPassword($password) && $user->getCredential()) { $this->getUser()->addCredential($user->getCredential()); $this->getUser()->setAuthenticated(true); $this->getUser()->setFlash('notice', "Welcome " . $user->getCredential()); $this->redirect('@user'); } } $this->getUser()->setFlash('error', 'You are not authorized.'); }
/** * Get the associated User object * * @param PropelPDO Optional Connection object. * @return User The associated User object. * @throws PropelException */ public function getUser(PropelPDO $con = null) { if ($this->aUser === null && $this->user_id !== null) { $c = new Criteria(UserPeer::DATABASE_NAME); $c->add(UserPeer::ID, $this->user_id); $this->aUser = UserPeer::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->aUser->addShoppingCarts($this); */ } return $this->aUser; }
/** * 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 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()); } }
public function validateChangePassword() { $result = false; if ($activation_code = $this->getRequestParameter('q')) { if ($this->getRequestParameter('password1') && $this->getRequestParameter('password2')) { $password1 = $this->getRequestParameter('password1'); $password2 = $this->getRequestParameter('password2'); if ($password1 == $password2) { $c = new Criteria(); $c->add(UserPeer::ACTIVATION_CODE, $activation_code); $c->add(UserPeer::ACTIVATION_CODE, "{$activation_code}", Criteria::LIKE); $user = UserPeer::doSelectOne($c); if ($user) { $user->setPassword($password2); $user->setActivationCode(''); $user->save(); return true; } else { UtilsHelper::setFlashMsg("Invalid user. Please contact with system administrator", UtilsHelper::MSG_ERROR); } } else { UtilsHelper::setFlashMsg("Passwords doesn't match.", UtilsHelper::MSG_ERROR); } } } return $result; }
/** * Description : Retrieve a user from data base * * @param String $email : An e-mail * @return : User object */ public function getUserByEmail($email) { try { $criteria = new Criteria(); $criteria->add(UserPeer::EMAIL, $email); return UserPeer::doSelectOne($criteria); } catch (Exception $e) { return null; } }