[icinga-checkins] icinga.org: icinga-web/mhein/extlayout: * Minor compatibility fixes

git at icinga.org git at icinga.org
Tue May 18 12:02:51 CEST 2010


Module: icinga-web
Branch: mhein/extlayout
Commit: f14672e73ab3e911d43011096c4da46243c41dfc
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=f14672e73ab3e911d43011096c4da46243c41dfc

Author: jmosshammer <jannis.mosshammer at netways.de>
Date:   Tue May 18 10:04:39 2010 +0200

* Minor compatibility fixes

---

 app/config/databases.xml.in                        |    5 ++++-
 lib/appkit/auth/AppKitAuthDispatcher.class.php     |    2 +-
 lib/appkit/auth/AppKitSecurityUser.class.php       |    3 +--
 lib/appkit/database/models/NsmUser.php             |   17 +++++++++++++++--
 lib/appkit/html/AppKitHtmlHelper.class.php         |    8 +++++++-
 .../storage/AppKitDoctrineSessionStorage.class.php |    4 ++--
 6 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/app/config/databases.xml.in b/app/config/databases.xml.in
index cae56f8..7a2f5e9 100755
--- a/app/config/databases.xml.in
+++ b/app/config/databases.xml.in
@@ -3,7 +3,10 @@
 	
 	<ae:configuration>
 		<databases default="icinga_web">
-			
+			<!-- Make icinga web doctrine default -->
+			<database name="default" class="AgaviDoctrineDatabase">
+				<xi:include xpointer="xmlns(ae=http://agavi.org/agavi/config/global/envelope/1.0) xmlns(db=http://agavi.org/agavi/config/parts/databases/1.0) xpointer(//ae:configurations/ae:configuration/db:databases/db:database[@name='icinga_web']/*)" />
+			</database>
 			<database name="icinga_web" class="AgaviDoctrineDatabase">
 
 				<!--
diff --git a/lib/appkit/auth/AppKitAuthDispatcher.class.php b/lib/appkit/auth/AppKitAuthDispatcher.class.php
index f208710..8e45727 100644
--- a/lib/appkit/auth/AppKitAuthDispatcher.class.php
+++ b/lib/appkit/auth/AppKitAuthDispatcher.class.php
@@ -90,7 +90,7 @@ class AppKitAuthDispatcher extends AppKitFactory implements AppKitEventHandlerIn
 		// Try to load from DB
 		$res = Doctrine_Query::create()
 		->from('NsmUser')
-		->andWhere('user_disabled=? and user_name=?', array(false, $username))
+		->andWhere('user_disabled=? and user_name=?', array(0, $username))
 		->execute();
 		
 		if ($res->count() == 1 && ($user = $res->getFirst()) instanceof NsmUser) {
diff --git a/lib/appkit/auth/AppKitSecurityUser.class.php b/lib/appkit/auth/AppKitSecurityUser.class.php
index e1b339d..8bdaccd 100644
--- a/lib/appkit/auth/AppKitSecurityUser.class.php
+++ b/lib/appkit/auth/AppKitSecurityUser.class.php
@@ -16,7 +16,7 @@ class AppKitSecurityUser extends AgaviRbacSecurityUser {
 	 * @author Marius Hein
 	 */
 	public function doLogin($username, $password, $isHashedPassword=false) {
-		
+
 		// Okay, try to get our provider
 		$provider = AppKitFactories::getInstance()->getFactory('AuthDispatcher');
 		
@@ -40,7 +40,6 @@ class AppKitSecurityUser extends AgaviRbacSecurityUser {
 				
 				// Grant related roles
 				$this->applyDoctrineUserRoles($user);
-
 				// Give notice
 				$this->getContext()->getLoggerManager()
 				->log(sprintf('User %s (%s) logged in!', $username, $user->givenName()), AgaviLogger::INFO);
diff --git a/lib/appkit/database/models/NsmUser.php b/lib/appkit/database/models/NsmUser.php
index 9f0d3e7..d48463a 100755
--- a/lib/appkit/database/models/NsmUser.php
+++ b/lib/appkit/database/models/NsmUser.php
@@ -183,10 +183,23 @@ class NsmUser extends BaseNsmUser
 	 * @author Marius Hein
 	 */
 	public function delPref($key) {
+		/*
+		 * WORKAROUND: 
+		 * Postgresql doesn't support limit, so we must first select a row, then delete it
+		 */
+		$idToDelete = Doctrine_Query::create()
+			->select("upref_id")
+			->from("NsmUserPreference p")
+			->where('p.upref_user_id=? and p.upref_key=?', array($this->user_id, $key))
+			->execute()->getFirst();
+		if(is_null($idToDelete))
+			return false;
+			
+		$upref_id = $idToDelete->get('upref_id');
 		$test = Doctrine_Query::create()
 		->delete('NsmUserPreference p')
-		->where('p.upref_user_id=? and p.upref_key=?', array($this->user_id, $key))
-		->limit(1)
+		->where('p.upref_id=? and p.upref_user_id=? and p.upref_key=?', array($upref_id,$this->user_id, $key))
+		//->limit(1)  -> not supported by postgresql
 		->execute();
 		
 		if ($test) return true;
diff --git a/lib/appkit/html/AppKitHtmlHelper.class.php b/lib/appkit/html/AppKitHtmlHelper.class.php
index 928f5f1..dc6f738 100755
--- a/lib/appkit/html/AppKitHtmlHelper.class.php
+++ b/lib/appkit/html/AppKitHtmlHelper.class.php
@@ -9,7 +9,13 @@ class AppKitHtmlHelper extends AppKitSingleton implements AppKitHtmlEntitiesInte
 	public static function getInstance() {
 		return parent::getInstance('AppKitHtmlHelper');
 	}
-	
+	public static function pageFinished() {
+		echo "<script type='text/javascript'>
+				Ext.onReady(function() {
+					AppKit.util.Layout.doLayout()
+				})
+			</script>";
+	}
 	/**
 	 * Constructor method (short form) for
 	 * @return AppKitHtmlHelper
diff --git a/lib/appkit/storage/AppKitDoctrineSessionStorage.class.php b/lib/appkit/storage/AppKitDoctrineSessionStorage.class.php
index 2eaed71..9b5cc55 100755
--- a/lib/appkit/storage/AppKitDoctrineSessionStorage.class.php
+++ b/lib/appkit/storage/AppKitDoctrineSessionStorage.class.php
@@ -42,9 +42,9 @@ class AppKitDoctrineSessionStorage extends AgaviSessionStorage {
 	}
 	
 	public function sessionGC($lifetime) {
-	
+		$maxlifetime = time()-$lifetime;
 		$result = Doctrine_Query::create()
-		->andWhere('TIME_TO_SEC(TIMEDIFF(now(), session_created)) > ?', array($lifetime))
+		->andWhere('session_created < ?', array(date("c",$maxlifetime)))
 		->delete('NsmSession')
 		->execute();
 		





More information about the icinga-checkins mailing list