+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
protected $_numVoters;
/**
- * Build all the data structures needed to build the form
+ * Build all the data structures needed to build the form.
*
* @return void
*/
//get the survey activities.
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
$statusIds = array();
- foreach (array(
- 'Scheduled') as $name) {
+ foreach (array('Scheduled') as $name) {
if ($statusId = array_search($name, $activityStatus)) {
$statusIds[] = $statusId;
}
$errorMsg = ts('The maximum number of contacts is already reserved for this interviewer.');
}
elseif (count($this->_contactIds) > ($maxVoters - $this->_numVoters)) {
- $errorMsg = ts('You can reserve a maximum of %1 contact(s) at a time for this survey.',
- array(1 => $maxVoters - $this->_numVoters)
+ $errorMsg = ts('You can reserve a maximum of %count contact at a time for this survey.',
+ array(
+ 'plural' => 'You can reserve a maximum of %count contacts at a time for this survey.',
+ 'count' => $maxVoters - $this->_numVoters,
+ )
);
}
}
$defaultNum = CRM_Utils_Array::value('default_number_of_contacts', $this->_surveyDetails);
if (!$errorMsg && $defaultNum && (count($this->_contactIds) > $defaultNum)) {
- $errorMsg = ts('You can reserve a maximum of %1 contact(s) at a time for this survey.',
- array(1 => $defaultNum)
+ $errorMsg = ts('You can reserve a maximum of %count contact at a time for this survey.',
+ array(
+ 'plural' => 'You can reserve a maximum of %count contacts at a time for this survey.',
+ 'count' => $defaultNum,
+ )
);
}
}
/**
- * Build the form object
+ * Build the form object.
*
*
* @return void
$buttons = array(
array(
- 'type' => 'done',
+ 'type' => 'done',
'name' => ts('Reserve'),
'subName' => 'reserve',
'isDefault' => TRUE,
- ));
+ ),
+ );
if (CRM_Core_Permission::check('manage campaign') ||
CRM_Core_Permission::check('administer CiviCampaign') ||
}
/**
- * Global validation rules for the form
+ * Global validation rules for the form.
*
* @param array $fields
* Posted values of the form.
*
* @return array
* list of errors to be posted back to the form
- * @static
*/
public static function formRule($fields, $files, $self) {
$errors = array();
$invalidGroupName = FALSE;
if (!empty($fields['newGroupName'])) {
- $title = trim($fields['newGroupName']);
- $name = CRM_Utils_String::titleToVar($title);
- $query = 'select count(*) from civicrm_group where name like %1 OR title like %2';
+ $title = trim($fields['newGroupName']);
+ $name = CRM_Utils_String::titleToVar($title);
+ $query = 'select count(*) from civicrm_group where name like %1 OR title like %2';
$grpCnt = CRM_Core_DAO::singleValueQuery($query, array(
- 1 => array($name, 'String'),
- 2 => array($title, 'String'),
- ));
+ 1 => array($name, 'String'),
+ 2 => array($title, 'String'),
+ ));
if ($grpCnt) {
$invalidGroupName = TRUE;
$errors['newGroupName'] = ts('Group \'%1\' already exists.', array(1 => $fields['newGroupName']));
}
/**
- * Process the form after the input has been submitted and validated
+ * Process the form after the input has been submitted and validated.
*
*
* @return void
*/
public function postProcess() {
//add reservation.
- $countVoters = 0;
- $maxVoters = CRM_Utils_Array::value('max_number_of_contacts', $this->_surveyDetails);
+ $countVoters = 0;
+ $maxVoters = CRM_Utils_Array::value('max_number_of_contacts', $this->_surveyDetails);
$activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
- $statusHeld = array_search('Scheduled', $activityStatus);
+ $statusHeld = array_search('Scheduled', $activityStatus);
$reservedVoterIds = array();
foreach ($this->_contactIds as $cid) {
- $subject = ts('%1', array(1 => $this->_surveyDetails['title'])) . ' - ' . ts('Respondent Reservation');
- $session = CRM_Core_Session::singleton();
+ $subject = $this->_surveyDetails['title'] . ' - ' . ts('Respondent Reservation');
+ $session = CRM_Core_Session::singleton();
$activityParams = array(
- 'source_contact_id' => $session->get('userID'),
+ 'source_contact_id' => $session->get('userID'),
'assignee_contact_id' => array($this->_interviewerId),
'target_contact_id' => array($cid),
'source_record_id' => $this->_surveyId,
// Success message
if ($countVoters > 0) {
- $status = '<p>' . ts("%1 Contact(s) have been reserved.", array(1 => $countVoters)) . '</p>';
+ $status = '<p>' . ts("%count contact has been reserved.", array('plural' => '%count contacts have been reserved.', 'count' => $countVoters)) . '</p>';
if ($groupAdditions) {
- $status .= '<p>' . ts('Respondent(s) has been added to %1 group(s).',
- array(1 => implode(', ', $groupAdditions))
- ) . '</p>';
+ $status .= '<p>' . ts('They have been added to %1.',
+ array(1 => implode(' ' . ts('and') . ' ', $groupAdditions))
+ ) . '</p>';
}
CRM_Core_Session::setStatus($status, ts('Reservation Added'), 'success');
}
// Error message
if (count($this->_contactIds) > $countVoters) {
- CRM_Core_Session::setStatus(ts('Reservation did not add for %1 contact(s).',
- array(1 => (count($this->_contactIds) - $countVoters))
+ CRM_Core_Session::setStatus(ts('Reservation did not add for %count contact.',
+ array(
+ 'plural' => 'Reservation did not add for %count contacts.',
+ 'count' => (count($this->_contactIds) - $countVoters),
+ )
), ts('Notice'));
}
return $groupAdditions;
}
- $params = $this->controller->exportValues($this->_name);
- $groups = CRM_Utils_Array::value('groups', $params, array());
+ $params = $this->controller->exportValues($this->_name);
+ $groups = CRM_Utils_Array::value('groups', $params, array());
$newGroupName = CRM_Utils_Array::value('newGroupName', $params);
$newGroupDesc = CRM_Utils_Array::value('newGroupDesc', $params);
return $groupAdditions;
}
+
}