PHP Method User::findByUserName, codiad Code Examples

This page contains top rated real world PHP examples of method User::findByUserName from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: LoginForm.php Project: pauk2012/test_desk
0
 public function login()
 {
     $user = User::findByUserName($this->username);
     if ($user) {
         if ($user->password === $this->password) {
             return $user;
         }
     }
     return false;
 }
Example #2
Show file File: class.RankingsController.php Project: JoffreyO/hackademic
0
 public function go()
 {
     $this->setViewTemplate("rankings.tpl");
     if ($this->isLoggedIn()) {
         $username = $this->getLoggedInUser();
         if (Session::isAdmin() || Session::isTeacher()) {
             $classes = Classes::getAllClasses();
         } else {
             $user = User::findByUserName($username);
             $classes = ClassMemberships::getMembershipsOfUserObjects($user->id);
         }
         $this->addToView('classes', $classes);
     }
     if (!isset($_GET["class"]) || $_GET["class"] == "") {
         $rankings = ChallengeAttempts::getUniversalRankings();
     } else {
         $class_id = $_GET["class"];
         $class = Classes::getClass($class_id);
         if (!$class) {
             $this->addErrorMessage("Not a valid class");
             return $this->generateView();
         } else {
             $rankings = ChallengeAttempts::getClasswiseRankings($class_id);
         }
     }
     $final = array();
     $counter = 1;
     $rank = 1;
     $rankcount = 1;
     $prevcount = null;
     foreach ($rankings as $ranking) {
         if ($counter != 1 && $prevcount == $ranking['count']) {
             $rank = $rankcount;
             $rankcount++;
         }
         if ($counter != 1 && $prevcount != $ranking['count']) {
             $rankcount++;
             $rank = $rankcount;
         }
         $prevcount = $ranking['count'];
         $counter++;
         $temp = array('user_id' => $ranking['user_id'], 'time' => $ranking['time'], 'count' => $ranking['count'], 'username' => $ranking['username'], 'rank' => $rank);
         array_push($final, $temp);
     }
     $this->addToView('rankings', $final);
     return $this->generateView();
 }
Example #3
Show file File: class.ChallengeMenuController.php Project: JoffreyO/hackademic
0
 public function go()
 {
     $username = $this->getLoggedInUser();
     $user = User::findByUserName($username);
     if (!$user) {
         return;
     }
     if (Session::isAdmin() || Session::isTeacher()) {
         $challenges = Challenge::getChallengesFrontend();
     } else {
         $challenges = Challenge::getChallengesAssigned($user->id);
     }
     $menu = array();
     foreach ($challenges as $challenge) {
         $link = array('id' => $challenge->id, 'title' => $challenge->title, 'url' => 'challenges/' . $challenge->pkg_name . '/index.php');
         array_push($menu, $link);
     }
     return $menu;
 }
Example #4
Show file File: class.ChallengeMonitorController.php Project: JoffreyO/hackademic
0
 public function update($status)
 {
     if (!Session::isAdmin() && !Session::isTeacher()) {
         $username = Session::getLoggedInUser();
         $url = $_SERVER['REQUEST_URI'];
         $url_components = explode("/", $url);
         $count_url_components = count($url_components);
         for ($i = 0; $url_components[$i] != "challenges"; $i++) {
         }
         $pkg_name = $url_components[$i + 1];
         $user = User::findByUserName($username);
         $challenge = Challenge::getChallengeByPkgName($pkg_name);
         $user_id = $user->id;
         $challenge_id = $challenge[0]->id;
         if (!ChallengeAttempts::isChallengeCleared($user_id, $challenge_id)) {
             ChallengeAttempts::addChallengeAttempt($user_id, $challenge_id, $status);
         }
     }
 }
Example #5
Show file File: class.ProgressReportController.php Project: JoffreyO/hackademic
0
 public function go()
 {
     $this->setViewTemplate('progressreport.tpl');
     if ($this->isAdmin() || $this->isTeacher()) {
         $this->addToView('search_box', true);
         if (isset($_GET['username'])) {
             $username = $_GET['username'];
         }
     } else {
         $username = Session::getLoggedInUser();
     }
     if (isset($username)) {
         $user = User::findByUserName($username);
         if (!$user) {
             $this->addErrorMessage("You provided an invalid username");
             return $this->generateView();
         } elseif ($user->type) {
             $this->addErrorMessage("Please select a student!");
             return $this->generateView();
         }
         $challenges_of_user = ClassChallenges::getChallengesOfUser($user->id);
         $attempts = ChallengeAttempts::getTotalAttempts($user->id);
         $cleared_challenges = ChallengeAttempts::getClearedChallenges($user->id);
         $data = array();
         foreach ($challenges_of_user as $id => $title) {
             $attempt = isset($attempts[$id]) ? $attempts[$id] : 0;
             $cleared = isset($cleared_challenges[$id]['cleared']) ? $cleared_challenges[$id]['cleared'] : false;
             if ($cleared) {
                 $cleared_on = $cleared_challenges[$id]['cleared_on'];
             } else {
                 $cleared_on = false;
             }
             $arr = array('id' => $id, 'title' => $title, 'attempts' => $attempt, 'cleared' => $cleared, 'cleared_on' => $cleared_on);
             array_push($data, $arr);
         }
         $this->addToView('data', $data);
     } else {
         $this->addErrorMessage("Please select a student to see his progress");
     }
     return $this->generateView();
 }
Example #6
Show file File: app.php Project: juliocesardiaz/Face2Face
0
    $password = $_POST['password'];
    $retype_password = $_POST['retype_password'];
    $latitude = 45.516231;
    $longitude = -122.682519;
    $signed_in = true;
    $user = new User($user_name, $password, $longitude, $latitude, $signed_in, $id = null);
    $user->save();
    return $app['twig']->render('users.html.twig', array('user' => $user, 'avialable_users' => $user->findUsersNear(), 'requests' => $user->findMeetupRequests()));
});
//log in page
$app->get("/login", function () use($app) {
    return $app['twig']->render('login.html.twig');
});
$app->get("/logged_on", function () use($app) {
    $user_name = $_GET['username'];
    $user = User::findByUserName($user_name);
    $user_logged = $user->logIn($user_name, $_GET['password']);
    if ($user_logged == "Wrong Password") {
        return $app['twig']->render('login.html.twig');
    } else {
        return $app['twig']->render('users.html.twig', array('user' => $user_logged, 'avialable_users' => $user->findUsersNear(), 'requests' => $user->findMeetupRequests()));
    }
});
$app->post("/request_meetup", function () use($app) {
    $user1 = User::find($_POST['user1_id']);
    $user2 = User::find($_POST['user2_id']);
    $location = Place::setMeetupLocation($user1, $user2);
    $user1->addMeetUpRequest($user2->getId(), $location->getId());
    return $app['twig']->render('waiting_to_confirm.html.twig', array('user1_id' => $user1->getId(), 'user2_id' => $user2->getId()));
});
//waiting for request respond page
Example #7
Show file File: UserTest.php Project: juliocesardiaz/Face2Face
0
 function test_findByUserName()
 {
     //Arrange
     $user_name = "Nathan";
     $password = "xxx60606";
     $latitude = 45.520969;
     $longitude = -122.679953;
     $signed_in = 1;
     $id = 1;
     $test_user = new User($user_name, $password, $longitude, $latitude, $signed_in, $id);
     $test_user->save();
     $user_name2 = "John";
     $password2 = "xxx";
     $latitude2 = 45.515852;
     $longitude2 = -122.674644;
     $signed_in2 = 1;
     $id2 = 1;
     $test_user2 = new User($user_name2, $password2, $longitude2, $latitude2, $signed_in2, $id2);
     $test_user2->save();
     //Act
     $result = User::findByUserName("John");
     //Assert
     $this->assertEquals($test_user2, $result);
 }
Example #8
Show file File: User.php Project: juliocesardiaz/Face2Face
0
 static function logIn($user_name, $user_password)
 {
     $user = User::findByUserName($user_name);
     if (password_verify($user_password, $user->getPassword()) === false) {
         return "Wrong Password";
     } else {
         $user->updateSignedIn(1);
         return $user;
     }
 }
Example #9
Show file File: class.TryChallengeController.php Project: JoffreyO/hackademic
0
 protected static function isAllowed($username, $challenge_id)
 {
     $user = User::findByUserName($username);
     $classes = ClassMemberships::getMembershipsOfUser($user->id);
     return ClassChallenges::isAllowed($challenge_id, $classes);
 }