/** * default constructor */ function __construct() { try { $popup = Input::session(self::SESSION_KEY); } catch (InputNotSetException $e) { } if (!empty($popup)) { $this->popup = $popup; } }
public function index() { $query = Input::get('query', true); $results = []; if (!empty($query)) { $results['users'] = $this->userModel->search($query); $results['articles'] = $this->articleModel->search($query); $results['events'] = $this->eventModel->search($query); } $this->getView()->render('search/index', $results); }
public function update() { $this->userModel = $this->loadModel('User'); $iduser = (int) $this->getParams()[0]; $username = Input::get('username'); $firstname = Input::get('firstname'); $lastname = Input::get('lastname'); $mail = Input::get('mail'); $password = sha1(Input::get('password')); $this->userModel->updateAdminUser($iduser, ['username' => $username, 'firstname' => $firstname, 'lastname' => $lastname, 'mail' => $mail, 'password' => $password]); }
public function commentPOST() { if (!Authentication::getInstance()->isAuthenticated()) { throw new NotAuthenticatedException(); } $id = (int) $this->getParams()[0]; $this->articleCommentModel->insertCommentArticle(Authentication::getInstance()->getUserId(), $id, Input::post('message')); $this->getView()->redirect('/article/show/' . $id); }
public function addPOST() { if (empty($this->getParams(true))) { $this->getView()->redirect('/conversation'); } $conversationId = (int) $this->getParams()[0]; $userModel = $this->loadModel('User'); foreach (explode(', ', Input::post('participations')) as $participation) { $userId = $userModel->getUserFullNameLike($participation)['id']; $this->conversationModel->addUserToConversation($conversationId, $userId); } $this->getView()->redirect('/conversation/show/' . $conversationId); }
public function accountPOST() { // HARDCODE $privacyValues = ['jobPrivacy' => 1, 'websitePrivacy' => 2, 'facebookuriPrivacy' => 4, 'skypePrivacy' => 8, 'twitterPrivacy' => 16, 'phonenumberPrivacy' => 32, 'mailPrivacy' => 64]; $input = new Input(); $toModify = $input->getPost(); try { if (!empty($params) && Authentication::getInstance()->getOptionOr('accessLevel', 0)) { $user = $this->userModel->getUser($toModify['id']); } else { $user = $this->userModel->getUser(Authentication::getInstance()->getUserId()); } if (empty($user)) { throw new NoUserFoundException(Authentication::getInstance()->getUserName()); } $privacyUser = PrivacyCalculator::calculate($user['id']); foreach ($privacyValues as $key => $value) { if (!isset($toModify[$key]) && $privacyUser[$key] == true) { $user['privacy'] -= $value; } else { if (isset($toModify[$key]) && $privacyUser[$key] == false) { $user['privacy'] += $value; } } if (isset($toModify[$key])) { unset($toModify[$key]); } } foreach ($toModify as $key => $value) { if ($user[$key] != $value) { $user[$key] = $value; } } $toModify['privacy'] = $user['privacy']; $toModify['id'] = $user['id']; $this->userModel->updateUser($toModify); $this->getView()->redirect('/user/profile/' . $toModify['username']); //$this->getView()->render('home/index'); } catch (NoUserFoundException $e) { $e->getMessage(); $this->getView()->render('/home/index'); } }
public function validate($inputs) { $result = []; foreach ($this->getFields() as $field) { if (array_key_exists($field->getName(), $inputs)) { if ($this->getMethod() == 'POST') { $result[$field->getName()] = Input::post($field->getName()); } elseif ($this->getMethod() == 'GET') { $result[$field->getName()] = Input::get($field->getName()); } } } return $result; }