. /** * Custom moove admin infos * * @package theme_moove * @copyright 2020 Willian Mano - http://conecti.me * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace theme_moove\util; defined('MOODLE_INTERNAL') || die(); /** * Class to get some admin infos in Moodle. * * @package theme_moove * @copyright 2020 Willian Mano - http://conecti.me * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class admininfos { /** * Returns the total of active users. * * @return int * @throws \dml_exception */ public function get_totalactiveusers() { global $DB; return $DB->count_records('user', array('deleted' => 0, 'suspended' => 0)) - 1; } /** * Returns the total of suspended users. * * @return int * @throws \dml_exception */ public function get_suspendedusers() { global $DB; return $DB->count_records('user', array('deleted' => 0, 'suspended' => 1)); } /** * Returns the total of courses. * * @return int * @throws \dml_exception */ public function get_totalcourses() { global $DB; return $totalcourses = $DB->count_records('course') - 1; } /** * Returns the total of online users. * * @return int * @throws \dml_exception */ public function get_totalonlineusers() { $onlineusers = new \block_online_users\fetcher(null, time(), 300, null, CONTEXT_SYSTEM, null); return $onlineusers->count_users(); } /** * Returns the total of disk usage * * @return string * @throws \coding_exception */ public function get_totaldiskusage() { $cache = \cache::make('theme_moove', 'admininfos'); $totalusagereadable = $cache->get('totalusagereadable'); if (!$totalusagereadable) { return get_string('notcalculatedyet', 'theme_moove'); } $usageunit = ' MB'; if ($totalusagereadable > 1024) { $usageunit = ' GB'; } return $totalusagereadable . $usageunit; } }