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); }
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; }
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); }
/** * Get profile data of the subscriber, using for json format * */ function get_profile_data() { $config = OSMembershipHelper::getConfig(); $input = JFactory::getApplication()->input; $userId = $input->getInt('user_id', 0); $planId = $input->getInt('plan_id'); $data = array(); if ($userId && $planId) { $rowFields = OSMembershipHelper::getProfileFields($planId, true); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->clear(); $query->select('*')->from('#__osmembership_subscribers')->where('user_id=' . $userId . ' AND is_profile=1'); $db->setQuery($query); $rowProfile = $db->loadObject(); if ($rowProfile) { $data = OSMembershipHelper::getProfileData($rowProfile, $planId, $rowFields); } elseif (JPluginHelper::isEnabled('user', 'profile') && !$config->cb_integration) { $syncronizer = new RADSynchronizerJoomla(); $mappings = array(); foreach ($rowFields as $rowField) { if ($rowField->profile_field_mapping) { $mappings[$rowField->name] = $rowField->profile_field_mapping; } } $data = $syncronizer->getData($userId, $mappings); } else { // Trigger plugin to get data $mappings = array(); foreach ($rowFields as $rowField) { if ($rowField->field_mapping) { $mappings[$rowField->name] = $rowField->field_mapping; } } JPluginHelper::importPlugin('osmembership'); $dispatcher = JDispatcher::getInstance(); $results = $dispatcher->trigger('onGetProfileData', array($userId, $mappings)); if (count($results)) { foreach ($results as $res) { if (is_array($res) && count($res)) { $data = $res; break; } } } } } if ($userId && !isset($data['first_name'])) { //Load the name from Joomla default name $user = JFactory::getUser($userId); $name = $user->name; if ($name) { $pos = strpos($name, ' '); if ($pos !== false) { $data['first_name'] = substr($name, 0, $pos); $data['last_name'] = substr($name, $pos + 1); } else { $data['first_name'] = $name; $data['last_name'] = ''; } } } if ($userId && !isset($data['email'])) { $user = JFactory::getUser($userId); $data['email'] = $user->email; } echo json_encode($data); JFactory::getApplication()->close(); }
/** * Get detail information of the subscription * * @param object $config * @param object $row * * @return string */ public static function getEmailContent($config, $row, $toAdmin = false) { $db = JFactory::getDbo(); $sql = 'SELECT lifetime_membership, title FROM #__osmembership_plans WHERE id=' . $row->plan_id; $db->setQuery($sql); $plan = $db->loadObject(); $data = array(); $data['planTitle'] = $plan->title; $data['lifetimeMembership'] = $plan->lifetime_membership; $data['config'] = $config; $data['row'] = $row; $data['toAdmin'] = $toAdmin; if ($row->payment_method == 'os_creditcard') { $cardNumber = JRequest::getVar('x_card_num', ''); $last4Digits = substr($cardNumber, strlen($cardNumber) - 4); $data['last4Digits'] = $last4Digits; } if ($row->user_id) { $sql = 'SELECT username FROM #__users WHERE id=' . $row->user_id; $db->setQuery($sql); $username = $db->loadResult(); $data['username'] = $username; } if ($row->username && $row->user_password) { $data['username'] = $row->username; //Password $privateKey = md5(JFactory::getConfig()->get('secret')); $key = new JCryptKey('simple', $privateKey, $privateKey); $crypt = new JCrypt(new JCryptCipherSimple(), $key); $data['password'] = $crypt->decrypt($row->user_password); } $rowFields = OSMembershipHelper::getProfileFields($row->plan_id); $formData = OSMembershipHelper::getProfileData($row, $row->plan_id, $rowFields); $form = new RADForm($rowFields); $form->setData($formData)->bindData(); $data['form'] = $form; return OSMembershipHelperHtml::loadCommonLayout(JPATH_ROOT . '/components/com_osmembership/emailtemplates/email.php', $data); }
function display($tpl = null) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $user = JFactory::getUser(); $config = OSMembershipHelper::getConfig(); $messageObj = OSMembershipHelper::getMessages(); $fieldSuffix = OSMembershipHelper::getFieldSuffix(); JFactory::getDocument()->addScript(JUri::base(true) . '/components/com_osmembership/assets/js/paymentmethods.js'); $userId = $user->get('id'); $Itemid = JRequest::getInt('Itemid', 0); if (!$Itemid) { $Itemid = OSMembershipHelper::getItemid(); } $planId = JRequest::getInt('id', 0); // Check to see whether this is a valid form or not if (!$planId) { JFactory::getApplication()->redirect('index.php', JText::_('OSM_INVALID_MEMBERSHIP_PLAN')); } $query->select('*, title' . $fieldSuffix . ' AS title')->from('#__osmembership_plans')->where('id=' . $planId); $db->setQuery($query); $plan = $db->loadObject(); if ($plan->published == 0 || !$plan) { JFactory::getApplication()->redirect('index.php', JText::_('OSM_CANNOT_ACCESS_UNPUBLISHED_PLAN')); return; } if (!in_array($plan->access, $user->getAuthorisedViewLevels())) { JFactory::getApplication()->redirect('index.php', JText::_('OSM_NOT_ALLOWED_PLAN')); } // Check if user can subscribe to the plan if (!OSMembershipHelper::canSubscribe($plan)) { if ($config->number_days_before_renewal) { // Redirect to memberhsip profile page $app = JFactory::getApplication(); $app->enqueueMessage(JText::sprintf('OSM_COULD_NOT_RENEWAL', $config->number_days_before_renewal), 'message'); $profileItemId = OSMembershipHelperRoute::findView('profile', $Itemid); $app->redirect(JRoute::_('index.php?option=com_osmembership&view=profile&Itemid=' . $profileItemId)); } else { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('OSM_YOU_ARE_NOT_ALLOWED_TO_SIGNUP'), 'message'); $app->redirect('index.php'); } } $paymentMethod = JRequest::getVar('payment_method', os_payments::getDefautPaymentMethod(), 'post'); if (!$paymentMethod) { $paymentMethod = os_payments::getDefautPaymentMethod(); } $renewOptionId = JRequest::getInt('renew_option_id', 0); $upgradeOptionId = JRequest::getInt('upgrade_option_id', 0); if ($renewOptionId) { $action = 'renew'; } elseif ($upgradeOptionId) { $action = 'upgrade'; } else { $action = 'subscribe'; } ###############Payment Methods parameters############################### $lists['exp_month'] = JHtml::_('select.integerlist', 1, 12, 1, 'exp_month', ' id="exp_month" class="input-small" ', JRequest::getVar('exp_month', date('m'), 'post'), '%02d'); $currentYear = date('Y'); $lists['exp_year'] = JHtml::_('select.integerlist', $currentYear, $currentYear + 10, 1, 'exp_year', ' id="exp_year" class="input-small" ', JRequest::getVar('exp_year', date('Y'), 'post')); $options = array(); $cardTypes = explode(',', $config->enable_cardtypes); if (in_array('Visa', $cardTypes)) { $options[] = JHtml::_('select.option', 'Visa', JText::_('OSM_VISA_CARD')); } if (in_array('MasterCard', $cardTypes)) { $options[] = JHtml::_('select.option', 'MasterCard', JText::_('OSM_MASTER_CARD')); } if (in_array('Discover', $cardTypes)) { $options[] = JHtml::_('select.option', 'Discover', JText::_('OSM_DISCOVER')); } if (in_array('Amex', $cardTypes)) { $options[] = JHtml::_('select.option', 'Amex', JText::_('OSM_AMEX')); } $lists['card_type'] = JHtml::_('select.genericlist', $options, 'card_type', ' class="inputbox" ', 'value', 'text', JRequest::getVar('card_type', null, 'post')); $options = array(); $options[] = JHtml::_('select.option', 'CHECKING', JText::_('OSM_BANK_TYPE_CHECKING')); $options[] = JHtml::_('select.option', 'BUSINESSCHECKING', JText::_('OSM_BANK_TYPE_BUSINESSCHECKING')); $options[] = JHtml::_('select.option', 'SAVINGS', JText::_('OSM_BANK_TYPE_SAVINGS')); $lists['x_bank_acct_type'] = JHtml::_('select.genericlist', $options, 'x_bank_acct_type', ' class="inputbox" ', 'value', 'text', JRequest::getVar('x_bank_acct_type', null, 'post')); // IDEAL Mollie payment plugin support $idealEnabled = OSMembershipHelper::idealEnabled(); if ($idealEnabled) { $bankLists = OSMembershipHelper::getBankLists(); $options = array(); foreach ($bankLists as $bankId => $bankName) { $options[] = JHtml::_('select.option', $bankId, $bankName); } $lists['bank_id'] = JHtml::_('select.genericlist', $options, 'bank_id', ' class="inputbox" ', 'value', 'text', JRequest::getInt('bank_id')); } if ($plan->recurring_subscription) { $onlyRecurring = 1; } else { $onlyRecurring = 0; } if ($action == 'renew' || $action == 'upgrade') { $methods = os_payments::getPaymentMethods(true, $onlyRecurring); } else { $methods = os_payments::getPaymentMethods(true, $onlyRecurring); } if (count($methods) == 0) { JFactory::getApplication()->redirect('index.php', JText::_('OSM_NEED_TO_PUBLISH_PLUGIN')); } // Check to see if there is payment processing fee or not $showPaymentFee = false; foreach ($methods as $method) { if ($method->paymentFee) { $showPaymentFee = true; break; } } $this->showPaymentFee = $showPaymentFee; $rowFields = OSMembershipHelper::getProfileFields($planId, true, null, $action); if (isset($_POST['first_name'])) { $data = JRequest::get('post', JREQUEST_ALLOWHTML); } else { $data = array(); if ($userId) { // Check to see if this user has profile data already $query->clear(); $query->select('*')->from('#__osmembership_subscribers')->where('user_id=' . $userId . ' AND is_profile=1'); $db->setQuery($query); $rowProfile = $db->loadObject(); if ($rowProfile) { $data = OSMembershipHelper::getProfileData($rowProfile, $planId, $rowFields); } elseif (JPluginHelper::isEnabled('user', 'profile')) { $syncronizer = new RADSynchronizerJoomla(); $mappings = array(); foreach ($rowFields as $rowField) { if ($rowField->profile_field_mapping) { $mappings[$rowField->name] = $rowField->profile_field_mapping; } } $data = $syncronizer->getData($userId, $mappings); } else { // Trigger plugin to get data $mappings = array(); foreach ($rowFields as $rowField) { if ($rowField->field_mapping) { $mappings[$rowField->name] = $rowField->field_mapping; } } JPluginHelper::importPlugin('osmembership'); $dispatcher = JDispatcher::getInstance(); $results = $dispatcher->trigger('onGetProfileData', array($userId, $mappings)); if (count($results)) { foreach ($results as $res) { if (is_array($res) && count($res)) { $data = $res; break; } } } } } } if ($userId && !isset($data['first_name'])) { // Load the name from Joomla default name $name = $user->name; if ($name) { $pos = strpos($name, ' '); if ($pos !== false) { $data['first_name'] = substr($name, 0, $pos); $data['last_name'] = substr($name, $pos + 1); } else { $data['first_name'] = $name; $data['last_name'] = ''; } } } if ($userId && !isset($data['email'])) { $data['email'] = $user->email; } if (!isset($data['country']) || !$data['country']) { $data['country'] = $config->default_country; } $countryCode = OSMembershipHelper::getCountryCode($data['country']); // Get data $form = new RADForm($rowFields); $form->setData($data)->bindData(true); $form->prepareFormFields('calculateSubscriptionFee();'); $data['renew_option_id'] = $renewOptionId; $data['upgrade_option_id'] = $upgradeOptionId; $data['act'] = $action; $fees = OSMembershipHelper::calculateSubscriptionFee($plan, $form, $data, $config, $paymentMethod); $amount = $fees['amount']; if ($action == 'renew') { if (strlen(strip_tags($messageObj->{'subscription_renew_form_msg' . $fieldSuffix}))) { $message = $messageObj->{'subscription_renew_form_msg' . $fieldSuffix}; } else { $message = $messageObj->subscription_renew_form_msg; } if ($renewOptionId == OSM_DEFAULT_RENEW_OPTION_ID) { switch ($plan->subscription_length_unit) { case 'D': $text = $plan->subscription_length > 1 ? JText::_('OSM_DAYS') : JText::_('OSM_DAY'); break; case 'W': $text = $plan->subscription_length > 1 ? JText::_('OSM_WEEKS') : JText::_('OSM_WEEK'); break; case 'M': $text = $plan->subscription_length > 1 ? JText::_('OSM_MONTHS') : JText::_('OSM_MONTH'); break; case 'Y': $text = $plan->subscription_length > 1 ? JText::_('OSM_YEARS') : JText::_('OSM_YEAR'); break; } $message = str_replace('[NUMBER_DAYS] days', $plan->subscription_length . ' ' . $text, $message); } else { $query->clear(); $query->select('number_days')->from('#__osmembership_renewrates')->where('id=' . $renewOptionId); $db->setQuery($query); $numberDays = $db->loadResult(); $message = str_replace('[NUMBER_DAYS]', $numberDays, $message); } $message = str_replace('[PLAN_TITLE]', $plan->title, $message); $message = str_replace('[AMOUNT]', OSMembershipHelper::formatCurrency($amount, $config), $message); } elseif ($action == 'upgrade') { if (strlen(strip_tags($messageObj->{'subscription_upgrade_form_msg' . $fieldSuffix}))) { $message = $messageObj->{'subscription_upgrade_form_msg' . $fieldSuffix}; } else { $message = $messageObj->subscription_upgrade_form_msg; } $query->clear(); $query->select('b.title')->from('#__osmembership_upgraderules AS a')->innerJoin('#__osmembership_plans AS b ON a.from_plan_id=b.id')->where('a.id=' . $upgradeOptionId); $db->setQuery($query); $fromPlan = $db->loadResult(); $message = str_replace('[PLAN_TITLE]', $plan->title, $message); $message = str_replace('[AMOUNT]', OSMembershipHelper::formatCurrency($amount, $config), $message); $message = str_replace('[FROM_PLAN_TITLE]', $fromPlan, $message); } else { if (strlen(strip_tags($plan->{'subscription_form_message' . $fieldSuffix})) || strlen(strip_tags($plan->subscription_form_message))) { if (strlen(strip_tags($plan->{'subscription_form_message' . $fieldSuffix}))) { $message = $plan->{'subscription_form_message' . $fieldSuffix}; } else { $message = $plan->subscription_form_message; } } else { if (strlen(strip_tags($messageObj->{'subscription_form_msg' . $fieldSuffix}))) { $message = $messageObj->{'subscription_form_msg' . $fieldSuffix}; } else { $message = $messageObj->subscription_form_msg; } } if ($plan->recurring_subscription) { //We will first need to detect regular duration if ($plan->trial_duration) { $trialPeriorText = JText::_('OSM_TRIAL_RECURRING_SUBSCRIPTION_PERIOR'); $trialPeriorText = str_replace('[TRIAL_DURATION]', $plan->trial_duration, $trialPeriorText); switch ($plan->trial_duration_unit) { case 'D': $trialPeriorText = str_replace('[TRIAL_DURATION_UNIT]', $plan->trial_duration > 1 ? JText::_('OSM_DAYS') : JText::_('OSM_DAY'), $trialPeriorText); break; case 'W': $trialPeriorText = str_replace('[TRIAL_DURATION_UNIT]', $plan->trial_duration > 1 ? JText::_('OSM_WEEKS') : JText::_('OSM_WEEK'), $trialPeriorText); break; case 'M': $trialPeriorText = str_replace('[TRIAL_DURATION_UNIT]', $plan->trial_duration > 1 ? JText::_('OSM_MONTHS') : JText::_('OSM_MONTH'), $trialPeriorText); break; case 'Y': $trialPeriorText = str_replace('[TRIAL_DURATION_UNIT]', $plan->trial_duration > 1 ? JText::_('OSM_YEARS') : JText::_('OSM_YEAR'), $trialPeriorText); break; default: $trialPeriorText = str_replace('[TRIAL_DURATION_UNIT]', $plan->trial_duration > 1 ? JText::_('OSM_DAYS') : JText::_('OSM_DAY'), $trialPeriorText); break; } $this->trialPeriorText = $trialPeriorText; } $length = $plan->subscription_length; $regularPeriorText = JText::_('OSM_REGULAR_SUBSCRIPTION_PERIOR'); $regularPeriorText = str_replace('[REGULAR_DURATION]', $length, $regularPeriorText); switch ($plan->subscription_length_unit) { case 'D': $regularPeriorText = str_replace('[REGULAR_DURATION_UNIT]', $length > 1 ? JText::_('OSM_DAYS') : JText::_('OSM_DAY'), $regularPeriorText); break; case 'W': $regularPeriorText = str_replace('[REGULAR_DURATION_UNIT]', $length > 1 ? JText::_('OSM_WEEKS') : JText::_('OSM_WEEK'), $regularPeriorText); break; case 'M': $regularPeriorText = str_replace('[REGULAR_DURATION_UNIT]', $length > 1 ? JText::_('OSM_MONTHS') : JText::_('OSM_MONTH'), $regularPeriorText); break; case 'Y': $regularPeriorText = str_replace('[REGULAR_DURATION_UNIT]', $length > 1 ? JText::_('OSM_YEARS') : JText::_('OSM_YEAR'), $regularPeriorText); break; default: $regularPeriorText = str_replace('[REGULAR_DURATION_UNIT]', $length > 1 ? JText::_('OSM_DAYS') : JText::_('OSM_DAY'), $regularPeriorText); break; } $this->regularPeriorText = $regularPeriorText; $message = str_replace('[PLAN_TITLE]', $plan->title, $message); $message = str_replace('[AMOUNT]', OSMembershipHelper::formatCurrency($amount, $config), $message); } else { $message = str_replace('[PLAN_TITLE]', $plan->title, $message); $message = str_replace('[AMOUNT]', OSMembershipHelper::formatCurrency($amount, $config), $message); } } // Implement Joomla core recpatcha $showCaptcha = 0; if ($config->enable_captcha) { $captchaPlugin = JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha')); if ($captchaPlugin) { $showCaptcha = 1; $this->captcha = JCaptcha::getInstance($captchaPlugin)->display('dynamic_recaptcha_1', 'dynamic_recaptcha_1', 'required'); } else { JFactory::getApplication()->enqueueMessage(JText::_('OSM_CAPTCHA_NOT_ACTIVATED_IN_YOUR_SITE'), 'error'); } } // Assign variables to template $this->userId = $userId; $this->paymentMethod = $paymentMethod; $this->lists = $lists; $this->Itemid = $Itemid; $this->config = $config; $this->plan = $plan; $this->methods = $methods; $this->idealEnabled = $idealEnabled; $this->action = $action; $this->renewOptionId = $renewOptionId; $this->upgradeOptionId = $upgradeOptionId; $this->message = $message; $this->form = $form; $this->fees = $fees; $this->showCaptcha = $showCaptcha; $this->countryBaseTax = (int) OSMembershipHelper::isCountryBaseTax(); $this->taxRate = OSMembershipHelper::calculateTaxRate($planId); $this->countryCode = $countryCode; parent::display($tpl); }
function display($tpl = null) { $db = JFactory::getDbo(); $user = JFactory::getUser(); if (!$user->id) { $return = JRoute::_('index.php?option=com_osmembership&view=profile&Itemid=' . JRequest::getInt('Itemid')); JFactory::getApplication()->redirect('index.php?option=com_users&view=login&return=' . base64_encode($return), JText::_('OSM_LOGIN_TO_EDIT_PROFILE')); } $config = OSMembershipHelper::getConfig(); $Itemid = JRequest::getInt('Itemid'); $item = $this->get('Data'); if (!$item) { $redirectURL = OSMembershipHelper::getViewUrl(array('categories', 'plans', 'plan', 'register')); if (!$redirectURL) { $redirectURL = 'index.php'; } JFactory::getApplication()->redirect('index.php', JText::_('OSM_DONOT_HAVE_SUBSCRIPTION_RECORD')); } //Get subscriptions history require_once JPATH_COMPONENT . '/models/subscriptions.php'; $model = JModelLegacy::getInstance('Subscriptions', 'OSMembershipModel'); $items = $model->getData(); //Form $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(); $results = $dispatcher->trigger('onProfileDisplay', array($item)); //Get renew and upgrade options, only allow renew for active or expired subscriptions $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; } } //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 $plans = OSMembershipHelper::getSubscriptions($item->profile_id); $renewOptions = array(); $this->item = $item; $this->config = $config; $this->items = $items; $this->form = $form; $this->Itemid = $Itemid; $this->plugins = $results; $this->planIds = $planIds; $this->plans = $plans; $this->canRenew = $canRenew; parent::display($tpl); }