/**
  * The disk quota report list shows user accounts, their disk quota and their
  * disk usage, as well as the last time a reminder was sent.
  */
 public function viewDiskQuotaReport()
 {
     global $rbacsystem, $ilErr, $ilSetting, $lng;
     if (!$rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
         $ilErr->raiseError($lng->txt("no_permission"), $ilErr->WARNING);
     }
     $this->tabs_gui->setTabActive('disk_quota');
     $this->addDiskQuotaSubtabs('disk_quota_report');
     // nothing to do if disk quota is not active
     require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
     if (!ilDiskQuotaActivationChecker::_isActive()) {
         return;
     }
     // get the form
     $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.disk_quota_report.html', "Services/WebDAV");
     // get the date of the last update
     require_once "./Services/WebDAV/classes/class.ilDiskQuotaChecker.php";
     $last_update = ilDiskQuotaChecker::_lookupDiskUsageReportLastUpdate();
     if ($last_update == null) {
         // nothing to do if disk usage report has not been run
         $this->tpl->setVariable('LAST_UPDATE_TEXT', $lng->txt('disk_quota_report_not_run_yet'));
         return;
     } else {
         $this->tpl->setVariable('LAST_UPDATE_TEXT', $lng->txt('last_update') . ': ' . ilFormat::formatDate($last_update, 'datetime', true));
     }
     // Filter
     $_SESSION['quota_usage_filter'] = isset($_POST['usage_filter']) ? $_POST['usage_filter'] : $_SESSION['quota_usage_filter'];
     if ($_SESSION['quota_usage_filter'] == 0) {
         $_SESSION['quota_usage_filter'] = 4;
     }
     $_SESSION['quota_access_filter'] = isset($_POST['access_filter']) ? $_POST['access_filter'] : $_SESSION['quota_access_filter'];
     if ($_SESSION['quota_access_filter'] == 0) {
         $_SESSION['quota_access_filter'] = 1;
     }
     $usage_action[1] = $lng->txt('all_users');
     $usage_action[2] = $lng->txt('filter_users_without_disk_usage');
     $usage_action[3] = $lng->txt('filter_users_with_disk_usage');
     $usage_action[4] = $lng->txt('filter_users_with_exceeded_disk_quota');
     $access_action[1] = $lng->txt('all_users');
     $access_action[2] = $lng->txt('filter_users_with_access');
     $access_action[3] = $lng->txt('filter_users_without_access');
     $select_usage_filter = ilUtil::formSelect($_SESSION['quota_usage_filter'], "usage_filter", $usage_action, false, true);
     $select_access_filter = ilUtil::formSelect($_SESSION['quota_access_filter'], "access_filter", $access_action, false, true);
     $this->tpl->setCurrentBlock("filter");
     $this->tpl->setVariable("FILTER_TXT_FILTER", $lng->txt('filter'));
     $this->tpl->setVariable("SELECT_USAGE_FILTER", $select_usage_filter);
     $this->tpl->setVariable("SELECT_ACCESS_FILTER", $select_access_filter);
     $this->tpl->setVariable("FILTER_ACTION", $this->ctrl->getLinkTarget($this, 'viewDiskQuotaReport'));
     $this->tpl->setVariable("FILTER_NAME", 'view');
     $this->tpl->setVariable("FILTER_VALUE", $lng->txt('apply_filter'));
     $this->tpl->parseCurrentBlock();
     // load templates for table
     $a_tpl = new ilTemplate('tpl.table.html', true, true);
     $a_tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
     // create table
     require_once './Services/Table/classes/class.ilTableGUI.php';
     $tbl = new ilTableGUI(0, false);
     // title & header columns
     $header_vars = array('login', 'firstname', 'lastname', 'email', 'access_until', 'last_login', 'disk_quota', 'disk_usage', 'last_reminder');
     $tbl->setHeaderNames(array($lng->txt('login'), $lng->txt('firstname'), $lng->txt('lastname'), $lng->txt('email'), $lng->txt('access_until'), $lng->txt('last_login'), $lng->txt('disk_quota'), $lng->txt('disk_usage'), $lng->txt('last_reminder')));
     $tbl->setHeaderVars($header_vars, $this->ctrl->getParameterArray($this, 'viewDiskQuotaReport', false));
     $tbl->enable("numinfo_header");
     $tbl->setFormName("cmd");
     $tbl->setSelectAllCheckbox("id");
     // sorting
     $tbl->setOrderColumn($_GET["sort_by"]);
     $tbl->setOrderDirection($_GET["sort_order"]);
     // fetch the data
     $data = ilDiskQuotaChecker::_fetchDiskQuotaReport($_SESSION['quota_usage_filter'], $_SESSION['quota_access_filter'], $header_vars[$tbl->getOrderColumn()], $tbl->getOrderDirection());
     // paging
     $tbl->setLimit($_GET["limit"]);
     $tbl->setOffset($_GET["offset"]);
     $tbl->setMaxCount(count($data));
     // footer
     $tbl->setFooter("tblfooter", $lng->txt("previous"), $lng->txt("next"));
     // render table
     $tbl->setTemplate($a_tpl);
     // render rows
     $count = 0;
     for ($i = $tbl->getOffset(); $i < count($data) && $i < $tbl->getOffset() + $tbl->getLimit(); $i++) {
         $row = $data[$i];
         // build columns
         foreach ($header_vars as $key) {
             switch ($key) {
                 case 'login':
                     //build link
                     $this->ctrl->setParameterByClass("ilobjusergui", "ref_id", "7");
                     $this->ctrl->setParameterByClass("ilobjusergui", "obj_id", $row["usr_id"]);
                     $link = $this->ctrl->getLinkTargetByClass("ilobjusergui", "view");
                     $tbl_content_cell = '<a href="' . $link . '">' . htmlspecialchars($row[$key]) . '</a>';
                     break;
                 case 'disk_quota':
                     if ($row['role_id'] == SYSTEM_ROLE_ID) {
                         $tbl_content_cell = "<span class=\"smallgreen\">" . $lng->txt('access_unlimited') . '</span>';
                     } else {
                         $tbl_content_cell = ilFormat::formatSize($row[$key], 'short');
                     }
                     break;
                 case 'disk_usage':
                     if ($row['last_update'] == null) {
                         $tbl_content_cell = $lng->txt('unknown');
                     } else {
                         if ($row['disk_usage'] > $row['disk_quota']) {
                             $tbl_content_cell = "<span class=\"smallred\">" . ilFormat::formatSize($row[$key], 'short') . '</span>';
                         } else {
                             $tbl_content_cell = ilFormat::formatSize($row[$key], 'short');
                         }
                     }
                     break;
                 case 'access_until':
                     if (!$row['active']) {
                         $tbl_content_cell = "<span class=\"smallred\">" . $lng->txt('inactive') . '</span>';
                     } else {
                         if ($row['time_limit_unlimited']) {
                             $tbl_content_cell = "<span class=\"smallgreen\">" . $lng->txt('access_unlimited') . '</span>';
                         } else {
                             if ($row['expired']) {
                                 $tbl_content_cell = "<span class=\"smallred\">" . $lng->txt('access_expired') . '</span>';
                             } else {
                                 $tbl_content_cell = ilFormat::formatDate($row[$key]);
                             }
                         }
                     }
                     break;
                 case 'last_login':
                 case 'last_reminder':
                     if ($row[$key] == null) {
                         $tbl_content_cell = $lng->txt('no_date');
                     } else {
                         $tbl_content_cell = ilFormat::formatDate($row[$key]);
                     }
                     break;
                 default:
                     $tbl_content_cell = htmlspecialchars($row[$key]);
             }
             /*
             				if (is_array($tbl_content_cell))
             				{
             					$tbl->tpl->setCurrentBlock("tbl_cell_subtitle");
             					$tbl->tpl->setVariable("TBL_CELL_SUBTITLE",$tbl_content_cell[1]);
             					$tbl->tpl->parseCurrentBlock();
             					$tbl_content_cell = "<b>".$tbl_content_cell[0]."</b>";
             				}*/
             $tbl->tpl->setCurrentBlock("tbl_content_cell");
             $tbl->tpl->setVariable("TBL_CONTENT_CELL", $tbl_content_cell);
             $tbl->tpl->parseCurrentBlock();
         }
         $tbl->tpl->setCurrentBlock("tbl_content_row");
         $rowcolor = ilUtil::switchColor($count, "tblrow1", "tblrow2");
         $tbl->tpl->setVariable("ROWCOLOR", $rowcolor);
         $tbl->tpl->parseCurrentBlock();
         $count++;
     }
     $tbl->render();
     // Add table to page
     $this->tpl->setVariable("USER_TABLE", $a_tpl->get());
 }
 /**
  * Displays the settings page for test defaults
  *
  * @access public
  */
 function defaultsObject()
 {
     global $ilUser;
     global $ilAccess;
     if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
         // allow only write access
         ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
         $this->ctrl->redirect($this, "infoScreen");
     }
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_defaults.html", "Modules/Test");
     $maxentries = $ilUser->getPref("hits_per_page");
     if ($maxentries < 1) {
         $maxentries = 9999;
     }
     $offset = $_GET["offset"] ? $_GET["offset"] : 0;
     $sortby = $_GET["sort_by"] ? $_GET["sort_by"] : "name";
     $sortorder = $_GET["sort_order"] ? $_GET["sort_order"] : "asc";
     $defaults =& $this->object->getAvailableDefaults($sortby, $sortorder);
     if (count($defaults) > 0) {
         $tablerows = array();
         foreach ($defaults as $row) {
             array_push($tablerows, array("checkbox" => "<input type=\"checkbox\" name=\"chb_defaults[]\" value=\"" . $row["test_defaults_id"] . "\"/>", "name" => $row["name"]));
         }
         $headervars = array("", "name");
         include_once "./Services/Table/classes/class.ilTableGUI.php";
         $tbl = new ilTableGUI(0, FALSE);
         $tbl->setTitle($this->lng->txt("tst_defaults_available"));
         $header_names = array("", $this->lng->txt("title"));
         $tbl->setHeaderNames($header_names);
         $tbl->disable("sort");
         $tbl->disable("auto_sort");
         $tbl->enable("title");
         $tbl->enable("action");
         $tbl->enable("select_all");
         $tbl->setLimit($maxentries);
         $tbl->setOffset($offset);
         $tbl->setData($tablerows);
         $tbl->setMaxCount(count($tablerows));
         $tbl->setOrderDirection($sortorder);
         $tbl->setSelectAllCheckbox("chb_defaults");
         $tbl->setFormName("formDefaults");
         $tbl->addActionButton("deleteDefaults", $this->lng->txt("delete"));
         $tbl->addActionButton("applyDefaults", $this->lng->txt("apply"));
         $header_params = $this->ctrl->getParameterArray($this, "defaults");
         $tbl->setHeaderVars($headervars, $header_params);
         // footer
         $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
         // render table
         $tableoutput = $tbl->render();
         $this->tpl->setVariable("TEST_DEFAULTS_TABLE", $tableoutput);
     } else {
         $this->tpl->setVariable("TEST_DEFAULTS_TABLE", $this->lng->txt("tst_defaults_not_defined"));
     }
     $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "addDefaults"));
     $this->tpl->setVariable("BUTTON_ADD", $this->lng->txt("add"));
     $this->tpl->setVariable("TEXT_DEFAULTS_OF_TEST", $this->lng->txt("tst_defaults_defaults_of_test"));
 }