}
}
- // first see if the contact has edit / view all contacts
- if (CRM_Core_Permission::check('edit all contacts') ||
- ($type == self::VIEW && CRM_Core_Permission::check('view all contacts'))
- ) {
- return $deleteClause;
- }
-
if (!$contactID) {
$contactID = CRM_Core_Session::getLoggedInContactID();
}
$contactID = (int) $contactID;
+ // first see if the contact has edit / view all permission
+ if (CRM_Core_Permission::check('edit all contacts', $contactID) ||
+ ($type == self::VIEW && CRM_Core_Permission::check('view all contacts', $contactID))
+ ) {
+ return $deleteClause;
+ }
+
$where = implode(' AND ',
array(
CRM_ACL_BAO_ACL::whereClause($type,
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
// note this also resets any ACL cache
$staticGroupIDs = array();
$cachedGroupIDs = array();
while ($dao->fetch()) {
- // currently operation is restrcited to VIEW/EDIT
+ // currently operation is restricted to VIEW/EDIT
if ($dao->where_clause) {
if ($dao->select_tables) {
$tmpTables = array();
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_ACL_DAO_EntityRole', $id, 'is_active', $is_active);
CRM_Core_Session::setStatus("", ts('Wordpress Access Control Updated'), "success");
- // rebuild the menus to comply with the new permisssions/capabilites
+ // rebuild the menus to comply with the new permissions/capabilites
CRM_Core_Invoke::rebuildMenuAndCaches();
CRM_Utils_System::redirect('admin.php?page=CiviCRM&q=civicrm/admin/access&reset=1');
continue;
}
- $isBulkActivity = (!$bulkActivityTypeID || ($bulkActivityTypeID != $activity['activity_type_id']));
+ $isBulkActivity = (!$bulkActivityTypeID || ($bulkActivityTypeID === $activity['activity_type_id']));
foreach ($mappingParams as $apiKey => $expectedName) {
if (in_array($apiKey, array('assignee_contact_name', 'target_contact_name'))) {
$activities[$id][$expectedName] = CRM_Utils_Array::value($apiKey, $activity, array());
}
// Get contact activities.
- $activities = CRM_Activity_BAO_Activity::deprecatedGetActivities($params);
+ $activities = CRM_Activity_BAO_Activity::getActivities($params);
// Add total.
$params['total'] = CRM_Activity_BAO_Activity::deprecatedGetActivitiesCount($params);
}
elseif (isset($values['target_contact_counter']) && $values['target_contact_counter']) {
$activity['target_contact_name'] = '';
- foreach ($values['target_contact_name'] as $tcID => $tcName) {
- $targetTypeImage = "";
- $targetLink = CRM_Utils_System::href($tcName, 'civicrm/contact/view', "reset=1&cid={$tcID}");
- if ($showContactOverlay) {
- $targetTypeImage = CRM_Contact_BAO_Contact_Utils::getImage(
- CRM_Contact_BAO_Contact::getContactType($tcID),
- FALSE,
- $tcID);
- $activity['target_contact_name'] .= "<div>$targetTypeImage $targetLink";
- }
- else {
- $activity['target_contact_name'] .= $targetLink;
- }
+ $firstTargetName = reset($values['target_contact_name']);
+ $firstTargetContactID = key($values['target_contact_name']);
+
+ $targetLink = CRM_Utils_System::href($firstTargetName, 'civicrm/contact/view', "reset=1&cid={$firstTargetContactID}");
+ if ($showContactOverlay) {
+ $targetTypeImage = CRM_Contact_BAO_Contact_Utils::getImage(
+ CRM_Contact_BAO_Contact::getContactType($firstTargetContactID),
+ FALSE,
+ $firstTargetContactID);
+ $activity['target_contact_name'] .= "<div>$targetTypeImage $targetLink";
+ }
+ else {
+ $activity['target_contact_name'] .= $targetLink;
}
if ($extraCount = $values['target_contact_counter'] - 1) {
$mainActivity->activity_date_time = $actDateTime;
// Make sure this is current revision.
$mainActivity->is_current_revision = TRUE;
- // Drop all relations.
- $mainActivity->parent_id = $mainActivity->original_id = NULL;
+ $mainActivity->original_id = $otherActivity->id;
+ $otherActivity->is_current_revision = FALSE;
$mainActivity->save();
$mainActivityId = $mainActivity->id;
1 => $params['caseID'],
)) . ' ' . $otherActivity->subject;
}
- $otherActivity->activity_date_time = $actDateTime;
$otherActivity->save();
$caseActivity->free();
'sort' => $sort,
);
$config = CRM_Core_Config::singleton();
- $rows = CRM_Activity_BAO_Activity::deprecatedGetActivities($params);
+ $rows = CRM_Activity_BAO_Activity::getActivities($params);
if (empty($rows)) {
return $rows;
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_PrintLabel', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return CRM_Campaign_DAO_Campaign|null
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Campaign_DAO_Campaign', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Campaign_DAO_Survey', $id, 'is_active', $is_active);
*
* @param null $context
* @param int $userID
- * @param null $type
+ * @param null $type (deprecated)
*
* @return array
* Array of case activities
*
*/
public static function getCaseActivity($caseID, &$params, $contactID, $context = NULL, $userID = NULL, $type = NULL) {
- $values = array();
-
$activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
CRM_Activity_BAO_Activity::getStatusesByType(CRM_Activity_BAO_Activity::CANCELLED)
);
- $contactViewUrl = CRM_Utils_System::url("civicrm/contact/view", "reset=1&cid=", FALSE, NULL, FALSE);
- $hasViewContact = CRM_Core_Permission::giveMeAllACLs();
-
if (!$userID) {
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
continue;
}
- $caseActivity['DT_RowId'] = $caseActivityId;
+ $caseActivities[$caseActivityId]['DT_RowId'] = $caseActivityId;
//Add classes to the row, via DataTables syntax
- $caseActivity['DT_RowClass'] = "crm-entity status-id-$dao->status";
+ $caseActivities[$caseActivityId]['DT_RowClass'] = "crm-entity status-id-$dao->status";
if (CRM_Utils_Array::crmInArray($dao->status, $compStatusValues)) {
- $caseActivity['DT_RowClass'] .= " status-completed";
+ $caseActivities[$caseActivityId]['DT_RowClass'] .= " status-completed";
}
else {
if (CRM_Utils_Date::overdue($dao->display_date)) {
- $caseActivity['DT_RowClass'] .= " status-overdue";
+ $caseActivities[$caseActivityId]['DT_RowClass'] .= " status-overdue";
}
else {
- $caseActivity['DT_RowClass'] .= " status-scheduled";
+ $caseActivities[$caseActivityId]['DT_RowClass'] .= " status-scheduled";
}
}
if (!empty($dao->priority)) {
if ($dao->priority == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'priority_id', 'Urgent')) {
- $caseActivity['DT_RowClass'] .= " priority-urgent ";
+ $caseActivities[$caseActivityId]['DT_RowClass'] .= " priority-urgent ";
}
elseif ($dao->priority == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'priority_id', 'Low')) {
- $caseActivity['DT_RowClass'] .= " priority-low ";
+ $caseActivities[$caseActivityId]['DT_RowClass'] .= " priority-low ";
}
}
//Add data to the row for inline editing, via DataTable syntax
- $caseActivity['DT_RowAttr'] = array();
- $caseActivity['DT_RowAttr']['data-entity'] = 'activity';
- $caseActivity['DT_RowAttr']['data-id'] = $caseActivityId;
+ $caseActivities[$caseActivityId]['DT_RowAttr'] = array();
+ $caseActivities[$caseActivityId]['DT_RowAttr']['data-entity'] = 'activity';
+ $caseActivities[$caseActivityId]['DT_RowAttr']['data-id'] = $caseActivityId;
//Activity Date and Time
- $caseActivity['activity_date_time'] = CRM_Utils_Date::customFormat($dao->display_date);
+ $caseActivities[$caseActivityId]['activity_date_time'] = CRM_Utils_Date::customFormat($dao->display_date);
//Activity Subject
- $caseActivity['subject'] = $dao->subject;
+ $caseActivities[$caseActivityId]['subject'] = $dao->subject;
//Activity Type
- $caseActivity['type'] = (!empty($activityTypes[$dao->type]['icon']) ? '<span class="crm-i ' . $activityTypes[$dao->type]['icon'] . '"></span> ' : '')
+ $caseActivities[$caseActivityId]['type'] = (!empty($activityTypes[$dao->type]['icon']) ? '<span class="crm-i ' . $activityTypes[$dao->type]['icon'] . '"></span> ' : '')
. $activityTypes[$dao->type]['label'];
- //Activity Target (With)
- $targetContact = '';
- if (isset($dao->target_contact_id)) {
- $targetContact = $dao->target_contact_name;
- if ($hasViewContact) {
- $targetContact = '<a href="' . $contactViewUrl . $dao->target_contact_id . '">' . $dao->target_contact_name . '</a>';
+ // Activity Target (With Contact) (There can be more than one)
+ $targetContact = self::formatContactLink($dao->target_contact_id, $dao->target_contact_name);
+ if (empty($caseActivities[$caseActivityId]['target_contact_name'])) {
+ $caseActivities[$caseActivityId]['target_contact_name'] = $targetContact;
+ }
+ else {
+ if (strpos($caseActivities[$caseActivityId]['target_contact_name'], $targetContact) === FALSE) {
+ $caseActivities[$caseActivityId]['target_contact_name'] .= '; ' . $targetContact;
}
}
- $caseActivity['target_contact_name'] = $targetContact;
- //Activity Source Contact (Reporter)
- $sourceContact = $dao->source_contact_name;
- if ($hasViewContact) {
- $sourceContact = '<a href="' . $contactViewUrl . $dao->source_contact_id . '">' . $dao->source_contact_name . '</a>';
- }
- $caseActivity['source_contact_name'] = $sourceContact;
+ // Activity Source Contact (Reporter) (There can only be one)
+ $sourceContact = self::formatContactLink($dao->source_contact_id, $dao->source_contact_name);
+ $caseActivities[$caseActivityId]['source_contact_name'] = $sourceContact;
- //Activity Assignee. CRM-4485.
- $assigneeContact = '';
- if (isset($dao->assignee_contact_id)) {
- $assigneeContact = $dao->assignee_contact_name;
- if ($hasViewContact) {
- $assigneeContact = '<a href="' . $contactViewUrl . $dao->assignee_contact_id . '">' . $dao->assignee_contact_name . '</a>';
+ // Activity Assignee (There can be more than one)
+ $assigneeContact = self::formatContactLink($dao->assignee_contact_id, $dao->assignee_contact_name);
+ if (empty($caseActivities[$caseActivityId]['assignee_contact_name'])) {
+ $caseActivities[$caseActivityId]['assignee_contact_name'] = $assigneeContact;
+ }
+ else {
+ if (strpos($caseActivities[$caseActivityId]['assignee_contact_name'], $assigneeContact) === FALSE) {
+ $caseActivities[$caseActivityId]['assignee_contact_name'] .= '; ' . $assigneeContact;
}
}
- $caseActivity['assignee_contact_name'] = $assigneeContact;
//Activity Status
- $caseActivity['status_id'] = $activityStatuses[$dao->status];
+ $caseActivities[$caseActivityId]['status_id'] = $activityStatuses[$dao->status];
// FIXME: Why are we not using CRM_Core_Action for these links? This is too much manual work and likely to get out-of-sync with core markup.
$url = "";
}
elseif (!$caseDeleted) {
$url = ' <a ' . $css . ' href="' . $restoreUrl . $additionalUrl . '">' . ts('Restore') . '</a>';
- $caseActivity['status_id'] = $caseActivity['status_id'] . '<br /> (deleted)';
+ $caseActivities[$caseActivityId]['status_id'] = $caseActivities[$caseActivityId]['status_id'] . '<br /> (deleted)';
}
//check for operations.
// if there are file attachments we will return how many and, if only one, add a link to it
if (!empty($dao->attachment_ids)) {
$attachmentIDs = array_unique(explode(',', $dao->attachment_ids));
- $caseActivity['no_attachments'] = count($attachmentIDs);
+ $caseActivities[$caseActivityId]['no_attachments'] = count($attachmentIDs);
$url .= implode(' ', CRM_Core_BAO_File::paperIconAttachment('civicrm_activity', $caseActivityId));
}
- $caseActivity['links'] = $url;
-
- array_push($caseActivities, $caseActivity);
+ $caseActivities[$caseActivityId]['links'] = $url;
}
$dao->free();
$caseActivitiesDT = array();
- $caseActivitiesDT['data'] = $caseActivities;
+ $caseActivitiesDT['data'] = array_values($caseActivities);
$caseActivitiesDT['recordsTotal'] = $caseCount;
$caseActivitiesDT['recordsFiltered'] = $caseCount;
return $caseActivitiesDT;
}
+ /**
+ * Helper function to generate a formatted contact link/name for display in the Case activities tab
+ *
+ * @param $contactId
+ * @param $contactName
+ *
+ * @return string
+ */
+ private static function formatContactLink($contactId, $contactName) {
+ if (empty($contactId)) {
+ return NULL;
+ }
+
+ $hasViewContact = CRM_Contact_BAO_Contact_Permission::allow($contactId);
+
+ if ($hasViewContact) {
+ $contactViewUrl = CRM_Utils_System::url("civicrm/contact/view", "reset=1&cid={$contactId}");
+ return "<a href=\"{$contactViewUrl}\">" . $contactName . "</a>";
+ }
+ else {
+ return $contactName;
+ }
+ }
+
/**
* Get Case Related Contacts.
*
$atArray,
$this->_currentUserId
);
- $activities = array_keys($activities);
- $activities = $activities[0];
+ $activityId = CRM_Utils_Array::first(array_keys($activities['data']));
$editUrl = CRM_Utils_System::url('civicrm/case/activity',
- "reset=1&cid={$this->_currentlyViewedContactId}&caseid={$caseId}&action=update&id={$activities}"
+ "reset=1&cid={$this->_currentlyViewedContactId}&caseid={$caseId}&action=update&id={$activityId}"
);
}
CRM_Core_Error::statusBounce(ts("You can not add another '%1' activity to this case. %2",
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
$params = array('id' => $id);
* @param bool $isActive
* Value we want to set the is_active field.
*
- * @return CRM_Core_DAO|null
- * DAO object on success, NULL otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $isActive) {
return CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Group', $id, 'is_active', $isActive);
$this->_qill[$grouping][] = "$field[title] $op \"$value\"";
}
elseif ($name === 'email_greeting') {
+ CRM_Core_Error::deprecatedFunctionWarning('pass in email_greeting_id or email_greeting_display');
$filterCondition = array('greeting_type' => 'email_greeting');
$this->optionValueQuery(
$name, $op, $value, $grouping,
);
}
elseif ($name === 'postal_greeting') {
+ CRM_Core_Error::deprecatedFunctionWarning('pass in postal_greeting_id or postal_greeting_display');
$filterCondition = array('greeting_type' => 'postal_greeting');
$this->optionValueQuery(
$name, $op, $value, $grouping,
);
}
elseif ($name === 'addressee') {
+ CRM_Core_Error::deprecatedFunctionWarning('pass in addressee_id or addressee_display');
$filterCondition = array('greeting_type' => 'addressee');
$this->optionValueQuery(
$name, $op, $value, $grouping,
}
}
else {
- // LOWER roughly translates to 'hurt my database without deriving any benefit' See CRM-19811.
- $wc = self::caseImportant($op) ? "LOWER({$field['where']})" : "{$field['where']}";
+ CRM_Core_Error::deprecatedFunctionWarning('pass $ids to this method');
+ $wc = "{$field['where']}";
}
if (in_array($name, $pseudoFields)) {
if (!in_array($name, array('gender_id', 'prefix_id', 'suffix_id', 'communication_style_id'))) {
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_RelationshipType', $id, 'is_active', $is_active);
if ((CRM_Utils_Array::value('radio_ts', self::$_searchFormValues) == 'ts_all') ||
($form->_task == CRM_Contact_Task::SAVE_SEARCH)
) {
- $sortByCharacter = $form->get('sortByCharacter');
- $cacheKey = ($sortByCharacter && $sortByCharacter != 'all') ? "{$cacheKey}_alphabet" : $cacheKey;
-
// since we don't store all contacts in prevnextcache, when user selects "all" use query to retrieve contacts
// rather than prevnext cache table for most of the task actions except export where we rebuild query to fetch
// final result set
}
$form->_emails = $fromEmailValues;
+ $defaults = array();
$form->_fromEmails = $fromEmailValues;
+ if (!Civi::settings()->get('allow_mail_from_logged_in_contact')) {
+ $defaults['from_email_address'] = current(CRM_Core_BAO_Domain::getNameAndEmail(FALSE, TRUE));
+ }
if (is_numeric(key($form->_fromEmails))) {
// Add signature
$defaultEmail = civicrm_api3('email', 'getsingle', array('id' => key($form->_fromEmails)));
if (!empty($defaultEmail['signature_text'])) {
$defaults['text_message'] = "\n\n--\n" . $defaultEmail['signature_text'];
}
- $form->setDefaults($defaults);
}
+ $form->setDefaults($defaults);
}
/**
$countRow = Civi::service('prevnext')->getCount($cacheKey);
// $sortByCharacter triggers a refresh in the prevNext cache
if ($sortByCharacter && $sortByCharacter != 'all') {
- $cacheKey .= "_alphabet";
$this->fillupPrevNextCache($sort, $cacheKey, 0, max(self::CACHE_SIZE, $pageSize));
}
elseif (($firstRecord + $pageSize) >= $countRow) {
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_ContributionPage', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Premium', $id, 'premiums_active ', $is_active);
*
*/
class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task {
+
+ use CRM_Financial_Form_SalesTaxTrait;
+
public $_mode;
public $_action;
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_ActionSchedule', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
// reset the cache
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_Job', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_LocationType', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, NULL otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_MessageTemplate', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return CRM_Core_DAO_Navigation|NULL
- * DAO object on success, NULL otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_Navigation', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_OptionGroup', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_OptionValue', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
//check if custom data profile field is disabled
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * CRM_Core_DAO_UFGroup object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', $id, 'is_active', $is_active);
/**
* Modify indices to account for localization options.
*
- * @param CRM_Core_DAO $class DAO class
+ * @param string $class DAO class
* @param array $originalIndices index definitions before localization
*
* @return array
/**
* Given a permission string or array, check for access requirements
- * @param mixed $permissions
+ * @param string|array $permissions
* The permission to check as an array or string -see examples.
- * arrays
+ *
+ * @param int $contactId
+ * Contact id to check permissions for. Defaults to current logged-in user.
*
* Ex 1
*
* @return bool
* true if yes, else false
*/
- public static function check($permissions) {
+ public static function check($permissions, $contactId = NULL) {
$permissions = (array) $permissions;
+ $userId = NULL;
+ if ($contactId) {
+ $userId = CRM_Core_BAO_UFMatch::getUFId($contactId);
+ }
+ /** @var CRM_Core_Permission_Temp $tempPerm */
$tempPerm = CRM_Core_Config::singleton()->userPermissionTemp;
foreach ($permissions as $permission) {
if (is_array($permission)) {
foreach ($permission as $orPerm) {
- if (self::check($orPerm)) {
+ if (self::check($orPerm, $contactId)) {
//one of our 'or' permissions has succeeded - stop checking this permission
return TRUE;
}
}
else {
// This is an individual permission
- $granted = CRM_Core_Config::singleton()->userPermissionClass->check($permission);
+ $granted = CRM_Core_Config::singleton()->userPermissionClass->check($permission, $userId);
// Call the permission_check hook to permit dynamic escalation (CRM-19256)
- CRM_Utils_Hook::permission_check($permission, $granted);
+ CRM_Utils_Hook::permission_check($permission, $granted, $contactId);
if (
!$granted
&& !($tempPerm && $tempPerm->check($permission))
* @param string $str
* The permission to check.
*
- * @param int $contactID
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str, $contactID = NULL) {
+ public function check($str, $userId = NULL) {
$str = $this->translatePermission($str, 'Drupal', array(
'view user account' => 'access user profiles',
'administer users' => 'administer users',
return TRUE;
}
if (function_exists('user_access')) {
- return user_access($str) ? TRUE : FALSE;
+ $account = NULL;
+ if ($userId) {
+ $account = user_load($userId);
+ }
+ return user_access($str, $account);
}
return TRUE;
}
*
* @param string $str
* The permission to check.
+ * @param int $userId
*
*/
- public function check($str) {
+ public function check($str, $userId = NULL) {
//no default behaviour
}
* @param string $str
* The permission to check.
*
- * @param int $contactID
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str, $contactID = NULL) {
+ public function check($str, $userId = NULL) {
$str = $this->translatePermission($str, 'Drupal', array(
'view user account' => 'access user profiles',
'administer users' => 'administer users',
return TRUE;
}
if (function_exists('user_access')) {
- return user_access($str) ? TRUE : FALSE;
+ $account = NULL;
+ if ($userId) {
+ $account = user_load($userId);
+ }
+ return user_access($str, $account);
}
return TRUE;
}
* @param string $str
* The permission to check.
*
- * @param int $contactID
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str, $contactID = NULL) {
+ public function check($str, $userId = NULL) {
$str = $this->translatePermission($str, 'Drupal6', array(
'view user account' => 'access user profiles',
'administer users' => 'administer users',
return TRUE;
}
if (function_exists('user_access')) {
- return user_access($str) ? TRUE : FALSE;
+ $account = NULL;
+ if ($userId) {
+ $account = user_load($userId);
+ }
+ return user_access($str, $account);
}
return TRUE;
}
* @param string $str
* The permission to check.
*
- * @param null $contactID
+ * @param int $userId
*
* @return bool
*/
- public function check($str, $contactID = NULL) {
+ public function check($str, $userId = NULL) {
$str = $this->translatePermission($str, 'Drupal', array(
'view user account' => 'access user profiles',
));
if ($str == CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) {
return TRUE;
}
- return \Drupal::currentUser()->hasPermission($str);
+ $acct = $userId ? \Drupal\user\Entity\User::load($userId) : \Drupal::currentUser();
+ return $acct->hasPermission($str);
}
/**
*
* @param string $str
* The permission to check.
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str) {
+ public function check($str, $userId = NULL) {
$config = CRM_Core_Config::singleton();
+ // JFactory::getUser does strict type checking, so convert falesy values to NULL
+ if (!$userId) {
+ $userId = NULL;
+ }
$translated = $this->translateJoomlaPermission($str);
if ($translated === CRM_Core_Permission::ALWAYS_DENY_PERMISSION) {
// we've not yet figured out how to bootstrap joomla, so we should
// not execute hooks if joomla is not loaded
if (defined('_JEXEC')) {
- $user = JFactory::getUser();
+ $user = JFactory::getUser($userId);
$api_key = CRM_Utils_Request::retrieve('api_key', 'String', $store, FALSE, NULL, 'REQUEST');
// If we are coming from REST we don't have a user but we do have the api_key for a user.
*
* @param string $str
* The permission to check.
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str) {
+ public function check($str, $userId = NULL) {
return TRUE;
}
*
* @param string $str
* The permission to check.
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str) {
+ public function check($str, $userId = NULL) {
if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) {
return FALSE;
}
*
* @param string $str
* The permission to check.
+ * @param int $userId
*
* @return bool
* true if yes, else false
*/
- public function check($str) {
+ public function check($str, $userId = NULL) {
// Generic cms 'administer users' role tranlates to users with the 'edit_users' capability' in WordPress
$str = $this->translatePermission($str, 'WordPress', array(
'administer users' => 'edit_users',
return TRUE;
}
- if (current_user_can('super admin') || current_user_can('administrator')) {
+ $user = $userId ? get_userdata($userId) : wp_get_current_user();
+
+ if ($user->has_cap('super admin') || $user->has_cap('administrator')) {
return TRUE;
}
// Make string lowercase and convert spaces into underscore
$str = CRM_Utils_String::munge(strtolower($str));
- if (is_user_logged_in()) {
+ if ($user->exists()) {
// Check whether the logged in user has the capabilitity
- if (current_user_can($str)) {
+ if ($user->has_cap($str)) {
return TRUE;
}
}
if (is_array($cIds)) {
$cIdFilter = "(" . implode(',', $cIds) . ")";
$whereClause = "
-WHERE cacheKey LIKE %1
+WHERE cacheKey = %1
AND (entity_id1 IN {$cIdFilter} OR entity_id2 IN {$cIdFilter})
";
}
else {
$whereClause = "
-WHERE cacheKey LIKE %1
+WHERE cacheKey = %1
AND (entity_id1 = %2 OR entity_id2 = %2)
";
$params[2] = array("{$cIds}", 'Integer');
if ($action == 'select') {
$whereClause .= "AND is_selected = 0";
$sql = "UPDATE civicrm_prevnext_cache SET is_selected = 1 {$whereClause} {$entity_whereClause}";
- $params[1] = array("{$cacheKey}%", 'String');
+ $params[1] = array($cacheKey, 'String');
}
elseif ($action == 'unselect') {
$whereClause .= "AND is_selected = 1";
$sql = "UPDATE civicrm_prevnext_cache SET is_selected = 0 {$whereClause} {$entity_whereClause}";
- $params[1] = array("%{$cacheKey}%", 'String');
+ $params[1] = array($cacheKey, 'String');
}
// default action is reseting
}
$sql = "
UPDATE civicrm_prevnext_cache
SET is_selected = 0
-WHERE cacheKey LIKE %1 AND is_selected = 1
+WHERE cacheKey = %1 AND is_selected = 1
{$entity_whereClause}
";
- $params[1] = array("{$cacheKey}%", 'String');
+ $params[1] = array($cacheKey, 'String');
}
CRM_Core_DAO::executeQuery($sql, $params);
}
$actionGet = ($action == "get") ? " AND is_selected = 1 " : "";
$sql = "
SELECT entity_id1, entity_id2 FROM civicrm_prevnext_cache
-WHERE cacheKey LIKE %1
+WHERE cacheKey = %1
$actionGet
$entity_whereClause
ORDER BY id
";
- $params[1] = array("{$cacheKey}%", 'String');
+ $params[1] = array($cacheKey, 'String');
$contactIds = array($cacheKey => array());
$cIdDao = CRM_Core_DAO::executeQuery($sql, $params);
* @param string $entityTable
*/
public function deleteItem($id = NULL, $cacheKey = NULL, $entityTable = 'civicrm_contact') {
- CRM_Core_BAO_PrevNextCache::deleteItem($id, $cacheKey, $entityTable);
+ $sql = "DELETE FROM civicrm_prevnext_cache WHERE entity_table = %1";
+ $params = array(1 => array($entityTable, 'String'));
+
+ if (is_numeric($id)) {
+ $sql .= " AND ( entity_id1 = %2 OR entity_id2 = %2 )";
+ $params[2] = array($id, 'Integer');
+ }
+
+ if (isset($cacheKey)) {
+ $sql .= " AND cacheKey = %3";
+ $params[3] = array($cacheKey, 'String');
+ }
+ CRM_Core_DAO::executeQuery($sql, $params);
}
/**
"bower_components/datatables/media/css/jquery.dataTables.min.css",
"bower_components/jquery-validation/dist/jquery.validate.min.js",
"packages/jquery/plugins/jquery.ui.datepicker.validation.min.js",
+ "js/crm.datepicker.js",
"js/Common.js",
"js/crm.ajax.js",
"js/wysiwyg/crm.wysiwyg.js",
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Event', $id, 'is_active', $is_active);
* the permission that the user has (or null)
*/
public static function checkPermission($eventId = NULL, $type = CRM_Core_Permission::VIEW) {
- static $permissions = NULL;
-
- if (empty($permissions)) {
+ if (!isset(Civi::$statics[__CLASS__]['permissions'])) {
$params = array(
'check_permissions' => 1,
'return' => 'title',
// Search again, but only events created by the user.
$params['created_id'] = 'user_contact_id';
$result = civicrm_api3('Event', 'get', $params);
- $createdEvents = CRM_Utils_Array::collect('title', $result['values']);
+ $createdEvents = array_keys($result['values']);
// Note: for a multisite setup, a user with edit all events, can edit all events
// including those from other sites
if (CRM_Core_Permission::check('edit all events')) {
- $permissions[CRM_Core_Permission::EDIT] = array_keys($allEvents);
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::EDIT] = array_keys($allEvents);
}
else {
- $permissions[CRM_Core_Permission::EDIT] = CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_event', $allEvents, $createdEvents);
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::EDIT] = CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_event', $allEvents, $createdEvents);
}
if (CRM_Core_Permission::check('edit all events')) {
- $permissions[CRM_Core_Permission::VIEW] = array_keys($allEvents);
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::VIEW] = array_keys($allEvents);
}
else {
if (CRM_Core_Permission::check('access CiviEvent') &&
// at the same time also allow any hook to override if needed.
$createdEvents = array_keys($allEvents);
}
- $permissions[CRM_Core_Permission::VIEW] = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_event', $allEvents, $createdEvents);
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::VIEW] = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_event', $allEvents, $createdEvents);
}
- $permissions[CRM_Core_Permission::DELETE] = array();
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::DELETE] = array();
if (CRM_Core_Permission::check('delete in CiviEvent')) {
// Note: we want to restrict the scope of delete permission to
// events that are editable/viewable (usecase multisite).
// We can remove array_intersect once we have ACL support for delete functionality.
- $permissions[CRM_Core_Permission::DELETE] = array_intersect($permissions[CRM_Core_Permission::EDIT],
- $permissions[CRM_Core_Permission::VIEW]
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::DELETE] = array_intersect(Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::EDIT],
+ Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::VIEW]
);
}
}
if ($eventId) {
- return in_array($eventId, $permissions[$type]) ? TRUE : FALSE;
+ return in_array($eventId, Civi::$statics[__CLASS__]['permissions'][$type]) ? TRUE : FALSE;
}
- return $permissions;
+ return Civi::$statics[__CLASS__]['permissions'];
}
/**
$returnMessages = array();
- $participantRole = CRM_Event_PseudoConstant::participantRole();
$pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'");
$expiredStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'");
$waitingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
$expiredParticipantCount = $waitingConfirmCount = $waitingApprovalCount = 0;
//get all participant who's status in class pending and waiting
- $query = "SELECT * FROM civicrm_participant WHERE status_id IN {$statusIds} ORDER BY register_date";
-
$query = "
SELECT participant.id,
participant.contact_id,
}
/**
- * This function checks if there was any registraion for related event ids,
- * and returns array of ids with no regsitrations
+ * This function checks if there was any registration for related event ids,
+ * and returns array of ids with no registrations
*
* @param string or int or object... $eventID
*
}
}
$this->assign('totalTaxAmount', $totalTaxAmount);
- $this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings));
+ $this->assign('taxTerm', $this->getSalesTaxTerm());
$this->assign('dataArray', $dataArray);
}
if (!empty($additionalParticipantDetails)) {
$displayOpt = CRM_Utils_Array::value('tax_display_settings', $invoiceSettings);
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
foreach ($fieldValues['options'] as $optionId => $optionVal) {
+ if (CRM_Utils_Array::value('visibility_id', $optionVal) != array_search('public', $visibility) &&
+ $adminFieldVisible == FALSE
+ ) {
+ continue;
+ }
+
$values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues);
if ($invoicing && isset($optionVal['tax_amount'])) {
$values['feeBlock']['value'][$fieldCnt] = CRM_Price_BAO_PriceField::getTaxLabel($optionVal, 'amount', $displayOpt, $taxTerm);
// CRM-7675
const EXPORT_ROW_COUNT = 100000;
- /**
- * Key representing the head of household in the relationship array.
- *
- * e.g. 8_a_b.
- *
- * @var string
- */
- protected static $headOfHouseholdRelationshipKey;
-
- /**
- * Key representing the head of household in the relationship array.
- *
- * e.g. 8_a_b.
- *
- * @var string
- */
- protected static $memberOfHouseholdRelationshipKey;
-
/**
* Key representing the head of household in the relationship array.
*
/**
* Get Query Group By Clause
- * @param int $exportMode
+ * @param \CRM_Export_BAO_ExportProcessor $processor
* Export Mode
- * @param string $queryMode
- * Query Mode
* @param array $returnProperties
* Return Properties
* @param object $query
* @return string $groupBy
* Group By Clause
*/
- public static function getGroupBy($exportMode, $queryMode, $returnProperties, $query) {
+ public static function getGroupBy($processor, $returnProperties, $query) {
$groupBy = '';
+ $exportMode = $processor->getExportMode();
+ $queryMode = $processor->getQueryMode();
if (!empty($returnProperties['tags']) || !empty($returnProperties['groups']) ||
CRM_Utils_Array::value('notes', $returnProperties) ||
// CRM-9552
$queryOperator = 'AND'
) {
- $processor = new CRM_Export_BAO_ExportProcessor($exportMode, $fields, $queryOperator);
+ $processor = new CRM_Export_BAO_ExportProcessor($exportMode, $fields, $queryOperator, $mergeSameHousehold);
$returnProperties = array();
$phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
// without manually testing the export of IM provider still works.
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
self::$relationshipTypes = $processor->getRelationshipTypes();
- //also merge Head of Household
- self::$memberOfHouseholdRelationshipKey = CRM_Utils_Array::key('Household Member of', self::$relationshipTypes);
- self::$headOfHouseholdRelationshipKey = CRM_Utils_Array::key('Head of Household for', self::$relationshipTypes);
$queryMode = $processor->getQueryMode();
foreach ($returnProperties as $key => $value) {
if (!$processor->isRelationshipTypeKey($key)) {
- $returnProperties[self::$memberOfHouseholdRelationshipKey][$key] = $value;
- $returnProperties[self::$headOfHouseholdRelationshipKey][$key] = $value;
+ foreach ($processor->getHouseholdRelationshipTypes() as $householdRelationshipType) {
+ if (!in_array($key, ['location_type', 'im_provider'])) {
+ $returnProperties[$householdRelationshipType][$key] = $value;
+ }
+ }
}
}
-
- unset($returnProperties[self::$memberOfHouseholdRelationshipKey]['location_type']);
- unset($returnProperties[self::$memberOfHouseholdRelationshipKey]['im_provider']);
- unset($returnProperties[self::$headOfHouseholdRelationshipKey]['location_type']);
- unset($returnProperties[self::$headOfHouseholdRelationshipKey]['im_provider']);
}
- list($relationQuery, $allRelContactArray) = self::buildRelatedContactArray($selectAll, $ids, $exportMode, $componentTable, $returnProperties, $queryMode);
+ list($relationQuery, $allRelContactArray) = self::buildRelatedContactArray($selectAll, $ids, $processor, $componentTable, $returnProperties);
// make sure the groups stuff is included only if specifically specified
// by the fields param (CRM-1969), else we limit the contacts outputted to only
$queryString = "$select $from $where $having";
- $groupBy = self::getGroupBy($exportMode, $queryMode, $returnProperties, $query);
+ $groupBy = self::getGroupBy($processor, $returnProperties, $query);
$queryString .= $groupBy;
// merge the records if they have corresponding households
if ($mergeSameHousehold) {
- self::mergeSameHousehold($exportTempTable, $headerRows, $sqlColumns, self::$memberOfHouseholdRelationshipKey);
- self::mergeSameHousehold($exportTempTable, $headerRows, $sqlColumns, self::$headOfHouseholdRelationshipKey);
+ foreach ($processor->getHouseholdRelationshipTypes() as $householdRelationshipType) {
+ self::mergeSameHousehold($exportTempTable, $sqlColumns, $householdRelationshipType);
+ }
}
// call export hook
self::writeCSVFromTable($exportTempTable, $headerRows, $sqlColumns, $exportMode);
}
else {
- // return tableName and sqlColumns in test context
+ // return tableName sqlColumns headerRows in test context
return array($exportTempTable, $sqlColumns, $headerRows);
}
*
* @param string $exportTempTable
* Temporary temp table that stores the records.
- * @param array $headerRows
- * Array of headers for the export file.
* @param array $sqlColumns
* Array of names of the table columns of the temp table.
* @param string $prefix
* Name of the relationship type that is prefixed to the table columns.
*/
- public static function mergeSameHousehold($exportTempTable, &$headerRows, &$sqlColumns, $prefix) {
+ public static function mergeSameHousehold($exportTempTable, &$sqlColumns, $prefix) {
$prefixColumn = $prefix . '_';
$allKeys = array_keys($sqlColumns);
$replaced = array();
- $headerRows = array_values($headerRows);
// name map of the non standard fields in header rows & sql columns
$mappingFields = array(
foreach ($replaced as $from => $to) {
$clause[] = "$from = $to ";
unset($sqlColumns[$to]);
- if ($key = CRM_Utils_Array::key($to, $allKeys)) {
- unset($headerRows[$key]);
- }
}
$query .= implode(",\n", $clause);
$query .= " WHERE {$replaced['civicrm_primary_id']} != ''";
* Columns to go in the temp table.
* @param \CRM_Export_BAO_ExportProcessor $processor
* @param array|string $value
- * @param array $phoneTypes
- * @param array $imProviders
*
* @return array
*/
- public static function setHeaderRows($field, $headerRows, $sqlColumns, $processor, $value, $phoneTypes, $imProviders) {
+ public static function setHeaderRows($field, $headerRows, $sqlColumns, $processor, $value) {
$queryFields = $processor->getQueryFields();
if (substr($field, -11) == 'campaign_id') {
// @todo - set this correctly in the xml rather than here.
$headerRows[] = ts('Campaign ID');
}
+ elseif ($processor->isMergeSameHousehold() && $field === 'id') {
+ $headerRows[] = ts('Household ID');
+ }
elseif (isset($queryFields[$field]['title'])) {
$headerRows[] = $queryFields[$field]['title'];
}
}
}
- $headerRows[] = $headerName;
+ if (!$processor->isHouseholdMergeRelationshipTypeKey($field)) {
+ // Do not add to header row if we are only generating for merge reasons.
+ $headerRows[] = $headerName;
+ }
self::sqlColumnDefn($processor, $sqlColumns, $headerName);
}
if (!empty($type[1])) {
if (CRM_Utils_Array::value(0, $type) == 'phone') {
- $hdr .= "-" . CRM_Utils_Array::value($type[1], $phoneTypes);
+ $hdr .= "-" . CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Phone', 'phone_type_id', $type[1]);
}
elseif (CRM_Utils_Array::value(0, $type) == 'im') {
- $hdr .= "-" . CRM_Utils_Array::value($type[1], $imProviders);
+ $hdr .= "-" . CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_IM', 'provider_id', $type[1]);
}
}
$headerName = $field . '-' . $hdr;
$metadata = $headerRows = $outputColumns = $sqlColumns = array();
$phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
$imProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id');
-
$queryFields = $processor->getQueryFields();
foreach ($returnProperties as $key => $value) {
if ($key != 'location' || !is_array($value)) {
$outputColumns[$key] = $value;
- list($headerRows, $sqlColumns) = self::setHeaderRows($key, $headerRows, $sqlColumns, $processor, $value, $phoneTypes, $imProviders);
+ list($headerRows, $sqlColumns) = self::setHeaderRows($key, $headerRows, $sqlColumns, $processor, $value);
}
else {
foreach ($value as $locationType => $locationFields) {
$metadata[$daoFieldName]['pseudoconstant']['var'] = 'imProviders';
}
self::sqlColumnDefn($processor, $sqlColumns, $outputFieldName);
- list($headerRows, $sqlColumns) = self::setHeaderRows($outputFieldName, $headerRows, $sqlColumns, $processor, $value, $phoneTypes, $imProviders);
+ list($headerRows, $sqlColumns) = self::setHeaderRows($outputFieldName, $headerRows, $sqlColumns, $processor, $value);
if ($actualDBFieldName == 'country' || $actualDBFieldName == 'world_region') {
$metadata[$daoFieldName] = array('context' => 'country');
}
/**
* @param $selectAll
* @param $ids
- * @param $exportMode
+ * @param \CRM_Export_BAO_ExportProcessor $processor
* @param $componentTable
* @param $returnProperties
- * @param $queryMode
+ *
* @return array
*/
- protected static function buildRelatedContactArray($selectAll, $ids, $exportMode, $componentTable, $returnProperties, $queryMode) {
+ protected static function buildRelatedContactArray($selectAll, $ids, $processor, $componentTable, $returnProperties) {
$allRelContactArray = $relationQuery = array();
-
+ $queryMode = $processor->getQueryMode();
+ $exportMode = $processor->getExportMode();
foreach (self::$relationshipTypes as $rel => $dnt) {
if ($relationReturnProperties = CRM_Utils_Array::value($rel, $returnProperties)) {
$allRelContactArray[$rel] = array();
*/
protected $requestedFields;
+ /**
+ * Is the contact being merged into a single household.
+ *
+ * @var bool
+ */
+ protected $isMergeSameHousehold;
+
/**
* Key representing the head of household in the relationship array.
*
* @param int $exportMode
* @param array|NULL $requestedFields
* @param string $queryOperator
+ * @param bool $isMergeSameHousehold
*/
- public function __construct($exportMode, $requestedFields, $queryOperator) {
+ public function __construct($exportMode, $requestedFields, $queryOperator, $isMergeSameHousehold = FALSE) {
$this->setExportMode($exportMode);
$this->setQueryMode();
$this->setQueryOperator($queryOperator);
$this->setRequestedFields($requestedFields);
$this->setRelationshipTypes();
+ $this->setIsMergeSameHousehold($isMergeSameHousehold);
}
/**
);
}
+ /**
+ * @return bool
+ */
+ public function isMergeSameHousehold() {
+ return $this->isMergeSameHousehold;
+ }
+
+ /**
+ * @param bool $isMergeSameHousehold
+ */
+ public function setIsMergeSameHousehold($isMergeSameHousehold) {
+ $this->isMergeSameHousehold = $isMergeSameHousehold;
+ }
+
+ /**
+ * Return relationship types for household merge.
+ *
+ * @return mixed
+ */
+ public function getHouseholdRelationshipTypes() {
+ if (!$this->isMergeSameHousehold()) {
+ return [];
+ }
+ return [
+ CRM_Utils_Array::key('Household Member of', $this->getRelationshipTypes()),
+ CRM_Utils_Array::key('Head of Household for', $this->getRelationshipTypes()),
+ ];
+ }
/**
* @param $fieldName
return array_key_exists($fieldName, $this->relationshipTypes);
}
+
+ /**
+ * @param $fieldName
+ * @return bool
+ */
+ public function isHouseholdMergeRelationshipTypeKey($fieldName) {
+ return in_array($fieldName, $this->getHouseholdRelationshipTypes());
+ }
+
/**
* @return string
*/
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return CRM_Core_DAO|null
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_FinancialAccount', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return CRM_Financial_DAO_PaymentProcessor|null
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_PaymentProcessor', $id, 'is_active', $is_active);
*/
public static function getAllPaymentProcessors($mode = 'all', $reset = FALSE, $isCurrentDomainOnly = TRUE) {
- $cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . $mode . '_' . CRM_Core_Config::domainID();
+ $cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . $mode . '_' . $isCurrentDomainOnly . '_' . CRM_Core_Config::domainID();
if (!$reset) {
$processors = CRM_Utils_Cache::singleton()->get($cacheKey);
if (!empty($processors)) {
public static function getPaymentProcessors($capabilities = array(), $ids = FALSE) {
$testProcessors = in_array('TestMode', $capabilities) ? self::getAllPaymentProcessors('test') : array();
if (is_array($ids)) {
- $processors = self::getAllPaymentProcessors('all', TRUE, FALSE);
+ $processors = self::getAllPaymentProcessors('all', FALSE, FALSE);
}
else {
- $processors = self::getAllPaymentProcessors('all', TRUE);
+ $processors = self::getAllPaymentProcessors('all');
}
if (in_array('TestMode', $capabilities) && is_array($ids)) {
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_PaymentProcessorType', $id, 'is_active', $is_active);
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.7 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | 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-2018
+ */
+
+trait CRM_Financial_Form_SalesTaxTrait {
+
+ /**
+ * Assign the sales tax term to the template.
+ */
+ public function assignSalesTaxTermToTemplate() {
+ $this->assign('taxTerm', $this->getSalesTaxTerm());
+ }
+
+ /**
+ * Assign sales tax rates to the template.
+ */
+ public function assignSalesTaxRates() {
+ $this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
+ }
+
+ /**
+ * Return the string to be assigned to the template for sales tax - e.g GST, VAT.
+ *
+ * @return string
+ */
+ public function getSalesTaxTerm() {
+ $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
+ $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
+ if (!$invoicing) {
+ return '';
+ }
+ return CRM_Utils_Array::value('tax_term', $invoiceSettings);
+ }
+
+ /**
+ * Assign information to the template required for sales tax purposes.
+ */
+ public function assignSalesTaxMetadataToTemplate() {
+ $this->assignSalesTaxRates();
+ $this->assignSalesTaxTermToTemplate();
+ }
+
+ /**
+ * Get sales tax rates.
+ *
+ * @return array
+ */
+ public function getTaxRatesForFinancialTypes() {
+ return CRM_Core_PseudoConstant::getTaxRates();
+ }
+
+ /**
+ * @param int $financialTypeID
+ *
+ * @return string
+ */
+ public function getTaxRateForFinancialType($financialTypeID) {
+ return CRM_Utils_Array::value($financialTypeID, $this->getTaxRatesForFinancialTypes());
+ }
+
+}
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Component', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Member_DAO_MembershipStatus', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Member_DAO_MembershipType', $id, 'is_active', $is_active);
*
* @param int $membershipId
* @param $changeToday
+ * If provided, specify an alternative date to use as "today" for renewal
* @param int $membershipTypeID
* If provided, overrides the membership type of the $membershipID membership.
* @param int $numRenewTerms
* Build the form object.
*/
public function buildQuickForm() {
+ $this->assignSalesTaxMetadataToTemplate();
$this->addPaymentProcessorSelect(TRUE, FALSE, TRUE);
CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE, $this->getDefaultPaymentInstrumentId());
*/
public function buildQuickForm() {
- $this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
-
$this->assign('currency', CRM_Core_Config::singleton()->defaultCurrencySymbol);
- $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
- $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
- if (isset($invoicing)) {
- $this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings));
- }
+
// build price set form.
$buildPriceSet = FALSE;
if ($this->_priceSetId || !empty($_POST['price_set_id'])) {
}
if ($taxAmount) {
$this->assign('totalTaxAmount', $totalTaxAmount);
- $this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings));
+ // Not sure why would need this on Submit.... unless it's being used when sending mails in which case this is the wrong place
+ $this->assign('taxTerm', $this->getSalesTaxTerm());
}
$this->assign('dataArray', $dataArray);
}
}
//CRM-16950
- $taxRates = CRM_Core_PseudoConstant::getTaxRates();
- $taxRate = CRM_Utils_Array::value($this->allMembershipTypeDetails[$defaults['membership_type_id']]['financial_type_id'], $taxRates);
-
- $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
+ $taxRate = $this->getTaxRateForFinancialType($this->allMembershipTypeDetails[$defaults['membership_type_id']]['financial_type_id']);
// auto renew options if enabled for the membership
$options = CRM_Core_SelectValues::memberAutoRenew();
//CRM-16950
$taxAmount = NULL;
$totalAmount = CRM_Utils_Array::value('minimum_fee', $values);
- if (CRM_Utils_Array::value($values['financial_type_id'], $taxRates)) {
+ // @todo - feels a bug - we use taxRate from the form default rather than from the specified type?!?
+ if ($this->getTaxRateForFinancialType($values['financial_type_id'])) {
$taxAmount = ($taxRate / 100) * CRM_Utils_Array::value('minimum_fee', $values);
$totalAmount = $totalAmount + $taxAmount;
}
'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $values),
'total_amount' => CRM_Utils_Money::format($totalAmount, NULL, '%a'),
'total_amount_numeric' => $totalAmount,
- 'tax_message' => $taxAmount ? ts("Includes %1 amount of %2", array(1 => CRM_Utils_Array::value('tax_term', $invoiceSettings), 2 => CRM_Utils_Money::format($taxAmount))) : $taxAmount,
+ 'tax_message' => $taxAmount ? ts("Includes %1 amount of %2", array(1 => $this->getSalesTaxTerm(), 2 => CRM_Utils_Money::format($taxAmount))) : $taxAmount,
);
if (!empty($values['auto_renew'])) {
* Campaign page id.
*
* @param bool $is_active
- * @return null
+ *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setDisable($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_PCP_DAO_PCP', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise.
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceField', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceFieldValue', $id, 'is_active', $is_active);
* Id of the database record.
* @param $isActive
*
- * @internal param bool $is_active value we want to set the is_active field
- *
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $isActive) {
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $id, 'is_active', $isActive);
* @param bool $isQuickConfig we want to set the is_quick_config field.
* Value we want to set the is_quick_config field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsQuickConfig($id, $isQuickConfig) {
return CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceSet', $id, 'is_quick_config', $isQuickConfig);
if (!CRM_Core_Permission::check('view report sql')) {
return;
}
+ $ignored_output_modes = array('pdf', 'csv', 'print');
+ if (in_array($this->_outputMode, $ignored_output_modes)) {
+ return;
+ }
$this->tabs['Developer'] = array(
'title' => ts('Developer'),
'tpl' => 'Developer',
$this->sqlArray[] = $sql;
foreach ($this->sqlArray as $sql) {
foreach (array('LEFT JOIN') as $term) {
- $sql = str_replace($term, '<br>  ' . $term, $sql);
+ $sql = str_replace($term, '<br> ' . $term, $sql);
}
foreach (array('FROM', 'WHERE', 'GROUP BY', 'ORDER BY', 'LIMIT', ';') as $term) {
$sql = str_replace($term, '<br><br>' . $term, $sql);
$this->sqlFormattedArray[] = $sql;
$this->assign('sql', implode(';<br><br><br><br>', $this->sqlFormattedArray));
}
+ $this->assign('sqlModes', $sqlModes = CRM_Utils_SQL::getSqlModes());
+
}
/**
if (!empty($field['pseudofield'])) {
continue;
}
- $clause = NULL;
- if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
- if (CRM_Utils_Array::value('operatorType', $field) ==
- CRM_Report_Form::OP_MONTH
- ) {
- $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
- $value = CRM_Utils_Array::value("{$fieldName}_value", $this->_params);
- if (is_array($value) && !empty($value)) {
- $clause
- = "(month({$field['dbAlias']}) $op (" . implode(', ', $value) .
- '))';
- }
- }
- else {
- $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
- $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
- $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
- $fromTime = CRM_Utils_Array::value("{$fieldName}_from_time", $this->_params);
- $toTime = CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params);
- $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type'], $fromTime, $toTime);
- }
- }
- else {
- $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
- if ($op) {
- $clause = $this->whereClause($field,
- $op,
- CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
- CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
- CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
- );
- }
- }
+ $clause = $this->generateFilterClause($field, $fieldName);
if (!empty($clause)) {
if (!empty($field['having'])) {
'title' => $options['prefix_label'] . ts('Gender'),
'options' => CRM_Contact_BAO_Contact::buildOptions('gender_id'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'alter_display' => 'alterGenderID',
'is_fields' => TRUE,
'is_filters' => TRUE,
),
}
}
+ /**
+ * Generate clause for the selected filter.
+ *
+ * @param array $field
+ * Field specification
+ * @param string $fieldName
+ * Field name.
+ *
+ * @return string
+ * Relevant where clause.
+ */
+ protected function generateFilterClause($field, $fieldName) {
+ if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
+ if (CRM_Utils_Array::value('operatorType', $field) ==
+ CRM_Report_Form::OP_MONTH
+ ) {
+ $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
+ $value = CRM_Utils_Array::value("{$fieldName}_value", $this->_params);
+ if (is_array($value) && !empty($value)) {
+ return "(month({$field['dbAlias']}) $op (" . implode(', ', $value) .
+ '))';
+ }
+ }
+ else {
+ $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
+ $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
+ $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
+ $fromTime = CRM_Utils_Array::value("{$fieldName}_from_time", $this->_params);
+ $toTime = CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params);
+ return $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type'], $fromTime, $toTime);
+ }
+ }
+ else {
+ $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
+ if ($op) {
+ return $this->whereClause($field,
+ $op,
+ CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
+ CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
+ CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
+ );
+ }
+ }
+ return '';
+ }
+
}
),
),
),
- 'civicrm_group' => array(
- 'dao' => 'CRM_Contact_DAO_Group',
- 'alias' => 'cgroup',
- 'filters' => array(
- 'gid' => array(
- 'name' => 'group_id',
- 'title' => ts('Group'),
- 'type' => CRM_Utils_Type::T_INT,
- 'group' => TRUE,
- 'operatorType' => CRM_Report_Form::OP_MULTISELECT,
- 'options' => CRM_Core_PseudoConstant::staticGroup(),
- ),
- ),
- ),
);
+ $this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
parent::__construct();
}
SELECT civicrm_contact_id, civicrm_contact_sort_name, civicrm_contribution_total_amount, civicrm_contribution_currency
FROM civireport_contribution_detail_temp2
WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribution_id']}";
- $this->addToDeveloperTab($query);
$dao = CRM_Core_DAO::executeQuery($query);
$string = '';
$separator = ($this->_outputMode !== 'csv') ? "<br/>" : ' ';
SELECT civicrm_contact_id, civicrm_contact_sort_name
FROM civireport_contribution_detail_temp1
WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribution_id']}";
- $this->addToDeveloperTab($query);
$dao = CRM_Core_DAO::executeQuery($query);
$string = '';
while ($dao->fetch()) {
/**
* The recommended PHP version.
*/
- const RECOMMENDED_PHP_VER = '7.0';
+ const RECOMMENDED_PHP_VER = '7.1';
/**
* The previous recommended PHP version.
*/
- const MIN_RECOMMENDED_PHP_VER = '5.6';
+ const MIN_RECOMMENDED_PHP_VER = '7.0';
/**
* The minimum PHP version required to install Civi.
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2017 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License along with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Upgrade logic for FiveSix */
+class CRM_Upgrade_Incremental_php_FiveSix extends CRM_Upgrade_Incremental_Base {
+
+ /**
+ * Compute any messages which should be displayed beforeupgrade.
+ *
+ * Note: This function is called iteratively for each upcoming
+ * revision to the database.
+ *
+ * @param string $preUpgradeMessage
+ * @param string $rev
+ * a version number, e.g. '4.4.alpha1', '4.4.beta3', '4.4.0'.
+ * @param null $currentVer
+ */
+ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
+ // Example: Generate a pre-upgrade message.
+ // if ($rev == '5.12.34') {
+ // $preUpgradeMessage .= '<p>' . ts('A new permission has been added called %1 This Permission is now used to control access to the Manage Tags screen', array(1 => 'manage tags')) . '</p>';
+ // }
+ }
+
+ /**
+ * Compute any messages which should be displayed after upgrade.
+ *
+ * @param string $postUpgradeMessage
+ * alterable.
+ * @param string $rev
+ * an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
+ */
+ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
+ // Example: Generate a post-upgrade message.
+ // if ($rev == '5.12.34') {
+ // $postUpgradeMessage .= '<br /><br />' . ts("By default, CiviCRM now disables the ability to import directly from SQL. To use this feature, you must explicitly grant permission 'import SQL datasource'.");
+ // }
+ }
+
+ /*
+ * Important! All upgrade functions MUST add a 'runSql' task.
+ * Uncomment and use the following template for a new upgrade version
+ * (change the x in the function name):
+ */
+
+ // /**
+ // * Upgrade function.
+ // *
+ // * @param string $rev
+ // */
+ // public function upgrade_5_0_x($rev) {
+ // $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
+ // $this->addTask('Do the foo change', 'taskFoo', ...);
+ // // Additional tasks here...
+ // // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex.
+ // // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable.
+ // }
+
+ // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) {
+ // return TRUE;
+ // }
+
+}
--- /dev/null
+{* file to handle db changes in 5.6.alpha1 during upgrade *}
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $id, 'is_active', $is_active);
* @param bool $is_active
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
- *
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $is_active) {
return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $id, 'is_active', $is_active);
* @param bool $isActive
* Value we want to set the is_active field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsActive($id, $isActive) {
return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $id, 'is_active', $isActive);
* @param bool $isQuickConfig we want to set the is_quick_config field.
* Value we want to set the is_quick_config field.
*
- * @return Object
- * DAO object on success, null otherwise
+ * @return bool
+ * true if we found and updated the object, else false
*/
public static function setIsQuickConfig($id, $isQuickConfig) {
return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $id, 'is_quick_config', $isQuickConfig);
elseif (version_compare($phpVersion, CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER) >= 0) {
$messages[] = new CRM_Utils_Check_Message(
__FUNCTION__,
- ts('This system uses PHP version %1. This meets the minimum requirements for CiviCRM to function but is not recommended. At least PHP version %2 is recommended; the preferrred version is %3.',
+ ts('This system uses PHP version %1. This meets the minimum requirements for CiviCRM to function but is not recommended. At least PHP version %2 is recommended; the preferred version is %3.',
array(
1 => $phpVersion,
2 => CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER,
* The name of an atomic permission, ie. 'access deleted contacts'
* @param bool $granted
* Whether this permission is currently granted. The hook can change this value.
+ * @param int $contactId
+ * Contact whose permissions we are checking (if null, assume current user).
*
* @return null
* The return value is ignored
*/
- public static function permission_check($permission, &$granted) {
- return self::singleton()->invoke(array('permission', 'granted'), $permission, $granted,
- self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
+ public static function permission_check($permission, &$granted, $contactId) {
+ return self::singleton()->invoke(array('permission', 'granted', 'contactId'), $permission, $granted, $contactId,
+ self::$_nullObject, self::$_nullObject, self::$_nullObject,
'civicrm_permission_check'
);
}
}
}
+ /**
+ * Append Drupal7 js to coreResourcesList.
+ *
+ * @param array $list
+ */
+ public function appendCoreResources(&$list) {
+ $list[] = 'js/crm.drupal7.js';
+ }
+
}
return \Drupal::languageManager()->getCurrentLanguage()->getId();
}
+ /**
+ * Append Drupal8 js to coreResourcesList.
+ *
+ * @param array $list
+ */
+ public function appendCoreResources(&$list) {
+ $list[] = 'js/crm.drupal8.js';
+ }
+
}
_drupal_flush_css_js();
}
- /**
- * Append Drupal js to coreResourcesList.
- *
- * @param array $list
- */
- public function appendCoreResources(&$list) {
- $list[] = 'js/crm.drupal.js';
- }
-
/**
* @inheritDoc
*/
define('JDEBUG', FALSE);
}
+ // Set timezone for Joomla on Cron
+ $config = JFactory::getConfig();
+ $timezone = $config->get('offset');
+ if ($timezone) {
+ date_default_timezone_set($timezone);
+ CRM_Core_Config::singleton()->userSystem->setMySQLTimeZone();
+ }
+
// CRM-14281 Joomla wasn't available during bootstrap, so hook_civicrm_config never executes.
$config = CRM_Core_Config::singleton();
CRM_Utils_Hook::config($config);
// less randomly.
\CRM_Utils_Hook::tokenValues($contactArray,
(array) $contactId,
- empty($row->context['mailingJob']) ? NULL : $row->context['mailingJob']->id,
+ empty($row->context['mailingJobId']) ? NULL : $row->context['mailingJobId'],
$messageTokens,
$row->context['controller']
);
$params['payment_processor_type_id']['api.required'] = 1;
$params['is_default']['api.default'] = 0;
$params['is_test']['api.default'] = 0;
+ $params['domain_id']['api.default'] = CRM_Core_Config::domainID();
}
/**
$params['class_name']['api.required'] = 1;
$params['is_active']['api.default'] = 1;
$params['is_recur']['api.default'] = FALSE;
- // FIXME bool support // $params['is_recur']['api.required'] = 1;
$params['name']['api.required'] = 1;
$params['title']['api.required'] = 1;
$params['payment_instrument_id']['api.default'] = 'Credit Card';
"require": {
"dompdf/dompdf" : "0.8.*",
"electrolinux/phpquery": "^0.9.6",
- "symfony/config": "^2.6.13 || ~3.0",
- "symfony/dependency-injection": "^2.6.13 || ~3.0",
- "symfony/event-dispatcher": "^2.6.13 || ~3.0",
- "symfony/filesystem": "^2.6.13 || ~3.0",
- "symfony/process": "^2.6.13 || ~3.0",
+ "symfony/config": "^2.8.44 || ~3.0",
+ "symfony/polyfill-iconv": "~1.0",
+ "symfony/dependency-injection": "^2.8.44 || ~3.0",
+ "symfony/event-dispatcher": "^2.8.44 || ~3.0",
+ "symfony/filesystem": "^2.8.44 || ~3.0",
+ "symfony/process": "^2.8.44 || ~3.0",
"psr/log": "~1.0.0",
- "symfony/finder": "^2.6.13 || ~3.0",
+ "symfony/finder": "^2.8.44 || ~3.0",
"tecnickcom/tcpdf" : "6.2.*",
"totten/ca-config": "~17.05",
"zetacomponents/base": "1.7.*",
{
"_readme": [
"This file locks the dependencies of your project to a known state",
- "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "233f9c457d9e7d49a6d96c356e1035f1",
+ "content-hash": "38f5450ab72f881008f5cd10bb588b6f",
"packages": [
{
"name": "civicrm/civicrm-cxn-rpc",
"extra": {
"branch-alias": {
"dev-develop": "0.7-dev"
+ },
+ "patches_applied": {
+ "Fix Fatal error: Uncaught Dompdf Exception: No block-level parent found.": "tools/scripts/composer/patches/dompdf_no_block_level_parent_fix.patch"
}
},
"autoload": {
"pear/auth_sasl": "Install optionally via your project's composer.json"
},
"type": "library",
+ "extra": {
+ "patches_applied": {
+ "CRM-8744 Display CiviCRM Specific error message": "tools/scripts/composer/patches/net-smtp-patch.patch",
+ "Fix PHP7 Compliance": "tools/scripts/composer/patches/net-smtp-php7-patch.patch",
+ "Fix Pass by reference issues": "tools/scripts/composer/patches/net-smtp-ref-patch.patch",
+ "Fix TLS support issue in PHP5.6": "tools/scripts/composer/patches/net-smtp-tls-patch.patch"
+ }
+ },
"autoload": {
"psr-0": {
"Net": "./"
},
{
"name": "symfony/config",
- "version": "v2.6.13",
- "target-dir": "Symfony/Component/Config",
+ "version": "v2.8.44",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
- "reference": "0ca496cbe208fc37c4cf3415ebb3056e0963115b"
+ "reference": "06c0be4cdd8363f3ec8d592c9a4d1b981d5052af"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/config/zipball/0ca496cbe208fc37c4cf3415ebb3056e0963115b",
- "reference": "0ca496cbe208fc37c4cf3415ebb3056e0963115b",
+ "url": "https://api.github.com/repos/symfony/config/zipball/06c0be4cdd8363f3ec8d592c9a4d1b981d5052af",
+ "reference": "06c0be4cdd8363f3ec8d592c9a4d1b981d5052af",
"shasum": ""
},
"require": {
- "php": ">=5.3.3",
- "symfony/filesystem": "~2.3"
+ "php": ">=5.3.9",
+ "symfony/filesystem": "~2.3|~3.0.0",
+ "symfony/polyfill-ctype": "~1.8"
},
"require-dev": {
- "symfony/phpunit-bridge": "~2.7"
+ "symfony/yaml": "~2.7|~3.0.0"
+ },
+ "suggest": {
+ "symfony/yaml": "To use the yaml reference dumper"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.8-dev"
}
},
"autoload": {
- "psr-0": {
+ "psr-4": {
"Symfony\\Component\\Config\\": ""
- }
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
- "time": "2015-07-08T05:59:48+00:00"
+ "time": "2018-07-26T11:13:39+00:00"
},
{
"name": "symfony/dependency-injection",
- "version": "v2.6.13",
- "target-dir": "Symfony/Component/DependencyInjection",
+ "version": "v2.8.44",
"source": {
"type": "git",
"url": "https://github.com/symfony/dependency-injection.git",
- "reference": "d9fe6837d74aed11e5ee741cd6b6dfe45e0af78e"
+ "reference": "ad2446d39d11c3daaa7f147d957941a187e47357"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/d9fe6837d74aed11e5ee741cd6b6dfe45e0af78e",
- "reference": "d9fe6837d74aed11e5ee741cd6b6dfe45e0af78e",
+ "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/ad2446d39d11c3daaa7f147d957941a187e47357",
+ "reference": "ad2446d39d11c3daaa7f147d957941a187e47357",
"shasum": ""
},
"require": {
- "php": ">=5.3.3"
+ "php": ">=5.3.9"
},
"conflict": {
"symfony/expression-language": "<2.6"
},
"require-dev": {
- "symfony/config": "~2.2",
- "symfony/expression-language": "~2.6",
- "symfony/phpunit-bridge": "~2.7",
- "symfony/yaml": "~2.1"
+ "symfony/config": "~2.2|~3.0.0",
+ "symfony/expression-language": "~2.6|~3.0.0",
+ "symfony/yaml": "~2.3.42|~2.7.14|~2.8.7|~3.0.7"
},
"suggest": {
"symfony/config": "",
+ "symfony/expression-language": "For using expressions in service container configuration",
"symfony/proxy-manager-bridge": "Generate service proxies to lazy load them",
"symfony/yaml": ""
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.8-dev"
}
},
"autoload": {
- "psr-0": {
+ "psr-4": {
"Symfony\\Component\\DependencyInjection\\": ""
- }
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
],
"description": "Symfony DependencyInjection Component",
"homepage": "https://symfony.com",
- "time": "2015-07-22T10:08:40+00:00"
+ "time": "2018-07-26T11:13:39+00:00"
},
{
"name": "symfony/event-dispatcher",
- "version": "v2.6.13",
- "target-dir": "Symfony/Component/EventDispatcher",
+ "version": "v2.8.44",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
- "reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02"
+ "reference": "84ae343f39947aa084426ed1138bb96bf94d1f12"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/672593bc4b0043a0acf91903bb75a1c82d8f2e02",
- "reference": "672593bc4b0043a0acf91903bb75a1c82d8f2e02",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/84ae343f39947aa084426ed1138bb96bf94d1f12",
+ "reference": "84ae343f39947aa084426ed1138bb96bf94d1f12",
"shasum": ""
},
"require": {
- "php": ">=5.3.3"
+ "php": ">=5.3.9"
},
"require-dev": {
"psr/log": "~1.0",
- "symfony/config": "~2.0,>=2.0.5",
- "symfony/dependency-injection": "~2.6",
- "symfony/expression-language": "~2.6",
- "symfony/phpunit-bridge": "~2.7",
- "symfony/stopwatch": "~2.3"
+ "symfony/config": "^2.0.5|~3.0.0",
+ "symfony/dependency-injection": "~2.6|~3.0.0",
+ "symfony/expression-language": "~2.6|~3.0.0",
+ "symfony/stopwatch": "~2.3|~3.0.0"
},
"suggest": {
"symfony/dependency-injection": "",
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.8-dev"
}
},
"autoload": {
- "psr-0": {
+ "psr-4": {
"Symfony\\Component\\EventDispatcher\\": ""
- }
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
- "time": "2015-05-02T15:18:45+00:00"
+ "time": "2018-07-26T09:03:18+00:00"
},
{
"name": "symfony/filesystem",
- "version": "v2.6.13",
- "target-dir": "Symfony/Component/Filesystem",
+ "version": "v2.8.44",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
- "reference": "823c035b1a5c13a4924e324d016eb07e70f94735"
+ "reference": "2d6a4deccdfa2e4e9f113138b93457b2d0886c15"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/filesystem/zipball/823c035b1a5c13a4924e324d016eb07e70f94735",
- "reference": "823c035b1a5c13a4924e324d016eb07e70f94735",
+ "url": "https://api.github.com/repos/symfony/filesystem/zipball/2d6a4deccdfa2e4e9f113138b93457b2d0886c15",
+ "reference": "2d6a4deccdfa2e4e9f113138b93457b2d0886c15",
"shasum": ""
},
"require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "symfony/phpunit-bridge": "~2.7"
+ "php": ">=5.3.9",
+ "symfony/polyfill-ctype": "~1.8"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.8-dev"
}
},
"autoload": {
- "psr-0": {
+ "psr-4": {
"Symfony\\Component\\Filesystem\\": ""
- }
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
- "time": "2015-07-08T05:59:48+00:00"
+ "time": "2018-07-26T11:13:39+00:00"
},
{
"name": "symfony/finder",
- "version": "v2.6.13",
- "target-dir": "Symfony/Component/Finder",
+ "version": "v2.8.44",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
- "reference": "203a10f928ae30176deeba33512999233181dd28"
+ "reference": "f0de0b51913eb2caab7dfed6413b87e14fca780e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/finder/zipball/203a10f928ae30176deeba33512999233181dd28",
- "reference": "203a10f928ae30176deeba33512999233181dd28",
+ "url": "https://api.github.com/repos/symfony/finder/zipball/f0de0b51913eb2caab7dfed6413b87e14fca780e",
+ "reference": "f0de0b51913eb2caab7dfed6413b87e14fca780e",
"shasum": ""
},
"require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "symfony/phpunit-bridge": "~2.7"
+ "php": ">=5.3.9"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "2.8-dev"
}
},
"autoload": {
- "psr-0": {
+ "psr-4": {
"Symfony\\Component\\Finder\\": ""
- }
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
- "time": "2015-07-09T16:02:48+00:00"
+ "time": "2018-07-26T11:13:39+00:00"
},
{
- "name": "symfony/process",
- "version": "v2.6.13",
- "target-dir": "Symfony/Component/Process",
+ "name": "symfony/polyfill-ctype",
+ "version": "v1.8.0",
"source": {
"type": "git",
- "url": "https://github.com/symfony/process.git",
- "reference": "57f1e88bb5dafa449b83f9f265b11d52d517b3e9"
+ "url": "https://github.com/symfony/polyfill-ctype.git",
+ "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/process/zipball/57f1e88bb5dafa449b83f9f265b11d52d517b3e9",
- "reference": "57f1e88bb5dafa449b83f9f265b11d52d517b3e9",
+ "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
+ "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
- "require-dev": {
- "symfony/phpunit-bridge": "~2.7"
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.8-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Polyfill\\Ctype\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ },
+ {
+ "name": "Gert de Pagter",
+ "email": "BackEndTea@gmail.com"
+ }
+ ],
+ "description": "Symfony polyfill for ctype functions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "ctype",
+ "polyfill",
+ "portable"
+ ],
+ "time": "2018-04-30T19:57:29+00:00"
+ },
+ {
+ "name": "symfony/polyfill-iconv",
+ "version": "v1.9.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-iconv.git",
+ "reference": "bcc0cd69185b8a5d8b4a5400c489ed3333bf9bb2"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/bcc0cd69185b8a5d8b4a5400c489ed3333bf9bb2",
+ "reference": "bcc0cd69185b8a5d8b4a5400c489ed3333bf9bb2",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "suggest": {
+ "ext-iconv": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "2.6-dev"
+ "dev-master": "1.9-dev"
}
},
"autoload": {
- "psr-0": {
- "Symfony\\Component\\Process\\": ""
+ "psr-4": {
+ "Symfony\\Polyfill\\Iconv\\": ""
+ },
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
}
+ ],
+ "description": "Symfony polyfill for the Iconv extension",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "iconv",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "time": "2018-08-06T14:22:27+00:00"
+ },
+ {
+ "name": "symfony/process",
+ "version": "v2.8.44",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/process.git",
+ "reference": "cc83afdb5ac99147806b3bb65a3ff1227664f596"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/process/zipball/cc83afdb5ac99147806b3bb65a3ff1227664f596",
+ "reference": "cc83afdb5ac99147806b3bb65a3ff1227664f596",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.9"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.8-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Process\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
- "time": "2015-06-30T16:10:16+00:00"
+ "time": "2018-07-26T11:13:39+00:00"
},
{
"name": "tecnickcom/tcpdf",
}
#civicrm-menu {
- position:absolute;
+ position:fixed;
top:0;
left:0;
background:#1B1B1B repeat-x;
/* Moved from civicrm.css in v3.2 */
ul#civicrm-menu {
- z-index: 1;
position:relative;
- border: none;
- left:0px;
- height:0px;
- padding: 2px 0px 25px 2px !important;
- padding-bottom:25px !important; /*moz bottom */
- padding-bottom:2px; /*ie bottom */
}
div#toolbar-box div.m {
return combined;
}
- function copyAttributes($source, $target, attributes) {
+ CRM.utils.copyAttributes = function ($source, $target, attributes) {
_.each(attributes, function(name) {
if ($source.attr(name) !== undefined) {
$target.attr(name, $source.attr(name));
}
});
- }
-
- /**
- * @see http://wiki.civicrm.org/confluence/display/CRMDOC/crmDatepicker
- */
- $.fn.crmDatepicker = function(options) {
- return $(this).each(function() {
- if ($(this).is('.crm-form-date-wrapper .crm-hidden-date')) {
- // Already initialized - destroy
- $(this)
- .off('.crmDatepicker')
- .css('display', '')
- .removeClass('crm-hidden-date')
- .siblings().remove();
- $(this).unwrap();
- }
- if (options === 'destroy') {
- return;
- }
- var
- $dataField = $(this).wrap('<span class="crm-form-date-wrapper" />'),
- settings = _.cloneDeep(options || {}),
- $dateField = $(),
- $timeField = $(),
- $clearLink = $(),
- hasDatepicker = settings.date !== false && settings.date !== 'yy',
- type = hasDatepicker ? 'text' : 'number';
-
- if (settings.allowClear !== undefined ? settings.allowClear : !$dataField.is('.required, [required]')) {
- $clearLink = $('<a class="crm-hover-button crm-clear-link" title="'+ _.escape(ts('Clear')) +'"><i class="crm-i fa-times"></i></a>')
- .insertAfter($dataField);
- }
- if (settings.time !== false) {
- $timeField = $('<input>').insertAfter($dataField);
- copyAttributes($dataField, $timeField, ['class', 'disabled']);
- $timeField
- .addClass('crm-form-text crm-form-time')
- .attr('placeholder', $dataField.attr('time-placeholder') === undefined ? ts('Time') : $dataField.attr('time-placeholder'))
- .attr('aria-label', $dataField.attr('time-placeholder') === undefined ? ts('Time') : $dataField.attr('time-placeholder'))
- .change(updateDataField)
- .timeEntry({
- spinnerImage: '',
- show24Hours: settings.time === true || settings.time === undefined ? CRM.config.timeIs24Hr : settings.time == '24'
- });
- }
- if (settings.date !== false) {
- // Render "number" field for year-only format, calendar popup for all other formats
- $dateField = $('<input type="' + type + '">').insertAfter($dataField);
- copyAttributes($dataField, $dateField, ['placeholder', 'style', 'class', 'disabled', 'aria-label']);
- $dateField.addClass('crm-form-' + type);
- if (hasDatepicker) {
- settings.minDate = settings.minDate ? CRM.utils.makeDate(settings.minDate) : null;
- settings.maxDate = settings.maxDate ? CRM.utils.makeDate(settings.maxDate) : null;
- settings.dateFormat = typeof settings.date === 'string' ? settings.date : CRM.config.dateInputFormat;
- settings.changeMonth = _.includes(settings.dateFormat, 'm');
- settings.changeYear = _.includes(settings.dateFormat, 'y');
- if (!settings.yearRange && settings.minDate !== null && settings.maxDate !== null) {
- settings.yearRange = '' + CRM.utils.formatDate(settings.minDate, 'yy') + ':' + CRM.utils.formatDate(settings.maxDate, 'yy');
- }
- $dateField.addClass('crm-form-date').datepicker(settings);
- } else {
- $dateField.attr('min', settings.minDate ? CRM.utils.formatDate(settings.minDate, 'yy') : '1000');
- $dateField.attr('max', settings.maxDate ? CRM.utils.formatDate(settings.maxDate, 'yy') : '4000');
- }
- $dateField.change(updateDataField);
- }
- // Rudimentary validation. TODO: Roll into use of jQUery validate and ui.datepicker.validation
- function isValidDate() {
- // FIXME: parseDate doesn't work with incomplete date formats; skip validation if no month, day or year in format
- var lowerFormat = settings.dateFormat.toLowerCase();
- if (lowerFormat.indexOf('y') < 0 || lowerFormat.indexOf('m') < 0 || !dateHasDay()) {
- return true;
- }
- try {
- $.datepicker.parseDate(settings.dateFormat, $dateField.val());
- return true;
- } catch (e) {
- return false;
- }
- }
-
- /**
- * Does the date format contain the day.
- *
- * @returns {boolean}
- */
- function dateHasDay() {
- var lowerFormat = settings.dateFormat.toLowerCase();
- if (lowerFormat.indexOf('d') < 0) {
- return false;
- }
- return true;
- }
- function updateInputFields(e, context) {
- var val = $dataField.val(),
- time = null;
- if (context !== 'userInput' && context !== 'crmClear') {
- if (hasDatepicker) {
- $dateField.datepicker('setDate', _.includes(val, '-') ? $.datepicker.parseDate('yy-mm-dd', val) : null);
- } else if ($dateField.length) {
- $dateField.val(val.slice(0, 4));
- }
- if ($timeField.length) {
- if (val.length === 8) {
- time = val;
- } else if (val.length === 19) {
- time = val.split(' ')[1];
- }
- $timeField.timeEntry('setTime', time);
- }
- }
- $clearLink.css('visibility', val ? 'visible' : 'hidden');
- }
- function updateDataField(e, context) {
- // The crmClear event wipes all the field values anyway, so no need to respond
- if (context !== 'crmClear') {
- var val = '';
- if ($dateField.val()) {
- if (hasDatepicker && isValidDate() && dateHasDay()) {
- val = $.datepicker.formatDate('yy-mm-dd', $dateField.datepicker('getDate'));
- $dateField.removeClass('crm-error');
- } else if (!hasDatepicker) {
- val = $dateField.val() + '-01-01';
- }
- else if (!dateHasDay()) {
- // This would be a Year-month date (yyyy-mm)
- // it could be argued it should not use a datepicker....
- val = $dateField.val() + '-01';
- } else {
- $dateField.addClass('crm-error');
- }
- }
- if ($timeField.val()) {
- val += (val ? ' ' : '') + $timeField.timeEntry('getTime').toTimeString().substr(0, 8);
- }
- $dataField.val(val).trigger('change', ['userInput']);
- }
- }
- $dataField.hide().addClass('crm-hidden-date').on('change.crmDatepicker', updateInputFields);
- updateInputFields();
- });
};
CRM.utils.formatSelect2Result = function (row) {
--- /dev/null
+(function($, CRM, _) {
+ "use strict";
+
+ /**
+ * @see http://wiki.civicrm.org/confluence/display/CRMDOC/crmDatepicker
+ */
+ $.fn.crmDatepicker = function(options) {
+ return $(this).each(function() {
+ if ($(this).is('.crm-form-date-wrapper .crm-hidden-date')) {
+ // Already initialized - destroy
+ $(this)
+ .off('.crmDatepicker')
+ .css('display', '')
+ .removeClass('crm-hidden-date')
+ .siblings().remove();
+ $(this).unwrap();
+ }
+ if (options === 'destroy') {
+ return;
+ }
+ var
+ $dataField = $(this).wrap('<span class="crm-form-date-wrapper" />'),
+ settings = CRM._.cloneDeep(options || {}),
+ $dateField = $(),
+ $timeField = $(),
+ $clearLink = $(),
+ hasDatepicker = settings.date !== false && settings.date !== 'yy',
+ type = hasDatepicker ? 'text' : 'number';
+
+ if (settings.allowClear !== undefined ? settings.allowClear : !$dataField.is('.required, [required]')) {
+ $clearLink = $('<a class="crm-hover-button crm-clear-link" title="'+ CRM._.escape(ts('Clear')) +'"><i class="crm-i fa-times"></i></a>')
+ .insertAfter($dataField);
+ }
+ if (settings.time !== false) {
+ $timeField = $('<input>').insertAfter($dataField);
+ CRM.utils.copyAttributes($dataField, $timeField, ['class', 'disabled']);
+ $timeField
+ .addClass('crm-form-text crm-form-time')
+ .attr('placeholder', $dataField.attr('time-placeholder') === undefined ? ts('Time') : $dataField.attr('time-placeholder'))
+ .attr('aria-label', $dataField.attr('time-placeholder') === undefined ? ts('Time') : $dataField.attr('time-placeholder'))
+ .change(updateDataField)
+ .timeEntry({
+ spinnerImage: '',
+ show24Hours: settings.time === true || settings.time === undefined ? CRM.config.timeIs24Hr : settings.time == '24'
+ });
+ }
+ if (settings.date !== false) {
+ // Render "number" field for year-only format, calendar popup for all other formats
+ $dateField = $('<input type="' + type + '">').insertAfter($dataField);
+ CRM.utils.copyAttributes($dataField, $dateField, ['placeholder', 'style', 'class', 'disabled', 'aria-label']);
+ $dateField.addClass('crm-form-' + type);
+ if (hasDatepicker) {
+ settings.minDate = settings.minDate ? CRM.utils.makeDate(settings.minDate) : null;
+ settings.maxDate = settings.maxDate ? CRM.utils.makeDate(settings.maxDate) : null;
+ settings.dateFormat = typeof settings.date === 'string' ? settings.date : CRM.config.dateInputFormat;
+ settings.changeMonth = CRM._.includes(settings.dateFormat, 'm');
+ settings.changeYear = CRM._.includes(settings.dateFormat, 'y');
+ if (!settings.yearRange && settings.minDate !== null && settings.maxDate !== null) {
+ settings.yearRange = '' + CRM.utils.formatDate(settings.minDate, 'yy') + ':' + CRM.utils.formatDate(settings.maxDate, 'yy');
+ }
+ $dateField.addClass('crm-form-date').datepicker(settings);
+ } else {
+ $dateField.attr('min', settings.minDate ? CRM.utils.formatDate(settings.minDate, 'yy') : '1000');
+ $dateField.attr('max', settings.maxDate ? CRM.utils.formatDate(settings.maxDate, 'yy') : '4000');
+ }
+ $dateField.change(updateDataField);
+ }
+ // Rudimentary validation. TODO: Roll into use of jQUery validate and ui.datepicker.validation
+ function isValidDate() {
+ // FIXME: parseDate doesn't work with incomplete date formats; skip validation if no month, day or year in format
+ var lowerFormat = settings.dateFormat.toLowerCase();
+ if (lowerFormat.indexOf('y') < 0 || lowerFormat.indexOf('m') < 0 || !dateHasDay()) {
+ return true;
+ }
+ try {
+ $.datepicker.parseDate(settings.dateFormat, $dateField.val());
+ return true;
+ } catch (e) {
+ return false;
+ }
+ }
+
+ /**
+ * Does the date format contain the day.
+ *
+ * @returns {boolean}
+ */
+ function dateHasDay() {
+ var lowerFormat = settings.dateFormat.toLowerCase();
+ if (lowerFormat.indexOf('d') < 0) {
+ return false;
+ }
+ return true;
+ }
+ function updateInputFields(e, context) {
+ var val = $dataField.val(),
+ time = null;
+ if (context !== 'userInput' && context !== 'crmClear') {
+ if (hasDatepicker) {
+ $dateField.datepicker('setDate', CRM._.includes(val, '-') ? $.datepicker.parseDate('yy-mm-dd', val) : null);
+ } else if ($dateField.length) {
+ $dateField.val(val.slice(0, 4));
+ }
+ if ($timeField.length) {
+ if (val.length === 8) {
+ time = val;
+ } else if (val.length === 19) {
+ time = val.split(' ')[1];
+ }
+ $timeField.timeEntry('setTime', time);
+ }
+ }
+ $clearLink.css('visibility', val ? 'visible' : 'hidden');
+ }
+ function updateDataField(e, context) {
+ // The crmClear event wipes all the field values anyway, so no need to respond
+ if (context !== 'crmClear') {
+ var val = '';
+ if ($dateField.val()) {
+ if (hasDatepicker && isValidDate() && dateHasDay()) {
+ val = $.datepicker.formatDate('yy-mm-dd', $dateField.datepicker('getDate'));
+ $dateField.removeClass('crm-error');
+ } else if (!hasDatepicker) {
+ val = $dateField.val() + '-01-01';
+ }
+ else if (!dateHasDay()) {
+ // This would be a Year-month date (yyyy-mm)
+ // it could be argued it should not use a datepicker....
+ val = $dateField.val() + '-01';
+ } else {
+ $dateField.addClass('crm-error');
+ }
+ }
+ if ($timeField.val()) {
+ val += (val ? ' ' : '') + $timeField.timeEntry('getTime').toTimeString().substr(0, 8);
+ }
+ $dataField.val(val).trigger('change', ['userInput']);
+ }
+ }
+ $dataField.hide().addClass('crm-hidden-date').on('change.crmDatepicker', updateInputFields);
+ updateInputFields();
+ });
+ };
+})(jQuery, CRM, CRM._);
// D7 hack, restore toolbar position (CRM-15341)
$('#toolbar').css('z-index', '');
}
- })
- // d8 Hack to hide title when it should be (CRM-19960)
- .ready(function() {
- var pageTitle = $('.page-title');
- var title = $('.page-title').text();
- if ('<span id="crm-remove-title" style="display:none">CiviCRM</span>' == title) {
- pageTitle.hide();
- }
- });
+ });
+ $('#civicrm-menu').css({'width': '97%'});
});
--- /dev/null
+// http://civicrm.org/licensing
+CRM.$(function($) {
+ // d8 Hack to hide title when it should be (CRM-19960)
+ var pageTitle = $('.page-title');
+ if ('<span id="crm-remove-title" style="display:none">CiviCRM</span>' == pageTitle.text()) {
+ pageTitle.hide();
+ }
+
+ $('#toolbar-bar').hide();
+
+ $('.crm-hidemenu').click(function(e) {
+ $('#toolbar-bar').slideDown();
+ });
+ $('#crm-notification-container').on('click', '#crm-restore-menu', function() {
+ $('#toolbar-bar').slideUp();
+ });
+});
'bower_components/jquery-validation/dist/jquery.validate.min.js',
'packages/jquery/plugins/jquery.timeentry.js',
'js/Common.js',
+ 'js/crm.datepicker.js',
'bower_components/angular/angular.js',
'js/crm.angular.js',
angularTempFile,
LOCK TABLES `civicrm_domain` WRITE;
/*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */;
-INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.5.beta1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
+INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.6.alpha1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
/*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */;
UNLOCK TABLES;
<table class="form-layout-compressed">
{foreach from=$caseRoles.client item=client}
<tr class="crm-case-caseview-display_name">
- <td class="label-left bold" style="padding: 0px; border: none;">{$client.display_name}</td>
+ <td class="label-left bold" style="padding: 0px; border: none;">
+ <a href="{crmURL p='civicrm/contact/view' q="action=view&reset=1&cid=`$client.contact_id`"}" title="{ts}View contact record{/ts}">{$client.display_name}</a>
+ </td>
</tr>
{if $client.phone}
<tr class="crm-case-caseview-phone">
<div id="report-tab-set-developer" class="civireport-criteria">
- <p><b>{ts}Class used{/ts}: {$report_class}</b></p>
+ <p><b>{ts}Class used{/ts}: {$report_class|escape}</b></p>
+ <p>{ts}SQL Modes{/ts}:
+ {foreach from=$sqlModes item=sqlMode}
+ {$sqlMode|escape}
+ {/foreach}
+ </p>
<pre>{$sql|purify}</pre>
</div>
{/strip}{/capture}// <script> Generated {$smarty.now|date_format:'%d %b %Y %H:%M:%S'}
{literal}
(function($) {
- var menuMarkup = {/literal}{$menuMarkup|@json_encode};
-{if $config->userFramework neq 'Joomla'}{literal}
- $('body').append(menuMarkup);
-
- $('#civicrm-menu').css({position: "fixed", top: "0px"});
+ var menuMarkup = {/literal}{$menuMarkup|@json_encode}{literal};
//Track Scrolling
- $(window).scroll(function () {
- $('div.sticky-header').css({top: $('#civicrm-menu').height() + "px", position: "fixed"});
- });
-
- if ($('#edit-shortcuts').length > 0) {
- $('#civicrm-menu').css({'width': '97%'});
+ if ($('div.sticky-header').length) {
+ $(window).scroll(function () {
+ $('div.sticky-header').css({top: $('#civicrm-menu').height() + "px", position: "fixed"});
+ });
}
-{/literal}{else}{* Special menu hacks for Joomla *}{literal}
- // below div is present in older version of joomla 2.5.x
- var elementExists = $('div#toolbar-box div.m').length;
- if (elementExists > 0) {
+
+ if ($('div#toolbar-box div.m').length) {
$('div#toolbar-box div.m').html(menuMarkup);
}
- else {
+ else if ($("#crm-nav-menu-container").length) {
$("#crm-nav-menu-container").html(menuMarkup).css({'padding-bottom': '10px'});
}
-{/literal}{/if}{literal}
+ else {
+ $('body').append(menuMarkup);
+ }
+
// CRM-15493 get the current qfKey
$("input[name=qfKey]", "#quickSearch").val($('#civicrm-navigation-menu').data('qfkey'));
*/
public function testHardLocks() {
$hardLocks = array(
- 'symfony/config' => '/^v2\.6\./',
- 'symfony/dependency-injection' => '/^v2\.6\./',
- 'symfony/event-dispatcher' => '/^v2\.6\./',
- 'symfony/filesystem' => '/^v2\.6\./',
- 'symfony/finder' => '/^v2\.6\./',
- 'symfony/process' => '/^v2\.6\./',
+ 'symfony/config' => '/^v2\.8\./',
+ 'symfony/dependency-injection' => '/^v2\.8\./',
+ 'symfony/event-dispatcher' => '/^v2\.8\./',
+ 'symfony/filesystem' => '/^v2\.8\./',
+ 'symfony/finder' => '/^v2\.8\./',
+ 'symfony/process' => '/^v2\.8\./',
);
$lockFile = Civi::paths()->getPath('[civicrm.root]/composer.lock');
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Class CRM_Event_BAO_EventPermissionsTest
+ * @group headless
+ */
+class CRM_Event_BAO_EventPermissionsTest extends CiviUnitTestCase {
+
+ public function setUp() {
+ parent::setUp();
+ $this->_contactId = $this->createLoggedInUser();
+ $event = $this->eventCreate(array(
+ 'created_id' => $this->_contactId,
+ ));
+ $this->_eventId = $event['id'];
+ }
+
+ public function testEditOwnEvent() {
+ CRM_Core_Config::singleton()->userPermissionTemp = ['access civievent', 'access CiviCRM', 'view event info'];
+ unset(\Civi::$statics['CRM_Event_BAO_Event']['permissions']);
+ $permissions = CRM_Event_BAO_Event::checkPermission($this->_eventId, CRM_Core_Permission::EDIT);
+ $this->assertTrue($permissions);
+ }
+
+}
['Individual', 'city', ''],
['Individual', 'state_province', ''],
];
- list($tableName) = CRM_Export_BAO_Export::exportComponents(
+ list($tableName, $sqlColumns, $headerRows) = CRM_Export_BAO_Export::exportComponents(
FALSE,
$this->contactIDs,
[],
$this->assertEquals($householdID, $dao->civicrm_primary_id);
}
+ $this->assertEquals([
+ 0 => 'City',
+ 1 => 'State',
+ 2 => 'Household ID',
+ ], $headerRows);
+ $this->assertEquals(
+ [
+ 'city' => 'city varchar(64)',
+ 'state_province' => 'state_province varchar(64)',
+ 'civicrm_primary_id' => 'civicrm_primary_id varchar(16)',
+ ], $sqlColumns);
}
/**
}
/**
- * CRM-21656: Test the submit function of the membership form if Sale Tax is enabled.
- * Check that the tax rate isn't reapplied to line item's unit price and total amount
+ * CRM-21656: Test the submit function of the membership form if Sales Tax is enabled.
+ * This test simulates what happens when one hits Edit on a Contribution that has both LineItems and Sales Tax components
+ * Without making any Edits -> check that the LineItem data remain the same
+ * In addition (a data-integrity check) -> check that the LineItem data add up to the data at the Contribution level
*/
- public function testLineItemAmountOnSaleTax() {
+ public function testLineItemAmountOnSalesTax() {
$this->enableTaxAndInvoicing();
$this->relationForFinancialTypeWithFinancialAccount(2);
$form = $this->getForm();
$this->createLoggedInUser();
$priceSet = $this->callAPISuccess('PriceSet', 'Get', array("extends" => "CiviMember"));
$form->set('priceSetId', $priceSet['id']);
+ // we are simulating the creation of a Price Set in Administer -> CiviContribute -> Manage Price Sets so set is_quick_config = 0
+ $this->callAPISuccess('PriceSet', 'Create', array("id" => $priceSet['id'], 'is_quick_config' => 0));
// clean the price options static variable to repopulate the options, in order to fetch tax information
\Civi::$statics['CRM_Price_BAO_PriceField']['priceOptions'] = NULL;
CRM_Price_BAO_PriceSet::buildPriceSet($form);
),
CRM_Core_Action::UPDATE);
- // ensure that the line-item values got unaffected
+ // ensure that the LineItem data remain the same
$lineItem = $this->callAPISuccessGetSingle('LineItem', array('entity_id' => $membership['id'], 'entity_table' => 'civicrm_membership'));
$this->assertEquals(1, $lineItem['qty']);
- $this->assertEquals(5.00, $lineItem['tax_amount']); // ensure that tax amount is not changed
+ $this->assertEquals(50.00, $lineItem['unit_price']);
+ $this->assertEquals(50.00, $lineItem['line_total']);
+ $this->assertEquals(5.00, $lineItem['tax_amount']);
+
+ // ensure that the LineItem data add up to the data at the Contribution level
+ $contribution = $this->callAPISuccessGetSingle('Contribution',
+ array(
+ 'contribution_id' => 1,
+ 'return' => array('tax_amount', 'total_amount'),
+ )
+ );
+ $this->assertEquals($contribution['total_amount'], $lineItem['line_total'] + $lineItem['tax_amount']);
+ $this->assertEquals($contribution['tax_amount'], $lineItem['tax_amount']);
+
+ $financialItems = $this->callAPISuccess('FinancialItem', 'get', array());
+ $financialItems_sum = 0;
+ foreach ($financialItems['values'] as $financialItem) {
+ $financialItems_sum += $financialItem['amount'];
+ }
+ $this->assertEquals($contribution['total_amount'], $financialItems_sum);
// reset the price options static variable so not leave any dummy data, that might hamper other unit tests
\Civi::$statics['CRM_Price_BAO_PriceField']['priceOptions'] = NULL;
<?xml version="1.0" encoding="iso-8859-1" ?>
<version>
- <version_no>5.5.beta1</version_no>
+ <version_no>5.6.alpha1</version_no>
</version>