]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/ModLog/ModLogPlugin.php
Merged
[quix0rs-gnu-social.git] / plugins / ModLog / ModLogPlugin.php
index 459df63e8213eeac24b87f6b370d7450ad7c365a..aa275fd82abeab8abc570363d58f7492078e17eb 100644 (file)
@@ -71,29 +71,7 @@ class ModLogPlugin extends Plugin
         return true;
     }
 
-    /**
-     * Load related modules when needed
-     *
-     * @param string $cls Name of the class to be loaded
-     *
-     * @return boolean hook value; true means continue processing, false means stop.
-     */
-
-    function onAutoload($cls)
-    {
-        $dir = dirname(__FILE__);
-
-        switch ($cls)
-        {
-        case 'ModLog':
-            include_once $dir . '/'.$cls.'.php';
-            return false;
-        default:
-            return true;
-        }
-    }
-
-    function onEndGrantRole($profile, $role)
+    function onEndGrantRole(Profile $profile, $role)
     {
         $modlog = new ModLog();
 
@@ -101,7 +79,7 @@ class ModLogPlugin extends Plugin
         $modlog->profile_id = $profile->id;
 
         $cur = common_current_user();
-        
+
         if (!empty($cur)) {
             $modlog->moderator_id = $cur->id;
         }
@@ -115,7 +93,7 @@ class ModLogPlugin extends Plugin
         return true;
     }
 
-    function onEndRevokeRole($profile, $role)
+    function onEndRevokeRole(Profile $profile, $role)
     {
         $modlog = new ModLog();
 
@@ -123,10 +101,10 @@ class ModLogPlugin extends Plugin
 
         $modlog->profile_id = $profile->id;
 
-        $cur = common_current_user();
-        
-        if (!empty($cur)) {
-            $modlog->moderator_id = $cur->id;
+        $scoped = Profile::current();
+
+        if ($scoped instanceof Profile) {
+            $modlog->moderator_id = $scoped->getID();
         }
 
         $modlog->role     = $role;
@@ -138,23 +116,24 @@ class ModLogPlugin extends Plugin
         return true;
     }
 
-    function onEndShowSections($action)
+    function onEndShowSections(Action $action)
     {
-        if ($action->arg('action') != 'showstream') {
+        if (!$action instanceof ShowstreamAction) {
+            // early return for actions we're not interested in
             return true;
         }
 
-        $cur = common_current_user();
-
-        if (empty($cur) || !$cur->hasRight(self::VIEWMODLOG)) {
+        $scoped = $action->getScoped();
+        if (!$scoped instanceof Profile || !$scoped->hasRight(self::VIEWMODLOG)) {
+            // only continue if we are allowed to VIEWMODLOG
             return true;
         }
 
-        $profile = $action->profile;
+        $profile = $action->getTarget();
 
         $ml = new ModLog();
 
-        $ml->profile_id = $profile->id;
+        $ml->profile_id = $profile->getID();
         $ml->orderBy("created");
 
         $cnt = $ml->find();
@@ -174,13 +153,13 @@ class ModLogPlugin extends Plugin
                 $action->element('td', null, sprintf(($ml->is_grant) ? _('+%s') : _('-%s'), $ml->role));
                 $action->elementStart('td');
                 if ($ml->moderator_id) {
-                    $mod = Profile::staticGet('id', $ml->moderator_id);
+                    $mod = Profile::getByID($ml->moderator_id);
                     if (empty($mod)) {
                         $action->text(_('[unknown]'));
                     } else {
-                        $action->element('a', array('href' => $mod->profileurl,
-                                                    'title' => $mod->fullname),
-                                         $mod->nickname);
+                        $action->element('a', array('href' => $mod->getUrl(),
+                                                    'title' => $mod->getFullname()),
+                                         $mod->getNickname());
                     }
                 } else {
                     $action->text(_('[unknown]'));
@@ -195,7 +174,7 @@ class ModLogPlugin extends Plugin
         }
     }
 
-    function onUserRightsCheck($profile, $right, &$result) {
+    function onUserRightsCheck(Profile $profile, $right, &$result) {
         switch ($right) {
         case self::VIEWMODLOG:
             $result = ($profile->hasRole(Profile_role::MODERATOR) || $profile->hasRole('modhelper'));
@@ -205,10 +184,10 @@ class ModLogPlugin extends Plugin
         }
     }
 
-    function onPluginVersion(&$versions)
+    function onPluginVersion(array &$versions)
     {
         $versions[] = array('name' => 'ModLog',
-                            'version' => STATUSNET_VERSION,
+                            'version' => GNUSOCIAL_VERSION,
                             'author' => 'Evan Prodromou',
                             'homepage' => 'http://status.net/wiki/Plugin:ModLog',
                             'description' =>