/**
  * process the form after the input has been submitted and validated
  *
  * @access public
  * @return None
  */
 function postProcess()
 {
     $tagId = $this->controller->exportValue('RemoveFromTag', 'tag_id');
     $this->_name = $this->_tags[$tagId];
     list($total, $removed, $notRemoved) = CRM_Core_BAO_EntityTag::removeContactsFromTag($this->_contactIds, $tagId);
     $status = array('Contact(s) tagged as: ' . $this->_name, 'Total Selected Contact(s): ' . $total);
     if ($removed) {
         $status[] = 'Total Contact(s) to be  removed from tag: ' . $removed;
     }
     if ($notRemoved) {
         $status[] = 'Total Contact(s) already removed: ' . $notRemoved;
     }
     CRM_Core_Session::setStatus($status);
 }
Example #2
0
/**
 *
 * @param <type> $params
 * @param <type> $op
 * @return <type> 
 */
function civicrm_entity_tag_common(&$params, $op = 'add')
{
    $contactIDs = array();
    $tagsIDs = array();
    if (is_array($params)) {
        foreach ($params as $n => $v) {
            if (substr($n, 0, 10) == 'contact_id') {
                $contactIDs[] = $v;
            } else {
                if (substr($n, 0, 6) == 'tag_id') {
                    $tagIDs[] = $v;
                }
            }
        }
    }
    if (empty($contactIDs)) {
        return civicrm_create_error(ts('contact_id is a required field'));
    }
    if (empty($tagIDs)) {
        return civicrm_create_error(ts('tag_id is a required field'));
    }
    require_once 'CRM/Core/BAO/EntityTag.php';
    $values = array('is_error' => 0);
    if ($op == 'add') {
        $values['total_count'] = $values['added'] = $values['not_added'] = 0;
        foreach ($tagIDs as $tagID) {
            list($tc, $a, $na) = CRM_Core_BAO_EntityTag::addContactsToTag($contactIDs, $tagID);
            $values['total_count'] += $tc;
            $values['added'] += $a;
            $values['not_added'] += $na;
        }
    } else {
        $values['total_count'] = $values['removed'] = $values['not_removed'] = 0;
        foreach ($tagIDs as $tagID) {
            list($tc, $r, $nr) = CRM_Core_BAO_EntityTag::removeContactsFromTag($contactIDs, $tagID);
            $values['total_count'] += $tc;
            $values['removed'] += $r;
            $values['not_removed'] += $nr;
        }
    }
    return $values;
}
Example #3
0
 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     $tagId = $this->controller->exportValue('RemoveFromTag', 'tag');
     $this->_name = array();
     foreach ($tagId as $key => $dnc) {
         $this->_name[] = $this->_tags[$key];
         list($total, $removed, $notRemoved) = CRM_Core_BAO_EntityTag::removeContactsFromTag($this->_contactIds, $key);
         $status = array('Contact(s) tagged as: ' . implode(',', $this->_name), 'Total Selected Contact(s): ' . $total);
     }
     if ($removed) {
         $status[] = 'Total Contact(s) to be  removed from tag: ' . $removed;
     }
     if ($notRemoved) {
         $status[] = 'Total Contact(s) already removed: ' . $notRemoved;
     }
     CRM_Core_Session::setStatus($status);
 }