Esempio n. 1
0
 /**
  * Link the price set with the specified table and id.
  *
  * @param string $entityTable
  * @param int $entityId
  * @param int $priceSetId
  *
  * @return bool
  */
 public static function addTo($entityTable, $entityId, $priceSetId)
 {
     // verify that the price set exists
     $dao = new CRM_Price_DAO_PriceSet();
     $dao->id = $priceSetId;
     if (!$dao->find()) {
         return FALSE;
     }
     unset($dao);
     $dao = new CRM_Price_DAO_PriceSetEntity();
     // find if this already exists
     $dao->entity_id = $entityId;
     $dao->entity_table = $entityTable;
     $dao->find(TRUE);
     // add or update price_set_id
     $dao->price_set_id = $priceSetId;
     return $dao->save();
 }
Esempio n. 2
0
 /**
  * Browse all price sets
  *
  * @param string $action   the action to be invoked
  *
  * @return void
  * @access public
  */
 function browse($action = NULL)
 {
     // get all price sets
     $priceSet = array();
     $comps = array('CiviEvent' => ts('Event'), 'CiviContribute' => ts('Contribution'), 'CiviMember' => ts('Membership'));
     $dao = new CRM_Price_DAO_PriceSet();
     if (CRM_Price_BAO_PriceSet::eventPriceSetDomainID()) {
         $dao->domain_id = CRM_Core_Config::domainID();
     }
     $dao->is_quick_config = 0;
     $dao->find();
     while ($dao->fetch()) {
         $priceSet[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $priceSet[$dao->id]);
         $compIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('extends', $priceSet[$dao->id]));
         $extends = array();
         //CRM-10225
         foreach ($compIds as $compId) {
             if (!empty($comps[CRM_Core_Component::getComponentName($compId)])) {
                 $extends[] = $comps[CRM_Core_Component::getComponentName($compId)];
             }
         }
         $priceSet[$dao->id]['extends'] = implode(', ', $extends);
         // form all action links
         $action = array_sum(array_keys($this->actionLinks()));
         // update enable/disable links depending on price_set properties.
         if ($dao->is_reserved) {
             $action -= CRM_Core_Action::UPDATE + CRM_Core_Action::DISABLE + CRM_Core_Action::ENABLE + CRM_Core_Action::DELETE + CRM_Core_Action::COPY;
         } else {
             if ($dao->is_active) {
                 $action -= CRM_Core_Action::ENABLE;
             } else {
                 $action -= CRM_Core_Action::DISABLE;
             }
         }
         $actionLinks = self::actionLinks();
         //CRM-10117
         if ($dao->is_reserved) {
             $actionLinks[CRM_Core_Action::BROWSE]['name'] = 'View Price Fields';
         }
         $priceSet[$dao->id]['action'] = CRM_Core_Action::formLink($actionLinks, $action, array('sid' => $dao->id), ts('more'), FALSE, 'priceSet.row.actions', 'PriceSet', $dao->id);
     }
     $this->assign('rows', $priceSet);
 }