/** * Browse all mail settings. * * @return void */ public function browse() { //get all mail settings. $allMailSettings = array(); $mailSetting = new CRM_Core_DAO_MailSettings(); $allProtocols = CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'); //multi-domain support for mail settings. CRM-5244 $mailSetting->domain_id = CRM_Core_Config::domainID(); //find all mail settings. $mailSetting->find(); while ($mailSetting->fetch()) { //replace protocol value with name $mailSetting->protocol = CRM_Utils_Array::value($mailSetting->protocol, $allProtocols); CRM_Core_DAO::storeValues($mailSetting, $allMailSettings[$mailSetting->id]); //form all action links $action = array_sum(array_keys($this->links())); // disallow the DELETE action for the default set of settings if ($mailSetting->is_default) { $action &= ~CRM_Core_Action::DELETE; } //add action links. $allMailSettings[$mailSetting->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $mailSetting->id), ts('more'), FALSE, 'mailSetting.manage.action', 'MailSetting', $mailSetting->id); } $this->assign('rows', $allMailSettings); }
/** * Initialize the constants used during lock acquire / release * * @param string $name name of the lock. Please prefix with component / functionality * e.g. civimail.cronjob.JOB_ID * @param int $timeout the number of seconds to wait to get the lock. 1 if not set * @param boolean $serverWideLock should this lock be applicable across your entire mysql server * this is useful if you have mutliple sites running on the same * mysql server and you want to limit the number of parallel cron * jobs - CRM-91XX * * @return object the lock object * */ function __construct($name, $timeout = NULL, $serverWideLock = FALSE) { $config = CRM_Core_Config::singleton(); $dsnArray = DB::parseDSN($config->dsn); $database = $dsnArray['database']; $domainID = CRM_Core_Config::domainID(); if ($serverWideLock) { $this->_name = $name; } else { $this->_name = $database . '.' . $domainID . '.' . $name; } if (defined('CIVICRM_LOCK_DEBUG')) { CRM_Core_Error::debug_log_message('trying to construct lock for ' . $this->_name); } static $jobLog = FALSE; if ($jobLog && CRM_Core_DAO::singleValueQuery("SELECT IS_USED_LOCK( '{$jobLog}')")) { return $this->hackyHandleBrokenCode($jobLog); } if (stristr($name, 'civimail.job.')) { $jobLog = $this->_name; } //if (defined('CIVICRM_LOCK_DEBUG')) { //CRM_Core_Error::debug_var('backtrace', debug_backtrace()); //} $this->_timeout = $timeout !== NULL ? $timeout : self::TIMEOUT; $this->acquire(); }
/** * Sets the tsLocale and dbLocale for multi-lingual sites. * Some code duplication from CRM/Core/BAO/ConfigSetting.php retrieve() * to avoid regressions from refactoring. * @param $lcMessagesRequest * @throws \API_Exception */ public function setLocale($lcMessagesRequest) { // We must validate whether the locale is valid, otherwise setting a bad // dbLocale could probably lead to sql-injection. $domain = new \CRM_Core_DAO_Domain(); $domain->id = \CRM_Core_Config::domainID(); $domain->find(TRUE); if ($domain->config_backend) { $defaults = unserialize($domain->config_backend); // are we in a multi-language setup? $multiLang = $domain->locales ? TRUE : FALSE; $lcMessages = NULL; // on multi-lang sites based on request and civicrm_uf_match if ($multiLang) { $languageLimit = array(); if (array_key_exists('languageLimit', $defaults) && is_array($defaults['languageLimit'])) { $languageLimit = $defaults['languageLimit']; } if (in_array($lcMessagesRequest, array_keys($languageLimit))) { $lcMessages = $lcMessagesRequest; } else { throw new \API_Exception(ts('Language not enabled: %1', array(1 => $lcMessagesRequest))); } } global $dbLocale; // set suffix for table names - use views if more than one language if ($lcMessages) { $dbLocale = $multiLang && $lcMessages ? "_{$lcMessages}" : ''; // FIXME: an ugly hack to fix CRM-4041 global $tsLocale; $tsLocale = $lcMessages; } } }
/** * WARNING: This interface may change. * * This provides information about the setting - similar to the fields concept for DAO information. * As the setting is serialized code creating validation setting input needs to know the data type * This also helps move information out of the form layer into the data layer where people can interact with * it via the API or other mechanisms. In order to keep this consistent it is important the form layer * also leverages it. * * Note that this function should never be called when using the runtime getvalue function. Caching works * around the expectation it will be called during setting administration * * Function is intended for configuration rather than runtime access to settings * * The following params will filter the result. If none are passed all settings will be returns * * @param array $filters * @param int $domainID * * @return array * the following information as appropriate for each setting * - name * - type * - default * - add (CiviCRM version added) * - is_domain * - is_contact * - description * - help_text */ public static function getMetadata($filters = array(), $domainID = NULL) { if ($domainID === NULL) { $domainID = \CRM_Core_Config::domainID(); } $cache = \Civi::cache('settings'); $cacheString = 'settingsMetadata_' . $domainID . '_'; // the caching into 'All' seems to be a duplicate of caching to // settingsMetadata__ - I think the reason was to cache all settings as defined & then those altered by a hook $settingsMetadata = $cache->get($cacheString); $cached = is_array($settingsMetadata); if (!$cached) { $settingsMetadata = $cache->get(self::ALL); if (empty($settingsMetadata)) { global $civicrm_root; $metaDataFolders = array($civicrm_root . '/settings'); \CRM_Utils_Hook::alterSettingsFolders($metaDataFolders); $settingsMetadata = self::loadSettingsMetaDataFolders($metaDataFolders); $cache->set(self::ALL, $settingsMetadata); } } \CRM_Utils_Hook::alterSettingsMetaData($settingsMetadata, $domainID, NULL); if (!$cached) { $cache->set($cacheString, $settingsMetadata); } self::_filterSettingsSpecification($filters, $settingsMetadata); return $settingsMetadata; }
/** * Output navigation script tag * * @param array $params * - is_default: bool, true if this is normal/default instance of the menu (which may be subject to CIVICRM_DISABLE_DEFAULT_MENU) * @param CRM_Core_Smarty $smarty * The Smarty object. * * @return string * HTML */ function smarty_function_crmNavigationMenu($params, &$smarty) { $config = CRM_Core_Config::singleton(); //check if logged in user has access CiviCRM permission and build menu $buildNavigation = !CRM_Core_Config::isUpgradeMode() && CRM_Core_Permission::check('access CiviCRM'); if (defined('CIVICRM_DISABLE_DEFAULT_MENU') && CRM_Utils_Array::value('is_default', $params, FALSE)) { $buildNavigation = FALSE; } if ($config->userFrameworkFrontend) { $buildNavigation = FALSE; } if ($buildNavigation) { $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); if ($contactID) { // These params force the browser to refresh the js file when switching user, domain, or language // We don't put them as a query string because some browsers will refuse to cache a page with a ? in the url // @see CRM_Admin_Page_AJAX::getNavigationMenu $lang = $config->lcMessages; $domain = CRM_Core_Config::domainID(); $key = CRM_Core_BAO_Navigation::getCacheKey($contactID); $src = CRM_Utils_System::url("civicrm/ajax/menujs/{$contactID}/{$lang}/{$domain}/{$key}"); // CRM-15493 QFkey needed for quicksearch bar - must be unique on each page refresh so adding it directly to markup $qfKey = CRM_Core_Key::get('CRM_Contact_Controller_Search', TRUE); return '<script id="civicrm-navigation-menu" type="text/javascript" src="' . $src . '" data-qfkey=' . json_encode($qfKey) . '></script>'; } } return ''; }
static function &values($name, $flip = FALSE, $grouping = FALSE, $localize = FALSE, $condition = NULL, $valueColumnName = 'label', $onlyActive = TRUE) { static $_cache = array(); $cacheKey = "CRM_OG_{$name}_{$flip}_{$grouping}_{$localize}_{$condition}_{$valueColumnName}_{$onlyActive}"; if (array_key_exists($cacheKey, $_cache)) { return $_cache[$cacheKey]; } $cache = CRM_Utils_Cache::singleton(); $var = $cache->get($cacheKey); if ($var) { return $var; } $query = "\nSELECT v.{$valueColumnName} as {$valueColumnName} ,v.value as value, v.grouping as grouping\nFROM civicrm_option_value v,\n civicrm_option_group g\nWHERE v.option_group_id = g.id\n AND g.name = %1\n AND g.is_active = 1 "; if ($onlyActive) { $query .= " AND v.is_active = 1 "; } if (in_array($name, self::$_domainIDGroups)) { $query .= " AND v.domain_id = " . CRM_Core_Config::domainID(); } if ($condition) { $query .= $condition; } $query .= " ORDER BY v.weight"; $p = array(1 => array($name, 'String')); $dao = CRM_Core_DAO::executeQuery($query, $p); $var = self::valuesCommon($dao, $flip, $grouping, $localize, $valueColumnName); // call option value hook CRM_Utils_Hook::optionValues($var, $name); $_cache[$cacheKey] = $var; $cache->set($cacheKey, $var); return $var; }
/** * Get CiviCRM domain details * {@getfields domain_create} * @example DomainGet.php */ function civicrm_api3_domain_get($params) { $params['version'] = CRM_Utils_Array::value('domain_version', $params); unset($params['version']); $bao = new CRM_Core_BAO_Domain(); if (CRM_Utils_Array::value('current_domain', $params)) { $domainBAO = CRM_Core_Config::domainID(); $params['id'] = $domainBAO; } _civicrm_api3_dao_set_filter($bao, $params, true, 'domain'); $domains = _civicrm_api3_dao_to_array($bao, $params, true, 'domain'); foreach ($domains as $domain) { if (!empty($domain['contact_id'])) { $values = array(); $locparams = array('contact_id' => $domain['contact_id']); $values['location'] = CRM_Core_BAO_Location::getValues($locparams, TRUE); $address_array = array('street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'state_province_id', 'postal_code', 'country_id', 'geo_code_1', 'geo_code_2'); if (!empty($values['location']['email'])) { $domain['domain_email'] = CRM_Utils_Array::value('email', $values['location']['email'][1]); } if (!empty($values['location']['phone'])) { $domain['domain_phone'] = array('phone_type' => CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Phone', 'phone_type_id', CRM_Utils_Array::value('phone_type_id', $values['location']['phone'][1])), 'phone' => CRM_Utils_Array::value('phone', $values['location']['phone'][1])); } if (!empty($values['location']['address'])) { foreach ($address_array as $value) { $domain['domain_address'][$value] = CRM_Utils_Array::value($value, $values['location']['address'][1]); } } list($domain['from_name'], $domain['from_email']) = CRM_Core_BAO_Domain::getNameAndEmail(TRUE); $domains[$domain['id']] = array_merge($domains[$domain['id']], $domain); } } return civicrm_api3_create_success($domains, $params, 'domain', 'get', $bao); }
public function setUp() { parent::setUp(); $params = array('contact_type_a' => 'Individual', 'contact_type_b' => 'Organization', 'name_a_b' => 'Test Employee of', 'name_b_a' => 'Test Employer of'); $this->_relationshipTypeId = $this->relationshipTypeCreate($params); $this->_orgContactID = $this->organizationCreate(); $this->_financialTypeId = 1; $this->_membershipTypeName = 'Mickey Mouse Club Member'; $params = array('name' => $this->_membershipTypeName, 'description' => NULL, 'minimum_fee' => 10, 'duration_unit' => 'year', 'member_of_contact_id' => $this->_orgContactID, 'period_type' => 'fixed', 'duration_interval' => 1, 'financial_type_id' => $this->_financialTypeId, 'relationship_type_id' => $this->_relationshipTypeId, 'visibility' => 'Public', 'is_active' => 1, 'fixed_period_start_day' => 101, 'fixed_period_rollover_day' => 1231, 'domain_id' => CRM_Core_Config::domainID()); $membershipType = $this->callAPISuccess('membership_type', 'create', $params); $this->_membershipTypeID = $membershipType['id']; $this->_orgContactID2 = $this->organizationCreate(); $params = array('name' => 'General', 'duration_unit' => 'year', 'duration_interval' => 1, 'period_type' => 'rolling', 'member_of_contact_id' => $this->_orgContactID2, 'domain_id' => 1, 'financial_type_id' => 1, 'is_active' => 1, 'sequential' => 1, 'visibility' => 'Public'); $membershipType2 = $this->callAPISuccess('membership_type', 'create', $params); $this->_membershipTypeID2 = $membershipType2['id']; $this->_membershipStatusID = $this->membershipStatusCreate('test status'); $this->_contactID = $this->individualCreate(); $contact2Params = array('first_name' => 'Anthonita', 'middle_name' => 'J.', 'last_name' => 'Anderson', 'prefix_id' => 3, 'suffix_id' => 3, 'email' => '*****@*****.**', 'contact_type' => 'Individual'); $this->_contactID2 = $this->individualCreate($contact2Params); $this->_contactID3 = $this->individualCreate(array('first_name' => 'bobby', 'email' => '*****@*****.**')); $this->_contactID4 = $this->individualCreate(array('first_name' => 'bobbynita', 'email' => '*****@*****.**')); $session = CRM_Core_Session::singleton(); $session->set('dateTypes', 1); $this->_sethtmlGlobals(); }
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(); require_once 'CRM/Core/DAO/Preferences.php'; $this->_config = new CRM_Core_DAO_Preferences(); $this->_config->domain_id = CRM_Core_Config::domainID(); 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->is_domain = 1; $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->is_domain = 0; $this->_config->contact_id = $this->_contactID; } $this->_config->find(true); $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/setting', 'reset=1')); }
/** * Function to process the form * * @access public * @return None */ function postProcess() { if ($this->_action & CRM_CORE_ACTION_DELETE) { CRM_Core_BAO_LocationType::del($this->_id); CRM_Core_Session::setStatus(ts('Selected Location type has been deleted.')); } else { // store the submitted values in an array $params = $this->exportValues(); $params['is_active'] = CRM_Utils_Array::value('is_active', $params, false); $params['is_default'] = CRM_Utils_Array::value('is_default', $params, false); // action is taken depending upon the mode $locationType =& new CRM_Core_DAO_LocationType(); $locationType->domain_id = CRM_Core_Config::domainID(); $locationType->name = $params['name']; $locationType->vcard_name = $params['vcard_name']; $locationType->description = $params['description']; $locationType->is_active = $params['is_active']; $locationType->is_default = $params['is_default']; if ($params['is_default']) { $unsetDefault =& new CRM_Core_DAO(); $query = 'UPDATE civicrm_location_type SET is_default = 0'; $unsetDefault->query($query); } if ($this->_action & CRM_CORE_ACTION_UPDATE) { $locationType->id = $this->_id; } $locationType->save(); CRM_Core_Session::setStatus(ts('The location type "%1" has been saved.', array(1 => $locationType->name))); } }
/** * Get AngularJS modules and their dependencies * * @return array * list of modules; same format as CRM_Utils_Hook::angularModules(&$angularModules) * @see CRM_Utils_Hook::angularModules */ public function getAngularModules() { // load angular files only if valid permissions are granted to the user if (!CRM_Core_Permission::check('access CiviMail') && !CRM_Core_Permission::check('create mailings') && !CRM_Core_Permission::check('schedule mailings') && !CRM_Core_Permission::check('approve mailings')) { return array(); } $result = array(); $result['crmMailing'] = array('ext' => 'civicrm', 'js' => array('ang/crmMailing.js', 'ang/crmMailing/*.js'), 'css' => array('ang/crmMailing.css'), 'partials' => array('ang/crmMailing')); $result['crmMailingAB'] = array('ext' => 'civicrm', 'js' => array('ang/crmMailingAB.js', 'ang/crmMailingAB/*.js', 'ang/crmMailingAB/*/*.js'), 'css' => array('ang/crmMailingAB.css'), 'partials' => array('ang/crmMailingAB')); $result['crmD3'] = array('ext' => 'civicrm', 'js' => array('ang/crmD3.js', 'bower_components/d3/d3.min.js')); $config = CRM_Core_Config::singleton(); $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); // Get past mailings // CRM-16155 - Limit to a reasonable number $civiMails = civicrm_api3('Mailing', 'get', array('is_completed' => 1, 'mailing_type' => array('IN' => array('standalone', 'winner')), 'return' => array('id', 'name', 'scheduled_date'), 'sequential' => 1, 'options' => array('limit' => 500, 'sort' => 'is_archived asc, scheduled_date desc'))); // Generic params $params = array('options' => array('limit' => 0), 'sequential' => 1); $groupNames = civicrm_api3('Group', 'get', $params + array('is_active' => 1, 'check_permissions' => TRUE, 'return' => array('title', 'visibility', 'group_type', 'is_hidden'))); $headerfooterList = civicrm_api3('MailingComponent', 'get', $params + array('is_active' => 1, 'return' => array('name', 'component_type', 'is_default', 'body_html', 'body_text'))); $emailAdd = civicrm_api3('Email', 'get', array('sequential' => 1, 'return' => "email", 'contact_id' => $contactID)); $mesTemplate = civicrm_api3('MessageTemplate', 'get', $params + array('sequential' => 1, 'is_active' => 1, 'return' => array("id", "msg_title"), 'workflow_id' => array('IS NULL' => ""))); $mailTokens = civicrm_api3('Mailing', 'gettokens', array('entity' => array('contact', 'mailing'), 'sequential' => 1)); $fromAddress = civicrm_api3('OptionValue', 'get', $params + array('option_group_id' => "from_email_address", 'domain_id' => CRM_Core_Config::domainID())); CRM_Core_Resources::singleton()->addSetting(array('crmMailing' => array('civiMails' => $civiMails['values'], 'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents), 'groupNames' => $groupNames['values'], 'headerfooterList' => $headerfooterList['values'], 'mesTemplate' => $mesTemplate['values'], 'emailAdd' => $emailAdd['values'], 'mailTokens' => $mailTokens['values'], 'contactid' => $contactID, 'requiredTokens' => CRM_Utils_Token::getRequiredTokens(), 'enableReplyTo' => (int) CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'replyTo'), 'disableMandatoryTokensCheck' => (int) CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'disable_mandatory_tokens_check'), 'fromAddress' => $fromAddress['values'], 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array('id' => 'user_contact_id', 'return' => 'email')), 'visibility' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::groupVisibility()), 'workflowEnabled' => CRM_Mailing_Info::workflowEnabled())))->addPermissions(array('view all contacts', 'access CiviMail', 'create mailings', 'schedule mailings', 'approve mailings', 'delete in CiviMail', 'edit message templates')); return $result; }
/** * takes an associative array and creates an instance object * * the function extract all the params it needs to initialize the create a * instance object. the params array could contain additional unused name/value * pairs * * @param array $params (reference ) an assoc array of name/value pairs * * @return object CRM_Report_DAO_ReportInstance object * @access public * @static */ static function add(&$params) { $instance = new CRM_Report_DAO_ReportInstance(); if (empty($params)) { return NULL; } $config = CRM_Core_Config::singleton(); $params['domain_id'] = CRM_Core_Config::domainID(); // convert roles array to string if (isset($params['grouprole']) && is_array($params['grouprole'])) { $grouprole_array = array(); foreach ($params['grouprole'] as $key => $value) { $grouprole_array[$value] = $value; } $params['grouprole'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($grouprole_array)); } if (!isset($params['id'])) { $params['is_reserved'] = CRM_Utils_Array::value('is_reserved', $params, FALSE); } $instanceID = CRM_Utils_Array::value('id', $params); if (!empty($params['instance_id'])) { $instanceID = CRM_Utils_Array::value('instance_id', $params); } if ($instanceID) { CRM_Utils_Hook::pre('edit', 'ReportInstance', $instanceID, $params); } else { CRM_Utils_Hook::pre('create', 'ReportInstance', NULL, $params); } $instance = new CRM_Report_DAO_ReportInstance(); $instance->copyValues($params); if ($config->userFramework == 'Joomla') { $instance->permission = 'null'; } // explicitly set to null if params value is empty if (!$instanceID && empty($params['grouprole'])) { $instance->grouprole = 'null'; } if ($instanceID) { $instance->id = $instanceID; } if (!$instanceID) { if ($reportID = CRM_Utils_Array::value('report_id', $params)) { $instance->report_id = $reportID; } else { if ($instanceID) { $instance->report_id = CRM_Report_Utils_Report::getValueFromUrl($instanceID); } else { // just take it from current url $instance->report_id = CRM_Report_Utils_Report::getValueFromUrl(); } } } $instance->save(); if ($instanceID) { CRM_Utils_Hook::pre('edit', 'ReportInstance', $instance->id, $instance); } else { CRM_Utils_Hook::pre('create', 'ReportInstance', $instance->id, $instance); } return $instance; }
/** * Output navigation script tag * * @param array $params * - is_default: bool, true if this is normal/default instance of the menu (which may be subject to CIVICRM_DISABLE_DEFAULT_MENU) * @param object $smarty the Smarty object * * @return string HTML */ function smarty_function_crmNavigationMenu($params, &$smarty) { $config = CRM_Core_Config::singleton(); //check if logged in user has access CiviCRM permission and build menu $buildNavigation = !CRM_Core_Config::isUpgradeMode() && CRM_Core_Permission::check('access CiviCRM'); if (defined('CIVICRM_DISABLE_DEFAULT_MENU') && CRM_Utils_Array::value('is_default', $params, FALSE)) { $buildNavigation = FALSE; } if ($config->userFrameworkFrontend) { $buildNavigation = FALSE; } if ($buildNavigation) { $session = CRM_Core_Session::singleton(); $contactID = $session->get('userID'); if ($contactID) { // These params force the browser to refresh the js file when switching user, domain, or language // We don't put them as a query string because some browsers will refuse to cache a page with a ? in the url // We end the string with .js to trick apache mods into sending pro-caching headers // @see CRM_Admin_Page_AJAX::getNavigationMenu $lang = $config->lcMessages; $domain = CRM_Core_Config::domainID(); $key = CRM_Core_BAO_Navigation::getCacheKey($contactID); $src = CRM_Utils_System::url("civicrm/ajax/menujs/{$contactID}/{$lang}/{$domain}/{$key}.js"); return '<script type="text/javascript" src="' . $src . '"></script>'; } } return ''; }
/** * Return the proper mail store implementation, based on config settings * * @param string $name name of the settings set from civimail_mail_settings to use (null for default) * @return object mail store implementation for processing CiviMail-bound emails */ function getStore($name = null) { $dao = new CRM_Core_DAO_MailSettings(); $dao->domain_id = CRM_Core_Config::domainID(); $name ? $dao->name = $name : ($dao->is_default = 1); if (!$dao->find(true)) { throw new Exception("Could not find entry named {$name} in civicrm_mail_settings"); } $protocols =& CRM_Core_PseudoConstant::mailProtocol(); switch ($protocols[$dao->protocol]) { case 'IMAP': require_once 'CRM/Mailing/MailStore/Imap.php'; return new CRM_Mailing_MailStore_Imap($dao->server, $dao->username, $dao->password, (bool) $dao->is_ssl, $dao->source); case 'POP3': require_once 'CRM/Mailing/MailStore/Pop3.php'; return new CRM_Mailing_MailStore_Pop3($dao->server, $dao->username, $dao->password, (bool) $dao->is_ssl); case 'Maildir': require_once 'CRM/Mailing/MailStore/Maildir.php'; return new CRM_Mailing_MailStore_Maildir($dao->source); case 'Localdir': require_once 'CRM/Mailing/MailStore/Localdir.php'; return new CRM_Mailing_MailStore_Localdir($dao->source); // DO NOT USE the mbox transport for anything other than testing // in particular, it does not clear the mbox afterwards // DO NOT USE the mbox transport for anything other than testing // in particular, it does not clear the mbox afterwards case 'mbox': require_once 'CRM/Mailing/MailStore/Mbox.php'; return new CRM_Mailing_MailStore_Mbox($dao->source); default: throw new Exception("Unknown protocol {$dao->protocol}"); } }
/** * Get all the mailing components of a particular type * * @param $type the type of component needed * @access public * @return array - array reference of all mailing components * @static */ function &component($type = null) { $name = $type ? $type : 'ALL'; if (!$GLOBALS['_CRM_MAILING_PSEUDOCONSTANT']['component'] || !array_key_exists($name, $GLOBALS['_CRM_MAILING_PSEUDOCONSTANT']['component'])) { if (!$GLOBALS['_CRM_MAILING_PSEUDOCONSTANT']['component']) { $GLOBALS['_CRM_MAILING_PSEUDOCONSTANT']['component'] = array(); } if (!$type) { $GLOBALS['_CRM_MAILING_PSEUDOCONSTANT']['component'][$name] = null; CRM_Core_PseudoConstant::populate($GLOBALS['_CRM_MAILING_PSEUDOCONSTANT']['component'][$name], 'CRM_Mailing_DAO_Component'); } else { // we need to add an additional filter for $type $GLOBALS['_CRM_MAILING_PSEUDOCONSTANT']['component'][$name] = array(); require_once 'CRM/Mailing/DAO/Component.php'; $object =& new CRM_Mailing_DAO_Component(); $object->domain_id = CRM_Core_Config::domainID(); $object->component_type = $type; $object->selectAdd(); $object->selectAdd("id, name"); $object->orderBy('is_default, name'); $object->is_active = 1; $object->find(); while ($object->fetch()) { $GLOBALS['_CRM_MAILING_PSEUDOCONSTANT']['component'][$name][$object->id] = $object->name; } } } return $GLOBALS['_CRM_MAILING_PSEUDOCONSTANT']['component'][$name]; }
/** * Function to pre processing * * @return None * @access public */ function preProcess() { $this->_BAOName = CRM_Admin_Page_DupeMatch::getBAOName(); $this->_advanced = CRM_Utils_Request::retrieve('advance', $this, false); $dupematch =& new CRM_Core_DAO_DupeMatch(); $dupematch->domain_id = CRM_Core_Config::domainID(); $dupematch->find(true); $id = $dupematch->id; $rule = $dupematch->rule; $tokens = preg_split('/[\\s]+/', $rule, -1, PREG_SPLIT_NO_EMPTY); $rule = explode(' ', $rule); if (count($tokens) > 9) { $this->_advanced = true; } foreach ($rule as $value) { if ($value == 'OR' || $value == '(' || $value == ')') { $this->_advanced = true; } else { if (substr($value, 0, 1) == '(') { $this->_advanced = true; } } } $this->_id = $id; $this->assign('advance', $this->_advanced); }
/** * Return the domain BAO for the current domain. * * @param NULL * * @return object CRM_Core_BAO_Domain object * * @access public * @static */ function &getCurrentDomain() { if ($GLOBALS['_CRM_CORE_BAO_DOMAIN']['_domain'] == null) { $GLOBALS['_CRM_CORE_BAO_DOMAIN']['_domain'] =& CRM_Core_BAO_Domain::getDomainByID(CRM_Core_Config::domainID()); } return $GLOBALS['_CRM_CORE_BAO_DOMAIN']['_domain']; }
/** * Return the proper mail store implementation, based on config settings * * @param string $name * Name of the settings set from civimail_mail_settings to use (null for default). * * @throws Exception * @return object * mail store implementation for processing CiviMail-bound emails */ public static function getStore($name = NULL) { $dao = new CRM_Core_DAO_MailSettings(); $dao->domain_id = CRM_Core_Config::domainID(); $name ? $dao->name = $name : ($dao->is_default = 1); if (!$dao->find(TRUE)) { throw new Exception("Could not find entry named {$name} in civicrm_mail_settings"); } $protocols = CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'); if (empty($protocols[$dao->protocol])) { throw new Exception("Empty mail protocol"); } switch ($protocols[$dao->protocol]) { case 'IMAP': return new CRM_Mailing_MailStore_Imap($dao->server, $dao->username, $dao->password, (bool) $dao->is_ssl, $dao->source); case 'POP3': return new CRM_Mailing_MailStore_Pop3($dao->server, $dao->username, $dao->password, (bool) $dao->is_ssl); case 'Maildir': return new CRM_Mailing_MailStore_Maildir($dao->source); case 'Localdir': return new CRM_Mailing_MailStore_Localdir($dao->source); // DO NOT USE the mbox transport for anything other than testing // in particular, it does not clear the mbox afterwards // DO NOT USE the mbox transport for anything other than testing // in particular, it does not clear the mbox afterwards case 'mbox': return new CRM_Mailing_MailStore_Mbox($dao->source); default: throw new Exception("Unknown protocol {$dao->protocol}"); } }
/** * Run the page. * * This method is called after the page is created. It checks for the * type of action and executes that action. * Finally it calls the parent's run method. * * @return void * @access public * */ function run() { // get the requested action $action = CRM_Utils_Request::retrieve('action', $this, false, 'browse'); // default to 'browse' // assign vars to templates $this->assign('action', $action); $this->_id = CRM_Utils_Request::retrieve('id', $this, false, 0); if (!$this->_id) { $dao =& new CRM_Contribute_DAO_ContributionPage(); $dao->domain_id = CRM_Core_Config::domainID(); $dao->save(); $this->_id = $dao->id; $this->set('id', $dao->id); } $this->assign('id', $this->_id); $subPage = CRM_Utils_Request::retrieve('subPage', $this); $this->assign('title', CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title')); $this->assign('is_active', CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'is_active')); CRM_Utils_System::setTitle(ts('Configure Contribution Page')); $form = null; switch ($subPage) { case 'Amount': $form = 'CRM_Contribute_Form_ContributionPage_Amount'; break; case 'Custom': $form = 'CRM_Contribute_Form_ContributionPage_Custom'; break; case 'Settings': $form = 'CRM_Contribute_Form_ContributionPage_Settings'; break; case 'ThankYou': $form = 'CRM_Contribute_Form_ContributionPage_ThankYou'; break; case 'AddProductToPage': $form = 'CRM_Contribute_Form_ContributionPage_AddProduct'; break; case 'Premium': //$form = 'CRM_Contribute_Form_ContributionPage_Premium'; require_once 'CRM/Contribute/Page/Premium.php'; $page =& new CRM_Contribute_Page_Premium('Configure Premiums'); $session =& CRM_Core_Session::singleton(); $session->set('singleForm', true); $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/contribute', 'action=update&reset=1&id=' . $this->_id)); return $page->run(); } if ($form) { $session =& CRM_Core_Session::singleton(); require_once 'CRM/Core/Controller/Simple.php'; $controller =& new CRM_Core_Controller_Simple($form, $subPage, $action); $session =& CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/contribute', 'action=update&reset=1&id=' . $this->_id)); $controller->set('id', $this->_id); $controller->set('single', true); $controller->process(); return $controller->run(); } return parent::run(); }
/** * @return CRM_Financial_DAO_PaymentProcessor */ function create() { $paymentProcessor = new CRM_Financial_DAO_PaymentProcessor(); $paymentParams = array('name' => 'Authorize', 'domain_id' => CRM_Core_Config::domainID(), 'payment_processor_type' => 'AuthNet', 'is_active' => 1, 'is_default' => 0, 'is_test' => 1, 'user_name' => '4y5BfuW7jm', 'password' => '4cAmW927n8uLf5J8', 'url_site' => 'https://test.authorize.net/gateway/transact.dll', 'url_recur' => 'https://apitest.authorize.net/xml/v1/request.api', 'class_name' => 'Payment_AuthorizeNet', 'billing_mode' => 1); $paymentProcessor->copyValues($paymentParams); $paymentProcessor->save(); return $paymentProcessor; }
/** * Helper function to create * a payment processor of type Paypal Pro * * @return int $paymentProcessor id of created payment processor@todo this appears not to be working but because it doesn't extend the test class * callAPISuccess won't work * I have duplicated this on the main test class as a work around */ static function create() { $paymentProcessor = new CRM_Financial_DAO_PaymentProcessor(); $paymentParams = array('name' => 'demo', 'domain_id' => CRM_Core_Config::domainID(), 'payment_processor_type' => 'PayPal', 'is_active' => 1, 'is_default' => 0, 'is_test' => 1, 'user_name' => 'sunil._1183377782_biz_api1.webaccess.co.in', 'password' => '1183377788', 'signature' => 'APixCoQ-Zsaj-u3IH7mD5Do-7HUqA9loGnLSzsZga9Zr-aNmaJa3WGPH', 'url_site' => 'https://www.sandbox.paypal.com/', 'url_api' => 'https://api-3t.sandbox.paypal.com/', 'url_button' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif', 'class_name' => 'Payment_PayPalImpl', 'billing_mode' => 3, 'financial_type_id' => 1); $paymentProcessor->copyValues($paymentParams); $paymentProcessor->save(); return $paymentProcessor->id; }
/** * Get details about the CMS User entity. * * @param array $params * * @return array */ function civicrm_api3_user_get($params) { if (empty($params['contact_id'])) { $params['contact_id'] = civicrm_api3('UFMatch', 'getvalue', array('uf_id' => $params['id'], 'domain_id' => CRM_Core_Config::domainID(), 'return' => 'contact_id')); } $result = CRM_Core_Config::singleton()->userSystem->getUser($params['contact_id']); $result['contact_id'] = $params['contact_id']; return civicrm_api3_create_success(array($result['id'] => $result), $params, 'user', 'get'); }
/** * Adjust metadata for "Create" action. * * The metadata is used for setting defaults, documentation & validation. * * @param array $params * Array of parameters determined by getfields. */ function _civicrm_api3_job_create_spec(&$params) { $params['run_frequency']['api.required'] = 1; $params['name']['api.required'] = 1; $params['api_entity']['api.required'] = 1; $params['api_action']['api.required'] = 1; $params['domain_id']['api.default'] = CRM_Core_Config::domainID(); $params['is_active']['api.default'] = 1; }
/** * Adjust metadata for navigation reset action. * * @param array $params */ function _civicrm_api3_navigation_reset_spec(&$params) { $params['for']['api.required'] = TRUE; $params['for']['title'] = "Is this reset for all navigation or reports"; $params['for']['type'] = CRM_Utils_Type::T_STRING; $params['for']['options'] = array('all' => 'General Navigation rebuild from xml', 'report' => 'Reset report menu to default structure'); $params['domain_id']['api.default'] = CRM_Core_Config::domainID(); $params['domain_id']['type'] = CRM_Utils_Type::T_INT; $params['domain_id']['title'] = 'Domain ID'; }
function &saveUFMatch($contact_id, $uf_id, $uf_name) { require_once 'CRM/Core/DAO/UFMatch.php'; $ufmatch =& new CRM_Core_DAO_UFMatch(); $ufmatch->domain_id = CRM_Core_Config::domainID(); $ufmatch->contact_id = $contact_id; $ufmatch->uf_id = $uf_id; $ufmatch->uf_name = $uf_name; return $ufmatch->save(); }
function __construct($name, $timeout = null) { $config = CRM_Core_Config::singleton(); $dsnArray = DB::parseDSN($config->dsn); $database = $dsnArray['database']; $domainID = CRM_Core_Config::domainID(); $this->_name = $database . '.' . $domainID . '.' . $name; $this->_timeout = $timeout ? $timeout : self::TIMEOUT; $this->acquire(); }
function preProcess() { CRM_Utils_System::setTitle(ts('Domain Information')); $breadCrumbPath = CRM_Utils_System::url('civicrm/admin', 'reset=1'); CRM_Utils_System::appendBreadCrumb(ts('Administer CiviCRM'), $breadCrumbPath); $this->_id = CRM_Core_Config::domainID(); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'view'); //location blocks. CRM_Contact_Form_Location::preProcess($this); }
/** * Return the DAO object containing to the default row of * civicrm_mail_settings and cache it for further calls * * @return object DAO with the default mail settings set */ static function &defaultDAO() { static $dao = null; if (!$dao) { $dao = new self(); $dao->is_default = 1; $dao->domain_id = CRM_Core_Config::domainID(); $dao->find(true); } return $dao; }
static function registerScripts() { static $loaded = FALSE; if ($loaded) { return; } $loaded = TRUE; CRM_Core_Resources::singleton()->addSettingsFactory(function () { $config = CRM_Core_Config::singleton(); return array('PseudoConstant' => array('locationType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), 'job_hours_time' => CRM_Hrjobcontract_Page_JobContractTab::getJobHoursTime(), 'working_days' => CRM_Hrjobcontract_Page_JobContractTab::getDaysPerTime()), 'FieldOptions' => CRM_Hrjobcontract_Page_JobContractTab::getFieldOptions(), 'jobContractTabApp' => array('contactId' => CRM_Utils_Request::retrieve('cid', 'Integer'), 'domainId' => CRM_Core_Config::domainID(), 'isLogEnabled' => (bool) $config->logging, 'loggingReportId' => CRM_Report_Utils_Report::getInstanceIDForValue('logging/contact/summary'), 'currencies' => CRM_Hrjobcontract_Page_JobContractTab::getCurrencyFormats(), 'defaultCurrency' => $config->defaultCurrency, 'path' => CRM_Core_Resources::singleton()->getUrl('org.civicrm.hrjobcontract'), 'fields' => CRM_Hrjobcontract_Page_JobContractTab::getFields(), 'contractList' => CRM_Hrjobcontract_Page_JobContractTab::getContractList(), 'maxFileSize' => file_upload_max_size()), 'debug' => $config->debug); }); }
/** * takes an associative array and creates a financial transaction object * * @param array $params (reference ) an assoc array of name/value pairs * * @return object CRM_Contribute_BAO_FinancialTrxn object * @access public * @static */ function create(&$params) { $trxn =& new CRM_Contribute_DAO_FinancialTrxn(); $trxn->copyValues($params); $trxn->domain_id = CRM_Core_Config::domainID(); require_once 'CRM/Utils/Rule.php'; if (!CRM_Utils_Rule::currencyCode($contribution->currency)) { require_once 'CRM/Core/Config.php'; $config =& CRM_Core_Config::singleton(); $contribution->currency = $config->defaultCurrency; } return $trxn->save(); }