/**
  * Render the list of associated items
  *
  * @param   integer  $catid      Category identifier to search its associations
  * @param   string   $extension  Category Extension
  *
  * @return  string   The language HTML
  *
  * @since   3.2
  * @throws  Exception
  */
 public static function association($catid, $extension = 'com_content')
 {
     // Defaults
     $html = '';
     // Get the associations
     if ($associations = CategoriesHelper::getAssociations($catid, $extension)) {
         $associations = ArrayHelper::toInteger($associations);
         // Get the associated categories
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('c.id, c.title')->select('l.sef as lang_sef')->select('l.lang_code')->from('#__categories as c')->where('c.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON c.language=l.lang_code')->select('l.image')->select('l.title as language_title');
         $db->setQuery($query);
         try {
             $items = $db->loadObjectList('id');
         } catch (RuntimeException $e) {
             throw new Exception($e->getMessage(), 500, $e);
         }
         if ($items) {
             foreach ($items as &$item) {
                 $text = $item->lang_sef ? strtoupper($item->lang_sef) : 'XX';
                 $url = JRoute::_('index.php?option=com_categories&task=category.edit&id=' . (int) $item->id . '&extension=' . $extension);
                 $classes = 'hasPopover label label-association label-' . $item->lang_sef;
                 $item->link = '<a href="' . $url . '" title="' . $item->language_title . '" class="' . $classes . '" data-content="' . $item->title . '" data-placement="top">' . $text . '</a>';
             }
         }
         JHtml::_('bootstrap.popover');
         $html = JLayoutHelper::render('joomla.content.associations', $items);
     }
     return $html;
 }
Beispiel #2
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @param   string  $ordering   An optional ordering field.
  * @param   string  $direction  An optional direction (asc|desc).
  *
  * @return  void
  *
  * @since   1.6
  */
 protected function populateState($ordering = 'a.name', $direction = 'asc')
 {
     $app = JFactory::getApplication('administrator');
     // Adjust the context to support modal layouts.
     if ($layout = $app->input->get('layout', 'default', 'cmd')) {
         $this->context .= '.' . $layout;
     }
     // Load the filter state.
     $this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
     $this->setState('filter.active', $this->getUserStateFromRequest($this->context . '.filter.active', 'filter_active', '', 'cmd'));
     $this->setState('filter.state', $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'cmd'));
     $this->setState('filter.group_id', $this->getUserStateFromRequest($this->context . '.filter.group_id', 'filter_group_id', null, 'int'));
     $this->setState('filter.range', $this->getUserStateFromRequest($this->context . '.filter.range', 'filter_range', '', 'cmd'));
     $this->setState('filter.lastvisitrange', $this->getUserStateFromRequest($this->context . '.filter.lastvisitrange', 'filter_lastvisitrange', '', 'cmd'));
     $groups = json_decode(base64_decode($app->input->get('groups', '', 'BASE64')));
     if (isset($groups)) {
         $groups = ArrayHelper::toInteger($groups);
     }
     $this->setState('filter.groups', $groups);
     $excluded = json_decode(base64_decode($app->input->get('excluded', '', 'BASE64')));
     if (isset($excluded)) {
         $excluded = ArrayHelper::toInteger($excluded);
     }
     $this->setState('filter.excluded', $excluded);
     // Load the parameters.
     $params = JComponentHelper::getParams('com_users');
     $this->setState('params', $params);
     // List state information.
     parent::populateState($ordering, $direction);
 }
 /**
  * Load locations data by ID from database.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3,4,5), // Load locations by IDs.
  *     "search" => "London" // It is a phrase for searching.
  * );
  *
  * $locations   = new Socialcommunity\Locations(JFactory::getDbo());
  * $locations->load($options);
  *
  * foreach($locations as $location) {
  *   echo $location["name"];
  *   echo $location["country_code"];
  * }
  * </code>
  *
  * @param array $options
  */
 public function load(array $options = array())
 {
     $ids = ArrayHelper::getValue($options, 'ids', array(), 'array');
     $search = ArrayHelper::getValue($options, 'search', '', 'string');
     $countryId = ArrayHelper::getValue($options, 'country_id', 0, 'int');
     ArrayHelper::toInteger($ids);
     $query = $this->db->getQuery(true);
     $query->select('a.id, a.name, a.latitude, a.longitude, a.country_code, a.state_code, a.timezone, a.published')->from($this->db->quoteName('#__itpsc_locations', 'a'));
     if (count($ids) > 0) {
         $query->where('a.id IN ( ' . implode(',', $ids) . ' )');
     }
     // Filter by country ID ( use subquery to get country code ).
     if ($countryId > 0) {
         $subQuery = $this->db->getQuery(true);
         $subQuery->select('sqc.code')->from($this->db->quoteName('#__itpsc_countries', 'sqc'))->where('sqc.id = ' . (int) $countryId);
         $query->where('a.country_code = ( ' . $subQuery . ' )');
     }
     if ($query !== null and $query !== '') {
         $escaped = $this->db->escape($search, true);
         $quoted = $this->db->quote('%' . $escaped . '%', false);
         $query->where('a.name LIKE ' . $quoted);
     }
     $this->db->setQuery($query);
     $this->items = (array) $this->db->loadAssocList('id');
 }
Beispiel #4
0
 /**
  * Remove an item.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function delete()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $cids = (array) $this->input->get('cid', array(), 'array');
     if (count($cids) < 1) {
         $app->enqueueMessage(JText::_('COM_MENUS_NO_MENUS_SELECTED'), 'notice');
     } else {
         // Access checks.
         foreach ($cids as $i => $id) {
             if (!$user->authorise('core.delete', 'com_menus.menu.' . (int) $id)) {
                 // Prune items that you can't change.
                 unset($cids[$i]);
                 $app->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), 'error');
             }
         }
         if (count($cids) > 0) {
             // Get the model.
             $model = $this->getModel();
             // Make sure the item ids are integers
             $cids = ArrayHelper::toInteger($cids);
             // Remove the items.
             if (!$model->delete($cids)) {
                 $this->setMessage($model->getError());
             } else {
                 $this->setMessage(JText::plural('COM_MENUS_N_MENUS_DELETED', count($cids)));
             }
         }
     }
     $this->setRedirect('index.php?option=com_menus&view=menus');
 }
Beispiel #5
0
 /**
  * Update a set of extensions.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function update()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     /** @var InstallerModelUpdate $model */
     $model = $this->getModel('update');
     $uid = $this->input->get('cid', array(), 'array');
     $uid = ArrayHelper::toInteger($uid, array());
     // Get the minimum stability.
     $component = JComponentHelper::getComponent('com_installer');
     $params = $component->params;
     $minimum_stability = $params->get('minimum_stability', JUpdater::STABILITY_STABLE, 'int');
     $model->update($uid, $minimum_stability);
     if ($model->getState('result', false)) {
         JFactory::getCache('mod_menu')->clean();
     }
     $app = JFactory::getApplication();
     $redirect_url = $app->getUserState('com_installer.redirect_url');
     // Don't redirect to an external URL.
     if (!JUri::isInternal($redirect_url)) {
         $redirect_url = '';
     }
     if (empty($redirect_url)) {
         $redirect_url = JRoute::_('index.php?option=com_installer&view=update', false);
     } else {
         // Wipe out the user state when we're going to redirect.
         $app->setUserState('com_installer.redirect_url', '');
         $app->setUserState('com_installer.message', '');
         $app->setUserState('com_installer.extension_message', '');
     }
     $this->setRedirect($redirect_url);
 }
Beispiel #6
0
 /**
  * Load transactions from database.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3),
  *     "txn_status" => "completed"
  * );
  *
  * $transactions    = new Crowdfunding\Transactions(\JFactory::getDbo());
  * $transactions->load($options);
  *
  * foreach($transactions as $transaction) {
  *   echo $transaction->txn_id;
  *   echo $transaction->txn_amount;
  * }
  *
  * </code>
  *
  * @param array $options
  *
  * @throws \UnexpectedValueException
  */
 public function load($options = array())
 {
     $ids = !array_key_exists('ids', $options) ? array() : (array) $options['ids'];
     $ids = ArrayHelper::toInteger($ids);
     $results = array();
     if (count($ids) > 0) {
         // Load project data
         $query = $this->db->getQuery(true);
         $query->select('a.id, a.txn_date, a.txn_id, a.txn_amount, a.txn_currency, a.txn_status, ' . 'a.extra_data, a.status_reason, a.project_id, a.reward_id, a.investor_id, ' . 'a.receiver_id, a.service_provider, a.service_alias, a.reward_state')->from($this->db->quoteName('#__crowdf_transactions', 'a'))->where('a.id IN ( ' . implode(',', $ids) . ' )');
         // Filter by status.
         $status = ArrayHelper::getValue($options, 'txn_status', null, 'cmd');
         if ($status !== null) {
             $query->where('a.txn_status = ' . $this->db->quote($status));
         }
         $this->db->setQuery($query);
         $results = (array) $this->db->loadAssocList();
         // Convert JSON string into an array.
         if (count($results) > 0) {
             foreach ($results as $key => &$result) {
                 if (!empty($result['extra_data'])) {
                     $result['extra_data'] = json_decode($result['extra_data'], true);
                 }
             }
             unset($result);
         }
     }
     $this->items = $results;
 }
 /**
  * Method to get a JDatabaseQuery object for retrieving the data set from a database.
  *
  * @return  JDatabaseQuery   A JDatabaseQuery object to retrieve the data set.
  */
 protected function getListQuery()
 {
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     $subQuery = $db->getQuery(true);
     $includeRaw = $this->state->params->get('include_issues', null);
     $excludeRaw = $this->state->params->get('exclude_issues', null);
     $includeArray = explode(',', $includeRaw);
     $excludeArray = explode(',', $excludeRaw);
     $includeArray = ArrayHelper::toInteger($includeArray);
     $excludeArray = ArrayHelper::toInteger($excludeArray);
     $subQuery->select('it.issue_id AS issue_id, it.tag_id AS tag_id, t.tag AS tag')->join('LEFT', '#__code_tags AS t ON t.tag_id = it.tag_id')->from('#__code_tracker_issue_tag_map AS it')->where('it.tag_id IN (6,10,16,20,24,26,28,51,52,55,62,65,67,74,75,78,79,82,83,87,92,93,105,107,112,115)')->group('it.issue_id, it.tag_id, t.tag');
     // Select required fields from the categories.
     $query->select('CASE WHEN ISNULL(m.tag) THEN ' . $db->quote('None') . ' ELSE m.tag END as category');
     $query->select('i.title, i.jc_issue_id, i.close_date');
     $query->from('#__code_tracker_issues AS i');
     $query->join('LEFT', '(' . (string) $subQuery . ') AS m ON i.jc_issue_id = m.issue_id');
     $query->where('((DATE(close_date) BETWEEN ' . $db->quote(substr($this->state->params->get('start_date'), 0, 10)) . ' AND ' . $db->quote(substr($this->state->params->get('end_date'), 0, 10)) . ')' . ' OR (i.jc_issue_id IN (' . implode(',', $includeArray) . ')))');
     // Join the status table to get the status name
     $query->select('s.title AS status_name');
     $query->join('LEFT', '#__code_tracker_status AS s ON i.status = s.jc_status_id');
     // Filter on merged items from the trackers
     $query->where('(s.title LIKE ' . $db->quote('%Fixed in SVN%') . ' OR s.title LIKE ' . $db->quote('%Implemented in trunk%') . ')');
     // Exclude explicitly listed trackers
     $query->where('i.jc_issue_id NOT IN (' . implode(',', $excludeArray) . ')');
     if ($this->state->get('list.filter')) {
         $query->where('i.title LIKE ' . $db->quote('%' . $this->state->get('list.filter') . '%'));
     }
     $query->order('CASE WHEN ISNULL(m.tag) THEN ' . $db->quote('None') . ' ELSE m.tag END ASC');
     $query->order('i.jc_issue_id ASC');
     return $query;
 }
Beispiel #8
0
 /**
  * Get the lists that contain events
  *
  * @return array
  */
 public function &getEventLists()
 {
     if (is_null($this->eventLists)) {
         $this->eventLists = array();
         $db = FabrikWorker::getDbo(true);
         $params = $this->getParams();
         $lists = (array) $params->get('calendar_table');
         $lists = ArrayHelper::toInteger($lists);
         $dateFields = (array) $params->get('calendar_startdate_element');
         $dateFields2 = (array) $params->get('calendar_enddate_element');
         $labels = (array) $params->get('calendar_label_element');
         $stati = (array) $params->get('status_element');
         $colours = (array) $params->get('colour');
         $query = $db->getQuery(true);
         $query->select('id AS value, label AS text')->from('#__{package}_lists')->where('id IN (' . implode(',', $lists) . ')');
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         for ($i = 0; $i < count($rows); $i++) {
             if (!isset($colours[$i])) {
                 $colours[$i] = '';
             }
             if (!isset($stati[$i])) {
                 $stati[$i] = '';
             }
             $rows[$i]->startdate_element = $dateFields[$i];
             $rows[$i]->enddate_element = FArrayHelper::getValue($dateFields2, $i);
             $rows[$i]->label_element = $labels[$i];
             $rows[$i]->status = FArrayHelper::getValue($stati, $i, '');
             $rows[$i]->colour = $colours[$i];
         }
         $this->eventLists = $rows;
     }
     return $this->eventLists;
 }
 /**
  * Load transactions from database.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3),
  *     "txn_status" => "completed"
  * );
  *
  * $transactions    = new Crowdfunding\Transactions(\JFactory::getDbo());
  * $transactions->load($options);
  *
  * foreach($transactions as $transaction) {
  *   echo $transaction->txn_id;
  *   echo $transaction->txn_amount;
  * }
  *
  * </code>
  *
  * @param array $options
  *
  * @throws \UnexpectedValueException
  */
 public function load($options = array())
 {
     $ids = !isset($options["ids"]) ? null : (array) $options["ids"];
     if (!is_array($ids) or !$ids) {
         return;
     }
     ArrayHelper::toInteger($ids);
     // Load project data
     $query = $this->db->getQuery(true);
     $query->select("a.id, a.txn_date, a.txn_id, a.txn_amount, a.txn_currency, a.txn_status, " . "a.extra_data, a.status_reason, a.project_id, a.reward_id, a.investor_id, " . "a.receiver_id, a.service_provider, a.reward_state")->from($this->db->quoteName("#__crowdf_transactions", "a"))->where("a.id IN ( " . implode(",", $ids) . " )");
     // Filter by status.
     $status = ArrayHelper::getValue($options, "txn_status", null, "cmd");
     if (!empty($status)) {
         $query->where("a.txn_status = " . $this->db->quote($status));
     }
     $this->db->setQuery($query);
     $results = $this->db->loadObjectList();
     // Convert JSON string into an array.
     if (!empty($results)) {
         foreach ($results as $key => $result) {
             if (!empty($result->extra_data)) {
                 $result->extra_data = json_decode($result->extra_data, true);
                 $results[$key] = $result;
             }
         }
     } else {
         $results = array();
     }
     $this->items = $results;
 }
Beispiel #10
0
 /**
  * Set which fieldsets should be used
  *
  * @since   3.0.7
  *
  * @return  array  fieldset names
  */
 private function setFieldSets()
 {
     $input = $this->app->input;
     // From list data view in admin
     $id = $input->getInt('listid', 0);
     // From list of lists checkbox selection
     $cid = $input->get('cid', array(0), 'array');
     $cid = ArrayHelper::toInteger($cid);
     if ($id === 0) {
         $id = $cid[0];
     }
     if ($id !== 0) {
         $db = FabrikWorker::getDbo();
         $query = $db->getQuery(true);
         $query->select('label')->from('#__{package}_lists')->where('id = ' . $id);
         $db->setQuery($query);
         $this->listName = $db->loadResult();
     }
     $fieldsets = array('details');
     if ($this->model->canEmpty()) {
         $fieldsets[] = 'drop';
     }
     $fieldsets[] = $id === 0 ? 'creation' : 'append';
     $fieldsets[] = 'format';
     return $fieldsets;
 }
Beispiel #11
0
 /**
  * Method to set the publishing state for a row or list of rows in the database
  * table. The method respects checked out rows by other users and will attempt
  * to checkin rows that it can after adjustments are made.
  *
  * @param   mixed    $pks     An array of primary key values to update.  If not
  *                            set the instance property value is used. [optional]
  * @param   integer  $state   The publishing state. eg. [0 = unpublished, 1 = published] [optional]
  * @param   integer  $userId  The user id of the user performing the operation. [optional]
  *
  * @return  boolean  True on success.
  *
  * @since   2.5
  */
 public function publish($pks = null, $state = 1, $userId = 0)
 {
     $k = $this->_tbl_key;
     // Sanitize input.
     $pks = ArrayHelper::toInteger($pks);
     $state = (int) $state;
     // If there are no primary keys set check to see if the instance key is set.
     if (empty($pks)) {
         if ($this->{$k}) {
             $pks = array($this->{$k});
         } else {
             $this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
             return false;
         }
     }
     // Build the WHERE clause for the primary keys.
     $where = $k . '=' . implode(' OR ' . $k . '=', $pks);
     // Update the publishing state for rows with the given primary keys.
     $query = $this->_db->getQuery(true)->update($this->_db->quoteName($this->_tbl))->set($this->_db->quoteName('state') . ' = ' . (int) $state)->where($where);
     $this->_db->setQuery($query);
     try {
         $this->_db->execute();
     } catch (RuntimeException $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // If the JTable instance value is in the list of primary keys that were set, set the instance.
     if (in_array($this->{$k}, $pks)) {
         $this->state = $state;
     }
     $this->setError('');
     return true;
 }
 public function read()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Get items to publish from the request.
     $cid = $this->input->get('cid', array(), 'array');
     $data = array('read' => 1, 'notread' => 0);
     $task = $this->getTask();
     $value = ArrayHelper::getValue($data, $task, 0, 'int');
     $redirectOptions = array("view" => "notifications");
     // Make sure the item ids are integers
     ArrayHelper::toInteger($cid);
     if (empty($cid)) {
         $this->displayNotice(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), $redirectOptions);
         return;
     }
     try {
         $model = $this->getModel();
         $model->read($cid, $value);
     } catch (RuntimeException $e) {
         $this->displayWarning($e->getMessage(), $redirectOptions);
         return;
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_GAMIFICATION_ERROR_SYSTEM'));
     }
     if ($value == 1) {
         $msg = $this->text_prefix . '_N_ITEMS_READ';
     } else {
         $msg = $this->text_prefix . '_N_ITEMS_NOT_READ';
     }
     $this->displayMessage(JText::plural($msg, count($cid)), $redirectOptions);
 }
 /**
  * Render the list of associated items
  *
  * @param   integer  $catid      Category identifier to search its associations
  * @param   string   $extension  Category Extension
  *
  * @return  string   The language HTML
  *
  * @since   3.2
  * @throws  Exception
  */
 public static function association($catid, $extension = 'com_content')
 {
     // Defaults
     $html = '';
     // Get the associations
     if ($associations = CategoriesHelper::getAssociations($catid, $extension)) {
         $associations = ArrayHelper::toInteger($associations);
         // Get the associated categories
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('c.id, c.title')->select('l.sef as lang_sef')->from('#__categories as c')->where('c.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON c.language=l.lang_code')->select('l.image')->select('l.title as language_title');
         $db->setQuery($query);
         try {
             $items = $db->loadObjectList('id');
         } catch (RuntimeException $e) {
             throw new Exception($e->getMessage(), 500, $e);
         }
         if ($items) {
             foreach ($items as &$item) {
                 $text = strtoupper($item->lang_sef);
                 $url = JRoute::_('index.php?option=com_categories&task=category.edit&id=' . (int) $item->id . '&extension=' . $extension);
                 $tooltipParts = array(JHtml::_('image', 'mod_languages/' . $item->image . '.gif', $item->language_title, array('title' => $item->language_title), true), $item->title);
                 $item->link = JHtml::_('tooltip', implode(' ', $tooltipParts), null, null, $text, $url, null, 'hasTooltip label label-association label-' . $item->lang_sef);
             }
         }
         $html = JLayoutHelper::render('joomla.content.associations', $items);
     }
     return $html;
 }
 /**
  * Method to get a list of tags for an item, optionally with the tag data.
  *
  * <code>
  * $keys = array(1,2,3,4);
  *
  * $options = array(
  *     'content_type' => 'com_userideas.item',
  *     'access_groups' => \JFactory::getUser()->getAuthorisedViewLevels(),
  *     'language' => 'en_GB',
  *     'get_tag_data' => true
  * );
  *
  * $tagHelper = new TagHelper($keys, $options);
  * </code>
  *
  * @param   int|array  $keys
  * @param   array  $options
  *
  * @return  array    Array of tag objects
  */
 public function getItemTags($keys, array $options = array())
 {
     $contentType = JArrayHelper::getValue($options, 'content_type');
     if (!$contentType) {
         throw new \InvalidArgumentException(\JText::_('LIB_PRISM_ERROR_INVALID_CONTENT_TYPE'));
     }
     if (is_array($keys)) {
         $keys = JArrayHelper::toInteger($keys);
         $keys = array_filter(array_unique($keys));
         $hash = md5(implode(',', $keys) . '_' . $contentType);
     } else {
         $keys = (int) $keys;
         $hash = md5($keys . '_' . $contentType);
     }
     if (!$keys) {
         throw new \InvalidArgumentException(\JText::_('LIB_PRISM_ERROR_INVALID_KEYS'));
     }
     if (!array_key_exists($hash, $this->itemTags)) {
         $this->itemTags[$hash] = array();
         $groups = JArrayHelper::getValue($options, 'access_groups', array(), 'array');
         if (!$groups) {
             throw new \InvalidArgumentException(\JText::_('LIB_PRISM_ERROR_INVALID_ACCESS_GROUPS'));
         }
         // Initialize some variables.
         $db = \JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('m.tag_id, m.content_item_id')->from($db->quoteName('#__contentitem_tag_map', 'm'))->where($db->quoteName('m.type_alias') . ' = ' . $db->quote($contentType));
         if (is_array($keys)) {
             $query->where($db->quoteName('m.content_item_id') . ' IN (' . implode(',', $keys) . ')');
         } else {
             $query->where($db->quoteName('m.content_item_id') . ' = ' . (int) $keys);
         }
         $query->where($db->quoteName('t.published') . ' = ' . Constants::PUBLISHED);
         $query->where('t.access IN (' . implode(',', $groups) . ')');
         // Optionally filter on language
         $language = JArrayHelper::getValue($options, 'language', 'all', 'string');
         if ($language !== 'all') {
             if ($language === 'current_language') {
                 $language = $this->getCurrentLanguage();
             }
             $query->where($db->quoteName('language') . ' IN (' . $db->quote($language) . ', ' . $db->quote('*') . ')');
         }
         $getTagData = JArrayHelper::getValue($options, 'get_tag_data', true, 'bool');
         if ($getTagData) {
             $query->select($db->quoteName('t') . '.*');
         }
         $query->join('INNER', $db->quoteName('#__tags', 't') . ' ON ' . $db->quoteName('m.tag_id') . ' = ' . $db->quoteName('t.id'));
         $db->setQuery($query);
         $tags = $db->loadObjectList();
         foreach ($tags as $value) {
             $this->itemTags[$hash][$value->content_item_id][] = $value;
         }
     }
     return $this->itemTags[$hash];
 }
Beispiel #15
0
 /**
  * Load users data from database.
  *
  * <code>
  * $options = array(
  *      "ids" => array(1,2,3,4,5)
  * );
  *
  * $users   = new Crowdfunding\Users(\JFactory::getDbo());
  * $users->load($options);
  *
  * foreach($users as $user) {
  *   echo $user["id"];
  *   echo $user["name"];
  * }
  * </code>
  *
  * @param array $options
  */
 public function load($options = array())
 {
     // Filter by users IDs.
     $ids = ArrayHelper::getValue($options, "ids", array(), "array");
     ArrayHelper::toInteger($ids);
     if (!empty($ids)) {
         $query = $this->db->getQuery(true);
         $query->select("a.id, a.name, a.email")->from($this->db->quoteName("#__users", "a"));
         $query->where("a.id IN (" . implode(",", $ids) . ")");
         $this->db->setQuery($query);
         $this->items = (array) $this->db->loadAssocList();
     }
 }
Beispiel #16
0
 /**
  * Load users data from database.
  *
  * <code>
  * $options = array(
  *      "ids" => array(1,2,3,4,5)
  * );
  *
  * $users   = new Crowdfunding\Users(\JFactory::getDbo());
  * $users->load($options);
  *
  * foreach($users as $user) {
  *   echo $user["id"];
  *   echo $user["name"];
  * }
  * </code>
  *
  * @param array $options
  */
 public function load(array $options = array())
 {
     // Filter by users IDs.
     $ids = ArrayHelper::getValue($options, 'ids', array(), 'array');
     $ids = ArrayHelper::toInteger($ids);
     if (count($ids) > 0) {
         $query = $this->db->getQuery(true);
         $query->select('a.id, a.name, a.email')->from($this->db->quoteName('#__users', 'a'));
         $query->where('a.id IN (' . implode(',', $ids) . ')');
         $this->db->setQuery($query);
         $this->items = (array) $this->db->loadAssocList();
     }
 }
Beispiel #17
0
 /**
  * Load locations data by ID from database.
  *
  * <code>
  * $options = array(
  *      "ids" => array(1,2,3,4,5)
  * );
  *
  * $locations   = new Crowdfunding\Locations(\JFactory::getDbo());
  * $locations->load($options);
  *
  * foreach($locations as $location) {
  *   echo $location["id"];
  *   echo $location["name"];
  * }
  *
  * </code>
  *
  * @param array $options
  */
 public function load(array $options = array())
 {
     // Load project data
     $query = $this->db->getQuery(true);
     $query->select('a.id, a.name, a.latitude, a.longitude, a.country_code, a.state_code, a.timezone, a.published')->from($this->db->quoteName('#__crowdf_locations', 'a'));
     $ids = (array_key_exists('ids', $options) and is_array($options['ids'])) ? $options['ids'] : array();
     $ids = ArrayHelper::toInteger($ids);
     if (count($ids) > 0) {
         $query->where('a.id IN ( ' . implode(',', $ids) . ' )');
     }
     $this->db->setQuery($query);
     $this->items = (array) $this->db->loadAssocList();
 }
Beispiel #18
0
 /**
  * Build the route for the com_tags component
  *
  * @param   array  &$query  An array of URL arguments
  *
  * @return  array  The URL arguments to use to assemble the subsequent URL.
  *
  * @since   3.3
  */
 public function build(&$query)
 {
     $segments = array();
     // Get a menu item based on Itemid or currently active
     $params = JComponentHelper::getParams('com_tags');
     // We need a menu item.  Either the one specified in the query, or the current active one if none specified
     if (empty($query['Itemid'])) {
         $menuItem = $this->menu->getActive();
     } else {
         $menuItem = $this->menu->getItem($query['Itemid']);
     }
     $mView = empty($menuItem->query['view']) ? null : $menuItem->query['view'];
     $mId = empty($menuItem->query['id']) ? null : $menuItem->query['id'];
     if (is_array($mId)) {
         $mId = ArrayHelper::toInteger($mId);
     }
     $view = '';
     if (isset($query['view'])) {
         $view = $query['view'];
         if (empty($query['Itemid'])) {
             $segments[] = $view;
         }
         unset($query['view']);
     }
     // Are we dealing with a tag that is attached to a menu item?
     if ($mView == $view && isset($query['id']) && $mId == $query['id']) {
         unset($query['id']);
         return $segments;
     }
     if ($view == 'tag') {
         $notActiveTag = is_array($mId) ? count($mId) > 1 || $mId[0] != (int) $query['id'] : $mId != (int) $query['id'];
         if ($notActiveTag || $mView != $view) {
             // ID in com_tags can be either an integer, a string or an array of IDs
             $id = is_array($query['id']) ? implode(',', $query['id']) : $query['id'];
             $segments[] = $id;
         }
         unset($query['id']);
     }
     if (isset($query['layout'])) {
         if (!empty($query['Itemid']) && isset($menuItem->query['layout']) && $query['layout'] == $menuItem->query['layout'] || $query['layout'] == 'default') {
             unset($query['layout']);
         }
     }
     $total = count($segments);
     for ($i = 0; $i < $total; $i++) {
         $segments[$i] = str_replace(':', '-', $segments[$i]);
     }
     return $segments;
 }
Beispiel #19
0
 /**
  * Load projects from database by IDs.
  *
  * <code>
  * $options = array(
  *    "ids"       => array(1,2,3),
  *    "published" => Prism\Constants::PUBLISHED,
  *    "approved" => Prism\Constants::APPROVED
  * );
  *
  * $projects    = new Crowdfunding\Projects(\JFactory::getDbo());
  * $projects->load($options);
  *
  * foreach ($projects as $project) {
  *      echo $project["title"];
  *      echo $project["funding_start"];
  * }
  * </code>
  *
  * @param array $options
  *
  * @return array
  */
 public function load($options = array())
 {
     $ids = !isset($options["ids"]) ? array() : $options["ids"];
     ArrayHelper::toInteger($ids);
     if (!empty($ids)) {
         // Prepare and return main query.
         $query = $this->getQuery();
         // Prepare the query to load project by IDs.
         $query->where("a.id IN ( " . implode(",", $ids) . " )");
         // Prepare project states in the query.
         $this->prepareQueryStates($query, $options);
         $this->db->setQuery($query);
         $this->items = (array) $this->db->loadAssocList();
     }
 }
Beispiel #20
0
 /**
  * Install languages.
  *
  * @return  void
  *
  * @since   2.5.7
  */
 public function install()
 {
     $model = $this->getModel('languages');
     // Get array of selected languages
     $lids = $this->input->get('cid', array(), 'array');
     $lids = ArrayHelper::toInteger($lids, array());
     if (!$lids) {
         // No languages have been selected
         JFactory::getApplication()->enqueueMessage(JText::_('COM_INSTALLER_MSG_DISCOVER_NOEXTENSIONSELECTED'));
     } else {
         // Install selected languages
         $model->install($lids);
     }
     $this->setRedirect(JRoute::_('index.php?option=com_installer&view=languages', false));
 }
Beispiel #21
0
 /**
  * Delete a notification
  *
  * @return  void
  */
 public function delete()
 {
     // Check for request forgeries
     JSessoin::checkToken() or die('Invalid Token');
     $ids = $this->app->input->get('cid', array());
     $ids = ArrayHelper::toInteger($ids);
     if (empty($ids)) {
         return;
     }
     $db = FabrikWorker::getDbo();
     $query = $db->getQuery(true);
     $query->delete('#__{package}_notification')->where('id IN (' . implode(',', $ids) . ')');
     $db->setQuery($query);
     $db->execute();
 }
Beispiel #22
0
 /**
  * Method to set the publishing state for a row or list of rows in the database
  * table.  The method respects checked out rows by other users and will attempt
  * to check-in rows that it can after adjustments are made.
  *
  * @param   mixed    $pks     An optional array of primary key values to update.  If not set the instance property value is used.
  * @param   integer  $state   The publishing state. eg. [0 = unpublished, 1 = published]
  * @param   integer  $userId  The user id of the user performing the operation.
  *
  * @return  boolean  True on success.
  *
  * @since   2.5
  */
 public function publish($pks = null, $state = 1, $userId = 0)
 {
     $k = $this->_tbl_key;
     // Sanitize input.
     $pks = ArrayHelper::toInteger($pks);
     $userId = (int) $userId;
     $state = (int) $state;
     // If there are no primary keys set check to see if the instance key is set.
     if (empty($pks)) {
         if ($this->{$k}) {
             $pks = array($this->{$k});
         } else {
             $this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
             return false;
         }
     }
     $query = $this->_db->getQuery(true)->update($this->_db->quoteName($this->_tbl))->set($this->_db->quoteName('state') . ' = ' . (int) $state);
     // Build the WHERE clause for the primary keys.
     $query->where($k . '=' . implode(' OR ' . $k . '=', $pks));
     // Determine if there is checkin support for the table.
     if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) {
         $checkin = false;
     } else {
         $query->where('(checked_out = 0 OR checked_out = ' . (int) $userId . ')');
         $checkin = true;
     }
     // Update the publishing state for rows with the given primary keys.
     $this->_db->setQuery($query);
     try {
         $this->_db->execute();
     } catch (RuntimeException $e) {
         $this->setError($this->_db->getMessage());
         return false;
     }
     // If checkin is supported and all rows were adjusted, check them in.
     if ($checkin && count($pks) == $this->_db->getAffectedRows()) {
         // Checkin the rows.
         foreach ($pks as $pk) {
             $this->checkin($pk);
         }
     }
     // If the JTable instance value is in the list of primary keys that were set, set the instance.
     if (in_array($this->{$k}, $pks)) {
         $this->state = $state;
     }
     $this->setError('');
     return true;
 }
 /**
  * Load currencies data by ID from database.
  *
  * <code>
  * $ids = array(1,2,3,4,5);
  * $currencies   = new Crowdfunding\Currencies(\JFactory::getDbo());
  * $currencies->load($ids);
  *
  * foreach($currencies as $currency) {
  *   echo $currency["title"];
  *   echo $currency["code"];
  * }
  * </code>
  *
  * @param array $ids
  */
 public function load($ids = array())
 {
     // Load project data
     $query = $this->db->getQuery(true);
     $query->select("a.id, a.title, a.code, a.symbol, a.position")->from($this->db->quoteName("#__crowdf_currencies", "a"));
     if (!empty($ids)) {
         ArrayHelper::toInteger($ids);
         $query->where("a.id IN ( " . implode(",", $ids) . " )");
     }
     $this->db->setQuery($query);
     $results = $this->db->loadAssocList();
     if (!$results) {
         $results = array();
     }
     $this->items = $results;
 }
Beispiel #24
0
 /**
  * Method to save the submitted ordering values for records via AJAX.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function saveOrderAjax()
 {
     $pks = $this->input->post->get('cid', array(), 'array');
     $order = $this->input->post->get('order', array(), 'array');
     // Sanitize the input.
     $pks = ArrayHelper::toInteger($pks);
     $order = ArrayHelper::toInteger($order);
     // Get the model.
     $model = $this->getModel();
     // Save the ordering.
     $return = $model->saveorder($pks, $order);
     if ($return) {
         echo "1";
     }
     // Close the application.
     JFactory::getApplication()->close();
 }
Beispiel #25
0
 /**
  * Load locations data by ID from database.
  *
  * <code>
  * $options = array(
  *      "ids" => array(1,2,3,4,5)
  * );
  *
  * $locations   = new Crowdfunding\Locations(\JFactory::getDbo());
  * $locations->load($options);
  *
  * foreach($locations as $location) {
  *   echo $location["id"];
  *   echo $location["name"];
  * }
  *
  * </code>
  *
  * @param array $options
  */
 public function load($options = array())
 {
     // Load project data
     $query = $this->db->getQuery(true);
     $query->select("a.id, a.name, a.latitude, a.longitude, a.country_code, a.state_code, a.timezone, a.published")->from($this->db->quoteName("#__crowdf_locations", "a"));
     $ids = !isset($options["ids"]) ? null : (array) $options["ids"];
     if (!empty($ids)) {
         ArrayHelper::toInteger($ids);
         $query->where("a.id IN ( " . implode(",", $ids) . " )");
     }
     $this->db->setQuery($query);
     $results = $this->db->loadAssocList();
     if (!$results) {
         $results = array();
     }
     $this->items = $results;
 }
 /**
  * Load countries data from database.
  *
  * <code>
  * $countries = new Crowdfunding\Country\Countries(\JFactory::getDbo());
  * $countries->load();
  * </code>
  *
  * @param array $options
  */
 public function load(array $options = array())
 {
     // Get columns
     $defaultColumns = array('a.id', 'a.name', 'a.code', 'a.locale', 'a.latitude', 'a.longitude', 'a.currency', 'a.timezone');
     $columns = (array_key_exists('columns', $options) and is_array($options['columns'])) ? $options['columns'] : $defaultColumns;
     // Get IDs.
     $ids = (array_key_exists('ids', $options) and is_array($options['ids'])) ? $options['ids'] : array();
     $ids = ArrayHelper::toInteger($ids);
     $query = $this->db->getQuery(true);
     $query->select(implode(',', $columns))->from($this->db->quoteName('#__crowdf_countries', 'a'));
     // Filter by IDs
     if (count($ids) > 0) {
         $query->where('a.id IN ( ' . implode(',', $ids) . ' )');
     }
     $this->db->setQuery($query);
     $this->items = (array) $this->db->loadAssocList();
 }
Beispiel #27
0
 /**
  * Method to clone an existing module.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function duplicate()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $pks = $this->input->post->get('cid', array(), 'array');
     $pks = ArrayHelper::toInteger($pks);
     try {
         if (empty($pks)) {
             throw new Exception(JText::_('COM_MODULES_ERROR_NO_MODULES_SELECTED'));
         }
         $model = $this->getModel();
         $model->duplicate($pks);
         $this->setMessage(JText::plural('COM_MODULES_N_MODULES_DUPLICATED', count($pks)));
     } catch (Exception $e) {
         JError::raiseWarning(500, $e->getMessage());
     }
     $this->setRedirect('index.php?option=com_modules&view=modules');
 }
Beispiel #28
0
 /**
  * Get Smart Search query object.
  *
  * @param   \Joomla\Registry\Registry  $params  Module parameters.
  *
  * @return  FinderIndexerQuery object
  *
  * @since   2.5
  */
 public static function getQuery($params)
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $request = $input->request;
     $filter = JFilterInput::getInstance();
     // Get the static taxonomy filters.
     $options = array();
     $options['filter'] = $request->get('f', 0, 'int') != 0 ? $request->get('f', '', 'int') : $params->get('searchfilter');
     $options['filter'] = $filter->clean($options['filter'], 'int');
     // Get the dynamic taxonomy filters.
     $options['filters'] = $request->get('t', '', 'array');
     $options['filters'] = $filter->clean($options['filters'], 'array');
     $options['filters'] = ArrayHelper::toInteger($options['filters']);
     // Instantiate a query object.
     $query = new FinderIndexerQuery($options);
     return $query;
 }
Beispiel #29
0
 /**
  * Build the sql query to filter the data
  *
  * @param   object  $params  plugin params
  *
  * @return  string  query's where statement
  */
 protected function getQuery($params)
 {
     $input = $this->app->input;
     $lookUps = $input->get('radius_lookup' . $this->renderOrder, array(), 'array');
     $lookUps = array_filter($lookUps, function ($v) {
         return (string) $v === '1';
     });
     $ids = array_keys($lookUps);
     $ids = ArrayHelper::toInteger($ids);
     $listModel = new FabrikFEModelList();
     $listModel->setId($params->get('radius_lookup_list'));
     $listModel->setLimits(0, -1);
     $key = $listModel->getPrimaryKey();
     $listModel->setPluginQueryWhere('list.radius_lookup', $key . ' IN (' . implode(',', $ids) . ')');
     $data = $listModel->getData();
     $distanceField = $params->get('distance_field') . '_raw';
     $data = $listModel->getData();
     list($latitude, $longitude) = $this->getSearchLatLon();
     if (trim($latitude) === '' && trim($longitude) === '') {
         $input->set('radius_search_active' . $this->renderOrder, array(0));
         return;
     }
     // Need to unset for multiple radius searches to work
     unset($this->mapElement);
     $el = $this->getMapElement();
     $el = FabrikString::safeColName($el->getFullName(false, false));
     // Crazy sql to get the lat/lon from google map element
     $latField = "SUBSTRING_INDEX(TRIM(LEADING '(' FROM {$el}), ',', 1)";
     $lonField = "SUBSTRING_INDEX(SUBSTRING_INDEX({$el}, ',', -1), ')', 1)";
     $query = array();
     $unit = $params->get('radius_lookup_unit', 'km');
     foreach ($data as $group) {
         foreach ($group as $row) {
             $v = $row->{$distanceField};
             if ($unit == 'km') {
                 $query[] = "((((acos(sin((" . $latitude . "*pi()/180)) * sin(({$latField} *pi()/180))+cos((" . $latitude . "*pi()/180)) * cos(({$latField} *pi()/180)) * cos(((" . $longitude . "- {$lonField})*pi()/180))))*180/pi())*60*1.1515*1.609344) <= " . $v . ')';
             } else {
                 $query[] = "((((acos(sin((" . $latitude . "*pi()/180)) * sin(({$latField} *pi()/180))+cos((" . $latitude . "*pi()/180)) * cos(({$latField} *pi()/180)) * cos(((" . $longitude . "- {$lonField})*pi()/180))))*180/pi())*60*1.1515) <= " . $v . ')';
             }
         }
     }
     $query = '(' . implode(' OR ', $query) . ')';
     return $query;
 }
Beispiel #30
0
 /**
  * Load partners data by ID from database.
  *
  * <code>
  * $ids = array(1,2,3,4,5);
  *
  * $partners   = new CrowdfundingPartners\Partners(JFactory::getDbo());
  * $partners->load($ids);
  *
  * foreach($partners as $partner) {
  *   echo $partners["name"];
  *   echo $partners["partner_id"];
  * }
  * </code>
  *
  * @param int $projectId
  * @param array $ids
  */
 public function load($projectId = 0, $ids = array())
 {
     // Load project data
     $query = $this->db->getQuery(true);
     $query->select("a.id, a.name, a.project_id, a.partner_id")->from($this->db->quoteName("#__cfpartners_partners", "a"));
     if (!empty($ids)) {
         ArrayHelper::toInteger($ids);
         $query->where("a.id IN ( " . implode(",", $ids) . " )");
     }
     if (!empty($projectId)) {
         $query->where("a.project_id = " . (int) $projectId);
     }
     $this->db->setQuery($query);
     $results = $this->db->loadAssocList();
     if (!$results) {
         $results = array();
     }
     $this->items = $results;
 }