示例#1
0
 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the  
  * type of action and executes that action.
  * Finally it calls the parent's run method.
  * 
  * @param null
  * 
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the requested action
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
     // default to 'browse'
     // assign vars to templates
     $this->assign('action', $action);
     $sid = CRM_Utils_Request::retrieve('sid', 'Positive', $this, false, 0);
     if ($sid) {
         require_once 'CRM/Price/BAO/Set.php';
         CRM_Price_BAO_Set::checkPermission($sid);
     }
     // what action to take ?
     if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
         $this->edit($sid, $action);
     } else {
         if ($action & CRM_Core_Action::PREVIEW) {
             $this->preview($sid);
         } else {
             if ($action & CRM_Core_Action::COPY) {
                 $session = CRM_Core_Session::singleton();
                 CRM_Core_Session::setStatus("A copy of the price set has been created");
                 $this->copy();
             } else {
                 require_once 'CRM/Price/BAO/Set.php';
                 require_once 'CRM/Price/BAO/Field.php';
                 // if action is delete do the needful.
                 if ($action & CRM_Core_Action::DELETE) {
                     $usedBy =& CRM_Price_BAO_Set::getUsedBy($sid);
                     if (empty($usedBy)) {
                         // prompt to delete
                         $session =& CRM_Core_Session::singleton();
                         $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/price', 'action=browse'));
                         $controller = new CRM_Core_Controller_Simple('CRM_Price_Form_DeleteSet', 'Delete Price Set', null);
                         // $id = CRM_Utils_Request::retrieve('sid', 'Positive', $this, false, 0);
                         $controller->set('sid', $sid);
                         $controller->setEmbedded(true);
                         $controller->process();
                         $controller->run();
                     } else {
                         // add breadcrumb
                         $url = CRM_Utils_System::url('civicrm/admin/price', 'reset=1');
                         CRM_Utils_System::appendBreadCrumb(ts('Price Sets'), $url);
                         $this->assign('usedPriceSetTitle', CRM_Price_BAO_Set::getTitle($sid));
                         $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);
                     }
                 }
                 // finally browse the price sets
                 $this->browse();
             }
         }
     }
     // parent run
     parent::run();
 }
示例#2
0
文件: Field.php 项目: bhirsch/voipdev
 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the  
  * type of action and executes that action. 
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 function run()
 {
     require_once 'CRM/Price/BAO/Set.php';
     // get the group id
     $this->_sid = CRM_Utils_Request::retrieve('sid', 'Positive', $this);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, false, 0);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'browse');
     // default to 'browse'
     if ($this->_sid) {
         require_once 'CRM/Price/BAO/Set.php';
         CRM_Price_BAO_Set::checkPermission($this->_sid);
     }
     if ($action & CRM_Core_Action::DELETE) {
         require_once 'CRM/Price/BAO/Set.php';
         $usedBy =& CRM_Price_BAO_Set::getUsedBy($this->_sid);
         if (empty($usedBy)) {
             // prompt to delete
             $session =& CRM_Core_Session::singleton();
             $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&action=browse&sid=' . $this->_sid));
             $controller =& new CRM_Core_Controller_Simple('CRM_Price_Form_DeleteField', "Delete Price Field", '');
             $controller->set('fid', $fid);
             $controller->setEmbedded(true);
             $controller->process();
             $controller->run();
         } else {
             // add breadcrumb
             require_once 'CRM/Price/BAO/Field.php';
             $url = CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1');
             CRM_Utils_System::appendBreadCrumb(ts('Price'), $url);
             $this->assign('usedPriceSetTitle', CRM_Price_BAO_Field::getTitle($fid));
             $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);
         }
     }
     if ($this->_sid) {
         $groupTitle = CRM_Price_BAO_Set::getTitle($this->_sid);
         $this->assign('sid', $this->_sid);
         $this->assign('groupTitle', $groupTitle);
         CRM_Utils_System::setTitle(ts('%1 - Price Fields', array(1 => $groupTitle)));
     }
     // assign vars to templates
     $this->assign('action', $action);
     // what action to take ?
     if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
         $this->edit($action);
         // no browse for edit/update/view
     } else {
         if ($action & CRM_Core_Action::PREVIEW) {
             $this->preview($fid);
         } else {
             require_once 'CRM/Price/BAO/Field.php';
             $this->browse();
         }
     }
     // Call the parents run method
     parent::run();
 }
 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the
  * type of action and executes that action.
  *
  * @param null
  *
  * @return void
  * @access public
  */
 function run()
 {
     // get the field id
     $this->_fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE, 0);
     //get the price set id
     if (!$this->_sid) {
         $this->_sid = CRM_Utils_Request::retrieve('sid', 'Positive', $this);
     }
     if ($this->_sid) {
         CRM_Price_BAO_Set::checkPermission($this->_sid);
         $this->_isSetReserved = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_sid, 'is_reserved');
         $this->assign('isReserved', $this->_isSetReserved);
     }
     //as url contain $sid so append breadcrumb dynamically.
     $breadcrumb = array(array('title' => ts('Price Fields'), 'url' => CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&sid=' . $this->_sid)));
     CRM_Utils_System::appendBreadCrumb($breadcrumb);
     if ($this->_fid) {
         $fieldTitle = CRM_Price_BAO_Field::getTitle($this->_fid);
         $this->assign('fid', $this->_fid);
         $this->assign('fieldTitle', $fieldTitle);
         CRM_Utils_System::setTitle(ts('%1 - Price Options', array(1 => $fieldTitle)));
         $htmlType = CRM_Core_DAO::getFieldValue('CRM_Price_BAO_Field', $this->_fid, 'html_type');
         $this->assign('addMoreFields', TRUE);
         //for text price field only single option present
         if ($htmlType == 'Text') {
             $this->assign('addMoreFields', FALSE);
         }
     }
     // get the requested action
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     // assign vars to templates
     $this->assign('action', $action);
     $oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, FALSE, 0);
     // what action to take ?
     if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::VIEW | CRM_Core_Action::DELETE) && !$this->_isSetReserved) {
         // no browse for edit/update/view
         $this->edit($action);
     } else {
         $this->browse();
     }
     // Call the parents run method
     return parent::run();
 }
 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the
  * type of action and executes that action.
  *
  * @param null
  *
  * @return void
  * @access public
  */
 function run()
 {
     // get the group id
     $this->_sid = CRM_Utils_Request::retrieve('sid', 'Positive', $this);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE, 0);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     if ($this->_sid) {
         $usedBy = CRM_Price_BAO_Set::getUsedBy($this->_sid);
         $this->assign('usedBy', $usedBy);
         $this->_isSetReserved = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Set', $this->_sid, 'is_reserved');
         $this->assign('isReserved', $this->_isSetReserved);
         CRM_Price_BAO_Set::checkPermission($this->_sid);
         $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);
     }
     if ($action & CRM_Core_Action::DELETE && !$this->_isSetReserved) {
         if (empty($usedBy)) {
             // prompt to delete
             $session = CRM_Core_Session::singleton();
             $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&action=browse&sid=' . $this->_sid));
             $controller = new CRM_Core_Controller_Simple('CRM_Price_Form_DeleteField', 'Delete Price Field', '');
             $controller->set('fid', $fid);
             $controller->setEmbedded(TRUE);
             $controller->process();
             $controller->run();
         } else {
             // add breadcrumb
             $url = CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1');
             CRM_Utils_System::appendBreadCrumb(ts('Price'), $url);
             $this->assign('usedPriceSetTitle', CRM_Price_BAO_Field::getTitle($fid));
         }
     }
     if ($this->_sid) {
         $groupTitle = CRM_Price_BAO_Set::getTitle($this->_sid);
         $this->assign('sid', $this->_sid);
         $this->assign('groupTitle', $groupTitle);
         CRM_Utils_System::setTitle(ts('%1 - Price Fields', array(1 => $groupTitle)));
     }
     // assign vars to templates
     $this->assign('action', $action);
     // what action to take ?
     if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD) && !$this->_isSetReserved) {
         // no browse for edit/update/view
         $this->edit($action);
     } elseif ($action & CRM_Core_Action::PREVIEW) {
         $this->preview($fid);
     } else {
         $this->browse();
     }
     // Call the parents run method
     return parent::run();
 }