function onJ2StoreGetReportExported($row) { $app = JFactory::getApplication(); $ignore_column = array('sum', 'count', 'orderitem_quantity', 'product_source_id', 'id'); $this->includeCustomModel('Reportitemised'); if (!$this->_isMe($row)) { return null; } $model = F0FModel::getTmpInstance('ReportItemised', 'J2StoreModel'); $items = $model->getData(); foreach ($items as &$item) { $item->orderitem_options = ''; if (isset($item->orderitem_attributes) && $item->orderitem_attributes) { foreach ($item->orderitem_attributes as $attr) { unset($item->orderitem_attributes); $item->orderitem_options .= $attr->orderitemattribute_name . ' : ' . $attr->orderitemattribute_value; } } $item->qty = $item->sum; $item->total_purchase = $item->count; foreach ($ignore_column as $key => $value) { unset($item->{$value}); } } return $items; }
/** * Initialize the user data * * @return bool */ public function onBeforeBrowse() { // Make sure there's a logged in user, or ask him to log in if (JFactory::getUser()->guest) { $returnURL = base64_encode(JFactory::getURI()->toString()); $comUsers = 'com_users'; $url = JRoute::_('index.php?option=' . $comUsers . '&view=login&return=' . $returnURL); JFactory::getApplication()->redirect($url); } $view = $this->getThisView(); $model = $this->getThisModel(); // Get the user model and load the user data $userparams = F0FModel::getTmpInstance('Users', 'AkeebasubsModel')->user_id(JFactory::getUser()->id)->getMergedData(JFactory::getUser()->id); $view->assign('userparams', $userparams); $cache = (array) $model->getData(); if ($cache['firstrun']) { foreach ($cache as $k => $v) { if (empty($v)) { if (property_exists($userparams, $k)) { $cache[$k] = $userparams->{$k}; } } } } $view->assign('cache', (array) $cache); $view->assign('validation', $model->getValidation()); return true; }
/** * onAdd. * * @param string $tpl Param * * @return void */ public function onAdd($tpl = null) { $result = parent::onAdd($tpl); Extly::loadAwesome(); $file = EHtml::getRelativeFile('js', 'com_autotweet/channel.min.js'); if ($file) { $dependencies = array(); $dependencies['channel'] = array('extlycore'); Extly::initApp(CAUTOTWEETNG_VERSION, $file, $dependencies); } $postsModel = F0FModel::getTmpInstance('Posts', 'AutoTweetModel'); $postsModel->set('pubstate', array(AutotweetPostHelper::POST_SUCCESS, AutotweetPostHelper::POST_ERROR)); $postsModel->set('channel', $this->item->id); $postsModel->set('filter_order', 'id'); $postsModel->set('filter_order_Dir', 'DESC'); $postsModel->set('limit', 1); $posts = $postsModel->getItemList(); $alert_message = ''; $alert_style = 'alert-info'; if (count($posts) > 0) { $lastpost = $posts[0]; if ($lastpost->pubstate == AutotweetPostHelper::POST_ERROR) { $alert_style = 'alert-error'; } $alert_message = $lastpost->postdate . ' - ' . JText::_($lastpost->resultmsg); } $this->assign('alert_message', $alert_message); $this->assign('alert_style', $alert_style); return $result; }
private function formatInvTempLevels($ids) { if (empty($ids)) { return JText::_('COM_AKEEBASUBS_COMMON_LEVEL_ALL'); } if (empty($ids)) { return JText::_('COM_AKEEBASUBS_COMMON_LEVEL_NONE'); } if (!is_array($ids)) { $ids = explode(',', $ids); } static $levels; if (empty($levels)) { $levelsList = F0FModel::getTmpInstance('Levels', 'AkeebasubsModel')->getItemList(true); if (!empty($levelsList)) { foreach ($levelsList as $level) { $levels[$level->akeebasubs_level_id] = $level->title; } } $levels[-1] = JText::_('COM_AKEEBASUBS_COMMON_LEVEL_NONE'); $levels[0] = JText::_('COM_AKEEBASUBS_COMMON_LEVEL_ALL'); } $ret = array(); foreach ($ids as $id) { if (array_key_exists($id, $levels)) { $ret[] = $levels[$id]; } else { $ret[] = '—'; } } return implode(', ', $ret); }
/** * Returns the payment form to be submitted by the user's browser. The form must have an ID of * "paymentForm" and a visible submit button. * * @param string $paymentmethod * @param JUser $user * @param AkeebasubsTableLevel $level * @param AkeebasubsTableSubscription $subscription * @return string */ public function onAKPaymentNew($paymentmethod, $user, $level, $subscription) { if ($paymentmethod != $this->ppName) { return false; } // Set the payment status to Pending $oSub = F0FModel::getTmpInstance('Subscriptions', 'AkeebasubsModel')->setId($subscription->akeebasubs_subscription_id)->getItem(); $updates = array('state' => 'P', 'enabled' => 0, 'processor_key' => md5(time())); $oSub->save($updates); // Activate the user account, if the option is selected $activate = $this->params->get('activate', 0); if ($activate && $user->block) { $updates = array('block' => 0, 'activation' => ''); $user->bind($updates); $user->save($updates); } // Render the HTML form $nameParts = explode(' ', $user->name, 2); $firstName = $nameParts[0]; if (count($nameParts) > 1) { $lastName = $nameParts[1]; } else { $lastName = ''; } $html = $this->params->get('instructions', ''); if (empty($html)) { $html = <<<ENDTEMPLATE <p>Dear Sir/Madam,<br/> In order to complete your payment, please deposit {AMOUNT}€ to our bank account:</p> <p> <b>IBAN</b>: XX00.000000.00000000.00000000<br/> <b>BIC</b>: XXXXXXXX </p> <p>Please reference subscription code {SUBSCRIPTION} in your payment. Make sure that any bank charges are paid by you in full and not deducted from the transferred amount. If you're using e-Banking to transfer the funds, please select the "OUR" bank expenses option.</p> <p>Thank you in advance,<br/> The management</p> ENDTEMPLATE; } $html = str_replace('{AMOUNT}', sprintf('%01.02f', $subscription->gross_amount), $html); $html = str_replace('{SUBSCRIPTION}', sprintf('%06u', $subscription->akeebasubs_subscription_id), $html); $html = str_replace('{FIRSTNAME}', $firstName, $html); $html = str_replace('{LASTNAME}', $lastName, $html); $html = str_replace('{LEVEL}', $level->title, $html); // Get a preloaded mailer $mailer = AkeebasubsHelperEmail::getPreloadedMailer($subscription, 'plg_akeebasubs_subscriptionemails_offline'); // Replace custom [INSTRUCTIONS] tag $body = str_replace('[INSTRUCTIONS]', $html, $mailer->Body); $mailer->setBody($body); if ($mailer !== false) { $mailer->addRecipient($user->email); $result = $mailer->Send(); $mailer = null; } @(include_once JPATH_SITE . '/components/com_akeebasubs/helpers/message.php'); if (class_exists('AkeebasubsHelperMessage')) { $html = AkeebasubsHelperMessage::processLanguage($html); } $html = '<div>' . $html . '</div>'; return $html; }
protected function onAdd($tpl = null) { /** @var AkeebaModelCpanels $model */ $model = $this->getModel(); $aeconfig = Factory::getConfiguration(); // Load the helper classes $this->loadHelper('utils'); $this->loadHelper('status'); $statusHelper = AkeebaHelperStatus::getInstance(); // Load the model if (!class_exists('AkeebaModelStatistics')) { JLoader::import('models.statistics', JPATH_COMPONENT_ADMINISTRATOR); } $statmodel = new AkeebaModelStatistics(); $this->profileid = $model->getProfileID(); // Active profile ID $this->profilelist = $model->getProfilesList(); // List of available profiles $this->statuscell = $statusHelper->getStatusCell(); // Backup status $this->detailscell = $statusHelper->getQuirksCell(); // Details (warnings) $this->statscell = $statmodel->getLatestBackupDetails(); $this->fixedpermissions = $model->fixMediaPermissions(); // Fix media/com_akeeba permissions $this->needsdlid = $model->needsDownloadID(); $this->needscoredlidwarning = $model->mustWarnAboutDownloadIDInCore(); $this->extension_id = $model->getState('extension_id', 0, 'int'); // Should I ask for permission to display desktop notifications? JLoader::import('joomla.application.component.helper'); $this->desktop_notifications = \Akeeba\Engine\Util\Comconfig::getValue('desktop_notifications', '0') ? 1 : 0; $this->statsIframe = F0FModel::getTmpInstance('Stats', 'AkeebaModel')->collectStatistics(true); return $this->onDisplay($tpl); }
/** * Method to save data * (non-PHPdoc) * @see F0FController::save() */ public function save() { //security check JSession::checkToken() or die('Invalid Token'); $app = JFactory::getApplication(); $model = $this->getModel('configurations'); $data = $app->input->getArray($_POST); $task = $this->getTask(); $token = JSession::getFormToken(); unset($data['option']); unset($data['task']); unset($data['view']); unset($data[$token]); if ($task == 'populatedata') { $this->getPopulatedData($data); } $db = JFactory::getDbo(); $config = J2Store::config(); $query = 'REPLACE INTO #__j2store_configurations (config_meta_key,config_meta_value) VALUES '; jimport('joomla.filter.filterinput'); $filter = JFilterInput::getInstance(null, null, 1, 1); $conditions = array(); foreach ($data as $metakey => $value) { if (is_array($value)) { $value = implode(',', $value); } //now clean up the value if ($metakey == 'store_billing_layout' || $metakey == 'store_shipping_layout' || $metakey == 'store_payment_layout') { $value = $app->input->get($metakey, '', 'raw'); $clean_value = $filter->clean($value, 'html'); } else { $clean_value = $filter->clean($value, 'string'); } $config->set($metakey, $clean_value); $conditions[] = '(' . $db->q(strip_tags($metakey)) . ',' . $db->q($clean_value) . ')'; } $query .= implode(',', $conditions); try { $db->setQuery($query); $db->execute(); //update currencies F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->updateCurrencies(false); $msg = JText::_('J2STORE_CHANGES_SAVED'); } catch (Exception $e) { $msg = $e->getMessage(); $msgType = 'Warning'; } switch ($task) { case 'apply': $url = 'index.php?option=com_j2store&view=configuration'; break; case 'populatedata': $url = 'index.php?option=com_j2store&view=configuration'; break; case 'save': $url = 'index.php?option=com_j2store&view=cpanels'; break; } $this->setRedirect($url, $msg, $msgType); }
/** * Gets the level ID out of a level title. If an ID was passed, it simply returns the ID. * If a non-existent subscription level is passed, it returns -1. * * @param $title string|int The subscription level title or ID * * @return int The subscription level ID */ private static function getId($title, $slug = false) { static $levels = null; static $slugs = null; static $upperSlugs = null; // Don't process invalid titles if (empty($title)) { return -1; } // Fetch a list of subscription levels if we haven't done so already if (is_null($levels)) { $levels = array(); $slugs = array(); $upperSlugs = array(); $list = F0FModel::getTmpInstance('Levels', 'AkeebasubsModel')->getList(); if (count($list)) { foreach ($list as $level) { $thisTitle = strtoupper($level->title); $levels[$thisTitle] = $level->akeebasubs_level_id; $slugs[$thisTitle] = $level->slug; $upperSlugs[strtoupper($level->slug)] = $level->slug; } } } $title = strtoupper($title); if (array_key_exists($title, $levels)) { // Mapping found return $slug ? $slugs[$title] : $levels[$title]; } elseif (array_key_exists($title, $upperSlugs)) { $mySlug = $upperSlugs[$title]; if ($slug) { return $mySlug; } else { foreach ($slugs as $t => $s) { if ($s = $mySlug) { return $levels[$t]; } } return -1; } } elseif ((int) $title == $title) { $id = (int) $title; $title = ''; // Find the title from the ID foreach ($levels as $t => $lid) { if ($lid == $id) { $title = $t; break; } } if (empty($title)) { return $slug ? '' : -1; } else { return $slug ? $slugs[$title] : $levels[$title]; } } else { // No match! return $slug ? '' : -1; } }
protected function onAfterGetItem(&$record) { $record->taxrates = F0FModel::getTmpInstance('Taxrates', 'J2StoreModel')->enabled(1)->getList(); if ($record->j2store_taxprofile_id) { $record->taxrules = F0FModel::getTmpInstance('Taxrules', 'J2StoreModel')->taxprofile_id($record->j2store_taxprofile_id)->getList(); } }
protected function onBeforeBrowse() { $db = JFactory::getDbo(); $config = J2Store::config(); $installation_complete = $config->get('installation_complete', 0); if (!$installation_complete) { //installation not completed JFactory::getApplication()->redirect('index.php?option=com_j2store&view=postconfig'); } //first check if the currency table has a default records at least. $rows = F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->enabled(1)->getList(); if (count($rows) < 1) { //no records found. Dumb default data F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->create_currency_by_code('USD', 'USD'); } //update schema $dbInstaller = new F0FDatabaseInstaller(array('dbinstaller_directory' => JPATH_ADMINISTRATOR . '/components/com_j2store/sql/xml')); $dbInstaller->updateSchema(); //update cart table $cols = $db->getTableColumns('#__j2store_carts'); $cols_to_delete = array('product_id', 'vendor_id', 'variant_id', 'product_type', 'product_options', 'product_qty'); foreach ($cols_to_delete as $key) { if (array_key_exists($key, $cols)) { $db->setQuery('ALTER TABLE #__j2store_carts DROP COLUMN ' . $key); try { $db->execute(); } catch (Exception $e) { echo $e->getMessage(); } } } return parent::onBeforeBrowse(); }
public function onAdd($tpl = null) { AkeebaStrapper::addJSfile('media://com_akeeba/js/configuration.js'); $media_folder = JUri::base() . '../media/com_akeeba/'; // Get a JSON representation of GUI data $json = AkeebaHelperEscape::escapeJS(Factory::getEngineParamsProvider()->getJsonGuiDefinition(), '"\\'); $this->json = $json; // Get profile ID $profileid = Platform::getInstance()->get_active_profile(); $this->profileid = $profileid; // Get profile name $profile = F0FModel::getTmpInstance('Profiles', 'AkeebaModel')->setId($profileid)->getItem(); $this->profilename = $this->escape($profile->description); $this->quickicon = (int) $profile->quickicon; // Get the root URI for media files $this->mediadir = AkeebaHelperEscape::escapeJS($media_folder . 'theme/'); // Are the settings secured? if (Platform::getInstance()->get_platform_configuration_option('useencryption', -1) == 0) { $this->securesettings = -1; } elseif (!Factory::getSecureSettings()->supportsEncryption()) { $this->securesettings = 0; } else { JLoader::import('joomla.filesystem.file'); $filename = JPATH_COMPONENT_ADMINISTRATOR . '/engine/serverkey.php'; if (JFile::exists($filename)) { $this->securesettings = 1; } else { $this->securesettings = 0; } } }
/** * Get the information for the latest backup * * @return array|null An array of backup record information or null if there is no usable backup for site transfer */ public function getLatestBackupInformation() { // Initialise $ret = null; $db = Factory::getDatabase(); /** @var AkeebaModelStatistics $model */ $model = F0FModel::getTmpInstance('Statistics', 'AkeebaModel'); $model->savestate(0); $model->setState('limitstart', 0); $model->setState('limit', 1); $backups = $model->getStatisticsListWithMeta(false, null, $db->qn('id') . ' DESC'); // No valid backups? No joy. if (empty($backups)) { return $ret; } // Get the latest backup $backup = array_shift($backups); // If it's not stored on the server (e.g. remote backup), no joy. if ($backup['meta'] != 'ok') { return $ret; } // If it's not a full site backup, no joy. if ($backup['type'] != 'full') { return $ret; } return $backup; }
public function updateinfo() { /** @var AdmintoolsModelUpdates $updateModel */ $updateModel = F0FModel::getTmpInstance('Updates', 'AdmintoolsModel'); $updateInfo = (object) $updateModel->getUpdates(); $result = ''; if ($updateInfo->hasUpdate) { $strings = array('header' => JText::sprintf('COM_ADMINTOOLS_CPANEL_MSG_UPDATEFOUND', $updateInfo->version), 'button' => JText::sprintf('COM_ADMINTOOLS_CPANEL_MSG_UPDATENOW', $updateInfo->version), 'infourl' => $updateInfo->infoURL, 'infolbl' => JText::_('COM_ADMINTOOLS_CPANEL_MSG_MOREINFO')); $result = <<<ENDRESULT \t<div class="alert alert-warning"> \t\t<h3> \t\t\t<span class="icon icon-exclamation-sign glyphicon glyphicon-exclamation-sign"></span> \t\t\t{$strings['header']} \t\t</h3> \t\t<p> \t\t\t<a href="index.php?option=com_installer&view=update" class="btn btn-primary"> \t\t\t\t{$strings['button']} \t\t\t</a> \t\t\t<a href="{$strings['infourl']}" target="_blank" class="btn btn-small btn-info"> \t\t\t\t{$strings['infolbl']} \t\t\t</a> \t\t</p> \t</div> ENDRESULT; } echo '###' . $result . '###'; // Cut the execution short JFactory::getApplication()->close(); }
public function cancel() { // Makes sure SiteGround's SuperCache doesn't cache the subscription page JResponse::setHeader('X-Cache-Control', 'False', true); $msg = null; $type = null; $subid = $this->input->getInt('sid'); // No subscription id? Let's stop here if (!$subid) { $url = 'index.php'; $msg = JText::_('COM_AKEEBASUBS_SUBSCRIPTIONS_FAILED_CANCELLING'); $type = 'error'; } else { $sub = F0FModel::getTmpInstance('Subscriptions', 'AkeebasubsModel')->getTable(); $sub->load($subid); $level = F0FModel::getTmpInstance('Levels', 'AkeebasubsModel')->getTable(); $level->load($sub->akeebasubs_level_id); $url = JRoute::_('index.php?option=com_akeebasubs&view=message&slug=' . $level->slug . '&layout=cancel&subid=' . $subid); $result = F0FModel::getTmpInstance('Subscribes', 'AkeebasubsModel')->paymentmethod($this->input->getCmd('paymentmethod', 'none'))->runCancelRecurring(); if (!$result) { $msg = JText::_('COM_AKEEBASUBS_SUBSCRIPTIONS_FAILED_CANCELLING'); $type = 'error'; } } $this->setRedirect($url, $msg, $type); }
public function deleteChildren($oid) { $status = true; //should delete geozonerules $geozonerules = F0FModel::getTmpInstance('GeozoneRules', 'J2StoreModel')->geozone_id($oid)->getList(); $geozonerule = F0FTable::getAnInstance('GeozoneRule', 'J2StoreTable'); if (isset($geozonerules) && count($geozonerules)) { foreach ($geozonerules as $grule) { if (!$geozonerule->delete($grule->j2store_geozonerule_id)) { $status = false; } } } if ($status) { // delete taxrate and also related taxprofile rules... $taxrates = F0FModel::getTmpInstance('Taxrates', 'J2StoreModel')->geozone_id($oid)->getList(); $taxrate = F0FTable::getAnInstance('Taxrate', 'J2StoreTable'); if (isset($taxrates) && count($taxrates)) { foreach ($taxrates as $trate) { if (!$taxrate->delete($trate->j2store_taxrate_id)) { $status = false; } } } } return $status; }
public function onAfterGetItem(&$record) { if (isset($record->j2store_geozone_id) && !empty($record->j2store_geozone_id)) { $record->geoRuleList = $this->getGeoZoneRules($record->j2store_geozone_id); } $record->countryList = F0FModel::getTmpInstance('Countries', 'J2StoreModel')->enabled(1)->getList(); }
public function import() { $app = JFactory::getApplication(); $model = F0FModel::getTmpInstance('Imports', 'AkeebasubsModel'); $file = JRequest::getVar('csvfile', '', 'FILES'); $delimiter = $this->input->getInt('csvdelimiters', 0); $field = $this->input->getString('field_delimiter', ''); $enclosure = $this->input->getString('field_enclosure', ''); if ($file['error']) { $this->setRedirect('index.php?option=com_akeebasubs&view=import', JText::_('COM_AKEEBASUBS_IMPORT_ERR_UPLOAD'), 'error'); return true; } if ($delimiter != -99) { list($field, $enclosure) = $model->decodeDelimiterOptions($delimiter); } // Import ok, but maybe I have warnings (ie skipped lines) $result = $model->import($file['tmp_name'], $field, $enclosure); if ($result !== false) { $errors = $model->getErrors(); if ($errors) { $app->enqueueMessage(JText::_('COM_AKEEBASUBS_IMPORT_WITH_WARNINGS'), 'notice'); foreach ($errors as $error) { $app->enqueueMessage($error, 'notice'); } } else { // Import ok, congrat with yourself! $app->enqueueMessage(JText::sprintf('COM_AKEEBASUBS_IMPORT_OK', $result)); } } else { //Uh oh... import failed, let's inform the user why it happened $app->enqueueMessage(JText::sprintf('COM_AKEEBASUBS_IMPORT_FAIL', $model->getError()), 'error'); } $this->setRedirect('index.php?option=com_akeebasubs&view=import'); }
public function onAdd($tpl = null) { $media_folder = JURI::base() . '../media/com_akeeba/'; // Get a JSON representation of GUI data $json = AkeebaHelperEscape::escapeJS(AEUtilInihelper::getJsonGuiDefinition(), '"\\'); $this->json = $json; // Get profile ID $profileid = AEPlatform::getInstance()->get_active_profile(); $this->profileid = $profileid; // Get profile name $profileName = F0FModel::getTmpInstance('Profiles', 'AkeebaModel')->setId($profileid)->getItem()->description; $this->profilename = $profileName; // Get the root URI for media files $this->mediadir = AkeebaHelperEscape::escapeJS($media_folder . 'theme/'); // Are the settings secured? if (AEPlatform::getInstance()->get_platform_configuration_option('useencryption', -1) == 0) { $this->securesettings = -1; } elseif (!AEUtilSecuresettings::supportsEncryption()) { $this->securesettings = 0; } else { JLoader::import('joomla.filesystem.file'); $filename = JPATH_COMPONENT_ADMINISTRATOR . '/akeeba/serverkey.php'; if (JFile::exists($filename)) { $this->securesettings = 1; } else { $this->securesettings = 0; } } // Add live help AkeebaHelperIncludes::addHelp('config'); }
/** * addTargetArguments. * * @param array &$arguments Params * @param int $target_id Params * * @return void */ protected function addTargetArguments(&$arguments, $target_id) { $target = F0FModel::getTmpInstance('Targets', 'AutoTweetModel')->getItem($target_id); $criterias = $target->xtform->toArray(); if (is_array($criterias)) { $targeting = array(); foreach ($criterias as $key => $criteria) { $fbkey = str_replace('fb', '', $key); $criteria = urldecode($criteria); $criteria = json_decode($criteria); if (!array_key_exists($fbkey, $targeting)) { $targeting[$fbkey] = array(); } $value = $criteria->criteriaValue; if (empty($value)) { $value = $criteria->criteriaValueText; } $targeting[$fbkey][] = $value; } if ($targeting) { $arguments['targeting'] = json_encode($targeting); } } $logger = AutotweetLogger::getInstance(); $logger->log(JLog::INFO, 'Targeting', $arguments); }
/** * Method * @return boolean */ function elements() { $geozone_id = $this->input->getInt('geozone_id'); $model = F0FModel::getTmpInstance('Countries', 'J2StoreModel'); $filter = array(); $filter['limit'] = $this->input->getInt('limit', 20); $filter['limitstart'] = $this->input->getInt('limitstart'); $filter['search'] = $this->input->getString('search', ''); $filter['country_name'] = $this->input->getString('country_name', ''); foreach ($filter as $key => $value) { $model->setState($key, $value); } if (isset($geozone_id) && $geozone_id) { $view = $this->getThisView(); $state = $model->getState(); $view->setModel($this->getThisModel(), true); $view->assign('countries', $model->enabled(1)->country_name($filter['country_name'])->getItemList()); $view->assign('pagination', $model->getPagination()); $view->assign('geozone_id', $geozone_id); $view->assign('state', $model->getState()); $view->setLayout('modal'); $view->display(); } else { return false; } }
/** * Get the rendering of this field type for a repeatable (grid) display, * e.g. in a view listing many item (typically a "browse" task) * * @since 2.0 * * @return string The field HTML */ public function getRepeatable() { static $extensions = null; if (is_null($extensions)) { $extensions = F0FModel::getTmpInstance('Invoices', 'AkeebasubsModel')->getExtensions(); } $html = ''; if ($this->item->extension == 'akeebasubs') { $html .= '<a href="index.php?option=com_akeebasubs&view=invoices&task=read&id=' . htmlspecialchars($this->item->akeebasubs_subscription_id, ENT_COMPAT, 'UTF-8') . '&tmpl=component" class="btn btn-info modal" rel="{handler: \'iframe\', size: {x: 800, y: 500}}" title="' . JText::_('COM_AKEEBASUBS_INVOICES_ACTION_PREVIEW') . '"><span class="icon icon-file icon-white"></span></a>' . "\n"; $html .= '<a href="index.php?option=com_akeebasubs&view=invoices&task=download&id=' . htmlspecialchars($this->item->akeebasubs_subscription_id, ENT_COMPAT, 'UTF-8') . '" class="btn btn-primary" title="' . JText::_('COM_AKEEBASUBS_INVOICES_ACTION_DOWNLOAD') . '"><span class="icon icon-download-alt icon-white"></span></a>' . "\n"; $html .= '<a href="index.php?option=com_akeebasubs&view=invoices&task=send&id=' . htmlentities($this->item->akeebasubs_subscription_id, ENT_COMPAT, 'UTF-8') . '" class="btn btn-success" title="' . JText::_('COM_AKEEBASUBS_INVOICES_ACTION_RESEND') . '"><span class="icon icon-envelope icon-white"></span></a>' . "\n"; $db = JFactory::getDbo(); if (empty($this->item->sent_on) || $this->item->sent_on == $db->getNullDate()) { $html .= '<span class="label"><span class="icon icon-white icon-warning-sign"></span>' . JText::_('COM_AKEEBASUBS_INVOICES_LBL_NOTSENT') . '</span>' . "\n"; } else { $html .= '<span class="label label-success"><span class="icon icon-white icon-ok"></span>' . JText::_('COM_AKEEBASUBS_INVOICES_LBL_SENT') . '</span>' . "\n"; } $html .= '<a href="index.php?option=com_akeebasubs&view=invoices&task=generate&id=' . htmlentities($this->item->akeebasubs_subscription_id, ENT_COMPAT, 'UTF-8') . '" class="btn btn-mini btn-warning" title="' . JText::_('COM_AKEEBASUBS_INVOICES_ACTION_REGENERATE') . '"><span class="icon icon-retweet icon-white"></span></a>' . "\n"; } elseif (array_key_exists($this->item->extension, $extensions)) { $html .= '<a class="btn" href="' . sprintf($extensions[$this->item->extension]['backendurl'], $this->item->invoice_no) . '"><span class="icon icon-share-alt"></span>' . JText::_('COM_AKEEBASUBS_INVOICES_LBL_OPENEXTERNAL') . '</a>' . "\n"; } else { $html .= '<span class="label">' . JText::_('COM_AKEEBASUBS_INVOICES_LBL_NOACTIONS') . '</span>' . "\n"; } return $html; }
public function &getItem($id = null) { $user = JFactory::getUser(); $this->record = F0FTable::getAnInstance('Vendoruser', 'J2StoreTable'); $this->record->load($user->id); $this->record->products = F0FModel::getTmpInstance('Products', 'J2StoreModel')->vendor_id($this->record->j2store_vendor_id)->enabled(1)->getList(); return $this->record; }
protected function onBeforeSave(&$data, &$table) { $country = F0FModel::getTmpInstance('Countries', 'J2StoreModel')->getItem($data['country_id']); $data['country_name'] = $country->country_name; $zone = F0FModel::getTmpInstance('zones', 'J2StoreModel')->getItem($data['zone_id']); $data['zone_name'] = $zone->zone_name; return true; }
public function autoupdate() { $return = array('message' => ''); // First of all let's check if there are any updates $updateInfo = (object) $this->getUpdates(true); // There are no updates, there's no point in continuing if (!$updateInfo->hasUpdate) { return array('message' => array("No available updates found")); } $return['message'][] = "Update detected, version: " . $updateInfo->version; // Ok, an update is found, what should I do? $params = JComponentHelper::getParams('com_admintools'); $autoupdate = $params->get('autoupdateCli', 1); // Let's notifiy the user if ($autoupdate == 1 || $autoupdate == 2) { $email = $params->get('notificationEmail'); if (!$email) { $return['message'][] = "There isn't an email for notifications, no notification will be sent."; } else { // Ok, I can send it out, but before let's check if the user set any frequency limit $numfreq = $params->get('notificationFreq', 1); $freqtime = $params->get('notificationTime', 'day'); $lastSend = $this->getLastSend(); $shouldSend = false; if (!$numfreq) { $shouldSend = true; } else { $check = strtotime('-' . $numfreq . ' ' . $freqtime); if ($lastSend < $check) { $shouldSend = true; } else { $return['message'][] = "Frequency limit hit, I won't send any email"; } } if ($shouldSend) { if ($this->sendNotificationEmail($updateInfo->version, $email)) { $return['message'][] = "E-mail(s) correctly sent"; } else { $return['message'][] = "An error occurred while sending e-mail(s). Please double check your settings"; } $this->setLastSend(); } } } // Let's download and install the latest version if ($autoupdate == 1 || $autoupdate == 3) { // DO NOT REMOVE THIS. Since we have a plural class name (AdmintoolsModelCpanels) in a singular file (cpanel.php) // we have to do this trick in order to load the correct file $t = F0FModel::getTmpInstance('Cpanel', 'AdmintoolsModel'); if (F0FModel::getTmpInstance('Cpanels', 'AdmintoolsModel')->needsDownloadID()) { $return['message'][] = "You have to enter the DownloadID in order to update your pro version"; } else { $return['message'][] = $this->updateComponent(); } } return $return; }
/** * onBeforeBrowse * * @return void */ public function onBeforeBrowse() { $result = parent::onBeforeBrowse(); if ($result) { // Run the automatic update site refresh $updateModel = F0FModel::getTmpInstance('LiveUpdates', 'AutoTweetModel'); $updateModel->refreshUpdateSite(); } return $result; }
/** * Runs before rendering the view template, echoing HTML to put before the * view template's generated HTML * * @return void */ protected function preRender() { parent::preRender(); if (!AUTOTWEETNG_FREE) { $cron_enabled = EParameter::getComponentParam(CAUTOTWEETNG, 'cron_enabled'); if (!$cron_enabled && F0FModel::getTmpInstance('Channels', 'AutoTweetModel')->getTotal() > self::CHANNELS_PAGE_LOAD_LIMIT) { echo JText::_('COM_AUTOTWEET_LBL_CHANNELS_TOOMANY_NOTCRON'); } } }
/** * Method to check any product is associated with this taxprofile id * @param int $oid * @return boolean */ private function isProductAssociated($oid) { $status = true; $model = F0FModel::getTmpInstance('Products', 'J2StoreModel'); $items = $model->taxprofile_id($oid)->getList(); if (isset($items) && count($items)) { $status = false; } return $status; }
private function isProductAssociated($oid) { $status = true; $model = F0FModel::getTmpInstance('Products', 'J2StoreModel'); $items = $model->vendor_id($oid)->getList(); if (isset($items) && count($items)) { // will return null and stop deleting vendor $status = false; } return $status; }
protected function getOptions() { static $options = null; if (is_null($options)) { $rows = F0FModel::getTmpInstance('Levels', 'AkeebasubsModel')->getList(true); foreach ($rows as $row) { $options[] = JHTML::_('select.option', $row->akeebasubs_level_id, $row->title); } } return $options; }
/** * Finds the applicable tax rule for a given set of parameters * * @param int $akeebasubs_level_id The subscription level to get the rule for. 0 looks for "All levels" rules. * @param string $country The country code, e.g. 'DE' for Germany * @param string $state The state of the client * @param string $city The city of the client * @param int $vies Is the user VIES-registered? * * @return object Information object. The taxrate property has the effective tax rate in percentage points. */ public function getTaxRule($akeebasubs_level_id = 0, $country = 'XX', $state = '', $city = '', $vies = 0) { $hash = (int) $akeebasubs_level_id . '_' . strtoupper($country) . '_' . strtoupper($state) . '_' . strtoupper($city) . '_' . (int) $vies; if (!array_key_exists($hash, self::$cachedTaxRates)) { // First try loading the rules for this level $taxrules = F0FModel::getTmpInstance('Taxrules', 'AkeebasubsModel')->savestate(0)->enabled(1)->akeebasubs_level_id($akeebasubs_level_id)->filter_order('ordering')->filter_order_Dir('ASC')->limit(0)->limitstart(0)->getList(); // If this level has no rules use the "All levels" rules if (empty($taxrules) && $akeebasubs_level_id != 0) { self::$cachedTaxRates[$hash] = $this->getTaxRule(0, $country, $state, $city, $vies); return self::$cachedTaxRates[$hash]; } $bestTaxRule = (object) array('match' => 0, 'fuzzy' => 0, 'taxrate' => 0, 'id' => 0); if (empty($taxrules)) { return $bestTaxRule; } foreach ($taxrules as $rule) { // For each rule, get the match and fuzziness rating. The best, least fuzzy and last match wins. $match = 0; $fuzzy = 0; if (empty($rule->country)) { $match++; $fuzzy++; } elseif ($rule->country == $country) { $match++; } if (empty($rule->state)) { $match++; $fuzzy++; } elseif ($rule->state == $state) { $match++; } if (empty($rule->city)) { $match++; $fuzzy++; } elseif (strtolower(trim($rule->city)) == strtolower(trim($city))) { $match++; } if ($rule->vies && $vies || !$rule->vies && !$vies) { $match++; } if ($match > $bestTaxRule->match || $bestTaxRule->match == $match && $fuzzy < $bestTaxRule->fuzzy) { if ($match == 0) { continue; } $bestTaxRule->match = $match; $bestTaxRule->fuzzy = $fuzzy; $bestTaxRule->taxrate = $rule->taxrate; $bestTaxRule->id = $rule->akeebasubs_taxrule_id; } } self::$cachedTaxRates[$hash] = $bestTaxRule; } return self::$cachedTaxRates[$hash]; }