コード例 #1
0
ファイル: Hint.php プロジェクト: modulargaming/core
 /**
  * Set a new message using the `messages/hint` file.
  *
  *     // The array path to the message
  *     Hint::error('user.login.error');
  *
  *     // Embed some values
  *     Hint::success('user.login.success', array($username));
  *
  * @param  string  $type  message type (e.g. Hint::SUCCESS)
  * @param  array   $arg   remaining parameters
  * @uses   __()
  */
 public static function __callStatic($type, $arg)
 {
     Hint::set($type, $arg[0], Arr::get($arg, 1), Arr::get($arg, 2));
 }
コード例 #2
0
ファイル: error.php プロジェクト: nexeck/kohana-errors
	/**
	 * Redirects the user upon error
	 *
	 * @param	 array	$options	Options from config
	 * @return	void
	 */
	protected function _action_redirect(array $options = array())
	{
		if ($this->code === 'E_PARSE')
		{
			echo '<p><strong>NOTE:</strong> Cannot redirect on a parse error, because it might cause a redirect loop.</p>';
			echo $this->display;
			return;
		}

		$hint_available = (class_exists('Hint') and method_exists('Hint', 'set'));
		$message = Arr::get($options, 'message', false);
		if ($hint_available and $message)
		{
			Hint::set(HINT::ERROR, $message);
		}

		$url = Arr::get($options, 'url');
		if (strpos($url, '://') === false)
		{
			// Make the URI into a URL
			$url = URL::site($url, true);
		}
		header("Location: $url", true);
		exit;
	}
コード例 #3
0
ファイル: Manage.php プロジェクト: happydemon/s4k
 public function action_delete()
 {
     $id = $this->request->param('id');
     try {
         $user = Sentry::getUserProvider()->findById($id);
         $id = $user->id;
         $user->delete();
         Hint::set(Hint::SUCCESS, 'You\'ve deleted user "#' . $id);
         $this->redirect(Route::url('S4K.users.manage', null, true));
     } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) {
         Hint::set(Hint::ERROR, 'No corresponding user found');
         $this->redirect(Route::url('S4K.users.manage', null, true));
     }
 }
コード例 #4
0
ファイル: User.php プロジェクト: happydemon/s4k
 public function action_reset_valid_complete()
 {
     if ($this->request->post() != null) {
         try {
             // Find the user using the user id
             $user = Sentry::getUserProvider()->findByCredentials(array('email' => $this->request->post('email')));
             if ($this->request->post('password') == '') {
                 Hint::set(Hint::ERROR, 'Please provide a password.');
             } else {
                 if ($user->checkResetPasswordCode($this->request->post('code'))) {
                     // Attempt to reset the user password
                     if ($user->attemptResetPassword($this->request->post('code'), $this->request->post('password'))) {
                         // Password reset passed
                         Hint::set(Hint::SUCCESS, 'You have successfully reset your password');
                         //everything went successful, send the user somewhere else
                         $this->redirect(Route::url('S4K.users.reset_valid', null, true));
                     } else {
                         Hint::set(Hint::ERROR, 'Resetting your password has failed.');
                     }
                 } else {
                     // The provided password reset code is Invalid
                     Hint::set(Hint::ERROR, 'The provided reset code is invalid.');
                 }
             }
         } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
             Hint::set(Hint::ERROR, 'There\'s no user with that login credential.');
         }
         // Resetting the password failed, show the form with the errors
         $this->redirect(Route::url('S4K.users.reset_valid', null, true));
         $this->action_reset_valid();
     } else {
         // no post request made, send back
         $this->redirect(Route::url('S4K.users.reset_valid', null, true));
     }
 }
コード例 #5
0
ファイル: Groups.php プロジェクト: happydemon/s4k
 public function action_delete()
 {
     $id = $this->request->param('id');
     try {
         $group = Sentry::getGroupProvider()->findById($id);
         $name = $group->name;
         $group->delete();
         //set a success message an redirect to the management page
         Hint::set(Hint::SUCCESS, 'You\'ve deleted group "' . $name . '"');
         $this->redirect(Route::url('S4K.groups', null, true));
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         //set an error message an redirect to the management page
         Hint::set(Hint::ERROR, 'No corresponding group found');
         $this->redirect(Route::url('S4K.groups', null, true));
     }
 }