コード例 #1
0
 /**
  * Takes a bunch of params that are needed to match certain criteria and
  * retrieves the relevant objects.  Typically, the valid params are only
  * price_field_id.  This is the inverse function of create.  It also
  * stores all of 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_Price_BAO_LineItem object
  * @access public
  * @static
  */
 static function retrieve(&$params, &$defaults)
 {
     $lineItem = new CRM_Price_BAO_LineItem();
     $lineItem->copyValues($params);
     if ($lineItem->find(TRUE)) {
         CRM_Core_DAO::storeValues($lineItem, $defaults);
         return $lineItem;
     }
     return NULL;
 }
コード例 #2
0
 function upgrade_3_3_beta3($rev)
 {
     // get the duplicate Ids of line item entries
     $dupeLineItemIds = array();
     $fields = array('entity_table', 'entity_id', 'price_field_id', 'price_field_value_id');
     $mainLineItem = new CRM_Price_BAO_LineItem();
     $mainLineItem->find(TRUE);
     while ($mainLineItem->fetch()) {
         $dupeLineItem = new CRM_Price_BAO_LineItem();
         foreach ($fields as $fld) {
             $dupeLineItem->{$fld} = $mainLineItem->{$fld};
         }
         $dupeLineItem->find(TRUE);
         $dupeLineItem->addWhere("id != {$mainLineItem->id}");
         while ($dupeLineItem->fetch()) {
             $dupeLineItemIds[$dupeLineItem->id] = $dupeLineItem->id;
         }
         $dupeLineItem->free();
     }
     $mainLineItem->free();
     //clean line item table.
     if (!empty($dupeLineItemIds)) {
         $sql = 'DELETE FROM civicrm_line_item WHERE id IN ( ' . implode(', ', $dupeLineItemIds) . ' )';
         CRM_Core_DAO::executeQuery($sql);
     }
     $upgrade = new CRM_Upgrade_Form();
     $upgrade->processSQL($rev);
 }