Ejemplo n.º 1
0
 /**
  * Class constructor
  */
 public function __construct($typeId)
 {
     parent::__construct();
     if (!OW::getUser()->isAdmin()) {
         $this->setVisible(false);
         return;
     }
     $service = MEMBERSHIP_BOL_MembershipService::getInstance();
     $type = $service->findTypeById($typeId);
     if (!$type) {
         $this->setVisible(false);
         return;
     }
     $types = $service->getTypeList($type->accountTypeId);
     $availableTypes = array();
     if ($types) {
         foreach ($types as $mType) {
             if ($mType->id == $typeId) {
                 continue;
             }
             $availableTypes[$mType->id] = $service->getMembershipTitle($mType->roleId);
         }
     }
     $this->assign('availableTypes', $availableTypes);
     $form = new MEMBERSHIP_CLASS_DeleteMembershipForm();
     $this->addForm($form);
     $form->getElement('typeId')->setValue($typeId);
     if ($availableTypes) {
         $form->getElement('newTypeId')->addOptions($availableTypes);
     }
 }
Ejemplo n.º 2
0
 /**
  * Returns class instance
  *
  * @return MEMBERSHIP_BOL_MembershipService
  */
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
 public function deliverSale(BOL_BillingSale $sale)
 {
     $planId = $sale->entityId;
     $membershipService = MEMBERSHIP_BOL_MembershipService::getInstance();
     $plan = $membershipService->findPlanById($planId);
     $type = $membershipService->findTypeByPlanId($planId);
     if ($plan && $type) {
         $isRebill = false;
         if ($sale->recurring) {
             /* @var $currentMembership MEMBERSHIP_BOL_MembershipUser */
             $currentMembership = $membershipService->getUserMembership($sale->userId);
             if ($currentMembership && $currentMembership->recurring && $currentMembership->typeId == $type->id) {
                 $isRebill = true;
             }
         }
         $userMembership = new MEMBERSHIP_BOL_MembershipUser();
         $userMembership->userId = $sale->userId;
         $userMembership->typeId = $type->id;
         $userMembership->expirationStamp = time() + (int) $plan->period * 60 * 60 * 24;
         $userMembership->recurring = $sale->recurring;
         $membershipService->setUserMembership($userMembership);
         $title = $membershipService->getMembershipTitle($type->roleId);
         if ($isRebill) {
             $membershipService->sendMembershipRenewedNotification($sale->userId, $title);
         } else {
             $membershipService->sendMembershipPurchasedNotification($sale->userId, $title, $userMembership->expirationStamp);
         }
         return true;
     }
     return false;
 }
 public function deliverSale(BOL_BillingSale $sale)
 {
     $planId = $sale->entityId;
     $membershipService = MEMBERSHIP_BOL_MembershipService::getInstance();
     $plan = $membershipService->findPlanById($planId);
     $type = $membershipService->findTypeByPlanId($planId);
     if ($plan && $type) {
         $userMembership = new MEMBERSHIP_BOL_MembershipUser();
         $userMembership->userId = $sale->userId;
         $userMembership->typeId = $type->id;
         $userMembership->expirationStamp = time() + (int) $plan->period * 60 * 60 * 24;
         $userMembership->recurring = $sale->recurring;
         $membershipService->setUserMembership($userMembership);
         return true;
     }
     return false;
 }
Ejemplo n.º 5
0
 /**
  * Class constructor
  */
 public function __construct($userId)
 {
     parent::__construct();
     if (!OW::getUser()->isAuthorized('membership')) {
         $this->setVisible(false);
         return;
     }
     $user = BOL_UserService::getInstance()->findUserById($userId);
     if (!$user) {
         $this->setVisible(false);
         return;
     }
     $accTypeName = $user->getAccountType();
     $accType = BOL_QuestionService::getInstance()->findAccountTypeByName($accTypeName);
     $service = MEMBERSHIP_BOL_MembershipService::getInstance();
     $authService = BOL_AuthorizationService::getInstance();
     $types = $service->getTypeList($accType->id);
     /* @var $defaultRole BOL_AuthorizationRole */
     $defaultRole = $authService->getDefaultRole();
     $default = array('value' => 'default', 'label' => $authService->getRoleLabel($defaultRole->name));
     $this->assign('default', $default);
     $memberships = array();
     foreach ($types as &$ms) {
         $memberships[$ms->id] = $service->getMembershipTitle($ms->roleId);
     }
     $this->assign('memberships', $memberships);
     $current = $service->getUserMembership($userId);
     $this->assign('current', $current);
     if ($current) {
         $this->assign('remaining', $service->getRemainingPeriod($current->expirationStamp));
     }
     $form = new MEMBERSHIP_CLASS_SetMembershipForm();
     $this->addForm($form);
     $form->getElement('userId')->setValue($userId);
     $form->bindJsFunction(Form::BIND_SUCCESS, "function(data){\n                if ( data.result ) {\n                    OW.info(data.msg);\n                    document.setMembershipFloatBox.close();\n                }\n                else {\n                    OW.error(data.msg);\n                }\n             }");
     $script = '$("input[name=type]").change(function(){
         if ( $(this).val() == "default" ) {
             $("#period-cont").css("display", "none");
         }
         else {
             $("#period-cont").css("display", "table-row");
         }
     });';
     OW::getDocument()->addOnloadScript($script);
 }
Ejemplo n.º 6
0
 /**
  * Class constructor
  */
 public function __construct(BASE_CLASS_WidgetParameter $paramObj)
 {
     parent::__construct();
     $this->membershipService = MEMBERSHIP_BOL_MembershipService::getInstance();
     $userId = OW::getUser()->getId();
     if (!$userId) {
         $this->setVisible(false);
         return;
     }
     $membership = $this->membershipService->getUserMembership($userId);
     if (!$membership) {
         $this->setVisible(false);
         return;
     }
     $this->assign('membership', $membership);
     $type = $this->membershipService->findTypeById($membership->typeId);
     $this->assign('title', $this->membershipService->getMembershipTitle($type->roleId));
     $this->setSettingValue(self::SETTING_TOOLBAR, array(array('label' => OW::getLanguage()->text('membership', 'subscribe'), 'href' => OW::getRouter()->urlForRoute('membership_subscribe'))));
 }
Ejemplo n.º 7
0
 /**
  * Class constructor
  */
 public function __construct(BASE_CLASS_WidgetParameter $paramObj)
 {
     parent::__construct();
     $this->membershipService = MEMBERSHIP_BOL_MembershipService::getInstance();
     $userId = (int) $paramObj->additionalParamList['entityId'];
     $viewerId = OW::getUser()->getId();
     if (!$userId) {
         $this->setVisible(false);
         return;
     }
     $membership = $this->membershipService->getUserMembership($userId);
     if (!$membership) {
         $this->setVisible(false);
         return;
     }
     $this->assign('membership', $membership);
     $isModerator = OW::getUser()->isAuthorized('membership');
     $this->assign('isModerator', $isModerator);
     $this->assign('isOwner', $viewerId == $userId);
     $type = $this->membershipService->findTypeById($membership->typeId);
     $this->assign('title', $this->membershipService->getMembershipTitle($type->roleId));
 }
Ejemplo n.º 8
0
 /**
  * Class constructor
  */
 public function __construct(BASE_CLASS_WidgetParameter $paramObj)
 {
     parent::__construct();
     $this->membershipService = MEMBERSHIP_BOL_MembershipService::getInstance();
     $userId = OW::getUser()->getId();
     if (!$userId) {
         $this->setVisible(false);
         return;
     }
     $limit = 3;
     $actions = $this->membershipService->getPromoActionList(OW::getUser()->getId(), $limit);
     if ($actions == null) {
         $this->setVisible(false);
         return;
     }
     $showMore = count($actions) == $limit + 1;
     $this->assign('showMore', $showMore);
     if ($showMore) {
         array_pop($actions);
     }
     $this->assign('actions', $actions);
     $membership = $this->membershipService->getUserMembership($userId);
     $this->assign('membership', $membership);
     if ($membership) {
         $type = $this->membershipService->findTypeById($membership->typeId);
         $this->assign('title', $this->membershipService->getMembershipTitle($type->roleId));
     } else {
         $authService = BOL_AuthorizationService::getInstance();
         $roles = $authService->getRoleListOfUsers(array($userId), false);
         if (isset($roles[$userId])) {
             $this->assign('title', $roles[$userId]['label']);
         }
     }
     $script = '$("#btn-sidebar-upgrade").click(function(){
         document.location.href = ' . json_encode(OW::getRouter()->urlForRoute('membership_subscribe')) . ';
     });';
     OW::getDocument()->addOnloadScript($script);
 }
Ejemplo n.º 9
0
 private function getSuggestedMembershipPlan($userId, $pluginKey, $actionKey)
 {
     $membershipService = MEMBERSHIP_BOL_MembershipService::getInstance();
     $authService = BOL_AuthorizationService::getInstance();
     $action = $authService->findAction($pluginKey, $actionKey);
     if (!$action) {
         return null;
     }
     if (OW::getAuthorization()->isUserAuthorized($userId, $pluginKey, $actionKey)) {
         return null;
     }
     // get user account type
     $accTypeName = BOL_UserService::getInstance()->findUserById($userId)->getAccountType();
     $accType = BOL_QuestionService::getInstance()->findAccountTypeByName($accTypeName);
     $typeList = $membershipService->getTypeList($accType->id);
     /*@var $membership MEMBERSHIP_BOL_MembershipUser */
     $membership = $membershipService->getUserMembership($userId);
     $exclude = $membershipService->getUserTrialPlansUsage($userId);
     $plans = $membershipService->getTypePlanList($exclude);
     $permissions = $authService->getPermissionList();
     $suggestedPlanId = null;
     $suggestedPlanPrice = PHP_INT_MAX;
     $suggestedPlanTitle = null;
     $suggestedPlanPeriod = null;
     if (!$typeList) {
         return null;
     }
     foreach ($typeList as $type) {
         if (!isset($plans[$type->id])) {
             continue;
         }
         if (!$this->actionPermittedForMembershipType($action, $type, $permissions)) {
             continue;
         }
         if (!empty($membership) && $membership->typeId == $type->id) {
             continue;
         }
         $used = $membershipService->isTrialUsedByUser($userId);
         foreach ($plans[$type->id] as $plan) {
             if ($used && $plan['dto']->price == 0) {
                 continue;
             }
             /*@var $plan['dto'] MEMBERSHIP_BOL_MembershipPlan*/
             if ($plan['dto']->price < $suggestedPlanPrice) {
                 $suggestedPlanId = $plan['dto']->id;
                 $suggestedPlanPrice = $plan['dto']->price;
                 $suggestedPlanTitle = $plan['plan_format'];
                 $suggestedPlanPrice = $plan['dto']->price;
                 $suggestedPlanPeriod = $plan['dto']->period;
             }
         }
     }
     if ($suggestedPlanId) {
         return array('id' => $suggestedPlanId, 'title' => $suggestedPlanTitle, 'productId' => $membershipService->getPlanProductId($suggestedPlanId), 'price' => $suggestedPlanPrice, 'period' => $suggestedPlanPeriod);
     }
     return null;
 }
Ejemplo n.º 10
0
 protected function joinUser($joinData, $accountType, $params)
 {
     $event = new OW_Event(OW_EventManager::ON_BEFORE_USER_REGISTER, $joinData);
     OW::getEventManager()->trigger($event);
     $language = OW::getLanguage();
     // create new user
     $user = $this->userService->createUser($joinData['username'], $joinData['password'], $joinData['email'], $accountType);
     $password = $joinData['password'];
     unset($joinData['username']);
     unset($joinData['password']);
     unset($joinData['email']);
     unset($joinData['accountType']);
     // save user data
     if (!empty($user->id)) {
         if (BOL_QuestionService::getInstance()->saveQuestionsData($joinData, $user->id)) {
             OW::getSession()->delete(JoinForm::SESSION_JOIN_DATA);
             OW::getSession()->delete(JoinForm::SESSION_JOIN_STEP);
             // authenticate user
             OW::getUser()->login($user->id);
             // create Avatar
             BOL_AvatarService::getInstance()->createAvatar($user->id, false, false);
             $event = new OW_Event(OW_EventManager::ON_USER_REGISTER, array('userId' => $user->id, 'method' => 'native', 'params' => $params));
             OW::getEventManager()->trigger($event);
             OW::getFeedback()->info(OW::getLanguage()->text('base', 'join_successful_join'));
             if (OW::getConfig()->getValue('base', 'confirm_email')) {
                 BOL_EmailVerifyService::getInstance()->sendUserVerificationMail($user);
             }
         } else {
             OW::getFeedback()->error($language->text('base', 'join_join_error'));
         }
         $billingService = BOL_BillingService::getInstance();
         $membershipService = MEMBERSHIP_BOL_MembershipService::getInstance();
         //$url = OW::getRouter()->urlForRoute('membership_subscribe');
         $lang = OW::getLanguage();
         $planId = 16;
         $userId = $user->id;
         if (!($plan = $membershipService->findPlanById($planId))) {
             $message = $lang->text('membership', 'plan_not_found');
             //            OW::getApplication()->redirect($url);
             $this->jsonEncodeResponse(array("status" => "false", "message" => $message));
         }
         if ($plan->price == 0) {
             // trial plan
             // check if trial plan used
             $used = $membershipService->isTrialUsedByUser($userId);
             if ($used) {
                 $message = $lang->text('membership', 'trial_used_error');
             } else {
                 // give trial plan
                 $userMembership = new MEMBERSHIP_BOL_MembershipUser();
                 $userMembership->userId = $userId;
                 $userMembership->typeId = $plan->typeId;
                 $userMembership->expirationStamp = time() + (int) $plan->period * 3600 * 24;
                 $userMembership->recurring = 0;
                 $userMembership->trial = 1;
                 $membershipService->setUserMembership($userMembership);
                 $membershipService->addTrialPlanUsage($userId, $plan->id, $plan->period);
             }
         }
     } else {
         OW::getFeedback()->error($language->text('base', 'join_join_error'));
     }
 }
Ejemplo n.º 11
0
 public function process()
 {
     $values = $this->getValues();
     $type = new MEMBERSHIP_BOL_MembershipType();
     $type->roleId = $values['role'];
     $type->accountTypeId = $values['accType'];
     if (isset($values['price']) && isset($values['period'])) {
         $plan = new MEMBERSHIP_BOL_MembershipPlan();
         $plan->price = floatval($values['price']);
         $plan->period = intval($values['period']);
         $plan->recurring = isset($values['isRecurring']) && $values['price'] > 0 ? $values['isRecurring'] : false;
     } else {
         $plan = null;
     }
     $res = MEMBERSHIP_BOL_MembershipService::getInstance()->addType($type, $plan);
     return $res;
 }
Ejemplo n.º 12
0
 public function billingAddGatewayProduct(BASE_CLASS_EventCollector $event)
 {
     $service = MEMBERSHIP_BOL_MembershipService::getInstance();
     $types = $service->getTypePlanList();
     if (!$types) {
         return;
     }
     foreach ($types as $type) {
         foreach ($type as $plan) {
             $data[] = array('pluginKey' => 'membership', 'label' => $plan['plan_format'], 'entityType' => 'membership_plan', 'entityId' => $plan['dto']->id);
         }
     }
     $event->add($data);
 }
    function content_55c9cb8e203de4_13136957($_smarty_tpl)
    {
        if (!is_callable('smarty_block_style')) {
            include 'E:\\wamp\\www\\hammu\\ow_smarty\\plugin\\block.style.php';
        }
        if (!is_callable('smarty_function_text')) {
            include 'E:\\wamp\\www\\hammu\\ow_smarty\\plugin\\function.text.php';
        }
        if (!is_callable('smarty_function_cycle')) {
            include 'E:\\wamp\\www\\hammu\\ow_libraries\\smarty3\\plugins\\function.cycle.php';
        }
        if (!is_callable('smarty_function_decorator')) {
            include 'E:\\wamp\\www\\hammu\\ow_smarty\\plugin\\function.decorator.php';
        }
        if (!is_callable('smarty_function_user_link')) {
            include 'E:\\wamp\\www\\hammu\\ow_smarty\\plugin\\function.user_link.php';
        }
        if (!is_callable('smarty_function_question_value_lang')) {
            include 'E:\\wamp\\www\\hammu\\ow_smarty\\plugin\\function.question_value_lang.php';
        }
        if (!is_callable('smarty_function_age')) {
            include 'E:\\wamp\\www\\hammu\\ow_smarty\\plugin\\function.age.php';
        }
        $_smarty_tpl->smarty->_tag_stack[] = array('style', array());
        $_block_repeat = true;
        echo smarty_block_style(array(), null, $_smarty_tpl, $_block_repeat);
        while ($_block_repeat) {
            ob_start();
            ?>


    .user_list_thumb {
        width: 55px;
        height: 45px;
    }
    
    .user_list_thumb img {
        width: 45px;
        height: 45px;
    }

<?php 
            $_block_content = ob_get_clean();
            $_block_repeat = false;
            echo smarty_block_style(array(), $_block_content, $_smarty_tpl, $_block_repeat);
        }
        array_pop($_smarty_tpl->smarty->_tag_stack);
        ?>


<?php 
        echo $_smarty_tpl->tpl_vars['menu']->value;
        ?>


<?php 
        if ($_smarty_tpl->tpl_vars['types']->value) {
            ?>
<div class="ow_anno ow_center ow_stdmargin">
    <?php 
            echo smarty_function_text(array('key' => 'membership+displaying_members'), $_smarty_tpl);
            ?>

    <select name="ms_types" onchange="location.href = '<?php 
            echo $_smarty_tpl->tpl_vars['route']->value;
            ?>
/role/'+this.value;">
    <?php 
            $_smarty_tpl->tpl_vars['type'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['type']->_loop = false;
            $_from = $_smarty_tpl->tpl_vars['types']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars['type']->key => $_smarty_tpl->tpl_vars['type']->value) {
                $_smarty_tpl->tpl_vars['type']->_loop = true;
                ?>
        <option value="<?php 
                echo $_smarty_tpl->tpl_vars['type']->value['dto']->roleId;
                ?>
"<?php 
                if ($_smarty_tpl->tpl_vars['type']->value['dto']->roleId == $_smarty_tpl->tpl_vars['roleId']->value) {
                    ?>
 selected="selected"<?php 
                }
                ?>
><?php 
                echo $_smarty_tpl->tpl_vars['type']->value['title'];
                ?>
</option>
    <?php 
            }
            ?>
    </select>
    <?php 
            echo smarty_function_text(array('key' => 'membership+membership'), $_smarty_tpl);
            ?>

</div>
<?php 
        }
        ?>

<?php 
        if (isset($_smarty_tpl->tpl_vars['list']->value)) {
            ?>

<?php 
            echo $_smarty_tpl->tpl_vars['paging']->value;
            ?>


<table class="ow_table_1">
<tr class="ow_tr_first <?php 
            if (empty($_smarty_tpl->tpl_vars['list']->value)) {
                ?>
ow_tr_last<?php 
            }
            ?>
">
    <th><?php 
            echo smarty_function_text(array('key' => 'admin+user'), $_smarty_tpl);
            ?>
</th>
    <th width="20%"><?php 
            echo smarty_function_text(array('key' => 'membership+expires'), $_smarty_tpl);
            ?>
</th>
    <th width="1"><?php 
            echo smarty_function_text(array('key' => 'membership+recurring'), $_smarty_tpl);
            ?>
</th>
</tr>
<?php 
            $_smarty_tpl->tpl_vars['user'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['user']->_loop = false;
            $_from = $_smarty_tpl->tpl_vars['list']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            $_smarty_tpl->tpl_vars['user']->total = $_smarty_tpl->_count($_from);
            $_smarty_tpl->tpl_vars['user']->iteration = 0;
            foreach ($_from as $_smarty_tpl->tpl_vars['user']->key => $_smarty_tpl->tpl_vars['user']->value) {
                $_smarty_tpl->tpl_vars['user']->_loop = true;
                $_smarty_tpl->tpl_vars['user']->iteration++;
                $_smarty_tpl->tpl_vars['user']->last = $_smarty_tpl->tpl_vars['user']->iteration === $_smarty_tpl->tpl_vars['user']->total;
                $_smarty_tpl->tpl_vars['smarty']->value['foreach']["f"]['last'] = $_smarty_tpl->tpl_vars['user']->last;
                $_smarty_tpl->_capture_stack[0][] = array('default', 'userId', null);
                ob_start();
                echo $_smarty_tpl->tpl_vars['user']->value['userId'];
                list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
                if (!empty($_capture_buffer)) {
                    if (isset($_capture_assign)) {
                        $_smarty_tpl->assign($_capture_assign, ob_get_contents());
                    }
                    if (isset($_capture_append)) {
                        $_smarty_tpl->append($_capture_append, ob_get_contents());
                    }
                    Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
                } else {
                    $_smarty_tpl->capture_error();
                }
                $_smarty_tpl->_capture_stack[0][] = array('default', 'username', null);
                ob_start();
                echo $_smarty_tpl->tpl_vars['userNameList']->value[$_smarty_tpl->tpl_vars['userId']->value];
                list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
                if (!empty($_capture_buffer)) {
                    if (isset($_capture_assign)) {
                        $_smarty_tpl->assign($_capture_assign, ob_get_contents());
                    }
                    if (isset($_capture_append)) {
                        $_smarty_tpl->append($_capture_append, ob_get_contents());
                    }
                    Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
                } else {
                    $_smarty_tpl->capture_error();
                }
                ?>
    <tr class="ow_alt<?php 
                echo smarty_function_cycle(array('values' => '1,2'), $_smarty_tpl);
                ?>
 <?php 
                if ($_smarty_tpl->getVariable('smarty')->value['foreach']['f']['last']) {
                    ?>
ow_tr_last<?php 
                }
                ?>
">
        <td>
        <div class="clearfix">
            <div class="ow_left ow_txtleft user_list_thumb"><?php 
                echo smarty_function_decorator(array('name' => 'avatar_item', 'data' => $_smarty_tpl->tpl_vars['avatars']->value[$_smarty_tpl->tpl_vars['userId']->value]), $_smarty_tpl);
                ?>
</div>
            <div class="ow_left ow_txtleft">            
            <?php 
                echo smarty_function_user_link(array('name' => $_smarty_tpl->tpl_vars['displayNames']->value[$_smarty_tpl->tpl_vars['userId']->value], 'username' => $_smarty_tpl->tpl_vars['userNameList']->value[$_smarty_tpl->tpl_vars['userId']->value]), $_smarty_tpl);
                ?>
<br />
            <span class="ow_small">
            <?php 
                if (!empty($_smarty_tpl->tpl_vars['questionList']->value[$_smarty_tpl->tpl_vars['userId']->value]['sex'])) {
                    ?>
                <?php 
                    echo smarty_function_question_value_lang(array('name' => 'sex', 'value' => $_smarty_tpl->tpl_vars['questionList']->value[$_smarty_tpl->tpl_vars['userId']->value]['sex']), $_smarty_tpl);
                    ?>

            <?php 
                }
                ?>
            <?php 
                if (!empty($_smarty_tpl->tpl_vars['questionList']->value[$_smarty_tpl->tpl_vars['userId']->value]['birthdate'])) {
                    ?>
                <?php 
                    echo smarty_function_age(array('dateTime' => $_smarty_tpl->tpl_vars['questionList']->value[$_smarty_tpl->tpl_vars['userId']->value]['birthdate']), $_smarty_tpl);
                    ?>

            <?php 
                }
                ?>
            <br />
            <?php 
                if (!empty($_smarty_tpl->tpl_vars['questionList']->value[$_smarty_tpl->tpl_vars['userId']->value]['email'])) {
                    ?>
                <span class="ow_remark"><?php 
                    echo $_smarty_tpl->tpl_vars['questionList']->value[$_smarty_tpl->tpl_vars['userId']->value]['email'];
                    ?>
</span>
            <?php 
                }
                ?>
            </span>
            </div>
        </div>
        </td>
        <td><?php 
                echo MEMBERSHIP_BOL_MembershipService::formatDate(array('timestamp' => $_smarty_tpl->tpl_vars['user']->value['expirationStamp']), $_smarty_tpl);
                ?>
</td>
        <td><?php 
                if ($_smarty_tpl->tpl_vars['user']->value['recurring']) {
                    ?>
<div class="ow_marked_cell" style="width: 70px;">&nbsp;</div><?php 
                }
                ?>
</td>
    </tr>
<?php 
            }
            ?>
</table>

<?php 
            echo $_smarty_tpl->tpl_vars['paging']->value;
            ?>


<?php 
        } else {
            ?>
    <div class="ow_nocontent"><?php 
            echo smarty_function_text(array('key' => 'admin+no_users'), $_smarty_tpl);
            ?>
</div>
<?php 
        }
    }
Ejemplo n.º 14
0
 public function process()
 {
     $values = $this->getValues();
     $lang = OW::getLanguage();
     $userId = OW::getUser()->getId();
     $billingService = BOL_BillingService::getInstance();
     $membershipService = MEMBERSHIP_BOL_MembershipService::getInstance();
     if (empty($values['gateway']['url']) || empty($values['gateway']['key']) || !($gateway = $billingService->findGatewayByKey($values['gateway']['key']) || !$gateway->active)) {
         OW::getFeedback()->error($lang->text('base', 'billing_gateway_not_found'));
         OW::getApplication()->redirect(OW::getRouter()->urlForRoute('membership_subscribe'));
     }
     if (!($plan = $membershipService->findPlanById($values['plan']))) {
         OW::getFeedback()->error($lang->text('membership', 'plan_not_found'));
         OW::getApplication()->redirect(OW::getRouter()->urlForRoute('membership_subscribe'));
     }
     // create membership plan product adapter object
     $productAdapter = new MEMBERSHIP_CLASS_MembershipPlanProductAdapter();
     // sale object
     $sale = new BOL_BillingSale();
     $sale->pluginKey = 'membership';
     $sale->entityDescription = $membershipService->getFormattedPlan($plan->price, $plan->period, $plan->recurring);
     $sale->entityKey = $productAdapter->getProductKey();
     $sale->entityId = $plan->id;
     $sale->price = floatval($plan->price);
     $sale->period = $plan->period;
     $sale->userId = $userId ? $userId : 0;
     $sale->recurring = $plan->recurring;
     $saleId = $billingService->initSale($sale, $values['gateway']['key']);
     if ($saleId) {
         // sale Id is temporarily stored in session
         $billingService->storeSaleInSession($saleId);
         $billingService->setSessionBackUrl($productAdapter->getProductOrderUrl());
         // redirect to gateway form page
         OW::getApplication()->redirect($values['gateway']['url']);
     }
 }
Ejemplo n.º 15
0
    /**
     * Class constructor
     */
    public function __construct($typeId)
    {
        parent::__construct();
        if (!OW::getUser()->isAdmin()) {
            $this->setVisible(false);
            return;
        }
        $service = MEMBERSHIP_BOL_MembershipService::getInstance();
        $type = $service->findTypeById($typeId);
        $plans = $service->getPlanList($typeId);
        $this->assign('plans', $plans);
        $this->assign('membership', $service->getMembershipTitle($type->roleId));
        $this->assign('typeId', $typeId);
        $this->assign('currency', BOL_BillingService::getInstance()->getActiveCurrency());
        $script = '$("#btn_add_plan").click(function(){
            $(".paid-plan-template:first").clone().insertBefore($(this).closest("tr")).show();
        });

        $("#btn_add_trial_plan").click(function(){
            $(".trial-plan-template:first").clone().insertBefore($(this).closest("tr")).show();
        });

        $("#plans-form").submit(function(){
            $(".paid-plan-template:first").remove();
            $(".trial-plan-template:first").remove();
        });

        $("body")
            .on("change", "#check_all", function(){
                $("#plans .plan_id, #plans .new_plan_id").prop("checked", $(this).prop("checked"));
            });

        $("#btn_delete").click(function(){
            var $plans = $("#plans input.plan_id:checked");
            if ( $plans.length ) {
                var plans = $plans.map(function(){
                    return $(this).data("pid");
                }).get();
                $.ajax({
                    type: "POST",
                    url: ' . json_encode(OW::getRouter()->urlForRoute('membership_delete_plans')) . ',
                    data: { plans : plans },
                    dataType: "json",
                    success : function(data){
                        $plans.each(function(){
                            $(this).closest("tr").remove();
                        });
                    }
                });
            }
            var $newPlans = $("#plans input.new_plan_id:checked:visible");
            if ( $newPlans.length )
            {
                $newPlans.each(function(){
                    $(this).closest("tr").remove();
                });
            }
        });
        ';
        OW::getDocument()->addOnloadScript($script);
    }
Ejemplo n.º 16
0
 public function membershipExpireProcess()
 {
     MEMBERSHIP_BOL_MembershipService::getInstance()->expireUsersMemberships();
 }
Ejemplo n.º 17
0
 public function process()
 {
     $values = $this->getValues();
     $service = MEMBERSHIP_BOL_MembershipService::getInstance();
     $type = $service->findTypeById($values['type']);
     if ($type) {
         $type->roleId = $values['role'];
         $res = $service->updateType($type);
         return (bool) $res;
     }
 }
Ejemplo n.º 18
0
 public function deletePlans()
 {
     if (!OW::getUser()->isAdmin()) {
         throw new Redirect403Exception();
     }
     if (empty($_POST['plans'])) {
         throw new Redirect403Exception();
     }
     $plans = $_POST['plans'];
     $service = MEMBERSHIP_BOL_MembershipService::getInstance();
     foreach ($plans as $planId) {
         $service->deletePlan($planId);
     }
     exit(json_encode(array('result' => true)));
 }
Ejemplo n.º 19
0
 public function findProductByItunesProductId($productId)
 {
     $entityKey = strtolower(substr($productId, 0, strrpos($productId, '_')));
     $entityId = (int) substr($productId, strrpos($productId, '_') + 1);
     if (!strlen($entityKey) || !$productId) {
         return null;
     }
     $pm = OW::getPluginManager();
     $return = array();
     switch ($entityKey) {
         case 'membership_plan':
             if (!$pm->isPluginActive('membership')) {
                 return null;
             }
             $membershipService = MEMBERSHIP_BOL_MembershipService::getInstance();
             $plan = $membershipService->findPlanById($entityId);
             if (!$plan) {
                 return null;
             }
             $return['pluginKey'] = 'membership';
             $return['entityDescription'] = $membershipService->getFormattedPlan($plan->price, $plan->period, $plan->recurring);
             $return['price'] = floatval($plan->price);
             $return['period'] = $plan->period;
             $return['recurring'] = $plan->recurring;
             break;
         case 'user_credits_pack':
             if (!$pm->isPluginActive('usercredits')) {
                 return null;
             }
             $creditsService = USERCREDITS_BOL_CreditsService::getInstance();
             $pack = $creditsService->findPackById($entityId);
             if (!$pack) {
                 return null;
             }
             $return['pluginKey'] = 'usercredits';
             $return['entityDescription'] = $creditsService->getPackTitle($pack->price, $pack->credits);
             $return['price'] = floatval($pack->price);
             $return['period'] = 30;
             $return['recurring'] = 0;
             break;
     }
     $return['entityKey'] = $entityKey;
     $return['entityId'] = $entityId;
     return $return;
 }
Ejemplo n.º 20
0
 public function onAuthLayerCheckCollectError(BASE_CLASS_EventCollector $event)
 {
     $params = $event->getParams();
     $actionName = $params['actionName'];
     $groupName = $params['groupName'];
     $service = MEMBERSHIP_BOL_MembershipService::getInstance();
     $authService = BOL_AuthorizationService::getInstance();
     $action = $authService->findAction($groupName, $actionName);
     if (!$action) {
         return;
     }
     $canPurchase = $service->actionCanBePurchased($action->id);
     if (!$canPurchase) {
         return;
     }
     $data = array('pluginKey' => 'membership', 'label' => OW::getLanguage()->text('membership', 'upgrade'), 'url' => OW::getRouter()->urlForRoute('membership_subscribe'), 'priority' => 1);
     $event->add($data);
 }
Ejemplo n.º 21
0
 public function process()
 {
     $values = $this->getValues();
     $lang = OW::getLanguage();
     $userId = OW::getUser()->getId();
     $billingService = BOL_BillingService::getInstance();
     $membershipService = MEMBERSHIP_BOL_MembershipService::getInstance();
     $url = OW::getRouter()->urlForRoute('membership_subscribe');
     if (!($plan = $membershipService->findPlanById($values['plan']))) {
         OW::getFeedback()->error($lang->text('membership', 'plan_not_found'));
         OW::getApplication()->redirect($url);
     }
     if ($plan->price == 0) {
         // trial plan
         // check if trial plan used
         $used = $membershipService->isTrialUsedByUser($userId);
         if ($used) {
             OW::getFeedback()->error($lang->text('membership', 'trial_used_error'));
             OW::getApplication()->redirect($url);
         } else {
             // give trial plan
             $userMembership = new MEMBERSHIP_BOL_MembershipUser();
             $userMembership->userId = $userId;
             $userMembership->typeId = $plan->typeId;
             $userMembership->expirationStamp = time() + (int) $plan->period * 3600 * 24;
             $userMembership->recurring = 0;
             $userMembership->trial = 1;
             $membershipService->setUserMembership($userMembership);
             $membershipService->addTrialPlanUsage($userId, $plan->id, $plan->period);
             OW::getFeedback()->info($lang->text('membership', 'trial_granted', array('days' => $plan->period)));
             OW::getApplication()->redirect($url);
         }
     }
     if (empty($values['gateway']['url']) || empty($values['gateway']['key'])) {
         OW::getFeedback()->error($lang->text('base', 'billing_gateway_not_found'));
         OW::getApplication()->redirect($url);
     }
     $gateway = $billingService->findGatewayByKey($values['gateway']['key']);
     if (!$gateway || !$gateway->active) {
         OW::getFeedback()->error($lang->text('base', 'billing_gateway_not_found'));
         OW::getApplication()->redirect($url);
     }
     // create membership plan product adapter object
     $productAdapter = new MEMBERSHIP_CLASS_MembershipPlanProductAdapter();
     // sale object
     $sale = new BOL_BillingSale();
     $sale->pluginKey = 'membership';
     $sale->entityDescription = $membershipService->getFormattedPlan($plan->price, $plan->period, $plan->recurring);
     $sale->entityKey = $productAdapter->getProductKey();
     $sale->entityId = $plan->id;
     $sale->price = floatval($plan->price);
     $sale->period = $plan->period;
     $sale->userId = $userId ? $userId : 0;
     $sale->recurring = $plan->recurring;
     $saleId = $billingService->initSale($sale, $values['gateway']['key']);
     if ($saleId) {
         // sale Id is temporarily stored in session
         $billingService->storeSaleInSession($saleId);
         $billingService->setSessionBackUrl($productAdapter->getProductOrderUrl());
         // redirect to gateway form page
         OW::getApplication()->redirect($values['gateway']['url']);
     }
 }
Ejemplo n.º 22
0
 public function membershipExpireProcess()
 {
     MEMBERSHIP_BOL_MembershipService::getInstance()->expireUsersMemberships();
     MEMBERSHIP_BOL_MembershipService::getInstance()->sendExpirationNotifications(self::MEMBERSHIP_EXPIRE_NOTIFICATIONS_LIMIT);
 }