]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/EmailSummary/EmailSummaryPlugin.php
Start and End EmailSaveForm events now take a scoped profile
[quix0rs-gnu-social.git] / plugins / EmailSummary / EmailSummaryPlugin.php
index da94322411c533e59a4a1c15b7be69d043678968..da682e0454e2834054ff298bb95ed894a5d278a5 100644 (file)
@@ -115,39 +115,35 @@ class EmailSummaryPlugin extends Plugin
      * Add a checkbox to turn off email summaries
      *
      * @param Action $action Action being executed (emailsettings)
+     * @param Profile $scoped Profile for whom settings are configured (current user)
      *
      * @return boolean hook value
      */
-    function onEndEmailSaveForm($action)
+    public function onEndEmailSaveForm(Action $action, Profile $scoped)
     {
         $sendSummary = $action->boolean('emailsummary');
 
-        $user = common_current_user();
-
-        if (!empty($user)) {
-
-            $ess = Email_summary_status::getKV('user_id', $user->id);
+        $ess = Email_summary_status::getKV('user_id', $scoped->id);
 
-            if (empty($ess)) {
+        if (empty($ess)) {
 
-                $ess = new Email_summary_status();
+            $ess = new Email_summary_status();
 
-                $ess->user_id      = $user->id;
-                $ess->send_summary = $sendSummary;
-                $ess->created      = common_sql_now();
-                $ess->modified     = common_sql_now();
+            $ess->user_id      = $scoped->id;
+            $ess->send_summary = $sendSummary;
+            $ess->created      = common_sql_now();
+            $ess->modified     = common_sql_now();
 
-                $ess->insert();
+            $ess->insert();
 
-            } else {
+        } else {
 
-                $orig = clone($ess);
+            $orig = clone($ess);
 
-                $ess->send_summary = $sendSummary;
-                $ess->modified     = common_sql_now();
+            $ess->send_summary = $sendSummary;
+            $ess->modified     = common_sql_now();
 
-                $ess->update($orig);
-            }
+            $ess->update($orig);
         }
 
         return true;