Esempio n. 1
0
 /**
  * Protected constructor - call instance() to instantiate
  */
 protected function ScoreDisplay($category_id = 0)
 {
     if (!empty($category_id)) {
         $this->category_id = $category_id;
     }
     // Loading portal settings + using standard functions.
     $value = api_get_setting('gradebook_score_display_coloring');
     $value = $value['my_display_coloring'];
     // Setting coloring.
     $this->coloring_enabled = $value == 'true' ? true : false;
     if ($this->coloring_enabled) {
         $value = api_get_setting('gradebook_score_display_colorsplit');
         if (isset($value)) {
             $this->color_split_value = $value;
         }
     }
     //Setting custom enabled
     $value = api_get_setting('gradebook_score_display_custom');
     $value = $value['my_display_custom'];
     $this->custom_enabled = $value == 'true' ? true : false;
     if ($this->custom_enabled) {
         $params = array('category = ?' => array('Gradebook'));
         $displays = api_get_settings_params($params);
         $portal_displays = array();
         if (!empty($displays)) {
             foreach ($displays as $display) {
                 $data = explode('::', $display['selected_value']);
                 if (empty($data[1])) {
                     $data[1] = "";
                 }
                 $portal_displays[$data[0]] = array('score' => $data[0], 'display' => $data[1]);
             }
             sort($portal_displays);
         }
         $this->custom_display = $portal_displays;
         if (count($this->custom_display) > 0) {
             $value = api_get_setting('gradebook_score_display_upperlimit');
             $value = $value['my_display_upperlimit'];
             $this->upperlimit_included = $value == 'true' ? true : false;
             $this->custom_display_conv = $this->convert_displays($this->custom_display);
         }
     }
     //If teachers can override the portal parameters
     if (api_get_setting('teachers_can_change_score_settings') == 'true') {
         //Load course settings
         if ($this->custom_enabled) {
             $this->custom_display = $this->get_custom_displays();
             if (count($this->custom_display) > 0) {
                 $this->custom_display_conv = $this->convert_displays($this->custom_display);
             }
         }
         if ($this->coloring_enabled) {
             $this->color_split_value = $this->get_score_color_percent();
         }
     }
 }
Esempio n. 2
0
/* For licensing terms, see /license.txt */
/**
 * Responses to AJAX calls
 */
//require_once '../global.inc.php';
\Chamilo\CoreBundle\Framework\Container::$legacyTemplate = 'layout_empty.html.twig';
api_protect_admin_script();
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
switch ($action) {
    case 'update_changeable_setting':
        $url_id = api_get_current_access_url_id();
        if (api_is_global_platform_admin() && $url_id == 1) {
            if (isset($_GET['id']) && !empty($_GET['id'])) {
                $params = array('variable = ? ' => array($_GET['id']));
                $data = api_get_settings_params($params);
                if (!empty($data)) {
                    foreach ($data as $item) {
                        $params = array('id' => $item['id'], 'access_url_changeable' => $_GET['changeable']);
                        api_set_setting_simple($params);
                    }
                }
                echo '1';
            }
        }
        break;
    case 'version':
        echo version_check();
        break;
    case 'get_extra_content':
        $blockName = isset($_POST['block']) ? Security::remove_XSS($_POST['block']) : null;
Esempio n. 3
0
 /**
  * Loads plugin info
  *
  * @staticvar array $plugin_data
  * @param string    $plugin_name
  * @param bool      $forced load from DB or from the static array
  *
  * @return array
  * @todo filter setting_form
  */
 public function getPluginInfo($plugin_name, $forced = false)
 {
     static $plugin_data = array();
     if (isset($plugin_data[$plugin_name]) && $forced == false) {
         return $plugin_data[$plugin_name];
     } else {
         $plugin_file = api_get_path(SYS_PLUGIN_PATH) . "{$plugin_name}/plugin.php";
         $plugin_info = array();
         if (file_exists($plugin_file)) {
             require $plugin_file;
         }
         //extra options
         $plugin_settings = api_get_settings_params(array("subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins', 'setting')));
         $settings_filtered = array();
         foreach ($plugin_settings as $item) {
             $settings_filtered[$item['variable']] = $item['selected_value'];
         }
         $plugin_info['settings'] = $settings_filtered;
         $plugin_data[$plugin_name] = $plugin_info;
         return $plugin_info;
     }
 }
Esempio n. 4
0
 /**
  * Returns an array with the global settings for this plugin
  * @return array Plugin settings as an array
  */
 public function get_settings()
 {
     if (is_null($this->settings)) {
         $settings = api_get_settings_params(array("subkey = ? AND category = ? AND type = ? " => array($this->get_name(), 'Plugins', 'setting')));
         $this->settings = $settings;
     }
     return $this->settings;
 }
Esempio n. 5
0
 */
/* Plugin config */
//the plugin title
$plugin_info['title'] = 'Custom Footer';
//the comments that go with the plugin
$plugin_info['comment'] = "Drives configuration parameters that plugs custom footer notes";
//the plugin version
$plugin_info['version'] = '1.0';
//the plugin author
$plugin_info['author'] = 'Valery Fremaux, Julio Montoya';
/* Plugin optional settings */
/*
 * This form will be showed in the plugin settings once the plugin was installed
 * in the plugin/hello_world/index.php you can have access to the value: $plugin_info['settings']['hello_world_show_type']
*/
$form = new FormValidator('customfooter_form');
$plugininstance = CustomFooterPlugin::create();
$config = api_get_settings_params(array('subkey = ? ' => 'customfooter', ' AND category = ? ' => 'Plugins'));
$form_settings = [];
foreach ($config as $fooid => $configrecord) {
    $canonic = preg_replace('/^customfooter_/', '', $configrecord['variable']);
    if (in_array($canonic, array('footer_left', 'footer_right'))) {
        $form_settings[$canonic] = $configrecord['selected_value'];
    }
}
// A simple select.
$form->addElement('text', 'footer_left', $plugininstance->get_lang('footerleft'));
$form->addElement('text', 'footer_right', $plugininstance->get_lang('footerright'));
$form->addButtonSave($plugininstance->get_lang('Save'));
$form->setDefaults($form_settings);
$plugin_info['settings_form'] = $form;