當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Model_Users::getByUserName方法代碼示例

本文整理匯總了PHP中Model_Users::getByUserName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Users::getByUserName方法的具體用法?PHP Model_Users::getByUserName怎麽用?PHP Model_Users::getByUserName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Model_Users的用法示例。


在下文中一共展示了Model_Users::getByUserName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: indexAction

 public function indexAction()
 {
     if (isset($this->_session->user)) {
         $this->redirect("home/");
     }
     if (isset($_POST['submit']) && $_POST['submit'] == "SIGN IN") {
         $login_data = $_POST;
         $user = Model_Users::getByUserName($login_data['username']);
         if (!empty($user['user_name']) && $user['user_password'] == $login_data['password']) {
             Zend_Session::regenerateId();
             $this->_session->user = $user;
             $this->redirect('home');
         } else {
             $errors['invalid_credentials'] = 'Invalid Credentials!!';
         }
         $this->view->errors = $errors;
     }
 }
開發者ID:rahulreghu,項目名稱:shreeimpex,代碼行數:18,代碼來源:IndexController.php

示例2: editAction

 public function editAction()
 {
     $request = $this->getRequest();
     if (!JO_Session::get('user_id')) {
         JO_Session::set('msg_error', $this->translate('You must be logged to change your profile'));
         $redir = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
         if ($request->getRequest('tool') == 'change_avatar') {
             die(json_encode(array('logout' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'))));
         } else {
             $this->redirect($redir);
         }
     }
     $this->getLayout()->meta_title = $this->translate('Edit settings');
     $this->getLayout()->meta_description = $this->translate('Edit settings');
     if (JO_Session::get('msg_success')) {
         $this->view->msg_success = JO_Session::get('msg_success');
         JO_Session::clear('msg_success');
     } elseif (JO_Session::get('msg_error')) {
         $this->view->error = JO_Session::get('msg_error');
         JO_Session::clear('msg_error');
     }
     $tool = $request->getRequest('tool');
     $username = JO_Session::get('username');
     $this->view->user = Model_Users::getByUserName($username);
     $this->view->author_header = Helper_Author::authorHeader($this->view->user);
     $this->view->settings_box = Helper_Author::getSettingsBox($tool);
     $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Profile'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username=' . $username)), array('name' => $this->translate('Settings'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=edit')));
     switch ($tool) {
         case 'change_avatar':
             $image = $request->getFile('file');
             if ($image) {
                 $users_path = '/users/' . JO_Date::getInstance(JO_Session::get('register_datetime'), 'yy/mm') . '/' . JO_Session::get('user_id') . '/';
                 $upload_folder = realpath(BASE_PATH . '/uploads');
                 $upload_folder .= $users_path;
                 $upload = new JO_Upload();
                 $upload->setFile($image)->setExtension(array('.jpg', '.jpeg', '.png', '.gif'))->setUploadDir($upload_folder);
                 $new_name = md5(time() . serialize($image));
                 if ($upload->upload($new_name)) {
                     $info = $upload->getFileInfo();
                     if ($info) {
                         $file_path = $users_path . $info['name'];
                         $model_images = new Model_Images();
                         if (JO_Session::get('avatar')) {
                             $model_images->deleteImages(JO_Session::get('avatar'), true);
                         }
                         $thumb = $model_images->resize($file_path, JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true);
                         Model_Users::editAvatar(JO_Session::get('user_id'), $file_path);
                         die('{ "avatar": "' . $thumb . '", "msg_success": "' . $this->translate('You have successfully changed your avatar') . '"}');
                     } else {
                         die('{ "msg_error": "' . $this->translate('There was an unexpected error with uploading the file') . '"}');
                     }
                 } else {
                     die('{ "msg_error": "' . $this->translate('The file must be valid image') . '" }');
                 }
             }
             break;
         case 'change_password':
             if ($request->isPost()) {
                 $s = Model_Users::editPassword(JO_Session::get('user_id'), array('password' => $request->getPost('password'), 'new_password' => $request->getPost('new_password'), 'new_password_confirm' => $request->getPost('new_password_confirm')));
                 if ($s === true) {
                     $this->session->set('msg_success', $this->translate('You have successfully updated your password'));
                 } else {
                     $this->session->set('msg_error', $s);
                 }
                 $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=edit&tool=change_password'));
             }
             $this->view->formtitle = $this->translate('Change your password');
             $this->view->crumbs[] = array('name' => $this->view->formtitle);
             $this->view->author_form = $this->view->renderByModule('single_user/change_password', 'users', 'themes');
             break;
         case 'exclusive_author':
             if ($request->isPost()) {
                 $exclusive_author = $request->getPost('exclusive_author');
                 Model_Users::editExclusive(JO_Session::get('user_id'), $exclusive_author);
                 if ($exclusive_author == 'true') {
                     JO_Session::set('msg_success', $this->translate('You have successfully changed to exclusive author'));
                 } else {
                     JO_Session::set('msg_success', $this->translate('You have successfully changed to non exclusive author'));
                 }
                 $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=edit&tool=exclusive_author'));
             }
             if ($this->view->user['exclusive_author'] == 'true') {
                 $this->view->formtitle = $this->translate('Exclusive Author');
                 $this->view->button = $this->translate('Unsubscribe me as exclusive author');
             } else {
                 $this->view->formtitle = $this->translate('Non-Exclusive Author');
                 $this->view->button = $this->translate('Subscribe me as exclusive author');
             }
             $this->view->top_text = $this->translate('Agreeing to keep your portfolio of items for sale exclusive to the Marketplaces entitles you to a higher percentage of each sale - from 40% to 70%. You can still sell other items elsewhere (on other marketplaces, your own site) however any items you place on an Marketplace must be exclusively sold there.');
             $this->view->bottom_text = $this->translate('You can opt-out of the exclusivity program by clicking the button below. You will be given a 30 day grace period wherein the agreement is still observed after which your payments will return to normal and you may commence selling your items elsewhere.');
             $this->view->crumbs[] = array('name' => $this->view->formtitle);
             $this->view->author_form = $this->view->renderByModule('single_user/exclusive_author', 'users', 'themes');
             break;
         case 'sale_license':
             if ($request->isPost()) {
                 if ($request->getPost('license')) {
                     Model_Users::editLicense(JO_Session::get('user_id'), $request->getPost('license'));
                     JO_Session::set('msg_success', $this->translate('You have successfully changed the license types'));
                 } else {
                     JO_Session::set('msg_error', $this->translate('You have to choose your license'));
//.........這裏部分代碼省略.........
開發者ID:noikiy,項目名稱:PD,代碼行數:101,代碼來源:UsersController.php

示例3: addUserAction

 public function addUserAction()
 {
     $data = array();
     $error = false;
     $this->_helper->viewRenderer->setNoRender(true);
     $request = $this->getRequest()->getPost();
     //print_r($request);exit();
     $data['user_name'] = $request['user_name'];
     $data['user_firstname'] = $request['user_firstname'];
     $data['user_lastname'] = $request['user_lastname'];
     $data['user_email'] = $request['user_email'];
     $data['user_password'] = $request['user_password'];
     $data['user_role'] = $request['user_role'];
     $data['user_registered'] = date('Y-m-d H:i:s');
     $data['user_status'] = 1;
     if (Model_Users::getByUserName($data['user_name'])) {
         $error .= 'Username already exists' . '</br>';
     }
     if (Model_Users::getByEmail($data['user_email'])) {
         $error .= 'Email already exists' . '</br>';
     }
     if (!$error) {
         if (Model_Users::addUser($data)) {
             $this->view->success = "User details have been added successfully";
         } else {
             $this->view->error .= 'Unexpected error occured' . '</br>';
         }
     } else {
         $this->view->error = $error;
     }
     $this->view->activetab = 'add_user';
     self::indexAction();
     $this->render('index');
 }
開發者ID:rahulreghu,項目名稱:shreeimpex,代碼行數:34,代碼來源:SettingsController.php


注:本文中的Model_Users::getByUserName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。