summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rwxr-xr-xclasses/Group_inbox.php22
-rwxr-xr-xclasses/Group_member.php24
-rwxr-xr-xclasses/Related_group.php22
-rw-r--r--classes/User.php28
-rwxr-xr-xclasses/User_group.php90
-rwxr-xr-x[-rw-r--r--]classes/laconica.ini46
6 files changed, 232 insertions, 0 deletions
diff --git a/classes/Group_inbox.php b/classes/Group_inbox.php
new file mode 100755
index 000000000..826889636
--- /dev/null
+++ b/classes/Group_inbox.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Table Definition for group_inbox
+ */
+require_once 'classes/Memcached_DataObject';
+
+class Group_inbox extends Memcached_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'group_inbox'; // table name
+ public $group_id; // int(4) primary_key not_null
+ public $notice_id; // int(4) primary_key not_null
+ public $created; // datetime() not_null
+
+ /* Static get */
+ function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Group_inbox',$k,$v); }
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+}
diff --git a/classes/Group_member.php b/classes/Group_member.php
new file mode 100755
index 000000000..32243fe45
--- /dev/null
+++ b/classes/Group_member.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Table Definition for group_member
+ */
+require_once 'classes/Memcached_DataObject.php';
+
+class Group_member extends Memcached_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'group_member'; // table name
+ public $group_id; // int(4) primary_key not_null
+ public $profile_id; // int(4) primary_key not_null
+ public $is_admin; // tinyint(1)
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
+
+ /* Static get */
+ function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Group_member',$k,$v); }
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+}
diff --git a/classes/Related_group.php b/classes/Related_group.php
new file mode 100755
index 000000000..40e4904c5
--- /dev/null
+++ b/classes/Related_group.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Table Definition for related_group
+ */
+require_once 'classes/Memcached_DataObject';
+
+class Related_group extends Memcached_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'related_group'; // table name
+ public $group_id; // int(4) primary_key not_null
+ public $related_group_id; // int(4) primary_key not_null
+ public $created; // datetime() not_null
+
+ /* Static get */
+ function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Related_group',$k,$v); }
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+}
diff --git a/classes/User.php b/classes/User.php
index 92ff8776b..51e23fccf 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -492,4 +492,32 @@ class User extends Memcached_DataObject
return true;
}
+ function isMember($group)
+ {
+ $mem = new Group_member();
+
+ $mem->group_id = $group->id;
+ $mem->profile_id = $this->id;
+
+ if ($mem->find()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ function isAdmin($group)
+ {
+ $mem = new Group_member();
+
+ $mem->group_id = $group->id;
+ $mem->profile_id = $this->id;
+ $mem->is_admin = 1;
+
+ if ($mem->find()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
}
diff --git a/classes/User_group.php b/classes/User_group.php
new file mode 100755
index 000000000..06c031610
--- /dev/null
+++ b/classes/User_group.php
@@ -0,0 +1,90 @@
+<?php
+/**
+ * Table Definition for user_group
+ */
+require_once 'classes/Memcached_DataObject.php';
+
+class User_group extends Memcached_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'user_group'; // table name
+ public $id; // int(4) primary_key not_null
+ public $nickname; // varchar(64) unique_key
+ public $fullname; // varchar(255)
+ public $homepage; // varchar(255)
+ public $description; // varchar(140)
+ public $location; // varchar(255)
+ public $original_logo; // varchar(255)
+ public $homepage_logo; // varchar(255)
+ public $stream_logo; // varchar(255)
+ public $mini_logo; // varchar(255)
+ public $created; // datetime() not_null
+ public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
+
+ /* Static get */
+ function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('User_group',$k,$v); }
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+
+ function defaultLogo($size)
+ {
+ static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile',
+ AVATAR_STREAM_SIZE => 'stream',
+ AVATAR_MINI_SIZE => 'mini');
+ return theme_path('default-avatar-'.$sizenames[$size].'.png');
+ }
+
+ function homeUrl()
+ {
+ return common_local_url('showgroup',
+ array('nickname' => $this->nickname));
+ }
+
+ function permalink()
+ {
+ return common_local_url('groupbyid',
+ array('id' => $this->id));
+ }
+
+ function getNotices($offset, $limit)
+ {
+ $qry =
+ 'SELECT notice.* ' .
+ 'FROM notice JOIN group_inbox ON notice.id = group_inbox.notice_id ' .
+ 'WHERE group_inbox.group_id = %d ';
+ return Notice::getStream(sprintf($qry, $this->id),
+ 'group:notices:'.$this->id,
+ $offset, $limit);
+ }
+
+ function allowedNickname($nickname)
+ {
+ static $blacklist = array('new');
+ return !in_array($nickname, $blacklist);
+ }
+
+ function getMembers($offset=0, $limit=null)
+ {
+ $qry =
+ 'SELECT profile.* ' .
+ 'FROM profile JOIN group_member '.
+ 'ON profile.id = group_member.profile_id ' .
+ 'WHERE group_member.group_id = %d ' .
+ 'ORDER BY group_member.created DESC ';
+
+ if (common_config('db','type') == 'pgsql') {
+ $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
+ } else {
+ $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+ }
+
+ $members = new Profile();
+
+ $cnt = $members->query(sprintf($qry, $this->id));
+
+ return $members;
+ }
+}
diff --git a/classes/laconica.ini b/classes/laconica.ini
index db76b2dee..255122a97 100644..100755
--- a/classes/laconica.ini
+++ b/classes/laconica.ini
@@ -98,6 +98,26 @@ id = K
service = K
uri = U
+[group_inbox]
+group_id = 129
+notice_id = 129
+created = 142
+
+[group_inbox__keys]
+group_id = K
+notice_id = K
+
+[group_member]
+group_id = 129
+profile_id = 129
+is_admin = 17
+created = 142
+modified = 384
+
+[group_member__keys]
+group_id = K
+profile_id = K
+
[invitation]
code = 130
user_id = 129
@@ -225,6 +245,15 @@ claimed = 14
notice_id = K
transport = K
+[related_group]
+group_id = 129
+related_group_id = 129
+created = 142
+
+[related_group__keys]
+group_id = K
+related_group_id = K
+
[remember_me]
code = 130
user_id = 129
@@ -332,6 +361,23 @@ jabber = U
sms = U
uri = U
+[user_group]
+id = 129
+nickname = 2
+fullname = 2
+homepage = 2
+description = 2
+location = 2
+original_logo = 2
+homepage_logo = 2
+stream_logo = 2
+mini_logo = 2
+created = 142
+modified = 384
+
+[user_group__keys]
+id = N
+
[user_openid]
canonical = 130
display = 130