/**
  * function to add the contribution types
  *
  * @param array $params reference array contains the values submitted by the form
  * @param array $ids    reference array contains the id
  *
  * @access public
  * @static
  *
  * @return object
  */
 static function add(&$params, &$ids)
 {
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['is_deductible'] = CRM_Utils_Array::value('is_deductible', $params, FALSE);
     // action is taken depending upon the mode
     $premium = new CRM_Contribute_DAO_Product();
     $premium->copyValues($params);
     $premium->id = CRM_Utils_Array::value('premium', $ids);
     // set currency for CRM-1496
     if (!isset($premium->currency)) {
         $config = CRM_Core_Config::singleton();
         $premium->currency = $config->defaultCurrency;
     }
     $premium->save();
     return $premium;
 }
Exemple #2
0
 /**
  * add the financial types.
  *
  * @param array $params
  *   Reference array contains the values submitted by the form.
  * @param array $ids
  *   Reference array contains the id.
  *
  *
  * @return object
  */
 public static function add(&$params, &$ids)
 {
     // CRM-14283 - strip protocol and domain from image URLs
     $image_type = array('image', 'thumbnail');
     foreach ($image_type as $key) {
         if (isset($params[$key])) {
             $parsedURL = explode('/', $params[$key]);
             $pathComponents = array_slice($parsedURL, 3);
             $params[$key] = '/' . implode('/', $pathComponents);
         }
     }
     $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE);
     $params['is_deductible'] = CRM_Utils_Array::value('is_deductible', $params, FALSE);
     // action is taken depending upon the mode
     $premium = new CRM_Contribute_DAO_Product();
     $premium->copyValues($params);
     $premium->id = CRM_Utils_Array::value('premium', $ids);
     // set currency for CRM-1496
     if (!isset($premium->currency)) {
         $config = CRM_Core_Config::singleton();
         $premium->currency = $config->defaultCurrency;
     }
     $premium->save();
     return $premium;
 }