Example #1
2
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('COM_REDSOCIALSTREAM_CONFIGURE'), 'configure.png');
     JToolBarHelper::apply();
     JToolBarHelper::cancel('cancel', 'COM_REDSOCIALSTREAM_CLOSE');
     //DEVNOTE: set document title
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_REDSOCIALSTREAM_REDSOCIALSTREAMS'));
     $mainframe = JFactory::getApplication();
     $context = "config";
     $model = $this->getModel('configure');
     $db = JFactory::getDbo();
     $q = "SELECT * FROM #__redsocialstream_settings";
     $db->setQuery($q);
     $this->settingsrows = $db->loadObjectList();
     $typelist = $this->get('type_list_sorted');
     $pagination = $this->get('Pagination');
     //DEVNOTE:give me ordering from request
     $filter_order = $mainframe->getUserStateFromRequest($context . 'filter_order', 'filter_order', 'ordering');
     $filter_order_Dir = $mainframe->getUserStateFromRequest($context . 'filter_order_Dir', 'filter_order_Dir', '');
     $this->assignRef('lists', $lists);
     $this->assignRef("typelist", $typelist);
     $this->assignRef('pagination', $pagination);
     parent::display($tpl);
 }
 protected function getInput()
 {
     $html = '';
     $db = JFactory::getDbo();
     $options = JUDownloadHelper::getFieldGroupOptions();
     if ($this->element['usenone'] == 'true') {
         array_unshift($options, array('value' => '0', 'text' => JText::_('COM_JUDOWNLOAD_NONE')));
     }
     if ($this->element['useinherit'] == 'true') {
         $appendInherit = "";
         if ($this->form->getValue("id")) {
             $appendInherit = " ( " . JText::_('COM_JUDOWNLOAD_NONE') . " )";
             if ($this->form->getValue("id") > 0) {
                 $catObj = JUDownloadHelper::getCategoryById($this->form->getValue("parent_id"));
                 if ($catObj->fieldgroup_id > 1) {
                     $query = "SELECT name, published FROM #__judownload_fields_groups WHERE id = " . (int) $catObj->fieldgroup_id . " AND id != 1";
                     $db->setQuery($query);
                     $fieldgroup = $db->loadObject();
                     $groupName = $fieldgroup->published != 1 ? "[" . $fieldgroup->name . "]" : $fieldgroup->name;
                     $appendInherit = "( " . $groupName . " )";
                 }
             }
         }
         array_unshift($options, array('value' => '-1', 'text' => JText::_('COM_JUDOWNLOAD_INHERIT') . $appendInherit));
     } else {
         array_unshift($options, array('value' => '', 'text' => JText::_('COM_JUDOWNLOAD_SELECT_FIELD_GROUP')));
     }
     $required_class = $this->element['required'] == 'true' ? 'required' : '';
     $attributes = "class=\"inputbox {$required_class}\"";
     $html .= JHtml::_('select.genericlist', $options, $this->name, $attributes, 'value', 'text', $this->value, $this->id);
     return $html;
 }
Example #3
1
 /**
  * sauto view display method.
  *
  * @param string $tpl The name of the template file to parse;
  *
  * @return void
  */
 public function display($tpl = null)
 {
     $app =& JFactory::getApplication();
     $link_redirect = JRoute::_('index.php?option=com_sauto');
     $user =& JFactory::getUser();
     $uid = $user->id;
     if ($uid == 0) {
         //vizitator
         $app->redirect($link_redirect, JText::_('SAUTO_PAGE_NOT_EXIST'));
     } else {
         $db = JFactory::getDbo();
         $query = "SELECT `tip_cont` FROM #__sa_profiles WHERE `uid` = '" . $uid . "'";
         $db->setQuery($query);
         $type = $db->loadResult();
         if ($type == 0) {
             //cont customer
             $tpl = '0';
         } elseif ($type == 1) {
             //cont dealer
             $tpl = '1';
         } else {
             $app->redirect($link_redirect, JText::_('SAUTO_PAGE_NOT_EXIST'));
         }
         parent::display($tpl);
     }
 }
 /**
  * Override parent::_getData()
  *
  * @return unknown_type
  */
 function _getData()
 {
     $app = JFactory::getApplication();
     Tienda::load('TiendaQuery', 'library.query');
     // just in case
     $db = JFactory::getDbo();
     $state = $this->_getState();
     $model = $this->_getModel();
     // filter only complete orders ( 3 - Shipped, 5 - Complete, 17 - Payment Received )
     $order_states = array('3', '5', '17');
     $model->setState('filter_orderstates', $order_states);
     $model->setState('order', '`price_total`');
     $model->setState('direction', 'DESC');
     $query = $model->getQuery(true);
     $query->group('p.manufacturer_id');
     $field[] = " SUM(tbl.orderitem_final_price) AS `price_total` ";
     $field[] = " SUM(tbl.orderitem_quantity) AS `count_items` ";
     $query->select($field);
     $model->setQuery($query);
     $list = $model->getList();
     if (!count($list)) {
         return $list;
     }
     return $list;
 }
Example #5
0
 /**
  * Method to test whether a record can be deleted.
  *
  * @param   object  $record  A record object.
  *
  * @return  boolean  True if allowed to delete the record. Defaults to the permission set in the component.
  *
  * @since   1.6
  */
 protected function canDelete($record)
 {
     if (!empty($record->id)) {
         if ($record->state != -2) {
             return false;
         }
         $user = JFactory::getUser();
         $permissions = SibdietHelper::getUserPermissions();
         // Check that user have access permission to data banks and can delete
         if (in_array('contags', $permissions)) {
             // Check that tag not used in diets controller
             $db = JFactory::getDbo();
             $query = $db->getQuery(true)->select("s.id")->from('#__sibdiet_setdiets AS s')->where("FIND_IN_SET('" . $record->id . "', s.tags)");
             $db->setQuery($query);
             try {
                 $used = $db->loadColumn();
             } catch (Exception $e) {
                 // catch any database errors.
             }
             if (count($used)) {
                 // echo that item is used
                 $this->setError(JText::sprintf('COM_SIBDIET_ERR_CONTAG_USED', $record->title . ' (' . implode(' - ', $used) . ')'));
                 return;
             }
             return $user->authorise('core.delete', 'com_sibdiet');
         }
     }
     return false;
 }
Example #6
0
	/**
	 * Add the root node to an empty table.
	 *
	 * @return    integer  The id of the new root node.
	 */
	public function addRoot()
	{
		if (self::getRootId() !== false) {
			return;
		}

		$db = JFactory::getDbo();
		$query = $db->getQuery(true);

		// Insert columns.
		$columns = array('parent_id', 'lft','rgt', 'level', 'catname', 'alias', 'access', 'published');

		// Insert values.
		$values = array(0, 0, 1, 0, $db->quote('root'), $db->quote('root'), 1, 1);

		// Prepare the insert query.
		$query
		->insert($db->quoteName('#__jem_categories'))
		->columns($db->quoteName($columns))
		->values(implode(',', $values));

		$db->setQuery($query);
		$db->execute();

		return $db->insertid();
	}
Example #7
0
 /**
  * Loads the entire menu table into memory.
  *
  * @return  boolean  True on success, false on failure
  *
  * @since   1.5
  */
 public function load()
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('m.id, m.menutype, m.title, m.alias, m.note, m.path AS route, m.link, m.type, m.level, m.language')->select($db->quoteName('m.browserNav') . ', m.access, m.params, m.home, m.img, m.template_style_id, m.component_id, m.parent_id')->select('e.element as component')->from('#__menu AS m')->join('LEFT', '#__extensions AS e ON m.component_id = e.extension_id')->where('m.published = 1')->where('m.parent_id > 0')->where('m.client_id = 0')->order('m.lft');
     // Set the query
     $db->setQuery($query);
     try {
         $this->_items = $db->loadObjectList('id');
     } catch (RuntimeException $e) {
         JError::raiseWarning(500, JText::sprintf('JERROR_LOADING_MENUS', $e->getMessage()));
         return false;
     }
     foreach ($this->_items as &$item) {
         // Get parent information.
         $parent_tree = array();
         if (isset($this->_items[$item->parent_id])) {
             $parent_tree = $this->_items[$item->parent_id]->tree;
         }
         // Create tree.
         $parent_tree[] = $item->id;
         $item->tree = $parent_tree;
         // Create the query array.
         $url = str_replace('index.php?', '', $item->link);
         $url = str_replace('&', '&', $url);
         parse_str($url, $item->query);
     }
     return true;
 }
Example #8
0
 /**
  * Get current plugin id in the #__extensions table
  *
  * @return  integer  The plugin / extension id
  */
 protected function getExtensionId()
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select($db->qn('extension_id'))->from($db->qn('#__extensions'))->where($db->qn('folder') . ' = ' . $db->q($this->_type))->where($db->qn('element') . ' = ' . $db->q($this->_name));
     $db->setQuery($query);
     return $db->loadResult();
 }
Example #9
0
 public function display($tpl = null)
 {
     // Initialise variables
     $this->state = $this->get("State");
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     // Get params
     $this->params = $this->state->get("params");
     /** @var  $this->params Joomla\Registry\Registry */
     $this->numberInRow = $this->params->get("items_row", 3);
     $this->items = CrowdfundingHelper::prepareItems($this->items, $this->numberInRow);
     // Get the folder with images
     $this->imageFolder = $this->params->get("images_directory", "images/crowdfunding");
     // Get currency
     $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->params->get("project_currency"));
     $this->amount = new Crowdfunding\Amount($this->params);
     $this->amount->setCurrency($currency);
     $this->displayCreator = $this->params->get("integration_display_creator", true);
     // Prepare social integration.
     if (!empty($this->displayCreator)) {
         $socialProfilesBuilder = new Prism\Integration\Profiles\Builder(array("social_platform" => $this->params->get("integration_social_platform"), "users_ids" => CrowdfundingHelper::fetchUserIds($this->items)));
         $socialProfilesBuilder->build();
         $this->socialProfiles = $socialProfilesBuilder->getProfiles();
     }
     $this->layoutData = array("items" => $this->items, "params" => $this->params, "amount" => $this->amount, "socialProfiles" => $this->socialProfiles, "imageFolder" => $this->imageFolder, "titleLength" => $this->params->get("discover_title_length", 0), "descriptionLength" => $this->params->get("discover_description_length", 0), "span" => !empty($this->numberInRow) ? round(12 / $this->numberInRow) : 4);
     $this->prepareDocument();
     parent::display($tpl);
 }
 function getObjectOwner($id)
 {
     $db = JFactory::getDbo();
     $db->setQuery('SELECT dmsubmitedby FROM #__docman WHERE id = ' . $id);
     $userid = $db->loadResult();
     return $userid;
 }
Example #11
0
 protected function getOptions()
 {
     // Database Table
     $this->table = $this->getAttribute('table');
     // The field that the field will save on the database
     $this->key_field = (string) $this->getAttribute('key_field');
     // The column that the field shows in the input
     $this->value_field = (string) $this->getAttribute('value_field');
     //where clause
     $this->where_clause = (string) $this->getAttribute('where_clause');
     // Initialize variables.
     $html = '';
     // Load all the field options
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select(array($db->quoteName($this->key_field), $db->quoteName($this->value_field)))->from($this->table);
     if (!empty($this->where_clause)) {
         $query->where($this->where_clause);
     }
     //error_log("Query --> " . $query->__toString());
     $db->setQuery($query);
     $results = $db->loadObjectList();
     $options = array();
     // Iterate through all the results
     foreach ($results as $result) {
         //$options[] = JHtml::_('select.option', $result->{$this->key_field}, $result->{$this->value_field});
         //error_log("result --> " . print_r($result,true));
         $option = new stdClass();
         $option->value = $result->id;
         $option->text = $result->contest_name;
         $options[] = $option;
     }
     return $options;
 }
Example #12
0
 /**
  * method to run after an install/update/uninstall method
  *
  * @return void
  */
 function postflight($type, $parent)
 {
     $manifest = $parent->getParent()->getManifest();
     if ($type != 'uninstall' && !$this->_installAllowed($manifest)) {
         return false;
     }
     // Remove AjaxHelpAry
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select(array('extension_id', 'name', 'params', 'element'));
     $query->from('#__extensions');
     $query->where($db->quoteName('element') . ' = ' . $db->quote('ajaxhelpary'));
     $query->where($db->quoteName('folder') . ' = ' . $db->quote('ajax'));
     $db->setQuery($query);
     $row = $db->loadAssoc();
     if (!empty($row)) {
         $installer = new JInstaller();
         $res = $installer->uninstall('plugin', $row['extension_id']);
         if ($res) {
             $msg = '<b style="color:green">' . JText::sprintf('COM_INSTALLER_UNINSTALL_SUCCESS', $row['name']) . '</b>';
         } else {
             $msg = '<b style="color:red">' . JText::sprintf('COM_INSTALLER_UNINSTALL_ERROR', $row['name']) . '</b>';
         }
         $this->messages[] = $msg;
     }
     parent::postflight($type, $parent, $publishPlugin = true);
 }
Example #13
0
 /**
  * Method to get the field options.
  *
  * @return	array	The field option objects.
  * @since	1.6
  */
 public function getOptions()
 {
     // Initialize variables.
     $options = array();
     /*
      * SQL query:
      * 
      * SELECT DISTINCT (school) AS value, school AS text
      * FROM #__osbitusers
      * ORDER BY school
      */
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('DISTINCT (school) AS value, school AS text');
     $query->from('#__osbitusers');
     $query->order('school');
     // Get the options.
     $db->setQuery($query);
     $options = $db->loadObjectList();
     // Check for a database error.
     if ($db->getErrorNum()) {
         JError::raiseWarning(500, $db->getErrorMsg());
     }
     return $options;
 }
Example #14
0
 public function display($tpl = null)
 {
     $this->state = $this->get('State');
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->params = $this->state->get("params");
     $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $this->state->params->get("project_currency"));
     $this->amount = new Crowdfunding\Amount($this->params);
     $this->amount->setCurrency($currency);
     // Get rewards number
     $usersIds = array();
     foreach ($this->items as $item) {
         $usersIds[] = $item->id;
     }
     // Get number of rewards.
     $statistics = new Crowdfunding\Statistics\Users(JFactory::getDbo(), $usersIds);
     $this->projects = $statistics->getProjectsNumber();
     $this->amounts = $statistics->getAmounts();
     // Add submenu
     CrowdfundingHelper::addSubmenu($this->getName());
     // Prepare sorting data
     $this->prepareSorting();
     // Prepare actions
     $this->addToolbar();
     $this->addSidebar();
     $this->setDocument();
     parent::display($tpl);
 }
Example #15
0
 /**
  * Method to test whether a record can be deleted.
  *
  * @param   object	A record object.
  * @return  boolean  True if allowed to delete the record. Defaults to the permission set in the component.
  */
 protected function canDelete($record)
 {
     if (!empty($record->id)) {
         if ($record->state != -2) {
             return;
         }
         $user = JFactory::getUser();
         // Check that user have access permission to data banks and can delete
         if ($user->authorise('core.delete', $this->option)) {
             // Check that desease not used in these tables
             $tables = array('defaults', 'setdiets');
             $db = JFactory::getDbo();
             foreach ($tables as $table) {
                 $query = $db->getQuery(true)->select("s.id")->from('#__sibdiet_' . $table . ' AS s')->where("FIND_IN_SET('" . $record->id . "', s.goals)");
                 $db->setQuery($query);
                 try {
                     $used = $db->loadColumn();
                 } catch (Exception $e) {
                     // catch any database errors.
                 }
                 if (count($used)) {
                     // echo that item is used
                     $this->setError(JText::sprintf('COM_SIBDIET_ERR_GOAL_USED', $record->title . ' (' . JText::_('COM_SIBDIET_SUBMENU_' . $table) . ': ' . implode(' - ', $used) . ')'));
                     return;
                 }
             }
             return true;
         }
         return;
     }
 }
Example #16
0
 /**
  * Method to load Smart Search plug-in language files.
  *
  * @return  void
  *
  * @since   2.5
  */
 public static function loadPluginLanguage()
 {
     static $loaded = false;
     // If already loaded, don't load again.
     if ($loaded) {
         return;
     }
     $loaded = true;
     // Get array of all the enabled Smart Search plug-in names.
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('name');
     $query->from($db->quoteName('#__extensions'));
     $query->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
     $query->where($db->quoteName('folder') . ' = ' . $db->quote('finder'));
     $query->where($db->quoteName('enabled') . ' = 1');
     $db->setQuery($query);
     $plugins = $db->loadObjectList();
     if (empty($plugins)) {
         return;
     }
     // Load generic language strings.
     $lang = JFactory::getLanguage();
     $lang->load('plg_content_finder', JPATH_ADMINISTRATOR);
     // Load language file for each plug-in.
     foreach ($plugins as $plugin) {
         $lang->load($plugin->name, JPATH_ADMINISTRATOR);
     }
 }
Example #17
0
 /**
  * Search content (articles).
  * The SQL must return the following fields that are used in a common display
  * routine: href, title, section, created, text, browsernav.
  *
  * @param   string  $text      Target search string.
  * @param   string  $phrase    Matching option (possible values: exact|any|all).  Default is "any".
  * @param   string  $ordering  Ordering option (possible values: newest|oldest|popular|alpha|category).  Default is "newest".
  * @param   mixed   $areas     An array if the search it to be restricted to areas or null to search all areas.
  *
  * @return  array  Search results.
  *
  * @since   1.6
  */
 public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $db = JFactory::getDbo();
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
             return array();
         }
     }
     $limit = $this->params->def('search_limit', 50);
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     $rows = array();
     //Search Contents.
     if ($limit > 0) {
         switch ($phrase) {
             case 'exact':
                 $text = $db->quote('%' . $db->escape($text, true) . '%', false);
                 $wheres2 = array();
                 $wheres2[] = 'a.vocabulary LIKE ' . $text;
                 $wheres2[] = 'vocab_subject.subject LIKE ' . $text;
                 $wheres2[] = 'vocab_category.category LIKE ' . $text;
                 $where = '(' . implode(') OR (', $wheres2) . ')';
                 break;
             case 'all':
             case 'any':
             default:
                 $words = explode(' ', $text);
                 $wheres = array();
                 foreach ($words as $word) {
                     $word = $db->quote('%' . $db->escape($word, true) . '%', false);
                     $wheres2 = array();
                     $wheres2[] = 'a.vocabulary LIKE ' . $word;
                     $wheres2[] = 'vocab_subject.subject LIKE ' . $word;
                     $wheres2[] = 'vocab_category.category LIKE ' . $word;
                     $wheres[] = implode(' OR ', $wheres2);
                 }
                 $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
                 break;
         }
         switch ($ordering) {
             default:
                 $order = 'a.id DESC';
                 break;
         }
         $query = $db->getQuery(true);
         $query->clear()->select(array('a.id', 'a.vocabulary AS title', '"" AS created', 'a.vocabulary AS text', '"Content" AS section', '1 AS browsernav'))->from('#__vocab_content AS a')->innerJoin('`#__vocab_subject` AS vocab_subject ON vocab_subject.id = a.subject')->innerJoin('`#__vocab_category` AS vocab_category ON vocab_category.id = a.category')->where('(' . $where . ')')->group('a.id')->order($order);
         $db->setQuery($query, 0, $limit);
         $list = $db->loadObjectList();
         $limit -= count($list);
         if (isset($list)) {
             foreach ($list as $key => $item) {
                 $list[$key]->href = JRoute::_('index.php?option=com_vocab&view=content&id=' . $item->id, false, 2);
             }
         }
         $rows = array_merge($list, $rows);
     }
     return $rows;
 }
Example #18
0
 /**
  * Get a list of logged users.
  *
  * @param	JObject	The module parameters.
  * @return	mixed	An array of articles, or false on error.
  */
 public static function getList($params)
 {
     $db = JFactory::getDbo();
     $user = JFactory::getUser();
     $query = $db->getQuery(true);
     $query->select('s.time, s.client_id, u.id, u.name, u.username');
     $query->from('#__session AS s');
     $query->leftJoin('#__users AS u ON s.userid = u.id');
     $query->where('s.guest = 0');
     $db->setQuery($query, 0, $params->get('count', 5));
     try {
         $results = $db->loadObjectList();
     } catch (RuntimeException $e) {
         JError::raiseError(500, $e->getMessage());
         return false;
     }
     foreach ($results as $k => $result) {
         $results[$k]->logoutLink = '';
         if ($user->authorise('core.manage', 'com_users')) {
             $results[$k]->editLink = JRoute::_('index.php?option=com_users&task=user.edit&id=' . $result->id);
             $results[$k]->logoutLink = JRoute::_('index.php?option=com_login&task=logout&uid=' . $result->id . '&' . JSession::getFormToken() . '=1');
         }
         if ($params->get('name', 1) == 0) {
             $results[$k]->name = $results[$k]->username;
         }
     }
     return $results;
 }
Example #19
0
 /**
  * Method to get a list of content types
  *
  * @return  array  The field option objects.
  *
  * @since   3.1
  */
 protected function getOptions()
 {
     $lang = JFactory::getLanguage();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('a.type_id AS value, a.type_title AS text, a.type_alias AS alias')->from('#__content_types AS a')->order('a.type_title ASC');
     // Get the options.
     $db->setQuery($query);
     try {
         $options = $db->loadObjectList();
     } catch (RuntimeException $e) {
         return false;
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     foreach ($options as $option) {
         // Make up the string from the component sys.ini file
         $parts = explode('.', $option->alias);
         $comp = array_shift($parts);
         // Make sure the component sys.ini is loaded
         $lang->load($comp . '.sys', JPATH_ADMINISTRATOR, null, false, true) || $lang->load($comp . '.sys', JPATH_ADMINISTRATOR . '/components/' . $comp, null, false, true);
         $option->string = implode('_', $parts);
         $option->string = $comp . '_CONTENT_TYPE_' . $option->string;
         if ($lang->hasKey($option->string)) {
             $option->text = JText::_($option->string);
         }
     }
     return $options;
 }
 function getObjectOwner($id)
 {
     $db = JFactory::getDbo();
     $db->setQuery('SELECT created_by, id FROM #__eventlist_events WHERE id = ' . $id);
     $userid = $db->loadResult();
     return $userid;
 }
Example #21
0
 /**
  * Method to get a list of options for a list input.
  *
  * @return	array		An array of JHtml options.
  *
  * @since   11.4
  */
 protected function getOptions()
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     // Select the required fields from the table.
     $query->select('c.id, c.country, c.country_jtext');
     $query->from('`#__tj_country` AS c');
     $query->where('c.com_quick2cart = 1');
     $query->order($db->escape('c.ordering ASC'));
     $db->setQuery($query);
     // Get all countries.
     $countries = $db->loadObjectList();
     $options = array();
     // Load lang file for countries
     $lang = JFactory::getLanguage();
     $lang->load('tjgeo.countries', JPATH_SITE, null, false, true);
     foreach ($countries as $c) {
         if ($lang->hasKey(strtoupper($c->country_jtext))) {
             $c->country = JText::_($c->country_jtext);
         }
         $options[] = JHtml::_('select.option', $c->id, $c->country);
     }
     if (!$this->loadExternally) {
         // Merge any additional options in the XML definition.
         $options = array_merge(parent::getOptions(), $options);
     }
     return $options;
 }
Example #22
0
function addUser($username, $rnames, $email, $password, $block)
{
    /*
    jimport('joomla.user.helper');
    $salt   = JUserHelper::genRandomPassword(32);
    $crypted  = JUserHelper::getCryptedPassword($password, $salt);
    $cpassword = $crypted.':'.$salt; $data = array( "name"=>$name, "username"=>$username, "password"=>$password,
    "password2"=>$password, "email"=>$email, "block"=>0, "groups"=>array("1","2") );
    $user = new JUser;
    if(!$user->bind($data)) { throw new Exception("Could not bind data. Error: " . $user->getError()); }
    if (!$user->save()) { echo "<br>Could not save user $name - " . $user->getError(); }
    return $user->id;
    */
    $db = JFactory::getDbo();
    jimport('joomla.user.helper');
    $pass = JUserHelper::hashPassword($password);
    $time = time();
    $params = '{"admin_style":"","admin_language":"","language":"","editor":"","helpsite":"","timezone":""}';
    $registerDate = date('Y-m-d H:i:s', $time);
    $n_name = explode(" ", $rnames);
    $username = $n_name[0] . $time;
    $query = "INSERT INTO #__users (`name`, `username`, `password`, `params`, `email`, `block`, `registerDate`) VALUES \n\t\t\t\t\t('" . $rnames . "', '" . $username . "', '" . $pass . "', '" . $params . "', '" . $email . "', '" . $block . "', '" . $registerDate . "')";
    $db->setQuery($query);
    $db->query();
    $last_id = $db->insertid();
    $query = "INSERT INTO #__user_usergroup_map (`user_id`, `group_id`) VALUES ('" . $last_id . "', '2')";
    $db->setQuery($query);
    $db->query();
    return $last_id;
}
Example #23
0
 function getObjectOwner($id)
 {
     $db = JFactory::getDbo();
     $db->setQuery('SELECT user_id FROM #__autoexp_add WHERE id = ' . $id);
     $userid = $db->loadResult();
     return $userid;
 }
Example #24
0
 public static function get_list_tour_style()
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('*')->from('#__tsmart_tour_style');
     return $db->setQuery($query)->loadObjectList();
 }
Example #25
0
 /**
  * Initialize the object
  *
  * <code>
  * $ids = array(1, 2, 3, 4);
  *
  * $profiles = new ITPrismIntegrateProfilesGravatar($ids);
  * </code>
  *
  * @param  array $ids Users IDs
  */
 public function __construct($ids = array())
 {
     $this->db = JFactory::getDbo();
     if (!empty($ids)) {
         $this->load($ids);
     }
 }
Example #26
0
 static function getList(&$params)
 {
     //get database
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year');
     $query->from('#__content');
     $query->where('state = 2 AND checked_out = 0');
     $query->group('created_year DESC, created_month DESC');
     // Filter by language
     if (JFactory::getApplication()->getLanguageFilter()) {
         $query->where('language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
     }
     $db->setQuery($query, 0, intval($params->get('count')));
     $rows = (array) $db->loadObjectList();
     $app = JFactory::getApplication();
     $menu = $app->getMenu();
     $item = $menu->getItems('link', 'index.php?option=com_content&view=archive', true);
     $itemid = isset($item) && !empty($item->id) ? '&Itemid=' . $item->id : '';
     $i = 0;
     $lists = array();
     foreach ($rows as $row) {
         $date = JFactory::getDate($row->created);
         $created_month = $date->format('n');
         $created_year = $date->format('Y');
         $created_year_cal = JHTML::_('date', $row->created, 'Y');
         $month_name_cal = JHTML::_('date', $row->created, 'F');
         $lists[$i] = new stdClass();
         $lists[$i]->link = JRoute::_('index.php?option=com_content&view=archive&year=' . $created_year . '&month=' . $created_month . $itemid);
         $lists[$i]->text = JText::sprintf('MOD_ARTICLES_ARCHIVE_DATE', $month_name_cal, $created_year_cal);
         $i++;
     }
     return $lists;
 }
Example #27
0
 public static function getContentList($params)
 {
     $db = JFactory::getDbo();
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $groups = implode(',', $user->getAuthorisedViewLevels());
     //$matchtype  = $params->get('matchtype', 'all');
     $maximum = $params->get('maximum', 5);
     $tagsHelper = new JHelperTags();
     $option = $app->input->get('option');
     $view = $app->input->get('view');
     $prefix = $option . '.' . $view;
     $id = (array) $app->input->getObject('id');
     $selectedTag = $params->get('selected_tag');
     // Strip off any slug data.
     foreach ($id as $id) {
         if (substr_count($id, ':') > 0) {
             $idexplode = explode(':', $id);
             $id = $idexplode[0];
         }
     }
     $tagsToMatch = $selectedTag;
     if (!$tagsToMatch || is_null($tagsToMatch)) {
         return $results = false;
     }
     $query = $tagsHelper->getTagItemsQuery($tagsToMatch, $typesr = null, $includeChildren = false, $orderByOption = 'c.core_title', $orderDir = 'ASC', $anyOrAll = true, $languageFilter = 'all', $stateFilter = '0,1');
     $db->setQuery($query, 0, $maximum);
     $results = $db->loadObjectList();
     foreach ($results as $result) {
         $explodedAlias = explode('.', $result->type_alias);
         $result->link = 'index.php?option=' . $explodedAlias[0] . '&view=' . $explodedAlias[1] . '&id=' . $result->content_item_id . '-' . $result->core_alias;
     }
     return $results;
 }
Example #28
0
 public function saveOrder($pks = array(), $lft = array())
 {
     JPluginHelper::importPlugin('cck_storage_location');
     if (!count($pks)) {
         return false;
     }
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('a.id, a.pk, a.storage_location, b.id AS type_id')->from('#__cck_core AS a')->join('LEFT', '#__cck_core_types AS b ON b.name = a.cck')->where('a.id IN (' . implode(',', $pks) . ')');
     $db->setQuery($query);
     $results = $db->loadAssocList('id');
     if (!empty($results)) {
         $ids = array();
         $location = null;
         $user = JCck::getUser();
         $user_id = $user->get('id');
         foreach ($pks as $i => $pk) {
             $canEdit = $user->authorise('core.edit', 'com_cck.form.' . $results[$pk]['type_id']);
             $canEditOwn = $user->authorise('core.edit.own', 'com_cck.form.' . $results[$pk]['type_id']);
             // Check Permissions
             if (!($canEdit && $canEditOwn || $canEdit && !$canEditOwn && $results[$pk]['author_id'] != $user_id || $canEditOwn && $results[$pk]['author_id'] == $user_id)) {
                 unset($lft[$i]);
                 continue;
             }
             $ids[] = $results[$pk]['pk'];
             if (null === $location) {
                 $location = $results[$pk]['storage_location'];
             }
         }
         if ($location && count($ids)) {
             return JCck::callFunc_Array('plgCCK_Storage_Location' . $location, 'onCCK_Storage_LocationSaveOrder', array($ids, $lft));
         }
     }
     return false;
 }
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     $options = array();
     $options[] = JHtml::_('select.option', 'id', JText::_('COM_VISFORMS_ID'), 'value', 'text', false);
     $options[] = JHtml::_('select.option', 'created', JText::_('COM_VISFORMS_SUBMISSIONDATE'), 'value', 'text', false);
     $options[] = JHtml::_('select.option', 'ismfd', JText::_('COM_VISFORMS_MODIFIED'), 'value', 'text', false);
     $id = 0;
     //extract form id
     $form = $this->form;
     $link = $form->getValue('link');
     if (isset($link) && $link != "") {
         $parts = array();
         parse_str($link, $parts);
         if (isset($parts['id']) && is_numeric($parts['id'])) {
             $id = $parts['id'];
         }
     }
     // Create options according to visfield settings
     $db = JFactory::getDbo();
     $query = ' SELECT c.id , c.label from #__visfields as c where c.fid=' . $id . ' AND c.published = 1 AND (c.frontdisplay is null or c.frontdisplay = 1 or c.frontdisplay = 2) ' . "and !(c.typefield = 'reset') and !(c.typefield = 'submit') and !(c.typefield = 'image') and !(c.typefield = 'fieldsep') and !(c.typefield = 'hidden')";
     $db->setQuery($query);
     $fields = $db->loadObjectList();
     if ($fields) {
         foreach ($fields as $field) {
             $tmp = JHtml::_('select.option', $field->id, $field->label, 'value', 'text', false);
             // Add the option object to the result set.
             $options[] = $tmp;
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Example #30
-3
 /**
  * Method to get a list of options for a list input.
  *
  * @return	array		An array of JHtml options.
  *
  * @since   11.4
  */
 protected function getOptions()
 {
     // Initialise variables
     $folder = $this->element['folder'];
     if (!empty($folder)) {
         // Get list of plugins
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('element AS value, name AS text');
         $query->from('#__extensions');
         $query->where('folder = ' . $db->q($folder));
         $query->where('enabled = 1');
         $query->order('ordering, name');
         $db->setQuery($query);
         $options = $db->loadObjectList();
         $lang = JFactory::getLanguage();
         foreach ($options as $i => $item) {
             $source = JPATH_PLUGINS . '/' . $folder . '/' . $item->value;
             $extension = 'plg_' . $folder . '_' . $item->value;
             $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension . '.sys', $source, null, false, false) || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false);
             $options[$i]->text = JText::_($item->text);
         }
         if ($db->getErrorMsg()) {
             JError::raiseWarning(500, JText::_('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY'));
             return '';
         }
     } else {
         JError::raiseWarning(500, JText::_('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY'));
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }