/**
  * Form submission of new/edit api is processed.
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     //get the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     // Save the API Key & Save the Security Key
     if (CRM_Utils_Array::value('api_key', $params)) {
         CRM_Core_BAO_Setting::setItem($params['api_key'], self::MC_SETTING_GROUP, 'api_key');
     }
     $session = CRM_Core_Session::singleton();
     $message = "Api Key has been Saved!";
     $session->setStatus($message, ts('Api Key Saved'), 'success');
     $urlParams = null;
     $session->replaceUserContext(CRM_Utils_System::url('civicrm/mailchimp/apikeyregister', $urlParams));
     try {
         $mcClient = new Mailchimp($params['api_key']);
         $mcHelper = new Mailchimp_Helper($mcClient);
         $details = $mcHelper->accountDetails();
     } catch (Mailchimp_Invalid_ApiKey $e) {
         CRM_Core_Session::setStatus($e->getMessage());
         return FALSE;
     } catch (Mailchimp_HttpError $e) {
         CRM_Core_Session::setStatus($e->getMessage());
         return FALSE;
     }
     $message = "Following is the account information received from API callback:<br/>\n        <table class='mailchimp-table'>\n        <tr><td>Company:</td><td>{$details['contact']['company']}</td></tr>\n        <tr><td>First Name:</td><td>{$details['contact']['fname']}</td></tr>\n        <tr><td>Last Name:</td><td>{$details['contact']['lname']}</td></tr>\n        </table>";
     CRM_Core_Session::setStatus($message);
 }
コード例 #2
0
 function run()
 {
     // title
     CRM_Utils_System::setTitle(ts('WindowSill'));
     // config
     // https://github.com/kreynen/civicrm-min/blob/master/CRM/Core/Extensions.php
     $config = CRM_Core_Config::singleton();
     if ($config->userFramework != 'Drupal') {
         $error = "<div class='messages status no-popup'><div class='icon inform-icon'></div>Not a Drupal installation</div>";
     } else {
         $error = "<div class='messages status no-popup'><div class='icon inform-icon'></div>Drupal installation</div>";
     }
     // error
     $this->assign('error', $error);
     // on form action update settings
     if (isset($_REQUEST['settings'])) {
         // set
         CRM_Core_BAO_Setting::setItem($_REQUEST['settings'], 'windowsill', 'settings');
         // notice
         CRM_Core_Session::setStatus(ts('Windowsill settings changed'), ts('Saved'), 'success');
     }
     // url
     $url = CRM_Utils_System::url() . "civicrm/ctrl/windowsill";
     $this->assign('url', $url);
     // render
     parent::run();
 }
コード例 #3
0
/**
 * Implements hook_civicrm_install().
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
 */
function overrides_civicrm_install()
{
    CRM_Core_DAO::executeQuery("\n    CREATE TABLE `klangsoft_overrides` (\n      `snapshot` text NOT NULL\n    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
    CRM_Core_DAO::executeQuery("INSERT INTO `klangsoft_overrides` VALUES ('a:0:{}');");
    CRM_Core_BAO_Setting::setItem('', 'com.klangsoft_overrides', 'last_snapshot');
    _overrides_civix_civicrm_install();
}
コード例 #4
0
 /**
  * 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;
 }
コード例 #5
0
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     // Store the submitted values in an array.
     $params = $this->controller->exportValues($this->_name);
     if (CRM_Utils_Array::value('activity_type', $params)) {
         CRM_Core_BAO_Setting::setItem($params['activity_type'], self::OUTLOOK_SETTING_GROUP, 'activity_type');
     }
     CRM_Core_Session::setStatus(ts('Changes saved!'), ts('Outlook Settings'), 'success');
 }
コード例 #6
0
/**
 * Implementation of hook_civicrm_disable
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable
 */
function windowsill_civicrm_disable()
{
    // log
    watchdog('be.ctrl.windowsill', 'disabled windowsill');
    // assign
    CRM_Core_BAO_Setting::setItem('', 'windowsill', 'settings');
    // continue
    _windowsill_civix_civicrm_disable();
}
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function postProcess()
 {
     $values = $this->exportValues();
     $settings = new stdClass();
     $settings->globally_enabled = empty($values['globally_enabled']) ? 0 : 1;
     $settings->financial_types_enabled = $values['financial_types_enabled'];
     CRM_Core_BAO_Setting::setItem($settings, 'Extension', 'uk.co.compucorp.civicrm.giftaid:settings');
     CRM_Core_Session::setStatus(ts('Settings saved'), '', 'success');
     parent::postProcess();
 }
コード例 #8
0
 function postProcess()
 {
     $values = $this->exportValues();
     foreach (array('qfKey', '_qf_default', '_qf_IatsSettings_submit', 'entryURL') as $key) {
         if (isset($values[$key])) {
             unset($values[$key]);
         }
     }
     CRM_Core_BAO_Setting::setItem($values, 'iATS Payments Extension', 'iats_settings');
     parent::postProcess();
 }
コード例 #9
0
 function postProcess()
 {
     $values = $this->exportValues();
     // process menu entry
     $old_menu_position = (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'menu_position');
     $new_menu_position = (int) $values['menu_position'];
     if ($old_menu_position != $new_menu_position) {
         CRM_Core_BAO_Setting::setItem($new_menu_position, 'CiviBanking', 'menu_position');
         CRM_Core_Invoke::rebuildMenuAndCaches();
     }
     parent::postProcess();
 }
コード例 #10
0
 function postProcess()
 {
     $values = $this->exportValues();
     CRM_Core_BAO_Setting::setItem($values['metrics_reporting_url'], "metrics", "metrics_reporting_url");
     CRM_Core_BAO_Setting::setItem($values['metrics_site_name'], "metrics", "metrics_site_name");
     CRM_Core_BAO_Setting::setItem($values['metrics_ca_path'], "metrics", "metrics_ca_path");
     $peer = array_key_exists("metrics_ignore_verify_peer", $values) ? $values['metrics_ignore_verify_peer'] : 0;
     CRM_Core_BAO_Setting::setItem($peer, "metrics", "metrics_ignore_verify_peer");
     $host = array_key_exists("metrics_ignore_verify_host", $values) ? $values['metrics_ignore_verify_host'] : 0;
     CRM_Core_BAO_Setting::setItem($host, "metrics", "metrics_ignore_verify_host");
     CRM_Core_Session::setStatus(ts("Changed Saved"), "Saved", "success");
     parent::postProcess();
 }
コード例 #11
0
 function postProcess()
 {
     $group = "CiviCRM Mobile";
     $values = $this->controller->exportValues($this->_name);
     $keys = array('ind_profile_id', 'org_profile_id', 'house_profile_id');
     while (list(, $key) = each($keys)) {
         if (array_key_exists($key, $values)) {
             CRM_Core_BAO_Setting::setItem($values[$key], $group, $key);
         }
     }
     $session = CRM_Core_Session::singleton();
     $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/setting/mobile'));
 }
コード例 #12
0
 /**
  * Handle the data submitted
  */
 function postProcess()
 {
     $values = $this->exportValues();
     if ($values['securefiles_backend_service'] != $this->backend_service_class) {
         CRM_Core_BAO_Setting::setItem($values['securefiles_backend_service'], "securefiles", "securefiles_backend_service");
         CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/securefiles/settings'));
         return;
     }
     if ($this->backend_service) {
         $this->backend_service->saveSettings($values);
     }
     parent::postProcess();
     CRM_Core_Session::setStatus(ts("Settings Saved"), '', 'success');
 }
コード例 #13
0
 function postProcess()
 {
     $values = $this->exportValues();
     // process menu entry
     $old_menu_position = (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'menu_position');
     $new_menu_position = (int) $values['menu_position'];
     if ($old_menu_position != $new_menu_position) {
         CRM_Core_BAO_Setting::setItem($new_menu_position, 'CiviBanking', 'menu_position');
         CRM_Core_Invoke::rebuildMenuAndCaches();
     }
     // process reference normalisation / validation
     CRM_Core_BAO_Setting::setItem(!empty($values['reference_normalisation']), 'CiviBanking', 'reference_normalisation');
     CRM_Core_BAO_Setting::setItem(!empty($values['reference_validation']), 'CiviBanking', 'reference_validation');
     parent::postProcess();
 }
コード例 #14
0
 function run()
 {
     // title
     CRM_Utils_System::setTitle(ts('SuperStyler'));
     // variables
     $url = CRM_Utils_System::baseURL() . 'civicrm/ctrl/superstyler';
     $this->assign('url', $url);
     // get settings
     $settings = CRM_Core_BAO_Setting::getItem('superstyler', 'settings');
     $decode = json_decode(utf8_decode($settings), true);
     // on form action
     if (isset($_REQUEST['color'])) {
         // clear
         foreach ($decode['superstyler'] as $key => $value) {
             if ($value['name'] == $_REQUEST['color']) {
                 $decode['superstyler'][$key]['active'] = 1;
             } else {
                 $decode['superstyler'][$key]['active'] = 0;
             }
         }
         // set
         $encode = json_encode($decode);
         CRM_Core_BAO_Setting::setItem($encode, 'superstyler', 'settings');
         // notice
         CRM_Core_Session::setStatus(ts('Superstyler settings changed'), ts('Saved'), 'success');
     }
     // form
     $form = "";
     $form .= "<form action=" . $url . " method='post'>";
     $form .= "<label>Select stylesheet</label>";
     $form .= "<div class='listing-box'>";
     // loop
     foreach ($decode['superstyler'] as $key => $value) {
         $v = $value['name'];
         if ($value['active'] == 1) {
             $form .= "<input type='radio' id='css_{$v}' name='color' value='{$v}' checked><label for='css_{$v}' >{$v}</label><br>";
         } else {
             $form .= "<input type='radio' id='css_{$v}' name='color' value='{$v}'><label for='css_{$v}' >{$v}</label><br>";
         }
     }
     $form .= "</div>";
     $form .= "<div class='crm-submit-buttons'><span class='crm-button'><input class='crm-form-submit default' type='submit' value='Submit'></span></div>";
     $form .= "</form>";
     // assign form
     $this->assign('content', $form);
     // render
     parent::run();
 }
コード例 #15
0
 public function postProcess()
 {
     // check if mailing tab is enabled, if not prompt user to enable the tab if "write_activity_record" is disabled
     $params = $this->controller->exportValues($this->_name);
     if (empty($params['write_activity_record'])) {
         $existingViewOptions = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_view_options');
         $displayValue = CRM_Core_OptionGroup::getValue('contact_view_options', 'CiviMail', 'name');
         $viewOptions = explode(CRM_Core_DAO::VALUE_SEPARATOR, $existingViewOptions);
         if (!in_array($displayValue, $viewOptions)) {
             $existingViewOptions .= $displayValue . CRM_Core_DAO::VALUE_SEPARATOR;
             CRM_Core_BAO_Setting::setItem($existingViewOptions, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_view_options');
             CRM_Core_Session::setStatus(ts('We have automatically enabled the Mailings tab for the Contact Summary screens
     so that you can view mailings sent to each contact.'), ts('Saved'), 'success');
         }
     }
     parent::postProcess();
 }
コード例 #16
0
 function postProcess()
 {
     $params = $this->exportValues();
     // Save the API Key & Save the Security Key
     //if (CRM_Utils_Array::value('api_email_address', $params) || CRM_Utils_Array::value('api_password', $params)) {
     CRM_Core_BAO_Setting::setItem($params['api_email_address'], self::DOTMAILER_SETTING_GROUP, 'api_email_address');
     CRM_Core_BAO_Setting::setItem($params['api_password'], self::DOTMAILER_SETTING_GROUP, 'api_password');
     //}
     CRM_Core_BAO_Setting::setItem($params['api_audience_type'], self::DOTMAILER_SETTING_GROUP, 'api_audience_type');
     CRM_Core_BAO_Setting::setItem($params['api_opt_in_type'], self::DOTMAILER_SETTING_GROUP, 'api_opt_in_type');
     CRM_Core_BAO_Setting::setItem($params['api_email_type'], self::DOTMAILER_SETTING_GROUP, 'api_email_type');
     CRM_Core_BAO_Setting::setItem($params['api_notes'], self::DOTMAILER_SETTING_GROUP, 'api_notes');
     /*$activityTypeStr = @serialize($params['activity_types']);
       CRM_Core_BAO_Setting::setItem($activityTypeStr,
         self::DOTMAILER_SETTING_GROUP,
         'activity_types'
       );*/
     $message = ts('Settings saved.');
     CRM_Core_Session::setStatus($message, 'Dotmailer', 'success');
 }
コード例 #17
0
ファイル: ProxySettings.php プロジェクト: systopia/CiviProxy
 function postProcess()
 {
     // process all form values and save valid settings
     $values = $this->exportValues();
     // checkboxes
     CRM_Core_BAO_Setting::setItem(!empty($values['proxy_enabled']), 'CiviProxy Settings', 'proxy_enabled');
     // text
     if (isset($values['proxy_url'])) {
         CRM_Core_BAO_Setting::setItem($values['proxy_url'], 'CiviProxy Settings', 'proxy_url');
     }
     if (isset($values['custom_mailing_base'])) {
         // check if it is simply default ({$proxy_url}/mailing)
         if ($values['custom_mailing_base'] == $values['proxy_url'] . '/mailing') {
             // ...in which case we'll simply set it to ''
             $values['custom_mailing_base'] = '';
         }
         CRM_Core_BAO_Setting::setItem($values['custom_mailing_base'], 'CiviProxy Settings', 'custom_mailing_base');
     }
     // give feedback to user
     $session = CRM_Core_Session::singleton();
     $session->setStatus(ts("Settings successfully saved"), ts('Settings'), 'success');
     $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/setting/civiproxy'));
 }
コード例 #18
0
 /**
  * Process the form after the input has been submitted and validated.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     // store the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     unset($params['qfKey']);
     unset($params['entryURL']);
     $setInvoiceSettings = CRM_Core_BAO_Setting::setItem($params, CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
     // to set default value for 'Invoices / Credit Notes' checkbox on display preferences
     $values = CRM_Core_BAO_Setting::getItem("CiviCRM Preferences");
     $optionValues = CRM_Core_OptionGroup::values('user_dashboard_options', FALSE, FALSE, FALSE, NULL, 'name');
     $setKey = array_search('Invoices / Credit Notes', $optionValues);
     if (isset($params['invoicing'])) {
         $value = array($setKey => $optionValues[$setKey]);
         $setInvoice = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($value)) . CRM_Core_DAO::VALUE_SEPARATOR;
         CRM_Core_BAO_Setting::setItem($values['user_dashboard_options'] . $setInvoice, 'CiviCRM Preferences', 'user_dashboard_options');
     } else {
         $setting = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values['user_dashboard_options'], 1, -1));
         $invoiceKey = array_search($setKey, $setting);
         unset($setting[$invoiceKey]);
         $settingName = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_values($setting)) . CRM_Core_DAO::VALUE_SEPARATOR;
         CRM_Core_BAO_Setting::setItem($settingName, 'CiviCRM Preferences', 'user_dashboard_options');
     }
 }
コード例 #19
0
 public function setUp()
 {
     parent::setUp();
     $this->_individualId = $this->individualCreate();
     $this->_orgId = $this->organizationCreate(NULL);
     $this->params = array('title' => "Test Contribution Page" . substr(sha1(rand()), 0, 7), 'financial_type_id' => 1, 'payment_processor' => 1, 'currency' => 'NZD', 'goal_amount' => 350, 'is_pay_later' => 1, 'pay_later_text' => 'I will pay later', 'pay_later_receipt' => "I will pay later", 'is_monetary' => TRUE, 'is_billing_required' => TRUE);
     $this->_priceSetParams = array('name' => 'tax_contribution' . substr(sha1(rand()), 0, 7), 'title' => 'contributiontax' . substr(sha1(rand()), 0, 7), 'is_active' => 1, 'help_pre' => "Where does your goat sleep", 'help_post' => "thank you for your time", 'extends' => 2, 'financial_type_id' => 3, 'is_quick_config' => 0, 'is_reserved' => 0);
     // Financial Account with 20% tax rate
     $financialAccountSetparams = array('name' => 'vat full taxrate account' . substr(sha1(rand()), 0, 7), 'contact_id' => $this->_orgId, 'financial_account_type_id' => 2, 'is_tax' => 1, 'tax_rate' => 20.0, 'is_reserved' => 0, 'is_active' => 1, 'is_default' => 0);
     $financialAccount = $this->callAPISuccess('financial_account', 'create', $financialAccountSetparams);
     $this->financialAccountId = $financialAccount['id'];
     // Financial type having 'Sales Tax Account is' with liability financail account
     $financialType = array('name' => 'grassvariety1' . substr(sha1(rand()), 0, 7), 'is_reserved' => 0, 'is_active' => 1);
     $priceField = $this->callAPISuccess('financial_type', 'create', $financialType);
     $this->financialtypeID = $priceField['id'];
     $financialRelationParams = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $this->financialtypeID, 'account_relationship' => 10, 'financial_account_id' => $this->financialAccountId);
     $financialRelation = CRM_Financial_BAO_FinancialTypeAccount::add($financialRelationParams);
     // Financial type with 5% tax rate
     $financialAccHalftax = array('name' => 'vat half taxrate account' . substr(sha1(rand()), 0, 7), 'contact_id' => $this->_orgId, 'financial_account_type_id' => 2, 'is_tax' => 1, 'tax_rate' => 5.0, 'is_reserved' => 0, 'is_active' => 1, 'is_default' => 0);
     $halfFinancialAccount = CRM_Financial_BAO_FinancialAccount::add($financialAccHalftax);
     $this->halfFinancialAccId = $halfFinancialAccount->id;
     $halfFinancialtypeHalftax = array('name' => 'grassvariety2' . substr(sha1(rand()), 0, 7), 'is_reserved' => 0, 'is_active' => 1);
     $halfFinancialType = CRM_Financial_BAO_FinancialType::add($halfFinancialtypeHalftax);
     $this->halfFinancialTypeId = $halfFinancialType->id;
     $financialRelationHalftax = array('entity_table' => 'civicrm_financial_type', 'entity_id' => $this->halfFinancialTypeId, 'account_relationship' => 10, 'financial_account_id' => $this->halfFinancialAccId);
     $halfFinancialRelation = CRM_Financial_BAO_FinancialTypeAccount::add($financialRelationHalftax);
     // Enable component contribute setting
     $contributeSetting = array('invoicing' => 1, 'invoice_prefix' => 'INV_', 'credit_notes_prefix' => 'CN_', 'due_date' => 10, 'due_date_period' => 'days', 'notes' => '', 'is_email_pdf' => 1, 'tax_term' => 'Sales Tax', 'tax_display_settings' => 'Inclusive');
     $setInvoiceSettings = CRM_Core_BAO_Setting::setItem($contributeSetting, CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
     // Payment Processor
     $paymentProceParams = array('domain_id' => 1, 'name' => 'dummy' . substr(sha1(rand()), 0, 7), 'payment_processor_type_id' => 10, 'financial_account_id' => 12, 'is_active' => 1, 'is_default' => 1, 'user_name' => 'dummy', 'url_site' => 'http://dummy.com', 'url_recur' => 'http://dummyrecur.com', 'class_name' => 'Payment_Dummy', 'billing_mode' => 1, 'is_recur' => 1, 'payment_type' => 1);
     $result = $this->callAPISuccess('payment_processor', 'create', $paymentProceParams);
     $this->_ids['paymentProcessID'] = $result['id'];
     require_once 'api/v3/examples/PaymentProcessor/Create.php';
     $this->assertAPISuccess($result);
 }
コード例 #20
0
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     // Store the submitted values in an array.
     $params = $this->controller->exportValues($this->_name);
     // Save the API Key & Save the Security Key
     if (CRM_Utils_Array::value('api_key', $params) || CRM_Utils_Array::value('security_key', $params)) {
         CRM_Core_BAO_Setting::setItem($params['api_key'], self::MC_SETTING_GROUP, 'api_key');
         CRM_Core_BAO_Setting::setItem($params['security_key'], self::MC_SETTING_GROUP, 'security_key');
         CRM_Core_BAO_Setting::setItem($params['enable_debugging'], self::MC_SETTING_GROUP, 'enable_debugging');
         try {
             $mcClient = new Mailchimp($params['api_key']);
             $mcHelper = new Mailchimp_Helper($mcClient);
             $details = $mcHelper->accountDetails();
         } catch (Mailchimp_Invalid_ApiKey $e) {
             CRM_Core_Session::setStatus($e->getMessage());
             return FALSE;
         } catch (Mailchimp_HttpError $e) {
             CRM_Core_Session::setStatus($e->getMessage());
             return FALSE;
         }
         $message = "Following is the account information received from API callback:<br/>\n        <table class='mailchimp-table'>\n        <tr><td>Company:</td><td>{$details['contact']['company']}</td></tr>\n        <tr><td>First Name:</td><td>{$details['contact']['fname']}</td></tr>\n        <tr><td>Last Name:</td><td>{$details['contact']['lname']}</td></tr>\n        </table>";
         CRM_Core_Session::setStatus($message);
     }
 }
コード例 #21
0
 /**
  * Process the form submission.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     CRM_Utils_System::flushCache('CRM_Core_DAO_Job');
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_BAO_Job::del($this->_id);
         CRM_Core_Session::setStatus("", ts('Scheduled Job Deleted.'), "success");
         return;
     }
     $values = $this->controller->exportValues($this->_name);
     $domainID = CRM_Core_Config::domainID();
     $dao = new CRM_Core_DAO_Job();
     $dao->id = $this->_id;
     $dao->domain_id = $domainID;
     $dao->run_frequency = $values['run_frequency'];
     $dao->parameters = $values['parameters'];
     $dao->name = $values['name'];
     $dao->api_entity = $values['api_entity'];
     $dao->api_action = $values['api_action'];
     $dao->description = $values['description'];
     $dao->is_active = CRM_Utils_Array::value('is_active', $values, 0);
     $dao->save();
     /************************************
      * begin com.klangsoft.flexiblejobs *
      ************************************/
     $ts = strtotime($values['schedule_at']);
     if ($ts < time()) {
         $ts = null;
     }
     CRM_Core_BAO_Setting::setItem($ts ?: null, 'com.klangsoft.flexiblejobs', 'job_' . $dao->id);
     /**********************************
      * end com.klangsoft.flexiblejobs *
      **********************************/
     // CRM-11143 - Give warning message if update_greetings is Enabled (is_active) since it generally should not be run automatically via execute action or runjobs url.
     if ($values['api_action'] == 'update_greeting' && CRM_Utils_Array::value('is_active', $values) == 1) {
         // pass "wiki" as 6th param to docURL2 if you are linking to a page in wiki.civicrm.org
         $docLink = CRM_Utils_System::docURL2("Managing Scheduled Jobs", NULL, NULL, NULL, NULL, "wiki");
         $msg = ts('The update greeting job can be very resource intensive and is typically not necessary to run on a regular basis. If you do choose to enable the job, we recommend you do not run it with the force=1 option, which would rebuild greetings on all records. Leaving that option absent, or setting it to force=0, will only rebuild greetings for contacts that do not currently have a value stored. %1', array(1 => $docLink));
         CRM_Core_Session::setStatus($msg, ts('Warning: Update Greeting job enabled'), 'alert');
     }
 }
コード例 #22
0
 static function setUpBeforeClass()
 {
     // Use the Mailchimp API test class for all the tests.
     CRM_Core_BAO_Setting::setItem('CRM_MailchimpMock', 'CiviMailchimp Preferences', 'mailchimp_api_class');
 }
コード例 #23
0
 public function setCurrentRevision($revision)
 {
     // We call this during hook_civicrm_install, but the underlying SQL
     // UPDATE fails because the extension record hasn't been INSERTed yet.
     // Instead, track revisions in our own namespace.
     // CRM_Core_BAO_Extension::setSchemaVersion($this->extensionName, $revision);
     $key = $this->extensionName . ':version';
     CRM_Core_BAO_Setting::setItem($revision, 'Extension', $key);
     return TRUE;
 }
コード例 #24
0
 public function stop()
 {
     if ($this->_webtest) {
         if ($this->_outBound_option != CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB) {
             // Change outbound mail setting
             $this->_ut->openCiviPage('admin/setting/smtp', "reset=1", "_qf_Smtp_next");
             $this->_ut->click('xpath=//input[@name="outBound_option" and @value="' . $this->_outBound_option . '"]');
             // There will be a warning when switching from test to live mode
             if ($this->_outBound_option != CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED) {
                 $this->_ut->getAlert();
             }
             $this->_ut->clickLink("_qf_Smtp_next");
         }
     } else {
         $mailingBackend = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend');
         $mailingBackend['outBound_option'] = $this->_outBound_option;
         CRM_Core_BAO_Setting::setItem($mailingBackend, CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailing_backend');
     }
 }
コード例 #25
0
 /**
  * @return bool
  */
 public function needsRunning()
 {
     /************************************
      * begin com.klangsoft.flexiblejobs *
      ************************************/
     // check if the job has a specificly scheduled date/time
     $key = 'job_' . $this->id;
     $ts = CRM_Core_BAO_Setting::getItem('com.klangsoft.flexiblejobs', $key);
     if (!is_null($ts)) {
         if ($ts < time()) {
             CRM_Core_BAO_Setting::setItem(NULL, 'com.klangsoft.flexiblejobs', $key);
             return TRUE;
         } else {
             return FALSE;
         }
     }
     /**********************************
      * end com.klangsoft.flexiblejobs *
      **********************************/
     // run if it was never run
     if (empty($this->last_run)) {
         return TRUE;
     }
     // run_frequency check
     switch ($this->run_frequency) {
         case 'Always':
             return TRUE;
             /************************************
              * begin com.klangsoft.flexiblejobs *
              ************************************/
         /************************************
          * begin com.klangsoft.flexiblejobs *
          ************************************/
         case 'Yearly':
             $offset = '+1 year';
             break;
         case 'Quarter':
             $offset = '+3 months';
             break;
         case 'Monthly':
             $offset = '+1 month';
             break;
         case 'Weekly':
             $offset = '+1 week';
             break;
         case 'Daily':
             $offset = '+1 day';
             break;
         case 'Hourly':
             $offset = '+1 hour';
             break;
     }
     $now = strtotime(CRM_Utils_Date::currentDBDate());
     $lastTime = strtotime($this->last_run);
     $nextTime = strtotime($offset, $lastTime);
     return $now >= $nextTime;
     /**********************************
      * end com.klangsoft.flexiblejobs *
      **********************************/
 }
コード例 #26
0
ファイル: FourSeven.php プロジェクト: nganivet/civicrm-core
 /**
  * CRM-16354
  *
  * @return int
  */
 public static function updateWysiwyg()
 {
     $editorID = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'editor_id');
     // Previously a numeric value indicated one of 4 wysiwyg editors shipped in core, and no value indicated 'Textarea'
     // Now the options are "Textarea", "CKEditor", and the rest have been dropped from core.
     $newEditor = $editorID ? "CKEditor" : "Textarea";
     CRM_Core_BAO_Setting::setItem($newEditor, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'editor_id');
     return $editorID;
 }
コード例 #27
0
 /**
  * Process the form submission.
  *
  *
  * @return void
  */
 public function postProcess()
 {
     CRM_Utils_System::flushCache('CRM_Core_DAO_Job');
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_BAO_Job::del($this->_id);
         CRM_Core_Session::setStatus("", ts('Scheduled Job Deleted.'), "success");
         return;
     }
     $values = $this->controller->exportValues($this->_name);
     $domainID = CRM_Core_Config::domainID();
     $dao = new CRM_Core_DAO_Job();
     $dao->id = $this->_id;
     $dao->domain_id = $domainID;
     $dao->run_frequency = $values['run_frequency'];
     $dao->parameters = $values['parameters'];
     $dao->name = $values['name'];
     $dao->api_entity = $values['api_entity'];
     $dao->api_action = $values['api_action'];
     $dao->description = $values['description'];
     $dao->is_active = CRM_Utils_Array::value('is_active', $values, 0);
     $dao->save();
     /************************************
      * begin com.klangsoft.flexiblejobs *
      ************************************/
     $ts = strtotime(trim("{$values['schedule_at']} {$values['schedule_at_time']}"));
     if ($ts < time()) {
         $ts = NULL;
     } else {
         // warn about monthly/quarterly scheduling, if applicable
         if ($dao->run_frequency == 'Monthly' || $dao->run_frequency == 'Quarter') {
             $info = getdate($ts);
             if ($info['mday'] > 28) {
                 CRM_Core_Session::setStatus(ts('Relative month values are calculated based on the length of month(s) that they pass through.
           The result will land on the same day of the month except for days 29-31 when the target month contains fewer days than the previous month.
           For example, if a job is scheduled to run on August 31st, the following invocation will occur on October 1st, and then the 1st of every month thereafter.
           To avoid this issue, please schedule Monthly and Quarterly jobs to run within the first 28 days of the month.'), ts('Warning'), 'info', array('expires' => 0));
             }
         }
     }
     CRM_Core_BAO_Setting::setItem($ts ?: NULL, 'com.klangsoft.flexiblejobs', 'job_' . $dao->id);
     /**********************************
      * end com.klangsoft.flexiblejobs *
      **********************************/
     // CRM-11143 - Give warning message if update_greetings is Enabled (is_active) since it generally should not be run automatically via execute action or runjobs url.
     if ($values['api_action'] == 'update_greeting' && CRM_Utils_Array::value('is_active', $values) == 1) {
         // pass "wiki" as 6th param to docURL2 if you are linking to a page in wiki.civicrm.org
         $docLink = CRM_Utils_System::docURL2("Managing Scheduled Jobs", NULL, NULL, NULL, NULL, "wiki");
         $msg = ts('The update greeting job can be very resource intensive and is typically not necessary to run on a regular basis. If you do choose to enable the job, we recommend you do not run it with the force=1 option, which would rebuild greetings on all records. Leaving that option absent, or setting it to force=0, will only rebuild greetings for contacts that do not currently have a value stored. %1', array(1 => $docLink));
         CRM_Core_Session::setStatus($msg, ts('Warning: Update Greeting job enabled'), 'alert');
     }
 }
コード例 #28
0
 public static function iats_extension_version()
 {
     $version = CRM_Core_BAO_Setting::getItem('iATS Payments Extension', 'iats_extension_version');
     if (empty($version)) {
         $xmlfile = CRM_Core_Resources::singleton()->getUrl('com.iatspayments.civicrm', 'info.xml');
         $myxml = simplexml_load_file($xmlfile);
         $version = (string) $myxml->version;
         CRM_Core_BAO_Setting::setItem($version, 'iATS Payments Extension', 'iats_extension_version');
     }
     return $version;
 }
コード例 #29
0
ファイル: Resources.php プロジェクト: nganivet/civicrm-core
 /**
  * @param $value
  * @return CRM_Core_Resources
  */
 public function setCacheCode($value)
 {
     $this->cacheCode = $value;
     if ($this->cacheCodeKey) {
         CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, $this->cacheCodeKey);
     }
     return $this;
 }
コード例 #30
0
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcessCommon()
 {
     foreach ($this->_varNames as $groupName => $groupValues) {
         foreach ($groupValues as $settingName => $fieldValue) {
             switch ($fieldValue['html_type']) {
                 case 'checkboxes':
                     if (CRM_Utils_Array::value($settingName, $this->_params) && is_array($this->_params[$settingName])) {
                         $this->_config->{$settingName} = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($this->_params[$settingName])) . CRM_Core_DAO::VALUE_SEPARATOR;
                     } else {
                         $this->_config->{$settingName} = NULL;
                     }
                     break;
                 case 'checkbox':
                     $this->_config->{$settingName} = CRM_Utils_Array::value($settingName, $this->_params) ? 1 : 0;
                     break;
                 case 'text':
                 case 'select':
                     $this->_config->{$settingName} = CRM_Utils_Array::value($settingName, $this->_params);
                     break;
                 case 'textarea':
                     $value = CRM_Utils_Array::value($settingName, $this->_params);
                     if ($value) {
                         $value = trim($value);
                         $value = str_replace(array("\r\n", "\r"), "\n", $value);
                     }
                     $this->_config->{$settingName} = $value;
                     break;
             }
         }
     }
     foreach ($this->_varNames as $groupName => $groupValues) {
         foreach ($groupValues as $settingName => $fieldValue) {
             $settingValue = isset($this->_config->{$settingName}) ? $this->_config->{$settingName} : NULL;
             CRM_Core_BAO_Setting::setItem($settingValue, $groupName, $settingName);
         }
     }
     CRM_Core_Session::setStatus(ts('Your changes have been saved.'));
 }