function OnLoadPageData()
 {
     # Add subscription
     $o_subs = new SubscriptionManager($this->GetSettings(), $this->GetDataConnection());
     $o_subs->SaveSubscription($this->o_review_item->GetId(), $this->o_review_item->GetType(), AuthenticationManager::GetUser()->GetId());
     unset($o_subs);
 }
 function OnLoadPageData()
 {
     $sub_manager = new SubscriptionManager($this->GetSettings(), $this->GetDataConnection());
     # process delete request
     if (isset($_GET['delete']) and is_numeric($_GET['delete']) and (isset($_GET['type']) and is_numeric($_GET['type']))) {
         $sub_manager->DeleteSubscription($_GET['delete'], $_GET['type'], AuthenticationManager::GetUser()->GetId());
     }
     # get subscription data
     $sub_manager->ReadSubscriptionsForUser(AuthenticationManager::GetUser()->GetId());
     $this->a_subs = $sub_manager->GetItems();
 }
 public function OnPostback()
 {
     # If there's no id, ensure no match object is created. Page will then display a "match not found" message.
     # There's a separate page for adding matches, even for admins.
     if (!$this->editor->GetDataObjectId()) {
         return;
     }
     # Get the submitted match
     $this->match = $this->editor->GetDataObject();
     # Because this is a new request, we need to reverify whether this is the match owner before letting anything happen.
     # Can't trust that info from a postback so MUST go to the database to check it.
     $this->match_manager->ReadByMatchId(array($this->editor->GetDataObjectId()));
     $check_match = $this->match_manager->GetFirst();
     $this->b_user_is_match_owner = ($check_match instanceof Match and AuthenticationManager::GetUser()->GetId() == $check_match->GetAddedBy()->GetId());
     # Don't wan't to edit tournaments on this page, so even as admin make sure we're not trying to save one.
     # Can't change the match type, so find out what that is from the db too.
     $this->b_is_tournament = $check_match->GetMatchType() == MatchType::TOURNAMENT;
     # Check whether cancel was clicked
     if ($this->editor->CancelClicked()) {
         # If so, get the match's short URL and redirect
         $this->match_manager->ExpandMatchUrl($this->match);
         $this->Redirect($this->match->GetNavigateUrl());
     }
     # save data if valid
     if ($this->IsValid() and !$this->b_is_tournament) {
         # Save player of match
         $this->match_manager->SaveHighlights($this->match);
         $this->match_manager->ExpandMatchUrl($this->match);
         # Add comment if provided
         if (trim($this->match->GetNewComment())) {
             require_once 'forums/topic-manager.class.php';
             require_once 'forums/review-item.class.php';
             require_once 'forums/subscription-manager.class.php';
             $topic_manager = new TopicManager($this->GetSettings(), $this->GetDataConnection());
             $item_to_comment_on = new ReviewItem($this->GetSettings());
             $item_to_comment_on->SetType(ContentType::STOOLBALL_MATCH);
             $item_to_comment_on->SetId($this->match->GetId());
             $item_to_comment_on->SetNavigateUrl("https://" . $this->GetSettings()->GetDomain() . $this->match->GetNavigateUrl());
             $message = $topic_manager->SaveComment($item_to_comment_on, $this->match->GetNewComment());
             # send subscription emails
             $subs_manager = new SubscriptionManager($this->GetSettings(), $this->GetDataConnection());
             $subs_manager->SendCommentsSubscriptions($item_to_comment_on, $message);
             unset($subs_manager);
         }
         # Match may have been updated so send an email
         $this->match_manager->NotifyMatchModerator($this->match->GetId());
         # Show user the match, so they can see update was applied
         $this->Redirect($this->match->GetNavigateUrl());
     }
 }
Пример #4
0
 function do_main()
 {
     $this->aBreadcrumbs[] = array("name" => _kt("Subscription Management"));
     $aFolderSubscriptions = SubscriptionManager::retrieveUserSubscriptions($this->oUser->getId(), SubscriptionEvent::subTypes('Folder'));
     $aDocumentSubscriptions = SubscriptionManager::retrieveUserSubscriptions($this->oUser->getId(), SubscriptionEvent::subTypes('Document'));
     $bNoSubscriptions = count($aFolderSubscriptions) == 0 && count($aDocumentSubscriptions) == 0 ? true : false;
     $oTemplate = $this->oValidator->validateTemplate('ktstandard/subscriptions/manage');
     $aTemplateData = array('aFolderSubscriptions' => $aFolderSubscriptions, 'aDocumentSubscriptions' => $aDocumentSubscriptions);
     return $oTemplate->render($aTemplateData);
 }
Пример #5
0
    $termStart = get_post_value('TermStart');
    $contractEffdt = $termStart;
    $activationDt = $termStart;
    $acceptanceDt = $termStart;
    // set parent ID to the node in the hierarchy clicked
    $parentId = $_SESSION['accountId'];
    // echo 'payment in post: ' . $paymentTerm;
    if ($invoiceOwner == 'pbill') {
        $InvoiceOwnerId = $_SESSION['accountId'];
    } else {
        $InvoiceOwnerId = 'null';
    }
    //echo 'parent id: ' . $_SESSION['parentId'];
    $subInfo = array('accountName' => $acctName, 'term' => $term, 'firstName' => $firstName, 'lastName' => $lastName, 'accountName' => $acctName, 'parentId' => $parentId, 'address' => $address, 'city' => $city, 'state' => $state, 'country' => $country, 'postalCode' => $postalCode, 'paymentTerm' => $paymentTerm, 'invoiceOwner' => $InvoiceOwnerId, 'initTerm' => $initTerm, 'renewTerm' => $renewTerm, 'autoRenew' => $autoRenew, 'termStart' => $termStart, 'contractEffdt' => $contractEffdt, 'activationDt' => $activationDt, 'acceptanceDt' => $acceptanceDt);
    //TODO add code to check up against app table
    $subRes = SubscriptionManager::partnerSubscribe($subInfo, $_SESSION['cart']);
    //$sandbox_session_id = get_session_id($username, $password, $url);
    if (!$subRes->result->Success) {
        $_SESSION['subSuccess'] = 'false';
        echo 'false ';
        echo $subRes->result->Errors->Message . ' ';
        echo $subRes->result->Errors->Code . ' ';
    } else {
        $_SESSION['subSuccess'] = 'true';
        $_SESSION['subInfo'] = $subInfo;
        echo 'true';
    }
    $headerStr = "../confirmation.html";
    Header("Location:" . $headerStr);
}
ob_end_flush();
Пример #6
0
function previewCurrentCart()
{
    global $messages;
    $subscribePreview = new Subscribe_Preview();
    $subscribePreview = SubscriptionManager::previewCart($_SESSION['cart']);
    $messages = $subscribePreview;
    return;
}
Пример #7
0
function test_Amender_updateRatePlan()
{
    global $EXISTING_CUSTOMER_ACCOUNT_NAME;
    printResultStart(__FUNCTION__);
    $messages = array();
    try {
        //Get the Rateplan ID of an updatable active plan on this user's subscription
        $sub = SubscriptionManager::getCurrentSubscriptions($EXISTING_CUSTOMER_ACCOUNT_NAME);
        $rpId = null;
        foreach ($sub->active_plans as $rp) {
            if ($rp->uom != null) {
                $rpId = $rp->Id;
            }
        }
        if ($rpId == null) {
            echo "This must have an updatable rate plan to run this test.";
            printResultEnd($messages);
            return;
        }
        echo "Updating quantity of Rate Plan '" . $rpId . "' on account '" . $EXISTING_CUSTOMER_ACCOUNT_NAME . "'<br>";
        //Test
        $amRes = Amender::updateRatePlan($EXISTING_CUSTOMER_ACCOUNT_NAME, $rpId, 4, true);
        print_r_html($amRes);
        /*
        		if($amRes->results->Success){
        			echo "<br>RemoveProduct amendment successfully created.<br>";
        
        			$zapi = new zApi();
        			echo "Deleting created amendment.<br>";
        			$deleteResult = $zapi->zDelete(array($amRes->results->AmendmentIds),'Amendment');
        			print_r_html($deleteResult);
        
        		}*/
    } catch (Exception $e) {
        array_push($messages, $e->getMessage());
    }
    printResultEnd($messages);
}
Пример #8
0
    $signature = $_POST['signature'];
}
$respSignature = hash_hmac('sha1', $data, $secret_key);
if ($signature != "" && strcmp($signature, $respSignature) != 0) {
    $flag = "false";
}
$Payment = new Payment();
$details = $Payment->get($txnid);
if (!empty($details) && $flag == "true") {
    $comments = $_POST['TxMsg'];
    $status = "Paid";
    if ($txnstatus != "SUCCESS") {
        $status = "Failed";
    }
    $more_details = array('transaction_id' => $pgtxnno, 'status' => $status, 'comments' => $comments, 'payment_date' => $payment_date, 'postal_code' => $pincode);
    $SM = new SubscriptionManager();
    $package = $SM->getPackageDetails($details['package_id']);
    if (!empty($package)) {
        /*
         * 03-11-15 :: vj calculate ext payment date using last payment details
         * 18-11-15 :: vj : Purchase, Updgrade and Re-purchase has been handled 
         */
        $last_payment = $SM->getLastPaymentDetails($details['app_key'], 'Paid');
        if (empty($last_payment)) {
            //18-11-15 :: vj : if no last payment then set next_payment_date to now
            $last_payment['next_payment_date'] = 'now';
        }
        if ($details['type'] != 'Upgrade') {
            //03-11-15 :: set next payment date if not upgrading
            $more_details['next_payment_date'] = $SM->calculateNextPaymentDate($package['payment_cycle'], $last_payment['next_payment_date']);
        }
Пример #9
0
<form action="" method="post">
	<label>Email</label><input type="text" name="sub_email" id="sub_email_id">
	<input type="Submit" value="Subscribe" id="submitbtn">
	<span id="sub_error"></span>
</form>

<form action="" method="post">
	<label>Email</label><input type="text" name="usub_email" id="usub_email_id">
	<input type="Submit" value="UnSubscribe" id="usubmitbtn">
	<span id="usub_error"></span>
</form>

<?php 
$sub_email = isset($_POST['sub_email']) ? $_POST['sub_email'] : "";
$usub_email = isset($_POST['usub_email']) ? $_POST['usub_email'] : "";
$subscribe = new SubscriptionManager();
if ($sub_email != "") {
    $subscribed = $subscribe->subscribe($sub_email);
    if ($subscribed) {
        echo "Subscribed successfully";
        $sub_body = "\n<html>\n<head>\n  <title>Tarboz Newsletter Subscription</title>\n</head>\n<body>\n        <b>Dear subscriber</b>, \n           <p>Thank you for subscribe out news letter. This is to confirm your subscription. Please note we have your permission to send you newsletters periodically.</p>\n           <p>To unsubscribe newsletter, please click <a href='http://zenit.senecac.on.ca:9086/tarboz'>here</a>.</p>\n           <br/>\n           Yours truly,<br/>\n           Tarboz Newsletter\n</body>\n</html>";
        $sub_subject = "Tarboz Newsletter Subscription";
        $subscribe->sendEmail($sub_email, $sub_body, $sub_subject);
    } else {
        echo "Failed successfully";
    }
    header("Location: ../index.php");
} else {
    if ($usub_email != "") {
        $subscribed = $subscribe->unsubscribe($usub_email);
        if ($subscribed) {
Пример #10
0
 /**
  * Get the users subscriptions
  *
  * @author KnowledgeTree Team
  * @access public
  * @param string $filter
  * @return array of Subscription
  */
 public function getSubscriptions($filter = null)
 {
     $user = $this->get_user();
     $userId = $user->getID();
     $subscriptions = SubscriptionManager::listSubscriptions($userId);
     return $subscriptions;
 }
 function SavePostedComments(TopicManager $topic_manager)
 {
     /* @var $message ForumMessage */
     if (trim($_POST['message']) and !$this->IsRefresh()) {
         $message = $topic_manager->SaveComment($this->review_item, $_POST['message']);
         # send subscription emails
         require_once 'forums/subscription-manager.class.php';
         $o_subs = new SubscriptionManager($this->GetSettings(), $this->GetDataConnection());
         $o_subs->SendCommentsSubscriptions($this->review_item, $message);
         # add subscription if appropriate
         if (isset($_POST['subscribe'])) {
             $o_subs->SaveSubscription($this->review_item->GetId(), $this->review_item->GetType(), AuthenticationManager::GetUser()->GetId());
         }
     }
 }
 function OnLoadPageData()
 {
     /* @var $o_match Match */
     /* @var $o_team Team */
     # new data manager
     $match_manager = new MatchManager($this->GetSettings(), $this->GetDataConnection());
     # create repeater control, and save any posted data
     $this->repeater = new DataEditRepeater($this, 'CreateEditControl');
     $this->repeater->SetCssClass('matchResults');
     $this->repeater->SetPersistedParameters(array('team', 'season', "tournament"));
     $this->repeater->SetButtonText('Save all results');
     $this->repeater->SetShowButtonsAtTop(true);
     if ($this->IsPostback() and !$this->IsRefresh() and $this->IsValid()) {
         require_once 'forums/topic-manager.class.php';
         require_once 'forums/review-item.class.php';
         require_once 'forums/subscription-manager.class.php';
         $topic_manager = new TopicManager($this->GetSettings(), $this->GetDataConnection());
         foreach ($this->repeater->GetDataObjects() as $o_current_match) {
             /* @var $o_current_match Match */
             $match_manager->SaveResult($o_current_match);
             $match_manager->ExpandMatchUrl($o_current_match);
             $match_manager->NotifyMatchModerator($o_current_match->GetId());
             if (trim($o_current_match->GetNewComment())) {
                 $item_to_comment_on = new ReviewItem($this->GetSettings());
                 $item_to_comment_on->SetType(ContentType::STOOLBALL_MATCH);
                 $item_to_comment_on->SetId($o_current_match->GetId());
                 $item_to_comment_on->SetNavigateUrl("https://" . $this->GetSettings()->GetDomain() . $o_current_match->GetNavigateUrl());
                 $message = $topic_manager->SaveComment($item_to_comment_on, $o_current_match->GetNewComment());
                 # send subscription emails - new object each time to reset list of who's already recieved an email
                 $subs_manager = new SubscriptionManager($this->GetSettings(), $this->GetDataConnection());
                 $subs_manager->SendCommentsSubscriptions($item_to_comment_on, $message);
                 unset($subs_manager);
             }
         }
         $this->b_saved = true;
     }
     # get matches
     if (!is_null($this->i_team_id)) {
         $a_season_times = Season::SeasonDates();
         $match_manager->FilterByTeam(array($this->i_team_id));
         $match_manager->FilterByDateStart($a_season_times[0]);
         $match_manager->FilterByDateEnd($a_season_times[1]);
         $match_manager->ReadMatchSummaries();
     } else {
         if (!is_null($this->i_season_id)) {
             $match_manager->ReadBySeasonId(array($this->i_season_id), true);
         } else {
             if (!is_null($this->tournament_id)) {
                 $match_manager->FilterByTournament($this->tournament_id);
                 $this->a_matches = $match_manager->ReadMatchSummaries();
             }
         }
     }
     $this->a_matches = $match_manager->GetItems();
     # Make sure we have some matches
     if (count($this->a_matches)) {
         # If it's matches for a team, get the team
         if (!is_null($this->i_team_id)) {
             # Should only need to look at the first match, because the team must be a
             # part of that match in order for the match to be in this list
             $o_match =& $this->a_matches[0];
             $o_team = $o_match->GetHomeTeam();
             if ($o_team instanceof Team and $o_team->GetId() == $this->i_team_id) {
                 $this->team = $o_team;
             } else {
                 foreach ($o_match->GetAwayTeams() as $o_team) {
                     if ($o_team->GetId() == $this->i_team_id) {
                         $this->team = $o_team;
                         break;
                     }
                 }
             }
             if (!is_object($this->team)) {
                 $this->Redirect();
             }
             # Now that we have short URL data, if data has just been saved for team, redirect back to team
             if ($this->b_saved) {
                 $this->Redirect($this->team->GetNavigateUrl());
             }
         } else {
             if (!is_null($this->i_season_id)) {
                 # get details of the season
                 require_once 'stoolball/competition-manager.class.php';
                 $o_comp_manager = new CompetitionManager($this->GetSettings(), $this->GetDataConnection());
                 $o_comp_manager->ReadById(null, array($this->i_season_id));
                 $o_competition = $o_comp_manager->GetFirst();
                 unset($o_comp_manager);
                 if ($o_competition instanceof Competition) {
                     $this->season = $o_competition->GetWorkingSeason();
                 }
                 if (!$this->season instanceof Season) {
                     $this->Redirect();
                 }
                 # Now that we have short URL data, if data has just been saved for season, redirect back to season
                 if ($this->b_saved) {
                     $this->Redirect($this->season->GetNavigateUrl());
                 }
             } else {
                 if (!is_null($this->tournament_id)) {
                     $match_manager->ReadByMatchId(array($this->tournament_id));
                     $this->tournament = $match_manager->GetFirst();
                     if (!is_null($this->tournament)) {
                         # If the tournament has just been saved, now we have its URL so redirect to the thanks page
                         if ($this->b_saved) {
                             $this->Redirect($this->tournament->GetNavigateUrl());
                         }
                     }
                 }
             }
         }
     } else {
         $this->Redirect();
     }
     unset($match_manager);
 }
Пример #13
0
 /**
  * Creates dummy subscription with given cart, used to determine the value of the first invoice. Error codes are as follows:
  * 		EMPTY_CART: No items in the cart
  * 		RATE_PLAN_DOESNT_EXIST: No match was found for a rate plan
  * 		RATE_PLAN_EXPIRED: Rate Plan is outside of its effective period
  * @param $cart An instance of a Cart object that contains all rate plans and quantities that will be used in this subscription.
  * @return Subscribe_Preview Object with fields for invoice success result, invoiceAmount if successful, and error code if unsuccessful.
  */
 static function previewCart($cart)
 {
     // Need to FIX this to fail gracefully (not hard-code address info)
     // $firstName = isset($_SESSION['userFname']) ? $_SESSION['userFname'] : 'John';
     // $lastName = isset($_SESSION['userLname']) ? $_SESSION['userLname'] : 'Smith';
     // $Address1 = isset($_SESSION['userAddress1']) ? $_SESSION['userAddress1'] : '';
     // // $Address2 = isset($pm->CreditCardAddress2) ? $pm->CreditCardAddress2 : '';
     // $City = isset($_SESSION['userCity']) ? $_SESSION['userCity'] : '';
     // $Country = isset($_SESSION['userCountry']) ? $_SESSION['userCountry'] : 'USA'; // only USA if left blank
     // $PostalCode = isset($_SESSION['userPostalCode']) ? $_SESSION['userPostalCode'] : '';
     // $State = isset($_SESSION['userState']) ? $_SESSION['userState'] : 'CA'; // only CA if left blank
     // $Phone = isset($_SESSION['userPhone']) ? $_SESSION['userPhone'] : '';
     //Initialize Subscribe_Preview model
     $subscribePreview = new Subscribe_Preview();
     //If Cart is empty, return an empty cart message
     if (count($cart->cart_items) == 0) {
         $subscribePreview->invoiceAmount = 0;
         $subscribePreview->success = false;
         $subscribePreview->error = "EMPTY_CART";
         return $subscribePreview;
     }
     //Preview with SubscribeRequest
     $zapi = new zApi();
     date_default_timezone_set('America/Los_Angeles');
     //		$date = date('Y-m-d',time()) . 'T00:00:00';
     $date = date('Y-m-d\\T00:00:00', time());
     $today = getdate();
     $mday = $today['mday'];
     include "./config.php";
     //Set up account
     $account = array("AutoPay" => 0, "Currency" => $defaultCurrency, "Name" => 'TestName', "PaymentTerm" => "Net 30", "Batch" => "Batch1", "BillCycleDay" => $mday, "Status" => "Active");
     // FIX this
     //Set up contact
     $bcontact = array("Address1" => $Address1, "City" => $City, "Country" => 'USA', "FirstName" => 'John', "LastName" => 'Smith', "PostalCode" => $PostalCode, "State" => 'CA', "WorkEmail" => $userEmail, "WorkPhone" => $Phone);
     $subscribeOptions = array("GenerateInvoice" => true, "ProcessPayments" => false);
     $previewOptions = array("EnablePreviewMode" => true);
     //Set up subscription
     $subscription = array("ContractEffectiveDate" => $date, "ServiceActivationDate" => $date, "ContractAcceptanceDate" => $date, "TermStartDate" => $date, "TermType" => "TERMED", "InitialTerm" => 12, "RenewalTerm" => 12, "AutoRenew" => true, "Status" => "Active");
     $ratePlanData = SubscriptionManager::getRatePlanDataFromCart($cart);
     $subscriptionData = array("Subscription" => $subscription, "RatePlanData" => $ratePlanData);
     $subscribeRequest = array("Account" => $account, "BillToContact" => $bcontact, "SubscribeOptions" => $subscribeOptions, "PreviewOptions" => $previewOptions, "SubscriptionData" => $subscriptionData);
     $subResult = $zapi->zSubscribe($subscribeRequest);
     if ($subResult->result->Success == true) {
         if (isset($subResult->result->InvoiceData)) {
             $subscribePreview->invoiceAmount = $subResult->result->InvoiceData->Invoice->Amount;
             $subscribePreview->success = true;
         } else {
             $subscribePreview->invoiceAmount = number_format((double) 0, 2, '.', '');
             $subscribePreview->success = true;
         }
     } else {
         $subscribePreview->success = false;
         if (count($subResult->result->Errors) == 1) {
             $subResult->result->Errors = array($subResult->result->Errors);
         }
         $errorResponse = $subResult->result->Errors[0]->Message;
         if (strpos($errorResponse, 'ProductRatePlanId is invalid.')) {
             $subscribePreview->error = "RATE_PLAN_DOESNT_EXIST";
         } else {
             if (strpos($errorResponse, 'RatePlan is out of date.')) {
                 $subscribePreview->error = "RATE_PLAN_EXPIRED";
             } else {
                 $subscribePreview->error = $errorResponse;
             }
         }
     }
     return $subscribePreview;
 }