Example #1
0
 function panel()
 {
     $this->load->model('user');
     $this->load->model('script');
     $this->load->library('facebook');
     if ($signedUp = $this->session->flashdata('signedUp')) {
         $this->session->keep_flashdata('signedUp');
         $viewData['signedUp'] = $signedUp;
     }
     if ($this->input->post('changePassword')) {
         if ($this->_checkToken()) {
             $this->load->library('validation');
             $rules['currentPassword'] = '******';
             $rules['newPassword'] = '******';
             $rules['newPasswordRepeat'] = 'required|matches[newPassword]';
             $fields['currentPassword'] = '******';
             $fields['newPassword'] = '******';
             $fields['newPasswordRepeat'] = 'new password repeated';
             $this->validation->set_rules($rules);
             $this->validation->set_fields($fields);
             if ($this->validation->run() === true) {
                 $user = new User();
                 $user->setKey($this->_getUser());
                 $user->retrieve();
                 if ($user->get('password') === $user->makePass($this->input->post('currentPassword'))) {
                     $user->set('password', $user->makePass($this->input->post('newPassword')));
                     $viewData['checkpoints'][] = 'You have successfully changed your password.';
                     $user->update();
                 } else {
                     $viewData['errors'][] = 'You did not enter your current password correctly.';
                 }
             }
         }
     }
     $viewData['token'] = $this->_token();
     $user = new User();
     $script = new Script();
     $user->retrieve($this->session->userdata('email'));
     if ($user->getType() === User::FB_CONNECT) {
         $viewData['email'] = false;
         $viewData['UID'] = $user->getKey();
         $viewData['name'] = $user->name();
         $viewData['institution'] = $user->institution();
         if (!($subject = $user->subject())) {
             $subject = 'Not specified on Facebook';
         }
         $viewData['subject'] = $subject;
         $viewData['fbEmail'] = $user->get('fbEmail');
     } else {
         $viewData['email'] = $user->getKey();
         $viewData['name'] = $user->get('name');
         $user->get('subject') ? $viewData['subject'] = $user->get('subject') : ($viewData['subject'] = 'Not specified');
         $viewData['institution'] = $user->get('institution');
     }
     //$viewData['messages'][] = 'We are on day '.ceil((time() - 1229536800)/86400).' of the Exambuff pilot. Thanks for taking part!';
     $this->_template('user/panel', 'Your account', 'my-account', $viewData);
 }
Example #2
0
 /**
  * sign in, set the remember key if necessary
  *
  * @param User $user
  * @param boolean $rememberMe
  */
 public function signIn(User $user, $rememberMe = false)
 {
     $this->setAuthenticated(true);
     $this->setUserTypeCredentials($user->getType());
     if ($rememberMe) {
         $cookie_key = MyTools::generateRandomKey();
         $user->setCookieKey($cookie_key);
         $user->save();
         $value = base64_encode(serialize(array($cookie_key, $user->getUsername())));
         sfContext::getInstance()->getResponse()->setCookie('rayku', $value, time() + 60 * 60 * 24 * 15, '/', sfConfig::get('app_cookies_domain'));
     }
     $this->setAttribute('user_id', $user->getId());
     $user->save();
 }
 /**
  * create html info, if current contact is also a user
  * @return string html-content
  * @todo find better solution than style tag in html
  */
 function createUserInfo()
 {
     $cont = '';
     if ($this->contact->isUser()) {
         $uid = $this->contact->isUser();
         $user = new User($uid);
         if ($_SESSION['user']->contact['id'] == $this->contact->contact['id']) {
             if ($_SESSION['user']->isAtLeast('admin')) {
                 $cont .= '<div class="user-info"><span class="user-info-title">User type</span><span class="user-info-info"><a href="#" onclick="effect_1 = Effect.SlideDown(\'userChanger' . $uid . '\',{duration:1.2}); return false;">' . $user->getType() . '</a></span></div>';
             } else {
                 $cont .= '<div class="user-info"><span class="user-info-title">User type</span><span class="user-info-info">' . $user->getType() . '</span></div>';
             }
         } elseif ($_SESSION['user']->isAtLeast('admin')) {
             $cont .= '<div class="user-info"><span class="user-info-title">This is a user</span><span class="user-info-info"><a href="../user/options.php?userid=' . $uid . '">show/change settings</a></span></div>';
             $cont .= '<div class="user-info"><span class="user-info-title">User type</span><span class="user-info-info"><a href="#" onclick="effect_1 = Effect.SlideDown(\'userChanger' . $uid . '\',{duration:1.2}); return false;">' . $user->getType() . '</a></span></div>';
         }
         if ($_SESSION['user']->isAtLeast('admin')) {
             $cont .= '<div class="user-info" id="userChanger' . $uid . '" style="display: none;"><span class="user-info-title"></span><span class="user-info-info">Change:
                 <a href="../admin/saveadmin.php?mode=chtype&amp;userid=' . $uid . '&amp;type=admin">admin</a>
                 <a href="../admin/saveadmin.php?mode=chtype&amp;userid=' . $uid . '&amp;type=manager">manager</a>
                 <a href="../admin/saveadmin.php?mode=chtype&amp;userid=' . $uid . '&amp;type=user">user</a>
                 <a href="../admin/saveadmin.php?mode=chtype&amp;userid=' . $uid . '&amp;type=guest">guest</a>
             </span></div>';
         }
     }
     if ($cont != '') {
         return '<div class="other-spacer"></div>' . $cont;
     } else {
         return '';
     }
 }
    $errorHandler->error('login', 'Please enter a password');
    // fatal
    // redisplay login page
    $page = new PageLoginScreen(isset($_GET['redirect']) ? $_GET['redirect'] : '');
    echo $page->create();
    exit;
}
// create user class with email
$user = new User(StringHelper::cleanGPC($_POST['user_email']));
// was the email correct?
if ($user->id !== null) {
    // was the password correct?
    if ($user->login(StringHelper::cleanGPC($_POST['user_password']))) {
        $_SESSION['user'] =& $user;
        $options = new Options($user);
        if ($user->getType() == 'register') {
            if ($user->isConfirmed()) {
                // New User -> Attach Contact
                if ($user->attachContact()) {
                    $flag = 'found';
                } else {
                    $flag = 'created';
                }
                $page = new PageRegister('confirm', $flag, isset($_GET['redirect']) ? $_GET['redirect'] : '');
                echo $page->create();
                exit;
            } else {
                // User#136 has set an error message; redisplay login page
                $page = new PageLoginScreen(isset($_GET['redirect']) ? $_GET['redirect'] : '');
                echo $page->create();
                exit;
 /**
  * Search one user by one similar name
  * 
  * @author Jonathan Sandoval <*****@*****.**>
  * @param  User           $user         Pseudo-user with the data to search
  * @param  string         $operator     To search with 'or' or 'and'
  * @param  string         $order        The type of sort of the User
  * @param  integer        $begin        The number of page to display the registry
  * @return Array[User] $users     User objects with the similar name or null
  */
 static function advancedSearchUser($user = null, $operator = 'AND', $order = 'id', $begin = 0)
 {
     if ($user === null) {
         return null;
     }
     $tableUser = DatabaseManager::getNameTable('TABLE_USER');
     $tableChurch = DatabaseManager::getNameTable('TABLE_CHURCH');
     $username = $user->getUsername();
     $type = $user->getType();
     $online = $user->getOffline();
     $user->getId() == 0 ? $id = '' : ($id = $user->getId());
     if ($online == 'true') {
         $online = "0";
     } else {
         $online = "";
     }
     if ($type == '0') {
         $type = "";
     } else {
         if ($type == '1') {
             $type = "A";
         } else {
             if ($type == '2') {
                 $type = "G";
             }
         }
     }
     $queryChurch = "(";
     $posibleChurch = $user->getIdChurch();
     if ($posibleChurch !== NULL) {
         for ($i = 0; $i < sizeof($posibleChurch) - 1; $i++) {
             $queryChurch = $queryChurch . $posibleChurch[$i]->getId() . ",";
         }
         $queryChurch = $queryChurch . $posibleChurch[sizeof($posibleChurch) - 1]->getId() . ")";
         $queryChurch = "(c.id IN " . $queryChurch . ")";
     }
     $query = "SELECT b.* FROM {$tableUser} AS b\r\n                        JOIN {$tableChurch} AS c  ON b.idChurch = c.id\r\n                        WHERE b.id               LIKE '%{$id}%'        {$operator}\r\n                              b.type             LIKE '%{$type}%'      {$operator}\r\n                              b.username         LIKE '%{$username}%'  {$operator} ";
     if ($online !== '') {
         $query = $query . "b.offline = {$online} {$operator} ";
     }
     if ($queryChurch != '(') {
         $query = $query . $queryChurch . " ";
     } else {
         $query = $query . "(c.id IN ())" . " ";
     }
     if ($order == 'username') {
         $query = $query . " ORDER BY b.username";
     } else {
         if ($order == 'nameChurch') {
             $query = $query . " ORDER BY c.name";
         } else {
             $query = $query . " ORDER BY b.id DESC";
         }
     }
     $query = $query . " LIMIT " . strval($begin * 10) . ", 11 ";
     $arrayUsers = DatabaseManager::multiFetchAssoc($query);
     $users = array();
     if ($arrayUsers !== NULL) {
         $i = 0;
         foreach ($arrayUsers as $user) {
             if ($i == 10) {
                 continue;
             }
             $users[] = self::ArrayToUser($user);
             $i++;
         }
         return $users;
     } else {
         return null;
     }
 }
Example #6
0
<?php

include "includes/functions.inc";
if (!Tools::isUserLogged()) {
    Tools::redirect("signin.php");
}
$school = new School($_SESSION['school_id']);
$user = new User($_SESSION['id']);
//echo $user->getType();
if ($user->getType() == "teacher") {
    $teacher = new Teacher($_SESSION['id']);
    if ($class_check = $teacher->getClassID()) {
        $class = new SchoolClass($class_check);
    }
    include "app/teacher/t_students.php";
}
Example #7
0
 /**
  * @return string
  * @param User $user
  */
 public static function add($user)
 {
     if (UserCtrl::has($user->getUsername())) {
         return 'Duplicate User!';
     } else {
         $db = DB::getConn();
         $stm = $db->prepare('insert into Users (username, password, type) values (:uid, :pwd, :type)');
         $stm->bindParam(':uid', $user->getUsername());
         $stm->bindParam(':pwd', $user->getPassword());
         $stm->bindParam(':type', $user->getType());
         return $stm->execute();
     }
 }
Example #8
0
 public function getType()
 {
     return 'This is an Member with a type of .... ' . parent::getType();
 }
Example #9
0
	public function getType() {
		return 'Hello from '. parent::getType();
	}