PageRenderTime 27ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/modules/system/index.php

https://github.com/buitenzorg812/s3st15_matoa
PHP | 257 lines | 134 code | 45 blank | 78 comment | 13 complexity | 6973cfdc563e8e0f89c6521f77f5bc32 MD5 | raw file
  1. <?php
  2. /**
  3. *
  4. * Copyright (C) 2007,2008 Arie Nugraha (dicarve@yahoo.com)
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. */
  21. /* Global application configuration */
  22. // key to authenticate
  23. define('INDEX_AUTH', '1');
  24. // key to get full database access
  25. define('DB_ACCESS', 'fa');
  26. if (!defined('SENAYAN_BASE_DIR')) {
  27. // main system configuration
  28. require '../../../sysconfig.inc.php';
  29. // start the session
  30. require SENAYAN_BASE_DIR.'admin/default/session.inc.php';
  31. }
  32. // IP based access limitation
  33. require LIB_DIR.'ip_based_access.inc.php';
  34. do_checkIP('smc');
  35. do_checkIP('smc-system');
  36. // only administrator have privileges to change global settings
  37. if ($_SESSION['uid'] != 1) {
  38. header('Location: '.MODULES_WEB_ROOT_DIR.'system/content.php');
  39. die();
  40. }
  41. require SENAYAN_BASE_DIR.'admin/default/session_check.inc.php';
  42. require SIMBIO_BASE_DIR.'simbio_FILE/simbio_directory.inc.php';
  43. require SIMBIO_BASE_DIR.'simbio_GUI/form_maker/simbio_form_table_AJAX.inc.php';
  44. require SIMBIO_BASE_DIR.'simbio_GUI/table/simbio_table.inc.php';
  45. require SIMBIO_BASE_DIR.'simbio_DB/simbio_dbop.inc.php';
  46. ?>
  47. <fieldset class="menuBox">
  48. <div class="menuBoxInner systemIcon">
  49. <?php echo strtoupper(__('System Configuration')).'<hr />'.__('Modify global application preferences'); ?>
  50. </div>
  51. </fieldset>
  52. <?php
  53. /* main content */
  54. /* Config Vars EDIT FORM */
  55. /* Config Vars update process */
  56. if (isset($_POST['updateData'])) {
  57. // reset/truncate setting table content
  58. // library name
  59. $library_name = $dbs->escape_string(strip_tags(trim($_POST['library_name'])));
  60. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($library_name)).'\' WHERE setting_name=\'library_name\'');
  61. // library subname
  62. $library_subname = $dbs->escape_string(strip_tags(trim($_POST['library_subname'])));
  63. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($library_subname)).'\' WHERE setting_name=\'library_subname\'');
  64. // initialize template arrays
  65. $template = array('theme' => $sysconf['template']['theme'], 'css' => $sysconf['template']['css']);
  66. $admin_template = array('theme' => $sysconf['admin_template']['theme'], 'css' => $sysconf['admin_template']['css']);
  67. // template
  68. $template['theme'] = $_POST['template'];
  69. $template['css'] = str_replace($sysconf['template']['theme'], $template['theme'], $sysconf['template']['css']);
  70. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($template)).'\' WHERE setting_name=\'template\'');
  71. // admin template
  72. $admin_template['theme'] = $_POST['admin_template'];
  73. $admin_template['css'] = str_replace($sysconf['admin_template']['theme'], $admin_template['theme'], $sysconf['admin_template']['css']);
  74. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($admin_template)).'\' WHERE setting_name=\'admin_template\'');
  75. // language
  76. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($_POST['default_lang'])).'\' WHERE setting_name=\'default_lang\'');
  77. // opac num result
  78. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($_POST['opac_result_num'])).'\' WHERE setting_name=\'opac_result_num\'');
  79. // promoted titles in homepage
  80. if (isset($_POST['enable_promote_titles'])) {
  81. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($_POST['enable_promote_titles'])).'\' WHERE setting_name=\'enable_promote_titles\'');
  82. } else {
  83. $dbs->query('UPDATE setting SET setting_value=\'N;\' WHERE setting_name=\'enable_promote_titles\'');
  84. }
  85. // quick return
  86. $quick_return = $_POST['quick_return'] == '1'?true:false;
  87. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($quick_return)).'\' WHERE setting_name=\'quick_return\'');
  88. // loan and due date manual change
  89. $circulation_receipt = $_POST['circulation_receipt'] == '1'?true:false;
  90. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($circulation_receipt)).'\' WHERE setting_name=\'circulation_receipt\'');
  91. // loan and due date manual change
  92. $allow_loan_date_change = $_POST['allow_loan_date_change'] == '1'?true:false;
  93. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($allow_loan_date_change)).'\' WHERE setting_name=\'allow_loan_date_change\'');
  94. // loan limit override
  95. $loan_limit_override = $_POST['loan_limit_override'] == '1'?true:false;
  96. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($loan_limit_override)).'\' WHERE setting_name=\'loan_limit_override\'');
  97. // xml detail
  98. $xml_detail = $_POST['enable_xml_detail'] == '1'?true:false;
  99. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($xml_detail)).'\' WHERE setting_name=\'enable_xml_detail\'');
  100. // xml result
  101. $xml_result = $_POST['enable_xml_result'] == '1'?true:false;
  102. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($xml_result)).'\' WHERE setting_name=\'enable_xml_result\'');
  103. // file download
  104. $file_download = $_POST['allow_file_download'] == '1'?true:false;
  105. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($file_download)).'\' WHERE setting_name=\'allow_file_download\'');
  106. // session timeout
  107. $session_timeout = intval($_POST['session_timeout']) >= 1800?$_POST['session_timeout']:1800;
  108. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($session_timeout)).'\' WHERE setting_name=\'session_timeout\'');
  109. // barcode encoding
  110. $dbs->query('UPDATE setting SET setting_value=\''.$dbs->escape_string(serialize($_POST['barcode_encoding'])).'\' WHERE setting_name=\'barcode_encoding\'');
  111. // write log
  112. utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'system', $_SESSION['realname'].' change application global configuration');
  113. utility::jsAlert(__('Settings saved. Refreshing page'));
  114. echo '<script type="text/javascript">parent.location.href = \'../../index.php?mod=system\';</script>';
  115. }
  116. /* Config Vars update process end */
  117. // create new instance
  118. $form = new simbio_form_table_AJAX('mainForm', $_SERVER['PHP_SELF'], 'post');
  119. $form->submit_button_attr = 'name="updateData" value="'.__('Save Settings').'" class="button"';
  120. // form table attributes
  121. $form->table_attr = 'align="center" id="dataList" cellpadding="5" cellspacing="0"';
  122. $form->table_header_attr = 'class="alterCell" style="font-weight: bold;"';
  123. $form->table_content_attr = 'class="alterCell2"';
  124. // load settings from database
  125. utility::loadSettings($dbs);
  126. // version status
  127. $form->addAnything('Senayan Version', '<strong>'.SENAYAN_VERSION.'</strong>');
  128. // library name
  129. $form->addTextField('text', 'library_name', __('Library Name'), $sysconf['library_name'], 'style="width: 100%;"');
  130. // library subname
  131. $form->addTextField('text', 'library_subname', __('Library Subname'), $sysconf['library_subname'], 'style="width: 100%;"');
  132. /* Form Element(s) */
  133. // public template
  134. // scan template directory
  135. $template_dir = SENAYAN_BASE_DIR.$sysconf['template']['dir'];
  136. $dir = new simbio_directory($template_dir);
  137. $dir_tree = $dir->getDirectoryTree(1);
  138. // sort array by index
  139. ksort($dir_tree);
  140. // loop array
  141. foreach ($dir_tree as $dir) {
  142. $tpl_options[] = array($dir, $dir);
  143. }
  144. $form->addSelectList('template', __('Public Template'), $tpl_options, $sysconf['template']['theme']);
  145. // admin template
  146. // scan admin template directory
  147. $admin_template_dir = SENAYAN_BASE_DIR.'admin'.DIRECTORY_SEPARATOR.$sysconf['admin_template']['dir'];
  148. $dir = new simbio_directory($admin_template_dir);
  149. $dir_tree = $dir->getDirectoryTree(1);
  150. // sort array by index
  151. ksort($dir_tree);
  152. // loop array
  153. foreach ($dir_tree as $dir) {
  154. $admin_tpl_options[] = array($dir, $dir);
  155. }
  156. $form->addSelectList('admin_template', __('Admin Template'), $admin_tpl_options, $sysconf['admin_template']['theme']);
  157. // application language
  158. require_once(LANGUAGES_BASE_DIR.'localisation.php');
  159. $form->addSelectList('default_lang', __('Default App. Language'), $available_languages, $sysconf['default_lang']);
  160. // opac result list number
  161. $result_num_options[] = array('10', '10');
  162. $result_num_options[] = array('20', '20');
  163. $result_num_options[] = array('30', '30');
  164. $result_num_options[] = array('40', '40');
  165. $result_num_options[] = array('50', '50');
  166. $form->addSelectList('opac_result_num', __('Number Of Collections To Show In OPAC Result List'), $result_num_options, $sysconf['opac_result_num'] );
  167. // homepage setting
  168. $promote_options[] = array('1', 'Yes');
  169. $form->addCheckBox('enable_promote_titles', __('Show Promoted Titles at Homepage'), $promote_options, $sysconf['enable_promote_titles']?'1':'0');
  170. // enable quick return
  171. $options = null;
  172. $options[] = array('0', __('Disable'));
  173. $options[] = array('1', __('Enable'));
  174. $form->addSelectList('quick_return', __('Quick Return'), $options, $sysconf['quick_return']?'1':'0');
  175. // circulation receipt
  176. $options = null;
  177. $options[] = array('0', __('Don\'t Print'));
  178. $options[] = array('1', __('Print'));
  179. $form->addSelectList('circulation_receipt', __('Print Circulation Receipt'), $options, $sysconf['circulation_receipt']?'1':'0');
  180. // enable manual changes of loan and due date in circulation transaction
  181. $options = null;
  182. $options[] = array('0', __('Disable'));
  183. $options[] = array('1', __('Enable'));
  184. $form->addSelectList('allow_loan_date_change', __('Loan and Due Date Manual Change'), $options, $sysconf['allow_loan_date_change']?'1':'0');
  185. // enable loan limit overriden
  186. $options = null;
  187. $options[] = array('0', __('Disable'));
  188. $options[] = array('1', __('Enable'));
  189. $form->addSelectList('loan_limit_override', __('Loan Limit Override'), $options, $sysconf['loan_limit_override']?'1':'0');
  190. // enable bibliography xml detail
  191. $options = null;
  192. $options[] = array('0', __('Disable'));
  193. $options[] = array('1', __('Enable'));
  194. $form->addSelectList('enable_xml_detail', __('OPAC XML Detail'), $options, $sysconf['enable_xml_detail']?'1':'0');
  195. // enable bibliography xml result set
  196. $options = null;
  197. $options[] = array('0', __('Disable'));
  198. $options[] = array('1', __('Enable'));
  199. $form->addSelectList('enable_xml_result', __('OPAC XML Result'), $options, $sysconf['enable_xml_result']?'1':'0');
  200. // allow file attachment download
  201. $options = null;
  202. $options[] = array('0', __('Forbid'));
  203. $options[] = array('1', __('Allow'));
  204. $form->addSelectList('allow_file_download', __('Allow OPAC File Download'), $options, $sysconf['allow_file_download']?'1':'0');
  205. // session timeout
  206. $form->addTextField('text', 'session_timeout', __('Session Login Timeout'), $sysconf['session_timeout'], 'style="width: 10%;"');
  207. // barcode encoding
  208. $form->addSelectList('barcode_encoding', __('Barcode Encoding'), $barcodes_encoding, $sysconf['barcode_encoding'] );
  209. // print out the object
  210. echo $form->printOut();
  211. /* main content end */
  212. ?>