Index: init.php =================================================================== --- init.php (revisión: 159) +++ init.php (copia de trabajo) @@ -123,6 +123,14 @@ benchmark_timer_set_marker('Init application'); } // if + // here we will load plugin helper file + require_once 'plugins.php'; + + // Set plugin manager timer... + if (Env::isDebugging()) { + benchmark_timer_set_marker('Plugin Manager loaded'); + } // if + // We need to call application.php after the routing is executed because // some of the application classes may need CONTROLLER, ACTION or $_GET // data collected by the matched route Index: application/helpers/tabbednavigation.php =================================================================== --- application/helpers/tabbednavigation.php (revisión: 159) +++ application/helpers/tabbednavigation.php (copia de trabajo) @@ -7,7 +7,10 @@ * @return array */ function tabbed_navigation_items() { - return TabbedNavigation::instance()->getItems(); + // PLUGIN HOOK + return plugin_manager()->apply_filters('tabbed_navigation_items', + TabbedNavigation::instance()->getItems()); + // PLUGIN HOOK } // tabbed_navigation_items /** Index: application/helpers/company_website.php =================================================================== --- application/helpers/company_website.php (revisión: 159) +++ application/helpers/company_website.php (copia de trabajo) @@ -51,6 +51,10 @@ get_url('dashboard', 'my_tasks') )); + // PLUGIN HOOK + plugin_manager()->do_action('add_dashboard_tab'); + // PLUGIN HOOK + tabbed_navigation_set_selected($selected); } // dashboard_tabbed_navigation @@ -86,6 +90,7 @@ define('ADMINISTRATION_TAB_CONFIGURATION', 'config'); define('ADMINISTRATION_TAB_TOOLS', 'tools'); define('ADMINISTRATION_TAB_UPGRADE', 'upgrade'); + define('ADMINISTRATION_TAB_PLUGINS', 'plugins'); /** * Prepare administration tabbed navigation @@ -135,6 +140,16 @@ lang('upgrade'), get_url('administration', 'upgrade') )); + add_tabbed_navigation_item(new TabbedNavigationItem( + ADMINISTRATION_TAB_PLUGINS, + lang('plugins'), + get_url('administration','plugins') + )); + + // PLUGIN HOOK + plugin_manager()->do_action('add_administration_tab'); + // PLUGIN HOOK + tabbed_navigation_set_selected($selected); } // administration_tabbed_navigation @@ -177,6 +192,11 @@ lang('my account'), get_url('account', 'index') )); + + // PLUGIN HOOK + plugin_manager()->do_action('add_my_account_tab'); + // PLUGIN HOOK + tabbed_navigation_set_selected($selected); } // account_tabbed_navigation Index: application/helpers/project_website.php =================================================================== --- application/helpers/project_website.php (revisión: 159) +++ application/helpers/project_website.php (copia de trabajo) @@ -78,6 +78,11 @@ lang('people'), get_url('project', 'people') )); + + // PLUGIN HOOK + plugin_manager()->do_action('add_project_tab'); + // PLUGIN HOOK + tabbed_navigation_set_selected($selected); } // dashboard_tabbed_navigation Index: application/models/application_logs/ApplicationLogs.class.php =================================================================== --- application/models/application_logs/ApplicationLogs.class.php (revisión: 159) +++ application/models/application_logs/ApplicationLogs.class.php (copia de trabajo) @@ -130,19 +130,62 @@ $private_filter = $include_private ? 1 : 0; $silent_filter = $include_silent ? 1 : 0; - return self::findAll(array( + $all_logs = self::findAll(array( 'conditions' => array('`is_private` <= ? AND `is_silent` <= ? AND `project_id` = (?)', $private_filter, $silent_filter, $project->getId()), 'order' => '`created_on` DESC', 'limit' => $limit, 'offset' => $offset, )); // findAll + + + return ApplicationLogs::filterLogs($all_logs); + } // getProjectLogs + + /** + * Exclude logs from uninstaller plugins + * + * @param Project $project + * @param boolean $include_private + * @param boolean $include_silent + * @param integer $limit + * @param integer $offset + * @return array + */ + static function filterLogs($all_logs) { + if ($all_logs==NULL) return; + $filtered_logs = array(); + //Only show logs related to installed applications + foreach ($all_logs as $log) + { + if ($log->getObject()==NULL) continue; + //Search the string 'plugins' in the file path containing the class, if false is a core application else is a plugin + if (strpos($GLOBALS['autoloader_classes'][strtoupper(get_class($log->getObject()))], 'plugins') == false) + { + //the class is a core application + $filtered_logs[]=$log; + } + else + { + //the class comes from a plugin + //so we need to filter logs from uninstalled plugins + $plugin_name = strtolower(get_class($log->getObject()->manager())); + $plugin = Plugins::findOne(array('conditions'=>array('`name` = ?', $plugin_name))); + if($plugin->isInstalled()) $filtered_logs[] = $log; + } + + } + return $filtered_logs; + + } // filterLogs + + /** * Return overall (for dashboard or RSS) * * This function will return array of application logs that match the function arguments. Entries can be filtered by - * type (prvivate, silent), projects (if $project_ids is array, if NULL project ID is ignored). Result set can be + * type (private, silent), projects (if $project_ids is array, if NULL project ID is ignored). Result set can be * also limited using $limit and $offset params * * @param boolean $include_private @@ -162,12 +205,14 @@ $conditions = array('`is_private` <= ? AND `is_silent` <= ?', $private_filter, $silent_filter); } // if - return self::findAll(array( + $all_logs = self::findAll(array( 'conditions' => $conditions, 'order' => '`created_on` DESC', 'limit' => $limit, 'offset' => $offset, )); // findAll + + return ApplicationLogs::filterLogs($all_logs); } // getOverallLogs /** Index: application/models/project_users/ProjectUsers.class.php =================================================================== --- application/models/project_users/ProjectUsers.class.php (revisión: 159) +++ application/models/project_users/ProjectUsers.class.php (copia de trabajo) @@ -16,7 +16,7 @@ const CAN_MANAGE_FILES = 'can_manage_files'; const CAN_ASSIGN_TO_OWNERS = 'can_assign_to_owners'; const CAN_ASSIGN_TO_OTHER = 'can_assign_to_other'; - + /** * Return all users that are involved in specific project * Index: application/controllers/AdministrationController.class.php =================================================================== --- application/controllers/AdministrationController.class.php (revisión: 159) +++ application/controllers/AdministrationController.class.php (copia de trabajo) @@ -245,6 +245,83 @@ } // try } // if } // tool_mass_mailer + + function plugins() { + + $plugins = Plugins::getAllPlugins(); + tpl_assign('plugins',$plugins); + + } // index + + function update_plugins() { + + $plugins = array_var($_POST,'plugins'); + $reference = Plugins::getAllPlugins(); + $errors = array(); + foreach($plugins as $name => $yes_no) { + //If it is not a plugin continue + $plugin_file_path = APPLICATION_PATH.'/plugins/plugin.'.$name.'.php'; + if (!file_exists($plugin_file_path)) continue; + // get existing id + $id = $reference[$name]; + $nicename = ucwords(str_replace('_',' ',$name)); + if($yes_no && '-' == $id) { + try { + //Check if plugin exists in database + $plugin = Plugins::findOne(array('conditions' => array('`name` = ?', $name))); + if ($plugin == NULL) $plugin = new Plugin(); + $plugin->setName($name); + $plugin->setInstalled(true); + + DB::beginWork(); + // get the file loaded here + include_once($plugin_file_path); + + // get activation routine ready + $activate = $name.'_activate'; + if( function_exists($activate) ) { + $activate(); + } + + // save to db now + $plugin->save(); + DB::commit(); + } catch(Exception $e) { + DB::rollback(); + $errors[] = $nicename.' ('.$e->getMessage().')'; + } + } + elseif(!$yes_no && '-' != $id) { + try + { + $plugin = Plugins::findById($id); + DB::beginWork(); + $deactivate = $name.'_deactivate'; + if( function_exists($deactivate) ) + { + //Check if user choose to purge data + if ($plugins[$name."_data"]=="0") + $deactivate(true); + else + $deactivate(); + } + $plugin->setInstalled(false); + $plugin->save(); + DB::commit(); + } catch(Exception $e) { + DB::rollback(); + $errors[] = $nicename.' ('.$e->getMessage().')'; + } + } + } + + if( count($errors) ) + flash_error(lang('plugin activation failed', implode(", ",$errors))); + else + flash_error(lang('plugins updated')); + $this->redirectTo('administration','plugins'); + + } // update } // AdministrationController Index: application/views/administration/index.php =================================================================== --- application/views/administration/index.php (revisión: 159) +++ application/views/administration/index.php (copia de trabajo) @@ -17,6 +17,7 @@
  • ()
  • +
  • Index: application/views/application/user_box.php =================================================================== --- application/views/application/user_box.php (revisión: 159) +++ application/views/application/user_box.php (copia de trabajo) @@ -54,6 +54,7 @@
  • +