public function check()
 {
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     $query->select('*')->from('#__pf_projects')->order('id ASC');
     $db->setQuery($query, (int) $this->getState('limitstart'), 1);
     $this->project = $db->loadObject();
     if (empty($this->project)) {
         return false;
     }
     $this->components = PFApplicationHelper::getComponents();
     $this->getRootAssets();
     if (!$this->checkProjectCategory()) {
         return false;
     }
     if (!$this->checkProjectAssets()) {
         return false;
     }
     foreach ($this->components as $name => $item) {
         if (!isset($this->root_assets[$name]) || empty($this->root_assets[$name])) {
             continue;
         }
         if (!isset($this->project_assets[$name]) || empty($this->project_assets[$name])) {
             continue;
         }
         if (!$this->checkComponentAssets($name)) {
             return false;
         }
     }
     return true;
 }
 /**
  * Method to get a list of available buttons
  *
  * @return    array    $buttons    The available buttons
  */
 public static function getButtons()
 {
     $components = PFApplicationHelper::getComponents();
     $buttons = array();
     foreach ($components as $component) {
         if (!PFApplicationHelper::enabled($component->element)) {
             continue;
         }
         // Register component route helper if exists
         $router = JPATH_SITE . '/components/' . $component->element . '/helpers/route.php';
         $class = str_replace('com_pf', 'PF', $component->element) . 'HelperRoute';
         if (JFile::exists($router)) {
             JLoader::register($class, $router);
         }
         // Register component dashboard helper if exists
         $helper = JPATH_ADMINISTRATOR . '/components/' . $component->element . '/helpers/dashboard.php';
         $class = str_replace('com_pf', 'PF', $component->element) . 'HelperDashboard';
         if (!JFile::exists($helper)) {
             continue;
         }
         JLoader::register($class, $helper);
         // Get the dashboard button
         if (class_exists($class)) {
             if (in_array('getSiteButtons', get_class_methods($class))) {
                 $com_buttons = (array) call_user_func(array($class, 'getSiteButtons'));
                 $buttons[$component->element] = array();
                 foreach ($com_buttons as $button) {
                     $buttons[$component->element][] = $button;
                 }
             }
         }
     }
     return $buttons;
 }
 /**
  * Configure the Linkbar.
  *
  * @param     string    $view    The name of the active view.
  *
  * @return    void
  */
 public static function addSubmenu($view)
 {
     $is_j3 = version_compare(JVERSION, '3.0.0', 'ge');
     $forms = array('task', 'tasklist');
     if (in_array($view, $forms) && $is_j3) {
         return;
     }
     $components = PFApplicationHelper::getComponents();
     $option = JFactory::getApplication()->input->get('option');
     $class = $is_j3 ? 'JHtmlSidebar' : 'JSubMenuHelper';
     foreach ($components as $component) {
         if ($component->enabled == '0') {
             continue;
         }
         $title = JText::_($component->element);
         $parts = explode('-', $title, 2);
         if (count($parts) == 2) {
             $title = trim($parts[1]);
         }
         call_user_func(array($class, 'addEntry'), $title, 'index.php?option=' . $component->element, $option == $component->element && $view == 'tasks');
         if ($option == $component->element) {
             call_user_func(array($class, 'addEntry'), JText::_('COM_PROJECTFORK_SUBMENU_TASKLISTS'), 'index.php?option=' . $component->element . '&view=tasklists', $option == $component->element && $view == 'tasklists');
         }
     }
 }
Beispiel #4
0
 /**
  * Configure the Linkbar.
  *
  * @param     string    $view    The name of the active view.
  *
  * @return    void
  */
 public static function addSubmenu($view)
 {
     $components = PFApplicationHelper::getComponents();
     $option = JFactory::getApplication()->input->get('option');
     foreach ($components as $component) {
         if ($component->enabled == '0') {
             continue;
         }
         $title = JText::_($component->element);
         $parts = explode('-', $title, 2);
         if (count($parts) == 2) {
             $title = trim($parts[1]);
         }
         JSubMenuHelper::addEntry($title, 'index.php?option=' . $component->element, $option == $component->element);
     }
 }
Beispiel #5
0
 /**
  * Configure the Linkbar.
  *
  * @param     string    $view    The name of the active view.
  *
  * @return    void
  */
 public static function addSubmenu($view)
 {
     $is_j3 = version_compare(JVERSION, '3.0.0', 'ge');
     $forms = array('design', 'revision');
     if (in_array($view, $forms) && $is_j3) {
         return;
     }
     $components = PFApplicationHelper::getComponents();
     $option = JFactory::getApplication()->input->get('option');
     foreach ($components as $component) {
         if ($component->enabled == '0') {
             continue;
         }
         $title = JText::_($component->element);
         $parts = explode('-', $title, 2);
         if (count($parts) == 2) {
             $title = trim($parts[1]);
         }
         if ($is_j3) {
             // Joomla 3+
             JHtmlSidebar::addEntry($title, 'index.php?option=' . $component->element, $option == $component->element && ($view == '' || $view == 'designs'));
             if ($component->element == self::$extension) {
                 if ($view == 'designs' || $view == 'albums' || $view == 'import' || $view == 'revisions') {
                     JHtmlSidebar::addEntry("→ " . JText::_('COM_PROJECTFORK_SUBMENU_DESIGN_ALBUMS'), 'index.php?option=com_pfdesigns&view=albums', $view == 'albums');
                     JHtmlSidebar::addEntry("→ " . JText::_('COM_PROJECTFORK_SUBMENU_DESIGN_IMPORT'), 'index.php?option=com_pfdesigns&view=import', $view == 'import');
                     if ($view == 'revisions') {
                         JHtmlSidebar::addEntry("→ " . JText::_('COM_PROJECTFORK_SUBMENU_DESIGN_REVISIONS'), 'index.php?option=com_pfdesigns&view=revisions', $view == 'revisions');
                     }
                 }
             }
         } else {
             // Joomla 2.5
             JSubMenuHelper::addEntry($title, 'index.php?option=' . $component->element, $option == $component->element && ($view == '' || $view == 'designs'));
             if ($component->element == self::$extension && ($view == 'designs' || $view == 'albums')) {
                 JSubMenuHelper::addEntry(JText::_('COM_PROJECTFORK_SUBMENU_DESIGN_ALBUMS'), 'index.php?option=com_pfdesigns&view=albums', $view == 'albums');
             }
             if ($component->element == self::$extension && $view == 'revisions') {
                 JSubMenuHelper::addEntry(JText::_('COM_PROJECTFORK_SUBMENU_DESIGN_REVISIONS'), 'index.php?option=com_pfdesigns&view=revisions', $view == 'revisions');
             }
             if ($component->element == self::$extension && ($view == 'revisions' || $view == 'designs' || $view == 'import')) {
                 JSubMenuHelper::addEntry(JText::_('COM_PROJECTFORK_SUBMENU_DESIGN_IMPORT'), 'index.php?option=com_pfdesigns&view=import', $view == 'import');
             }
         }
     }
 }
 /**
  * Discovers the table classes in all Projectfork related components.
  * Stores an instance in $table_cache.
  *
  * @return    void
  */
 public static function discover()
 {
     static $loaded = false;
     if ($loaded) {
         return;
     }
     $coms = PFApplicationHelper::getComponents();
     foreach ($coms as $com) {
         $path = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $com->element . '/tables');
         $prefixes = array('PFtable', 'JTable', ucfirst(substr($com->element, 3)) . 'Table');
         if (!is_dir($path)) {
             continue;
         }
         $files = JFolder::files($path, '.php$');
         if (!count($files)) {
             continue;
         }
         // Discover the table class names with some guessing about the prefix
         foreach ($prefixes as $prefix) {
             JLoader::discover($prefix, $path, false);
             foreach ($files as $file) {
                 $name = JFile::stripExt($file);
                 $class = $prefix . $name;
                 $context = strtolower($com->element . '.' . $name);
                 if (class_exists($class)) {
                     // Class found, try to get an instance
                     $instance = JTable::getInstance($name, $prefix);
                     if (!$instance) {
                         continue;
                     }
                     self::$context_cache[] = $context;
                     self::$table_cache[$context] = $instance;
                     self::$methods_cache[$context] = array();
                     $methods = get_class_methods($instance);
                     foreach ($methods as $method) {
                         self::$methods_cache[$context][] = strtolower($method);
                     }
                 }
             }
         }
     }
     $loaded = true;
 }
 /**
  * Configure the Linkbar.
  *
  * @param     string    $view    The name of the active view.
  *
  * @return    void
  */
 public static function addSubmenu($view)
 {
     $is_j3 = version_compare(JVERSION, '3.0.0', 'ge');
     if ($view == 'milestone' && $is_j3) {
         return;
     }
     $components = PFApplicationHelper::getComponents();
     $option = JFactory::getApplication()->input->get('option');
     $class = $is_j3 ? 'JHtmlSidebar' : 'JSubMenuHelper';
     foreach ($components as $component) {
         if ($component->enabled == '0') {
             continue;
         }
         $title = JText::_($component->element);
         $parts = explode('-', $title, 2);
         if (count($parts) == 2) {
             $title = trim($parts[1]);
         }
         call_user_func(array($class, 'addEntry'), $title, 'index.php?option=' . $component->element, $option == $component->element);
     }
 }
Beispiel #8
0
 public static function isSupported($context, $params = null)
 {
     list($component, $item) = explode('.', $context, 2);
     $components = PFApplicationHelper::getComponents();
     if (!array_key_exists($component, $components)) {
         return false;
     }
     if (!self::getComponentHelper($component)) {
         return false;
     }
     $class_name = 'PF' . str_replace('com_pf', '', $component) . 'NotificationsHelper';
     $methods = get_class_methods($class_name);
     if (!in_array('isSupported', $methods)) {
         return false;
     }
     if (is_object($params)) {
         $settings = array('com_pfprojects' => (int) $params->get('projects_enabled', 1), 'com_pfmilestones' => (int) $params->get('milestones_enabled', 1), 'com_pftasks' => (int) $params->get('tasks_enabled', 1), 'com_pfforum' => (int) $params->get('forum_enabled', 1), 'com_pfrepo' => (int) $params->get('repo_enabled', 1), 'com_pfdesigns' => (int) $params->get('designs_enabled', 1));
         if (array_key_exists($component, $settings)) {
             if (!$settings[$component]) {
                 return false;
             }
         }
     }
     $supported = call_user_func(array($class_name, 'isSupported'), $context);
     return $supported;
 }
 public static function isSupported($context)
 {
     list($component, $item) = explode('.', $context, 2);
     $components = PFApplicationHelper::getComponents();
     if (!array_key_exists($component, $components)) {
         return false;
     }
     if (!self::getComponentHelper($component)) {
         return false;
     }
     $class_name = 'PF' . str_replace('com_pf', '', $component) . 'NotificationsHelper';
     $methods = get_class_methods($class_name);
     if (!in_array('isSupported', $methods)) {
         return false;
     }
     $supported = call_user_func(array($class_name, 'isSupported'), $context);
     return $supported;
 }
 /**
  * Method to get item data.
  *
  * @param     integer    The id of the item.
  *
  * @return    mixed      Record object on success, false on failure.
  */
 public function getItem($pk = null)
 {
     // Initialise variables.
     $pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
     if ($this->_item === null) {
         $this->_item = array();
     }
     if (isset($this->_item[$pk])) {
         return $this->_item[$pk];
     }
     $cfg = JComponentHelper::getParams('com_pfprojects');
     $create_group = (int) $cfg->get('create_group');
     $group_location = (int) $cfg->get('group_location');
     $inherit = $this->getState($this->getName() . '.inherit');
     if (!$group_location) {
         $group_location = 1;
     }
     try {
         $db = $this->getDbo();
         $query = $db->getQuery(true);
         if (!$inherit && !$pk && $create_group) {
             $item = new stdClass();
             $item->id = 0;
             $item->parent_id = $group_location;
             $item->lft = 0;
             $item->rgt = 0;
             $item->title = JText::_('COM_PFUSERS_DEFAULT_GROUP');
         } else {
             $query->select('id, parent_id, lft, rgt, title')->from('#__usergroups')->where('id = ' . (int) $pk);
             $db->setQuery($query);
             $item = $db->loadObject();
         }
         if ($error = $db->getErrorMsg()) {
             throw new Exception($error);
         }
         $this->_item[$pk] = empty($item) ? false : $item;
         if ($this->_item[$pk]) {
             if (!$inherit) {
                 $component = $this->getState($this->getName() . '.component');
                 $section = $this->getState($this->getName() . '.section');
                 $this->_item[$pk]->actions = array();
                 $this->_item[$pk]->actions[$component] = JAccess::getActions($component, $section);
                 $components = PFApplicationHelper::getComponents();
                 foreach ($components as $name => $item) {
                     if ($name == $component) {
                         continue;
                     }
                     $use_asset = PFApplicationHelper::usesProjectAsset($name);
                     $enabled = PFApplicationHelper::enabled($name);
                     if (!$use_asset || !$enabled) {
                         continue;
                     }
                     $this->_item[$pk]->actions[$name] = JAccess::getActions($name, $section);
                 }
                 // Get child group names
                 if ($this->_item[$pk]->lft && $this->_item[$pk]->rgt) {
                     $this->_item[$pk]->children = $this->getChildGroups($this->_item[$pk]->lft, $this->_item[$pk]->rgt);
                 } else {
                     $this->_item[$pk]->children = array();
                 }
             } else {
                 $component = $this->getState($this->getName() . '.component');
                 $section = $this->getState($this->getName() . '.section');
                 $this->_item[$pk]->actions = JAccess::getActions($component, $section);
                 // Get child group names
                 if ($this->_item[$pk]->lft && $this->_item[$pk]->rgt) {
                     $this->_item[$pk]->children = $this->getChildGroups($this->_item[$pk]->lft, $this->_item[$pk]->rgt);
                 } else {
                     $this->_item[$pk]->children = array();
                 }
             }
         }
     } catch (JException $e) {
         if ($e->getCode() == 404) {
             // Need to go thru the error handler to allow Redirect to work.
             JError::raiseError(404, $e->getMessage());
         } else {
             $this->setError($e);
             $this->_item[$pk] = false;
         }
     }
     return $this->_item[$pk];
 }
 /**
  * Method to store the project asset for the other PF components
  *
  * @param     mixed      $pk    An optional primary key value to delete.
  *
  * @return    boolean           True on success.
  */
 public function storeComponentAssets($pk = null)
 {
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     if (!$pk) {
         return false;
     }
     $components = PFApplicationHelper::getComponents();
     $query = $this->_db->getQuery(true);
     $ignore = array('com_projectfork', 'com_pfprojects');
     // First, find the asset id's of each component
     // Then, search for corresponding project asset
     // And lastly, create the project asset if it does not exist
     foreach ($components as $name => $item) {
         if (!PFApplicationHelper::usesProjectAsset($name)) {
             continue;
         }
         // Search component asset
         $query->clear();
         $query->select('id')->from('#__assets')->where('name = ' . $this->_db->quote($name))->order('id ASC');
         $this->_db->setQuery($query, 0, 1);
         $com_asset = (int) $this->_db->loadResult();
         if (!$com_asset) {
             continue;
         }
         // Search project asset
         $query->clear();
         $query->select('id')->from('#__assets')->where('parent_id = ' . $com_asset)->where('name = ' . $this->_db->quote($name . '.project.' . $pk))->order('id ASC');
         $this->_db->setQuery($query, 0, 1);
         $project_asset = (int) $this->_db->loadResult();
         if ($project_asset) {
             // Update asset
             $asset = self::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
             $asset->loadByName($name . '.project.' . $pk);
             if (isset($this->asset_rules[$name])) {
                 if ($this->asset_rules[$name] instanceof JAccessRules) {
                     $asset->rules = (string) $this->asset_rules[$name];
                 } else {
                     $asset->rules = '{}';
                 }
             } else {
                 $asset->rules = '{}';
             }
             if (!$asset->check() || !$asset->store(false)) {
                 $this->setError($asset->getError());
                 return false;
             }
         } else {
             // Create asset
             $asset = self::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
             $asset->setLocation($com_asset, 'last-child');
             $asset->parent_id = $com_asset;
             $asset->name = $name . '.project.' . $pk;
             $asset->title = empty($this->title) ? $asset->name : $this->title;
             if (isset($this->asset_rules[$name])) {
                 if ($this->asset_rules[$name] instanceof JAccessRules) {
                     $asset->rules = (string) $this->asset_rules[$name];
                 }
             }
             if (!$asset->check() || !$asset->store(false)) {
                 $this->setError($asset->getError());
                 return false;
             }
         }
     }
     return true;
 }
defined('_JEXEC') or die;
// Make sure the cms libraries are loaded
if (!defined('JPATH_PLATFORM')) {
    require_once dirname(__FILE__) . '/../cms.php';
}
if (!defined('PF_FRAMEWORK')) {
    define('PF_FRAMEWORK', 1);
} else {
    // Make sure we run the code below only once
    return;
}
jimport('joomla.filesystem.folder');
// Include the library
require_once dirname(__FILE__) . '/library.php';
// Get the list of Projectfork components, as well as the currently active
$components = PFApplicationHelper::getComponents();
$current = JFactory::getApplication()->input->get('option');
$lang = JFactory::getLanguage();
$is_site = JFactory::getApplication()->isSite();
// Go through each component
foreach ($components as $component) {
    $site_path = JPATH_SITE . '/components/' . $component->element;
    $admin_path = JPATH_ADMINISTRATOR . '/components/' . $component->element;
    $com_name = str_replace('com_', '', $component->element);
    if (substr($com_name, 0, 2) == 'pf') {
        $com_name = 'PF' . substr($com_name, 2);
    } else {
        $com_name = ucfirst($com_name);
    }
    // Begin loading language files
    if ($component->element != $current) {