Jelajahi Sumber

fixed links in Notify

Piotr Labudda 10 tahun lalu
induk
melakukan
b5d2b0e892
4 mengubah file dengan 44 tambahan dan 48 penghapusan
  1. 13 1
      SE/se-lib/Request.php
  2. 15 31
      SE/se-lib/Route/Notify.php
  3. 4 4
      SE/se-lib/User.php
  4. 12 12
      SE/se-lib/UserStorageDB.php

+ 13 - 1
SE/se-lib/Request.php

@@ -48,6 +48,18 @@ class Request {
 		return $uri;
 	}
 
+	// @usage: Request::getUriDirName() . "/index.php?...";
+	public static function getUriDirName() {
+		// [SCRIPT_URI] => http://biuro.biall-net.pl:34543/dev-pl/se-master/wfs-qgis.php/default_db/
+		// [SCRIPT_URL] => /dev-pl/se-master/wfs-qgis.php/default_db/
+		// [SCRIPT_NAME] => /dev-pl/se-master/wfs-qgis.php
+		// [HTTP_HOST] => biuro.biall-net.pl
+		$uri = (Request::isHttps())? 'https://' : 'http://';
+		$uri .= $_SERVER['HTTP_HOST'];
+		$uri .= dirname($_SERVER['SCRIPT_NAME']);
+		return $uri;
+	}
+
 	// @usage: Request::getRewriteTaskPath();
 	public static function getRewriteTaskPath() {
 		$reqUri = $_SERVER['REQUEST_URI'];
@@ -65,4 +77,4 @@ class Request {
 		return $requestBody;
 	}
 
-}
+}

+ 15 - 31
SE/se-lib/Route/Notify.php

@@ -69,13 +69,11 @@ class Route_Notify extends RouteBase {
 		}
 
 		$urlParts = array();// index.php?_route=Notify&_task=generateUserReminders&usrLogin=magdalena.cichosz&reminder[]=msgs
-		$urlParts[] = Request::getPathUri();
-		$urlParts[] = 'index.php?_route=Notify&_task=generateUserReminders';
-		$urlParts[] = "&usrLogin={$usrLogin}";
-		foreach ($notifyTypeList as $reminderType) {
-			$urlParts[] = "&reminder[]={$reminderType}";
-		}
-		$previewLink = implode('', $urlParts);
+		$urlQuery = array('_route' => "Notify"
+										, '_task' => 'generateUserReminders'
+										, 'usrLogin' => $usrLogin
+										, 'reminder' => array_values($notifyTypeList));
+		$previewLink = Request::getUriDirName() . "/index.php?" . http_build_query($urlQuery);
 
 		$lastSentDate = 'brak';// TODO: getLastSendData($usrLogin);
 		$typeSpecialUserLogin = TypespecialVariable::getInstance(-1, '__USER_LOGIN');
@@ -128,17 +126,11 @@ class Route_Notify extends RouteBase {
 </div>
 <script>
 function refreshPreview() {
-//		$urlParts[] = Request::getPathUri();
-//		$urlParts[] = 'index.php?_route=Notify&_task=generateUserReminders';
-//		$urlParts[] = "&usrLogin={$usrLogin}";
-//		foreach ($notifyTypeList as $reminderType) {
-//			$urlParts[] = "&reminder[]={$reminderType}";
-//		}
 	var frm = document.getElementById('reminderPanelForm'),
-			baseUrl = '<?php echo Request::getPathUri(); ?>',
+			baseUrl = '<?php echo Request::getUriDirName(); ?>',
 			previewLink = '';
 
-	previewLink = baseUrl + 'index.php?_route=Notify&_task=generateUserReminders';
+	previewLink = baseUrl + '/index.php?_route=Notify&_task=generateUserReminders';
 	previewLink += '&usrLogin=' + frm['usrLogin'].value;
 	for (var i in frm['reminder[]']) {
 		console.log('frm[reminder[]]['+i+']', frm['reminder[]'][i].value, ' checked:', frm['reminder[]'][i].checked);
@@ -389,14 +381,9 @@ function refreshPreview() {
 		}
 		if (!$idTblZasob || !$idRecord) return '#';
 
-		$urlParts = array();
-		$urlParts[] = (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']))? $_SERVER['HTTP_X_FORWARDED_PROTO'] : V::get('REQUEST_SCHEME', 'http', $_SERVER);
-		$urlParts[] = '://';
-		$urlParts[] = $_SERVER['SERVER_NAME'];
-		$urlParts[] = $_SERVER['SCRIPT_URL'];
-		// https://biuro.biall-net.pl/dev-pl/se-master/index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=1466#EDIT/3954
-		$urlParts[] = "?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID={$idTblZasob}#EDIT/{$idRecord}";
-		return implode("", $urlParts);
+		$urlQuery = array('MENU_INIT' => "VIEWTABLE_AJAX"
+										, 'ZASOB_ID' => $idTblZasob);
+		return Request::getUriDirName() . "/index.php?" . http_build_query($urlQuery) . "#EDIT/{$idRecord}";
 	}
 
 	public function readMsgLink($usrLogin, $todo) {
@@ -407,14 +394,11 @@ function refreshPreview() {
 		if (!$idMsg) return '#' . json_encode($todo);
 		if (!$idMsg) return '#';
 
-		$urlParts = array();
-		$urlParts[] = Request::getPathUri();
-		$urlParts[] = 'index.php';
-		$urlParts[] = "?_route=UserMsgs";
-		$urlParts[] = "&_task=read";
-		$urlParts[] = "&usrLogin={$usrLogin}";
-		$urlParts[] = "&id={$idMsg}";
-		return implode("", $urlParts);
+		$urlQuery = array('_route' => "UserMsgs"
+											, '_task' => 'read'
+											, 'usrLogin' => $usrLogin
+											, 'id' => $idMsg);
+		return Request::getUriDirName() . "/index.php?" . http_build_query($urlQuery);
 	}
 
 	public function inlineCss($cssSelector) {

+ 4 - 4
SE/se-lib/User.php

@@ -88,7 +88,7 @@ class User {
 		if (!$_groups) {
 			$user_id = User::getID();
 			Lib::loadClass('UsersHelper');
-			$_groups = UsersHelper::get_group_by_user($user_id);
+			$_groups = UsersHelper::getGroupByUser($user_id);
 		}
 		return $_groups;
 	}
@@ -340,7 +340,7 @@ class User {
 				break;
 
 			default:
-				
+
 		}
 
 		if (!User::logged()) {
@@ -642,7 +642,7 @@ class User {
 	 * Check user access.
 	 * @param string $name
 	 *   'menu' - access to view menu
-	 * 
+	 *
 	 * @from [4101] ADM_ADMIN_LEVEL
 	 *   Poziom uprawnień - każdy powinien mieć poziom o numerze 3
 	 *   kierownicy powinni mieć 2
@@ -700,7 +700,7 @@ class User {
 				break;
 			}
 			default:
-				
+
 		}
 		return false;
 	}

+ 12 - 12
SE/se-lib/UserStorageDB.php

@@ -85,7 +85,7 @@ class UserStorageDB extends UserStorageBase {
 
 	/**
 	 * Build group realName from zasob.
-	 * 
+	 *
 	 * @param object $zasob {ID, DESC, TYPE}
 	 * @return string realName
 	 */
@@ -98,7 +98,7 @@ class UserStorageDB extends UserStorageBase {
 
 	/**
 	 * Group.
-	 * 
+	 *
 	 * @return object $group
 	 *   $group->primaryKey
 	 *   $group->realName
@@ -350,7 +350,7 @@ class UserStorageDB extends UserStorageBase {
 		return false;
 	}
 
-	private function _getUserGroupsAll($usrLogin) {
+	public function _getUserGroupsAll($usrLogin) {
 		$groups = array();
 
 		$sql_select = array();
@@ -383,7 +383,7 @@ class UserStorageDB extends UserStorageBase {
 		$groupsBelow = array();
 		$sqlGroupIds = array_keys($groups);
 		$sql = "
-			
+
 		";
 
 		return $groupsBelow;
@@ -394,7 +394,7 @@ class UserStorageDB extends UserStorageBase {
 		$groupsAbove = array();
 		$sqlGroupIds = array_keys($groups);
 		$sql = "
-			
+
 		";
 
 		return $groupsAbove;
@@ -402,10 +402,10 @@ class UserStorageDB extends UserStorageBase {
 
 	/**
 	 * Build network group object.
-	 * 
+	 *
 	 * @param object $groupDB {ID, DESC, TYPE} @see _getUserGroupsAll
 	 * @return object $group @see getGroup
-	 * 
+	 *
 	 * Example: _buildGroupFromRow($r) => {@see group}
 	 */
 	private function _buildGroupFromRow($groupDB, $fetchNested = false) {
@@ -421,9 +421,9 @@ class UserStorageDB extends UserStorageBase {
 
 	/**
 	 * User group list by id.
-	 * 
+	 *
 	 * @param bool $fetchNested - contain all groups below connected groups and group PODMIOT from above.
-	 * 
+	 *
 	 * @return array with group objects @see getGroup
 	 */
 	public function getUserGroups($usrLogin, $fetchNested = false) {
@@ -477,7 +477,7 @@ class UserStorageDB extends UserStorageBase {
 
 	/**
 	 * Add group member.
-	 * 
+	 *
 	 * @param string $usrLogin - user login
 	 * @param object $group - @see getGroup
 	 * @param optional int $telboxID
@@ -519,7 +519,7 @@ class UserStorageDB extends UserStorageBase {
 	/**
 	 * Get user and group info by profile ID (CRM_AUTH_PROFILE.ID)
 	 * Only in UserStorageDB
-	 * 
+	 *
 	 * @return profile {}
 	 *   ID
 	 *   usrId
@@ -567,7 +567,7 @@ class UserStorageDB extends UserStorageBase {
 	/**
 	 * Get user and group info by profile ID (CRM_AUTH_PROFILE.ID)
 	 * Only in UserStorageDB
-	 * 
+	 *
 	 * @return array of profile {}
 	 *   ID
 	 *   usrId