From d35faa04c1927994916a46a1bd48f8420a3e2dfe Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 15 Jan 2010 13:06:21 -0800 Subject: [PATCH 1/4] Fix for background recalculation of groups; needs to get Group objects not IDs; also don't list any groups for repeats to match saveGroups behavior todo: merge calculation portion with saveGroups so they don't get out of sync --- classes/Notice.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index a43ce867b5..38b10db048 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -826,6 +826,10 @@ class Notice extends Memcached_DataObject return $ids; } + /** + * @param $groups array of Group *objects* + * @param $recipients array of profile *ids* + */ function whoGets($groups=null, $recipients=null) { $c = self::memcache(); @@ -925,6 +929,9 @@ class Notice extends Memcached_DataObject return $ids; } + /** + * @return array of Group objects + */ function saveGroups() { // Don't save groups for repeats @@ -1117,11 +1124,22 @@ class Notice extends Memcached_DataObject return $ids; } + /** + * Same calculation as saveGroups but without the saving + * @fixme merge the functions + * @return array of Group objects + */ function getGroups() { + // Don't save groups for repeats + + if (!empty($this->repeat_of)) { + return array(); + } + // XXX: cache me - $ids = array(); + $groups = array(); $gi = new Group_inbox(); @@ -1132,13 +1150,13 @@ class Notice extends Memcached_DataObject if ($gi->find()) { while ($gi->fetch()) { - $ids[] = $gi->group_id; + $groups[] = clone($gi); } } $gi->free(); - return $ids; + return $groups; } function asAtomEntry($namespace=false, $source=false) From 775c63b654dacf733e7bef99cb9f6f07aa824854 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 16 Jan 2010 13:39:05 -0800 Subject: [PATCH 2/4] Cleanup for memcached host/port split -- apparently we use ';' on purpose, restoring. Keeping fix for the notices spewing into the log. --- plugins/MemcachePlugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/MemcachePlugin.php b/plugins/MemcachePlugin.php index 5214ab9c89..8c8b8da6dc 100644 --- a/plugins/MemcachePlugin.php +++ b/plugins/MemcachePlugin.php @@ -170,8 +170,8 @@ class MemcachePlugin extends Plugin $servers = array($this->servers); } foreach ($servers as $server) { - if (strpos($server, ':') !== false) { - list($host, $port) = explode(':', $server); + if (strpos($server, ';') !== false) { + list($host, $port) = explode(';', $server); } else { $host = $server; $port = 11211; From 71f519f64aed1dd6823a0f09db5c4c2e409da778 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 18 Jan 2010 23:25:45 -0500 Subject: [PATCH 3/4] add event for showing content license in action --- EVENTS.txt | 6 ++++++ lib/action.php | 37 ++++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index e6400244e4..6e6afa070f 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -687,3 +687,9 @@ StartLeaveGroup: when a user is leaving a group EndLeaveGroup: when a user has left a group - $group: the group being left - $user: the user leaving + +StartShowContentLicense: Showing the default license for content +- $action: the current action + +EndShowContentLicense: Showing the default license for content +- $action: the current action diff --git a/lib/action.php b/lib/action.php index a521bcb507..813d089fef 100644 --- a/lib/action.php +++ b/lib/action.php @@ -791,23 +791,26 @@ class Action extends HTMLOutputter // lawsuit */ function showContentLicense() { - $this->element('dt', array('id' => 'site_content_license'), _('Site content license')); - $this->elementStart('dd', array('id' => 'site_content_license_cc')); - $this->elementStart('p'); - $this->element('img', array('id' => 'license_cc', - 'src' => common_config('license', 'image'), - 'alt' => common_config('license', 'title'), - 'width' => '80', - 'height' => '15')); - //TODO: This is dirty: i18n - $this->text(_('All '.common_config('site', 'name').' content and data are available under the ')); - $this->element('a', array('class' => 'license', - 'rel' => 'external license', - 'href' => common_config('license', 'url')), - common_config('license', 'title')); - $this->text(_('license.')); - $this->elementEnd('p'); - $this->elementEnd('dd'); + if (Event::handle('StartShowContentLicense', array($this))) { + $this->element('dt', array('id' => 'site_content_license'), _('Site content license')); + $this->elementStart('dd', array('id' => 'site_content_license_cc')); + $this->elementStart('p'); + $this->element('img', array('id' => 'license_cc', + 'src' => common_config('license', 'image'), + 'alt' => common_config('license', 'title'), + 'width' => '80', + 'height' => '15')); + //TODO: This is dirty: i18n + $this->text(_('All '.common_config('site', 'name').' content and data are available under the ')); + $this->element('a', array('class' => 'license', + 'rel' => 'external license', + 'href' => common_config('license', 'url')), + common_config('license', 'title')); + $this->text(_('license.')); + $this->elementEnd('p'); + $this->elementEnd('dd'); + Event::handle('EndShowContentLicense', array($this)); + } } /** From c7f14cd7774d21e16aa6b020da71f318c648e3f0 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 19 Jan 2010 00:04:58 -0500 Subject: [PATCH 4/4] allow all rights reserved, private data --- README | 6 ++++++ lib/action.php | 47 +++++++++++++++++++++++++++++++++-------------- lib/default.php | 4 +++- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/README b/README index 7457215a1f..386b3264a2 100644 --- a/README +++ b/README @@ -1035,6 +1035,12 @@ Creative Commons Attribution 3.0 license, which is probably the right choice for any public site. Note that some other servers will not accept notices if you apply a stricter license than this. +type: one of 'cc' (for Creative Commons licenses), 'allrightsreserved' + (default copyright), or 'private' (for private and confidential + information). +owner: for 'allrightsreserved' or 'private', an assigned copyright + holder (for example, an employer for a private site). If + not specified, will be attributed to 'contributors'. url: URL of the license, used for links. title: Title for the license, like 'Creative Commons Attribution 3.0'. image: A button shown on each page for the license. diff --git a/lib/action.php b/lib/action.php index 813d089fef..171bea17c7 100644 --- a/lib/action.php +++ b/lib/action.php @@ -794,20 +794,39 @@ class Action extends HTMLOutputter // lawsuit if (Event::handle('StartShowContentLicense', array($this))) { $this->element('dt', array('id' => 'site_content_license'), _('Site content license')); $this->elementStart('dd', array('id' => 'site_content_license_cc')); - $this->elementStart('p'); - $this->element('img', array('id' => 'license_cc', - 'src' => common_config('license', 'image'), - 'alt' => common_config('license', 'title'), - 'width' => '80', - 'height' => '15')); - //TODO: This is dirty: i18n - $this->text(_('All '.common_config('site', 'name').' content and data are available under the ')); - $this->element('a', array('class' => 'license', - 'rel' => 'external license', - 'href' => common_config('license', 'url')), - common_config('license', 'title')); - $this->text(_('license.')); - $this->elementEnd('p'); + + switch (common_config('license', 'type')) { + case 'private': + $this->element('p', null, sprintf(_('Content and data of %1$s are private and confidential.'), + common_config('site', 'name'))); + // fall through + case 'allrightsreserved': + if (common_config('license', 'owner')) { + $this->element('p', null, sprintf(_('Content and data copyright by %1$s. All rights reserved.'), + common_config('license', 'owner'))); + } else { + $this->element('p', null, _('Content and data copyright by contributors. All rights reserved.')); + } + break; + case 'cc': // fall through + default: + $this->elementStart('p'); + $this->element('img', array('id' => 'license_cc', + 'src' => common_config('license', 'image'), + 'alt' => common_config('license', 'title'), + 'width' => '80', + 'height' => '15')); + //TODO: This is dirty: i18n + $this->text(_('All '.common_config('site', 'name').' content and data are available under the ')); + $this->element('a', array('class' => 'license', + 'rel' => 'external license', + 'href' => common_config('license', 'url')), + common_config('license', 'title')); + $this->text(_('license.')); + $this->elementEnd('p'); + break; + } + $this->elementEnd('dd'); Event::handle('EndShowContentLicense', array($this)); } diff --git a/lib/default.php b/lib/default.php index f7f4777a2e..5b2ae6c7c1 100644 --- a/lib/default.php +++ b/lib/default.php @@ -83,7 +83,9 @@ $default = 'softlimit' => '90%', // total size or % of memory_limit at which to restart queue threads gracefully ), 'license' => - array('url' => 'http://creativecommons.org/licenses/by/3.0/', + array('type' => 'cc', # can be 'cc', 'allrightsreserved', 'private' + 'owner' => null, # can be name of content owner e.g. for enterprise + 'url' => 'http://creativecommons.org/licenses/by/3.0/', 'title' => 'Creative Commons Attribution 3.0', 'image' => 'http://i.creativecommons.org/l/by/3.0/80x15.png'), 'mail' =>