当前位置: 首页>>代码示例>>PHP>>正文


PHP Subscription::createNew方法代码示例

本文整理汇总了PHP中Subscription::createNew方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscription::createNew方法的具体用法?PHP Subscription::createNew怎么用?PHP Subscription::createNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subscription的用法示例。


在下文中一共展示了Subscription::createNew方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: establishFocus

 public function establishFocus($payment_plan, $processor = 'none', $silent = false, $bias = null)
 {
     if (!is_object($payment_plan)) {
         $planid = $payment_plan;
         $payment_plan = new SubscriptionPlan();
         $payment_plan->load($planid);
         if (empty($payment_plan->id)) {
             return false;
         }
     }
     if (is_object($this->focusSubscription)) {
         if ($this->focusSubscription->plan == $payment_plan->id) {
             return 'existing';
         }
     }
     $plan_params = $payment_plan->params;
     if (!isset($plan_params['make_primary'])) {
         $plan_params['make_primary'] = 1;
     }
     if ($plan_params['make_primary'] && $this->hasSubscription) {
         if ($this->objSubscription->primary) {
             $this->focusSubscription = $this->objSubscription;
             return 'existing';
         } else {
             $existing_record = $this->objSubscription->getSubscriptionID($this->userid);
             if ($existing_record) {
                 $this->objSubscription = new Subscription();
                 $this->objSubscription->load($existing_record);
                 $this->focusSubscription = $this->objSubscription;
                 return 'existing';
             }
         }
     }
     // If we are not dealing with a primary (or an otherwise unclear situation),
     // we need to figure out how to prepare the switch
     $existing_record = 0;
     $existing_status = false;
     // Check whether a record exists
     if ($this->hasSubscription) {
         $existing_record = $this->focusSubscription->getSubscriptionID($this->userid, $payment_plan->id, $plan_params['make_primary'], false, $bias);
         if (!empty($existing_record)) {
             $db = JFactory::getDBO();
             $query = 'SELECT `status`' . ' FROM #__acctexp_subscr' . ' WHERE `id` = \'' . (int) $existing_record . '\'';
             $db->setQuery($query);
             $existing_status = $db->loadResult();
         }
     }
     $return = false;
     // To be failsafe, a new subscription may have to be added in here
     if (empty($this->hasSubscription) || !$plan_params['make_primary'] || $plan_params['update_existing']) {
         if (!empty($existing_record) && ($existing_status == 'Trial' || $existing_status == 'Pending' || $plan_params['update_existing'] || $plan_params['make_primary'])) {
             // Update existing non-primary subscription
             if ($this->focusSubscription->id !== $existing_record) {
                 $this->focusSubscription = new Subscription();
                 $this->focusSubscription->load($existing_record);
             }
             $return = 'existing';
         } else {
             if (!empty($this->hasSubscription)) {
                 $existing_parent = $this->focusSubscription->getSubscriptionID($this->userid, $plan_params['standard_parent'], null);
             } else {
                 $existing_parent = false;
             }
             // Create a root new subscription
             if (empty($this->hasSubscription) && !$plan_params['make_primary'] && !empty($plan_params['standard_parent']) && empty($existing_parent)) {
                 $this->objSubscription = new Subscription();
                 $this->objSubscription->load(0);
                 if ($this->objSubscription->createNew($this->userid, 'none', 1, 1, $plan_params['standard_parent'])) {
                     $this->objSubscription->applyUsage($plan_params['standard_parent'], 'none', $silent, 0);
                 }
             } elseif (!$plan_params['make_primary'] && !empty($plan_params['standard_parent']) && $existing_parent) {
                 $this->objSubscription = new Subscription();
                 $this->objSubscription->load($existing_parent);
                 if ($this->objSubscription->isExpired()) {
                     $this->objSubscription->applyUsage($plan_params['standard_parent'], 'none', $silent, 0);
                 }
             }
             // Create new subscription
             $this->focusSubscription = new Subscription();
             $this->focusSubscription->load(0);
             $this->focusSubscription->createNew($this->userid, $processor, 1, $plan_params['make_primary'], $payment_plan->id);
             $this->hasSubscription = 1;
             if ($plan_params['make_primary']) {
                 $this->objSubscription = clone $this->focusSubscription;
             }
             $return = 'new';
         }
     }
     if (empty($this->objSubscription) && !empty($this->focusSubscription)) {
         $this->objSubscription = clone $this->focusSubscription;
     }
     $this->temporaryRFIX();
     return $return;
 }
开发者ID:Ibrahim1,项目名称:aec,代码行数:94,代码来源:acctexp.user.class.php

示例2: index


//.........这里部分代码省略.........
     if (!empty($planid) && $users_selected) {
         $plan = new SubscriptionPlan();
         $plan->load($planid);
         if (!empty($subscriptionid)) {
             foreach ($subscriptionid as $sid) {
                 $metaUser = new metaUser(false, $sid);
                 $metaUser->establishFocus($plan);
                 $metaUser->focusSubscription->applyUsage($planid, 'none', 1);
             }
         }
         if (!empty($userid)) {
             foreach ($userid as $uid) {
                 $metaUser = new metaUser($uid);
                 $metaUser->establishFocus($plan);
                 $metaUser->focusSubscription->applyUsage($planid, 'none', 1);
                 $subscriptionid[] = $metaUser->focusSubscription->id;
             }
         }
         // Also show active users now
         if (!in_array('active', $groups)) {
             $groups[] = 'active';
         }
     }
     $set_status = trim(aecGetParam('set_status', null));
     $add_or_set_expiration = trim(aecGetParam('add_or_set_expiration', null));
     $set_time = trim(aecGetParam('set_time', null));
     $set_time_unit = trim(aecGetParam('set_time_unit', null));
     if ((!empty($set_status) || !empty($add_or_set_expiration)) && is_array($subscriptionid) && count($subscriptionid) > 0) {
         foreach ($subscriptionid as $k) {
             $subscriptionHandler = new Subscription();
             if (!empty($k)) {
                 $subscriptionHandler->load($k);
             } else {
                 $subscriptionHandler->createNew($k, '', 1);
             }
             if (strcmp($set_status, 'now') === 0) {
                 $subscriptionHandler->expire();
                 if (!in_array('expired', $groups)) {
                     $groups[] = 'expired';
                 }
             } elseif (strcmp($set_status, 'exclude') === 0) {
                 $subscriptionHandler->setStatus('Excluded');
                 if (!in_array('excluded', $groups)) {
                     $groups[] = 'excluded';
                 }
             } elseif (strcmp($set_status, 'close') === 0) {
                 $subscriptionHandler->setStatus('Closed');
                 if (!in_array('closed', $groups)) {
                     $groups[] = 'closed';
                 }
             } elseif (strcmp($set_status, 'hold') === 0) {
                 $subscriptionHandler->setStatus('Hold');
                 if (!in_array('hold', $groups)) {
                     $groups[] = 'hold';
                 }
             } elseif (strcmp($set_status, 'include') === 0) {
                 $subscriptionHandler->setStatus('Active');
                 if (!in_array('active', $groups)) {
                     $groups[] = 'active';
                 }
             } elseif (strcmp($set_status, 'lifetime') === 0) {
                 if (!$subscriptionHandler->isLifetime()) {
                     $subscriptionHandler->expiration = '9999-12-31 00:00:00';
                     $subscriptionHandler->lifetime = 1;
                 }
                 $subscriptionHandler->setStatus('Active');
开发者ID:Ibrahim1,项目名称:aec,代码行数:67,代码来源:admin.acctexp.php


注:本文中的Subscription::createNew方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。