$invoice = false; if ($metaUser->hasSubscription) { // Make sure this really is expired if (!$metaUser->objSubscription->isExpired()) { return getView('access_denied'); } $expired = strtotime($metaUser->objSubscription->expiration); $trial = strcmp($metaUser->objSubscription->status, 'Trial') === 0; if (!$trial) { $params = $metaUser->objSubscription->params; if (isset($params['trialflag'])) { $trial = 1; } } } $invoices = aecInvoiceHelper::InvoiceCountbyUserID($metaUser->userid); if ($invoices) { $invoice = aecInvoiceHelper::lastUnclearedInvoiceIDbyUserID($metaUser->userid); } else { $invoice = null; } $expiration = AECToolbox::formatDate($expired); $tmpl->setTitle(JText::_('EXPIRED_TITLE')); $continue = false; if ($tmpl->cfg['continue_button'] && $metaUser->hasSubscription) { $status = SubscriptionPlanHandler::PlanStatus($metaUser->focusSubscription->plan); if (!empty($status)) { $continue = true; } } $intro = 0;
public function edit($userid, $subscriptionid, $task, $page = 0) { if (!empty($subscriptionid)) { $userid = aecUserHelper::UserIDfromSubscriptionID($subscriptionid); } if (!empty($subscriptionid)) { $sid = $subscriptionid; } else { $sid = 0; } $lists = array(); $metaUser = new metaUser($userid); if (!empty($sid)) { $metaUser->moveFocus($sid); } else { if ($metaUser->hasSubscription) { $sid = $metaUser->focusSubscription->id; } } if ($metaUser->loadSubscriptions() && !empty($sid)) { foreach ($metaUser->allSubscriptions as $s_id => $s_c) { if ($s_c->id == $sid) { $metaUser->allSubscriptions[$s_id]->current_focus = true; continue; } } } $invoices_limit = 15; $invoice_ids = aecInvoiceHelper::InvoiceIdList($metaUser->userid, $page * $invoices_limit, $invoices_limit); $group_selection = array(); $group_selection[] = JHTML::_('select.option', '', JText::_('EXPIRE_SET')); $group_selection[] = JHTML::_('select.option', 'expired', JText::_('EXPIRE_NOW')); $group_selection[] = JHTML::_('select.option', 'excluded', JText::_('EXPIRE_EXCLUDE')); $group_selection[] = JHTML::_('select.option', 'active', JText::_('EXPIRE_INCLUDE')); $group_selection[] = JHTML::_('select.option', 'closed', JText::_('EXPIRE_CLOSE')); $group_selection[] = JHTML::_('select.option', 'cancelled', JText::_('EXPIRE_CANCEL')); $group_selection[] = JHTML::_('select.option', 'hold', JText::_('EXPIRE_HOLD')); $lists['set_status'] = JHTML::_('select.genericlist', $group_selection, 'set_status', 'class="inputbox" size="1"', 'value', 'text', ''); $invoices = array(); $couponsh = array(); $invoice_counter = 0; $processors = PaymentProcessorHandler::getObjectList(PaymentProcessorHandler::getProcessorList()); $procs = array('free' => 'Free', 'none' => 'None'); foreach ($processors as $processor) { $procs[$processor->processor_name] = $processor->processor->info['longname']; } foreach ($invoice_ids as $inv_id) { $invoice = new Invoice(); $invoice->load($inv_id); if (!empty($invoice->coupons)) { foreach ($invoice->coupons as $coupon_code) { if (!isset($couponsh[$coupon_code])) { $couponsh[$coupon_code] = couponHandler::idFromCode($coupon_code); } $couponsh[$coupon_code]['invoices'][] = $invoice->invoice_number; } } if ($invoice_counter >= $invoices_limit && strcmp($invoice->transaction_date, '0000-00-00 00:00:00') !== 0) { continue; } else { $invoice_counter++; } $status = aecHTML::Icon('plus') . HTML_AcctExp::DisplayDateInLocalTime($invoice->created_date) . '<br />'; if (isset($invoice->params['deactivated'])) { $status .= aecHTML::Icon('remove-circle') . 'deactivated'; } elseif (strcmp($invoice->transaction_date, '0000-00-00 00:00:00') === 0) { if (isset($invoice->params['pending_reason'])) { if ($this->lang->hasKey('PAYMENT_PENDING_REASON_' . strtoupper($invoice->params['pending_reason']))) { $status .= aecHTML::Icon('warning-sign') . JText::_('PAYMENT_PENDING_REASON_' . strtoupper($invoice->params['pending_reason'])); } else { $status .= aecHTML::Icon('warning-sign') . $invoice->params['pending_reason']; } } else { $status .= aecHTML::Icon('time') . 'uncleared'; } } $actions = array(); $rowstyle = ''; if (strcmp($invoice->transaction_date, '0000-00-00 00:00:00') === 0) { $checkoutlink = AECToolbox::deadsureURL('index.php?option=com_acctexp&task=repeatPayment&invoice=' . $invoice->invoice_number); $actions = array(array('repeat', 'arrow-right', 'USERINVOICE_ACTION_REPEAT', 'info', '', $checkoutlink), array('cancel', 'remove', 'USERINVOICE_ACTION_CANCEL', 'danger'), array('clear', 'ok', 'USERINVOICE_ACTION_CLEAR_APPLY', 'success', '&applyplan=1'), array('clear', 'check', 'USERINVOICE_ACTION_CLEAR', 'warning')); $rowstyle = ' style="background-color:#fee;"'; } else { $status .= aecHTML::Icon('shopping-cart') . HTML_AcctExp::DisplayDateInLocalTime($invoice->transaction_date); } $actions[] = array('print', 'print', 'HISTORY_ACTION_PRINT', '', '&tmpl=component" target="_blank'); $actions[] = array('pdf', 'file', 'PDF', '', ''); $actionlist = '<div class="btn-group">'; foreach ($actions as $action) { if (!empty($action[5])) { $alink = $action[5]; } else { $alink = 'index.php?option=com_acctexp&task=' . $action[0] . 'Invoice&invoice=' . $invoice->invoice_number . '&returntask=edit&entity=Membership&userid=' . $metaUser->userid; if (!empty($action[4])) { $alink .= $action[4]; } } $actionlist .= aecHTML::Button($action[1], $action[2], $action[3], $alink); } $actionlist .= '</div>'; $non_formatted = $invoice->invoice_number; $invoice->formatInvoiceNumber(); $is_formatted = $invoice->invoice_number; if ($non_formatted != $is_formatted) { $is_formatted = $non_formatted . "\n" . '(' . $is_formatted . ')'; } $invoices[$inv_id] = array(); $invoices[$inv_id]['rowstyle'] = $rowstyle; $invoices[$inv_id]['invoice_number'] = $is_formatted; $invoices[$inv_id]['amount'] = $invoice->amount . ' ' . $invoice->currency; $invoices[$inv_id]['status'] = $status; if ($procs[$invoice->method]) { $invoices[$inv_id]['processor'] = $invoice->method; } else { $invoices[$inv_id]['processor'] = $procs[$invoice->method]; } $invoices[$inv_id]['usage'] = $invoice->usage; $invoices[$inv_id]['actions'] = $actionlist; } $coupons = array(); $coupon_counter = 0; foreach ($couponsh as $coupon_code => $coupon) { if ($coupon_counter >= 10) { continue; } else { $coupon_counter++; } $cc = array(); $cc['coupon_code'] = '<a href="index.php?option=com_acctexp&task=edit&entity=Coupon&id=' . $coupon['type'] . '.' . $coupon['id'] . '">' . $coupon_code . '</a>'; $cc['invoices'] = implode(", ", $coupon['invoices']); $coupons[] = $cc; } // get available plans $available_plans = SubscriptionPlanHandler::getActivePlanList(false); $lists['assignto_plan'] = JHTML::_('select.genericlist', $available_plans, 'assignto_plan[]', 'size="1" multiple="multiple" class="select2-bootstrap"', 'value', 'text', 0); $userMIs = $metaUser->getUserMIs(); $mi = array(); $mi['profile'] = array(); $mi['admin'] = array(); $mi['profile_form'] = array(); $mi['admin_form'] = array(); $params = array(); foreach ($userMIs as $m) { $pref = 'mi_' . $m->id . '_'; $ui = $m->profile_info($metaUser); if (!empty($ui)) { $mi['profile'][] = array('name' => $m->info['name'] . ' - ' . $m->name, 'info' => $ui); } $uf = $m->profile_form($metaUser, true); if (!empty($uf)) { foreach ($uf as $k => $v) { $mi['profile_form'][] = $pref . $k; $params[$pref . $k] = $v; } } $ai = $m->admin_info($metaUser); if (!empty($ai)) { $mi['admin'][] = array('name' => $m->info['name'] . ' - ' . $m->name, 'info' => $ai); } $af = $m->admin_form($metaUser); if (!empty($af)) { foreach ($af as $k => $v) { $mi['admin_form'][] = $pref . $k; $params[$pref . $k] = $v; } } } if (!empty($params)) { $settings = new aecSettings('userForm', 'mi'); $settings->fullSettingsArray($params, array(), $lists); // Call HTML Class $aecHTML = new aecHTML($settings->settings, $settings->lists); } else { $aecHTML = new stdClass(); } $aecHTML->invoice_pages = (int) (aecInvoiceHelper::InvoiceCountbyUserID($metaUser->userid) / $invoices_limit); $aecHTML->invoice_page = $page; $aecHTML->sid = $sid; HTML_AcctExp::userForm($metaUser, $invoices, $coupons, $mi, $lists, $task, $aecHTML); }
public function executeCommand($command, $vars, $safe = false) { $result = ''; switch ($command) { case 'rw_constant': if (isset($this->rewrite[$vars])) { $result = $this->rewrite[$vars]; } break; case 'data': if (empty($this->data)) { return false; } $result = AECToolbox::getObjectProperty($this->data, $vars); break; case 'safedata': if (empty($this->data)) { return false; } if (AECToolbox::getObjectProperty($this->data, $vars, true)) { $result = AECToolbox::getObjectProperty($this->data, $vars); } break; case 'checkdata': if (empty($this->data)) { return false; } $result = AECToolbox::getObjectProperty($this->data, $vars, true); break; case 'checkdata_notempty': if (empty($this->data)) { return false; } $check = AECToolbox::getObjectProperty($this->data, $vars, true); if (AECToolbox::getObjectProperty($this->data, $vars, true)) { $check = AECToolbox::getObjectProperty($this->data, $vars); $result = !empty($check); } break; case 'metaUser': if (!is_object($this->data['metaUser'])) { return false; } // We also support dot notation for the vars, // so explode if that is what the admin wants here if (!is_array($vars) && strpos($vars, '.') !== false) { $temp = explode('.', $vars); $vars = $temp; } elseif (!is_array($vars)) { return false; } $result = $this->data['metaUser']->getProperty($vars); break; case 'invoice_count': if (!is_object($this->data['metaUser'])) { return false; } return aecInvoiceHelper::InvoiceCountbyUserID($this->data['metaUser']->userid); break; case 'invoice_count_paid': if (!is_object($this->data['metaUser'])) { return false; } return aecInvoiceHelper::PaidInvoiceCountbyUserID($this->data['metaUser']->userid); break; case 'invoice_count_unpaid': if (!is_object($this->data['metaUser'])) { return false; } return aecInvoiceHelper::UnpaidInvoiceCountbyUserID($this->data['metaUser']->userid); break; case 'jtext': $result = JText::_($vars); break; case 'constant': if (defined($vars)) { $result = constant($vars); } else { $result = JText::_($vars); } break; case 'global': if (is_array($vars)) { if (isset($vars[0]) && isset($vars[1])) { $call = strtoupper($vars[0]); $v = $vars[1]; $allowed = array('SERVER', 'GET', 'POST', 'FILES', 'COOKIE', 'SESSION', 'REQUEST', 'ENV'); if (in_array($call, $allowed)) { switch ($call) { case 'SERVER': if (isset($_SERVER[$v]) && !$safe) { $result = $_SERVER[$v]; } break; case 'GET': if (isset($_GET[$v])) { $result = $_GET[$v]; } break; case 'POST': if (isset($_POST[$v])) { $result = $_POST[$v]; } break; case 'FILES': if (isset($_FILES[$v]) && !$safe) { $result = $_FILES[$v]; } break; case 'COOKIE': if (isset($_COOKIE[$v])) { $result = $_COOKIE[$v]; } break; case 'SESSION': if (isset($_SESSION[$v])) { $result = $_SESSION[$v]; } break; case 'REQUEST': if (isset($_REQUEST[$v])) { $result = $_REQUEST[$v]; } break; case 'ENV': if (isset($_ENV[$v]) && !$safe) { $result = $_ENV[$v]; } break; } } } } else { if (isset($GLOBALS[$vars])) { $result = $GLOBALS[$vars]; } } break; case 'condition': if (empty($vars[0]) || !isset($vars[1])) { if (isset($vars[2])) { $result = $vars[2]; } else { $result = ''; } } elseif (isset($vars[1])) { $result = $vars[1]; } else { $result = ''; } break; case 'hastext': $result = strpos($vars[0], $vars[1]) !== false ? 1 : 0; break; case 'uppercase': $result = strtoupper($vars); break; case 'lowercase': $result = strtoupper($vars); break; case 'concat': $result = implode($vars); break; case 'date': $result = date($vars[0], strtotime($vars[1])); break; case 'date_distance': $result = round($vars - (int) gmdate('U')); break; case 'date_distance_days': $result = round(($vars - (int) gmdate('U')) / 86400); break; case 'crop': if (isset($vars[2])) { $result = substr($vars[0], (int) $vars[1], (int) $vars[2]); } else { $result = substr($vars[0], (int) $vars[1]); } break; case 'pad': if (isset($vars[3])) { $result = str_pad($vars[0], (int) $vars[1], $vars[2], JText::_("STR_PAD_" . strtoupper($vars[3]))); } elseif (isset($vars[2])) { $result = str_pad($vars[0], (int) $vars[1], $vars[2]); } else { $result = str_pad($vars[0], (int) $vars[1]); } break; case 'chunk': $chunks = str_split($vars[0], (int) $vars[1]); if (isset($vars[2])) { $result = implode($vars[2], $chunks); } else { $result = implode(' ', $chunks); } break; case 'compare': if (isset($vars[2])) { $result = AECToolbox::compare($vars[1], $vars[0], $vars[2]); } else { $result = 0; } break; case 'math': if (isset($vars[2])) { $result = AECToolbox::math($vars[1], (double) $vars[0], (double) $vars[2]); } else { $result = 0; } break; case 'randomstring': $result = AECToolbox::randomstring((int) $vars); break; case 'randomstring_alphanum': $result = AECToolbox::randomstring((int) $vars, true); break; case 'randomstring_alphanum_large': $result = AECToolbox::randomstring((int) $vars, true, true); break; case 'php_function': if (!$safe) { if (isset($vars[1])) { $result = call_user_func_array($vars[0], $vars[1]); } else { $result = call_user_func_array($vars[0], array()); } } break; case 'php_method': if (!$safe) { $callback = array($vars[0], $vars[1]); if (isset($vars[2])) { $result = call_user_func_array($callback, $vars[2]); } else { $result = call_user_func_array($callback, array()); } } break; default: $result = $command . ' is no command'; break; } return $result; }
static function VerifyMetaUser($metaUser) { global $aecConfig; if (!$aecConfig->cfg['require_subscription']) { return true; } if ($metaUser->hasSubscription) { $result = $metaUser->objSubscription->verify($metaUser); if ($result == 'expired' || $result == 'pending') { $metaUser->setTempAuth(); } return $result; } if (!empty($aecConfig->cfg['entry_plan'])) { $payment_plan = new SubscriptionPlan(); $payment_plan->load($aecConfig->cfg['entry_plan']); $metaUser->establishFocus($payment_plan, 'free', false); $metaUser->focusSubscription->applyUsage($payment_plan->id, 'free', 1, 0); return AECToolbox::VerifyUser($metaUser->cmsUser->username); } else { $invoices = aecInvoiceHelper::InvoiceCountbyUserID($metaUser->userid); $metaUser->setTempAuth(); if ($invoices) { $invoice = aecInvoiceHelper::lastUnclearedInvoiceIDbyUserID($metaUser->userid); if ($invoice) { return 'open_invoice'; } } return 'subscribe'; } }
* @copyright 2012 Copyright (C) David Deutsch * @author David Deutsch <*****@*****.**> & Team AEC - http://www.valanx.org * @license GNU/GPL v.3 http://www.gnu.org/licenses/gpl.html or, at your option, any later version */ // Dont allow direct linking defined('_JEXEC') or die('Direct Access to this location is not allowed.'); if ($userid == 0) { return aecRedirect(AECToolbox::deadsureURL('index.php')); } if ($metaUser->hasSubscription) { // Make sure this really is pending if (strcmp($metaUser->objSubscription->status, 'Pending') !== 0) { return getView('access_denied'); } } $invoices = aecInvoiceHelper::InvoiceCountbyUserID($userid); $reason = ""; if ($invoices) { $invoice = aecInvoiceHelper::lastUnclearedInvoiceIDbyUserID($userid); $objInvoice = new Invoice(); $objInvoice->loadInvoiceNumber($invoice); $params = $objInvoice->params; if (isset($params['pending_reason'])) { $lang = JFactory::getLanguage(); if ($lang->hasKey('PENDING_REASON_' . strtoupper($params['pending_reason']))) { $reason = JText::_('PENDING_REASON_' . strtoupper($params['pending_reason'])); } else { $reason = $params['pending_reason']; } } elseif (strcmp($objInvoice->method, 'transfer') === 0) { $reason = 'transfer';