12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340 |
- <?php
- function handle_regions() {
-
- if (isset($_POST['submit_plugins'])) {
- store_regions();
-
- $user_id = api_get_user_id();
- $category = $_GET['category'];
- event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
- Display :: display_confirmation_message(get_lang('SettingsStored'));
- }
-
- $plugin_obj = new AppPlugin();
- $possible_plugins = $plugin_obj->read_plugins_from_path();
- $installed_plugins = $plugin_obj->get_installed_plugins();
- if (!empty($installed_plugins)) {
- $not_installed = array_diff($possible_plugins, $installed_plugins);
- } else {
- $not_installed = $possible_plugins;
- }
- echo '<form name="plugins" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'">';
- echo '<table class="data_table">';
- echo '<tr>';
- echo '<th width="400px">';
- echo get_lang('Plugin');
- echo '</th><th>';
- echo get_lang('Regions');
- echo '</th>';
- echo '</th>';
- echo '</tr>';
-
-
-
- $plugin_region_list = array();
- $my_plugin_list = $plugin_obj->get_plugin_regions();
- foreach ($my_plugin_list as $plugin_item) {
- $plugin_region_list[$plugin_item] = $plugin_item;
- }
-
-
- unset($plugin_region_list['course_tool_plugin']);
- foreach ($installed_plugins as $plugin) {
- $plugin_info_file = api_get_path(SYS_PLUGIN_PATH).$plugin.'/plugin.php';
-
- if (file_exists($plugin_info_file)) {
- $plugin_info = array();
- require $plugin_info_file;
- if (isset($_GET['name']) && $_GET['name'] == $plugin) {
- echo '<tr class="row_selected">';
- } else {
- echo '<tr>';
- }
- echo '<td>';
- echo '<h4>'.$plugin_info['title'].' <small>v'.$plugin_info['version'].'</small></h4>';
- echo '<p>'.$plugin_info['comment'].'</p>';
- echo '</td><td>';
- $selected_plugins = $plugin_obj->get_areas_by_plugin($plugin);
-
- if ($plugin_info['is_course_plugin']) {
- $region_list = array('course_tool_plugin' => 'course_tool_plugin');
- } else {
- $region_list = $plugin_region_list;
- }
- echo Display::select('plugin_'.$plugin.'[]', $region_list, $selected_plugins, array('multiple' => 'multiple', 'style' => 'width:500px'), true, get_lang('None'));
- echo '</td></tr>';
- }
- }
- echo '</table>';
- echo '<br />';
- echo '<button class="save" type="submit" name="submit_plugins">'.get_lang('EnablePlugins').'</button></form>';
- }
- function handle_extensions() {
- echo Display::page_subheader(get_lang('ConfigureExtensions'));
- echo '<a class="btn" href="configure_extensions.php?display=ppt2lp">'.get_lang('Ppt2lp').'</a>';
-
- }
- function handle_plugins() {
- $plugin_obj = new AppPlugin();
-
- if (isset($_POST['submit_plugins'])) {
- store_plugins();
-
- $user_id = api_get_user_id();
- $category = $_GET['category'];
- event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
- Display :: display_confirmation_message(get_lang('SettingsStored'));
- }
-
- $all_plugins = $plugin_obj->read_plugins_from_path();
- $installed_plugins = $plugin_obj->get_installed_plugins();
-
- echo Display::page_subheader(get_lang('Plugins'));
- echo '<form class="form-horizontal" name="plugins" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'">';
- echo '<table class="data_table">';
- echo '<tr>';
- echo '<th width="20px">';
- echo get_lang('Action');
- echo '</th><th>';
- echo get_lang('Description');
- echo '</th>';
- echo '</tr>';
-
- $plugin_list = array();
- $my_plugin_list = $plugin_obj->get_plugin_regions();
- foreach($my_plugin_list as $plugin_item) {
- $plugin_list[$plugin_item] = $plugin_item;
- }
- foreach ($all_plugins as $plugin) {
- $plugin_info_file = api_get_path(SYS_PLUGIN_PATH).$plugin.'/plugin.php';
-
- if (file_exists($plugin_info_file)) {
- $plugin_info = array();
- require $plugin_info_file;
- if (in_array($plugin, $installed_plugins)) {
- echo '<tr class="row_selected">';
- } else {
- echo '<tr>';
- }
-
- echo '<td>';
-
- if (in_array($plugin, $installed_plugins)) {
- echo '<input type="checkbox" name="plugin_'.$plugin.'[]" checked="checked">';
-
- } else {
- echo '<input type="checkbox" name="plugin_'.$plugin.'[]">';
- }
- echo '</td><td>';
-
- echo '<h4>'.$plugin_info['title'].' <small>v '.$plugin_info['version'].'</small></h4>';
- echo '<p>'.$plugin_info['comment'].'</p>';
- echo '<p>'.get_lang('Author').': '.$plugin_info['author'].'</p>';
-
- echo '<div class="btn-group">';
- if (in_array($plugin, $installed_plugins)) {
- echo Display::url(get_lang('Configure'), 'configure_plugin.php?name='.$plugin, array('class' => 'btn'));
- echo Display::url(get_lang('Regions'), 'settings.php?category=Regions&name='.$plugin, array('class' => 'btn'));
- }
-
- if (file_exists(api_get_path(SYS_PLUGIN_PATH).$plugin.'/readme.txt')) {
- echo Display::url("readme.txt", api_get_path(WEB_PLUGIN_PATH).$plugin."/readme.txt", array('class' => 'btn ajax', '_target' => '_blank'));
- }
- echo '</div>';
- echo '</td></tr>';
- }
- }
- echo '</table>';
-
- echo '<div class="form-actions bottom_actions">';
- echo '<button class="save" type="submit" name="submit_plugins">'.get_lang('EnablePlugins').'</button>';
- echo '</div>';
- echo '</form>';
-
- }
- function handle_stylesheets() {
- global $_configuration;
-
- $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;
- echo '<div class="actions" id="stylesheetuploadlink">';
- Display::display_icon('upload_stylesheets.png',get_lang('UploadNewStylesheet'),'',ICON_SIZE_MEDIUM);
- echo '<a href="" onclick="javascript: document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\'; return false; ">'.get_lang('UploadNewStylesheet').'</a>';
- echo '</div>';
- }
- } else {
- $is_style_changeable = true;
- echo '<div class="actions" id="stylesheetuploadlink">';
- Display::display_icon('upload_stylesheets.png',get_lang('UploadNewStylesheet'),'',ICON_SIZE_MEDIUM);
- echo '<a href="" onclick="javascript: document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\'; return false; ">'.get_lang('UploadNewStylesheet').'</a>';
- echo '</div>';
- }
- $form = new FormValidator('stylesheet_upload', 'post', 'settings.php?category=stylesheets&showuploadform=true');
- $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');
- $form->addRule('new_stylesheet', get_lang('InvalidExtension').' ('.implode(',', $allowed_file_types).')', 'filetype', $allowed_file_types);
- $form->addRule('new_stylesheet', get_lang('ThisFieldIsRequired'), 'required');
- $form->addElement('style_submit_button', 'stylesheet_upload', get_lang('Ok'), array('class'=>'save'));
- if ($form->validate() && is_writable(api_get_path(SYS_CODE_PATH).'css/')) {
- $values = $form->exportValues();
- $picture_element = & $form->getElement('new_stylesheet');
- $picture = $picture_element->getValue();
- $result = upload_stylesheet($values, $picture);
-
- $user_id = api_get_user_id();
- $category = $_GET['category'];
- event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
-
- if ($result) {
- Display::display_confirmation_message(get_lang('StylesheetAdded'));
- }
- } else {
- if (!is_writable(api_get_path(SYS_CODE_PATH).'css/')) {
- Display::display_error_message(api_get_path(SYS_CODE_PATH).'css/'.get_lang('IsNotWritable'));
- } else {
- if ($_GET['showuploadform'] == 'true') {
- echo '<div id="newstylesheetform">';
- } else {
- echo '<div id="newstylesheetform" style="display: none;">';
- }
-
- if ($_configuration['access_url'] == 1) {
- $form->display();
- } else {
- if ($is_style_changeable) {
- $form->display();
- }
- }
- echo '</div>';
- }
- }
- ?>
- <script type="text/javascript">
- function load_preview(){
- $('#stylesheets_id').submit();
- }
- </script>
- <?php
- echo '<form id="stylesheets_id" name="stylesheets" class="form-search" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'">';
- echo '<br /><select name="style" onchange="load_preview(this)" >';
- $list_of_styles = array();
- $list_of_names = array();
- if ($handle = @opendir(api_get_path(SYS_PATH).'main/css/')) {
- $counter = 1;
- while (false !== ($style_dir = readdir($handle))) {
- if (substr($style_dir, 0, 1) == '.') {
- continue;
- }
- $dirpath = api_get_path(SYS_PATH).'main/css/'.$style_dir;
-
- if (is_dir($dirpath)) {
- if ($style_dir != '.' && $style_dir != '..') {
- if (isset($_POST['style']) && $_POST['style'] == $style_dir) {
- $selected = 'selected="true"';
- } else {
- if (!isset($_POST['style']) && ($currentstyle == $style_dir || ($style_dir == 'chamilo' && !$currentstyle))) {
- $selected = 'selected="true"';
- } else {
- $selected = '';
- }
- }
- $show_name = ucwords(str_replace('_', ' ', $style_dir));
- if ($is_style_changeable) {
- $list_of_styles[$style_dir] = "<option value=\"".$style_dir."\" ".$selected." /> $show_name </option>";
- $list_of_names[$style_dir] = $show_name;
-
-
- } else {
- echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>';
- }
- echo '<br />';
- $counter++;
- }
- }
- }
- @closedir($handle);
- }
-
-
- asort($list_of_names);
- foreach($list_of_names as $style_dir=>$item) {
- echo $list_of_styles[$style_dir];
- }
-
- echo '</select> ';
- if ($is_style_changeable){
- echo '<button class="btn save" type="submit" name="submit_stylesheets"> '.get_lang('SaveSettings').' </button></form>';
- }
- }
- function upload_stylesheet($values, $picture) {
- $result = false;
-
- $style_name = api_preg_replace('/[^A-Za-z0-9]/', '', $values['name_stylesheet']);
-
- if (!is_dir(api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/')) {
- mkdir(api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/', api_get_permissions_for_new_directories());
- }
- $info = pathinfo($picture['name']);
- if ($info['extension'] == 'zip') {
-
- $zip = new ZipArchive();
- if ($zip->open($picture['tmp_name'])) {
-
- $num_files = $zip->numFiles;
- $valid = true;
- $single_directory = true;
- $invalid_files = array();
- for ($i = 0; $i < $num_files; $i++) {
- $file = $zip->statIndex($i);
- if (substr($file['name'], -1) != '/') {
- $path_parts = pathinfo($file['name']);
- if (!in_array($path_parts['extension'], array('jpg', 'jpeg', 'png', 'gif', 'css'))) {
- $valid = false;
- $invalid_files[] = $file['name'];
- }
- }
- if (strpos($file['name'], '/') === false) {
- $single_directory = false;
- }
- }
- if (!$valid) {
- $error_string = '<ul>';
- foreach ($invalid_files as $invalid_file) {
- $error_string .= '<li>'.$invalid_file.'</li>';
- }
- $error_string .= '</ul>';
- Display::display_error_message(get_lang('ErrorStylesheetFilesExtensionsInsideZip').$error_string, false);
- } else {
-
- if (!$single_directory) {
-
- $zip->extractTo(api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/');
- $result = true;
- } else {
- $extraction_path = api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/';
- for ($i = 0; $i < $num_files; $i++) {
- $entry = $zip->getNameIndex($i);
- if (substr($entry, -1) == '/') continue;
- $pos_slash = strpos($entry, '/');
- $entry_without_first_dir = substr($entry, $pos_slash + 1);
-
- if (strpos($entry_without_first_dir, '/') !== false) {
- if (!is_dir($extraction_path.dirname($entry_without_first_dir))) {
-
- @mkdir($extraction_path.dirname($entry_without_first_dir), $mode = 0777, true);
- }
- }
- $fp = $zip->getStream($entry);
- $ofp = fopen($extraction_path.dirname($entry_without_first_dir).'/'.basename($entry), 'w');
- while (!feof($fp)) {
- fwrite($ofp, fread($fp, 8192));
- }
- fclose($fp);
- fclose($ofp);
- }
- $result = true;
- }
- }
- $zip->close();
- } else {
- Display::display_error_message(get_lang('ErrorReadingZip').$info['extension'], false);
- }
- } else {
-
- move_uploaded_file($picture['tmp_name'], api_get_path(SYS_CODE_PATH).'css/'.$style_name.'/'.$picture['name']);
- $result = true;
- }
- return $result;
- }
- function store_regions() {
- $plugin_obj = new AppPlugin();
-
- $installed_plugins = $plugin_obj->get_installed_plugins();
-
- $shortlist_installed = array();
- foreach ($installed_plugins as $plugin) {
- $shortlist_installed[] = $plugin['subkey'];
- }
- $shortlist_installed = array_flip(array_flip($shortlist_installed));
- $plugin_list = $plugin_obj->read_plugins_from_path();
- foreach ($plugin_list as $plugin) {
- if (isset($_POST['plugin_'.$plugin])) {
- $areas_to_installed = $_POST['plugin_'.$plugin];
- if (!empty($areas_to_installed)) {
- $plugin_obj->remove_all_regions($plugin);
- foreach ($areas_to_installed as $region) {
- if (!empty($region) && $region != '-1' ) {
- $plugin_obj->add_to_region($plugin, $region);
- }
- }
- }
- }
- }
- }
- function store_plugins() {
- $plugin_obj = new AppPlugin();
-
-
- $plugin_list = $plugin_obj->read_plugins_from_path();
-
- $installed_plugins = array();
-
- foreach ($plugin_list as $plugin) {
- if (isset($_POST['plugin_'.$plugin])) {
- $plugin_obj->install($plugin);
- $installed_plugins[] = $plugin;
- }
- }
-
- if (!empty($installed_plugins)) {
- $remove_plugins = array_diff($plugin_list, $installed_plugins);
- } else {
- $remove_plugins = $plugin_list;
- }
- foreach ($remove_plugins as $plugin) {
- $plugin_obj->uninstall($plugin);
- }
- }
- function store_stylesheets() {
- global $_configuration;
-
- $style = Database::escape_string($_POST['style']);
- if (is_style($style)) {
- api_set_setting('stylesheets', $style, null, 'stylesheets', $_configuration['access_url']);
- }
- return true;
- }
- function is_style($style) {
- $dir = api_get_path(SYS_PATH).'main/css/';
- $dirs = scandir($dir);
- $style = str_replace(array('/', '\\'), array('', ''), $style);
- if (in_array($style, $dirs) && is_dir($dir.$style)) {
- return true;
- }
- return false;
- }
- function handle_search() {
- global $SettingsStored, $_configuration;
- require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
- $search_enabled = api_get_setting('search_enabled');
-
- $form = new FormValidator('search-options', 'post', api_get_self().'?category=Search');
-
-
-
-
-
-
- $values = api_get_settings_options('search_enabled');
- $form->addElement('header', null, get_lang('SearchEnabledTitle'));
-
- $group = array ();
- if (is_array($values)) {
- foreach ($values as $key => $value) {
- $element = & $form->createElement('radio', 'search_enabled', '', get_lang($value['display_text']), $value['value']);
-
- $group[] = $element;
- }
- }
-
- $form->addGroup($group, 'search_enabled', array(get_lang('SearchEnabledTitle'), get_lang('SearchEnabledComment')), '<br />', false);
-
- $search_enabled = api_get_setting('search_enabled');
-
- if ($form->validate()) {
- $formvalues = $form->exportValues();
- $r = api_set_settings_category('Search', 'false', $_configuration['access_url']);
-
- foreach ($formvalues as $key => $value) {
- $result = api_set_setting($key, $value, null, null);
- }
- $search_enabled = $formvalues['search_enabled'];
- Display::display_confirmation_message($SettingsStored);
- }
- $specific_fields = get_specific_field_list();
-
- if ($search_enabled == 'true') {
-
-
-
-
- $values = api_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', array(get_lang('SearchShowUnlinkedResultsTitle'),get_lang('SearchShowUnlinkedResultsComment')), '', false);
- $default_values['search_show_unlinked_results'] = api_get_setting('search_show_unlinked_results');
-
-
-
-
-
- $sf_values = array();
- foreach ($specific_fields as $sf) {
- $sf_values[$sf['code']] = $sf['name'];
- }
- $group = array();
- $url = Display::div(Display::url(get_lang('AddSpecificSearchField'), 'specific_fields.php'), array('class'=>'sectioncomment'));
- if (empty($sf_values)) {
- $form->addElement('html', get_lang('SearchPrefilterPrefix').$url);
- } else {
- $form->addElement('select', 'search_prefilter_prefix', array(get_lang('SearchPrefilterPrefix'), $url), $sf_values, '');
- $default_values['search_prefilter_prefix'] = api_get_setting('search_prefilter_prefix');
- }
-
- }
- $default_values['search_enabled'] = $search_enabled;
-
- $form->addElement('style_submit_button', 'submit', get_lang('Save'),'class="save"');
- $form->setDefaults($default_values);
-
- echo '<div id="search-options-form">';
- $form->display();
- echo '</div>';
-
- if ($search_enabled == 'true') {
- require_once api_get_path(LIBRARY_PATH).'sortable_table.class.php';
- $xapian_path = api_get_path(SYS_PATH).'searchdb';
-
-
-
- $xapian_loaded = Display::return_icon('bullet_green.gif', get_lang('Ok'));
- $dir_exists = Display::return_icon('bullet_green.gif', get_lang('Ok'));
- $dir_is_writable = Display::return_icon('bullet_green.gif', get_lang('Ok'));
- $specific_fields_exists = Display::return_icon('bullet_green.gif', get_lang('Ok'));
-
-
- if (empty($specific_fields)) {
- $specific_fields_exists = Display::return_icon('bullet_red.gif', get_lang('AddSpecificSearchField'));
- }
-
- if (!extension_loaded('xapian')) {
- $xapian_loaded = Display::return_icon('bullet_red.gif', get_lang('Error'));
- }
-
- if (!is_dir($xapian_path)) {
- $dir_exists = Display::return_icon('bullet_red.gif', get_lang('Error'));
- }
-
- if (!is_writable($xapian_path)) {
- $dir_is_writable = Display::return_icon('bullet_red.gif', get_lang('Error'));
- }
-
- $data[] = array(get_lang('XapianModuleInstalled'),$xapian_loaded);
- $data[] = array(get_lang('DirectoryExists').' - '.$xapian_path,$dir_exists);
- $data[] = array(get_lang('IsWritable').' - '.$xapian_path,$dir_is_writable);
- $data[] = array(get_lang('SpecificSearchFieldsAvailable') ,$specific_fields_exists);
- echo Display::tag('h3', get_lang('Settings'));
- $table = new SortableTableFromArray($data);
- $table->set_header(0, get_lang('Setting'), false);
- $table->set_header(1, get_lang('Status'), false);
- echo $table->display();
-
-
- if (api_is_windows_os() == false) {
- $list_of_programs = array('pdftotext','ps2pdf', 'catdoc','html2text','unrtf', 'catppt', 'xls2csv');
-
- foreach($list_of_programs as $program) {
- $output = $ret_val = null;
- exec("which $program", $output, $ret_val);
- $icon = Display::return_icon('bullet_red.gif', get_lang('NotInstalled'));
- if (!empty($output[0])) {
- $icon = Display::return_icon('bullet_green.gif', get_lang('Installed'));
- }
- $data2[]= array($program, $output[0], $icon);
- }
- echo Display::tag('h3', get_lang('ProgramsNeededToConvertFiles'));
- $table = new SortableTableFromArray($data2);
- $table->set_header(0, get_lang('Program'), false);
- $table->set_header(1, get_lang('Path'), false);
- $table->set_header(2, get_lang('Status'), false);
- echo $table->display();
- } else {
- Display::display_warning_message(get_lang('YouAreUsingChamiloInAWindowsPlatformSadlyYouCantConvertDocumentsInOrderToSearchTheContentUsingThisTool'));
- }
- }
- }
- function handle_templates() {
- if ($_GET['action'] != 'add') {
- echo '<div class="actions" style="margin-left: 1px;">';
- echo '<a href="settings.php?category=Templates&action=add">'.Display::return_icon('new_template.png', get_lang('AddTemplate'),'',ICON_SIZE_MEDIUM).'</a>';
- echo '</div>';
- }
- if ($_GET['action'] == 'add' || ($_GET['action'] == 'edit' && is_numeric($_GET['id']))) {
- add_edit_template();
-
- $user_id = api_get_user_id();
- $category = $_GET['category'];
- event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
- } else {
- if ($_GET['action'] == 'delete' && is_numeric($_GET['id'])) {
- delete_template($_GET['id']);
-
- $user_id = api_get_user_id();
- $category = $_GET['category'];
- event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
- }
- display_templates();
- }
- }
- function display_templates() {
- $table = new SortableTable('templates', 'get_number_of_templates', 'get_template_data', 1);
- $table->set_additional_parameters(array('category' => Security::remove_XSS($_GET['category'])));
- $table->set_header(0, get_lang('Image'), true, array('style' => 'width: 101px;'));
- $table->set_header(1, get_lang('Title'));
- $table->set_header(2, get_lang('Actions'), false, array('style' => 'width:50px;'));
- $table->set_column_filter(2, 'actions_filter');
- $table->set_column_filter(0, 'image_filter');
- $table->display();
- }
- function get_number_of_templates() {
-
- $table_system_template = Database :: get_main_table('system_template');
-
- $sql = "SELECT COUNT(id) AS total FROM $table_system_template";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
-
- return $row['total'];
- }
- function get_template_data($from, $number_of_items, $column, $direction) {
-
- $table_system_template = Database :: get_main_table('system_template');
-
- $sql = "SELECT image as col0, title as col1, id as col2 FROM $table_system_template";
- $sql .= " ORDER BY col$column $direction ";
- $sql .= " LIMIT $from,$number_of_items";
- $result = Database::query($sql);
- $return = array();
- while ($row = Database::fetch_array($result)) {
- $row['1'] = get_lang($row['1']);
- $return[] = $row;
- }
-
- return $return;
- }
- function actions_filter($id) {
- $return = '<a href="settings.php?category=Templates&action=edit&id='.Security::remove_XSS($id).'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
- $return .= '<a href="settings.php?category=Templates&action=delete&id='.Security::remove_XSS($id).'" onClick="javascript:if(!confirm('."'".get_lang('ConfirmYourChoice')."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
- return $return;
- }
- function image_filter($image) {
- if (!empty($image)) {
- return '<img src="'.api_get_path(WEB_PATH).'home/default_platform_document/template_thumb/'.$image.'" alt="'.get_lang('TemplatePreview').'"/>';
- } else {
- return '<img src="'.api_get_path(WEB_PATH).'home/default_platform_document/template_thumb/noimage.gif" alt="'.get_lang('NoTemplatePreview').'"/>';
- }
- }
- function add_edit_template() {
-
- $form = new FormValidator('template', 'post', 'settings.php?category=Templates&action='.Security::remove_XSS($_GET['action']).'&id='.Security::remove_XSS($_GET['id']));
-
- if ($_GET['action'] == 'add') {
- $title = get_lang('AddTemplate');
- } else {
- $title = get_lang('EditTemplate');
- }
- $form->addElement('header', '', $title);
-
- $form->add_textfield('title', get_lang('Title'), false);
-
- $form->addElement('html_editor', 'template_text', get_lang('Text'), null, array('ToolbarSet' => 'AdminTemplates', 'Width' => '100%', 'Height' => '400'));
-
- $form->addElement('file','template_image',get_lang('Image'),'');
-
- $form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70'));
-
- if ($_GET['action'] == 'edit') {
-
- $table_system_template = Database :: get_main_table('system_template');
- $sql = "SELECT * FROM $table_system_template WHERE id = '".Database::escape_string($_GET['id'])."'";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
- $defaults['template_id'] = intval($_GET['id']);
- $defaults['template_text'] = $row['content'];
-
- $defaults['title'] = get_lang($row['title']);
-
- $form->addElement('hidden', 'template_id');
-
- if (!empty($row['image'])) {
- $form->addElement('static', 'template_image_preview', '', '<img src="'.api_get_path(WEB_PATH).'home/default_platform_document/template_thumb/'.$row['image'].'" alt="'.get_lang('TemplatePreview').'"/>');
- } else {
- $form->addElement('static', 'template_image_preview', '', '<img src="'.api_get_path(WEB_PATH).'home/default_platform_document/template_thumb/noimage.gif" alt="'.get_lang('NoTemplatePreview').'"/>');
- }
-
- $form->setDefaults($defaults);
- }
-
- $form->addElement('style_submit_button' , 'submit', get_lang('Ok') ,'class="save"');
-
- $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
- $form->addRule('template_text', get_lang('ThisFieldIsRequired'), 'required');
-
- if ($form->validate()) {
- $check = Security::check_token('post');
- if ($check) {
-
- $values = $form->exportValues();
-
- if (!empty($_FILES['template_image']['name'])) {
- require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
- $upload_ok = process_uploaded_file($_FILES['template_image']);
- if ($upload_ok) {
-
- $new_file_name = add_ext_on_mime(stripslashes($_FILES['template_image']['name']), $_FILES['template_image']['type']);
-
- $upload_dir = api_get_path(SYS_PATH).'home/default_platform_document/template_thumb/';
-
- if (!is_dir($upload_dir)) {
- mkdir($upload_dir, api_get_permissions_for_new_directories());
- }
-
- $temp = new Image($_FILES['template_image']['tmp_name']);
- $picture_info = $temp->get_image_info();
- $max_width_for_picture = 100;
- if ($picture_info['width'] > $max_width_for_picture) {
- $thumbwidth = $max_width_for_picture;
- if (empty($thumbwidth) || $thumbwidth == 0) {
- $thumbwidth = $max_width_for_picture;
- }
- $new_height = round(($thumbwidth / $picture_info['width']) * $picture_info['height']);
- $temp->resize($thumbwidth, $new_height, 0);
- }
- $temp->send_image($upload_dir.$new_file_name);
- }
- }
-
- $table_system_template = Database :: get_main_table('system_template');
- if ($_GET['action'] == 'add') {
- $content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>'.Database::escape_string($values['template_text']).'</body>';
- $sql = "INSERT INTO $table_system_template (title, content, image) VALUES ('".Database::escape_string($values['title'])."','".$content_template."','".Database::escape_string($new_file_name)."')";
- $result = Database::query($sql);
-
- Display::display_confirmation_message(get_lang('TemplateAdded'));
- echo '<a href="settings.php?category=Templates&action=add">'.Display::return_icon('new_template.png', get_lang('AddTemplate'),'',ICON_SIZE_MEDIUM).'</a>';
- } else {
- $content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>'.Database::escape_string($values['template_text']).'</body>';
- $sql = "UPDATE $table_system_template set title = '".Database::escape_string($values['title'])."', content = '".$content_template."'";
- if (!empty($new_file_name)) {
- $sql .= ", image = '".Database::escape_string($new_file_name)."'";
- }
- $sql .= " WHERE id='".Database::escape_string($_GET['id'])."'";
- $result = Database::query($sql);
-
- Display::display_confirmation_message(get_lang('TemplateEdited'));
- }
- }
- Security::clear_token();
- display_templates();
- } else {
- $token = Security::get_token();
- $form->addElement('hidden','sec_token');
- $form->setConstants(array('sec_token' => $token));
-
- $form->display();
- }
- }
- function delete_template($id) {
-
- $table_system_template = Database :: get_main_table('system_template');
- $sql = "SELECT * FROM $table_system_template WHERE id = '".Database::escape_string($id)."'";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
- if (!empty($row['image'])) {
- @unlink(api_get_path(SYS_PATH).'home/default_platform_document/template_thumb/'.$row['image']);
- }
-
- $sql = "DELETE FROM $table_system_template WHERE id = '".Database::escape_string($id)."'";
- $result = Database::query($sql);
-
- Display::display_confirmation_message(get_lang('TemplateDeleted'));
- }
- function select_timezone_value() {
- return api_get_timezones();
- }
- function select_gradebook_number_decimals() {
- return array('0', '1', '2');
- }
- function select_gradebook_default_grade_model_id() {
- $grade_model = new GradeModel();
- $models = $grade_model->get_all();
- $options = array();
- $options[-1] = get_lang('None');
- if (!empty($models)) {
- foreach ($models as $model) {
- $options[$model['id']] = $model['name'];
- }
- }
- return $options;
- }
- function update_gradebook_score_display_custom_values($values) {
- require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/scoredisplay.class.php';
- $scoredisplay = ScoreDisplay::instance();
- $scores = $values['gradebook_score_display_custom_values_endscore'];
- $displays = $values['gradebook_score_display_custom_values_displaytext'];
- $nr_displays = count($displays);
- $final = array();
- for ($i = 1; $i < $nr_displays; $i++) {
- if (!empty($scores[$i]) && !empty($displays[$i])) {
- $final[$i]['score'] = $scores[$i];
- $final[$i]['display'] = $displays[$i];
- }
- }
- $scoredisplay->update_custom_score_display_settings($final);
- }
- function generate_settings_form($settings, $settings_by_access_list) {
- $table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
- global $_configuration, $settings_to_avoid, $convert_byte_to_mega_list;
-
- $form = new FormValidator('settings', 'post', 'settings.php?category='.Security::remove_XSS($_GET['category']));
-
- $form->addElement('hidden', 'search_field', Security::remove_XSS($_GET['search_field']));
-
- $url_id = api_get_current_access_url_id();
-
- if ( $_configuration['multiple_access_urls'] && api_is_global_platform_admin() && $url_id == 1) {
- $group = array();
- $group[] = $form->createElement('button', 'mark_all', get_lang('MarkAll'));
- $group[] = $form->createElement('button', 'unmark_all', get_lang('UnmarkAll'));
- $form->addGroup($group, 'buttons_in_action_right');
- }
-
- $default_values = array();
-
- $i = 0;
- foreach ($settings as $row) {
- if (in_array($row['variable'], array_keys($settings_to_avoid))) { continue; }
-
- if ( $_configuration['multiple_access_urls']) {
- if (api_is_global_platform_admin()) {
- if ($row['access_url_locked'] == 0) {
- if ($url_id == 1) {
- if ($row['access_url_changeable'] == '1') {
- $form->addElement('html', '<div style="float: right;"><a class="share_this_setting" data_status = "0" data_to_send = "'.$row['variable'].'" href="javascript:void(0);">'.
- Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')).'</a></div>');
- } else {
- $form->addElement('html', '<div style="float: right;"><a class="share_this_setting" data_status = "1" data_to_send = "'.$row['variable'].'" href="javascript:void(0);">'.
- Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')).'</a></div>');
- }
- } else {
- if ($row['access_url_changeable'] == '1') {
- $form->addElement('html', '<div style="float: right;">'.
- Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')).'</div>');
- } else {
- $form->addElement('html', '<div style="float: right;">'.
- Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')).'</div>');
- }
- }
- }
- }
- }
- $hideme = array();
- $hide_element = false;
- if ($_configuration['access_url'] != 1) {
- if ($row['access_url_changeable'] == 0) {
-
- $hide_element = true;
- $hideme = array('disabled');
- } elseif ($url_info['active'] == 1) {
-
- if (empty($row['variable']))
- $row['variable'] = 0;
- if (empty($row['subkey']))
- $row['subkey'] = 0;
- if (empty($row['category']))
- $row['category'] = 0;
- if (is_array($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ] [ $row['category'] ])) {
-
- if ($settings_by_access_list[ $row['variable'] ] [ $row['subkey'] ] [ $row['category'] ]['selected_value'] != '')
- $row['selected_value'] =$settings_by_access_list[$row['variable']] [$row['subkey']] [ $row['category'] ]['selected_value'];
- }
-
- }
- }
-
- switch ($row['type']) {
- case 'textfield':
- if (in_array($row['variable'], $convert_byte_to_mega_list)) {
- $form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment']), get_lang('MB')), array('class' => 'span1', 'maxlength' => '8'));
- $form->applyFilter($row['variable'], 'html_filter');
- $default_values[$row['variable']] = round($row['selected_value']/1024/1024, 1);
- } elseif ($row['variable'] == 'account_valid_duration') {
- $form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), array('maxlength' => '5'));
- $form->applyFilter($row['variable'], 'html_filter');
- $default_values[$row['variable']] = $row['selected_value'];
-
- } elseif ($row['variable'] == 'platform_charset') {
- $current_system_encoding = api_refine_encoding_id(trim($row['selected_value']));
- $valid_encodings = array_flip(api_get_valid_encodings());
- if (!isset($valid_encodings[$current_system_encoding])) {
- $is_alias_encoding = false;
- foreach ($valid_encodings as $encoding) {
- if (api_equal_encodings($encoding, $current_system_encoding)) {
- $is_alias_encoding = true;
- $current_system_encoding = $encoding;
- break;
- }
- }
- if (!$is_alias_encoding) {
- $valid_encodings[$current_system_encoding] = $current_system_encoding;
- }
- }
- foreach ($valid_encodings as $key => &$encoding) {
- if (api_is_encoding_supported($key) && Database::is_encoding_supported($key)) {
- $encoding = $key;
- } else {
- unset($valid_encodings[$key]);
- }
- }
- $form->addElement('select', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), $valid_encodings);
- $default_values[$row['variable']] = $current_system_encoding;
- } else {
- $hideme['class'] = 'span4';
- $form->addElement('text', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), $hideme);
- $form->applyFilter($row['variable'],'html_filter');
- $default_values[$row['variable']] = $row['selected_value'];
- }
- break;
- case 'textarea':
- if ($row['variable'] == 'header_extra_content') {
- $file = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content.txt';
- $value = '';
- if (file_exists($file)) {
- $value = file_get_contents($file);
- }
- $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('class'=>'span6','rows'=>'10'), $hideme);
- $default_values[$row['variable']] = $value;
- } elseif ($row['variable'] == 'footer_extra_content') {
- $file = api_get_path(SYS_PATH).api_get_home_path().'footer_extra_content.txt';
- $value = '';
- if (file_exists($file)) {
- $value = file_get_contents($file);
- }
- $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('rows'=>'10', 'class'=>'span6'), $hideme);
- $default_values[$row['variable']] = $value;
- } else {
- $form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('rows'=>'10','class'=>'span6'), $hideme);
- $default_values[$row['variable']] = $row['selected_value'];
- }
- break;
- case 'radio':
- $values = api_get_settings_options($row['variable']);
- $group = array ();
- if (is_array($values )) {
- foreach ($values as $key => $value) {
- $element = & $form->createElement('radio', $row['variable'], '', get_lang($value['display_text']), $value['value']);
- if ($hide_element) {
- $element->freeze();
- }
- $group[] = $element;
- }
- }
- $form->addGroup($group, $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), '', false);
- $default_values[$row['variable']] = $row['selected_value'];
- break;
- case 'checkbox';
-
- $sql = "SELECT * FROM $table_settings_current WHERE variable='".$row['variable']."' AND access_url = 1";
- $result = Database::query($sql);
- $group = array ();
- while ($rowkeys = Database::fetch_array($result)) {
-
-
- if (api_get_setting('allow_social_tool') == 'true') {
- if ($rowkeys['variable'] == 'show_tabs' && $rowkeys['subkey'] == 'my_profile') { continue; }
- }
-
- if ($rowkeys['variable'] == 'show_tabs' && $rowkeys['subkey'] == 'my_gradebook') { continue; }
- $element = & $form->createElement('checkbox', $rowkeys['subkey'], '', get_lang($rowkeys['subkeytext']));
- if ($row['access_url_changeable'] == 1) {
-
- $access_url = $_configuration['access_url'];
- if (empty($access_url )) $access_url = 1;
- $sql = "SELECT selected_value FROM $table_settings_current WHERE variable='".$rowkeys['variable']."' AND subkey='".$rowkeys['subkey']."' AND subkeytext='".$rowkeys['subkeytext']."' AND access_url = $access_url";
- $result_access = Database::query($sql);
- $row_access = Database::fetch_array($result_access);
- if ($row_access['selected_value'] == 'true' && !$form->isSubmitted()) {
- $element->setChecked(true);
- }
- } else {
- if ($rowkeys['selected_value'] == 'true' && !$form->isSubmitted()) {
- $element->setChecked(true);
- }
- }
- if ($hide_element) {
- $element->freeze();
- }
- $group[] = $element;
- }
- $form->addGroup($group, $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])),'');
- break;
- case 'link':
- $form->addElement('static', null, array(get_lang($row['title']), get_lang($row['comment'])), get_lang('CurrentValue').' : '.$row['selected_value'], $hideme);
- break;
- case 'select':
-
- $form->addElement('select', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), call_user_func('select_'.$row['variable']), $hideme);
- $default_values[$row['variable']] = $row['selected_value'];
- break;
- case 'custom':
- break;
- }
-
- switch ($row['variable']) {
- case 'pdf_export_watermark_enable':
- $url = PDF::get_watermark($course_code);
- $form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
- if ($url != false) {
- $delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.png',get_lang('DelImage')).'</a>';
- $form->addElement('html', '<a href="'.$url.'">'.$url.' '.$delete_url.'</a>');
- }
- $allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
- $form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
- break;
- case 'timezone_value':
- $timezone = $row['selected_value'];
- if (empty($timezone)) {
- $timezone = _api_get_timezone();
- }
- $form->addElement('html', sprintf(get_lang('LocalTimeUsingPortalTimezoneXIsY'), $timezone, api_get_local_time()));
- break;
- }
- }
-
- if (!empty($settings)) {
- $form->setDefaults($default_values);
- }
- $form->addElement('button', 'submit_fixed_in_bottom', get_lang('SaveSettings'), 'class="save"');
- return $form;
- }
- function search_setting($search) {
- if (empty($search)) {
- return array();
- }
- $table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
- $sql = "SELECT * FROM $table_settings_current WHERE category <> 'Plugins' GROUP BY variable ORDER BY id ASC ";
- $result = Database::store_result(Database::query($sql), 'ASSOC');
- $settings = array();
-
- $search = api_strtolower($search);
-
- if (!empty($result)) {
- foreach ($result as $setting) {
- $found = false;
-
- $title = api_strtolower(get_lang($setting['title']));
-
- if (strpos($title, $search) === false) {
- $comment = api_strtolower(get_lang($setting['comment']));
-
- if (strpos($comment, $search) === false) {
-
- if (strpos($setting['variable'], $search) === false) {
- continue;
- } else {
- $found = true;
- }
- } else {
- $found = true;
- }
-
- } else {
- $found = true;
- }
- if ($found) {
- $settings[] = $setting;
- }
- }
- }
- return $settings;
- }
|