Index: /drupal/modules/iutilities/trunk/iutilities.module =================================================================== --- /drupal/modules/iutilities/trunk/iutilities.module (revision 23) +++ /drupal/modules/iutilities/trunk/iutilities.module (revision 24) @@ -3,13 +3,26 @@ function iutilities_perm() { - return array('access disk usage information'); + return array('access disk usage information', 'access disk usage settings'); } // function illuminate_perm() + +function iutilities_admin() { + $form['disk_space_limit'] = array( + '#type' => 'textfield', + '#title' => t('Maximum space allowed'), + '#default_value' => variable_get('disk_space_limit', 150), + '#size' => 5, + '#maxlength' => 4, + '#field_suffix' => t('MB'), + '#description' => t("Each illuminate ict website is permitted a certain amount of space. By default this is 150MB. This can be increased here."), + '#required' => TRUE, + ); + return system_settings_form($form); +} function iutilities_cron() { $confpath = conf_path(); - $space_used_string = `du -sh $confpath`; + $space_used_string = `du -sm $confpath`; $space_used_array = explode("\t", $space_used_string); - print_r($space_used_array); - $space_used = trim($space_used_array[0]); + $space_used = (int) trim($space_used_array[0]); variable_set('disk_space_used', $space_used); } @@ -17,8 +30,43 @@ function iutilities_menu() { $items['admin/reports/diskusage'] = array( - 'title' => 'Disk Usage', + 'title' => 'Disk Usage Report', + 'description' => 'Dispay a disk usage report for this website. Includes the space limit for the site.', 'access arguments' => array('access disk usage information'), + 'page callback' => 'display_diskusage_report', ); + $items['admin/settings/diskusage'] = array( + 'title' => 'Set Disk Usage Limit', + 'description' => 'The default 150MB space allowance set by illuminate ICT can be increased here.', + 'access callback' => 'access_disk_usage_settings', + 'access arguments' => array('access disk usage settings'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array(iutilities_admin), + ); + return $items; } // illuminate_menu() + +function stuff() { + return "Hello"; +} + +function access_disk_usage_settings() { + global $user; + if ( $user->uid == 1 ) { + return TRUE; + } else { + return FALSE; + } +} + +function display_diskusage_report() { + $space_used = variable_get('disk_space_used',150); + $space_limit = variable_get('disk_space_limit',150); + $space_percentage = ( $space_used / $space_limit ) * 100; + $output = '

Your hosting account with illuminate ICT allows a maximum of '. $space_limit . 'MB.

'; + $output .= '

You are currently using ' . $space_used . 'MB of your allowance.

'; + $output .= '

This is ' . $space_percentage . '% of the available space.

'; + return $output; +} + function iutilities_init() {