[icinga-checkins] icinga.org: icinga-web/jmosshammer/default2: * PHP 5.2 compatibility fix, fixed wrong reference in NsmRole

git at icinga.org git at icinga.org
Fri May 28 15:43:44 CEST 2010


Module: icinga-web
Branch: jmosshammer/default2
Commit: de248ff3a29399fbaf2359fb03b5b6a0faf39e44
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=de248ff3a29399fbaf2359fb03b5b6a0faf39e44

Author: jmosshammer <jannis.mosshammer at netways.de>
Date:   Fri May 28 15:43:08 2010 +0200

* PHP 5.2 compatibility fix, fixed wrong reference in NsmRole

---

 app/modules/AppKit/lib/database/models/NsmRole.php |    8 ++++----
 app/modules/AppKit/lib/database/models/NsmUser.php |   15 +++++++--------
 .../lib/database/models/NsmUserPreference.php      |    2 +-
 .../lib/database/models/generated/BaseNsmRole.php  |    6 +++---
 etc/lib/dbInitializeTask.php                       |    4 ++--
 5 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/app/modules/AppKit/lib/database/models/NsmRole.php b/app/modules/AppKit/lib/database/models/NsmRole.php
index f149da0..09147b3 100755
--- a/app/modules/AppKit/lib/database/models/NsmRole.php
+++ b/app/modules/AppKit/lib/database/models/NsmRole.php
@@ -27,15 +27,15 @@ class NsmRole extends BaseNsmRole
 	}
 
 	public function hasParent() {
-
-		if($this->get('role_parent'))
+		if($this->get('role_parent')) 
 			return true;
 		return false;
 	}
 	
 	public function getParent() {
-		if($this->hasParent())
-			return $this->NsmRole;
+		if($this->hasParent()) {
+			return $this->parent;
+		}
 		return null;
 	}
 	
diff --git a/app/modules/AppKit/lib/database/models/NsmUser.php b/app/modules/AppKit/lib/database/models/NsmUser.php
index 69605f7..ebf8c16 100755
--- a/app/modules/AppKit/lib/database/models/NsmUser.php
+++ b/app/modules/AppKit/lib/database/models/NsmUser.php
@@ -30,19 +30,17 @@ class NsmUser extends BaseNsmUser
 		
 		$this->index('user_unique', array (
 			'fields' => array (
-				'user_name' => array (
-					'sorting' => 'ASC'
-				)
+				'user_name'
 			),
 			'type' => 'unique'
 		));
 		
 		$this->index('user_search', array (
 			'fields' => array (
-				'user_name' => array ('sorting' => 'ASC'),
-				'user_authsrc' => array ('sorting' => 'ASC'),
-				'user_authid' => array ('sorting' => 'ASC'),
-				'user_disabled' => array ('sorting' => 'ASC')
+				'user_name',
+				'user_authsrc',
+				'user_authid',
+				'user_disabled'
 			)
 		));
 	}
@@ -324,6 +322,7 @@ class NsmUser extends BaseNsmUser
 	 * @return Doctrine_Collection
 	 */
 	public function getTargets($type=null) {
+
 		return $this->getTargetsQuery($type)->execute();
 	}
 	
@@ -343,7 +342,7 @@ class NsmUser extends BaseNsmUser
 		if ($type !== null) {
 			$q->andWhere('t.target_type=?', array($type));
 		}
-		
+
 		return $q;
 	}
 
diff --git a/app/modules/AppKit/lib/database/models/NsmUserPreference.php b/app/modules/AppKit/lib/database/models/NsmUserPreference.php
index 2f9c081..c82b36b 100755
--- a/app/modules/AppKit/lib/database/models/NsmUserPreference.php
+++ b/app/modules/AppKit/lib/database/models/NsmUserPreference.php
@@ -25,7 +25,7 @@ class NsmUserPreference extends BaseNsmUserPreference
 		
 		$this->index('upref_search_key', array (
 			'fields' => array (
-				'upref_key' => array ('sorting' => 'ASC')
+				'upref_key'
 			)
 		));
 		
diff --git a/app/modules/AppKit/lib/database/models/generated/BaseNsmRole.php b/app/modules/AppKit/lib/database/models/generated/BaseNsmRole.php
index a60b63d..b540304 100755
--- a/app/modules/AppKit/lib/database/models/generated/BaseNsmRole.php
+++ b/app/modules/AppKit/lib/database/models/generated/BaseNsmRole.php
@@ -92,9 +92,9 @@ abstract class BaseNsmRole extends Doctrine_Record
     public function setUp()
     {
         parent::setUp();
-        $this->hasOne('NsmRole', array(
-             'local' => 'role_id',
-             'foreign' => 'role_parent'));
+        $this->hasOne('NsmRole as parent', array(
+             'local' => 'role_parent',
+             'foreign' => 'role_id'));
 
         $this->hasOne('NsmPrincipal', array(
              'local' => 'role_id',
diff --git a/etc/lib/dbInitializeTask.php b/etc/lib/dbInitializeTask.php
index 14d40e3..f1378c9 100644
--- a/etc/lib/dbInitializeTask.php
+++ b/etc/lib/dbInitializeTask.php
@@ -52,8 +52,8 @@ class dbInitializeTask extends doctrineTask {
 				$refCl = new ReflectionClass($model);
 				if(!$refCl->hasMethod("getInitialData")) 
 					continue;
-					
-				foreach($model::getInitialData() as $initData) {
+				$cl = new $model();
+				foreach($cl->getInitialData() as $initData) {
 					$initData["_model_"] = $model;
 					if(in_array(serialize($initData),$this->insertedData)) {
 						continue;





More information about the icinga-checkins mailing list