]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add commands to turn sms notification on and off
authorEvan Prodromou <evan@prodromou.name>
Mon, 4 Aug 2008 19:07:49 +0000 (15:07 -0400)
committerEvan Prodromou <evan@prodromou.name>
Mon, 4 Aug 2008 19:07:49 +0000 (15:07 -0400)
darcs-hash:20080804190749-84dde-0b6d007e3da6d468e7dbe1c859f2c5c753726e8a.gz

maildaemon.php

index 5be62efb88683f61b8e6a2af92eefb9eab6b6062..0a96bfeb4d994bdb92df96553d04c03a8ba861ea 100755 (executable)
@@ -98,9 +98,30 @@ class MailerDaemon {
        }
 
        function handle_command($user, $msg) {
-               return false;
+               $cmd = trim(strtolower($msg));
+               switch ($cmd) {
+                case 'off':
+                       $this->set_notify($user, false);
+                       return true;
+                case 'on':
+                       $this->set_notify($user, true);
+                       return true;
+                default:
+                       return false;
+               }
        }
 
+       function set_notify($user, $value) {
+               $orig = clone($user);
+               $user->smsnotify = $value;
+               $result = $user->update($orig);
+               if (!$result) {
+                       common_log_db_error($user, 'UPDATE', __FILE__);
+                       return false;
+               }
+               return true;
+       }
+       
        function respond($from, $to, $response) {
 
                $headers['From'] = $to;