Просмотр исходного кода

added reinstall to RouteBase for UrlAction

Piotr Labudda 9 лет назад
Родитель
Сommit
3d23de8779
1 измененных файлов с 63 добавлено и 1 удалено
  1. 63 1
      SE/se-lib/RouteBase.php

+ 63 - 1
SE/se-lib/RouteBase.php

@@ -75,7 +75,69 @@ class RouteBase {
 		User::authByRequest();
 	}
 
-	public function reinstall() {// migrate
+	public function reinstall() {
+		$clsName = get_class($this);
+		if ('Route_UrlAction' == substr($clsName, 0, strlen('Route_UrlAction'))) {
+			$actionName = substr($clsName, strlen('Route_UrlAction_'));
+			DBG::log(['msg'=>"\$actionName", '$actionName'=>$actionName]);
+			$idTypespecial = DB::getPDO()->fetchValue("
+				select z.ID
+				from CRM_LISTA_ZASOBOW z
+				where z.`TYPE` = 'TYPESPECIALS'
+			");
+			if (!$idTypespecial) {
+				$idTypespecial = DB::getPDO()->insert('CRM_LISTA_ZASOBOW', [
+					'TYPE' => 'TYPESPECIALS',
+					'DESC' => 'TYPESPECIALS',
+					'DESC_PL' => 'Powiązania tabel',
+					'OPIS' => 'Powiązania i relacje tabel do wyświetlania w funkcjach systemowych',
+				]);
+			}
+			DBG::log(['msg'=>"\$idTypespecial", '$idTypespecial'=>$idTypespecial]);
+			if (!$idTypespecial) throw new Exception("Wystąpił błąd podczas tworzenia zasobu 'Powiązania tabel' (TYPESPECIALS)");
+
+			$idAction = DB::getPDO()->fetchValue("
+				select z.ID
+				from CRM_LISTA_ZASOBOW z
+				where z.`PARENT_ID` = {$idTypespecial}
+					and z.`DESC` = '{$actionName}'
+			");
+			if (!$idAction) {
+				$idAction = DB::getPDO()->insert('CRM_LISTA_ZASOBOW', [
+					'PARENT_ID' => $idTypespecial,
+					'TYPE' => 'URL_ACTION',
+					'DESC' => $actionName,
+					'DESC_PL' => $this->getActionLabel(),
+					'OPIS' => $this->getActionDescription(),
+				]);
+			}
+			DBG::log(['msg'=>"\$idAction", '$idAction'=>$idAction]);
+			if (!$idAction) throw new Exception("Wystąpił błąd podczas tworzenia zasobu funkcji '{$actionName}' (URL_ACTION)");
+
+			$args = $this->getActionArgs();
+			foreach ($args as $argName => $argDesc) {
+				$idArg = DB::getPDO()->fetchValue("
+					select z.ID
+					from CRM_LISTA_ZASOBOW z
+					where z.`PARENT_ID` = {$idAction}
+						and z.`TYPE` = 'PARAM_IN'
+						and z.`DESC` = '{$argName}'
+				");
+				if (!$idArg) {
+					$idArg = DB::getPDO()->insert('CRM_LISTA_ZASOBOW', [
+						'PARENT_ID' => $idAction,
+						'TYPE' => 'PARAM_IN',
+						'DESC' => $argName,
+						'OPIS' => $argDesc,
+					]);
+				}
+				DBG::log(['msg'=>"\$idArg ('{$argName}')", '$idArg'=>$idArg]);
+				if (!$idArg) throw new Exception("Wystąpił błąd podczas tworzenia zasobu dla argumentu funkcji '{$actionName}' '{$argName}' (PARAM_IN)");
+			}
+		}
 	}
+	public function getActionLabel() { return ""; }
+	public function getActionDescription() { return ""; }
+	public function getActionArgs() { return []; }
 
 }