Ejemplo n.º 1
0
 /**
  * Displays the form
  * Inherits from TagManager_Form the form displaying methods
  * so the view can be slightly the same than the one used for one classical form
  *
  * @param FTL_Binding $tag
  *
  * @return string
  */
 public static function tag_form(FTL_Binding $tag)
 {
     $ajax = $tag->getAttribute('ajax');
     // Ajax form
     if ($ajax == TRUE) {
         // Get form string
         $str = parent::tag_form($tag);
         // No JS  The user will add the JS part in his own JS script
         $nojs = $tag->getAttribute('nojs');
         $form_name = $tag->getAttribute('name');
         $form_submit_id = $tag->getAttribute('submit');
         // $error_tag = $tag->getAttribute('error_tag');
         // $error_tag_class = $tag->getAttribute('error_tag_class');
         // Module settings
         self::$config = Modules()->get_module_config('Ajaxform');
         if (!$nojs) {
             // Add the JS part of the module
             if ($form_name && $form_submit_id) {
                 $data = array('form_name' => $form_name, 'form_submit_id' => $form_submit_id, 'url' => base_url() . Settings::get_lang() . '/' . self::$config['uri'] . '/post');
                 $str .= self::$ci->load->view('ajaxform_js', $data, TRUE);
             } else {
                 log_message('error', 'Ajaxform ERROR : Set the name & submit attributes of the <ion:form name="formName" submit="submitButtonID"> tag');
             }
         }
         return $str;
     } else {
         return parent::tag_form($tag);
     }
 }
Ejemplo n.º 2
0
 public function __construct($config = array())
 {
     // If the CI object is needed :
     self::$ci =& get_instance();
     self::$config = Modules()->get_module_config('Sfs');
     self::$config = array('api_server' => !empty(self::$config['api_server']) ? self::$config['api_server'] : NULL, 'api_key' => !empty(self::$config['api_key']) ? self::$config['api_key'] : NULL, 'track' => !empty(self::$config['track']) ? self::$config['track'] : FALSE, 'evidence_input' => !empty(self::$config['evidence_input']) ? self::$config['evidence_input'] : NULL, 'username_input' => !empty(self::$config['username_input']) ? self::$config['username_input'] : NULL);
     self::$ci->load->library('rest', array('server' => self::$config['api_server']));
 }
Ejemplo n.º 3
0
 /**
  * Load Modules Events
  *
  */
 private static function _load_modules_events()
 {
     // Add path to installed modules
     $installed_modules = Modules()->get_installed_modules();
     if (is_null($installed_modules)) {
         return FALSE;
     }
     // Be sure Events classes will be found but also will be able to load module libraries
     foreach ($installed_modules as $module) {
         if (isset($module['folder'])) {
             Finder::add_path(MODPATH . $module['folder'] . '/');
         }
     }
     foreach ($installed_modules as $module) {
         if (!($details_class = self::_start_events_class($module['path']))) {
             continue;
         }
     }
     return TRUE;
 }
Ejemplo n.º 4
0
Archivo: role.php Proyecto: trk/ionize
 /**
  * Edit
  *
  */
 public function edit()
 {
     $role = $this->role_model->get($this->input->post('id_role'));
     $this->template['role'] = $role;
     // Get roles list
     // TODO: Filter roles on level ?
     $roles = $this->role_model->get_list();
     $this->template['roles'] = array_filter($roles, array($this, '_filter_roles'));
     // All Admin Resources
     $resources = $this->resource_model->get_tree();
     $this->template['json_resources'] = json_encode($resources, TRUE);
     // All Modules Resources
     $modules_resources = Modules()->get_resources();
     $resources = $this->resource_model->build_resources_tree($modules_resources);
     $this->template['json_modules_resources'] = json_encode($resources, TRUE);
     // Role's permissions
     $rules = $this->rule_model->get_list(array('id_role' => $role['id_role']));
     $this->template['has_all'] = $this->_has_all_permissions($rules);
     $this->template['json_rules'] = json_encode($rules, TRUE);
     $this->output('role/edit');
 }
Ejemplo n.º 5
0
 /**
  * Installs one module
  *
  * @param	string	Module Folder name
  * @param	string	Module User's choosen URI (by default, the "uri_segment" value in config.php
  *
  */
 public function install($module_folder, $module_uri)
 {
     // Add the module in $module config array : /application/config/modules.php
     if (!is_really_writable(APPPATH . '/config/modules.php')) {
         $this->error(lang('ionize_message_module_install_error_config_write') . ' : ' . APPPATH . '/config/modules.php');
     } else {
         // Get the modules config file : $modules, $disable_controller, $aliases
         $modules = array();
         $disable_controller = array();
         $aliases = array();
         include APPPATH . 'config/modules.php';
         // Load the module config
         $config = Modules()->get_module_config($module_folder);
         //set to true/false
         $config['has_frontend'] = !empty($config['has_frontend']);
         if ($config['has_frontend'] && $this->_has_conflict_with_uri($module_uri)) {
             $this->error(lang('ionize_message_module_page_conflict'));
         } else {
             // uri => Module Folder
             $modules[$module_uri] = $module_folder;
             // The module controller is disabled : Not possible to call this module from controller.
             if (!$config['has_frontend'] && !in_array($module_uri, $disable_controller)) {
                 $disable_controller[] = $module_uri;
             }
             // Database installer
             $database_install_script = !empty($config['database_installer']) ? $config['database_installer'] : 'database.xml';
             if (file_exists(MODPATH . $module_folder . '/' . $database_install_script)) {
                 $this->install_database_script($database_install_script, $module_folder);
             }
             // Write config file : /application/config/modules.php
             $this->save_config($modules, $aliases, $disable_controller);
             // Reload the panel
             $this->update[] = array('element' => 'mainPanel', 'url' => 'modules');
             // OK Answer
             $this->success(lang('ionize_message_module_saved'));
         }
     }
 }
Ejemplo n.º 6
0
 function get_sfs_declare_spam_url()
 {
     $url = NULL;
     $config = Modules()->get_module_config('Sfs');
     if (!empty($config)) {
         $ci =& get_instance();
         $ui = $config['username_input'];
         // Username
         $username = '';
         if (!empty($ui)) {
             $username = array();
             $arr = explode(',', $ui);
             foreach ($arr as $key) {
                 if ($ci->input->post($key)) {
                     $username[] = $ci->input->post($key);
                 }
             }
             $username = '******' . urlencode(implode(' ', $username));
         }
         // Email
         $email = '';
         if ($ci->input->post('email')) {
             $email = '&email=' . $ci->input->post('email');
         }
         // Evidence
         $evidence = '';
         if ($ci->input->post($config['evidence_input'])) {
             $evidence = '&evidence=' . urlencode($ci->input->post($config['evidence_input']));
         }
         // IP
         $ip = '&ip_addr=' . $ci->input->ip_address();
         $base_href = $config['api_server'] . '/add?api_key=' . $config['api_key'] . $username . $email . $ip;
         $complete_href = $base_href . $evidence;
         $url = '<a href="' . $complete_href . '">' . $base_href . '</a>';
     }
     return $url;
 }
Ejemplo n.º 7
0
 public function __construct()
 {
     // If the CI object is needed :
     self::$ci =& get_instance();
     // Config Events
     $config = Modules()->get_module_config('Sfs');
     $events = explode(',', $config['events']);
     // ionize < 1.0.4 hack : Be able to load module libraries
     $installed_modules = Modules()->get_installed_modules();
     foreach ($installed_modules as $module) {
         if (isset($module['folder'])) {
             Finder::add_path(MODPATH . $module['folder'] . '/');
         }
     }
     // Stop Forum Spam lib
     // @TODO : Enhance here to handle more services:
     // 1. Create one lib / service
     // 2. Rewrite the config system, which should have one key / service
     self::$ci->load->library('Sfs_Sfs');
     foreach ($events as $event) {
         $event = trim($event);
         Event::register($event, array('Sfs_Sfs', 'on_post_check_before'));
     }
 }
Ejemplo n.º 8
0
 /**
  * Returns all the available resources,
  * DB + Modules, merged in one array.
  *
  * @return array
  *
  */
 public function get_all_resources()
 {
     $resources = $this->get_list();
     $modules_resources = Modules()->get_resources();
     return array_merge($resources, $modules_resources);
 }
Ejemplo n.º 9
0
}
?>

				</ul>
			</li>
			<?php 
if (Authority::can('access', 'admin/modules')) {
    ?>
				<li><a class="returnFalse"><?php 
    echo lang('ionize_menu_modules');
    ?>
</a>
					<ul>
						<!-- Module Admin controllers links -->
						<?php 
    $modules = Modules()->get_installed_modules();
    ?>
						<?php 
    foreach ($modules as $key => $module) {
        ?>
							<?php 
        if (Authority::can('access', 'module/' . $module['key']) && $module['has_admin']) {
            ?>
								<li><a class="navlink" id="<?php 
            echo $module['uri'];
            ?>
ModuleLink" href="module/<?php 
            echo $module['uri'];
            ?>
/<?php 
            echo $module['uri'];
Ejemplo n.º 10
0
 /**
  * Get Modules Language Files
  */
 function _get_module_lang_files()
 {
     $paths['module'] = array('title' => lang('ionize_title_translation_module'), 'type' => 'module', 'files' => array());
     $lang = $this->default_lang_code;
     $installed_modules = Modules()->get_installed_modules();
     foreach ($installed_modules as $key => $imodule) {
         // Module Language Folder Path
         $mpath = $imodule['path'] . $this->DP . 'language' . $this->DP;
         $mlpath = $mpath . $lang . $this->DP . strtolower($key) . '_lang.php';
         if (file_exists($mlpath)) {
             $paths['module']['files'][] = array('path' => $mlpath, 'lang_path' => $mpath, 'filename' => strtolower($key) . '_lang.php');
         }
     }
     return $paths;
 }
Ejemplo n.º 11
0
 function index()
 {
     // Articles
     $articles = $this->article_model->get_lang_list(array('order_by' => 'updated DESC'), Settings::get_lang('default'));
     // Last 10 articles
     $last_articles = array();
     $max = count($articles) > 9 ? 10 : count($articles);
     $count = 0;
     if (!empty($articles)) {
         foreach ($articles as $article) {
             if (Authority::can('access', 'backend/menu/' . $article['id_menu'], NULL, TRUE) && Authority::can('access', 'backend/page/' . $article['id_page'], NULL, TRUE) && Authority::can('access', 'backend/article/' . $article['id_article'], NULL, TRUE)) {
                 $last_articles[] = $article;
                 $count++;
                 if ($count == $max) {
                     break;
                 }
             }
         }
     }
     // Orphan articles
     $orphan_articles = array();
     foreach ($articles as $article) {
         if (!$article['id_page']) {
             $orphan_articles[] = $article;
         }
     }
     // Orphan pages
     $orphan_pages = $this->page_model->get_lang_list(array('id_menu' => '0', 'order_by' => 'name ASC'), Settings::get_lang('default'));
     // Last connected /registered users
     $logged_user_role = User()->get_role();
     $users = $this->user_model->get_list_with_role(array('limit' => '10', 'order_by' => 'last_visit DESC', 'last_visit <>' => ''));
     $last_registered_users = $this->user_model->get_list_with_role(array('limit' => '10', 'order_by' => 'join_date DESC'));
     // Updates on last articles
     foreach ($last_articles as &$article) {
         // User name update
         foreach ($users as $user) {
             if ($user['username'] == $article['updater']) {
                 $article['updater'] = $user['screen_name'];
             }
             if ($user['username'] == $article['author']) {
                 $article['author'] = $user['screen_name'];
             }
         }
         $pages = $this->page_model->get_parent_array($article['id_page'], array(), Settings::get_lang('default'));
         $breadcrumb = array();
         foreach ($pages as $page) {
             $breadcrumb[] = !empty($page['title']) ? $page['title'] : $page['name'];
         }
         $article['breadcrumb'] = implode(' > ', $breadcrumb);
     }
     // Updates on orphan pages
     foreach ($orphan_pages as &$page) {
         // User name update
         foreach ($users as $user) {
             if ($user['username'] == $page['updater']) {
                 $page['updater'] = $user['screen_name'];
             }
             if ($user['username'] == $page['author']) {
                 $page['author'] = $user['screen_name'];
             }
         }
     }
     // Updates on orphan articles
     foreach ($orphan_articles as &$article) {
         // User name update
         foreach ($users as $user) {
             if ($user['username'] == $article['updater']) {
                 $article['updater'] = $user['screen_name'];
             }
             if ($user['username'] == $article['author']) {
                 $article['author'] = $user['screen_name'];
             }
         }
     }
     // Flags
     $settings = Settings::get_settings();
     $flags = array();
     foreach ($settings as $key => $setting) {
         if (strpos($key, 'flag') !== FALSE && $setting != '') {
             $flags[substr($key, -1)] = $setting;
         }
     }
     // Put installed module list to template
     $installed_modules = Modules()->get_installed_modules();
     $modules = array();
     foreach ($installed_modules as $module) {
         if ($module['has_admin'] && Authority::can('access', 'module/' . $module['key'])) {
             $modules[] = $module;
         }
     }
     $this->template['modules'] = $modules;
     $this->template['flags'] = $flags;
     $this->template['last_articles'] = $last_articles;
     $this->template['orphan_pages'] = $orphan_pages;
     $this->template['orphan_articles'] = $orphan_articles;
     $this->template['users'] = $users;
     $this->template['last_registered_users'] = $last_registered_users;
     $this->output('desktop/dashboard');
 }
Ejemplo n.º 12
0
 /**
  * Constructor
  *
  * @param	CI_Controller
  *
  */
 public final function __construct(CI_Controller $c)
 {
     $this->parent = $c;
     // Set Module's config
     $ci =& get_instance();
     $config_items = Modules()->get_module_config($ci->uri->segment(3));
     foreach ($config_items as $item => $value) {
         $this->config->set_item($item, $value);
     }
     $this->construct();
 }
Ejemplo n.º 13
0
 /**
  * Model Loader
  *
  * This function lets users load and instantiate models.
  *
  * @param	string	the name of the class
  * @param	string	name for the model
  * @param	bool	database connection
  * @return	void
  */
 public function model($model, $name = '', $db_conn = FALSE)
 {
     if (is_array($model)) {
         foreach ($model as $babe => $nickname) {
             if (!is_string($babe)) {
                 $babe = $nickname;
                 $nickname = NULL;
             }
             $this->model($babe, $nickname, $db_conn);
         }
         return;
     }
     if ($model == '') {
         return;
     }
     $path = '';
     // Is the model in a sub-folder? If so, parse out the filename and path.
     if (($last_slash = strrpos($model, '/')) !== FALSE) {
         // The path is in front of the last slash
         $path = substr($model, 0, $last_slash + 1);
         // And the model name behind it
         $model = substr($model, $last_slash + 1);
     }
     if ($name == '') {
         $name = $model;
     }
     if (in_array($name, $this->_ci_models, TRUE)) {
         return;
     }
     $CI =& get_instance();
     if (isset($CI->{$name})) {
         log_message('ERROR', 'The model name you are loading is the name of a resource that is already being used : ' . $name);
     }
     $model = strtolower($model);
     $installed_modules = Modules()->get_installed_modules();
     if (!empty($installed_modules)) {
         foreach ($installed_modules as $module) {
             $this->_ci_model_paths = array_unique(array_merge($this->_ci_model_paths, array(MODPATH . $module['folder'] . '/')));
         }
     }
     foreach ($this->_ci_model_paths as $mod_path) {
         if (!file_exists($mod_path . 'models/' . $path . $model . '.php')) {
             continue;
         }
         if ($db_conn !== FALSE and !class_exists('CI_DB')) {
             if ($db_conn === TRUE) {
                 $db_conn = '';
             }
             $CI->load->database($db_conn, FALSE, TRUE);
         }
         if (!class_exists('CI_Model')) {
             load_class('Model', 'core');
         }
         require_once $mod_path . 'models/' . $path . $model . '.php';
         $model = ucfirst($model);
         $CI->{$name} = new $model();
         $this->_ci_models[] = $name;
         return;
     }
     // Could not find the model
     log_message('ERROR', 'Unable to locate the model you have specified : ' . $model);
 }