<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
protected $_context;
/**
- * the groupId retrieved from the GET vars
+ * The groupId retrieved from the GET vars
*
* @var int
*/
protected $_id;
/**
- * the title of the group
+ * The title of the group
*
* @var string
*/
protected $_title;
/**
- * build all the data structures needed to build the form
+ * Build all the data structures needed to build the form
*
* @return void
- * @access public
*/
- function preProcess() {
- /*
- * initialize the task and row fields
- */
+ public function preProcess() {
+ // initialize the task and row fields
parent::preProcess();
$this->_context = $this->get('context');
/**
* Build the form object
*
- * @access public
*
* @return void
*/
- function buildQuickForm() {
+ public function buildQuickForm() {
//create radio buttons to select existing group or add a new group
$options = array(ts('Add Contact To Existing Group'), ts('Create New Group'));
/**
* Set the default form values
*
- * @access protected
*
- * @return array the default array reference
+ * @return array
+ * the default array reference
*/
- function setDefaultValues() {
+ public function setDefaultValues() {
$defaults = array();
if ($this->_context === 'amtg') {
/**
* Add local and global form rules
*
- * @access protected
*
* @return void
*/
- function addRules() {
+ public function addRules() {
$this->addFormRule(array('CRM_Contact_Form_task_AddToGroup', 'formRule'));
}
/**
- * global validation rules for the form
+ * Global validation rules for the form
*
* @param array $params
*
- * @return array list of errors to be posted back to the form
- * @static
- * @access public
+ * @return array
+ * list of errors to be posted back to the form
*/
- static function formRule($params) {
+ public static function formRule($params) {
$errors = array();
if (!empty($params['group_option']) && empty($params['title'])) {
}
/**
- * process the form after the input has been submitted and validated
+ * Process the form after the input has been submitted and validated
*
- * @access public
*
* @return void
*/
$groupParams['visibility'] = "User and User Admin Only";
if (array_key_exists('group_type', $params) && is_array($params['group_type'])) {
$groupParams['group_type'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
- array_keys($params['group_type'])
- ) . CRM_Core_DAO::VALUE_SEPARATOR;
+ array_keys($params['group_type'])
+ ) . CRM_Core_DAO::VALUE_SEPARATOR;
}
else {
$groupParams['group_type'] = '';
$groupParams['is_active'] = 1;
$createdGroup = CRM_Contact_BAO_Group::create($groupParams);
- $groupID = $createdGroup->id;
- $groupName = $groupParams['title'];
+ $groupID = $createdGroup->id;
+ $groupName = $groupParams['title'];
}
else {
- $groupID = $params['group_id'];
- $group = CRM_Core_PseudoConstant::group();
+ $groupID = $params['group_id'];
+ $group = CRM_Core_PseudoConstant::group();
$groupName = $group[$groupID];
}
list($total, $added, $notAdded) = CRM_Contact_BAO_GroupContact::addContactsToGroup($this->_contactIds, $groupID);
- $status = array(ts('%count contact added to group', array('count' => $added, 'plural' => '%count contacts added to group')));
+ $status = array(
+ ts('%count contact added to group', array(
+ 'count' => $added,
+ 'plural' => '%count contacts added to group'
+ ))
+ );
if ($notAdded) {
- $status[] = ts('%count contact was already in group', array('count' => $notAdded, 'plural' => '%count contacts were already in group'));
+ $status[] = ts('%count contact was already in group', array(
+ 'count' => $notAdded,
+ 'plural' => '%count contacts were already in group'
+ ));
}
$status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
- CRM_Core_Session::setStatus($status, ts('Added Contact to %1', array(1 => $groupName, 'count' => $added, 'plural' => 'Added Contacts to %1')), 'success', array('expires' => 0));
+ CRM_Core_Session::setStatus($status, ts('Added Contact to %1', array(
+ 1 => $groupName,
+ 'count' => $added,
+ 'plural' => 'Added Contacts to %1'
+ )), 'success', array('expires' => 0));
if ($this->_context === 'amtg') {
- CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/group/search', "reset=1&force=1&context=smog&gid=$groupID"));
+ CRM_Core_Session::singleton()
+ ->pushUserContext(CRM_Utils_System::url('civicrm/group/search', "reset=1&force=1&context=smog&gid=$groupID"));
}
}
}
-