Esempio n. 1
0
 function display($tpl = null)
 {
     $db = JFactory::getDbo();
     $item = $this->get('Data');
     //Get list of subscription records
     $sql = 'SELECT a.*, b.title AS plan_title, b.lifetime_membership, b.enable_renewal, b.recurring_subscription' . ' FROM #__osmembership_subscribers  AS a' . ' INNER JOIN #__osmembership_plans AS b' . ' ON a.plan_id = b.id' . ' WHERE a.profile_id=' . $item->id . ' ORDER BY a.id DESC ';
     $db->setQuery($sql);
     $items = $db->loadObjectList();
     //Form fields
     $rowFields = OSMembershipHelper::getProfileFields(0, true, $item->language);
     $data = OSMembershipHelper::getProfileData($item, 0, $rowFields);
     $form = new RADForm($rowFields);
     $form->setData($data)->bindData();
     //Trigger third party add-on
     JPluginHelper::importPlugin('osmembership');
     $dispatcher = JDispatcher::getInstance();
     //Trigger plugins
     $results = $dispatcher->trigger('onProfileDisplay', array($item));
     $this->item = $item;
     $this->config = OSMembershipHelper::getConfig();
     $this->plugins = $results;
     $this->items = $items;
     $this->form = $form;
     parent::display($tpl);
 }
Esempio n. 2
0
 /**
  * Run when a membership expiried die
  * @param PlanOsMembership $row
  */
 function onMembershipExpire($row)
 {
     if ($row->user_id) {
         $user = JFactory::getUser($row->user_id);
         $currentGroups = $user->get('groups');
         $plan = JTable::getInstance('Osmembership', 'Plan');
         $plan->load($row->plan_id);
         $params = new JRegistry($plan->params);
         $groups = explode(',', $params->get('joomla_expried_group_ids'));
         $subscriptionExpiredGroupIds = explode(',', $params->get('subscription_expired_joomla_group_ids'));
         $activePlans = OSMembershipHelper::getActiveMembershipPlans($row->user_id, array($row->id));
         // Subscribers will be assigned to this group if he has no more active subscription of this plan, haven't renewed yet
         if (!in_array($row->plan_id, $activePlans)) {
             $currentGroups = array_merge($currentGroups, $subscriptionExpiredGroupIds);
         }
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('params')->from('#__osmembership_plans')->where('id IN  (' . implode(',', $activePlans) . ')');
         $db->setQuery($query);
         $rowPlans = $db->loadObjectList();
         if (count($rowPlans)) {
             foreach ($rowPlans as $rowPlan) {
                 $planParams = new JRegistry($rowPlan->params);
                 $planGroups = explode(',', $planParams->get('joomla_group_ids'));
                 $groups = array_diff($groups, $planGroups);
             }
         }
         $currentGroups = array_unique(array_diff($currentGroups, $groups));
         $user->set('groups', $currentGroups);
         $user->save(true);
     }
 }
Esempio n. 3
0
 function processRestriction($matches)
 {
     $document = JFactory::getDocument();
     $styleUrl = JURI::base(true) . '/components/com_osmembership/assets/css/style.css';
     $document->addStylesheet($styleUrl, 'text/css', null, null);
     require_once JPATH_ROOT . '/components/com_osmembership/helper/helper.php';
     $message = OSMembershipHelper::getMessages();
     $fieldSuffix = OSMembershipHelper::getFieldSuffix();
     if (strlen($message->{'content_restricted_message' . $fieldSuffix})) {
         $restrictedText = $message->{'content_restricted_message' . $fieldSuffix};
     } else {
         $restrictedText = $message->content_restricted_message;
     }
     $requiredPlanIds = $matches[1];
     $protectedText = $matches[2];
     $activePlanIds = OSMembershipHelper::getActiveMembershipPlans();
     if (count($activePlanIds) == 1 && $activePlanIds[0] == 0) {
         return '<div id="restricted_info">' . $restrictedText . '</div>';
     } elseif ($requiredPlanIds == '*') {
         return $protectedText;
     } else {
         $requiredPlanIds = explode(',', $requiredPlanIds);
         if (count(array_intersect($requiredPlanIds, $activePlanIds))) {
             return $protectedText;
         } else {
             return '<div id="restricted_info">' . $restrictedText . '</div>';
         }
     }
 }
Esempio n. 4
0
 function _buildListArray(&$lists, $state)
 {
     $db = JFactory::getDbo();
     // Build plans dropdown
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('OSM_PLAN'), 'id', 'title');
     $sql = 'SELECT id, title FROM #__osmembership_plans WHERE published=1 ORDER BY ordering ';
     $db->setQuery($sql);
     $options = array_merge($options, $db->loadObjectList());
     $lists['plan_id'] = JHtml::_('select.genericlist', $options, 'plan_id', ' class="inputbox" onchange="submit();"', 'id', 'title', $state->plan_id);
     // Build countries dropdown
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('OSM_SELECT_COUNTRY'));
     $sql = 'SELECT `name` AS value, `name` AS text FROM `#__osmembership_countries` WHERE `published`=1';
     $db->setQuery($sql);
     $options = array_merge($options, $db->loadObjectList());
     $lists['country'] = JHtml::_('select.genericlist', $options, 'country', ' class="inputbox" onchange="submit();" ', 'value', 'text', $state->country);
     $defaultCountry = OSMembershipHelper::getConfigValue('default_country');
     $countryCode = OSmembershipHelper::getCountryCode($defaultCountry);
     if (OSMembershipHelperEuvat::isEUCountry($countryCode)) {
         $this->showVies = true;
         $options = array();
         $options[] = JHtml::_('select.option', -1, JText::_('OSM_VIES'));
         $options[] = JHtml::_('select.option', 0, JText::_('OSM_NO'));
         $options[] = JHtml::_('select.option', 1, JText::_('OSM_YES'));
         $lists['vies'] = JHtml::_('select.genericlist', $options, 'vies', ' class="inputbox" onchange="submit();" ', 'value', 'text', $state->vies);
     } else {
         $this->showVies = false;
     }
 }
Esempio n. 5
0
 function onAfterStoreSubscription($row)
 {
     if ($row->payment_method == 'os_offline' && !$row->invoice_number && OSMembershipHelper::needToCreateInvoice($row)) {
         $row->invoice_number = OSMembershipHelper::getInvoiceNumber($row);
         $row->store();
     }
 }
Esempio n. 6
0
 function _buildListArray(&$lists, $state)
 {
     $db = JFactory::getDbo();
     $config = OSMembershipHelper::getConfig();
     $sql = 'SELECT id, title FROM #__osmembership_plans WHERE published = 1 ORDER BY ordering ';
     $db->setQuery($sql);
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('OSM_ALL_PLANS'), 'id', 'title');
     $options = array_merge($options, $db->loadObjectList());
     $lists['plan_id'] = JHtml::_('select.genericlist', $options, 'plan_id', ' class="inputbox" onchange="submit();" ', 'id', 'title', $state->plan_id);
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('OSM_ALL_SUBSCRIPTIONS'));
     $options[] = JHtml::_('select.option', 1, JText::_('OSM_NEW_SUBSCRIPTION'));
     $options[] = JHtml::_('select.option', 2, JText::_('OSM_SUBSCRIPTION_RENEWAL'));
     $options[] = JHtml::_('select.option', 3, JText::_('OSM_SUBSCRIPTION_UPGRADE'));
     $lists['subscription_type'] = JHtml::_('select.genericlist', $options, 'subscription_type', ' class="inputbox" onchange="submit();" ', 'value', 'text', $state->subscription_type);
     $options = array();
     $options[] = JHtml::_('select.option', -1, JText::_('OSM_ALL'));
     $options[] = JHtml::_('select.option', 0, JText::_('OSM_PENDING'));
     $options[] = JHtml::_('select.option', 1, JText::_('OSM_ACTIVE'));
     $options[] = JHtml::_('select.option', 2, JText::_('OSM_EXPIRED'));
     $options[] = JHtml::_('select.option', 3, JText::_('OSM_CANCELLED_PENDING'));
     $options[] = JHtml::_('select.option', 4, JText::_('OSM_CANCELLED_REFUNDED'));
     $lists['published'] = JHtml::_('select.genericlist', $options, 'published', ' class="inputbox" onchange="submit();" ', 'value', 'text', $state->published);
     $this->config = $config;
     return true;
 }
Esempio n. 7
0
 function display($tpl = null)
 {
     $this->setLayout('default');
     $message = OSMembershipHelper::getConfigValue('cancel_message');
     $this->assignRef('message', $message);
     parent::display($tpl);
 }
Esempio n. 8
0
 function display($tpl = null)
 {
     $languages = OSMembershipHelper::getLanguages();
     $item = $this->get('Data');
     $this->item = $item;
     $this->languages = $languages;
     parent::display($tpl);
 }
Esempio n. 9
0
 function _buildQuery()
 {
     $fieldSuffix = OSMembershipHelper::getFieldSuffix();
     // Get the WHERE and ORDER BY clauses for the query
     $where = $this->_buildContentWhere();
     $query = 'SELECT a.*, a.title' . $fieldSuffix . ' AS title, a.description' . $fieldSuffix . ' AS description, a.short_description' . $fieldSuffix . ' AS short_description  FROM #__osmembership_plans AS a' . $where . ' ORDER BY a.ordering ';
     return $query;
 }
Esempio n. 10
0
 function _buildQuery()
 {
     $fieldSuffix = OSMembershipHelper::getFieldSuffix();
     // Get the WHERE and ORDER BY clauses for the query
     $where = $this->_buildContentWhere();
     $query = 'SELECT a.*, a.title' . $fieldSuffix . ' AS title, a.description' . $fieldSuffix . ' AS description, COUNT(b.id) AS total_plans FROM #__osmembership_categories AS a' . ' LEFT JOIN #__osmembership_plans AS b ' . ' ON (a.id=b.category_id AND b.published=1)' . $where . ' GROUP BY a.id ' . ' ORDER BY a.ordering ';
     return $query;
 }
Esempio n. 11
0
 function _loadData()
 {
     $fieldSuffix = OSMembershipHelper::getFieldSuffix();
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     $query->select('*, title' . $fieldSuffix . ' AS title, description' . $fieldSuffix . ' AS description')->from('#__osmembership_plans')->where('id=' . $this->_id);
     $db->setQuery($query);
     $this->_data = $db->loadObject();
 }
Esempio n. 12
0
 /**
  * Run when a membership activated
  * @param PlanOsMembership $row
  */
 function onMembershipActive($row)
 {
     $db = JFactory::getDbo();
     $config = OSMembershipHelper::getConfig();
     if ($row->user_id > 0 && !$config->send_activation_email) {
         $user = JFactory::getUser($row->user_id);
         $user->set('block', 0);
         $user->save(true);
     }
     return true;
 }
Esempio n. 13
0
 function getData()
 {
     if (empty($this->_data)) {
         $db = JFactory::getDbo();
         $rows = parent::getData();
         for ($i = 0, $n = count($rows); $i < $n; $i++) {
             $row = $rows[$i];
             $row->plans = OSMembershipHelper::getSubscriptions($row->id);
         }
         $this->_data = $rows;
     }
     return $this->_data;
 }
Esempio n. 14
0
 function _buildListArray(&$lists, $item)
 {
     $db = JFactory::getDbo();
     $config = OSMembershipHelper::getConfig();
     $sql = 'SELECT id, title FROM #__osmembership_plans WHERE published = 1 ORDER BY ordering ';
     $db->setQuery($sql);
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('OSM_ALL_PLANS'), 'id', 'title');
     $options = array_merge($options, $db->loadObjectList());
     $lists['plan_id'] = JHtml::_('select.genericlist', $options, 'plan_id', ' class="inputbox" ', 'id', 'title', $item->plan_id);
     //Subscription status
     $options = array();
     $options[] = JHtml::_('select.option', -1, JText::_('OSM_ALL'));
     $options[] = JHtml::_('select.option', 0, JText::_('OSM_PENDING'));
     $options[] = JHtml::_('select.option', 1, JText::_('OSM_ACTIVE'));
     $options[] = JHtml::_('select.option', 2, JText::_('OSM_EXPIRED'));
     $options[] = JHtml::_('select.option', 3, JText::_('OSM_CANCELLED_PENDING'));
     $options[] = JHtml::_('select.option', 4, JText::_('OSM_CANCELLED_REFUNDED'));
     $lists['published'] = JHtml::_('select.genericlist', $options, 'published', ' class="inputbox" ', 'value', 'text', $item->published);
     //Get list of payment methods
     $sql = 'SELECT name, title FROM #__osmembership_plugins WHERE published=1 ORDER BY ordering';
     $db->setQuery($sql);
     $options = array();
     $options[] = JHtml::_('select.option', '', JText::_('OSM_PAYMENT_METHOD'), 'name', 'title');
     $options = array_merge($options, $db->loadObjectList());
     $lists['payment_method'] = JHtml::_('select.genericlist', $options, 'payment_method', ' class="inputbox" ', 'name', 'title', $item->payment_method);
     $rowFields = OSMembershipHelper::getProfileFields($item->plan_id, true, $item->language);
     $data = array();
     if ($item->id) {
         $data = OSMembershipHelper::getProfileData($item, $item->plan_id, $rowFields);
         $setDefault = false;
     } else {
         $setDefault = true;
     }
     if (!isset($data['country']) || !$data['country']) {
         $data['country'] = $config->default_country;
     }
     $form = new RADForm($rowFields);
     $form->setData($data)->bindData($setDefault);
     //Custom fields processing goes here
     if ($item->plan_id) {
         $sql = 'SELECT lifetime_membership FROM #__osmembership_plans WHERE id=' . $item->plan_id;
         $db->setQuery($sql);
         $item->lifetime_membership = (int) $db->loadResult();
     } else {
         $item->lifetime_membership = 0;
     }
     $this->config = $config;
     $this->form = $form;
     return true;
 }
Esempio n. 15
0
 function _buildListArray(&$lists, $state)
 {
     $config = OSMembershipHelper::getConfig();
     $options = array();
     $options[] = JHtml::_('select.option', -1, JText::_('OSM_ALL'));
     $options[] = JHtml::_('select.option', 0, JText::_('OSM_PENDING'));
     $options[] = JHtml::_('select.option', 1, JText::_('OSM_ACTIVE'));
     $options[] = JHtml::_('select.option', 2, JText::_('OSM_EXPIRED'));
     $options[] = JHtml::_('select.option', 3, JText::_('OSM_CANCELLED_PENDING'));
     $options[] = JHtml::_('select.option', 4, JText::_('OSM_CANCELLED_REFUNDED'));
     $lists['published'] = JHtml::_('select.genericlist', $options, 'published', ' class="inputbox" onchange="submit();" ', 'value', 'text', $state->published);
     $this->config = $config;
     return true;
 }
Esempio n. 16
0
 /**
  * Process payment 
  *
  */
 function processPayment($row, $data)
 {
     $Itemid = JRequest::getint('Itemid');
     $config = OSMembershipHelper::getConfig();
     OSMembershipHelper::sendEmails($row, $config);
     $db = JFactory::getDbo();
     $sql = 'SELECT subscription_complete_url FROM #__osmembership_plans WHERE id=' . $row->plan_id;
     $db->setQuery($sql);
     $subscriptionCompleteURL = $db->loadResult();
     if ($subscriptionCompleteURL) {
         JFactory::getApplication()->redirect($subscriptionCompleteURL);
     } else {
         JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_osmembership&view=complete&act=' . $row->act . '&subscription_code=' . $row->subscription_code . '&Itemid=' . $Itemid, false, false));
     }
 }
Esempio n. 17
0
 function _buildListArray(&$lists, $state)
 {
     $db = JFactory::getDbo();
     $discountTypes = array(0 => '%', 1 => OSMembershipHelper::getConfigValue('currency_symbol'));
     $nullDate = $db->getNullDate();
     $sql = 'SELECT id, title FROM #__osmembership_plans WHERE published=1 ORDER BY ordering ';
     $db->setQuery($sql);
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('OSM_PLAN'), 'id', 'title');
     $options = array_merge($options, $db->loadObjectList());
     $lists['plan_id'] = JHtml::_('select.genericlist', $options, 'plan_id', ' class="inputbox" onchange="submit();"', 'id', 'title', $state->plan_id);
     $this->dateFormat = OSMembershipHelper::getConfigValue('date_format');
     $this->nullDate = '0000-00-00';
     $this->discountTypes = $discountTypes;
 }
Esempio n. 18
0
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  *	 
  */
 protected function getInput()
 {
     $attributes = $this->buildAttributes();
     /*if ($this->value && file_exists(JPATH_ROOT.'/media/com_osmembership/upload/'.$this->value))*/
     if ($this->value) {
         if ($this->name == "osm_avatar") {
             $str = '<div class="avatar" onclick="jQuery(\'#' . $this->name . '\').trigger(\'click\');" title="Click to Change" style="max-height:100px;overflow:hidden;"><img style="max-width:100px;" src="' . JURI::base() . 'media/com_osmembership/upload/' . OSMembershipHelper::getOriginalFilename($this->value) . '"/></div>';
             $str .= '<div><input style="display:none" onchange="jQuery(\'#osm_form\').submit()" type="file" name="' . $this->name . '" id="' . $this->name . '" value=""' . $attributes . $this->extraAttributes . ' /></div>';
             return $str;
         } else {
             return '<input type="file" name="' . $this->name . '" id="' . $this->name . '" value=""' . $attributes . $this->extraAttributes . ' />. ' . JText::_('OSM_CURRENT_FILE') . ' <strong>' . OSMembershipHelper::getOriginalFilename($this->value) . '</strong> <a href="index.php?option=com_osmembership&task=download_file&file_name=' . $this->value . '">' . JText::_('OSM_DOWNLOAD') . '</a>';
         }
     } else {
         return '<input type="file" name="' . $this->name . '" id="' . $this->name . '" value=""' . $attributes . $this->extraAttributes . ' />';
     }
 }
Esempio n. 19
0
 function store(&$data)
 {
     $db = $this->getDbo();
     $row = $this->getTable('OsMembership', 'Subscriber');
     $row->load($data['id']);
     if (isset($data['password'])) {
         $userData = array();
         $query = $db->getQuery(true);
         $query->select('COUNT(*)')->from('#__users')->where('email=' . $db->quote($data['email']))->where('id!=' . (int) $row->user_id);
         $db->setQuery($query);
         $total = $db->loadResult();
         if (!$total) {
             $userData['email'] = $data['email'];
         }
         if ($data['password']) {
             $userData['password2'] = $userData['password'] = $data['password'];
         }
         if (count($userData)) {
             $user = JFactory::getUser($row->user_id);
             $user->bind($userData);
             $user->save(true);
         }
     }
     if (!$row->bind($data)) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     if (!$row->check()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     if (!$row->store()) {
         $this->setError($db->getErrorMsg());
         return false;
     }
     //Store custom field data for this profile record
     $rowFields = OSMembershipHelper::getProfileFields(0, false);
     $form = new RADForm($rowFields);
     $form->storeData($row->id, $data);
     //Syncronize profile data of other subscription records from this subscriber
     OSMembershipHelper::syncronizeProfileData($row, $data);
     //Trigger event	onProfileUpdate event
     JPluginHelper::importPlugin('osmembership');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onProfileUpdate', array($row));
     return true;
 }
Esempio n. 20
0
 function display($tpl = null)
 {
     $items = $this->get('Data');
     //Process content plugin in the description
     for ($i = 0, $n = count($items); $i < $n; $i++) {
         $item = $items[$i];
         $item->description = JHtml::_('content.prepare', $item->description);
     }
     $pagination = $this->get('Pagination');
     $Itemid = JRequest::getInt('Itemid', 0);
     $config = OSMembershipHelper::getConfig();
     $this->assignRef('config', $config);
     $this->assignRef('items', $items);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('Itemid', $Itemid);
     parent::display($tpl);
 }
 function onAfterRoute()
 {
     if (file_exists(JPATH_ROOT . '/components/com_osmembership/osmembership.php')) {
         $option = JRequest::getCmd('option');
         $task = JRequest::getCmd('task');
         $view = JRequest::getCmd('view');
         if ($option == 'com_users' && $view == 'registration' || $option == 'com_comprofiler' && $task == 'registers' || $option == 'com_community' && $view == 'register') {
             require_once JPATH_ROOT . '/components/com_osmembership/helper/helper.php';
             $url = $this->params->get('redirect_url', OSMembershipHelper::getViewUrl(array('categories', 'plans', 'plan', 'register')));
             if (!$url) {
                 $Itemid = OSMembershipHelper::getItemid();
                 $url = JRoute::_('index.php?option=com_osmembership&view=plans&Itemid=' . $Itemid);
             }
             JFactory::getApplication()->redirect($url);
         }
     }
     return true;
 }
Esempio n. 22
0
 function display($tpl = null)
 {
     $db = JFactory::getDbo();
     $user = JFactory::getUser();
     if (!$user->id) {
         $return = JRoute::_('index.php?option=com_osmembership&view=renewmembership&Itemid=' . JRequest::getInt('Itemid'));
         JFactory::getApplication()->redirect('index.php?option=com_users&view=login&return=' . base64_encode($return), JText::_('OSM_LOGIN_TO_RENEW_MEMBERSHIP'));
     }
     $config = OSMembershipHelper::getConfig();
     $Itemid = JRequest::getInt('Itemid');
     $query = $db->getQuery(true);
     $query->select('a.*, b.username')->from('#__osmembership_subscribers AS a ')->leftJoin('#__users AS b ON a.user_id=b.id')->where('is_profile=1')->where("(a.email='{$user->email}' OR a.user_id={$user->id})");
     $db->setQuery($query);
     $item = $db->loadObject();
     if (!$item) {
         JFactory::getApplication()->redirect('index.php', JText::_('OSM_DONOT_HAVE_SUBSCRIPTION_RECORD_TO_RENEW'));
     }
     //Get renew and upgrade options
     $sql = 'SELECT DISTINCT plan_id FROM #__osmembership_subscribers WHERE profile_id=' . $item->id . ' AND (published = 1 OR published = 2)';
     $db->setQuery($sql);
     $planIds = $db->loadColumn();
     //Check to see whether the user can renew or not
     $canRenew = false;
     foreach ($planIds as $planId) {
         $sql = 'SELECT recurring_subscription, enable_renewal FROM #__osmembership_plans WHERE id=' . $planId;
         $db->setQuery($sql);
         $plan = $db->loadObject();
         if (!$plan->recurring_subscription && $plan->enable_renewal) {
             $canRenew = true;
             break;
         }
     }
     if (!$canRenew) {
         JFactory::getApplication()->redirect('index.php', JText::_('OSM_NO_RENEW_OPTIONS_AVAILABLE'));
     }
     //Load js file to support state field dropdown
     JFactory::getDocument()->addScript(JUri::base(true) . '/components/com_osmembership/assets/js/paymentmethods.js');
     //Need to get subscriptions information of the user
     $this->Itemid = $Itemid;
     $this->planIds = $planIds;
     $this->canRenew = $canRenew;
     $this->config = $config;
     parent::display($tpl);
 }
Esempio n. 23
0
 /**
  * Run when a membership activated
  * @param PlanOsMembership $row
  */
 function onMembershipActive($row)
 {
     $db = JFactory::getDbo();
     if (!$row->membership_id) {
         if ($row->user_id) {
             $sql = 'SELECT MAX(membership_id) FROM #__osmembership_subscribers WHERE user_id=' . $row->user_id;
             $db->setQuery($sql);
             $membershipId = (int) $db->loadResult();
             if ($membershipId) {
                 $row->membership_id = $membershipId;
             }
         }
         if (!$row->membership_id) {
             $row->membership_id = OSMembershipHelper::getMembershipId();
         }
         $row->store();
     }
     return true;
 }
Esempio n. 24
0
 function display($tpl = null)
 {
     $db = JFactory::getDbo();
     $item = $this->get('Data');
     $languages = OSMembershipHelper::getLanguages();
     $lists = array();
     if (property_exists($item, 'published')) {
         $lists['published'] = JHtml::_('select.booleanlist', 'published', ' class="inputbox" ', $item->published);
     }
     if (property_exists($item, 'access')) {
         $lists['access'] = JHtml::_('access.level', 'access', $item->access, 'class="inputbox"', false);
     }
     $this->_buildListArray($lists, $item);
     $this->item = $item;
     $this->lists = $lists;
     $this->languages = $languages;
     $this->_buildToolbar();
     parent::display($tpl);
 }
Esempio n. 25
0
 function onAfterInitialise()
 {
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         return true;
     }
     if (JPluginHelper::isEnabled('osmembership', 'urls')) {
         $db = JFactory::getDbo();
         $currentUrl = trim(JUri::getInstance()->toString());
         //remove www in the url
         $currentUrl = str_replace('www.', '', $currentUrl);
         $siteURL = JURI::root();
         $siteURL = str_replace('www.', '', $siteURL);
         if ($siteURL == $currentUrl) {
             //Dont' prevent access to homepage
             return;
         }
         $sql = 'SELECT DISTINCT plan_id FROM #__osmembership_urls WHERE url = "' . $currentUrl . '"';
         $db->setQuery($sql);
         $planIds = $db->loadColumn();
         if (count($planIds)) {
             //Check to see the current user has an active subscription plans
             require_once JPATH_ROOT . '/components/com_osmembership/helper/helper.php';
             $activePlans = OSMembershipHelper::getActiveMembershipPlans();
             if (!count(array_intersect($planIds, $activePlans))) {
                 //Load language file
                 OSMembershipHelper::loadLanguage();
                 //Get title of these subscription plans
                 $sql = 'SELECT title FROM #__osmembership_plans WHERE id IN (' . implode(',', $planIds) . ') AND published=1 ORDER BY ordering';
                 $db->setQuery($sql);
                 $planTitles = $db->loadColumn();
                 $planTitles = implode(' OR ', $planTitles);
                 $msg = JText::_('OS_MEMBERSHIP_URL_ACCESS_RESITRICTED');
                 $msg = str_replace('[PLAN_TITLES]', $planTitles, $msg);
                 $redirectUrl = $this->params->get('redirect_url', OSMembershipHelper::getViewUrl(array('categories', 'plans', 'plan', 'register')));
                 if (!$redirectUrl) {
                     $redirectUrl = JUri::root();
                 }
                 JFactory::getApplication()->redirect($redirectUrl, $msg);
             }
         }
     }
 }
 function onAfterRoute()
 {
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         return true;
     }
     $user = JFactory::getUser();
     if ($user->authorise('core.admin')) {
         return true;
     }
     $option = JRequest::getCmd('option');
     $view = JRequest::getCmd('view');
     if ($option != 'com_content' || $view != 'article') {
         return true;
     }
     require_once JPATH_ROOT . '/components/com_osmembership/helper/helper.php';
     OSMembershipHelper::loadLanguage();
     $db = JFactory::getDbo();
     $articleId = JRequest::getInt('id');
     $sql = 'SELECT DISTINCT plan_id FROM #__osmembership_articles WHERE article_id = ' . $articleId;
     $db->setQuery($sql);
     $planIds = $db->loadColumn();
     if (count($planIds)) {
         //Check to see the current user has an active subscription plans
         require_once JPATH_ROOT . '/components/com_osmembership/helper/helper.php';
         $activePlans = OSMembershipHelper::getActiveMembershipPlans();
         if (!count(array_intersect($planIds, $activePlans))) {
             //Get title of these subscription plans
             $sql = 'SELECT title FROM #__osmembership_plans WHERE id IN (' . implode(',', $planIds) . ') AND published=1 ORDER BY ordering';
             $db->setQuery($sql);
             $planTitles = $db->loadColumn();
             $planTitles = implode(' OR ', $planTitles);
             $msg = JText::_('OS_MEMBERSHIP_ARTICLE_ACCESS_RESITRICTED');
             $msg = str_replace('[PLAN_TITLES]', $planTitles, $msg);
             $redirectUrl = $this->params->get('redirect_url', OSMembershipHelper::getViewUrl(array('categories', 'plans', 'plan', 'register')));
             if (!$redirectUrl) {
                 $redirectUrl = JUri::root();
             }
             JFactory::getApplication()->redirect($redirectUrl, $msg);
         }
     }
 }
Esempio n. 27
0
 function display($tpl = null)
 {
     $config = OSMembershipHelper::getConfig();
     $Itemid = JRequest::getInt('Itemid', 0);
     $item = $this->get('Data');
     if (!in_array($item->access, JFactory::getUser()->getAuthorisedViewLevels())) {
         JFactory::getApplication()->redirect('index.php', JText::_('OSM_NOT_ALLOWED_PLAN'));
     }
     $taxRate = OSMembershipHelper::calculateTaxRate($item->id);
     if ($config->show_price_including_tax && $taxRate > 0) {
         $item->price = $item->price * (1 + $taxRate / 100);
         $item->trial_amount = $item->trial_amount * (1 + $taxRate / 100);
     }
     $item->short_description = JHtml::_('content.prepare', $item->short_description);
     $item->description = JHtml::_('content.prepare', $item->description);
     $this->item = $item;
     $this->Itemid = $Itemid;
     $this->config = $config;
     parent::display($tpl);
 }
Esempio n. 28
0
 function display($tpl = null)
 {
     $user = JFactory::getUser();
     $userId = $user->get('id');
     if (!$userId) {
         $Itemid = JRequest::getInt('Itemid');
         $returnUrl = JRoute::_('index.php?option=com_osmembership&view=subscriptions&Itemid=' . $Itemid);
         $app = JFactory::getApplication();
         $url = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($returnUrl));
         $app->redirect($url, JText::_('OSM_PLEASE_LOGIN'));
     }
     $config = OSMembershipHelper::getConfig();
     $Itemid = JRequest::getInt('Itemid');
     $items = $this->get('Data');
     $pagination = $this->get('Pagination');
     $this->items = $items;
     $this->Itemid = $Itemid;
     $this->config = $config;
     $this->pagination = $pagination;
     parent::display($tpl);
 }
Esempio n. 29
0
 function display($tpl = null)
 {
     $user = JFactory::getUser();
     $config = OSMembershipHelper::getConfig();
     $Itemid = JRequest::getInt('Itemid', 0);
     $item = $this->get('Data');
     if ($item->user_id != $user->get('id')) {
         $app = JFactory::getApplication();
         $app->redirect('index.php', JText::_('OSM_INVALID_ACTION'));
     }
     //Form
     $rowFields = OSMembershipHelper::getProfileFields($item->plan_id, true, $item->language);
     $data = OSMembershipHelper::getProfileData($item, $item->plan_id, $rowFields);
     $form = new RADForm($rowFields);
     $form->setData($data)->bindData();
     $this->Itemid = $Itemid;
     $this->config = $config;
     $this->item = $item;
     $this->form = $form;
     parent::display($tpl);
 }
Esempio n. 30
0
 function display($tpl = null)
 {
     $user = JFactory::getUser();
     $db = JFactory::getDbo();
     $config = OSMembershipHelper::getConfig();
     $Itemid = JRequest::getInt('Itemid');
     $query = $db->getQuery(true);
     $query->select('a.*, b.username')->from('#__osmembership_subscribers AS a ')->leftJoin('#__users AS b ON a.user_id=b.id')->where('is_profile=1')->where("(a.email='{$user->email}' OR user_id={$user->id})");
     $db->setQuery($query);
     $item = $db->loadObject();
     if (!$item) {
         JFactory::getApplication()->redirect('index.php', JText::_('OSM_DONOT_HAVE_SUBSCRIPTION_RECORD_TO_UPGRADE'));
     }
     // Get upgrade options
     $query->clear();
     $query->select('DISTINCT plan_id')->from('#__osmembership_subscribers')->where('profile_id = ' . $item->id)->where('published = 1');
     $db->setQuery($query);
     $planIds = $db->loadColumn();
     $query->clear();
     $query->select('*')->from('#__osmembership_upgraderules')->where('from_plan_id IN (' . implode(',', $planIds) . ')')->order('from_plan_id');
     $db->setQuery($query);
     $upgradeRules = $db->loadObjectList();
     if (!count($upgradeRules)) {
         JFactory::getApplication()->redirect('index.php', JText::_('OSM_NO_UPGRADE_OPTIONS_AVAILABLE'));
     }
     $query->clear();
     $query->select('*')->from('#__osmembership_plans')->where('published = 1');
     $db->setQuery($query);
     $plans = $db->loadObjectList('id');
     // Load js file to support state field dropdown
     JFactory::getDocument()->addScript(JUri::base(true) . '/components/com_osmembership/assets/js/paymentmethods.js');
     // Need to get subscriptions information of the user
     $this->Itemid = $Itemid;
     $this->planIds = $planIds;
     $this->upgradeRules = $upgradeRules;
     $this->config = $config;
     $this->plans = $plans;
     parent::display($tpl);
 }