예제 #1
0
    /**
     * Get content
     */
    public function getContent()
    {
        headline(t("admin.user.1"));
        $users = RDR_User::getByCondition(null, null, "+username");
        foreach ($users as $user) {
            ?>
            <a href="<?php 
            echo url()->getModifiedUri(array("id" => $user->getId()));
            ?>
"><?php 
            echo s($user->username);
            ?>
 (<?php 
            echo t("user." . $user->role);
            ?>
)</a><br/>
            <?php 
        }
        ?>
        <div class="spacer"></div>
        <?php 
        headline($this->user->getId() ? t("admin.user.3") : t("admin.user.4"));
        $table = new Form_Table($this->form);
        $table->addSubmit(t("saveit"));
        if ($this->user->getId()) {
            $table->addButton(t("admin.user.4"), array("onclick" => "window.location.href = '" . url()->getModifiedUri(false) . "'"));
        }
        echo $table->getHtml();
    }
예제 #2
0
 /**
  * Login with username and password of all is correct
  *
  * @param mixed $username
  * @param mixed $password
  * @param bool $remember
  * @return self | null
  */
 static function login($username, $password, $remember = false)
 {
     $user = RDR_User::getByCondition("username = {0}", array($username));
     if ($user) {
         $user = reset($user);
         if ($user->passwordMatch($password)) {
             session("user.id", $user->getId());
             if ($remember) {
                 cookie("user-id", $user->getId(), dt("now + 1 year")->getUnixtime());
                 cookie("user-id-salted", saltedHash("sha256", $user->getId()), dt("now + 1 year")->getUnixtime());
             }
             return $user;
         }
     }
 }