コード例 #1
0
ファイル: sidemik.php プロジェクト: trie0856/sidemik
 public static function getSemester($nim)
 {
     $config = new Model_Config();
     $mahasiswa = new Model_Mahasiswa($nim);
     $tahun = $config->where('name', '=', 'tahun')->find()->value;
     $semester = $config->where('name', '=', 'semester')->find()->value;
     return ($tahun - $mahasiswa->tahun_masuk) * 2 + $semester;
 }
コード例 #2
0
ファイル: translations.php プロジェクト: demoic/common
 public function action_index()
 {
     // validation active
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('List')));
     $this->template->title = __('Translations');
     //scan project files and generate .po
     $parse = $this->request->query('parse');
     if ($parse) {
         //scan script
         require_once Kohana::find_file('vendor', 'POTCreator/POTCreator', 'php');
         $obj = new POTCreator();
         $obj->set_root(DOCROOT);
         $obj->set_exts('php');
         $obj->set_regular('/_[_|e]\\([\\"|\']([^\\"|\']+)[\\"|\']\\)/i');
         $obj->set_base_path('..');
         $obj->set_read_subdir(true);
         $obj->write_pot(i18n::get_language_path());
         Alert::set(Alert::SUCCESS, 'File regenerated');
     }
     //change default site language
     if ($this->request->param('id')) {
         //save language
         $locale = new Model_Config();
         $locale->where('group_name', '=', 'i18n')->where('config_key', '=', 'locale')->limit(1)->find();
         if (!$locale->loaded()) {
             $locale->group_name = 'i18n';
             $locale->config_key = 'locale';
         }
         $locale->config_value = $this->request->param('id');
         try {
             $locale->save();
             Alert::set(Alert::SUCCESS, __('Translations regenarated'));
         } catch (Exception $e) {
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'translations')));
     }
     //create language
     if (Core::post('locale')) {
         $language = $this->request->post('locale');
         $folder = DOCROOT . 'languages/' . $language . '/LC_MESSAGES/';
         // if folder does not exist, try to make it
         if (!file_exists($folder) and !@mkdir($folder, 0775, true)) {
             // mkdir not successful ?
             Alert::set(Alert::ERROR, __('Language folder cannot be created with mkdir. Please correct to be able to create new translation.'));
             HTTP::redirect(Route::url('oc-panel', array('controller' => 'translations')));
         }
         // write an empty .po file for $language
         $out = 'msgid ""' . PHP_EOL;
         $out .= 'msgstr ""' . PHP_EOL;
         File::write($folder . 'messages.po', $out);
         Alert::set(Alert::SUCCESS, $this->request->param('id') . ' ' . __('Language saved'));
     }
     $this->template->content = View::factory('oc-panel/pages/translations/index', array('languages' => i18n::get_languages(), 'current_language' => core::config('i18n.locale')));
 }
コード例 #3
0
 public function salaryAction()
 {
     $salaryConfig = new Model_Config();
     $salaryData = $salaryConfig->findConfig();
     $this->view->salaryData = $salaryData;
     if ($this->_request->isPost()) {
         $data = $this->_getParam('searchParam');
         $salaryConfig->updateSalary($data);
         echo "<script>alert('Cập nhật dữ liệu thành công');</script>";
         header('Refresh:0');
     }
 }
コード例 #4
0
 public function updateAction()
 {
     $degree = new Model_Config();
     $listDegree = $degree->listDegree();
     $this->view->listDegree = $listDegree;
     if ($this->_request->isPost()) {
         $data = $this->_getParam('Params');
         foreach ($data as $degree_id => $coefficient) {
             $degree->updateDegree($degree_id, $coefficient);
         }
         $this->redirect('giaovu/degree/update');
     }
 }
コード例 #5
0
ファイル: Config.php プロジェクト: Gorp/pr
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
コード例 #6
0
ファイル: blog.php プロジェクト: rundiz/fuel-start
 public function action_index()
 {
     if (!\DBUtil::table_exists('blog') && !\DBUtil::table_exists('blog_comment')) {
         \Response::redirect('blog/installrequired');
     }
     // list posts -----------------------------------------------------------------------------------------------------
     $option['limit'] = \Model_Config::getval('content_items_perpage');
     $option['offset'] = trim(\Input::get('page')) != null ? ((int) \Input::get('page') - 1) * $option['limit'] : 0;
     $list_items = \Blog\Model_Blog::listItems($option);
     // pagination config
     $config['pagination_url'] = \Uri::main() . \Uri::getCurrentQuerystrings(true, true, false);
     $config['total_items'] = $list_items['total'];
     $config['per_page'] = $option['limit'];
     $config['uri_segment'] = 'page';
     $config['num_links'] = 3;
     $config['show_first'] = true;
     $config['show_last'] = true;
     $config['first-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['first-inactive-link'] = '<a href="#">{page}</a>';
     $config['first-marker'] = '&laquo;';
     $config['last-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['last-inactive-link'] = '<a href="#">{page}</a>';
     $config['last-marker'] = '&raquo;';
     $config['previous-marker'] = '&lsaquo;';
     $config['next-marker'] = '&rsaquo;';
     $pagination = \Pagination::forge('viewlogins_pagination', $config);
     $output['list_items'] = $list_items;
     $output['pagination'] = $pagination;
     unset($config, $list_accounts, $option, $pagination);
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('blog'));
     // <head> output ----------------------------------------------------------------------------------------------
     return $this->generatePage('blog_v', $output, false);
 }
コード例 #7
0
 public function listAction()
 {
     $hocky = new Model_Config();
     $listHocky = $hocky->listHocky();
     $this->view->listHocky = $listHocky;
     if ($this->_request->isPost()) {
         $findHocky = $hocky->findOneHocky();
         $name = $findHocky->schoolyears_name;
         $array1 = explode(' - ', $name);
         $array2 = array($array1[0] + 1, $array1[1] + 1);
         $schoolyears_name = implode(' - ', $array2);
         $hocky->addHocky($schoolyears_name);
         $this->redirect('giaovu/namhoc/list');
         var_dump($schoolyears_name);
     }
 }
コード例 #8
0
 public function action_status()
 {
     $status = (bool) $this->request->param('id');
     Model_Config::set_value('general', 'cron', $status);
     Alert::set(Alert::SUCCESS, __('General Configuration updated'));
     $this->redirect(Route::url('oc-panel', array('controller' => 'crontab')));
 }
コード例 #9
0
 public function action_index()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Social Authentication for login')));
     $this->template->title = __('Social Auth');
     $this->template->styles = array('css/sortable.css' => 'screen');
     $this->template->scripts['footer'][] = 'js/jquery-sortable-min.js';
     //retrieve social_auth values
     $config = Social::get();
     if ($p = $this->request->post()) {
         $confit_old = $config;
         $config_new = array();
         foreach ($p as $key => $value) {
             if ($key != 'submit') {
                 // check if its id, secret .. and build multy d. array, same as they have
                 if (strpos($key, '_id')) {
                     $config_new['providers'][str_replace('_id', '', $key)]['keys']['id'] = $value;
                 } elseif (strpos($key, '_secret')) {
                     $config_new['providers'][str_replace('_secret', '', $key)]['keys']['secret'] = $value;
                 } elseif (strpos($key, '_key')) {
                     $config_new['providers'][str_replace('_key', '', $key)]['keys']['key'] = $value;
                 } elseif ($key == 'debug_mode') {
                     $config_new[$key] = $value;
                 } else {
                     $config_new['providers'][$key]['enabled'] = $value;
                 }
             }
         }
         // two fields not included
         $config_new['base_url'] = Route::url('default', array('controller' => 'social', 'action' => 'login', 'id' => 1));
         $config_new['debug_file'] = DOCROOT . 'oc/vendor/hybridauth/logs.txt';
         $obj_social_config = new Model_Config();
         $conf = $obj_social_config->where('group_name', '=', 'social')->where('config_key', '=', 'config')->limit(1)->find();
         if ($conf->loaded()) {
             $conf->config_value = json_encode($config_new);
             try {
                 $conf->save();
                 $config = $config_new;
                 //we update the form values if we changed them
                 Alert::set(Alert::SUCCESS, __('Social Auth updated'));
             } catch (Exception $e) {
                 throw HTTP_Exception::factory(500, $e->getMessage());
             }
         }
     }
     $this->template->content = View::factory('oc-panel/pages/social_auth/index', array('config' => $config));
 }
コード例 #10
0
 public static function save($items)
 {
     // save widget to DB
     $conf = new Model_Config();
     $conf->where('group_name', '=', 'general')->where('config_key', '=', 'menu')->limit(1)->find();
     if (!$conf->loaded()) {
         $conf->group_name = 'general';
         $conf->config_key = 'menu';
     }
     $conf->config_value = json_encode($items);
     try {
         $conf->save();
         return TRUE;
     } catch (Exception $e) {
         throw HTTP_Exception::factory(500, $e->getMessage());
     }
     return FALSE;
 }
コード例 #11
0
ファイル: Config.php プロジェクト: ssrsfs/blg
 /**
  * A shortcut for creating or updating a config value.
  * @param string $name The config name.
  * @param string $value The config value.
  * @return Dbi_Record The resulting record.
  */
 public static function Set($name, $value)
 {
     $config = Model_Config::Get($name);
     if (!$config->exists()) {
         $config = Model_Config::Create();
         $config['configname'] = $name;
     }
     $config['configvalue'] = $value;
     $config->save();
     return $config;
 }
コード例 #12
0
ファイル: core.php プロジェクト: khoapld/wjshop
 public function check_maintenance()
 {
     $config = Model_Config::find('first');
     View::set_global('config', $config);
     if ($this->action === 'maintenance' && (int) $config->maintenance !== 1) {
         Response::redirect('/');
     }
     if (!in_array($this->action, ['maintenance']) && (int) $config->maintenance === 1) {
         Response::redirect('/maintenance');
     }
 }
コード例 #13
0
 /**
  * Automatically executed before the widget action. Can be used to set
  * class properties, do authorization checks, and execute other custom code.
  *
  * @return  void
  */
 public function before()
 {
     //we need this option enabled for this plugin to work
     if (Core::config('i18n.allow_query_language') == 0) {
         Model_Config::set_value('i18n', 'allow_query_language', 1);
     }
     if ($this->languages == '') {
         $this->languages = i18n::get_languages();
     } else {
         $this->languages = array_map('trim', explode(',', $this->languages));
     }
 }
コード例 #14
0
ファイル: translations.php プロジェクト: Wildboard/WbWebApp
 public function action_index()
 {
     // validation active
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('List')));
     $this->template->title = __('Translations');
     //scan project files and generate .po
     $parse = $this->request->query('parse');
     if ($parse) {
         //scan script
         require_once Kohana::find_file('vendor', 'POTCreator/POTCreator', 'php');
         $obj = new POTCreator();
         $obj->set_root(DOCROOT);
         $obj->set_exts('php');
         $obj->set_regular('/_[_|e]\\([\\"|\']([^\\"|\']+)[\\"|\']\\)/i');
         $obj->set_base_path('..');
         $obj->set_read_subdir(true);
         $obj->write_pot(i18n::get_language_path());
         Alert::set(Alert::SUCCESS, 'File regenerated');
     }
     //change default site language
     if ($this->request->param('id')) {
         //save language
         $locale = new Model_Config();
         $locale->where('group_name', '=', 'i18n')->where('config_key', '=', 'locale')->limit(1)->find();
         if (!$locale->loaded()) {
             $locale->group_name = 'i18n';
             $locale->config_key = 'locale';
         }
         $locale->config_value = $this->request->param('id');
         try {
             $locale->save();
             Alert::set(Alert::SUCCESS, '');
             Request::current()->redirect(Route::url('oc-panel', array('controller' => 'translations')));
         } catch (Exception $e) {
             echo $e;
         }
     }
     $this->template->content = View::factory('oc-panel/pages/translations/index', array('languages' => i18n::get_languages(), 'current_language' => core::config('i18n.locale')));
 }
コード例 #15
0
ファイル: config.php プロジェクト: khoapld/wjshop
 public static function update($data)
 {
     try {
         $data['updated_at'] = date('Y-m-d H:i:s', Date::forge()->get_timestamp());
         $query = Model_Config::find(1);
         $query->set($data);
         $query->save();
     } catch (Exception $e) {
         Log::write('ERROR', $e->getMessage());
         return false;
     }
     return true;
 }
コード例 #16
0
ファイル: email.php プロジェクト: rundiz/fuel-start
 /**
  * get config
  * get email config values from db and set it to ready for FuelPHP email configuration array.
  *
  * @author Vee Winch.
  * @return array all email configuration in db.
  */
 public static function getConfig()
 {
     $cfg_email = \Model_Config::getvalues(array('mail_protocol', 'mail_mailpath', 'mail_smtp_host', 'mail_smtp_user', 'mail_smtp_pass', 'mail_smtp_port'));
     $config['driver'] = $cfg_email['mail_protocol']['value'];
     $config['sendmail_path'] = $cfg_email['mail_mailpath']['value'];
     $config['smtp']['host'] = $cfg_email['mail_smtp_host']['value'];
     $config['smtp']['port'] = (int) $cfg_email['mail_smtp_port']['value'];
     $config['smtp']['username'] = $cfg_email['mail_smtp_user']['value'];
     $config['smtp']['password'] = $cfg_email['mail_smtp_pass']['value'];
     $config['smtp']['timeout'] = 20;
     $config['newline'] = "\r\n";
     unset($cfg_email);
     return $config;
 }
コード例 #17
0
ファイル: index.php プロジェクト: rundiz/fuel-start
 /**
  * default method for this controller.
  * you may replace code in this method with yours to start build your project.
  */
 public function action_index()
 {
     // load language
     \Lang::load('fslang');
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = \Model_Config::getval('site_name');
     // example for asset and theme asset
     //\Asset::css('bootstrap.min.css', array(), 'fuelstart');
     //\Theme::instance()->asset->css('main.css', array(), 'fuelstart');
     //$output['page_meta'][] = \Html::meta('description', 'test-fuel-start-description');
     //$output['page_link'][] = html_tag('link', array('rel' => 'stylesheet', 'href' => Uri::createNL(\Theme::instance()->asset_path('css/main.css'))));
     // end example
     // <head> output ----------------------------------------------------------------------------------------------
     $theme = \Theme::instance();
     return $theme->view('front/templates/index_v', $output, false);
 }
コード例 #18
0
ファイル: translations.php プロジェクト: ThomWensink/common
 public function action_index()
 {
     // validation active
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('List')));
     $this->template->title = __('Translations');
     //scan project files and generate .po
     if (core::get('parse') !== NULL) {
         //scan script
         require_once Kohana::find_file('vendor', 'POTCreator/POTCreator', 'php');
         $obj = new POTCreator();
         $obj->set_root(DOCROOT);
         $obj->set_exts('php');
         $obj->set_regular('/_[_|e]\\([\\"|\']([^\\"|\']+)[\\"|\']\\)/i');
         $obj->set_base_path('..');
         $obj->set_read_subdir(true);
         $obj->write_pot(i18n::get_language_path());
         Alert::set(Alert::SUCCESS, 'File regenerated');
     }
     //change default site language
     if (($locale = $this->request->param('id')) != NULL and array_key_exists($locale, i18n::get_languages())) {
         //save language
         Model_Config::set_value('i18n', 'locale', $locale);
         //change the cookie if not he will not see the changes
         if (Core::config('i18n.allow_query_language') == 1) {
             Cookie::set('user_language', $locale, Core::config('auth.lifetime'));
         }
         Alert::set(Alert::SUCCESS, __('Language') . ' ' . $locale);
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'translations')));
     }
     //create language
     if (Core::post('locale')) {
         $language = $this->request->post('locale');
         $folder = DOCROOT . 'languages/' . $language . '/LC_MESSAGES/';
         // if folder does not exist, try to make it
         if (!file_exists($folder) and !@mkdir($folder, 0775, true)) {
             // mkdir not successful ?
             Alert::set(Alert::ERROR, __('Language folder cannot be created with mkdir. Please correct to be able to create new translation.'));
             HTTP::redirect(Route::url('oc-panel', array('controller' => 'translations')));
         }
         // write an empty .po file for $language
         $out = 'msgid ""' . PHP_EOL;
         $out .= 'msgstr ""' . PHP_EOL;
         File::write($folder . 'messages.po', $out);
         Alert::set(Alert::SUCCESS, $this->request->param('id') . ' ' . __('Language saved'));
     }
     $this->template->content = View::factory('oc-panel/pages/translations/index', array('languages' => i18n::get_languages(), 'current_language' => core::config('i18n.locale')));
 }
コード例 #19
0
ファイル: date.php プロジェクト: rundiz/fuel-start
 /**
  * gmt date. the timezone up to current user data.
  *
  * @param string $date_format date format can use both date() function or strftime() function
  * @param integer $timestamp localtime timestamp.
  * @param type $timezone php timezone (http://www.php.net/manual/en/timezones.php)
  * @return null
  */
 public static function gmtDate($date_format = '%Y-%m-%d %H:%M:%S', $timestamp = '', $timezone = '')
 {
     // check empty date format
     if (empty($date_format)) {
         $date_format = '%Y-%m-%d %H:%M:%S';
     }
     // check timestamp
     if (empty($timestamp)) {
         $timestamp = time();
     } else {
         if (!self::isValidTimeStamp($timestamp)) {
             $timestamp = strtotime($timestamp);
         }
     }
     // make very sure that selected timezone is in the timezone list or converted to real timezone.
     if ($timezone != null) {
         $timezone = static::isValidTimezone($timezone);
     }
     // check timezone
     if ($timezone == null) {
         $account_model = new \Model_Accounts();
         $cookie = $account_model->getAccountCookie();
         $site_timezone = static::getRealTimezoneValue(\Model_Config::getval('site_timezone'));
         if (!isset($cookie['account_id'])) {
             // not member or not log in. use default config timezone.
             $timezone = $site_timezone;
         } else {
             // find timezone for current user.
             $row = \Model_Accounts::find($cookie['account_id']);
             if (!empty($row)) {
                 $timezone = static::getRealTimezoneValue($row->account_timezone);
             } else {
                 $timezone = $site_timezone;
             }
         }
         unset($account_model, $cookie, $row, $site_timezone);
     }
     // what format of the date_format (use date() value or strftime() value)
     if (strpos($date_format, '%') !== false) {
         // use strftime() format
         return \Date::forge($timestamp)->set_timezone($timezone)->format($date_format);
     } else {
         // use date() format
         return date($date_format, strtotime(\Date::forge($timestamp)->set_timezone($timezone)->format('%Y-%m-%d %H:%M:%S')));
     }
 }
コード例 #20
0
ファイル: blog.php プロジェクト: rundiz/fuel-start
 /**
  * list items
  * 
  * @param array $option
  * @return mixed
  */
 public static function listItems($option = array())
 {
     $query = self::query();
     $output['total'] = $query->count();
     // offset and limit
     if (!isset($option['offset'])) {
         $option['offset'] = 0;
     }
     if (!isset($option['limit'])) {
         if (isset($option['list_for']) && $option['list_for'] == 'admin') {
             $option['limit'] = \Model_Config::getval('content_admin_items_perpage');
         } else {
             $option['limit'] = \Model_Config::getval('content_items_perpage');
         }
     }
     // get the results from sort, order, offset, limit.
     $output['items'] = $query->order_by('post_id', 'DESC')->offset($option['offset'])->limit($option['limit'])->get();
     unset($orders, $query, $sort);
     return $output;
 }
コード例 #21
0
ファイル: emailtemplate.php プロジェクト: rundiz/fuel-start
 /**
  * read template
  *
  * @author Vee Winch.
  * @param string $email_file email file.
  * @param string $template_path path to folder that store email file.
  * @return mixed
  */
 public static function readTemplate($email_file = '', $template_path = null)
 {
     if ($email_file == null) {
         return null;
     }
     if ($template_path == null) {
         $template_path = APPPATH . 'lang' . DS . \Lang::get_lang() . DS . 'email' . DS;
     }
     if (file_exists($template_path . $email_file)) {
         $site_name = \Model_Config::getval('site_name');
         $output = file_get_contents($template_path . $email_file);
         $output = str_replace("%site_name%", $site_name, $output);
         $output = str_replace("%site_url%", \Uri::base(), $output);
         $output = str_replace("%site_admin%", \Uri::create('admin'), $output);
         unset($site_name, $template_path);
         return $output;
     } else {
         return false;
     }
 }
コード例 #22
0
 public function action_index()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Interactive map')));
     $this->template->title = __('Interactive map');
     $this->template->styles = array('css/map-generator.css' => 'screen');
     $this->template->scripts['footer'][] = '//www.google.com/jsapi';
     $this->template->scripts['footer'][] = '//maps.google.com/maps/api/js?sensor=false';
     $this->template->scripts['footer'][] = 'js/oc-panel/map/jscolor.js';
     $this->template->scripts['footer'][] = 'js/oc-panel/map/map-generator.js';
     $map_active = Core::post('map_active', Core::Config('appearance.map_active'));
     $map_settings = Core::post('current_settings', Core::Config('appearance.map_settings'));
     // change map
     if (Theme::get('premium') == 1 and Core::post('jscode')) {
         Model_Config::set_value('appearance', 'map_active', Core::post('map_active'));
         Model_Config::set_value('appearance', 'map_settings', Core::post('current_settings'));
         Model_Config::set_value('appearance', 'map_jscode', Kohana::$_POST_ORIG['jscode']);
         Core::delete_cache();
         Alert::set(Alert::SUCCESS, __('Map saved.'));
     }
     $this->template->content = View::factory('oc-panel/pages/map', array('map_active' => $map_active, 'map_settings' => $map_settings));
 }
コード例 #23
0
ファイル: accountlogins.php プロジェクト: rundiz/fuel-start
 /**
  * list login history.
  *
  * @param array $data
  * @param array $option available options: [orders], [sort], [offset], [limit], [list_for]
  * @return mixed
  */
 public static function listLogins(array $data = array(), array $option = array())
 {
     if (!isset($data['account_id']) || isset($data['account_id']) && !is_numeric($data['account_id'])) {
         return null;
     }
     // get total logins of current user
     $query = static::query()->where('account_id', $data['account_id']);
     // if specify to view logins from site id.
     if (isset($data['site_id'])) {
         $query->where('site_id', $data['site_id']);
     }
     $output['total'] = $query->count();
     // sort and order
     $allowed_orders = array('account_login_id', 'site_id', 'login_ua', 'login_os', 'login_browser', 'login_ip', 'login_time', 'login_time_gmt', 'login_attempt', 'login_attempt_text');
     if (!isset($option['orders']) || isset($option['orders']) && !in_array($option['orders'], $allowed_orders)) {
         $option['orders'] = 'account_login_id';
     }
     unset($allowed_orders);
     if (!isset($option['sort'])) {
         $option['sort'] = 'DESC';
     }
     // offset and limit
     if (!isset($option['offset'])) {
         $option['offset'] = 0;
     }
     if (!isset($option['limit'])) {
         if (isset($option['list_for']) && $option['list_for'] == 'admin') {
             $option['limit'] = \Model_Config::getval('content_admin_items_perpage');
         } else {
             $option['limit'] = \Model_Config::getval('content_items_perpage');
         }
     }
     // get the results from sort, order, offset, limit.
     $output['items'] = $query->order_by($option['orders'], $option['sort'])->offset($option['offset'])->limit($option['limit'])->get();
     unset($query);
     return $output;
 }
コード例 #24
0
ファイル: theme.php プロジェクト: Wildboard/WbWebApp
 /**
  * saves thme options as json 'theme.NAMETHEME' = array json
  * @param  string $theme theme to save at
  * @param  array $data to save
  * @return void 
  */
 public static function save($theme = NULL, $data = NULL)
 {
     if ($theme === NULL) {
         $theme = self::$theme;
     }
     if ($data === NULL) {
         $data = self::$data;
     }
     // save theme to DB
     $conf = new Model_Config();
     $conf->where('group_name', '=', 'theme')->where('config_key', '=', $theme)->limit(1)->find();
     if (!$conf->loaded()) {
         $conf->group_name = 'theme';
         $conf->config_key = $theme;
     }
     $conf->config_value = json_encode($data);
     try {
         $conf->save();
     } catch (Exception $e) {
         throw new HTTP_Exception_500();
     }
 }
コード例 #25
0
ファイル: edit.php プロジェクト: rundiz/fuel-start
 public function action_index()
 {
     // load language
     \Lang::load('account');
     // is user logged in?
     if (\Model_Accounts::isMemberLogin() == false) {
         \Response::redirect(\Uri::create('account/login') . '?rdr=' . urlencode(\Uri::main()));
     }
     // load config from db.
     $cfg_values = array('allow_avatar', 'avatar_size', 'avatar_allowed_types');
     $config = \Model_Config::getvalues($cfg_values);
     $output['config'] = $config;
     // set config data to display in view file.
     $output['allow_avatar'] = $config['allow_avatar']['value'];
     $output['avatar_size'] = $config['avatar_size']['value'];
     $output['avatar_allowed_types'] = $config['avatar_allowed_types']['value'];
     unset($cfg_values);
     // read flash message for display errors. this is REQUIRED if you coding the check login with simultaneous login detection on.
     $form_status = \Session::get_flash('form_status');
     if (isset($form_status['form_status']) && isset($form_status['form_status_message'])) {
         $output['form_status'] = $form_status['form_status'];
         $output['form_status_message'] = $form_status['form_status_message'];
     }
     unset($form_status);
     // get account id
     $cookie_account = \Model_Accounts::forge()->getAccountCookie();
     // get account data
     $query = \Model_Accounts::query()->where('account_id', $cookie_account['account_id'])->where('account_username', $cookie_account['account_username'])->where('account_email', $cookie_account['account_email']);
     if ($query->count() > 0) {
         // found
         $row = $query->get_one();
         $output['row'] = $row;
         // loop set data for display in form.
         foreach ($row as $key => $field) {
             $output[$key] = $field;
         }
         // get account_fields data of current user and send to views form
         // to access data from view, use $account_field['field_name']. for example: the field_name is phone, just use $account_field['phone'];
         $account_fields = \Model_AccountFields::getData($cookie_account['account_id']);
         if ($account_fields->count() > 0) {
             foreach ($account_fields as $af) {
                 $output['account_field'][$af->field_name] = \Extension\Str::isJsonFormat($af->field_value) ? json_decode($af->field_value, true) : $af->field_value;
             }
         }
         unset($account_fields, $af);
         // get timezone list to display.
         \Config::load('timezone', 'timezone');
         $output['timezone_list'] = \Config::get('timezone.timezone', array());
         unset($query);
     } else {
         // not found account.
         unset($cookie_account, $query);
         \Model_Accounts::logout();
         \Response::redirect(\Uri::create('account/login') . '?rdr=' . urlencode(\Uri::main()));
     }
     // if form submitted
     if (\Input::method() == 'POST') {
         // store data for save to db.
         $data['account_id'] = $cookie_account['account_id'];
         $data['account_username'] = $cookie_account['account_username'];
         //trim(\Input::post('account_username'));//no, do not edit username.
         $data['account_old_email'] = $cookie_account['account_email'];
         $data['account_email'] = \Security::strip_tags(trim(\Input::post('account_email')));
         $data['account_password'] = trim(\Input::post('account_password'));
         $data['account_new_password'] = trim(\Input::post('account_new_password'));
         $data['account_display_name'] = \Security::htmlentities(\Input::post('account_display_name'));
         $data['account_firstname'] = \Security::htmlentities(trim(\Input::post('account_firstname', null)));
         if ($data['account_firstname'] == null) {
             $data['account_firstname'] = null;
         }
         $data['account_middlename'] = \Security::htmlentities(trim(\Input::post('account_middlename', null)));
         if ($data['account_middlename'] == null) {
             $data['account_middlename'] = null;
         }
         $data['account_lastname'] = \Security::htmlentities(trim(\Input::post('account_lastname', null)));
         if ($data['account_lastname'] == null) {
             $data['account_lastname'] = null;
         }
         $data['account_birthdate'] = \Security::strip_tags(trim(\Input::post('account_birthdate', null)));
         if ($data['account_birthdate'] == null) {
             $data['account_birthdate'] = null;
         }
         $data['account_signature'] = \Security::htmlentities(trim(\Input::post('account_signature', null)));
         if ($data['account_signature'] == null) {
             $data['account_signature'] = null;
         }
         $data['account_timezone'] = \Security::strip_tags(trim(\Input::post('account_timezone')));
         $data['account_language'] = \Security::strip_tags(trim(\Input::post('account_language', null)));
         if ($data['account_language'] == null) {
             $data['account_language'] = null;
         }
         // store data for account_fields
         $data_field = array();
         if (is_array(\Input::post('account_field'))) {
             foreach (\Input::post('account_field') as $field_name => $field_value) {
                 if (is_string($field_name)) {
                     if (is_array($field_value)) {
                         $field_value = json_encode($field_value);
                     }
                     $data_field[$field_name] = $field_value;
                 }
             }
         }
         unset($field_name, $field_value);
         // validate form.
         $validate = \Validation::forge();
         $validate->add_callable(new \Extension\FsValidate());
         //$validate->add('account_username', \Lang::get('account_username'), array(), array('required', 'noSpaceBetweenText'));//no, do not edit username.
         $validate->add('account_email', \Lang::get('account_email'), array(), array('required', 'valid_email'));
         $validate->add('account_display_name', \Lang::get('account_display_name'), array(), array('required'));
         $validate->add('account_birthdate', \Lang::get('account_birthdate'))->add_rule('valid_date', 'Y-m-d');
         $validate->add('account_timezone', \Lang::get('account_timezone'), array(), array('required'));
         if (!\Extension\NoCsrf::check()) {
             // validate token failed
             $output['form_status'] = 'error';
             $output['form_status_message'] = \Lang::get('fslang_invalid_csrf_token');
         } elseif (!$validate->run()) {
             // validate failed
             $output['form_status'] = 'error';
             $output['form_status_message'] = $validate->show_errors();
         } else {
             // save
             $result = \Model_accounts::memberEditProfile($data, $data_field);
             if ($result === true) {
                 if (\Session::get_flash('form_status', null, false) == null) {
                     \Session::set_flash('form_status', array('form_status' => 'success', 'form_status_message' => \Lang::get('account_saved')));
                 }
                 \Response::redirect(\Uri::main());
             } else {
                 $output['form_status'] = 'error';
                 $output['form_status_message'] = $result;
             }
         }
         // re-populate form
         //$output['account_username'] = trim(\Input::post('account_username'));//no, do not edit username.
         $output['account_email'] = trim(\Input::post('account_email'));
         $output['account_display_name'] = trim(\Input::post('account_display_name'));
         $output['account_firstname'] = trim(\Input::post('account_firstname'));
         $output['account_middlename'] = trim(\Input::post('account_middlename'));
         $output['account_lastname'] = trim(\Input::post('account_lastname'));
         $output['account_birthdate'] = trim(\Input::post('account_birthdate'));
         $output['account_signature'] = trim(\Input::post('account_signature'));
         $output['account_timezone'] = trim(\Input::post('account_timezone'));
         $output['account_language'] = trim(\Input::post('account_language'));
         // re-populate form for account fields
         if (is_array(\Input::post('account_field'))) {
             foreach (\Input::post('account_field') as $field_name => $field_value) {
                 if (is_string($field_name)) {
                     $output['account_field'][$field_name] = $field_value;
                 }
             }
         }
         unset($field_name, $field_value);
     }
     // clear variables
     unset($cookie_account, $data, $result);
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('account_edit'));
     // <head> output ----------------------------------------------------------------------------------------------
     return $this->generatePage('front/templates/account/edit_v', $output, false);
 }
コード例 #26
0
 public function action_subscribe()
 {
     $this->auto_render = FALSE;
     // Update subscribe config action
     Model_Config::set_value('general', 'subscribe', 1);
     Core::delete_cache();
     die('OK');
 }
コード例 #27
0
ファイル: dashboard.php プロジェクト: khoapld/wjshop
 public function action_index()
 {
     $this->data['config'] = Model_Config::find('first');
     $this->template->content = View::forge($this->layout . '/dashboard/index', $this->data);
 }
コード例 #28
0
ファイル: update.php プロジェクト: johnulist/openclassifieds2
 /**
  * This function will upgrade configs that didn't existed in versions prior to 2.0.3 
  */
 public function action_203()
 {
     // build array with new (missing) configs
     $configs = array(array('config_key' => 'watermark', 'group_name' => 'image', 'config_value' => '0'), array('config_key' => 'watermark_path', 'group_name' => 'image', 'config_value' => ''), array('config_key' => 'watermark_position', 'group_name' => 'image', 'config_value' => '0'), array('config_key' => 'ads_in_home', 'group_name' => 'advertisement', 'config_value' => '0'));
     $contents = array(array('order' => '0', 'title' => 'Hello [USER.NAME]!', 'seotitle' => 'user-profile-contact', 'description' => "User [EMAIL.SENDER] [EMAIL.FROM], have a message for you: \n\n [EMAIL.SUBJECT] \n\n[EMAIL.BODY]. \n\n Regards!", 'from_email' => core::config('email.notify_email'), 'type' => 'email', 'status' => '1'));
     // returns TRUE if some config is saved
     $return_conf = Model_Config::config_array($configs);
     $return_cont = Model_Content::content_array($contents);
 }
コード例 #29
0
ファイル: order.php プロジェクト: zhangkom/openclassifieds2
 /**
  * sets/creates a new plan
  * @param integer $days  
  * @param integer $price
  * @param integer $days_key key to be deleted...
  */
 public static function set_featured_plan($days, $price, $days_key = NULL)
 {
     $plans = self::get_featured_plans();
     //this deletes the previous key in case is a set. we do it here since calling delete_featured was cached...ugly as hell.
     if (is_numeric($days_key) and isset($plans[$days_key])) {
         unset($plans[$days_key]);
     }
     //this updates a current plan
     $plans[$days] = $price;
     //order from lowest to highest number of days
     ksort($plans);
     Model_Config::set_value('payment', 'featured_plans', json_encode($plans));
 }
コード例 #30
0
 /**
  * Plugins configuration 
  * @return [view] Renders view with form inputs
  */
 public function action_plugins()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Plugins')));
     $this->template->title = __('Plugins');
     // all form config values
     $generalconfig = new Model_Config();
     $config = $generalconfig->where('group_name', '=', 'general')->or_where('group_name', '=', 'i18n')->find_all();
     // config general array
     foreach ($config as $c) {
         $forms[$c->config_key] = $forms[$c->config_key] = array('key' => $c->group_name . '[' . $c->config_key . '][]', 'id' => $c->config_key, 'value' => $c->config_value);
     }
     // save only changed values
     if ($this->request->post()) {
         //d($this->request->post());
         foreach ($this->request->post('general') as $k => $v) {
             $this->request->post('general_' . $k, $v[0]);
         }
         $validation = Validation::factory($this->request->post());
         if ($validation->check()) {
             //save general
             foreach ($config as $c) {
                 $config_res = $this->request->post();
                 if (isset($config_res[$c->group_name][$c->config_key][0]) and $config_res[$c->group_name][$c->config_key][0] != $c->config_value) {
                     $c->config_value = $config_res[$c->group_name][$c->config_key][0];
                     Model_Config::set_value($c->group_name, $c->config_key, $c->config_value);
                 }
             }
         } else {
             $errors = $validation->errors('config');
             foreach ($errors as $error) {
                 Alert::set(Alert::ALERT, $error);
             }
             $this->redirect(Route::url('oc-panel', array('controller' => 'settings', 'action' => 'plugins')));
         }
         Alert::set(Alert::SUCCESS, __('Plugins configuration updated'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'settings', 'action' => 'plugins')));
     }
     $this->template->content = View::factory('oc-panel/pages/settings/plugins', array('forms' => $forms));
 }