Exemplo n.º 1
0
 /**
  * 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;
     }
 }
Exemplo n.º 2
0
 public function save($data)
 {
     $app = JFactory::getApplication();
     $task = $app->input->getString('task');
     if ($task == 'saveorder') {
         return parent::save($data);
     }
     if (parent::save($data)) {
         if (isset($this->otable->j2store_filtergroup_id)) {
             if (isset($data['filter_value']) && count($data['filter_value'])) {
                 $ovTable = F0FTable::getInstance('filter', 'J2StoreTable');
                 $status = true;
                 foreach ($data['filter_value'] as $filtervalue) {
                     $ovTable->load($filtervalue['j2store_filter_id']);
                     $filtervalue['group_id'] = $this->otable->j2store_filtergroup_id;
                     if (!$ovTable->save($filtervalue)) {
                         $status = false;
                     }
                 }
             } else {
                 return true;
             }
         }
     } else {
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * 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);
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 /**
  * 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);
 }
Exemplo n.º 6
0
 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;
         }
     }
 }
Exemplo n.º 7
0
 /**
  * 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;
 }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
 /**
  * buildQuery
  *
  * @param   bool  $overrideLimits  Param
  *
  * @return	F0FQuery
  */
 public function buildQuery($overrideLimits = false)
 {
     $db = $this->getDBO();
     $query = parent::buildQuery($overrideLimits);
     $query->order($db->qn('name'));
     return $query;
 }
Exemplo n.º 10
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     if (interface_exists('JModel')) {
         $params = JModelLegacy::getInstance('Storage', 'AdmintoolsModel');
     } else {
         $params = JModel::getInstance('Storage', 'AdmintoolsModel');
     }
     $dirperms = '0' . ltrim(trim($params->getValue('dirperms', '0755')), '0');
     $fileperms = '0' . ltrim(trim($params->getValue('fileperms', '0644')), '0');
     $dirperms = octdec($dirperms);
     if ($dirperms < 0400 || $dirperms > 0777) {
         $dirperms = 0755;
     }
     $this->dirperms = $dirperms;
     $fileperms = octdec($fileperms);
     if ($fileperms < 0400 || $fileperms > 0777) {
         $fileperms = 0755;
     }
     $this->fileperms = $fileperms;
     $db = $this->getDBO();
     $query = $db->getQuery(true)->select(array($db->quoteName('path'), $db->quoteName('perms')))->from($db->quoteName('#__admintools_customperms'))->order($db->quoteName('path') . ' ASC');
     $db->setQuery($query);
     $this->customperms = $db->loadAssocList('path');
     // Add cache, tmp and log to the exceptions
     $this->skipDirs[] = rtrim(JPATH_CACHE, '/');
     $this->skipDirs[] = rtrim(JPATH_ROOT . '/cache', '/');
     $this->skipDirs[] = rtrim(JFactory::getConfig()->get('tmp_path', JPATH_ROOT . '/tmp'), '/');
     $this->skipDirs[] = rtrim(JFactory::getConfig()->get('log_path', JPATH_ROOT . '/logs'), '/');
 }
Exemplo n.º 11
0
    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();
    }
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
 public function save($data)
 {
     if (parent::save($data)) {
         if ($this->otable->j2store_geozone_id) {
             if (isset($data['zone_to_geo_zone']) && count($data['zone_to_geo_zone'])) {
                 $grtable = F0FTable::getInstance('geozonerule', 'J2StoreTable');
                 $status = true;
                 foreach ($data['zone_to_geo_zone'] as $georule) {
                     $grtable->load($georule['j2store_geozonerule_id']);
                     $georule['geozone_id'] = $this->otable->j2store_geozone_id;
                     try {
                         $grtable->save($georule);
                     } catch (Exception $e) {
                         $status = false;
                     }
                     if (!$status) {
                         break;
                     }
                 }
             } else {
                 return true;
             }
         }
     } else {
         return false;
     }
     return true;
 }
Exemplo n.º 14
0
 public function save($data)
 {
     if (parent::save($data)) {
         if ($this->otable->j2store_taxprofile_id) {
             if (isset($data['tax-to-taxrule-row']) && count($data['tax-to-taxrule-row'])) {
                 $trTable = F0FTable::getInstance('taxrules', 'Table');
                 $status = true;
                 foreach ($data['tax-to-taxrule-row'] as $taxrate) {
                     $trTable->load($taxrate['j2store_taxrule_id']);
                     $taxrate['taxprofile_id'] = $this->otable->j2store_taxprofile_id;
                     try {
                         $trTable->save($taxrate);
                     } catch (Exception $e) {
                         $status = false;
                     }
                     if (!$status) {
                         break;
                     }
                 }
             } else {
                 return true;
             }
         }
     } else {
         return false;
     }
     return true;
 }
Exemplo n.º 15
0
 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');
 }
Exemplo n.º 16
0
 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();
 }
Exemplo n.º 17
0
 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);
 }
Exemplo n.º 18
0
 public function save($data)
 {
     if (parent::save($data)) {
         if ($this->otable->j2store_option_id) {
             if (is_object($data)) {
                 $data = (array) $data;
             }
             if (isset($data['option_value']) && count($data['option_value'])) {
                 $ovTable = F0FTable::getInstance('optionvalue', 'Table');
                 $status = true;
                 foreach ($data['option_value'] as $optionvalue) {
                     $ovTable->load($optionvalue['j2store_optionvalue_id']);
                     $optionvalue['option_id'] = $this->otable->j2store_option_id;
                     if (!$ovTable->save($optionvalue)) {
                         $status = false;
                     }
                 }
             } else {
                 return true;
             }
         }
     } else {
         return false;
     }
     return true;
 }
Exemplo n.º 19
0
 /**
  * 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;
 }
Exemplo n.º 20
0
 public function onBrowse($tpl = null)
 {
     AkeebaStrapper::addJSfile('media://com_akeeba/js/fsfilter.js');
     $model = $this->getModel();
     $task = $model->getState('browse_task', 'normal');
     // Add custom submenus
     $toolbar = F0FToolbar::getAnInstance($this->input->get('option', 'com_foobar', 'cmd'), $this->config);
     $toolbar->appendLink(JText::_('FILTERS_LABEL_NORMALVIEW'), JUri::base() . 'index.php?option=com_akeeba&view=fsfilter&task=normal', $task == 'normal');
     $toolbar->appendLink(JText::_('FILTERS_LABEL_TABULARVIEW'), JUri::base() . 'index.php?option=com_akeeba&view=fsfilter&task=tabular', $task == 'tabular');
     $media_folder = JUri::base() . '../media/com_akeeba/';
     // Get the root URI for media files
     $this->mediadir = AkeebaHelperEscape::escapeJS($media_folder . 'theme/');
     // Get a JSON representation of the available roots
     $filters = Factory::getFilters();
     $root_info = $filters->getInclusions('dir');
     $roots = array();
     $options = array();
     if (!empty($root_info)) {
         // Loop all dir definitions
         foreach ($root_info as $dir_definition) {
             if (is_null($dir_definition[1])) {
                 // Site root definition has a null element 1. It is always pushed on top of the stack.
                 array_unshift($roots, $dir_definition[0]);
             } else {
                 $roots[] = $dir_definition[0];
             }
             $options[] = JHTML::_('select.option', $dir_definition[0], $dir_definition[0]);
         }
     }
     $site_root = $roots[0];
     $attribs = 'onchange="akeeba.Fsfilters.activeRootChanged();"';
     $this->root_select = JHTML::_('select.genericlist', $options, 'root', $attribs, 'value', 'text', $site_root, 'active_root');
     $this->roots = $roots;
     switch ($task) {
         case 'normal':
         default:
             $this->setLayout('default');
             // Get a JSON representation of the directory data
             $model = $this->getModel();
             $json = json_encode($model->make_listing($site_root, array(), ''));
             $this->json = $json;
             break;
         case 'tabular':
             $this->setLayout('tabular');
             // Get a JSON representation of the tabular filter data
             $model = $this->getModel();
             $json = json_encode($model->get_filters($site_root));
             $this->json = $json;
             break;
     }
     // Get profile ID
     $profileid = Platform::getInstance()->get_active_profile();
     $this->profileid = $profileid;
     // Get profile name
     $pmodel = F0FModel::getAnInstance('Profiles', 'AkeebaModel');
     $pmodel->setId($profileid);
     $profile_data = $pmodel->getItem();
     $this->profilename = $this->escape($profile_data->description);
     return true;
 }
Exemplo n.º 21
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;
 }
 /**
  * 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;
 }
Exemplo n.º 23
0
 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[] = '&mdash;';
         }
     }
     return implode(', ', $ret);
 }
Exemplo n.º 24
0
 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');
 }
Exemplo n.º 25
0
    /**
     * 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;
    }
Exemplo n.º 26
0
 /**
  * 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;
     }
 }
Exemplo n.º 27
0
 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;
 }
Exemplo n.º 28
0
 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;
 }
Exemplo n.º 29
0
 public function getAddressesByemail($email)
 {
     $db = JFactory::getDbo();
     $query = parent::buildQuery($overrideLimits = false);
     $query->where($this->_db->qn('#__j2store_addresses.email') . ' LIKE ' . $db->q('%' . $email . '%'));
     $db->setQuery($query);
     return $db->loadObject();
 }
Exemplo n.º 30
0
 public function buildQuery($overrideLimits = false)
 {
     $query = parent::buildQuery($overrideLimits);
     /* 	$query = $this->_db->getQuery(true);
     		$query->select($this->_db->qn('#__j2store_product_optionvalues').'.*')->from($this->_db->qn('#__j2store_product_optionvalues').' AS '.$this->_db->qn('#__j2store_product_optionvalues')); */
     $query->select('#__j2store_optionvalues.optionvalue_name, #__j2store_optionvalues.optionvalue_image')->join('LEFT OUTER', '#__j2store_optionvalues ON #__j2store_optionvalues.j2store_optionvalue_id = #__j2store_product_optionvalues.optionvalue_id');
     return $query;
 }