/** * implementation of CiviCRM tokenValues hook. */ function windowsill_civicrm_tokenValues(&$values, &$contactIDs, $jobID, $tokens = array(), $context = NULL) { // Get settings from civicrm $settings = CRM_Core_BAO_Setting::getItem('windowsill', 'settings'); $decode = json_decode(utf8_decode($settings), TRUE); // Loop settings foreach ($decode as &$value) { // Check if tab is configured if ($value['token']) { $name = str_replace(' ', '_', $value['name']); $view = explode(':', $value['view']); // Rendered $rendered = views_embed_view($view[0], $view[1]); /* // absolute paths are set to url paths (Anchor tags) //$rendered['windowsill:'.$name] = preg_replace('/<\s*a\s(.*?)href="\/(.*?)"(.*?)>/i', '<a $1href="'.$base_url.$base_path.'$2"$3>', $rendered['windowsill:'.$name]); //$rendered['windowsill:'.$name] = preg_replace('/<\s*img\s(.*?)src="\/(.*?)"(.*?)>/i', '<img $1src="'.$base_url.$base_path.'$2"$3>', $rendered['windowsill:'.$name]); */ // Set token foreach ($contactIDs as $contactID) { $values[$contactID]['windowsill.' . $name] = $rendered; } } } }
/** * Identify all the households to check and do it * * If max_count is set, it will stop after that amount, * saving the last household id for the next call */ public function checkAllHouseholds($max_count = NULL) { $max_count = (int) $max_count; $activity_type_id = CRM_Householdmerge_Logic_Configuration::getCheckHouseholdActivityTypeID(); $activity_status_ids = CRM_Householdmerge_Logic_Configuration::getLiveActivityStatusIDs(); if ($max_count) { $contact_id_minimum = CRM_Core_BAO_Setting::getItem(CRM_Householdmerge_Logic_Configuration::$HHMERGE_SETTING_DOMAIN, 'hh_check_last_id'); if (!$contact_id_minimum) { $contact_id_minimum = 0; } $limit_clause = "LIMIT {$max_count}"; } else { $contact_id_minimum = 0; $limit_clause = ''; } $last_contact_id_processed = 0; $selector_sql = "SELECT civicrm_contact.id AS contact_id\n FROM civicrm_contact\n LEFT JOIN civicrm_activity_contact ON civicrm_activity_contact.contact_id = civicrm_contact.id\n LEFT JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_activity.id AND civicrm_activity.activity_type_id = {$activity_type_id} AND civicrm_activity.status_id IN ({$activity_status_ids})\n WHERE contact_type = 'Household'\n AND civicrm_activity.id IS NULL \n AND (civicrm_contact.is_deleted IS NULL or civicrm_contact.is_deleted = 0)\n AND civicrm_contact.id > {$contact_id_minimum}\n GROUP BY civicrm_contact.id\n ORDER BY civicrm_contact.id ASC\n {$limit_clause}"; $query = CRM_Core_DAO::executeQuery($selector_sql); while ($query->fetch()) { $last_contact_id_processed = $query->contact_id; $this->checkHousehold($last_contact_id_processed); $max_count--; } // done if ($max_count > 0) { // we're through the whole list, reset marker CRM_Core_BAO_Setting::setItem('0', CRM_Householdmerge_Logic_Configuration::$HHMERGE_SETTING_DOMAIN, 'hh_check_last_id'); } else { CRM_Core_BAO_Setting::setItem($last_contact_id_processed, CRM_Householdmerge_Logic_Configuration::$HHMERGE_SETTING_DOMAIN, 'hh_check_last_id'); } return; }
function run() { $this->setActivityStatusIds(); $this->setValues(); $contactParams = array('is_opt_out' => 1); $groupId = CRM_Core_BAO_Setting::getItem('Speakcivi API Preferences', 'group_id'); $location = ''; if ($this->isGroupContactAdded($this->contactId, $groupId)) { $this->setGroupContactRemoved($this->contactId, $groupId); $location = 'removed from Members after optout link'; if (CRM_Speakcivi_Cleanup_Leave::hasJoins($this->contactId)) { CRM_Speakcivi_Logic_Activity::leave($this->contactId, 'confirmation_link', $this->campaignId, $this->activityId, '', 'Added by SpeakCivi Optout'); } } if ($this->campaignId) { $campaign = new CRM_Speakcivi_Logic_Campaign($this->campaignId); $locale = $campaign->getLanguage(); $language = substr($locale, 0, 2); $this->setLanguageTag($this->contactId, $language); } CRM_Speakcivi_Logic_Contact::set($this->contactId, $contactParams); $aids = $this->findActivitiesIds($this->activityId, $this->campaignId, $this->contactId); $this->setActivitiesStatuses($this->activityId, $aids, 'optout', $location); $country = $this->getCountry($this->campaignId); $url = "{$country}/post_optout"; CRM_Utils_System::redirect($url); }
public function setDefaultValues() { $defaults = $details = array(); $activity_type = CRM_Core_BAO_Setting::getItem(self::OUTLOOK_SETTING_GROUP, 'activity_type', NULL, FALSE); $defaults['activity_type'] = $activity_type; return $defaults; }
/** * @param array $cxn * @param string $entity * @param string $action * @param array $params * @return mixed */ public static function route($cxn, $entity, $action, $params) { $SUPER_PERM = array('administer CiviCRM'); require_once 'api/v3/utils.php'; // FIXME: Shouldn't the X-Forwarded-Proto check be part of CRM_Utils_System::isSSL()? if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL') && !CRM_Utils_System::isSSL() && strtolower(CRM_Utils_Array::value('X_FORWARDED_PROTO', CRM_Utils_System::getRequestHeaders())) != 'https') { return civicrm_api3_create_error('System policy requires HTTPS.'); } // Note: $cxn and cxnId are authenticated before router is called. $dao = new CRM_Cxn_DAO_Cxn(); $dao->cxn_id = $cxn['cxnId']; if (empty($cxn['cxnId']) || !$dao->find(TRUE) || !$dao->cxn_id) { return civicrm_api3_create_error('Failed to lookup connection authorizations.'); } if (!$dao->is_active) { return civicrm_api3_create_error('Connection is inactive.'); } if (!is_string($entity) || !is_string($action) || !is_array($params)) { return civicrm_api3_create_error('API parameters are malformed.'); } if (empty($cxn['perm']['api']) || !is_array($cxn['perm']['api']) || empty($cxn['perm']['grant']) || !(is_array($cxn['perm']['grant']) || is_string($cxn['perm']['grant']))) { return civicrm_api3_create_error('Connection has no permissions.'); } $whitelist = \Civi\API\WhitelistRule::createAll($cxn['perm']['api']); \Civi::service('dispatcher')->addSubscriber(new \Civi\API\Subscriber\WhitelistSubscriber($whitelist)); CRM_Core_Config::singleton()->userPermissionTemp = new CRM_Core_Permission_Temp(); if ($cxn['perm']['grant'] === '*') { CRM_Core_Config::singleton()->userPermissionTemp->grant($SUPER_PERM); } else { CRM_Core_Config::singleton()->userPermissionTemp->grant($cxn['perm']['grant']); } $params['check_permissions'] = 'whitelist'; return civicrm_api($entity, $action, $params); }
/** * Process a webhook request from Mailchimp. * * The only documentation for this *sigh* is (May 2016) at * https://apidocs.mailchimp.com/webhooks/ */ public function run() { CRM_Mailchimp_Utils::checkDebug("Webhook POST: " . serialize($_POST)); // Empty response object, default response code. try { $expected_key = CRM_Core_BAO_Setting::getItem(self::MC_SETTING_GROUP, 'security_key', NULL, FALSE); $given_key = isset($_GET['key']) ? $_GET['key'] : null; list($response_code, $response_object) = $this->processRequest($expected_key, $given_key, $_POST); CRM_Mailchimp_Utils::checkDebug("Webhook response code {$response_code} (200 = ok)"); } catch (RuntimeException $e) { $response_code = $e->getCode(); $response_object = NULL; CRM_Mailchimp_Utils::checkDebug("Webhook RuntimeException code {$response_code} (200 means OK): " . $e->getMessage()); } catch (Exception $e) { // Broad catch. $response_code = 500; $response_object = NULL; CRM_Mailchimp_Utils::checkDebug("Webhook " . get_class($e) . ": " . $e->getMessage()); } // Serve HTTP response. if ($response_code != 200) { // Some fault. header("HTTP/1.1 {$response_code}"); } else { // Return the JSON output header('Content-type: application/json'); print json_encode($response_object); } CRM_Utils_System::civiExit(); }
/** * This function sets the default values for the form. * default values are retrieved from the database * * @access public * * @return None */ function setDefaultValues() { if (!$this->_defaults) { $this->_defaults = array(); $formArray = array('Component', 'Localization'); $formMode = FALSE; if (in_array($this->_name, $formArray)) { $formMode = TRUE; } CRM_Core_BAO_ConfigSetting::retrieve($this->_defaults); CRM_Core_Config_Defaults::setValues($this->_defaults, $formMode); $list = array_flip(CRM_Core_OptionGroup::values('contact_autocomplete_options', FALSE, FALSE, TRUE, NULL, 'name')); $cRlist = array_flip(CRM_Core_OptionGroup::values('contact_reference_options', FALSE, FALSE, TRUE, NULL, 'name')); $listEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options'); $cRlistEnabled = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_reference_options'); $autoSearchFields = array(); if (!empty($list) && !empty($listEnabled)) { $autoSearchFields = array_combine($list, $listEnabled); } $cRSearchFields = array(); if (!empty($cRlist) && !empty($cRlistEnabled)) { $cRSearchFields = array_combine($cRlist, $cRlistEnabled); } //Set defaults for autocomplete and contact reference options $this->_defaults['autocompleteContactSearch'] = array('1' => 1) + $autoSearchFields; $this->_defaults['autocompleteContactReference'] = array('1' => 1) + $cRSearchFields; $this->_defaults['enableSSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enableSSL', NULL, 0); $this->_defaults['verifySSL'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL', NULL, 1); $sql = "\nSELECT time_format\nFROM civicrm_preferences_date\nWHERE time_format IS NOT NULL\nAND time_format <> ''\nLIMIT 1\n"; $this->_defaults['timeInputFormat'] = CRM_Core_DAO::singleValueQuery($sql); } return $this->_defaults; }
/** * Set defaults for api.getlist * * @param $entity string * @param $request array */ function _civicrm_api3_generic_getList_defaults($entity, &$request) { $config = CRM_Core_Config::singleton(); $fields = _civicrm_api_get_fields($entity); $defaults = array('page_num' => 1, 'input' => '', 'image_field' => NULL, 'id_field' => 'id', 'params' => array()); // Find main field from meta foreach (array('sort_name', 'title', 'label', 'name') as $field) { if (isset($fields[$field])) { $defaults['label_field'] = $defaults['search_field'] = $field; break; } } foreach (array('description') as $field) { if (isset($fields[$field])) { $defaults['description_field'] = $field; break; } } $resultsPerPage = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'search_autocomplete_count', NULL, 10); $request += $defaults; // Default api params $params = array('options' => array('limit' => $resultsPerPage + 1, 'offset' => ($request['page_num'] - 1) * $resultsPerPage, 'sort' => $request['label_field']), 'sequential' => 1); // When searching e.g. autocomplete if ($request['input']) { $params[$request['search_field']] = array('LIKE' => ($config->includeWildCardInName ? '%' : '') . $request['input'] . '%'); } // When looking up a field e.g. displaying existing record if (!empty($request['id'])) { if (is_string($request['id']) && strpos(',', $request['id'])) { $request['id'] = explode(',', $request['id']); } $params[$request['id_field']] = is_array($request['id']) ? array('IN' => $request['id']) : $request['id']; } $request['params'] += $params; }
function preProcess() { $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE); $this->_system = CRM_Utils_Request::retrieve('system', 'Boolean', $this, FALSE, TRUE); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'update'); if (isset($action)) { $this->assign('action', $action); } $session = CRM_Core_Session::singleton(); $this->_config = new CRM_Core_DAO(); if ($this->_system) { if (CRM_Core_Permission::check('administer CiviCRM')) { $this->_contactID = NULL; } else { CRM_Utils_System::fatal('You do not have permission to edit preferences'); } $this->_config->contact_id = NULL; } else { if (!$this->_contactID) { $this->_contactID = $session->get('userID'); if (!$this->_contactID) { CRM_Utils_System::fatal('Could not retrieve contact id'); } $this->set('cid', $this->_contactID); } $this->_config->contact_id = $this->_contactID; } foreach ($this->_varNames as $groupName => $settingNames) { $values = CRM_Core_BAO_Setting::getItem($groupName); foreach ($values as $name => $value) { $this->_config->{$name} = $value; } } $session->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); }
public function setDefaultValues() { $defaults = array(); try { $defaults['rood_mtype'] = civicrm_api3('MembershipType', 'getvalue', array('return' => 'id', 'name' => 'Lid SP en ROOD')); } catch (Exception $e) { //do nothing } try { $defaults['rood_mstatus'] = civicrm_api3('MembershipStatus', 'getvalue', array('return' => 'id', 'name' => 'Correctie')); } catch (Exception $e) { //do nothing } try { $defaults['sp_mtype'] = civicrm_api3('MembershipType', 'getvalue', array('return' => 'id', 'name' => 'Lid SP')); } catch (Exception $e) { //do nothing } try { $status = civicrm_api3('MembershipStatus', 'getvalue', array('return' => 'id', 'name' => 'current')); $defaults['member_status_id'][$status] = $status; } catch (Exception $e) { //do nothing } $date = new DateTime(); $date->modify('-26 years'); $date->modify('first day of this year'); list($defaults['birth_date_from']) = CRM_Utils_Date::setDateDefaults($date->format('Y-m-d')); $date->modify('last day of this year'); list($defaults['birth_date_to']) = CRM_Utils_Date::setDateDefaults($date->format('Y-m-d')); $minimum_fee = CRM_Core_BAO_Setting::getItem('nl.sp.rood', 'minimum_fee', null, '5.00'); $defaults['minimum_fee'] = $minimum_fee; return $defaults; }
/** * Basic page run function. */ public function run() { // Get link options for managing events. $enableCart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart'); $tabs = CRM_Event_Page_ManageEvent::tabs($enableCart); foreach ($tabs as $tab => $tabInfo) { $tabs[$tab]['name'] = $tabInfo['title']; $tabs[$tab]['qs'] = $tab == 'reminder' ? 'reset=1&action=browse&setTab=1&id=%%id%%' : 'reset=1&action=update&id=%%id%%'; } // Get link options for participant listings. $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1'); $statusTypesPending = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0'); $participantLinks = array(); if (1 || !empty($statusTypes)) { $participantLinks[2] = array('name' => implode(', ', array_values($statusTypes)), 'url' => 'civicrm/event/search', 'qs' => 'reset=1&force=1&status=true&event=%%id%%', 'title' => ts('Counted', array('domain' => 'com.aghstrategies.eventpermissions'))); } if (!empty($statusTypesPending)) { $participantLinks[3] = array('name' => implode(', ', array_values($statusTypesPending)), 'url' => 'civicrm/event/search', 'qs' => 'reset=1&force=1&status=false&event=%%id%%', 'title' => ts('Not Counted', array('domain' => 'com.aghstrategies.eventpermissions'))); } $participantLinks[4] = array('name' => ts('Public Participant Listing', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/participant', 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Public Participant Listing', array('domain' => 'com.aghstrategies.eventpermissions'))); // Get link options for event links. $eventLinks = array(array('name' => ts('Register Participant', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/participant/add', 'qs' => 'reset=1&action=add&context=standalone&eid=%%id%%', 'title' => ts('Register Participant', array('domain' => 'com.aghstrategies.eventpermissions'))), array('name' => ts('Event Info', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/info', 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Event Info', array('domain' => 'com.aghstrategies.eventpermissions'))), array('name' => ts('Online Registration (Test-drive)', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/register', 'qs' => 'reset=1&action=preview&id=%%id%%', 'title' => ts('Online Registration (Test-drive)', array('domain' => 'com.aghstrategies.eventpermissions'))), array('name' => ts('Online Registration (Live)', array('domain' => 'com.aghstrategies.eventpermissions')), 'url' => 'civicrm/event/register', 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Online Registration (Live)', array('domain' => 'com.aghstrategies.eventpermissions')))); $utils = new CRM_Eventpermissions_Utils(); $events = array(); foreach ($utils->myUpcomingEvents() as $id => $event) { $events[] = array('title' => CRM_Utils_System::href($event['title'], 'civicrm/event/info', "id={$id}&reset=1"), 'links' => CRM_Core_Action::formLink($tabs, NULL, array('id' => $id), ts('Configure', array('domain' => 'com.aghstrategies.eventpermissions')), TRUE, 'eventpermissions.myevents.configure', 'Event', $id), 'participantLinks' => CRM_Core_Action::formLink($participantLinks, $event['participant_listing_id'] ? 6 : 3, array('id' => $id), ts('Participants', array('domain' => 'com.aghstrategies.eventpermissions')), TRUE, 'eventpermissions.myevents.participants', 'Event', $id), 'eventLinks' => CRM_Core_Action::formLink($eventLinks, NULL, array('id' => $id), ts('Event Links', array('domain' => 'com.aghstrategies.eventpermissions')), TRUE, 'eventpermissions.myevents.links', 'Event', $id)); } $this->assign('events', $events); parent::run(); }
/** * @return array */ public static function getSettings() { if (is_null(static::$settings)) { static::$settings = (array) CRM_Core_BAO_Setting::getItem('Extension', 'uk.co.compucorp.civicrm.giftaid:settings'); } return static::$settings; }
/** * Add an ics attachment to the input array. * * @param array $attachments * Reference to array in same format returned from CRM_Core_BAO_File::getEntityFile(). * @param array $contacts * Array of contacts (attendees). * * @return string|null * Array index of the added attachment in the $attachments array, else NULL. */ public function addAttachment(&$attachments, $contacts) { // Check preferences setting if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'activity_assignee_notification_ics')) { $config =& CRM_Core_Config::singleton(); $this->icsfile = tempnam($config->customFileUploadDir, 'ics'); if ($this->icsfile !== FALSE) { rename($this->icsfile, $this->icsfile . '.ics'); $this->icsfile .= '.ics'; $icsFileName = basename($this->icsfile); // get logged in user's primary email // TODO: Is there a better way to do this? $organizer = $this->getPrimaryEmail(); $template = CRM_Core_Smarty::singleton(); $template->assign('activity', $this->activity); $template->assign('organizer', $organizer); $template->assign('contacts', $contacts); $template->assign('timezone', date_default_timezone_get()); $calendar = $template->fetch('CRM/Activity/Calendar/ICal.tpl'); if (file_put_contents($this->icsfile, $calendar) !== FALSE) { if (empty($attachments)) { $attachments = array(); } $attachments['activity_ics'] = array('mime_type' => 'text/calendar', 'fileName' => $icsFileName, 'cleanName' => $icsFileName, 'fullPath' => $this->icsfile); return 'activity_ics'; } } } return NULL; }
function _civicrm_api3_speakcivi_sendconfirm_spec(&$params) { $params['toEmail']['api.required'] = 1; $params['contact_id']['api.required'] = 1; $params['campaign_id']['api.required'] = 1; $params['from']['api.default'] = html_entity_decode(CRM_Core_BAO_Setting::getItem('Speakcivi API Preferences', 'from')); }
/** * Execute "checkAll". * * @param array|NULL $messages * List of CRM_Utils_Check_Message; or NULL if the default list should be fetched. * @param array|string|callable $filter * Restrict messages using a callback filter. * By default, only show warnings and errors. * Set TRUE to show all messages. */ public function showPeriodicAlerts($messages = NULL, $filter = array(__CLASS__, 'severityMap')) { if (CRM_Core_Permission::check('administer CiviCRM') && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'securityAlert', NULL, TRUE)) { $session = CRM_Core_Session::singleton(); if ($session->timer('check_' . __CLASS__, self::CHECK_TIMER)) { // Best attempt at re-securing folders $config = CRM_Core_Config::singleton(); $config->cleanup(0, FALSE); if ($messages === NULL) { $messages = $this->checkAll(); } $statusMessages = array(); $statusType = 'alert'; foreach ($messages as $message) { if ($filter === TRUE || $message->getSeverity() >= 3) { $statusType = $message->getSeverity() >= 4 ? 'error' : $statusType; $statusMessage = $message->getMessage(); $statusMessages[] = $statusTitle = $message->getTitle(); } } if (count($statusMessages)) { if (count($statusMessages) > 1) { $statusTitle = ts('Multiple Alerts'); $statusMessage = '<ul><li>' . implode('</li><li>', $statusMessages) . '</li></ul>'; } // TODO: add link to status page CRM_Core_Session::setStatus($statusMessage, $statusTitle, $statusType); } } } }
/** * Metrics.collate API * * @param array $params * @return array API result descriptor * @see civicrm_api3_create_success * @see civicrm_api3_create_error * @throws API_Exception */ function civicrm_api3_metrics_collate($params) { $data = array(); CRM_Metricclient_Hook::collateMetrics($data); if (!empty($data)) { $header = array(); $header['site_url'] = $_SERVER['SERVER_NAME']; $metricSettings = CRM_Core_BAO_Setting::getItem("metrics"); $header['site_name'] = $metricSettings['metrics_site_name']; $header['data'] = $data; $curl = curl_init($metricSettings['metrics_reporting_url']); curl_setopt($curl, CURLOPT_POST, true); if (array_key_exists("metrics_ignore_verify_peer", $metricSettings) && $metricSettings['metrics_ignore_verify_peer'] == 1) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); } if (array_key_exists("metrics_ignore_verify_host", $metricSettings) && $metricSettings['metrics_ignore_verify_host'] == 1) { curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); } else { curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); } if (array_key_exists("metrics_ca_path", $metricSettings) && $metricSettings['metrics_ca_path']) { curl_setopt($curl, CURLOPT_CAPATH, $metricSettings['metrics_ca_path']); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POSTFIELDS, array("json" => json_encode($header))); $response = curl_exec($curl); $error = curl_error($curl); if ($error) { throw new API_Exception($error, 1); } return civicrm_api3_create_success(count($data), $params, 'Metrics', 'collate'); } return civicrm_api3_create_success(0, $params, 'Metrics', 'collate'); }
/** * Function to list memberships for the UF user * * return null * @access public */ function listMemberships() { $membership = array(); $dao = new CRM_Member_DAO_Membership(); $dao->contact_id = $this->_contactId; $dao->is_test = 0; $dao->find(); while ($dao->fetch()) { $membership[$dao->id] = array(); CRM_Core_DAO::storeValues($dao, $membership[$dao->id]); //get the membership status and type values. $statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id); foreach (array('status', 'membership_type') as $fld) { $membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]); } if (!empty($statusANDType[$dao->id]['is_current_member'])) { $membership[$dao->id]['active'] = TRUE; } $membership[$dao->id]['renewPageId'] = CRM_Member_BAO_Membership::getContributionPageId($dao->id); if (!$membership[$dao->id]['renewPageId']) { // Membership payment was not done via online contribution page or free membership. Check for default membership renewal page from CiviMember Settings $defaultRenewPageId = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME, 'default_renewal_contribution_page'); if ($defaultRenewPageId) { $membership[$dao->id]['renewPageId'] = $defaultRenewPageId; } } } $activeMembers = CRM_Member_BAO_Membership::activeMembers($membership); $inActiveMembers = CRM_Member_BAO_Membership::activeMembers($membership, 'inactive'); $this->assign('activeMembers', $activeMembers); $this->assign('inActiveMembers', $inActiveMembers); }
function run() { $this->setValues(); $this->setIsOptOut($this->contactId, 0); $groupId = CRM_Core_BAO_Setting::getItem('Speakcivi API Preferences', 'group_id'); $activityStatus = 'Completed'; // Completed existing member if (!$this->isGroupContactAdded($this->contactId, $groupId)) { CRM_Speakcivi_Logic_Activity::join($this->contactId, 'confirmation_link', $this->campaignId); $this->setGroupContactAdded($this->contactId, $groupId); $activityStatus = 'optin'; // Completed new member } if ($this->campaignId) { $campaign = new CRM_Speakcivi_Logic_Campaign($this->campaignId); $locale = $campaign->getLanguage(); $language = substr($locale, 0, 2); $this->setLanguageGroup($this->contactId, $language); $this->setLanguageTag($this->contactId, $language); } $aids = $this->findActivitiesIds($this->activityId, $this->campaignId, $this->contactId); $this->setActivitiesStatuses($this->activityId, $aids, $activityStatus); $email = CRM_Speakcivi_Logic_Contact::getEmail($this->contactId); $speakcivi = new CRM_Speakcivi_Page_Speakcivi(); $speakcivi->sendConfirm($email, $this->contactId, $this->activityId, $this->campaignId, false); $country = $this->getCountry($this->campaignId); $url = "{$country}/post_confirm"; CRM_Utils_System::redirect($url); }
/** * Compute any messages which should be displayed before upgrade. * * @param string $preUpgradeMessage * alterable. * @param $currentVer * @param $latestVer */ public static function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $latestVer) { if (version_compare(phpversion(), self::MIN_RECOMMENDED_PHP_VER) < 0) { $preUpgradeMessage .= '<br />' . ts('This webserver is running an outdated version of PHP (%1). The recommended version is %2 or later.', array(1 => phpversion(), 2 => self::MIN_RECOMMENDED_PHP_VER)) . '<br />' . ts('You may proceed with the upgrade and CiviCRM %1 will continue working normally, but future releases will require PHP %2.', array(1 => $latestVer, 2 => self::MIN_RECOMMENDED_PHP_VER)); } // http://issues.civicrm.org/jira/browse/CRM-13572 // Depending on how the code was upgraded, some sites may still have copies of old // source files left behind. This is often a forgivable offense, but it's quite // dangerous for CIVI-SA-2013-001. global $civicrm_root; $ofcFile = "{$civicrm_root}/packages/OpenFlashChart/php-ofc-library/ofc_upload_image.php"; if (file_exists($ofcFile)) { if (@unlink($ofcFile)) { $preUpgradeMessage .= '<br />' . ts('This system included an outdated, insecure script (%1). The file was automatically deleted.', array(1 => $ofcFile)); } else { $preUpgradeMessage .= '<br />' . ts('This system includes an outdated, insecure script (%1). Please delete it.', array(1 => $ofcFile)); } } if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, 'enable_innodb_fts', NULL, FALSE)) { // The FTS indexing feature dynamically manipulates the schema which could // cause conflicts with other layers that manipulate the schema. The // simplest thing is to turn it off and back on. // It may not always be necessary to do this -- but I doubt we're going to test // systematically in future releases. When it is necessary, one could probably // ignore the matter and simply run CRM_Core_InnoDBIndexer::fixSchemaDifferences // after the upgrade. But that's speculative. For now, we'll leave this // advanced feature in the hands of the sysadmin. $preUpgradeMessage .= '<br />' . ts('This database uses InnoDB Full Text Search for optimized searching. The upgrade procedure has not been tested with this feature. You should disable (and later re-enable) the feature by navigating to "Administer => System Settings => Miscellaneous".'); } }
function run() { $json = array(); // get action $data = json_decode(file_get_contents("php://input")); // switch switch ($data->action) { case 'views': // variables $view_array = views_get_all_views($reset = FALSE); // build array for each view and their display foreach ($view_array as $view => $v) { foreach ($view_array[$view]->display as $display => $d) { $arr = array('id' => "{$v->name}:{$display}", 'name' => "{$v->human_name} ({$d->display_title})"); $json[] = $arr; } } break; case 'settings': // variables // log $settings = CRM_Core_BAO_Setting::getItem('windowsill', 'settings'); $json = json_decode(utf8_decode($settings), true); break; } // return JSON // http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension // http://civicrm.stackexchange.com/questions/2348/how-to-display-a-drupal-view-in-a-civicrm-tab print json_encode($json, JSON_PRETTY_PRINT); // exit CRM_Utils_System::civiExit(); }
/** * This function will manipulate the URLs in Emails, so they point * to the correct proxy addresses */ static function mendURLs(&$value) { // check if the proxy is enabled $enabled = CRM_Core_BAO_Setting::getItem('CiviProxy Settings', 'proxy_enabled'); if (!$enabled) { return; } // get the URLs $config = CRM_Core_Config::singleton(); $system_base = $config->userFrameworkBaseURL; $proxy_base = CRM_Core_BAO_Setting::getItem('CiviProxy Settings', 'proxy_url'); // General external functions $value = preg_replace("#{$system_base}sites/all/modules/civicrm/extern/url.php#i", $proxy_base . '/url.php', $value); $value = preg_replace("#{$system_base}sites/all/modules/civicrm/extern/open.php#i", $proxy_base . '/open.php', $value); $value = preg_replace("#{$system_base}sites/default/files/civicrm/persist/#i", $proxy_base . '/file.php?id=', $value); // Mailing related functions $value = preg_replace("#{$system_base}civicrm/mailing/view#i", $proxy_base . '/mailing/mail.php', $value); $custom_mailing_base = CRM_Core_BAO_Setting::getItem('CiviProxy Settings', 'custom_mailing_base'); $other_mailing_functions = array('subscribe', 'confirm', 'unsubscribe', 'resubscribe', 'optout'); foreach ($other_mailing_functions as $function) { if (empty($custom_mailing_base)) { $new_url = "{$proxy_base}/mailing/{$function}.php"; } else { $new_url = "{$custom_mailing_base}/{$function}.php"; } $value = preg_replace("#{$system_base}civicrm/mailing/{$function}#i", $new_url, $value); } }
function civicrm_api3_mailchimp_synchronize($params) { $return = $tags = $createdContact = array(); $apiKey = CRM_Core_BAO_Setting::getItem('MailChimp Preferences', 'api_key', NULL, FALSE); $tagsCount = civicrm_api3('Tag', 'getcount', array('sequential' => 1)); $tagsGet = civicrm_api3('Tag', 'get', array('sequential' => 1, 'rowCount' => $tagsCount)); foreach ($tagsGet['values'] as $tagIds => $tagsValues) { $tags[$tagsValues['id']] = $tagsValues['name']; } $mcClient = new Mailchimp($apiKey); $mcLists = new Mailchimp_Lists($mcClient); $lists = $mcLists->getList(); foreach ($lists['data'] as $listsDetails) { if (!in_array($listsDetails['name'], $tags)) { $tagsCreate = civicrm_api3('Tag', 'create', array('sequential' => 1, 'name' => $listsDetails['name'])); } $tagsCount = civicrm_api3('Tag', 'getcount', array('sequential' => 1)); $tagsGet = civicrm_api3('Tag', 'get', array('sequential' => 1, 'rowCount' => $tagsCount)); foreach ($tagsGet['values'] as $tagIds => $tagsValues) { $tags[$tagsValues['id']] = $tagsValues['name']; } if (in_array($listsDetails['name'], $tags)) { $keyTags = array_search($listsDetails['name'], $tags); $members = $mcLists->members($listsDetails['id']); foreach ($members['data'] as $key => $value) { try { $createdContact = civicrm_api3('Contact', 'create', array('sequential' => 1, 'contact_type' => "Individual", 'first_name' => $value['merges']['FNAME'], 'last_name' => $value['merges']['LNAME'], 'email' => $value['merges']['EMAIL'], 'api.EntityTag.create' => array('entity_id' => "\$value.id", 'entity_table' => "civicrm_contact", 'tag_id' => $keyTags), 'dupe_check' => true)); } catch (CiviCRM_API3_Exception $e) { $result = civicrm_api3('EntityTag', 'create', array('contact_id' => $e->getExtraParams()['ids'][0], 'tag_id' => $keyTags)); } } } } return civicrm_api3_create_success(); }
/** +--------------------------------------------------------------------+ | CiviCRM version 4.6 | +--------------------------------------------------------------------+ | Copyright CiviCRM LLC (c) 2004-2015 | +--------------------------------------------------------------------+ | 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 | +--------------------------------------------------------------------+ */ function civicrm_api3_prevem_login($params) { $prevemUrl = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'prevem_url'); $prevemURL = !empty($prevemUrl) ? CRM_Utils_URL::mask($prevemUrl, array('user', 'pass')) : NULL; if (!$prevemURL) { return civicrm_api3_create_error("prevemURL is not configured. Go to Administer>CiviMail>CiviMail Component Settings to configure prevemURL"); } $prevemConsumer = parse_url($prevemUrl, PHP_URL_USER); $prevemSecret = parse_url($prevemUrl, PHP_URL_PASS); /** TODO Parse $prevemUrl. Send login request to get token. **/ /** To send login request, see eg http://stackoverflow.com/questions/2445276/how-to-post-data-in-php-using-file-get-contents **/ $postdata = http_build_query(array('email' => $prevemConsumer . "@foo.com", 'password' => $prevemSecret)); $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata)); $context = stream_context_create($opts); $result = file_get_contents($prevemURL . '/api/Users/login', FALSE, $context); if ($result === FALSE) { return civicrm_api3_create_error("Failed to login. Check if Preview Manager is running on " . $prevemURL); } else { $accessToken = json_decode($result)->{'id'}; if (!$accessToken) { return civicrm_api3_create_error("Failed to parse access token. Check if Preview Manager is running on " . $prevemURL); } $returnValues = array('url' => $prevemURL, 'consumerId' => $prevemConsumer, 'token' => $accessToken, 'password' => $prevemSecret); return civicrm_api3_create_success($returnValues, $params, 'Prevem', 'login'); } }
/** * This function sets the default values for the form. * default values are retrieved from the database * * @access public * * @return void */ function setDefaultValues() { $domainID = CRM_Core_Config::domainID(); $settings = civicrm_api3('Setting', 'get', array('domain_id' => $domainID, 'return' => "simple_donation_page")); $this->_defaults['simpleDonation'] = CRM_Utils_Array::value('simple_donation_page', $settings['values'][$domainID]); $this->_defaults['ziptastic'] = CRM_Core_BAO_Setting::getItem('Simple Donation', 'ziptastic_enable'); return $this->_defaults; }
/** * @param bool $fresh * @return CRM_Utils_QueryFormatter */ public static function singleton($fresh = FALSE) { if ($fresh || self::$singleton === NULL) { $mode = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, 'fts_query_mode', NULL, self::MODE_NONE); self::$singleton = new CRM_Utils_QueryFormatter($mode); } return self::$singleton; }
public function getCurrentValue($key) { if (!empty($this->_submitValues[$key])) { return $this->_submitValues[$key]; } else { return CRM_Core_BAO_Setting::getItem('CiviBanking', $key); } }
/** * build all the data structures needed to build the form * * @return void * @access public */ function preProcess() { $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE); $this->_searchKey = CRM_Utils_Request::retrieve('key', 'String', $this); // sort out whether it’s a delete-to-trash, delete-into-oblivion or restore (and let the template know) $values = $this->controller->exportValues(); $this->_skipUndelete = (CRM_Core_Permission::check('access deleted contacts') and (CRM_Utils_Request::retrieve('skip_undelete', 'Boolean', $this) or CRM_Utils_Array::value('task', $values) == CRM_Contact_Task::DELETE_PERMANENTLY)); $this->_restore = (CRM_Utils_Request::retrieve('restore', 'Boolean', $this) or CRM_Utils_Array::value('task', $values) == CRM_Contact_Task::RESTORE); if ($this->_restore && !CRM_Core_Permission::check('access deleted contacts')) { CRM_Core_Error::fatal(ts('You do not have permission to access this contact.')); } elseif (!CRM_Core_Permission::check('delete contacts')) { CRM_Core_Error::fatal(ts('You do not have permission to delete this contact.')); } $this->assign('trash', CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_undelete', NULL) and !$this->_skipUndelete); $this->assign('restore', $this->_restore); if ($this->_restore) { CRM_Utils_System::setTitle(ts('Restore Contact')); } if ($cid) { if (!CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT)) { CRM_Core_Error::fatal(ts('You do not have permission to delete this contact. Note: you can delete contacts if you can edit them.')); } elseif (CRM_Contact_BAO_Contact::checkDomainContact($cid)) { CRM_Core_Error::fatal(ts('This contact is a special one for the contact information associated with the CiviCRM installation for this domain. No one is allowed to delete it because the information is used for special system purposes.')); } $this->_contactIds = array($cid); $this->_single = TRUE; $this->assign('totalSelectedContacts', 1); } else { parent::preProcess(); } $this->_sharedAddressMessage = $this->get('sharedAddressMessage'); if (!$this->_restore && !$this->_sharedAddressMessage) { // we check for each contact for shared contact address $sharedContactList = array(); $sharedAddressCount = 0; foreach ($this->_contactIds as $contactId) { // check if a contact that is being deleted has any shared addresses $sharedAddressMessage = CRM_Core_BAO_Address::setSharedAddressDeleteStatus(NULL, $contactId, TRUE); if ($sharedAddressMessage['count'] > 0) { $sharedAddressCount += $sharedAddressMessage['count']; $sharedContactList = array_merge($sharedContactList, $sharedAddressMessage['contactList']); } } $this->_sharedAddressMessage = array('count' => $sharedAddressCount, 'contactList' => $sharedContactList); if ($sharedAddressCount > 0) { if (count($this->_contactIds) > 1) { // more than one contact deleted $message = ts('One of the selected contacts has an address record that is shared with 1 other contact.', array('plural' => 'One or more selected contacts have address records which are shared with %count other contacts.', 'count' => $sharedAddressCount)); } else { // only one contact deleted $message = ts('This contact has an address record which is shared with 1 other contact.', array('plural' => 'This contact has an address record which is shared with %count other contacts.', 'count' => $sharedAddressCount)); } CRM_Core_Session::setStatus($message . ' ' . ts('Shared addresses will not be removed or altered but will no longer be shared.'), ts('Shared Addesses Owner')); } // set in form controller so that queries are not fired again $this->set('sharedAddressMessage', $this->_sharedAddressMessage); } }
function setDefaultValues() { $apiKey = CRM_Core_BAO_Setting::getItem(self::MC_SETTING_GROUP, 'api_key', NULL, FALSE); if (isset($apiKey)) { return array('api_key' => $apiKey); } else { return array('api_key' => $this->_apiKey); } }
/** * create all fields needed for a credit card transaction * * @return void * @access public */ function setCreditCardFields(&$form) { CRM_Core_Payment_Form::_setPaymentFields($form); $form->_paymentFields['credit_card_number'] = array('htmlType' => 'text', 'name' => 'credit_card_number', 'title' => ts('Card Number'), 'cc_field' => TRUE, 'attributes' => array('size' => 20, 'maxlength' => 20, 'autocomplete' => 'off'), 'is_required' => TRUE); $form->_paymentFields['cvv2'] = array('htmlType' => 'text', 'name' => 'cvv2', 'title' => ts('Security Code'), 'cc_field' => TRUE, 'attributes' => array('size' => 5, 'maxlength' => 10, 'autocomplete' => 'off'), 'is_required' => CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'cvv_backoffice_required', CRM_Core_Component::getComponentID('CiviContribute'), 1)); $form->_paymentFields['credit_card_exp_date'] = array('htmlType' => 'date', 'name' => 'credit_card_exp_date', 'title' => ts('Expiration Date'), 'cc_field' => TRUE, 'attributes' => CRM_Core_SelectValues::date('creditCard'), 'is_required' => TRUE); $creditCardType = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::creditCard(); $form->_paymentFields['credit_card_type'] = array('htmlType' => 'select', 'name' => 'credit_card_type', 'title' => ts('Card Type'), 'cc_field' => TRUE, 'attributes' => $creditCardType, 'is_required' => TRUE); }
/** * @param bool $fresh * @return CRM_Core_InnoDBIndexer */ public static function singleton($fresh = FALSE) { if ($fresh || self::$singleton === NULL) { $indices = array('civicrm_address' => array(array('street_address', 'city', 'postal_code')), 'civicrm_activity' => array(array('subject', 'details')), 'civicrm_contact' => array(array('sort_name', 'nick_name', 'display_name')), 'civicrm_contribution' => array(array('source', 'amount_level', 'trxn_Id', 'invoice_id')), 'civicrm_email' => array(array('email')), 'civicrm_membership' => array(array('source')), 'civicrm_note' => array(array('subject', 'note')), 'civicrm_participant' => array(array('source', 'fee_level')), 'civicrm_phone' => array(array('phone')), 'civicrm_tag' => array(array('name'))); $active = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, 'enable_innodb_fts', NULL, FALSE); self::$singleton = new self($active, $indices); } return self::$singleton; }