Ejemplo n.º 1
0
 public function createTeamAction()
 {
     $array_id = array();
     $coach = array('login' => $_POST['coach']);
     $coach = Model\User::find($coach);
     $chef = array('login' => $_POST['chef']);
     $chef = Model\User::find($chef);
     $array_id[] = $chef->getId();
     $student1 = array('login' => $_POST['student1']);
     $student1 = Model\User::find($student1);
     $array_id[] = $student1->getId();
     if ($_POST['student2']) {
         $student2 = array('login' => $_POST['student2']);
         $student2 = Model\User::find($student2);
         $array_id[] = $student2->getId();
     }
     if ($_POST['student3']) {
         $student3 = array('login' => $_POST['student3']);
         $student3 = Model\User::find($student3);
         $array_id[] = $student3->getId();
     }
     //On récupère le dernière ID group utilisé
     $id_group = $this->getLastId();
     //On relie les étudiants pour former le groupes
     $this->insertNewGroup($coach, $array_id, $id_group);
     $this->updateGroupId($id_group, $array_id);
     $this->createProject($id_group, $coach->getId(), $_POST['nomprojet']);
     $this->redirect('equipe');
 }
 public function indexAction()
 {
     //	init
     $this->init();
     //  get users
     $this->view->userArray = \Model\User::find();
     //	set main view
     $this->view->setMainView('block-module-users/admin-index');
 }
Ejemplo n.º 3
0
 protected function validate()
 {
     $this->fields[] = 'user_id';
     // hack
     $vals = array('mail' => $this->values['mail'], 'password' => $this->values['password']);
     if ($user = Model\User::find($vals)) {
         return $this->values['user_id'] = $user->getPk();
     } else {
         $this->errors['email'][] = 'Mauvais nom de compte / mot de passe';
     }
 }
Ejemplo n.º 4
0
function findSavingsAccountObs($userId)
{
    return Observable::just($userId)->skipWhile(function ($input) {
        return empty($input);
    })->map(function ($userId) {
        return User::find($userId);
    })->flatMap(function (User $user) {
        return Observable::fromArray(Account::query('user_id', $user->getId()));
    })->takeWhile(function (Account $account) {
        return $account->getType() === 'SAVINGS';
    });
}
Ejemplo n.º 5
0
 public function homeAction()
 {
     $meeting = array();
     $vals = array('id' => $_SESSION['user_id']);
     $user = Model\User::find($vals);
     $vals = array('id_group' => $_GET['projet']);
     $projet = Model\Projet::find($vals);
     $id_group = $projet['id_group'];
     $sql = "SELECT * FROM meeting WHERE id_group = {$id_group} ORDER BY updated_at";
     $meeting = $this->db->query($sql);
     $meeting = $meeting->fetchAll();
     return array('user' => $user, 'projet' => $projet, 'meeting' => $meeting);
 }
Ejemplo n.º 6
0
 public function init($uid)
 {
     $user = Model\User::find($uid);
     if ($user) {
         $this->uid = $uid;
         $this->nama = $user->nama;
         $this->role = $user->role;
         $grup = Model\Grup::where('nama', $user->role)->first();
         if ($grup) {
             $this->hakAkses = json_decode($grup->hak_akses, true);
         }
     }
 }
Ejemplo n.º 7
0
 public static function helloMathis($app)
 {
     $ajout = false;
     $username = '******';
     $user = User::find($username);
     // Si $user n'est pas set, c'est qu'il n'y a rien et on ajoute donc en base !
     if (!isset($user)) {
         $user = new User();
         $user->name = $username;
         $user->save();
         $ajout = true;
     }
     $app->render('user.html.twig', array('ajout' => $ajout, 'autre' => 'ahah !', 'name' => $user->name));
 }
Ejemplo n.º 8
0
 function login()
 {
     $app = get_app();
     $is_debug = get_config('debug');
     //GET
     if ($app->request()->isGet()) {
         if (!$is_debug) {
             $app->render('login.php');
         } else {
             $app->render('debug.php');
         }
     }
     //POST
     if ($app->request()->isPost()) {
         /* if (empty($_SESSION['captcha']) || trim(strtolower($_REQUEST['captcha'])) != $_SESSION['captcha']) {
         		 	$app->flashNow('errors',array('验证码错误!'));
         		 	$app->render('login.php');
         		 }
         		 else{ */
         $account = $app->request()->post('account');
         $password = $app->request()->post('password');
         $user = User::find('first', array('conditions' => array(' account = ? AND password = ?', $account, md5($password))));
         if (!empty($user)) {
             $_SESSION['is_logged'] = true;
             $_SESSION['account'] = $user->account;
             $_SESSION['username'] = $user->username;
             $_SESSION['user_id'] = $user->id;
             $_SESSION['role_id'] = $user->role_id;
             $_SESSION['group_id'] = $user->group_id;
             $_SESSION['team_id'] = $user->team_id;
             redirect('/');
         } else {
             $app->flashNow('errors', array('错误的用户名或密码!'));
             $app->render('login.php');
         }
         /* } */
     }
 }
Ejemplo n.º 9
0
 public function scopeOnlyAllowEditor($query, $user_id = 0)
 {
     $user = $user_id ? Model\User::find($user_id) : sentinel()->getUser();
     return $query->whereHas('categories', function ($query) use($user) {
         return $query->whereIn($query->getModel()->getTable() . '.id', $user->editorcategory->pluck('id')->toArray());
     });
 }
Ejemplo n.º 10
0
 function index()
 {
     $app = get_app();
     $users = User::find('all', array('order' => 'id desc'));
     render_with_layout('misc.php', 'Users/index.php', compact('users'));
 }
Ejemplo n.º 11
0
 public function scopeOnlyAllowEditor($query, $user_id = 0)
 {
     $user = $user_id ? Model\User::find($user_id) : sentinel()->getUser();
     return $query->whereIn('id', $user->editorcategory->pluck('id')->toArray());
 }
Ejemplo n.º 12
0
 public static function getLoginContext()
 {
     $config = array('token' => '_user_', 'path' => '/', 'sign_salt' => function ($context) {
         do {
             if (!isset($context['id']) || !$context['id']) {
                 break;
             }
             if (!($user = \Model\User::find($context['id']))) {
                 break;
             }
             // 以用户密码作为salt
             return $user->passwd;
         } while (false);
         // 如果用户不存在,就用固定的随机字符串
         return 'fdq0rj32jr0dsjfwf';
     });
     $handler = new \Lysine\CookieContextHandler($config);
     $expire = (int) $handler->get('expire');
     if ($expire && $expire < time()) {
         $handler->clear();
     }
     return $handler;
 }
Ejemplo n.º 13
0
 public function homeAction()
 {
     $vals = array('id' => $_SESSION['user_id']);
     $user = Model\User::find($vals);
     return array('user' => $user);
 }
Ejemplo n.º 14
0
    echo 'Completed', PHP_EOL;
}));
println('Example 3 - Just and Map');
\Rx\Observable::just(\Model\User::all())->map(function ($results) {
    return count($results);
})->subscribe($stdoutObserver());
println('Example 4 - Get all accounts of type SAVING');
\Rx\Observable::fromArray(\Model\Account::all())->filter(function (Account $account) {
    return $account->getType() === 'SAVINGS';
})->map(function (Account $savingsAccount) {
    return $savingsAccount->getBalance();
})->subscribe($stdoutObserver());
println('Withdraw 1000 from Luis SAVINGS account');
$id = 1;
Observable::just($id)->map(function ($userId) {
    return User::find($userId);
})->doOnNext(function (User $user) {
    printf("Found user: %s \n", $user->getEmail());
})->flatMap(function (User $user) {
    return Observable::fromArray(Account::query('user_id', $user->getId()));
})->takeWhile(function (Account $account) {
    return $account->getType() === 'SAVINGS';
})->doOnNext(function (Account $account) {
    printf("Found savings account. Current balance: %d \n", $account->getBalance());
})->map(function (Account $account) {
    return $account->withdraw(1000)->save();
})->subscribe(new Observer\CallbackObserver(function ($account) {
    printf("New account balance: %d \n", $account->getBalance());
}, function (Exception $ex) {
    print 'Error: ' . $ex->getMessage();
}, function () {