예제 #1
0
 public function update()
 {
     include_once "models/Users.php";
     $users = new Users();
     $users->update();
     //header("Location: ../profile?error=ok");
 }
예제 #2
0
 function loginAction()
 {
     if ($this->_request->isPost('log-form')) {
         Zend_Loader::loadClass('Zend_Filter_StripTags');
         $filter = new Zend_Filter_StripTags();
         $username = trim($filter->filter($this->_request->getPost('log-name')));
         $password = trim($filter->filter($this->_request->getPost('log-pswd')));
         $warnings = new Zend_Session_Namespace();
         $warnings->username = $username;
         $warnings->error = '';
         $error_msg = '';
         if ($username == '') {
             $error_msg .= '<p>Enter your username.</p>';
         } else {
             if ($password == '') {
                 $error_msg .= '<p>Enter your password.</p>';
             } else {
                 $data = new Users();
                 $query = 'login = "******"';
                 $data_row = $data->fetchRow($query);
                 if (!count($data_row)) {
                     $error_msg .= '<p>There is no user with such username.</p>';
                 } else {
                     if ($data_row == '0') {
                         $error_msg .= '<p>Your account is not activated.</p>';
                     }
                     $check_pass = sha1($password . $data_row['salt']);
                     if ($check_pass != $data_row['password']) {
                         $error_msg .= '<p>Wrong password.</p>';
                     }
                 }
             }
         }
         if ($error_msg != '') {
             $warnings->error = $error_msg;
             $warnings->status = '';
             $this->_redirect('/');
             return;
         } else {
             Zend_Loader::loadClass('Zend_Date');
             $date = new Zend_Date();
             $current_date = $date->toString('YYYY-MM-dd HH:mm:ss');
             $where = 'login = "******"';
             $data = array('last_login' => $current_date);
             $user_update = new Users();
             $user_update->update($data, $where);
             $warnings->error = '';
             $warnings->username = '';
             $warnings->email = '';
             $warnings->real_name = '';
             $warnings->status = ' hide';
             $user_dates = new Zend_Session_Namespace();
             $user_dates->username = $username;
             $user_dates->status = '1';
             $this->_redirect('/profile/');
             return;
         }
     }
 }
예제 #3
0
function updateProcess($id)
{
    $send = Request::get('send');
    $address = Request::get('address');
    $address['firstname'] = $send['firstname'];
    $address['lastname'] = $send['lastname'];
    Users::update($id, $send);
    Address::update($id, $address);
}
예제 #4
0
 function UpdateUser($data, $fields)
 {
     try {
         $User = new Users();
         $result = $User->update($fields);
         return $result;
     } catch (Exception $e) {
         return array('Exception!! ' => $e->getMessage());
     }
 }
예제 #5
0
 public function editAction(Users $user)
 {
     if ($this->request->isPost()) {
         $data = $this->request->getPost();
         if ($user->update($data)) {
             $this->redirectByRoute(['for' => 'users.show', 'user' => $user->id]);
         }
     }
     $this->view->form = $this->buildFormFromModel($user);
     $this->view->user = $user;
 }
예제 #6
0
function loadApi($action)
{
    switch ($action) {
        case 'login':
            if (isset($_COOKIE['userid'])) {
                throw new Exception("You have been loggedin.");
            }
            $username = Request::get('username', '');
            $password = Request::get('password', '');
            try {
                Users::makeLogin($username, $password);
                return json_encode(array('error' => 'no', 'loggedin' => 'yes'));
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            break;
        case 'register':
            try {
                $id = Users::makeRegister();
                return json_encode(array('error' => 'no', 'userid' => $id));
            } catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
            break;
        case 'verify_email':
            $code = Request::get('verify_code', '');
            if ($code == '') {
                throw new Exception("Error Processing Request");
            }
            $loadData = Users::get(array('where' => "where verify_code='{$code}'"));
            if (isset($loadData[0]['userid'])) {
                Users::update($loadData[0]['userid'], array('verify_code' => ''));
                Redirect::to(ROOT_URL);
                // Users::sendNewPassword($loadData[0]['email']);
            } else {
                throw new Exception("Verify link not valid.");
            }
            break;
        case 'verify_forgotpassword':
            $code = Request::get('verify_code', '');
            if ($code == '') {
                throw new Exception("Error Processing Request");
            }
            $loadData = Users::get(array('where' => "where forgot_code='{$code}'"));
            if (isset($loadData[0]['userid'])) {
                Users::update($loadData[0]['userid'], array('forgot_code' => ''));
                Users::sendNewPassword($loadData[0]['email']);
                Redirect::to(ROOT_URL);
            } else {
                throw new Exception("Verify code not valid.");
            }
            break;
    }
}
예제 #7
0
 /**
  * 设置密码
  */
 public function actionSetpwd()
 {
     $Users = new Users();
     $data = $this->Common->getFilter($_POST);
     if (empty($data['pwd']) || empty($data['newpwd']) || empty($data['confirmpwd'])) {
         $this->jumpBox('参数错误!', Wave::app()->homeUrl . 'member', 1);
     }
     if ($data['newpwd'] != $data['confirmpwd']) {
         $this->jumpBox('两次密码不一样!', Wave::app()->homeUrl . 'member', 1);
     }
     $updateData = array('password' => md5($data['newpwd']));
     $Users->update($updateData, array('userid' => $this->userinfo['userid']));
     $this->jumpBox('修改成功!', Wave::app()->homeUrl . 'member', 1);
 }
예제 #8
0
 public static function update()
 {
     static::purifier();
     if ($_POST['id'] != "" && $_POST['name'] != "" && $_POST['email'] != "" && $_POST['course'] != "" && $_POST['phone'] != "" && $_POST['semester'] != "" && $_POST['registry'] != "") {
         $user = new Users($_POST);
         try {
             $user->update($_POST['id']);
             $_SESSION['msg'] = 'success">Atualizado!';
             array_key_exists('status', $_POST) && $_POST['status'] == '1' ? header('Location: ../views/candidates') : header('Location: ../views/subscribers');
         } catch (pdoexception $e) {
             $_SESSION['msg'] = 'fail">Erro.';
             header('Location: ../views/edit-user');
         }
     }
 }
예제 #9
0
 public function edit($id)
 {
     // find user
     if (($user = Users::find(array('id' => $id))) === false) {
         return Response::redirect($this->admin_url . '/users');
     }
     // process post request
     if (Input::method() == 'POST') {
         if (Users::update($id)) {
             // redirect path
             return Response::redirect($this->admin_url . '/users/edit/' . $id);
         }
     }
     Template::render('users/edit', array('user' => $user));
 }
예제 #10
0
 public function recover()
 {
     if (isset($_POST['email'])) {
         $recover = new Users();
         if ($recover->select(array('email' => $_POST['email']))) {
             // Create a random password and update the table row
             $recover->password = String::random();
             $recover->update();
             $msg = 'Your new password is: ' . $recover->password . '<br /><br />';
             $msg .= 'Try logging in at <a href="' . WEB_ROOT . 'login/">' . WEB_ROOT . 'login/</a>';
             Core_Helpers::send_html_mail($recover->email, 'Password Recovery', $msg, $data['config']->email_address);
             Flash::set('<p class="flash success">Password has been reset and will be emailed to you shortly.</p>');
         } else {
             Flash::set('<p class="flash validation">Sorry, you have entered an email address that is not associated with any account.</p>');
         }
     }
     $this->load_template('recover');
 }
예제 #11
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Users('createSubAdmin');
     if (isset($_POST['Users'])) {
         $model->attributes = $_POST['Users'];
         $model->status = $_POST['Users']['status'];
         if ($model->validate()) {
             $model->temp_password = $model->password_hash;
             $model->created_date = date("Y-m-d H:i:s");
             $model->application_id = BE;
             //save user for back end
             $model->save();
             $model->password_hash = md5($model->password_hash);
             $model->update();
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model, 'actions' => $this->listActionsCanAccess));
 }
예제 #12
0
 /**
  * Validate if exist folder PMDrive
  *
  * @param $userUid id user
  */
 private function validateFolderPMDrive($usrUid)
 {
     if ($this->folderIdPMDrive != '') {
         return;
     }
     $user = new Users();
     $dataUser = $user->load($usrUid);
     if (!empty($dataUser['USR_EMAIL'])) {
         $this->setDriveUser($dataUser['USR_EMAIL']);
     }
     $this->folderIdPMDrive = empty($dataUser['USR_PMDRIVE_FOLDER_UID']) ? '' : $dataUser['USR_PMDRIVE_FOLDER_UID'];
     $conf = $this->getConfigGmail();
     $this->folderNamePMDrive = empty($conf->aConfig['folderNamePMDrive']) ? 'PMDrive (' . SYS_SYS . ')' : $conf->aConfig['folderNamePMDrive'];
     if ($this->folderIdPMDrive == '') {
         $folderid = $this->createFolder($this->folderNamePMDrive);
         $this->folderIdPMDrive = $folderid->id;
         $dataUser['USR_PMDRIVE_FOLDER_UID'] = $folderid->id;
         $user->update($dataUser);
     }
 }
예제 #13
0
 public function isValid($value, $context = null)
 {
     $value = (string) $value;
     $this->_setValue($value);
     if (is_array($context)) {
         if (!isset($context['password'])) {
             return false;
         }
     }
     $dbAdapter = Zend_Registry::get('db');
     $this->_authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
     $this->_authAdapter->setTableName('users')->setIdentityColumn('username')->setCredentialColumn('password');
     // get "salt" for better security
     $salt = $this->_config->auth->salt;
     $password = sha1($salt . $context['password']);
     $this->_authAdapter->setIdentity($value);
     $this->_authAdapter->setCredential($password);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($this->_authAdapter);
     if (!$result->isValid()) {
         $this->_error(self::NOT_AUTHORISED);
         return false;
     }
     //Updated the user table - this needs moving to the users model
     $users = new Users();
     $updateArray = array('visits' => new Zend_Db_Expr('visits + 1'), 'lastLogin' => Zend_Date::now()->toString('yyyy-MM-dd HH:mm'));
     $where = array();
     $where[] = $users->getAdapter()->quoteInto('username = ?', $value);
     $users->update($updateArray, $where);
     //Update login table needs moving to the login model
     $logins = new Logins();
     $data['loginDate'] = Zend_Date::now()->toString('yyyy-MM-dd HH:mm');
     $data['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
     $data['ipAddress'] = $_SERVER['REMOTE_ADDR'];
     $data['username'] = $value;
     $insert = $logins->insert($data);
     return true;
 }
예제 #14
0
 /** Upgrade an account
  * @access public
  * @return void
  */
 public function upgradeAction()
 {
     $allowed = array('public', 'member');
     if (in_array($this->getRole(), $allowed)) {
         $user = $this->getAccount();
         $form = new AccountUpgradeForm();
         $this->view->form = $form;
         if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) {
             if ($form->isValid($form->getValues())) {
                 $where = array();
                 $where[] = $this->_users->getAdapter()->quoteInto('id = ?', (int) $this->getAccount()->id);
                 $updateData = $form->getValues();
                 $updateData['higherLevel'] = 1;
                 $this->_users->update($updateData, $where);
                 $to = array(array('email' => $user->email, 'name' => $user->fullname));
                 $advisers = new Contacts();
                 $emails = $advisers->getAdvisersEmails();
                 $central = $advisers->getCentralEmails();
                 $emails = array_merge($to, $emails, $central);
                 $attachments = array(ROOT_PATH . '/public_html/documents/tac.pdf');
                 $assignData = array_merge($to[0], $form->getValues());
                 $toReferee = array(array('email' => $form->getValue('referenceEmail'), 'name' => $form->getValue('reference')));
                 //data, template, to, cc, from, bcc, attachments, subject
                 $this->sendAdvisers($assignData, $toReferee, $emails, $attachments);
                 $this->getFlash()->addMessage('Thank you! We have received your request.');
                 $this->redirect('/users/account/');
             } else {
                 $form->populate($form->getValues());
                 $this->getFlash()->addMessage('There are a few problems with your registration<br>
                 Please review and correct them.');
             }
         }
     } else {
         $this->getFlash()->addMessage('You can\'t request an upgrade as you already have ' . $this->getRole() . ' status!');
         $this->redirect('/users/account/');
     }
 }
예제 #15
0
 /**
  * 提交信息
  */
 public function actionModified()
 {
     $data = $this->Common->getFilter($_POST);
     $userid = (int) $data['userid'];
     unset($data['userid']);
     $Users = new Users();
     if ($userid == 0) {
         unset($data['oldemail']);
         $count = $Users->getCount('*', array('email' => $data['email']));
         if ($count > 0) {
             $this->jumpBox('邮箱不能重复!', Wave::app()->homeUrl . 'users', 1);
         }
         $data['password'] = md5($data['password']);
         $data['add_date'] = date('Y-m-d H:i:s');
         $userid = $Users->insert($data);
         $data['userid'] = $userid;
         $this->Log->saveLogs('添加用户', 1, $data);
     } else {
         if ($data['oldemail'] != $data['email']) {
             $count = $Users->getCount('*', array('email' => $data['email']));
             if ($count > 0) {
                 $this->jumpBox('邮箱不能重复!', Wave::app()->homeUrl . 'users', 1);
             }
         }
         unset($data['oldemail']);
         if (!empty($data['password'])) {
             $data['password'] = md5($data['password']);
         } else {
             unset($data['password']);
         }
         $Users->update($data, array('userid' => $userid));
         $data['userid'] = $userid;
         $this->Log->saveLogs('更新用户', 1, $data);
     }
     $this->jumpBox('成功!', Wave::app()->homeUrl . 'users', 1);
 }
예제 #16
0
  if ($form['USR_RESUME'] != '') {
  $aData['USR_RESUME'] = $form['USR_RESUME'];
  }
 */
 if (isset($form['USR_ROLE'])) {
     $aData['USR_ROLE'] = $form['USR_ROLE'];
 }
 if (isset($form['USR_REPLACED_BY'])) {
     $aData['USR_REPLACED_BY'] = $form['USR_REPLACED_BY'];
 }
 if (isset($form['USR_AUTH_USER_DN'])) {
     $aData['USR_AUTH_USER_DN'] = $form['USR_AUTH_USER_DN'];
 }
 require_once 'classes/model/Users.php';
 $oUser = new Users();
 $oUser->update($aData);
 if ($_FILES['USR_PHOTO']['error'] != 1) {
     if ($_FILES['USR_PHOTO']['tmp_name'] != '') {
         $aAux = explode('.', $_FILES['USR_PHOTO']['name']);
         G::uploadFile($_FILES['USR_PHOTO']['tmp_name'], PATH_IMAGES_ENVIRONMENT_USERS, $aData['USR_UID'] . '.' . $aAux[1]);
         G::resizeImage(PATH_IMAGES_ENVIRONMENT_USERS . $aData['USR_UID'] . '.' . $aAux[1], 96, 96, PATH_IMAGES_ENVIRONMENT_USERS . $aData['USR_UID'] . '.gif');
     }
 } else {
     $result->success = false;
     $result->fileError = true;
     print G::json_encode($result);
     die;
 }
 /*
  if ($_FILES['USR_RESUME']['error'] != 1) {
  if ($_FILES['USR_RESUME']['tmp_name'] != '') {
예제 #17
0
 public function forgotPassword($httpData)
 {
     $this->setResponseType('json');
     global $RBAC;
     require_once PATH_RBAC . "model/RbacUsers.php";
     require_once 'classes/model/Users.php';
     G::LoadClass("system");
     $rbacUser = new RbacUsers();
     $user = new Users();
     try {
         $userData = $rbacUser->getByUsername($httpData->username);
         if (!$userData) {
             $msg = G::LoadTranslation('ID_USER') . ' <b>' . $httpData->username . '</b> ' . G::LoadTranslation('ID_IS_NOT_REGISTERED');
             throw new Exception($msg);
         }
         if (trim($userData['USR_EMAIL']) != trim($httpData->email)) {
             $msg = G::LoadTranslation('ID_EMAIL_DOES_NOT_MATCH_FOR_USER') . ' <b>' . $httpData->username . '</b>';
             throw new Exception($msg);
         }
         $newPass = G::generate_password();
         $aData['USR_UID'] = $userData['USR_UID'];
         $aData['USR_PASSWORD'] = md5($newPass);
         $rbacUser->update($aData);
         $user->update($aData);
         $subject = G::loadTranslation('ID_PROCESSMAKER_FORGOT_PASSWORD_SERVICE');
         $template = new TemplatePower(PATH_TPL . 'main/forgotPassword.tpl');
         $template->prepare();
         $template->assign('server', $_SERVER['SERVER_NAME']);
         $template->assign('serviceMsg', G::loadTranslation('ID_PROCESSMAKER_FORGOT_PASSWORD_SERVICE'));
         $template->assign('content', G::loadTranslation('ID_PASSWORD_CHANGED_SUCCESSFULLY'));
         $template->assign('passwd', $newPass);
         $template->assign('poweredBy', G::loadTranslation('ID_PROCESSMAKER_SLOGAN1'));
         $template->assign('versionLabel', G::loadTranslation('ID_VERSION'));
         $template->assign('version', System::getVersion());
         $template->assign('visit', G::loadTranslation('ID_VISIT'));
         $template->assign('footer', '');
         $body = $template->getOutputContent();
         G::sendMail('', 'ProcessMaker Service', $httpData->email, $subject, $body);
         $result->success = true;
         $result->message = G::LoadTranslation('ID_NEW_PASSWORD_SENT');
     } catch (Exception $e) {
         $result->success = false;
         $result->message = $e->getMessage();
     }
     return $result;
 }
예제 #18
0
파일: user.php 프로젝트: todary/Eshopper
}
$_method = $_SERVER['REQUEST_METHOD'];
if ($_method == 'POST') {
    if (isset($_POST['_method'])) {
        if ($_POST['_method'] == 'put') {
            $user = new Users($_GET['id']);
            $user->id = $_GET['id'];
            $user->name = $_POST['name'];
            $user->birthday = $_POST['birthday'];
            $user->address = $_POST['address'];
            $user->username = $_POST['username'];
            $user->email = $_POST['email'];
            $user->password = $_POST['password'];
            $user->credit = $_POST['credit'];
            $user->image = $_POST['image'];
            $user->update();
        } else {
            if ($_POST['_method'] == 'delete') {
                $user = new Users($_GET['id']);
                $user->delete();
                $rest = new User_server();
                $rest->handle_response('Deleted', 400);
                // $response['data'] = 'Deleted';
                // $response['status'] = 'Bad Request';
                // $json_response = json_encode($response);
                // echo $json_response;
            }
        }
    } else {
        //insert action
        $user = new Users();
예제 #19
0
         G::SendMessageText($_SESSION['__AUTH_ERROR__'], "warning");
         unset($_SESSION['__AUTH_ERROR__']);
     }
     break;
     //The user is inactive
 //The user is inactive
 case -3:
     require_once 'classes/model/Users.php';
     $user = new Users();
     $aUser = $user->loadByUsernameInArray($usr);
     switch ($aUser['USR_STATUS']) {
         case 'VACATION':
             $uid = $aUser['USR_UID'];
             $RBAC->changeUserStatus($uid, 1);
             $aUser['USR_STATUS'] = 'ACTIVE';
             $user->update($aUser);
             break;
         case 'INACTIVE':
             $errLabel = 'ID_USER_INACTIVE';
             break;
     }
     break;
     //The Due date is finished
 //The Due date is finished
 case -4:
     $errLabel = 'ID_USER_INACTIVE_BY_DATE';
     break;
 case -5:
     $errLabel = 'ID_AUTHENTICATION_SOURCE_INVALID';
     break;
 case -6:
예제 #20
0
    /**

     * Update user

     *

     * @param string userUid : The user UID.

     * @param string userName : The username for the user.

     * @param string firstName : Optional parameter. The user's first name.

     * @param string lastName : Optional parameter. The user's last name.

     * @param string email : Optional parameter. The user's email address.

     * @param string dueDate : Optional parameter. The expiration date must be a string in the format "yyyy-mm-dd".

     * @param string status : Optional parameter. The user's status, such as "ACTIVE", "INACTIVE" or "VACATION".

     * @param string role : Optional parameter. The user's role, such

     * as "PROCESSMAKER_ADMIN" or "PROCESSMAKER_OPERATOR".

     * @param string password : Optional parameter. The user's password such as "Be@gle2" (It will be automatically

     * encrypted with an MD5 hash).

     * @return $result will return an object

     */

    public function updateUser ($userUid, $userName, $firstName = null, $lastName = null, $email = null, $dueDate = null, $status = null, $role = null, $password = null)

    {

        try {

            global $RBAC;



            $RBAC->initRBAC();



            if (empty( $userUid )) {

                $result = new wsResponse( 25, G::LoadTranslation( "ID_REQUIRED_FIELD" ) . " userUid" );



                return $result;

            }



            if (empty( $userName )) {

                $result = new wsResponse( 25, G::LoadTranslation( "ID_USERNAME_REQUIRED" ) );



                return $result;

            }



            if ($RBAC->verifyUserId( $userUid ) == 0) {

                $result = new wsResponse( 3, G::loadTranslation( "ID_USER_NOT_REGISTERED_SYSTEM" ) );



                return $result;

            }



            $mktimeDueDate = 0;



            if (! empty( $dueDate )) {

                if (! preg_match( "/^(\d{4})-(\d{2})-(\d{2})$/", $dueDate, $arrayMatch )) {

                    $result = new wsResponse( - 1, G::LoadTranslation( "ID_INVALID_DATA" ) . " $dueDate" );



                    return $result;

                } else {

                    $mktimeDueDate = mktime( 0, 0, 0, intval( $arrayMatch[2] ), intval( $arrayMatch[3] ), intval( $arrayMatch[1] ) );

                }

            }



            if (! empty( $status )) {

                if ($status != "ACTIVE" && $status != "INACTIVE" && $status != "VACATION") {

                    $result = new wsResponse( - 1, G::LoadTranslation( "ID_INVALID_DATA" ) . " $status" );



                    return $result;

                }

            }



            $strRole = null;



            if (! empty( $role )) {

                $arrayRole = $RBAC->loadById( $role );



                if (is_array( $arrayRole )) {

                    $strRole = $arrayRole["ROL_CODE"];

                } else {

                    $strRole = $role;



                    if ($RBAC->verifyByCode( $role ) == 0) {

                        $data = array ();

                        $data["ROLE"] = $role;



                        $result = new wsResponse( 6, G::LoadTranslation( "ID_INVALID_ROLE", SYS_LANG, $data ) );



                        return $result;

                    }

                }

            }



            if (! empty( $password ) && strlen( $password ) > 20) {

                $result = new wsResponse( - 1, G::LoadTranslation( "ID_PASSWORD_SURPRASES" ) );



                return $result;

            }



            $criteria = new Criteria();

            $criteria->addSelectColumn( UsersPeer::USR_UID );

            $criteria->add( UsersPeer::USR_USERNAME, $userName );

            $criteria->add( UsersPeer::USR_UID, $userUid, Criteria::NOT_EQUAL );

            $rs = UsersPeer::doSelectRS( $criteria );



            if ($rs->next()) {

                $data = array ();

                $data["USER_ID"] = $userName;



                $result = new wsResponse( 7, G::LoadTranslation( "ID_USERNAME_ALREADY_EXISTS", SYS_LANG, $data ) );



                return $result;

            }



            //Set fields

            $arrayData = array ();



            $arrayData["USR_UID"] = $userUid;

            $arrayData["USR_USERNAME"] = $userName;



            if (! empty( $firstName )) {

                $arrayData["USR_FIRSTNAME"] = $firstName;

            }



            if (! empty( $lastName )) {

                $arrayData["USR_LASTNAME"] = $lastName;

            }



            if (! empty( $email )) {

                $arrayData["USR_EMAIL"] = $email;

            }



            if ($mktimeDueDate != 0) {

                $arrayData["USR_DUE_DATE"] = $mktimeDueDate;

            }



            $arrayData["USR_UPDATE_DATE"] = date( "Y-m-d H:i:s" );



            if (! empty( $status )) {

                $arrayData["USR_STATUS"] = $status;

            }



            if ($strRole != null) {

                $arrayData["USR_ROLE"] = $strRole;

            }



            if (! empty( $password )) {

                $arrayData["USR_PASSWORD"] = Bootstrap::hashPassword( $password );

            }



            //Update user

            if ($strRole != null) {

                $RBAC->updateUser( $arrayData, $strRole );

            } else {

                $RBAC->updateUser( $arrayData );

            }



            $user = new Users();

            $user->update( $arrayData );



            //Response

            //$res = new wsResponse(0, G::LoadTranslation("ID_OBJECT_UPDATE"));

            $res = new wsResponse( 0, G::LoadTranslation( "ID_UPDATED_SUCCESSFULLY" ) );



            $result = array ("status_code" => $res->status_code,"message" => $res->message,"timestamp" => $res->timestamp

            );



            return $result;

        } catch (Exception $e) {

            $result = new wsResponse(100, $e->getMessage());



            return $result;

        }

    }
예제 #21
0
 function editAction()
 {
     $errors = array();
     $users_table = new Users();
     $users_roles_table = new UsersRoles();
     $request = new Bolts_Request($this->getRequest());
     $countries_table = new Countries();
     $this->view->countries = $countries_table->getCountriesArray('Choose a country...');
     $roles_table = new Roles();
     $roles = $roles_table->fetchAll(NULL, "shortname ASC");
     $arRoles = array();
     foreach ($roles as $role) {
         if (!strpos($role->shortname, "-base")) {
             $arRoles[$role->id] = $role->description;
         }
     }
     $this->view->roles = $arRoles;
     $is_new = true;
     $user = array();
     if ($request->has('username')) {
         $obUser = $users_table->fetchByUsername($request->username);
         if (!is_null($obUser)) {
             $is_new = false;
             $user_roles = $users_roles_table->fetchAll($users_roles_table->select()->where("username = ?", $obUser->username));
             if (count($user_roles) > 0) {
                 $tmp_selected = array();
                 foreach ($user_roles as $user_role) {
                     $tmp_selected[] = $user_role->role_id;
                 }
                 $this->view->selected_roles = $tmp_selected;
             }
             $user = $obUser->toArray();
         }
     }
     $this->view->is_new = $is_new;
     if ($is_new) {
         // defaults for form fields
         $user['username'] = "";
         $user['full_name'] = "";
         $user['aboutme'] = "";
     }
     $pre_render = $this->_Bolts_plugin->doFilter($this->_mca . "_pre_render", array('user' => $user, 'request' => $this->_request));
     // FILTER HOOK
     $user = $pre_render['user'];
     foreach ($pre_render as $key => $value) {
         if ($key != "user") {
             $this->view->{$key} = $value;
         }
     }
     // $tags = unserialize($user['tags']);
     if ($this->getRequest()->isPost()) {
         $errors = array();
         $request->stripTags(array('full_name', 'email', 'newpassword', 'confirm'));
         // $request->stripTags(array('full_name', 'email', 'newpassword', 'confirm', 'aboutme'));
         $user['username'] = $request->username;
         $user['email'] = $request->email;
         $user['password'] = $request->newpassword;
         $user['confirm'] = $request->confirm;
         $user['full_name'] = $request->full_name;
         $user['birthday'] = $birthday = strtotime($request->Birthday_Day . $request->Birthday_Month . $request->Birthday_Year);
         $user['gender'] = $request->gender;
         $user['country_code'] = $request->country_code;
         $user['aboutme'] = $request->aboutme;
         // validate username
         $username_validator = new Zend_Validate();
         $username_validator->addValidator(new Zend_Validate_StringLength(1, Bolts_Registry::get('username_length')));
         $username_validator->addValidator(new Zend_Validate_Alnum());
         if (!$username_validator->isValid($user['username'])) {
             $show_username = "******" . $user['username'] . "'";
             if (trim($user['username']) == "") {
                 $show_username = "******" . $this->_T("empty") . "]";
             }
             $errors[] = $this->_T("%s isn't a valid username. (Between %d and %d characters, only letters and numbers)", array($show_username, 1, Bolts_Registry::get('username_length')));
         }
         if ($is_new) {
             $user_where = $users_table->getAdapter()->quoteInto('username = ?', $user['username']);
             if ($users_table->getCountByWhereClause($user_where) > 0) {
                 $errors[] = $this->_T("The username '%s' is already in use", $user['username']);
             }
         }
         // validate email
         if (!Bolts_Validate::checkEmail($user['email'])) {
             $errors[] = $this->_T("Email is not valid");
         }
         // check to see if email is in use already by someone else
         if ($users_table->isEmailInUse($user['email'], $user['username'])) {
             $errors[] = $this->_T("Email already in use");
         }
         // if password isn't blank, validate it
         if ($user['password'] != "") {
             if (!Bolts_Validate::checkLength($user['password'], 6, Bolts_Registry::get('password_length'))) {
                 $errors[] = $this->_T("Password must be between 6 and 32 characters");
             }
             // if password is set, make sure it matches confirm
             if ($user['password'] != $user['confirm']) {
                 $errors[] = $this->_T("Passwords don't match");
             }
         }
         // convert birthday_ts to mysql date
         $birthday = date("Y-m-d H:i:s", $user['birthday']);
         $params = array('request' => $request, 'user' => $user, 'errors' => $errors);
         // upload new avatar image if present
         if (array_key_exists('filedata', $_FILES)) {
             if ($_FILES['filedata']['tmp_name'] != '') {
                 $destination_path = Bolts_Registry::get('upload_path') . "/" . $user['username'] . "/original";
                 if (!is_dir($destination_path)) {
                     mkdir($destination_path, 0777, true);
                     Bolts_Log::report("Creating user folder at " . $destination_path, null, Zend_Log::DEBUG);
                 }
                 if (file_exists($destination_path . "/avatar")) {
                     unlink($destination_path . "/avatar");
                     Bolts_Log::report("Deleted existing user avatar from " . $destination_path, null, Zend_Log::DEBUG);
                 } else {
                     Bolts_Log::report("User avatar did not exist in " . $destination_path, null, Zend_Log::DEBUG);
                 }
                 move_uploaded_file($_FILES['filedata']['tmp_name'], $destination_path . "/avatar");
                 Users::clearUserCache($user['username']);
                 Bolts_Log::report("User avatar uploaded to " . $destination_path, null, Zend_Log::DEBUG);
                 $params['user']['hasnewfile'] = true;
             } else {
                 $params['user']['hasnewfile'] = false;
             }
         }
         $additional = $this->_Bolts_plugin->doFilter($this->_mca . "_pre_save", $params);
         // FILTER HOOK
         $errors = $additional['errors'];
         $user = $additional['user'];
         $users_roles_table->delete($users_roles_table->getAdapter()->quoteInto("username = ?", $user['username']));
         foreach ($request->role_ids as $role_id) {
             $role_data = array("username" => $user['username'], "role_id" => $role_id);
             $users_roles_table->insert($role_data);
         }
         if (count($errors) == 0) {
             /**********  Commented out due to Plug-in compatibility issues. 
             			$data = array(
             				'email' => $user['email'],
             				'birthday' => $birthday,
             				'aboutme' => nl2br($user['aboutme']),
             				'gender' => $user['gender'],
             				'full_name' => $user['full_name'],
             				'country_code' => $user['country_code'],
             				'last_modified_on' => date(DB_DATETIME_FORMAT),
             			);
             			**********/
             $user['birthday'] = $birthday;
             $user['aboutme'] = nl2br($user['aboutme']);
             $user['last_modified_on'] = date(DB_DATETIME_FORMAT);
             // This is a hold-over value from the form.
             unset($user['confirm']);
             if ($user['password'] != "") {
                 #$data['password'] = $user['password'];
             } else {
                 unset($user['password']);
             }
             if ($is_new) {
                 // TODO - stuff?  really?
                 $stuff = array('request' => $request, 'user' => $user, 'errors' => $errors);
                 $additional1 = $this->_Bolts_plugin->doFilter($this->_mca, $stuff);
                 // FILTER HOOK
                 $errors = $additional1['errors'];
                 $user = $additional1['user'];
                 $data['username'] = $user['username'];
                 #$data['created_on'] = date(DB_DATETIME_FORMAT);
                 $user['created_on'] = date(DB_DATETIME_FORMAT);
                 $users_table->insert($user);
                 $this->view->success = "Profile created.";
             } else {
                 $where = $users_table->getAdapter()->quoteInto('username = ?', $user['username']);
                 #$users_table->update($data, $where);
                 $users_table->update($user, $where);
                 $this->view->success = "Profile updated.";
             }
         } else {
             $this->view->errors = $errors;
         }
     }
     $this->view->end_year = -Bolts_Registry::get('minimum_registration_age');
     $this->view->genders = Bolts_Common::getGenderArray();
     $user['aboutme'] = Bolts_Common::br2nl($user['aboutme']);
     $this->view->user = $user;
 }
예제 #22
0
 public function pdoEditModelAction($id)
 {
     $this->_view->title = 'Model Edit Form';
     $this->_view->link = base_url() . 'pdo-database/pdo-model/pdo-edit-model/' . $id;
     $users = new Users();
     $row = $users->get($id);
     if (empty($row)) {
         redirect('pdo-database/pdo-model/pdo-model');
     }
     $this->_view->data = $row;
     if (!empty($_POST)) {
         $val = new Validation();
         $val->source = $_POST;
         $val->addValidator(array('name' => 'first_name', 'type' => 'string', 'required' => true));
         $val->addValidator(array('name' => 'last_name', 'type' => 'string', 'required' => true));
         $val->addValidator(array('name' => 'email', 'type' => 'email', 'required' => true));
         $val->addValidator(array('name' => 'address', 'type' => 'string', 'required' => true));
         $val->run();
         if (sizeof($val->errors) == 0) {
             $data = array('first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'email' => $_POST['email'], 'address' => $_POST['address']);
             $users->update($id, $data);
             redirect('pdo-database/pdo-model/pdo-model');
         }
         $this->_view->errorMessage = $val->errorMessage();
         $this->_view->data = $_POST;
     }
     $this->renderView('pdo-database/pdo-model/_form');
 }
예제 #23
0
 private function onEditUser()
 {
     /* Bail out if the user doesn't have SA permissions. */
     if ($this->_realAccessLevel < ACCESS_LEVEL_SA) {
         CommonErrors::fatal(COMMONERROR_PERMISSION, $this);
         return;
         //$this->fatal(ERROR_NO_PERMISSION);
     }
     /* Bail out if we don't have a valid user ID. */
     if (!$this->isRequiredIDValid('userID', $_POST)) {
         CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'Invalid user ID.');
     }
     if ($this->isRequiredIDValid('accessLevel', $_POST, true)) {
         $accessLevel = $_POST['accessLevel'];
     } else {
         $accessLevel = -1;
     }
     $userID = $_POST['userID'];
     $firstName = $this->getTrimmedInput('firstName', $_POST);
     $lastName = $this->getTrimmedInput('lastName', $_POST);
     $email = $this->getTrimmedInput('email', $_POST);
     $username = $this->getTrimmedInput('username', $_POST);
     $password1 = $this->getTrimmedInput('password1', $_POST);
     $password2 = $this->getTrimmedInput('password2', $_POST);
     $passwordRst = $this->getTrimmedInput('passwordIsReset', $_POST);
     $role = $this->getTrimmedInput('role', $_POST);
     $eeoIsVisible = $this->isChecked('eeoIsVisible', $_POST);
     /* Bail out if any of the required fields are empty. */
     if (empty($firstName) || empty($lastName) || empty($username)) {
         CommonErrors::fatal(COMMONERROR_MISSINGFIELDS, $this, 'First name, last name and username are required.');
     }
     /* Bail out if reseting password to null. */
     if (trim($password1) == '' && $passwordRst == 1) {
         CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Cannot set a blank password.');
     }
     /* Bail out if the two passwords don't match. */
     if ($password1 !== $password2) {
         CommonErrors::fatal(COMMONERROR_NOPASSWORDMATCH, $this, 'Passwords do not match.');
     }
     /* Don't allow access level changes to the currently logged-in user's
      * account.
      */
     if ($userID == $this->_userID) {
         $accessLevel = $this->_realAccessLevel;
     }
     /* If adding an e-mail username, verify it is a valid e-mail. */
     // FIXME: PREG!
     if (strpos($username, '@') !== false && !eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})\$", $username)) {
         CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Username is in improper format for an E-Mail address.');
     }
     /* Make it a multisite user name if the user is part of a hosted site. */
     $unixName = $_SESSION['CATS']->getUnixName();
     if (strpos($username, '@') === false && !empty($unixName)) {
         $username .= '@' . $_SESSION['CATS']->getSiteID();
     }
     $users = new Users($this->_siteID);
     if (!$users->update($userID, $lastName, $firstName, $email, $username, $accessLevel, $eeoIsVisible)) {
         CommonErrors::fatal(COMMONERROR_RECORDERROR, $this, 'Failed to update user.');
     }
     if (trim($password1) !== '') {
         /* Bail out if the password is 'cats'. */
         if ($password1 == 'cats') {
             CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'New password can not equal \'cats\'.');
         }
         if (!$users->resetPassword($userID, $password1)) {
             CommonErrors::fatal(COMMONERROR_RECORDERROR, $this, 'Failed to reset password.');
         }
     }
     /* Set categories. */
     $modules = ModuleUtility::getModules();
     $users->updateCategories($userID, '');
     foreach ($modules as $moduleName => $parameters) {
         $moduleCategories = $parameters[MODULE_SETTINGS_USER_CATEGORIES];
         if ($moduleCategories != false) {
             foreach ($moduleCategories as $category) {
                 if ($category[1] == $role) {
                     /* index 3 is the user level required to assign this type of category. */
                     if (!isset($category[3]) || $category[3] <= $this->_realAccessLevel) {
                         /* Set this category. */
                         $users->updateCategories($userID, $role);
                     }
                 }
             }
         }
     }
     CATSUtility::transferRelativeURI('m=settings&a=showUser&userID=' . $userID);
 }
예제 #24
0
 /**
  * Remove the row
  *
  * @param array $aData or string $ProUid
  * @return string
  *
  */
 public function remove($ProUid)
 {
     if (is_array($ProUid)) {
         $ProUid = isset($ProUid['DEP_UID']) ? $ProUid['DEP_UID'] : '';
     }
     try {
         $oCriteria = new Criteria('workflow');
         $oCriteria->addSelectColumn(UsersPeer::USR_UID);
         $oCriteria->add(UsersPeer::DEP_UID, $ProUid, Criteria::EQUAL);
         $oDataset = UsersPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         $aFields = array();
         while ($aRow = $oDataset->getRow()) {
             $aFields['USR_UID'] = $aRow['USR_UID'];
             $aFields['DEP_UID'] = '';
             $oDepto = UsersPeer::retrieveByPk($aFields['USR_UID']);
             if (is_object($oDepto) && get_class($oDepto) == 'UsersPeer') {
                 return true;
             } else {
                 $oDepto = new Users();
                 $oDepto->update($aFields);
             }
             $oDataset->next();
         }
         $oPro = DepartmentPeer::retrieveByPK($ProUid);
         if (!is_null($oPro)) {
             $dptoTitle = $this->Load($oPro->getDepUid());
             Content::removeContent('DEPO_TITLE', '', $oPro->getDepUid());
             Content::removeContent('DEPO_DESCRIPTION', '', $oPro->getDepUid());
             G::auditLog("DeleteDepartament", "Departament Name: " . $dptoTitle['DEPO_TITLE'] . " Departament ID: (" . $oPro->getDepUid() . ") ");
             return $oPro->delete();
         } else {
             throw new Exception("The row '{$ProUid}' in table Group doesn't exist!");
         }
     } catch (Exception $oError) {
         throw $oError;
     }
 }
예제 #25
0
    /**

     * Migrate all cases to New list

     *

     * return all LIST TABLES with data

     */

    public function migrateList ($workSpace)

    {

        if ($this->listFirstExecution('check')) {

            return 1;

        }

        $this->initPropel(true);

        $appCache = new AppCacheView();

        $users    = new Users();

        G::LoadClass("case");

        $case = new Cases();



        //Select data CANCELLED

        $canCriteria = $appCache->getSelAllColumns();

        $canCriteria->add(AppCacheViewPeer::APP_STATUS, "CANCELLED", CRITERIA::EQUAL);

        $canCriteria->add(AppCacheViewPeer::DEL_LAST_INDEX, "1", CRITERIA::EQUAL);

        $rsCriteria = AppCacheViewPeer::doSelectRS($canCriteria);

        $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        //Insert data LIST_CANCELED

        while ($rsCriteria->next()) {

              $row = $rsCriteria->getRow();

              $listCanceled = new ListCanceled();

              $listCanceled->remove($row["APP_UID"]);

              $listCanceled->setDeleted(false);

              $listCanceled->create($row);

        }

        CLI::logging("> Completed table LIST_CANCELED\n");



        //Select data COMPLETED

        $comCriteria = $appCache->getSelAllColumns();

        $comCriteria->add(AppCacheViewPeer::APP_STATUS, "COMPLETED", CRITERIA::EQUAL);

        $comCriteria->add(AppCacheViewPeer::DEL_LAST_INDEX, "1", CRITERIA::EQUAL);

        $rsCriteria = AppCacheViewPeer::doSelectRS($comCriteria);

        $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        //Insert new data LIST_COMPLETED

        while ($rsCriteria->next()) {

              $row = $rsCriteria->getRow();

              $listCompleted = new ListCompleted();

              $listCompleted->remove($row["APP_UID"]);

              $listCompleted->setDeleted(false);

              $listCompleted->create($row);

        }

        CLI::logging("> Completed table LIST_COMPLETED\n");



        //Select data TO_DO OR DRAFT

        $inbCriteria = $appCache->getSelAllColumns();

        $rsCriteria = AppCacheViewPeer::doSelectRS($inbCriteria);

        $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);



        $criteriaUser = new Criteria();

        $criteriaUser->addSelectColumn( UsersPeer::USR_UID );

        $criteriaUser->addSelectColumn( UsersPeer::USR_FIRSTNAME );

        $criteriaUser->addSelectColumn( UsersPeer::USR_LASTNAME );

        $criteriaUser->addSelectColumn( UsersPeer::USR_USERNAME );

        //Insert new data LIST_INBOX

        while ($rsCriteria->next()) {

            $row = $rsCriteria->getRow();

            $isSelfService = ($row['USR_UID'] == '') ? true : false;

            if($row["DEL_THREAD_STATUS"] == 'OPEN'){

                //Update information about the previous_user

                $row["DEL_PREVIOUS_USR_UID"] = $row["PREVIOUS_USR_UID"];

                $criteriaUser->add( UsersPeer::USR_UID, $row["PREVIOUS_USR_UID"] );

                $datasetU = UsersPeer::doSelectRS($criteriaUser);

                $datasetU->setFetchmode(ResultSet::FETCHMODE_ASSOC);

                $datasetU->next();

                $arrayUsers = $datasetU->getRow();

                $row["DEL_PREVIOUS_USR_USERNAME"] = $arrayUsers["USR_USERNAME"];

                $row["DEL_PREVIOUS_USR_FIRSTNAME"]= $arrayUsers["USR_FIRSTNAME"];

                $row["DEL_PREVIOUS_USR_LASTNAME"] = $arrayUsers["USR_LASTNAME"];

                //Update the due date

                $row["DEL_DUE_DATE"]         = $row["DEL_TASK_DUE_DATE"];

                $listInbox = new ListInbox();

                $listInbox->remove($row["APP_UID"],$row["DEL_INDEX"]);

                $listInbox->setDeleted(false);

                $listInbox->create($row, $isSelfService);

            } else {

                // create participated List when the thread is CLOSED

                $listParticipatedHistory = new ListParticipatedHistory();

                $listParticipatedHistory->remove($row['APP_UID'], $row['DEL_INDEX']);

                $listParticipatedHistory = new ListParticipatedHistory();

                $listParticipatedHistory->create($row);



                $oCriteria = new Criteria('workflow');

                $oCriteria->add(ListParticipatedLastPeer::APP_UID, $row['APP_UID']);

                $oCriteria->add(ListParticipatedLastPeer::USR_UID, $row['USR_UID']);

                ListParticipatedLastPeer::doDelete($oCriteria);



                $listParticipatedLast = new ListParticipatedLast();

                $listParticipatedLast->create($row);

                $listParticipatedLast = new ListParticipatedLast();

                $listParticipatedLast->refresh($row);

            }



        }



        CLI::logging("> Completed table LIST_INBOX\n");

        //With this List is populated the LIST_PARTICIPATED_HISTORY and LIST_PARTICIPATED_LAST

        CLI::logging("> Completed table LIST_PARTICIPATED_HISTORY\n");

        CLI::logging("> Completed table LIST_PARTICIPATED_LAST\n");



        //Select data TO_DO OR DRAFT CASES CREATED BY AN USER

        $myiCriteria = $appCache->getSelAllColumns();

        $myiCriteria->add(AppCacheViewPeer::DEL_INDEX, "1", CRITERIA::EQUAL);

        $rsCriteria = AppCacheViewPeer::doSelectRS($myiCriteria);

        $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        //Insert new data LIST_MY_INBOX

        while ($rsCriteria->next()) {

              $row = $rsCriteria->getRow();

              $listMyInbox = new ListMyInbox();

              $listMyInbox ->remove($row["APP_UID"],$row["USR_UID"]);

              $listMyInbox->setDeleted(false);

              $listMyInbox->create($row);

        }

        CLI::logging("> Completed table LIST_MY_INBOX\n");



        //Select data PAUSED

        $delaycriteria = new Criteria("workflow");

        $delaycriteria->addSelectColumn(AppDelayPeer::APP_UID);

        $delaycriteria->addSelectColumn(AppDelayPeer::PRO_UID);

        $delaycriteria->addSelectColumn(AppDelayPeer::APP_DEL_INDEX);

        $delaycriteria->addSelectColumn(AppCacheViewPeer::APP_NUMBER);

        $delaycriteria->addSelectColumn(AppCacheViewPeer::USR_UID);

        $delaycriteria->addSelectColumn(AppCacheViewPeer::APP_STATUS);

        $delaycriteria->addSelectColumn(AppCacheViewPeer::TAS_UID);



        $delaycriteria->addJoin( AppCacheViewPeer::APP_UID, AppDelayPeer::APP_UID . ' AND ' . AppCacheViewPeer::DEL_INDEX . ' = ' . AppDelayPeer::APP_DEL_INDEX, Criteria::INNER_JOIN );

        $delaycriteria->add(AppDelayPeer::APP_DISABLE_ACTION_USER, "0", CRITERIA::EQUAL);

        $delaycriteria->add(AppDelayPeer::APP_TYPE, "PAUSE", CRITERIA::EQUAL);

        $rsCriteria = AppDelayPeer::doSelectRS($delaycriteria);

        $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        //Insert new data LIST_PAUSED

        while ($rsCriteria->next()) {

              $row = $rsCriteria->getRow();

              $data = $row;

              $data["DEL_INDEX"] = $row["APP_DEL_INDEX"];

              $listPaused = new ListPaused();

              $listPaused ->remove($row["APP_UID"],$row["APP_DEL_INDEX"],$data);

              $listPaused->setDeleted(false);

              $listPaused->create($data);

        }

        CLI::logging("> Completed table LIST_PAUSED\n");



        //Select and Insert LIST_UNASSIGNED

        $unaCriteria = $appCache->getSelAllColumns();

        $unaCriteria->add(AppCacheViewPeer::USR_UID, "", CRITERIA::EQUAL);

        $rsCriteria = AppCacheViewPeer::doSelectRS($unaCriteria);

        $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        $del = new ListUnassignedPeer();

        $del->doDeleteAll();

        $del = new ListUnassignedGroupPeer();

        $del->doDeleteAll();

        while ($rsCriteria->next()) {

            $row = $rsCriteria->getRow();

            $listUnassigned = new ListUnassigned();

            $unaUid = $listUnassigned->generateData($row["APP_UID"],$row["PREVIOUS_USR_UID"]);

        }

        CLI::logging("> Completed table LIST_UNASSIGNED\n");

        CLI::logging("> Completed table LIST_UNASSIGNED_GROUP\n");



        // ADD LISTS COUNTS

        $aTypes = array(

            'to_do',

            'draft',

            'cancelled',

            'sent',

            'paused',

            'completed',

            'selfservice'

        );



        $users = new Users();

        $criteria = new Criteria();

        $criteria->addSelectColumn(UsersPeer::USR_UID);

        $dataset = UsersPeer::doSelectRS($criteria);

        $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        while($dataset->next()) {

            $aRow = $dataset->getRow();

            $oAppCache = new AppCacheView();

            $aCount = $oAppCache->getAllCounters( $aTypes, $aRow['USR_UID'] );

            $newData = array(

                'USR_UID'                   => $aRow['USR_UID'],

                'USR_TOTAL_INBOX'           => $aCount['to_do'],

                'USR_TOTAL_DRAFT'           => $aCount['draft'],

                'USR_TOTAL_CANCELLED'       => $aCount['cancelled'],

                'USR_TOTAL_PARTICIPATED'    => $aCount['sent'],

                'USR_TOTAL_PAUSED'          => $aCount['paused'],

                'USR_TOTAL_COMPLETED'       => $aCount['completed'],

                'USR_TOTAL_UNASSIGNED'      => $aCount['selfservice']

            );

            $users->update($newData);

        }

        $this->listFirstExecution('insert');

        return true;

    }
예제 #26
0
    $passwd = $oSpool->config['MESS_PASSWORD'];
    $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT');
    $auxPass = explode('hash:', $passwdDec);
    if (count($auxPass) > 1) {
        if (count($auxPass) == 2) {
            $passwd = $auxPass[1];
        } else {
            array_shift($auxPass);
            $passwd = implode('', $auxPass);
        }
    }
    $oSpool->config['MESS_PASSWORD'] = $passwd;
    $oSpool->create(array('msg_uid' => '', 'app_uid' => '', 'del_index' => 0, 'app_msg_type' => 'TEST', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $data['USR_EMAIL'], 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending', 'app_msg_attach' => ''));
    try {
        $oSpool->sendMail();
        $rbacUser->update($aData);
        $user->update($aData);
        G::header("location: login.html");
        G::SendTemporalMessage('ID_NEW_PASSWORD_SENT', "info");
    } catch (phpmailerException $e) {
        G::header("location: login.html");
        G::SendTemporalMessage(G::LoadTranslation('MISSING_OR_NOT_CONFIGURED_SMTP'), "warning", 'string');
    } catch (Exception $e) {
        G::header("location: login.html");
        G::SendTemporalMessage($e->getMessage(), "warning", 'string');
    }
} else {
    $msg = G::LoadTranslation('ID_USER') . ' ' . htmlentities($data['USR_USERNAME'], ENT_QUOTES, 'UTF-8') . ' ' . G::LoadTranslation('ID_IS_NOT_REGISTERED');
    G::SendTemporalMessage($msg, "warning", 'string');
    G::header('location: forgotPassword');
}
예제 #27
0
<?php

spl_autoload_register(function ($class) {
    include "library/" . $class . ".php";
});
$connection = array("dbserver" => "mysql", "host" => 'localhost', "dbname" => "loft", "port" => 3306, "user" => "dake", "password" => "boromir");
$user = new Users($connection);
$user->setName("Иван");
$user->setLastname("Иванов");
$user->setBirthday("20.09.1985");
$user->setEmail("*****@*****.**");
$user->setPassword("asdasd");
$user->setIsActive(1);
$user->setRegDate("10.09.2015");
$user->setLastUpdate("11.09.2015");
//TODO: проеобразовать запрашиваемые значения в utf-8
//$res = $user->findBy(array("is_active"=>"0", "name"=>("Бернар")));
//var_dump($res);
$user->update(array("id" => "6", "is_active" => "4"), array("lastname" => "Кох", "name" => "David", "is_active" => 1));
예제 #28
0
     //Delete Dashboard
     require_once 'classes/model/DashletInstance.php';
     $criteria = new Criteria('workflow');
     $criteria->add(DashletInstancePeer::DAS_INS_OWNER_UID, $UID);
     $criteria->add(DashletInstancePeer::DAS_INS_OWNER_TYPE, 'USER');
     DashletInstancePeer::doDelete($criteria);
     break;
 case 'changeUserStatus':
     $response = new stdclass();
     if (isset($_REQUEST['USR_UID']) && isset($_REQUEST['NEW_USR_STATUS'])) {
         $RBAC->changeUserStatus($_REQUEST['USR_UID'], $_REQUEST['NEW_USR_STATUS'] == 'ACTIVE' ? 1 : 0);
         require_once 'classes/model/Users.php';
         $userInstance = new Users();
         $userData = $userInstance->load($_REQUEST['USR_UID']);
         $userData['USR_STATUS'] = $_REQUEST['NEW_USR_STATUS'];
         $userInstance->update($userData);
         $response->status = 'OK';
     } else {
         $response->status = 'ERROR';
         $response->message = 'USR_UID and NEW_USR_STATUS parameters are required.';
     }
     die(G::json_encode($response));
     break;
 case 'availableGroups':
     G::LoadClass('groups');
     $filter = isset($_POST['textFilter']) ? $_POST['textFilter'] : '';
     $groups = new Groups();
     $criteria = $groups->getAvailableGroupsCriteria($_REQUEST['uUID'], $filter);
     $objects = GroupwfPeer::doSelectRS($criteria);
     $objects->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $arr = array();
예제 #29
0
     $user["xxxview"] = "1";
     $user["consoleview"] = "1";
     $user["bookview"] = "1";
     $page->smarty->assign('user', $user);
     break;
 case 'submit':
     if ($_POST["id"] == "") {
         $invites = $defaultinvites;
         foreach ($userroles as $role) {
             if ($role['id'] == $_POST['role']) {
                 $invites = $role['defaultinvites'];
             }
         }
         $ret = $users->signup($_POST["username"], $_POST["password"], $_POST["email"], '', $_POST["role"], $_POST["notes"], $invites, "", true);
     } else {
         $ret = $users->update($_POST["id"], $_POST["username"], $_POST["email"], $_POST["grabs"], $_POST["role"], $_POST["notes"], $_POST["invites"], isset($_POST['movieview']) ? "1" : "0", isset($_POST['musicview']) ? "1" : "0", isset($_POST['gameview']) ? "1" : "0", isset($_POST['xxxview']) ? "1" : "0", isset($_POST['consoleview']) ? "1" : "0", isset($_POST['bookview']) ? "1" : "0");
         if ($_POST['password'] != "") {
             $users->updatePassword($_POST["id"], $_POST['password']);
         }
     }
     if ($ret >= 0) {
         header("Location:" . WWW_TOP . "/user-list.php");
     } else {
         switch ($ret) {
             case Users::ERR_SIGNUP_BADUNAME:
                 $page->smarty->assign('error', "Bad username. Try a better one.");
                 break;
             case Users::ERR_SIGNUP_BADPASS:
                 $page->smarty->assign('error', "Bad password. Try a longer one.");
                 break;
             case Users::ERR_SIGNUP_BADEMAIL:
예제 #30
0
파일: sign.php 프로젝트: isonz/fxptpcn
function BCCL()
{
    $user = isset($_SESSION['user']) ? $_SESSION['user'] : null;
    if (!$user) {
        header('Location: /');
        exit;
    }
    $userid = isset($_SESSION['userid']) ? (int) $_SESSION['userid'] : 0;
    $usertype = isset($_SESSION['usertype']) ? (int) $_SESSION['usertype'] : 0;
    $name = isset($_SESSION['name']) ? $_SESSION['name'] : '';
    $userstatus = isset($_SESSION['userstatus']) ? (int) $_SESSION['userstatus'] : 0;
    if ($userstatus) {
        header('Location: /');
        exit;
    }
    //状态为0时才显示本页
    $savestatus = 0;
    $errormsg = '';
    $data['sales_channel'] = $sales_channel = isset($_POST['sales_channel']) ? $_POST['sales_channel'] : '';
    $data['how_to_kown_we'] = $how_to_kown_we = isset($_POST['how_to_kown_we']) ? $_POST['how_to_kown_we'] : '';
    $data['certification_photo'] = $certification_photo = isset($_POST['certification_photo_val']) ? $_POST['certification_photo_val'] : '';
    $data['person_hold_photo'] = $person_hold_photo = isset($_POST['person_hold_photo_val']) ? $_POST['person_hold_photo_val'] : '';
    $data['others_photo'] = $others_photo = isset($_POST['others_photo_val']) ? $_POST['others_photo_val'] : '';
    if ($sales_channel && $how_to_kown_we && $certification_photo && $person_hold_photo) {
        if (1 == $usertype) {
            $data['enterprise_legal_photo'] = $enterprise_legal_photo = isset($_POST['enterprise_legal_photo_val']) ? $_POST['enterprise_legal_photo_val'] : '';
            $data['enterprise_grant_photo'] = $enterprise_grant_photo = isset($_POST['enterprise_grant_photo_val']) ? $_POST['enterprise_grant_photo_val'] : '';
            $data['enterprise_tax_photo'] = $enterprise_tax_photo = isset($_POST['enterprise_tax_photo_val']) ? $_POST['enterprise_tax_photo_val'] : '';
            if (!$enterprise_legal_photo) {
                $errormsg = '信息未填写完整。';
                $savestatus = -1;
            } else {
                Users::update($userid, $data);
                $savestatus = 1;
            }
        } else {
            Users::update($userid, $data);
            $savestatus = 1;
        }
    }
    if (!$savestatus) {
        $userinfo = Users::getData($userid, 'certification_photo');
        $savestatus = isset($userinfo['certification_photo']) ? $userinfo['certification_photo'] : '';
        if ($savestatus) {
            $savestatus = 1;
        }
    }
    Templates::Assign('user', $user);
    Templates::Assign('usertype', $usertype);
    Templates::Assign('userid', $userid);
    Templates::Assign('name', $name);
    Templates::Assign('errormsg', $errormsg);
    Templates::Assign('savestatus', $savestatus);
    Templates::Display('signbccl.html');
}