Esempio n. 1
0
 function load($var = '')
 {
     if (!$var && !($var = $this->getId())) {
         return false;
     }
     $sql = 'SELECT staff.created as added, grp.*, staff.* ' . ' FROM ' . STAFF_TABLE . ' staff ' . ' LEFT JOIN ' . GROUP_TABLE . ' grp ON(grp.group_id=staff.group_id)
            WHERE ';
     if (is_numeric($var)) {
         $sql .= 'staff_id=' . db_input($var);
     } elseif (Validator::is_email($var)) {
         $sql .= 'email=' . db_input($var);
     } else {
         $sql .= 'username='******'staff_id'];
     $this->teams = $this->ht['teams'] = array();
     $this->group = $this->dept = null;
     $this->departments = $this->stats = array();
     //WE have to patch info here to support upgrading from old versions.
     if ($time = strtotime($this->ht['passwdreset'] ? $this->ht['passwdreset'] : $this->ht['added'])) {
         $this->ht['passwd_change'] = time() - $time;
     }
     //XXX: check timezone issues.
     if ($this->ht['timezone_id']) {
         $this->ht['tz_offset'] = Timezone::getOffsetById($this->ht['timezone_id']);
     } elseif ($this->ht['timezone_offset']) {
         $this->ht['tz_offset'] = $this->ht['timezone_offset'];
     }
     return $this->id;
 }
Esempio n. 2
0
 function OsticketConfig($section = null)
 {
     parent::Config($section);
     if (count($this->config) == 0) {
         // Fallback for osticket < 1.7@852ca89e
         $sql = 'SELECT * FROM ' . $this->table . ' WHERE id = 1';
         if (($res = db_query($sql)) && db_num_rows($res)) {
             foreach (db_fetch_array($res) as $key => $value) {
                 $this->config[$key] = array('value' => $value);
             }
         }
     }
     //Get the default time zone
     // We can't JOIN timezone table above due to upgrade support.
     if ($this->get('default_timezone_id')) {
         if (!$this->exists('tz_offset')) {
             $this->persist('tz_offset', Timezone::getOffsetById($this->get('default_timezone_id')));
         }
     } else {
         // Previous osTicket versions saved the offset value instead of
         // a timezone instance. This is compatibility for the upgrader
         $this->persist('tz_offset', 0);
     }
     return true;
 }
Esempio n. 3
0
 function login($user, $bk)
 {
     global $ost;
     if (!$user || !$bk || !$bk::$id || !($authkey = $bk->getAuthKey($user))) {
         return false;
     }
     $acct = $user->getAccount();
     if ($acct) {
         if (!$acct->isConfirmed()) {
             throw new AccessDenied(__('Account confirmation required'));
         } elseif ($acct->isLocked()) {
             throw new AccessDenied(__('Account is administratively locked'));
         }
     }
     // Tag the user and associated ticket in the SESSION
     $this->setAuthKey($user, $bk, $authkey);
     //The backend used decides the format of the auth key.
     // XXX: encrypt to hide the bk??
     $user->setAuthKey($authkey);
     $user->refreshSession(true);
     //set the hash.
     if (($acct = $user->getAccount()) && ($tid = $acct->get('timezone_id'))) {
         $_SESSION['TZ_OFFSET'] = Timezone::getOffsetById($tid);
         $_SESSION['TZ_DST'] = $acct->get('dst');
     }
     //Log login info...
     $msg = sprintf(_S('%1$s (%2$s) logged in [%3$s]'), $user->getUserName(), $user->getId(), $_SERVER['REMOTE_ADDR']);
     $ost->logDebug(_S('User login'), $msg);
     if ($bk->supportsInteractiveAuthentication() && ($acct = $user->getAccount())) {
         $acct->cancelResetTokens();
     }
     return true;
 }