------------------------------------------------------------
revno: 1151
committer: Roger Martin <[email protected]>
branch nick: aikiframework
timestamp: Wed 2012-03-28 17:22:43 +0200
message:
  correct view and permission parser of engine2
modified:
  libs/Engine_v2.php


--
lp:aikiframework
https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk

Your team Aiki Framework Developers is subscribed to branch lp:aikiframework.
To unsubscribe from this branch go to 
https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk/+edit-subscription
=== modified file 'libs/Engine_v2.php'
--- libs/Engine_v2.php	2012-03-25 20:58:04 +0000
+++ libs/Engine_v2.php	2012-03-28 15:22:43 +0000
@@ -85,7 +85,8 @@
 		$this->parsers = array (
 		    ""            => "parse_vars",
 		    "widget"      => "parse_widget",
-			"permissions" => "parse_permissions",
+		    "template"    => "parse_template",
+			"permission"  => "parse_permission",
 			"view"        => "parse_view",
 			"noaiki"      => "parse_noaiki",
 			"sql"         => "parse_sql",
@@ -233,9 +234,9 @@
 	/*
 	 * Parse template
 	 */
-	function parse_template($matches){
+	function parse_template($arg, $true, $false){
 		global $aiki;
-		$widget= $aiki->widgets->get_widget($matches[0]);
+		$widget= $aiki->widgets->get_widget($arg[0]);
 		return  ( is_null($widget) ? "": $wiget->widget );
 	}
 
@@ -514,47 +515,35 @@
 	}
 
 
-	function parse_view( $para, $true, $false){
-		global $aiki;
-
-		if ( !isset($para[0])){
-			return $false;
-        }
-
-		list($view,$language)= exlode("/",$para[0]."/*",2);
-
-		if  ( match_pair_one( $view, $aiki->site->view()) &&
-		      match_pair_one( $language, $aiki->site->language() )){
-			return $true;
-		}
-		return $false;
-
-	}
-
-
-	function parse_permission($para, $true, $false){
-		global $aiki, $db;
-
-		if ( !isset($para[0])) {
-			return $true;
-		}
-
-		$filter= $para[0];
-
-		// @TODO call a membership method
-		$sql = "SELECT group_level" .
-			   " FROM  aiki_users_groups".
-			   " WHERE group_permissions='". addslashes($filter) ."'";
-
-		$get_group_level = $db->get_var($sql);
-
-		if ( trim($filter) == $aiki->membership->permissions ||
-			$aiki->membership->group_level < $get_group_level ) {
-			return $true;
-		}
-
-		return $false;
-	}
+	function parse_view( $selectors, $trueBlock, $falseBlock){
+		global $aiki;
+
+		if ( count($selectors)){
+			foreach ( $selectors as $selector){
+				list($view,$language)= explode("/",$selector."/*/*",3);
+			
+				if  ( $aiki->match_pair_one( $view, $aiki->site->view()) &&
+					  $aiki->match_pair_one( $language, $aiki->site->language() )){
+					return $trueBlock;
+				}
+			}
+		}	
+		return $falseBlock;
+	}
+
+
+	function parse_permission($permissions, $trueBlock, $falseBlock){
+		global $aiki;
+
+		if ( count($permissions) ) {
+			foreach ($permissions as $permission ){
+				if ( $aiki->membership->have_permission($permission)){
+					return $trueBlock;
+				}				
+			}
+		}
+		return $falseBlock;
+	}	
 
 
     /*

_______________________________________________
Mailing list: https://launchpad.net/~aikiframework-devel
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~aikiframework-devel
More help   : https://help.launchpad.net/ListHelp

Reply via email to