public function action_profile()
 {
     $data = null;
     $data['user'] = Model_User::query()->related('user_providers')->where('id', static::$user_id)->get_one();
     $data['api_key'] = Auth::get('api_key');
     if (Input::Method() == 'POST') {
         $new_password = Input::Post('new_password');
         $current_password = Input::Post('current_password');
         if (empty($new_password) === false) {
             if (empty($current_password) === true) {
                 Session::set('error', 'You must enter your old password in first!');
                 $this->template->content = View::Forge('settings/profile', $data);
                 return;
             } else {
                 if (Auth::change_password($current_password, $new_password) === false) {
                     Session::set('error', 'Wrong Password');
                     $this->template->content = View::Forge('settings/profile', $data);
                     return;
                 } else {
                     Session::delete('current_password');
                 }
             }
         }
         // update the data for the current user
         try {
             Auth::update_user(array('email' => Input::Post('email'), 'fullname' => Input::Post('full_name')));
         } catch (Exception $e) {
             Session::set('error', $e->getMessage());
             $this->template->content = View::Forge('settings/profile', $data);
             return;
         }
         Session::set('success', 'Your profile has been updated');
     }
     $this->template->content = View::Forge('settings/profile', $data);
 }
Пример #2
0
	private function save()
	{
		$bind=array();
		$input=Input::Post();
		
		if ($this->controller->method=='POST')
		{
			if (!$input->has($this->model->primary_key))
				return;
				
			$this->model->{$this->model->primary_key}=$input->{$this->model->primary_key};
			$this->model->reload();
		}

		foreach($this->fields as $f)
			$bind[$f['id']]=$f['id'];
			
		$this->model->bind_input($input,$bind);
		
		$errors=$this->model->save();
		
		if (is_array($errors))
			$this->errors=$errors;
		else if($this->redirect)
			redirect(sprintf($this->redirect,$this->model->id));
	}
 public function action_index()
 {
     $data['settings'] = Settings::get_all();
     if (\Input::method() == 'POST') {
         Controller_Settings::update(Input::Post());
         $data['settings'] = Settings::get_all(true);
     }
     $data['blocked'] = $blacklist_item = Model_Blacklist::query()->get();
     $keys = \Settings::Get('character_set');
     if (empty($keys) === true) {
         $keys = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
     }
     $random_length = \Settings::Get('random_url_length');
     if (empty($random_length) === true) {
         $random_length = 5;
     }
     $url_sample_space = DB::select(DB::expr('count(id) as count'))->from('urls')->where(DB::expr('char_length(short_url)'), $random_length)->limit(1)->execute()->as_array();
     $data['urls_left'] = Controller_Admin::mathFact(strlen($keys)) / (Controller_Admin::mathFact(strlen($keys) - $random_length) * Controller_Admin::mathFact($random_length)) - $url_sample_space[0]['count'];
     $this->template->content = View::Forge('admin/index', $data);
 }
Пример #4
0
 public function action_index()
 {
     //システム設定レコードがなければ作成する。
     $sysRecords = Model_System::find('all');
     $found = false;
     foreach ($sysRecords as $sys) {
         if ($sys != null) {
             $found = true;
             break;
         }
     }
     if ($found == false) {
         $sys = Model_System::forge();
         $sys->mailAtLogin = 0;
         $sys->systemAd1 = '';
         $sys->systemAd2 = '';
         $sys->systemAd3 = '';
         $sys->systemAdMobile1 = '';
         $sys->systemAdMobile2 = '';
         $sys->systemAdMobile2 = '';
         $sys->save();
     }
     $sys = Model_System::getSystemRecord();
     $msg = '';
     if (Input::Post() != null) {
         $msg = "システム設定を保存しました。";
         $sys->mailAtLogin = Input::post('mailAtLogin');
         $sys->headTag = Input::post('headTag');
         $sys->systemAd1 = Input::post('systemAd1');
         $sys->systemAd2 = Input::post('systemAd2');
         $sys->systemAd3 = Input::post('systemAd3');
         $sys->systemAdMobile1 = Input::post('systemAdMobile1');
         $sys->systemAdMobile2 = Input::post('systemAdMobile2');
         $sys->systemAdMobile3 = Input::post('systemAdMobile3');
         $sys->save();
     }
     $content = View::forge('admin/index');
     $this->template->boardDescription = 'メインメニュー';
     $this->template->msg = $msg;
     $this->template->content = $content;
 }
Пример #5
0
 public function action_create()
 {
     $auth = Auth::instance();
     $groupList = Config::get("cmsauth.group_list");
     $data['grouplist'] = $groupList;
     if (Input::method() == 'POST') {
         $val = Model_User::validate('create');
         if ($val->run()) {
             $ignore = array('button', 'submit', 'password', 'confirm_password', 'email', 'group');
             foreach (Input::Post() as $feild => $value) {
                 if (!in_array($feild, $ignore)) {
                     $fields[$feild] = $value;
                 }
             }
             $username = Input::post('first_name') . " " . Input::post('last_name');
             $password = Input::post('password');
             $email = Input::post('email');
             $group = Input::post('group');
             $post_data = Input::post();
             try {
                 $auth = Auth::instance();
                 $user = $auth->create_user($username, $password, $email, $group, $fields, $post_data);
                 Response::redirect("admin");
             } catch (Exception $e) {
                 $error = $e->getMessage();
                 var_dump($error);
                 die;
             }
         } else {
             $data['status'] = "fail";
             $data['msg'] = $val->show_errors();
         }
     }
     $this->template->title = "Create Users";
     $this->template->content = View::forge('admin/users/create', $data, false);
 }
 public function action_signup()
 {
     // already logged in?
     if (\Auth::check()) {
         // yes, so go back to the page the user came from, or the
         // application home if no previous page can be detected
         \Response::redirect_back('home');
     }
     // was the login form posted?
     if (\Input::method() == 'POST') {
         // Default Group
         // 3 Users
         // Moderators
         // 5 Admins
         // call Auth to create this user
         $created = \Auth::create_user(Input::Post('username'), Input::Post('password'), Input::Post('email'), \Config::get('application.user.default_group', 3), array('fullname' => Input::Post('name')));
         // if a user was created succesfully
         if ($created) {
             \Auth::instance()->login(\Input::param('email'), \Input::param('password'));
             // and go back to the previous page, or show the
             // application home if we don't have any
             \Response::redirect_back('home');
         } else {
             // oops, creating a new user failed?
         }
     }
     $this->template->content = View::forge('login/signup');
 }
Пример #7
0
	/**
	 * Constructor
	 * 
	 * @param string $root The root uri path
	 * @param array $segments The uri segments following the root path
	 */
 	public function __construct($root,$segments)
 	{
 		$this->session=Session::Get();
 		
 		$this->uri=new URI($root,$segments);
 		$this->query=new Query();
 		
 		// assign the get and post vars
 		$this->post=Input::Post();
 		$this->get=Input::Get();
 		$this->files=Input::Files();
 		
 		$this->setup();
 	}
Пример #8
0
                                    <?php 
echo Form::Input('Dkana', Input::Post('Dkana'), array('class' => 'form-control'));
?>
                                </div>
                                <div class="col-md-2"></div>
                            </div>

                            <div><br><br><br></div>

                            <!--入力-->
                            <div class="form-group">
                                <div class="col-md-2 col-xs-12"></div>
                                <label class="col-md-1 control-label">Department (略称):</label>
                                <div class="col-md-7 col-xs-12">
                                    <?php 
echo Form::Input('Did', Input::Post('Did'), array('class' => 'form-control'));
?>
                                </div>
                                <div class="col-md-2"></div>
                            </div>

                            <div><br><br><br></div>

                            <!-- select -->
                            <div class="form-group">
                                <div class="col-md-2 col-xs-12"></div>
                                <label class="col-md-1 control-label">College:</label>
                                <div class="col-md-7 col-xs-12">
                                    <?php 
echo Form::select('college', null, $select, array('class' => 'form-control'));
?>
Пример #9
0
 public function action_Delete()
 {
     //チェックされたユーザの取得
     $check = Input::Post('check');
     //チェックされたユーザーがいない場合
     if ($check == '') {
         //何もしないで元に戻る
     } else {
         //いた場合
         //チェックされた項目の数だけ回る
         foreach ($check as $ck) {
             //カラム
             $query = DB::update('users')->set(array('df' => '1'))->where('id', '=', $ck)->execute();
         }
     }
     return View::forge('usermanagement/UserManagement', $this->action_UserAcquisition());
 }
Пример #10
0
 public function set_user()
 {
     $user = NULL;
     if (Session::get('loginAs')) {
         $this->current_user = Model_User::find(Session::get('loginAs'));
         View::set_global('current_user', $this->current_user);
     } else {
         if (Input::method() == 'POST') {
             $id = Arr::get(Auth::get_user_id(), 1);
             $post = Input::Post();
             $notMe = isset($post['notMe']) ? $post['notMe'] : NULL;
             $group = isset($user->group) ? $user->group : null;
             if ($id) {
                 $user = Model_User::find($id);
             }
             if ($this->not_me_check($notMe, $group)) {
                 $user = Model_User::find((int) $post['editAs']);
             }
         }
         $id = Arr::get(Auth::get_user_id(), 1);
         if ($id) {
             $user = Model_User::find($id);
         }
         $this->current_user = Auth::check() ? $user : null;
         View::set_global('current_user', $this->current_user);
     }
 }