Beispiel #1
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  */
 public function display($tpl = null)
 {
     // Set toolbar items for the page
     JToolbarHelper::title(JText::_('COM_CPANEL'), 'home-2 cpanel');
     JToolbarHelper::help('screen.cpanel');
     $input = JFactory::getApplication()->input;
     /*
      * Set the template - this will display cpanel.php
      * from the selected admin template.
      */
     $input->set('tmpl', 'cpanel');
     // Display the cpanel modules
     $this->modules = JModuleHelper::getModules('cpanel');
     // Load the RAD layer and count the number of post-installation messages
     if (!defined('FOF_INCLUDED')) {
         require_once JPATH_LIBRARIES . '/fof/include.php';
     }
     try {
         $messages_model = FOFModel::getTmpInstance('Messages', 'PostinstallModel')->eid(700);
         $messages = $messages_model->getItemList();
     } catch (RuntimeException $e) {
         $messages = array();
         // Still render the error message from the Exception object
         JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
     }
     $this->postinstall_message_count = count($messages);
     parent::display($tpl);
 }
Beispiel #2
0
 /**
  * redirects to correct view...
  *
  * @return bool
  *
  * @throws Exception
  */
 public function onBeforeAdd()
 {
     $user = JFactory::getUser();
     if (!$user) {
         throw new Exception('access not allowed', 403);
     }
     // If the user is logged, check if he already has a profile
     $model = FOFModel::getTmpInstance('IndividualEdits', 'TracksModel');
     $ind = $model->getUserIndividual($user->get('id'));
     if (!$ind) {
         $allow_register = JComponentHelper::getParams('com_tracks')->get('user_registration', 0);
         if (!$allow_register) {
             throw new Exception('Create individuals not allowed', 403);
         }
         // Redirect to individual edit
         $link = JRoute::_(TrackslibHelperRoute::getEditIndividualRoute());
     } else {
         // Redirect to individual edit
         $link = JRoute::_(TrackslibHelperRoute::getEditIndividualRoute($ind));
     }
     $this->setRedirect($link);
     $this->redirect();
     // We shouldn't arrive at that point ;)
     return false;
 }
 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->assignRef('json', $json);
     // Get profile ID
     $profileid = AEPlatform::getInstance()->get_active_profile();
     $this->assign('profileid', $profileid);
     // Get profile name
     $profileName = FOFModel::getTmpInstance('Profiles', 'AkeebaModel')->setId($profileid)->getItem()->description;
     $this->assign('profilename', $profileName);
     // Get the root URI for media files
     $this->assign('mediadir', AkeebaHelperEscape::escapeJS($media_folder . 'theme/'));
     // Are the settings secured?
     if (AEPlatform::getInstance()->get_platform_configuration_option('useencryption', -1) == 0) {
         $this->assign('securesettings', -1);
     } elseif (!AEUtilSecuresettings::supportsEncryption()) {
         $this->assign('securesettings', 0);
     } else {
         JLoader::import('joomla.filesystem.file');
         $filename = JPATH_COMPONENT_ADMINISTRATOR . '/akeeba/serverkey.php';
         if (JFile::exists($filename)) {
             $this->assign('securesettings', 1);
         } else {
             $this->assign('securesettings', 0);
         }
     }
     // Add live help
     AkeebaHelperIncludes::addHelp('config');
 }
 public function get()
 {
     $input = JFactory::getApplication()->input;
     $user = $this->plugin->getUser();
     $filters = array('search' => '', 'title' => '', 'enabled' => '', 'level' => '', 'publish_up' => '', 'publish_down' => '', 'user_id', 'paystate' => '', 'processor' => '', 'paykey' => '', 'since' => '', 'until' => '', 'contact_flag' => '', 'expires_from' => '', 'expires_to' => '', 'refresh' => '', 'groupbydate' => '', 'groupbyweek' => '', 'groupbylevel' => '', 'moneysum' => '', 'coupon_id' => '', 'filter_discountmode' => '', 'filter_discountcode' => '', 'nozero' => '', 'nojoins' => '');
     if (!$user) {
         $this->plugin->setResponse($this->getErrorResponse(404, JText::_('JERROR_ALERTNOAUTHOR')));
         return;
     }
     $authorised = $user->authorise('core.manage', 'com_akeebasubs');
     if (!$authorised) {
         $this->plugin->setResponse($this->getErrorResponse(404, JText::_('JERROR_ALERTNOAUTHOR')));
         return;
     }
     $subscriptionsmodel = FOFModel::getTmpInstance('Subscriptions', 'AkeebasubsModel');
     $order = $input->get('filter_order', 'akeebasubs_subscription_id');
     $orderdir = $input->get('filter_order_Dir', 'DESC');
     if (!in_array($order, array_keys($subscriptionsmodel->getTable()->getData()))) {
         $order = 'akeebasubs_subscription_id';
     }
     $subscriptionsmodel->setState('filter_order', $order);
     $subscriptionsmodel->setState('filter_order_Dir', $orderdir);
     foreach ($filters as $filter => $val) {
         $subscriptionsmodel->setState($filter, $input->get($filter, $val));
     }
     $subscriptionsmodel->limit($input->get('limit', 10))->limitstart($input->get('limit', 0));
     $this->plugin->setResponse($subscriptionsmodel->getList());
 }
Beispiel #5
0
 public function check()
 {
     $result = true;
     //Alias
     if (empty($this->alias)) {
         $this->alias = JFilterOutput::stringURLSafe($this->title);
     } else {
         $this->alias = JFilterOutput::stringURLSafe($this->alias);
     }
     $existingAlias = FOFModel::getTmpInstance('Tags', 'SpsimpleportfolioModel')->alias($this->alias)->getList(true);
     if (!empty($existingAlias)) {
         $count = 0;
         $k = $this->getKeyName();
         foreach ($existingAlias as $item) {
             if ($item->{$k} != $this->{$k}) {
                 $count++;
             }
         }
         if ($count) {
             $this->setError(JText::_('COM_SPSIMPLEPORTFOLIO_ALIAS_ERR_SLUGUNIQUE'));
             $result = false;
         }
     }
     return $result;
 }
 public function check()
 {
     $result = true;
     //Alias
     if (empty($this->alias)) {
         // Auto-fetch a alias
         $this->alias = JFilterOutput::stringURLSafe($this->title);
     } else {
         // Make sure nobody adds crap characters to the alias
         $this->alias = JFilterOutput::stringURLSafe($this->alias);
     }
     $existingAlias = FOFModel::getTmpInstance('Items', 'SpsimpleportfolioModel')->alias($this->alias)->getList(true);
     if (!empty($existingAlias)) {
         $count = 0;
         $k = $this->getKeyName();
         foreach ($existingAlias as $item) {
             if ($item->{$k} != $this->{$k}) {
                 $count++;
             }
         }
         if ($count) {
             $this->setError(JText::_('COM_SPSIMPLEPORTFOLIO_ALIAS_ERR_SLUGUNIQUE'));
             $result = false;
         }
     }
     //Tags
     if (is_array($this->spsimpleportfolio_tag_id)) {
         if (!empty($this->spsimpleportfolio_tag_id)) {
             $this->spsimpleportfolio_tag_id = json_encode($this->spsimpleportfolio_tag_id);
         }
     }
     if (is_null($this->spsimpleportfolio_tag_id) || empty($this->spsimpleportfolio_tag_id)) {
         $this->spsimpleportfolio_tag_id = '';
     }
     //Generate Thumbnails
     if ($result) {
         $params = JComponentHelper::getParams('com_spsimpleportfolio');
         $square = strtolower($params->get('square', '600x600'));
         $rectangle = strtolower($params->get('rectangle', '600x400'));
         $tower = strtolower($params->get('tower', '600x800'));
         $cropratio = $params->get('cropratio', 4);
         if (!is_null($this->image)) {
             jimport('joomla.filesystem.file');
             jimport('joomla.filesystem.folder');
             jimport('joomla.image.image');
             $image = JPATH_ROOT . '/' . $this->image;
             $path = JPATH_ROOT . '/images/spsimpleportfolio/' . $this->alias;
             if (!file_exists($path)) {
                 JFolder::create($path, 0755);
             }
             $sizes = array($square, $rectangle, $tower);
             $image = new JImage($image);
             $image->createThumbs($sizes, $cropratio, $path);
         }
     }
     return $result;
 }
 /**
  * Setup the toolbar and title
  *
  * @return  void
  *
  * @since   3.2
  */
 public function onMessages()
 {
     $extension_name = JText::_('COM_POSTINSTALL_TITLE_JOOMLA');
     $eid = $this->input->getInt('eid', 700);
     if ($eid != 700) {
         $model = FOFModel::getTmpInstance('Messages', 'PostinstallModel');
         $extension_name = $model->getExtensionName($eid);
     }
     JToolBarHelper::title(JText::sprintf('COM_POSTINSTALL_MESSAGES_TITLE', $extension_name));
     JToolBarHelper::preferences($this->config['option'], 550, 875);
 }
Beispiel #8
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     $options = array();
     // Initialize some field attributes.
     $key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value';
     $value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name'];
     $applyAccess = $this->element['apply_access'] ? (string) $this->element['apply_access'] : 'false';
     $modelName = (string) $this->element['model'];
     $nonePlaceholder = (string) $this->element['none'];
     $translate = empty($this->element['translate']) ? 'true' : (string) $this->element['translate'];
     $translate = in_array(strtolower($translate), array('true', 'yes', '1', 'on')) ? true : false;
     if (!empty($nonePlaceholder)) {
         $options[] = JHtml::_('select.option', JText::_($nonePlaceholder), null);
     }
     // Process field atrtibutes
     $applyAccess = strtolower($applyAccess);
     $applyAccess = in_array($applyAccess, array('yes', 'on', 'true', '1'));
     // Explode model name into model name and prefix
     $parts = FOFInflector::explode($modelName);
     $mName = ucfirst(array_pop($parts));
     $mPrefix = FOFInflector::implode($parts);
     // Get the model object
     $config = array('savestate' => 0);
     $model = FOFModel::getTmpInstance($mName, $mPrefix, $config);
     if ($applyAccess) {
         $model->applyAccessFiltering();
     }
     // Process state variables
     foreach ($this->element->children() as $stateoption) {
         // Only add <option /> elements.
         if ($stateoption->getName() != 'state') {
             continue;
         }
         $stateKey = (string) $stateoption['key'];
         $stateValue = (string) $stateoption;
         $model->setState($stateKey, $stateValue);
     }
     // Set the query and get the result list.
     $items = $model->getItemList(true);
     // Build the field options.
     if (!empty($items)) {
         foreach ($items as $item) {
             if ($translate == true) {
                 $options[] = JHtml::_('select.option', $item->{$key}, JText::_($item->{$value}));
             } else {
                 $options[] = JHtml::_('select.option', $item->{$key}, $item->{$value});
             }
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Beispiel #9
0
 public static function getExtensionsAndVersions()
 {
     require_once dirname(__FILE__) . '/../models/jextensions.php';
     require_once dirname(__FILE__) . '/../models/elements.php';
     require_once dirname(__FILE__) . '/../models/apps.php';
     $jmodel = FOFModel::getTmpInstance('JExtensions', 'ZLManagerModel', array('input' => array()));
     $emodel = FOFModel::getTmpInstance('Elements', 'ZLManagerModel', array('input' => array()));
     $amodel = FOFModel::getTmpInstance('Apps', 'ZLManagerModel', array('input' => array()));
     $extensions = FOFModel::getTmpInstance('Extensions', 'ZLManagerModel', array('input' => array()))->getItemList();
     $exts = array();
     foreach ($extensions as &$e) {
         // QUick naming fix
         if (trim($e->title) == 'ZL Extensions Manager') {
             $e->title = 'ZLManager';
         }
         $exts[] = trim($e->title);
     }
     // Filter extensions
     $jmodel->setState('extensions', $exts);
     $jextensions = $jmodel->getItemList();
     // Get Elements
     $elements = $emodel->getItemList();
     // Get Apps
     $apps = $amodel->getItemList();
     // Extensions
     $jexts = array();
     $jextsv = array();
     foreach ($jextensions as $je) {
         $jexts[] = $je->name;
         $jextsv[$je->name] = $je->version;
     }
     // Elements
     $el = array();
     $elv = array();
     if ($elements && count($elements)) {
         foreach ($elements as $e) {
             $el[] = $e->getMetaData('name');
             $elv[$e->getMetaData('name')] = $e->getMetaData('version');
         }
     }
     // Apps
     $applications = array();
     $applicationsv = array();
     if ($apps && count($apps)) {
         foreach ($apps as $a) {
             $applications[] = $a->getMetaData('name');
             $applicationsv[$a->getMetaData('name')] = $a->getMetaData('version');
         }
     }
     $jexts = array_merge($jexts, $el, $applications);
     $jextv = array_merge($jextsv, $elv, $applicationsv);
     return array('extensions' => $jexts, 'versions' => $jextv);
 }
Beispiel #10
0
 public function onAdd($tpl = null)
 {
     // Get profile ID
     $profileid = AEPlatform::getInstance()->get_active_profile();
     $this->profileid = $profileid;
     // Get profile name
     $profileName = FOFModel::getTmpInstance('Profiles', 'AkeebaModel')->setId($profileid)->getItem()->description;
     $this->profilename = $profileName;
     // Get the CRON paths
     $this->croninfo = $this->getModel()->getPaths();
     // Add live help
     AkeebaHelperIncludes::addHelp('schedule');
 }
Beispiel #11
0
 private function notifyMC($row, $info)
 {
     $session = JFactory::getSession();
     // Trigger plugin only if user comes from Mailchimp
     if (!$session->get('mc', '0')) {
         return;
     }
     $shop_name = $this->params->get("store_name", "Your shop");
     $shop_id = $this->params->get("store_id", 42);
     $akeebasubsLevel = FOFModel::getTmpInstance('Levels', 'AkeebasubsModel')->setId($row->akeebasubs_level_id)->getItem();
     $akeeba_subscription_name = $akeebasubsLevel->title;
     $products = array(0 => array("product_id" => $info['current']->akeebasubs_level_id, "sku" => "", "product_name" => $akeeba_subscription_name, "category_id" => 0, "category_name" => "", "qty" => 1.0, "cost" => $info['current']->gross_amount));
     CmcHelperEcom360::sendOrderInformations($shop_id, $shop_name, $info['current']->akeebasubs_subscription_id, $info['current']->gross_amount, $info['current']->tax_percent, 0.0, $products);
 }
Beispiel #12
0
 public function browse()
 {
     // Check permissions
     $this->_checkPermissions();
     /** @var AkeebaModelStatistics $model */
     $model = FOFModel::getTmpInstance('Statistics', 'AkeebaModel');
     $model->setInput($this->input);
     $result = $model->notifyFailed();
     $message = $result['result'] ? '200 ' : '500 ';
     $message .= implode(', ', $result['message']);
     @ob_end_clean();
     echo $message;
     flush();
     JFactory::getApplication()->close();
 }
 /**
  * Tries to copy the profile whose ID is set in the model to a new record
  *
  * @return bool True on success
  */
 public function copy()
 {
     $id = $this->getId();
     // Check for invalid id's (not numeric, or <= 0)
     if (!is_numeric($id) || $id <= 0) {
         $this->setError(JText::_('PROFILE_INVALID_ID'));
         return false;
     }
     $profile = FOFModel::getTmpInstance('Profiles', 'AkeebaModel')->setId($id)->getItem()->getData();
     $profile['id'] = 0;
     $oProfile = $this->getTable();
     $oProfile->reset();
     $status = $oProfile->save($profile);
     if ($status) {
         $this->setId($oProfile->id);
     }
     return $status;
 }
 public function onBrowse($tpl = null)
 {
     // Add live help
     //AkeebaHelperIncludes::addHelp('alice');
     // Get a list of log names
     $model = $this->getModel();
     $this->logs = FOFModel::getTmpInstance('Logs', 'AkeebaModel')->getLogList();
     $log = $model->getState('log');
     if (empty($log)) {
         $log = null;
     }
     $this->log = $log;
     // Get profile ID
     $profileid = AEPlatform::getInstance()->get_active_profile();
     $this->profileid = $profileid;
     // Get profile name
     $pmodel = FOFModel::getAnInstance('Profiles', 'AkeebaModel');
     $pmodel->setId($profileid);
     $profile_data = $pmodel->getItem();
     $this->profilename = $profile_data->description;
     return true;
 }
Beispiel #15
0
 public function onDisplay($tpl = null)
 {
     $aeconfig = AEFactory::getConfiguration();
     // Add live help
     AkeebaHelperIncludes::addHelp('stw');
     $model = $this->getModel();
     $step = $model->getState('stwstep', 1);
     switch ($step) {
         case 1:
         default:
             $cpanelmodel = FOFModel::getTmpInstance('Cpanels', 'AkeebaModel');
             $this->profilelist = $cpanelmodel->getProfilesList();
             $this->stw_profile_id = $model->getSTWProfileID();
             break;
         case 2:
             $this->opts = $model->getTransferSettings();
             break;
         case 3:
             break;
     }
     $this->setLayout('step' . $step);
     return true;
 }
Beispiel #16
0
 public function getVoucherTotals()
 {
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     $cart_helper = J2store::cart();
     $params = J2Store::config();
     $items = $this->getItems();
     $voucher = FOFModel::getTmpInstance('Vouchers', 'J2StoreModel')->getVoucher($session->get('voucher', '', 'j2store'));
     if ($voucher === false) {
         $session->clear('voucher', 'j2store');
         $app->enqueueMessage(JText::_('J2STORE_INVALID_VOUCHER'), 'notice');
     }
     /* 	//check agianst the email
     		if(JString::strtolower($voucher->voucher_to_email) != JString::strtolower($this->user_email) && $session->has('voucher', 'j2store')) {
     			$voucher = false;
     			$app->enqueueMessage(JText::_('J2STORE_VOUCHER_WILL_APPLY_AFTER_LOGIN_OR_PROVIDING_BILLING_ADDRESS'), 'notice');
     		} */
     //voucher is validated. Apply it
     $voucher_total = 0;
     if ($voucher) {
         $voucher_total = $voucher->amount > $this->order_subtotal + $this->order_tax ? $this->order_subtotal + $this->order_tax : $voucher->amount;
         $voucherHistoryTable = F0FTable::getAnInstance('Voucherhistories', 'J2StoreTable');
         $voucherHistoryTable->voucher_id = $voucher->voucher_id;
         $voucherHistoryTable->voucher_code = $voucher->voucher_code;
         $voucherHistoryTable->voucher_to_email = $voucher->voucher_to_email;
         $voucherHistoryTable->amount = -$voucher_total;
         $this->_ordervouchers[$voucher->voucher_code] = $voucherHistoryTable;
         J2Store::plugin()->event("CalculateVoucherTotals", array($this));
     }
     return $voucher_total;
 }
 function _updateAdminToolsHtaccess()
 {
     // Define the files and folders to add to .htaccess Maker here:
     $base = 'plugins/editors/jckeditor/';
     $registry = null;
     jimport('joomla.filesystem.folder');
     $buffer = JFile::read(JPATH_ROOT . '/' . $base . 'install/access/exceptions.ini');
     $chunks = explode(chr(13), trim($buffer));
     $folders = array();
     $files = array();
     foreach ($chunks as $chunk) {
         list($k, $v) = explode('=', $chunk);
         if ($v == 'folder') {
             $folders[] = $base . trim($k);
         } elseif ($k && $v) {
             $files[] = $base . trim($k) . '.' . trim($v);
         }
     }
     $htmaker_additions = array('folders' => $folders, 'files' => $files);
     // DO NOT MODIFY BELOW THIS LINE
     // Is Admin Tools installed?
     if (!is_dir(JPATH_ADMINISTRATOR . '/components/com_admintools')) {
         return;
     }
     // Is it the Professional version?
     if (!is_file(JPATH_ADMINISTRATOR . '/components/com_admintools/models/htaccess.php') && !is_file(JPATH_ADMINISTRATOR . '/components/com_admintools/models/htmaker.php')) {
         return;
     }
     // Is Admin Tools enabled?
     $db = JFactory::getDbo();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $query = $db->getQuery(true)->select($db->qn('enabled'))->from($db->qn('#__extensions'))->where($db->qn('element') . ' = ' . $db->q('com_admintools'))->where($db->qn('type') . ' = ' . $db->q('component'));
         $db->setQuery($query);
     } else {
         $db->setQuery('SELECT `enabled` FROM `#__components` WHERE `link` = "option=com_admintools"');
     }
     $enabled = $db->loadResult();
     if (!$enabled) {
         return;
     }
     // Do we have a custom .htaccess file?
     $generateHtaccess = false;
     jimport('joomla.filesystem.file');
     if (JFile::exists(JPATH_ROOT . '/.htaccess')) {
         $htaccess = JFile::read(JPATH_ROOT . '/.htaccess');
         if ($htaccess !== false) {
             $htaccess = explode("\n", $htaccess);
             if ($htaccess[1] == '### Security Enhanced & Highly Optimized .htaccess File for Joomla!') {
                 $generateHtaccess = true;
             }
         }
     }
     // Load the FoF library
     if (!defined('FOF_INCLUDED')) {
         include_once JPATH_LIBRARIES . '/fof/include.php';
     }
     // Load the .htaccess Maker configuration
     if (!class_exists('AdmintoolsModelStorage')) {
         include_once JPATH_ADMINISTRATOR . '/components/com_admintools/models/storage.php';
     }
     $model = FOFModel::getTmpInstance('Htmaker', 'AdmintoolsModel');
     $config = $model->loadConfiguration();
     if (is_string($config->exceptionfiles)) {
         $config->exceptionfiles = explode("\n", $config->exceptionfiles);
     }
     if (is_string($config->exceptiondirs)) {
         $config->exceptiondirs = explode("\n", $config->exceptiondirs);
     }
     // Initialise
     $madeChanges = false;
     // Add missing files
     if (!empty($htmaker_additions['files'])) {
         foreach ($htmaker_additions['files'] as $f) {
             if (!in_array($f, $config->exceptionfiles)) {
                 $config->exceptionfiles[] = $f;
                 $madeChanges = true;
             }
         }
     }
     // Add missing folders
     if (!empty($htmaker_additions['folders'])) {
         foreach ($htmaker_additions['folders'] as $f) {
             if (!in_array($f, $config->exceptiondirs)) {
                 $config->exceptiondirs[] = $f;
                 $madeChanges = true;
             }
         }
     }
     if ($madeChanges) {
         // Save the configuration
         $customhead = $config->custhead;
         if (!strpos($customhead, 'pixlr.com')) {
             $customhead .= "\nRewriteCond %{QUERY_STRING} image=http://[a-zA-Z0-9_]+\\.pixlr.com\r\nRewriteRule .* - [L]";
         }
         $updates = array('exceptionfiles' => implode("\n", $config->exceptionfiles), 'exceptiondirs' => implode("\n", $config->exceptiondirs), 'custhead' => $customhead);
         $model->saveConfiguration($updates);
         if ($generateHtaccess) {
             $model->writeHtaccess();
         }
     }
 }
Beispiel #18
0
 /**
  * Returns true if we are installed in Joomla! 3.2 or later and we have post-installation messages for our component
  * which must be showed to the user.
  *
  * @return bool
  */
 public function hasPostInstallMessages()
 {
     // Make sure we have Joomla! 3.2.0 or later
     if (!version_compare(JVERSION, '3.2.0', 'ge')) {
         return false;
     }
     // Get the extension ID
     // Get the extension ID for our component
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('extension_id')->from('#__extensions')->where($db->qn('element') . ' = ' . $db->q('com_admintools'));
     $db->setQuery($query);
     try {
         $ids = $db->loadColumn();
     } catch (Exception $exc) {
         return false;
     }
     if (empty($ids)) {
         return false;
     }
     $extension_id = array_shift($ids);
     $this->setState('extension_id', $extension_id);
     if (!defined('FOF_INCLUDED')) {
         include_once JPATH_SITE . '/libraries/fof/include.php';
     }
     if (!defined('FOF_INCLUDED')) {
         return false;
     }
     // Do I have messages?
     $pimModel = FOFModel::getTmpInstance('Messages', 'PostinstallModel');
     $pimModel->savestate(false);
     $pimModel->setState('eid', $extension_id);
     return count($pimModel->getList()) >= 1;
 }
Beispiel #19
0
 private function checkLevel($level)
 {
     $akeeba_level = FOFModel::getTmpInstance('Levels', 'AkeebasubsModel')->only_once(1)->enabled(1)->getItem($level);
     return $akeeba_level->enabled && $akeeba_level->akeebasubs_level_id == $level;
 }
Beispiel #20
0
 private function createNewSTWProfile($copyfrom = null)
 {
     // Get the Profiles model and fetch the STW profile ID
     $m = FOFModel::getTmpInstance('Profiles', 'AkeebaModel');
     $id = $this->getSTWProfileID();
     if ($id != 0) {
         AEPlatform::getInstance()->load_configuration($id);
     }
     // Create a new profile
     $data = array('id' => $id, 'description' => $this->stwProfileName, 'configuration' => '', 'filters' => serialize(array()));
     // Inherit settings from another profile
     if ($id != 0 && !empty($copyfrom)) {
         $m->setId($copyfrom);
         if ($m->checkID()) {
             $oldProfile = $m->getProfile();
             $data['configuration'] = $oldProfile->configuration;
             $data['filters'] = $oldProfile->filters;
         }
     }
     // Save the new/changed profile
     $m->setId($id);
     $result = $m->save($data);
     if ($result) {
         // If the save was successful, switch the active profile
         $newRecord = $m->getSavedTable();
         $session = JFactory::getSession();
         $session->set('profile', $newRecord->id, 'akeeba');
     }
     return $result;
 }
 private function _angieUpgrade()
 {
     // Get all profiles
     $model = FOFModel::getTmpInstance('Cpanels', 'AkeebaModel');
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select(array($db->qn('id')))->from($db->qn('#__ak_profiles'))->order($db->qn('id') . " ASC");
     $db->setQuery($query);
     $profiles = $db->loadColumn();
     $session = JFactory::getSession();
     $oldProfile = $session->get('profile', 1, 'akeeba');
     foreach ($profiles as $profile_id) {
         AEFactory::nuke();
         AEPlatform::getInstance()->load_configuration($profile_id);
         $config = AEFactory::getConfiguration();
         $config->set('akeeba.advanced.embedded_installer', 'angie');
         AEPlatform::getInstance()->save_configuration($profile_id);
     }
     AEFactory::nuke();
     AEPlatform::getInstance()->load_configuration($oldProfile);
 }
	/**
	 * Called whenever a subscription is modified. Namely, when its enabled status,
	 * payment status or valid from/to dates are changed.
	 */
	public function onAKSubscriptionChange($row, $info)
	{
		$akeebaSubLevelId = $row->akeebasubs_level_id;
            
        include_once(JPATH_LIBRARIES.'/fof/include.php');
        
        $level = FOFModel::getTmpInstance('Levels','AkeebasubsModel')
				->setId($akeebaSubLevelId)
				->getItem();

		if (($row->state == 'C')&&($row->enabled == 1)) {
			if (@$level->params['published'] == 1) {
				$this->publishAds($row->user_id);
			}
            if (@$level->params['bringtotop'] == 1) {
				$this->bringToTopAds($row->user_id);
			}
            if (@$level->params['highlight'] == 1) {
				$this->highlightAds($row->user_id);
			}
            if (@$level->params['featured'] == 1) {
				$this->featuredAds($row->user_id);
			}
		} else {
			if (@$level->params['unpublished'] == 1) {
				$this->unpublishAds($row->user_id);
			}
            if (@$level->params['notbringtotop'] == 1) {
				$this->notbringToTopAds($row->user_id);
			}
            if (@$level->params['unhighlight'] == 1) {
				$this->unhighlightAds($row->user_id);
			}
            if (@$level->params['unfeatured'] == 1) {
				$this->unfeaturedAds($row->user_id);
			}
		}
	}
 private function enableSettingsEncryption()
 {
     $key = $this->createSettingsKey();
     if (empty($key) || $key == false) {
         return;
     }
     // Loop all profiles and encrypt their settings
     $profilesModel = FOFModel::getTmpInstance('Profiles', 'AkeebaModel');
     $profiles = $profilesModel->getList(true);
     $db = $this->getDBO();
     if (!empty($profiles)) {
         foreach ($profiles as $profile) {
             $id = $profile->id;
             $config = AEUtilSecuresettings::encryptSettings($profile->configuration, $key);
             $sql = $db->getQuery(true)->update($db->qn('#__ak_profiles'))->set($db->qn('configuration') . ' = ' . $db->q($config))->where($db->qn('id') . ' = ' . $db->q($id));
             $db->setQuery($sql);
             $db->execute();
         }
     }
 }
    public function execute()
    {
        // Load the language files
        $paths = array(JPATH_ADMINISTRATOR, JPATH_ROOT);
        $jlang = JFactory::getLanguage();
        $jlang->load('com_akeeba', $paths[0], 'en-GB', true);
        $jlang->load('com_akeeba', $paths[1], 'en-GB', true);
        $jlang->load('com_akeeba' . '.override', $paths[0], 'en-GB', true);
        $jlang->load('com_akeeba' . '.override', $paths[1], 'en-GB', true);
        $debugmessage = '';
        if ($this->input->get('debug', -1, 'int') != -1) {
            if (!defined('AKEEBADEBUG')) {
                define('AKEEBADEBUG', 1);
            }
            $debugmessage = "*** DEBUG MODE ENABLED ***\n";
        }
        $version = AKEEBA_VERSION;
        $date = AKEEBA_DATE;
        $phpversion = PHP_VERSION;
        $phpenvironment = PHP_SAPI;
        if ($this->input->get('quiet', -1, 'int') == -1) {
            $year = gmdate('Y');
            echo <<<ENDBLOCK
Akeeba Backup Check failed backups CLI {$version} ({$date})
Copyright (C) 2010-{$year} Nicholas K. Dionysopoulos
-------------------------------------------------------------------------------
Akeeba Backup is Free Software, distributed under the terms of the GNU General
Public License version 3 or, at your option, any later version.
This program comes with ABSOLUTELY NO WARRANTY as per sections 15 & 16 of the
license. See http://www.gnu.org/licenses/gpl-3.0.html for details.
-------------------------------------------------------------------------------
You are using PHP {$phpversion} ({$phpenvironment})
{$debugmessage}
Checking for failed backups

ENDBLOCK;
        }
        // Load the engine
        $factoryPath = JPATH_ADMINISTRATOR . '/components/com_akeeba/akeeba/factory.php';
        define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/com_akeeba');
        define('AKEEBAROOT', JPATH_ADMINISTRATOR . '/components/com_akeeba/akeeba');
        if (!file_exists($factoryPath)) {
            echo "ERROR!\n";
            echo "Could not load the backup engine; file does not exist. Technical information:\n";
            echo "Path to " . basename(__FILE__) . ": " . __DIR__ . "\n";
            echo "Path to factory file: {$factoryPath}\n";
            die("\n");
        } else {
            try {
                require_once $factoryPath;
            } catch (Exception $e) {
                echo "ERROR!\n";
                echo "Backup engine returned an error. Technical information:\n";
                echo "Error message:\n\n";
                echo $e->getMessage() . "\n\n";
                echo "Path to " . basename(__FILE__) . ":" . __DIR__ . "\n";
                echo "Path to factory file: {$factoryPath}\n";
                die("\n");
            }
        }
        define('AKEEBA_BACKUP_ORIGIN', 'cli');
        // Force loading CLI-mode translation class
        $dummy = new AEUtilTranslate();
        require_once JPATH_ROOT . '/libraries/fof/include.php';
        /** @var AkeebaModelStatistics $model */
        $model = FOFModel::getTmpInstance('Statistics', 'AkeebaModel');
        $model->setInput($this->input);
        $result = $model->notifyFailed();
        echo implode("\n", $result['message']);
        exit;
    }
Beispiel #25
0
 /**
  * Method to get the field options.
  *
  * @return  array  The field option objects.
  */
 protected function getOptions()
 {
     $options = array();
     $this->value = array();
     $value_field = $this->element['value_field'] ? (string) $this->element['value_field'] : 'title';
     $input = new FOFInput();
     $component = ucfirst(str_replace('com_', '', $input->getString('option')));
     $view = ucfirst($input->getString('view'));
     $relation = FOFInflector::pluralize((string) $this->element['name']);
     $model = FOFModel::getTmpInstance(ucfirst($relation), $component . 'Model');
     $table = $model->getTable();
     $key = $table->getKeyName();
     $value = $table->getColumnAlias($value_field);
     foreach ($model->getItemList(true) as $option) {
         $options[] = JHtml::_('select.option', $option->{$key}, $option->{$value});
     }
     if ($id = FOFModel::getAnInstance($view)->getId()) {
         $table = FOFTable::getInstance($view, $component . 'Table');
         $table->load($id);
         $relations = $table->getRelations()->getMultiple($relation);
         foreach ($relations as $item) {
             $this->value[] = $item->getId();
         }
     }
     return $options;
 }
Beispiel #26
0
    public function onBrowse($tpl = null)
    {
        $session = JFactory::getSession();
        $task = $session->get('buadmin.task', 'default', 'akeeba');
        if ($task != 'restorepoint') {
            $task = 'default';
        }
        $aeconfig = AEFactory::getConfiguration();
        // Add custom submenus
        if (AKEEBA_PRO) {
            $toolbar = FOFToolbar::getAnInstance($this->input->get('option', 'com_foobar', 'cmd'), $this->config);
            $toolbar->appendLink(JText::_('BUADMIN_LABEL_BACKUPS'), JURI::base() . 'index.php?option=com_akeeba&view=buadmin&task=browse', $task == 'default');
            $toolbar->appendLink(JText::_('BUADMIN_LABEL_SRP'), JURI::base() . 'index.php?option=com_akeeba&view=buadmin&task=restorepoint', $task == 'restorepoint');
        }
        if (AKEEBA_PRO && $task == 'default') {
            $bar = JToolBar::getInstance('toolbar');
            $bar->appendButton('Link', 'restore', JText::_('DISCOVER'), 'index.php?option=com_akeeba&view=discover');
            JToolBarHelper::publish('restore', JText::_('STATS_LABEL_RESTORE'));
        }
        if ($task == 'default') {
            JToolBarHelper::editList('showcomment', JText::_('STATS_LOG_EDITCOMMENT'));
            $pModel = FOFModel::getTmpInstance('Profiles', 'AkeebaModel');
            $enginesPerPprofile = $pModel->getPostProcessingEnginePerProfile();
            $this->enginesPerProfile = $enginesPerPprofile;
        }
        JToolBarHelper::spacer();
        // "Show warning first" download button. Joomlantastic!
        $confirmationText = AkeebaHelperEscape::escapeJS(JText::_('STATS_LOG_DOWNLOAD_CONFIRM'), "'\n");
        $baseURI = JURI::base();
        $js = <<<ENDSCRIPT
function confirmDownloadButton()
{
\tvar answer = confirm('{$confirmationText}');
\tif(answer) submitbutton('download');
}

function confirmDownload(id, part)
{
\tvar answer = confirm('{$confirmationText}');
\tvar newURL = '{$baseURI}';
\tif(answer) {
\t\tnewURL += 'index.php?option=com_akeeba&view=buadmin&task=download&id='+id;
\t\tif( part != '' ) newURL += '&part=' + part
\t\twindow.location = newURL;
\t}
}

ENDSCRIPT;
        $document = JFactory::getDocument();
        $document->addScriptDeclaration($js);
        $hash = 'akeebabuadmin';
        // ...ordering
        $app = JFactory::getApplication();
        $this->lists->set('order', $app->getUserStateFromRequest($hash . 'filter_order', 'filter_order', 'backupstart'));
        $this->lists->set('order_Dir', $app->getUserStateFromRequest($hash . 'filter_order_Dir', 'filter_order_Dir', 'DESC'));
        // ...filter state
        $this->lists->set('fltDescription', $app->getUserStateFromRequest($hash . 'filter_description', 'description', null));
        $this->lists->set('fltFrom', $app->getUserStateFromRequest($hash . 'filter_from', 'from', null));
        $this->lists->set('fltTo', $app->getUserStateFromRequest($hash . 'filter_to', 'to', null));
        $this->lists->set('fltOrigin', $app->getUserStateFromRequest($hash . 'filter_origin', 'origin', null));
        $this->lists->set('fltProfile', $app->getUserStateFromRequest($hash . 'filter_profile', 'profile', null));
        $filters = $this->_getFilters();
        $ordering = $this->_getOrdering();
        require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/statistics.php';
        $model = new AkeebaModelStatistics();
        $list = $model->getStatisticsListWithMeta(false, $filters, $ordering);
        // Assign data to the view
        $this->lists = $this->lists;
        // Filter lists
        $this->list = $list;
        // Data
        $this->pagination = $model->getPagination($filters);
        // Pagination object
        // Add live help
        if ($task == 'restorepoint') {
            $this->setLayout('restorepoint');
            AkeebaHelperIncludes::addHelp('restorepoint');
        } else {
            AkeebaHelperIncludes::addHelp('buadmin');
        }
        return true;
    }
Beispiel #27
0
 /**
  * Returns true if we are installed in Joomla! 3.2 or later and we have post-installation messages for our component
  * which must be showed to the user.
  *
  * Returns null if the com_postinstall component is broken because the user screwed up his Joomla! site following
  * some idiot's advice. Apparently there's no shortage of idiots giving terribly bad advice to Joomla! users.
  *
  * @return bool|null
  */
 public function hasPostInstallMessages()
 {
     // Get the extension ID for our component
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('extension_id')->from('#__extensions')->where($db->qn('element') . ' = ' . $db->q('com_akeeba'));
     $db->setQuery($query);
     try {
         $ids = $db->loadColumn();
     } catch (Exception $exc) {
         return false;
     }
     if (empty($ids)) {
         return false;
     }
     $extension_id = array_shift($ids);
     $this->setState('extension_id', $extension_id);
     if (!defined('FOF_INCLUDED')) {
         include_once JPATH_SITE . '/libraries/fof/include.php';
     }
     if (!defined('FOF_INCLUDED')) {
         return false;
     }
     // Do I have messages?
     try {
         $pimModel = FOFModel::getTmpInstance('Messages', 'PostinstallModel');
         $pimModel->savestate(false);
         $pimModel->setState('eid', $extension_id);
         $list = $pimModel->getList();
         $result = count($list) >= 1;
     } catch (\Exception $e) {
         $result = null;
     }
     return $result;
 }