Beispiel #1
0
 /**
  * Enable/disable profile field given a custom field id
  *
  * @param int $customFieldId
  *   Custom field id.
  * @param bool $is_active
  *   Set the is_active field.
  *
  * @return void
  */
 public static function setUFField($customFieldId, $is_active)
 {
     //find the profile id given custom field
     $ufField = new CRM_Core_DAO_UFField();
     $ufField->field_name = "custom_" . $customFieldId;
     $ufField->find();
     while ($ufField->fetch()) {
         //enable/ disable profile
         CRM_Core_BAO_UFField::setIsActive($ufField->id, $is_active);
     }
 }
Beispiel #2
0
 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the  
  * type of action and executes that action. 
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the group id
     $this->_gid = CRM_Utils_Request::retrieve('gid', $this, false, 0);
     if ($this->_gid) {
         require_once 'CRM/Core/BAO/UFGroup.php';
         $groupTitle = CRM_Core_BAO_UFGroup::getTitle($this->_gid);
         $this->assign('gid', $this->_gid);
         $this->assign('groupTitle', $groupTitle);
         CRM_Utils_System::setTitle(ts('%1 - CiviCRM Profile Fields', array(1 => $groupTitle)));
     }
     // get the requested action
     $action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
     // default to 'browse'
     // 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 | CRM_CORE_ACTION_VIEW | CRM_CORE_ACTION_DELETE)) {
         $this->edit($action);
         // no browse for edit/update/view/delete
     } else {
         if ($action & CRM_CORE_ACTION_PREVIEW) {
             $this->preview($id, $this->_gid);
         } else {
             require_once 'CRM/Core/BAO/UFField.php';
             if ($action & CRM_CORE_ACTION_DISABLE) {
                 CRM_Core_BAO_UFField::setIsActive($id, 0);
             } else {
                 if ($action & CRM_CORE_ACTION_ENABLE) {
                     CRM_Core_BAO_UFField::setIsActive($id, 1);
                 }
             }
             $this->browse();
         }
     }
     // Call the parents run method
     parent::run();
 }