Пример #1
0
/**
 * Deletes an existing Tag
 *
 * @param  object        $tag valid tag object
 * @return NULL | error  if delete successfull then NULL otherwise object of CRM_Core_Error
 * @access public
 */
function crm_delete_tag(&$tag)
{
    require_once 'CRM/Core/BAO/Tag.php';
    if (!isset($tag->id)) {
        return _crm_error('Invalid Tag object passed in');
    }
    if (CRM_Core_BAO_Tag::del($tag->id)) {
        return null;
    } else {
        return _crm_error('Error while deleting Tag object');
    }
}
Пример #2
0
 /**
  * Function to process the form
  *
  * @access public
  * @return None
  */
 function postProcess()
 {
     $params = $ids = array();
     // store the submitted values in an array
     $params = $this->exportValues();
     $ids['tag'] = $this->_id;
     if ($this->_action == CRM_CORE_ACTION_DELETE) {
         if ($this->_id > 0) {
             CRM_Core_BAO_Tag::del($this->_id);
         }
     } else {
         CRM_Core_BAO_Tag::add($params, $ids);
     }
 }
Пример #3
0
/**
 * Deletes an existing Tag
 *
 * @param  array  $params
 * 
 * @return boolean | error  true if successfull, error otherwise
 * @access public
 */
function civicrm_tag_delete(&$params)
{
    if (!is_array($params)) {
        return civicrm_create_error(ts('Input parameters is not an array'));
    }
    $tagID = CRM_Utils_Array::value('tag_id', $params);
    if (!$tagID) {
        return civicrm_create_error(ts('Could not find tag_id in input parameters'));
    }
    require_once 'CRM/Core/BAO/Tag.php';
    return CRM_Core_BAO_Tag::del($tagID) ? civicrm_create_success() : civicrm_create_error(ts('Could not delete tag'));
}
Пример #4
0
/**
 * Deletes an existing Tag
 *
 * @param  array  $params
 *
 * @return boolean | error  true if successfull, error otherwise
 * @access public
 */
function civicrm_tag_delete(&$params)
{
    _civicrm_initialize();
    $errorScope = CRM_Core_TemporaryErrorScope::useException();
    try {
        civicrm_verify_mandatory($params, NULL, array('tag_id'));
        $tagID = CRM_Utils_Array::value('tag_id', $params);
        require_once 'CRM/Core/BAO/Tag.php';
        return CRM_Core_BAO_Tag::del($tagID) ? civicrm_create_success() : civicrm_create_error(ts('Could not delete tag'));
    } catch (Exception $e) {
        if (CRM_Core_Error::$modeException) {
            throw $e;
        }
        return civicrm_create_error($e->getMessage());
    }
}
Пример #5
0
 /**
  * Process the form submission.
  */
 public function postProcess()
 {
     $params = $ids = array();
     // store the submitted values in an array
     $params = $this->exportValues();
     $ids['tag'] = $this->_id;
     if ($this->_action == CRM_Core_Action::ADD || $this->_action == CRM_Core_Action::UPDATE) {
         $params['used_for'] = implode(",", $params['used_for']);
     }
     $params['is_tagset'] = 0;
     if ($this->_isTagSet) {
         $params['is_tagset'] = 1;
     }
     if (!isset($params['is_reserved'])) {
         $params['is_reserved'] = 0;
     }
     if (!isset($params['is_selectable'])) {
         $params['is_selectable'] = 0;
     }
     if ($this->_action == CRM_Core_Action::DELETE) {
         if ($this->_id > 0) {
             $tag = civicrm_api3('tag', 'getsingle', array('id' => $this->_id));
             CRM_Core_BAO_Tag::del($this->_id);
             CRM_Core_Session::setStatus(ts('The tag \'%1\' has been deleted.', array(1 => $tag['name'])), ts('Deleted'), 'success');
         }
     } else {
         $tag = CRM_Core_BAO_Tag::add($params, $ids);
         CRM_Core_Session::setStatus(ts('The tag \'%1\' has been saved.', array(1 => $tag->name)), ts('Saved'), 'success');
     }
 }