Sfoglia il codice sorgente

moved views from User to Route Users

Piotr Labudda 8 anni fa
parent
commit
b704b7e083
2 ha cambiato i file con 51 aggiunte e 52 eliminazioni
  1. 46 3
      SE/se-lib/Route/Users.php
  2. 5 49
      SE/se-lib/User.php

+ 46 - 3
SE/se-lib/Route/Users.php

@@ -136,9 +136,7 @@ class Route_Users extends RouteBase {
 			}
 			}
 			$this->printFormNestedGroups($idGroup);
 			$this->printFormNestedGroups($idGroup);
 		} catch (Exception $e) {
 		} catch (Exception $e) {
-			?><div class="alert alert-danger"><?php echo $e->getMessage(); ?>
-	<br><a href="index.php?_route=Users">wróć</a>
-</div><?php
+			UI::alert('danger', $e->getMessage() . '<br><a href="index.php?_route=Users">wróć</a>');
 			echo UserActivity::showListInContainer();
 			echo UserActivity::showListInContainer();
 		}
 		}
 		echo '</div>';// .container
 		echo '</div>';// .container
@@ -959,4 +957,49 @@ class Route_Users extends RouteBase {
 		]);
 		]);
 	}
 	}
 
 
+	public function loginView($data = []) {
+		UI::gora();
+		UI::loadTemplate('login', $data);
+		UI::inlineJS(APP_PATH_WWW . '/static/p5UI/menuStore.js');
+		echo UI::h('script', [], "
+			(function (global) {
+				if (global.p5UI__MenuStore) global.p5UI__MenuStore.clearCache()
+			})(window)
+		");
+		UI::dol();
+	}
+	public function logoutView($data = []) {
+		UI::gora();
+		UI::loadTemplate('logout', $data);
+		UI::inlineJS(APP_PATH_WWW . '/static/p5UI/menuStore.js');
+		echo UI::h('script', [], "
+			(function (global) {
+				if (global.p5UI__MenuStore) global.p5UI__MenuStore.clearCache()
+			})(window)
+		");
+		UI::dol();
+	}
+	public function passeditView($data = []) {
+		UI::gora();
+		UI::loadTemplate('passedit', $data);
+		UI::dol();
+	}
+	public function reloadPermsView($data = [], $fixUserPermsExecTime = 0) {
+		UI::gora();
+		UI::menu();
+		echo UI::h('div', [ 'class' => "container"], [
+			UI::h('div', [
+				'class' => "alert alert-success",
+				'title' => number_format($fixAllPermsExecTime, 4) . " s / " . number_format($fixUserPermsExecTime, 4) . " s"
+			], "Zaktualizowano uprawnienia"),
+		]);
+		Theme::home($data);
+		echo UI::h('script', [], "
+			(function (global) {
+				if (global.p5UI__MenuStore) global.p5UI__MenuStore.remoteUpdate()
+			})(window)
+		");
+		UI::dol();
+	}
+
 }
 }

+ 5 - 49
SE/se-lib/User.php

@@ -3,7 +3,6 @@
 Lib::loadClass('UserProfile');
 Lib::loadClass('UserProfile');
 Lib::loadClass('Router');
 Lib::loadClass('Router');
 Lib::loadClass('DebugExecutionTime');
 Lib::loadClass('DebugExecutionTime');
-Lib::loadClass('UI');
 
 
 class User {
 class User {
 
 
@@ -244,16 +243,7 @@ class User {
 							unset($_SESSION['AUTHORIZE_USER']);
 							unset($_SESSION['AUTHORIZE_USER']);
 							unset($_SESSION['ADM_ACCOUNT']);
 							unset($_SESSION['ADM_ACCOUNT']);
 
 
-							Lib::loadClass('UI');
-							UI::gora();
-							UI::loadTemplate('logout', $data);
-							UI::inlineJS(APP_PATH_WWW . '/static/p5UI/menuStore.js');
-							echo UI::h('script', [], "
-								(function (global) {
-									if (global.p5UI__MenuStore) global.p5UI__MenuStore.clearCache()
-								})(window)
-							");
-							UI::dol();
+							Router::getRoute('Users')->logoutView($data);
 							exit;
 							exit;
 						}
 						}
 					}
 					}
@@ -269,16 +259,7 @@ class User {
 					session_start();
 					session_start();
 					session_regenerate_id(true);
 					session_regenerate_id(true);
 
 
-					Lib::loadClass('UI');
-					UI::gora();
-					UI::loadTemplate('logout', $data);
-					UI::inlineJS(APP_PATH_WWW . '/static/p5UI/menuStore.js');
-					echo UI::h('script', [], "
-						(function (global) {
-							if (global.p5UI__MenuStore) global.p5UI__MenuStore.clearCache()
-						})(window)
-					");
-					UI::dol();
+					Router::getRoute('Users')->logoutView($data);
 					exit;
 					exit;
 				}
 				}
 				break;
 				break;
@@ -307,21 +288,7 @@ class User {
 						$data['errors'][] = $e->getMessage();
 						$data['errors'][] = $e->getMessage();
 					}
 					}
 
 
-					UI::gora();
-					UI::menu();
-					echo UI::h('div', [ 'class' => "container"], [
-						UI::h('div', [
-							'class' => "alert alert-success",
-							'title' => number_format($fixAllPermsExecTime, 4) . " s / " . number_format($fixUserPermsExecTime, 4) . " s"
-						], "Zaktualizowano uprawnienia"),
-					]);
-					Theme::home($data);
-					echo UI::h('script', [], "
-						(function (global) {
-							if (global.p5UI__MenuStore) global.p5UI__MenuStore.remoteUpdate()
-						})(window)
-					");
-					UI::dol();
+					Router::getRoute('Users')->reloadPermsView($data, $fixUserPermsExecTime);
 					exit;
 					exit;
 				}
 				}
 				break;
 				break;
@@ -344,9 +311,7 @@ class User {
 						}
 						}
 					}
 					}
 
 
-					UI::gora();
-					UI::loadTemplate('passedit', $data);
-					UI::dol();
+					Router::getRoute('Users')->passeditView($data);
 					exit;
 					exit;
 				}
 				}
 				break;
 				break;
@@ -376,16 +341,7 @@ class User {
 		}
 		}
 
 
 		if (!User::logged()) {
 		if (!User::logged()) {
-			Lib::loadClass('UI');
-			UI::gora();
-			UI::loadTemplate('login', $data);
-			UI::inlineJS(APP_PATH_WWW . '/static/p5UI/menuStore.js');
-			echo UI::h('script', [], "
-				(function (global) {
-					if (global.p5UI__MenuStore) global.p5UI__MenuStore.clearCache()
-				})(window)
-			");
-			UI::dol();
+			Router::getRoute('Users')->loginView($data);
 			exit;
 			exit;
 		}
 		}
 	}
 	}