http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88500

Revision: 88500
Author:   jeroendedauw
Date:     2011-05-20 22:39:20 +0000 (Fri, 20 May 2011)
Log Message:
-----------
some work on selective property handling

Modified Paths:
--------------
    trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php
    trunk/extensions/SemanticWatchlist/includes/SWL_Group.php

Modified: trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php
===================================================================
--- trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php       
2011-05-20 22:38:41 UTC (rev 88499)
+++ trunk/extensions/SemanticWatchlist/includes/SWL_ChangeSet.php       
2011-05-20 22:39:20 UTC (rev 88500)
@@ -363,4 +363,19 @@
                return $this->time;
        }
        
+       /**
+        * Remove changes to properties not in the porvided list.
+        * 
+        * @since 0.1
+        * 
+        * @param array $properties List of property names
+        */
+       public function filterOnProperties( array $properties ) {
+               foreach ( $this->getAllProperties() as /* SMWDIProperty */ 
$property ) {
+                       if ( !in_array( $property->getSerialization(), 
$properties ) ) {
+                               $this->changeSet->removeChangesForProperty( 
$property );
+                       }
+               }
+       }
+       
 }
\ No newline at end of file

Modified: trunk/extensions/SemanticWatchlist/includes/SWL_Group.php
===================================================================
--- trunk/extensions/SemanticWatchlist/includes/SWL_Group.php   2011-05-20 
22:38:41 UTC (rev 88499)
+++ trunk/extensions/SemanticWatchlist/includes/SWL_Group.php   2011-05-20 
22:39:20 UTC (rev 88500)
@@ -421,6 +421,19 @@
        }
        
        /**
+        * Removethe non covered properties.
+        * 
+        * @since 0.1
+        * 
+        * @param SWLChangeSet $changes
+        * 
+        * @return SWLChangeSet
+        */
+       public function removeNonCoveredChanges( SWLChangeSet &$changes ) {
+               $changes->filterOnProperties( $this->getProperties() );
+       }
+       
+       /**
         * Gets all the watching users and passes them, together with the 
specified
         * changes and the group object itself, to the SWLGroupNotify hook.
         * 
@@ -431,7 +444,11 @@
        public function notifyWatchingUsers( SWLChangeSet $changes ) {
                $users = $this->getWatchingUsers();
                
-               wfRunHooks( 'SWLGroupNotify', array( $this, $users, $changes ) 
);
+               $this->removeNonCoveredChanges( $changes );
+               
+               if ( $changes->hasChanges( true ) ) {
+                       wfRunHooks( 'SWLGroupNotify', array( $this, $users, 
$changes ) );
+               }
        }
        
 }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to