2021-10-23 14:21:30 +03:00
|
|
|
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* Easy!Appointments - Open Source Web Scheduler
|
|
|
|
*
|
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
|
|
|
* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
|
|
|
|
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
* @link http://easyappointments.org
|
2021-10-23 14:29:31 +03:00
|
|
|
* @since v1.5.0
|
2021-10-23 14:21:30 +03:00
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
if ( ! function_exists('setting'))
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Get / set the specified setting value.
|
|
|
|
*
|
|
|
|
* If an array is passed as the key, we will assume you want to set an array of values.
|
|
|
|
*
|
|
|
|
* Example "Get":
|
|
|
|
*
|
|
|
|
* $company_name = session('company_name', FALSE);
|
|
|
|
*
|
|
|
|
* Example "Set":
|
|
|
|
*
|
|
|
|
* setting(['company_name' => 'ACME Inc']);
|
|
|
|
*
|
2021-10-23 14:41:41 +03:00
|
|
|
* @param array|string $key Setting key.
|
|
|
|
* @param mixed $default Default value in case the requested setting has no value.
|
2021-10-23 14:21:30 +03:00
|
|
|
*
|
|
|
|
* @return mixed|NULL Returns the requested value or NULL if you assign a new setting value.
|
|
|
|
*
|
|
|
|
* @throws InvalidArgumentException
|
|
|
|
*/
|
|
|
|
function setting($key = NULL, $default = NULL)
|
|
|
|
{
|
|
|
|
/** @var EA_Controller $CI */
|
|
|
|
$CI = &get_instance();
|
|
|
|
|
|
|
|
if (empty($key))
|
|
|
|
{
|
|
|
|
throw new InvalidArgumentException('The $key argument cannot be empty.');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_array($key))
|
|
|
|
{
|
|
|
|
foreach ($key as $item => $value)
|
|
|
|
{
|
|
|
|
$CI->session->set_userdata($item, $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
$value = $CI->session->userdata($key);
|
|
|
|
|
|
|
|
return $value ?? $default;
|
|
|
|
}
|
|
|
|
}
|