Beispiel #1
0
 /**
  * function to add or update either a Personal Campaign Page OR a PCP Block
  *
  * @param array $params reference array contains the values submitted by the form
  * @param bool  $pcpBlock if true, create or update PCPBlock, else PCP
  * @access public
  * @static 
  * @return object
  */
 static function add(&$params, $pcpBlock = true)
 {
     if ($pcpBlock) {
         // action is taken depending upon the mode
         require_once 'CRM/Contribute/DAO/PCPBlock.php';
         $dao = new CRM_Contribute_DAO_PCPBlock();
         $dao->copyValues($params);
         $dao->save();
         return $dao;
     } else {
         require_once 'CRM/Contribute/DAO/PCP.php';
         $dao = new CRM_Contribute_DAO_PCP();
         $dao->copyValues($params);
         // ensure we set status_id since it is a not null field
         // we should change the schema and allow this to be null
         if (!$dao->id && !isset($dao->status_id)) {
             $dao->status_id = 0;
         }
         // set currency for CRM-1496
         if (!isset($dao->currency)) {
             $config =& CRM_Core_Config::singleton();
             $dao->currency = $config->defaultCurrency;
         }
         $dao->save();
         return $dao;
     }
 }