/** * Sets the passed in user as the authenticated * user of the application. Will generate a ticket * for this user which will be used for subsequent * requests. * * @param NovemberUser $user */ public function setAuthenticatedUser(NovemberUser $user, $regenTicket = true) { if ($regenTicket) { $user->ticket = $this->generateTicket($user->getUsername()); } $today = date('Y-m-d H:i:s'); $user->setLastLogin($today); $this->dbService->updateObject($user); za()->setUser($user); }
/** * The user is held in the application object * for quick and easy access * * @param ZendUser $user */ public function setUser(NovemberUser $user) { $this->getSession()->CURRENT_USER_NAME = $user->getUsername(); $this->getSession()->CURRENT_USER_TICKET = $user->getTicket(); $this->user = $user; }
/** * Get a detailed timesheet * * If an explicit timesheet id is passed in, only records that have * been locked off against that timesheet will be included in the * result. * * @param NovemberUser $user * @param int $taskid * @param int $projectid * @param int $clientid * @param int $timesheet * @param int $start * @param int $end * @return ArrayObject */ public function getDetailedTimesheet($user = null, $taskid = null, $projectid = null, $clientid = null, $timesheet = -1, $start = null, $end = null, $categories = array(), $order = 'endtime DESC') { $select = $this->dbService->select(); /* @var $select Zend_Db_Select */ $select->from('timesheetrecord', '*')->joinLeft('task', new Zend_Db_Expr('task.id=timesheetrecord.taskid'), new Zend_Db_Expr('task.title as tasktitle, task.category as taskcategory')); //-> if (count($categories)) { $this->dbService->applyWhereToSelect(array('task.category' => $categories), $select); } $select = $this->filterBaseTimesheetQuery($select, $taskid, $projectid, $clientid, $start, $end); // If passed a user object, just filter their timesheet entries if ($user != null) { $select->where('timesheetrecord.userid = ?', $user->getUsername()); } // If a timesheet is -1, it means we're just generating dynamic reports, // and it doesn't matter if we include the already accounted for timesheet // records if ($timesheet >= 0) { $select->where('timesheetrecord.timesheetid = ?', $timesheet); } $select->order($order); return $this->dbService->fetchObjects('TimesheetRecord', $select); }
/** * Sets the passed in user as the authenticated * user of the application. Will generate a ticket * for this user which will be used for subsequent * requests. * * @param NovemberUser $user */ public function setAuthenticatedUser(NovemberUser $user) { $user->ticket = $this->generateTicket($user->getUsername()); za()->setUser($user); }
/** * Update a given user. * @param NovemberUser $userToEdit * @param array $params */ public function updateUser($userToEdit, $params, $synch = true) { if (isset($params['email'])) { // Check if there's a user with this email first. $existing = $this->dbService->getByField(array('email' => $params['email']), $this->userClass); if ($existing && $existing->id != $userToEdit->getId()) { throw new ExistingUserException($params['email'] . ' already exists'); } } // Make sure no role is being changed! we do that in another method. unset($params['role']); $newPass = null; if (isset($params['password'])) { $newPass = $params['password']; $userToEdit->generateSaltedPassword($params['password']); unset($params['password']); } $userToEdit->bind($params); $validator = new ModelValidator(); if (!$validator->isValid($userToEdit)) { throw new InvalidModelException($validator->getMessages()); } $ret = $this->dbService->updateObject($userToEdit); $this->authComponent->updateUser($userToEdit, $newPass); return $ret; }