/** * 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'); }
/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { // Initialise variables. $html = array(); $recordId = (int) $this->form->getValue('id'); $size = ($v = $this->element['size']) ? ' size="' . $v . '"' : ''; $class = ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="text_area"'; // Get a reverse lookup of the base link URL to Title $model = JModel::getInstance('menutypes', 'menusModel'); $rlu = $model->getReverseLookup(); switch ($this->value) { case 'url': $value = JText::_('COM_MENUS_TYPE_EXTERNAL_URL'); break; case 'alias': $value = JText::_('COM_MENUS_TYPE_ALIAS'); break; case 'separator': $value = JText::_('COM_MENUS_TYPE_SEPARATOR'); break; default: $link = $this->form->getValue('link'); // Clean the link back to the option, view and layout $value = JText::_(JArrayHelper::getValue($rlu, MenusHelper::getLinkKey($link))); break; } // Load the javascript and css JHtml::_('behavior.framework'); JHtml::_('behavior.modal'); $html[] = '<input type="text" readonly="readonly" disabled="disabled" value="' . $value . '"' . $size . $class . ' />'; $html[] = '<input type="button" value="' . JText::_('JSELECT') . '" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\'' . JRoute::_('index.php?option=com_menus&view=menutypes&tmpl=component&recordId=' . $recordId) . '\'})" />'; $html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />'; return implode("\n", $html); }
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)); }
/** * 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); }
/** * Returns an object list * * @param string The query * @param int Offset * @param int The number of records * @return array */ protected function _getList($query, $limitstart = 0, $limit = 0) { $ordering = $this->getState('list.ordering'); $search = $this->getState('filter.search'); // Replace slashes so preg_match will work $search = str_replace('/', ' ', $search); $db = $this->getDbo(); if ($ordering == 'name' || !empty($search) && stripos($search, 'id:') !== 0) { $db->setQuery($query); $result = $db->loadObjectList(); $lang = JFactory::getLanguage(); $this->translate($result); if (!empty($search)) { foreach ($result as $i => $item) { if (!preg_match("/{$search}/i", $item->name)) { unset($result[$i]); } } } JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == 'desc' ? -1 : 1, true, $lang->getLocale()); $total = count($result); $this->cache[$this->getStoreId('getTotal')] = $total; if ($total < $limitstart) { $limitstart = 0; $this->setState('list.start', 0); } return array_slice($result, $limitstart, $limit ? $limit : null); } else { $query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction')); $result = parent::_getList($query, $limitstart, $limit); $this->translate($result); return $result; } }
static function link($url, $text, $attribs = null) { if (is_array($attribs)) { $attribs = JArrayHelper::toString($attribs); } return "<a href='" . $url . "' " . $attribs . ">" . $text . "</a>"; }
/** * 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; }
public function getItem($pk = null) { // Initialise variables. $pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id'); $table = $this->getTable(); if ($pk > 0) { // Attempt to load the row. $return = $table->load($pk); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return false; } } // Convert to the JObject before adding other data. $properties = $table->getProperties(1); $item = JArrayHelper::toObject($properties, 'JObject'); $item->title = htmlspecialchars(strip_tags($item->title)); if (property_exists($item, 'params')) { $registry = new JRegistry(); $registry->loadString($item->params); $item->params = $registry->toArray(); } if ($item) { $arr = str_replace('[', '', $item->value); $arr = str_replace(']', '', $arr); if (preg_match('/.*\\},{\\.*?/s', $arr, $match)) { //var_dump($match); $values = str_replace('},', '}///', $arr); $values = explode('///', $values); } else { $values = (array) $arr; } // $artOptFields = $this -> _checkArticleFields($item -> id); if (count($values) > 0) { $list = array(); $i = 0; foreach ($values as $value) { $list[$i] = new stdClass(); $param = new JRegistry($value); $list[$i]->type = $item->type; if (!empty($item->default_value)) { $list[$i]->default_value = explode(',', $item->default_value); } else { $list[$i]->default_value = array(); } $list[$i]->name = $param->get('name'); $list[$i]->value = $param->get('value'); $list[$i]->target = $param->get('target'); $list[$i]->editor = $param->get('editor'); $list[$i]->image = $param->get('image'); $list[$i]->ordering = $param->get('ordering'); $i++; } $item->defvalue = $list; } $item->groups = $this->getGroups(); } return $item; }
/** * 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'); }
/** * 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; }
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; }
/** this function returns math expression into your form, the parameter is optional * quite simmilar to insertQuestion, but returns the output as a text instead of echoing */ public static function returnQuestion($attributes = array(), $suffix = '') { //default prime is 37, you can change it when specifying the different parameter $a = rand() % 10; // generates the random number $b = rand() % 10; // generates the random number $code = $a + $b; if (!is_array($attributes)) { $attributes = array(); } if (!isset($attributes['name'])) { $suffix = $suffix . rand(1, 99999); $attributes['name'] = 'captcha_code' . $suffix; } if (!isset($attributes['id'])) { $attributes['id'] = $attributes['name']; } if (!isset($attributes['size'])) { $attributes['size'] = '2'; } if (!isset($attributes['class'])) { $attributes['class'] = 'inputbox mathguard-answer required'; } $session =& JFactory::getSession(); $session->set($attributes['name'], $code); return $a . ' + ' . $b . ' = ' . '<input type="text" ' . JArrayHelper::toString($attributes) . ' />'; }
/** * 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); }
/** * Render the profiler log data, and echo it.. * * @param string $namespace The JProfiler instance ID. Default is the core profiler "Application". * @param boolean $asString Return as string. * * @return string */ public static function render($namespace = 'Windwalker', $asString = false) { $app = Container::getInstance()->get('app'); if ($namespace == 'core' || !$namespace) { $namespace = 'Application'; } $buffer = 'No Profiler data.'; if (isset(self::$profiler[$namespace])) { $_PROFILER = self::$profiler[$namespace]; $buffer = $_PROFILER->getBuffer(); $buffer = implode("\n<br />\n", $buffer); } else { $buffer = $app->getUserState('windwalker.system.profiler.' . $namespace); $buffer = $buffer ? implode("\n<br />\n", $buffer) : ''; } $buffer = $buffer ? $buffer : 'No Profiler data.'; // Get last page logs $state_buffer = \JArrayHelper::getValue(self::$stateBuffer, $namespace); if ($state_buffer) { $state_buffer = implode("\n<br />\n", $state_buffer); $buffer = $state_buffer . "\n<br />---------<br />\n" . $buffer; } // Render $buffer = "<pre><h3>WindWalker Debug [namespace: {$namespace}]: </h3>" . $buffer . '</pre>'; $app->setUserState('windwalker.system.profiler.' . $namespace, ''); if ($asString) { return $buffer; } echo $buffer; return ''; }
/** * Method to get an ojbect. * * @param integer The id of the object to get. * * @return mixed Object on success, false on failure. */ public function &getItem($id = null) { if ($this->_item === null) { $this->_item = false; if (empty($id)) { $id = $this->getState('weblink.id'); } // Get a level row instance. $table = JTable::getInstance('Weblink', 'WeblinksTable'); // 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 = JArrayHelper::toObject($properties, 'JObject'); } else { if ($error = $table->getError()) { $this->setError($error); } } } return $this->_item; }
/** * Method is called before user data is stored in the database. * * Changes the password in LDAP if the user changed their password. * * @param array $user Holds the old user data. * @param boolean $isNew True if a new user is stored. * @param array $new Holds the new user data. * * @return boolean Cancels the save if False. * * @since 2.0 */ public function onUserBeforeSave($user, $isNew, $new) { if ($isNew) { // We dont want to deal with new users here return; } // Get username and password to use for authenticating with Ldap $username = JArrayHelper::getValue($user, 'username', false, 'string'); $password = JArrayHelper::getValue($new, 'password_clear', null, 'string'); if (!empty($password)) { $auth = array('authenticate' => SHLdap::AUTH_USER, 'username' => $username, 'password' => $password); try { // We will double check the password for double safety (breaks password reset if on) $authenticate = $this->params->get('authenticate', 0); // Get the user adapter then set the password on it $adapter = SHFactory::getUserAdapter($auth); $adapter->setPassword($password, JArrayHelper::getValue($new, 'current-password', null, 'string'), $authenticate); SHLog::add(JText::sprintf('PLG_LDAP_PASSWORD_INFO_12411', $username), 12411, JLog::INFO, 'ldap'); } catch (Exception $e) { // Log and Error out SHLog::add($e, 12401, JLog::ERROR, 'ldap'); return false; } } }
/** * 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')); } }
/** * @param XmapDisplayerInterface $xmap * @param stdClass $parent * @param array $params */ public static function getTree($xmap, stdClass $parent, array &$params) { $uri = new JUri($parent->link); if ($xmap->isNews || !self::$enabled || !in_array($uri->getVar('view'), self::$views)) { return; } $params['include_topics'] = JArrayHelper::getValue($params, 'include_topics', 1); $params['include_topics'] = $params['include_topics'] == 1 || $params['include_topics'] == 2 && $xmap->view == 'xml' || $params['include_topics'] == 3 && $xmap->view == 'html'; $params['include_pagination'] = JArrayHelper::getValue($params, 'include_pagination', 0); $params['include_pagination'] = $params['include_pagination'] == 1 || $params['include_pagination'] == 2 && $xmap->view == 'xml' || $params['include_pagination'] == 3 && $xmap->view == 'html'; $params['cat_priority'] = JArrayHelper::getValue($params, 'cat_priority', $parent->priority); $params['cat_priority'] = $params['cat_priority'] == -1 ? $parent->priority : $params['cat_priority']; $params['cat_changefreq'] = JArrayHelper::getValue($params, 'cat_changefreq', $parent->changefreq); $params['cat_changefreq'] = $params['cat_changefreq'] == -1 ? $parent->changefreq : $params['cat_changefreq']; $params['topic_priority'] = JArrayHelper::getValue($params, 'topic_priority', $parent->changefreq); $params['topic_priority'] = $params['topic_priority'] == -1 ? $parent->priority : $params['topic_priority']; $params['topic_changefreq'] = JArrayHelper::getValue($params, 'topic_changefreq', $parent->changefreq); $params['topic_changefreq'] = $params['topic_changefreq'] == -1 ? $parent->changefreq : $params['topic_changefreq']; if ($params['include_topics']) { if ((int) ($limit = JArrayHelper::getValue($params, 'max_topics', 0))) { $params['limit'] = $limit; } else { $params['limit'] = 0; } if ((int) ($days = JArrayHelper::getValue($params, 'max_age', 0))) { $params['days'] = JFactory::getDate()->toUnix() - intval($days) * 86400; } else { $params['days'] = ''; } } self::getCategoryTree($xmap, $parent, $params, $uri->getVar('catid', 0)); }
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; }
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)); }
/** * Save data into the DB * * @param array $data The data about item * * @return mixed Item ID or null */ public function save($data) { $id = JArrayHelper::getValue($data, "id"); $units = JArrayHelper::getValue($data, "units"); $currencyId = JArrayHelper::getValue($data, "currency_id"); $txnId = JArrayHelper::getValue($data, "txn_id"); $txnAmount = JArrayHelper::getValue($data, "txn_amount"); $txnCurrency = JArrayHelper::getValue($data, "txn_currency"); $txnStatus = JArrayHelper::getValue($data, "txn_status"); $txnDate = JArrayHelper::getValue($data, "txn_date"); $senderId = JArrayHelper::getValue($data, "sender_id"); $receiverId = JArrayHelper::getValue($data, "receiver_id"); $serviceProvider = JArrayHelper::getValue($data, "service_provider"); // Load a record from the database $row = $this->getTable(); $row->load($id); $row->set("currency_id", $currencyId); $row->set("units", $units); $row->set("txn_id", $txnId); $row->set("txn_amount", $txnAmount); $row->set("txn_currency", $txnCurrency); $row->set("txn_status", $txnStatus); $row->set("txn_date", $txnDate); $row->set("txn_date", $txnDate); $row->set("sender_id", $senderId); $row->set("receiver_id", $receiverId); $row->set("service_provider", $serviceProvider); $row->store(); return $row->get("id"); }
/** * Method to get an ojbect. * * @param integer 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('address.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 = JArrayHelper::toObject($properties, 'JObject'); } elseif ($error = $table->getError()) { $this->setError($error); } } if (isset($this->_item->created_by)) { $this->_item->created_by = JFactory::getUser($this->_item->created_by)->name; } return $this->_item; }
/** * Method to get an ojbect. * * @param integer The id of the object to get. * * @return mixed Object on success, false on failure. FIGYELEM!!! alternativák tömb is!!!!! */ public function &getItem($id = null) { $db = JFactory::getDBO(); if ($this->_item === null) { $this->_item = false; if (empty($id)) { $id = $this->getState('alternativak.id'); } // Get a level row instance. $table = JTable::getInstance('Alternativak', 'Table'); // Attempt to load the row. if ($id == null | $id == 0) { // rekord init felvitelhez $user = JFactory::getUser(); $this->_item = new stdclass(); $this->_item->id = 0; $this->_item->megnevezes = ''; $this->_item->leiras = ''; $this->_item->temakor_id = JRequest::getVar('temakor', 0); $this->_item->szavazas_id = JRequest::getVar('szavazas', 0); $this->_item->letrehozo = $user->id; $this->_item->letrehozva = date('Y-m-d H:i:s'); } else { if ($table->load($id)) { // Convert the JTable to a clean JObject. $this->_item = JArrayHelper::toObject($table->getProperties(1), 'JObject'); } else { if ($error = $table->getError()) { $this->setError($error); } } } } return $this->_item; }
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]); }
/** * 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; }
/** * Method to get an ojbect. * * @param integer 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('user.id'); } // Get a level row instance. $table = $this->getTable(); // Attempt to load the row. if ($table !== false && $table->load($id)) { $user = JFactory::getUser(); $id = $table->id; $canEdit = $user->authorise('core.edit', 'com_db8download') || $user->authorise('core.create', 'com_db8download'); if (!$canEdit && $user->authorise('core.edit.own', 'com_db8download')) { $canEdit = $user->id == $table->created_by; } if (!$canEdit) { throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 500); } // 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 = JArrayHelper::toObject($properties, 'JObject'); } } return $this->_item; }
/** * Enable auto-update. * * @throws Exception * @return void */ public function enableau() { // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $redirectOptions = array("view" => "urls"); $cid = $this->input->post->get("cid", array(), "array"); $cid = Joomla\Utilities\ArrayHelper::toInteger($cid); $data = array('enableau' => 1, 'disableau' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($data, $task, 0, 'int'); if (empty($cid)) { $this->displayNotice(JText::_($this->text_prefix . '_ERROR_NO_ITEM_SELECTED'), $redirectOptions); return; } try { $model = $this->getModel(); $model->updateAutoupdate($cid, $value); } catch (Exception $e) { JLog::add($e->getMessage()); throw new Exception(JText::_('COM_ITPMETA_ERROR_SYSTEM')); } if ($value == 1) { $msg = $this->text_prefix . '_N_ITEMS_AUTOUPDATE_ENABLED'; } else { $msg = $this->text_prefix . '_N_ITEMS_AUTOUPDATE_DISABLED'; } $this->displayMessage(JText::plural($msg, count($cid)), $redirectOptions); }
/** * Method to get a single record. * * @param integer $pk The id of the primary key. * * @return mixed Object on success, false on failure. * * @since 1.6 */ public function getItem($pk = null) { $pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id'); $table = $this->getTable(); if ($pk > 0) { // Attempt to load the row. $return = $table->load($pk); // Check for a table object error. if ($return === false && $table->getError()) { $this->setError($table->getError()); return false; } } // Convert to the JObject before adding other data. $properties = $table->getProperties(1); $item = JArrayHelper::toObject($properties, 'JObject'); if (property_exists($item, 'params')) { $registry = new JRegistry(); $registry->loadString($item->params); $item->params = $registry->toArray(); } if (property_exists($item, 'order_params')) { $registry = new JRegistry(); $registry->loadString($item->order_params); $item->order_params = $registry->toArray(); } return $item; }
/** * Overloaded bind function to pre-process the params. * * @param array Named array * * @return null|string null is operation was satisfactory, otherwise returns an error * @see JTable::bind */ public function bind($array, $ignore = '') { // For Fields group // Convert jform[fields_group][field] to jform[field] or JTable cannot bind data. // ========================================================================================== $data = array(); $array = AKHelper::_('array.pivotFromTwoDimension', $array); // Set field['param_xxx'] to params // ========================================================================================== if (empty($array['params'])) { $array['params'] = AKHelper::_('array.pivotFromPrefix', 'param_', $array, JArrayHelper::getValue($array, 'params', array())); } // Set params to JRegistry // ========================================================================================== if (isset($array['params']) && is_array($array['params'])) { $registry = new JRegistry(); $registry->loadArray($array['params']); $array['params'] = (string) $registry; } // Bind the rules. // ========================================================================================== if (isset($array['rules']) && is_array($array['rules'])) { $rules = new JAccessRules($array['rules']); $this->setRules($rules); } return parent::bind($array, $ignore); }