本文整理汇总了PHP中api_get_settings函数的典型用法代码示例。如果您正苦于以下问题:PHP api_get_settings函数的具体用法?PHP api_get_settings怎么用?PHP api_get_settings使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了api_get_settings函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preventMultipleLogin
/**
* @param int $userId
*/
function preventMultipleLogin($userId)
{
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$userId = intval($userId);
if (api_get_settings('prevent_multiple_simultaneous_login') === 'true') {
if (!empty($userId) && !api_is_anonymous()) {
$isFirstLogin = Session::read('first_user_login');
if (empty($isFirstLogin)) {
$sql = "SELECT login_id FROM {$table}\n WHERE login_user_id = " . $userId . " LIMIT 1";
$result = Database::query($sql);
$loginData = array();
if (Database::num_rows($result)) {
$loginData = Database::fetch_array($result);
}
$userIsReallyOnline = user_is_online($userId);
// Trying double login.
if (!empty($loginData) && $userIsReallyOnline == true) {
session_regenerate_id();
Session::destroy();
header('Location: ' . api_get_path(WEB_PATH) . 'index.php?loginFailed=1&error=multiple_connection_not_allowed');
exit;
} else {
// First time
Session::write('first_user_login', 1);
}
}
}
}
}
示例2: get_areas_by_plugin
function get_areas_by_plugin($plugin_name)
{
$result = api_get_settings('Plugins');
$areas = array();
foreach ($result as $row) {
if ($plugin_name == $row['selected_value']) {
$areas[] = $row['variable'];
}
}
return $areas;
}
示例3: get_settings
function get_settings($category = null)
{
$url_id = api_get_current_access_url_id();
$settings_by_access_list = array();
if ($url_id == 1) {
$settings = api_get_settings($category, 'group', $url_id);
} else {
$url_info = api_get_access_url($url_id);
if ($url_info['active'] == 1) {
// The default settings of Chamilo
$settings = api_get_settings($category, 'group', 1, 0);
// The settings that are changeable from a particular site.
$settings_by_access = api_get_settings($category, 'group', $url_id, 1);
foreach ($settings_by_access as $row) {
if (empty($row['variable'])) {
$row['variable'] = 0;
}
if (empty($row['subkey'])) {
$row['subkey'] = 0;
}
if (empty($row['category'])) {
$row['category'] = 0;
}
// One more validation if is changeable.
if ($row['access_url_changeable'] == 1) {
$settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row;
} else {
$settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = array();
}
}
}
}
if (isset($category) && $category == 'search_setting') {
if (!empty($_REQUEST['search_field'])) {
$settings = search_setting($_REQUEST['search_field']);
}
}
return array('settings' => $settings, 'settings_by_access_list' => $settings_by_access_list);
}
示例4: api_set_settings_and_plugins
function api_set_settings_and_plugins()
{
global $_configuration;
$_setting = array();
$_plugins = array();
// access_url == 1 is the default chamilo location
$settings_by_access_list = array();
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != 1) {
$url_info = api_get_access_url($_configuration['access_url']);
if ($url_info['active'] == 1) {
$settings_by_access =& api_get_settings(null, 'list', $_configuration['access_url'], 1);
foreach ($settings_by_access as &$row) {
if (empty($row['variable'])) {
$row['variable'] = 0;
}
if (empty($row['subkey'])) {
$row['subkey'] = 0;
}
if (empty($row['category'])) {
$row['category'] = 0;
}
$settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row;
}
}
}
$result = api_get_settings(null, 'list', 1);
foreach ($result as &$row) {
if ($access_url_id != 1) {
if ($url_info['active'] == 1) {
$var = empty($row['variable']) ? 0 : $row['variable'];
$subkey = empty($row['subkey']) ? 0 : $row['subkey'];
$category = empty($row['category']) ? 0 : $row['category'];
}
if ($row['access_url_changeable'] == 1 && $url_info['active'] == 1) {
if (isset($settings_by_access_list[$var]) && $settings_by_access_list[$var][$subkey][$category]['selected_value'] != '') {
if ($row['subkey'] == null) {
$_setting[$row['variable']] = $settings_by_access_list[$var][$subkey][$category]['selected_value'];
} else {
$_setting[$row['variable']][$row['subkey']] = $settings_by_access_list[$var][$subkey][$category]['selected_value'];
}
} else {
if ($row['subkey'] == null) {
$_setting[$row['variable']] = $row['selected_value'];
} else {
$_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
}
}
} else {
if ($row['subkey'] == null) {
$_setting[$row['variable']] = $row['selected_value'];
} else {
$_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
}
}
} else {
if ($row['subkey'] == null) {
$_setting[$row['variable']] = $row['selected_value'];
} else {
$_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
}
}
}
$result = api_get_settings('Plugins', 'list', $access_url_id);
$_plugins = array();
foreach ($result as &$row) {
$key =& $row['variable'];
if (is_string($_setting[$key])) {
$_setting[$key] = array();
}
$_setting[$key][] = $row['selected_value'];
$_plugins[$key][] = $row['selected_value'];
}
$_SESSION['_setting'] = $_setting;
$_SESSION['_plugins'] = $_plugins;
}
示例5: get_tools_category
/**
* Gets the tools of a certain category. Returns an array expected
* by show_tools_category()
* @param string $course_tool_category contains the category of tools to
* display: "toolauthoring", "toolinteraction", "tooladmin", "tooladminplatform", "toolplugin"
* @return array
*/
public static function get_tools_category($course_tool_category)
{
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$is_platform_admin = api_is_platform_admin();
$all_tools_list = array();
// Condition for the session
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
$condition_session = api_get_session_condition($session_id, true, true, 't.session_id');
switch ($course_tool_category) {
case TOOL_STUDENT_VIEW:
$conditions = ' WHERE visibility = 1 AND (category = "authoring" OR category = "interaction" OR category = "plugin") ';
if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') {
$conditions = ' WHERE (visibility = 1 AND (category = "authoring" OR category = "interaction" OR category = "plugin") OR (name = "' . TOOL_TRACKING . '") ) ';
}
$sql = "SELECT *\n FROM {$course_tool_table} t\n {$conditions} AND\n c_id = {$course_id} {$condition_session}\n ORDER BY id";
$result = Database::query($sql);
break;
case TOOL_AUTHORING:
$sql = "SELECT * FROM {$course_tool_table} t\n WHERE category = 'authoring' AND c_id = {$course_id} {$condition_session}\n ORDER BY id";
$result = Database::query($sql);
break;
case TOOL_INTERACTION:
$sql = "SELECT * FROM {$course_tool_table} t\n WHERE category = 'interaction' AND c_id = {$course_id} {$condition_session}\n ORDER BY id";
$result = Database::query($sql);
break;
case TOOL_ADMIN_VISIBLE:
$sql = "SELECT * FROM {$course_tool_table} t\n WHERE category = 'admin' AND visibility ='1' AND c_id = {$course_id} {$condition_session}\n ORDER BY id";
$result = Database::query($sql);
break;
case TOOL_ADMIN_PLATFORM:
$sql = "SELECT * FROM {$course_tool_table} t\n WHERE category = 'admin' AND c_id = {$course_id} {$condition_session}\n ORDER BY id";
$result = Database::query($sql);
break;
case TOOL_DRH:
$sql = "SELECT * FROM {$course_tool_table} t\n WHERE name IN ('tracking') AND c_id = {$course_id} {$condition_session}\n ORDER BY id";
$result = Database::query($sql);
break;
case TOOL_COURSE_PLUGIN:
//Other queries recover id, name, link, image, visibility, admin, address, added_tool, target, category and session_id
// but plugins are not present in the tool table, only globally and inside the course_settings table once configured
$sql = "SELECT * FROM {$course_tool_table} t\n WHERE category = 'plugin' AND c_id = {$course_id} {$condition_session}\n ORDER BY id";
$result = Database::query($sql);
break;
}
//Get the list of hidden tools - this might imply performance slowdowns
// if the course homepage is loaded many times, so the list of hidden
// tools might benefit from a shared memory storage later on
$list = api_get_settings('Tools', 'list', api_get_current_access_url_id());
$hide_list = array();
$check = false;
foreach ($list as $line) {
// Admin can see all tools even if the course_hide_tools configuration is set
if ($is_platform_admin) {
continue;
}
if ($line['variable'] == 'course_hide_tools' and $line['selected_value'] == 'true') {
$hide_list[] = $line['subkey'];
$check = true;
}
}
while ($temp_row = Database::fetch_assoc($result)) {
$add = false;
if ($check) {
if (!in_array($temp_row['name'], $hide_list)) {
$add = true;
}
} else {
$add = true;
}
if ($temp_row['image'] == 'scormbuilder.gif') {
$lp_id = self::get_published_lp_id_from_link($temp_row['link']);
$lp = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
$path = $lp->get_preview_image_path(ICON_SIZE_BIG);
$add = $lp->is_lp_visible_for_student($lp_id, api_get_user_id(), api_get_course_id(), api_get_session_id());
if ($path) {
$temp_row['custom_image'] = $path;
}
}
if ($add) {
$all_tools_list[] = $temp_row;
}
}
// Grabbing all the links that have the property on_homepage set to 1
$course_link_table = Database::get_course_table(TABLE_LINK);
$course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$condition_session = api_get_session_condition($session_id, true, true, 'tip.session_id');
switch ($course_tool_category) {
case TOOL_AUTHORING:
$sql_links = "SELECT tl.*, tip.visibility\n FROM {$course_link_table} tl\n LEFT JOIN {$course_item_property_table} tip\n ON tip.tool='link' AND tip.ref=tl.id\n WHERE\n tl.c_id = {$course_id} AND\n tip.c_id = {$course_id} AND\n tl.on_homepage='1' {$condition_session}";
break;
case TOOL_INTERACTION:
$sql_links = null;
//.........这里部分代码省略.........
示例6: handle_stylesheets
/**
* This function allows the platform admin to choose the default stylesheet
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @author Julio Montoya <gugli100@gmail.com>, Chamilo
*/
function handle_stylesheets()
{
global $_configuration;
// Current style.
$currentstyle = api_get_setting('stylesheets');
$is_style_changeable = false;
if ($_configuration['access_url'] != 1) {
$style_info = api_get_settings('stylesheets', '', 1, 0);
$url_info = api_get_access_url($_configuration['access_url']);
if ($style_info[0]['access_url_changeable'] == 1 && $url_info['active'] == 1) {
$is_style_changeable = true;
}
} else {
$is_style_changeable = true;
}
$form = new FormValidator('stylesheet_upload', 'post', 'settings.php?category=Stylesheets#tabs-2');
$form->addElement('text', 'name_stylesheet', get_lang('NameStylesheet'), array('size' => '40', 'maxlength' => '40'));
$form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('file', 'new_stylesheet', get_lang('UploadNewStylesheet'));
$allowed_file_types = array('css', 'zip', 'jpeg', 'jpg', 'png', 'gif', 'ico', 'psd');
$form->addRule('new_stylesheet', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')', 'filetype', $allowed_file_types);
$form->addRule('new_stylesheet', get_lang('ThisFieldIsRequired'), 'required');
$form->addButtonUpload(get_lang('Upload'), 'stylesheet_upload');
$show_upload_form = false;
if (!is_writable(CSS_UPLOAD_PATH)) {
Display::display_error_message(CSS_UPLOAD_PATH . get_lang('IsNotWritable'));
} else {
// Uploading a new stylesheet.
if ($_configuration['access_url'] == 1) {
$show_upload_form = true;
} else {
if ($is_style_changeable) {
$show_upload_form = true;
}
}
}
// Stylesheet upload.
if (isset($_POST['stylesheet_upload'])) {
if ($form->validate()) {
$values = $form->exportValues();
$picture_element = $form->getElement('new_stylesheet');
$picture = $picture_element->getValue();
$result = upload_stylesheet($values, $picture);
// Add event to the system log.
$user_id = api_get_user_id();
$category = $_GET['category'];
Event::addEvent(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
if ($result) {
Display::display_confirmation_message(get_lang('StylesheetAdded'));
}
}
}
$form_change = new FormValidator('stylesheet_upload', 'post', api_get_self() . '?category=Stylesheets', null, array('id' => 'stylesheets_id'));
$list_of_names = array();
$selected = '';
$dirpath = '';
$safe_style_dir = '';
if ($handle = @opendir(CSS_UPLOAD_PATH)) {
$counter = 1;
while (false !== ($style_dir = readdir($handle))) {
if (substr($style_dir, 0, 1) == '.') {
// Skip directories starting with a '.'
continue;
}
$dirpath = CSS_UPLOAD_PATH . $style_dir;
if (is_dir($dirpath)) {
if ($style_dir != '.' && $style_dir != '..') {
if (isset($_POST['style']) && (isset($_POST['preview']) || isset($_POST['download'])) && $_POST['style'] == $style_dir) {
$safe_style_dir = $style_dir;
} else {
if ($currentstyle == $style_dir || $style_dir == 'chamilo' && !$currentstyle) {
if (isset($_POST['style'])) {
$selected = Database::escape_string($_POST['style']);
} else {
$selected = $style_dir;
}
}
}
$show_name = ucwords(str_replace('_', ' ', $style_dir));
if ($is_style_changeable) {
$list_of_names[$style_dir] = $show_name;
}
$counter++;
}
}
}
closedir($handle);
}
// Sort styles in alphabetical order.
asort($list_of_names);
$select_list = array();
foreach ($list_of_names as $style_dir => $item) {
$select_list[$style_dir] = $item;
}
$styles =& $form_change->addElement('select', 'style', get_lang('NameStylesheet'), $select_list);
//.........这里部分代码省略.........
示例7: get_settings_form
/**
* Returns an HTML form (generated by FormValidator) of the plugin settings
* @return string FormValidator-generated form
*/
public function get_settings_form()
{
$result = new FormValidator($this->get_name());
$defaults = array();
$checkboxGroup = array();
$checkboxCollection = array();
if ($checkboxNames = array_keys($this->fields, 'checkbox')) {
$pluginInfoCollection = api_get_settings('Plugins');
foreach ($pluginInfoCollection as $pluginInfo) {
if (array_search($pluginInfo['title'], $checkboxNames) !== false) {
$checkboxCollection[$pluginInfo['title']] = $pluginInfo;
}
}
}
foreach ($this->fields as $name => $type) {
$options = null;
if (is_array($type) && isset($type['type']) && $type['type'] === "select") {
$options = $type['options'];
$type = $type['type'];
}
$value = $this->get($name);
$defaults[$name] = $value;
$type = isset($type) ? $type : 'text';
$help = null;
if ($this->get_lang_plugin_exists($name . '_help')) {
$help = $this->get_lang($name . '_help');
if ($name === "show_main_menu_tab") {
$pluginName = strtolower(str_replace('Plugin', '', get_class($this)));
$pluginUrl = api_get_path(WEB_PATH) . "plugin/{$pluginName}/index.php";
$pluginUrl = "<a href={$pluginUrl}>{$pluginUrl}</a>";
$help = sprintf($help, $pluginUrl);
}
}
switch ($type) {
case 'html':
$result->addElement('html', $this->get_lang($name));
break;
case 'wysiwyg':
$result->addHtmlEditor($name, $this->get_lang($name), false);
break;
case 'text':
$result->addElement($type, $name, array($this->get_lang($name), $help));
break;
case 'boolean':
$group = array();
$group[] = $result->createElement('radio', $name, '', get_lang('Yes'), 'true');
$group[] = $result->createElement('radio', $name, '', get_lang('No'), 'false');
$result->addGroup($group, null, array($this->get_lang($name), $help));
break;
case 'checkbox':
$selectedValue = null;
if (isset($checkboxCollection[$name])) {
if ($checkboxCollection[$name]['selected_value'] === 'true') {
$selectedValue = 'checked';
}
}
$element = $result->createElement($type, $name, '', $this->get_lang($name), $selectedValue);
$element->_attributes['value'] = 'true';
$checkboxGroup[] = $element;
break;
case 'select':
$result->addElement($type, $name, array($this->get_lang($name), $help), $options);
break;
}
}
if (!empty($checkboxGroup)) {
$result->addGroup($checkboxGroup, null, array($this->get_lang('sms_types'), $help));
}
$result->setDefaults($defaults);
$result->addButtonSave($this->get_lang('Save'), 'submit_button');
return $result;
}
示例8: api_get_settings
} else {
if ($row['subkey'] == null) {
$_setting[$row['variable']] = $row['selected_value'];
} else {
$_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
}
}
} else {
if ($row['subkey'] == null) {
$_setting[$row['variable']] = $row['selected_value'];
} else {
$_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
}
}
}
$result =& api_get_settings('Plugins', 'list', $_configuration['access_url']);
$_plugins = array();
foreach ($result as &$row) {
$key =& $row['variable'];
if (is_string($_setting[$key])) {
$_setting[$key] = array();
}
$_setting[$key][] = $row['selected_value'];
$_plugins[$key][] = $row['selected_value'];
}
// Error reporting settings.
if (api_get_setting('server_type') == 'test') {
ini_set('display_errors', '1');
ini_set('log_errors', '1');
error_reporting(-1);
} else {
示例9: handle_search
/**
* Search options
* TODO: support for multiple site. aka $_configuration['access_url'] == 1
* @author Marco Villegas <marvil07@gmail.com>
*/
function handle_search()
{
global $SettingsStored, $_configuration;
$search_enabled = api_get_setting('search_enabled');
$settings = api_get_settings('Search');
if ($search_enabled !== 'true' || count($settings) < 1) {
Display::display_error_message(get_lang('SearchFeatureNotEnabledComment'));
return;
}
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
$form = new FormValidator('search-options', 'post', api_get_self() . '?category=Search');
$renderer =& $form->defaultRenderer();
$renderer->setHeaderTemplate('<div class="sectiontitle">{header}</div>' . "\n");
$renderer->setElementTemplate('<div class="sectioncomment">{label}</div>' . "\n" . '<div class="sectionvalue">{element}</div>' . "\n");
//search_show_unlinked_results
$form->addElement('header', null, get_lang('SearchShowUnlinkedResultsTitle'));
$form->addElement('label', null, get_lang('SearchShowUnlinkedResultsComment'));
$values = get_settings_options('search_show_unlinked_results');
$group = array();
foreach ($values as $key => $value) {
$element =& $form->createElement('radio', 'search_show_unlinked_results', '', get_lang($value['display_text']), $value['value']);
$group[] = $element;
}
$form->addGroup($group, 'search_show_unlinked_results', get_lang('SearchShowUnlinkedResultsComment'), '<br />', false);
$default_values['search_show_unlinked_results'] = api_get_setting('search_show_unlinked_results');
//search_prefilter_prefix
$form->addElement('header', null, get_lang('SearchPrefilterPrefix'));
$form->addElement('label', null, get_lang('SearchPrefilterPrefixComment'));
$specific_fields = get_specific_field_list();
$sf_values = array();
foreach ($specific_fields as $sf) {
$sf_values[$sf['code']] = $sf['name'];
}
$group = array();
$form->addElement('select', 'search_prefilter_prefix', get_lang('SearchPrefilterPrefix'), $sf_values, '');
$default_values['search_prefilter_prefix'] = api_get_setting('search_prefilter_prefix');
//$form->addRule('search_show_unlinked_results', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('style_submit_button', 'search-options-save', get_lang('Ok'));
$form->setDefaults($default_values);
if ($form->validate()) {
$formvalues = $form->exportValues();
$r = api_set_settings_category('Search', 'false', $_configuration['access_url']);
// Save the settings
foreach ($formvalues as $key => $value) {
$result = api_set_setting($key, $value, null, null);
}
Display::display_normal_message($SettingsStored);
} else {
echo '<div id="search-options-form">';
$form->display();
echo '</div>';
}
}
示例10: getTransactionMappingSettings
/**
* Retrieves transaction mapping settings.
*
* @return array
* Every item is an array of mapping settings, keyed by transaction
* action, with the following keys:
* - max_attempts: Maximum number of attempts for trying to import the
* transaction into the system.
*/
public static function getTransactionMappingSettings($action = null, $reset = false)
{
static $settings;
if (isset($settings) && !$reset) {
if (!empty($action)) {
return $settings[$action];
}
return $settings;
}
$settings = array();
$transaction_mapping_settings = api_get_settings('TransactionMapping');
foreach ($transaction_mapping_settings as $setting) {
$maps = unserialize($setting['selected_value']);
$settings[$setting['subkey']] = $maps;
}
if (!empty($action)) {
return $settings[$action];
}
return $settings;
}