当前位置: 首页>>代码示例>>PHP>>正文


PHP PFApplicationHelper::getActiveProjectId方法代码示例

本文整理汇总了PHP中PFApplicationHelper::getActiveProjectId方法的典型用法代码示例。如果您正苦于以下问题:PHP PFApplicationHelper::getActiveProjectId方法的具体用法?PHP PFApplicationHelper::getActiveProjectId怎么用?PHP PFApplicationHelper::getActiveProjectId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PFApplicationHelper的用法示例。


在下文中一共展示了PFApplicationHelper::getActiveProjectId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: populateState

 /**
  * Method to auto-populate the model state.
  * Note: Calling getState in this method will result in recursion.
  *
  * @param     string    $ordering     Default field to sort the items by
  * @param     string    $direction    Default list sorting direction
  *
  * @return    void
  */
 protected function populateState($ordering = 'a.created', $direction = 'desc')
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     // Adjust the context to support modal layouts.
     if ($layout = JRequest::getVar('layout')) {
         $this->context .= '.' . $layout;
     }
     // Filter - Search
     $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
     $this->setState('filter.search', $search);
     // Filter - Author
     $author_id = $app->getUserStateFromRequest($this->context . '.filter.author_id', 'filter_author_id');
     $this->setState('filter.author_id', $author_id);
     // Filter - State
     $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
     $this->setState('filter.published', $published);
     // Filter - Access
     $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', '');
     $this->setState('filter.access', $access);
     // Filter - Project
     $project = PFApplicationHelper::getActiveProjectId('filter_project');
     $this->setState('filter.project', $project);
     // Disable author filter if no project is selected
     if (!$project) {
         $this->setState('filter.author_id', '');
     }
     // List state information.
     parent::populateState($ordering, $direction);
 }
开发者ID:gagnonjeanfrancois,项目名称:Projectfork,代码行数:39,代码来源:topics.php

示例2: allowAdd

 /**
  * Method to check if you can add a new record.
  *
  * @param     array      $data    An array of input data.
  *
  * @return    boolean
  */
 protected function allowAdd($data = array())
 {
     // Get form input
     $project = isset($data['project_id']) ? (int) $data['project_id'] : PFApplicationHelper::getActiveProjectId();
     $ms = isset($data['milestone_id']) ? (int) $data['milestone_id'] : 0;
     $user = JFactory::getUser();
     $db = JFactory::getDbo();
     $is_sa = $user->authorise('core.admin');
     $levels = $user->getAuthorisedViewLevels();
     $query = $db->getQuery(true);
     $asset = 'com_pftasks';
     $access = true;
     // Check if the user has access to the project
     if ($project) {
         // Check if in allowed projects when not a super admin
         if (!$is_sa) {
             $access = in_array($project, PFUserHelper::getAuthorisedProjects());
         }
         // Change the asset name
         $asset .= '.project.' . $project;
     }
     // Check if the user can access the selected milestone when not a super admin
     if (!$is_sa && $ms && $access) {
         $query->select('access')->from('#__pf_milestones')->where('id = ' . $db->quote((int) $ms));
         $db->setQuery($query);
         $lvl = $db->loadResult();
         $access = in_array($lvl, $levels);
     }
     return $user->authorise('core.create', $asset) && $access;
 }
开发者ID:gagnonjeanfrancois,项目名称:Projectfork,代码行数:37,代码来源:tasklistform.json.php

示例3: getItems

 /**
  * Method to get a list of tasks
  *
  * @return    array    $items    The tasks
  */
 public static function getItems($params)
 {
     JLoader::register('PFtasksModelTasks', JPATH_SITE . '/components/com_pftasks/models/tasks.php');
     $model = JModelLegacy::getInstance('Tasks', 'PFtasksModel', array('ignore_request' => true));
     // Set application parameters in model
     $app = JFactory::getApplication();
     $appParams = $app->getParams();
     $model->setState('params', $appParams);
     // Set the filters based on the module params
     $model->setState('list.start', 0);
     $model->setState('list.limit', (int) $params->get('count', 10));
     $model->setState('filter.published', 1);
     // Set project filter
     if (!(int) $params->get('tasks_of')) {
         $model->setState('filter.project', PFApplicationHelper::getActiveProjectId());
     } else {
         $project = (int) $params->get('project');
         if ($project) {
             $model->setState('filter.project', $project);
         } else {
             $model->setState('filter.project', PFApplicationHelper::getActiveProjectId());
         }
     }
     // Set completition filter
     $model->setState('filter.complete', $params->get('filter_complete'));
     // Sort and order
     $model->setState('list.ordering', $params->get('sort'));
     $model->setState('list.direction', $params->get('order'));
     $items = $model->getItems();
     return $items;
 }
开发者ID:gagnonjeanfrancois,项目名称:Projectfork,代码行数:36,代码来源:helper.php

示例4: allowAdd

 /**
  * Method to check if you can add a new record.
  *
  * @param     array      $data    An array of input data.
  *
  * @return    boolean
  */
 protected function allowAdd($data = array())
 {
     $user = JFactory::getUser();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $access = true;
     $project = isset($data['project_id']) ? (int) $data['project_id'] : PFApplicationHelper::getActiveProjectId();
     $album = isset($data['album_id']) ? (int) $data['album_id'] : 0;
     $asset = 'com_pfdesigns';
     // Check if the user has access to the album
     if (!$user->authorise('core.admin')) {
         if ($album && $access) {
             $query->clear();
             $query->select('access')->from('#__pf_design_albums')->where('id = ' . (int) $album);
             $db->setQuery($query);
             $access = in_array((int) $db->loadResult(), $levels);
         }
     }
     // Check if the user has access to the project
     if (!$user->authorise('core.admin')) {
         if ($project && $access) {
             $query->select('access')->from('#__pf_projects')->where('id = ' . (int) $project);
             $db->setQuery($query);
             $access = in_array((int) $db->loadResult(), $user->getAuthorisedViewLevels());
             // Change the asset name
             if (version_compare(PFVERSION, '4.2', 'ge')) {
                 $asset .= '.project.' . $project;
             }
         }
     }
     return $user->authorise('core.create', $asset) && $access;
 }
开发者ID:MrJookie,项目名称:pm,代码行数:39,代码来源:designform.json.php

示例5: getMilestoneRoute

 /**
  * Creates a link to a milestone item view
  *
  * @param     string    $milestone_slug    The milestone slug
  * @param     string    $project_slug      The project slug. Optional
  *
  * @return    string    $link              The link
  */
 public static function getMilestoneRoute($milestone_slug, $project_slug = '')
 {
     if (!$project_slug) {
         $project_slug = PFApplicationHelper::getActiveProjectId();
     }
     $link = 'index.php?option=com_pfmilestones&view=milestone&filter_project=' . $project_slug . '&id=' . $milestone_slug;
     // Get the id from the slug
     if (strrpos($milestone_slug, ':') !== false) {
         $slug_parts = explode(':', $milestone_slug);
         $milestone_id = (int) $slug_parts[0];
     } else {
         $milestone_id = (int) $milestone_slug;
     }
     $needles = array('id' => array($milestone_slug));
     $item = PFApplicationHelper::itemRoute($needles, 'com_pfmilestones.milestone');
     if (!$item) {
         $app = JFactory::getApplication();
         // Stay on current menu item if we are viewing a milestone list
         if ($app->input->get('option') == 'com_pfmilestones' && $app->input->get('view') == 'milestones') {
             $item = PFApplicationHelper::getActiveMenuItemId();
         } else {
             // Find overview menu item
             $item = PFApplicationHelper::itemRoute(null, 'com_pfmilestones.milestones');
         }
     }
     if ($item) {
         $link .= '&Itemid=' . $item;
     }
     return $link;
 }
开发者ID:eno93,项目名称:Projectfork,代码行数:38,代码来源:route.php

示例6: display

 /**
  * Displays the view.
  *
  */
 public function display($tpl = null)
 {
     // Get data from model
     $this->items = $this->get('Items');
     $this->state = $this->get('State');
     $this->albums = $this->get('Albums');
     $this->designs = $this->get('Designs');
     if (PFApplicationHelper::getActiveProjectId() <= 0) {
         $text = JText::_('COM_PROJECTFORK_DESIGNS_WARNING_IMPORT_SELECT_PROJECT');
         JFactory::getApplication()->enqueueMessage($text);
     }
     // Check for errors
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     if ($this->getLayout() !== 'modal') {
         $this->addToolbar();
         if (version_compare(JVERSION, '3', 'ge')) {
             PFdesignsHelper::addSubmenu('import');
             $this->sidebar = JHtmlSidebar::render();
         }
     }
     parent::display($tpl);
 }
开发者ID:MrJookie,项目名称:pm,代码行数:29,代码来源:view.html.php

示例7: getSiteButtons

 /**
  * Returns a list of buttons for the frontend
  *
  * @return    array
  */
 public static function getSiteButtons()
 {
     $user = JFactory::getUser();
     $buttons = array();
     $pid = PFApplicationHelper::getActiveProjectId();
     $asset = 'com_pfmilestones';
     if ($pid) {
         $asset .= '.project.' . $pid;
     }
     if ($user->authorise('core.create', $asset)) {
         $buttons[] = array('title' => 'MOD_PF_DASH_BUTTONS_ADD_MILESTONE', 'link' => PFmilestonesHelperRoute::getMilestonesRoute() . '&task=form.add', 'icon' => JHtml::image('com_projectfork/projectfork/header/icon-48-milestoneform.add.png', JText::_('MOD_PF_DASH_BUTTONS_ADD_MILESTONE'), null, true));
     }
     return $buttons;
 }
开发者ID:gagnonjeanfrancois,项目名称:Projectfork,代码行数:19,代码来源:dashboard.php

示例8: display

 /**
  * Method to display a view.
  *
  * @param     boolean        If true, the view output will be cached
  * @param     array          An array of safe url parameters
  *
  * @return    jcontroller    This object to support chaining.
  */
 public function display($cachable = false, $urlparams = false)
 {
     $view = JRequest::getCmd('view', $this->default_view);
     $layout = JRequest::getCmd('layout');
     $id = JRequest::getUint('id');
     // Inject default view if not set
     if (empty($view)) {
         JRequest::setVar('view', $this->default_view);
         $view = $this->default_view;
     }
     if ($view == $this->default_view) {
         $parent_id = JRequest::getUInt('filter_parent_id');
         $project = PFApplicationHelper::getActiveProjectId('filter_project');
         if ($parent_id && $project === "") {
             $this->setRedirect('index.php?option=com_pfrepo&view=' . $this->default_view);
             return $this;
         } elseif ($parent_id > 1 && $project > 0) {
             // Check if the folder belongs to the project
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select('project_id')->from('#__pf_repo_dirs')->where('id = ' . (int) $parent_id);
             $db->setQuery($query);
             $pid = $db->loadResult();
             if ($pid != $project) {
                 // No match, redirect to the project root dir
                 $query->clear();
                 $query->select('id, path')->from('#__pf_repo_dirs')->where('parent_id = 1')->where('project_id = ' . (int) $project);
                 $db->setQuery($query, 0, 1);
                 $dir = $db->loadObject();
                 if ($dir) {
                     $this->setRedirect('index.php?option=com_pfrepo&view=' . $this->default_view . '&filter_project=' . $project . '&filter_parent_id=' . $dir->id);
                     return $this;
                 }
             }
         }
     }
     // Check form edit access
     if ($layout == 'edit' && !$this->checkEditId('com_pfrepo.edit.' . $view, $id)) {
         $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(JRoute::_('index.php?option=com_pfrepo&view=' . $this->default_view, false));
         return false;
     }
     // Add the sub-menu
     PFrepoHelper::addSubmenu($view);
     // Display the view
     parent::display($cachable, $urlparams);
     return $this;
 }
开发者ID:gagnonjeanfrancois,项目名称:Projectfork,代码行数:57,代码来源:controller.php

示例9: getActions

 /**
  * Gets a list of actions that can be performed.
  *
  * @param     integer    $id    The item id
  *
  * @return    jobject
  */
 public static function getActions($id = 0)
 {
     $user = JFactory::getUser();
     $result = new JObject();
     if (empty($id)) {
         $pid = PFApplicationHelper::getActiveProjectId();
         $asset = empty($pid) ? self::$extension : 'com_pfmilestones.project.' . $pid;
     } else {
         $asset = 'com_pfmilestones.milestone.' . (int) $id;
     }
     $actions = array('core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.own', 'core.edit.state', 'core.delete');
     foreach ($actions as $action) {
         $result->set($action, $user->authorise($action, $asset));
     }
     return $result;
 }
开发者ID:gagnonjeanfrancois,项目名称:Projectfork,代码行数:23,代码来源:pfmilestones.php

示例10: populateState

 /**
  * Method to auto-populate the model state.
  * Note. Calling getState in this method will result in recursion.
  *
  * @return    void
  */
 protected function populateState($ordering = null, $direction = null)
 {
     parent::populateState();
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $model = $this->getInstance('Form', 'PFprojectsModel', array('ignore_request' => true));
     $groups = array();
     // Filter - State
     $this->setState('filter.state', 0);
     // Filter - Project
     $pid = PFApplicationHelper::getActiveProjectId('filter_project');
     $this->setState('filter.project', $pid);
     // Override group filter by active project
     if ($pid) {
         $tmp_groups = $model->getUserGroups($pid);
         // Get group ids
         if (is_array($tmp_groups)) {
             foreach ($tmp_groups as $group) {
                 $groups[] = (int) $group;
             }
         }
     } else {
         // No active project. Filter by all accessible projects
         if (!$user->authorise('core.admin')) {
             $umodel = $this->getInstance('User', 'PFusersModel');
             $projects = $umodel->getProjects();
             foreach ($projects as $project) {
                 $tmp_groups = $model->getUserGroups($project);
                 if ($tmp_groups !== false) {
                     // Get group ids
                     if (is_array($tmp_groups)) {
                         foreach ($tmp_groups as $group) {
                             $groups[] = (int) $group;
                         }
                     }
                 }
             }
         }
     }
     if (count($groups)) {
         $this->setState('filter.groups', $groups);
     } else {
         if (!$user->authorise('core.admin')) {
             $this->setState('filter.groups', array('1'));
         }
     }
 }
开发者ID:gagnonjeanfrancois,项目名称:Projectfork,代码行数:53,代码来源:users.php

示例11: allowAdd

 /**
  * Method to check if you can add a new record.
  *
  * @param     array      $data    An array of input data.
  *
  * @return    boolean
  */
 protected function allowAdd($data = array())
 {
     // Get form input
     $project = isset($data['project_id']) ? (int) $data['project_id'] : PFApplicationHelper::getActiveProjectId();
     $user = JFactory::getUser();
     $asset = 'com_pftime';
     $access = true;
     if ($project) {
         // Check if the user has viewing access when not a super admin
         if (!$user->authorise('core.admin')) {
             $access = in_array($project, PFUserHelper::getAuthorisedProjects());
         }
         // Change the asset name
         $asset .= '.project.' . $project;
     }
     return $user->authorise('core.create', $asset) && $access;
 }
开发者ID:gagnonjeanfrancois,项目名称:Projectfork,代码行数:24,代码来源:form.json.php

示例12: getInput

 /**
  * Method to get the field input markup.
  *
  * @return    string    The html field markup
  */
 protected function getInput()
 {
     // Add the script to the document head.
     $script = $this->getJavascript();
     JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
     if (!is_array($this->value)) {
         $this->value = array();
     }
     $project = (int) $this->form->getValue('project_id');
     $hidden = '<input type="hidden" name="' . $this->name . '[]" value="" />';
     if (!$project) {
         $project = PFApplicationHelper::getActiveProjectId();
     }
     if (!$project) {
         return '<span class="readonly">' . JText::_('COM_PROJECTFORK_FIELD_PROJECT_REQ') . '</span>' . $hidden;
     }
     $html = $this->getHTML($project);
     return implode("\n", $html);
 }
开发者ID:gagnonjeanfrancois,项目名称:Projectfork,代码行数:24,代码来源:taskdependency.php

示例13: init

 /**
  * Init the helper class and populates member vars
  *
  * @param    object    $params    The module params
  * @param    integer   $id        The module id
  *
  * @return    void
  */
 public static function init($params, $id)
 {
     $user = JFactory::getUser();
     $config = JFactory::getConfig();
     $date_now = new JDate('now', 'UTC');
     $date_now->setTimezone(new DateTimeZone($user->getParam('timezone', $config->get('offset'))));
     self::$time_today = floor($date_now->toUnix() / 86400) * 86400;
     self::$params = $params;
     self::$id = (int) $id;
     if ($params->get('mode')) {
         self::$project = (int) $params->get('project');
     } else {
         self::$project = (int) PFApplicationHelper::getActiveProjectId();
     }
     // Get project dates
     $dates = modPFganttHelperProjects::getDateRange();
     self::$project_start = $dates[0];
     self::$project_end = $dates[1];
 }
开发者ID:MrJookie,项目名称:pm,代码行数:27,代码来源:helper.php

示例14: getItems

 /**
  * Method to get a list of tasks
  *
  * @return    array    $items    The tasks
  */
 public static function getItems($params)
 {
     $user = JFactory::getUser();
     JLoader::register('PFtimeModelTimesheet', JPATH_SITE . '/components/com_pftime/models/timesheet.php');
     $model = JModelLegacy::getInstance('Timesheet', 'PFtimeModel', array('ignore_request' => true));
     // Set application parameters in model
     $app = JFactory::getApplication();
     $appParams = $app->getParams();
     $model->setState('params', $appParams);
     if (intval($params->get('filter_own')) == 1) {
         $model->setState('filter.author', $user->get('id'));
     }
     // Set the filters based on the module params
     $model->setState('list.start', 0);
     $model->setState('list.limit', (int) $params->get('count', 5));
     $project = PFApplicationHelper::getActiveProjectId();
     $model->setState('filter.project', $project);
     $items = $model->getItems();
     return $items;
 }
开发者ID:sgershen,项目名称:Projectfork,代码行数:25,代码来源:helper.php

示例15: populateState

 /**
  * Method to auto-populate the model state.
  * Note. Calling getState in this method will result in recursion.
  *
  * @return    void
  */
 protected function populateState()
 {
     $app = JFactory::getApplication();
     $pk = JRequest::getUInt('id');
     $parent = JRequest::getUInt('filter_parent_id');
     $option = JRequest::getVar('option');
     $return = JRequest::getVar('return', null, 'default', 'base64');
     $project = PFApplicationHelper::getActiveProjectId();
     // Set primary key
     $this->setState($this->getName() . '.id', $pk);
     // Set return page
     $this->setState('return_page', base64_decode($return));
     // Set params
     $params = $app->getParams();
     $this->setState('params', $params);
     // Set layout
     $this->setState('layout', JRequest::getCmd('layout'));
     // Set parent id
     $this->setState($this->getName() . '.parent_id', $parent);
     // Set project
     $this->setState($this->getName() . '.project', $project);
 }
开发者ID:gagnonjeanfrancois,项目名称:Projectfork,代码行数:28,代码来源:directoryform.php


注:本文中的PFApplicationHelper::getActiveProjectId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。