Example #1
0
 /**
  * edit custom Option.
  *
  * editing would involved modifying existing fields + adding data to new fields.
  *
  * @param string  $action   the action to be invoked
  *
  * @return void
  * @access public
  */
 function edit($action)
 {
     $oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, FALSE, 0);
     $params = array();
     if ($oid) {
         $params['oid'] = $oid;
         $sid = CRM_Price_BAO_PriceSet::getSetId($params);
         $usedBy = CRM_Price_BAO_PriceSet::getUsedBy($sid);
     }
     // set the userContext stack
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/price/field/option', "reset=1&action=browse&fid={$this->_fid}&sid={$this->_sid}"));
     $controller = new CRM_Core_Controller_Simple('CRM_Price_Form_Option', ts('Price Field Option'), $action);
     $controller->set('fid', $this->_fid);
     $controller->setEmbedded(TRUE);
     $controller->process();
     $controller->run();
     $this->browse();
     if ($action & CRM_Core_Action::DELETE) {
         // add breadcrumb
         $url = CRM_Utils_System::url('civicrm/admin/price/field/option', 'reset=1');
         CRM_Utils_System::appendBreadCrumb(ts('Price Option'), $url);
         $this->assign('usedPriceSetTitle', CRM_Price_BAO_PriceFieldValue::getOptionLabel($oid));
         $this->assign('usedBy', $usedBy);
         $comps = array("Event" => "civicrm_event", "Contribution" => "civicrm_contribution_page");
         $priceSetContexts = array();
         foreach ($comps as $name => $table) {
             if (array_key_exists($table, $usedBy)) {
                 $priceSetContexts[] = $name;
             }
         }
         $this->assign('contexts', $priceSetContexts);
     }
 }