Exemplo n.º 1
0
 static function getKey($key)
 {
     if (self::$cache === null) {
         self::$cache = Model::pluck(Setting::find('1=1'), 'value', 'key');
     }
     return self::$cache[$key];
 }
 public function postreg()
 {
     //if($slug == Setting::find(3)->value){
     if (Auth::check()) {
         return View::make('admin.index');
     } else {
         $input = Input::all();
         $validator = Validator::make($input, array('username' => 'required|unique:Users,username|between:5,20', 'email' => 'required|email', 'password' => 'required|between:5,50', 'code' => 'required'));
         if ($validator->fails()) {
             $messages = $validator->messages();
             $out = '';
             foreach ($messages->all() as $message) {
                 $out .= $message . '<Br>';
             }
             return View::make('admin.register')->with('error', $out);
         } else {
             if (Input::get('code') !== Setting::find(5)->value) {
                 return View::make('admin.register')->with('error', 'Invalid Code');
             }
             $user = new User();
             $user->email = Input::get('email');
             $user->username = Input::get('username');
             $user->password = Hash::make(Input::get('password'));
             $user->status = 'active';
             $user->save();
             Auth::login($user);
             return Redirect::to('/admin/' . Setting::find(3)->value);
         }
     }
     //}else{
     //App::abort('404');
     //}
 }
Exemplo n.º 3
0
 public function sendEmail()
 {
     App::import('Model', 'Setting');
     $setting_model = new Setting();
     $setting = $setting_model->find('first', array('fields' => 'email_contact'));
     $email_contact = empty($setting['Setting']['email_contact']) ? '' : $setting['Setting']['email_contact'];
     if (!empty($this->data['Contato'])) {
         $contato = $this->data['Contato'];
         App::uses('CakeEmail', 'Network/Email');
         $Email = new CakeEmail();
         $Email->config('smtp');
         $Email->template('contato', null);
         $Email->viewVars(array('contato' => $contato));
         $Email->to($email_contact);
         $Email->emailFormat('html');
         $Email->subject("Cartório NET - Contato: " . $contato['subject']);
         $success = false;
         try {
             if ($Email->send()) {
                 $success = true;
             } else {
                 $success = false;
             }
         } catch (Exception $e) {
             //                pr($e);die;
             $success = false;
         }
         return $success;
     }
     return false;
 }
Exemplo n.º 4
0
    public function update($id)
    {
        $data = Setting::find($id);
        $data->email_sender = Input::get('email');
        $data->protokol = Input::get('protokol');
        $data->port = Input::get('port');
        $data->host = Input::get('host');
        $data->user_email = Input::get('user');
        $data->pass_email = Input::get('pass');
        $data->save();
        if ($data->save()) {
            Session::flash('messages', '
					<div class="alert alert-info alert-dismissable" id="notif">
                    		<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    		<strong>Keterangan</strong><br>
                    			Setting berhasil disimpan
                		</div>
				');
        } else {
            Session::flash('messages', '
					<div class="alert alert-danger alert-dismissable" id="notif">
                    		<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    		<strong>Peringatan...</strong><br>
                    			Settig gagal disimpan
                		</div>
				');
        }
        return Redirect::to('admin/setting/email');
    }
Exemplo n.º 5
0
 /**
  * Show the form for editing the specified resource.
  * GET /settings/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id = NULL)
 {
     parent::show();
     $banner = $this->banner;
     $path = "/img/settings";
     $setting = Setting::find($id);
     return View::make('settings.edit', compact('setting', 'path', 'banner'));
 }
Exemplo n.º 6
0
 public static function getSettings()
 {
     static $static_cache = NULL;
     if (!$static_cache) {
         $static_cache = Setting::find(1);
     }
     return $static_cache;
 }
Exemplo n.º 7
0
 public function get_index()
 {
     $articles = cmsHelper::getAllArticles($message, true);
     //get the article limit size
     $articles = $articles->where('status', '=', 1)->paginate(Setting::find(2)->value);
     $dbquery = $articles;
     $articles = cmsHelper::bakeArticleForViewers($articles->results);
     return View::make('visitor.index', array("articles" => $articles, 'dbquery' => $dbquery));
 }
Exemplo n.º 8
0
 public function get_index($authorname)
 {
     $user = User::where('username', '=', $authorname)->first();
     //get the article limit size
     $articles = Article::where('author_id', '=', $user->id)->paginate(Setting::find(2)->value);
     $dbquery = $articles;
     $articles = cmsHelper::bakeArticleForViewers($articles->results);
     return View::make('visitor.index', array("articles" => $articles, 'dbquery' => $dbquery, 'message' => 'Showing all articles by ' . $user->displayname));
 }
Exemplo n.º 9
0
 /**
  * update() Update a database setting
  * @var string, Current setting name to update
  * @var string, setting name
  * @var string, New value for the setting
  *
  * @return boolean
  */
 public static function updateSetting($name, $newvalue)
 {
     //All clear now, now to the fun stuff. We are going to pull our current setting
     $setting = Setting::find($name);
     //Declare our new property values
     $setting->value = $newvalue;
     //Finally update the db
     $setting->save();
     //The response everyone is looking for :)
     return true;
 }
Exemplo n.º 10
0
 public function getAdjustedArticleContent()
 {
     $trim = Setting::find(1)->value;
     if ($trim != 0 && strlen($this->content) > $trim) {
         $text = substr($this->content, 0, $trim) . '...';
     } else {
         $text = $this->content;
     }
     $tidy = new tidy();
     $tidy->parseString($text, array('show-body-only' => true), 'utf8');
     $tidy->cleanRepair();
     return $tidy . '<a href="' . $this->getArticleUrl() . '">[ Continue reading ]</a>';
 }
Exemplo n.º 11
0
 /**
  * Update the settings in mass
  *
  * @param  array   $settingsToUpdate Setting name => value array
  *
  * @return integer Number of settings that were affected
  */
 public static function massUpdate($settingsToUpdate)
 {
     $affected = 0;
     foreach ($settingsToUpdate as $name => $value) {
         $setting = Setting::find($name);
         if (!$setting) {
             continue;
         }
         // Only update if there is a difference
         if ($setting->value != $value && $setting->save()) {
             $affected++;
         }
     }
     return $affected;
 }
Exemplo n.º 12
0
 public function post_index($category, $title, $id, $idparent = null)
 {
     $id = !is_null($idparent) ? $idparent : $id;
     Input::flash();
     //check if unregistered users' are allowed to post
     if (Setting::find(5)->value != 1 && Auth::guest()) {
         echo " Only Registered user's can post comments";
         die;
     }
     if (Setting::find(6)->value < strlen(Input::get('content'))) {
         echo " Comment size cannot be greater than " . Setting::find(6)->value . ' characters ';
         die;
     }
     //Add rules here
     $rules = array('name' => 'required|max:100', 'email' => 'required|email', 'content' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     if ($validation->fails()) {
         return Redirect::to($_SERVER['PATH_INFO'] . '#commentheading')->with_errors($validation);
     }
     $newComment = new Comment();
     $newComment->name = Input::get('name');
     $newComment->email = Input::get('email');
     $newComment->content = Input::get('content');
     $newComment->article_id = $id;
     $newComment->approved = 1;
     $blacklists = explode(',', Setting::find(8)->value);
     foreach ($blacklists as $blword) {
         if (false !== strpos($newComment->content, $blword)) {
             $newComment->approved = 0;
             break;
         }
     }
     $newComment->save();
     Input::flush();
     return Redirect::to($_SERVER['PATH_INFO'] . '#comment-' . $newComment->id);
 }
Exemplo n.º 13
0
 public function send_email($id)
 {
     $solicitacao = $this->getSolicitacao($id);
     App::import('Model', 'Setting');
     $settingModel = new Setting();
     $setting = $settingModel->find('first', array('fields' => 'email_contact'));
     $email_contact = empty($setting['Setting']['email_contact']) ? '' : $setting['Setting']['email_contact'];
     App::uses('CakeEmail', 'Network/Email');
     $Email = new CakeEmail();
     $Email->config('smtp');
     $Email->template('servicos', null);
     $Email->viewVars(array('solicitacao' => $solicitacao));
     $Email->to($email_contact);
     $Email->emailFormat('html');
     $Email->subject('Cartório NET - Solicitação de Serviço');
     /*#### DEBUG ####*/
     //        $Email->transport('Debug');
     //        $response = $Email->send();
     //
     //        echo $response['message'];
     //        die;
     /*#### END DEBUG ####*/
     $success = false;
     try {
         if ($Email->send()) {
             $success = true;
         } else {
             $success = false;
         }
     } catch (Exception $e) {
         //            pr($e);
         //            die;
         $success = false;
     }
     $this->id = $id;
     $this->saveField('email_send', $success);
     return $success;
 }
Exemplo n.º 14
0
 public function editSetting()
 {
     $setting = Setting::find(Input::get('id'));
     $setting->setting_value = Input::get('value');
     $setting->save();
     return Redirect::route('get.admin.settings');
 }
Exemplo n.º 15
0
 /**
  * Ugly and wrong, but thi will get the word when user open an app for a first time
  *
  * @param  $id user_id
  * @return Response
  */
 public function firstword($id)
 {
     $word = Setting::find(1)->word_id;
     return $this->respond($word);
 }
Exemplo n.º 16
0
 /**
  * Show the form for editing the specified setting.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $setting = Setting::find($id);
     return View::make('settings.edit', compact('setting'));
 }
Exemplo n.º 17
0
 public function topluSil()
 {
     $ayar = Input::get('id');
     foreach ($ayar as $id) {
         Setting::find($id)->delete();
     }
     return Redirect::back()->withInput()->with(array('basarili' => 'Seçilen Ayarlar başarı ile silindi.'));
 }
Exemplo n.º 18
0
 /**
  * Enter description here...
  */
 function getsetting($name = null)
 {
     if (!$name) {
         return false;
     }
     $objSetting = new Setting();
     $setting = $objSetting->find('first', array('conditions' => array('parent_id' => '<> 0', 'name' => $name)));
     if (empty($setting)) {
         $defaultGroup = $objSetting->find('first', array('conditions' => array('parent_id' => 0, 'name' => 'Global'), 'fields' => 'id'));
         if (empty($defaultGroup)) {
             $objSetting->create(array('parent_id' => 0, 'name' => 'Global'));
             $objSetting->save() or $this->logErr('cannot create default settings group');
             $gid = $objSetting->id;
         } else {
             $gid = $defaultGroup['Setting']['id'];
         }
         $objSetting->create(array('parent_id' => $gid, 'name' => $name));
         $objSetting->save();
         //or $this->logErr('cannot create a new setting');
     } else {
         return $setting['Setting']['value'];
     }
 }
Exemplo n.º 19
0
<?php

/*
|--------------------------------------------------------------------------
| Application & Route Filters
|--------------------------------------------------------------------------
|
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
App::before(function ($request) {
    $settings = Setting::find(1);
    if ($settings !== null && $settings->maintenance_mode && Auth::guest() && Request::path() != 'login') {
        return View::make('layouts.maintenance', compact('settings'));
    }
});
App::after(function ($request, $response) {
    //
});
/*
|--------------------------------------------------------------------------
| Authentication Filters
|--------------------------------------------------------------------------
|
| The following filters are used to verify that the user of the current
| session is logged into this application. The "basic" filter easily
| integrates HTTP Basic authentication for quick, simple checking.
|
*/
Exemplo n.º 20
0
 /**
  * Update settings method
  * 
  */
 protected function _updateSettings()
 {
     App::import('Model', 'Setting');
     $Setting = new Setting();
     // find all of the dynamic js files
     $jsFiles = $this->find('all', array('conditions' => array('WebpageJs.is_requested' => 0)));
     if (!empty($jsFiles)) {
         // write the settings using all js files in existence
         $data['Setting']['type'] = 'Webpages';
         $data['Setting']['name'] = 'DEFAULT_JS_FILENAMES';
         $data['Setting']['value'] = '';
         foreach ($jsFiles as $js) {
             if (!empty($js['WebpageJs']['webpage_id'])) {
                 $data['Setting']['value'] .= @$js['WebpageJs']['type'] . 'text/javascript[] = ' . $js['WebpageJs']['webpage_id'] . ',' . $js['WebpageJs']['name'] . PHP_EOL;
             } else {
                 $data['Setting']['value'] .= 'text/javascript[] = ' . $js['WebpageJs']['name'] . PHP_EOL;
             }
         }
         if ($Setting->add($data)) {
             return true;
         } else {
             return false;
         }
     } else {
         // if its empty then just delete the setting
         $setting = $Setting->find('first', array('conditions' => array('Setting.name' => 'DEFAULT_JS_FILENAMES')));
         if ($Setting->delete($setting['Setting']['id'])) {
             if ($Setting->writeSettingsIniData()) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
 }
Exemplo n.º 21
0
 public function postSettings()
 {
     $input = \Input::all();
     if (\Request::ajax()) {
         if ($_POST['action'] == "update") {
             array_forget($input, "action");
             $setting = \Setting::find($input['id']);
             foreach ($input as $key => $value) {
                 $setting->{$key} = $value;
             }
             if ($setting->update) {
                 echo "Setting Successfully Updated";
             }
         }
     }
 }
Exemplo n.º 22
0
 /**
  *
  * @param $action string
  * @param $id int
  * @return nothing
  * @author Tremor
  */
 public function settingAction($action, $id = 0)
 {
     if (isset($id) && !empty($id) && !is_numeric($id)) {
         return Redirect::to('admin/setting');
     }
     switch ($action) {
         case 'add':
             $setting = new Setting();
             $setting->save();
             $newId = $setting->id;
             return Redirect::to('admin/setting/' . $newId);
             break;
         case 'edit':
             $post = Input::except('_token');
             //                $affectedRows = Category::where('id', $categoryId)->update($post);
             $setting = Setting::find($id);
             foreach ($post as $key => $val) {
                 if (isset($setting->{$key})) {
                     $setting->{$key} = $val;
                 }
             }
             $setting->save();
             return Redirect::to('admin/setting/' . $id);
             break;
         case 'delete':
             $setting = Setting::find($id);
             $setting->delete();
             break;
         default:
             break;
     }
     return Redirect::to('admin/setting');
 }
Exemplo n.º 23
0
 /**
  * Sets application wide settings per request and loads them into the Configure component
  */
 function _fetchSettings()
 {
     App::import('Model', 'Setting');
     $settings = new Setting();
     $all_settings = $settings->find('all');
     foreach ($all_settings as $key => $value) {
         Configure::write('Pandion.' . $value['Setting']['key'], $value['Setting']);
     }
 }
Exemplo n.º 24
0
 public function simpan()
 {
     $validasi = Validator::make(Input::all(), Setting::$rules, Setting::$pesan);
     if ($validasi->fails()) {
         return Redirect::back()->withInput()->withErrors($validasi);
     } else {
         $cek = DB::table('setting')->count();
         if ($cek > 0) {
             $id = Input::get('id');
             $setting = Setting::find($id);
             $setting->nm_sekolah = Input::get('nama');
             $setting->npsn = Input::get('npsn');
             $setting->nss = Input::get('nss');
             $setting->alamat_sekolah = Input::get('alamat');
             $setting->kabupaten = Input::get('kabupaten');
             $setting->kecamatan = Input::get('kecamatan');
             $setting->status_sekolah = Input::get('status');
             $setting->status_mutu = Input::get('mutu');
             $setting->akreditasi = Input::get('akreditasi');
             $setting->telp_sekolah = Input::get('telp');
             $setting->fax_sekolah = Input::get('fax');
             $setting->nip_kepsek = Input::get('nip');
             $setting->dari_tahun = Input::get('mulai');
             $setting->sampai_tahun = Input::get('sampai');
             $setting->semester = Input::get('semester');
             if (Input::hasFile('logo')) {
                 $file = Input::file('logo');
                 $filename = str_random(5) . '-' . $file->getClientOriginalName();
                 $destinationPath = 'uploads/logo/';
                 $file->move($destinationPath, $filename);
                 if ($setting->logo_sekolah) {
                     $fotolama = $setting->logo_sekolah;
                     $filepath = public_path() . DIRECTORY_SEPARATOR . 'uploads/logo' . DIRECTORY_SEPARATOR . $setting->logo_sekolah;
                     try {
                         File::delete($filepath);
                     } catch (FileNotFoundException $e) {
                     }
                 }
                 $setting->logo_sekolah = $filename;
             }
             $setting->save();
             Session::flash('pesan', "<div class='alert alert-info'>\n\t\t\t\t\tData Berhasil diupdate</div>");
             return Redirect::back();
         } else {
             $setting->nm_sekolah = Input::get('nama');
             $setting->npsn = Input::get('npsn');
             $setting->nss = Input::get('nss');
             $setting->alamat_sekolah = Input::get('alamat');
             $setting->kabupaten = Input::get('kabupaten');
             $setting->kecamatan = Input::get('kecamatan');
             $setting->status_sekolah = Input::get('status');
             $setting->status_mutu = Input::get('mutu');
             $setting->akreditasi = Input::get('akreditasi');
             $setting->telp_sekolah = Input::get('telp');
             $setting->fax_sekolah = Input::get('fax');
             $setting->nip_kepsek = Input::get('nip');
             $setting->dari_tahun = Input::get('mulai');
             $setting->sampai_tahun = Input::get('sampai');
             $setting->semester = Input::get('semester');
             if (Input::hasFile('logo')) {
                 $file = Input::file('logo');
                 $filename = str_random(5) . '-' . $file->getClientOriginalName();
                 $destinationPath = 'uploads/logo/';
                 $file->move($destinationPath, $filename);
                 $setting->logo_sekolah = $filename;
             }
             $setting->save();
             Session::flash('pesan', "<div class='alert alert-info'>\n\t\t\t\t\tData Berhasil disimpan</div>");
             return Redirect::back();
         }
     }
 }