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


PHP RSMembershipHelper::calculateFixedDate方法代码示例

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


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

示例1: approve

 public static function approve($transaction_id, $force = false)
 {
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_rsmembership/tables');
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $date = JFactory::getDate();
     // Load the transaction
     $query->select($db->qn('id'))->from($db->qn('#__rsmembership_transactions'))->where($db->qn('id') . '=' . $db->q($transaction_id));
     if (!$force) {
         $query->where($db->qn('status') . ' != ' . $db->q('completed'));
     }
     $db->setQuery($query);
     if ($id = $db->loadResult()) {
         $transaction = JTable::getInstance('Transaction', 'RSMembershipTable');
         $transaction->load($id);
     } else {
         return false;
     }
     $params = RSMembershipHelper::parseParams($transaction->params);
     $user_data = !empty($transaction->user_data) ? (object) unserialize($transaction->user_data) : (object) array();
     // Handle user creation
     $user_id = $transaction->user_id;
     if (!RSMembershipHelper::getConfig('create_user_instantly') && !$user_id) {
         $user_id = RSMembership::createUser($transaction->user_email, $user_data);
         // Update the transaction with the newly created user ID
         if ($user_id != $transaction->user_id) {
             $updateTransaction = JTable::getInstance('Transaction', 'RSMembershipTable');
             $updateTransaction->save(array('id' => $transaction->id, 'user_id' => $user_id));
         }
     }
     // Update user data
     if ($transaction->user_id && is_object($user_data) && isset($user_data->fields)) {
         RSMembership::createUserData($user_id, $user_data->fields);
     }
     // Create the subscriber
     $row = JTable::getInstance('Membership_Subscriber', 'RSMembershipTable');
     $row->bind(array('published' => 1, 'user_id' => $user_id, 'price' => $transaction->price, 'currency' => $transaction->currency));
     // Set some defaults
     $idev_enabled = RSMembershipHelper::getConfig('idev_enable');
     $idev_track_renewals = RSMembershipHelper::getConfig('idev_track_renewals');
     $update_gid = false;
     $update_user = false;
     $update_idev = false;
     $update_rsmail = false;
     switch ($transaction->type) {
         case 'new':
             $membership_id = $params['membership_id'];
             // Check if this membership still exists
             $membership = JTable::getInstance('Membership', 'RSMembershipTable');
             if (!$membership->load($membership_id)) {
                 JError::raiseWarning(500, JText::_('COM_RSMEMBERSHIP_COULD_NOT_APPROVE_TRANSACTION'));
                 return false;
             }
             // Trial settings
             if ($membership->use_trial_period) {
                 $period = $membership->trial_period;
                 $period_type = $membership->trial_period_type;
             } else {
                 $period = $membership->period;
                 $period_type = $membership->period_type;
             }
             // Fixed expiry
             if ($membership->fixed_expiry) {
                 $date = RSMembershipHelper::calculateFixedDate($membership->fixed_day, $membership->fixed_month, $membership->fixed_year);
                 $membership_end = $date->toSql();
             } elseif ($period) {
                 // Expire in a period of time
                 $date = JFactory::getDate();
                 $date->modify(self::getDateString($period, $period_type));
                 $membership_end = $date->toSql();
             } else {
                 // No expiry
                 $membership_end = $db->getNullDate();
             }
             $extras = !empty($params['extras']) ? implode(',', $params['extras']) : '';
             $row->bind(array('membership_id' => $membership->id, 'extras' => $extras, 'membership_start' => JFactory::getDate()->toSql(), 'membership_end' => $membership_end, 'status' => 0, 'from_transaction_id' => $transaction->id, 'last_transaction_id' => $transaction->id));
             $row->store();
             // Take care of integrations
             if ($membership->gid_enable) {
                 $update_gid = true;
             }
             if ($membership->disable_expired_account) {
                 $update_user = true;
             }
             if ($idev_enabled) {
                 $update_idev = true;
             }
             $update_rsmail = $membership->id;
             // Some values used later on
             $membership_start = $row->membership_start;
             $membership_end = $row->membership_end;
             $return = $row->id;
             break;
         case 'renew':
             $membership_id = $params['membership_id'];
             // Check if this membership still exists
             $membership = JTable::getInstance('Membership', 'RSMembershipTable');
             if (!$membership->load($membership_id)) {
                 JError::raiseWarning(500, JText::_('COM_RSMEMBERSHIP_COULD_NOT_APPROVE_TRANSACTION'));
//.........这里部分代码省略.........
开发者ID:JozefAB,项目名称:qk,代码行数:101,代码来源:rsmembership.php

示例2: getEndDate

 public function getEndDate($membership_id, $membership_start)
 {
     $format = 'Y-m-d H:i:s';
     $membership = JTable::getInstance('Membership', 'RSMembershipTable');
     $offset = JFactory::getApplication()->getCfg('offset');
     if ($membership->load($membership_id)) {
         // Trial settings
         if ($membership->use_trial_period) {
             $period = $membership->trial_period;
             $period_type = $membership->trial_period_type;
         } else {
             $period = $membership->period;
             $period_type = $membership->period_type;
         }
         // Fixed expiry
         if ($membership->fixed_expiry) {
             $date = RSMembershipHelper::calculateFixedDate($membership->fixed_day, $membership->fixed_month, $membership->fixed_year, JFactory::getDate($membership_start));
             $membership_end = JHtml::_('date', $date->toSql(), $format);
         } elseif ($period) {
             // Expire in a period of time
             $date = JFactory::getDate($membership_start, $offset);
             $date->modify(RSMembership::getDateString($period, $period_type));
             $membership_end = JHtml::_('date', $date->toSql(), $format);
         } else {
             // No expiry
             $membership_end = JFactory::getDbo()->getNullDate();
         }
         return $membership_end;
     }
 }
开发者ID:JozefAB,项目名称:qk,代码行数:30,代码来源:membership_subscriber.php

示例3: approve

 function approve($transaction_id, $force = false)
 {
     $db =& JFactory::getDBO();
     $db->setQuery("SELECT * FROM #__rsmembership_transactions WHERE `id`='" . (int) $transaction_id . "'" . ($force ? "" : " AND `status`!='completed'"));
     $transaction = $db->loadObject();
     if (empty($transaction->id)) {
         return false;
     }
     $params = RSMembershipHelper::parseParams($transaction->params);
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsmembership' . DS . 'tables');
     $row =& JTable::getInstance('RSMembership_Membership_Users', 'Table');
     $row->user_id = $transaction->user_id;
     if (!RSMembershipHelper::getConfig('create_user_instantly') || $row->user_id == 0) {
         $row->user_id = RSMembership::createUser($transaction->user_email, unserialize($transaction->user_data));
         $db->setQuery("UPDATE #__rsmembership_transactions SET `user_id`='" . $row->user_id . "' WHERE `id`='" . $transaction->id . "'");
         $db->query();
     }
     $row->price = $transaction->price;
     $row->currency = $transaction->currency;
     $idev_enabled = RSMembershipHelper::getConfig('idev_enable');
     $idev_track_renewals = RSMembershipHelper::getConfig('idev_track_renewals');
     $update_gid = false;
     $update_user = false;
     $update_idev = false;
     $update_rsmail = false;
     $date = JFactory::getDate();
     switch ($transaction->type) {
         case 'new':
             $row->membership_id = $params['membership_id'];
             $db->setQuery("SELECT * FROM #__rsmembership_memberships WHERE `id`='" . (int) $row->membership_id . "'");
             $membership = $db->loadObject();
             if (empty($membership)) {
                 JError::raiseWarning(500, JText::_('RSM_COULD_NOT_APPROVE_TRANSACTION'));
                 return false;
             }
             if ($membership->gid_enable) {
                 $update_gid = true;
             }
             if ($membership->disable_expired_account) {
                 $update_user = true;
             }
             $row->membership_start = $date->toUnix();
             if ($membership->use_trial_period) {
                 $membership->period = $membership->trial_period;
                 $membership->period_type = $membership->trial_period_type;
             }
             if ($membership->fixed_expiry) {
                 $row->membership_end = RSMembershipHelper::calculateFixedDate($membership);
             } else {
                 if ($membership->period > 0) {
                     switch ($membership->period_type) {
                         case 'h':
                             $offset = $membership->period * 3600;
                             break;
                         case 'd':
                             $offset = $membership->period * 86400;
                             break;
                         case 'm':
                             $offset = strtotime('+' . $membership->period . ' months', $row->membership_start) - $row->membership_start;
                             break;
                         case 'y':
                             $offset = strtotime('+' . $membership->period . ' years', $row->membership_start) - $row->membership_start;
                             break;
                     }
                     $row->membership_end = $date->toUnix() + $offset;
                 } else {
                     $row->membership_end = 0;
                 }
             }
             if (!empty($params['extras'])) {
                 $row->extras = implode(',', $params['extras']);
             }
             $row->status = 0;
             $row->from_transaction_id = $transaction->id;
             $row->last_transaction_id = $transaction->id;
             $row->store();
             $return = $row->id;
             // iDev Integration
             if ($idev_enabled) {
                 $update_idev = true;
             }
             $update_rsmail = $membership->id;
             break;
         case 'addextra':
             $db->setQuery("SELECT `extras` FROM #__rsmembership_membership_users WHERE `id`='" . (int) $params['id'] . "'");
             $extras = $db->loadResult();
             $extras = explode(',', $extras);
             if (empty($extras[0])) {
                 $extras = $params['extras'];
             } else {
                 $extras = array_merge($extras, $params['extras']);
             }
             $db->setQuery("UPDATE #__rsmembership_membership_users SET `extras`='" . implode(',', $extras) . "' WHERE `id`='" . (int) $params['id'] . "'");
             $db->query();
             $return = $params['id'];
             break;
         case 'upgrade':
             // Get the upgraded membership
             $db->setQuery("SELECT * FROM #__rsmembership_memberships WHERE `id`='" . (int) $params['to_id'] . "'");
             $membership = $db->loadObject();
//.........这里部分代码省略.........
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:101,代码来源:rsmembership.php


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