<?php
/*********************************************************************************
* TES is a Time and Expense Management program developed by
* Initechs, LLC. Copyright (C) 2009 - 2010 Initechs LLC.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY INITECHS, INITECHS DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact Initechs headquarters at 1841 Piedmont Road, Suite 301,
* Marietta, GA, USA. or at email address hide@address.com
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display od the "Initechs" logo.
* If the display of the logo is not reasonably feasible for technical reasons,
* the Appropriate Legal Notices must display the words "Powered by Initechs".
********************************************************************************/
$basedir = dirname(__FILE__) . '/..';
require_once("$basedir/initialize.php");
require_once ("$basedir/users/DbObj.php");
class User extends UserData
{
public $Userid;
public $FullName;
public $Password;
public $Email;
public $JoinDate;
public $Class;
public $Status;
public $AuthId;
public $DateFormat;
public $Language;
public function __construct($users_id)
{
if ($users_id == '')
throw new iInvalidDataException();
$UserData = new UserData();
$user_row = $UserData->fetchRow('users', 'users_id', $users_id);
if ($user_row <> null)
{
$this->Userid = $user_row['users_id'];
$this->FullName = $user_row['fullname'];
$this->Password = $user_row['password'];
$this->EmailAddress = $user_row['email'];
$this->JoinDate = $user_row['joindate'];
$this->UserStatus = $user_row['status'];
$this->AuthId = $user_row['authorizations_id'];
$this->DateFormat = $user_row['dateformat'];
$this->Language = $user_row['language'];
}
}
public function registerUser($ui, $pw)
{
if (($ui == '')
or ($pw == '')
or !$this->checkPassword($pw))
return false;
if ($this->UserStatus <> '10')
throw new iBLError('users_id', 'er0039');
$_SESSION['userid'] = $this->Userid;
$_SESSION['fullname'] = $this->FullName;
$_SESSION['authid'] = $this->AuthId;
$_SESSION['dateformat'] = $this->DateFormat;
$_SESSION['language'] = $this->Language;
$this->loadLiteral($_SESSION['language']);
return true;
}
public function loadLiteral($language='ENG')
{
$language = strtoupper($language);
$where = "language = '$language'";
$DbObj = new dbObj();
$literal_rows = $DbObj->fetchRowsbyWhereClause('literals', $where);
if ($literal_rows == null)
return;
foreach ($literal_rows as $literal_row)
{
$_SESSION['literal'][strtolower($literal_row['eng_label'])] = $literal_row['label'];
}
return;
}
public function checkPassword($pw_to_check)
{
return (md5($pw_to_check) == $this->Password) ? true : false;
}
}
?>