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);
154 * Registers modules variables for the modules settings
157 * The form with the information
161 * Not very convinced in the fieldset handling method
163 function system_process_form_admin(&$form, $module){
167 //Remove all variables
168 core_variable_rm(FALSE, $module, TRUE);
170 foreach($form[$module.'_admin'] as $item => $value){
172 if($value['type'] == 'fieldset'){
173 foreach($value as $field => $field_value){
174 if(is_array($field_value)){
175 core_variable_set($field, $field_value['value'], $module);
179 if($value['type'] != 'submit' && $value['type'] != 'fieldset'){
180 core_variable_set($item, $value['value'], $module);
184 system_warnings("Changes succesfully made");
190 * Gets settigs for an administrative form, any module can/should use this.
193 * Function to call in order to get the appropriate form
195 * The module that wants to get/set settings
197 * An array with a list of access permissions in order to access this form
199 * The page title, will use 'Foo Settings Page' by default
201 * The file extension in which your function is located, default = admin (will load foo.admin)
204 function system_settings_page($func, $module, $perms, $title = NULL, $file = 'admin'){
206 global $form_status, $skin;
208 //No access by default
211 foreach($perms as $perm){
212 if(user_access($perm)){
218 return PATH_NO_ACCESS;
221 $skin['page_title'] = (!$title ? $module.' Settings Page' : $title);
223 core_load($module, $file);
225 $form = call_user_func($func);
227 //Convert accordingly
228 if(!isset($_POST['form_id'])){
229 system_convert_form_admin($form, $module);
233 $form[$module . '_admin']['submit'] = array(
238 $content = form_form($form, 'post', NULL, (isset($_POST['form_id']) ? FALSE : TRUE));
240 if($form_status == 'verified'){
242 system_process_form_admin($content, $module);
251 function system_settings(){
255 $skin['page_title'] = 'System main settings';
257 return system_settings_page('system_settings_form', 'system');
262 This page will manually rebuild the modules in the database
264 function system_rebuild_modules(){
268 include_once('./includes/modules.admin.inc');
270 $skin['page_title'] = "Module rebuild system";
272 $modules = modules_rebuild_module_settings();
274 $content = "The following modules where proccesed: <br /><br />" ;
276 foreach($modules as $module => $status){
277 $content .= $module . " ........... " . $status . "<br />";
284 function system_modules_overview(){
288 include_once('./includes/modules.admin.inc');
290 $skin['page_title'] = "Module administration page";
291 system_warnings("I am not doing any dependency verifications, if you install something without its dependencies you may crash your system.");
293 //Full available module list
294 $modules = modules_get_modules_list();
297 $core_modules = modules_required_modules();
300 $module_list = modules_list(-1, TRUE);
302 //Details of all available modules
303 $details = modules_get_module_settings($modules);
305 $content .='<table id="system_module_list">
312 foreach($details as $module => $module_details){
314 if(isset($module_list[$module])){
315 if($module_list[$module]['status'] == 1){
316 $module_status = 'Installed';
318 elseif($module_list[$module]['status'] == 0){
319 $module_status = 'Disabled';
323 $module_status = 'Not Installed';
327 <td>'.$module_status.'</td>
328 <td>'. module_parse_details($module_details). '</td>
333 $content .= '</table>';
338 function system_modules_admin($module){
343 include_once('./includes/modules.admin.inc');
344 $skin['page_title'] = "Module Administration Page";
345 system_warnings("I am not doing any dependency verifications, if you install something without its dependencies you may crash your system.");
347 $module_list = modules_list(-1, TRUE);
349 //I have no idea if the module is installed or not at this point. Let's find out where it is
350 if(is_file('./modules/'.$module.'/'.$module.'.install')){
351 include_once('./modules/'.$module.'/'.$module.'.install');
353 elseif(is_file('./core/'.$module.'/'.$module.'.install')){
354 include_once('./core/'.$module.'/'.$module.'.install');
358 if(isset($_GET['t'])){
359 if($_GET['t'] == 'enable' && user_access('admin modules')){
360 module_admin_status(1, $module);
362 else if($_GET['t'] == 'install' && user_access('admin modules')){
363 if(function_exists($module.'_install')){
364 call_user_func($module.'_install'); //Install the module, or at least tell it to run its own installation procedures
365 echo module_admin_status(1, $module);
370 if(!isset($module_list[$module])){
371 $module_details = array($module => 'modules/'.$module.'/'.$module.'.module', 'status' => -1);
374 $module_details = $module_list[$module];
377 $module_ini = modules_get_module_settings(array($module => $module_details[$module]));
379 if($module_details['status'] == 1){
380 $module_status = 'Installed';
382 elseif($module_details['status'] == 0){
383 $module_status = 'Disabled';
386 $module_status = 'Not Installed';
389 $content = '<h2>Module Details</h2';
390 $content .= '<div>'.module_parse_details($module_ini[$module]).'</div><br />';
391 $content .= 'Module Status: ' . $module_status . '<br />';
392 $content .= 'Operations: ';
394 if($module_details['status'] == 1){
395 $content .= path_link('system/admin/modules/admin/'.$module.'&t=uninstall', 'Uninstall');
396 $content .= ' ' . path_link('system/admin/modules/admin/'.$module.'&t=disable', 'Disable');
398 elseif($module_details['status'] == -1){
399 $content .= path_link('system/admin/modules/admin/'.$module.'&t=install', 'Install');
402 $content .= path_link('system/admin/modules/admin/'.$module.'&t=enable', 'Enable');
406 if(function_exists($module.'_perms') && $module_details['status'] == 1){
407 $content .= system_module_perms($module);
418 function system_module_perms($module){
420 $roles = user_roles();
421 core_load('form', 'api');
423 $content = form_set_head('roles_perms');
424 $content .= '<table id="roles_perms">
433 <td>'.$block['owner'].'</td>
434 <td> ('. $block['rid']. ')' .$block['title']. '</td>
438 $content .= '</table></form>';
445 * Page to display php information
447 function system_show_php_info(){
451 $pinfo = ob_get_contents () ;
454 // the name attribute "module_Zend Optimizer" of an anker-tag is not xhtml valide, so replace it with "module_Zend_Optimizer"
455 $content = ( str_replace ( "module_Zend Optimizer", "module_Zend_Optimizer", preg_replace ( '%^.*<body>(.*)</body>.*$%ms', '$1', $pinfo ) ) ) ;