Skip to content

Commit

Permalink
Merge pull request civicrm#22 from civicrm/master
Browse files Browse the repository at this point in the history
Merging last few weeks from civicrm/civicrm-core into JMAConsulting/civicrm-core
  • Loading branch information
JoeMurray committed Mar 25, 2015
2 parents fd890d4 + 5b3cb17 commit 01984fc
Show file tree
Hide file tree
Showing 190 changed files with 2,522 additions and 753 deletions.
7 changes: 7 additions & 0 deletions CRM/Activity/Form/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {

protected $unsavedWarn = TRUE;

/**
* Explicitly declare the entity api name.
*/
public function getDefaultEntity() {
return 'Activity';
}

/**
* The _fields var can be used by sub class to set/unset/edit the
* form fields based on their requirement
Expand Down
4 changes: 2 additions & 2 deletions CRM/Activity/Form/Task/AddToTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ public function postProcess() {

list($total, $added, $notAdded) = CRM_Core_BAO_EntityTag::addEntitiesToTag($this->_activityHolderIds, $key, 'civicrm_activity');

$status = array(ts('%count activities tagged', array('count' => $added, 'plural' => '%count activities tagged')));
$status = array(ts('Activity tagged', array('count' => $added, 'plural' => '%count activities tagged')));
if ($notAdded) {
$status[] = ts('%count activities already had this tag', array(
$status[] = ts('1 activity already had this tag', array(
'count' => $notAdded,
'plural' => '%count activities already had this tag',
));
Expand Down
17 changes: 13 additions & 4 deletions CRM/Activity/Form/Task/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,25 @@ public function buildQuickForm() {
* @return void
*/
public function postProcess() {
$deletedActivities = 0;
$deleted = $failed = 0;
foreach ($this->_activityHolderIds as $activityId['id']) {
$moveToTrash = CRM_Case_BAO_Case::isCaseActivity($activityId['id']);
if (CRM_Activity_BAO_Activity::deleteActivity($activityId, $moveToTrash)) {
$deletedActivities++;
$deleted++;
}
else {
$failed++;
}
}

if ($deleted) {
$msg = ts('%count activity deleted.', array('plural' => '%count activities deleted.', 'count' => $deleted));
CRM_Core_Session::setStatus($msg, ts('Removed'), 'success');
}

CRM_Core_Session::setStatus($deletedActivities, ts('Deleted Activities'), "success");
CRM_Core_Session::setStatus("", ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds))), "info");
if ($failed) {
CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error');
}
}

}
2 changes: 1 addition & 1 deletion CRM/Activity/Form/Task/RemoveFromTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function postProcess() {
list($total, $removed, $notRemoved) = CRM_Core_BAO_EntityTag::removeEntitiesFromTag($this->_activityHolderIds, $key, 'civicrm_activity');

$status = array(
ts('%count activities un-tagged', array(
ts('%count activity un-tagged', array(
'count' => $removed,
'plural' => '%count activities un-tagged',
)),
Expand Down
36 changes: 20 additions & 16 deletions CRM/Admin/Form/LabelFormats.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@ public function buildQuickForm() {
'CRM_Core_BAO_LabelFormat',
$this->_id,
));
$this->addRule('NX', ts('Must be an integer'), 'integer');
$this->addRule('NY', ts('Must be an integer'), 'integer');
$this->addRule('tMargin', ts('Must be numeric'), 'numeric');
$this->addRule('lMargin', ts('Must be numeric'), 'numeric');
$this->addRule('SpaceX', ts('Must be numeric'), 'numeric');
$this->addRule('SpaceY', ts('Must be numeric'), 'numeric');
$this->addRule('lPadding', ts('Must be numeric'), 'numeric');
$this->addRule('tPadding', ts('Must be numeric'), 'numeric');
$this->addRule('width', ts('Must be numeric'), 'numeric');
$this->addRule('height', ts('Must be numeric'), 'numeric');
$this->addRule('weight', ts('Must be integer'), 'integer');
$this->addRule('NX', ts('Please enter a valid integer.'), 'integer');
$this->addRule('NY', ts('Please enter a valid integer.'), 'integer');
$this->addRule('tMargin', ts('Please enter a valid number.'), 'numeric');
$this->addRule('lMargin', ts('Please enter a valid number.'), 'numeric');
$this->addRule('SpaceX', ts('Please enter a valid number.'), 'numeric');
$this->addRule('SpaceY', ts('Please enter a valid number.'), 'numeric');
$this->addRule('lPadding', ts('Please enter a valid number.'), 'numeric');
$this->addRule('tPadding', ts('Please enter a valid number.'), 'numeric');
$this->addRule('width', ts('Please enter a valid number.'), 'numeric');
$this->addRule('height', ts('Please enter a valid number.'), 'numeric');
$this->addRule('weight', ts('Please enter a valid integer.'), 'integer');
}

/**
Expand Down Expand Up @@ -194,20 +194,24 @@ public function postProcess() {
if ($this->_action & CRM_Core_Action::COPY) {
// make a copy of the Label Format
$labelFormat = CRM_Core_BAO_LabelFormat::getById($this->_id, $this->_group);
$newlabel = ts('Copy of %1', array(1 => $labelFormat['label']));

$list = CRM_Core_BAO_LabelFormat::getList(TRUE, $this->_group);
$count = 1;
$prefix = ts('Copy of ');
while (in_array($prefix . $labelFormat['label'], $list)) {
$prefix = ts('Copy') . ' (' . ++$count . ') ' . ts('of ');

while (in_array($newlabel, $list)) {
$count++;
$newlabel = ts('Copy %1 of %2', array(1 => $count, 2 => $labelFormat['label']));
}
$labelFormat['label'] = $prefix . $labelFormat['label'];

$labelFormat['label'] = $newlabel;
$labelFormat['grouping'] = CRM_Core_BAO_LabelFormat::customGroupName();
$labelFormat['is_default'] = 0;
$labelFormat['is_reserved'] = 0;

$bao = new CRM_Core_BAO_LabelFormat();
$bao->saveLabelFormat($labelFormat, NULL, $this->_group);
CRM_Core_Session::setStatus($labelFormat['label'] . ts(' has been created.'), ts('Saved'), 'success');
CRM_Core_Session::setStatus(ts('%1 has been created.', array(1 => $labelFormat['label'])), ts('Saved'), 'success');
return;
}

Expand Down
8 changes: 8 additions & 0 deletions CRM/Admin/Form/ParticipantStatusType.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
*
*/
class CRM_Admin_Form_ParticipantStatusType extends CRM_Admin_Form {

/**
* Explicitly declare the entity api name.
*/
public function getDefaultEntity() {
return 'ParticipantStatusType';
}

public function buildQuickForm() {
parent::buildQuickForm();

Expand Down
2 changes: 2 additions & 0 deletions CRM/Admin/Form/Preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ public function postProcessCommon() {
);
}
}
// Update any settings stored in dynamic js
CRM_Core_Resources::singleton()->resetCacheCode();

CRM_Core_Session::setStatus(ts('Your changes have been saved.'), ts('Saved'), 'success');
}
Expand Down
8 changes: 4 additions & 4 deletions CRM/Admin/Form/Setting/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public function buildQuickForm() {
$session->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1'));

$this->addFormRule(array('CRM_Admin_Form_Setting_Mail', 'formRule'));
$this->addRule('mailerBatchLimit', ts('Must be an integer'), 'integer');
$this->addRule('mailThrottleTime', ts('Must be an integer'), 'integer');
$this->addRule('mailerJobSize', ts('Must be an integer'), 'integer');
$this->addRule('mailerJobsMax', ts('Must be an integer'), 'integer');
$this->addRule('mailerBatchLimit', ts('Please enter a valid integer.'), 'integer');
$this->addRule('mailThrottleTime', ts('Please enter a valid integer.'), 'integer');
$this->addRule('mailerJobSize', ts('Please enter a valid integer.'), 'integer');
$this->addRule('mailerJobsMax', ts('Please enter a valid integer.'), 'integer');

parent::buildQuickForm($check);
}
Expand Down
7 changes: 7 additions & 0 deletions CRM/Admin/Form/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
class CRM_Admin_Form_Tag extends CRM_Admin_Form {
protected $_isTagSet;

/**
* Explicitly declare the entity api name.
*/
public function getDefaultEntity() {
return 'Tag';
}

/**
* Build the form object.
*
Expand Down
2 changes: 1 addition & 1 deletion CRM/Admin/Page/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function mappingList() {
CRM_Utils_JSON::output(array('status' => 'error', 'error_msg' => 'required params missing.'));
}

$selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($_GET['mappingID']);
$selectionOptions = CRM_Core_BAO_ActionSchedule::getSelection1($_GET['mappingID'], $_GET['isLimit']);

$output = array(
'sel4' => array(),
Expand Down
7 changes: 7 additions & 0 deletions CRM/Campaign/Form/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
*/
protected $_campaignId;

/**
* Explicitly declare the entity api name.
*/
public function getDefaultEntity() {
return 'Campaign';
}

public function preProcess() {
if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
CRM_Utils_System::permissionDenied();
Expand Down
7 changes: 7 additions & 0 deletions CRM/Campaign/Form/Survey/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ class CRM_Campaign_Form_Survey_Main extends CRM_Campaign_Form_Survey {
*/
protected $_context;

/**
* Explicitly declare the entity api name.
*/
public function getDefaultEntity() {
return 'Survey';
}

public function preProcess() {
parent::preProcess();

Expand Down
3 changes: 1 addition & 2 deletions CRM/Campaign/Form/Task/Interview.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,7 @@ public static function registerInterview($params) {
$subject = '';
$surveyTitle = CRM_Utils_Array::value('surveyTitle', $params);
if ($surveyTitle) {
$subject = ts('%1', array(1 => $surveyTitle));
$subject .= ' - ';
$subject = $surveyTitle . ' - ';
}
$subject .= ts('Respondent Interview');

Expand Down
18 changes: 14 additions & 4 deletions CRM/Campaign/Form/Task/Release.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,23 @@ public function postProcess() {
$query = 'UPDATE civicrm_activity SET is_deleted = 1 WHERE id IN ( ' . implode(', ', $deleteActivityIds) . ' )';
CRM_Core_DAO::executeQuery($query);

$status = array(ts("%1 respondent(s) have been released.", array(1 => count($deleteActivityIds))));
if ($deleteActivityIds) {
$status = ts("Respondent has been released.", array(
'count' => count($deleteActivityIds),
'plural' => '%count respondents have been released.',
));
CRM_Core_Session::setStatus($status, ts('Released'), 'success');
}

if (count($this->_contactIds) > count($deleteActivityIds)) {
$status[] = ts("%1 respondents did not release.",
array(1 => (count($this->_contactIds) - count($deleteActivityIds)))
$status = ts('1 respondent did not release.',
array(
'count' => (count($this->_contactIds) - count($deleteActivityIds)),
'plural' => '%count respondents did not release.',
)
);
CRM_Core_Session::setStatus($status, ts('Notice'), 'alert');
}
CRM_Core_Session::setStatus(implode(' ', $status), '', 'info');
}
}

Expand Down
29 changes: 19 additions & 10 deletions CRM/Campaign/Form/Task/Reserve.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,22 @@ public function validateSurvey() {
$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,
)
);
}

Expand Down Expand Up @@ -247,7 +253,7 @@ public function postProcess() {

$reservedVoterIds = array();
foreach ($this->_contactIds as $cid) {
$subject = ts('%1', array(1 => $this->_surveyDetails['title'])) . ' - ' . ts('Respondent Reservation');
$subject = $this->_surveyDetails['title'] . ' - ' . ts('Respondent Reservation');
$session = CRM_Core_Session::singleton();
$activityParams = array(
'source_contact_id' => $session->get('userID'),
Expand Down Expand Up @@ -276,18 +282,21 @@ public function postProcess() {

// 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))
$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'));
}

Expand Down
2 changes: 1 addition & 1 deletion CRM/Campaign/Page/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public function processVoterData() {
$surveytitle = $surveyValues['title'];
}

$subject = ts('%1', array(1 => $surveytitle)) . ' - ' . ts('Respondent Reservation');
$subject = $surveytitle . ' - ' . ts('Respondent Reservation');
$activityParams['subject'] = $subject;
$activityParams['status_id'] = $scheduledStatusId;
$activityParams['skipRecentView'] = 1;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Campaign/Page/DashBoard.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public function getSurveySummary($params = array()) {
$surveysData[$sid]['campaign'] = CRM_Utils_Array::value($campaignId, $campaigns);
$surveysData[$sid]['activity_type'] = $surveyType[$survey['activity_type_id']];
if (!empty($survey['release_frequency'])) {
$surveysData[$sid]['release_frequency'] = $survey['release_frequency'] . ' ' . ts('Day(s)');
$surveysData[$sid]['release_frequency'] = ts('1 Day', array('plural' => '%count Days', 'count' => $survey['release_frequency']));
}

$action = array_sum(array_keys(self::surveyActionLinks($surveysData[$sid]['activity_type'])));
Expand Down
4 changes: 2 additions & 2 deletions CRM/Case/BAO/Case.php
Original file line number Diff line number Diff line change
Expand Up @@ -2724,13 +2724,13 @@ public static function mergeCases(
}
}

//create merge activity record.
//Create merge activity record. Source for merge activity is the logged in user's contact ID ($currentUserId).
$activityParams = array(
'subject' => $mergeActSubject,
'details' => $mergeActSubjectDetails,
'status_id' => array_search('Completed', $activityStatuses),
'activity_type_id' => $mergeActType,
'source_contact_id' => $mainContactId,
'source_contact_id' => $currentUserId,
'activity_date_time' => date('YmdHis'),
);

Expand Down
22 changes: 18 additions & 4 deletions CRM/Case/Form/Task/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,29 @@ public function buildQuickForm() {
* @return void
*/
public function postProcess() {
$deletedCases = 0;
$deleted = $failed = 0;
foreach ($this->_caseIds as $caseId) {
if (CRM_Case_BAO_Case::deleteCase($caseId, $this->_moveToTrash)) {
$deletedCases++;
$deleted++;
}
else {
$failed++;
}
}

if ($deleted) {
if ($this->_moveToTrash) {
$msg = ts('%count case moved to trash.', array('plural' => '%count cases moved to trash.', 'count' => $deleted));
}
else {
$msg = ts('%count case permanently deleted.', array('plural' => '%count cases permanently deleted.', 'count' => $deleted));
}
CRM_Core_Session::setStatus($msg, ts('Removed'), 'success');
}

CRM_Core_Session::setStatus($deletedCases, ts('Deleted Cases'), 'success');
CRM_Core_Session::setStatus('', ts('Total Selected Case(s): %1', array(1 => count($this->_caseIds))), 'info');
if ($failed) {
CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error');
}
}

}
Loading

0 comments on commit 01984fc

Please sign in to comment.