<?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>
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(); }