diff -upNr --exclude=.svn ../projectpier/application/controllers/AdministrationController.class.php projectpier.mod/application/controllers/AdministrationController.class.php --- ../projectpier/application/controllers/AdministrationController.class.php 2008-05-15 17:02:51.000000000 +0200 +++ projectpier.mod/application/controllers/AdministrationController.class.php 2008-05-01 20:49:56.000000000 +0200 @@ -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 diff -upNr --exclude=.svn ../projectpier/application/helpers/company_website.php projectpier.mod/application/helpers/company_website.php --- ../projectpier/application/helpers/company_website.php 2008-05-15 17:02:28.000000000 +0200 +++ projectpier.mod/application/helpers/company_website.php 2008-04-15 16:41:51.000000000 +0200 @@ -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 diff -upNr --exclude=.svn ../projectpier/application/helpers/project_website.php projectpier.mod/application/helpers/project_website.php --- ../projectpier/application/helpers/project_website.php 2008-05-15 17:02:28.000000000 +0200 +++ projectpier.mod/application/helpers/project_website.php 2008-04-15 16:41:51.000000000 +0200 @@ -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 diff -upNr --exclude=.svn ../projectpier/application/helpers/tabbednavigation.php projectpier.mod/application/helpers/tabbednavigation.php --- ../projectpier/application/helpers/tabbednavigation.php 2008-05-15 17:02:28.000000000 +0200 +++ projectpier.mod/application/helpers/tabbednavigation.php 2008-04-15 16:41:51.000000000 +0200 @@ -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 /** diff -upNr --exclude=.svn ../projectpier/application/models/Angie_Feed_Renderer.class.php projectpier.mod/application/models/Angie_Feed_Renderer.class.php --- ../projectpier/application/models/Angie_Feed_Renderer.class.php 1970-01-01 01:00:00.000000000 +0100 +++ projectpier.mod/application/models/Angie_Feed_Renderer.class.php 2008-01-29 13:48:55.000000000 +0100 @@ -0,0 +1,24 @@ + diff -upNr --exclude=.svn ../projectpier/application/models/application_logs/ApplicationLogs.class.php projectpier.mod/application/models/application_logs/ApplicationLogs.class.php --- ../projectpier/application/models/application_logs/ApplicationLogs.class.php 2008-05-15 17:02:32.000000000 +0200 +++ projectpier.mod/application/models/application_logs/ApplicationLogs.class.php 2008-05-02 18:15:06.000000000 +0200 @@ -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 /** diff -upNr --exclude=.svn ../projectpier/application/models/PluginManager.class.php projectpier.mod/application/models/PluginManager.class.php --- ../projectpier/application/models/PluginManager.class.php 1970-01-01 01:00:00.000000000 +0100 +++ projectpier.mod/application/models/PluginManager.class.php 2008-04-15 16:41:51.000000000 +0200 @@ -0,0 +1,148 @@ +filter_table= array(); + + $activated_plugins = Plugins::getActivatedPlugins(); + + // now load each plugin + foreach(array_keys($activated_plugins) as $name) { + include_once 'plugins/plugin.'.$name.'.php'; + } + + // TODO : cleanup up old activated plugins without valid file?? + + } else { + PluginManager::instance()->init(); + } // if + } + + function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) { + + if ( isset($this->filter_table[$tag][$priority]) ) { + foreach($this->filter_table[$tag][$priority] as $filter) { + if ( $filter['function'] == $function_to_add ) { + return false; + } + } + } + $this->filter_table[$tag][$priority][] = array( + 'function'=>$function_to_add, + 'accepted_args'=>$accepted_args); + return true; + } + + function remove_filter($tag, $function_to_remove, $priority = 10) { + + + $toret = false; + + if ( isset($this->filter_table[$tag][$priority]) ) { + foreach($this->filter_table[$tag][$priority] as $filter) { + if ( $filter['function'] != $function_to_remove ) { + $new_function_list[] = $filter; + } + else { + $toret = true; + } + } + $this->filter_table[$tag][$priority] = $new_function_list; + } + return $toret; + } + + function do_action($tag,$arg='') { + + if ( !isset($this->filter_table[$tag]) ) { + return; + } + else { + ksort($this->filter_table[$tag]); + } + + $args = array(); + if ( is_array($arg) && 1 == count($arg) && is_object($arg[0]) ) + $args[] =& $arg[0]; + else + $args[] = $arg; + for ( $a = 2; $a < func_num_args(); $a++ ) + $args[] = func_get_arg($a); + + foreach ($this->filter_table[$tag] as $priority => $functions) { + if ( !is_null($functions) ) { + foreach($functions as $f) { + call_user_func_array($f['function'], array_slice($args, 0, (int)$f['accepted_args'])); + } + } + } + } + function apply_filters($tag,$value) { + + $args = func_get_args(); + + if ( !isset($this->filter_table[$tag]) ) { + return $value; + } + else { + ksort($this->filter_table[$tag]); + } + + foreach ($this->filter_table[$tag] as $priority => $functions) { + if ( !is_null($functions) ) { + foreach($functions as $f) { + $args[1] = $value; + $value = call_user_func_array($f['function'], array_slice($args, 1,(int)$f['accepted_args'])); + } + } + } + return $value; + } + + /** + * Return single PluginManager instance + * + * @access public + * @param void + * @return PluginManager + */ + static function instance() { + static $instance; + if (!($instance instanceof PluginManager )) { + $instance = new PluginManager(); + } // if + return $instance; + } // instance + + } +?> \ No hay ningún carácter de nueva línea al final del fichero diff -upNr --exclude=.svn ../projectpier/application/models/plugins/base/BasePlugin.class.php projectpier.mod/application/models/plugins/base/BasePlugin.class.php --- ../projectpier/application/models/plugins/base/BasePlugin.class.php 1970-01-01 01:00:00.000000000 +0100 +++ projectpier.mod/application/models/plugins/base/BasePlugin.class.php 2008-05-01 19:48:50.000000000 +0200 @@ -0,0 +1,96 @@ +getColumnValue('plugin_id'); + } // getPluginId() + + /** + * Set value of 'plugin_id' field + * + * @access public + * @param integer $value + * @return boolean + */ + function setPluginId($value) { + return $this->setColumnValue('plugin_id', $value); + } // setPluginId() + + /** + * Return value of 'name' field + * + * @access public + * @param void + * @return integer + */ + function getName() { + return $this->getColumnValue('name'); + } // getName() + + /** + * Set value of 'name' field + * + * @access public + * @param integer $value + * @return boolean + */ + function setName($value) { + return $this->setColumnValue('name', $value); + } // setName() + + /** + * Tell if a plugin is installed + * + * @access public + * @return boolean + */ + function isInstalled() + { + return $this->getColumnValue('installed'); + } + + /** + * Set the value of installed property + * + * @access public + * @return boolean + */ + function setInstalled($value) + { + return $this->setColumnValue('installed', $value); + } + + /** + * Return manager instance + * + * @access protected + * @param void + * @return Plugins + */ + function manager() { + if (!($this->manager instanceof Plugins)) { + $this->manager = Plugins::instance(); + } + return $this->manager; + } // manager + + } // BasePlugin + +?> diff -upNr --exclude=.svn ../projectpier/application/models/plugins/base/BasePlugins.class.php projectpier.mod/application/models/plugins/base/BasePlugins.class.php --- ../projectpier/application/models/plugins/base/BasePlugins.class.php 1970-01-01 01:00:00.000000000 +0100 +++ projectpier.mod/application/models/plugins/base/BasePlugins.class.php 2008-05-01 20:47:07.000000000 +0200 @@ -0,0 +1,234 @@ + Column type map + * + * @var array + * @static + */ + static private $columns = array('plugin_id' => DATA_TYPE_INTEGER, 'name' => DATA_TYPE_STRING, 'installed' => DATA_TYPE_BOOLEAN); + + /** + * Construct + * + * @return BasePlugins + */ + function __construct() { + parent::__construct('Plugin', 'plugins', true); + } // __construct + + // ------------------------------------------------------- + // Description methods + // ------------------------------------------------------- + + /** + * Return array of object columns + * + * @access public + * @param void + * @return array + */ + function getColumns() { + return array_keys(self::$columns); + } // getColumns + + /** + * Return column type + * + * @access public + * @param string $column_name + * @return string + */ + function getColumnType($column_name) { + if (isset(self::$columns[$column_name])) { + return self::$columns[$column_name]; + } else { + return DATA_TYPE_STRING; + } // if + } // getColumnType + + /** + * Return array of PK columns. If only one column is PK returns its name as string + * + * @access public + * @param void + * @return array or string + */ + function getPkColumns() { + return 'plugin_id'; + } // getPkColumns + + /** + * Return name of first auto_incremenent column if it exists + * + * @access public + * @param void + * @return string + */ + function getAutoIncrementColumn() { + return 'plugin_id'; + } // getAutoIncrementColumn + + // ------------------------------------------------------- + // Finders + // ------------------------------------------------------- + + /** + * Do a SELECT query over database with specified arguments + * + * @access public + * @param array $arguments Array of query arguments. Fields: + * + * - one - select first row + * - conditions - additional conditions + * - order - order by string + * - offset - limit offset, valid only if limit is present + * - limit + * + * @return one or Plugins objects + * @throws DBQueryError + */ + function find($arguments = null) { + if (isset($this) && instance_of($this, 'Plugins')) { + return parent::find($arguments); + } else { + return Plugins::instance()->find($arguments); + //$instance =& Plugins::instance(); + //return $instance->find($arguments); + } // if + } // find + + /** + * Find all records + * + * @access public + * @param array $arguments + * @return one or Plugins objects + */ + function findAll($arguments = null) { + if (isset($this) && instance_of($this, 'Plugins')) { + return parent::findAll($arguments); + } else { + return Plugins::instance()->findAll($arguments); + //$instance =& Plugins::instance(); + //return $instance->findAll($arguments); + } // if + } // findAll + + /** + * Find one specific record + * + * @access public + * @param array $arguments + * @return Plugin + */ + function findOne($arguments = null) { + if (isset($this) && instance_of($this, 'Plugins')) { + return parent::findOne($arguments); + } else { + return Plugins::instance()->findOne($arguments); + //$instance =& Plugins::instance(); + //return $instance->findOne($arguments); + } // if + } // findOne + + /** + * Return object by its PK value + * + * @access public + * @param mixed $id + * @param boolean $force_reload If true cache will be skipped and data will be loaded from database + * @return Plugin + */ + function findById($id, $force_reload = false) { + if (isset($this) && instance_of($this, 'Plugins')) { + return parent::findById($id, $force_reload); + } else { + return Plugins::instance()->findById($id, $force_reload); + //$instance =& Plugins::instance(); + //return $instance->findById($id, $force_reload); + } // if + } // findById + + /** + * Return number of rows in this table + * + * @access public + * @param string $conditions Query conditions + * @return integer + */ + function count($condition = null) { + if (isset($this) && instance_of($this, 'Plugins')) { + return parent::count($condition); + } else { + return Plugins::instance()->count($condition); + //$instance =& Plugins::instance(); + //return $instance->count($condition); + } // if + } // count + + /** + * Delete rows that match specific conditions. If $conditions is NULL all rows from table will be deleted + * + * @access public + * @param string $conditions Query conditions + * @return boolean + */ + function delete($condition = null) { + if (isset($this) && instance_of($this, 'Plugins')) { + return parent::delete($condition); + } else { + return Plugins::instance()->delete($condition); + //$instance =& Plugins::instance(); + //return $instance->delete($condition); + } // if + } // delete + + /** + * This function will return paginated result. Result is an array where first element is + * array of returned object and second populated pagination object that can be used for + * obtaining and rendering pagination data using various helpers. + * + * Items and pagination array vars are indexed with 0 for items and 1 for pagination + * because you can't use associative indexing with list() construct + * + * @access public + * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! + * @param integer $items_per_page Number of items per page + * @param integer $current_page Current page number + * @return array + */ + function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { + if (isset($this) && instance_of($this, 'Plugins')) { + return parent::paginate($arguments, $items_per_page, $current_page); + } else { + return Plugins::instance()->paginate($arguments, $items_per_page, $current_page); + //$instance =& Plugins::instance(); + //return $instance->paginate($arguments, $items_per_page, $current_page); + } // if + } // paginate + + /** + * Return manager instance + * + * @return Plugins + */ + function instance() { + static $instance; + if (!instance_of($instance, 'Plugins')) { + $instance = new Plugins(); + } // if + return $instance; + } // instance + + } // Plugins + +?> diff -upNr --exclude=.svn ../projectpier/application/models/plugins/Plugin.class.php projectpier.mod/application/models/plugins/Plugin.class.php --- ../projectpier/application/models/plugins/Plugin.class.php 1970-01-01 01:00:00.000000000 +0100 +++ projectpier.mod/application/models/plugins/Plugin.class.php 2008-04-15 16:41:51.000000000 +0200 @@ -0,0 +1,12 @@ + diff -upNr --exclude=.svn ../projectpier/application/models/plugins/Plugins.class.php projectpier.mod/application/models/plugins/Plugins.class.php --- ../projectpier/application/models/plugins/Plugins.class.php 1970-01-01 01:00:00.000000000 +0100 +++ projectpier.mod/application/models/plugins/Plugins.class.php 2008-05-01 19:53:29.000000000 +0200 @@ -0,0 +1,84 @@ + $conditions + )); + foreach((array)$plugins as $plugin) { + if( array_key_exists($plugin->getName(),$results) ) { + $results[$plugin->getName()] = $plugin->getPluginId(); + } else { + // TODO : remove from DB here?? + } + } + + return $results; + + } // getAllPlugins + + /** + * Return array of all activated plugins based on plugin files on filesystem + * + * @param none + * @return array + */ + static function getActivatedPlugins() { + + $results = Plugins::getAllPlugins(); + + foreach($results as $name => $id) { + if( '-' == $id ) + unset($results[$name]); + } + + return $results; + + } // getActivatedPlugins + + /** + * Return array of all activated plugins + * + * @param none + * @return array + */ + static function getNamesFromDB() { + $names = array(); + $plugins = Plugins::findAll(array()); // findAll + if (is_array($plugins)) { + foreach ($plugins as $plugin) { + $names[] = $plugin->getName(); + } // foreach + } // if + return $names; + } // getActivatedPlugins + + } // Plugins + +?> diff -upNr --exclude=.svn ../projectpier/application/models/project_links/base/BaseProjectLink.class.php projectpier.mod/application/models/project_links/base/BaseProjectLink.class.php --- ../projectpier/application/models/project_links/base/BaseProjectLink.class.php 1970-01-01 01:00:00.000000000 +0100 +++ projectpier.mod/application/models/project_links/base/BaseProjectLink.class.php 2008-04-15 21:16:50.000000000 +0200 @@ -0,0 +1,59 @@ +getColumnValue('id'); + } // getObjectId() + + // ----------------------------------------------------- + // Magic access method + // NB: this replaces the need for other setters/getters + // ----------------------------------------------------- + function __call($method, $args) { + if( preg_match('/(set|get)(_)?/', $method) ) { + if(substr($method, 0, 3) == "get") { + $col = substr(strtolower(preg_replace('([A-Z])', '_$0', $method)), 4); + if( $col ) { + return $this->getColumnValue($col); + } + } elseif(substr($method, 0, 3) == "set" && count($args)) { + $col = substr(strtolower(preg_replace('([A-Z])', '_$0', $method)), 4); + if( $col ) { + return $this->setColumnValue($col, $args[0]); + } + } + } + // me no understand! + return false; + } + + /** + * Return manager instance + * + * @access protected + * @param void + * @return ProjectLinks + */ + function manager() { + if (!($this->manager instanceof ProjectLinks)) { + $this->manager = ProjectLinks::instance(); + } + return $this->manager; + } // manager + + } // BaseProjectLink + +?> diff -upNr --exclude=.svn ../projectpier/application/models/project_links/base/BaseProjectLinks.class.php projectpier.mod/application/models/project_links/base/BaseProjectLinks.class.php --- ../projectpier/application/models/project_links/base/BaseProjectLinks.class.php 1970-01-01 01:00:00.000000000 +0100 +++ projectpier.mod/application/models/project_links/base/BaseProjectLinks.class.php 2008-04-15 21:16:40.000000000 +0200 @@ -0,0 +1,224 @@ + Column type map + * + * @var array + * @static + */ + static private $columns = array('id' => DATA_TYPE_INTEGER, + 'project_id' => DATA_TYPE_INTEGER, + 'title' => DATA_TYPE_STRING, + 'url' => DATA_TYPE_STRING, + 'created_on' => DATA_TYPE_DATETIME, + 'created_by_id' => DATA_TYPE_INTEGER); + + /** + * Construct + * + * @return BaseProjectLinks + */ + function __construct() { + parent::__construct('ProjectLink', 'project_links', true); + } // __construct + + // ------------------------------------------------------- + // Description methods + // ------------------------------------------------------- + + /** + * Return array of object columns + * + * @access public + * @param void + * @return array + */ + function getColumns() { + return array_keys(self::$columns); + } // getColumns + + /** + * Return column type + * + * @access public + * @param string $column_name + * @return string + */ + function getColumnType($column_name) { + if (isset(self::$columns[$column_name])) { + return self::$columns[$column_name]; + } else { + return DATA_TYPE_STRING; + } // if + } // getColumnType + + /** + * Return array of PK columns. If only one column is PK returns its name as string + * + * @access public + * @param void + * @return array or string + */ + function getPkColumns() { + return 'id'; + } // getPkColumns + + /** + * Return name of first auto_increment column if it exists + * + * @access public + * @param void + * @return string + */ + function getAutoIncrementColumn() { + return 'id'; + } // getAutoIncrementColumn + + // ------------------------------------------------------- + // Finders + // ------------------------------------------------------- + + /** + * Do a SELECT query over database with specified arguments + * + * @access public + * @param array $arguments Array of query arguments. Fields: + * + * - one - select first row + * - conditions - additional conditions + * - order - order by string + * - offset - limit offset, valid only if limit is present + * - limit + * + * @return one or ProjectLinks objects + * @throws DBQueryError + */ + function find($arguments = null) { + if (isset($this) && instance_of($this, 'ProjectLinks')) { + return parent::find($arguments); + } else { + return ProjectLinks::instance()->find($arguments); + } // if + } // find + + /** + * Find all records + * + * @access public + * @param array $arguments + * @return one or ProjectLinks objects + */ + function findAll($arguments = null) { + if (isset($this) && instance_of($this, 'ProjectLinks')) { + return parent::findAll($arguments); + } else { + return ProjectLinks::instance()->findAll($arguments); + } // if + } // findAll + + /** + * Find one specific record + * + * @access public + * @param array $arguments + * @return ProjectLink + */ + function findOne($arguments = null) { + if (isset($this) && instance_of($this, 'ProjectLinks')) { + return parent::findOne($arguments); + } else { + return ProjectLinks::instance()->findOne($arguments); + } // if + } // findOne + + /** + * Return object by its PK value + * + * @access public + * @param mixed $id + * @param boolean $force_reload If true cache will be skipped and data will be loaded from database + * @return ProjectLink + */ + function findById($id, $force_reload = false) { + if (isset($this) && instance_of($this, 'ProjectLinks')) { + return parent::findById($id, $force_reload); + } else { + return ProjectLinks::instance()->findById($id, $force_reload); + } // if + } // findById + + /** + * Return number of rows in this table + * + * @access public + * @param string $conditions Query conditions + * @return integer + */ + function count($condition = null) { + if (isset($this) && instance_of($this, 'ProjectLinks')) { + return parent::count($condition); + } else { + return ProjectLinks::instance()->count($condition); + } // if + } // count + + /** + * Delete rows that match specific conditions. If $conditions is NULL all rows from table will be deleted + * + * @access public + * @param string $conditions Query conditions + * @return boolean + */ + function delete($condition = null) { + if (isset($this) && instance_of($this, 'ProjectLinks')) { + return parent::delete($condition); + } else { + return ProjectLinks::instance()->delete($condition); + } // if + } // delete + + /** + * This function will return paginated result. Result is an array where first element is + * array of returned object and second populated pagination object that can be used for + * obtaining and rendering pagination data using various helpers. + * + * Items and pagination array vars are indexed with 0 for items and 1 for pagination + * because you can't use associative indexing with list() construct + * + * @access public + * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! + * @param integer $items_per_page Number of items per page + * @param integer $current_page Current page number + * @return array + */ + function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { + if (isset($this) && instance_of($this, 'ProjectLinks')) { + return parent::paginate($arguments, $items_per_page, $current_page); + } else { + return ProjectLinks::instance()->paginate($arguments, $items_per_page, $current_page); + } // if + } // paginate + + /** + * Return manager instance + * + * @return ProjectLinks + */ + function instance() { + static $instance; + if (!instance_of($instance, 'ProjectLinks')) { + $instance = new ProjectLinks(); + } // if + return $instance; + } // instance + + } // ProjectLinks + +?> diff -upNr --exclude=.svn ../projectpier/application/models/project_links/ProjectLink.class.php projectpier.mod/application/models/project_links/ProjectLink.class.php --- ../projectpier/application/models/project_links/ProjectLink.class.php 1970-01-01 01:00:00.000000000 +0100 +++ projectpier.mod/application/models/project_links/ProjectLink.class.php 2008-04-15 21:16:18.000000000 +0200 @@ -0,0 +1,111 @@ +project)) { + $this->project = Projects::findById($this->getProjectId()); + } // if + return $this->project; + } // getProject + + /** + * Add new link + * + * @param void + * @return null + */ + function canAdd(User $user, Project $project) { + return $user->isAdministrator() || $user->isMemberOfOwnerCompany(); + } + + /** + * Edit link + * + * @param void + * @return null + */ + function canEdit(User $user) { + return $user->isAdministrator() || $user->isMemberOfOwnerCompany(); + } + + /** + * Delete link + * + * @param void + * @return null + */ + function canDelete(User $user) { + return $user->isAdministrator() || $user->isMemberOfOwnerCompany(); + } + + /** + * Does user have view access + * + * @param void + * @return boolean + */ + function canView(User $user) { + if ($user->isAdministrator() || $user->isMemberOfOwnerCompany()) { + return true; + } // if + if ($user->isProjectUser($this->getProject())) { + return true; + } // if + return false; + } // canView + + /** + * Return edit link URL + * + * @param void + * @return string + */ + function getEditUrl() { + return get_url('link', 'edit_link', array('id' => $this->getId(), 'active_project' => active_project()->getId())); + } // getEditUrl + + /** + * Return delete link URL + * + * @param void + * @return string + */ + function getDeleteUrl() { + return get_url('link', 'delete_link', array('id' => $this->getId(), 'active_project' => active_project()->getId())); + } // getEditUrl + + /** + * Return object name + * + * @param void + * @return string + */ + function getObjectName() { + return $this->getTitle(); + } + + /** + * Return object type name + * + * @param void + * @return string + */ + function getObjectTypeName() { + return lang('link'); + } // getObjectTypeName + + } // ProjectLink + +?> diff -upNr --exclude=.svn ../projectpier/application/models/project_links/ProjectLinks.class.php projectpier.mod/application/models/project_links/ProjectLinks.class.php --- ../projectpier/application/models/project_links/ProjectLinks.class.php 1970-01-01 01:00:00.000000000 +0100 +++ projectpier.mod/application/models/project_links/ProjectLinks.class.php 2008-04-16 13:31:16.000000000 +0200 @@ -0,0 +1,28 @@ +getId()); + + return self::findAll(array( + 'conditions' => $conditions, + 'order' => '`created_on` DESC', + )); // findAll + + } // getAllProjectLinks + + } // ProjectLinks + +?> diff -upNr --exclude=.svn ../projectpier/application/models/project_users/ProjectUsers.class.php projectpier.mod/application/models/project_users/ProjectUsers.class.php --- ../projectpier/application/models/project_users/ProjectUsers.class.php 2008-05-15 17:02:42.000000000 +0200 +++ projectpier.mod/application/models/project_users/ProjectUsers.class.php 2008-04-29 16:28:10.000000000 +0200 @@ -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 * diff -upNr --exclude=.svn ../projectpier/application/plugins.php projectpier.mod/application/plugins.php --- ../projectpier/application/plugins.php 1970-01-01 01:00:00.000000000 +0100 +++ projectpier.mod/application/plugins.php 2008-04-15 16:41:51.000000000 +0200 @@ -0,0 +1,50 @@ +init(); + /* + * Convenience function for instance of PluginManager used by hooks throughout + */ + function plugin_manager() { + return PluginManager::instance(); + } + /* + * Convenience functions for plugin writers + */ + function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) { + return plugin_manager()->add_filter($tag,$function_to_add,$priority,$accepted_args); + } + function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) { + return plugin_manager()->add_filter($tag,$function_to_add,$priority,$accepted_args); + } + function remove_action($tag, $function_to_remove, $priority = 10) { + return plugin_manager()->remove_filter($tag,$function_to_remove,$priority); + } + function remove_filter($tag, $function_to_remove, $priority = 10) { + return plugin_manager()->remove_filter($tag,$function_to_remove,$priority); + } + +?> \ No hay ningún carácter de nueva línea al final del fichero diff -upNr --exclude=.svn ../projectpier/application/views/administration/index.php projectpier.mod/application/views/administration/index.php --- ../projectpier/application/views/administration/index.php 2008-05-15 17:02:54.000000000 +0200 +++ projectpier.mod/application/views/administration/index.php 2008-04-15 16:41:51.000000000 +0200 @@ -17,6 +17,7 @@