예제 #1
0
 public static function addRideRules($rideId, $rules)
 {
     $result = true;
     foreach ($rules as $rule) {
         $categoryPreferences = CategoryPreferences::model()->find('preferences=:preferences', array(':preferences' => $rule));
         $rideRules = new RideRules();
         $rideRules->ride_id = $rideId;
         $rideRules->rule = $rule;
         if ($categoryPreferences) {
             $rideRules->created_by = 'ADMIN';
         } else {
             $rideRules->created_by = 'USER';
         }
         $result = $result && $rideRules->save();
     }
     return $result;
 }
예제 #2
0
 public static function getPreferencesByType($type)
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'id,preferences';
     $criteria->condition = 'type=:type';
     $criteria->params = array(':type' => $type);
     $categoryPreferences = CategoryPreferences::model()->findAll($criteria);
     $result = array();
     $i = 0;
     if (!empty($categoryPreferences)) {
         foreach ($categoryPreferences as $categoryPreference) {
             $result[$i] = array($categoryPreference->id, $categoryPreference->preferences);
             $i = $i + 1;
         }
         return $result;
     } else {
         return false;
     }
 }