/**
  *
  */
 public function register_user_informationAction()
 {
     $dataRequest = $this->request->getJsonPost();
     $fields = array("key", "name", "last_name", "email", "image", "phone", "uuid", "platform");
     if ($this->_checkFields($dataRequest, $fields)) {
         if ($this->_validKey()) {
             $user = new User();
             $user->setName($dataRequest->name);
             $user->setLastName($dataRequest->last_name);
             $user->setEmail($dataRequest->email);
             $user->setImage($dataRequest->image);
             $user->setPhone($dataRequest->phone);
             $user->setUuid($dataRequest->uuid);
             $user->setPlatform($dataRequest->platform);
             $user->setSession(true);
             $user->setFirstConnection($this->_dateTime->format("Y-m-d H:m:s"));
             $user->setLastConnection($this->_dateTime->format("Y-m-d H:m:s"));
             $user->setStatus(1);
             if ($user->save()) {
                 $this->setJsonResponse(ControllerBase::SUCCESS, ControllerBase::FAILED_MESSAGE, array("status" => $this->strings->getString("http", "success"), "message" => $this->strings->getString("user", "insert_success"), "data" => array("user_id" => $user->getIdUser())));
             } else {
                 $this->setJsonResponse(ControllerBase::SUCCESS, ControllerBase::FAILED_MESSAGE, array("status" => $this->strings->getString("http", "error"), "message" => $this->_checkError($user), "data" => $return));
             }
         }
     }
 }
Example #2
0
 /**
  * Creates new user
  *
  * @param email - required -
  *           The email address of the new user.
  *           Maximum 128 characters are allowed in the email address.
  * @param password - required -
  *           The password for the new user.
  *           Minimum 5 characters are required for the password.
  * @param firstName - optional -
  *            The first name of the user.
  *            Maximum 128 characters are allowed in the first name.
  * @param lastName - optional -
  *            The last name of the user.
  *            Maximum 128 characters are allowed in the last name.
  * @return The User object. If the operation was successful, the object contains the status, if not, the object
  * 			contains the error code and message.
  */
 public function createUser($email, $password, $firstName = '', $lastName = '')
 {
     $parameters = array('email' => $email, 'password' => $password);
     if ($firstName !== '') {
         $parameters['firstname'] = $firstName;
     }
     if ($lastName !== '') {
         $parameters['lastname'] = $lastName;
     }
     $urld = 'dpi/v1/user';
     $this->response = $this->restTransportInstance->sendRequest($urld, $parameters, self::HTTP_POST);
     $responseBody = simplexml_load_string($this->response);
     $returnObject = new User();
     if ($responseBody === false) {
         $errorCode = 'N/A';
         $errorMessage = 'The server has encountered an error, please try again.';
         $errorObject = new ErrorStatus($errorCode, $errorMessage);
         $returnObject->setErrorStatus($errorObject);
     } else {
         $errorStatus = $responseBody->errorStatus;
         if (empty($errorStatus)) {
             $status = (string) $responseBody->status;
             $returnObject->setStatus($status);
         } else {
             $errorCode = (string) $responseBody->errorStatus->code;
             $errorMessage = (string) $responseBody->errorStatus->message;
             $errorObject = new ErrorStatus($errorCode, $errorMessage);
             $returnObject->setErrorStatus($errorObject);
         }
     }
     return $returnObject;
 }
 public function insert(User $user)
 {
     $user->setId(null);
     $user->setStatus(User::PENDING);
     $sql = '
         INSERT INTO user_tb(id,first_name, user_password,status)
             VALUES (:id,:first_name,:user_password,:status)';
     return $this->execute($sql, $user);
 }
Example #4
0
 /**
  * Vytvoří nového uživatele a uloží jej do databáze.
  * @param \Nette\Utils\ArrayHash $values
  * @param int $defaultGroupId
  * @param int $status
  * @return \Model\Core\User\User
  */
 public function createNewUser(\Nette\Utils\ArrayHash $values, $defaultGroupId = BasicGroupId::USER, $status = \Model\Common\RecordStatus::VALID)
 {
     $user = new User();
     $user->setUsername($values->username);
     $user->setPassword(\Nette\Security\Passwords::hash($values->password));
     $user->setEmail($values->email);
     $user->setGroupId($defaultGroupId);
     $user->setStatus($status);
     $this->saveUser($user);
     return $user;
 }
Example #5
0
function create_user()
{
    $user = new User();
    $user->setName("abebe");
    $user->setFathersName("kebede");
    $user->setGrandFathersName("welede");
    $user->setEmailQuota("500000S");
    $user->setGid("2000");
    $user->setExpiresAt("2010-08-08");
    $user->setStatus("Disactivated");
    $user->setEmailLocalPart("abebe.kebede" . rand(1, 1000));
    $user->save();
    return $user;
}
Example #6
0
 public function executeAddUser(sfWebRequest $request)
 {
     if ($request->isMethod('POST')) {
         $password = md5($this->getRequestParameter('password'));
         $user = new User();
         $user->setEmployeeId($this->getRequestParameter('employee_id'));
         $user->setRoleId($this->getRequestParameter('role_id'));
         $user->setUser($this->getRequestParameter('user'));
         $user->setPassword($password);
         $user->setStatus(Constant::RECORD_STATUS_ACTIVE);
         $user->save();
         $this->getUser()->setFlash('SUCCESS_MESSAGE', 'UserName and Password assigned Successfully.');
         $this->redirect('User/list');
     }
 }
function _newUserToken($token = '')
{
    if (!is_null($token)) {
        $user = new User(getdbh());
        $result = $user->checkConfirmationToken($token);
        if (isset($result['ID']) && isset($result['EMAIL'])) {
            if ($setStatus = $user->setStatus($result['ID'], 'NO_GROUP')) {
                $data['msg'][] = 'Emailul a fost confirmat';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
        } else {
            redirect('error/404');
        }
    }
}
Example #8
0
 public function run()
 {
     //        echo "inside model/run";
     $uid = $_POST['login'];
     $password = MD5($_POST['password']);
     $po = UserDAOImpl::doLogin($uid, $password);
     // get from DB
     /**
      * 1. no record found
      * 2. user email and password matched and status is activated
      * 3. user email and password matched and status is non-activated
      * 4. exception
      */
     if (null == $po) {
         $msg = NO_RECORD_PROMPT . BACK_TO_LOGIN_LINK;
         //  header('location: ../login');
     } elseif ($po->status == STATUS_ACTIVATED) {
         $user = new User();
         // vo : used to convey user info
         $user->setId($po->id);
         $user->setUserName($po->username);
         $user->setPassword($po->password);
         $user->setEmail($po->email);
         $user->setStatus($po->status);
         $user->setToken($po->token);
         $user->setTokenExptime($po->token_exptime);
         $user->setRegTime($po->regtime);
         Session::init();
         Session::set('loggedIn', true);
         Session::set('user', $user);
         // header('location: ../dashboard');
         $msg = STATUS_LOGIN_SUCCESS;
     } elseif ($po->status == STATUS_NON_ACTIVATED) {
         $msg = STATUS_NON_ACTIVATED_PROMPT . BACK_TO_LOGIN_LINK;
     } else {
         //header('location: ../login?status=exception');
         $msg = "Unknown Exception happened when login.";
     }
     return $msg;
 }
 /**
  * Create user account based on LDAP info.
  *
  * @param  String $eduid
  * @param  String $uid
  * @param  String $cn
  * @param  String $email
  * @return User
  */
 function createAccount($eduid, $uid, $cn, $email)
 {
     if (trim($uid) == '' || trim($eduid) == '') {
         return false;
     }
     $user = new User();
     $user->setUserName($this->generateLogin($uid));
     $user->setLdapId($eduid);
     $user->setRealName($cn);
     $user->setEmail($email);
     // Generates a pseudo-random password. Its not full secure but its
     // better than nothing.
     $user->setPassword(md5((string) mt_rand(10000, 999999) . time()));
     // Default LDAP
     $user->setStatus($this->getLdap()->getLDAPParam('default_user_status'));
     $user->setRegisterPurpose('LDAP');
     $user->setUnixStatus('S');
     $user->setTimezone('GMT');
     $user->setLanguageID($GLOBALS['Language']->getText('conf', 'language_id'));
     $um = $this->getUserManager();
     $u = $um->createAccount($user);
     if ($u) {
         // Create an entry in the ldap user db
         $ldapUserDao = $this->getDao();
         $ldapUserDao->createLdapUser($u->getId(), 0, $uid);
         return $u;
     }
     return false;
 }
Example #10
0
 function showEditUserRes()
 {
     /* update last page */
     $_SESSION['LASTPAGE'] = 'sysadmin.users.edituser';
     $displayUsers = new DisplayUsers();
     $urid = getFromSessionParams('urid');
     $content = "";
     if ($urid != '') {
         //edit
         $content = $displayUsers->displaySuccess(Language::messageUserChanged(loadvar('name')));
         $_SESSION['LASTURID'] = $urid;
     } else {
         //add user!
         if (loadvar('username') != "" && loadvar('name') != '') {
             //ADD NEW!!!
             $user = new User('', true);
             $urid = $user->getUrid();
             $_SESSION['LASTURID'] = $urid;
             $content = $displayUsers->displaySuccess(Language::messageUserAdded(loadvar('name')));
         }
     }
     //ADD ALL SORTS OF CHECKS!!
     if ($urid != '' && loadvar('name') != "" && loadvar('username') != '') {
         $user = new User($urid);
         $user->setName(loadvar('name'));
         $user->setUsername(loadvar('username'));
         if (loadvar('pwd1') != '') {
             if (loadvar('pwd1') == loadvar('pwd2')) {
                 $user->setPassword(loadvar('pwd1'));
             } else {
                 $content = $displayUsers->displayWarning(Language::messageUserNoMatch());
             }
         }
         $user->setSupervisor(loadvar('uridsel'));
         $user->setStatus(loadvar('status'));
         $user->setUserType(loadvar('usertype'));
         $user->setUserSubType(loadvar('usersubtype'));
         $current = $user->getSurveysAccess();
         $allowedsurveys = loadvar(SETTING_USER_SURVEYS);
         // add access to all modes and languages if not specified in current access
         foreach ($allowedsurveys as $a) {
             if (!inArray($a, $current)) {
                 $surv = new Survey($a);
                 $mods = explode("~", $surv->getAllowedModes());
                 foreach ($mods as $m) {
                     $user->setLanguages($a, $m, $surv->getAllowedLanguages($m));
                 }
             }
         }
         foreach ($current as $c) {
             if (!inArray($c, $allowedsurveys)) {
                 $user->removeSurvey($c);
             }
         }
         $user->saveChanges();
         // current survey not in allowed, then update to first survey for user
         if (!inArray($_SESSION['SUID'], $allowedsurveys)) {
             $surveys = new Surveys();
             $_SESSION['SUID'] = $surveys->getFirstSurvey();
         }
     } else {
         $content = $displayUsers->displayWarning(Language::messageUserCorrectErrors());
     }
     return $displayUsers->showEditUser($_SESSION['LASTURID'], $content);
 }
 /**
  * Return User object of given user_id
  *
  * @param int $user_id
  * @return User
  */
 public function getObjectById($user_id, $cacheMinutes = 0)
 {
     $user_id = intval($user_id);
     $this->query->exec("select * from `" . Tbl::get('TBL_USERS') . "` where `id`='{$user_id}'", $cacheMinutes);
     if ($this->query->countRecords()) {
         $res = $this->query->fetchRecord();
         $user = new User();
         $user->setLogin($res["login"]);
         $user->setId($user_id);
         $user->setCreationDate($res["creation_date"]);
         $user->setStatus($res["enable"]);
         foreach ($res as $key => $val) {
             if ($key != 'id' && $key != 'enable' && $key != 'creation_date' && $key != 'login' && $key != 'password') {
                 $user->{$key} = $val;
             }
         }
         $this->query->exec("select `permission_id` from `" . Tbl::get('TBL_USERS_PERMISSIONS') . "` where `user_id`='{$user_id}'", $cacheMinutes);
         $perms_ids_count = $this->query->countRecords();
         if ($perms_ids_count) {
             $perms_ids = $this->query->fetchFields(0, true);
             $sql_statement = "select `name` from `" . Tbl::get('TBL_PERMISSIONS') . "` where `id` in (";
             $count = $perms_ids_count - 1;
             for ($i = 0; $i < $count; ++$i) {
                 $sql_statement .= $perms_ids[$i] . ", ";
             }
             $sql_statement .= $perms_ids[$count] . ")";
             $this->query->exec($sql_statement, $cacheMinutes);
             $user->setPermissions($this->query->fetchFields(0, true));
         }
         $this->query->exec("select `group_id` from `" . Tbl::get('TBL_USERS_GROUPS') . "` where `user_id`='{$user_id}'", $cacheMinutes);
         $groups_ids_count = $this->query->countRecords();
         if ($groups_ids_count) {
             $groups_ids = $this->query->fetchFields(0, true);
             $sql_statement = "select `name` from `" . Tbl::get('TBL_GROUPS') . "` where `id` in (";
             $count = $groups_ids_count - 1;
             for ($i = 0; $i < $count; ++$i) {
                 $sql_statement .= $groups_ids[$i] . ", ";
             }
             $sql_statement .= $groups_ids[$count] . ")";
             $this->query->exec($sql_statement, $cacheMinutes);
             $groups_names = $this->query->fetchFields(0, true);
             $user->setGroups($groups_names);
             foreach ($groups_names as $group_name) {
                 $user->addPermissions($this->getGroupPermissionsList($group_name, $cacheMinutes));
             }
             $user->setPrimaryGroup($this->getPrimaryGroup($user_id, $cacheMinutes));
         }
         return $user;
     }
     return new User();
 }
Example #12
0
     }
 }
 if ($password == "") {
     $err .= "Password field can't be empty";
 } else {
     if ($password != $con_passwd) {
         $err .= "Password didn't match";
     }
 }
 $my_user = new User('', '', '', $company, $email, $password, $reg_date, $last_log, $status, $act_code);
 $my_user->setFirstname($firstname);
 $my_user->setLastname($lastname);
 $my_user->setComapny($company);
 $act_code = $my_user->gen_actcode();
 $my_user->setAct_code($act_code);
 $my_user->setStatus(_INACTIVE);
 $my_user->setRegdate($dateTime);
 $my_user->setLastlog(null);
 $valemail = $my_user->checkEmail($email);
 if ($_POST['email'] != "") {
     if (isset($valemail) && ($valemail = $email)) {
         $my_user->setEmail($email);
     } else {
         $err .= "Email already exits";
     }
 }
 $pass = $my_user->setPassword($password);
 if ($password != "") {
     if (isset($pass) && $pass == FALSE) {
         $err .= "Password needs to be more than 6 characters";
     }
Example #13
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 #14
0
function account_create($loginname = '', $pw = '', $ldap_id = '', $realname = '', $register_purpose = '', $email = '', $status = 'P', $confirm_hash = '', $mail_site = 0, $mail_va = 0, $timezone = 'GMT', $lang_id = 'en_US', $unix_status = 'N', $expiry_date = 0)
{
    $um = UserManager::instance();
    $user = new User();
    $user->setUserName($loginname);
    $user->setRealName($realname);
    $user->setPassword($pw);
    $user->setLdapId($ldap_id);
    $user->setRegisterPurpose($register_purpose);
    $user->setEmail($email);
    $user->setStatus($status);
    $user->setConfirmHash($confirm_hash);
    $user->setMailSiteUpdates($mail_site);
    $user->setMailVA($mail_va);
    $user->setTimezone($timezone);
    $user->setLanguageID($lang_id);
    $user->setUnixStatus($unix_status);
    $user->setExpiryDate($expiry_date);
    $u = $um->createAccount($user);
    if ($u) {
        return $u->getId();
    } else {
        return $u;
    }
}
Example #15
0
 public function testGetAndSetStatus()
 {
     $this->user->setStatus(new Status(array()));
     $this->assertInstanceOf('League\\Twitter\\Status', $this->user->getStatus());
 }
Example #16
0
 public function executeGiveCredential(sfWebRequest $request)
 {
     if ($request->isMethod('Post')) {
         $password = md5($this->getRequestParameter('password'));
         $user = new User();
         $user->setEmployeeId($this->getRequestParameter('employee_id'));
         $user->setUser($this->getRequestParameter('user_name'));
         $user->setPassword($password);
         $user->setRoleId($this->getRequestParameter('role_id'));
         $user->setStatus(Constant::RECORD_STATUS_ACTIVE);
         $user->save();
         $this->getUser()->setFlash('SUCCESS_MESSAGE', 'Credentials Assigned Successfully.');
         $this->redirect('Employee/detail?employee=' . Utility::EncryptQueryString($this->getRequestParameter('employee_id')));
     } else {
         $this->employee = EmployeePeer::retrieveByPk(Utility::DecryptQueryString($request->getParameter('employee')));
     }
 }
 function AuthUser($loginname, $passwd)
 {
     global $feedback;
     if (!function_exists("ldap_connect")) {
         return false;
     }
     if (!$this->ldap_conn) {
         $this->ldap_conn = ldap_connect($this->ldap_server, $this->ldap_port);
     }
     if ($GLOBALS['sys_ldap_version']) {
         ldap_set_option($this->ldap_conn, LDAP_OPT_PROTOCOL_VERSION, $GLOBALS['sys_ldap_version']);
     }
     $dn = plugin_ldapextauth_getdn($this, $loginname);
     if (empty($dn)) {
         $GLOBALS['ldap_auth_failed'] = true;
         return false;
     }
     $u = user_get_object_by_name($loginname);
     if ($u) {
         // User exists in DB
         if (@ldap_bind($this->ldap_conn, $dn, $passwd)) {
             // Password from form is valid in LDAP
             if (session_login_valid_dbonly($loginname, $passwd, false)) {
                 // Also according to DB
                 $GLOBALS['ldap_auth_failed'] = false;
                 return true;
             } else {
                 // Passwords mismatch, update DB's
                 $u->setPasswd($passwd);
                 $GLOBALS['ldap_auth_failed'] = false;
                 return true;
             }
         } else {
             // Wrong password according to LDAP
             $feedback = _('Invalid Password Or User Name');
             $GLOBALS['ldap_auth_failed'] = true;
             return false;
         }
     } else {
         // User doesn't exist in DB yet
         if (@ldap_bind($this->ldap_conn, $dn, $passwd)) {
             // User authenticated
             // Now get her info
             if ($this->ldap_kind == "AD") {
                 $res = ldap_search($this->ldap_conn, $this->base_dn, "sAMAccountName=" . $loginname);
             } else {
                 $res = ldap_read($this->ldap_conn, $dn, "objectclass=*");
             }
             $info = ldap_get_entries($this->ldap_conn, $res);
             $ldapentry = $info[0];
             $mappedinfo = plugin_ldapextauth_mapping($ldapentry);
             // Insert into DB
             $u = new User();
             $unix_name = $loginname;
             $firstname = '';
             $lastname = '';
             $password1 = $passwd;
             $password2 = $passwd;
             $email = '';
             $mail_site = 1;
             $mail_va = 0;
             $language_id = 1;
             $timezone = 'GMT';
             $jabber_address = '';
             $jabber_only = 0;
             $theme_id = 1;
             $unix_box = '';
             $address = '';
             $address2 = '';
             $phone = '';
             $fax = '';
             $title = '';
             $ccode = 'US';
             $send_mail = false;
             if ($mappedinfo['firstname']) {
                 $firstname = $mappedinfo['firstname'];
             }
             if ($mappedinfo['lastname']) {
                 $lastname = $mappedinfo['lastname'];
             }
             if ($mappedinfo['email']) {
                 $email = $mappedinfo['email'];
             }
             if ($mappedinfo['language_id']) {
                 $language_id = $mappedinfo['language_id'];
             }
             if ($mappedinfo['timezone']) {
                 $timezone = $mappedinfo['timezone'];
             }
             if ($mappedinfo['jabber_address']) {
                 $jabber_address = $mappedinfo['jabber_address'];
             }
             if ($mappedinfo['address']) {
                 $address = $mappedinfo['address'];
             }
             if ($mappedinfo['address2']) {
                 $address2 = $mappedinfo['address2'];
             }
             if ($mappedinfo['phone']) {
                 $phone = $mappedinfo['phone'];
             }
             if ($mappedinfo['fax']) {
                 $fax = $mappedinfo['fax'];
             }
             if ($mappedinfo['title']) {
                 $title = $mappedinfo['title'];
             }
             if ($mappedinfo['ccode']) {
                 $ccode = $mappedinfo['ccode'];
             }
             if ($mappedinfo['themeid']) {
                 $theme_id = $mappedinfo['themeid'];
             }
             if (!$u->create($unix_name, $firstname, $lastname, $password1, $password2, $email, $mail_site, $mail_va, $language_id, $timezone, $jabber_address, $jabber_only, $theme_id, $unix_box, $address, $address2, $phone, $fax, $title, $ccode, $send_mail)) {
                 $GLOBALS['ldap_auth_failed'] = true;
                 $feedback = "<br>Error Creating User: "******"<br>Error Activating User: " . $u->getErrorMessage();
                 return false;
             }
             $GLOBALS['ldap_auth_failed'] = false;
             $GLOBALS['ldap_first_login'] = true;
             return true;
         } else {
             $GLOBALS['ldap_auth_failed'] = true;
             $feedback = _('Invalid Password Or User Name');
             return false;
             // Probably ignored, but just in case
         }
     }
 }
Example #18
0
/**
 * Load the data for a User object from a DomNode and create and return the object
 *
 * @param node the DomNode object holding the User data
 * @param $errors the error array to pass error information back.
 * @return User class or NULL
 */
function loadUserFromDomNode($node, &$errors)
{
    global $LNG, $CFG, $DB, $HUB_SQL, $HUB_FLM;
    if ($node->hasChildNodes()) {
        $child = $node->firstChild;
        $nodeData = array();
        while ($child) {
            $tag = $child->nodeName;
            if ($tag == 'userid' || $tag == 'name' || $tag == 'photo' || $tag == 'thumb' || $tag == 'lastlogin' || $tag == 'status' || $tag == 'isgroup' || $tag == 'description' || $tag == 'creationdate' || $tag == 'modificationdate' || $tag == 'privatedata' || $tag == 'website' || $tag == 'location' || $tag == 'countrycode' || $tag == 'country' || $tag == 'locationlat' || $tag == 'locationlng') {
                $nodeData[$tag] = $child->textContent;
            }
            if ($child->firstChild) {
                if ($tag == 'tags') {
                    $tagsArray = array();
                    $child2 = $child->firstChild;
                    while ($child2) {
                        $taginner = loadTagFromDomNode($child2, $errors);
                        array_push($tagsArray, $taginner);
                        $child2 = $child2->nextSibling;
                    }
                    if (empty($errors)) {
                        $nodeData[$tag] = $tagsArray;
                    }
                }
            }
            $child = $child->nextSibling;
        }
        if (empty($errors)) {
            if (isset($nodeData['userid'])) {
                $userObj = new User($nodeData['userid']);
                // Check if Users table has OriginalID field and if so check if this userid is an old ID and adjust.
                $params = array();
                $resArray = $DB->select($HUB_SQL->AUDIT_USER_CHECK_ORIGINALID_EXISTS, $params);
                if ($resArray !== false) {
                    if (count($resArray) > 0) {
                        $array = $resArray[0];
                        if (isset($array['OriginalID'])) {
                            $params = array();
                            $params[0] = $nodeData['userid'];
                            $resArray2 = $DB->select($HUB_SQL->AUDIT_USER_SELECT_ORIGINALID, $params);
                            if ($resArray2 !== false) {
                                if (count($resArray2) > 0) {
                                    $array2 = $resArray2[0];
                                    $userObj->olduserid = $nodeData['userid'];
                                    $userObj->userid = $array2['UserID'];
                                }
                            }
                        }
                    }
                }
                if (isset($nodeData['name'])) {
                    $userObj->name = $nodeData['name'];
                }
                if (isset($nodeData['photo'])) {
                    //rebuild stored path in case of http to https changes, or upload folder location changes.
                    $url = $nodeData['photo'];
                    $parts = pathinfo($url);
                    $filename = $parts['basename'];
                    $finalimg = "";
                    if ($filename == 'profile.png') {
                        $finalimg = $HUB_FLM->getUploadsWebPath($filename);
                    } else {
                        $finalimg = $HUB_FLM->getUploadsWebPath($userObj->userid . "/" . $filename);
                    }
                    $userObj->photo = $finalimg;
                }
                if (isset($nodeData['thumb'])) {
                    //rebuild stored path in case of http to https changes, or upload folder location changes.
                    $url = $nodeData['thumb'];
                    $parts = pathinfo($url);
                    $filename = $parts['basename'];
                    $finalimg = "";
                    if ($filename == 'profile_thumb.png') {
                        $finalimg = $HUB_FLM->getUploadsWebPath($filename);
                    } else {
                        $finalimg = $HUB_FLM->getUploadsWebPath($userObj->userid . "/" . $filename);
                    }
                    $userObj->thumb = $finalimg;
                }
                if (isset($nodeData['lastlogin'])) {
                    $userObj->lastlogin = $nodeData['lastlogin'];
                }
                if (isset($nodeData['website'])) {
                    $userObj->website = $nodeData['website'];
                }
                if (isset($nodeData['status'])) {
                    $userObj->setStatus($nodeData['status']);
                }
                if (isset($nodeData['isgroup'])) {
                    $userObj->isgroup = $nodeData['isgroup'];
                }
                if (isset($nodeData['description'])) {
                    $userObj->description = $nodeData['description'];
                }
                if (isset($nodeData['creationdate'])) {
                    $userObj->creationdate = $nodeData['creationdate'];
                }
                if (isset($nodeData['modificationdate'])) {
                    $userObj->modificationdate = $nodeData['modificationdate'];
                }
                if (isset($nodeData['privatedata'])) {
                    $userObj->privatedata = $nodeData['privatedata'];
                }
                if (isset($nodeData['location'])) {
                    $userObj->location = $nodeData['location'];
                }
                if (isset($nodeData['countrycode'])) {
                    $userObj->countrycode = $nodeData['countrycode'];
                }
                if (isset($nodeData['country'])) {
                    $userObj->country = $nodeData['country'];
                }
                if (isset($nodeData['locationlat'])) {
                    $userObj->locationlat = $nodeData['locationlat'];
                }
                if (isset($nodeData['locationlng'])) {
                    $userObj->locationlng = $nodeData['locationlng'];
                }
                if (isset($nodeData['tags'])) {
                    $userObj->tags = $nodeData['tags'];
                }
                return $userObj;
            } else {
                array_push($errors, $LNG->CORE_AUDIT_USER_ID_MISSING_ERROR);
            }
        }
    } else {
        array_push($errors, $LNG->CORE_AUDIT_USER_DATA_MISSING_ERROR);
    }
    return NULL;
}
Example #19
0
 public static function Edit()
 {
     $log_user = Tool::getLoginUser();
     try {
         $user = new User();
         if (isset($_POST["id"]) && !empty($_POST["id"])) {
             $user->setId($_POST["id"]);
         }
         if (isset($_POST["cache"]) && !empty($_POST["cache"])) {
             $user->setCache($_POST["cache"]);
         }
         if (isset($_POST["username"]) && !empty($_POST["username"])) {
             $user->setUsername($_POST["username"]);
         } else {
             Tool::pageError();
         }
         if (isset($_POST["password"]) && !empty($_POST["password"])) {
             $user->setPassword($_POST["password"]);
         } else {
             Tool::pageError();
         }
         if (isset($_POST["name"]) && !empty($_POST["name"])) {
             $user->setName($_POST["name"]);
         }
         if (isset($_POST["status"]) && !empty($_POST["status"])) {
             $user->setStatus($_POST["status"]);
         }
         if (isset($_POST["address"]) && !empty($_POST["address"])) {
             $user->setAddress($_POST["address"]);
         }
         if (isset($_POST["phone"]) && !empty($_POST["phone"])) {
             $user->setPhone($_POST["phone"]);
         }
         if (isset($_POST["cache"]) && !empty($_POST["cache"])) {
             if ($_POST["cache"] == User::CACHE_HIDE) {
                 $user->setCache(User::CACHE_HIDE);
             } else {
                 $user->setCache(User::CACHE_SHOW);
             }
         }
         $user->UpdateDatabase($log_user);
         header("Location:../?menu=" . PAGE_MANAGE_USER);
         exit;
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
         // header("Location:../404.html");
     }
 }