Procházet zdrojové kódy

add Route FixUsersLongLogin

Piotr Labudda před 10 roky
rodič
revize
686bbaff15
1 změnil soubory, kde provedl 79 přidání a 0 odebrání
  1. 79 0
      SE/se-lib/Route/FixUsersLongLogin.php

+ 79 - 0
SE/se-lib/Route/FixUsersLongLogin.php

@@ -0,0 +1,79 @@
+<?php
+
+Lib::loadClass('RouteBase');
+
+class Route_FixUsersLongLogin extends RouteBase {
+
+	public function handleAuth() {
+		if (!User::logged()) {
+			throw new HttpException('Unauthorized', 401);
+		}
+	}
+
+	public function defaultAction() {
+		SE_Layout::gora();
+		SE_Layout::menu();
+		$this->_menu();
+		SE_Layout::dol();
+	}
+
+	private function _menu($selectedMonth) {
+		$usersTodoList = $this->getUsersWithTooLongLogin();
+		?>
+  <div class="container">
+		<?php if (empty($usersTodoList)) : ?>
+			<div class="alert alert-info">
+				Brak użytwkoników z loginem dłuższym niż 20 znaków
+			</div>
+		<?php else : ?>
+		<table class="table table-bordered table-hovered">
+			<tr>
+				<th>Lp.</th>
+				<th>Nr</th>
+				<th>Login</th>
+				<th>Poziom Uprawnień</th>
+				<th>Status</th>
+				<th>Data synch.</th>
+				<th>Nowy login</th>
+				<th>Synch. nowy login</th>
+			</tr>
+			<?php $i = 0; foreach ($usersTodoList as $user) : $i++ ?>
+			<?php $newLogin = substr($user->ADM_ACCOUNT, 0, 20); ?>
+			<tr>
+				<td><?php echo $i; ?></td>
+				<td><?php echo $user->ID; ?></td>
+				<td style="font-family:monospace">
+					<span style=""><?php echo substr($user->ADM_ACCOUNT, 0, 20); ?></span><span style="color:red"><?php echo substr($user->ADM_ACCOUNT, 20); ?></span>
+				</td>
+				<td><?php echo $user->ADM_ADMIN_LEVEL; ?></td>
+				<td><?php echo $user->A_STATUS; ?></td>
+				<td><?php echo $user->A_SYNC_LDAP_DATE; ?></td>
+				<td><?php echo $newLogin; ?></td>
+				<td><a target="_blank"
+							 href="https://biuro.biall-net.pl/SE/version-git/index.php?MENU_INIT=SYNC_LDAP_PERMS&syncUsr=<?php echo $newLogin; ?>">synchronizuj do LDAP (<?php echo $newLogin; ?>)</td>
+			</tr>
+			<?php endforeach; ?>
+		</table>
+		<?php endif; ?>
+	</div>
+<?php
+	}
+
+	public function getUsersWithTooLongLogin() {
+		$usersTodoList = array();
+		$db = DB::getDB();
+		$sql = <<<SQL
+			select `ID`, `ADM_ACCOUNT`, `A_STATUS`
+				, `ADM_ADMIN_LEVEL`
+				, `A_SYNC_LDAP_DATE`
+			from `ADMIN_USERS`
+			where LENGTH(`ADM_ACCOUNT`) > 20
+SQL;
+		$res = $db->query($sql);
+		while ($r = $db->fetch($res)) {
+			$usersTodoList[$r->ADM_ACCOUNT] = $r;
+		}
+		return $usersTodoList;
+	}
+
+}