summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--classes/Design.php2
-rw-r--r--classes/Group_inbox.php6
-rw-r--r--classes/Notice.php142
-rw-r--r--classes/Notice_inbox.php1
-rw-r--r--classes/Profile.php48
-rw-r--r--classes/User.php46
-rw-r--r--classes/User_group.php24
-rw-r--r--js/userdesign.go.js8
-rw-r--r--theme/base/css/ie.css6
9 files changed, 198 insertions, 85 deletions
diff --git a/classes/Design.php b/classes/Design.php
index da4b670be..0927fcda7 100644
--- a/classes/Design.php
+++ b/classes/Design.php
@@ -85,7 +85,7 @@ class Design extends Memcached_DataObject
$css .= 'body { background-image:url(' .
Design::url($this->backgroundimage) .
- '); ' . $repeat . ' }' . "\n";
+ '); ' . $repeat . ' background-attachment:fixed; }' . "\n";
}
$out->element('style', array('type' => 'text/css'), $css);
diff --git a/classes/Group_inbox.php b/classes/Group_inbox.php
index b80ba4272..1af7439f7 100644
--- a/classes/Group_inbox.php
+++ b/classes/Group_inbox.php
@@ -14,8 +14,14 @@ class Group_inbox extends Memcached_DataObject
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
+
+ function &pkeyGet($kv)
+ {
+ return Memcached_DataObject::pkeyGet('Group_inbox', $kv);
+ }
}
diff --git a/classes/Notice.php b/classes/Notice.php
index 5bcfa896e..d0ee1d925 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -34,6 +34,8 @@ define('NOTICE_REMOTE_OMB', 0);
define('NOTICE_LOCAL_NONPUBLIC', -1);
define('NOTICE_GATEWAY', -2);
+define('MAX_BOXCARS', 128);
+
class Notice extends Memcached_DataObject
{
###START_AUTOCODE
@@ -221,7 +223,7 @@ class Notice extends Memcached_DataObject
$notice->saveTags();
$notice->addToInboxes();
- $notice->saveGroups();
+
$notice->saveUrls();
$orig2 = clone($notice);
$notice->rendered = common_render_content($final, $notice);
@@ -832,29 +834,94 @@ class Notice extends Memcached_DataObject
$enabled = common_config('inboxes', 'enabled');
if ($enabled === true || $enabled === 'transitional') {
+
+ // XXX: loads constants
+
$inbox = new Notice_inbox();
- $UT = common_config('db','type')=='pgsql'?'"user"':'user';
- $qry = 'INSERT INTO notice_inbox (user_id, notice_id, created) ' .
- "SELECT $UT.id, " . $this->id . ", '" . $this->created . "' " .
- "FROM $UT JOIN subscription ON $UT.id = subscription.subscriber " .
- 'WHERE subscription.subscribed = ' . $this->profile_id . ' ' .
- 'AND NOT EXISTS (SELECT user_id, notice_id ' .
- 'FROM notice_inbox ' .
- "WHERE user_id = $UT.id " .
- 'AND notice_id = ' . $this->id . ' )';
- if ($enabled === 'transitional') {
- $qry .= " AND $UT.inboxed = 1";
+
+ $users = $this->getSubscribedUsers();
+
+ // FIXME: kind of ignoring 'transitional'...
+ // we'll probably stop supporting inboxless mode
+ // in 0.9.x
+
+ $ni = array();
+
+ foreach ($users as $id) {
+ $ni[$id] = NOTICE_INBOX_SOURCE_SUB;
+ }
+
+ $groups = $this->saveGroups();
+
+ foreach ($groups as $group) {
+ $users = $group->getUserMembers();
+ foreach ($users as $id) {
+ if (!array_key_exists($id, $ni)) {
+ $ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
+ }
+ }
+ }
+
+ $cnt = 0;
+
+ $qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES ';
+ $qry = $qryhdr;
+
+ foreach ($ni as $id => $source) {
+ if ($cnt > 0) {
+ $qry .= ', ';
+ }
+ $qry .= '('.$id.', '.$this->id.', '.$source.', "'.$this->created.'") ';
+ $cnt++;
+ if ($cnt >= MAX_BOXCARS) {
+ common_debug($qry);
+ $inbox = new Notice_inbox();
+ $inbox->query($qry);
+ $qry = $qryhdr;
+ $cnt = 0;
+ }
+ }
+
+ if ($cnt > 0) {
+ common_debug($qry);
+ $inbox = new Notice_inbox();
+ $inbox->query($qry);
}
- $inbox->query($qry);
}
+
return;
}
+ function getSubscribedUsers()
+ {
+ $user = new User();
+
+ $qry =
+ 'SELECT id ' .
+ 'FROM user JOIN subscription '.
+ 'ON user.id = subscription.subscriber ' .
+ 'WHERE subscription.subscribed = %d ';
+
+ $user->query(sprintf($qry, $this->profile_id));
+
+ $ids = array();
+
+ while ($user->fetch()) {
+ $ids[] = $user->id;
+ }
+
+ $user->free();
+
+ return $ids;
+ }
+
function saveGroups()
{
+ $groups = array();
+
$enabled = common_config('inboxes', 'enabled');
if ($enabled !== true && $enabled !== 'transitional') {
- return;
+ return $groups;
}
/* extract all !group */
@@ -862,7 +929,7 @@ class Notice extends Memcached_DataObject
strtolower($this->content),
$match);
if (!$count) {
- return true;
+ return $groups;
}
$profile = $this->getProfile();
@@ -888,41 +955,36 @@ class Notice extends Memcached_DataObject
if ($profile->isMember($group)) {
- $gi = new Group_inbox();
-
- $gi->group_id = $group->id;
- $gi->notice_id = $this->id;
- $gi->created = common_sql_now();
-
- $result = $gi->insert();
+ $result = $this->addToGroupInbox($group);
if (!$result) {
common_log_db_error($gi, 'INSERT', __FILE__);
}
- // FIXME: do this in an offline daemon
-
- $this->addToGroupInboxes($group);
+ $groups[] = clone($group);
}
}
+
+ return $groups;
}
- function addToGroupInboxes($group)
+ function addToGroupInbox($group)
{
- $inbox = new Notice_inbox();
- $UT = common_config('db','type')=='pgsql'?'"user"':'user';
- $qry = 'INSERT INTO notice_inbox (user_id, notice_id, created, source) ' .
- "SELECT $UT.id, " . $this->id . ", '" . $this->created . "', " . NOTICE_INBOX_SOURCE_GROUP . " " .
- "FROM $UT JOIN group_member ON $UT.id = group_member.profile_id " .
- 'WHERE group_member.group_id = ' . $group->id . ' ' .
- 'AND NOT EXISTS (SELECT user_id, notice_id ' .
- 'FROM notice_inbox ' .
- "WHERE user_id = $UT.id " .
- 'AND notice_id = ' . $this->id . ' )';
- if ($enabled === 'transitional') {
- $qry .= " AND $UT.inboxed = 1";
- }
- $result = $inbox->query($qry);
+ $gi = Group_inbox::pkeyGet(array('group_id' => $group->id,
+ 'notice_id' => $this->id));
+
+ if (empty($gi)) {
+
+ $gi = new Group_inbox();
+
+ $gi->group_id = $group->id;
+ $gi->notice_id = $this->id;
+ $gi->created = $this->created;
+
+ return $gi->insert();
+ }
+
+ return true;
}
function saveReplies()
diff --git a/classes/Notice_inbox.php b/classes/Notice_inbox.php
index 4ca2e9ae3..940381f84 100644
--- a/classes/Notice_inbox.php
+++ b/classes/Notice_inbox.php
@@ -27,6 +27,7 @@ define('INBOX_CACHE_WINDOW', 101);
define('NOTICE_INBOX_SOURCE_SUB', 1);
define('NOTICE_INBOX_SOURCE_GROUP', 2);
+define('NOTICE_INBOX_SOURCE_REPLY', 3);
define('NOTICE_INBOX_SOURCE_GATEWAY', -1);
class Notice_inbox extends Memcached_DataObject
diff --git a/classes/Profile.php b/classes/Profile.php
index 6b27c80cb..a0ed6b3ca 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -289,4 +289,52 @@ class Profile extends Memcached_DataObject
return Avatar::defaultImage($size);
}
}
+
+ function getSubscriptions($offset=0, $limit=null)
+ {
+ $qry =
+ 'SELECT profile.* ' .
+ 'FROM profile JOIN subscription ' .
+ 'ON profile.id = subscription.subscribed ' .
+ 'WHERE subscription.subscriber = %d ' .
+ 'AND subscription.subscribed != subscription.subscriber ' .
+ 'ORDER BY subscription.created DESC ';
+
+ if (common_config('db','type') == 'pgsql') {
+ $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
+ } else {
+ $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+ }
+
+ $profile = new Profile();
+
+ $profile->query(sprintf($qry, $this->id));
+
+ return $profile;
+ }
+
+ function getSubscribers($offset=0, $limit=null)
+ {
+ $qry =
+ 'SELECT profile.* ' .
+ 'FROM profile JOIN subscription ' .
+ 'ON profile.id = subscription.subscriber ' .
+ 'WHERE subscription.subscribed = %d ' .
+ 'AND subscription.subscribed != subscription.subscriber ' .
+ 'ORDER BY subscription.created DESC ';
+
+ if ($offset) {
+ if (common_config('db','type') == 'pgsql') {
+ $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
+ } else {
+ $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+ }
+ }
+
+ $profile = new Profile();
+
+ $cnt = $profile->query(sprintf($qry, $this->id));
+
+ return $profile;
+ }
}
diff --git a/classes/User.php b/classes/User.php
index a01a3106f..62a3f8a66 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -600,50 +600,16 @@ class User extends Memcached_DataObject
function getSubscriptions($offset=0, $limit=null)
{
- $qry =
- 'SELECT profile.* ' .
- 'FROM profile JOIN subscription ' .
- 'ON profile.id = subscription.subscribed ' .
- 'WHERE subscription.subscriber = %d ' .
- 'AND subscription.subscribed != subscription.subscriber ' .
- 'ORDER BY subscription.created DESC ';
-
- if (common_config('db','type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
-
- $profile = new Profile();
-
- $profile->query(sprintf($qry, $this->id));
-
- return $profile;
+ $profile = $this->getProfile();
+ assert(!empty($profile));
+ return $profile->getSubscriptions($offset, $limit);
}
function getSubscribers($offset=0, $limit=null)
{
- $qry =
- 'SELECT profile.* ' .
- 'FROM profile JOIN subscription ' .
- 'ON profile.id = subscription.subscriber ' .
- 'WHERE subscription.subscribed = %d ' .
- 'AND subscription.subscribed != subscription.subscriber ' .
- 'ORDER BY subscription.created DESC ';
-
- if ($offset) {
- if (common_config('db','type') == 'pgsql') {
- $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
- } else {
- $qry .= ' LIMIT ' . $offset . ', ' . $limit;
- }
- }
-
- $profile = new Profile();
-
- $cnt = $profile->query(sprintf($qry, $this->id));
-
- return $profile;
+ $profile = $this->getProfile();
+ assert(!empty($profile));
+ return $profile->getSubscribers($offset, $limit);
}
function getTaggedSubscribers($tag, $offset=0, $limit=null)
diff --git a/classes/User_group.php b/classes/User_group.php
index 8a56b9e52..9b4b01ead 100644
--- a/classes/User_group.php
+++ b/classes/User_group.php
@@ -246,4 +246,28 @@ class User_group extends Memcached_DataObject
return Design::staticGet('id', $this->design_id);
}
+ function getUserMembers()
+ {
+ // XXX: cache this
+
+ $user = new User();
+
+ $qry =
+ 'SELECT id ' .
+ 'FROM user JOIN group_member '.
+ 'ON user.id = group_member.profile_id ' .
+ 'WHERE group_member.group_id = %d ';
+
+ $user->query(sprintf($qry, $this->id));
+
+ $ids = array();
+
+ while ($user->fetch()) {
+ $ids[] = $user->id;
+ }
+
+ $user->free();
+
+ return $ids;
+ }
}
diff --git a/js/userdesign.go.js b/js/userdesign.go.js
index b54b492cc..dda86294e 100644
--- a/js/userdesign.go.js
+++ b/js/userdesign.go.js
@@ -11,7 +11,7 @@ $(document).ready(function() {
C = $(S).val();
switch (parseInt(S.id.slice(-1))) {
case 1: default:
- $('html, body').css({'background-color':C});
+ $('body').css({'background-color':C});
break;
case 2:
$('#content, #site_nav_local_views .current a').css({'background-color':C});
@@ -89,11 +89,11 @@ $(document).ready(function() {
$('body').css({'background-image':'none'});
});
$('#design_background-image_on').focus(function() {
- var bis = $('#design_background-image_onoff img')[0].src;
- $('body').css({'background-image':'url('+bis+')'});
+ $('body').css({'background-image':'url('+$('#design_background-image_onoff img')[0].src+')'});
+ $('body').css({'background-attachment': 'fixed'});
});
$('#design_background-image_repeat').click(function() {
($(this)[0].checked) ? $('body').css({'background-repeat':'repeat'}) : $('body').css({'background-repeat':'no-repeat'});
});
-}); \ No newline at end of file
+});
diff --git a/theme/base/css/ie.css b/theme/base/css/ie.css
index da200388e..43fb01492 100644
--- a/theme/base/css/ie.css
+++ b/theme/base/css/ie.css
@@ -19,6 +19,12 @@ display:block;
width:17%;
max-width:17%;
}
+#form_notice #notice_data-attach_selected {
+width:78.5%;
+}
+#form_notice #notice_data-attach_selected button {
+padding:0 4px;
+}
#anon_notice {
max-width:39%;
}