]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/channel.php
added copyright, updated
[quix0rs-gnu-social.git] / lib / channel.php
index cb35e5ddb623034acb30077832d7b014e2956287..e83960ac5402cc41fbe1867ca2bceea31c7280f6 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /*
- * StatusNet - a distributed open-source microblogging tool
+ * StatusNet - the distributed open-source microblogging tool
  * Copyright (C) 2008, 2009, StatusNet, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
@@ -17,7 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
 
 class Channel
 {
@@ -47,60 +47,22 @@ class Channel
     }
 }
 
-class XMPPChannel extends Channel
+class CLIChannel extends Channel
 {
-
-    var $conn = null;
-
     function source()
     {
-        return 'xmpp';
-    }
-
-    function __construct($conn)
-    {
-        $this->conn = $conn;
-    }
-
-    function on($user)
-    {
-        return $this->set_notify($user, 1);
-    }
-
-    function off($user)
-    {
-        return $this->set_notify($user, 0);
+        return 'cli';
     }
 
     function output($user, $text)
     {
-        $text = '['.common_config('site', 'name') . '] ' . $text;
-        jabber_send_message($user->jabber, $text);
+        $site = common_config('site', 'name');
+        print "[{$user->nickname}@{$site}] $text\n";
     }
 
     function error($user, $text)
     {
-        $text = '['.common_config('site', 'name') . '] ' . $text;
-        jabber_send_message($user->jabber, $text);
-    }
-
-    function set_notify(&$user, $notify)
-    {
-        $orig = clone($user);
-        $user->jabbernotify = $notify;
-        $result = $user->update($orig);
-        if (!$result) {
-            $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
-            common_log(LOG_ERR,
-                       'Could not set notify flag to ' . $notify .
-                       ' for user ' . common_log_objstring($user) .
-                       ': ' . $last_error->message);
-            return false;
-        } else {
-            common_log(LOG_INFO,
-                       'User ' . $user->nickname . ' set notify flag to ' . $notify);
-            return true;
-        }
+        $this->output($user, $text);
     }
 }