Ejemplo n.º 1
0
 public function execute(&$value, &$error)
 {
     $c = new Criteria();
     $c->add(UserPeer::EMAIL, $value);
     $users = UserPeer::doSelect($c);
     // if it's unique
     if (0 === count($users)) {
         return true;
     } else {
         if (count($users) > 1) {
             $error = $this->getParameter('unique_error');
             return false;
         } else {
             $user = array_pop($users);
             /* @var $user User */
             $loggedInUser = sfContext::getInstance()->getUser()->getRaykuUser();
             if ($loggedInUser instanceof User) {
                 // if the logged in user matches the found user, then it's allowed to be the same email address
                 if ($loggedInUser->equals($user)) {
                     return true;
                 } else {
                     $error = $this->getParameter('unique_error');
                     return false;
                 }
             } else {
                 // we're not logged in, so die
                 throw new sfValidatorException('you need to be logged in to validate your email address');
             }
         }
     }
     $error = $this->getParameter('unique_error');
     return false;
 }
Ejemplo n.º 2
0
 public function getNonMembers($c = null)
 {
     $c = UserPeer::getNonUsergroupCriteria($this->getId(), $c);
     $c->addAscendingOrderByColumn(UserPeer::FAMILY_NAME);
     $c->addAscendingOrderByColumn(UserPeer::SURNAME);
     return UserPeer::doSelect($c);
 }
Ejemplo n.º 3
0
 public function getAllInterestedUsers()
 {
     $c = new Criteria();
     $c->addJoin(UserPeer::ID, InterestPeer::USER_ID, Criteria::LEFT_JOIN);
     $c->add(InterestPeer::QUESTION_ID, $this->getId());
     return UserPeer::doSelect($c);
 }
Ejemplo n.º 4
0
 public function executeList(sfWebRequest $request)
 {
     $c = new Criteria();
     $c->add(UserPeer::STATUS, Constant::RECORD_STATUS_DELETED, Criteria::NOT_EQUAL);
     $c->addAscendingOrderByColumn(UserPeer::EMPLOYEE_ID);
     $this->users = UserPeer::doSelect($c);
 }
 public function execute(&$value, &$error)
 {
     $c = new Criteria();
     $c->add(UserPeer::EMAIL, $value);
     $users = UserPeer::doSelect($c);
     // if it's not found
     if (0 === count($users)) {
         $error = $this->getParameter('invalid_error');
         return false;
     }
     return true;
 }
Ejemplo n.º 6
0
 public function executeAutocomplete()
 {
     //Find the e-mail addresses of banned users that're like the one typed
     $c = new Criteria();
     if ($this->getRequestParameter('hidden') == 'yes') {
         $c->add(UserPeer::HIDDEN, true);
     } else {
         $c->add(UserPeer::HIDDEN, false);
     }
     $c->add(UserPeer::USERNAME, $this->getRequestParameter('username') . '%', Criteria::LIKE);
     $c->setLimit(25);
     //Send that list to the template
     $this->users = UserPeer::doSelect($c);
 }
Ejemplo n.º 7
0
 public function executeSubmit(sfWebRequest $request)
 {
     $user = new User();
     $c = new Criteria();
     $c->add(UserPeer::USERNAME, $request->getParameter('user_name'));
     $c->add(UserPeer::PASSWORD, $request->getParameter('password'));
     $user_array = UserPeer::doSelect($c);
     $user = $this->getUser();
     if (sizeof($user_array) <= 0) {
         $user->setAuthenticated(false);
         return sfView::ERROR;
     }
     $user_class = new User();
     $user_class = $user_array[0];
     $user->setAttribute('userId', $user_class->getUserid());
     $user->setAuthenticated(true);
 }
Ejemplo n.º 8
0
 public function getSysadmin()
 {
     $c = new Criteria();
     $users = UserPeer::doSelect($c);
     foreach ($users as $user1) {
         $userrole = $user1->getUserRoles();
         $found = false;
         foreach ($userroles as $userrole) {
             if ($userrole . getRole()->getName() == 'sysadmin') {
                 $found = true;
                 break;
             }
         }
         if (found == true) {
             return $user1;
         }
     }
     return null;
 }
function checkUser($userEmail, $userPassword)
{
    global $firephp;
    $c = new Criteria();
    $c->add(UserPeer::USEREMAIL, $userEmail);
    $user = UserPeer::doSelect($c);
    $firephp->log($user, 'user');
    if (count($user) != 1) {
        return false;
    } else {
        $firephp->log($user[0]->getUserpwd(), 'password Bdd');
        $firephp->log($userPassword, 'password user');
        //controle du password
        if (!strcmp($user[0]->getUserpwd(), $userPassword)) {
            return $user[0];
            //login ok le password est bon
        } else {
            return false;
        }
    }
}
Ejemplo n.º 10
0
 public function executeSendmail()
 {
     $c = new Criteria();
     $users = UserPeer::doSelect($c);
     foreach ($users as $user) {
         $this->mail = Mailman::createCleanMailer();
         $subject = $_POST['massmail_subject'];
         $this->mail->setSubject($subject);
         $this->mail->setFrom("Rayku < *****@*****.** >");
         $to = $user->getEmail();
         sfProjectConfiguration::getActive()->loadHelpers(array('Partial'));
         $this->mail->setBody($_POST['massmail_content']);
         $this->mail->setContentType('text/html');
         $this->mail->addAddress($to);
         $this->mail->send();
         if ($this->mail) {
             $_SESSION['mailsent'] = 1;
         }
     }
     $this->redirect('massmail/index');
 }
Ejemplo n.º 11
0
 public function executeIndex()
 {
     $a = new Criteria();
     $users = UserPeer::doSelect($a);
     //print_r($users);
     $onlineusers = 0;
     foreach ($users as $user) {
         if ($user->isOnline()) {
             $onlineusers = $onlineusers + 1;
         }
     }
     //echo $onlineusers;
     $onlineusers = $onlineusers;
     if ($onlineusers == 0) {
         $onlineusers_msg = "(All members are in offline)";
     }
     if ($onlineusers == 1) {
         $onlineusers_msg = "(One member is in online)";
     }
     if ($onlineusers > 1) {
         $onlineusers_msg = "({$onlineusers} members are in online)";
     }
     $this->onlineusers_msg = $onlineusers_msg;
     if (!empty($_COOKIE["timer"])) {
         $this->redirect('/dashboard/rating');
     }
     if (!empty($_GET['post_id'])) {
         $this->getResponse()->setCookie("_post_Id", $_GET['post_id'], time() + 600, '/', sfConfig::get('app_cookies_domain'));
         $_COOKIE['_post_Id'] = 100;
     }
     $c = new Criteria();
     $c->add(ForumPeer::TYPE, 0);
     $this->publicforums = ForumPeer::doSelect($c);
     $this->categories = CategoryPeer::doSelect(new Criteria());
     $l = new Criteria();
     $l->addDescendingOrderByColumn(ThreadPeer::ID);
     $l->add(ThreadPeer::CANCEL, 0);
     $l->setLimit(5);
     $this->latest = ThreadPeer::doSelect($l);
 }
Ejemplo n.º 12
0
 public function executeList()
 {
     $this->users = UserPeer::doSelect(new Criteria());
 }
Ejemplo n.º 13
0
Archivo: User.php Proyecto: habtom/uas
 public function getLoginName($email_address)
 {
     $a = explode("@", $email_address);
     $c = new Criteria();
     $c->add(UserPeer::EMAIL_LOCAL_PART, $a[0]);
     $login = UserPeer::doSelect($c);
     return $login->getLogin();
 }
Ejemplo n.º 14
0
 private function getUserByName($keyword)
 {
     $departmentAvailable = $this->cmsTools->departmentAvailable($this->department->getId());
     $criteria = new Criteria();
     $criteria->add(UserPeer::LOGIN, '%' . $keyword . '%', Criteria::LIKE);
     $criteria->add(UserPeer::DEPARTMENT_ID, $departmentAvailable, Criteria::IN);
     $user = UserPeer::doSelect($criteria);
     $userId = array();
     foreach ($user as $u) {
         $userId[] = $u->getId();
     }
     return $userId;
 }
Ejemplo n.º 15
0
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(PagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         // rename for clarity
         $criteria = clone $values;
     } elseif ($values instanceof User) {
         // it's a model object
         // create criteria based on pk values
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it's a primary key, or an array of pks
         $criteria = new Criteria(self::DATABASE_NAME);
         $criteria->add(PagePeer::ID, (array) $values, Criteria::IN);
     }
     foreach (UserPeer::doSelect(clone $criteria, $con) as $object) {
         TagPeer::deleteTagsForObject($object);
     }
     return self::doDeleteBeforeTaggable($criteria, $con);
 }
Ejemplo n.º 16
0
 protected function userstat($col)
 {
     $c = new Criteria();
     $c->addGroupByColumn($col);
     $c->addAscendingOrderByColumn($col);
     return UserPeer::doSelect($c);
 }
Ejemplo n.º 17
0
    public function executeRegistration()
    {
        $userid = $this->getRequestParameter('userid');
        $this->getUser()->getAttributeHolder()->remove('claimerid');
        $roll = $this->getRequestParameter('roll');
        $hawa = $this->getRequestParameter('hawa');
        $city = $this->getRequestParameter('city');
        $hod = $this->getRequestParameter('hod');
        $director = $this->getRequestParameter('director');
        $teacher = $this->getRequestParameter('favteacher');
        $lanka = $this->getRequestParameter('favlankashop');
        $email = $this->getRequestParameter('email');
        $other = $this->getRequestParameter('otherinfo');
        $dusername = $this->getRequestParameter('dusername');
        $mob = $this->getRequestParameter('mob');
        if (!$userid) {
            $fname = $this->getRequestParameter('fname');
            $mname = $this->getRequestParameter('mname');
            $lname = $this->getRequestParameter('lname');
            $year = $this->getRequestParameter('year');
            $dusername = $this->getRequestParameter('dusername');
            $formerrors1 = array();
            if (!$fname) {
                $formerrors1[] = 'Please enter first name';
            }
            if (!$lname) {
                $formerrors1[] = 'Please enter last name';
            }
            if (!$dusername) {
                $formerrors1[] = 'Please enter username';
            }
            if ($formerrors1) {
                $this->getRequest()->setErrors($formerrors1);
                $this->forward('home', 'getmyaccount');
            }
            $branchn = BranchPeer::retrieveByPK($this->getRequestParameter('branchid'));
            $degreen = DegreePeer::retrieveByPK($this->getRequestParameter('degreeid'));
            if (!$dusername) {
                $newusername = $fname . "." . $lname . "@" . $branchn->getCode() . substr($year, -2);
            } else {
                $newusername = $dusername;
            }
            $currentyear = date('Y');
            if ($currentyear <= $year) {
                $usertype = '0';
            } else {
                $usertype = '1';
            }
            $user = new User();
            $user->setUsername($newusername);
            $user->setRoll($roll);
            $user->setRollflag(sfConfig::get('app_defaultprivacy_roll'));
            $user->setGraduationyear($year);
            $user->setGraduationyearflag(sfConfig::get('app_defaultprivacy_year'));
            $user->setBranchId($branchn->getId());
            $user->setBranchflag(sfConfig::get('app_defaultprivacy_branch'));
            $user->setDegreeId($degreen->getId());
            $user->setDegreeflag(sfConfig::get('app_defaultprivacy_degree'));
            $user->setUsertype($usertype);
            $user->setTempemail($email);
            $user->setIslocked(sfConfig::get('app_islocked_newreg'));
            $user->save();
            $personal = new Personal();
            $personal->setUserId($user->getId());
            $personal->setFirstname($fname);
            $personal->setMiddlename($mname);
            $personal->setLastname($lname);
            $personal->setEmail($email);
            $personal->setMobile($mob);
            $personal->save();
            $userid = $user->getId();
        } else {
            $user = UserPeer::retrieveByPK($userid);
            $user->setIslocked(sfConfig::get('app_islocked_claimed'));
            $user->save();
        }
        $c = new Criteria();
        $c->add(ClaiminfoPeer::USER_ID, $userid);
        $claiminfo = ClaiminfoPeer::doSelectOne($c);
        if ($claiminfo) {
            $this->user = $claiminfo->getUser();
            $this->claiminfo = $claiminfo;
        } else {
            $claiminfo = new Claiminfo();
            $claiminfo->setUserId($userid);
            $claiminfo->setRoll($roll);
            $claiminfo->setHawa($hawa);
            $claiminfo->setCity($city);
            $claiminfo->setHod($hod);
            $claiminfo->setDirector($director);
            $claiminfo->setTeacher($teacher);
            $claiminfo->setLankashop($lanka);
            $claiminfo->setOther($other);
            $claiminfo->setDusername($dusername);
            $claiminfo->save();
            $this->claiminfo = $claiminfo;
            $this->user = $user;
            if ($user) {
                $username = $user->getUsername();
                $personal = $user->getPersonal();
                $personal->setEmail($email);
                $personal->save();
                $sendermail = sfConfig::get('app_from_mail');
                $sendername = sfConfig::get('app_from_name');
                $to = sfConfig::get('app_to_adminmail');
                $subject = "Registration request for ITBHU Global Org";
                $body = '
	  Hi,
	 
	  I want to connect to ITBHU Global. My verification information is: 
	
	';
                $body = $body . 'Roll Number           : ' . $roll . '
	';
                $body = $body . 'HAWA                  :  ' . $hawa . '
	';
                $body = $body . 'City                  :  ' . $city . '
	';
                $body = $body . 'HoD                   :  ' . $hod . '
	';
                $body = $body . 'Director              :  ' . $director . '
	';
                $body = $body . 'Favourite Teacher     :  ' . $teacher . '
	';
                $body = $body . 'Favuorite Lanka Shop  :  ' . $lanka . '
	';
                $body = $body . 'My Email              :  ' . $email . '
	';
                $body = $body . 'Username I am claiming: ' . $username . '
	';
                $body = $body . 'Desired Username      : '******'
	';
                $body = $body . 'Thanks,';
                $body = $body . '
	' . $user->getFullname();
                //send mail to admin
                $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body);
                //send mail to class authorizer
                $ca = new Criteria();
                $ca->add(UserPeer::GRADUATIONYEAR, $user->getGraduationyear());
                $ca->add(UserPeer::BRANCH_ID, $user->getBranchId());
                $ca->addJoin(UserPeer::ID, UserrolePeer::USER_ID);
                $ca->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_auth'));
                $authusers = UserPeer::doSelect($ca);
                //if class authorizers are available.
                if ($authusers) {
                    foreach ($authusers as $authuser) {
                        $toauth = $authuser->getEmail();
                        $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $toauth, $subject, $body);
                    }
                    $user->setAuthcode(sfConfig::get('app_authcode_classauth'));
                    $user->save();
                } else {
                    //get other authorizers
                    $ugyear = $user->getGraduationyear() - 2;
                    $lgyear = $user->getGraduationyear() + 2;
                    $oa = new Criteria();
                    $oa->add(UserPeer::GRADUATIONYEAR, $ugyear, Criteria::GREATER_EQUAL);
                    $oa->add(UserPeer::GRADUATIONYEAR, $lgyear, Criteria::LESS_EQUAL);
                    $oa->add(UserPeer::BRANCH_ID, $user->getBranchId());
                    $oa->addJoin(UserPeer::ID, UserrolePeer::USER_ID);
                    $oa->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_auth'));
                    $authuserspm = UserPeer::doSelect($oa);
                    //if other authorizers are available
                    if ($authuserspm) {
                        foreach ($authuserspm as $authuserpm) {
                            $toauth = $authuserpm->getEmail();
                            $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $toauth, $subject, $body);
                            $user->setAuthcode(sfConfig::get('app_authcode_otherauth'));
                            $user->save();
                        }
                    } else {
                        // no authorizers were available, send to master list of authorizers
                        $ma = new Criteria();
                        $ma->addJoin(UserPeer::ID, UserrolePeer::USER_ID);
                        $ma->add(UserrolePeer::ROLE_ID, sfConfig::get('app_role_masterauth'));
                        $mauths = UserPeer::doSelect($ma);
                        if ($mauths) {
                            foreach ($mauths as $mauth) {
                                $toauth = $mauth->getEmail();
                                $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $toauth, $subject, $body);
                                $user->setAuthcode(sfConfig::get('app_authcode_masterauth'));
                                $user->save();
                            }
                        } else {
                            $user->setAuthcode(sfConfig::get('app_authcode_none'));
                            $user->save();
                        }
                    }
                }
                $sendermail = sfConfig::get('app_from_mail');
                $sendername = sfConfig::get('app_from_name');
                $to = $email;
                $subject = "Registration request for ITBHU Global Org";
                $body = '
				Dear ' . $user->getFullname() . ',
				
				Thank you for your connect request. We\'ll get back to you shortly.	
				
				
				Admin,
				ITBHU Global
				';
                $mail = myUtility::sendmail($sendermail, $sendername, $sendermail, $sendername, $sendermail, $to, $subject, $body);
            }
        }
        // saving the checkbox data in db
        $c = new Criteria();
        $c->add(PersonalPeer::USER_ID, $user->getId());
        $this->personal = PersonalPeer::doSelectOne($c);
        $c = new Criteria();
        $worktypes = WorktypePeer::doSelect($c);
        foreach ($worktypes as $worktype) {
            if ($this->getRequestParameter($worktype->getId())) {
                $personalWorktype = new PersonalWorktype();
                $personalWorktype->setPersonalId($this->personal->getId());
                $personalWorktype->setWorktypeId($worktype->getId());
                $personalWorktype->save();
            }
        }
    }
Ejemplo n.º 18
0
 public function executeIndex(sfWebRequest $request)
 {
     $this->users = UserPeer::doSelect(new Criteria());
 }
Ejemplo n.º 19
0
 public function execute($request)
 {
     $c = new Criteria();
     $c->setLimit(15);
     $this->users = UserPeer::doSelect($c);
     if (count($this->users) < 1) {
         return sfView::ERROR;
     }
     //        RaykuCommon::getDatabaseConnection();
     //
     //        /* @var $currentUser User */
     //        $currentUser = $this->getUser()->getRaykuUser();
     //
     //        $userId = $currentUser->getId();
     //
     //        $this->userId = $currentUser->getId();
     //
     //
     //        $time = time();
     //
     //
     //
     //        $_SESSION["rateDisplay"] = 1;
     //
     //
     //
     //        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 > 2) {
     //
     //                $close = 21000;
     //            } else if ($count == 2) {
     //
     //                $close = 31000;
     //            } else if ($count == 1) {
     //
     //                $close = 61000;
     //            }
     //
     //            $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());
     //            }
     //
     //
     //
     //            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 = @$_SESSION['tutcourse'];
     //
     //        if (empty($this->course_id)) {
     //            $this->course_id = 1;
     //        }
     //
     //
     //        if (empty($this->cat)) {
     //            $this->cat = 1;
     //        }
     //
     //
     //
     //        $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);
     //        }
     //
     //        $_points = $currentUser->getPoints();
     //
     //
     //        $newUser = array();
     //        $i = 0;
     //        $eachExpertOnlyOnce = array();
     //
     //        foreach ($experts as $exp) {
     //
     //            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() . "") or die("Er-1-->" . mysql_error());
     //            $tutors = mysql_fetch_array($tutorsq);
     //            $tutor = '';
     //
     //            $tutor = explode("-", $tutors['course_id']);
     //            $coursid = $this->course_id;
     //            if (in_array($coursid, $tutor)) {
     //                //echo $coursid;
     //
     //                $_queryCourse = mysql_query("select * from tutor_profile where category = 1 and user_id = " . $exp->getUserId() . "") or die("Er-1-->" . mysql_error());
     //                //echo "select * from tutor_profile where category = 1 and user_id = ".$exp->getUserId()."";
     //            }
     //
     //
     //
     //            if ($_queryCourse && 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)) {
     //
     //                $userFb = UserFbPeer::retrieveByUserId($new['userid']);
     //                if ($userFb) {
     //                    $fb_username = $userFb->getFbUsername();
     //
     //                    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);
     //    }
 }
Ejemplo n.º 20
0
 public function getUsers($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseUserPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collUsers === null) {
         if ($this->isNew()) {
             $this->collUsers = array();
         } else {
             $criteria->add(UserPeer::DEPARTMENT_ID, $this->getId());
             UserPeer::addSelectColumns($criteria);
             $this->collUsers = UserPeer::doSelect($criteria, $con);
         }
     } else {
         if (!$this->isNew()) {
             $criteria->add(UserPeer::DEPARTMENT_ID, $this->getId());
             UserPeer::addSelectColumns($criteria);
             if (!isset($this->lastUserCriteria) || !$this->lastUserCriteria->equals($criteria)) {
                 $this->collUsers = UserPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastUserCriteria = $criteria;
     return $this->collUsers;
 }
Ejemplo n.º 21
0
    </div>
    <div class="bot"></div>
  </div>
  <!--forumside-->

  <!--<div class="clear-both"></div>
  <div class="forumside">
    <div class="top"></div>
    <div class="bg">
      <h1>Top Experts (Overall)</h1>
      <?php 
$c = new Criteria();
$c->add(UserPeer::TYPE, '5');
$c->addDescendingOrderByColumn(UserPeer::POINTS);
$c->setLimit(10);
$experts = UserPeer::doSelect($c);
?>
      <ul class="experts">
        <?php 
foreach ($experts as $expert) {
    ?>
        <?php 
    $c = new Criteria();
    $c->add(PostPeer::POSTER_ID, $expert->getId());
    $c->add(PostPeer::BEST_RESPONSE, '1');
    $best_resp = PostPeer::doCount($c);
    ?>
        <li><?php 
    echo link_to($expert->getName(), sfConfig::get('app_rayku_url') . '/expertmanager/portfolio/' . $expert->getUsername());
    ?>
: <?php 
Ejemplo n.º 22
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(UserPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(UserPeer::DATABASE_NAME);
         $criteria->add(UserPeer::ID, $pks, Criteria::IN);
         $objs = UserPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Ejemplo n.º 23
0
 public function executeSearch()
 {
     $this->mdl = $this->getRequestParameter('mdl');
     $this->fnc = $this->getRequestParameter('fnc');
     $branchid = $this->getRequestParameter('branchoption');
     $chapterid = $this->getRequestParameter('chapteroption');
     $year = $this->getRequestParameter('yearoption');
     $degreeid = $this->getRequestParameter('degreeoption');
     // $currentlyat = $this->getRequestParameter('currentlyat');
     $flag = 0;
     $c = new Criteria();
     if ($branchid != 0) {
         $c->add(UserPeer::BRANCH_ID, $branchid);
         $flag = 1;
     }
     if ($chapterid != 0) {
         $c->addJoin(UserPeer::ID, UserchapterregionPeer::USER_ID);
         $c->addJoin(UserchapterregionPeer::CHAPTERREGION_ID, ChapterregionPeer::ID);
         $c->add(ChapterregionPeer::CHAPTER_ID, $chapterid);
         $flag = 1;
     }
     if ($year != 0) {
         $c->add(UserPeer::GRADUATIONYEAR, $year);
         $flag = 1;
     }
     if ($degreeid != 0) {
         $c->add(UserPeer::DEGREE_ID, $degreeid);
         $flag = 1;
     }
     if ($flag == 1) {
         $this->results = UserPeer::doSelect($c);
     } else {
         $this->flag = 1;
         $this->setFlash('searchnone', 'Select At least one field...');
         return $this->redirect('user/searchform');
     }
     $this->chapterid = $chapterid;
 }
 /**
  * Description            : List all users
  *
  * @return                : Collection of users
  */
 public function listUsers()
 {
     try {
         $criteria = new Criteria();
         $criteria->addAscendingOrderByColumn('NAME');
         return UserPeer::doSelect($criteria);
     } catch (Exception $e) {
         return array();
     }
 }
Ejemplo n.º 25
0
 /**
  * gets an array of User objects NOT related to the current agent
  *
  * The user group is defined by removing users already related to the supplied agentId
  *
  * @param Agent $agent The current agent
  * @return array An array of User objects
  */
 public static function getNewUsersForAgent($criteria)
 {
     $con = Propel::getConnection(self::DATABASE_NAME);
     $agent = sfContext::getInstance()->getUser()->getAttribute('agent', '');
     if ($agent) {
         $agentId = $agent->getId();
     }
     /**
     * @todo speed this up by making an array of current users and passing that to the query a 'not in array[]'
     **/
     //get the current user list for this agent
     $c = new Criteria();
     $c->add(AgentHasUserPeer::AGENT_ID, $agent->getId());
     $curUsers = AgentHasUserPeer::doSelect($c);
     $c = new Criteria();
     $c->addAscendingOrderByColumn(self::NICKNAME);
     $newUsers = UserPeer::doSelect($c);
     foreach ($curUsers as $curUser) {
         $curId = $curUser->getUserId();
         foreach ($newUsers as $key => $newUser) {
             if ($newUser->getId() == $curId) {
                 unset($newUsers[$key]);
                 break;
             }
         }
     }
     //make sure the array is contiguous
     $newUsers = array_merge($newUsers);
     return $newUsers;
 }
Ejemplo n.º 26
0
 /**
  * Gets an array of User 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 EnumItem has previously been saved, it will retrieve
  * related Users from storage. If this EnumItem 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 User[]
  * @throws     PropelException
  */
 public function getUsers($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(EnumItemPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collUsers === null) {
         if ($this->isNew()) {
             $this->collUsers = array();
         } else {
             $criteria->add(UserPeer::TYPE_ID, $this->id);
             UserPeer::addSelectColumns($criteria);
             $this->collUsers = UserPeer::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(UserPeer::TYPE_ID, $this->id);
             UserPeer::addSelectColumns($criteria);
             if (!isset($this->lastUserCriteria) || !$this->lastUserCriteria->equals($criteria)) {
                 $this->collUsers = UserPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastUserCriteria = $criteria;
     return $this->collUsers;
 }
Ejemplo n.º 27
0
 public static function getForExpertCategory($iCategoryId)
 {
     $c = new criteria();
     $c->addJoin(UserPeer::ID, ExpertCategoryPeer::USER_ID, Criteria::JOIN);
     $c->add(ExpertCategoryPeer::CATEGORY_ID, $iCategoryId);
     $c->addDescendingOrderbyColumn(UserPeer::POINTS);
     $c->setLimit(5);
     $c->setDistinct();
     return UserPeer::doSelect($c);
 }