浏览代码

Merge branch 'master' of ssh://biuro.biall-net.pl:2222/plabudda/se

arkadiusz binder 7 年之前
父节点
当前提交
ed68e0e847

+ 17 - 7
SE/index.php

@@ -32,14 +32,24 @@ User::auth();// die if not logged in
 
 if (!V::get('SKIP_TIMER', '', $_REQUEST)) S::timeoutUpdate(true);// User is authorized - update logout time
 
-$route = V::get('_route', '', $_REQUEST);
-try {
-	$rootPostTask = V::get('_rootPostTask', '', $_REQUEST);
-	if ($rootPostTask) Router::rootPostTask($rootPostTask);
-} catch (Exception $e) {
-	DBG::log($e);
-	S::saveUserMessage(get_class($e), $e->getMessage());
+if (Config::get('LEGACY_INIT_FUNCTIONS_OFF')) {
+	$route = V::get('_route', '', $_REQUEST);
+	if ($route) {
+		Router::route($route);
+	} else {
+		UI::startHtml();
+		UI::menu();
+		UI::loadTemplate('defaultPage', []);
+		UI::endHtml();
+	}
+
+	exit;
 }
+
+
+// LEGACY_INIT_FUNCTIONS:
+
+$route = V::get('_route', '', $_REQUEST);
 Router::route($route);
 
 //STD INCLUDE 2010-01-14

+ 9 - 0
SE/se-lib/Config.php

@@ -61,6 +61,15 @@ class Config {
 
 		if ($_main_config === null) {
 			$_main_config = self::getConfFile();
+
+			if ($projPath = Config::getProjectPath()) {
+				if (file_exists("{$projPath}/config.php")) {
+					$projConfig = include "{$projPath}/config.php";
+					if (!empty($projConfig)) {
+						$_main_config = array_merge($_main_config, $projConfig);
+					}
+				}
+			}
 		}
 
 		if ($key == 'get-all-data') {

+ 1 - 1
SE/se-lib/Core/AclHelper.php

@@ -281,7 +281,7 @@ class Core_AclHelper {// Helper class for Acl
 			}
 		}
 
-		if (1) {// Druki
+		if (1 && !Config::get('VIEW_TABLE_HIDE_BASE_ROW_FUNCTIONS')) {// Druki
 			$parsedNs = self::parseNamespaceUrl($acl->getNamespace());
 			// array (
 			//	 'name' => 'TEST_PERMS',

+ 5 - 1
SE/se-lib/DBG.php

@@ -199,6 +199,9 @@ class DBG {
 	}
 
 	public static function nicePrint($variable, $varName, $params = []) {
+		echo self::getNicePrint($variable, $varName, $params);
+	}
+	public static function getNicePrint($variable, $varName, $params = []) {
 		$col = ['green'=>'#96c178', 'red'=>'#de6b74', 'blue'=>'#55b5c1', 'bg-dark'=>'#282c34', 'white'=>'#abb2bf', 'orange'=>'#d19a66', 'violet'=>'#c476db'];
 		if (is_scalar($variable)) {
 			$outLines = [ V::strShort((string)$variable, 20), $variable ];
@@ -232,7 +235,8 @@ class DBG {
 			}
 		}
 		$maxHeight = V::get('maxHeight', '400px', $params);
-		echo UI::h('details', ['style'=>"max-width:800px"], [
+
+		return UI::h('details', ['style'=>"max-width:800px"], [
 			UI::h('summary', ['style'=>"padding:3px 8px;border:1px solid #ccc;background-color:{$col['bg-dark']};color:{$col['white']};font-size:small"],
 				($varName)
 				?	'<b style="color:'.$col['red'].'">' . $varName . "</b> => " . htmlspecialchars(V::strShort($firstLine, 20))

+ 64 - 2
SE/se-lib/Route/Status.php

@@ -18,7 +18,7 @@ class Route_Status extends RouteBase {
 		try {
 			DB::getPDO();
 
-			$this->runPostTask();
+			$this->runPostTask(); // _postTask = $this->"{$_POST['_postTask']}PostTask"()
 
 			$this->viewStatusDatabase();
 
@@ -76,7 +76,16 @@ class Route_Status extends RouteBase {
 		$totalToUpdateRef = RefConfig::getToUpdateTotal();
 
 		UI::table([
-			'caption' => UI::h('b', ['style' => "color:#000"], 'Baza danych'),
+			'caption' => UI::h('b', ['style' => "color:#000"], [
+				"Baza danych",
+				" ",
+				UI::hButtonPost("sprawdź tabele", [
+					'class' => "btn btn-xs btn-default",
+					'data' => [
+						'_postTask' => 'checkDatabaseTables',
+					]
+				]),
+			]),
 			'rows' => [
 				[
 					'nazwa' => "Event Scheduler (generowanie Grafika, itp.)",
@@ -354,4 +363,57 @@ class Route_Status extends RouteBase {
 		];
 	}
 
+	function checkDatabaseTablesPostTask() {
+		$pdo = DB::getPDO();
+		// DBG::nicePrint($pdo, "DB Info");
+		// DBG::nicePrint(get_class_methods($pdo), "pdo methods");
+		$tblName = V::get('_fixTable', '', $_POST);
+		if (!empty($tblName)) {
+			$sqlTableName = DB::getPDO()->identifierQuote($tblName);
+			$fixReturn = DB::getPDO()->fetchAll(" repair table {$sqlTableName} ");
+			echo UI::hTable([ 'caption' => "Naprawa tabeli '{$tblName}':", 'rows' => $fixReturn ]);
+			$lastFixRow = end($fixReturn);
+			if ('OK' === V::get('Msg_text', '', $lastFixRow)) {
+				UI::alert('success', "Naprawiono tabelę '{$tblName}'");
+			} else {
+				UI::alert('danger', "Nie udało się naprawić tabeli '{$tblName}'");
+			}
+		}
+
+		$listTables = DB::getPDO()->fetchValuesList("
+			select TABLE_NAME
+			from INFORMATION_SCHEMA.TABLES
+			where TABLE_SCHEMA = :db_name
+				and TABLE_TYPE = 'BASE TABLE'
+		", [
+			':db_name' => DB::getPDO()->getDatabaseName(),
+		]);
+
+		DBG::nicePrint($listTables, "all tables");
+		// $listTables = array_slice($listTables, 0, 10); // TODO: DBG
+		UI::table([
+			'rows' => array_map(function ($tblName) {
+
+				$fixTableBtn = UI::hButtonPost("napraw tabele", [
+					'class' => "btn btn-xs btn-primary",
+					'data' => [
+						'_postTask' => 'checkDatabaseTables',
+						'_fixTable' => $tblName,
+					]
+				]);
+				return [
+					'table' => $tblName,
+					'status' => UI::h('details', [ 'open' => '' ], [
+						UI::h('summary', [], [ 
+							"check table `{$tblName}`",
+							" ",
+							$fixTableBtn,
+						]),
+						UI::hTable([ 'rows' => DB::getPDO()->fetchAll(" check table `{$tblName}` ") ]),
+					]),
+				];
+			}, $listTables)
+		]);
+	}
+
 }

+ 1 - 1
SE/se-lib/Route/Storage.php

@@ -867,7 +867,7 @@ class Route_Storage extends RouteBase {
 	public function addCellToZasobyAction() {// sends JSON
 		$response = new stdClass();
 		try {
-			$idStorage = V::get('storageId', '', $_GET);
+			$idStorage = V::get('idStorage', '', $_GET);
 			$tblName = V::get('tblName', '', $_GET, 'word');
 			$cellName = V::get('cellName', '', $_GET, 'word');
 			if (empty($tblName)) throw new HttpException("Wrong table name");

+ 4 - 2
SE/se-lib/Route/ViewTableAjax.php

@@ -46,11 +46,13 @@ class Route_ViewTableAjax extends RouteBase {
 			$tblLabel = implode(" - ", $tblLabel);
 		}
 		$tbl->setSyncUrl($syncUrl);
-		$tbl->showProcesInitFiltr = $this->getLink("procesInitFiltrAjax", [ 'namespace' => $acl->getNamespace() ]);
+		$tbl->showProcesInitFiltr = (Config::get('VIEW_TABLE_HIDE_PROCESS_LIST')) ? null : $this->getLink("procesInitFiltrAjax", [ 'namespace' => $acl->getNamespace() ]);
 		$tbl->showTableTools = $this->getLink("tableToolsAjax", [ 'namespace' => $acl->getNamespace() ]);
 		$tbl->useUserTableFilter = $this->getLink("getUserTableFilterAjax");
 		$tbl->setLabel($tblLabel);
-		if (method_exists($acl, 'getGuiRowFunctions')) {
+		if (Config::get('VIEW_TABLE_HIDE_BASE_ROW_FUNCTIONS')) {
+			// dont show row functions column
+		} else if (method_exists($acl, 'getGuiRowFunctions')) {
 			foreach ($acl->getGuiRowFunctions() as $funKey => $funParams) {
 				$tbl->addRowFunction($funKey, $funParams);
 			}

+ 8 - 8
SE/se-lib/TableAjax.php

@@ -91,9 +91,9 @@ class TableAjax extends ViewAjax {
 						// DBG::log([ '$this->_filterInit' => $this->_filterInit ], 'array', "TODO:BUG?:filters");
 						$this->_filterInit = $v;
 						break;
-					case '_rowFunctions':
-						$this->_rowFunctions = $v;
-						break;
+					// case '_rowFunctions':
+					// 	$this->_rowFunctions = $v;
+					// 	break;
 					default:
 
 				}
@@ -113,13 +113,13 @@ class TableAjax extends ViewAjax {
 		if (!$key) {
 			$_SESSION['TableAjax_Cache'][$this->_htmlID]['_label'] = $this->_label;
 			$_SESSION['TableAjax_Cache'][$this->_htmlID]['_filterInit'] = $this->_filterInit;
-			$_SESSION['TableAjax_Cache'][$this->_htmlID]['_rowFunctions'] = $this->_rowFunctions;
+			// $_SESSION['TableAjax_Cache'][$this->_htmlID]['_rowFunctions'] = $this->_rowFunctions;
 		} else if ($key == '_label') {
 			$_SESSION['TableAjax_Cache'][$this->_htmlID]['_label'] = $this->_label;
 		} else if ($key == '_filterInit') {
 			$_SESSION['TableAjax_Cache'][$this->_htmlID]['_filterInit'] = $this->_filterInit;
-		} else if ($key == '_rowFunctions') {
-			$_SESSION['TableAjax_Cache'][$this->_htmlID]['_rowFunctions'] = $this->_rowFunctions;
+		// } else if ($key == '_rowFunctions') {
+		// 	$_SESSION['TableAjax_Cache'][$this->_htmlID]['_rowFunctions'] = $this->_rowFunctions;
 		}
 	}
 
@@ -181,7 +181,7 @@ class TableAjax extends ViewAjax {
 				$this->_rowFunctions[$funName] = $params;
 			}
 		}
-		$this->_saveState('_rowFunctions');
+		// $this->_saveState('_rowFunctions');
 	}
 
 	public function addRowFunction($funName, $funParams = array()) {
@@ -203,7 +203,7 @@ class TableAjax extends ViewAjax {
 		else {
 			$this->_rowFunctions[$funName] = $funParams;
 		}
-		$this->_saveState('_rowFunctions');
+		// $this->_saveState('_rowFunctions');
 	}
 
 	private function _parseRowFunctions($idRecord = null, $pomin = array(), $showLabel = false) {