本文整理汇总了PHP中CRM_Utils_Array::key方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Array::key方法的具体用法?PHP CRM_Utils_Array::key怎么用?PHP CRM_Utils_Array::key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Array
的用法示例。
在下文中一共展示了CRM_Utils_Array::key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hrvisa_civicrm_install
/**
* Implementation of hook_civicrm_install
*/
function hrvisa_civicrm_install()
{
if (!CRM_Core_OptionGroup::getValue('activity_type', 'Visa Expiration', 'name')) {
// create activity_type 'Visa Expiration'
$params = array('weight' => 1, 'label' => 'Visa Expiration', 'filter' => 0, 'is_active' => 1, 'is_default' => 0);
$result = civicrm_api3('activity_type', 'create', $params);
if (CRM_Utils_Array::value('is_error', $result, FALSE)) {
CRM_Core_Error::debug_var("Failed to create activity type 'Visa Expiration'", $result);
throw new CRM_Core_Exception('Failed to create activity type \'Visa Expiration\'');
}
$activityTypeId = $result['values'][$result['id']]['value'];
} else {
$activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Visa Expiration', 'name');
}
// set weekly reminder for Visa Expiration activities (not active)
// will be active when extension is enabled
if (!empty($activityTypeId)) {
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
// schedule reminder for Visa Expiration Creation
$result = civicrm_api3('action_schedule', 'get', array('name' => 'Visa Expiration Reminder'));
if (empty($result['id'])) {
$params = array('name' => 'Visa Expiration Reminder', 'title' => 'Visa Expiration Reminder', 'recipient' => $targetID, 'limit_to' => 1, 'entity_value' => $activityTypeId, 'entity_status' => CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled', 'name'), 'start_action_offset' => 1, 'start_action_unit' => 'week', 'start_action_condition' => 'before', 'start_action_date' => 'activity_date_time', 'is_repeat' => 0, 'is_active' => 0, 'body_html' => '<p>Your latest visa expiries on {activity.activity_date_time}</p>', 'subject' => 'Reminder for Visa Expiration', 'record_activity' => 1, 'mapping_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionMapping', 'activity_type', 'id', 'entity_value'));
$result = civicrm_api3('action_schedule', 'create', $params);
}
}
return _hrvisa_civix_civicrm_install();
}
示例2: preProcess
/**
* Build all the data structures needed to build the form.
*/
public function preProcess()
{
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
// this mean it's a batch action
if (!$this->_id) {
if (!empty($_GET['batch_id'])) {
// validate batch ids
$batchIds = explode(',', $_GET['batch_id']);
foreach ($batchIds as $batchId) {
CRM_Utils_Type::validate($batchId, 'Positive');
}
$this->_batchIds = $_GET['batch_id'];
$this->set('batchIds', $this->_batchIds);
} else {
$this->_batchIds = $this->get('batchIds');
}
if (!empty($_GET['export_format']) && in_array($_GET['export_format'], array('IIF', 'CSV'))) {
$this->_exportFormat = $_GET['export_format'];
}
} else {
$this->_batchIds = $this->_id;
}
$allBatchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id');
$this->_exportStatusId = CRM_Utils_Array::key('Exported', $allBatchStatus);
// check if batch status is valid, do not allow exported batches to export again
$batchStatus = CRM_Batch_BAO_Batch::getBatchStatuses($this->_batchIds);
foreach ($batchStatus as $batchStatusId) {
if ($batchStatusId == $this->_exportStatusId) {
CRM_Core_Error::fatal(ts('You cannot exported the batches which were exported earlier.'));
}
}
$session = CRM_Core_Session::singleton();
$session->replaceUserContext(CRM_Utils_System::url('civicrm/financial/financialbatches', "reset=1&batchStatus={$this->_exportStatusId}"));
}
示例3: setDefaultValues
/**
* Set defaults for the form.
*
* @return array
*/
public function setDefaultValues()
{
$defaults = parent::setDefaultValues();
if (!empty($defaults['preferred_language'])) {
$languages = CRM_Contact_BAO_Contact::buildOptions('preferred_language');
$defaults['preferred_language'] = CRM_Utils_Array::key($defaults['preferred_language'], $languages);
}
// CRM-7119: set preferred_language to default if unset
if (empty($defaults['preferred_language'])) {
$config = CRM_Core_Config::singleton();
$defaults['preferred_language'] = $config->lcMessages;
}
// CRM-19135: where CRM_Core_BAO_Contact::getValues() set label as a default value instead of reserved 'value',
// the code is to ensure we always set default to value instead of label
if (!empty($defaults['preferred_mail_format'])) {
$defaults['preferred_mail_format'] = array_search($defaults['preferred_mail_format'], CRM_Core_SelectValues::pmf());
}
if (empty($defaults['communication_style_id'])) {
$defaults['communication_style_id'] = array_pop(CRM_Core_OptionGroup::values('communication_style', TRUE, NULL, NULL, 'AND is_default = 1'));
}
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
$name = "{$greeting}_display";
$this->assign($name, CRM_Utils_Array::value($name, $defaults));
}
return $defaults;
}
示例4: __construct
/**
* Class constructor.
*/
public function __construct()
{
// don’t display the ‘Add these Contacts to Group’ button
$this->_add2groupSupported = FALSE;
$dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
$this->loggingDB = $dsn['database'];
// used for redirect back to contact summary
$this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$this->_logTables = array('log_civicrm_contact' => array('fk' => 'id'), 'log_civicrm_email' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_phone' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_address' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_note' => array('fk' => 'entity_id', 'entity_table' => TRUE, 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject')), 'log_civicrm_note_comment' => array('fk' => 'entity_id', 'table_name' => 'log_civicrm_note', 'joins' => array('table' => 'log_civicrm_note', 'join' => "entity_log_civireport.entity_id = fk_table.id AND entity_log_civireport.entity_table = 'civicrm_note'"), 'entity_table' => TRUE, 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject')), 'log_civicrm_group_contact' => array('fk' => 'contact_id', 'bracket_info' => array('entity_column' => 'group_id', 'table' => 'log_civicrm_group', 'column' => 'title'), 'action_column' => 'status', 'log_type' => 'Group'), 'log_civicrm_entity_tag' => array('fk' => 'entity_id', 'bracket_info' => array('entity_column' => 'tag_id', 'table' => 'log_civicrm_tag', 'column' => 'name'), 'entity_table' => TRUE), 'log_civicrm_relationship' => array('fk' => 'contact_id_a', 'bracket_info' => array('entity_column' => 'relationship_type_id', 'table' => 'log_civicrm_relationship_type', 'column' => 'label_a_b')), 'log_civicrm_activity_for_target' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "(entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$targetID})"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_activity_for_assignee' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$assigneeID}"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_activity_for_source' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$sourceID}"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_case' => array('fk' => 'contact_id', 'joins' => array('table' => 'log_civicrm_case_contact', 'join' => 'entity_log_civireport.id = fk_table.case_id'), 'bracket_info' => array('entity_column' => 'case_type_id', 'options' => CRM_Case_PseudoConstant::caseType('title', FALSE))));
$logging = new CRM_Logging_Schema();
// build _logTables for contact custom tables
$customTables = $logging->entityCustomDataLogTables('Contact');
foreach ($customTables as $table) {
$this->_logTables[$table] = array('fk' => 'entity_id', 'log_type' => 'Contact');
}
// build _logTables for address custom tables
$customTables = $logging->entityCustomDataLogTables('Address');
foreach ($customTables as $table) {
$this->_logTables[$table] = array('fk' => 'contact_id', 'joins' => array('table' => 'log_civicrm_address', 'join' => 'entity_log_civireport.entity_id = fk_table.id'), 'log_type' => 'Contact');
}
// Allow log tables to be extended via report hooks.
CRM_Report_BAO_Hook::singleton()->alterLogTables($this, $this->_logTables);
parent::__construct();
}
示例5: postProcess
function postProcess()
{
$session = CRM_Core_Session::singleton();
$params = $this->exportValues();
$result = civicrm_api3('OptionValue', 'create', array('value' => $params['hour_value'], 'id' => CRM_Utils_Array::key($params['hour_type_select'], $this->_id)));
$session->pushUserContext(CRM_Utils_System::url('civicrm/hour/editoption', "&value={$params['hour_value']}"));
}
示例6: diffsInTable
function diffsInTable($table, $contactID = null)
{
$diffs = array();
$params = array(1 => array($this->log_conn_id, 'Integer'), 2 => array($this->log_date, 'String'));
$logging = new CRM_Logging_Schema();
$addressCustomTables = $logging->entityCustomDataLogTables('Address');
$contactIdClause = $join = '';
if ($contactID) {
$params[3] = array($contactID, 'Integer');
switch ($table) {
case 'civicrm_contact':
$contactIdClause = "AND id = %3";
break;
case 'civicrm_note':
$contactIdClause = "AND (( entity_id = %3 AND entity_table = 'civicrm_contact' ) OR (entity_id IN (SELECT note.id FROM `{$this->db}`.log_civicrm_note note WHERE note.entity_id = %3 AND note.entity_table = 'civicrm_contact') AND entity_table = 'civicrm_note'))";
break;
case 'civicrm_entity_tag':
$contactIdClause = "AND entity_id = %3 AND entity_table = 'civicrm_contact'";
break;
case 'civicrm_relationship':
$contactIdClause = "AND (contact_id_a = %3 OR contact_id_b = %3)";
break;
case 'civicrm_activity':
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$join = "\nLEFT JOIN civicrm_activity_contact at ON at.activity_id = lt.id AND at.contact_id = %3 AND at.record_type_id = {$targetID}\nLEFT JOIN civicrm_activity_contact aa ON aa.activity_id = lt.id AND aa.contact_id = %3 AND aa.record_type_id = {$assigneeID}\nLEFT JOIN civicrm_activity_contact source ON source.activity_id = lt.id AND source.contact_id = %3 AND source.record_type_id = {$sourceID} ";
$contactIdClause = "AND (at.id IS NOT NULL OR aa.id IS NOT NULL OR source.id IS NOT NULL)";
break;
case 'civicrm_case':
$contactIdClause = "AND id = (select case_id FROM civicrm_case_contact WHERE contact_id = %3 LIMIT 1)";
break;
default:
if (array_key_exists($table, $addressCustomTables)) {
$join = "INNER JOIN `{$this->db}`.`log_civicrm_address` et ON et.id = lt.entity_id";
$contactIdClause = "AND contact_id = %3";
break;
}
// allow tables to be extended by report hook query objects
list($contactIdClause, $join) = CRM_Report_BAO_Hook::singleton()->logDiffClause($this, $table);
if (empty($contactIdClause)) {
$contactIdClause = "AND contact_id = %3";
}
if (strpos($table, 'civicrm_value') !== false) {
$contactIdClause = "AND entity_id = %3";
}
}
}
// find ids in this table that were affected in the given connection (based on connection id and a ±10 s time period around the date)
$sql = "\nSELECT DISTINCT lt.id FROM `{$this->db}`.`log_{$table}` lt\n{$join}\nWHERE lt.log_conn_id = %1 AND\n lt.log_date BETWEEN DATE_SUB(%2, INTERVAL {$this->interval}) AND DATE_ADD(%2, INTERVAL {$this->interval})\n {$contactIdClause}";
$dao = CRM_Core_DAO::executeQuery($sql, $params);
while ($dao->fetch()) {
$diffs = array_merge($diffs, $this->diffsInTableForId($table, $dao->id));
}
return $diffs;
}
示例7: sync
static function sync($contactId)
{
// get visa required value
$getInfo = array('entity_id' => $contactId, 'return.Extended_Demographics:Is_Visa_Required' => 1);
$isVisaRequired = civicrm_api3('custom_value', 'get', $getInfo);
$isVisaRequired = $isVisaRequired['count'] ? $isVisaRequired['values']["{$isVisaRequired['id']}"][0] : 0;
// this api call will get visa expiration date
// of immigration records for the contact
$getInfo = array('entity_id' => $contactId, 'return.Immigration:End_Date' => 1);
$immigrationDateInfo = civicrm_api3('custom_value', 'get', $getInfo);
$lastestVisaExpirationDate = NULL;
if ($immigrationDateInfo['count'] > 0) {
$lastestVisaExpirationDate = $immigrationDateInfo['values']["{$immigrationDateInfo['id']}"]['latest'];
}
// activity processing if immigration data found
if ($immigrationDateInfo['count']) {
// get 'Visa Expiration' activity for this contact
$activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Visa Expiration', 'name');
$activityStatuses = CRM_Core_OptionGroup::values('activity_status', FALSE, FALSE, FALSE, NULL, 'name');
// to check if visa expiration activity exists for the input target_contact_id
$activityGetParams = array('contact_id' => $contactId, 'activity_type_id' => $activityTypeId, 'sequential' => 1);
// note : using filter 'activity_type_id' in combination with 'contact_id' filter doesn't work
$activities = civicrm_api3('activity', 'get', $activityGetParams);
$activityId = NULL;
$count = 0;
foreach ($activities['values'] as $val) {
if ($val['activity_type_id'] != $activityTypeId || !array_key_exists('targets', $val)) {
continue;
}
$activityId = $val['id'];
$count++;
}
if ($count) {
$activityParams = array();
$activityParams['status_id'] = $isVisaRequired ? CRM_Utils_Array::key('Scheduled', $activityStatuses) : CRM_Utils_Array::key('Cancelled', $activityStatuses);
$activityParams['activity_date_time'] = $lastestVisaExpirationDate;
// check if count is one, if not log a error
if ($count > 1) {
// update the last activity and log a error
$logError = "Multiple 'Visa Expiration' activities exists for target contact with id : {$contactId}, so updating last activity with id : {$activityId}";
CRM_Core_Error::debug_log_message($logError);
}
$activityParams['id'] = $activityId;
$result = civicrm_api3('activity', 'create', $activityParams);
} else {
// if no activity create a new one only if 'visa is required'
if ($isVisaRequired) {
$activityParams = array('target_contact_id' => $contactId, 'activity_type_id' => $activityTypeId, 'subject' => 'Visa Expiration', 'activity_date_time' => $lastestVisaExpirationDate, 'status_id' => CRM_Utils_Array::key('Scheduled', $activityStatuses), 'details' => 'Visa Expiration');
$result = civicrm_api3('activity', 'create', $activityParams);
}
}
}
// end of if for immgration info check
}
示例8: getAbsenceDuration
/**
* Get duration of absences, in minutes.
*
* @param array $absenceTypeNames
* @param $periodId
*
* @return int
*/
private static function getAbsenceDuration($absenceTypeNames = array(), $periodId)
{
$absenceTypeIds = static::getActivityIdsForAbsenceTypeNames($absenceTypeNames, $periodId);
$activityStatuses = CRM_HRAbsence_BAO_HRAbsenceType::getActivityStatus('name');
$sql = "\n SELECT SUM(a1.duration) duration\n FROM civicrm_activity a\n\n INNER JOIN civicrm_activity_contact ac\n ON a.id = ac.activity_id\n\n INNER JOIN civicrm_contact c\n ON (ac.contact_id = c.id AND c.contact_type = 'Individual')\n\n INNER JOIN civicrm_hrjobcontract jc\n ON c.id = jc.contact_id AND jc.is_primary = 1\n\n INNER JOIN civicrm_hrjobcontract_revision jcr\n ON (jc.id = jcr.jobcontract_id AND jcr.effective_date <= NOW())\n\n INNER JOIN civicrm_hrjobcontract_details jcd\n ON (jcr.id = jcd.jobcontract_revision_id AND (jcd.period_end_date >= NOW() OR jcd.period_end_date IS NULL))\n\n INNER JOIN civicrm_activity a1\n ON (a.id = a1.source_record_id AND a1.activity_type_id = %1 AND a1.status_id = %2)\n\n WHERE\n a.id IN (" . implode(',', $absenceTypeIds) . ")\n AND a.status_id = %2\n ";
$params = array(1 => array(static::getAbsenceActivityTypeId(), 'Integer'), 2 => array(CRM_Utils_Array::key('Completed', $activityStatuses), 'Integer'));
$duration = 0;
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if ($dao->fetch()) {
$duration = $dao->duration;
}
return $duration;
}
示例9: civicrm_api3_activity_getabsences
/**
* Activity.GetAbsences API
*
* This is a variation on Activity.get with additional filtering behavior suitable for activities.
*
* @param array $params
* @return array API result descriptor
* @see civicrm_api3_create_success
* @see civicrm_api3_create_error
* @throws API_Exception
*/
function civicrm_api3_activity_getabsences($params)
{
// activity_type_id: int|string|array(int|string)
// period_id: int|array(int)
// target_contact_id: int
$activityTypes = CRM_Core_PseudoConstant::activityType();
// ****** Defaults ******
if (!isset($params['activity_type_id'])) {
$params['activity_type_id'] = CRM_HRAbsence_BAO_HRAbsenceType::getActivityTypes();
}
// ****** Build query ******
$select = new CRM_HRAbsence_DGWDIHTWT('civicrm_activity request');
$select->select('request.*')->groupBy('request.id')->join('absence', 'INNER JOIN civicrm_activity absence ON (absence.source_record_id = request.id AND absence.activity_type_id = #typeId)', array('#typeId' => array_search('Absence', $activityTypes)));
if (!empty($params['period_id'])) {
$periodIds = (array) $params['period_id'];
$dateExprs = array();
// array(string $sqlExpression)
foreach ($periodIds as $periodId) {
$period = civicrm_api3('HRAbsencePeriod', 'getsingle', array('id' => $periodId));
$dateExprs[] = $select->interpolate('min(absence.activity_date_time) between @start and @end', array('@start' => $period['start_date'], '@end' => $period['end_date']));
}
$select->having(implode(' or ', $dateExprs));
}
if (!empty($params['activity_type_id'])) {
$typeIds = (array) $params['activity_type_id'];
foreach (array_keys($typeIds) as $key) {
if (!is_numeric($typeIds[$key])) {
$typeIds[$key] = array_search($typeIds[$key], $activityTypes);
if ($typeIds[$key] === FALSE) {
throw new API_Exception("Invalid activity type");
}
}
}
$select->where('request.activity_type_id IN (#typeIds)', array('#typeIds' => $typeIds));
}
if (!empty($params['target_contact_id'])) {
$activityContactTypes = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$select->join('tgt', 'INNER JOIN civicrm_activity_contact tgt
ON tgt.activity_id = request.id
AND tgt.record_type_id = #tgt
AND tgt.contact_id IN (#targetIds)', array('#tgt' => CRM_Utils_Array::key('Activity Targets', $activityContactTypes), '#targetIds' => (array) $params['target_contact_id']));
}
// ****** Execute query ******
$entity = _civicrm_api3_get_BAO(__FUNCTION__);
$bao = CRM_Core_DAO::executeQuery($select->toSQL(), array(), TRUE, 'CRM_Activity_BAO_Activity');
$activities = _civicrm_api3_dao_to_array($bao, $params, FALSE, $entity, FALSE);
$activities = _civicrm_api3_activity_get_formatResult($params, $activities);
return civicrm_api3_create_success($activities, $params, $entity, 'getAbsences');
}
示例10: from
function from()
{
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$roleID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'volunteer_role', 'id', 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$this->_from = "\n FROM civicrm_activity {$this->_aliases['civicrm_activity']}\n LEFT JOIN civicrm_activity_contact {$this->_aliases['civicrm_activity_target']}\n ON {$this->_aliases['civicrm_activity']}.id = {$this->_aliases['civicrm_activity_target']}.activity_id AND\n {$this->_aliases['civicrm_activity_target']}.record_type_id = {$targetID}\n LEFT JOIN {$this->customGroup['table_name']} cg\n ON {$this->_aliases['civicrm_activity']}.id = cg.entity_id\n LEFT JOIN civicrm_volunteer_need n\n ON n.id = cg.{$this->customFields['volunteer_need_id']['column_name']}\n LEFT JOIN civicrm_option_value {$this->_aliases['role']} ON ( {$this->_aliases['role']}.value = cg.{$this->customFields['volunteer_role_id']['column_name']} AND {$this->_aliases['role']}.option_group_id = {$roleID} )\n LEFT JOIN civicrm_volunteer_project {$this->_aliases['project']}\n ON {$this->_aliases['project']}.id = n.project_id\n LEFT JOIN civicrm_activity_contact {$this->_aliases['civicrm_activity_assignment']}\n ON {$this->_aliases['civicrm_activity']}.id = {$this->_aliases['civicrm_activity_assignment']}.activity_id AND\n {$this->_aliases['civicrm_activity_assignment']}.record_type_id = {$assigneeID}\n LEFT JOIN civicrm_activity_contact {$this->_aliases['civicrm_activity_source']}\n ON {$this->_aliases['civicrm_activity']}.id = {$this->_aliases['civicrm_activity_source']}.activity_id AND\n {$this->_aliases['civicrm_activity_source']}.record_type_id = {$sourceID}\n LEFT JOIN civicrm_contact contact_civireport\n ON {$this->_aliases['civicrm_activity_target']}.contact_id = contact_civireport.id\n LEFT JOIN civicrm_contact civicrm_contact_assignee_civireport\n ON {$this->_aliases['civicrm_activity_assignment']}.contact_id = civicrm_contact_assignee_civireport.id\n LEFT JOIN civicrm_contact civicrm_contact_source\n ON {$this->_aliases['civicrm_activity_source']}.contact_id = civicrm_contact_source.id\n {$this->_aclFrom}\n LEFT JOIN civicrm_option_value\n ON ( {$this->_aliases['civicrm_activity']}.activity_type_id = civicrm_option_value.value )\n LEFT JOIN civicrm_option_group\n ON civicrm_option_group.id = civicrm_option_value.option_group_id\n LEFT JOIN civicrm_case_activity case_activity_civireport\n ON case_activity_civireport.activity_id = {$this->_aliases['civicrm_activity']}.id\n LEFT JOIN civicrm_case\n ON case_activity_civireport.case_id = civicrm_case.id\n LEFT JOIN civicrm_case_contact\n ON civicrm_case_contact.case_id = civicrm_case.id ";
if ($this->isTableSelected('civicrm_email')) {
$this->_from .= "\n LEFT JOIN civicrm_email civicrm_email_source\n ON {$this->_aliases['civicrm_activity_source']}.contact_id = civicrm_email_source.contact_id AND\n civicrm_email_source.is_primary = 1\n\n LEFT JOIN civicrm_email civicrm_email_target\n ON {$this->_aliases['civicrm_activity_target']}.contact_id = civicrm_email_target.contact_id AND\n civicrm_email_target.is_primary = 1\n\n LEFT JOIN civicrm_email civicrm_email_assignee\n ON {$this->_aliases['civicrm_activity_assignment']}.contact_id = civicrm_email_assignee.contact_id AND\n civicrm_email_assignee.is_primary = 1 ";
}
if ($this->isTableSelected('civicrm_phone')) {
$this->_from .= "\n LEFT JOIN civicrm_phone civicrm_phone_source\n ON {$this->_aliases['civicrm_activity_source']}.contact_id = civicrm_phone_source.contact_id AND\n civicrm_phone_source.is_primary = 1\n\n LEFT JOIN civicrm_phone civicrm_phone_target\n ON {$this->_aliases['civicrm_activity_target']}.contact_id = civicrm_phone_target.contact_id AND\n civicrm_phone_target.is_primary = 1\n\n LEFT JOIN civicrm_phone civicrm_phone_assignee\n ON {$this->_aliases['civicrm_activity_assignment']}.contact_id = civicrm_phone_assignee.contact_id AND\n civicrm_phone_assignee.is_primary = 1 ";
}
}
示例11: preProcess
/**
* build all the data structures needed to build the form
*
* @return void
* @access public
*/
function preProcess()
{
parent::preProcess();
$rows = array();
// display name and activity details of all selected contacts
$activityIDs = implode(',', $this->_activityHolderIds);
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
$query = "\n SELECT at.subject as subject,\n ov.label as activity_type,\n at.activity_date_time as activity_date,\n ct.display_name as display_name\n FROM civicrm_activity at\nLEFT JOIN civicrm_activity_contact ac ON ( ac.activity_id = at.id AND ac.record_type_id = {$sourceID} )\nINNER JOIN civicrm_contact ct ON ( ac.contact_id = ct.id )\n LEFT JOIN civicrm_option_group og ON ( og.name = 'activity_type' )\n LEFT JOIN civicrm_option_value ov ON (at.activity_type_id = ov.value AND og.id = ov.option_group_id )\n WHERE at.id IN ( {$activityIDs} )";
$dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
while ($dao->fetch()) {
$rows[] = array('subject' => $dao->subject, 'activity_type' => $dao->activity_type, 'activity_date' => $dao->activity_date, 'display_name' => $dao->display_name);
}
$this->assign('rows', $rows);
}
示例12: testActionScheduleWithScheduledDatesCreate
/**
* Test create with scheduled dates.
*/
public function testActionScheduleWithScheduledDatesCreate()
{
$oldCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_action_schedule');
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
$scheduledStatus = CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled', 'name');
$activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', "Meeting", 'name');
$title = "simpleActionSchedule" . substr(sha1(rand()), 0, 7);
$params = array('title' => $title, 'recipient' => $assigneeID, 'limit_to' => 1, 'entity_value' => $activityTypeId, 'entity_status' => $scheduledStatus, 'is_active' => 1, 'record_activity' => 1, 'mapping_id' => CRM_Activity_ActionMapping::ACTIVITY_MAPPING_ID, 'start_action_offset' => 3, 'start_action_unit' => 'day', 'start_action_condition' => 'before', 'start_action_date' => 'activity_date_time', 'is_repeat' => 1, 'repetition_frequency_unit' => 'day', 'repetition_frequency_interval' => 3, 'end_frequency_unit' => 'hour', 'end_frequency_interval' => 0, 'end_action' => 'before', 'end_date' => 'activity_date_time', 'body_html' => 'Test description', 'subject' => 'Test subject');
$actionSchedule = $this->callAPISuccess('action_schedule', 'create', $params);
$this->assertTrue(is_numeric($actionSchedule['id']));
$this->assertTrue($actionSchedule['id'] > 0);
$this->assertEquals($actionSchedule['values'][$actionSchedule['id']]['start_action_offset'][0], $params['start_action_offset']);
$newCount = CRM_Core_DAO::singleValueQuery('select count(*) from civicrm_action_schedule');
$this->assertEquals($oldCount + 1, $newCount);
}
示例13: setDefaultValues
/**
* set defaults for the form
*
* @return array
* @access public
*/
public function setDefaultValues()
{
$defaults = parent::setDefaultValues();
if (!empty($defaults['preferred_language'])) {
$languages = CRM_Contact_BAO_Contact::buildOptions('preferred_language');
$defaults['preferred_language'] = CRM_Utils_Array::key($defaults['preferred_language'], $languages);
}
// CRM-7119: set preferred_language to default if unset
if (empty($defaults['preferred_language'])) {
$config = CRM_Core_Config::singleton();
$defaults['preferred_language'] = $config->lcMessages;
}
foreach (CRM_Contact_BAO_Contact::$_greetingTypes as $greeting) {
$name = "{$greeting}_display";
$this->assign($name, CRM_Utils_Array::value($name, $defaults));
}
return $defaults;
}
示例14: preProcess
/**
* Pre processing.
*
* @return void
*/
public function preProcess()
{
// Ensure user has permission to be here
if (!CRM_Core_Permission::check('administer dedupe rules')) {
CRM_Utils_System::permissionDenied();
CRM_Utils_System::civiExit();
}
$this->_options = CRM_Core_SelectValues::getDedupeRuleTypes();
$this->_rgid = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
$this->_contactType = CRM_Utils_Request::retrieve('contact_type', 'String', $this, FALSE, 0);
if ($this->_rgid) {
$rgDao = new CRM_Dedupe_DAO_RuleGroup();
$rgDao->id = $this->_rgid;
$rgDao->find(TRUE);
$this->_defaults['threshold'] = $rgDao->threshold;
$this->_contactType = $rgDao->contact_type;
$this->_defaults['used'] = CRM_Utils_Array::key($rgDao->used, $this->_options);
$this->_defaults['title'] = $rgDao->title;
$this->_defaults['name'] = $rgDao->name;
$this->_defaults['is_reserved'] = $rgDao->is_reserved;
$this->assign('isReserved', $rgDao->is_reserved);
$this->assign('ruleName', $rgDao->name);
$ruleDao = new CRM_Dedupe_DAO_Rule();
$ruleDao->dedupe_rule_group_id = $this->_rgid;
$ruleDao->find();
$count = 0;
while ($ruleDao->fetch()) {
$this->_defaults["where_{$count}"] = "{$ruleDao->rule_table}.{$ruleDao->rule_field}";
$this->_defaults["length_{$count}"] = $ruleDao->rule_length;
$this->_defaults["weight_{$count}"] = $ruleDao->rule_weight;
$count++;
}
}
$supported = CRM_Dedupe_BAO_RuleGroup::supportedFields($this->_contactType);
if (is_array($supported)) {
foreach ($supported as $table => $fields) {
foreach ($fields as $field => $title) {
$this->_fields["{$table}.{$field}"] = $title;
}
}
}
asort($this->_fields);
}
示例15: getSmartDebitPayments
function getSmartDebitPayments($referenceNumber)
{
$paymentProcessorType = CRM_Core_PseudoConstant::paymentProcessorType(false, null, 'name');
$paymentProcessorTypeId = CRM_Utils_Array::key('Smart Debit', $paymentProcessorType);
$domainID = CRM_Core_Config::domainID();
$sql = " SELECT user_name ";
$sql .= " , password ";
$sql .= " , signature ";
$sql .= " FROM civicrm_payment_processor ";
$sql .= " WHERE payment_processor_type_id = %1";
$sql .= " AND is_test= %2 AND domain_id = %3";
$params = array(1 => array($paymentProcessorTypeId, 'Integer'), 2 => array('0', 'Int'), 3 => array($domainID, 'Int'));
$dao = CRM_Core_DAO::executeQuery($sql, $params);
if ($dao->fetch()) {
$username = $dao->user_name;
$password = $dao->password;
$pslid = $dao->signature;
}
// Send payment POST to the target URL
$url = "https://secure.ddprocessing.co.uk/api/data/dump?query[service_user][pslid]={$pslid}&query[report_format]=XML";
// Restrict to a single payer if we have a reference
if ($referenceNumber) {
$url .= "&query[reference_number]={$referenceNumber}";
}
$response = self::requestPost($url, $username, $password);
// Take action based upon the response status
switch (strtoupper($response["Status"])) {
case 'OK':
$smartDebitArray = array();
// Cater for a single response
if (isset($response['Data']['PayerDetails']['@attributes'])) {
$smartDebitArray[] = $response['Data']['PayerDetails']['@attributes'];
} else {
foreach ($response['Data']['PayerDetails'] as $key => $value) {
$smartDebitArray[] = $value['@attributes'];
}
}
return $smartDebitArray;
default:
return false;
}
}