예제 #1
0
파일: Image.php 프로젝트: pashakiz/crowdf
 /**
  * Create a thumbnail from an image file.
  *
  * <code>
  * $myFile   = "/tmp/myfile.jpg";
  *
  * $options = array(
  *     "destination" => "image/mypic.jpg",
  *     "width" => 200,
  *     "height" => 200,
  *     "scale" => JImage::SCALE_INSIDE
  * );
  *
  * $file = new PrismFileImage($myFile);
  * $file->createThumbnail($options);
  *
  * </code>
  *
  * @param  array $options Some options used in the process of generating thumbnail.
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  *
  * @return string A location to the new file.
  */
 public function createThumbnail($options)
 {
     $width = ArrayHelper::getValue($options, "width", 100);
     $height = ArrayHelper::getValue($options, "height", 100);
     $scale = ArrayHelper::getValue($options, "scale", \JImage::SCALE_INSIDE);
     $destination = ArrayHelper::getValue($options, "destination");
     if (!$destination) {
         throw new \InvalidArgumentException(\JText::_("LIB_PRISM_ERROR_INVALID_FILE_DESTINATION"));
     }
     // Generate thumbnail.
     $image = new \JImage();
     $image->loadFile($this->file);
     if (!$image->isLoaded()) {
         throw new \RuntimeException(\JText::sprintf('LIB_PRISM_ERROR_FILE_NOT_FOUND', $this->file));
     }
     // Resize the file as a new object
     $thumb = $image->resize($width, $height, true, $scale);
     $fileName = basename($this->file);
     $ext = \JString::strtolower(\JFile::getExt(\JFile::makeSafe($fileName)));
     switch ($ext) {
         case "gif":
             $type = IMAGETYPE_GIF;
             break;
         case "png":
             $type = IMAGETYPE_PNG;
             break;
         case IMAGETYPE_JPEG:
         default:
             $type = IMAGETYPE_JPEG;
     }
     $thumb->toFile($destination, $type);
     return $destination;
 }
예제 #2
0
파일: contacts.php 프로젝트: adjaika/J3Base
 /**
  * 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');
 }
예제 #3
0
 /**
  * Load data about updates from database by project ID.
  *
  * <code>
  * $options = array(
  *     "project_id" => 1, // It can also be an array with IDs.
  *     "period" => 7, // Period in days
  *     "limit" => 10 // Limit the results
  * );
  *
  * $updates   = new Crowdfunding\Updates(\JFactory::getDbo());
  * $updates->load($options);
  *
  * foreach($updates as $item) {
  *      echo $item->title;
  *      echo $item->record_date;
  * }
  * </code>
  *
  * @param array $options
  */
 public function load(array $options = array())
 {
     $query = $this->db->getQuery(true);
     $query->select('a.id, a.title, a.description, a.record_date, a.project_id')->from($this->db->quoteName('#__crowdf_updates', 'a'));
     // Filter by IDs.
     $ids = ArrayHelper::getValue($options, 'ids', array(), 'array');
     if (count($ids) > 0) {
         $query->where('a.ids IN (' . implode(',', $ids) . ')');
     }
     // Filter by project ID.
     $projectId = ArrayHelper::getValue($options, 'project_id', 0, 'int');
     if ($projectId > 0) {
         $query->where('a.project_id = ' . (int) $projectId);
     }
     // Filter by period.
     $period = ArrayHelper::getValue($options, 'period', 0, 'int');
     if ($period > 0) {
         $query->where('a.record_date >= DATE_SUB(NOW(), INTERVAL ' . $period . ' DAY)');
     }
     // Set limit.
     $limit = ArrayHelper::getValue($options, 'limit', 0, 'int');
     if ($limit > 0) {
         $this->db->setQuery($query, 0, $limit);
     } else {
         $this->db->setQuery($query);
     }
     $this->items = (array) $this->db->loadAssocList();
 }
예제 #4
0
 /**
  * Shows the data formatted for the list view
  *
  * @param   string    $data      Elements data
  * @param   stdClass  &$thisRow  All the data in the lists current row
  * @param   array     $opts      Rendering options
  *
  * @return  string	formatted value
  */
 public function renderListData($data, stdClass &$thisRow, $opts = array())
 {
     $listModel = $this->getListModel();
     $params = $this->getParams();
     $w = (int) $params->get('fb_gm_table_mapwidth');
     $h = (int) $params->get('fb_gm_table_mapheight');
     $z = (int) $params->get('fb_gm_table_zoomlevel');
     $data = FabrikWorker::JSONtoData($data, true);
     foreach ($data as $i => &$d) {
         if ($params->get('fb_gm_staticmap_tableview')) {
             $d = $this->_staticMap($d, $w, $h, $z, $i, true, ArrayHelper::fromObject($thisRow));
         }
         if ($params->get('icon_folder') == '1' && ArrayHelper::getValue($opts, 'icon', 1)) {
             // $$$ rob was returning here but that stopped us being able to use links and icons together
             $d = $this->replaceWithIcons($d, 'list', $listModel->getTmpl());
         } else {
             if (!$params->get('fb_gm_staticmap_tableview')) {
                 $d = $params->get('fb_gm_staticmap_tableview_type_coords', 'num') == 'dms' ? $this->_dmsformat($d) : $this->_microformat($d);
             }
         }
         if (ArrayHelper::getValue($opts, 'rollover', 1)) {
             $d = $this->rollover($d, $thisRow, 'list');
         }
         if (ArrayHelper::getValue($opts, 'link', 1)) {
             $d = $listModel->_addLink($d, $this, $thisRow, $i);
         }
     }
     return $this->renderListDataFinal($data);
 }
예제 #5
0
 public function save($key = null, $urlVar = null)
 {
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $data = $this->input->post->get('jform', array(), 'array');
     $itemId = ArrayHelper::getValue($data, "id");
     $redirectData = array("task" => $this->getTask(), "id" => $itemId);
     $model = $this->getModel();
     /** @var $model GamificationModelRank */
     $form = $model->getForm($data, false);
     /** @var $form JForm */
     if (!$form) {
         throw new Exception(JText::_("COM_GAMIFICATION_ERROR_FORM_CANNOT_BE_LOADED"), 500);
     }
     // Validate the form
     $validData = $model->validate($form, $data);
     // Check for errors
     if ($validData === false) {
         $this->displayNotice($form->getErrors(), $redirectData);
         return;
     }
     try {
         $itemId = $model->save($validData);
         $redirectData["id"] = $itemId;
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_GAMIFICATION_ERROR_SYSTEM'));
     }
     $this->displayMessage(JText::_('COM_GAMIFICATION_LEVEL_SAVED'), $redirectData);
 }
예제 #6
0
 /**
  * Get the lists that contain events
  *
  * @return array
  */
 public function &getEventLists()
 {
     if (is_null($this->eventLists)) {
         $this->eventLists = array();
         $db = FabrikWorker::getDbo(true);
         $params = $this->getParams();
         $lists = (array) $params->get('calendar_table');
         $lists = ArrayHelper::toInteger($lists);
         $dateFields = (array) $params->get('calendar_startdate_element');
         $dateFields2 = (array) $params->get('calendar_enddate_element');
         $labels = (array) $params->get('calendar_label_element');
         $stati = (array) $params->get('status_element');
         $colours = (array) $params->get('colour');
         $query = $db->getQuery(true);
         $query->select('id AS value, label AS text')->from('#__{package}_lists')->where('id IN (' . implode(',', $lists) . ')');
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         for ($i = 0; $i < count($rows); $i++) {
             if (!isset($colours[$i])) {
                 $colours[$i] = '';
             }
             if (!isset($stati[$i])) {
                 $stati[$i] = '';
             }
             $rows[$i]->startdate_element = $dateFields[$i];
             $rows[$i]->enddate_element = FArrayHelper::getValue($dateFields2, $i);
             $rows[$i]->label_element = $labels[$i];
             $rows[$i]->status = FArrayHelper::getValue($stati, $i, '');
             $rows[$i]->colour = $colours[$i];
         }
         $this->eventLists = $rows;
     }
     return $this->eventLists;
 }
예제 #7
0
파일: map.php 프로젝트: adjaika/J3Base
 /**
  * Method to set the publishing state for a row or list of rows in the database
  * table. The method respects checked out rows by other users and will attempt
  * to checkin rows that it can after adjustments are made.
  *
  * @param   mixed    $pks     An array of primary key values to update.  If not
  *                            set the instance property value is used. [optional]
  * @param   integer  $state   The publishing state. eg. [0 = unpublished, 1 = published] [optional]
  * @param   integer  $userId  The user id of the user performing the operation. [optional]
  *
  * @return  boolean  True on success.
  *
  * @since   2.5
  */
 public function publish($pks = null, $state = 1, $userId = 0)
 {
     $k = $this->_tbl_key;
     // Sanitize input.
     $pks = ArrayHelper::toInteger($pks);
     $state = (int) $state;
     // If there are no primary keys set check to see if the instance key is set.
     if (empty($pks)) {
         if ($this->{$k}) {
             $pks = array($this->{$k});
         } else {
             $this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
             return false;
         }
     }
     // Build the WHERE clause for the primary keys.
     $where = $k . '=' . implode(' OR ' . $k . '=', $pks);
     // Update the publishing state for rows with the given primary keys.
     $query = $this->_db->getQuery(true)->update($this->_db->quoteName($this->_tbl))->set($this->_db->quoteName('state') . ' = ' . (int) $state)->where($where);
     $this->_db->setQuery($query);
     try {
         $this->_db->execute();
     } catch (RuntimeException $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // If the JTable instance value is in the list of primary keys that were set, set the instance.
     if (in_array($this->{$k}, $pks)) {
         $this->state = $state;
     }
     $this->setError('');
     return true;
 }
예제 #8
0
파일: rest.php 프로젝트: jfquestiaux/fabrik
 /**
  * Get the foreign keys value.
  *
  * @return  mixed string|int
  */
 protected function fkData()
 {
     if (!isset($this->fkData)) {
         /** @var FabrikFEModelForm $formModel */
         $formModel = $this->getModel();
         $params = $this->getParams();
         $this->fkData = array();
         // Get the foreign key element
         $fkElement = $this->fkElement();
         if ($fkElement) {
             $fkElementKey = $fkElement->getFullName();
             $this->fkData = json_decode(FArrayHelper::getValue($formModel->formData, $fkElementKey));
             if (is_object($this->fkData)) {
                 $this->fkData = ArrayHelper::fromObject($this->fkData);
             }
             $fkEval = $params->get('foreign_key_eval', '');
             if ($fkEval !== '') {
                 $fkData = $this->fkData;
                 $eval = eval($fkEval);
                 if ($eval !== false) {
                     $this->fkData = $eval;
                 }
             }
         }
     }
     return $this->fkData;
 }
예제 #9
0
 /**
  * Load transactions from database.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3),
  *     "txn_status" => "completed"
  * );
  *
  * $transactions    = new Crowdfunding\Transactions(\JFactory::getDbo());
  * $transactions->load($options);
  *
  * foreach($transactions as $transaction) {
  *   echo $transaction->txn_id;
  *   echo $transaction->txn_amount;
  * }
  *
  * </code>
  *
  * @param array $options
  *
  * @throws \UnexpectedValueException
  */
 public function load($options = array())
 {
     $ids = !isset($options["ids"]) ? null : (array) $options["ids"];
     if (!is_array($ids) or !$ids) {
         return;
     }
     ArrayHelper::toInteger($ids);
     // Load project data
     $query = $this->db->getQuery(true);
     $query->select("a.id, a.txn_date, a.txn_id, a.txn_amount, a.txn_currency, a.txn_status, " . "a.extra_data, a.status_reason, a.project_id, a.reward_id, a.investor_id, " . "a.receiver_id, a.service_provider, a.reward_state")->from($this->db->quoteName("#__crowdf_transactions", "a"))->where("a.id IN ( " . implode(",", $ids) . " )");
     // Filter by status.
     $status = ArrayHelper::getValue($options, "txn_status", null, "cmd");
     if (!empty($status)) {
         $query->where("a.txn_status = " . $this->db->quote($status));
     }
     $this->db->setQuery($query);
     $results = $this->db->loadObjectList();
     // Convert JSON string into an array.
     if (!empty($results)) {
         foreach ($results as $key => $result) {
             if (!empty($result->extra_data)) {
                 $result->extra_data = json_decode($result->extra_data, true);
                 $results[$key] = $result;
             }
         }
     } else {
         $results = array();
     }
     $this->items = $results;
 }
예제 #10
0
파일: users.php 프로젝트: eshiol/joomla-cms
 /**
  * Method to change the block status on a record.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function changeBlock()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $ids = $this->input->get('cid', array(), 'array');
     $values = array('block' => 1, 'unblock' => 0);
     $task = $this->getTask();
     $value = ArrayHelper::getValue($values, $task, 0, 'int');
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('COM_USERS_USERS_NO_ITEM_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Change the state of the records.
         if (!$model->block($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         } else {
             if ($value == 1) {
                 $this->setMessage(JText::plural('COM_USERS_N_USERS_BLOCKED', count($ids)));
             } elseif ($value == 0) {
                 $this->setMessage(JText::plural('COM_USERS_N_USERS_UNBLOCKED', count($ids)));
             }
         }
     }
     $this->setRedirect('index.php?option=com_users&view=users');
 }
예제 #11
0
 /**
  * Set which fieldsets should be used
  *
  * @since   3.0.7
  *
  * @return  array  fieldset names
  */
 private function setFieldSets()
 {
     $input = $this->app->input;
     // From list data view in admin
     $id = $input->getInt('listid', 0);
     // From list of lists checkbox selection
     $cid = $input->get('cid', array(0), 'array');
     $cid = ArrayHelper::toInteger($cid);
     if ($id === 0) {
         $id = $cid[0];
     }
     if ($id !== 0) {
         $db = FabrikWorker::getDbo();
         $query = $db->getQuery(true);
         $query->select('label')->from('#__{package}_lists')->where('id = ' . $id);
         $db->setQuery($query);
         $this->listName = $db->loadResult();
     }
     $fieldsets = array('details');
     if ($this->model->canEmpty()) {
         $fieldsets[] = 'drop';
     }
     $fieldsets[] = $id === 0 ? 'creation' : 'append';
     $fieldsets[] = 'format';
     return $fieldsets;
 }
예제 #12
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  *
  * @since   3.6.0
  */
 public function getOptions()
 {
     $lang = JFactory::getLanguage();
     $options = array();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select($db->quoteName('id', 'value'))->select($db->quoteName('title', 'text'))->from($db->quoteName('#__finder_types'));
     // Get the options.
     $db->setQuery($query);
     try {
         $contentTypes = $db->loadObjectList();
     } catch (RuntimeException $e) {
         JError::raiseWarning(500, $db->getMessage());
     }
     // Translate.
     foreach ($contentTypes as $contentType) {
         $key = FinderHelperLanguage::branchSingular($contentType->text);
         $contentType->translatedText = $lang->hasKey($key) ? JText::_($key) : $contentType->text;
     }
     // Order by title.
     $contentTypes = ArrayHelper::sortObjects($contentTypes, 'translatedText', 1, true, true);
     // Convert the values to options.
     foreach ($contentTypes as $contentType) {
         $options[] = JHtml::_('select.option', $contentType->value, $contentType->translatedText);
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
예제 #13
0
 /**
  * Render the list of associated items
  *
  * @param   integer  $catid      Category identifier to search its associations
  * @param   string   $extension  Category Extension
  *
  * @return  string   The language HTML
  *
  * @since   3.2
  * @throws  Exception
  */
 public static function association($catid, $extension = 'com_content')
 {
     // Defaults
     $html = '';
     // Get the associations
     if ($associations = CategoriesHelper::getAssociations($catid, $extension)) {
         $associations = ArrayHelper::toInteger($associations);
         // Get the associated categories
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('c.id, c.title')->select('l.sef as lang_sef')->select('l.lang_code')->from('#__categories as c')->where('c.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON c.language=l.lang_code')->select('l.image')->select('l.title as language_title');
         $db->setQuery($query);
         try {
             $items = $db->loadObjectList('id');
         } catch (RuntimeException $e) {
             throw new Exception($e->getMessage(), 500, $e);
         }
         if ($items) {
             foreach ($items as &$item) {
                 $text = $item->lang_sef ? strtoupper($item->lang_sef) : 'XX';
                 $url = JRoute::_('index.php?option=com_categories&task=category.edit&id=' . (int) $item->id . '&extension=' . $extension);
                 $classes = 'hasPopover label label-association label-' . $item->lang_sef;
                 $item->link = '<a href="' . $url . '" title="' . $item->language_title . '" class="' . $classes . '" data-content="' . $item->title . '" data-placement="top">' . $text . '</a>';
             }
         }
         JHtml::_('bootstrap.popover');
         $html = JLayoutHelper::render('joomla.content.associations', $items);
     }
     return $html;
 }
예제 #14
0
파일: finder.php 프로젝트: N6REJ/joomla-cms
 /**
  * Creates a list of maps.
  *
  * @return  array  An array containing the maps that can be selected.
  *
  * @since   2.5
  */
 public static function mapslist()
 {
     $lang = JFactory::getLanguage();
     // Load the finder types.
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select($db->quoteName('title', 'text'))->select($db->quoteName('id', 'value'))->from($db->quoteName('#__finder_taxonomy'))->where($db->quoteName('parent_id') . ' = 1');
     $db->setQuery($query);
     try {
         $branches = $db->loadObjectList();
     } catch (RuntimeException $e) {
         JError::raiseWarning(500, $db->getMessage());
     }
     // Translate.
     foreach ($branches as $branch) {
         $key = FinderHelperLanguage::branchPlural($branch->text);
         $branch->translatedText = $lang->hasKey($key) ? JText::_($key) : $branch->text;
     }
     // Order by title.
     $branches = ArrayHelper::sortObjects($branches, 'translatedText', 1, true, true);
     // Compile the options.
     $options = array();
     $options[] = JHtml::_('select.option', '', JText::_('COM_FINDER_MAPS_SELECT_BRANCH'));
     // Convert the values to options.
     foreach ($branches as $branch) {
         $options[] = JHtml::_('select.option', $branch->value, $branch->translatedText);
     }
     return $options;
 }
 /**
  * Generate a string of amount based on location.
  * The method uses PHP NumberFormatter ( Internationalization Functions ).
  * If the internationalization library is not loaded, the method generates a simple string ( 100 USD, 500 EUR,... )
  *
  * <code>
  * $options = array(
  *     "intl" => true",
  *     "locale" => "en_GB",
  *     "symbol" => "£",
  *     "position" => 0 // 0 for symbol on the left side, 1 for symbole on the right side.
  * );
  *
  * $amount = Prism\Utilities\StringHelper::getAmount(100, GBP, $options);
  *
  * echo $amount;
  * </code>
  *
  * @param float $amount Amount value.
  * @param string $currency Currency Code ( GBP, USD, EUR,...)
  * @param array $options Options - "intl", "locale", "symbol",...
  *
  * @return string
  */
 public static function getAmount($amount, $currency, array $options = array())
 {
     $useIntl = ArrayHelper::getValue($options, 'intl', false, 'bool');
     $locale = ArrayHelper::getValue($options, 'locale');
     $symbol = ArrayHelper::getValue($options, 'symbol');
     $position = ArrayHelper::getValue($options, 'position', 0, 'int');
     // Use PHP Intl library.
     if ($useIntl and extension_loaded('intl')) {
         // Generate currency string using PHP NumberFormatter ( Internationalization Functions )
         // Get current locale code.
         if (!$locale) {
             $lang = \JFactory::getLanguage();
             $locale = $lang->getName();
         }
         $numberFormat = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
         $result = $numberFormat->formatCurrency($amount, $currency);
     } else {
         // Generate a custom currency string.
         if (\JString::strlen($symbol) > 0) {
             // Symbol
             if (0 === $position) {
                 // Symbol at the beginning.
                 $result = $symbol . $amount;
             } else {
                 // Symbol at end.
                 $result = $amount . $symbol;
             }
         } else {
             // Code
             $result = $amount . $currency;
         }
     }
     return $result;
 }
 /**
  * Method to get a JDatabaseQuery object for retrieving the data set from a database.
  *
  * @return  JDatabaseQuery   A JDatabaseQuery object to retrieve the data set.
  */
 protected function getListQuery()
 {
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     $subQuery = $db->getQuery(true);
     $includeRaw = $this->state->params->get('include_issues', null);
     $excludeRaw = $this->state->params->get('exclude_issues', null);
     $includeArray = explode(',', $includeRaw);
     $excludeArray = explode(',', $excludeRaw);
     $includeArray = ArrayHelper::toInteger($includeArray);
     $excludeArray = ArrayHelper::toInteger($excludeArray);
     $subQuery->select('it.issue_id AS issue_id, it.tag_id AS tag_id, t.tag AS tag')->join('LEFT', '#__code_tags AS t ON t.tag_id = it.tag_id')->from('#__code_tracker_issue_tag_map AS it')->where('it.tag_id IN (6,10,16,20,24,26,28,51,52,55,62,65,67,74,75,78,79,82,83,87,92,93,105,107,112,115)')->group('it.issue_id, it.tag_id, t.tag');
     // Select required fields from the categories.
     $query->select('CASE WHEN ISNULL(m.tag) THEN ' . $db->quote('None') . ' ELSE m.tag END as category');
     $query->select('i.title, i.jc_issue_id, i.close_date');
     $query->from('#__code_tracker_issues AS i');
     $query->join('LEFT', '(' . (string) $subQuery . ') AS m ON i.jc_issue_id = m.issue_id');
     $query->where('((DATE(close_date) BETWEEN ' . $db->quote(substr($this->state->params->get('start_date'), 0, 10)) . ' AND ' . $db->quote(substr($this->state->params->get('end_date'), 0, 10)) . ')' . ' OR (i.jc_issue_id IN (' . implode(',', $includeArray) . ')))');
     // Join the status table to get the status name
     $query->select('s.title AS status_name');
     $query->join('LEFT', '#__code_tracker_status AS s ON i.status = s.jc_status_id');
     // Filter on merged items from the trackers
     $query->where('(s.title LIKE ' . $db->quote('%Fixed in SVN%') . ' OR s.title LIKE ' . $db->quote('%Implemented in trunk%') . ')');
     // Exclude explicitly listed trackers
     $query->where('i.jc_issue_id NOT IN (' . implode(',', $excludeArray) . ')');
     if ($this->state->get('list.filter')) {
         $query->where('i.title LIKE ' . $db->quote('%' . $this->state->get('list.filter') . '%'));
     }
     $query->order('CASE WHEN ISNULL(m.tag) THEN ' . $db->quote('None') . ' ELSE m.tag END ASC');
     $query->order('i.jc_issue_id ASC');
     return $query;
 }
예제 #17
0
 /**
  * Update a set of extensions.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function update()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     /** @var InstallerModelUpdate $model */
     $model = $this->getModel('update');
     $uid = $this->input->get('cid', array(), 'array');
     $uid = ArrayHelper::toInteger($uid, array());
     // Get the minimum stability.
     $component = JComponentHelper::getComponent('com_installer');
     $params = $component->params;
     $minimum_stability = $params->get('minimum_stability', JUpdater::STABILITY_STABLE, 'int');
     $model->update($uid, $minimum_stability);
     if ($model->getState('result', false)) {
         JFactory::getCache('mod_menu')->clean();
     }
     $app = JFactory::getApplication();
     $redirect_url = $app->getUserState('com_installer.redirect_url');
     // Don't redirect to an external URL.
     if (!JUri::isInternal($redirect_url)) {
         $redirect_url = '';
     }
     if (empty($redirect_url)) {
         $redirect_url = JRoute::_('index.php?option=com_installer&view=update', false);
     } else {
         // Wipe out the user state when we're going to redirect.
         $app->setUserState('com_installer.redirect_url', '');
         $app->setUserState('com_installer.message', '');
         $app->setUserState('com_installer.extension_message', '');
     }
     $this->setRedirect($redirect_url);
 }
예제 #18
0
 public function save($key = null, $urlVar = null)
 {
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $data = $this->input->post->get('jform', array(), 'array');
     $itemId = ArrayHelper::getValue($data, 'id');
     $responseOptions = array('task' => $this->getTask(), 'id' => $itemId);
     $model = $this->getModel();
     /** @var $model EmailTemplatesModelEmail */
     $form = $model->getForm($data, false);
     /** @var $form JForm */
     if (!$form) {
         throw new Exception(JText::_('COM_EMAILTEMPLATES_ERROR_FORM_CANNOT_BE_LOADED'));
     }
     // Validate the form data
     $validData = $model->validate($form, $data);
     // Check for errors
     if ($validData === false) {
         $this->displayNotice($form->getErrors(), $responseOptions);
         return;
     }
     try {
         $itemId = $model->save($validData);
         $responseOptions['id'] = $itemId;
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_EMAILTEMPLATES_ERROR_SYSTEM'));
     }
     $this->displayMessage(JText::_('COM_EMAILTEMPLATES_EMAIL_SAVED_SUCCESSFULLY'), $responseOptions);
 }
예제 #19
0
파일: banners.php 프로젝트: adjaika/J3Base
 /**
  * Stick items
  *
  * @return  void
  *
  * @since   1.6
  */
 public function sticky_publish()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $ids = $this->input->get('cid', array(), 'array');
     $values = array('sticky_publish' => 1, 'sticky_unpublish' => 0);
     $task = $this->getTask();
     $value = ArrayHelper::getValue($values, $task, 0, 'int');
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('COM_BANNERS_NO_BANNERS_SELECTED'));
     } else {
         // Get the model.
         /** @var BannersModelBanner $model */
         $model = $this->getModel();
         // Change the state of the records.
         if (!$model->stick($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         } else {
             if ($value == 1) {
                 $ntext = 'COM_BANNERS_N_BANNERS_STUCK';
             } else {
                 $ntext = 'COM_BANNERS_N_BANNERS_UNSTUCK';
             }
             $this->setMessage(JText::plural($ntext, count($ids)));
         }
     }
     $this->setRedirect('index.php?option=com_banners&view=banners');
 }
예제 #20
0
 public function save($key = null, $urlVar = null)
 {
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     /** @var $app JApplicationAdministrator */
     $data = $app->input->post->get('jform', array(), 'array');
     $itemId = ArrayHelper::getValue($data, 'id');
     $redirectOptions = array('task' => $this->getTask(), 'id' => $itemId);
     $model = $this->getModel();
     /** @var $model GamificationModelPoint */
     $form = $model->getForm($data, false);
     /** @var $form JForm */
     if (!$form) {
         throw new Exception(JText::_('COM_GAMIFICATION_ERROR_FORM_CANNOT_BE_LOADED'));
     }
     // Validate the form
     $validData = $model->validate($form, $data);
     // Check for errors.
     if ($validData === false) {
         $this->displayNotice($form->getErrors(), $redirectOptions);
         return;
     }
     try {
         $itemId = $model->save($validData);
         $redirectOptions['id'] = $itemId;
     } catch (Exception $e) {
         JLog::add($e->getMessage(), JLog::ERROR, 'com_gamification');
         throw new Exception(JText::_('COM_GAMIFICATION_ERROR_SYSTEM'));
     }
     $this->displayMessage(JText::_('COM_GAMIFICATION_POINTS_SAVED'), $redirectOptions);
 }
예제 #21
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 = ArrayHelper::fromObject(new JConfig());
    $data = array_merge($prev, array('cacheHandler' => 'file'));
    $config = new Registry($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'));
    }
}
예제 #22
0
파일: users.php 프로젝트: adjaika/J3Base
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @param   string  $ordering   An optional ordering field.
  * @param   string  $direction  An optional direction (asc|desc).
  *
  * @return  void
  *
  * @since   1.6
  */
 protected function populateState($ordering = 'a.name', $direction = 'asc')
 {
     $app = JFactory::getApplication('administrator');
     // Adjust the context to support modal layouts.
     if ($layout = $app->input->get('layout', 'default', 'cmd')) {
         $this->context .= '.' . $layout;
     }
     // Load the filter state.
     $this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
     $this->setState('filter.active', $this->getUserStateFromRequest($this->context . '.filter.active', 'filter_active', '', 'cmd'));
     $this->setState('filter.state', $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'cmd'));
     $this->setState('filter.group_id', $this->getUserStateFromRequest($this->context . '.filter.group_id', 'filter_group_id', null, 'int'));
     $this->setState('filter.range', $this->getUserStateFromRequest($this->context . '.filter.range', 'filter_range', '', 'cmd'));
     $this->setState('filter.lastvisitrange', $this->getUserStateFromRequest($this->context . '.filter.lastvisitrange', 'filter_lastvisitrange', '', 'cmd'));
     $groups = json_decode(base64_decode($app->input->get('groups', '', 'BASE64')));
     if (isset($groups)) {
         $groups = ArrayHelper::toInteger($groups);
     }
     $this->setState('filter.groups', $groups);
     $excluded = json_decode(base64_decode($app->input->get('excluded', '', 'BASE64')));
     if (isset($excluded)) {
         $excluded = ArrayHelper::toInteger($excluded);
     }
     $this->setState('filter.excluded', $excluded);
     // Load the parameters.
     $params = JComponentHelper::getParams('com_users');
     $this->setState('params', $params);
     // List state information.
     parent::populateState($ordering, $direction);
 }
예제 #23
0
파일: menus.php 프로젝트: adjaika/J3Base
 /**
  * Remove an item.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function delete()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $cids = (array) $this->input->get('cid', array(), 'array');
     if (count($cids) < 1) {
         $app->enqueueMessage(JText::_('COM_MENUS_NO_MENUS_SELECTED'), 'notice');
     } else {
         // Access checks.
         foreach ($cids as $i => $id) {
             if (!$user->authorise('core.delete', 'com_menus.menu.' . (int) $id)) {
                 // Prune items that you can't change.
                 unset($cids[$i]);
                 $app->enqueueMessage(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), 'error');
             }
         }
         if (count($cids) > 0) {
             // Get the model.
             $model = $this->getModel();
             // Make sure the item ids are integers
             $cids = ArrayHelper::toInteger($cids);
             // Remove the items.
             if (!$model->delete($cids)) {
                 $this->setMessage($model->getError());
             } else {
                 $this->setMessage(JText::plural('COM_MENUS_N_MENUS_DELETED', count($cids)));
             }
         }
     }
     $this->setRedirect('index.php?option=com_menus&view=menus');
 }
예제 #24
0
 /**
  * Method to render the view.
  *
  * @return  string  The rendered view.
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function render()
 {
     // Set the vars to the template.
     $this->renderer->set('group', ArrayHelper::fromObject($this->model->getItem()));
     $this->renderer->set('project', $this->getProject());
     return parent::render();
 }
 public function read()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Get items to publish from the request.
     $cid = $this->input->get('cid', array(), 'array');
     $data = array('read' => 1, 'notread' => 0);
     $task = $this->getTask();
     $value = ArrayHelper::getValue($data, $task, 0, 'int');
     $redirectOptions = array("view" => "notifications");
     // Make sure the item ids are integers
     ArrayHelper::toInteger($cid);
     if (empty($cid)) {
         $this->displayNotice(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), $redirectOptions);
         return;
     }
     try {
         $model = $this->getModel();
         $model->read($cid, $value);
     } catch (RuntimeException $e) {
         $this->displayWarning($e->getMessage(), $redirectOptions);
         return;
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_GAMIFICATION_ERROR_SYSTEM'));
     }
     if ($value == 1) {
         $msg = $this->text_prefix . '_N_ITEMS_READ';
     } else {
         $msg = $this->text_prefix . '_N_ITEMS_NOT_READ';
     }
     $this->displayMessage(JText::plural($msg, count($cid)), $redirectOptions);
 }
예제 #26
0
 /**
  * Render the list of associated items
  *
  * @param   integer  $catid      Category identifier to search its associations
  * @param   string   $extension  Category Extension
  *
  * @return  string   The language HTML
  *
  * @since   3.2
  * @throws  Exception
  */
 public static function association($catid, $extension = 'com_content')
 {
     // Defaults
     $html = '';
     // Get the associations
     if ($associations = CategoriesHelper::getAssociations($catid, $extension)) {
         $associations = ArrayHelper::toInteger($associations);
         // Get the associated categories
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('c.id, c.title')->select('l.sef as lang_sef')->from('#__categories as c')->where('c.id IN (' . implode(',', array_values($associations)) . ')')->join('LEFT', '#__languages as l ON c.language=l.lang_code')->select('l.image')->select('l.title as language_title');
         $db->setQuery($query);
         try {
             $items = $db->loadObjectList('id');
         } catch (RuntimeException $e) {
             throw new Exception($e->getMessage(), 500, $e);
         }
         if ($items) {
             foreach ($items as &$item) {
                 $text = strtoupper($item->lang_sef);
                 $url = JRoute::_('index.php?option=com_categories&task=category.edit&id=' . (int) $item->id . '&extension=' . $extension);
                 $tooltipParts = array(JHtml::_('image', 'mod_languages/' . $item->image . '.gif', $item->language_title, array('title' => $item->language_title), true), $item->title);
                 $item->link = JHtml::_('tooltip', implode(' ', $tooltipParts), null, null, $text, $url, null, 'hasTooltip label label-association label-' . $item->lang_sef);
             }
         }
         $html = JLayoutHelper::render('joomla.content.associations', $items);
     }
     return $html;
 }
예제 #27
0
 /**
  * Load transactions from database.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3),
  *     "txn_status" => "completed"
  * );
  *
  * $transactions    = new Crowdfunding\Transactions(\JFactory::getDbo());
  * $transactions->load($options);
  *
  * foreach($transactions as $transaction) {
  *   echo $transaction->txn_id;
  *   echo $transaction->txn_amount;
  * }
  *
  * </code>
  *
  * @param array $options
  *
  * @throws \UnexpectedValueException
  */
 public function load($options = array())
 {
     $ids = !array_key_exists('ids', $options) ? array() : (array) $options['ids'];
     $ids = ArrayHelper::toInteger($ids);
     $results = array();
     if (count($ids) > 0) {
         // Load project data
         $query = $this->db->getQuery(true);
         $query->select('a.id, a.txn_date, a.txn_id, a.txn_amount, a.txn_currency, a.txn_status, ' . 'a.extra_data, a.status_reason, a.project_id, a.reward_id, a.investor_id, ' . 'a.receiver_id, a.service_provider, a.service_alias, a.reward_state')->from($this->db->quoteName('#__crowdf_transactions', 'a'))->where('a.id IN ( ' . implode(',', $ids) . ' )');
         // Filter by status.
         $status = ArrayHelper::getValue($options, 'txn_status', null, 'cmd');
         if ($status !== null) {
             $query->where('a.txn_status = ' . $this->db->quote($status));
         }
         $this->db->setQuery($query);
         $results = (array) $this->db->loadAssocList();
         // Convert JSON string into an array.
         if (count($results) > 0) {
             foreach ($results as $key => &$result) {
                 if (!empty($result['extra_data'])) {
                     $result['extra_data'] = json_decode($result['extra_data'], true);
                 }
             }
             unset($result);
         }
     }
     $this->items = $results;
 }
예제 #28
0
 /**
  * This method prepare a link where the user will be redirected
  * after action he has done.
  *
  * <code>
  * array(
  *        "view",
  *        "layout"
  *        "id",
  *        "url_var",
  *        "force_direction" // This is a link that will be used instead generated by the system.
  * );
  * </code>
  * @param array $options
  *
  * @throws \InvalidArgumentException
  *
  * @return string
  */
 protected function prepareRedirectLink($options)
 {
     $view = ArrayHelper::getValue($options, 'view');
     $task = ArrayHelper::getValue($options, 'task');
     $itemId = ArrayHelper::getValue($options, 'id', 0, 'uint');
     $urlVar = ArrayHelper::getValue($options, 'url_var', 'id');
     // Remove standard parameters
     unset($options['view'], $options['task'], $options['id'], $options['url_var']);
     $link = $this->defaultLink;
     // Redirect to different of common views
     if (null !== $view) {
         $link .= '&view=' . $view;
         if ($itemId > 0) {
             $link .= $this->getRedirectToItemAppend($itemId, $urlVar);
         } else {
             $link .= $this->getRedirectToListAppend();
         }
         return $link;
     }
     // Prepare redirection
     switch ($task) {
         case 'apply':
             $link .= '&view=' . $this->view_item . $this->getRedirectToItemAppend($itemId, $urlVar);
             break;
         case 'save2new':
             $link .= '&view=' . $this->view_item . $this->getRedirectToItemAppend();
             break;
         default:
             $link .= '&view=' . $this->view_list . $this->getRedirectToListAppend();
             break;
     }
     // Generate additional parameters
     $extraParams = $this->prepareExtraParameters($options);
     return $link . $extraParams;
 }
예제 #29
0
 /**
  * Method to get an object.
  *
  * @param   integer  $id  The id of the object to get.
  *
  * @return  mixed    Object on success, false on failure.
  */
 public function &getData($id = null)
 {
     if ($this->_item === null) {
         $this->_item = false;
         if (empty($id)) {
             $id = $this->getState('course.id');
         }
         // Get a level row instance.
         $table = $this->getTable();
         // Attempt to load the row.
         if ($table->load($id)) {
             // Check published state.
             if ($published = $this->getState('filter.published')) {
                 if ($table->state != $published) {
                     return $this->_item;
                 }
             }
             // Convert the JTable to a clean JObject.
             $properties = $table->getProperties(1);
             $this->_item = ArrayHelper::toObject($properties, 'JObject');
         }
     }
     if (isset($this->_item->created_by)) {
         $this->_item->created_by_name = JFactory::getUser($this->_item->created_by)->name;
     }
     return $this->_item;
 }
 /**
  * Load locations data by ID from database.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3,4,5), // Load locations by IDs.
  *     "search" => "London" // It is a phrase for searching.
  * );
  *
  * $locations   = new Socialcommunity\Locations(JFactory::getDbo());
  * $locations->load($options);
  *
  * foreach($locations as $location) {
  *   echo $location["name"];
  *   echo $location["country_code"];
  * }
  * </code>
  *
  * @param array $options
  */
 public function load(array $options = array())
 {
     $ids = ArrayHelper::getValue($options, 'ids', array(), 'array');
     $search = ArrayHelper::getValue($options, 'search', '', 'string');
     $countryId = ArrayHelper::getValue($options, 'country_id', 0, 'int');
     ArrayHelper::toInteger($ids);
     $query = $this->db->getQuery(true);
     $query->select('a.id, a.name, a.latitude, a.longitude, a.country_code, a.state_code, a.timezone, a.published')->from($this->db->quoteName('#__itpsc_locations', 'a'));
     if (count($ids) > 0) {
         $query->where('a.id IN ( ' . implode(',', $ids) . ' )');
     }
     // Filter by country ID ( use subquery to get country code ).
     if ($countryId > 0) {
         $subQuery = $this->db->getQuery(true);
         $subQuery->select('sqc.code')->from($this->db->quoteName('#__itpsc_countries', 'sqc'))->where('sqc.id = ' . (int) $countryId);
         $query->where('a.country_code = ( ' . $subQuery . ' )');
     }
     if ($query !== null and $query !== '') {
         $escaped = $this->db->escape($search, true);
         $quoted = $this->db->quote('%' . $escaped . '%', false);
         $query->where('a.name LIKE ' . $quoted);
     }
     $this->db->setQuery($query);
     $this->items = (array) $this->db->loadAssocList('id');
 }