/**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     //CREATE ROLES TABLE
     Schema::create('roles', function ($table) {
         $table->increments('id');
         $table->string('name', 50);
         $table->integer('level');
     });
     //POPULATE ROLES TABLE
     $roles = Config::get('cms::settings.roles');
     foreach ($roles as $key => $value) {
         $role = new CmsRole();
         $role->name = $key;
         $role->level = $value;
         $role->save();
     }
 }
Ejemplo n.º 2
0
 public function get_edit($id)
 {
     //LOAD JS LIBS
     Asset::container('footer')->add('form', 'bundles/cms/js/jquery.form.js', 'jquery');
     Asset::container('footer')->add('users', 'bundles/cms/js/sections/users_edit.js', 'cms');
     $this->layout->header_data = array('title' => LL('cms::title.users_edit', CMSLANG));
     $this->layout->top_data = array('search' => false);
     //GET PAGE DATA
     $user = CmsUser::find($id);
     $this->layout->content = View::make('cms::interface.pages.user_new_edit')->with('title', LL('cms::title.users_edit', CMSLANG))->with('user_id', $id)->with('user_username', $user->username)->with('user_email', $user->email)->with('user_role', CmsRole::select_user_roles())->with('user_role_selected', $user->role_id)->with('user_lang', Config::get('cms::settings.interface'))->with('user_lang_selected', $user->lang)->with('user_is_valid', (bool) $user->is_valid);
 }
 public function get_edit($id)
 {
     //LOAD JS LIBS
     Asset::container('footer')->add('form', 'bundles/cms/js/jquery.form.js', 'jquery');
     Asset::container('footer')->add('users', 'bundles/cms/js/sections/users_edit.js', 'cms');
     $this->layout->header_data = array('title' => LL('cms::title.users_edit', CMSLANG));
     $this->layout->top_data = array('search' => false);
     //GET PAGE DATA
     $user = CmsUser::find($id);
     $has_details = !is_null($user->details);
     $this->layout->content = View::make('cms::interface.pages.user_new_edit')->with('title', LL('cms::title.users_edit', CMSLANG))->with('user_id', $id)->with('user_username', $user->username)->with('user_email', $user->email)->with('user_role', CmsRole::select_user_roles())->with('user_role_selected', $user->role_id)->with('user_lang', Config::get('cms::settings.interface'))->with('user_lang_selected', $user->lang)->with('user_editor', Config::get('cms::settings.editor'))->with('user_editor_selected', $user->editor)->with('user_is_valid', (bool) $user->is_valid)->with('detail_id', $has_details ? $user->details->id : '')->with('user_name', $has_details ? $user->details->name : '')->with('user_surname', $has_details ? $user->details->surname : '')->with('user_address', $has_details ? $user->details->address : '')->with('user_info', $has_details ? $user->details->info : '')->with('user_number', $has_details ? $user->details->number : '')->with('user_city', $has_details ? $user->details->city : '')->with('user_zip', $has_details ? $user->details->zip : '')->with('user_state', $has_details ? $user->details->state : '')->with('user_country', $has_details ? $user->details->country : '')->with('user_tel', $has_details ? $user->details->tel : '')->with('user_cel', $has_details ? $user->details->cel : '');
 }
 public function post_save_account()
 {
     $auth = Auth::check();
     if ($auth and is_numeric(AUTHORID)) {
         $input = Input::get();
         //GRAB DATA
         $user = new CmsUser();
         if (!empty($input['user_id'])) {
             $user = CmsUser::find($input['user_id']);
         }
         //VALIDATION CHECK
         $rules = array('user_username' => 'required|between:2,20|unique:users,username,' . $input['user_id'], 'user_email' => 'required|email|unique:users,email,' . $input['user_id'], 'user_role' => 'not_in:0');
         $messages = array('required' => LL('cms::validation.required', CMSLANG)->get(), 'between' => LL('cms::validation.between.string', CMSLANG)->get(), 'unique' => LL('cms::validation.unique', CMSLANG)->get(), 'email' => LL('cms::validation.email', CMSLANG)->get(), 'not_in' => LL('cms::validation.not_in', CMSLANG)->get());
         $validation = Validator::make($input, $rules, $messages);
         if ($validation->fails()) {
             return json_encode($validation->errors);
         }
         //VALIDATION OK
         $user->username = $input['user_username'];
         $user->email = $input['user_email'];
         $user->role_id = $input['user_role'];
         $user->lang = $input['user_lang'];
         $user->editor = $input['user_editor'];
         $user->is_valid = Input::has('is_valid') ? 1 : 0;
         //SET DEFAULT PASSWORD AS USERNAME
         if (empty($input['user_id'])) {
             $user->password = Hash::make($input['user_username']);
         }
         //UPDATE ROLE LEVEL IN USERS
         $user->role_level = CmsRole::get_role_level($input['user_role']);
         $user->save();
         $uid = $user->id;
         $response = 'success';
         $msg = LL('cms::ajax_resp.user_account_success', CMSLANG)->get();
         $backurl = $input['back_url'];
     } else {
         $rid = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.user_account_error', CMSLANG)->get();
         $backurl = '#';
     }
     $data = array('auth' => $auth, 'cls' => 'user_id', 'id' => $uid, 'response' => $response, 'message' => $msg, 'backurl' => $backurl);
     return json_encode($data);
 }
 /**
  * Make changes to the database.
  *
  * @return void
  */
 public function up()
 {
     //CREATE USERS TABLE
     Schema::create('users', function ($table) {
         $table->increments('id');
         $table->integer('role_id');
         $table->string('username', 20);
         $table->string('email', 100);
         $table->string('password', 64);
         $table->integer('role_level');
         $table->string('lang', 5);
         $table->boolean('is_valid');
         $table->timestamps();
     });
     //GET ADMIN ROLE
     $admin = CmsRole::where_level(Config::get('cms::settings.roles.admin'))->first();
     //POPULATE ADMIN USER
     $user = CmsUser::create(array('role_id' => $admin->id, 'username' => Config::get('cms::settings.admin_setup.login'), 'email' => Config::get('cms::settings.admin_setup.login'), 'password' => Hash::make(Config::get('cms::settings.admin_setup.password')), 'role_level' => Config::get('cms::settings.roles.admin'), 'lang' => Config::get('application.language'), 'is_valid' => 1));
 }
 public function post_delete()
 {
     if (Input::has('role_id')) {
         $rid = Input::get('role_id');
         $page = CmsPage::where_role_id($rid)->first();
         //CHECK IF ROLE STILL IN USE
         if (!empty($page)) {
             Notification::error(LL('cms::alert.delete_role_stillinuse_error', CMSLANG, array('page' => $page->name)), 2500);
             return Redirect::to_action('cms::role');
         } else {
             $role = CmsRole::find($rid);
             $role->delete();
             Notification::success(LL('cms::alert.delete_role_success', CMSLANG, array('role' => $role->name)), 1500);
             return Redirect::to_action('cms::role');
         }
     } else {
         Notification::error(LL('cms::alert.delete_role_error', CMSLANG), 1500);
         return Redirect::to_action('cms::page');
     }
 }
Ejemplo n.º 7
0
 public function post_save_role()
 {
     $auth = Auth::check();
     if ($auth) {
         $input = Input::get();
         //GRAB DATA
         $role = new CmsRole();
         if (!empty($input['role_id'])) {
             $role = CmsRole::find($input['role_id']);
         }
         //VALIDATION CHECK
         $rules = array('role_name' => 'required|between:2,20|unique:roles,name,' . $input['role_id'], 'role_level' => 'not_in:0');
         $messages = array('required' => LL('cms::validation.required', CMSLANG)->get(), 'between' => LL('cms::validation.between.string', CMSLANG)->get(), 'unique' => LL('cms::validation.unique', CMSLANG)->get(), 'not_in' => LL('cms::validation.not_in', CMSLANG)->get());
         $validation = Validator::make($input, $rules, $messages);
         if ($validation->fails()) {
             return json_encode($validation->errors);
         }
         //VALIDATION OK
         $role->name = $input['role_name'];
         $role->level = $input['role_level'];
         $role->save();
         $rid = $role->id;
         //UPDATE ROLE LEVEL IN PAGE
         CmsPage::update_role_level($rid, $input['role_level']);
         $response = 'success';
         $msg = LL('cms::ajax_resp.role_save_success', CMSLANG)->get();
         $backurl = $input['back_url'];
     } else {
         $rid = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.role_save_error', CMSLANG)->get();
         $backurl = '#';
     }
     $data = array('auth' => $auth, 'cls' => 'role_id', 'id' => $rid, 'response' => $response, 'message' => $msg, 'backurl' => $backurl);
     return json_encode($data);
 }
Ejemplo n.º 8
0
 public function get_edit($id)
 {
     //LOAD JS LIBS
     Asset::container('footer')->add('form', 'bundles/cms/js/jquery.form.js', 'jquery');
     Asset::container('footer')->add('count', 'bundles/cms/js/jquery.charcount.js', 'jquery');
     Asset::container('footer')->add('elastic', 'bundles/cms/js/jquery.elastic.js', 'jquery');
     Asset::container('footer')->add('slug', 'bundles/cms/js/jquery.stringtoslug.js', 'jquery');
     Asset::container('footer')->add('ckcms', 'bundles/cms/js/ck.cms.js', 'jqadapter');
     //CKEDITOR
     if (IS('cms::settings.wysiwyg', 'ckeditor')) {
         Asset::container('footer')->add('ckeditor', 'bundles/cms/ckeditor/ckeditor.js', 'form');
         Asset::container('footer')->add('jqadapter', 'bundles/cms/ckeditor/adapters/jquery.js', 'form');
         Asset::container('footer')->add('ckcms', 'bundles/cms/js/ck.cms.js', 'jqadapter');
     }
     //MARKITUP
     if (IS('cms::settings.wysiwyg', 'markitup')) {
         Asset::container('footer')->add('markitup', 'bundles/cms/markitup/jquery.markitup.js', 'form');
         Asset::container('footer')->add('sethtml', 'bundles/cms/markitup/sets/html/set.js', 'markitup');
         Asset::container('footer')->add('ckcms', 'bundles/cms/js/ck.cms.js', 'jqadapter');
         Asset::container('header')->add('csshtml', 'bundles/cms/markitup/sets/html/style.css');
         Asset::container('header')->add('cssmarkitup', 'bundles/cms/markitup/skins/markitup/style.css');
     }
     //PLUPLOAD
     Asset::container('footer')->add('plupload', 'bundles/cms/js/plupload.js', 'jquery');
     Asset::container('footer')->add('plupload_html4', 'bundles/cms/js/plupload.html4.js', 'plupload');
     Asset::container('footer')->add('plupload_html5', 'bundles/cms/js/plupload.html5.js', 'plupload');
     //LOAD FANCYBOX LIBS
     Asset::container('header')->add('fancyboxcss', 'bundles/cms/css/fancybox.css', 'main');
     Asset::container('footer')->add('fancybox', 'bundles/cms/js/jquery.fancybox.js', 'jquery');
     //LOAD AUTOSUGGEST LIBS
     Asset::container('header')->add('autosuggestcss', 'bundles/cms/css/autosuggest.css', 'main');
     Asset::container('footer')->add('autosuggest', 'bundles/cms/js/jquery.autosuggest.js', 'jquery');
     //DATETIME PICKER
     Asset::container('header')->add('jqueryuicss', 'bundles/cms/css/jquery.ui.css', 'main');
     if (LANG !== 'en') {
         Asset::container('footer')->add('local', 'bundles/cms/js/i18n/jquery.ui.datepicker-' . LANG . '.js', 'jquery');
     }
     Asset::container('footer')->add('datepicker', 'bundles/cms/js/jquery.datepicker.js', 'local');
     Asset::container('footer')->add('timepicker', 'bundles/cms/js/jquery.timepicker.js', 'datepicker');
     //SORTING
     Asset::container('footer')->add('sortable', 'bundles/cms/js/jquery.sortable.js', 'jquery');
     Asset::container('footer')->add('serialize', 'bundles/cms/js/jquery.serializetree.js', 'sortable');
     Asset::container('footer')->add('pages', 'bundles/cms/js/sections/blogs_edit.js', 'cms');
     $this->layout->header_data = array('title' => LL('cms::title.blog_edit', CMSLANG));
     $this->layout->top_data = array('search' => false);
     if (!empty($id)) {
         //GET BLOG DATA
         $blog = CmsBlog::with(array('pages', 'blogrels'))->find($id);
         $pivot = DB::table('blogs_pages')->where_cmsblog_id($id)->where_is_default(1)->first();
         //FILES OF PAGE
         $files = CmsPage::find($pivot->cmspage_id)->files;
         if (!empty($blog)) {
             //GET EXTRA ID
             $extra_ids = Config::get('cms::settings.extra_id');
             //GET PAGE DATA
             $pagedata = CmsPage::where_lang($blog->lang)->where_parent_id(0)->where_extra_id(array_search('blogs', $extra_ids))->order_by('lang', 'asc')->order_by('is_home', 'desc')->order_by('order_id', 'asc')->get();
             $new_data = array();
             foreach ($pagedata as $obj) {
                 $new_data[$obj->id] = $obj;
                 $recursive = call_user_func_array('CmsPage::recursive_pages', array($obj->id));
                 $new_data = $new_data + $recursive;
             }
             //GET BLOG DATA
             $blogdata = CmsBlog::where_lang($blog->lang)->where('id', '<>', $id)->where_is_valid(1)->order_by('datetime_on', 'desc')->order_by('name', 'desc')->paginate(Config::get('cms::settings.pag'));
             if (empty($new_data)) {
                 $new_data = array();
             }
             $this->layout->content = View::make('cms::interface.pages.blog_new_edit')->with('role_fail', CmsRole::role_fail($pivot->cmspage_id))->with('title', LL('cms::title.blog_edit', CMSLANG))->with('blog_id', $id)->with('page_id', $pivot->cmspage_id)->with('blog_lang', $blog->lang)->with('blog_name', $blog->name)->with('blog_parent', CmsPage::select_page_slug($blog->lang, array_search('blogs', $extra_ids)))->with('blog_parent_selected', $pivot->cmspage_id)->with('blog_slug', substr($blog->slug, 1))->with('blog_parent_slug', CmsPage::get_page_slug($pivot->cmspage_id) . '/')->with('blog_zones', CmsElement::select_zone($pivot->cmspage_id))->with('blog_zone_selected', $blog->zone)->with('blog_is_valid', (bool) $blog->is_valid)->with('blog_date_on', $blog->get_datetime_on())->with('blog_date_off', $blog->get_datetime_off())->with('blog_title', $blog->title)->with('blog_preview', $blog->preview)->with('blog_text', $blog->text)->with('blog_keyw', $blog->keyw)->with('blog_descr', $blog->descr)->with('blog_tags', '')->with('files', $files)->with('pagedata', $new_data)->with('pagerels', $blog->pages)->with('blogdata', $blogdata)->with('blogrels', $blog->blogrels);
         }
     }
 }
Ejemplo n.º 9
0
 public function get_edit_element($page_id, $element_id)
 {
     //LOAD JS LIBS
     Asset::container('footer')->add('form', 'bundles/cms/js/jquery.form.js', 'jquery');
     Asset::container('footer')->add('count', 'bundles/cms/js/jquery.charcount.js', 'jquery');
     Asset::container('footer')->add('slug', 'bundles/cms/js/jquery.stringtoslug.js', 'jquery');
     //CKEDITOR
     if (IS('cms::settings.wysiwyg', 'ckeditor')) {
         Asset::container('footer')->add('ckeditor', 'bundles/cms/ckeditor/ckeditor.js', 'form');
         Asset::container('footer')->add('jqadapter', 'bundles/cms/ckeditor/adapters/jquery.js', 'form');
         Asset::container('footer')->add('ckcms', 'bundles/cms/js/ck.cms.js', 'jqadapter');
     }
     //MARKITUP
     if (IS('cms::settings.wysiwyg', 'markitup')) {
         Asset::container('footer')->add('markitup', 'bundles/cms/markitup/jquery.markitup.js', 'form');
         Asset::container('footer')->add('sethtml', 'bundles/cms/markitup/sets/html/set.js', 'markitup');
         Asset::container('footer')->add('ckcms', 'bundles/cms/js/ck.cms.js', 'jqadapter');
         Asset::container('header')->add('csshtml', 'bundles/cms/markitup/sets/html/style.css');
         Asset::container('header')->add('cssmarkitup', 'bundles/cms/markitup/skins/markitup/style.css');
     }
     //PLUPLOAD
     Asset::container('footer')->add('plupload', 'bundles/cms/js/plupload.js', 'jquery');
     Asset::container('footer')->add('plupload_html4', 'bundles/cms/js/plupload.html4.js', 'plupload');
     Asset::container('footer')->add('plupload_html5', 'bundles/cms/js/plupload.html5.js', 'plupload');
     //LOAD FANCYBOX LIBS
     Asset::container('header')->add('fancyboxcss', 'bundles/cms/css/fancybox.css', 'main');
     Asset::container('footer')->add('fancybox', 'bundles/cms/js/jquery.fancybox.js', 'jquery');
     //SORTING
     Asset::container('footer')->add('sortable', 'bundles/cms/js/jquery.sortable.js', 'jquery');
     Asset::container('footer')->add('serialize', 'bundles/cms/js/jquery.serializetree.js', 'sortable');
     Asset::container('footer')->add('elements', 'bundles/cms/js/sections/elements_edit.js', 'cms');
     $this->layout->header_data = array('title' => LL('cms::title.element_edit', CMSLANG));
     $this->layout->top_data = array('search' => false);
     if (!empty($element_id)) {
         //GET ELEMENT DATA
         $element = CmsElement::find($element_id);
         if (!empty($element)) {
             //GET PAGE DATA
             $page = CmsPage::find($page_id);
             //GET ELEMENTS DATA
             $elements = $page->elements;
             //GET FILE DATA
             $files = $page->files;
             // LOAD LAYOUT PREVIEW
             $preview_layout = CmsPage::preview_layout_create($page->layout);
             $this->layout->content = View::make('cms::interface.pages.element_new_edit')->with('role_fail', CmsRole::role_fail($page_id))->with('title', LL('cms::title.element_edit', CMSLANG))->with('page_id', $page_id)->with('element_id', $element_id)->with('element_name', $element->name)->with('element_label', $element->label)->with('element_text', $element->text)->with('element_zones', CmsElement::select_zone($page_id))->with('element_zone_selected', $element->zone)->with('element_is_valid', (bool) $element->is_valid)->with('elements', $elements)->with('media', $files)->with('page_header_selected', $page->header)->with('page_footer_selected', $page->footer)->with('page_layout_preview', $preview_layout);
         } else {
             $this->layout->content = View::make('cms::interface.pages.not_found')->with('message', LL('cms::alert.not_found', CMSLANG));
         }
     } else {
         $this->layout->content = View::make('cms::interface.pages.not_found')->with('message', LL('cms::alert.not_found', CMSLANG));
     }
 }
 public function post_save_tags()
 {
     $auth = Auth::check();
     if ($auth and is_numeric(AUTHORID)) {
         $input = Input::get();
         //GRAB DATA
         $blog = new CmsBlog();
         if (!empty($input['blog_id'])) {
             $blog = CmsBlog::find($input['blog_id']);
             //CHECK OWNERSHIP
             if (CmsRole::role_fail($input['page_id'])) {
                 $msg = array('noaccess' => LL('cms::ajax_resp.ownership_error', CMSLANG)->get());
                 return json_encode($msg);
             }
         }
         $bid = Input::get('blog_id');
         $pid = Input::get('page_id');
         if (Input::get('as_values_tags_id') !== '') {
             $tags = substr(Input::get('as_values_tags_id'), 0, -1);
             if (substr($tags, 0, 1) == ',') {
                 $tags = substr($tags, 1);
             }
             $rels = explode(',', $tags);
             if (is_array($rels)) {
                 $blog->tags()->sync($rels);
             }
             $response = 'success';
             $msg = LL('cms::ajax_resp.blog_tags_success', CMSLANG)->get();
             $backurl = $input['back_url'];
         } else {
             $response = 'success';
             $msg = LL('cms::ajax_resp.blog_tags_success', CMSLANG)->get();
             $backurl = $input['back_url'];
         }
     } else {
         $bid = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.blog_tags_error', CMSLANG)->get();
         $backurl = '#';
     }
     $data = array('auth' => $auth, 'cls' => 'blog_id', 'id' => $bid, 'pageid' => $pid, 'response' => $response, 'message' => $msg, 'backurl' => $backurl);
     return json_encode($data);
 }
 public function action_search_role()
 {
     $auth = Auth::check();
     if ($auth and is_numeric(AUTHORID)) {
         //LOAD JS LIBS
         Asset::container('footer')->add('pages', 'bundles/cms/js/sections/roles_list.js', 'cms');
         if (Input::has('q')) {
             $q = Input::get('q');
             $this->layout->header_data = array('title' => $q);
             $this->layout->top_data = array('search' => '/cms/role/search', 'q' => $q);
             //GET PAGE DATA
             $data = CmsRole::where('name', 'LIKE', '%' . $q . '%')->or_where('level', 'LIKE', '%' . $q . '%')->order_by('name', 'asc')->order_by('level', 'asc')->get();
             $this->layout->content = View::make('cms::interface.pages.role_list')->with('data', $data);
         } else {
             $this->layout->header_data = array('title' => LL('cms::title.roles', CMSLANG));
             $this->layout->top_data = array('search' => '/cms/role/search', 'q' => '');
             //GET ALL PAGE DATA
             $data = CmsRole::order_by('level', 'desc')->get();
             $this->layout->content = View::make('cms::interface.pages.role_list')->with('data', $data);
         }
     }
 }
Ejemplo n.º 12
0
 public function post_save_element_text()
 {
     $auth = Auth::check();
     if ($auth) {
         $input = Input::get();
         //OWNERSHIP
         if (!empty($input['page_id'])) {
             //CHECK OWNERSHIP
             if (CmsRole::role_fail($input['page_id'])) {
                 $msg = array('noaccess' => LL('cms::ajax_resp.ownership_error', CMSLANG)->get());
                 return json_encode($msg);
             }
         }
         $element = new CmsElement();
         if (!empty($input['element_id'])) {
             $element = CmsElement::find($input['element_id']);
         }
         $element->author_id = AUTHORID;
         $element->text = $input['element_text'];
         $element->lang = LANG;
         $element->save();
         $eid = $element->id;
         $page_id = $input['page_id'];
         $page = CmsPage::find($page_id);
         //IF NEW ADD TO PIVOT TABLE
         if (empty($input['element_id'])) {
             $page->elements()->attach($eid);
         }
         $response = 'success';
         $msg = LL('cms::ajax_resp.element_success', CMSLANG)->get();
         $backurl = $input['back_url'];
     } else {
         $eid = null;
         $page_id = null;
         $response = 'error';
         $msg = LL('cms::ajax_resp.element_error', CMSLANG)->get();
         $backurl = '#';
     }
     $data = array('auth' => $auth, 'cls' => 'element_id', 'id' => $eid, 'pageid' => $page_id, 'response' => $response, 'message' => $msg, 'backurl' => $backurl);
     return json_encode($data);
 }