Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated function calls #379

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions CRM/Admin/Form/Setting/BankingSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,19 @@ function buildQuickForm() {
function setDefaultValues() {
$defaults = array();

$defaults['new_ui'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'new_ui');
$defaults['menu_position'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'menu_position');
$defaults['json_editor_mode'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'json_editor_mode');
$defaults['banking_log_level'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'banking_log_level');
$defaults['banking_log_file'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'banking_log_file');
$defaults['reference_store_disabled'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_store_disabled');
$defaults['reference_normalisation'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_normalisation');
$defaults['reference_matching_probability'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_matching_probability');
$defaults['new_ui'] = Civi::settings()->get('new_ui');
$defaults['menu_position'] = Civi::settings()->get('menu_position');
$defaults['json_editor_mode'] = Civi::settings()->get('json_editor_mode');
$defaults['banking_log_level'] = Civi::settings()->get('banking_log_level');
$defaults['banking_log_file'] = Civi::settings()->get('banking_log_file');
$defaults['reference_store_disabled'] = Civi::settings()->get('reference_store_disabled');
$defaults['reference_normalisation'] = Civi::settings()->get('reference_normalisation');
$defaults['reference_matching_probability'] = Civi::settings()->get('reference_matching_probability');
if ($defaults['reference_matching_probability'] === null) {
$defaults['reference_matching_probability'] = '1.0';
}
$defaults['reference_validation'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_validation');
$defaults['lenient_dedupe'] = CRM_Core_BAO_Setting::getItem('CiviBanking', 'lenient_dedupe');
$defaults['reference_validation'] = Civi::settings()->get('reference_validation');
$defaults['lenient_dedupe'] = Civi::settings()->get('lenient_dedupe');

return $defaults;
}
Expand All @@ -165,31 +165,31 @@ function postProcess() {
$values = $this->exportValues();

// process menu relevant entries
$old_menu_position = (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'menu_position');
$old_menu_position = (int) Civi::settings()->get('menu_position');
$new_menu_position = (int) $values['menu_position'];

$old_ui_style = (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'new_ui');
$old_ui_style = (int) Civi::settings()->get('new_ui');
$new_ui_style = (int) $values['new_ui'];

if ($old_menu_position != $new_menu_position || $old_ui_style != $new_ui_style) {
CRM_Core_BAO_Setting::setItem($new_ui_style, 'CiviBanking', 'new_ui');
CRM_Core_BAO_Setting::setItem($new_menu_position, 'CiviBanking', 'menu_position');
Civi::settings()->set('new_ui', $new_ui_style);
Civi::settings()->set('menu_position', $new_menu_position);
CRM_Core_BAO_Navigation::resetNavigation();
}

// process menu entry
CRM_Core_BAO_Setting::setItem($values['json_editor_mode'], 'CiviBanking', 'json_editor_mode');
Civi::settings()->set('json_editor_mode', $values['json_editor_mode']);

// log levels
CRM_Core_BAO_Setting::setItem($values['banking_log_level'], 'CiviBanking', 'banking_log_level');
CRM_Core_BAO_Setting::setItem($values['banking_log_file'], 'CiviBanking', 'banking_log_file');
Civi::settings()->set('banking_log_level', $values['banking_log_level']);
Civi::settings()->set('banking_log_file', $values['banking_log_file']);

// process reference normalisation / validation
CRM_Core_BAO_Setting::setItem(!empty($values['reference_store_disabled']),'CiviBanking', 'reference_store_disabled');
CRM_Core_BAO_Setting::setItem(!empty($values['reference_normalisation']), 'CiviBanking', 'reference_normalisation');
CRM_Core_BAO_Setting::setItem($values['reference_matching_probability'], 'CiviBanking', 'reference_matching_probability');
CRM_Core_BAO_Setting::setItem(!empty($values['reference_validation']), 'CiviBanking', 'reference_validation');
CRM_Core_BAO_Setting::setItem(!empty($values['lenient_dedupe']), 'CiviBanking', 'lenient_dedupe');
Civi::settings()->set('reference_store_disabled', !empty($values['reference_store_disabled']));
Civi::settings()->set('reference_normalisation', !empty($values['reference_normalisation']));
Civi::settings()->set('reference_matching_probability', $values['reference_matching_probability']);
Civi::settings()->set('reference_validation', !empty($values['reference_validation']),);
Civi::settings()->set('lenient_dedupe', !empty($values['lenient_dedupe']), );

// log results
$logger = CRM_Banking_Helpers_Logger::getLogger();
Expand Down
2 changes: 1 addition & 1 deletion CRM/Banking/BAO/BankAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function setDataParsed($data) {
* ordered by the reference types' order in the option group
*/
public function getReferences() {
$bank_account_reference_matching_probability = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_matching_probability');
$bank_account_reference_matching_probability = Civi::settings()->get('reference_matching_probability');
if ($bank_account_reference_matching_probability === null) {
$bank_account_reference_matching_probability = 1.0;
}
Expand Down
4 changes: 2 additions & 2 deletions CRM/Banking/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class CRM_Banking_Config {
* Should the bank account dedupe be done in a lenient way?
*/
public static function lenientDedupe() {
$value = CRM_Core_BAO_Setting::getItem('CiviBanking', 'lenient_dedupe');
$value = Civi::settings()->get('lenient_dedupe');
if (empty($value)) {
return FALSE;
} else {
return TRUE;
}
}
}
}
32 changes: 16 additions & 16 deletions CRM/Banking/Form/AccountsTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ function buildQuickForm() {
}

// load settings
$this->assign('reference_normalisation', (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_normalisation'));
$this->assign('reference_validation', (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_validation'));
$this->assign('reference_normalisation', (int) Civi::settings()->get('reference_normalisation'));
$this->assign('reference_validation', (int) Civi::settings()->get('reference_validation'));

// ACCOUNT REFRENCE ITEMS
$this->add('hidden', 'contact_id', $contact_id, true);
$this->add('hidden', 'contact_id', $contact_id, []);
$this->add('hidden', 'reference_id');

$reference_type = $this->add(
Expand All @@ -85,7 +85,7 @@ function buildQuickForm() {
true // is required
);
// set last value
$reference_type->setSelected(CRM_Core_BAO_Setting::getItem('CiviBanking', 'account.default_reference_id'));
$reference_type->setSelected(Civi::settings()->get('account.default_reference_id'));

$reference_type = $this->add(
'text',
Expand All @@ -95,7 +95,7 @@ function buildQuickForm() {
true
);


// BANK ITEMS
$this->add('hidden', 'ba_id');

Expand Down Expand Up @@ -123,7 +123,7 @@ function buildQuickForm() {
false
);
// set last value
$country->setSelected(CRM_Core_BAO_Setting::getItem('CiviBanking', 'account.default_country'));
$country->setSelected(Civi::settings()->get('account.default_country'));


$this->addButtons(array(
Expand All @@ -148,8 +148,8 @@ function buildQuickForm() {
public function validate() {
$error = parent::validate();
$values = $this->exportValues();
$normalise = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_normalisation');
$validate = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_validation');
$normalise = Civi::settings()->get('reference_normalisation');
$validate = Civi::settings()->get('reference_validation');

if (!empty($values['reference_type']) && !empty($values['reference'])) {
if ($validate || $normalise) {
Expand All @@ -164,10 +164,10 @@ public function validate() {
} elseif ($normalise && $result['normalised'] ) {
$values['reference'] = $result['reference'];
$this->set('reference', $result['reference']);
}
}
}
}

if (0 == count($this->_errors)) {
return TRUE;
} else {
Expand All @@ -182,15 +182,15 @@ public function validate() {
function postProcess() {
$values = $this->exportValues();
$was_created = FALSE;

// save presets
if (!empty($values['reference_type'])) {
CRM_Core_BAO_Setting::setItem($values['reference_type'], 'CiviBanking', 'account.default_reference_id');
Civi::settings()->set('account.default_reference_id', $values['reference_type']);
}
if (!empty($values['country'])) {
CRM_Core_BAO_Setting::setItem($values['country'], 'CiviBanking', 'account.default_country');
Civi::settings()->set('account.default_country', $values['country']);
}

// create bank account
$ba_id = $values['ba_id'];
if (empty($ba_id)) {
Expand Down Expand Up @@ -226,7 +226,7 @@ function postProcess() {
if (!empty($values['reference_id'])) {
$reference_update['id'] = $values['reference_id'];
}

civicrm_api3('BankingAccountReference', 'create', $reference_update);

if ($was_created) {
Expand All @@ -237,7 +237,7 @@ function postProcess() {

// return to accounts tab
if (!empty($values['contact_id'])) {
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['contact_id']}&selectedChild=bank_accounts"));
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$values['contact_id']}&selectedChild=bank_accounts"));
}
parent::postProcess();
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Banking/Form/Configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function buildQuickForm() {
}

// set default editor mode
$json_editor_mode = CRM_Core_BAO_Setting::getItem('CiviBanking', 'json_editor_mode');
$json_editor_mode = Civi::settings()->get('json_editor_mode');
if (empty($json_editor_mode)) {
$json_editor_mode = 'text';
}
Expand Down
4 changes: 2 additions & 2 deletions CRM/Banking/Helpers/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static function getLogger() {
protected function __construct() {
// read log level
$all_levels = self::getLoglevels();
$this->log_level = CRM_Core_BAO_Setting::getItem('CiviBanking', 'banking_log_level');
$this->log_level = Civi::settings()->get('banking_log_level');
if (!isset($all_levels[$this->log_level])) {
// invalid log level -> fall back to 'off'
$this->log_level = 'off';
Expand All @@ -58,7 +58,7 @@ protected function __construct() {
$this->timers = array();

// create log file
$log_file = CRM_Core_BAO_Setting::getItem('CiviBanking', 'banking_log_file');
$log_file = Civi::settings()->get('banking_log_file');
if (!empty($log_file)) {
// log to file:
if (substr($log_file, 0, 1) != '/') {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Banking/Matcher/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct( CRM_Banking_BAO_BankTransaction $btx ) {
$this->btx = $btx;
$btx->context = $this;

$this->bank_account_reference_matching_probability = CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_matching_probability');
$this->bank_account_reference_matching_probability = Civi::settings()->get('reference_matching_probability');
if ($this->bank_account_reference_matching_probability === null) {
$this->bank_account_reference_matching_probability = 1.0;
}
Expand Down
12 changes: 6 additions & 6 deletions CRM/Banking/Page/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function run() {
if ($plugin->id == $plugin_id) {
$this->assign('plugin_list', array($plugin));
break;
}
}
}

// RUN the importer
Expand Down Expand Up @@ -70,7 +70,7 @@ function run() {
} else {
CRM_Core_Session::setStatus(E::ts('Importer needs a file to proceed.'), E::ts('No input file'), 'alert');
}

// TODO: RUN the processor
if (isset($_REQUEST['process']) && $_REQUEST['process']=="on") {
CRM_Core_Session::setStatus(E::ts('Automated running not yet implemented'), E::ts('Not implemented'), 'alert');
Expand Down Expand Up @@ -98,17 +98,17 @@ function run() {
foreach ($plugin_list as $plugin) {
$class = $plugin->getClass();
if ($class::does_import_files()) {
$has_file_source[$plugin->id] = 'true';
$has_file_source[$plugin->id] = 'true';
} else {
$has_file_source[$plugin->id] = 'false';
$has_file_source[$plugin->id] = 'false';
}

}
$this->assign('has_file_source', $has_file_source);
}

// URLs
$new_ui_enabled = CRM_Core_BAO_Setting::getItem('CiviBanking', 'new_ui');
$new_ui_enabled = Civi::settings()->get('new_ui');
if ($new_ui_enabled) {
$this->assign('url_payments', CRM_Utils_System::url('civicrm/banking/statements'));
} else {
Expand Down
4 changes: 2 additions & 2 deletions CRM/Banking/Page/Review.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CRM_Banking_Page_Review extends CRM_Core_Page {
function run() {
CRM_Core_Resources::singleton()->addStyleFile(E::LONG_NAME, 'css/banking.css');

$new_ui_enabled = CRM_Core_BAO_Setting::getItem('CiviBanking', 'new_ui');
$new_ui_enabled = Civi::settings()->get('new_ui');
// set this variable to request a redirect
$url_redirect = NULL;

Expand Down Expand Up @@ -297,7 +297,7 @@ function run() {
// tell the page if popups are available
$popups_allowed = (int) version_compare(CRM_Utils_System::version(), '4.6', '>=');
if ($popups_allowed) { // take the popup switch into account (thanks @VangelisP)
$popups_allowed = (int) CRM_Core_BAO_Setting::getItem('CiviCRM Preferences', 'ajaxPopupsEnabled');
$popups_allowed = (int) Civi::settings()->get('ajaxPopupsEnabled');
}
$this->assign('popups_allowed', $popups_allowed);

Expand Down
2 changes: 1 addition & 1 deletion CRM/Banking/PluginModel/Matcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function getPenalty($btx) {
*/
function storeAccountWithContact($btx, $contact_id) {
// check if this has been turned off
if (CRM_Core_BAO_Setting::getItem('CiviBanking', 'reference_store_disabled')) {
if (Civi::settings()->get('reference_store_disabled')) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions CRM/Banking/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function upgrade_0610() {
* @return TRUE on success
*/
public function upgrade_0611() {
CRM_Core_BAO_Setting::setItem(false, 'org.project60.banking', 'new_ui');
Civi::settings()->set(false, 'org.project60.banking', 'new_ui');

// Update order of the option group banking_tx_status.
$statusApi = civicrm_api3('OptionValue', 'get', array('option_group_id' => 'civicrm_banking.bank_tx_status', 'options' => array('limit' => 0)));
Expand Down Expand Up @@ -175,7 +175,7 @@ public function upgrade_0703() {
public function upgrade_0704() {
// rebuild menu, in particular for the UI
CRM_Core_Invoke::rebuildMenuAndCaches();
CRM_Core_BAO_Setting::setItem($values['reference_matching_probability'], 'CiviBanking', 'reference_matching_probability');
Civi::settings()->set('reference_matching_probability', $values['reference_matching_probability']);
return true;
}

Expand All @@ -186,7 +186,7 @@ public function upgrade_0704() {
*/
public function upgrade_0800() {
// Set the bank account reference probability to 100%.
CRM_Core_BAO_Setting::setItem('1.0', 'CiviBanking', 'reference_matching_probability');
Civi::settings()->set('reference_matching_probability', '1.0');
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions banking.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function banking_civicrm_install() {
banking_civicrm_install_options(_banking_options());

// Set the bank account reference probability to 100%.
CRM_Core_BAO_Setting::setItem('1.0', 'CiviBanking', 'reference_matching_probability');
Civi::settings()->set('reference_matching_probability', '1.0');

return _banking_civix_civicrm_install();
}
Expand Down Expand Up @@ -216,7 +216,7 @@ function banking_civicrm_entityTypes(&$entityTypes) {
*/
function banking_civicrm_navigationMenu(&$menu) {
// check if we want the menu to be built at all
$menu_position = (int) CRM_Core_BAO_Setting::getItem('CiviBanking', 'menu_position');
$menu_position = (int) Civi::settings()->get('menu_position');
switch ($menu_position) {
case 2:
// menu is off, see CRM_Admin_Form_Setting_BankingSettings
Expand All @@ -239,7 +239,7 @@ function banking_civicrm_navigationMenu(&$menu) {

// Determine the url for the statements/payments (new ui or old ui).
$statementUrl = 'civicrm/banking/statements';
if (!CRM_Core_BAO_Setting::getItem('CiviBanking', 'new_ui')) {
if (!Civi::settings()->get('new_ui')) {
$statementUrl = 'civicrm/banking/payments';
}

Expand Down