本文整理汇总了PHP中AuthUser::UpdateSubscription方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthUser::UpdateSubscription方法的具体用法?PHP AuthUser::UpdateSubscription怎么用?PHP AuthUser::UpdateSubscription使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthUser
的用法示例。
在下文中一共展示了AuthUser::UpdateSubscription方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
/**
* @method POST
*/
function post()
{
// parse request
parse_str($this->request->data, $request);
$plan = $request['plan'];
// get an authuser
$authUser = new AuthUser();
if (isset($authUser->UserUniqId)) {
// check if authorized
try {
$site = Site::GetBySiteUniqId($authUser->SiteUniqId);
Stripe::setApiKey(STRIPE_API_KEY);
$customer = Stripe_Customer::retrieve($site['CustomerId']);
// retrieve default subscription
if (isset($customer->subscriptions->data[0])) {
$subscription = $customer->subscriptions->data[0];
// updates the subscription
if ($subscription != NULL) {
$subscription->plan = $plan;
$subscription->save();
}
// update the session
AuthUser::UpdateSubscription();
}
// return a json response
return new Tonic\Response(Tonic\Response::OK);
} catch (Exception $e) {
$response = new Tonic\Response(Tonic\Response::BADREQUEST);
$response->body = $e->getMessage();
return $response;
}
} else {
return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
}
}
示例2: Create
public static function Create($user, $canEdit, $canPublish, $canRemove, $canCreate)
{
session_start();
$site = Site::GetBySiteId($user['SiteId']);
$isSuperAdmin = false;
if ($user['Email'] == SITE_ADMIN) {
// set is superman
$isSuperAdmin = true;
}
$isFirstLogin = 0;
if ($site['LastLogin'] == null || $site['LastLogin'] == '') {
$isFirstLogin = 1;
}
// determine whether user has a photo
$hasPhotoUrl = true;
if ($user['PhotoUrl'] == null || $user['PhotoUrl'] == '') {
$hasPhotoUrl = false;
}
Site::SetLastLogin($site['SiteUniqId']);
$directory = 'sites/' . $site['FriendlyId'] . '/';
$_SESSION['UserId'] = $user['UserId'];
$_SESSION['UserUniqId'] = $user['UserUniqId'];
$_SESSION['Role'] = $user['Role'];
$_SESSION['Language'] = $user['Language'];
$_SESSION['IsSuperAdmin'] = $isSuperAdmin;
$_SESSION['IsFirstLogin'] = $isFirstLogin;
$_SESSION['Email'] = $user['Email'];
$_SESSION['Name'] = $user['FirstName'] . ' ' . $user['LastName'];
$_SESSION['FirstName'] = $user['FirstName'];
$_SESSION['LastName'] = $user['LastName'];
$_SESSION['HasPhotoUrl'] = $hasPhotoUrl;
$_SESSION['PhotoUrl'] = $user['PhotoUrl'];
$_SESSION['SiteId'] = $user['SiteId'];
$_SESSION['SiteUniqId'] = $site['SiteUniqId'];
$_SESSION['SiteFriendlyId'] = $site['FriendlyId'];
$_SESSION['Domain'] = $site['Domain'];
$_SESSION['Currency'] = $site['Currency'];
$_SESSION['WeightUnit'] = $site['WeightUnit'];
$_SESSION['Directory'] = $directory;
$_SESSION['LogoUrl'] = $site['LogoUrl'];
$_SESSION['sid'] = session_id();
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['SiteName'] = $site['Name'];
$_SESSION['FileUrl'] = 'sites/' . $site['FriendlyId'] . '/files/';
$_SESSION['TimeZone'] = $site['TimeZone'];
$_SESSION['Type'] = $site['Type'];
$_SESSION['CustomerId'] = $site['CustomerId'];
// what can be edited and published
if ($canEdit == 'All' || $canPublish == 'All' || $canRemove == 'All' || $canCreate == 'All') {
$_SESSION['Access'] = 'All';
} else {
$_SESSION['Access'] = $canEdit . ',' . $canPublish . ',' . $canRemove . ',' . $canCreate;
}
$_SESSION['CanEdit'] = $canEdit;
$_SESSION['CanPublish'] = $canPublish;
$_SESSION['CanRemove'] = $canRemove;
$_SESSION['CanCreate'] = $canCreate;
if (strtoupper($site['Type']) == 'SUBSCRIPTION' && $site['CustomerId'] != NULL) {
AuthUser::UpdateSubscription();
} else {
$_SESSION['Status'] = 'N/A';
$_SESSION['Plan'] = 'N/A';
$_SESSION['RenewalDate'] = NULL;
}
}