Пример #1
0
 protected function check_user_is_admin()
 {
     return Auth\Auth::check() && Auth\Auth::get('group', -1) == 100;
 }
Пример #2
0
<?php

require 'init.php';
if (!Auth\Auth::check()) {
    die('error');
}
$user = Auth\Auth::get();
var_dump(Auth\Auth::edit($user->id, $_GET['mail'], $_GET['name'], isset($_GET['pass']) ? $_GET['pass'] : $_GET['pass'], isset($_GET['pass2']) ? $_GET['pass2'] : $_GET['pass2']));
?>
<form>
  <label>mail</label>
  <input type="email" name="mail" value="<?php 
echo $user->mail;
?>
">
  <label>name</label>
  <input type="text" name="name" value="<?php 
echo $user->name;
?>
">
  <label>pass</label>
  <input type="password" name="pass">
  <label>pass2</label>
  <input type="password" name="pass2">
  <input type="submit">
</form>
Пример #3
0
 public function action_view($task_id = null)
 {
     // if POST then get task id
     if (Fuel\Core\Input::method() == 'POST') {
         $task_id = Fuel\Core\Input::post('project_task_id');
     }
     if (!($task = Model_Projecttask::find($task_id))) {
         Fuel\Core\Session::set_flash('error', 'Cannot find task #' . $task_id);
         Fuel\Core\Response::redirect_back('admin/projects');
     }
     if (Fuel\Core\Input::method() == 'POST') {
         $val = Model_Projecttaskcomment::validate('create');
         if ($val->run()) {
             // save this comment
             $comment = Model_Projecttaskcomment::forge(array('user_id' => \Fuel\Core\Input::post('user_id'), 'project_task_id' => $task_id, 'comment' => \Fuel\Core\Input::post('comment')));
             if ($comment->save()) {
                 Fuel\Core\Session::set_flash('success', 'Saved comment # ' . $comment->id);
             } else {
                 Fuel\Core\Session::set_flash('error', 'Cannot save comment.');
             }
         } else {
             Fuel\Core\Session::set_flash('error', $val->error());
         }
     }
     $view = Fuel\Core\View::forge('user/timesheets/view');
     $view->set_global('task', $task);
     $view->set_global('user_id', Auth\Auth::get('id'));
     $view->set_global('show_comment_delete_link', false);
     $this->template->user_is_admin = $this->check_user_is_admin();
     $this->template->title = 'Timesheets';
     $this->template->content = $view;
 }