function display($tpl = null) { $app = JFactory::getApplication(); $params = clone $app->getParams('com_rsmembership'); $this->params = $params; $this->item = $this->get('Item'); if (empty($this->item->id) || !$this->item->published) { JError::raiseWarning(500, JText::_('COM_RSMEMBERSHIP_MEMBERSHIP_NOT_EXIST')); $app->redirect(JRoute::_(RSMembershipRoute::Memberships())); } $currency = RSMembershipHelper::getConfig('currency'); // {price} placeholder $price = RSMembershipHelper::getPriceFormat($this->item->price); // {extras} placeholder $viewclass = RSMembershipHelper::isJ3() ? 'JViewLegacy' : 'JView'; if ($viewclass == 'JView') { jimport('joomla.application.component.view'); } $view = new $viewclass(array('name' => 'extras', 'base_path' => JPATH_SITE . '/components/com_rsmembership')); $view->model = JModelLegacy::getInstance('Extras', 'RSMembershipModel'); $view->extras = $view->model->getItems(); $view->item = $this->item; $view->show_subscribe_btn = $this->item->stock == -1 ? false : true; $this->extras = $view->loadTemplate(); $placeholders = array('{price}' => $price, '{buy}' => '', '{extras}' => '', '{stock}' => $this->item->stock > -1 ? $this->item->stock == 0 ? JText::_('COM_RSMEMBERSHIP_UNLIMITED') : $this->item->stock : JText::_('COM_RSMEMBERSHIP_OUT_OF_STOCK_PLACEHOLDER'), '<hr id="system-readmore" />' => ''); $replace = array_keys($placeholders); $with = array_values($placeholders); $this->item->description = str_replace($replace, $with, $this->item->description); // prepare the Pathway $pathway = $app->getPathway(); $this->Itemid = JFactory::getApplication()->input->get('Itemid', 0, 'int'); $layout = JFactory::getApplication()->input->get('layout', '', 'cmd'); if ($this->item->category_id) { $pathway->addItem($this->item->category_name, JRoute::_(RSMembershipRoute::Memberships($this->item->category_id, $this->Itemid, $layout))); } $pathway->addItem($this->item->name, ''); // Title if (!$params->get('page_title')) { $this->document->setTitle($this->item->name); } else { $this->document->setTitle($params->get('page_title') . ' - ' . $this->item->name); } // Description if ($params->get('menu-meta_description')) { $this->document->setDescription($params->get('menu-meta_description')); } // Keywords if ($params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $params->get('menu-meta_keywords')); } // Robots if ($params->get('robots')) { $this->document->setMetadata('robots', $params->get('robots')); } parent::display(); }
function getTerms() { $app = JFactory::getApplication(); $cid = $app->input->get('cid', 0, 'int'); $row = JTable::getInstance('Term', 'RSMembershipTable'); $row->load($cid); if (!$row->published) { JError::raiseWarning(500, JText::_('COM_RSMEMBERSHIP_NO_TERM')); $app->redirect(JRoute::_(RSMembershipRoute::Memberships(), false)); } return $row; }
<div class="item-page"> <?php if ($this->params->get('show_page_heading', 1)) { ?> <div class="page-header"> <h1><?php echo $this->escape($this->params->get('page_heading', $this->item->name)); ?> </h1> </div> <?php } ?> <form method="post" action="<?php echo JRoute::_(RSMembershipRoute::Subscribe($this->item->category_id, $this->item->category_name, $this->item->id, $this->item->name, $this->Itemid)); ?> " id="rsm_membership_form"> <?php if (!empty($this->item->thumb)) { ?> <?php echo JHTML::_('image', 'components/com_rsmembership/assets/thumbs/' . $this->item->thumb, $this->item->name, 'class="rsm_thumb"'); ?> <?php } ?> <?php // Trigger content plugins if enabled if (RSMembershipHelper::getConfig('trigger_content_plugins')) { $this->item->description = JHtml::_('content.prepare', $this->item->description);
public function addExtra() { $extra_id = JFactory::getApplication()->input->get('extra_id', 0, 'int'); $membership_id = JFactory::getApplication()->input->get('cid', 0, 'int'); $my_membership_model = JModelLegacy::getInstance('MyMembership', 'RSMembershipModel'); $add_extra_model = JModelLegacy::getInstance('AddExtra', 'RSMembershipModel'); $bought_extras = $my_membership_model->getBoughtExtras(); $current_extra = $add_extra_model->getExtra(); // check if extra is already purchased if (empty($current_extra) || $current_extra->type != 'checkbox' && isset($bought_extras[$current_extra->extra_id])) { JError::raiseWarning(500, JText::_('COM_RSMEMBERSHIP_ALREADY_BOUGHT_EXTRA')); $this->setRedirect(JRoute::_(RSMembershipRoute::MyMembership($membership_id), false)); } JFactory::getApplication()->input->set('view', 'addextra'); JFactory::getApplication()->input->set('layout', 'default'); parent::display(); }
<?php $k = 1; ?> <?php foreach ($this->items as $i => $item) { ?> <tr class="sectiontableentry<?php echo $k . $this->escape($this->params->get('pageclass_sfx')); ?> " > <td align="right"><?php echo $this->pagination->getRowOffset($i); ?> </td> <td><a href="<?php echo JRoute::_(RSMembershipRoute::Memberships($item->id, $this->Itemid, 'list')); ?> "><?php echo $this->escape($item->name); ?> </a><?php if ($this->params->get('show_memberships', 0)) { ?> (<?php echo $item->memberships; ?> )<?php } ?> </td> </tr>
public function display($tpl = null) { $app = JFactory::getApplication(); $pathway = $app->getPathway(); // Assign variables $this->membership = $this->get('Membership'); $this->extras = $this->get('Extras'); $this->params = clone $app->getParams('com_rsmembership'); $this->user = JFactory::getUser(); $this->logged = (bool) (!$this->user->guest); $this->token = JHtml::_('form.token'); // Assign config variables $this->config = RSMembershipHelper::getConfig(); $this->show_login = $this->config->show_login; $this->choose_username = $this->config->choose_username; $this->choose_password = $this->config->choose_password; $this->currency = $this->config->currency; $this->one_page_checkout = $this->config->one_page_checkout; $this->captcha_case_sensitive = $this->config->captcha_case_sensitive; $this->payments = RSMembership::getPlugins(); // Set pathway $pathway->addItem($this->membership->name, JRoute::_(RSMembershipRoute::Membership($this->membership->id, $app->input->getInt('Itemid')))); $pathway->addItem(JText::_('COM_RSMEMBERSHIP_SUBSCRIBE'), ''); switch ($this->getLayout()) { default: // Get the encoded return url $this->return = base64_encode(JURI::getInstance()); $this->data = (object) $this->get('Data'); $this->membershipterms = $this->get('MembershipTerms'); $this->has_coupons = $this->get('HasCoupons'); $this->fields_validation = RSMembershipHelper::getFieldsValidation($this->membership->id); $this->fields = RSMembershipHelper::getFields(true); $this->membership_fields = RSMembershipHelper::getMembershipFields($this->membership->id); // Handle CAPTCHA $this->use_captcha = $this->get('UseCaptcha'); $this->use_builtin = $this->get('UseBuiltin'); $this->use_recaptcha = $this->get('UseReCaptcha'); $this->use_recaptcha_new = $this->get('UseReCaptchaNew'); if ($this->use_recaptcha) { if (!class_exists('JReCAPTCHA')) { require_once JPATH_ADMINISTRATOR . '/components/com_rsmembership/helpers/recaptcha/recaptchalib.php'; } $this->show_recaptcha = JReCAPTCHA::getHTML($this->get('ReCaptchaError')); } if ($this->use_recaptcha_new) { $doc = JFactory::getDocument(); if ($doc->getType() == 'html') { $doc->addScript('https://www.google.com/recaptcha/api.js?hl=' . JFactory::getLanguage()->getTag()); } } $this->assignExtrasView(); break; case 'preview': $this->fields = RSMembershipHelper::getFields(false); $this->membership_fields = RSMembershipHelper::getMembershipFields($this->membership->id, false); $this->data = (object) $this->get('Data'); break; case 'payment': $this->html = $this->get('Html'); break; } // Calculate the Total $this->total = $this->get('Total'); // Do we need to display the payment options? $model = $this->getModel(); $this->showPayments = $model->showPaymentOptions(); parent::display(); }
function getUpgrade() { $app = JFactory::getApplication(); $user = JFactory::getUser(); $db = JFactory::getDBO(); $query = $db->getQuery(true); $cid = $this->_id; $query->select($db->qn('membership_id'))->select($db->qn('status'))->from($db->qn('#__rsmembership_membership_subscribers'))->where($db->qn('user_id') . ' = ' . $db->q($user->get('id')))->where($db->qn('id') . ' = ' . $db->q($cid)); $db->setQuery($query); $membership = $db->loadObject(); if (empty($membership)) { $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } if ($membership->status != MEMBERSHIP_STATUS_ACTIVE) { JError::raiseWarning(500, JText::_('COM_RSMEMBERSHIP_MEMBERSHIP_NOT_ACTIVE')); $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } $query->clear(); $query->select('u.*')->select($db->qn('mfrom.name', 'fromname'))->select($db->qn('mto.name', 'toname'))->select($db->qn('mto.term_id'))->from($db->qn('#__rsmembership_membership_upgrades', 'u'))->join('left', $db->qn('#__rsmembership_memberships', 'mfrom') . ' ON ' . $db->qn('mfrom.id') . ' = ' . $db->qn('u.membership_from_id'))->join('left', $db->qn('#__rsmembership_memberships', 'mto') . ' ON ' . $db->qn('mto.id') . ' = ' . $db->qn('u.membership_to_id'))->where($db->qn('u.membership_from_id') . ' = ' . $db->q($membership->membership_id))->where($db->qn('u.membership_to_id') . ' = ' . $db->q($this->to_id))->where($db->qn('u.published') . ' = ' . $db->q(1)); $db->setQuery($query); $return = $db->loadObject(); $this->term_id = $return->term_id; if (empty($return)) { $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } return $return; }
function getMembership() { $cid = $this->_id; $app = JFactory::getApplication(); $user = JFactory::getUser(); $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select($db->qn('membership_id'))->select($db->qn('status'))->select($db->qn('extras'))->select($db->qn('last_transaction_id'))->from($db->qn('#__rsmembership_membership_subscribers'))->where($db->qn('user_id') . ' = ' . $db->q($user->get('id')))->where($db->qn('id') . ' = ' . $db->q($cid)); $db->setQuery($query); $membership = $db->loadObject(); if (empty($membership)) { $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } if ($membership->status == 1) { JError::raiseWarning(500, JText::_('COM_RSMEMBERSHIP_MEMBERSHIP_NOT_EXPIRED')); $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } $extras = explode(',', $membership->extras); if (!empty($extras[0])) { $this->_extras = $extras; } else { $this->_extras = array(); } $last_transaction_id = $membership->last_transaction_id; $query->clear(); $query->select('*')->from($db->qn('#__rsmembership_memberships'))->where($db->qn('id') . ' = ' . $db->q($membership->membership_id)); $db->setQuery($query); $membership = $db->loadObject(); if ($membership->use_renewal_price) { $membership->price = $membership->renewal_price; } if ($membership->no_renew) { JError::raiseWarning(500, JText::_('COM_RSMEMBERSHIP_MEMBERSHIP_CANNOT_RENEW')); $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } $this->term_id = $membership->term_id; $membership->last_transaction_id = $last_transaction_id; return $membership; }
public function __construct() { parent::__construct(); jimport('joomla.filesystem.folder'); // Some workarounds are needed for Windows $this->isWindows = DIRECTORY_SEPARATOR == '\\'; // Get logged in user $this->user = JFactory::getUser(); $app = JFactory::getApplication(); $jinput = $app->input; $db = JFactory::getDbo(); $query = $db->getQuery(true); // Not logged in - must redirect to login. if ($this->user->guest) { $link = base64_encode((string) JUri::getInstance()); $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $link, false)); } // Membership doesn't match - redirect back to My Memberships page. if (!$this->_getMembership()) { $app = JFactory::getApplication(); $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } $this->getParentFolders(); $this->getExtraParentFolders(); // Let's see if the membership is active if ($this->_data->status > 0) { return; } // let's get the path $path = $jinput->get('path', '', 'string'); if (!empty($path)) { $path = explode("|", $path); // extract the parent folder's id $parent_id = (int) $path[0]; if (empty($parent_id)) { $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } // extract the path within the parent $path = !empty($path[1]) ? $path[1] : ''; // check where are we looking $from = $this->getFrom(); if ($from == 'membership') { $parent = $this->_parents[$parent_id]; } elseif ($from == 'extra') { $parent = $this->_extra_parents[$parent_id]; } // check if the parent is within the allowed parents list if (empty($parent)) { $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } $this->_parent = $parent_id; // compute the full path: parent + path $path = realpath($parent . '/' . $path); $parent = realpath($parent); // check if we are trying to access a path that's not within the parent if (strpos($path, $parent) !== 0) { $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } // let's see if we've requested a download $task = $jinput->get('task', '', 'cmd'); if ($task == 'download') { // check if path exists and is a file if (is_file($path)) { // check if we need to agree to terms first $query->select($db->qn('term_id'))->from($db->qn('#__rsmembership_files'))->where($db->qn('path') . ' = ' . $db->q($path)); $db->setQuery($query); $term_id = $db->loadResult(); if (!empty($term_id)) { $row = JTable::getInstance('Term', 'RSMembershipTable'); $row->load($term_id); if (!$row->published) { $term_id = 0; } } $agree = $jinput->get('agree', '', 'string'); if (!empty($term_id) && empty($agree)) { $this->terms = $row->description; } else { @ob_end_clean(); $filename = basename($path); header("Cache-Control: public, must-revalidate"); header('Cache-Control: pre-check=0, post-check=0, max-age=0'); header("Pragma: no-cache"); header("Expires: 0"); header("Content-Description: File Transfer"); header("Expires: Sat, 01 Jan 2000 01:00:00 GMT"); if (preg_match('#Opera#', $_SERVER['HTTP_USER_AGENT'])) { header("Content-Type: application/octetstream"); } else { header("Content-Type: application/octet-stream"); } header("Content-Length: " . (string) filesize($path)); header('Content-Disposition: attachment; filename="' . $filename . '"'); header("Content-Transfer-Encoding: binary\n"); @readfile($path); $row = JTable::getInstance('Log', 'RSMembershipTable'); $row->date = JFactory::getDate()->toSql(); $row->user_id = $this->user->id; $row->path = '[DWN] ' . $path; $row->ip = $_SERVER['REMOTE_ADDR']; $row->store(); exit; } } else { $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } } else { // check if the path exists and is a folder if (is_dir($path)) { $this->_folder = $path; if (substr($this->_folder, -1) == '/') { $this->_folder = substr($this->_folder, 0, -1); } } else { $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } } } }
$i = 0; ?> <?php foreach ($this->items as $item) { $catid = $item->category_id ? '&catid=' . $item->category_id . ':' . JFilterOutput::stringURLSafe($item->category_name) : ''; ?> <tr class="sectiontableentry<?php echo $k . $this->escape($this->params->get('pageclass_sfx')); ?> " > <td align="right"><?php echo $this->pagination->getRowOffset($i); ?> </td> <td><a href="<?php echo JRoute::_(RSMembershipRoute::Membership($item->id, $this->Itemid)); ?> "><?php echo $this->escape($item->name); ?> </a></td> <?php if ($this->params->get('show_category', 0)) { ?> <td><?php echo $item->category_id ? $item->category_name : JText::_('COM_RSMEMBERSHIP_NO_CATEGORY'); ?> </td> <?php } ?>
function getMembership() { $cid = $this->_id; $app = JFactory::getApplication(); $user = JFactory::getUser(); $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select($db->qn('membership_id'))->select($db->qn('status'))->select($db->qn('extras'))->select($db->qn('last_transaction_id'))->from($db->qn('#__rsmembership_membership_subscribers'))->where($db->qn('user_id') . ' = ' . $db->q($user->get('id')))->where($db->qn('id') . ' = ' . $db->q($cid)); $db->setQuery($query); $membership = $db->loadObject(); if (empty($membership)) { $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } if ($membership->status > 0) { JError::raiseWarning(500, JText::_('COM_RSMEMBERSHIP_MEMBERSHIP_NOT_ACTIVE')); $app->redirect(JRoute::_(RSMembershipRoute::MyMemberships(), false)); } $last_transaction_id = $membership->last_transaction_id; $query->clear(); $query->select('*')->from($db->qn('#__rsmembership_memberships'))->where($db->qn('published') . ' = ' . $db->q(1))->where($db->qn('id') . ' = ' . $db->q($membership->membership_id)); $db->setQuery($query); $membership = $db->loadObject(); if ($membership) { $query->clear(); $query->select('*')->from($db->qn('#__rsmembership_membership_extras'))->where($db->qn('membership_id') . ' = ' . $db->q($membership->id)); $db->setQuery($query); $this->_extras = $db->loadColumn(); } $membership->last_transaction_id = $last_transaction_id; return $membership; }
<div class="page-header"> <h1><?php echo $this->escape($this->params->get('page_heading')); ?> </h1> </div> <?php } ?> <div class="row-fluid"> <ul class="thumbnails"> <?php $i = 1; foreach ($this->items as $item) { $link = JRoute::_(RSMembershipRoute::Membership($item->id, $this->Itemid)); $apply_link = JRoute::_(RSMembershipRoute::Subscribe($item->category_id, $item->category_name, $item->id, $item->name, $this->Itemid)); $price = RSMembershipHelper::getPriceFormat($item->price); $image = !empty($item->thumb) ? JHTML::_('image', 'components/com_rsmembership/assets/thumbs/' . $item->thumb, $item->name, 'class="span' . 4 * $this->params->get('columns_no', 2) . ' rsm_thumb' . $this->escape($this->params->get('pageclass_sfx')) . '"') : ''; $placeholders = array('{price}' => $price, '{buy}' => '', '{extras}' => '', '{stock}' => $item->stock > -1 ? $item->stock == 0 ? JText::_('COM_RSMEMBERSHIP_UNLIMITED') : $item->stock : JText::_('COM_RSMEMBERSHIP_OUT_OF_STOCK_PLACEHOLDER'), '<hr id="system-readmore" />' => ''); // Trigger content plugins if enabled if (RSMembershipHelper::getConfig('trigger_content_plugins')) { $item->description = JHtml::_('content.prepare', $item->description); } $item->description = str_replace(array_keys($placeholders), array_values($placeholders), $item->description); ?> <li class="span<?php echo 12 / $this->params->get('columns_no', 2); ?> pull-left rsm_container<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>