Beispiel #1
0
 public function action_repass($onepass)
 {
     if (!Model_User::count(array('where' => array('onepass' => $onepass)))) {
         Response::redirect('user/login/without');
     }
     if (Input::method() == 'POST') {
         $val = Model_User::validate('repass');
         $val->add_field('email', 'Eメール', 'required|valid_email');
         if ($val->run()) {
             $user = Model_User::find('first', array('where' => array('onepass' => $onepass)));
             $last_login = mb_substr($user['last_login'], -4);
             $reset = Input::post('reset');
             if ($last_login == $reset) {
                 $username = Input::post('username');
                 $email = Input::post('email');
                 $password = Input::post('password');
                 if ($username == $user['username'] && $email == $user['email']) {
                     $user->onepass = md5(time());
                     $user->save();
                     $auth = Auth::instance();
                     $old = $auth->reset_password($username);
                     $auth->change_password($old, $password, $username);
                     Response::redirect('user/login');
                 } else {
                     Session::set_flash('na', '<p><span class="alert-error">該当者がいません</span></p>');
                 }
             } else {
                 Session::set_flash('error', "<p>" . $val->show_errors() . "</p>");
             }
         }
         return Model_User::theme('admin/template', 'user/login/repass');
     }
 }
Beispiel #2
0
 public function action_list()
 {
     $page = $this->get_query('page', 1);
     $user_list = Model_User::find(array(), $page);
     $this->template_data['total'] = Model_User::count();
     $this->template_data['user_list'] = $user_list;
     $this->template_data['title'] = __('admin.user.list.user_list');
 }
 public function action_index()
 {
     $pagination = \Fuel\Core\Pagination::forge('users', array('pagination_url' => \Fuel\Core\Config::get('pagination.pagination_url', '') . 'admin/users/index/', 'total_items' => Model_User::count(), 'per_page' => \Fuel\Core\Config::get('pagination.per_page', 10), 'num_links' => \Fuel\Core\Config::get('pagination.num_links', 10), 'show_first' => \Fuel\Core\Config::get('pagination.show_first', false), 'show_last' => \Fuel\Core\Config::get('pagination.show_last', false), 'uri_segment' => \Fuel\Core\Config::get('pagination.uri_segment', 4)));
     $data['users'] = Model_User::find('all', array('order_by' => array('username' => 'asc'), 'limit' => $pagination->per_page, 'offset' => $pagination->offset));
     $data['pagination'] = $pagination;
     $data['groups'] = $this->get_groups_list();
     $this->template->title = "Users";
     $this->template->content = View::forge('admin/users/index', $data, false);
 }
Beispiel #4
0
 public function action_index()
 {
     $this->dataGlobal['pageTitle'] = __('backend.category.manage');
     // Pagination
     $config = array('pagination_url' => \Uri::current(), 'total_items' => \Model_User::count(), 'per_page' => floor(\Model_User::count() / 2), 'uri_segment' => 'page');
     $this->data['pagination'] = $pagination = \Pagination::forge('authors_pagination', $config);
     // Get categories
     $this->data['authors'] = \Model_User::query()->offset($pagination->offset)->limit($pagination->per_page)->order_by('created_at', 'DESC')->get();
     return \Response::forge(\View::forge('backend/author/index')->set($this->data, null, false));
 }
 public function action_index()
 {
     $config = \Fuel\Core\Config::get('pagination');
     $pagination = \Fuel\Core\Pagination::forge('admin.users', $config);
     $pagination->total_items = Model_User::count();
     $data['pagination'] = $pagination;
     $data['users'] = Model_User::find('all', array('order_by' => array(array('description', 'asc')), 'limit' => $pagination->per_page, 'offset' => $pagination->offset));
     $this->template->title = "Users";
     $this->template->content = View::forge('admin/users/index', $data);
 }
Beispiel #6
0
 /**
  * Log in the current user with the provided credentials.
  * @param string $usernameOrEmail User name or email of account
  * @param string $password
  * @param bool $cookie Use a cookie to store the login
  * @param string $use The field being used to identify the user (username, email, or either)
  * @return bool False if login failed
  */
 public function login($usernameOrEmail, $password, $cookie = false, $use = 'either')
 {
     switch ($use) {
         case 'username':
             $field = 'username';
             break;
         case 'email':
             $field = 'email';
             break;
         default:
             $field = 'username';
             if (preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i', $usernameOrEmail)) {
                 $field = 'email';
             }
             break;
     }
     $users = new Model_User();
     $users->where("{$field} = ?", $userNameOrEmail);
     if ($users->count() == 0) {
         Typeframe::Log("WARNING: {$usernameOrEmail} matches more than one {$field} in the user table.");
         //return false;
     }
     $row = $users->getFirst();
     // Did this even find a record?
     if (!$row) {
         Typeframe::Log("Login failed for {$usernameOrEmail} due to: no {$field} found");
         return false;
     }
     // Does the password not match?
     if (!self::CheckPassword($row, $password)) {
         Typeframe::Log("Login failed for {$usernameOrEmail} due to: incorrect password");
         return false;
     }
     //check to see if account is suspended.
     if ($row['confirmed'] == 0) {
         Typeframe::Log("Login failed for {$usernameOrEmail} due to: suspended account");
         return false;
     }
     // Whee, all the error checks must have passed!
     unset($row['salt']);
     unset($row['hashtype']);
     $_SESSION['typef_user'] = $row;
     if ($cookie) {
         // Store cookie
         // TODO: It might make more sense to store the user ID instead of the name.
         setcookie('typef_username', $row['username'], time() + 60 * 60 * 24 * 30, '/');
         setcookie('typef_passhash', $row['passhash'], time() + 60 * 60 * 24 * 30, '/');
     }
     Typeframe::Log("{$usernameOrEmail} logged in");
     return true;
 }
Beispiel #7
0
 public static function pagedata($lines = 10)
 {
     //配列の初期化
     $data = array();
     //データ件数の取得
     $count = Model_User::count();
     //Paginationの環境設定
     $config = array('pagination_url' => 'admin/index', 'uri_segment' => 3, 'num_links' => 2, 'per_page' => $lines, 'total_items' => $count);
     //Paginationのセット
     Pagination::set_config($config);
     $pagination = Pagination::forge('mypagination', $config);
     //ページデータの取得
     $data['users'] = Model_User::find('all', array('limit' => $pagination->per_page, 'offset' => $pagination->offset, 'order_by' => array('created_at' => 'desc')));
     return $data;
 }
Beispiel #8
0
if ('POST' == $_SERVER['REQUEST_METHOD']) {
    // save typing below
    $typef_app_dir = TYPEF_WEB_DIR . '/admin/users/groups';
    // get and validate user group id
    $usergroupid = @$_REQUEST['usergroupid'];
    $usergroup = Model_Usergroup::Get($usergroupid);
    if (!$usergroup->exists()) {
        Typeframe::Redirect('No user group provided.', $typef_app_dir, 1);
        return;
    }
    if (in_array($usergroupid, array(TYPEF_DEFAULT_USERGROUPID, TYPEF_ADMIN_USERGROUPID))) {
        Typeframe::Redirect('Unable to delete primary user groups.', $typef_app_dir, -1);
        return;
    }
    $users = new Model_User();
    $users->where('usergroupid = ?', $usergroupid);
    if ($users->count() > 0) {
        Typeframe::Redirect('Unable to delete a group containing users. Delete the users or move them to a different group first.', $typef_app_dir, -1);
        return;
    }
    // delete application associations
    /*$ugadmin = UserGroupAdmin::DAOFactory();
    	$ugadmin->select()->where('usergroupid = ?', $usergroupid);
    	foreach ($ugadmin->getAll() as $uga)
    		$uga->delete();*/
    // delete the user group
    $usergroup->delete();
    // done
    Typeframe::Redirect('User group deleted.', $typef_app_dir);
    return;
}
Beispiel #9
0
 public static function all_teachers()
 {
     $teachers = Model_User::count(array('where' => array('group' => 50)));
     return $teachers;
 }
Beispiel #10
0
 public function action_autorepass()
 {
     if (Input::method() == 'POST') {
         $username = Input::post('username');
         $email = Input::post('email');
         $user_count = Model_User::count(array('where' => array(array('username' => $username), array('email', $email))));
         if ($user_count > 0) {
             $auth = Auth::instance();
             $repass = $auth->reset_password($username);
             $data['repass'] = $repass;
             $data['username'] = $username;
             $data['email'] = $email;
             $data['anchor'] = 'user/login/';
             $body = View::forge('user/email/autorepass', $data);
             $sendmail = Email::forge();
             $sendmail->from('*****@*****.**', 'ameken.com');
             $sendmail->to($email, $username);
             $sendmail->subject('パスワードの再発行');
             $sendmail->html_body($body);
             //メールの送信
             $sendmail->send();
             return Model_User::theme('admin/template', 'user/repass-info');
         } else {
             Session::set_flash('error', '該当者がいません。');
         }
     }
     return Model_User::theme('admin/template', 'user/autorepass');
 }