/** * Logs one user on the admin panel * */ public function login() { $default_admin_lang = Settings::get_default_admin_lang(); // TODO : // - Replace by : config_item('uri_lang_code'); // - Remove / Rewrite Settings::get_uri_lang() $uri_lang = Settings::get_uri_lang(); // If the user is already logged and if he is in the correct minimum group, go to Admin if (User()->logged_in() && Authority::can('access', 'admin')) { redirect(base_url() . $uri_lang . '/' . config_item('admin_url')); } if (User()->logged_in() && !Authority::can('access', 'admin')) { redirect(base_url()); } if (!empty($_POST)) { unset($_POST['submit']); if ($this->_try_validate_login()) { // User can log with email OR username if (strpos($_POST['username'], '@') !== FALSE) { $email = $_POST['username']; unset($_POST['username']); $_POST['email'] = $email; } try { User()->login($_POST); redirect(base_url() . $uri_lang . '/' . config_item('admin_url') . '/auth/login'); } catch (Exception $e) { $this->login_errors = $e->getMessage(); } } else { $this->login_errors = lang('ionize_login_error'); } } else { if ($this->is_xhr()) { $html = ' <script type="text/javascript"> var url = "' . config_item('admin_url') . '"; top.location.href = url; </script>'; echo $html; exit; /* // Save options : as callback $this->callback[] = array( 'fn' => 'ION.reload', 'args' => array('url'=> config_item('admin_url')) ); $this->response(); */ } else { if (!in_array($uri_lang, Settings::get('displayed_admin_languages')) or $uri_lang != $default_admin_lang) { redirect(base_url() . $default_admin_lang . '/' . config_item('admin_url') . '/auth/login'); } } } $this->output('auth/login'); }
/** * Tree init. * Displays the tree view, which will call each menu tree builder * */ public function index() { // TODO : Limit the number of displayed articles in the tree // $nb_elements = $this->page_model->count_all() + $this->article_model->count_all(); if (Authority::can('access', 'admin/tree')) { // Menus : All menus $menus = $this->menu_model->get_list(array('order_by' => 'ordering ASC')); $this->template['menus'] = $menus; $this->output('tree/tree'); } }
/** * Update one menu * */ public function update() { $id = $this->input->post('id_menu'); if ($id) { $this->menu_model->update($id, $this->input->post()); if (Authority::can('access', 'admin/menu/permissions/backend')) { $resource = 'backend/menu/' . $id; $this->rule_model->save_element_roles_rules($resource, $this->input->post('backend_rule')); } } // UI update panels $this->_update_panels(); $this->success(lang('ionize_message_menu_updated')); }
/** * @param FTL_Binding $tag * * @return string */ public static function tag_authority_can(FTL_Binding $tag) { $action = $tag->getAttribute('action'); $resource = $tag->getAttribute('resource'); if (empty($action) && empty($resource)) { return self::show_tag_error($tag, 'Feed the "action" and "resource" attributes'); } if (Authority::can($action, $resource)) { return $tag->expand(); } else { // Else self::$trigger_else++; } return ''; }
/** * Constructor * */ public function __construct() { parent::__construct(); // Check the database settings if ($this->test_database_config() === FALSE) { redirect(base_url() . 'install/'); die; } $this->load->database(); if (!$this->db->db_select()) { $error =& load_class('Exceptions', 'core'); echo $error->show_error('Database Error', 'Unable to connect to the specified database : ' . $this->db->database, 'error_db'); exit; } // Models $this->load->model(array('base_model', 'settings_model'), '', TRUE); // Helpers $this->load->helper('file'); $this->load->helper('trace'); // Get all the website languages from DB and store them into config file "languages" key $languages = $this->settings_model->get_languages(); Settings::set_languages($languages); // Settings : google analytics string, filemanager, etc. // Each setting is accessible through Settings::get('setting_name'); Settings::set_settings_from_list($this->settings_model->get_settings(), 'name', 'content'); Settings::set_settings_from_list($this->settings_model->get_lang_settings(config_item('detected_lang_code')), 'name', 'content'); if (Authority::can('access', 'admin') && Settings::get('display_front_offline_content') == 1) { Settings::set_all_languages_online(); } // Try to find the installer class : No access if install folder is already there $installer = glob(BASEPATH . '../*/class/installer' . EXT); // If installer class is already here, avoid site access if (!empty($installer)) { // Get languages codes from available languages folder/translation file $languages = $this->settings_model->get_admin_langs(); if (!in_array(config_item('detected_lang_code'), $languages)) { $this->config->set_item('detected_lang_code', config_item('default_admin_lang')); } $this->lang->load('admin', config_item('detected_lang_code')); Theme::set_theme('admin'); // Set the view to output $this->output('system/delete_installer'); // Display the view directly $this->output->_display(); // Don't do anything more die; } }
e.stop(); ION.contentUpdate({ 'element': $('mainPanel'), 'loadMethod': 'xhr', 'url': admin_url + 'article/create/' + id, 'title': Lang.get('ionize_title_create_article') }); }); <?php } ?> } // Options column switcher ION.initSideColumn('sideColumnSwitcher'); <?php if (Authority::can('edit', 'admin/page')) { ?> // Save with CTRL+s ION.addFormSaveEvent('pageFormSubmit'); <?php } ?> </script>
?> <?php if (Authority::can('access', 'admin/settings/website')) { ?> <li class="divider"><a class="navlink" href="setting" title="<?php echo lang('ionize_menu_site_settings'); ?> "><?php echo lang('ionize_menu_site_settings'); ?> </a></li> <?php } ?> <?php if (Authority::can('access', 'admin/settings/technical')) { ?> <li><a class="navlink" href="setting/technical" title="<?php echo lang('ionize_menu_site_settings_technical'); ?> "><?php echo lang('ionize_menu_site_settings_technical'); ?> </a></li> <?php } ?> </ul> </li> <?php }
/** * Languages tag * * @param FTL_Binding * * @return null|string * * @usage <ion:languages [helper="helper:helper_method"]> * ... * <ion:languages> * */ public static function tag_languages(FTL_Binding $tag) { $languages = Authority::can('access', 'admin') && Settings::get('display_front_offline_content') == 1 ? Settings::get_languages() : Settings::get_online_languages(); $page = self::registry('page'); $article = self::registry('article'); // Current active language class $active_class = $tag->getAttribute('active_class', 'active'); // Ignore current language in output $ignore_current = $tag->getAttribute('ignore_current'); // helper $helper = $tag->getAttribute('helper'); $str = ''; $tag->set('count', count($languages)); foreach ($languages as $idx => &$lang) { $lang_code = $lang['lang']; $p_data = $page['languages'][$lang_code]; if ($ignore_current == TRUE && $lang_code == Settings::get_lang('current')) { continue; } // Correct the Home page URL if ($p_data['online'] == 1 or $p_data['online'] == 0 && Authority::can('access', 'admin') && Settings::get('display_front_offline_content') == 1) { if ($page['home'] != 1) { $lang['absolute_url'] = !empty($page['absolute_urls'][$lang_code]) ? $page['absolute_urls'][$lang_code] : base_url() . $lang_code; } else { $lang['absolute_url'] = base_url() . $lang_code; } } else { $lang['absolute_url'] = NULL; } $lang['active_class'] = $lang_code == Settings::get_lang('current') ? $active_class : ''; $lang['is_active'] = $lang_code == Settings::get_lang('current'); $lang['id'] = $lang_code; if (!is_null($article)) { $a_data = $article['languages'][$lang_code]; if (!is_null($a_data['url']) && $a_data['online'] == 1 or $a_data['online'] == 0 && Authority::can('access', 'admin') && Settings::get('display_front_offline_content') == 1) { if ($page['home'] != 1) { $lang['absolute_url'] .= '/' . $a_data['url']; } else { $lang['absolute_url'] .= '/' . $page['urls'][$lang_code] . '/' . $a_data['url']; } } else { $lang['absolute_url'] = NULL; } } // Tag locals $tag->set('language', $lang); $tag->set('id', $lang_code); $tag->set('absolute_url', $lang['absolute_url']); $tag->set('active_class', $lang['active_class']); $tag->set('is_active', $lang['is_active']); $tag->set('index', $idx); if (!is_null($lang['absolute_url'])) { $str .= $tag->expand(); } } // Try to return the helper function result if ($str != '' && !is_null($helper)) { $helper_function = substr(strrchr($helper, ':'), 1) ? substr(strrchr($helper, ':'), 1) : 'get_language_navigation'; $helper = strpos($helper, ':') !== FALSE ? substr($helper, 0, strpos($helper, ':')) : $helper; self::$ci->load->helper($helper); if (function_exists($helper_function)) { $nav = call_user_func($helper_function, $languages); return self::wrap($tag, $nav); } } return self::wrap($tag, $str); }
"> <p class="lite"><?php echo lang('ionize_help_notify_user_account_updated'); ?> </p> <textarea name="message" class="autogrow"></textarea> </div> </form> <div class="buttons"> <?php if (Authority::can('edit', 'admin/user')) { ?> <button id="bSaveuser<?php echo $user['id_user']; ?> " type="button" class="button yes right"><?php echo lang('ionize_button_save_close'); ?> </button> <?php } ?> <button id="bCanceluser<?php echo $user['id_user']; ?> " type="button" class="button no right"><?php
</ul> <script type="text/javascript"> /** * Types list itemManager * */ typesManager = new ION.ItemManager({ element: 'article_type', container: 'article_typeList' }); typesManager.makeSortable(); <?php if (Authority::can('edit', 'admin/article/type')) { ?> // Type editable $$('#article_typeList .title').each(function(item, idx) { var id = item.getProperty('data-id'); item.addEvent('click', function(e){ ION.formWindow('article_type' + id, 'article_typeForm' + id, Lang.get('ionize_title_type_edit'), 'article_type/edit/' + id); }); }); <?php } ?> </script>
"> <?php foreach ($fields as $field) { ?> <li class="sortme element_field" data-id="<?php echo $field['id_extend_field']; ?> " id="element_field<?php echo $field['id_extend_field']; ?> "> <span class="icon left drag"></span> <?php if (Authority::can('edit', 'admin/element')) { ?> <a class="icon delete right" data-id="<?php echo $field['id_extend_field']; ?> "></a> <?php } ?> <span class="lite right mr10" data-id="<?php echo $field['id_extend_field']; ?> "> <?php echo $field['type_name'];
<?php if (Authority::can('create', 'admin/article/type')) { ?> <div class="divider"> <a class="button light" id="newTypeToolbarButton"> <i class="icon-plus"></i><?php echo lang('ionize_label_new_type'); ?> </a> </div> <div class="toolbox"></div> <script type="text/javascript"> /** * New type button * */ $('newTypeToolbarButton').addEvent('click', function(e) { ION.formWindow( 'article_type', 'article_typeForm', Lang.get('ionize_label_new_type'), 'article_type/get_form' ); });
echo lang('ionize_help_denied_action_404'); ?> "><?php echo lang('ionize_label_denied_action_404'); ?> </a></label> </dd> </dl> </div> <?php } ?> <?php if (Authority::can('access', 'admin/article/permissions/backend')) { ?> <?php if (!empty($backend_roles_resources)) { ?> <dl class="x-small"> <dt><label><?php echo lang('ionize_label_backend'); ?> </label></dt> <dd> <?php foreach ($backend_roles_resources as $id_role => $role_resources) { ?> <div id="roleRulesContainer<?php
</td> <td><a><?php echo $role['role_code']; ?> </a></td> <td><?php echo $role['role_name']; ?> </td> <td><?php echo $role['role_description']; ?> </td> <td> <?php if (Authority::can('delete', 'admin/role')) { ?> <a data-id="<?php echo $role['id_role']; ?> " class="icon delete"></a> <?php } ?> </td> </tr> <?php } ?>
<?php if (Authority::can('create', 'admin/extend')) { ?> <div class="divider"> <a id="btnAddExtendField" class="button light"> <i class="icon-plus"></i> <?php echo lang('ionize_title_extend_field_new'); ?> </a> </div> <script type="text/javascript"> $('btnAddExtendField').addEvent('click', function(e) { // Does not limit to one parent ION.formWindow( 'extendfield', 'extendfieldForm', 'ionize_title_extend_field_new', 'extend_field/edit', { width:450, height:380 } ); });
echo $id; ?> " id="title_<?php echo $id; ?> " class="inputtext" type="text" value="<?php echo $title; ?> "/> </dd> </dl> <?php if (Authority::can('access', 'admin/menu/permissions/backend')) { ?> <?php if (!empty($menu['backend_roles_resources'])) { ?> <dl class="small"> <dt><label><?php echo lang('ionize_label_can_see_backend'); ?> </label></dt> <dd> <?php foreach ($menu['backend_roles_resources'] as $id_role => $role_resources) { ?>
/** * Deletes one article * * @param int $id_article */ public function delete($id_article) { if (!Authority::can('delete', 'admin/article')) { $this->error(lang('permission_denied')); } $affected_rows = $this->article_model->delete($id_article); // Delete was successful if ($affected_rows > 0) { // Clear the cache Cache()->clear_cache(); // Clean URL table $this->url_model->clean_table(); // Remove deleted article from DOM $this->callback[] = array('fn' => 'ION.deleteDomElements', 'args' => array('.article' . $id_article)); // If the current edited article is deleted if ($this->input->post('redirect')) { $this->callback[] = array('fn' => 'ION.updateElement', 'args' => array('element' => 'mainPanel', 'url' => 'dashboard')); } $this->success(lang('ionize_message_operation_ok')); } else { $this->error(lang('ionize_message_operation_nok')); } }
{'key':'title', 'as':'title'}, {'key':'description', 'as':'description'}, {'key':'actions', 'as':'actions'} ], 'rules' : <?php echo $json_rules; ?> } ); <?php } ?> <?php if (Authority::can('access', 'admin/modules/permissions')) { ?> <?php // log_message('error', print_r(json_decode($json_modules_resources), true)); ?> var modRules = new ION.PermissionTree( 'modulesRulesContainer', <?php echo $json_modules_resources; ?> , { 'key': 'id_resource', 'data': [
/** * Saves page ordering * */ public function save_ordering() { if (!Authority::can('edit', 'admin/page')) { $this->error(lang('permission_denied')); } $order = $this->input->post('order'); if ($order !== FALSE) { // Clear the cache Cache()->clear_cache(); // Saves the new ordering $this->page_model->save_ordering($order); // Answer sent $this->success(lang('ionize_message_page_ordered')); } else { $this->error(lang('ionize_message_operation_nok')); } }
], 'rules' : <?php echo json_encode($role_resources['rules'], true); ?> } ); <?php } ?> <?php } ?> <?php if (Authority::can('access', 'admin/page/permissions/frontend')) { ?> <?php foreach ($frontend_roles_resources as $id_role => $role_resources) { ?> var modRules<?php echo $id_role; ?> = new ION.PermissionTree( 'roleRulesContainer<?php echo $id_role; ?> ', <?php echo json_encode($role_resources['resources'], true);
<p class="icons"> <?php if (Authority::can('unlink', 'admin/' . $parent . '/media')) { ?> <a class="icon unlink right help" data-id="<?php echo $media['id_media']; ?> " title="<?php echo lang('ionize_label_detach_media'); ?> "></a> <?php } ?> <?php if (Authority::can('edit', 'admin/' . $parent . '/media')) { ?> <a class="icon edit left mr5" data-id="<?php echo $media['id_media']; ?> " data-title="<?php echo $title; ?> " title="<?php echo lang('ionize_label_edit'); ?> "></a> <?php } ?> <?php
public static function get_base_url() { if (Authority::can('access', 'admin') && Settings::get('display_front_offline_content') == 1) { Settings::set_all_languages_online(); } if (count(Settings::get_online_languages()) > 1) { return base_url() . Settings::get_lang() . '/'; } return base_url(); }
mediaManager.toggleFileManager(); }); // Init the staticItemManager staticItemManager.init({ 'parent': 'article', 'id_parent': id_article, 'parentListContainer': 'articleTab' }); // Get Static Items staticItemManager.getParentItemList(); // Add video button <?php if (Authority::can('link', 'admin/page/media')) { ?> $('btnAddVideoUrl').addEvent('click', function() { ION.dataWindow( 'addExternalMedia', 'ionize_label_add_video', 'media/add_external_media_window', {width:600, height:150}, { 'parent': 'article', 'id_parent': id_article } ) });
{ ION.formWindow( 'user', // Window ID 'userForm', // Form ID 'ionize_title_add_user', // Window title 'user/create', // Window content URL {width: 400, resize:true} // Window options ); }); <?php } ?> <?php if (Authority::can('create', 'admin/role')) { ?> // New Role $('newRoleToolbarButton').addEvent('click', function(e) { ION.formWindow( 'role', 'roleForm', 'ionize_title_add_role', 'role/create', {width: 420, resize:true} ); }); <?php
/** * Returns one definition fields list * * */ function get_field_list() { $fields = array(); if (Authority::can('edit', 'admin/item/definition')) { $id_definition = $this->input->post('id_item_definition'); $fields = $this->extend_field_model->get_lang_list(array('parent' => 'item', 'id_parent' => $id_definition), Settings::get_lang('default')); } // $this->template['id_item_definition'] = $id_definition; $this->template['fields'] = $fields; $this->output('item/definition/fields'); }
<?php // Check the current user is allowed to create a resource of this type if (Authority::can('create', $resource)) { // If an array of route parameters is specified use it, otherwise set to null $parameters = isset($parameters) && is_array($parameters) ? $parameters : null; // Set defaults for any options not specified $options = ['url' => URL::route($resource . '.create', $parameters), 'text' => !isset($text) ? '' : $text, 'icon' => !isset($icon) ? 'file' : $icon, 'size' => !isset($size) ? 'small' : $size, 'type' => !isset($type) ? 'normal' : $type, 'hover' => !isset($hover) ? 'Create a new ' . trans('resources.' . $resource) : $hover]; echo View::make('buttons.url', $options); }
/** * Returns the Home URL * * @return string * */ public static function get_home_url() { // Set all languages online if connected as editor or more if (Authority::can('access', 'admin') && Settings::get('display_front_offline_content') == 1) { Settings::set_all_languages_online(); } if (count(Settings::get_online_languages()) > 1) { // if the current lang is the default one : don't return the lang code if (Settings::get_lang() != Settings::get_lang('default')) { return base_url() . Settings::get_lang() . '/'; } } return base_url(); }
<?php if (Authority::can('access', 'admin/users_roles')) { ?> <div class="desktopIcon" data-url="user" data-title="ionize_title_users"> <i class="users"></i> <p><a><?php echo lang('ionize_dashboard_icon_users'); ?> </a></p> </div> <?php } ?> <?php if (Authority::can('access', 'admin/tools/google_analytics')) { ?> <div class="desktopIcon" id="iconGA" data-url="http://www.google.com/analytics/" data-external="true"> <i class="stats"></i> <p><a><?php echo lang('ionize_dashboard_icon_google_analytics'); ?> </a></p> </div> <?php } ?> </div> <?php } ?>
/** * Switch the publish filter off * */ public function unlock_publish_filter() { $uri_string_to_array = explode('/', preg_replace("|^\\/?|", '/', self::$ci->uri->uri_string)); if (!in_array(config_item('admin_url'), $uri_string_to_array)) { // Settings::get('display_front_offline_content') not available here $this->{$this->db_group}->where('name', 'display_front_offline_content'); $query = $this->{$this->db_group}->get('setting'); $result = $query->row_array(); if (Authority::can('access', 'admin') && (!empty($result['content']) && $result['content'] == '1')) { self::$publish_filter = FALSE; } } else { self::$publish_filter = FALSE; } }
<?php // Check the current user is allowed to update this particular item (pass the Model object) if (Authority::can('update', $resource, $item)) { // If an array of parameters is specified use it, otherwise default to the singular resource id $parameters = isset($parameters) && is_array($parameters) ? $parameters : $item->id; // Set defaults for any options not specified $options = ['url' => URL::route($resource . '.update', $parameters), 'method' => 'PUT', 'text' => !isset($text) ? '' : $text, 'icon' => !isset($icon) ? 'floppySave' : $icon, 'size' => !isset($size) ? 'small' : $size, 'type' => !isset($type) ? 'normal' : $type, 'hover' => !isset($hover) ? '' : $hover, 'class' => !isset($class) ? 'inline' : $class, 'id' => !isset($id) ? '' : $id, 'data' => !isset($data) ? '' : $data]; echo View::make('buttons.form', $options); }