$rows, 'nameTag' => User::hasPermission('actionlog.view') ? 'a' : 'span', )); } private static function listOrganizations() { $res = Database::simpleQuery('SELECT organizationid, displayname, canlogin FROM sat.organization' . ' ORDER BY displayname ASC'); $rows = array(); foreach ($res as $row) { $row['canlogin'] = self::checked((bool)$row['canlogin']); $rows[] = $row; } Render::addTemplate('orglist', array('organizations' => $rows)); } private static function checked(bool $val): string { if ($val) return 'checked="checked"'; return ''; } private static function setUserOption($option) { $val = (string) Request::post('value', '-'); if ($val !== '1' && $val !== '0') die('Nein'); if ($option === 'setmail') { $field = 'emailnotifications'; } elseif ($option === 'setsu') { $field = 'issuperuser'; } elseif ($option === 'setlogin') { $field = 'canlogin'; } else { die('Unknown'); } $user = (string) Request::post('userid', '?'); $ret = Database::exec("UPDATE sat.user SET $field = :onoff WHERE userid = :userid", array( 'userid' => $user, 'onoff' => $val )); error_log("Setting $field to $val for $user - affected: $ret"); if ($ret === false) die('Error'); if ($ret === 0) die(1 - $val); die($val); } private static function setOrgOption($option) { $val = (string) Request::post('value', '-'); if ($val !== '1' && $val !== '0') die('Nein'); if ($option === 'setorglogin') { $field = 'canlogin'; } else { die('Unknown'); } $ret = Database::exec("UPDATE sat.organization SET $field = :onoff WHERE organizationid = :organizationid", array( 'organizationid' => (string) Request::post('organizationid', ''), 'onoff' => $val )); if ($ret === false) die('Error'); if ($ret === 0) die(1 - $val); die($val); } }