예제 #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. 
  * 
  * @param null
  * 
  * @return void
  * @access public
  */
 function run()
 {
     require_once 'CRM/Core/BAO/CustomGroup.php';
     // get the group id
     $this->_gid = CRM_Utils_Request::retrieve('gid', $this);
     $action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
     // default to 'browse'
     if ($action & CRM_CORE_ACTION_DELETE) {
         $session =& CRM_Core_Session::singleton();
         $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=browse&gid=' . $this->_gid));
         $controller =& new CRM_Core_Controller_Simple('CRM_Custom_Form_DeleteField', "Delete Cutom Field", $mode);
         $id = CRM_Utils_Request::retrieve('id', $this, false, 0);
         $controller->set('id', $id);
         $controller->setEmbedded(true);
         $controller->process();
         $controller->run();
     }
     if ($this->_gid) {
         $groupTitle = CRM_Core_BAO_CustomGroup::getTitle($this->_gid);
         $this->assign('gid', $this->_gid);
         $this->assign('groupTitle', $groupTitle);
         CRM_Utils_System::setTitle(ts('%1 - Custom Fields', array(1 => $groupTitle)));
     }
     // get the requested action
     // assign vars to templates
     $this->assign('action', $action);
     $id = CRM_Utils_Request::retrieve('id', $this, false, 0);
     // 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($id);
         } else {
             require_once 'CRM/Core/BAO/CustomField.php';
             require_once 'CRM/Core/BAO/UFField.php';
             if ($action & CRM_CORE_ACTION_DISABLE) {
                 CRM_Core_BAO_CustomField::setIsActive($id, 0);
                 CRM_Core_BAO_UFField::setUFField($id, 0);
             } else {
                 if ($action & CRM_CORE_ACTION_ENABLE) {
                     CRM_Core_BAO_CustomField::setIsActive($id, 1);
                     CRM_Core_BAO_UFField::setUFField($id, 1);
                 }
             }
             $this->browse();
         }
     }
     // Call the parents run method
     parent::run();
 }