/** * Upload action * @access public * @return Response */ public function action_upload() { $files = array(); if (\Input::method() == 'POST') { \Util_security::check_csrf(); $file_tmps = array(); $moved_files = array(); try { //if (!$val->run()) throw new \FuelException($val->show_errors()); $file_tmps = \Site_FileTmp::get_file_tmps_uploaded($this->u->id, true); //\Site_FileTmp::check_uploaded_under_accepted_filesize($file_tmps, $this->u->filesize_total, \Site_Upload::get_accepted_filesize()); \DB::start_transaction(); list($moved_files, $site_image_ids) = \Site_FileTmp::save_images($file_tmps, $this->u->id, 'admin_user_id', 'site_image'); \DB::commit_transaction(); // thumbnail 作成 & tmp_file thumbnail 削除 \Site_FileTmp::make_and_remove_thumbnails($moved_files); $message = sprintf('%sをアップロードしました。', term('site.image')); \Session::set_flash('message', $message); \Response::redirect('admin/content/image'); } catch (\FuelException $e) { if (\DB::in_transaction()) { \DB::rollback_transaction(); } if ($moved_files) { \Site_FileTmp::move_files_to_tmp_dir($moved_files); } $files = \Site_FileTmp::get_file_objects($file_tmps, $this->u->id); \Session::set_flash('error', $e->getMessage()); } } $this->template->post_header = \View::forge('filetmp/_parts/upload_header'); $this->template->post_footer = \View::forge('_parts/form/upload_footer'); $this->set_title_and_breadcrumbs(term('site.image', 'form.upload'), array('admin/content' => term('site.content', 'site.management'), 'admin/content/image' => term('site.image', 'site.management'))); $this->template->content = \View::forge('_parts/form/upload', array('files' => $files)); }
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'); } }
public function action_edit($id = null) { $pay = Model_Part::find($id); $val = Model_Part::validate('edit'); if ($val->run()) { $pay->status = Input::post('status'); $pay->price = Input::post('price'); $pay->ship_number = Input::post('ship_number'); $pay->box_number = Input::post('box_number'); $pay->tracking = Input::post('tracking'); $pay->memo = Input::post('memo'); if ($pay->save()) { Session::set_flash('success', e('Updated pay #' . $id)); Response::redirect('admin/pay'); } else { Session::set_flash('error', e('Could not update pay #' . $id)); } } else { if (Input::method() == 'POST') { $pay->status = $val->validated('status'); $pay->price = $val->validated('price'); $pay->ship_number = $val->validated('ship_number'); $pay->box_number = $val->validated('box_number'); $pay->tracking = $val->validated('tracking'); $pay->memo = $val->validated('memo'); Session::set_flash('error', $val->error()); } $this->template->set_global('pay', $pay, false); } $this->template->title = "pays"; $this->template->content = View::forge('admin/pay/edit'); }
/** * Редактирование записи * * @param int $id */ public function action_edit($id = null) { is_null($id) and \Response::redirect_back('admin/videos'); if (!($video = \Model_Video::find($id))) { \Session::set_flash('error', 'Невозможно найти видео #' . $id); \Response::redirect_back('admin/videos'); } $val = \Model_Video::validate('edit'); if ($val->run()) { $video->videoid = \Input::post('videoid'); if ($video->save()) { \Session::set_flash('success', 'Видео обновлено.'); \Response::redirect_back('admin/videos'); } else { \Session::set_flash('error', 'Could not update video #' . $id); } } else { if (\Input::method() == 'POST') { $video->videoid = $val->validated('videoid'); \Session::set_flash('error', $val->error()); } $this->template->set_global('video', $video, false); } $this->template->content = \View::forge('videos/edit'); }
public function action_edit($id = null) { $setting = Model_Setting::find($id); $val = Model_Setting::validate('edit'); if ($val->run()) { $setting->setting_key = Input::post('setting_key'); $setting->setting_title = Input::post('setting_title'); $setting->setting_value = Input::post('setting_value'); $setting->setting_data_type_id = Input::post('setting_data_type_id'); if ($setting->save()) { Session::set_flash('success', e('Updated setting #' . $id)); Response::redirect('admin/settings/view/' . $setting->id); } else { Session::set_flash('error', e('Could not update setting #' . $id)); } } else { if (Input::method() == 'POST') { $setting->setting_key = $val->validated('setting_key'); $setting->setting_title = $val->validated('setting_title'); $setting->setting_value = $val->validated('setting_value'); $setting->setting_data_type_id = $val->validated('setting_data_type_id'); Session::set_flash('error', $val->error()); } $this->template->set_global('setting', $setting, false); } $this->template->set_global('data_types', Model_Setting_Data_Type::find('all', array('order_by' => array(array('name', 'asc'))))); $this->template->title = "Settings"; $this->template->content = View::forge('admin/settings/edit'); }
public function action_edit($id = null) { is_null($id) and Response::redirect('Survey'); if (!($survey = Model_Survey::find($id))) { Session::set_flash('error', 'Could not find survey #' . $id); Response::redirect('Survey'); } $val = Model_Survey::validate('edit'); if ($val->run()) { $survey->title = Input::post('title'); $survey->description = Input::post('description'); $survey->type = Input::post('type'); if ($survey->save()) { Session::set_flash('success', 'Updated survey #' . $id); Response::redirect('survey'); } else { Session::set_flash('error', 'Could not update survey #' . $id); } } else { if (Input::method() == 'POST') { $survey->title = $val->validated('title'); $survey->description = $val->validated('description'); $survey->type = $val->validated('type'); Session::set_flash('error', $val->error()); } $this->template->set_global('survey', $survey, false); } $this->template->title = "Surveys"; $this->template->content = View::forge('survey/edit'); }
public function action_edit($id = null) { parent::has_access("add_leave"); is_null($id) and Response::redirect('leaves'); if (!($leave = Model_Leave::find($id))) { Session::set_flash('error', 'Could not find leave #' . $id); Response::redirect('leaves'); } $val = Model_Leave::validate('edit'); if ($val->run()) { $var_dol_day = Input::post('dol_day'); $var_dol_month = Input::post('dol_month'); $var_dol_year = Input::post('dol_year'); $var_dol = $var_dol_year . '-' . $var_dol_month . '-' . $var_dol_day; $leave->date_of_leave = $var_dol; $leave->time = Input::post('time'); $leave->type = Input::post('type'); if ($leave->save()) { Session::set_flash('success', 'Updated leave #' . $id); Response::redirect('leaves/view/' . $leave->employee_id); } else { Session::set_flash('error', 'Could not update leave #' . $id); } } else { if (Input::method() == 'POST') { $leave->date_of_leave = $val->validated('date_of_leave'); $leave->time = $val->validated('time'); $leave->type = $val->validated('type'); Session::set_flash('error', $val->error()); } $this->template->set_global('leave', $leave, false); } $this->template->title = "Leaves"; $this->template->content = View::forge('leaves/edit'); }
public function action_edit($id = null) { if (Auth::has_access('country.edit') == false) { Session::set_flash("error", "Only admins may edit countries!"); Response::redirect("country/") and die; } is_null($id) and Response::redirect('Country'); $country = Model_Country::find($id); $val = Model_Country::validate('edit'); if ($val->run()) { $country->name = Input::post('name'); $country->iso_code = Input::post('iso_code'); if ($country->save()) { Session::set_flash('success', 'Updated country #' . $id); Response::redirect('country'); } else { Session::set_flash('error', 'Could not update country #' . $id); } } else { if (Input::method() == 'POST') { $country->name = $val->validated('name'); $country->iso_code = $val->validated('iso_code'); Session::set_flash('error', $val->error()); } $this->template->set_global('country', $country, false); } $this->template->title = "Countries"; $this->template->content = View::forge('country/edit'); }
public function action_edit($id = null) { is_null($id) and Response::redirect('Proxies'); $proxy = Model_Proxy::find($id); $val = Model_Proxy::validate('edit'); if ($val->run()) { $proxy->host = Input::post('host'); $proxy->port = Input::post('port'); $proxy->fail_count = Input::post('fail_count'); if ($proxy->save()) { Session::set_flash('success', 'Updated proxy #' . $id); Response::redirect('proxies'); } else { Session::set_flash('error', 'Could not update proxy #' . $id); } } else { if (Input::method() == 'POST') { $proxy->host = $val->validated('host'); $proxy->port = $val->validated('port'); $proxy->fail_count = $val->validated('fail_count'); Session::set_flash('error', $val->error()); } $this->template->set_global('proxy', $proxy, false); } $this->template->title = "Proxies"; $this->template->content = View::forge('proxies/edit'); }
public function action_edit($id = null) { is_null($id) and Response::redirect('Survey_Question_Answer'); if (!($survey_question_answer = Model_Survey_Question_Answer::find($id))) { Session::set_flash('error', 'Could not find survey_question_answer #' . $id); Response::redirect('Survey_Question_Answer'); } $val = Model_Survey_Question_Answer::validate('edit'); if ($val->run()) { $survey_question_answer->question_id = Input::post('question_id'); $survey_question_answer->answer = Input::post('answer'); if ($survey_question_answer->save()) { Session::set_flash('success', 'Updated survey_question_answer #' . $id); Response::redirect('survey/question/answer'); } else { Session::set_flash('error', 'Could not update survey_question_answer #' . $id); } } else { if (Input::method() == 'POST') { $survey_question_answer->question_id = $val->validated('question_id'); $survey_question_answer->answer = $val->validated('answer'); Session::set_flash('error', $val->error()); } $this->template->set_global('survey_question_answer', $survey_question_answer, false); } $this->template->title = "Survey_question_answers"; $this->template->content = View::forge('survey/question/answer/edit'); }
public function before() { parent::before(); // Check Auth if (!\Auth\Auth::check()) { \Fuel\Core\Response::redirect('auth'); } /* * Theme Set */ $this->theme = \Theme::instance(); $this->theme->set_template('index'); /* * Breadcrumb */ // $this->_breadcrumb = Breadcrumb::create_links(); if (Session::get('lang')) { $this->_lang = Session::get('lang'); } if (Input::method() == 'GET') { $this->_get = Input::get(); } if (Input::method() == 'POST') { $this->_post = Input::post(); } $this->initialized(); }
public function action_edit($id = null) { is_null($id) and Response::redirect('blog'); if (!($blog = Model_Blog::find($id))) { Session::set_flash('error', 'Could not find blog #' . $id); Response::redirect('blog'); } $val = Model_Blog::validate('edit'); if ($val->run()) { $blog->title = Input::post('title'); $blog->content = Input::post('content'); if ($blog->save()) { Session::set_flash('success', 'Updated blog #' . $id); Response::redirect('blog'); } else { Session::set_flash('error', 'Could not update blog #' . $id); } } else { if (Input::method() == 'POST') { $blog->title = $val->validated('title'); $blog->content = $val->validated('content'); Session::set_flash('error', $val->error()); } $this->template->set_global('blog', $blog, false); } $this->template->title = "Blogs"; $this->template->content = View::forge('blog/edit'); }
public function action_edit($id = null) { parent::has_access("create_employee"); is_null($id) and Response::redirect('employees/view' . $id); if (!($bank = Model_Bank::find('first', array('where' => array('employee_id' => $id))))) { Session::set_flash('error', 'Could not find user #' . $id); Response::redirect('employees/view/' . $id); } if (Input::method() == 'POST') { $bank->account_no = Input::post('account_no'); $bank->account_type = Input::post('account_type'); $bank->branch = Input::post('branch'); $bank->city = Input::post('city'); $bank->state = Input::post('state'); $bank->ifsc_code = Input::post('ifsc_code'); $bank->payment_type = Input::post('payment_type'); if ($bank->save()) { Session::set_flash('success', 'Updated bank details #' . $id); Response::redirect('employees/view/' . $id); } else { Session::set_flash('error', 'Could not update bank #' . $id); } } $this->template->title = "Banks"; $this->template->content = View::forge('banks/edit'); }
public function action_edit($id = null) { is_null($id) and Response::redirect('request'); if (!($request = Model_Request::find($id))) { Session::set_flash('error', 'Could not find request #' . $id); Response::redirect('request'); } $val = Model_Request::validate('edit'); if ($val->run()) { $request->body = Input::post('body'); $request->ip = Input::post('ip'); if ($request->save()) { Session::set_flash('success', 'Updated request #' . $id); Response::redirect('request'); } else { Session::set_flash('error', 'Could not update request #' . $id); } } else { if (Input::method() == 'POST') { $request->body = $val->validated('body'); $request->ip = $val->validated('ip'); Session::set_flash('error', $val->error()); } $this->template->set_global('request', $request, false); } $this->template->title = "Requests"; $this->template->content = View::forge('request/edit'); }
public function action_edit($id = null) { is_null($id) and Response::redirect('userstationlog'); if (!($userstationlog = Model_Userstationlog::find($id))) { Session::set_flash('error', 'Could not find userstationlog #' . $id); Response::redirect('userstationlog'); } $val = Model_Userstationlog::validate('edit'); if ($val->run()) { $userstationlog->id = Input::post('id'); $userstationlog->base_line = Input::post('base_line'); $userstationlog->station_id = Input::post('station_id'); $userstationlog->station_id_index = Input::post('station_id_index'); if ($userstationlog->save()) { Session::set_flash('success', 'Updated userstationlog #' . $id); Response::redirect('userstationlog'); } else { Session::set_flash('error', 'Could not update userstationlog #' . $id); } } else { if (Input::method() == 'POST') { $userstationlog->id = $val->validated('id'); $userstationlog->base_line = $val->validated('base_line'); $userstationlog->station_id = $val->validated('station_id'); $userstationlog->station_id_index = $val->validated('station_id_index'); Session::set_flash('error', $val->error()); } $this->template->set_global('userstationlog', $userstationlog, false); } $this->template->title = "Userstationlogs"; $this->template->content = View::forge('userstationlog/edit'); }
public function action_edit($id = null) { $currency = Model_Currency::find($id); $val = Model_Currency::validate('edit'); if ($val->run()) { $currency->name = Input::post('name'); $currency->symbol = Input::post('symbol'); $currency->country = Input::post('country'); $currency->is_default = Input::post('is_default'); $currency->exchange_rate = Input::post('exchange_rate'); if ($currency->save()) { Session::set_flash('success', e('Updated currency #' . $id)); Response::redirect('admin/currencies'); } else { Session::set_flash('error', e('Could not update currency #' . $id)); } } else { if (Input::method() == 'POST') { $currency->name = $val->validated('name'); $currency->symbol = $val->validated('symbol'); $currency->country = $val->validated('country'); $currency->is_default = $val->validated('is_default'); $currency->exchange_rate = $val->validated('exchange_rate'); Session::set_flash('error', $val->error()); } $this->template->set_global('currency', $currency, false); } $countries = Model_Country::find('all', array('order_by' => array(array('name', 'asc')))); $this->template->set_global('countries', $countries); $this->template->set_global('yes_no', array('0' => 'No', '1' => 'Yes')); $this->template->title = "Currencies"; $this->template->content = View::forge('admin/currencies/edit'); }
public function action_edit($id = null) { is_null($id) and Response::redirect('faculty'); if (!($faculty = Model_Faculty::find($id))) { Session::set_flash('error', 'Could not find faculty #' . $id); Response::redirect('faculty'); } $val = Model_Faculty::validate('edit'); if ($val->run()) { $faculty->name = Input::post('name'); $faculty->phone = Input::post('phone'); $faculty->email = Input::post('email'); $faculty->hotline = Input::post('hotline'); $faculty->address = Input::post('address'); if ($faculty->save()) { Session::set_flash('success', 'Updated faculty #' . $id); Response::redirect('faculty'); } else { Session::set_flash('error', 'Could not update faculty #' . $id); } } else { if (Input::method() == 'POST') { $faculty->name = $val->validated('name'); $faculty->phone = $val->validated('phone'); $faculty->email = $val->validated('email'); $faculty->hotline = $val->validated('hotline'); $faculty->address = $val->validated('address'); Session::set_flash('error', $val->error()); } $this->template->set_global('faculty', $faculty, false); } $this->template->title = "Faculties"; $this->template->content = View::forge('faculty/edit'); }
public function action_edit($id = null) { $form = Model_Form::find($id); $val = Model_Form::validate('edit'); if ($val->run()) { $form->name = Input::post('name'); $form->email = Input::post('email'); $form->comment = Input::post('comment'); $form->ip_address = Input::post('ip_address'); $form->user_agent = Input::post('user_agent'); if ($form->save()) { Session::set_flash('success', e('Updated form #' . $id)); Response::redirect('admin/form'); } else { Session::set_flash('error', e('Could not update form #' . $id)); } } else { if (Input::method() == 'POST') { $form->name = $val->validated('name'); $form->email = $val->validated('email'); $form->comment = $val->validated('comment'); $form->ip_address = $val->validated('ip_address'); $form->user_agent = $val->validated('user_agent'); Session::set_flash('error', $val->error()); } $this->template->set_global('form', $form, false); } $this->template->title = "Forms"; $this->template->content = View::forge('admin/form/edit'); }
/** * Mmeber setting viewtype * * @access public * @return Response */ public function action_index() { $page_name = term('notice', 'site.setting'); $val = \Form_MemberConfig::get_validation($this->u->id, 'notice', 'Notice'); if (\Input::method() == 'POST') { \Util_security::check_csrf(); try { if (!$val->run()) { throw new \FuelException($val->show_errors()); } $post = $val->validated(); \DB::start_transaction(); \Form_MemberConfig::save($this->u->id, $val, $post); \DB::commit_transaction(); \Session::set_flash('message', $page_name . 'を変更しました。'); \Response::redirect('member/setting'); } catch (\FuelException $e) { if (\DB::in_transaction()) { \DB::rollback_transaction(); } \Session::set_flash('error', $e->getMessage()); } } $this->set_title_and_breadcrumbs($page_name, array('member/setting' => term('site.setting', 'form.update')), $this->u); $this->template->content = \View::forge('member/setting/_parts/form', array('val' => $val, 'label_size' => 5, 'form_params' => array('common' => array('radio' => array('layout_type' => 'grid'))))); }
public function action_edit($id = null) { is_null($id) and Response::redirect('point'); if (!($point = Model_Point::find($id))) { Session::set_flash('error', 'Could not find point #' . $id); Response::redirect('point'); } $val = Model_Point::validate('edit'); if ($val->run()) { $point->user_id = Input::post('user_id'); $point->point = Input::post('point'); if ($point->save()) { Session::set_flash('success', 'Updated point #' . $id); Response::redirect('point'); } else { Session::set_flash('error', 'Could not update point #' . $id); } } else { if (Input::method() == 'POST') { $point->user_id = $val->validated('user_id'); $point->point = $val->validated('point'); Session::set_flash('error', $val->error()); } $this->template->set_global('point', $point, false); } $this->template->title = "Points"; $this->template->content = View::forge('point/edit'); }
public function action_edit($id = null) { is_null($id) and Response::redirect('news/category'); if (!($news_category = Model_News_Category::find($id))) { Session::set_flash('error', 'Could not find news_category #' . $id); Response::redirect('news/category'); } $val = Model_News_Category::validate('edit'); if ($val->run()) { $news_category->name = Input::post('name'); if ($news_category->save()) { Session::set_flash('success', 'Updated news_category #' . $id); Response::redirect('news/category'); } else { Session::set_flash('error', 'Could not update news_category #' . $id); } } else { if (Input::method() == 'POST') { $news_category->name = $val->validated('name'); Session::set_flash('error', $val->error()); } $this->template->set_global('news_category', $news_category, false); } $this->template->title = "News_categories"; $this->template->content = View::forge('news/category/edit'); }
/** * Mmeber_profile edit * * @access public * @return Response */ public function action_edit($type = null) { list($type, $is_regist) = self::validate_type($type, $this->u->id); $form_member_profile = new Form_MemberProfile($type == 'regist' ? 'regist-config' : 'config', $this->u); $form_member_profile->set_validation(); if (\Input::method() == 'POST') { \Util_security::check_csrf(); try { $form_member_profile->validate(true); \DB::start_transaction(); $form_member_profile->seve(); if ($is_regist) { Model_MemberConfig::delete_value($this->u->id, 'terms_un_agreement'); } \DB::commit_transaction(); $message = $is_regist ? sprintf('%sが%sしました。', term('site.registration'), term('form.complete')) : term('profile') . 'を編集しました。'; $redirect_uri = $is_regist ? $this->after_auth_uri : 'member/profile'; \Session::set_flash('message', $message); \Response::redirect($redirect_uri); } catch (\FuelException $e) { if (\DB::in_transaction()) { \DB::rollback_transaction(); } \Session::set_flash('error', $e->getMessage()); } } $this->set_title_and_breadcrumbs(term('profile') . term($is_regist ? 'site.registration' : 'form.edit'), $is_regist ? array() : array('member/profile' => term('common.my', 'profile')), $is_regist ? null : $this->u); $this->template->content = View::forge('member/profile/edit', array('is_regist' => $is_regist, 'val' => $form_member_profile->get_validation(), 'member_public_flags' => $form_member_profile->get_member_public_flags(), 'profiles' => $form_member_profile->get_profiles(), 'member_profile_public_flags' => $form_member_profile->get_member_profile_public_flags())); }
public function action_edit($id = null) { $student = Model_Student::find('first', ['where' => ['user_id' => $id]]); if (!$student) { $student = Model_Student::forge(['user_id' => $id]); } $val = Model_Student::validate('edit'); if ($val->run()) { $student->user_id = Input::post('user_id'); $student->year_level = Input::post('year_level'); $student->course_id = Input::post('course_id'); if ($student->save()) { Session::set_flash('success', e('Updated student #' . $id)); Response::redirect('site/student'); } else { Session::set_flash('error', e('Could not update student #' . $id)); } } else { if (Input::method() == 'POST') { $student->user_id = $val->validated('user_id'); $student->year_level = $val->validated('year_level'); $student->course_id = $val->validated('course_id'); Session::set_flash('error', $val->error()); } $this->template->set_global('student', $student, false); } $this->template->title = "Students"; $this->template->content = View::forge('site/student/edit'); }
public function action_edit($id = null) { is_null($id) and Response::redirect('News'); $news = Model_News::find($id); $val = Model_News::validate('edit'); if ($val->run()) { $news->title = Input::post('title'); $news->article = Input::post('article'); $news->call_center_id = Input::post('call_center_id'); $news->user_id = Input::post('user_id'); if ($news->save()) { Session::set_flash('success', 'Updated news #' . $id); Response::redirect('news'); } else { Session::set_flash('error', 'Could not update news #' . $id); } } else { if (Input::method() == 'POST') { $news->title = $val->validated('title'); $news->article = $val->validated('article'); $news->call_center_id = $val->validated('call_center_id'); $news->user_id = $val->validated('user_id'); Session::set_flash('error', $val->error()); } $this->template->set_global('news', $news, false); } $this->template->title = "News"; $this->template->content = View::forge('news/edit'); }
public function action_login() { // Already logged in Auth::check() and Response::redirect('admin'); $val = Validation::forge(); if (Input::method() == 'POST') { $val->add('email', 'Email or Username')->add_rule('required'); $val->add('password', 'Password')->add_rule('required'); if ($val->run()) { if (!Auth::check()) { if (Auth::login(Input::post('email'), Input::post('password'))) { // assign the user id that lasted updated this record foreach (\Auth::verified() as $driver) { if (($id = $driver->get_user_id()) !== false) { // credentials ok, go right in $current_user = Model\Auth_User::find($id[1]); Session::set_flash('success', e('Welcome, ' . $current_user->username)); Response::redirect_back('admin'); } } } else { $this->template->set_global('login_error', 'Login failed!'); } } else { $this->template->set_global('login_error', 'Already logged in!'); } } } $this->template->title = 'ITNT Timesheets Login'; $this->template->content = View::forge('admin/login', array('val' => $val), false); }
public function action_edit($id = null) { $usermyroute = $this->_get_user_my_rouet_data_by_id($id); // $val = Model_Form::validate('edit'); $val = true; // if ($val->run()) if ($val == true) { $usermyroute->departure = Input::post('departure'); $usermyroute->arrival = Input::post('arrival'); $usermyroute->fare = Input::post('fare'); $usermyroute->via = Input::post('via'); $usermyroute->vehicle = Input::post('vehicle'); if ($usermyroute->save()) { Session::set_flash('success', e('Updated form #' . $id)); Response::redirect('admin/myroute'); } else { Session::set_flash('error', e('Could not update form #' . $id)); } } else { if (Input::method() == 'POST') { $form->name = $val->validated('name'); $form->email = $val->validated('email'); $form->comment = $val->validated('comment'); $form->ip_address = $val->validated('ip_address'); $form->user_agent = $val->validated('user_agent'); Session::set_flash('error', $val->error()); } $this->template->set_global('form', $form, false); } $this->template->title = "Forms"; $this->template->content = View::forge('admin/myroute/edit'); }
public function action_index() { if (Input::method() == 'POST') { } echo View::forge('unsubscribe'); exit; }
function __construct($c) { if (!Input::method("GET", "id") || !is_numeric(Input::method("GET", "id"))) { redirect::url(WEBSITE); } $this->newsfetch($c); }
public function action_edit($id = null) { is_null($id) and Response::redirect('Foto'); $foto = Model_Foto::find($id); $val = Model_Foto::validate('edit'); if ($val->run()) { $foto->imagen = Input::post('imagen'); $foto->width = Input::post('width'); $foto->height = Input::post('height'); $foto->articulo_id = Input::post('articulo_id'); $foto->dimension_id = Input::post('dimension_id'); $foto->estado = Input::post('estado'); if ($foto->save()) { Session::set_flash('success', 'Updated foto #' . $id); Response::redirect('foto'); } else { Session::set_flash('error', 'Could not update foto #' . $id); } } else { if (Input::method() == 'POST') { $foto->imagen = $val->validated('imagen'); $foto->width = $val->validated('width'); $foto->height = $val->validated('height'); $foto->articulo_id = $val->validated('articulo_id'); $foto->dimension_id = $val->validated('dimension_id'); $foto->estado = $val->validated('estado'); Session::set_flash('error', $val->error()); } $this->template->set_global('foto', $foto, false); } $this->template->title = "Fotos"; $this->template->content = View::forge('foto/edit'); }
public function action_login() { // Already logged in Auth::check() and Response::redirect('admin'); $val = Validation::forge(); if (Input::method() == 'POST') { $val->add('email', 'ユーザ名')->add_rule('required'); $val->add('password', 'パスワード')->add_rule('required'); if ($val->run()) { $auth = Auth::instance(); // check the credentials. This assumes that you have the previous table created if (Auth::check() or $auth->login(Input::post('email'), Input::post('password'))) { // credentials ok, go right in if (Config::get('auth.driver', 'Simpleauth') == 'Ormauth') { $current_user = Model\Auth_User::find_by_username(Auth::get_screen_name()); } else { $current_user = Model_User::find_by_username(Auth::get_screen_name()); } Session::set_flash('success', e('ようこそ、' . $current_user->username . 'さん')); Response::redirect('admin'); } else { $this->template->set_global('login_error', '失敗しました'); } } } $this->template->title = 'ログイン'; $this->template->content = View::forge('admin/login', array('val' => $val), false); }