/**
 * Delete an existing participant_status.
 *
 * This method is used to delete any existing participant_status given its id.
 *
 * @param array $params
 *   [id]
 *
 * @return array
 *   api result array
 */
function civicrm_api3_participant_status_type_delete($params)
{
    if (CRM_Event_BAO_ParticipantStatusType::deleteParticipantStatusType($params['id'])) {
        return civicrm_api3_create_success(TRUE);
    }
    return civicrm_api3_create_error(TRUE);
}
/**
 * Delete an existing participant_status.
 *
 * This method is used to delete any existing participant_status given its id.
 *
 * @param array $params
 *   [id]
 *
 * @return array
 *   api result array
 */
function civicrm_api3_participant_status_type_delete($params)
{
    if (CRM_Event_BAO_ParticipantStatusType::deleteParticipantStatusType($params['id'])) {
        return civicrm_api3_create_success(TRUE);
    }
    throw new API_Exception('Could not delete participant status type id ' . $params['id']);
}
 /**
  *  create() and deleteParticipantStatusType() method
  */
 public function testCreateAndDelete()
 {
     // create using required params
     $params = array('name' => 'testStatus', 'label' => 'testParticipant', 'class' => 'Positive', 'weight' => 13, 'visibility_id' => 1);
     $statusType = CRM_Event_BAO_ParticipantStatusType::create($params);
     // Checking for participant status type id in db.
     $statusTypeId = $this->assertDBNotNull('CRM_Event_DAO_ParticipantStatusType', $statusType->id, 'id', 'id', 'Check DB for status type id');
     CRM_Event_BAO_ParticipantStatusType::deleteParticipantStatusType($statusType->id);
     // Checking for participant status type id after delete.
     $statusTypeId = $this->assertDBNull('CRM_Event_DAO_ParticipantStatusType', $statusType->id, 'id', 'id', 'Check DB for status type id');
 }
Example #4
0
 function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         if (CRM_Event_BAO_ParticipantStatusType::deleteParticipantStatusType($this->_id)) {
             CRM_Core_Session::setStatus(ts('Selected participant status has been deleted.'));
         } else {
             CRM_Core_Session::setStatus(ts('Selected participant status has <strong>NOT</strong> been deleted; there are still participants with this status.'));
         }
         return;
     }
     $formValues = $this->controller->exportValues($this->_name);
     $params = array('name' => CRM_Utils_Array::value('name', $formValues), 'label' => CRM_Utils_Array::value('label', $formValues), 'class' => CRM_Utils_Array::value('class', $formValues), 'is_active' => CRM_Utils_Array::value('is_active', $formValues, false), 'is_counted' => CRM_Utils_Array::value('is_counted', $formValues, false), 'weight' => CRM_Utils_Array::value('weight', $formValues), 'visibility_id' => CRM_Utils_Array::value('visibility_id', $formValues));
     // make sure a malicious POST does not change these on reserved statuses
     if ($this->_isReserved) {
         unset($params['name'], $params['class'], $params['is_active']);
     }
     if ($this->_action & CRM_Core_Action::UPDATE) {
         $params['id'] = $this->_id;
     }
     require_once 'CRM/Utils/Weight.php';
     if ($this->_id) {
         $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantStatusType', $this->_id, 'weight', 'id');
     } else {
         $oldWeight = 0;
     }
     $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Event_DAO_ParticipantStatusType', $oldWeight, $params['weight']);
     $participantStatus = CRM_Event_BAO_ParticipantStatusType::create($params);
     if ($participantStatus->id) {
         if ($this->_action & CRM_Core_Action::UPDATE) {
             CRM_Core_Session::setStatus(ts('The Participant Status has been updated.'));
         } else {
             CRM_Core_Session::setStatus(ts('The new Participant Status has been saved.'));
         }
     } else {
         CRM_Core_Session::setStatus(ts('The changes have not been saved.'));
     }
 }