<?php $checkFor = PlanResourceType::RTYPE_LISTINGS_PER_ADVERTISER; if (PlanRestriction::allowsNew($checkFor, Yii::app()->user->getAdvertiserId())) { ?> <div class="portlet"> <div class="portlet-header">Create Listing</div> <div class="portlet-content"> <?php echo $this->renderPartial('_form', array('model' => $model, 'coupons' => $coupons)); ?> </div> </div> <?php } else { ?> <?php echo $this->renderPartial('/restriction/restriction', array('model' => $model, 'resourceType' => $checkFor, 'resTypeName' => 'listings')); ?> <?php } ?> <div class="title title-spacing"> <h3>Manage Listings</h3> </div>
public static function checkAuthorizeNetPlans($planType, $advertiserId) { $sql = "SELECT plan_id, pplan_id, subscription_id, type, duration, expired FROM p_purchased_plans" . " WHERE wlabel_id=" . Yii::app()->user->getWhiteLabelId() . " AND expired=0" . " AND method=" . PaymentType::TYPE_AUTHORIZENET; if ($planType == PlanType::ADVERTISER_PLAN && $advertiserId != '') { $sql .= " AND advertiser_id=" . $advertiserId; } $dbCommand = Yii::app()->db->createCommand($sql); $results = $dbCommand->queryAll(); if ($results == null) { return null; } foreach ($results as $row) { // now check the plan subscription status through Authorize.net $status = PlanRestriction::checkSubscriptionStatus($row['subscription_id']); if ($status == 'active') { // insert new purchased plan payment PlanRestriction::insertNewPurchasedPlanPayment($row['pplan_id'], $row['duration']); return array('plan_id' => $row['plan_id']); } else { // set plan to expired $purchasedPlan = PurchasedPlan::model()->findByPk($row['pplan_id']); $purchasedPlan->expired = 1; $purchasedPlan->save(); } } return null; }
function beforeSave() { if (!$this->logo) { $this->logo = $this->_oldLogo; } if ($this->isNewRecord) { if ($this->type == ListingType::TYPE_STANDARD) { if (!PlanRestriction::allowsNew(PlanResourceType::RTYPE_LISTINGS_PER_ADVERTISER, $this->advertiser_id)) { throw new CHttpException(1234, "Cannot add new listing. You need to buy a plan that will allows you to add new listings!"); } } else { if ($this->type == ListingType::TYPE_FEATURED) { if (!PlanRestriction::allowsNew(PlanResourceType::RTYPE_FEATURED_LISTINGS_PER_ADVERTISER, $this->advertiser_id)) { throw new CHttpException(1234, "Cannot add new listing. You need to buy a plan that will allows you to add new listings!"); } } } } return parent::beforeSave(); }
<?php $checkFor = PlanResourceType::RTYPE_LOCATIONS_PER_ACCOUNT; if (PlanRestriction::allowsNew($checkFor)) { ?> <div class="portlet"> <div class="portlet-header">Create Location</div> <div class="portlet-content"> <?php echo $this->renderPartial('_form', array('model' => $model)); ?> </div> </div> <?php } else { ?> <?php echo $this->renderPartial('/restriction/restriction', array('model' => $model, 'resourceType' => $checkFor, 'resTypeName' => 'locations')); ?> <?php } ?> <div class="title title-spacing">
function beforeSave() { if (!$this->logo) { $this->logo = $this->_oldLogo; } if ($this->isNewRecord) { if (!PlanRestriction::allowsNew(PlanResourceType::RTYPE_LOCATIONS_PER_ACCOUNT, Yii::app()->user->getAdvertiserId())) { throw new CHttpException(1234, "Cannot add new Location. You need to buy a plan that will allows you to add new Location!"); } } return parent::beforeSave(); }