Explorar o código

The "Preferences" pages now allows a user to:
- change her/his favorite language
- set a global default for the length of all lists, overriding the system-wide configuration.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2138 a333f486-631f-4898-b8df-5754b55c2be0

dflaven %!s(int64=13) %!d(string=hai) anos
pai
achega
a79b2ab333

+ 3 - 7
application/cmdbabstract.class.inc.php

@@ -761,7 +761,7 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
 		
 		if ($bDisplayLimit)
 		{
-			$iDefaultPageSize = MetaModel::GetConfig()->GetMinDisplayLimit(); //TODO use user's prefs instead if any
+			$iDefaultPageSize = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit());
 			$oSettings->iDefaultPageSize = $iDefaultPageSize;
 		}
 		
@@ -848,9 +848,7 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
 					// Removed from the display list
 					unset($aList[$sAlias][$index]);
 				}
-			}
-		$iDefaultPageSize =  MetaModel::GetConfig()->GetMinDisplayLimit();
-			
+			}						
 		}
 		// Load only the requested columns
 		$aAttToLoad = array(); // attributes to load
@@ -863,8 +861,6 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
 		}
 		$oSet->OptimizeColumnLoad($aAttToLoad);
 
-		$iDefaultPageSize =  MetaModel::GetConfig()->GetMinDisplayLimit();
-		$iPageSize = MetaModel::GetConfig()->GetMinDisplayLimit();
 		$sSelectMode = 'none';
 				
 		$sClassAlias = $oSet->GetClassAlias();
@@ -875,7 +871,7 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
 		$bDisplayLimit = isset($aExtraParams['display_limit']) ? $aExtraParams['display_limit'] : true;
 		if ($bDisplayLimit)
 		{
-			$iDefaultPageSize = MetaModel::GetConfig()->GetMinDisplayLimit(); //TODO use user's prefs instead if any
+			$iDefaultPageSize = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit());
 			$oSettings->iDefaultPageSize = $iDefaultPageSize;
 		}
 		

+ 2 - 3
application/datatable.class.inc.php

@@ -102,7 +102,7 @@ class DataTable
 		$sHtml .= "<tr><td>$sPager</td><td class=\"menucontainer\">$sToolkitMenu</td></tr>\n";
 		$sHtml .= "<tr><td class=\"datacontents\" colspan=\"2\">$sDataTable</td></tr>\n";
 		$sHtml .= "</table>\n";
-		$sHtml .= $sConfigDlg;
+		$oPage->add_at_the_end($sConfigDlg);
 		
 		$aOptions = array(
 			'sPersistentId' => '',
@@ -618,8 +618,7 @@ class DataTableSettings implements Serializable
 				if ($aFieldData) $aColumns[$sAlias][$sAttCode] = $aFieldData;
 			}
 		}
-		// TODO retrieve the user default page size or the system wide setting
-		$iDefaultPageSize = MetaModel::GetConfig()->GetMinDisplayLimit();
+		$iDefaultPageSize = appUserPreferences::GetPref('default_page_size', MetaModel::GetConfig()->GetMinDisplayLimit());
 		$oSettings->Init($iDefaultPageSize, $aSortOrder, $aColumns);
 		return $oSettings;
 	}

+ 3 - 1
application/itopwebpage.class.inc.php

@@ -647,6 +647,8 @@ EOF
 
 		if ($this->GetOutputFormat() == 'html')
 		{
+			$oAppContext = new ApplicationContext();
+			
 			$sUserName = UserRights::GetUser();
 			$sIsAdmin = UserRights::IsAdministrator() ? '(Administrator)' : '';
 			if (UserRights::IsAdministrator())
@@ -659,7 +661,7 @@ EOF
 			}
 			$sLogOffMenu = "<span id=\"logOffBtn\"><ul><li><img src=\"../images/onOffBtn.png\"><ul>";
 			$sLogOffMenu .= "<li><span>$sLogonMessage</span></li>\n";
-			$sLogOffMenu .= "<li><a href=\"".utils::GetAbsoluteUrlAppRoot()."pages/preferences.php\">".Dict::S('UI:Preferences')."</a></li>\n";
+			$sLogOffMenu .= "<li><a href=\"".utils::GetAbsoluteUrlAppRoot()."pages/preferences.php?".$oAppContext->GetForLink()."\">".Dict::S('UI:Preferences')."</a></li>\n";
 				
 			if (utils::CanLogOff())
 			{