コード例 #1
0
ファイル: RideRulesApi.php プロジェクト: romeo14/pow
 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
ファイル: PreferencesApi.php プロジェクト: romeo14/pow
 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;
     }
 }