コード例 #1
0
ファイル: acctexp.user.class.php プロジェクト: Ibrahim1/aec
 public function CustomRestrictionResponse($restrictions)
 {
     $s = array();
     $n = 0;
     if (is_array($restrictions) && !empty($restrictions)) {
         foreach ($restrictions as $restriction) {
             $check1 = AECToolbox::rewriteEngine($restriction[0], $this);
             $check2 = AECToolbox::rewriteEngine($restriction[2], $this);
             $eval = $restriction[1];
             if ($check1 === $restriction[0] && reWriteEngine::isRWEstring($restriction[0])) {
                 $check1 = null;
             }
             if ($check2 === $restriction[2] && reWriteEngine::isRWEstring($restriction[2])) {
                 $check2 = null;
             }
             $s['customchecker' . $n] = AECToolbox::compare($eval, $check1, $check2);
             $n++;
         }
     }
     return $s;
 }
コード例 #2
0
 public function rw($string)
 {
     return AECToolbox::rewriteEngine($string, $this->metaUser);
 }
コード例 #3
0
 public function formatInvoiceNumber($invoice = null, $nostore = false)
 {
     global $aecConfig;
     if (empty($invoice)) {
         $subject = $this;
     } else {
         $subject = $invoice;
     }
     $invoice_number = $subject->invoice_number;
     if (empty($subject->invoice_number_format) && $aecConfig->cfg['invoicenum_doformat']) {
         $invoice_number = AECToolbox::rewriteEngine($aecConfig->cfg['invoicenum_formatting'], null, null, $subject);
     } elseif (!empty($subject->invoice_number_format)) {
         $invoice_number = $subject->invoice_number_format;
     }
     if (!empty($invoice)) {
         return $invoice_number;
     }
     if ($aecConfig->cfg['invoicenum_doformat'] && empty($this->invoice_number_format) && !empty($invoice_number) && !$nostore) {
         if ($invoice_number != "JSON PARSE ERROR - Malformed String!") {
             $this->invoice_number_format = $invoice_number;
             $this->storeload();
         }
     }
     $this->invoice_number = $invoice_number;
     return true;
 }
コード例 #4
0
 public function getPlanList()
 {
     $auth_problem = null;
     $this->list = array();
     if (!empty($this->usage)) {
         $db = JFactory::getDBO();
         $query = 'SELECT `id`' . ' FROM #__acctexp_plans' . ' WHERE `id` = \'' . $this->usage . '\' AND `active` = \'1\'';
         $db->setQuery($query);
         $id = $db->loadResult();
         if ($id) {
             $plan = new SubscriptionPlan();
             $plan->load($id);
             $authorized = $plan->checkAuthorized($this->metaUser);
             if ($authorized === true) {
                 $this->list[] = ItemGroupHandler::getItemListItem($plan);
             } elseif ($authorized === false) {
                 $auth_problem = true;
             } else {
                 $auth_problem = $authorized;
             }
         } else {
             // Plan does not exist
             $auth_problem = true;
         }
     } else {
         if (!empty($this->group)) {
             $gid = $this->group;
         } else {
             global $aecConfig;
             if (!empty($aecConfig->cfg['root_group_rw'])) {
                 $gid = AECToolbox::rewriteEngine($aecConfig->cfg['root_group_rw'], $this->metaUser);
             } else {
                 $gid = array($aecConfig->cfg['root_group']);
             }
         }
         if (is_array($gid)) {
             $gid = $gid[0];
         }
         $g = new ItemGroup();
         $g->load($gid);
         if ($g->checkPermission($this->metaUser)) {
             if (!empty($g->params['symlink_userid']) && !empty($g->params['symlink'])) {
                 aecRedirect($g->params['symlink'], $this->metaUser->userid, "aechidden");
             } elseif (!empty($g->params['symlink'])) {
                 return $g->params['symlink'];
             }
             $this->list = ItemGroupHandler::getTotalAllowedChildItems(array($gid), $this->metaUser);
             if (count($this->list) == 0) {
                 $auth_problem = true;
             }
         } else {
             $auth_problem = true;
         }
         if ($auth_problem && !empty($g->params['notauth_redirect'])) {
             $auth_problem = $g->params['notauth_redirect'];
         }
     }
     if (!is_null($auth_problem)) {
         $this->list = $auth_problem;
     }
     return true;
 }
コード例 #5
0
ファイル: admin.acctexp.class.php プロジェクト: Ibrahim1/aec
 public function exportMembers()
 {
     $db = JFactory::getDBO();
     foreach ($this->filter as $k => $v) {
         if (empty($v)) {
             $this->filter[$k] = array();
         }
     }
     // Assemble Database call
     if (!in_array('notconfig', $this->filter['status'])) {
         $where = array();
         if (!empty($this->filter['planid'])) {
             $where[] = '`plan` IN (' . implode(',', $this->filter['planid']) . ')';
         }
         $query = 'SELECT a.id, a.userid' . ' FROM #__acctexp_subscr AS a' . ' INNER JOIN #__users AS b ON a.userid = b.id';
         if (!empty($where)) {
             $query .= ' WHERE ( ' . implode(' OR ', $where) . ' )';
         }
         if (!empty($this->filter['status'])) {
             $stati = array();
             foreach ($this->filter['status'] as $status) {
                 $stati[] = 'LOWER( `status` ) = \'' . strtolower($status) . '\'';
             }
             if (!empty($where)) {
                 $query .= ' AND (' . implode(' OR ', $stati) . ')';
             } else {
                 $query .= ' WHERE (' . implode(' OR ', $stati) . ')';
             }
         }
         if (!empty($this->filter['orderby'])) {
             $query .= ' ORDER BY ' . $this->filter['orderby'] . '';
         }
     } else {
         $query = 'SELECT DISTINCT b.id AS `userid`' . ' FROM #__users as b' . ' WHERE b.id NOT IN (' . ' SELECT a.userid' . ' FROM #__acctexp_subscr as a);';
     }
     $db->setQuery($query);
     $descriptions = AECToolbox::rewriteEngineExplain($this->options['rewrite_rule']);
     $descarray = explode(';', $descriptions);
     $this->exphandler->putDescription($descarray);
     // Fetch Userlist
     $userlist = $db->loadObjectList();
     // Plans Array
     $plans = array();
     // Iterate through userlist
     if (!empty($userlist)) {
         foreach ($userlist as $entry) {
             $metaUser = new metaUser($entry->userid);
             if (!empty($entry->id)) {
                 $metaUser->moveFocus($entry->id);
             }
             if ($metaUser->hasSubscription) {
                 $planid = $metaUser->focusSubscription->plan;
                 if (!isset($plans[$planid])) {
                     $plans[$planid] = new SubscriptionPlan();
                     $plans[$planid]->load($planid);
                 }
                 $invoiceid = aecInvoiceHelper::lastClearedInvoiceIDbyUserID($metaUser->userid, $planid);
                 if ($invoiceid) {
                     $invoice = new Invoice();
                     $invoice->load($invoiceid);
                     $line = AECToolbox::rewriteEngine($this->options['rewrite_rule'], $metaUser, $plans[$planid], $invoice);
                 } else {
                     $line = AECToolbox::rewriteEngine($this->options['rewrite_rule'], $metaUser, $plans[$planid]);
                 }
             } else {
                 $line = AECToolbox::rewriteEngine($this->options['rewrite_rule'], $metaUser);
             }
             $larray = explode(';', $line);
             // Remove whitespaces and newlines
             foreach ($larray as $larrid => $larrval) {
                 $larray[$descarray[$larrid]] = trim($larrval);
                 unset($larray[$larrid]);
             }
             $this->exphandler->putln($larray);
         }
     }
 }
コード例 #6
0
 public function getUserform($var = array(), $values = null, $metaUser = null, $content = array())
 {
     $lang = JFactory::getLanguage();
     global $aecConfig;
     if (empty($values)) {
         $values = array('firstname', 'lastname');
     }
     $name = array('', '');
     if (is_object($metaUser)) {
         if (isset($metaUser->cmsUser->name)) {
             $name = explode(' ', $metaUser->cmsUser->name);
             if (empty($content['firstname'])) {
                 $content['firstname'] = $name[0];
             }
             if (empty($content['lastname']) && isset($name[1])) {
                 $content['lastname'] = $name[1];
             } else {
                 $content['lastname'] = '';
             }
         }
     }
     $fieldlist = explode("\n", AECToolbox::rewriteEngine($aecConfig->cfg['user_checkout_prefill'], $metaUser));
     $cfgarray = array();
     foreach ($fieldlist as $fcontent) {
         $c = explode('=', $fcontent, 2);
         if (!is_array($c)) {
             continue;
         }
         if (empty($c[0])) {
             continue;
         }
         if (!empty($c[1])) {
             $cfgarray[$c[0]] = trim($c[1]);
         } else {
             $cfgarray[$c[0]] = "";
         }
     }
     $translatelist = array('firstname' => 'billFirstName', 'lastname' => 'billLastName', 'address' => 'billAddress', 'address2' => 'billAddress2', 'city' => 'billCity', 'nonus' => 'billNonUs', 'state' => 'billState', 'state_us' => 'billState', 'state_usca' => 'billState', 'zip' => 'billZip', 'country_list' => 'billCountry', 'country3_list' => 'billCountry', 'country' => 'billCountry', 'phone' => 'billPhone', 'fax' => 'billFax', 'company' => 'billCompany');
     $cfgtranslatelist = array('state_us' => 'state', 'state_usca' => 'state', 'country_list' => 'country', 'country3_list' => 'country');
     foreach ($values as $value) {
         if (strpos($value, '*')) {
             $pf = '*';
             $value = substr($value, 0, -1);
         } else {
             $pf = '';
         }
         $vcontent = '';
         if (isset($content[$value])) {
             $vcontent = $content[$value];
         } elseif (isset($translatelist[$value])) {
             if (isset($content[$translatelist[$value]])) {
                 $vcontent = $content[$translatelist[$value]];
             }
         }
         if (empty($vcontent)) {
             if (isset($cfgtranslatelist[$value])) {
                 $xvalue = $cfgtranslatelist[$value];
             } else {
                 $xvalue = $value;
             }
             if (!empty($cfgarray[strtolower($xvalue)])) {
                 $vcontent = $cfgarray[strtolower($xvalue)];
             }
         }
         switch (strtolower($value)) {
             case 'firstname':
                 $var['params']['billFirstName'] = array('inputC', JText::_('AEC_USERFORM_BILLFIRSTNAME_NAME') . $pf, JText::_('AEC_USERFORM_BILLFIRSTNAME_DESC'), $vcontent);
                 break;
             case 'lastname':
                 $var['params']['billLastName'] = array('inputC', JText::_('AEC_USERFORM_BILLLASTNAME_NAME') . $pf, JText::_('AEC_USERFORM_BILLLASTNAME_DESC'), $vcontent);
                 break;
             case 'address':
                 $var['params']['billAddress'] = array('inputC', JText::_('AEC_USERFORM_BILLADDRESS_NAME') . $pf, JText::_('AEC_USERFORM_BILLADDRESS_DESC'), $vcontent);
                 break;
             case 'address2':
                 $var['params']['billAddress2'] = array('inputC', JText::_('AEC_USERFORM_BILLADDRESS2_NAME') . $pf, JText::_('AEC_USERFORM_BILLADDRESS2_DESC'), $vcontent);
                 break;
             case 'city':
                 $var['params']['billCity'] = array('inputC', JText::_('AEC_USERFORM_BILLCITY_NAME') . $pf, JText::_('AEC_USERFORM_BILLCITY_DESC'), $vcontent);
                 break;
             case 'nonus':
                 $var['params']['billNonUs'] = array('checkbox', JText::_('AEC_USERFORM_BILLNONUS_NAME') . $pf, JText::_('AEC_USERFORM_BILLNONUS_DESC'), $vcontent, 1);
                 break;
             case 'state':
                 $var['params']['billState'] = array('inputC', JText::_('AEC_USERFORM_BILLSTATE_NAME') . $pf, JText::_('AEC_USERFORM_BILLSTATE_DESC'), $vcontent);
                 break;
             case 'state_us':
                 $states = array('', '--- United States ---', 'AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VT', 'WA', 'WI', 'WV', 'WY', 'AA', 'AE', 'AP', 'AS', 'FM', 'GU', 'MH', 'MP', 'PR', 'PW', 'VI');
                 $statelist = array();
                 foreach ($states as $state) {
                     if (strpos($state, '---') !== false) {
                         $statelist[] = JHTML::_('select.option', 'NONSELECT', $state, 'value', 'text', true);
                     } else {
                         $statelist[] = JHTML::_('select.option', $state, $state);
                     }
                 }
                 $var['params']['lists']['billState'] = JHTML::_('select.genericlist', $statelist, 'billState', 'size="1" class="aec_formfield" title="' . JText::_('AEC_USERFORM_BILLSTATE_DESC') . '"', 'value', 'text', $vcontent);
                 $var['params']['billState'] = array('list', JText::_('AEC_USERFORM_BILLSTATE_NAME') . $pf, JText::_('AEC_USERFORM_BILLSTATE_DESC'));
                 break;
             case 'state_usca':
                 $states = array('', '--- United States ---', 'AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VT', 'WA', 'WI', 'WV', 'WY', 'AA', 'AE', 'AP', 'AS', 'FM', 'GU', 'MH', 'MP', 'PR', 'PW', 'VI', '--- Canada ---', 'AB', 'BC', 'MB', 'NB', 'NL', 'NT', 'NS', 'NU', 'ON', 'PE', 'QC', 'SK', 'YT');
                 $statelist = array();
                 foreach ($states as $state) {
                     if (strpos($state, '---') !== false) {
                         $statelist[] = JHTML::_('select.option', 'NONSELECT', $state, 'value', 'text', true);
                     } else {
                         $statelist[] = JHTML::_('select.option', $state, $state);
                     }
                 }
                 $var['params']['lists']['billState'] = JHTML::_('select.genericlist', $statelist, 'billState', 'size="1" class="aec_formfield" title="' . JText::_('AEC_USERFORM_BILLSTATEPROV_DESC') . '"', 'value', 'text', $vcontent);
                 $var['params']['billState'] = array('list', JText::_('AEC_USERFORM_BILLSTATEPROV_NAME') . $pf, JText::_('AEC_USERFORM_BILLSTATEPROV_DESC'));
                 break;
             case 'zip':
                 $var['params']['billZip'] = array('inputC', JText::_('AEC_USERFORM_BILLZIP_NAME') . $pf, JText::_('AEC_USERFORM_BILLZIP_DESC'), $vcontent);
                 break;
             case 'country_list':
                 $countries = AECToolbox::getCountryCodeList();
                 $countrylist[] = JHTML::_('select.option', '', JText::_('COUNTRYCODE_SELECT'), 'value', 'text', true);
                 if (empty($vcontent)) {
                     $vcontent = 'US';
                 }
                 $countrylist = array();
                 foreach ($countries as $country) {
                     if (!empty($country)) {
                         $cname = JText::_('COUNTRYCODE_' . $country);
                         if ($vcontent == $cname) {
                             $vcontent = $country;
                         }
                         $countrylist[] = JHTML::_('select.option', $country, $cname);
                     }
                 }
                 $var['params']['lists']['billCountry'] = JHTML::_('select.genericlist', $countrylist, 'billCountry', 'size="1" class="aec_formfield" title="' . JText::_('AEC_USERFORM_BILLCOUNTRY_DESC') . '"', 'value', 'text', $vcontent);
                 $var['params']['billCountry'] = array('list', JText::_('AEC_USERFORM_BILLCOUNTRY_NAME') . $pf, JText::_('AEC_USERFORM_BILLCOUNTRY_DESC'));
                 break;
             case 'country3_list':
                 $countries = AECToolbox::getCountryCodeList('num');
                 if (empty($vcontent)) {
                     $vcontent = 826;
                 }
                 $conversion = AECToolbox::ISO3166_conversiontable('num', 'a2');
                 $countrylist = array();
                 $countrylist[] = JHTML::_('select.option', '', JText::_('COUNTRYCODE_SELECT'), 'value', 'text', true);
                 foreach ($countries as $country) {
                     if ($lang->hasKey('COUNTRYCODE_' . $conversion[$country])) {
                         $cname = JText::_('COUNTRYCODE_' . $conversion[$country]);
                         if ($vcontent == $cname) {
                             $vcontent = $country;
                         }
                         $countrylist[] = JHTML::_('select.option', $country, $cname);
                     } elseif (is_null($country)) {
                         $countrylist[] = JHTML::_('select.option', '', " -- -- -- -- -- -- ", 'value', 'text', true);
                     }
                 }
                 $var['params']['lists']['billCountry'] = JHTML::_('select.genericlist', $countrylist, 'billCountry', 'size="1" class="aec_formfield" title="' . JText::_('AEC_USERFORM_BILLCOUNTRY_DESC') . '"', 'value', 'text', $vcontent);
                 $var['params']['billCountry'] = array('list', JText::_('AEC_USERFORM_BILLCOUNTRY_NAME') . $pf, JText::_('AEC_USERFORM_BILLCOUNTRY_DESC'));
                 break;
             case 'country':
                 $var['params']['billCountry'] = array('inputC', JText::_('AEC_USERFORM_BILLCOUNTRY_NAME') . $pf, JText::_('AEC_USERFORM_BILLCOUNTRY_DESC'), $vcontent);
                 break;
             case 'phone':
                 $var['params']['billPhone'] = array('inputC', JText::_('AEC_USERFORM_BILLPHONE_NAME') . $pf, JText::_('AEC_USERFORM_BILLPHONE_DESC'), $vcontent);
                 break;
             case 'fax':
                 $var['params']['billFax'] = array('inputC', JText::_('AEC_USERFORM_BILLFAX_NAME') . $pf, JText::_('AEC_USERFORM_BILLFAX_DESC'), $vcontent);
                 break;
             case 'company':
                 $var['params']['billCompany'] = array('inputC', JText::_('AEC_USERFORM_BILLCOMPANY_NAME') . $pf, JText::_('AEC_USERFORM_BILLCOMPANY_DESC'), $vcontent);
                 break;
         }
     }
     return $var;
 }