]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/UserFlag/UserFlagPlugin.php
Merge branch 'master' of gitorious.org:statusnet/mainline into testing
[quix0rs-gnu-social.git] / plugins / UserFlag / UserFlagPlugin.php
index 602a5bfa881d20c6739b71269a09fcc6b87f2803..ae3dfe0365155983e6518046afd1def6bb1ec51d 100644 (file)
@@ -102,20 +102,20 @@ class UserFlagPlugin extends Plugin
 
     function onAutoload($cls)
     {
-        switch ($cls)
+        switch (strtolower($cls))
         {
-        case 'FlagprofileAction':
-        case 'AdminprofileflagAction':
-        case 'ClearflagAction':
+        case 'flagprofileaction':
+        case 'adminprofileflagaction':
+        case 'clearflagaction':
             include_once INSTALLDIR.'/plugins/UserFlag/' .
               strtolower(mb_substr($cls, 0, -6)) . '.php';
             return false;
-        case 'FlagProfileForm':
-        case 'ClearFlagForm':
+        case 'flagprofileform':
+        case 'clearflagform':
             include_once INSTALLDIR.'/plugins/UserFlag/' . strtolower($cls . '.php');
             return false;
-        case 'User_flag_profile':
-            include_once INSTALLDIR.'/plugins/UserFlag/'.$cls.'.php';
+        case 'user_flag_profile':
+            include_once INSTALLDIR.'/plugins/UserFlag/'.ucfirst(strtolower($cls)).'.php';
             return false;
         default:
             return true;
@@ -182,21 +182,6 @@ class UserFlagPlugin extends Plugin
         return true;
     }
 
-    /**
-     * Add our plugin's CSS to page output
-     *
-     * @param Action $action action being shown
-     *
-     * @return boolean hook result
-     */
-
-    function onEndShowStatusNetStyles($action)
-    {
-        $action->cssLink(common_path('plugins/UserFlag/userflag.css'),
-                         null, 'screen, projection, tv');
-        return true;
-    }
-
     /**
      * Initialize any flagging buttons on the page
      *
@@ -208,8 +193,8 @@ class UserFlagPlugin extends Plugin
     function onEndShowScripts($action)
     {
         $action->inlineScript('if ($(".form_entity_flag").length > 0) { '.
-                              'SN.U.FormXHR($(".form_entity_flag")); '.
-                              '}');
+                              '$(".form_entity_flag").bind("click", function() {'.
+                              'SN.U.FormXHR($(this)); return false; }); }');
         return true;
     }
 
@@ -258,4 +243,39 @@ class UserFlagPlugin extends Plugin
         }
         return true;
     }
+
+    /**
+     * Ensure that flag entries for a profile are deleted
+     * along with the profile when deleting users.
+     * This prevents breakage of the admin profile flag UI.
+     *
+     * @param Profile $profile
+     * @param array &$related list of related tables; entries
+     *              with matching profile_id will be deleted.
+     *
+     * @return boolean hook result
+     */
+
+    function onProfileDeleteRelated($profile, &$related)
+    {
+        $related[] = 'user_flag_profile';
+        return true;
+    }
+
+    /**
+     * Ensure that flag entries created by a user are deleted
+     * when that user gets deleted.
+     *
+     * @param User $user
+     * @param array &$related list of related tables; entries
+     *              with matching user_id will be deleted.
+     *
+     * @return boolean hook result
+     */
+
+    function onUserDeleteRelated($user, &$related)
+    {
+        $related[] = 'user_flag_profile';
+        return true;
+    }
 }