public function delete()
 {
     // Check for request forgeries
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     // Get items to remove from the request.
     $cid = JFactory::getApplication()->input->get('cid', array(), 'array');
     if (!is_array($cid) || count($cid) < 1) {
         JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror');
     } else {
         // Get the model.
         $model = $this->getModel();
         // Make sure the item ids are integers
         jimport('joomla.utilities.arrayhelper');
         JArrayHelper::toInteger($cid);
         // Remove the items.
         if ($model->delete($cid)) {
             $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
         } else {
             $this->setMessage($model->getError());
         }
     }
     $version = new JVersion();
     if ($version->isCompatible('3.0')) {
         // Invoke the postDelete method to allow for the child class to access the model.
         $this->postDeleteHook($model, $cid);
     }
     $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
 }
Beispiel #2
0
 public function selectnfredirect()
 {
     // collect input data : which url needs to be redirected ?
     $notFoundUrlId = JRequest::getInt('notfound_url_id');
     // which URL to redirect to?
     $cid = JRequest::getVar('cid', array(0), 'default', 'array');
     JArrayHelper::toInteger($cid);
     if (count($cid) > 1) {
         // more than one target url selected, display error
         $this->setError(JText16::_('COM_SH404SEF_SELECT_ONLY_ONE_URL_TO_REDIRECT'));
         $this->display();
         return;
     }
     // only one url, use it
     $targetUrlId = $cid[0];
     if (empty($targetUrlId)) {
         // bad url, probably not an integer was passed
         $this->setError(JText16::_('COM_SH404SEF_INVALID_REDIRECT_TARGET_ID'));
         $this->display();
         return;
     }
     // get model and ask it to do the job
     $model =& $this->getModel($this->_defaultModel);
     $model->redirectNotFoundUrl($notFoundUrlId, $targetUrlId);
     // check errors
     $error = $model->getError();
     if (!empty($error)) {
         $this->setError($error);
     }
     // standard display
     $this->display();
 }
Beispiel #3
0
	/**
	 * Method to save the submitted ordering values for records via AJAX.
	 *
	 * @return  void
	 *
	 * @since   3.0
	 */
	public function saveOrderAjax()
	{
		// Get the input
		$pks   = $this->input->post->get('cid', array(), 'array');
		$order = $this->input->post->get('order', array(), 'array');

		// Sanitize the input
		JArrayHelper::toInteger($pks);
		JArrayHelper::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 #4
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return  void
  *
  * @since   1.6
  */
 protected function populateState($ordering = null, $direction = null)
 {
     $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.
     $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
     $this->setState('filter.search', $search);
     $active = $this->getUserStateFromRequest($this->context . '.filter.active', 'filter_active');
     $this->setState('filter.active', $active);
     $state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state');
     $this->setState('filter.state', $state);
     $groupId = $this->getUserStateFromRequest($this->context . '.filter.group', 'filter_group_id', null, 'int');
     $this->setState('filter.group_id', $groupId);
     $range = $this->getUserStateFromRequest($this->context . '.filter.range', 'filter_range');
     $this->setState('filter.range', $range);
     $groups = json_decode(base64_decode($app->input->get('groups', '', 'BASE64')));
     if (isset($groups)) {
         JArrayHelper::toInteger($groups);
     }
     $this->setState('filter.groups', $groups);
     $excluded = json_decode(base64_decode($app->input->get('excluded', '', 'BASE64')));
     if (isset($excluded)) {
         JArrayHelper::toInteger($excluded);
     }
     $this->setState('filter.excluded', $excluded);
     // Load the parameters.
     $params = JComponentHelper::getParams('com_users');
     $this->setState('params', $params);
     // List state information.
     parent::populateState('a.name', 'asc');
 }
Beispiel #5
0
 public function toggleInList()
 {
     // Check for request forgeries
     JRequest::checkToken() or die(JText::_('JINVALID_TOKEN'));
     // Get items to publish from the request.
     $cid = JRequest::getVar('cid', array(), '', 'array');
     $data = array('showInListView' => 1, 'hideFromListView' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($data, $task, 0, 'int');
     if (empty($cid)) {
         JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Make sure the item ids are integers
         JArrayHelper::toInteger($cid);
         // Publish the items.
         if (!$model->addToListView($cid, $value)) {
             JError::raiseWarning(500, $model->getError());
         } else {
             if ($value == 1) {
                 $ntext = $this->text_prefix . '_N_ITEMS_ADDED_TO_LIST_VIEW';
             } else {
                 $ntext = $this->text_prefix . '_N_ITEMS_REMOVED_FROM_LIST_VIEW';
             }
             $this->setMessage(JText::plural($ntext, count($cid)));
         }
     }
     $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
 }
Beispiel #6
0
 function savesetting()
 {
     $juser =& JFactory::getUser();
     if ($juser->guest) {
         $error = 'Bạn phải đăng nhập để thực hiện chức năng này';
         $this->setError($error);
         return false;
     }
     $post = JRequest::get('post');
     JArrayHelper::toInteger($post);
     $data = array();
     $data['user_id'] = $juser->id;
     $data['show_counter'] = $post['show_counter'] == 0 ? 0 : 1;
     $data['email_subscribe'] = $post['email_subscribe'] == 0 ? 0 : 1;
     $data['email_notify'] = $post['email_notify'] == 0 ? 0 : 1;
     $data['pre_check'] = $post['pre_check'] == 0 ? 0 : 1;
     $row =& $this->getTable('users');
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     return true;
 }
Beispiel #7
0
 /**
  * Execute the controller.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function execute()
 {
     // Get the application
     /* @var InstallationApplicationWeb $app */
     $app = $this->getApplication();
     // Check for request forgeries.
     JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403));
     // Get array of selected languages
     $lids = $this->input->get('cid', array(), 'array');
     JArrayHelper::toInteger($lids, array());
     // Get the languages model.
     $model = new InstallationModelLanguages();
     if (!$lids) {
         // No languages have been selected
         $app->enqueueMessage(JText::_('INSTL_LANGUAGES_NO_LANGUAGE_SELECTED'), 'warning');
     } else {
         // Install selected languages
         $model->install($lids);
         // Publish the Content Languages.
         $model->publishContentLanguages();
         $app->enqueueMessage(JText::_('INSTL_LANGUAGES_MORE_LANGUAGES'), 'notice');
     }
     // Redirect to the page.
     $r = new stdClass();
     $r->view = 'defaultlanguage';
     $app->sendJsonResponse($r);
 }
 /**
  * Returns an array of categories for the given extension.
  *
  * @param   string  $extension  The extension option.
  * @param   array   $config     An array of configuration options. By default, only published and unpublished categories are returned.
  *
  * @return  array   Categories for the extension
  *
  * @since   11.1
  */
 public function categories($extension, $config = array('filter.published' => array(0, 1)))
 {
     $config = (array) $config;
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('a.id, a.title, a.level, a.parent_id');
     $query->from('#__categories AS a');
     $query->where('a.parent_id > 0');
     // Filter on extension.
     $query->where('extension = ' . $db->quote($extension));
     // Filter on the published state
     if (isset($config['filter.published'])) {
         if (is_numeric($config['filter.published'])) {
             $query->where('a.published = ' . (int) $config['filter.published']);
         } elseif (is_array($config['filter.published'])) {
             JArrayHelper::toInteger($config['filter.published']);
             $query->where('a.published IN (' . implode(',', $config['filter.published']) . ')');
         }
     }
     $query->order('a.lft');
     $db->setQuery($query);
     $items = $db->loadObjectList();
     $allitems = array();
     foreach ($items as &$item) {
         $repeat = $item->level - 1 >= 0 ? $item->level - 1 : 0;
         $item->title = str_repeat('- ', $repeat) . $item->title;
         $allitems[$item->id] = $item->title;
     }
     return $allitems;
 }
Beispiel #9
0
 public function feature()
 {
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $cid = $app->input->post->get('documentid', array(), 'array');
     $data = array('feature' => 1, 'unfeature' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($data, $task, 0, 'int');
     $rootCat = JUDownloadFrontHelperCategory::getRootCategory();
     if (empty($cid)) {
         JError::raiseWarning(500, JText::_('COM_JUDOWNLOAD_NO_ITEM_SELECTED'));
     } else {
         $model = $this->getModel();
         JArrayHelper::toInteger($cid);
         if (!$model->feature($cid, $value)) {
             JError::raiseWarning(500, $model->getError());
         } else {
             if ($value == 1) {
                 $ntext = $this->text_prefix . '_N_ITEMS_FEATURED';
             } elseif ($value == 0) {
                 $ntext = $this->text_prefix . '_N_ITEMS_UNFEATURED';
             }
             $this->setMessage(JText::plural($ntext, count($cid)));
         }
     }
     $extension = $app->input->get('extension');
     $extensionURL = $extension ? '&extension=' . $extension : '';
     $catURL = '&cat_id=' . $app->input->getInt('cat_id', $rootCat->id);
     $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $catURL . $extensionURL, false));
 }
Beispiel #10
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	An optional array of primary key values to update.  If not
  * 					set the instance property value is used.
  * @param	integer The publishing state. eg. [0 = unpublished, 1 = published, 2=archived, -2=trashed]
  * @param	integer The user id of the user performing the operation.
  *
  * @return	boolean	True on success.
  * @since	1.0
  */
 public function publish($pks = null, $state = 1, $userId = 0)
 {
     // Initialise variables.
     $k = $this->_tbl_key;
     // Sanitize input.
     JArrayHelper::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;
         }
     }
     // Get an instance of the table
     $table = JTable::getInstance('List', 'NewsletterTable');
     // For all keys
     foreach ($pks as $pk) {
         // Load the banner
         if (!$table->load($pk)) {
             $this->setError($table->getError());
         }
         // Change the state
         $table->state = $state;
         // Store the row
         if (!$table->store()) {
             $this->setError($table->getError());
         }
     }
     return count($this->getErrors()) == 0;
 }
Beispiel #11
0
 public static function getArray($name, $default = array(), $type = 'array', $hash = 'default', $mask = 0)
 {
     // explode name
     $parts = explode('.', $name);
     if (count($parts) > 1) {
         $name = $parts[0];
         $key = $parts[1];
     }
     $array = self::getVar($name, $default, $hash, 'array', $mask);
     if (isset($key)) {
         if (is_array($array) && array_key_exists($key, $array)) {
             $value = $array[$key];
             settype($value, $type);
             return $value;
         }
         return $default;
     }
     if ($type == 'string') {
         JArrayHelper::toString($array);
     } else {
         if ($type == 'int') {
             JArrayHelper::toInteger($array);
         }
     }
     return $array;
 }
Beispiel #12
0
    private function setQueryConditions(&$query)
    {
        $db = $this->getDBO();
        if ($this->getState('itemId')) {
            $query->leftJoin($db->quoteName('#__k2_tags_xref', 'xref') . ' ON ' . $db->quoteName('xref.tagId') . ' = ' . $db->quoteName('tag.id'));
            $query->where($db->quoteName('xref.itemId') . ' = ' . (int) $this->getState('itemId'));
        }
        if (is_numeric($this->getState('state'))) {
            $query->where($db->quoteName('tag.state') . ' = ' . (int) $this->getState('state'));
        }
        if ($this->getState('id')) {
            $id = $this->getState('id');
            if (is_array($id)) {
                JArrayHelper::toInteger($id);
                $query->where($db->quoteName('tag.id') . ' IN (' . implode(',', $id) . ')');
            } else {
                $query->where($db->quoteName('tag.id') . ' = ' . (int) $id);
            }
        }
        if ($this->getState('alias')) {
            $query->where($db->quoteName('tag.alias') . ' = ' . $db->quote($this->getState('alias')));
        }
        if ($this->getState('search')) {
            $search = JString::trim($this->getState('search'));
            $search = JString::strtolower($search);
            if ($search) {
                $search = $db->escape($search, true);
                $query->where('( LOWER(' . $db->quoteName('tag.name') . ') LIKE ' . $db->Quote('%' . $search . '%', false) . ' 
				OR ' . $db->quoteName('tag.id') . ' = ' . (int) $search . '  
				OR LOWER(' . $db->quoteName('tag.alias') . ') LIKE ' . $db->Quote('%' . $search . '%', false) . ')');
            }
        }
    }
Beispiel #13
0
 /**
  * Method to remove a record.
  */
 public function delete()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JInvalid_Token'));
     // Initialise variables.
     $user = JFactory::getUser();
     $ids = JRequest::getVar('cid', array(), '', 'array');
     if (!JFactory::getUser()->authorise('core.admin', $this->option)) {
         JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR'));
         jexit();
     } elseif (empty($ids)) {
         JError::raiseWarning(500, JText::_('COM_USERS_NO_LEVELS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         JArrayHelper::toInteger($ids);
         // Remove the items.
         if (!$model->delete($ids)) {
             JError::raiseWarning(500, $model->getError());
         } else {
             $this->setMessage(JText::plural('COM_USERS_N_LEVELS_DELETED', count($ids)));
         }
     }
     $this->setRedirect('index.php?option=com_users&view=levels');
 }
Beispiel #14
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');
     JArrayHelper::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)) {
         $cache = JFactory::getCache('mod_menu');
         $cache->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 #15
0
 public function featured($pks, $value = 0)
 {
     // Sanitize the ids.
     $pks = (array) $pks;
     JArrayHelper::toInteger($pks);
     if (empty($pks)) {
         $this->setError(JText::_('COM_CONTACT_NO_ITEM_SELECTED'));
         return false;
     }
     $table = $this->getTable();
     try {
         $db = $this->getDbo();
         $query = $db->getQuery(true);
         $query->update('#__bookpro_tour');
         $query->set('featured = ' . (int) $value);
         $query->where('id IN (' . implode(',', $pks) . ')');
         $db->setQuery($query);
         $db->execute();
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     $table->reorder();
     // Clean component's cache
     $this->cleanCache();
     return true;
 }
Beispiel #16
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	An optional array of primary key values to update.  If not
  *					set the instance property value is used.
  * @param	integer The publishing state. eg. [0 = unpublished, 1 = published]
  * @param	integer The user id of the user performing the operation.
  * @return	boolean	True on success.
  * @since	1.0.4
  */
 public function publish($pks = null, $state = 1, $userId = 0)
 {
     // Initialise variables.
     $k = $this->_tbl_key;
     // Sanitize input.
     JArrayHelper::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;
         }
     }
     // 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.
     $this->_db->setQuery('UPDATE `' . $this->_tbl . '`' . ' SET state = ' . (int) $state . ' WHERE (' . $where . ')');
     $this->_db->execute();
     // Check for a database error.
     if ($this->_db->getErrorNum()) {
         $this->setError($this->_db->getErrorMsg());
         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;
 }
Beispiel #17
0
 public function delete()
 {
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $cid = $app->input->get('cid', array(), 'array');
     if (!is_array($cid) || count($cid) < 1) {
         JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Make sure the item ids are integers
         jimport('joomla.utilities.arrayhelper');
         JArrayHelper::toInteger($cid);
         // Remove the items.
         if ($model->delete($cid)) {
             $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
         } else {
             $this->setMessage($model->getError());
         }
     }
     $vars = '';
     $extension = $app->input->get('extension', '');
     if ($extension) {
         $vars = '&extension=' . $extension;
     }
     $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $vars, false));
 }
Beispiel #18
0
 protected function removeInstances($module_name)
 {
     $db = $this->parent->getDbo();
     // Lets delete all the module copies for the type we are uninstalling
     $query = 'SELECT `id`' . ' FROM `#__modules`' . ' WHERE module = ' . $db->quote($module_name);
     $db->setQuery($query);
     try {
         $modules = $db->loadColumn();
     } catch (Exception $e) {
         $modules = array();
     }
     // Do we have any module copies?
     if (count($modules)) {
         // Ensure the list is sane
         JArrayHelper::toInteger($modules);
         $modID = implode(',', $modules);
         // Wipe out any items assigned to menus
         $query = 'DELETE' . ' FROM #__modules_menu' . ' WHERE moduleid IN (' . $modID . ')';
         $db->setQuery($query);
         try {
             $db->execute();
         } catch (Exception $e) {
             JError::raiseWarning(100, JText::sprintf('JLIB_INSTALLER_ERROR_MOD_UNINSTALL_EXCEPTION', $db->stderr(true)));
         }
         // Wipe out any instances in the modules table
         $query = 'DELETE' . ' FROM #__modules' . ' WHERE id IN (' . $modID . ')';
         $db->setQuery($query);
         try {
             $db->execute();
         } catch (Exception $e) {
             JError::raiseWarning(100, JText::sprintf('JLIB_INSTALLER_ERROR_MOD_UNINSTALL_EXCEPTION', $db->stderr(true)));
         }
     }
 }
Beispiel #19
0
 /**
  * Function to convert a string or array into a single string
  *
  * @param   mixed   $values        Array or string to use as values
  * @param   string  $filter        Filter to apply to the values to quote or (int) them
  * @param   array   $removeValues  Items to remove/filter from the source array
  *
  * @return  string
  */
 public static function multipleSanitised($values, $filter = 'integer', $removeValues = array(''))
 {
     $db = JFactory::getDbo();
     // Extra verification to avoid null values
     if (is_null($values)) {
         return false;
     }
     if (!is_array($values)) {
         // Convert comma separated values to arrays
         $values = (array) explode(',', $values);
     }
     // If all is selected remove filter
     if (in_array('*', $values)) {
         return null;
     }
     // Remove undesired source values
     if (!empty($removeValues)) {
         $values = array_diff($values, $removeValues);
     }
     // Filter to sanitise data
     switch ($filter) {
         case 'integer':
             JArrayHelper::toInteger($values);
             break;
         default:
             $values = array_map(array($db, 'quote'), $values);
             break;
     }
     return $values;
 }
Beispiel #20
0
 /**
  * Logic to remove
  */
 function remove()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // Get the model
     $model = $this->getModel('groups');
     // Get the selected items
     $cid = JRequest::getVar('cid', array(0), 'post', 'array');
     // Force array elements to be integers
     JArrayHelper::toInteger($cid, array(0));
     $msg = '';
     // No items are selected
     if (!is_array($cid) || count($cid) < 1) {
         JError::raiseWarning(500, JText::_('SELECT ITEM DELETE'));
     } else {
         $model->remove($cid);
         $total = count($cid);
         $msg = JText::sprintf('RST_GROUPS_DELETED', $total);
         // Clean the cache, if any
         $cache =& JFactory::getCache('com_rsticketspro');
         $cache->clean();
     }
     // Redirect
     $this->setRedirect('index.php?option=com_rsticketspro&view=groups', $msg);
 }
Beispiel #21
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 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   1.6
  */
 public function publish($pks = null, $state = 1, $userId = 0)
 {
     $k = $this->_tbl_key;
     // Sanitize input.
     JArrayHelper::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 . ' IN (' . implode(',', $pks) . ')';
     // Update the publishing state for rows with the given primary keys.
     $this->_db->setQuery('UPDATE ' . $this->_db->quoteName($this->_tbl) . ' SET ' . $this->_db->quoteName('state') . ' = ' . (int) $state . ' WHERE (' . $where . ')');
     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;
 }
Beispiel #22
0
 function getZones($ids, $columns = '*', $key = 'zone_id', $returnArrayWithOneColumn = false)
 {
     if (is_numeric($ids)) {
         $ids = array($ids);
     } elseif (!is_array($ids)) {
         return array();
     }
     if ($key == 'zone_id') {
         JArrayHelper::toInteger($ids);
     } else {
         foreach ($ids as $k => $id) {
             $ids[$k] = $this->database->Quote($id);
         }
     }
     $query = 'SELECT ' . preg_replace('#[^a-z_, ]#', '', $columns) . ' FROM #__hikashop_zone WHERE ' . preg_replace('#[^a-z_]#', '', $key) . ' IN (' . implode(',', $ids) . ')';
     $this->database->setQuery($query);
     if ($returnArrayWithOneColumn) {
         if (!HIKASHOP_J25) {
             return $this->database->loadResultArray();
         } else {
             return $this->database->loadColumn();
         }
     } else {
         return $this->database->loadObjectList();
     }
 }
Beispiel #23
0
 function &getEventLists()
 {
     if (is_null($this->_eventLists)) {
         $this->_eventLists = array();
         $db = FabrikWorker::getDbo(true);
         $params = $this->getPluginParams();
         $lists = (array) $params->get('calendar_table');
         JArrayHelper::toInteger($lists);
         $dateFields = (array) $params->get('calendar_startdate_element');
         $dateFields2 = (array) $params->get('calendar_enddate_element');
         $labels = (array) $params->get('calendar_label_element');
         $colours = (array) $params->get('colour');
         $db->setQuery("SELECT id AS value, label AS text FROM #__{package}_lists WHERE id IN ('" . implode("','", $lists) . "')");
         $rows = $db->loadObjectList();
         for ($i = 0; $i < count($rows); $i++) {
             if (!isset($colours[$i])) {
                 $colours[$i] = '';
             }
             $rows[$i]->startdate_element = $dateFields[$i];
             $rows[$i]->enddate_element = JArrayHelper::getValue($dateFields2, $i);
             $rows[$i]->label_element = $labels[$i];
             $rows[$i]->colour = $colours[$i];
         }
         $this->_eventLists = $rows;
     }
     return $this->_eventLists;
 }
 function fetchElement($name, $value, &$node, $control_name)
 {
     $access = JFactory::getACL();
     // Include user in groups that have access to edit their articles, other articles, or manage content.
     $action = array('com_content.article.edit_own', 'com_content.article.edit_article', 'com_content.manage');
     $groups = $access->getAuthorisedUsergroups($action, true);
     // Check the results of the access check.
     if (!$groups) {
         return false;
     }
     // Clean up and serialize.
     JArrayHelper::toInteger($groups);
     $groups = implode(',', $groups);
     // Build the query to get the users.
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('u.id AS value');
     $query->select('u.name AS text');
     $query->from('#__users AS u');
     $query->join('INNER', '#__user_usergroup_map AS m ON m.user_id = u.id');
     $query->where('u.block = 0');
     $query->where('m.group_id IN (' . $groups . ')');
     // Get the users.
     $db->setQuery((string) $query);
     $users = $db->loadObjectList();
     // Check for a database error.
     if ($db->getErrorNum()) {
         JError::raiseNotice(500, $db->getErrorMsg());
         return false;
     }
     return JHtml::_('select.genericlist', $users, $name, 'class="inputbox" size="1"', 'value', 'text', $value);
 }
 public function exportData()
 {
     // Check for request forgeries
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     // check if export is allowed for this user.
     $user = JFactory::getUser();
     if ($user->authorise('help_document.export', 'com_costbenefitprojection') && $user->authorise('core.export', 'com_costbenefitprojection')) {
         // Get the input
         $input = JFactory::getApplication()->input;
         $pks = $input->post->get('cid', array(), 'array');
         // Sanitize the input
         JArrayHelper::toInteger($pks);
         // Get the model
         $model = $this->getModel('Help_documents');
         // get the data to export
         $data = $model->getExportData($pks);
         if (CostbenefitprojectionHelper::checkArray($data)) {
             // now set the data to the spreadsheet
             $date = JFactory::getDate();
             CostbenefitprojectionHelper::xls($data, 'Help_documents_' . $date->format('jS_F_Y'), 'Help documents exported (' . $date->format('jS F, Y') . ')', 'help documents');
         }
     }
     // Redirect to the list screen with error.
     $message = JText::_('COM_COSTBENEFITPROJECTION_EXPORT_FAILED');
     $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=help_documents', false), $message, 'error');
     return;
 }
Beispiel #26
0
 function remove()
 {
     $option = 'com_jobboard';
     $cid = JRequest::getVar('cid', array(), '', 'array');
     JArrayHelper::toInteger($cid);
     $doc =& JFactory::getDocument();
     $style = " .icon-48-job_posts {background-image:url(components/com_jobboard/images/job_posts.png); no-repeat; }";
     $doc->addStyleDeclaration($style);
     $this->setToolbar();
     $un_deletable = array();
     $undeletables = false;
     $count_cid = count($cid);
     if ($count_cid) {
         for ($i = 0; $i <= $count_cid; $i++) {
             if ($cid[$i] == 1 || $cid[$i] == 6 || $cid[$i] == 7) {
                 $un_deletable[] = $cid[$i];
                 unset($cid[$i]);
                 $undeletables = true;
             }
         }
         if ($undeletables == false) {
             $success_msg = $count_cid == 1 ? JText::_('COM_JOBBOARD_STATUS_DELETED') : JText::_('COM_JOBBOARD_STATUSES_DELETED');
             $cids = implode(',', $cid);
             $jobs_model =& $this->getModel('Statuses');
             $delete_result = $jobs_model->deleteStatuses($cids);
             if ($delete_result != true) {
                 $this->setRedirect('index.php?option=com_jobboard&view=statuses', $delete_result);
             } else {
                 $this->setRedirect('index.php?option=com_jobboard&view=statuses', $success_msg);
             }
         }
         if ($undeletables == true) {
             $undel_messg = JText::_('COM_JOBBOARD_ITEM_NO_DELETE') . ': #' . $un_deletable[0];
             if ($count_cid == 1) {
                 $this->setRedirect('index.php?option=' . $option . '&view=statuses', $undel_messg);
             } else {
                 $unDeletableCount = count($un_deletable);
                 $success_msg = $count_cid == 2 && $unDeletableCount == 1 || $count_cid <= 3 && $unDeletableCount > 1 ? JText::_('COM_JOBBOARD_STATUS_DELETED') : JText::_('COM_JOBBOARD_STATUSES_DELETED');
                 $cids = implode(',', $cid);
                 $jobs_model =& $this->getModel('Statuses');
                 $delete_result = $jobs_model->deleteStatuses($cids);
                 if ($unDeletableCount > 1) {
                     for ($i = 1; $i < $unDeletableCount; $i++) {
                         $undel_messg .= ', #' . $un_deletable[$i];
                     }
                 }
                 if ($unDeletableCount == $count_cid) {
                     $success_msg = $undel_messg;
                 } else {
                     $success_msg .= '; ' . $undel_messg;
                 }
                 if ($delete_result != true) {
                     $this->setRedirect('index.php?option=com_jobboard&view=statuses', $delete_result);
                 } else {
                     $this->setRedirect('index.php?option=com_jobboard&view=statuses', $success_msg);
                 }
             }
         }
     }
 }
Beispiel #27
0
 function _delete_templateinvite()
 {
     $app = JFactory::getApplication();
     // initialize variables
     $db = JFactory::getDBO();
     $cid = JFactory::getApplication()->input->get('cid', array(), 'array');
     $msgType = '';
     JArrayHelper::toInteger($cid);
     if (count($cid)) {
         // are there one or more rows to delete?
         /*
         if (count($cid) == 1) {
         	$row = JTable::getInstance('template_invite');
         	$row->load($cid[0]);
         } else {
         	$msg = JText::sprintf('AUP_MSGSUCCESSFULLYDELETED', JText::_('AUP_RULES'), '');
         }
         */
         $query = "DELETE FROM #__alpha_userpoints_template_invite" . "\n WHERE (`id` = " . implode(' OR `id` = ', $cid) . ")";
         $db->setQuery($query);
         if (!$db->query()) {
             $msg = $db->getErrorMsg();
             $msgType = 'error';
         }
     }
     JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&task=templateinvite', $msg, $msgType);
     JControllerLegacy::redirect();
 }
 /**
  * Constructor
  *
  * @since 1.0
  */
 function __construct()
 {
     parent::__construct();
     $cid = JRequest::getVar('cid', array(0), '', 'array');
     JArrayHelper::toInteger($cid, array(0));
     $this->setId($cid[0]);
 }
Beispiel #29
0
 public function saveOrder()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $mainframe = JFactory::getApplication();
     $jinput = $mainframe->input;
     $db = JFactory::getDBO();
     $cid = $jinput->post->get('cid', array(0), 'array');
     //JRequest::getVar( 'cid', array(0), 'post', 'array' );
     $order = $jinput->post->get('order', array(0), 'array');
     //JRequest::getVar( 'order', array (0), 'post', 'array' );
     $total = count($cid);
     $conditions = array();
     JArrayHelper::toInteger($cid, array(0));
     JArrayHelper::toInteger($order, array(0));
     $row = JTable::getInstance('MultiProfile', 'CTable');
     // Update the ordering for items in the cid array
     for ($i = 0; $i < $total; $i++) {
         $row->load((int) $cid[$i]);
         if ($row->ordering != $order[$i]) {
             $row->ordering = $order[$i];
             $row->store();
         }
     }
     $mainframe = JFactory::getApplication();
     $mainframe->redirect('index.php?option=com_community&view=multiprofile', JText::_('COM_COMMUNITY_MULTIPROFILE_ORDERING_SAVED'), 'message');
 }
Beispiel #30
-1
 function load($value)
 {
     $this->values = array();
     $config =& hikashop_config();
     $forced = array((int) $config->get('main_currency'));
     $filters = array('currency_published = 1');
     if ($this->displayType == 'auto') {
         $app = JFactory::getApplication();
         if ($app->isAdmin()) {
             if (is_array($value)) {
                 $forced = array_merge($forced, $value);
                 JArrayHelper::toInteger($forced);
             } else {
                 $forced[] = (int) $value;
             }
         } else {
             $filters[] = 'currency_displayed = 1';
         }
         $filters[] = 'currency_id IN (' . implode(',', $forced) . ')';
     } elseif ($this->displayType == 'all') {
         $filters[] = 'currency_displayed = 1';
         $this->values[] = JHTML::_('select.option', 0, JText::_('HIKA_NONE'));
     }
     if (empty($this->currencies)) {
         $query = 'SELECT * FROM ' . hikashop_table('currency') . ' WHERE (' . implode(') OR (', $filters) . ')';
         $db = JFactory::getDBO();
         $db->setQuery($query);
         $this->currencies = $db->loadObjectList('currency_id');
     }
     if (!empty($this->currencies)) {
         foreach ($this->currencies as $currency) {
             $this->values[] = JHTML::_('select.option', (int) $currency->currency_id, $currency->currency_symbol . ' ' . $currency->currency_code);
         }
     }
 }