コード例 #1
0
ファイル: PremiumAdsSlides.php プロジェクト: yasirgit/hotmall
 public function run()
 {
     $premiumAds = PremiumAd::model()->loadPremiumAds($this->position, Yii::app()->user->getCategoryId(), Yii::app()->user->getLocationId(), Yii::app()->user->getListingId());
     if ($this->position == PremiumAdPosition::POS_TOP || $this->position == PremiumAdPosition::POS_BOTTOM) {
         $this->render('premium_ad_slide_top', array('premiumAds' => $premiumAds));
     } else {
         $this->render('premium_ad_slide_sidebar', array('premiumAds' => $premiumAds));
     }
 }
コード例 #2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = PremiumAd::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     // load categories
     $criteria = new CDbCriteria();
     $criteria->condition = 'premiumad_id=:premiumad_id';
     $criteria->select = 'category_id';
     $criteria->params = array(':premiumad_id' => $id);
     $adCategories = PremiumAdCategory::model()->findAll($criteria);
     $categories = array();
     foreach ($adCategories as $category) {
         $categories[] = $category->category_id;
     }
     $model->p_categories = $categories;
     // load locations
     $criteria = new CDbCriteria();
     $criteria->condition = 'premiumad_id=:premiumad_id';
     $criteria->select = 'location_id';
     $criteria->params = array(':premiumad_id' => $id);
     $adLocations = PremiumAdLocation::model()->findAll($criteria);
     $locations = array();
     foreach ($adLocations as $location) {
         $locations[] = $location->location_id;
     }
     $model->p_locations = $locations;
     // load listings
     $criteria = new CDbCriteria();
     $criteria->condition = 'premiumad_id=:premiumad_id';
     $criteria->select = 'listing_id';
     $criteria->params = array(':premiumad_id' => $id);
     $adListings = PremiumAdListing::model()->findAll($criteria);
     $listings = array();
     foreach ($adListings as $listing) {
         $listings[] = $listing->listing_id;
     }
     $model->p_listings = $listings;
     return $model;
 }
コード例 #3
0
ファイル: PlanRestriction.php プロジェクト: yasirgit/hotmall
 /**
  * function returns current number of resources (listings, etc.) per given type and advertiser 
  */
 public function getCurrentResourceAmount($resourceType, $advertiserId)
 {
     $criteria = new CDbCriteria();
     if ($resourceType == PlanResourceType::RTYPE_LISTINGS_PER_ADVERTISER) {
         if ($advertiserId == '') {
             return 0;
         }
         $criteria->compare('t.advertiser_id', $advertiserId);
         return Listing::model()->count($criteria);
     } else {
         if ($resourceType == PlanResourceType::RTYPE_FEATURED_LISTINGS_PER_ADVERTISER) {
             if ($advertiserId == '') {
                 return 0;
             }
             $criteria->compare('t.advertiser_id', $advertiserId);
             $criteria->compare('t.type', ListingType::TYPE_FEATURED);
             return Listing::model()->count($criteria);
         } else {
             if ($resourceType == PlanResourceType::RTYPE_PREMIUMAD_PER_ADVERTISER) {
                 if ($advertiserId == '') {
                     return 0;
                 }
                 $criteria->compare('t.advertiser_id', $advertiserId);
                 return PremiumAd::model()->count($criteria);
             } else {
                 if ($resourceType == PlanResourceType::RTYPE_LOCATIONS_PER_ACCOUNT) {
                     $criteria->compare('t.wlabel_id', Yii::app()->user->getWhiteLabelId());
                     return Location::model()->count($criteria);
                 }
             }
         }
     }
     return null;
 }