/** * The code that needs to be called when the cron is running * * If $this->enableUserAndGroupSupport() returns TRUE then the run function * will be called for each $user. (The $user parameter will be given) * * If $this->enableUserAndGroupSupport() returns FALSE then the * $user parameter is null and the run function will be called only once. * * @param CronJob $cronJob * @param \GO\Base\Model\User $user [OPTIONAL] */ public function run(CronJob $cronJob, \GO\Base\Model\User $user = null) { $stmt = \GO::getDbConnection()->query("SHOW TABLE STATUS FROM `" . \GO::config()->db_name . "`;"); $database_usage = 0; while ($r = $stmt->fetch()) { $database_usage += $r['Data_length']; $database_usage += $r['Index_length']; } \GO::config()->save_setting('database_usage', $database_usage); $folder = new \GO\Base\Fs\Folder(\GO::config()->file_storage_path); \GO::config()->save_setting('file_storage_usage', $folder->calculateSize()); if (\GO::modules()->postfixadmin) { $findParams = \GO\Base\Db\FindParams::newInstance()->select('sum(`usage`) AS `usage`')->ignoreAcl()->single(); $result = \GO\Postfixadmin\Model\Mailbox::model()->find($findParams); \GO::config()->save_setting('mailbox_usage', $result->usage * 1024); } }