コード例 #1
0
ファイル: PledgeBlock.php プロジェクト: ksecor/civicrm
 /**
  * Takes a bunch of params that are needed to match certain criteria and
  * retrieves the relevant objects. Typically the valid params are only
  * pledgeBlock id. We'll tweak this function to be more full featured over a period
  * of time. This is the inverse function of create. It also stores all the retrieved
  * values in the default array
  *
  * @param array $params   (reference ) an assoc array of name/value pairs
  * @param array $defaults (reference ) an assoc array to hold the flattened values
  *
  * @return object CRM_Pledge_BAO_PledgeBlock object
  * @access public
  * @static
  */
 static function retrieve(&$params, &$defaults)
 {
     $pledgeBlock = new CRM_Pledge_DAO_PledgeBlock();
     $pledgeBlock->copyValues($params);
     if ($pledgeBlock->find(true)) {
         CRM_Core_DAO::storeValues($pledgeBlock, $defaults);
         return $pledgeBlock;
     }
     return null;
 }
コード例 #2
0
ファイル: PledgeBlock.php プロジェクト: nielosz/civicrm-core
 /**
  * Add pledgeBlock.
  *
  * @param array $params
  *   Reference array contains the values submitted by the form.
  *
  *
  * @return object
  */
 public static function add(&$params)
 {
     if (!empty($params['id'])) {
         CRM_Utils_Hook::pre('edit', 'PledgeBlock', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'PledgeBlock', NULL, $params);
     }
     $pledgeBlock = new CRM_Pledge_DAO_PledgeBlock();
     // fix for pledge_frequency_unit
     $freqUnits = CRM_Utils_Array::value('pledge_frequency_unit', $params);
     if ($freqUnits && is_array($freqUnits)) {
         unset($params['pledge_frequency_unit']);
         $newFreqUnits = array();
         foreach ($freqUnits as $k => $v) {
             if ($v) {
                 $newFreqUnits[$k] = $v;
             }
         }
         $freqUnits = $newFreqUnits;
         if (is_array($freqUnits) && !empty($freqUnits)) {
             $freqUnits = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($freqUnits));
             $pledgeBlock->pledge_frequency_unit = $freqUnits;
         } else {
             $pledgeBlock->pledge_frequency_unit = '';
         }
     }
     $pledgeBlock->copyValues($params);
     $result = $pledgeBlock->save();
     if (!empty($params['id'])) {
         CRM_Utils_Hook::post('edit', 'PledgeBlock', $pledgeBlock->id, $pledgeBlock);
     } else {
         CRM_Utils_Hook::post('create', 'Pledge', $pledgeBlock->id, $pledgeBlock);
     }
     return $result;
 }
コード例 #3
0
 /**
  * function to add pledgeBlock
  *
  * @param array $params reference array contains the values submitted by the form
  *
  * @access public
  * @static 
  * @return object
  */
 static function add(&$params)
 {
     require_once 'CRM/Utils/Hook.php';
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::pre('edit', 'PledgeBlock', $params['id'], $params);
     } else {
         CRM_Utils_Hook::pre('create', 'PledgeBlock', null, $params);
     }
     $pledgeBlock = new CRM_Pledge_DAO_PledgeBlock();
     //fix for pledge_frequency_unit
     require_once 'CRM/Core/BAO/CustomOption.php';
     $freqUnits = CRM_Utils_Array::value('pledge_frequency_unit', $params);
     if ($freqUnits && is_array($freqUnits)) {
         unset($params['pledge_frequency_unit']);
         $newFreqUnits = array();
         foreach ($freqUnits as $k => $v) {
             if ($v) {
                 $newFreqUnits[$k] = $v;
             }
         }
         $freqUnits = $newFreqUnits;
         if (is_array($freqUnits) && !empty($freqUnits)) {
             $freqUnits = implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, array_keys($freqUnits));
             $pledgeBlock->pledge_frequency_unit = $freqUnits;
         } else {
             $pledgeBlock->pledge_frequency_unit = '';
         }
     }
     $pledgeBlock->copyValues($params);
     $result = $pledgeBlock->save();
     if (CRM_Utils_Array::value('id', $params)) {
         CRM_Utils_Hook::post('edit', 'PledgeBlock', $pledgeBlock->id, $pledgeBlock);
     } else {
         CRM_Utils_Hook::post('create', 'Pledge', $pledgeBlock->id, $pledgeBlock);
     }
     return $result;
 }