/** * Method to get the options to populate list * * @return array The field option objects. * * @since 3.2 */ protected function getOptions() { // Hash for caching $hash = md5($this->element); if (!isset(static::$options[$hash])) { static::$options[$hash] = parent::getOptions(); $options = array(); $db = JFactory::getDbo(); $user = JFactory::getUser(); $query = $db->getQuery(true)->select('a.id AS value')->select('a.title AS text')->select('COUNT(DISTINCT b.id) AS level')->from('#__categories as a')->where('a.extension = "' . $this->extension . '"')->join('LEFT', '#__categories AS b ON a.lft > b.lft AND a.rgt < b.rgt')->group('a.id, a.title, a.lft, a.rgt')->order('a.lft ASC'); $isRoot = $user->authorise('core.admin'); if (!$isRoot) { require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/imc.php'; $allowed_catids = ImcHelper::getCategoriesByUserGroups(); $allowed_catids = implode(',', $allowed_catids); if (!empty($allowed_catids)) { $query->where('a.id IN (' . $allowed_catids . ')'); } } $db->setQuery($query); if ($options = $db->loadObjectList()) { foreach ($options as &$option) { $option->text = str_repeat('- ', $option->level) . $option->text; } static::$options[$hash] = array_merge(static::$options[$hash], $options); } } return static::$options[$hash]; }
/** * Add the page title and toolbar. */ protected function addToolbar() { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $isNew = $this->item->id == 0; if (isset($this->item->checked_out)) { $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); } else { $checkedOut = false; } $canDo = ImcHelper::getActions(); JToolBarHelper::title(JText::_('COM_IMC_TITLE_STEP'), 'drawer-2'); // If not checked out, can save the item. if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) { JToolBarHelper::apply('step.apply', 'JTOOLBAR_APPLY'); JToolBarHelper::save('step.save', 'JTOOLBAR_SAVE'); } if (!$checkedOut && $canDo->get('core.create')) { JToolBarHelper::custom('step.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); } // If an existing item, can save to a copy. if (!$isNew && $canDo->get('core.create')) { JToolBarHelper::custom('step.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); } if (empty($this->item->id)) { JToolBarHelper::cancel('step.cancel', 'JTOOLBAR_CANCEL'); } else { JToolBarHelper::cancel('step.cancel', 'JTOOLBAR_CLOSE'); } }
public function postComment() { $app = JFactory::getApplication(); $params = $app->getParams('com_imc'); $showComments = $params->get('enablecomments'); $directpublishing = $params->get('directpublishingcomment'); try { // Check for request forgeries. if (!JSession::checkToken('get')) { throw new Exception('Invalid session token'); } if (!$showComments) { throw new Exception('Comments are not allowed'); } $issueid = $app->input->getInt('issueid', null); $userid = $app->input->getInt('userid', null); $parentid = $app->input->getInt('parentid', 0); $description = $app->input->getString('description', ''); if (is_null($issueid) || is_null($userid)) { throw new Exception('issueid or userid are missing'); } //check is user is admin $created_by_admin = ImcHelper::getActions()->get('imc.manage.comments'); //make comment $comment = new StdClass(); $comment->state = 1; $comment->issueid = $issueid; if ($parentid > 0) { $comment->parentid = $parentid; } $comment->created = ImcFrontendHelper::convert2UTC(date('Y-m-d H:i:s')); $comment->updated = $comment->created; $comment->created_by = $userid; $comment->description = $description; $comment->fullname = JFactory::getUser($userid)->name; $comment->moderation = !$directpublishing && !$created_by_admin ? 1 : 0; $comment->language = "*"; $comment->isAdmin = (int) $created_by_admin; //post comment to the model $commentModel = $this->getModel(); $insertedId = $commentModel->add($comment); //fill missing fields to be aligned with jquery-comments and send back to the client $comment->id = $insertedId; $comment->profile_picture_url = JURI::base() . 'components/com_imc/assets/images/user-icon.png'; $comment->created_by_admin = $created_by_admin; $comment->created_by_current_user = true; if ($comment->moderation) { $comment->profile_picture_url = JURI::base() . 'components/com_imc/assets/images/user-icon-moderated.png'; } if ($created_by_admin) { $comment->profile_picture_url = JURI::base() . 'components/com_imc/assets/images/admin-user-icon.png'; } echo new JResponseJson($comment); } catch (Exception $e) { header("HTTP/1.0 403 Accepted"); echo new JResponseJson($e); } }
/** * Method to get the options to populate list * * @return array The field option objects. * * @since 3.2 */ protected function getOptions() { $showEmpty = $this->element['showempty']; // Hash for caching $hash = md5($this->element); if (!isset(static::$options[$hash])) { static::$options[$hash] = parent::getOptions(); $options = array(); $db = JFactory::getDbo(); $user = JFactory::getUser(); $canDo = ImcHelper::getActions(); $canShowAllIssues = $canDo->get('imc.showall.issues'); if ($canShowAllIssues) { $query = $db->getQuery(true)->select('a.id AS value')->select('a.title AS text')->select('COUNT(DISTINCT b.id) AS level')->from('#__usergroups as a')->where('a.id > 9')->join('LEFT', '#__usergroups AS b ON a.lft > b.lft AND a.rgt < b.rgt')->group('a.id, a.title, a.lft, a.rgt')->order('a.lft ASC'); } else { //get user groups higher than 9 $usergroups = JAccess::getGroupsByUser($user->id, false); for ($i = 0; $i < count($usergroups); $i++) { if ($usergroups[$i] <= 9) { unset($usergroups[$i]); } } $ids = implode(',', $usergroups); //get lft, rgt for these groups $where = array(); $query = $db->getQuery(true)->select('a.id, a.lft, a.rgt')->from('#__usergroups as a')->where('a.id IN (' . $ids . ')'); $db->setQuery($query); if ($grps = $db->loadAssocList()) { foreach ($grps as $grp) { $where[] = '(a.lft >= ' . $grp['lft'] . ' AND a.rgt <= ' . $grp['rgt'] . ')'; $where[] = ' OR '; } array_pop($where); } else { $where[] = "1=1"; } $query = $db->getQuery(true)->select('a.id AS value')->select('a.title AS text')->select('COUNT(DISTINCT b.id) AS level')->from('#__usergroups as a')->where('a.id > 9')->where(implode("\n", $where))->join('LEFT', '#__usergroups AS b ON a.lft > b.lft AND a.rgt < b.rgt')->group('a.id, a.title, a.lft, a.rgt')->order('a.lft ASC'); } $db->setQuery($query); if ($options = $db->loadObjectList()) { if ($showEmpty) { $empty = new stdClass(); $empty->value = '0'; $empty->text = ''; $empty->level = 1; array_unshift($options, $empty); } foreach ($options as &$option) { $option->text = str_repeat('- ', $option->level) . $option->text; } static::$options[$hash] = array_merge(static::$options[$hash], $options); } } return static::$options[$hash]; }
/** * Add the page title and toolbar. */ protected function addToolbar() { JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); $isNew = $this->item->id == 0; if (isset($this->item->checked_out)) { $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); } else { $checkedOut = false; } $canDo = ImcHelper::getActions(); JToolBarHelper::title(JText::_('COM_IMC_TITLE_ISSUE'), 'drawer'); // If not checked out, can save the item. if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) { JToolBarHelper::apply('issue.apply', 'JTOOLBAR_APPLY'); JToolBarHelper::save('issue.save', 'JTOOLBAR_SAVE'); } // if (!$checkedOut && ($canDo->get('core.create'))) { // JToolBarHelper::custom('issue.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); // } // If an existing item, can save to a copy. //if (!$isNew && $canDo->get('core.create')) { // JToolBarHelper::custom('issue.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); //} if (!empty($this->item->id)) { //on existing allow printing //JToolBarHelper::custom('issue.printIssue', 'print.png', 'print.png', 'COM_IMC_PRINT', false); $bar = JToolBar::getInstance('toolbar'); $layout = new JLayoutFile('joomla.toolbar.popup'); $dhtml = $layout->render(array('doTask' => 'print', 'class' => 'icon-print', 'text' => JText::_('COM_IMC_PRINT'), 'name' => 'imc-print')); $bar->appendButton('Custom', $dhtml); //$url = 'index.php?option=com_imc&view=issue&task=issue.printIssue&id='.$this->item->id.'&tmpl=component'; //$bar->appendButton('Popup', 'print', 'JTOOLBAR_EXPORT', $url); } if (empty($this->item->id)) { JToolBarHelper::cancel('issue.cancel', 'JTOOLBAR_CANCEL'); } else { JToolBarHelper::cancel('issue.cancel', 'JTOOLBAR_CLOSE'); } }
/** * Method to get the record form. * * @param array $data An optional array of data for the form to interogate. * @param boolean $loadData True if the form is to load its own data (default case), false if not. * @return JForm A JForm object on success, false on failure * @since 1.6 */ public function getForm($data = array(), $loadData = true) { // Initialise variables. $app = JFactory::getApplication(); // Get the form. $form = $this->loadForm('com_imc.log', 'log', array('control' => 'jform', 'load_data' => $loadData)); if (empty($form)) { return false; } $canDo = ImcHelper::getActions(); $canManageLogs = $canDo->get('imc.manage.logs'); if (!$canManageLogs) { //TODO: This alert to be moved on view echo '<div class="alert alert-info"><button type="button" class="close" data-dismiss="alert">×</button>' . JText::_('COM_IMC_ACTION_ALERT') . '</div>'; // Disable fields for display. $form->setFieldAttribute('state', 'disabled', 'true'); $form->setFieldAttribute('stepid', 'disabled', 'true'); $form->setFieldAttribute('issueid', 'disabled', 'true'); $form->setFieldAttribute('action', 'disabled', 'true'); $form->setFieldAttribute('description', 'disabled', 'true'); } return $form; }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/imc.php'; $state = $this->get('State'); $canDo = ImcHelper::getActions($state->get('filter.category_id')); JToolBarHelper::title(JText::_('COM_IMC_TITLE_ISSUES'), 'drawer'); //Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/issue'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('issue.add', 'JTOOLBAR_NEW'); } if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('issue.edit', 'JTOOLBAR_EDIT'); } } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::custom('issues.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::custom('issues.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); } else { if (isset($this->items[0])) { //If this component does not use state then show a direct delete button as we can not trash JToolBarHelper::deleteList('', 'issues.delete', 'JTOOLBAR_DELETE'); } } if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::archiveList('issues.archive', 'JTOOLBAR_ARCHIVE'); } if (isset($this->items[0]->checked_out)) { JToolBarHelper::custom('issues.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); } } //Show trash and delete for components that uses the state field if (isset($this->items[0]->state)) { if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'issues.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } else { if ($canDo->get('core.edit.state')) { JToolBarHelper::trash('issues.trash', 'JTOOLBAR_TRASH'); JToolBarHelper::divider(); } } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_imc'); } //Set sidebar action - New in 3.0 JHtmlSidebar::setAction('index.php?option=com_imc&view=issues'); $this->extra_sidebar = ''; JHtmlSidebar::addFilter(JText::_("JOPTION_SELECT_CATEGORY"), 'filter_catid', JHtml::_('select.options', JHtml::_('category.options', 'com_imc'), "value", "text", $this->state->get('filter.catid'))); //Get custom field JFormHelper::addFieldPath(JPATH_ROOT . '/components/com_imc/models/fields'); $steps = JFormHelper::loadFieldType('Step', false); $options = $steps->getOptions(); JHtmlSidebar::addFilter(JText::_("COM_IMC_ISSUES_STEPID_FILTER"), 'filter_stepid', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.stepid'), true)); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true)); }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT . '/helpers/imc.php'; $state = $this->get('State'); $canDo = ImcHelper::getActions($state->get('filter.category_id')); JToolBarHelper::title(JText::_('COM_IMC_TITLE_VOTES'), 'votes.png'); //Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/vote'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('vote.add', 'JTOOLBAR_NEW'); } if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('vote.edit', 'JTOOLBAR_EDIT'); } } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::custom('votes.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::custom('votes.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); } else { if (isset($this->items[0])) { //If this component does not use state then show a direct delete button as we can not trash JToolBarHelper::deleteList('', 'votes.delete', 'JTOOLBAR_DELETE'); } } if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::archiveList('votes.archive', 'JTOOLBAR_ARCHIVE'); } if (isset($this->items[0]->checked_out)) { JToolBarHelper::custom('votes.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); } } //Show trash and delete for components that uses the state field if (isset($this->items[0]->state)) { if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'votes.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } else { if ($canDo->get('core.edit.state')) { JToolBarHelper::trash('votes.trash', 'JTOOLBAR_TRASH'); JToolBarHelper::divider(); } } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_imc'); } //Set sidebar action - New in 3.0 JHtmlSidebar::setAction('index.php?option=com_imc&view=votes'); $this->extra_sidebar = ''; //Filter for the field ".issueid; jimport('joomla.form.form'); $options = array(); JForm::addFormPath(JPATH_COMPONENT . '/models/forms'); $form = JForm::getInstance('com_imc.vote', 'vote'); $field = $form->getField('issueid'); $query = $form->getFieldAttribute('filter_issueid', 'query'); $translate = $form->getFieldAttribute('filter_issueid', 'translate'); $key = $form->getFieldAttribute('filter_issueid', 'key_field'); $value = $form->getFieldAttribute('filter_issueid', 'value_field'); // Get the database object. $db = JFactory::getDBO(); // Set the query and get the result list. $db->setQuery($query); $items = $db->loadObjectlist(); // Build the field options. if (!empty($items)) { foreach ($items as $item) { if ($translate == true) { $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value})); } else { $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value}); } } } JHtmlSidebar::addFilter('Issue', 'filter_issueid', JHtml::_('select.options', $options, "value", "text", $this->state->get('filter.issueid')), true); JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true)); }
/** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { if (!$this->canManageKeys) { JToolBarHelper::title(JText::_('COM_IMC_TITLE_KEYS'), 'key'); //JToolBarHelper::back(); $bar = JToolBar::getInstance('toolbar'); $bar->appendButton('Link', 'leftarrow', 'COM_IMC_BACK', JRoute::_('index.php?option=com_imc', false)); return; } require_once JPATH_COMPONENT . '/helpers/imc.php'; $state = $this->get('State'); $canDo = ImcHelper::getActions($state->get('filter.category_id')); JToolBarHelper::title(JText::_('COM_IMC_TITLE_KEYS'), 'key'); //Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/key'; if (file_exists($formPath)) { if ($canDo->get('core.create')) { JToolBarHelper::addNew('key.add', 'JTOOLBAR_NEW'); } if ($canDo->get('core.edit') && isset($this->items[0])) { JToolBarHelper::editList('key.edit', 'JTOOLBAR_EDIT'); } } if ($canDo->get('core.edit.state')) { if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::custom('keys.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::custom('keys.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); } else { if (isset($this->items[0])) { //If this component does not use state then show a direct delete button as we can not trash JToolBarHelper::deleteList('', 'keys.delete', 'JTOOLBAR_DELETE'); } } if (isset($this->items[0]->state)) { JToolBarHelper::divider(); JToolBarHelper::archiveList('keys.archive', 'JTOOLBAR_ARCHIVE'); } if (isset($this->items[0]->checked_out)) { JToolBarHelper::custom('keys.checkin', 'checkin.png', 'checkin_f2.png', 'JTOOLBAR_CHECKIN', true); } } //Show trash and delete for components that uses the state field if (isset($this->items[0]->state)) { if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'keys.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } else { if ($canDo->get('core.edit.state')) { JToolBarHelper::trash('keys.trash', 'JTOOLBAR_TRASH'); JToolBarHelper::divider(); } } } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_imc'); } //Set sidebar action - New in 3.0 JHtmlSidebar::setAction('index.php?option=com_imc&view=keys'); $this->extra_sidebar = ''; JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'filter_published', JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), "value", "text", $this->state->get('filter.state'), true)); }
/** * Build an SQL query to load the list data. * * @return JDatabaseQuery * @since 1.6 */ protected function getListQuery() { $user = JFactory::getUser(); // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. $query->select($this->getState('list.select', 'DISTINCT a.*')); $query->from('`#__imc_issues` AS a'); // Join over the users for the checked out user $query->select("uc.name AS editor"); $query->join("LEFT", "#__users AS uc ON uc.id=a.checked_out"); // Join over the category 'catid' $query->select('catid.title AS catid_title'); $query->join('LEFT', '#__categories AS catid ON catid.id = a.catid'); // Join over the user field 'created_by' $query->select('created_by.name AS created_by'); $query->join('LEFT', '#__users AS created_by ON created_by.id = a.created_by'); // Join over the asset groups. $query->select('ag.title AS access_level')->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); // Join over the imc steps. $query->select('st.title AS stepid_title, st.stepcolor AS stepid_color')->join('LEFT', '#__imc_steps AS st ON st.id = a.stepid'); // Filter by published state $published = $this->getState('filter.state'); if (is_numeric($published)) { $query->where('a.state = ' . (int) $published); } else { if ($published === '') { $query->where('(a.state IN (0, 1))'); } } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $db->Quote('%' . $db->escape($search, true) . '%'); $query->where('( a.title LIKE ' . $search . ' OR a.address LIKE ' . $search . ' )'); } } // Filter by access level. if ($access = $this->getState('filter.access')) { $query->where('a.access = ' . (int) $access); } // Implement View Level Access if (!$user->authorise('core.admin')) { $groups = implode(',', $user->getAuthorisedViewLevels()); $query->where('a.access IN (' . $groups . ')'); } //Filtering stepid if ($stepid = $this->getState('filter.stepid')) { $query->where('a.stepid = ' . (int) $stepid); } //Filtering catid $filter_catid = $this->state->get("filter.catid"); if ($filter_catid) { $query->where("a.catid = '" . $db->escape($filter_catid) . "'"); } //Filtering by category usergroups except if access imc.showall.issues = true $canDo = ImcHelper::getActions(); $canShowAllIssues = $canDo->get('imc.showall.issues'); if (!$canShowAllIssues) { require_once JPATH_COMPONENT . '/helpers/imc.php'; $allowed_catids = ImcHelper::getCategoriesByUserGroups(); $allowed_catids = implode(',', $allowed_catids); if (!empty($allowed_catids)) { $query->where('a.catid IN (' . $allowed_catids . ')'); } else { //show nothing $query->where('a.catid = -1'); } } //Filtering by subgroup $filter_subgroup = $this->state->get("filter.subgroup"); if ($filter_subgroup) { $query->where("a.subgroup = '" . $db->escape($filter_subgroup) . "'"); } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); if ($orderCol == 'access_level') { $orderCol = 'ag.title'; } if ($orderCol && $orderDirn) { $query->order($db->escape($orderCol . ' ' . $orderDirn)); } return $query; }
private static function loadCats($cats = array()) { if (is_array($cats)) { foreach ($cats as $JCatNode) { $params = json_decode($JCatNode->params); if (isset($params->imc_category_usergroup)) { $usergroups = $params->imc_category_usergroup; } else { $usergroups = array(); } self::$catIds[] = array('catid' => $JCatNode->id, 'usergroups' => $usergroups); if ($JCatNode->hasChildren()) { ImcHelper::loadCats($JCatNode->getChildren()); } } } return false; }
?> '; var issueid = '<?php echo $this->item->id; ?> '; var userid = '<?php echo $user->id; ?> '; var picURL = '<?php echo JURI::base() . 'components/com_imc/assets/images/user-icon.png'; ?> '; <?php if (ImcHelper::getActions()->get('imc.manage.comments')) { ?> picURL = '<?php echo JURI::base() . 'components/com_imc/assets/images/admin-user-icon.png'; ?> '; <?php } ?> js('#comments-container').comments({ profilePictureURL: picURL, spinnerIconURL: '<?php echo JURI::base() . 'components/com_imc/assets/images/spinner.gif'; ?> ', upvoteIconURL: '<?php
/** * Build an SQL query to load the list data. * * @return JDatabaseQuery * @since 1.6 */ protected function getListQuery() { $userid = $this->getState('filter.imcapi.userid', 0); $guest = $this->getState('filter.imcapi.guest', false); if ($userid > 0) { $user = JFactory::getUser($userid); } elseif ($guest) { $user = JFactory::getUser(0); } else { $user = JFactory::getUser(); } // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. $query->select($this->getState('list.select', 'DISTINCT a.*')); $query->from('`#__imc_comments` AS a'); // Join over the users for the checked out user. $query->select('uc.name AS editor'); $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); // Join over the foreign key 'issueid' $query->select('b.title AS issue_title'); $query->join('LEFT', '#__imc_issues AS b ON b.id = a.issueid'); $query->join('LEFT', '#__users AS u ON u.id = a.created_by'); $query->select('u.name AS fullname'); // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = ' . (int) substr($search, 3)); } else { $search = $db->Quote('%' . $db->escape($search, true) . '%'); } } //Filtering issueid $filter_issueid = $this->getState('imc.filter.issueid', null); if (!is_null($filter_issueid)) { $query->where("a.issueid = " . $filter_issueid); } //Filtering state $filter_state = $this->getState('imc.filter.state', null); if (!is_null($filter_state)) { $query->where('a.state = ' . $filter_state); } // Filter by moderation (for non-admin users) if (!ImcHelper::getActions()->get('imc.manage.comments')) { $query->where(' ( (a.created_by > 0 AND a.created_by =' . $user->id . ' AND a.moderation IN (0,1)) OR (a.created_by > 0 AND a.created_by !=' . $user->id . ' AND a.moderation = 0) ) '); } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); if ($orderCol && $orderDirn) { $query->order($db->escape($orderCol . ' ' . $orderDirn)); } return $query; }