Exemplo n.º 1
3
 /**
  * Method to toggle the featured setting of a list of articles.
  *
  * @return	void
  * @since	1.6
  */
 function featured()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Initialise variables.
     $user = JFactory::getUser();
     $ids = JRequest::getVar('cid', array(), '', 'array');
     $values = array('featured' => 1, 'unfeatured' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($values, $task, 0, 'int');
     // Access checks.
     foreach ($ids as $i => $id) {
         if (!$user->authorise('core.edit.state', 'com_content.article.' . (int) $id)) {
             // Prune items that you can't change.
             unset($ids[$i]);
             JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Publish the items.
         if (!$model->featured($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         }
     }
     $this->setRedirect('index.php?option=com_content&view=articles');
 }
Exemplo n.º 2
0
 function doimport()
 {
     $model =& $this->getModel('Importcsv');
     $tableModel =& $model->getTableModel();
     $table =& $tableModel->getTable();
     if (!$tableModel->canCSVImport()) {
         JError::raiseError(400, 'Naughty naughty!');
         jexit;
     }
     $tmp_file = $model->checkUpload();
     if ($tmp_file === false) {
         $this->display();
     }
     $model->readCSV($tmp_file);
     $model->findExistingElements();
     $document =& JFactory::getDocument();
     $viewName = JRequest::getVar('view', 'form', 'default', 'cmd');
     $viewType = $document->getType();
     // Set the default view name from the Request
     $view =& $this->getView($viewName, $viewType);
     $Itemid = JRequest::getInt('Itemid');
     if (!empty($model->newHeadings)) {
         //as opposed to admin you can't alter table structure with a CSV import
         //from the front end
         JError::raiseNotice(500, $model->_makeError());
         $this->setRedirect("index.php?option=com_fabrik&c=import&view=import&fietype=csv&tableid=" . $table->id . "&Itemid=" . $Itemid);
     } else {
         JRequest::setVar('fabrik_table', $table->id);
         $msg = $model->makeTableFromCSV();
         $this->setRedirect('index.php?option=com_fabrik&view=table&tableid=' . $table->id . "&Itemid=" . $Itemid, $msg);
     }
 }
Exemplo n.º 3
0
/**
 * Disables the unsupported eAccelerator caching method, replacing it with the
 * "file" caching method.
 *
 * @return  void
 *
 * @since   3.2
 */
function admin_postinstall_eaccelerator_action()
{
    $prev = new JConfig();
    $prev = JArrayHelper::fromObject($prev);
    $data = array('cacheHandler' => 'file');
    $data = array_merge($prev, $data);
    $config = new Registry('config');
    $config->loadArray($data);
    jimport('joomla.filesystem.path');
    jimport('joomla.filesystem.file');
    // Set the configuration file path.
    $file = JPATH_CONFIGURATION . '/configuration.php';
    // Get the new FTP credentials.
    $ftp = JClientHelper::getCredentials('ftp', true);
    // Attempt to make the file writeable if using FTP.
    if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0644')) {
        JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTWRITABLE'));
    }
    // Attempt to write the configuration file as a PHP class named JConfig.
    $configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));
    if (!JFile::write($file, $configuration)) {
        JFactory::getApplication()->enqueueMessage(JText::_('COM_CONFIG_ERROR_WRITE_FAILED'), 'error');
        return;
    }
    // Attempt to make the file unwriteable if using FTP.
    if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0444')) {
        JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_CONFIG_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'));
    }
}
Exemplo n.º 4
0
 /**
  * Method to upgrade all registered packages at once
  *
  * @package MageBridge
  * @access public
  * @param int $allow_update
  * @return bool
  */
 public function updateAll($allow_update = array())
 {
     // Fetch all the available packages
     $packages = MageBridgeUpdateHelper::getPackageList();
     $count = 0;
     foreach ($packages as $package) {
         // Skip optional packages which are not yet installed and not selected in the list
         if (!in_array($package['name'], $allow_update)) {
             continue;
         }
         // Skip packages that are not available
         if ($package['available'] == 0) {
             continue;
         }
         // Update the package and add an error if something goes wrong
         if ($this->update($package['name']) == false) {
             JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_FAILED', $package['name']));
             // Only crash when installing the component, continue for all other extensions
             if ($package['name'] == 'com_magebridge') {
                 return false;
             }
             continue;
         } else {
             $count++;
         }
     }
     // Run the helper to remove obsolete files
     YireoHelperInstall::remove();
     // Simple notices as feedback
     JError::raiseNotice('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_SUCCESS', $count));
     JError::raiseNotice('SOME_ERROR_CODE', JText::sprintf('COM_MAGEBRIDGE_MODEL_UPDATE_INSTALL_CHANGELOG', MageBridgeHelper::getHelpLink('changelog')));
     return true;
 }
Exemplo n.º 5
0
 function doimport()
 {
     $model =& $this->getModel('Importcsv', 'FabrikFEModel');
     if (!$model->import()) {
         $this->display();
         return;
     }
     $id = $model->getListModel()->getId();
     $document = JFactory::getDocument();
     $viewName = JRequest::getVar('view', 'form', 'default', 'cmd');
     $viewType = $document->getType();
     // Set the default view name from the Request
     $view =& $this->getView($viewName, $viewType);
     $Itemid = JRequest::getInt('Itemid');
     if (!empty($model->newHeadings)) {
         //as opposed to admin you can't alter table structure with a CSV import
         //from the front end
         JError::raiseNotice(500, $model->_makeError());
         $this->setRedirect("index.php?option=com_fabrik&view=import&fietype=csv&listid=" . $id . "&Itemid=" . $Itemid);
     } else {
         JRequest::setVar('fabrik_list', $id);
         $msg = $model->makeTableFromCSV();
         $this->setRedirect('index.php?option=com_fabrik&view=list&listid=' . $id . "&resetfilters=1&Itemid=" . $Itemid, $msg);
     }
 }
Exemplo n.º 6
0
 /**
  * Clone the record
  *
  * @param   object  $params      plugin params
  * @param   object  &$formModel  form model
  *
  * @return  bool
  */
 private function _process($params, &$formModel)
 {
     $clone_times_field_id = $params->get('clone_times_field', '');
     $clone_batchid_field_id = $params->get('clone_batchid_field', '');
     if ($clone_times_field_id != '') {
         $elementModel = FabrikWorker::getPluginManager()->getElementPlugin($clone_times_field_id);
         $element = $elementModel->getElement(true);
         if ($clone_batchid_field_id != '') {
             $elementModel = FabrikWorker::getPluginManager()->getElementPlugin($clone_batchid_field_id);
             $id_element = $id_elementModel->getElement(true);
             $formModel->_formData[$id_element->name] = $formModel->_fullFormData['rowid'];
             $formModel->_formData[$id_element->name . '_raw'] = $formModel->_fullFormData['rowid'];
             $listModel = $formModel->getlistModel();
             $listModel->_oForm = $formModel;
             $primaryKey = FabrikString::shortColName($listModel->getTable()->db_primary_key);
             $formModel->_formData[$primaryKey] = $formModel->_fullFormData['rowid'];
             $formModel->_formData[$primaryKey . '_raw'] = $formModel->_fullFormData['rowid'];
             $listModel->storeRow($formModel->_formData, $formModel->_fullFormData['rowid']);
         }
         // $clone_times_field = $elementModel->getFullName(false, true, false);
         $clone_times = $formModel->_formData[$element->name];
         if (is_numeric($clone_times)) {
             $clone_times = (int) $clone_times;
             $formModel->_formData['Copy'] = 1;
             for ($x = 1; $x < $clone_times; $x++) {
                 $formModel->processToDB();
             }
             return true;
         }
     }
     JError::raiseNotice(JText::_('CLONEERR'), "Couldn't find a valid number of times to clone!");
     return true;
 }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 8
0
 /**
  * Displays a list of user groups.
  *
  * @param   boolean  true to include super admin groups, false to exclude them
  *
  * @return  array  An array containing a list of user groups.
  *
  * @since   11.4
  */
 public static function groups($includeSuperAdmin = false)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level');
     $query->from($db->quoteName('#__usergroups') . ' AS a');
     $query->join('LEFT', $db->quoteName('#__usergroups') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
     $query->group('a.id, a.title, a.lft, a.rgt');
     $query->order('a.lft ASC');
     $db->setQuery($query);
     $options = $db->loadObjectList();
     // Check for a database error.
     if ($db->getErrorNum()) {
         JError::raiseNotice(500, $db->getErrorMsg());
         return null;
     }
     for ($i = 0, $n = count($options); $i < $n; $i++) {
         $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
         $groups[] = JHtml::_('select.option', $options[$i]->value, $options[$i]->text);
     }
     // Exclude super admin groups if requested
     if (!$includeSuperAdmin) {
         $filteredGroups = array();
         foreach ($groups as $group) {
             if (!JAccess::checkGroup($group->value, 'core.admin')) {
                 $filteredGroups[] = $group;
             }
         }
         $groups = $filteredGroups;
     }
     return $groups;
 }
Exemplo n.º 9
0
	/**
	 * Method to set the date
	 *
	 * @access	public
	 * @param	string
	 */
	function setDate($date)
	{
		$app = JFactory::getApplication();

		# Get the params of the active menu item
		$params = $app->getParams('com_jem');

		# 0 means we have a direct request from a menuitem and without any params (eg: calendar module)
		if ($date == 0) {
			$dayoffset	= $params->get('days');
			$timestamp	= mktime(0, 0, 0, date("m"), date("d") + $dayoffset, date("Y"));
			$date		= strftime('%Y-%m-%d', $timestamp);

		# a valid date has 8 characters (ymd)
		} elseif (strlen($date) == 8) {
			$year 	= substr($date, 0, -4);
			$month	= substr($date, 4, -2);
			$tag	= substr($date, 6);

			//check if date is valid
			if (checkdate($month, $tag, $year)) {
				$date = $year.'-'.$month.'-'.$tag;
			} else {
				//date isn't valid raise notice and use current date
				$date = date('Ymd');
				JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_JEM_INVALID_DATE_REQUESTED_USING_CURRENT'));
			}
		} else {
			//date isn't valid raise notice and use current date
			$date = date('Ymd');
			JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_JEM_INVALID_DATE_REQUESTED_USING_CURRENT'));
		}

		$this->_date = $date;
	}
Exemplo n.º 10
0
	/**
	 * Image selection List
	 *
	 */
	function display($tpl = null) {
		$app 		= JFactory::getApplication();
		$option 	= $app->input->getString('option', 'com_jem');

		JHtml::_('behavior.framework');

		if($this->getLayout() == 'uploadimage') {
			$this->_displayuploadimage($tpl);
			return;
		}

		//get vars
		$task 		= $app->input->get('task', '');
		$search 	= $app->getUserStateFromRequest($option.'.filter_search', 'filter_search', '', 'string');
		$search 	= trim(JString::strtolower($search));

		//set variables
		if ($task == 'selecteventimg') {
			$folder = 'events';
			$task 	= 'eventimg';
			$redi	= 'selecteventimg';
		} else if ($task == 'selectvenueimg') {
			$folder = 'venues';
			$task   = 'venueimg';
			$redi   = 'selectvenueimg';
		} else if ($task == 'selectcategoriesimg') {
			$folder = 'categories';
			$task 	= 'categoriesimg';
			$redi	= 'selectcategoriesimg';
		}

		$app->input->set('folder', $folder);

		// Do not allow cache
		JResponse::allowCache(false);

		// Load css
		JHtml::_('stylesheet', 'com_jem/backend.css', array(), true);

		//get images
		$images = $this->get('images');
		$pagination = $this->get('Pagination');

		if (count($images) > 0 || $search) {
			$this->images 		= $images;
			$this->folder 		= $folder;
			$this->task 		= $redi;
			$this->search 		= $search;
			$this->state		= $this->get('state');
			$this->pagination 	= $pagination;
			parent::display($tpl);
		} else {
			//no images in the folder, redirect to uploadscreen and raise notice
			JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_JEM_NO_IMAGES_AVAILABLE'));
			$this->setLayout('uploadimage');
			$app->input->set('task', $task);
			$this->_displayuploadimage($tpl);
			return;
		}
	}
Exemplo n.º 11
0
    public static function getGroupsField()
    {
        $db =& JFactory::getDbo();
        $db->setQuery('
				 SELECT a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level
				 FROM #__usergroups AS a
				 LEFT JOIN `#__usergroups` AS b ON a.lft > b.lft AND a.rgt < b.rgt
				 GROUP BY a.id
				 ORDER BY a.lft ASC');
        $options = $db->loadObjectList();
        // Check for a database error.
        if ($db->getErrorNum()) {
            JError::raiseNotice(500, $db->getErrorMsg());
            return null;
        }
        for ($i = 0, $n = count($options); $i < $n; $i++) {
            $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
        }
        $gids = array();
        foreach ($options as $k => $v) {
            $gids[] = get_object_vars($v);
        }
        $gids[0] = array('value' => 0, 'text' => Sobi::Txt('ACL.REG_VISITOR'), 'level' => 0);
        return $gids;
    }
Exemplo n.º 12
0
	/**
	 * Logic to publish/unpublish/trash venues
	 *
	 * @access protected
	 * @return void
	 *
	 */
	protected function setStatus($status, $message)
	{
		// Check for request forgeries
		JSession::checkToken() or jexit('Invalid Token');

		$app = JFactory::getApplication();
		$input = $app->input;

		$cid = $input->get('cid', array(), 'array');

		if (empty($cid)) {
			JError::raiseNotice(100, JText::_('COM_JEM_SELECT_ITEM_TO_PUBLISH'));
			$this->setRedirect(JEMHelperRoute::getMyVenuesRoute());
			return;
		}

		$model = $this->getModel('myvenues');
		if (!$model->publish($cid, $status)) {
			echo "<script> alert('" . $model->getError() . "'); window.history.go(-1); </script>\n";
		}

		$total = count($cid);
		$msg   = $total . ' ' . JText::_($message);

		$this->setRedirect(JEMHelperRoute::getMyVenuesRoute(), $msg);
	}
Exemplo n.º 13
0
 /**
  * Upload a file
  * @param	string	$source			File to upload
  * @param	string	$destination	Upload to here
  * @return True on success
  */
 public static function upload($source, $destination)
 {
     $err = null;
     $ret = false;
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     // Load configurations.
     $config = CFactory::getConfig();
     // Make the filename safe
     jimport('joomla.filesystem.file');
     if (!isset($source['name'])) {
         JError::raiseNotice(100, JText::_('COM_COMMUNITY_INVALID_FILE_REQUEST'));
         return $ret;
     }
     $source['name'] = JFile::makeSafe($source['name']);
     if (is_dir($destination)) {
         jimport('joomla.filesystem.folder');
         JFolder::create($destination, (int) octdec($config->get('folderpermissionsvideo')));
         JFile::copy(JPATH_ROOT . '/components/com_community/index.html', $destination . '/index.html');
         $destination = JPath::clean($destination . '/' . strtolower($source['name']));
     }
     if (JFile::exists($destination)) {
         JError::raiseNotice(100, JText::_('COM_COMMUNITY_FILE_EXISTS'));
         return $ret;
     }
     if (!JFile::upload($source['tmp_name'], $destination)) {
         JError::raiseWarning(100, JText::_('COM_COMMUNITY_UNABLE_TO_UPLOAD_FILE'));
         return $ret;
     } else {
         $ret = true;
         return $ret;
     }
 }
 public function onBeforeAddProductToCart($cart, &$product_id, &$quantity, &$attr_id, &$freeattributes, &$updateqty, &$errors, &$displayErrorMessage, &$additional_fields, &$usetriggers)
 {
     $cart->clear();
     $date_from = $this->DateToUnix($freeattributes[1]);
     $date_to = $this->DateToUnix($freeattributes[2]);
     $db = JFactory::getDBO();
     //проверяем не фейковая ли это квартира
     $field = 'extra_field_' . $this->fake_extra_field_id;
     $query = "SELECT `{$field}` FROM `#__jshopping_products` WHERE `product_id` = {$product_id}";
     $db->setQuery($query);
     $value = $db->loadResult();
     //var_dump($value);die;
     if ($value == $this->fake_yes_extra_field_value) {
         $mainframe = JFactory::getApplication();
         JError::raiseNotice(100, _JSHOP_OBJECT_IS_BOOKED);
         $category_id = JRequest::getInt('category_id');
         $mainframe->redirect(SEFLink('index.php?option=com_jshopping&controller=product&task=view&category_id=' . $category_id . '&product_id=' . $product_id, 1, 1));
         return;
     }
     //проверяем доступность по датам
     $query = "SELECT `product_id`, `dfrom`, `dto` FROM `#__jshopping_order_bookings` WHERE (`product_id` = {$product_id}) AND (`dfrom` > " . time() . ") ORDER BY `order_id` DESC";
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     foreach ($rows as $row) {
         $order_date_from = $row->dfrom;
         $order_date_to = $row->dto;
         if ($date_from >= $order_date_from && $date_from <= $order_date_to || $date_to >= $order_date_from && $date_to <= $order_date_to) {
             $mainframe = JFactory::getApplication();
             JError::raiseNotice(100, _JSHOP_OBJECT_IS_BOOKED);
             $category_id = JRequest::getInt('category_id');
             $mainframe->redirect(SEFLink('index.php?option=com_jshopping&controller=product&task=view&category_id=' . $category_id . '&product_id=' . $product_id, 1, 1));
             break;
         }
     }
 }
Exemplo n.º 15
0
 /**
  * Method to get the filtering groups (null means no filtering)
  *
  * @return	array|null	array of filtering groups or null.
  * @since	1.6
  */
 protected function getGroups()
 {
     // Compute usergroups
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('id');
     $query->from('#__usergroups');
     $db->setQuery($query);
     $groups = $db->loadColumn();
     // Check for a database error.
     if ($db->getErrorNum()) {
         JError::raiseNotice(500, $db->getErrorMsg());
         return null;
     }
     foreach ($groups as $i => $group) {
         if (JAccess::checkGroup($group, 'core.admin')) {
             continue;
         }
         if (!JAccess::checkGroup($group, 'core.manage', 'com_messages')) {
             unset($groups[$i]);
             continue;
         }
         if (!JAccess::checkGroup($group, 'core.login.admin')) {
             unset($groups[$i]);
             continue;
         }
     }
     return array_values($groups);
 }
Exemplo n.º 16
0
 /**
  * Validates the data submitted based on the suffix provided
  * 
  * @param $suffix
  * @return html
  */
 function _processSuffix($suffix = '')
 {
     $html = "";
     switch ($suffix) {
         case "2":
             if (!($verify = $this->_verifyDB())) {
                 JError::raiseNotice('_verifyDB', $this->getError());
                 $html .= $this->_renderForm('1');
             } else {
                 // migrate the data and output the results
                 $html .= $this->_doMigration();
             }
             break;
         case "1":
             if (!($verify = $this->_verifyDB())) {
                 JError::raiseNotice('_verifyDB', $this->getError());
                 $html .= $this->_renderForm('1');
             } else {
                 $suffix++;
                 // display a 'connection verified' message
                 // and request confirmation before migrating data
                 $html .= $this->_renderForm($suffix);
                 $html .= $this->_renderView($suffix);
             }
             break;
         default:
             $html .= $this->_renderForm('1');
             break;
     }
     return $html;
 }
Exemplo n.º 17
0
 /**
  * Method to toggle the featured setting of a list of contacts.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function featured()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $ids = $this->input->get('cid', array(), 'array');
     $values = array('featured' => 1, 'unfeatured' => 0);
     $task = $this->getTask();
     $value = ArrayHelper::getValue($values, $task, 0, 'int');
     // Get the model.
     /** @var ContactModelContact $model */
     $model = $this->getModel();
     // Access checks.
     foreach ($ids as $i => $id) {
         $item = $model->getItem($id);
         if (!JFactory::getUser()->authorise('core.edit.state', 'com_contact.category.' . (int) $item->catid)) {
             // Prune items that you can't change.
             unset($ids[$i]);
             JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('COM_CONTACT_NO_ITEM_SELECTED'));
     } else {
         // Publish the items.
         if (!$model->featured($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         }
     }
     $this->setRedirect('index.php?option=com_contact&view=contacts');
 }
Exemplo n.º 18
0
 /**
  * Send sms
  *
  * @param   string  $method    post/get
  * @param   string  $url       url to request
  * @param   string  $vars      querystring vars to post
  * @param   string  $auth      auth
  * @param   string  $callback  method
  *
  * @return  mixed data or curl error
  */
 public static function doRequest($method, $url, $vars, $auth = '', $callback = false)
 {
     if (!function_exists('curl_init')) {
         JError::raiseNotice(500, JText::_('COM_FABRIK_ERR_CURL_NOT_INSTALLED'));
         return;
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_HEADER, 1);
     curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
     curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
     if ($method == 'POST') {
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
     }
     if (!empty($auth)) {
         curl_setopt($ch, CURLOPT_USERPWD, $auth);
     }
     $data = curl_exec($ch);
     curl_close($ch);
     if ($data) {
         if ($callback) {
             return call_user_func($callback, $data);
         } else {
             return $data;
         }
     } else {
         return curl_error($ch);
     }
 }
Exemplo n.º 19
0
 /**
  * Method to get the filtering groups (null means no filtering)
  *
  * @return  array|null	array of filtering groups or null.
  *
  * @since   1.6
  */
 protected function getGroups()
 {
     // Compute usergroups
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('id')->from('#__usergroups');
     $db->setQuery($query);
     try {
         $groups = $db->loadColumn();
     } catch (RuntimeException $e) {
         JError::raiseNotice(500, $e->getMessage());
         return null;
     }
     foreach ($groups as $i => $group) {
         if (JAccess::checkGroup($group, 'core.admin')) {
             continue;
         }
         if (!JAccess::checkGroup($group, 'core.manage', 'com_messages')) {
             unset($groups[$i]);
             continue;
         }
         if (!JAccess::checkGroup($group, 'core.login.admin')) {
             unset($groups[$i]);
             continue;
         }
     }
     return array_values($groups);
 }
 function display($tpl = null)
 {
     // Get a refrence of the page instance in joomla
     $document =& JFactory::getDocument();
     $model =& $this->getModel();
     $option = JRequest::getCmd('option');
     $optiontext = strtoupper(JRequest::getCmd('option') . '_');
     $this->assignRef('optiontext', $optiontext);
     $mainframe = JFactory::getApplication();
     $this->assignRef('predictionGame', $model->getPredictionGame());
     if (isset($this->predictionGame)) {
         $config = $model->getPredictionTemplateConfig($this->getName());
         $overallConfig = $model->getPredictionOverallConfig();
         $this->assignRef('model', $model);
         $this->assignRef('config', array_merge($overallConfig, $config));
         $configavatar = $model->getPredictionTemplateConfig('predictionusers');
         $this->assignRef('configavatar', $configavatar);
         $this->assignRef('predictionMember', $model->getPredictionMember($configavatar));
         $this->assignRef('predictionProjectS', $model->getPredictionProjectS());
         $this->assignRef('actJoomlaUser', JFactory::getUser());
         //echo '<br /><pre>~'.print_r($this,true).'~</pre><br />';
         $this->assign('show_debug_info', JComponentHelper::getParams('com_joomleague')->get('show_debug_info', 0));
         // Set page title
         $pageTitle = JText::_('COM_JOOMLEAGUE_PRED_USERS_TITLE');
         // 'Tippspiel Regeln'
         $document->setTitle($pageTitle);
         parent::display($tpl);
     } else {
         JError::raiseNotice(500, JText::_('COM_JOOMLEAGUE_PRED_PREDICTION_NOT_EXISTING'));
     }
 }
Exemplo n.º 21
0
 /**
  * take the recorded twitter screen name and parse it through the template
  * @param string $screenName
  * @return string|unknown
  */
 protected function format($screenName)
 {
     if (trim($screenName) == '') {
         return '';
     }
     require_once COM_FABRIK_FRONTEND . DS . 'libs' . DS . 'twitter' . DS . 'class.twitter.php';
     $twitter = new twitter();
     $params =& $this->getParams();
     static $error;
     $tmpl = $params->get('twitter_profile_template');
     $tmpl = str_replace('{screen_name}', $screenName, $tmpl);
     if (!$twitter->twitterAvailable()) {
         if (!isset($error)) {
             $error = true;
             JError::raiseNotice(500, 'Looks like twitters down');
         }
         $tmpl = preg_replace("/{[^}\\s]+}/i", '', $tmpl);
         return $tmpl;
     }
     $user = $twitter->showUser($screenName);
     foreach ($user as $k => $v) {
         if (is_object($v)) {
             foreach ($v as $k2 => $v2) {
                 $tmpl = str_replace('{' . $k . '.' . $k2 . '}', $v2, $tmpl);
             }
         } else {
             $tmpl = str_replace('{' . $k . '}', $v, $tmpl);
         }
     }
     $tmpl = preg_replace("/{[^}\\s]+}/i", '', $tmpl);
     return $tmpl;
 }
Exemplo n.º 22
0
 public function updateAll($allow_update = array())
 {
     // Fetch all the available packages
     $packages = MageBridgeUpdateHelper::getPackageList();
     $count = 0;
     foreach ($packages as $package) {
         // Skip optional packages which are not yet installed and not selected in the list
         if (!in_array($package['name'], $allow_update)) {
             continue;
         }
         // Update the package and add an error if something goes wrong
         if ($this->update($package['name']) == false) {
             JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('Installation of %s failed', $package['name']));
             // Only crash when installing the component, continue for all other extensions
             if ($package['name'] == 'com_magebridge') {
                 return false;
             }
             continue;
         } else {
             $count++;
         }
     }
     // Run the helper for post-install tasks
     $helper = new MageBridgeInstallHelper();
     $helper->cleanFiles();
     // Simple notices as feedback
     JError::raiseNotice('SOME_ERROR_CODE', JText::sprintf('Updated %d extensions successfully', $count));
     JError::raiseNotice('SOME_ERROR_CODE', JText::sprintf('Check %s for upgrade notices', MageBridgeHelper::getHelpText('builds')));
     return true;
 }
Exemplo n.º 23
0
 function _getData()
 {
     $urlCSV = "http://www.schachbund.de/dwz/db/spieler-csv.php?zps=" . $this->zps . "-" . $this->mglnr;
     $this->url = "http://www.schachbund.de/dwz/db/spieler.html?zps=" . $this->zps . "-" . $this->mglnr;
     if (!($handle = fopen($urlCSV, "r"))) {
         JError::raiseNotice(100, JText::_('NO_CONNECTION'));
     } else {
         // INIT
         $counter = 0;
         $this->rows = array();
         while ($row = fgetcsv($handle, 500, "|")) {
             $counter++;
             // Zeile 1: Datum
             if ($counter == 1) {
                 $this->date = $row[0];
                 // Teile 2: Vereinsnummer, Mitgliedsnummer, Status, Name, Geschlecht, Geburtsjahr, FIDE-Titel, Woche der letzten Auswertung, DWZ, DWZ-Index
             } elseif ($counter == 2) {
                 $this->playerData = $row;
                 // Zeile 3: FIDE-Elo, Partien, Titel, ID, Land
             } elseif ($counter == 3) {
                 $this->fideData = $row;
                 // Zeile 4++: Eintragsnummer, Turniercode, Turniername, Punkte, Partien, Erwartungswert, Gegner, Leistung, DWZ, DWZ-Index
             } elseif ($row[0] != "") {
                 // leere Zeilen ausscheiden
                 $this->rows[] = $row;
             }
         }
     }
 }
Exemplo n.º 24
0
 /**
  * Method to toggle the featured setting of a list of compromissos.
  *
  * @return  void
  * @since   1.6
  */
 public function featured()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $user = JFactory::getUser();
     $ids = $this->input->get('cid', array(), 'array');
     $values = array('featured' => 1, 'unfeatured' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($values, $task, 0, 'int');
     $model = $this->getModel();
     foreach ($ids as $i => $id) {
         // if(@isset($categories[$id]->catid)===false)
         // 	continue;
         if (!$user->authorise('core.edit.state', 'com_agendadirigentes.component')) {
             unset($ids[$i]);
             JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Publish compromissos.
         if (!$model->featured($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         }
     }
     $this->setRedirect('index.php?option=com_agendadirigentes&view=cargos');
 }
Exemplo n.º 25
0
    function send_certificate()
    {
        $app = JFactory::getApplication();
        $params = $app->getParams();
        $moodle_url = $params->get('MOODLE_URL');
        $cert_id = JRequest::getVar('cert_id');
        $simple = JRequest::getVar('simple');
        $email = JRequest::getString('mailto', '', 'post');
        $sender = JRequest::getString('sender', '', 'post');
        $from = JRequest::getString('from', '', 'post');
        $user = JFactory::getUser();
        $username = $user->username;
        $subject_default = JText::sprintf('COM_JOOMDLE_CERTIFICATE_EMAIL_SUBJECT', $user->name);
        $subject = JRequest::getString('subject', $subject_default, 'post');
        if (!$subject) {
            $subject = $subject_default;
        }
        $mailer = JFactory::getMailer();
        $config = JFactory::getConfig();
        $sender = array($config->get('mailfrom'), $config->get('fromname'));
        $mailer->setSender($sender);
        $mailer->addRecipient($email);
        $body = JText::sprintf('COM_JOOMDLE_CERTIFICATE_EMAIL_BODY', $user->name);
        $mailer->setSubject($subject);
        $mailer->setBody($body);
        $session = JFactory::getSession();
        $token = md5($session->getId());
        $pdf = file_get_contents($moodle_url . '/auth/joomdle/' . $simple . 'certificate_view.php?id=' . $cert_id . '&certificate=1&action=review&username='******'&token=' . $token);
        $tmp_path = $config->get('tmp_path');
        $filename = 'certificate-' . $cert_id . '-' . $user->name . '.pdf';
        file_put_contents($tmp_path . '/' . $filename, $pdf);
        $mailer->addAttachment($tmp_path . '/' . $filename);
        $send = $mailer->Send();
        unlink($tmp_path . '/' . $filename);
        if ($send !== true) {
            JError::raiseNotice(500, JText::_('COM_JOOMDLE_EMAIL_NOT_SENT'));
        } else {
            ?>
<div style="padding: 10px;">
    <div style="text-align:right">
        <a href="javascript: void window.close()">
            <?php 
            echo JText::_('COM_JOOMDLE_CLOSE_WINDOW');
            ?>
 <?php 
            echo JHtml::_('image', 'mailto/close-x.png', NULL, NULL, true);
            ?>
</a>
    </div>

    <h2>
        <?php 
            echo JText::_('COM_JOOMDLE_EMAIL_SENT');
            ?>
    </h2>
</div>

<?php 
        }
    }
Exemplo n.º 26
0
 /**
  * Returns an array of options
  *
  * @param   string   $sql    SQL with 'ordering' AS value and 'name field' AS text
  * @param   integer  $chop   The length of the truncated headline
  *
  * @return  array    An array of objects formatted for JHtml list processing
  * @since   11.1
  */
 public static function genericordering($sql, $chop = '30')
 {
     $db = JFactory::getDbo();
     $options = array();
     $db->setQuery($sql);
     $items = $db->loadObjectList();
     // Check for a database error.
     if ($db->getErrorNum()) {
         JError::raiseNotice(500, $db->getErrorMsg());
         return false;
     }
     if (empty($items)) {
         $options[] = JHtml::_('select.option', 1, JText::_('JOPTION_ORDER_FIRST'));
         return $options;
     }
     $options[] = JHtml::_('select.option', 0, '0 ' . JText::_('JOPTION_ORDER_FIRST'));
     for ($i = 0, $n = count($items); $i < $n; $i++) {
         $items[$i]->text = JText::_($items[$i]->text);
         if (JString::strlen($items[$i]->text) > $chop) {
             $text = JString::substr($items[$i]->text, 0, $chop) . "...";
         } else {
             $text = $items[$i]->text;
         }
         $options[] = JHtml::_('select.option', $items[$i]->value, $items[$i]->value . '. ' . $text);
     }
     $options[] = JHtml::_('select.option', $items[$i - 1]->value + 1, $items[$i - 1]->value + 1 . ' ' . JText::_('JOPTION_ORDER_LAST'));
     return $options;
 }
Exemplo n.º 27
0
 /**
  * Method to toggle the featured setting of a list of teamids.
  *
  * @return	void
  * 
  */
 public function featured()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $user = JFactory::getUser();
     $ids = $this->input->getVar('cid', array(), 'array');
     $values = array('featured' => 1, 'unfeatured' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($values, $task, 0, 'int');
     // Get the model.
     $model = $this->getModel();
     // Access checks.
     foreach ($ids as $i => $id) {
         $item = $model->getItem($id);
         if (!$user->authorise('core.edit.state', 'com_knvbapi2.teamid.' . $id)) {
             // Prune items that you can't change.
             unset($ids[$i]);
             JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('COM_KNVBAPI2_TEAMIDS_NO_ITEM_SELECTED'));
     } else {
         // Publish the items.
         if (!$model->featured($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         }
         if ($value == 1) {
             $message = JText::plural('COM_KNVBAPI2_TEAMIDS_N_ITEMS_FEATURED', count($ids));
         } else {
             $message = JText::plural('COM_KNVBAPI2_TEAMIDS_N_ITEMS_UNFEATURED', count($ids));
         }
     }
     $this->setRedirect(JRoute::_('index.php?option=com_knvbapi2&view=teamids', false), $message);
 }
Exemplo n.º 28
0
	private function getOpts($allowAll = true)
	{
		$db = JFactory::getDbo();
		$db->setQuery(
			'SELECT a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level' .
			' FROM #__usergroups AS a' .
			' LEFT JOIN `#__usergroups` AS b ON a.lft > b.lft AND a.rgt < b.rgt' .
			' GROUP BY a.id' .
			' ORDER BY a.lft ASC'
		);
		$options = $db->loadObjectList();

		// Check for a database error.
		if ($db->getErrorNum()) {
			JError::raiseNotice(500, $db->getErrorMsg());
			return null;
		}

		for ($i=0,$n=count($options); $i < $n; $i++) {
			$options[$i]->text = str_repeat('- ',$options[$i]->level).$options[$i]->text;
		}

		// If all usergroups is allowed, push it into the array.
		if ($allowAll) {
			array_unshift($options, JHtml::_('select.option', '', JText::_('JOPTION_ACCESS_SHOW_ALL_GROUPS')));
		}
		return $options;

		/*$acl = JFactory::getACL();
		$gtree = $acl->get_group_children_tree( null, 'USERS', false);
		$optAll = array(JHTML::_('select.option', '30', ' - Everyone'), JHTML::_('select.option', "26", 'Nobody'));
		return array_merge($gtree, $optAll);*/
	}
Exemplo n.º 29
0
 /**
  * Removes an item.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function delete()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $user = JFactory::getUser();
     $ids = $this->input->get('cid', array(), 'array');
     // Access checks.
     foreach ($ids as $i => $id) {
         if (!$user->authorise('core.delete', 'com_content.article.' . (int) $id)) {
             // Prune items that you can't delete.
             unset($ids[$i]);
             JError::raiseNotice(403, JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Remove the items.
         if (!$model->featured($ids, 0)) {
             JError::raiseWarning(500, $model->getError());
         }
     }
     $this->setRedirect('index.php?option=com_content&view=featured');
 }
Exemplo n.º 30
0
 function Edit()
 {
     $id = JRequest::getInt("id");
     $cfg = CustomFieldsFactory::getConfig();
     $field = JTable::getInstance('FieldsTable', 'JTheFactory');
     $parameters_plugins = null;
     if ($id) {
         if (!$field->load($id)) {
             JError::raiseNotice(101, JText::_("FACTORY_ERROR_LOADING_FIELD") . " {$id}");
             $this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=fields.listfields");
             return;
         }
     } else {
         $field->setDefaults();
     }
     $lists = JTheFactoryFieldsHelper::createHTMLObjectsForField($field);
     JHTML::_('behavior.mootools');
     //load mootools before fields.js
     JHTML::script("administrator/components/" . APP_EXTENSION . "/thefactory/fields/js/fields.js");
     JHTML::stylesheet("administrator/components/" . APP_EXTENSION . "/thefactory/fields/css/fields.css");
     if ($field->id && $field->categoryfilter) {
         $model = JModel::getInstance('Fields', 'JTheFactoryModel');
         $assigned = $model->getAssignedCats($field);
     } else {
         //select all by default
         $assigned = "all";
     }
     $lists->category = JHtml::_('factorycategory.select', 'parent[]', 'style="width:200px" multiple size=10' . ($field->categoryfilter ? '' : ' disabled'), $assigned, true);
     $view = $this->getView('edit');
     $view->assignRef('lists', $lists);
     $view->assignRef('field', $field);
     $view->display();
 }