Changeset 29
- Timestamp:
- 12/23/08 11:30:58 (3 years ago)
- Files:
-
- drupal/modules/iutilities/trunk/iutilities.module (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
drupal/modules/iutilities/trunk/iutilities.module
r28 r29 21 21 '#required' => TRUE, 22 22 ); 23 $form['i -general']['illuminate_notes'] = array(23 $form['i_general']['illuminate_notes'] = array( 24 24 '#type' => 'textarea', 25 25 '#title' => 'Notes', … … 126 126 function iutilities_cron() { 127 127 $confpath = conf_path(); 128 129 //deal with space usage things 128 130 $space_used_string = `du -sm $confpath`; 129 131 $space_used_array = explode("\t", $space_used_string); … … 152 154 variable_set('disk_space_last_emailed',0); 153 155 } 156 157 //deal with hosting expiry things 158 //get the hosting expiry date & convert to UNIX time 159 $expiry_date = variable_get('hosting_expiry_date', time()); 160 if ( is_array($expiry_date) ) { 161 $expiry_date_timestamp = mktime(0,0,0,$expiry_date['month'],$expiry_date['day'],$expiry_date['year']); 162 $warnings_start_date = $expiry_date_timestamp - 2592000; 163 //warning messages will begin a month before contract expiry - 2592000s = 1 month. 164 $now = time(); 165 if ( $warnings_start_date < $now ) { 166 //do the sending email thing, no more than once a week. 167 $site_default_language = language_default(); 168 $email_warnings_role = variable_get('email_warnings_role', 'site administrator'); 169 $users_with_role_query = "select u.mail from {users} u inner join {users_roles} ur on u.uid=ur.uid inner join {role} r on r.rid=ur.rid where r.name='%s'"; 170 $result = db_query(db_rewrite_sql($users_with_role_query),$email_warnings_role); 171 while ($data = db_fetch_object($result)) { 172 drupal_mail('iutilities', 'hosting_expiry', $data->mail, $site_default_language, $params); 173 } 174 //set a variable which notes that an email has been sent. 175 variable_set('hosting_expiry_last_emailed',$now); 176 } elseif ( $warnings_start_date >= $now ) { 177 variable_set('hosting_expiry_last_emailed',0); 178 } 179 } 180 154 181 } 155 182 … … 163 190 $message['body'] = t("An information message from your website host, ILLUMINATE ICT\n------------------------------------------------\n\nYou are listed as being a site administrator for $base_url.\n\nThis email is to inform you that you are currently exceeding your space allocation on our webserver. You have been allocated " . $space_limit . "MB and you are using " . $space_used . "MB.\n\nWe are not about to discontinue your service, but we would appreciate it if you would get in touch to discuss how we could help you. Contact us at http://www.illuminateict.org.uk.\n\nYou will receive this email weekly until we can help you to reduce the amount of space you are using, or increase your space allowance on the server."); 164 191 break; 192 case 'hosting_expiry': 193 $message['subject'] = t('Hosting expiry warning from ' . $base_url); 194 $message['body'] = t("You are about to run out of time."); 165 195 } 166 196 } 167 197 168 198 function iutilities_menu() { 169 $items['admin/reports/ diskusage'] = array(170 'title' => ' Disk UsageReport',171 'description' => 'Dispay a disk usage report for this website. Includes the space limit for the site.',199 $items['admin/reports/illuminate'] = array( 200 'title' => 'Illuminate Hosting Report', 201 'description' => 'Dispay a hosting report for this website. Includes the space limit for the site and other contract information.', 172 202 'access arguments' => array('access disk usage information'), 173 203 'page callback' => 'display_diskusage_report',
