PHP User::GetById Examples

PHP User::GetById - 5 examples found. These are the top rated real world PHP examples of User::GetById extracted from open source projects. You can rate examples to help us improve the quality of examples.
 /**
  * @access public
  * @static
  * @return User
  */
 public static function Start()
 {
     session_start();
     Server::UnregisterGlobals('_SESSION');
     if (empty($_SESSION["user_id"])) {
         return User::GetById(0);
     } else {
         return User::GetById($_SESSION["user_id"]);
     }
 }
Example #2
0
         }
     } else {
         Viewer::AddData("error_message", $error_message);
     }
     $action = "rate";
 }
 // If Commented only
 if (isset($_POST["comment_only"])) {
     $idea = Idea::GetById($id);
     if (empty($_POST["comment_text"])) {
         $error_message = I18n::L("Please fill comment text.");
     }
     if (empty($error_message)) {
         $comment = Comment::Add(Comment::Create($_POST["comment_text"], $idea, User::$current));
         $comment_lastnumber = sizeof(Comments::GetByIdea($idea));
         Notify::NotifyOfIdeaComment(User::GetById($idea->user_id), User::$current, $idea, $comment);
         header("Location:" . PREFIX . "/idea?" . $idea->idea_id . "#comment_{$comment_lastnumber}");
         exit;
     } else {
         Viewer::AddData("error_message", $error_message);
     }
     $action = "comment";
 }
 // New idea view
 if (isset($_GET["new"])) {
     if (User::Logged()) {
         Viewer::UseTemplate("new_idea.tpl");
         Viewer::AddData("title", I18n::L("Title New Idea"));
         $action = "new_idea";
     } else {
         Viewer::Restricted();
 /**
  * 
  * @static
  * @return void
  */
 public static function Logout()
 {
     Session::StartUser(User::GetById(0));
 }
Example #4
0
        Viewer::UseTemplate("password_recovery.tpl");
        $action = "password_recovery";
    }
} elseif ((!RESTRICT_ALL || User::Logged()) && !isset($_GET["recover"])) {
    $id = (int) $_SERVER["QUERY_STRING"];
    $user = User::GetById($id);
    if (!empty($id) && $user) {
        //remove user
        if (isset($_GET["removeuser"])) {
            if (User::$current->IsAdmin() && !empty($user->user_email)) {
                $user->user_password = User::GeneratePassword(8);
                $user->user_email = "";
                $user->user_name = $user->user_name . "_removed";
                if (!User::Update($user)) {
                    $error_message = I18n::L("Cannot update user.");
                    $user = User::GetById($id);
                } else {
                    header("Location:" . PREFIX . "/profile?" . $user->user_id);
                    exit;
                }
            } else {
                header("Location:" . PREFIX . "/profile?" . $user->user_id);
                exit;
            }
        }
        Viewer::AddData("user", $user);
        Viewer::AddData("title", I18n::L("Title %s's profile", array($user->user_name)));
        Viewer::AddData("ideas_count", Ideas::GetByUser($user) ? sizeof(Ideas::GetByUser($user)) : 0);
        Viewer::AddData("comments_count", Comments::GetByUser($user) ? sizeof(Comments::GetByUser($user)) : 0);
        Viewer::UseTemplate("user_profile.tpl");
        $action = "profile";
Example #5
0
        Viewer::AddData("title", I18n::L("Title Summary"));
        $action = "summary";
    }
    if (isset($_GET["search"])) {
        $q = $_GET["q"];
        Viewer::UseTemplate("ideas.tpl");
        Viewer::AddData("title", "Search Ideas");
        Viewer::AddData("q", $q);
        if (!empty($q)) {
            Viewer::AddData("ideas", Ideas::SearchByTitle($q));
        }
        $action = "search";
    }
    if (isset($_GET["user"])) {
        $user_id = (int) $_GET["user"];
        $user = User::GetById($user_id);
        Viewer::AddData("ideas", Ideas::GetByUser($user));
        Viewer::AddData("user", $user);
        Viewer::UseTemplate("ideas.tpl");
        Viewer::AddData("title", I18n::L("Title %s's ideas", array($user->user_name)));
        $action = "user";
    }
} else {
    Viewer::Restricted();
    $action = "ideas";
}
if (!$action) {
    Viewer::RequestError();
}
Viewer::AddData("action", $action);
Viewer::Show();