3 function system_main_links(){
7 if(user_access('admin site')){
8 $admin_links['System']['Settings'][] = array('href' => 'system/admin/settings', 'text' => 'System settings', 'help' => 'Main system settings');
9 $admin_links['System']['Settings'][] = array('href' => 'system/admin/php', 'text' => 'PHP Info');
10 $admin_links['System']['Modules'][] = array('href' => 'system/admin/rebuild/modules', 'text' => 'Rebuild Module Settings');
11 $admin_links['System']['Modules'][] = array('href' => 'system/admin/modules', 'text' => 'Handle Modules');
15 function system_links_main(&$links){
21 foreach($links as $cat => $details){
22 $final_links .= '<h2> '.$cat.' </h2><hr/>';
24 foreach($details as $d => $data){
25 foreach($data as $content => $c){
26 $final_links .= path_link($c['href'], $c['text'], $c['help']) .'<br />';
30 $final_links .= '<br/>';
37 * Add tabs to the system admin pages
39 function system_admin_tabs(){
41 $skin_tabs = array('admin' => 'Main Page',
42 'block/admin/new' => 'Add Block'
45 skin_tabs($skin_tabs);
48 function system_admin_main(){
50 global $admin_links, $skin, $admin_notices;
52 //Call hook for admin main page
54 hooks_invoke('admin_page');
56 $skin['page_title'] = 'Adiminstrative Center';
59 $content = implode("<br />", $admin_notices) . "<br /><br /><hr/><br />";
61 $content .= system_links_main($admin_links);
67 function system_settings_form(){
71 $form['system_admin']['site_name'] = array(
73 'text' => 'Site Name',
78 $form['system_admin']['site_slogan'] = array(
85 $form['system_admin']['site_mail'] = array(
87 'text' =>'Default email',
92 $form['system_admin']['anon_name'] = array(
94 'text' =>'Anonymous name',
95 'value' => 'Anonymous',
99 $form['system_admin']['site_frontpage'] = array(
101 'text' => 'Front page ' . $settings['base_root'].$settings['base_url'] . $settings['base_path'] . '?x=',
102 'help' => 'Leave blank for node',
107 $form['system_admin']['debug_info'] = array(
109 'text' => 'Display Debug info',
110 'help' => 'Leave blank for node',
112 'options' => array('No', 'Yes'),
113 'help' => 'This will be displayed for all acounts'
116 $form['system_admin']['db_errors'] = array(
118 'text' => 'Display Database errors',
119 'value' => 'Screen Only',
120 'options' => array('Screen Only', 'Screen and Database', 'Database Only', 'Do not Display'),
121 'help' => 'This will be displayed for all acounts'
128 * Set values for admin form
131 * The form with the values
135 function system_convert_form_admin(&$form, $module){
137 //modify default values if they have been set already
138 foreach($form[$module.'_admin'] as $item => $value){
141 if($value['type'] == 'fieldset'){
142 foreach($value as $field => $field_value){
143 if(is_array($field_value)){
144 $form[$module.'_admin'][$item][$field]['value'] = core_variable_get($field, $field_value['value'], $module);
149 $form[$module.'_admin'][$item]['value'] = core_variable_get($item, $value['value'], $module);
157 * Registers modules variables for the modules settings
160 * The form with the information
164 * Not very convinced in the fieldset handling method
166 function system_process_form_admin(&$form, $module){
170 //Remove all variables
171 core_variable_rm(FALSE, $module, TRUE);
173 foreach($form[$module.'_admin'] as $item => $value){
175 if($value['type'] == 'fieldset'){
176 foreach($value as $field => $field_value){
177 if(is_array($field_value)){
178 core_variable_set($field, $field_value['value'], $module);
182 if($value['type'] != 'submit' && $value['type'] != 'fieldset'){
183 core_variable_set($item, $value['value'], $module);
187 system_warnings("Changes succesfully made");
193 * Gets settigs for an administrative form, any module can/should use this.
196 * Function to call in order to get the appropriate form
198 * The module that wants to get/set settings
200 * An array with a list of access permissions in order to access this form
202 * The page title, will use 'Foo Settings Page' by default
204 * The file extension in which your function is located, default = admin (will load foo.admin)
207 function system_settings_page($func, $module, $perms, $title = NULL, $file = 'admin'){
209 global $form_status, $skin;
211 //No access by default
214 foreach($perms as $perm){
215 if(user_access($perm)){
221 return PATH_NO_ACCESS;
224 $skin['page_title'] = (!$title ? $module.' Settings Page' : $title);
226 core_load($module, $file);
228 $form = call_user_func($func);
230 //Convert accordingly
231 if(!isset($_POST['form_id'])){
232 system_convert_form_admin($form, $module);
236 $form[$module . '_admin']['submit'] = array(
241 $content = form_form($form, 'post', NULL, (isset($_POST['form_id']) ? FALSE : TRUE));
243 if($form_status == 'verified'){
245 system_process_form_admin($content, $module);
254 function system_settings(){
258 $skin['page_title'] = 'System main settings';
260 return system_settings_page('system_settings_form', 'system');
265 This page will manually rebuild the modules in the database
267 function system_rebuild_modules(){
271 include_once('./includes/modules.admin.inc');
273 $skin['page_title'] = "Module rebuild system";
275 $modules = modules_rebuild_module_settings();
277 $content = "The following modules where proccesed: <br /><br />" ;
279 foreach($modules as $module => $status){
280 $content .= $module . " ........... " . $status . "<br />";
287 function system_modules_overview(){
291 include_once('./includes/modules.admin.inc');
293 $skin['page_title'] = "Module administration page";
294 system_warnings("I am not doing any dependency verifications, if you install something without its dependencies you may crash your system.");
296 //Full available module list
297 $modules = modules_get_modules_list();
300 $core_modules = modules_required_modules();
303 $module_list = modules_list(-1, TRUE);
305 //Details of all available modules
306 $details = modules_get_module_settings($modules);
308 $content .='<table id="system_module_list">
315 foreach($details as $module => $module_details){
317 if(isset($module_list[$module])){
318 if($module_list[$module]['status'] == 1){
319 $module_status = 'Installed';
321 elseif($module_list[$module]['status'] == 0){
322 $module_status = 'Disabled';
326 $module_status = 'Not Installed';
330 <td>'.$module_status.'</td>
331 <td>'. module_parse_details($module_details). '</td>
336 $content .= '</table>';
341 function system_modules_admin($module){
346 include_once('./includes/modules.admin.inc');
347 $skin['page_title'] = "Module Administration Page";
348 system_warnings("I am not doing any dependency verifications, if you install something without its dependencies you may crash your system.");
350 $module_list = modules_list(-1, TRUE);
352 //I have no idea if the module is installed or not at this point. Let's find out where it is
353 if(is_file('./modules/'.$module.'/'.$module.'.install')){
354 include_once('./modules/'.$module.'/'.$module.'.install');
356 elseif(is_file('./core/'.$module.'/'.$module.'.install')){
357 include_once('./core/'.$module.'/'.$module.'.install');
361 if(isset($_GET['t'])){
362 if($_GET['t'] == 'enable' && user_access('admin modules')){
363 module_admin_status(1, $module);
365 else if($_GET['t'] == 'install' && user_access('admin modules')){
366 if(function_exists($module.'_install')){
367 call_user_func($module.'_install'); //Install the module, or at least tell it to run its own installation procedures
368 echo module_admin_status(1, $module);
373 if(!isset($module_list[$module])){
374 $module_details = array($module => 'modules/'.$module.'/'.$module.'.module', 'status' => -1);
377 $module_details = $module_list[$module];
380 $module_ini = modules_get_module_settings(array($module => $module_details[$module]));
382 if($module_details['status'] == 1){
383 $module_status = 'Installed';
385 elseif($module_details['status'] == 0){
386 $module_status = 'Disabled';
389 $module_status = 'Not Installed';
392 $content = '<h2>Module Details</h2';
393 $content .= '<div>'.module_parse_details($module_ini[$module]).'</div><br />';
394 $content .= 'Module Status: ' . $module_status . '<br />';
395 $content .= 'Operations: ';
397 if($module_details['status'] == 1){
398 $content .= path_link('system/admin/modules/admin/'.$module.'&t=uninstall', 'Uninstall');
399 $content .= ' ' . path_link('system/admin/modules/admin/'.$module.'&t=disable', 'Disable');
401 elseif($module_details['status'] == -1){
402 $content .= path_link('system/admin/modules/admin/'.$module.'&t=install', 'Install');
405 $content .= path_link('system/admin/modules/admin/'.$module.'&t=enable', 'Enable');
409 if(function_exists($module.'_perms') && $module_details['status'] == 1){
410 $content .= system_module_perms($module);
421 function system_module_perms($module){
423 $roles = user_roles();
424 core_load('form', 'api');
426 $content = form_set_head('roles_perms');
427 $content .= '<table id="roles_perms">
436 <td>'.$block['owner'].'</td>
437 <td> ('. $block['rid']. ')' .$block['title']. '</td>
441 $content .= '</table></form>';
448 * Page to display php information
450 function system_show_php_info(){
454 $pinfo = ob_get_contents () ;
457 // the name attribute "module_Zend Optimizer" of an anker-tag is not xhtml valide, so replace it with "module_Zend_Optimizer"
458 $content = ( str_replace ( "module_Zend Optimizer", "module_Zend_Optimizer", preg_replace ( '%^.*<body>(.*)</body>.*$%ms', '$1', $pinfo ) ) ) ;