PHP Method User::fetchRow, codiad Code Examples

This page contains top rated real world PHP examples of method User::fetchRow from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: PasswordController.php Project: josephholsten/swaplady
0
 public function sendAction()
 {
     $this->logger->entering();
     $this->logger->info('Get email from params');
     $email = $this->_getParam('email');
     $this->logger->info('Getting password for email');
     $users = new User();
     $where = $this->db->quoteInto('email = ?', $email);
     $user = $users->fetchRow($where);
     if ($user->id != null) {
         $this->logger->debug("Got user #{$user->id}");
         $this->logger->info('Sending password reminder');
         $mail = new Zend_Mail();
         $mail->setFrom('somebody@example.com', 'Some Sender');
         $mail->addTo($user->email, $user->name);
         $mail->setSubject("Your Swaplady Password");
         $mail->setBodyText("Hi {$user->name},\nHere's your swaplady password:\n{$user->password}\nPlease keep it safe and sound.");
         $mail->send();
         $this->flash->notice = "Your password has been emailed to {$user->email}";
         $this->_redirect('/session/new');
     } else {
         $this->logger->warn('Unknown email');
         $this->flash->notice = "Your email wasn't recognized, did you spell it right?";
         $this->_redirect('/password/forgot');
     }
     $this->logger->exiting();
 }
Example #2
Show file File: SessionController.php Project: josephholsten/swaplady
0
 public function createAction()
 {
     $this->logger->entering();
     $this->logger->info('Getting the username and password');
     $user = $this->_getParam('user');
     $username = $user['username'];
     $password = $user['password'];
     $this->logger->info("Loading the user by username and password '{$username}'");
     $users = new User();
     $where = $this->db->quoteInto('username = ?', $username) . $this->db->quoteInto('AND password = ?', $password);
     $user = $users->fetchRow($where);
     if ($user->username == $username && $user->password == $password) {
         $this->logger->info("Found the user '{$user->id}'");
         $this->session->user_id = $user->id;
         if (isset($this->flash->redirectedFrom)) {
             $intendedAction = $this->flash->redirectedFrom;
             $this->logger->notice("Redirecting to intended action '{$intendedAction['controller']}::{$intendedAction['action']}'");
             $this->_redirect('/' . $intendedAction['controller'] . '/' . $intendedAction['action']);
         } else {
             $this->logger->info('Redirecting to user page by default');
             $this->_redirect("user/show/{$user->id}");
         }
     } else {
         $this->flash->notice = 'Invalid username/password combination. Perhaps you\'d like to <a href="/user/new">register</a>? Or would you like us to <a href="/password/forgot">email your password to you</a>?';
         $this->flash->keep = TRUE;
         $this->_redirect('/session/new');
     }
 }
Example #3
Show file File: Ldap.php Project: knatorski/SMS
0
 /**
  * Implementacja metody z interfejsu Zend_Auth_Adapter_Interface
  * @see Zend_Auth_Adapter_Interface::authenticate()
  * @return Zend_Auth_Result
  */
 public function authenticate()
 {
     if (empty($this->_username)) {
         throw new Zend_Auth_Adapter_Exception('Nie podano loginu!');
     }
     if (empty($this->_password)) {
         throw new Zend_Auth_Adapter_Exception('Nie podano hasła!');
     }
     $config = Zend_Registry::get('config');
     $this->_options = $config['ldap'];
     $resultLDAP = parent::authenticate();
     if ($resultLDAP->isValid()) {
         $userModel = new User();
         $userRow = $userModel->fetchRow(array('login = ?' => new Zend_Db_Expr("UPPER('{$this->_username}')"), 'ghost = ?' => 'f', 'is_locked = ?' => 'f', new Zend_Db_Expr('valid_until > NOW()')));
         if ($userRow !== null) {
             $identity = $this->_toStdClass($userRow);
             unset($identity->password);
             $ldapData = parent::getAccountObject();
             $identity->ldap = $ldapData;
             $branchModel = new Branch();
             $identity->id_branch = ODDZIAL_ID;
             $identity->view_branch = ODDZIAL_ID;
             $data = $branchModel->find($identity->id_branch);
             $d = $data->current()->toArray();
             $d['application_code'] = 'getin';
             $identity->jednostka = $d;
             $identity->user_backend_apps_logins = null;
             $identity->default_branches[$d['application_code']]['default_login'] = 'user';
             $this->_authResult['code'] = Zend_Auth_Result::SUCCESS;
             $this->_authResult['messages'] = 'Autoryzacja pomyślna.';
             $this->_authResult['identity'] = $identity;
             return $this->_createAuthResult();
         } else {
             $this->_authResult['code'] = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
             $this->_authResult['messages'] = 'Konto nieaktywne lub zablokowane.';
             return $this->_createAuthResult();
         }
     } else {
         $this->_authResult['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
         $this->_authResult['messages'] = 'Nieprawidłowe dane logowania.';
         return $this->_createAuthResult();
     }
 }
Example #4
Show file File: Abstract.php Project: knatorski/SMS
0
 /**
  *
  * @TODO cach profilu
  */
 protected function getCurrentProfile()
 {
     if (defined('CMD')) {
         $config = Zend_Registry::get('config');
         if ($config['bin']['user'] === null || $config['bin']['branch'] === null) {
             throw new Exception('Brak ustawień w application.ini bin.user lub bin.branch');
         }
         $u = new User();
         $u_data = $u->fetchRow("login = '" . $config['bin']['user'] . "'", "id DESC")->toArray();
         $storageRow = new stdClass();
         foreach ($u_data as $key => $value) {
             $storageRow->{$key} = $value;
         }
         $auth = Zend_Auth::getInstance();
         $storage = $auth->getStorage();
         $o = new Branch();
         $data = $o->fetchRow("branch_name = '" . $config['bin']['branch'] . "'", "id DESC")->toArray();
         $storageRow->jednostka = $data;
         $profile = new Profile();
         $profiles = $profile->fetchAll(array('id_user = ' . $u_data['id'], 'id_branch = ' . $data['id'], 'ghost = false'));
         if (count($profiles)) {
             $storageRow->profile_id = $profiles[0]['id'];
         }
         $storage->write($storageRow);
     }
     if (defined('CMD') && defined('EXPORT_ID_USER')) {
         $identity['id'] = EXPORT_ID_USER;
         $where_id = $identity['id'];
     } else {
         $where_id = Zend_Auth::getInstance()->getIdentity() ? Zend_Auth::getInstance()->getIdentity()->id : '';
     }
     if (!$this->currentProfile and $where_id) {
         $cm = $this->getBootstrap()->getResource('cachemanager');
         $cache = $cm->getCache('rolecache');
         $cache_id = str_replace("-", "", 'OUcache' . ODDZIAL_ID . '_' . $where_id);
         if (!($this->currentProfile = $cache->load($cache_id))) {
             $profilModel = new Profile();
             $this->currentProfile = $profilModel->fetchRow(array("id_user = {$where_id}", "id_branch = " . ODDZIAL_ID, 'ghost = false'));
             $cache->save($this->currentProfile, $cache_id);
         }
     }
     return $this->currentProfile;
 }
Example #5
Show file File: RemoteUserDbTable.php Project: knatorski/SMS
0
 function _authenticateValidateResult($resultIdentity)
 {
     $zendAuthCredentialMatchColumn = $this->_zendDb->foldCase('zend_auth_credential_match');
     if ($resultIdentity[$zendAuthCredentialMatchColumn] != '1') {
         $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
         $this->_authenticateResultInfo['messages'][] = 'Supplied credential is invalid.';
         return $this->_authenticateCreateAuthResult();
     }
     unset($resultIdentity[$zendAuthCredentialMatchColumn]);
     $this->_resultRow = $resultIdentity;
     // $userModel = new Logic_User();
     //  $user = $userModel->getUserByLogin();
     $userModel = new User();
     $user = $userModel->fetchRow(array('login = ?' => new Zend_Db_Expr("UPPER('" . $resultIdentity['login'] . "')"), 'ghost = ?' => 'f', 'is_locked = ?' => 'f', new Zend_Db_Expr('valid_until > NOW()')));
     if (empty($user)) {
         $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
         $this->_authenticateResultInfo['messages'][] = 'Authentication failed.';
         return $this->_authenticateCreateAuthResult();
     }
     $identity = $this->_toStdClass($user);
     $identity->password = $this->_password;
     $branchModel = new Branch();
     $identity->id_branch = ODDZIAL_ID;
     $identity->view_branch = ODDZIAL_ID;
     $data = $branchModel->find($identity->id_branch);
     $d = $data->current()->toArray();
     $d['application_code'] = 'getin';
     $identity->jednostka = $d;
     $identity->user_backend_apps_logins = null;
     $identity->default_branches[$d['application_code']]['default_login'] = 'user';
     //$identity->user_backend_apps_logins[$d['application_code']]['application_login'] = 'app_user';
     $this->_authenticateResultInfo['identity'] = $identity;
     $this->_resultRow = $user;
     $this->_authenticateResultInfo['code'] = Zend_Auth_Result::SUCCESS;
     $this->_authenticateResultInfo['messages'][] = 'Authentication successful.';
     return $this->_authenticateCreateAuthResult();
 }
Example #6
Show file File: init.php Project: knatorski/SMS
0
    echo "\n\n" . $opts->getUsageMessage() . "\n\n";
    exit;
}
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
Base_Controller_Action_Helper_Currentip::$_unitTestEnabled = true;
$application->bootstrap();
Zend_Controller_Front::getInstance()->setParam('bootstrap', $application->getBootstrap());
$user = $application->getOption('bin');
if ($user['user'] === null || $user['branch'] === null) {
    throw new Exception('Brak ustawień w application.ini bin.user lub bin.branch');
}
$u = new User();
$u_data = $u->fetchRow("login = '" . $user['user'] . "'", "id DESC");
if (null == $u_data) {
    throw new Exception('Brak użytkownika o podanym loginie ' . $user['user']);
}
$u_data->toArray();
$storageRow = new stdClass();
foreach ($u_data as $key => $value) {
    $storageRow->{$key} = $value;
}
$auth = Zend_Auth::getInstance();
$storage = $auth->getStorage();
$o = new Branch();
$data = $o->fetchRow("branch_name = '" . $user['branch'] . "'", "id DESC");
if (null == $u_data) {
    throw new Exception('Brak Branch\'a ' . $user['branch']);
}
Example #7
Show file File: Transaction.php Project: josephholsten/swaplady
0
 public function signupUser($user)
 {
     Zend_Registry::get('logger')->entering();
     $transactionId = $this->create();
     $users = new User();
     $swaplady = $users->fetchRow('username = "swaplady"');
     Zend_Registry::get('logger')->debug('Transfer signup bonus from swaplady to user');
     SwapbuckEntry::transfer($transactionId, $swaplady, $user, self::SIGNUP_BONUS);
     Zend_Registry::get('logger')->exiting();
     return $transactionId;
 }
Example #8
Show file File: UserController.php Project: falafflepotatoe/trainsmart-code
0
 public function forgotPasswordAction()
 {
     $request = $this->getRequest();
     $validateOnly = $request->isXmlHttpRequest();
     if ($validateOnly) {
         $this->setNoRenderer();
     }
     $status = ValidationContainer::instance();
     $this->view->assign('complete', false);
     $status->setStatusMessage(t('Starting...'));
     if ($this->_getParam('send')) {
         $status->checkRequired($this, 'email', t('Email'));
         if (!$status->hasError()) {
             //$this->view->assign ( 'test', "has error");
             $userTable = new User();
             $select = $userTable->select();
             $select->where("email = ?", $this->_getParam('email'));
             $row = $userTable->fetchRow($select);
             if (!$row) {
                 $status->setStatusMessage('That user could not be found.');
                 $this->view->assign('complete', true);
             }
             if ($row) {
                 require_once 'models/Password.php';
                 $newpass = Text_Password::create(8);
                 $row->password = $newpass;
                 $result = $row->save();
                 if ($result > 0) {
                     $view = new Zend_View();
                     $view->assign('base_url', Settings::$COUNTRY_BASE_URL);
                     $view->setScriptPath(Globals::$BASE_PATH . '/app/views/scripts/email');
                     $view->assign('first_name', $row->first_name);
                     $view->assign('username', $row->username);
                     $view->assign('password', $newpass);
                     $text = $view->render('text/forgot.phtml');
                     $html = $view->render('html/forgot.phtml');
                     $mail = new Zend_Mail();
                     $mail->setBodyText($text);
                     $mail->setBodyHtml($html);
                     $mail->setFrom(Settings::$EMAIL_ADDRESS, Settings::$EMAIL_NAME);
                     $mail->addTo($row->email, $row->username);
                     $mail->setSubject('Password Change Requested');
                     $mail->send();
                     $status->setStatusMessage(t('Your new password has been sent. Please check your email for further instructions.'));
                     //$this->view->assign ( 'complete', true );
                 } else {
                     $status->setStatusMessage(t('Mail send error.'));
                 }
             }
         }
     }
     if ($validateOnly) {
         $this->sendData($status);
     } else {
         $this->view->assign('status', $status);
     }
 }
Example #9
Show file File: WorkoutController.php Project: laiello/workout
0
 /**
  * The default action - show the home page
  */
 public function indexAction()
 {
     $method = $this->getRequest()->getMethod();
     $view = $this->initView();
     $callback = $this->getRequest()->getParam('callback');
     $id = $this->getRequest()->getParam('id');
     $date = $this->getRequest()->getParam('date');
     if ($method == 'GET') {
         $user = new User();
         if ($id) {
             $s = 'id';
             if (!is_numeric($id)) {
                 $s = 'login';
             }
             $row = $user->fetchRow($user->select()->where($s . ' = ?', $id));
             if (is_null($row)) {
                 /* 404 Not Found */
                 $this->getResponse()->setHttpResponseCode(404);
             } else {
                 $response = Zend_Json_Encoder::encode($row->toArray());
             }
         } else {
             $rows = $user->fetchAll();
             $users = $rows->toArray();
             if ($users == 0) {
                 /* 404 Not Found */
                 $this->getResponse()->setHttpResponseCode(404);
             } else {
                 /*foreach ($users as &$u) {
                 			$u['teste'] = $id.' - '.$date;
                 		}*/
                 $response = Zend_Json_Encoder::encode($users);
             }
         }
         if ($callback) {
             $response = $callback . "(" . $response . ")";
         }
         $view->json = $response;
         $this->render('json');
     } elseif ($method == 'POST') {
         //$user = Zend_Json_Decoder::decode($this->getRequest()->getParam('user'));
         $t = $this->getRequest()->getRawBody();
         $temp = Zend_Json_Decoder::decode($t, Zend_Json::TYPE_ARRAY);
         $user = new User();
         try {
             $l = Zend_Json_Decoder::decode($t, Zend_Json::TYPE_OBJECT)->login;
             $verified = $user->fetchRow($user->select()->where('login = ?', $l));
             if ($verified->id == 0) {
                 $inserted = $user->insert($temp);
                 $response = $inserted;
                 //$user['name'];
             } else {
                 /* 409 Conflict */
                 $this->getResponse()->setHttpResponseCode(409);
             }
         } catch (Exception $e) {
             $response = $e->getMessage();
         }
         if ($callback) {
             $response = $callback . "(" . $response . ")";
         }
         $view->json = $response;
         $this->render('json');
     } elseif ($method == 'DELETE') {
     } elseif ($method == 'PUT') {
     } else {
         /* 405 Method Not Allowed */
         $this->getResponse()->setHttpResponseCode(405);
     }
 }
Example #10
Show file File: TrainingApprovalHistory.php Project: falafflepotatoe/trainsmart-code
0
 public function insert(array $data)
 {
     $auth = Zend_Auth::getInstance();
     $user_id = $auth->getIdentity()->id;
     $user_table = new User();
     $user_row = $user_table->fetchRow('id = ' . $user_id);
     $data['created_by'] = $user_id;
     if (!isset($data['approval_status']) or !$data['approval_status']) {
         $data['approval_status'] = 'new';
     }
     //get recipients
     $training_id = $data['training_id'];
     $select = $this->select()->setIntegrityCheck(false)->from($this->_name)->join(array('u' => 'user'), "training_approval_history.created_by = u.id", array('email', 'first_name', 'last_name'))->where("training_id = {$training_id} AND u.is_blocked = 0");
     $previous_history_rows = $this->fetchAll($select);
     $recipients = array();
     foreach ($previous_history_rows as $rec) {
         $recipients[$rec->created_by] = array('email' => $rec->email, 'name' => $rec->first_name . ' ' . $rec->last_name);
     }
     //send to anyone other than creator
     unset($recipients[$user_id]);
     //insert the row
     $data['recipients'] = implode(',', array_keys($recipients));
     parent::insert($data);
     //send the mail
     #echo print_r($recipients, true) . '//'.$data['approval_status'];
     #$recipients = array('name' => 'jgh23@uw.edu', 'email' => 'jgh23@uw.edu');
     if ($recipients && $data['approval_status']) {
         require_once 'models/table/Training.php';
         $training = new Training();
         $training_name = $training->getCourseName($training_id);
         $view = new Zend_View();
         $view->setScriptPath(Globals::$BASE_PATH . '/app/views/scripts/email');
         $view->assign('creator', $user_row->first_name . ' ' . $user_row->last_name);
         $view->assign('training_name', $training_name);
         $view->assign('comments', $data['message']);
         $view->assign('link', Settings::$COUNTRY_BASE_URL . '/training/edit/id/' . $training_id);
         $mail = new Zend_Mail();
         switch ($data['approval_status']) {
             case 'approved':
                 $text = $view->render('text/approved.phtml');
                 $html = $view->render('html/approved.phtml');
                 $mail->setSubject(t('Training') . ' ' . t('Approved'));
                 break;
             case 'rejected':
                 $text = $view->render('text/rejected.phtml');
                 $html = $view->render('html/rejected.phtml');
                 $mail->setSubject(t('Training') . ' ' . t('Rejected'));
                 break;
             case 'resubmitted':
                 $text = $view->render('text/resubmitted.phtml');
                 $html = $view->render('html/resubmitted.phtml');
                 $mail->setSubject(t('Training') . ' ' . t('Resubmitted'));
                 break;
         }
         $mail->setBodyText($text);
         $mail->setBodyHtml($html);
         $mail->setFrom(Settings::$EMAIL_ADDRESS, Settings::$EMAIL_NAME);
         foreach ($recipients as $guy) {
             $mail->addTo($guy['email'], $guy['name']);
         }
         //$mail->send();
     }
 }
Example #11
Show file File: User.php Project: knatorski/SMS
0
 public function getAssignetWsClientId($id = null)
 {
     if (null === $id) {
         if (null === ($identity = Zend_Auth::getInstance()->getIdentity())) {
             return null;
         }
         $userId = $identity->id;
     } else {
         $userId = $id;
     }
     $model = new User();
     $entry = $model->fetchRow('id = ' . $userId);
     return $entry->ws_client_id;
     /* $dict = new Base_Dictionary();
               $dicEntry = $dict->setSource(new WsClientMpk(),array("mpk_code ilike '".$entry->mpk_code."'"), 'id ASC' , 'mpk_code', array('ws_client_id'))->getDictionary();
               $ws_client_id = $dicEntry[$entry->mpk_code];
     
               return $ws_client_id; */
 }
Example #12
Show file File: UsersController.php Project: laiello/workout
0
 public function doGet()
 {
     $view = $this->initView();
     $callback = $this->getRequest()->getParam('callback');
     $id = $this->getRequest()->getParam('id');
     $date = $this->getRequest()->getParam('date');
     $user = new User();
     if ($id) {
         $s = 'id';
         if (!is_numeric($id)) {
             $s = 'login';
         }
         $row = $user->fetchRow($user->select()->where($s . ' = ?', $id));
         if (is_null($row)) {
             /* 404 Not Found */
             $this->getResponse()->setHttpResponseCode(404);
         } else {
             $response = Zend_Json_Encoder::encode($row->toArray());
         }
     } else {
         $rows = $user->fetchAll();
         $users = $rows->toArray();
         if ($users == 0) {
             /* 404 Not Found */
             $this->getResponse()->setHttpResponseCode(404);
         } else {
             /*foreach ($users as &$u) {
             			$u['teste'] = $id.' - '.$date;
             		}*/
             $response = Zend_Json_Encoder::encode($users);
         }
     }
     if ($callback) {
         $response = $callback . "(" . $response . ")";
     }
     $view->json = $response;
     $this->render('json');
 }