summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/command.php68
-rw-r--r--lib/commandinterpreter.php18
-rw-r--r--lib/common.php8
-rw-r--r--lib/mailbox.php2
-rw-r--r--lib/schema.php41
5 files changed, 134 insertions, 3 deletions
diff --git a/lib/command.php b/lib/command.php
index 2ec3320de..7e98156b6 100644
--- a/lib/command.php
+++ b/lib/command.php
@@ -605,6 +605,71 @@ class LoginCommand extends Command
}
}
+class SubscriptionsCommand extends Command
+{
+ function execute($channel)
+ {
+ $profile = $this->user->getSubscriptions(0);
+ $nicknames=array();
+ while ($profile->fetch()) {
+ $nicknames[]=$profile->nickname;
+ }
+ if(count($nicknames)==0){
+ $out=_('You are not subscribed to anyone.');
+ }else{
+ $out = ngettext('You are subscribed to this person:',
+ 'You are subscribed to these people:',
+ count($nicknames));
+ $out .= ' ';
+ $out .= implode(', ',$nicknames);
+ }
+ $channel->output($this->user,$out);
+ }
+}
+
+class SubscribersCommand extends Command
+{
+ function execute($channel)
+ {
+ $profile = $this->user->getSubscribers();
+ $nicknames=array();
+ while ($profile->fetch()) {
+ $nicknames[]=$profile->nickname;
+ }
+ if(count($nicknames)==0){
+ $out=_('No one is subscribed to you.');
+ }else{
+ $out = ngettext('This person is subscribed to you:',
+ 'These people are subscribed to you:',
+ count($nicknames));
+ $out .= ' ';
+ $out .= implode(', ',$nicknames);
+ }
+ $channel->output($this->user,$out);
+ }
+}
+
+class GroupsCommand extends Command
+{
+ function execute($channel)
+ {
+ $group = $this->user->getGroups();
+ $groups=array();
+ while ($group->fetch()) {
+ $groups[]=$group->nickname;
+ }
+ if(count($groups)==0){
+ $out=_('You are not a member of any groups.');
+ }else{
+ $out = ngettext('You are a member of this group:',
+ 'You are a member of these groups:',
+ count($nicknames));
+ $out.=implode(', ',$groups);
+ }
+ $channel->output($this->user,$out);
+ }
+}
+
class HelpCommand extends Command
{
function execute($channel)
@@ -615,6 +680,9 @@ class HelpCommand extends Command
"off - turn off notifications\n".
"help - show this help\n".
"follow <nickname> - subscribe to user\n".
+ "groups - lists the groups you have joined\n".
+ "subscriptions - list the people you follow\n".
+ "subscribers - list the people that follow you\n".
"leave <nickname> - unsubscribe from user\n".
"d <nickname> <text> - direct message to user\n".
"get <nickname> - get last notice from user\n".
diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php
index d878fe268..665015afc 100644
--- a/lib/commandinterpreter.php
+++ b/lib/commandinterpreter.php
@@ -47,6 +47,24 @@ class CommandInterpreter
} else {
return new LoginCommand($user);
}
+ case 'subscribers':
+ if ($arg) {
+ return null;
+ } else {
+ return new SubscribersCommand($user);
+ }
+ case 'subscriptions':
+ if ($arg) {
+ return null;
+ } else {
+ return new SubscriptionsCommand($user);
+ }
+ case 'groups':
+ if ($arg) {
+ return null;
+ } else {
+ return new GroupsCommand($user);
+ }
case 'on':
if ($arg) {
list($other, $extra) = $this->split_arg($arg);
diff --git a/lib/common.php b/lib/common.php
index 4524d50fa..063d7d9d9 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -45,6 +45,14 @@ define('FOREIGN_FRIEND_RECV', 2);
set_include_path(get_include_path() . PATH_SEPARATOR . INSTALLDIR . '/extlib/');
+# To protect against upstream libraries which haven't updated
+# for PHP 5.3 where dl() function may not be present...
+if (!function_exists('dl')) {
+ function dl($library) {
+ return false;
+ }
+}
+
# global configuration object
require_once('PEAR.php');
diff --git a/lib/mailbox.php b/lib/mailbox.php
index e1d384a06..90a58b4c4 100644
--- a/lib/mailbox.php
+++ b/lib/mailbox.php
@@ -282,7 +282,7 @@ class MailboxAction extends CurrentUserDesignAction
$ns->name);
$this->elementEnd('span');
} else {
- $this->out->element('span', 'device', $source_name);
+ $this->element('span', 'device', $source_name);
}
break;
}
diff --git a/lib/schema.php b/lib/schema.php
index 1e0c1f3e9..560884d9f 100644
--- a/lib/schema.php
+++ b/lib/schema.php
@@ -373,6 +373,26 @@ class Schema
}
/**
+ * Ensures that the table that backs a given
+ * Plugin_DataObject class exists.
+ *
+ * If the table does not yet exist, it will
+ * create the table. If it does exist, it will
+ * alter the table to match the column definitions.
+ *
+ * @param Plugin_DataObject $dataObjectClass
+ *
+ * @return boolean success flag
+ */
+
+ public function ensureDataObject($dataObjectClass)
+ {
+ $obj = new $dataObjectClass();
+ $tableDef = $obj->tableDef();
+ return $this->ensureTable($tableDef->name,$tableDef->columns);
+ }
+
+ /**
* Ensures that a table exists with the given
* name and the given column definitions.
*
@@ -544,6 +564,19 @@ class TableDef
public $name;
/** array of ColumnDef objects for the columns. */
public $columns;
+
+ /**
+ * Constructor.
+ *
+ * @param string $name name of the table
+ * @param array $columns columns in the table
+ */
+
+ function __construct($name=null,$columns=null)
+ {
+ $this->name = $name;
+ $this->columns = $columns;
+ }
}
/**
@@ -576,6 +609,8 @@ class ColumnDef
/** 'extra' stuff. Returned by MySQL, largely
* unused. */
public $extra;
+ /** auto increment this field if no value is specific for it during an insert **/
+ public $auto_increment;
/**
* Constructor.
@@ -591,7 +626,7 @@ class ColumnDef
function __construct($name=null, $type=null, $size=null,
$nullable=true, $key=null, $default=null,
- $extra=null)
+ $extra=null, $auto_increment=false)
{
$this->name = strtolower($name);
$this->type = strtolower($type);
@@ -600,6 +635,7 @@ class ColumnDef
$this->key = $key;
$this->default = $default;
$this->extra = $extra;
+ $this->auto_increment = $auto_increment;
}
/**
@@ -617,7 +653,8 @@ class ColumnDef
$this->_typeMatch($other) &&
$this->_defaultMatch($other) &&
$this->_nullMatch($other) &&
- $this->key == $other->key);
+ $this->key == $other->key &&
+ $this->auto_increment == $other->auto_increment);
}
/**