コード例 #1
0
ファイル: DetailsController.php プロジェクト: quenti77/easyhq
 private function getBooks($project_id, $page = 1)
 {
     if (!Session::exists('member')) {
         Router::redirect('home.index');
     }
     $nb = self::NUMBER_ITEM_PER_PAGE;
     $member = Session::get('member');
     $user = $this->checkUser($member['id'], $member['nickname']);
     $search = Helper::post('research');
     $project = Projects::select()->where('id', $project_id)->andWhere('id_leader', $member['id'])->get(0, 1);
     if (empty($project)) {
         Router::url('home.index');
     }
     $project = $project[0];
     $book = UsersBook::select()->addFields(['users_book.status' => 'status', 'F.id' => 'id_from', 'F.nickname' => 'nickname_from', 'T.id' => 'id_to', 'T.nickname' => 'nickname_to'])->innerJoin('users', 'F')->onJoin('F.id', '=', 'users_book.id_user_from')->innerJoin('users', 'T')->onJoin('T.id', '=', 'users_book.id_user_to')->where('status', 2)->andGroup([new Condition('WHERE', '', 'users_book.id_user_from', '!=', $project->id_client, false), new Condition('WHERE', 'AND', 'users_book.id_user_to', '!=', $project->id_client, false)])->andGroup([new Condition('WHERE', '', 'F.nickname', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'F.mail', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'T.nickname', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'T.mail', 'LIKE', '%' . $search . '%', false)])->andGroup([new Condition('WHERE', '', 'id_user_from', '=', $member['id'], false), new Condition('WHERE', 'OR', 'id_user_to', '=', $member['id'], false)])->get(($page - 1) * $nb, $nb);
     $count = UsersBook::select()->addFields(['COUNT(*)' => 'nb_row'])->innerJoin('users', 'F')->onJoin('F.id', '=', 'users_book.id_user_from')->innerJoin('users', 'T')->onJoin('T.id', '=', 'users_book.id_user_to')->where('status', 2)->andGroup([new Condition('WHERE', '', 'F.nickname', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'F.mail', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'T.nickname', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'T.mail', 'LIKE', '%' . $search . '%', false)])->andGroup([new Condition('WHERE', '', 'id_user_from', '=', $member['id'], false), new Condition('WHERE', 'OR', 'id_user_to', '=', $member['id'], false)])->get(0, 1)[0];
     $max_page = ceil($count->nb_row / $nb);
     if ($max_page == 0) {
         $max_page = 1;
     }
     $this->set('books', $book);
     $this->set('max_page', $max_page);
     $this->set('project', $project);
     $this->set('user', $user);
     $this->render('task/detail_user');
 }
コード例 #2
0
ファイル: HomeController.php プロジェクト: quenti77/easyhq
 public function index()
 {
     if (Session::exists('member')) {
         $member = Session::get('member');
         $projects = Projects::select('P')->addFields(['TIMESTAMPDIFF(DAY, NOW(), P.deadline)' => 'nb_day', 'P.id' => 'project_id', 'P.name', 'P.price', 'P.deadline', 'U.id' => 'id_user_leader', 'U.nickname' => 'nickname_user_leader', 'UC.id' => 'id_user_client', 'UC.nickname' => 'nickname_user_client'])->innerJoin('users', 'U')->onJoin('U.id', 'P.id_leader')->leftJoin('tasks', 'T')->onJoin('T.id_project', 'P.id')->leftJoin('task_users', 'task_users')->onJoin('task_users.id_task', 'T.id')->leftJoin('users', 'UC')->onJoin('UC.id', 'P.id_client')->where('id_client', $member['id'])->orWhere('id_leader', $member['id'])->orWhere('task_users.id_user', $member['id'])->groupBy('project_id')->get();
         $this->set('projects', $projects);
     }
     $this->script('projects');
     $this->render('task/home', 'home.task.title');
 }
コード例 #3
0
ファイル: Users.php プロジェクト: quenti77/easyhq
 public static function canUpdate($user)
 {
     $can_update = false;
     if (Session::exists('member')) {
         $member = Session::get('member');
         if ($member['nickname'] == $user->nickname && $member['id'] == $user->id && $member['user_key'] == $user->user_key) {
             $can_update = true;
         }
     }
     return $can_update;
 }
コード例 #4
0
ファイル: UserController.php プロジェクト: quenti77/easyhq
 public function update($id)
 {
     $this->checker('update_full_admin');
     if (Session::get('csrf') != Helper::post('_csrf')) {
         Router::redirect('home.index');
     }
     $user = Users::select()->where('id', $id)->get();
     if (empty($user)) {
         Router::redirect('home.index');
     }
     $modified = false;
     $user = $user[0];
     $nickname = Helper::post('nickname');
     if (!empty($nickname) && $nickname != $user->nickname) {
         $user->nickname = $nickname;
         $modified = true;
     }
     $firstname = Helper::post('firstname');
     if ($firstname != $user->firstname) {
         $user->firstname = $firstname;
         $modified = true;
     }
     $lastname = Helper::post('lastname');
     if ($lastname != $user->lastname) {
         $user->lastname = $lastname;
         $modified = true;
     }
     $id_group = Helper::post('group');
     if ($id_group != $user->id_group) {
         $user->id_group = $id_group;
         $modified = true;
     }
     $mail = Helper::post('mail');
     if (!empty($mail) && $mail != $user->mail) {
         $user->mail = $mail;
         $user->mail_check = sha1($user->user_key . '-----' . time());
         $user->mail_check_at = BaseModel::now();
         Users::sendMailCheck($user);
         $modified = true;
     }
     $result = Helper::post('deleteAvatar') != null;
     if ($result) {
         $user->avatar = '';
         $modified = true;
     }
     if ($modified) {
         $user->save();
     }
     Router::redirect('admin:user.show');
 }
コード例 #5
0
ファイル: Groups.php プロジェクト: quenti77/easyhq
 public static function check($type, $auths)
 {
     $id_group = 0;
     if (Session::exists('member')) {
         $member = Session::get('member');
         $id_group = $member['id_group'];
     }
     $auth = self::$authorization[$type]['nothing_right'];
     if ($id_group != 0) {
         $group = Groups::select()->where('id', $id_group)->get();
         if (!empty($group)) {
             $field = "auth_" . $type;
             $auth = $group[0]->{$field};
         }
     }
     $br = new BinaryRight($auth);
     return $br->compare($auths);
 }
コード例 #6
0
ファイル: BaseController.php プロジェクト: quenti77/easyhq
 public function render($page, $title = null)
 {
     $this->set('scripts', $this->scriptsJS);
     $lang = [];
     foreach (Translate::getAllLangs() as $k => $v) {
         $lang[] = ['short' => $k, 'long' => $v, 'desc' => Translate::get('lang.' . $v)];
     }
     $go = isset($_GET['url']) ? $_GET['url'] : '';
     $select = 'lang.' . Translate::get('lang');
     $this->set('MAIN_visited_url', "/{$go}");
     $this->set('MAIN_languages', $lang);
     $this->set('MAIN_select_languages', Translate::get($select));
     $this->set('MAIN_members', Session::get('member'));
     if ($title) {
         $this->set('title', Translate::get($title));
     }
     $blade = new BladeInstance(__DIR__ . '/../../public/views', __DIR__ . '/../../cache/views');
     echo $blade->render($page, $this->vars);
 }
コード例 #7
0
ファイル: AccountController.php プロジェクト: quenti77/easyhq
 public function verify($key)
 {
     //Users::redirectIf(true);
     $users = Users::select()->where('mail_check', $key)->andWhere('TIMESTAMPDIFF(MINUTE, mail_check_at, NOW())', '<', 30, false)->get();
     if (!empty($users)) {
         $user = $users[0];
         $user->mail_check = '1';
         $user->save();
     }
     $users = Users::select()->where('mail_check', '!=', '1')->andWhere('TIMESTAMPDIFF(MINUTE, mail_check_at, NOW())', '>', 35, false)->get();
     foreach ($users as $user) {
         $user->delete();
     }
     Session::setFlash('success', '', Translate::get('user.success.register_mail'));
     Router::redirect('home.index');
 }
コード例 #8
0
ファイル: UserController.php プロジェクト: quenti77/easyhq
 public function newPassword()
 {
     Users::redirectIf(true);
     try {
         $user = Users::findOrFail('mail', Helper::post('mail'));
         $pass = Config::randomString(8);
         $user->password = password_hash($pass, PASSWORD_BCRYPT);
         $user->save();
         Users::resendPassword($user, $pass);
     } catch (\Exception $e) {
         Session::setFlash('danger', '', 'Aucun compte trouvée avec cette adresse email !');
     }
     Router::redirect('user.signin');
 }
コード例 #9
0
ファイル: GroupController.php プロジェクト: quenti77/easyhq
 public function delete($id, $csrf)
 {
     $this->checker('update_full_admin');
     if (Session::get('csrf') != $csrf) {
         Router::redirect('home.index');
     }
     $group = Groups::select()->where('id', $id)->get();
     if (empty($group)) {
         Router::redirect('home.index');
     }
     $countGroup = Groups::select()->addFields(['COUNT(*)' => 'nb'])->get();
     $countGroup = intval($countGroup[0]->nb);
     if ($countGroup > 1) {
         $group = $group[0];
         $group->delete();
         $firstGroup = Groups::select()->addFields('id')->get(0, 1);
         $firstGroup = $firstGroup[0];
         $users = Users::select()->where('id_group', $id)->get();
         if (!empty($users)) {
             foreach ($users as $user) {
                 $user->id_group = $firstGroup->id;
                 $user->save();
             }
         }
     } else {
         Session::setFlash('danger', '', 'Il ne reste que 1 seul groupe donc on ne peut pas le supprimer');
     }
     Router::redirect('admin:group.show');
 }
コード例 #10
0
ファイル: BookController.php プロジェクト: quenti77/easyhq
 private function getForContact($page = 1)
 {
     if (!Session::exists('member')) {
         Router::redirect('home.index');
     }
     $nb = self::NUMBER_ITEM_PER_PAGE;
     $member = Session::get('member');
     $member = $this->checkUser($member['id'], $member['nickname']);
     $search = Helper::post('research');
     $all_contact = UsersBook::select()->where('id_user_from', $member->id)->orWhere('id_user_to', $member->id)->get();
     $list = [$member->id];
     foreach ($all_contact as $contact) {
         if ($contact->id_user_from == $member->id) {
             $list[] = $contact->id_user_to;
         } else {
             $list[] = $contact->id_user_from;
         }
     }
     $users = Users::select()->addFields(['users.id' => 'user_id', 'users.nickname' => 'user_nickname', 'users.mail' => 'user_mail'])->where('users.mail_check', '1')->andWhere('users.id', 'NOT IN', $list)->andGroup([new Condition('WHERE', '', 'users.nickname', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'users.mail', 'LIKE', '%' . $search . '%', false)])->get(($page - 1) * $nb, $nb);
     $count = Users::select()->addFields(['COUNT(*)' => 'nb_user'])->where('users.mail_check', '1')->andWhere('users.id', 'NOT IN', $list)->andGroup([new Condition('WHERE', '', 'users.nickname', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'users.mail', 'LIKE', '%' . $search . '%', false)])->get(0, 1);
     $max_page = 0;
     if (!empty($count)) {
         $count = $count[0];
         $max_page = ceil($count->nb_user / $nb);
     }
     if ($max_page == 0) {
         $max_page = 1;
     }
     $this->set('max_page', $max_page);
     $this->set('users', $users);
     $this->set('member', $member);
     $this->render('user/search');
 }
コード例 #11
0
ファイル: ProjectController.php プロジェクト: quenti77/easyhq
 private function ajaxSub($id = 0)
 {
     Users::redirectIf(false);
     $member = Session::get('member');
     $project = Projects::findOrCreate('id', $id);
     if ($project->id == 0) {
         $dl = new \DateTime();
         $deadline = $dl->format('d/m/Y H:i');
         $url = Router::url('task:project.insert');
     } else {
         if ($project->id_leader != $member['id']) {
             return;
         }
         $dl = new \DateTime($project->deadline);
         $deadline = $dl->format('d/m/Y H:i');
         $url = Router::url('task:project.update', ['id' => $id]);
     }
     $this->set(['url' => $url, 'deadline' => explode(' ', $deadline), 'project' => $project]);
     $this->render('task/project_spec');
 }