]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/UserFlag/UserFlagPlugin.php
call DB_DataObject::__destruct() if it exists
[quix0rs-gnu-social.git] / plugins / UserFlag / UserFlagPlugin.php
index fc56249e6f321e85a772c3f709c1fc99b5cc90c7..75dcca4fcb3eaba46b953cca453a39f448c542a3 100644 (file)
@@ -47,40 +47,18 @@ class UserFlagPlugin extends Plugin
     {
         $schema = Schema::get();
 
-        // For storing user-submitted flags on notices
-
-        $schema->ensureTable('user_flag_notice',
-                             array(new ColumnDef('notice_id', 'integer', null, null, 'PRI'),
-                                   new ColumnDef('user_id', 'integer', null, null, 'PRI'),
-                                   new ColumnDef('flag', 'varchar', '8'),
-                                   new ColumnDef('created', 'datetime', null,
-                                                 null, 'MUL')));
-
-        // Allowable values for user_flag_notice
-
-        $schema->ensureTable('notice_flag',
-                             array(new ColumnDef('flag', 'varchar', '8', null, 'PRI'),
-                                   new ColumnDef('display', 'varchar', '255'),
-                                   new ColumnDef('created', 'datetime', null, null, 'MUL')));
-
         // For storing user-submitted flags on profiles
 
         $schema->ensureTable('user_flag_profile',
                              array(new ColumnDef('profile_id', 'integer', null,
-                                                 null, 'PRI'),
+                                                 false, 'PRI'),
                                    new ColumnDef('user_id', 'integer', null,
-                                                 null, 'PRI'),
-                                   new ColumnDef('flag', 'varchar', '8'),
+                                                 false, 'PRI'),
                                    new ColumnDef('created', 'datetime', null,
-                                                 null, 'MUL')));
+                                                 false, 'MUL'),
+                                   new ColumnDef('cleared', 'datetime', null,
+                                                 true, 'MUL')));
 
-        // Allowable values for user_flag_notice
-
-        $schema->ensureTable('profile_flag',
-                             array(new ColumnDef('flag', 'varchar', '8', null, 'PRI'),
-                                   new ColumnDef('display', 'varchar', '255'),
-                                   new ColumnDef('created', 'datetime', null,
-                                                 null, 'MUL')));
         return true;
     }
 
@@ -90,10 +68,8 @@ class UserFlagPlugin extends Plugin
         return true;
     }
 
-    function onRouterInitialized(&$m) {
-        $m->connect('main/flag/notice', array('action' => 'flagnotice'));
+    function onRouterInitialized($m) {
         $m->connect('main/flag/profile', array('action' => 'flagprofile'));
-        $m->connect('admin/notice/flag', array('action' => 'adminnoticeflag'));
         $m->connect('admin/profile/flag', array('action' => 'adminprofileflag'));
         return true;
     }
@@ -102,19 +78,14 @@ class UserFlagPlugin extends Plugin
     {
         switch ($cls)
         {
-        case 'FlagnoticeAction':
         case 'FlagprofileAction':
-        case 'AdminnoticeflagAction':
         case 'AdminprofileflagAction':
             require_once(INSTALLDIR.'/plugins/UserFlag/' . strtolower(mb_substr($cls, 0, -6)) . '.php');
             return false;
         case 'FlagProfileForm':
             require_once(INSTALLDIR.'/plugins/UserFlag/' . strtolower($cls . '.php'));
             return false;
-        case 'User_flag_notice':
-        case 'Notice_flag':
         case 'User_flag_profile':
-        case 'Profile_flag':
             require_once(INSTALLDIR.'/plugins/UserFlag/'.$cls.'.php');
             return false;
         default:
@@ -126,14 +97,12 @@ class UserFlagPlugin extends Plugin
     {
         $user = common_current_user();
 
-        if (!empty($user)) {
+        if (!empty($user) && ($user->id != $profile->id)) {
 
             $action->elementStart('li', 'entity_flag');
 
-            if (User_flag_profile::exists($profile->id, $user->id,
-                                          Profile_flag::DEFAULTFLAG)) {
-                $action->element('span',
-                                 _('Flagged for review'));
+            if (User_flag_profile::exists($profile->id, $user->id)) {
+                $action->element('p', 'flagged', _('Flagged'));
             } else {
                 $form = new FlagProfileForm($action, $profile,
                                         array('action' => 'showstream',
@@ -153,11 +122,30 @@ class UserFlagPlugin extends Plugin
 
         if (!empty($user)) {
 
-            $form = new FlagProfileForm($item->action, $item->profile);
+            list($action, $args) = $item->action->returnToArgs();
+
+            $args['action'] = $action;
 
+            $form = new FlagProfileForm($item->action, $item->profile, $args);
+
+            $item->action->elementStart('li', 'entity_flag');
             $form->show();
+            $item->action->elementEnd('li');
         }
 
         return true;
     }
+
+    function onEndShowStatusNetStyles($action)
+    {
+        $action->cssLink(common_path('plugins/UserFlag/userflag.css'), 
+                         null, 'screen, projection, tv');
+        return true;
+    }
+
+    function onEndShowScripts($action)
+    {
+        $action->inlineScript('if ($(".form_entity_flag").length > 0) { SN.U.FormXHR($(".form_entity_flag")); }');
+        return true;
+    }
 }