public static function updateUser()
 {
     $users = UsersDB::getUsersBy('userID', $_SESSION['arguments']);
     if (empty($users)) {
         HomeView::show();
         header('Location: /' . $_SESSION['base']);
     } elseif ($_SERVER["REQUEST_METHOD"] == "GET") {
         $_SESSION['users'] = $users;
         UserView::showUpdate();
     } else {
         $parms = $users[0]->getParameters();
         $parms['userName'] = array_key_exists('userName', $_POST) ? $_POST['userName'] : $users[0]->getUsername();
         $parms['rank'] = array_key_exists('rank', $_POST) ? $_POST['rank'] : $users[0]->getRank();
         $newUser = new User($parms);
         $newUser->setUserID($users[0]->getUserID());
         $user = UsersDB::updateUser($newUser);
         if ($user->getErrorCount() != 0) {
             $_SESSION['user'] = $newUser;
             UserView::showUpdate();
         } else {
             HomeView::show();
             header('Location: /' . $_SESSION['base']);
         }
     }
 }
 /**
  * Maps a table row to an object.
  *
  * @param array $row
  *
  * @return User
  */
 protected function mapObject(array $row)
 {
     $entry = new User();
     $entry->setUserID($row['userid']);
     $entry->setUsername($row['username']);
     $entry->setEmail($row['email']);
     return $entry;
 }
Example #3
0
 public static function factory(Storage $storage, $row)
 {
     $user = new User($storage);
     $user->setUserID($row["userid"]);
     $user->setUsername($row["username"]);
     $user->setPassword($row["password"]);
     $user->setPasswordSalt($row["passwordsalt"]);
     $user->setAPIKey($row["apikey"]);
     $user->setAktiv($row["aktiv"]);
     $user->setDefaultGliederungID($row["defaultgliederungid"]);
     $user->setDefaultDokumentKategorieID($row["defaultdokumentkategorieid"]);
     $user->setDefaultDokumentStatusID($row["defaultdokumentstatusid"]);
     return $user;
 }
Example #4
0
    Utils::Redirect($url);
} else {
    require_once './helper/Page.php';
    require_once './helper/Context.php';
    $page = new Page();
    $page->setTitle('Thông Tin Cá Nhân');
    $page->addCSS("assets/css/profile.css");
    $page->addJavascript("assets/js/jquery.inputmask.bundle.min.js");
    $page->startBody();
    $update = null;
    //update PassWord
    $updatePW = true;
    date_default_timezone_set('Asia/Bangkok');
    $User = new User();
    if (isset($_POST["btnUpdate"])) {
        $User->setUserID($_POST["txtUserID"]);
        $User->setUserName($_POST["txtUserName"]);
        $User->setEmail($_POST["txtEmail"]);
        $dateOfBirth = new DateTime(str_replace('/', '-', $_POST["txtBirthDay"]));
        //d-m-Y
        $User->setDateOfBirth($dateOfBirth);
        $User->setFullName($_POST["txtFullName"]);
        $User->setGender($_POST["cboGender"]);
        $User->setUserPermission(0);
        $userLastModified = new DateTime();
        $User->setUserLastModified($userLastModified);
        $User->setUserPassWord(Context::getCurrentUser()["userPassWord"]);
        $User->update();
        $_SESSION["CurrentUser"] = (array) $User;
        $update = true;
        unset($_SESSION['captcha']);
Example #5
0
<?php

session_start();
if (!isset($_SESSION["IsLogin"])) {
    $_SESSION["IsLogin"] = 0;
    // chưa đăng nhập
}
require_once '../entities/User.php';
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once '../helper/Context.php';
require_once '../helper/Utils.php';
date_default_timezone_set('Asia/Bangkok');
if (Context::IsLogged()) {
    //Cập nhập lại đăng nhập lần cuối
    $User = new User();
    $User->setUserID(Context::getCurrentUser()["userID"]);
    $lastLogon = new DateTime();
    $User->setLastLogon($lastLogon);
    $User->updateLastLogon();
    Context::destroy();
    unset($_SESSION["token"]);
} else {
}
Utils::Redirect("adminLogin.php");
Example #6
0
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "edit":
             $UserDetails = new SoapObject(NCCBIZ . "UserDetails.php", "urn:Object");
             if (!($xmlStr = $UserDetails->getUserDetails($this->formArray["userID"]))) {
                 $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                 $this->tpl->set_var("TableBlock", "User record not found");
             } else {
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                     $this->tpl->set_var("TableBlock", "error xmlDoc");
                 } else {
                     $user = new User();
                     $user->parseDomDocument($domDoc);
                     $this->formArray["userID"] = $user->getUserID();
                     $this->formArray["userType"] = $user->getUserType();
                     $this->formArray["username"] = $user->getUsername();
                     $this->formArray["password"] = $user->getPassword();
                     $this->formArray["personID"] = $user->getPersonID();
                     $this->formArray["status"] = $user->getStatus();
                 }
             }
             $PersonDetails = new SoapObject(NCCBIZ . "PersonDetails.php", "urn:Object");
             if (!($xmlStr = $PersonDetails->getPersonDetails($this->formArray["personID"]))) {
                 $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                 $this->tpl->set_var("TableBlock", "Person record not found");
             } else {
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                     $this->tpl->set_var("TableBlock", "error xmlDoc");
                 } else {
                     $person = new Person();
                     $person->parseDomDocument($domDoc);
                     list($dateArr["year"], $dateArr["month"], $dateArr["day"]) = explode("-", $person->getBirthday());
                     $this->formArray["personID"] = $person->getPersonID();
                     $this->formArray["lastName"] = $person->getLastName();
                     $this->formArray["firstName"] = $person->getFirstName();
                     $this->formArray["middleName"] = $person->getMiddleName();
                     $this->formArray["gender"] = $person->getGender();
                     $this->formArray["birth_year"] = removePreZero($dateArr["year"]);
                     $this->formArray["birth_month"] = removePreZero($dateArr["month"]);
                     $this->formArray["birth_day"] = removePreZero($dateArr["day"]);
                     $this->formArray["maritalStatus"] = $person->getMaritalStatus();
                     $this->formArray["tin"] = $person->getTin();
                     $address = $person->addressArray[0];
                     if (is_a($address, Address)) {
                         $this->formArray["addressID"] = $address->getAddressID();
                         $this->formArray["number"] = $address->getNumber();
                         $this->formArray["street"] = $address->getStreet();
                         $this->formArray["barangay"] = $address->getBarangay();
                         $this->formArray["district"] = $address->getDistrict();
                         $this->formArray["municipalityCity"] = $address->getMunicipalitycity();
                         $this->formArray["province"] = $address->getProvince();
                     }
                     $this->formArray["telephone"] = $person->getTelephone();
                     $this->formArray["mobileNumber"] = $person->getMobileNumber();
                     $this->formArray["email"] = $person->getEmail();
                 }
             }
             $this->tpl->set_block("rptsTemplate", "NewUserPassword", "NewUserPasswordBlock");
             $this->tpl->set_var("NewUserPasswordBlock", "");
             $this->tpl->set_block("rptsTemplate", "OldUserPassword", "OldUserPasswordBlock");
             $this->tpl->set_var("oldNewUserRowspan", 5);
             //$this->tpl->set_var("oldNewUserRowspan", 3);
             $this->tpl->parse("OldUserPasswordBlock", "OldUserPassword", true);
             break;
         case "save":
             /*
             			    if($this->isOldPasswordCorrect()==false){
             			        $this->message = "Error. Cannot Save. Old password incorrect to create new password.";
             		    	    $this->tpl->set_var("message", $this->message);	
             		    	    $this->tpl->parse("MessageBlock", "Message", true);
             		    	    
                                 $this->tpl->set_block("rptsTemplate", "NewUserPassword", "NewUserPasswordBlock");
                                 $this->tpl->set_var("NewUserPasswordBlock", "");
             
                                 $this->tpl->set_block("rptsTemplate", "OldUserPassword", "OldUserPasswordBlock");
                                 $this->tpl->set_var("oldNewUserRowspan", 3);
                                 $this->tpl->parse("OldUserPasswordBlock", "OldUserPassword", true);		    	
             		    	    break;
             			    }
             */
             if ($this->formArray["newPassword"] != "" && $this->formArray["newPassword"] != "null") {
                 $this->formArray["password"] = md5($this->formArray["newPassword"]);
             }
             if ($this->usernameAlreadyExists() == true) {
                 $this->message = "Error. Cannot Save. Username already exists.";
                 $this->tpl->set_var("message", $this->message);
                 $this->tpl->parse("MessageBlock", "Message", true);
                 $this->tpl->set_block("rptsTemplate", "NewUserPassword", "NewUserPasswordBlock");
                 $this->tpl->set_block("rptsTemplate", "OldUserPassword", "OldUserPasswordBlock");
                 if ($this->formArray["personID"] != "") {
                     $this->tpl->set_var("NewUserPasswordBlock", "");
                     $this->tpl->set_var("oldNewUserRowspan", 3);
                     $this->tpl->parse("OldUserPasswordBlock", "OldUserPassword", true);
                 } else {
                     $this->tpl->set_var("oldNewUserRowspan", 2);
                     $this->tpl->parse("NewUserPasswordBlock", "NewUserPassword", true);
                     $this->tpl->set_var("OldUserPasswordBlock", "");
                 }
                 break;
             }
             $PersonEncode = new SoapObject(NCCBIZ . "PersonEncode.php", "urn:Object");
             if ($this->formArray["personID"] != "") {
                 $PersonDetails = new SoapObject(NCCBIZ . "PersonDetails.php", "urn:Object");
                 if (!($xmlStr = $PersonDetails->getPersonDetails($this->formArray["personID"]))) {
                     $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                     $this->tpl->set_var("TableBlock", "Person record not found");
                 } else {
                     if (!($domDoc = domxml_open_mem($xmlStr))) {
                         $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                         $this->tpl->set_var("TableBlock", "error xmlDoc");
                     } else {
                         $person = new Person();
                         $person->parseDomDocument($domDoc);
                         $address = $person->addressArray[0];
                         if (is_a($address, Address)) {
                             $address->setAddressID($this->formArray["addressID"]);
                             $address->setNumber($this->formArray["number"]);
                             $address->setStreet($this->formArray["street"]);
                             $address->setBarangay($this->formArray["barangay"]);
                             $address->setDistrict($this->formArray["district"]);
                             $address->setMunicipalityCity($this->formArray["municipalityCity"]);
                             $address->setProvince($this->formArray["province"]);
                             $address->setDomDocument();
                         }
                         $person->setPersonID($this->formArray["personID"]);
                         $person->setPersonType("adminUser");
                         $person->setLastName($this->formArray["lastName"]);
                         $person->setFirstName($this->formArray["firstName"]);
                         $person->setMiddleName($this->formArray["middleName"]);
                         $person->setGender($this->formArray["gender"]);
                         $person->setBirthday($this->birthdate);
                         $person->setMaritalStatus($this->formArray["maritalStatus"]);
                         $person->setTin($this->formArray["tin"]);
                         $person->setAddressArray($address);
                         $person->setTelephone($this->formArray["telephone"]);
                         $person->setMobileNumber($this->formArray["mobileNumber"]);
                         $person->setEmail($this->formArray["email"]);
                         $person->setDomDocument();
                         $doc = $person->getDomDocument();
                         //echo $doc->html_dump_mem();
                         $xmlStr = $doc->dump_mem(true);
                         if (!($ret = $PersonEncode->updatePerson($xmlStr))) {
                             exit("error update");
                         }
                     }
                 }
             } else {
                 $address = new Address();
                 $address->setNumber($this->formArray["number"]);
                 $address->setStreet($this->formArray["street"]);
                 $address->setBarangay($this->formArray["barangay"]);
                 $address->setDistrict($this->formArray["district"]);
                 $address->setMunicipalityCity($this->formArray["municipalityCity"]);
                 $address->setProvince($this->formArray["province"]);
                 $address->setDomDocument();
                 $person = new Person();
                 $person->setPersonID($this->formArray["personID"]);
                 $person->setPersonType("adminUser");
                 $person->setLastName($this->formArray["lastName"]);
                 $person->setFirstName($this->formArray["firstName"]);
                 $person->setMiddleName($this->formArray["middleName"]);
                 $person->setGender($this->formArray["gender"]);
                 $person->setBirthday($this->birthdate);
                 $person->setMaritalStatus($this->formArray["maritalStatus"]);
                 $person->setTin($this->formArray["tin"]);
                 $person->setAddressArray($address);
                 $person->setTelephone($this->formArray["telephone"]);
                 $person->setMobileNumber($this->formArray["mobileNumber"]);
                 $person->setEmail($this->formArray["email"]);
                 $person->setDomDocument();
                 $doc = $person->getDomDocument();
                 $xmlStr = $doc->dump_mem(true);
                 //echo $this->formArray["ownerID"].$xmlStr;
                 if (!($ret = $PersonEncode->savePerson($xmlStr, $this->formArray["ownerID"]))) {
                     exit("error save");
                 }
             }
             $this->formArray["personID"] = $ret;
             $UserEncode = new SoapObject(NCCBIZ . "UserEncode.php", "urn:Object");
             if ($this->formArray["userID"] != "") {
                 $UserDetails = new SoapObject(NCCBIZ . "UserDetails.php", "urn:Object");
                 if (!($xmlStr = $UserDetails->getUserDetails($this->formArray["userID"]))) {
                     exit("User record not found");
                 } else {
                     if (!($domDoc = domxml_open_mem($xmlStr))) {
                         $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                         $this->tpl->set_var("TableBlock", "error xmlDoc");
                     } else {
                         $user = new User();
                         $user->parseDomDocument($domDoc);
                         $user->setUserID($this->formArray["userID"]);
                         $user->setUserType($this->formArray["userType"]);
                         $user->setUsername($this->formArray["username"]);
                         $user->setPassword($this->formArray["password"]);
                         $user->setPersonID($this->formArray["personID"]);
                         $user->setStatus($this->formArray["status"]);
                         $user->setDomDocument();
                         $doc = $user->getDomDocument();
                         $xmlStr = $doc->dump_mem(true);
                         if (!($ret = $UserEncode->updateUser($xmlStr))) {
                             exit("error update");
                         }
                     }
                 }
             } else {
                 $user = new User();
                 //$user->setUserID($this->formArray["userID"]);
                 $user->setUserType($this->formArray["userType"]);
                 $user->setUsername($this->formArray["username"]);
                 $user->setPassword(md5($this->formArray["password"]));
                 $user->setPersonID($this->formArray["personID"]);
                 $user->setStatus($this->formArray["status"]);
                 $user->setDomDocument();
                 $doc = $user->getDomDocument();
                 $xmlStr = $doc->dump_mem(true);
                 if (!($ret = $UserEncode->saveUser($xmlStr))) {
                     exit("error save");
                 }
             }
             header("location: UserClose.php" . $this->sess->url(""));
             exit;
             break;
         case "cancel":
             header("location: UserClose.php" . $this->sess->url(""));
             exit;
             break;
         default:
             $this->tpl->set_block("rptsTemplate", "UserID", "UserIDBlock");
             $this->tpl->set_var("UserIDBlock", "");
             $this->tpl->set_block("rptsTemplate", "ACK", "ACKBlock");
             $this->tpl->set_var("ACKBlock", "");
             $this->tpl->set_block("rptsTemplate", "NewUserPassword", "NewUserPasswordBlock");
             $this->tpl->set_var("oldNewUserRowspan", 2);
             $this->tpl->parse("NewUserPasswordBlock", "NewUserPassword", true);
             $this->tpl->set_block("rptsTemplate", "OldUserPassword", "OldUserPasswordBlock");
             $this->tpl->set_var("OldUserPasswordBlock", "");
     }
     $this->setForm();
     if ($this->message == "") {
         $this->tpl->set_var("MessageBlock", "");
     }
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $this->tpl->p("templatePage");
 }
Example #7
0
<?php

session_start();
require_once '../classes/connection.class.php';
require_once '../classes/user.class.php';
$adduserobj = new User();
/*echo '<pre>';
print_r($adduserobj);
echo '</pre>';
exit;*/
$user_id = mysqli_real_escape_string($adduserobj->conxn, $_POST['user_id']);
$username = mysqli_real_escape_string($adduserobj->conxn, $_POST['username']);
$password = mysqli_real_escape_string($adduserobj->conxn, $_POST['password']);
$password = md5($password);
$adduserobj->setUserID($user_id);
$adduserobj->setUsername($username);
$adduserobj->setPassword($password);
$flag = $adduserobj->validateUser();
/*echo '<pre>';
print_r ($adduserobj);
echo '</pre>';
exit;*/
if ($flag) {
    header('location:../../fds/index.php');
    $_SESSION['username'] = $username;
} else {
    header('location:../../fds/login.php');
    $_SESSION['msg'] = $adduserobj->msg = "Sorry incorrect username and password";
}
Example #8
0
<?php

include 'classes/connection.class.php';
include 'classes/user.class.php';
$user_id = isset($_GET['user_id']) ? (int) $_GET['user_id'] : '';
$objUser = new User();
$objUser->setUserID($user_id);
$views = $objUser->viewUser();
foreach ($views as $value) {
    ?>
<form name="form1" method="post" action="process/process_update_user.php">
  <table width="669" border="1">
    <tbody>
      <tr>
        <th colspan="2" scope="row">Please Edit User</th>
      </tr>
      <tr>
        <th scope="row">Username</th>
        <td>
        <input name="username" type="text" id="username" value="<?php 
    echo $value['username'];
    ?>
" placeholder="username"></td>
      </tr>
      <tr>
        <th scope="row">Password</th>
        <td>
        <input name="password" type="password" required="required" id="password" value="<?php 
    echo $value['password'];
    ?>
" placeholder="password"></td>
    public function getUser($login)
    {
        if ($this->userLogin == 'NONE') {
            return false;
        }

        if (strlen($login)==0) {
            return new AnonymousUser();       
        }

        if ($userData = $this->getUserData($login)) {
            $user = new User($this);
            $user->setUserID($userData['userID']);
            $user->setEmail($userData['email']);
            $user->setFullName($userData['fullname']);
            return $user;
        } else {
            return false;
            return AUTH_USER_NOT_FOUND; // not sure which one is correct yet
        }
    }
Example #10
0
<?php

//require_once('../bootstrap.php');
//session_start();
require_once 'classes/connection.class.php';
require_once 'classes/user.class.php';
require_once 'classes/locate.class.php';
$user_id = isset($_GET['user_id']) ? $_GET['user_id'] : '';
$objdelete = new User();
$objdelete->setUserID($user_id);
$flag = $objdelete->deleteUser();
/*echo $objdelete->sql;
exit;*/
/*echo '<pre>';
print_r($flag);
echo'</pre>';
exit;*/
if ($flag) {
    //echo "user already deleted";
    new Locate('index.php?page=user&action=view');
    $_SESSION['msg'] = $objdelete->msg = "User deleted sucessfully";
} else {
    header('location:../index.php?page=user&action=view&err=usernotdeleted');
}
 if ($admin_password != $Previous_Password) {
     $errors[] = "previous password don't match";
     admin_redirect_error(Error_Type::PRV_PASSWORD_DONT_MATCH);
 }
 if ($admin_controller->Check_User_Name_For_Edit($User_Name, $User_ID)) {
     admin_redirect_error(Error_Type::SAME_USER_NAME);
 }
 /**
  * if there is no error
  */
 if (empty($errors)) {
     /**
      * instantiate a new user
      */
     $new_user = new User($User_Name, $New_Password);
     $new_user->setUserID($User_ID);
     /**
      * Edit the user and a new user will be returned if the user is updated
      */
     $edited = $admin_controller->Admin_Edit_Profile($new_user);
     /**
      * inform the admin about the result
      */
     if ($edited) {
         admin_redirect_success();
     } else {
         admin_redirect_error(Error_Type::DATA_BASE);
     }
 } else {
     admin_redirect_error(Error_Type::FORM);
 }
 /**
  * @param User $admin
  * @return bool
  * this will edit the admin profile
  */
 function Admin_Edit_Profile(User $admin)
 {
     $this->User_Name = mysqli_real_escape_string($this->getDbc(), trim($admin->getUserName()));
     $this->User_Password = mysqli_real_escape_string($this->getDbc(), trim($admin->getUserPassword()));
     $this->User_ID = mysqli_real_escape_string($this->getDbc(), trim($admin->getUserID()));
     $query = "UPDATE user\n\t\t\t      SET User_Name='{$this->User_Name}',User_Password=sha1('{$this->User_Password}')\n\t\t\t      WHERE ID='{$this->User_ID}'";
     $result = mysqli_query($this->getDbc(), $query);
     $updated_admin = new User($this->User_Name, $this->User_Password);
     $updated_admin->setUserID($this->User_ID);
     $updated_admin->setUserType(User_Type::ADMIN);
     /**
      * update the logged in user
      * and return true
      */
     session_start();
     $_SESSION["Logged_In_User"] = $updated_admin;
     return TRUE;
 }
Example #13
0
    echo "No User with this telephone number";
} else {
    echo "The value of User with a specified telephone number is:<br>{$user}<br>";
}
?>

<h2>It should get a user name by user id</h2>
<?php 
DBMaker::create('ptest');
Database::clearDB();
$db = Database::getDB('ptest');
$userNames = UsersDB::getUserValuesBy('userName', 'userID', 1);
print_r($userNames);
?>
<h2>It should allow update of the user name</h2>
<?php 
DBMaker::create('ptest');
Database::clearDB();
$db = Database::getDB('ptest');
$users = UsersDB::getUsersBy('userID', 1);
$user = $users[0];
echo "<br>Before update: {$user} <br>";
$parms = $user->getParameters();
$parms['userName'] = '******';
$newUser = new User($parms);
$newUser->setUserID(1);
$user = UsersDB::updateUser($newUser);
echo "<br>After update: {$user} <br>";
?>
</body>
</html>
Example #14
0
 private static function getUser($sql)
 {
     include 'connect.php';
     //$sql = "SELECT * FROM users WHERE id = " . $userID;
     //echo $sql;
     $result = mysql_query($sql);
     $row = mysql_fetch_array($result);
     mysql_close();
     if ($row) {
         $usr = new User();
         $usr->setUserID($row['id']);
         $usr->setUsername($row['username']);
         $usr->setAvailability($row['status'] == 'available' ? true : false);
         $usr->setChatID($row['chat_id']);
         $usr->isFB = $row['isFB'] == 0 ? false : true;
         return $usr;
     } else {
         return false;
     }
 }
<?php

require_once 'classes/User.php';
require_once 'core/initPublic.php';
if (Session::exists('home')) {
    echo Session::flash('home');
}
$user = new User();
$user->setUserID("ID");
$user->setUsername("Frank");
$user->setEmail("*****@*****.**");
$user->setPassword("1234567");
$user->setFullname("Frank Edwards");
$user->setJoinedDate("23/2/2015");
print "User Details <br/><br/>";
print "<br/>User ID = " . $user->getUserID();
print "<br/>Username = "******"<br/>Email = " . $user->getEmail();
print "<br/>Password = "******"<br/>Full Name = " . $user->getFullname();
print "<br/>Joined Date = " . $user->getJoinedDate();
/* print "<br/>UserID = ".$user->data()->ID;
  print "<br/>Username = "******"<br/>User Email = ".$user->data()->email;
  print "<br/>Full Name = ".$user->data()->name;
  print "<br/>Password = "******"<br/>Joined Date = ".$user->data()->joined; 
  print "<br/> Logged in = " .$user->isLoggedIn();
  print "<br/>Exists = ".$user->exists();
  /*print "<br/>Image Name = ".$user->getProtection();
  print "<br/>Quantity = ".$user->getIsAdmin(); */
Example #16
0
function getUser($email)
{
    global $config_db;
    try {
        // Check results
        $user = new User();
        foreach ($config_db->query("SELECT " . "* " . "FROM " . "users " . "WHERE " . "userEmail = '{$email}'") as $row) {
            $user->setFirstName($row['userFirstName']);
            $user->setLastName($row['userLastName']);
            $user->setEmail($row['userEmail']);
            $user->setPassword($row['userPassword']);
            $user->setSystemAdmin($row['systemAdmin']);
            $user->setUserID($row['user_id']);
        }
        return $user;
    } catch (Exception $ex) {
        $this->showMessage($ex);
    }
}
Example #17
0
 function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "edit":
             $UserDetails = new SoapObject(NCCBIZ . "UserDetails.php", "urn:Object");
             if (!($xmlStr = $UserDetails->getUserDetails($this->formArray["userID"]))) {
                 $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                 $this->tpl->set_var("TableBlock", "record not found");
             } else {
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                     $this->tpl->set_var("TableBlock", "error xmlDoc");
                 } else {
                     $user = new User();
                     $user->parseDomDocument($domDoc);
                     $this->formArray["userID"] = $user->getUserID();
                     $this->formArray["userType"] = $user->getUserType();
                     $this->formArray["username"] = $user->getUsername();
                     $this->formArray["password"] = $user->getPassword();
                     $this->formArray["personID"] = $user->getPersonID();
                 }
             }
             break;
         case "save":
             $UserEncode = new SoapObject(NCCBIZ . "UserEncode.php", "urn:Object");
             if ($this->formArray["userID"] != "") {
                 $UserDetails = new SoapObject(NCCBIZ . "UserDetails.php", "urn:Object");
                 if (!($xmlStr = $UserDetails->getUserDetails($this->formArray["userID"]))) {
                     exit("record not found");
                 } else {
                     if (!($domDoc = domxml_open_mem($xmlStr))) {
                         $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                         $this->tpl->set_var("TableBlock", "error xmlDoc");
                     } else {
                         $user = new User();
                         $user->parseDomDocument($domDoc);
                         $user->setUserID($this->formArray["userID"]);
                         $user->setUserType($this->formArray["userType"]);
                         $user->setUsername($this->formArray["username"]);
                         $user->setPassword($this->formArray["password"]);
                         $user->setPersonID($this->formArray["personID"]);
                         $user->setDomDocument();
                         $doc = $user->getDomDocument();
                         $xmlStr = $doc->dump_mem(true);
                         if (!($ret = $UserEncode->updateUser($xmlStr))) {
                             exit("error update");
                         }
                     }
                 }
             } else {
                 $user = new User();
                 //$user->setUserID($this->formArray["userID"]);
                 $user->setUserType($this->formArray["userType"]);
                 $user->setUsername($this->formArray["username"]);
                 $user->setPassword($this->formArray["password"]);
                 $user->setPersonID($this->formArray["personID"]);
                 $user->setDomDocument();
                 $doc = $user->getDomDocument();
                 $xmlStr = $doc->dump_mem(true);
                 if (!($ret = $UserEncode->saveUser($xmlStr))) {
                     exit("error save");
                 }
             }
             $this->formArray["userID"] = $ret;
             header("location: UserEncode.php");
             exit;
             break;
         case "cancel":
             header("location: UserList.php");
             exit;
             break;
         default:
             $this->tpl->set_block("rptsTemplate", "UserID", "UserIDBlock");
             $this->tpl->set_var("UserIDBlock", "");
             $this->tpl->set_block("rptsTemplate", "ACK", "ACKBlock");
             $this->tpl->set_var("ACKBlock", "");
     }
     $this->setForm();
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $this->tpl->p("templatePage");
 }