summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-03-04 07:00:45 -0800
committerBrion Vibber <brion@pobox.com>2010-03-04 07:00:45 -0800
commit62d5f1addb1b710a387f7732ace1dd33bd1b86c1 (patch)
treedf1d6d402dd057c330b0eb71b803d595c024d476 /lib
parent0f1c6e239acbf2c024c3aae9819d891f02b05bfd (diff)
parent9f861e9d895325adbb2dc7f1d540a442be2c1b2f (diff)
Merge branch 'testing'
Diffstat (limited to 'lib')
-rw-r--r--lib/activity.php12
-rw-r--r--lib/adminpanelaction.php5
-rw-r--r--lib/atom10entry.php105
-rw-r--r--lib/atom10feed.php28
-rw-r--r--lib/atomgroupnoticefeed.php32
-rw-r--r--lib/atomnoticefeed.php16
-rw-r--r--lib/atomusernoticefeed.php52
-rw-r--r--lib/grantroleform.php93
-rw-r--r--lib/revokeroleform.php93
-rw-r--r--lib/right.php2
-rw-r--r--lib/router.php2
-rw-r--r--lib/statusnet.php6
-rw-r--r--lib/userprofile.php26
13 files changed, 354 insertions, 118 deletions
diff --git a/lib/activity.php b/lib/activity.php
index 7334239ec..2cb80f9e1 100644
--- a/lib/activity.php
+++ b/lib/activity.php
@@ -1064,6 +1064,18 @@ class Activity
}
$this->entry = $entry;
+
+ // @fixme Don't send in a DOMDocument
+ if ($feed instanceof DOMDocument) {
+ common_log(
+ LOG_WARNING,
+ 'Activity::__construct() - '
+ . 'DOMDocument passed in for feed by mistake. '
+ . "Expecting a 'feed' DOMElement."
+ );
+ $feed = $feed->getElementsByTagName('feed')->item(0);
+ }
+
$this->feed = $feed;
$pubEl = $this->_child($entry, self::PUBLISHED, self::ATOM);
diff --git a/lib/adminpanelaction.php b/lib/adminpanelaction.php
index eb622871e..d1aab3dfc 100644
--- a/lib/adminpanelaction.php
+++ b/lib/adminpanelaction.php
@@ -381,6 +381,11 @@ class AdminPanelNav extends Widget
_('Edit site notice'), $action_name == 'sitenoticeadminpanel', 'nav_sitenotice_admin_panel');
}
+ if (AdminPanelAction::canAdmin('snapshot')) {
+ $this->out->menuItem(common_local_url('snapshotadminpanel'), _('Snapshots'),
+ _('Snapshots configuration'), $action_name == 'snapshotadminpanel', 'nav_snapshot_admin_panel');
+ }
+
Event::handle('EndAdminPanelNav', array($this));
}
$this->action->elementEnd('ul');
diff --git a/lib/atom10entry.php b/lib/atom10entry.php
deleted file mode 100644
index f8f16d594..000000000
--- a/lib/atom10entry.php
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * Class for building / manipulating an Atom entry in memory
- *
- * PHP version 5
- *
- * LICENCE: This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * @category Feed
- * @package StatusNet
- * @author Zach Copley <zach@status.net>
- * @copyright 2010 StatusNet, Inc.
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
- */
-
-if (!defined('STATUSNET')) {
- exit(1);
-}
-
-class Atom10EntryException extends Exception
-{
-}
-
-/**
- * Class for manipulating an Atom entry in memory. Get the entry as an XML
- * string with Atom10Entry::getString().
- *
- * @category Feed
- * @package StatusNet
- * @author Zach Copley <zach@status.net>
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
- */
-class Atom10Entry extends XMLStringer
-{
- private $namespaces;
- private $categories;
- private $content;
- private $contributors;
- private $id;
- private $links;
- private $published;
- private $rights;
- private $source;
- private $summary;
- private $title;
-
- function __construct($indent = true) {
- parent::__construct($indent);
- $this->namespaces = array();
- }
-
- function addNamespace($namespace, $uri)
- {
- $ns = array($namespace => $uri);
- $this->namespaces = array_merge($this->namespaces, $ns);
- }
-
- function initEntry()
- {
-
- }
-
- function endEntry()
- {
-
- }
-
- /**
- * Check that all required elements have been set, etc.
- * Throws an Atom10EntryException if something's missing.
- *
- * @return void
- */
- function validate()
- {
-
- }
-
- function getString()
- {
- $this->validate();
-
- $this->initEntry();
- $this->renderEntries();
- $this->endEntry();
-
- return $this->xw->outputMemory();
- }
-
-} \ No newline at end of file
diff --git a/lib/atom10feed.php b/lib/atom10feed.php
index 8842840d5..2d342e785 100644
--- a/lib/atom10feed.php
+++ b/lib/atom10feed.php
@@ -49,6 +49,8 @@ class Atom10FeedException extends Exception
class Atom10Feed extends XMLStringer
{
public $xw;
+
+ // @fixme most of these should probably be read-only properties
private $namespaces;
private $authors;
private $subject;
@@ -57,10 +59,12 @@ class Atom10Feed extends XMLStringer
private $generator;
private $icon;
private $links;
- private $logo;
+ private $selfLink;
+ private $selfLinkType;
+ public $logo;
private $rights;
- private $subtitle;
- private $title;
+ public $subtitle;
+ public $title;
private $published;
private $updated;
private $entries;
@@ -172,6 +176,14 @@ class Atom10Feed extends XMLStringer
}
$this->elementStart('feed', $commonAttrs);
+ $this->element(
+ 'generator', array(
+ 'url' => 'http://status.net',
+ 'version' => STATUSNET_VERSION
+ ),
+ 'StatusNet'
+ );
+
$this->element('id', null, $this->id);
$this->element('title', null, $this->title);
$this->element('subtitle', null, $this->subtitle);
@@ -184,6 +196,10 @@ class Atom10Feed extends XMLStringer
$this->renderAuthors();
+ if ($this->selfLink) {
+ $this->addLink($this->selfLink, array('rel' => 'self',
+ 'type' => $this->selfLinkType));
+ }
$this->renderLinks();
}
@@ -253,6 +269,12 @@ class Atom10Feed extends XMLStringer
$this->id = $id;
}
+ function setSelfLink($url, $type='application/atom+xml')
+ {
+ $this->selfLink = $url;
+ $this->selfLinkType = $type;
+ }
+
function setTitle($title)
{
$this->title = $title;
diff --git a/lib/atomgroupnoticefeed.php b/lib/atomgroupnoticefeed.php
index 52ee4c7d6..08c1c707c 100644
--- a/lib/atomgroupnoticefeed.php
+++ b/lib/atomgroupnoticefeed.php
@@ -49,14 +49,42 @@ class AtomGroupNoticeFeed extends AtomNoticeFeed
/**
* Constructor
*
- * @param Group $group the group for the feed (optional)
+ * @param Group $group the group for the feed
* @param boolean $indent flag to turn indenting on or off
*
* @return void
*/
- function __construct($group = null, $indent = true) {
+ function __construct($group, $indent = true) {
parent::__construct($indent);
$this->group = $group;
+
+ $title = sprintf(_("%s timeline"), $group->nickname);
+ $this->setTitle($title);
+
+ $sitename = common_config('site', 'name');
+ $subtitle = sprintf(
+ _('Updates from %1$s on %2$s!'),
+ $group->nickname,
+ $sitename
+ );
+ $this->setSubtitle($subtitle);
+
+ $avatar = $group->homepage_logo;
+ $logo = ($avatar) ? $avatar : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
+ $this->setLogo($logo);
+
+ $this->setUpdated('now');
+
+ $self = common_local_url('ApiTimelineGroup',
+ array('id' => $group->id,
+ 'format' => 'atom'));
+ $this->setId($self);
+ $this->setSelfLink($self);
+
+ $this->addAuthorRaw($group->asAtomAuthor());
+ $this->setActivitySubject($group->asActivitySubject());
+
+ $this->addLink($group->homeUrl());
}
function getGroup()
diff --git a/lib/atomnoticefeed.php b/lib/atomnoticefeed.php
index 3c3556cb9..e4df731fe 100644
--- a/lib/atomnoticefeed.php
+++ b/lib/atomnoticefeed.php
@@ -107,9 +107,19 @@ class AtomNoticeFeed extends Atom10Feed
*/
function addEntryFromNotice($notice)
{
- $this->addEntryRaw($notice->asAtomEntry());
- }
+ $source = $this->showSource();
+ $author = $this->showAuthor();
-}
+ $this->addEntryRaw($notice->asAtomEntry(false, $source, $author));
+ }
+ function showSource()
+ {
+ return true;
+ }
+ function showAuthor()
+ {
+ return true;
+ }
+}
diff --git a/lib/atomusernoticefeed.php b/lib/atomusernoticefeed.php
index 2ad8de455..428cc2de2 100644
--- a/lib/atomusernoticefeed.php
+++ b/lib/atomusernoticefeed.php
@@ -49,23 +49,71 @@ class AtomUserNoticeFeed extends AtomNoticeFeed
/**
* Constructor
*
- * @param User $user the user for the feed (optional)
+ * @param User $user the user for the feed
* @param boolean $indent flag to turn indenting on or off
*
* @return void
*/
- function __construct($user = null, $indent = true) {
+ function __construct($user, $indent = true) {
parent::__construct($indent);
$this->user = $user;
if (!empty($user)) {
$profile = $user->getProfile();
$this->addAuthor($profile->nickname, $user->uri);
+ $this->setActivitySubject($profile->asActivityNoun('subject'));
}
+
+ $title = sprintf(_("%s timeline"), $user->nickname);
+ $this->setTitle($title);
+
+ $sitename = common_config('site', 'name');
+ $subtitle = sprintf(
+ _('Updates from %1$s on %2$s!'),
+ $user->nickname, $sitename
+ );
+ $this->setSubtitle($subtitle);
+
+ $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+ $logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
+ $this->setLogo($logo);
+
+ $this->setUpdated('now');
+
+ $this->addLink(
+ common_local_url(
+ 'showstream',
+ array('nickname' => $user->nickname)
+ )
+ );
+
+ $self = common_local_url('ApiTimelineUser',
+ array('id' => $user->id,
+ 'format' => 'atom'));
+ $this->setId($self);
+ $this->setSelfLink($self);
+
+ $this->addLink(
+ common_local_url('sup', null, null, $user->id),
+ array(
+ 'rel' => 'http://api.friendfeed.com/2008/03#sup',
+ 'type' => 'application/json'
+ )
+ );
}
function getUser()
{
return $this->user;
}
+
+ function showSource()
+ {
+ return false;
+ }
+
+ function showAuthor()
+ {
+ return false;
+ }
}
diff --git a/lib/grantroleform.php b/lib/grantroleform.php
new file mode 100644
index 000000000..b5f952746
--- /dev/null
+++ b/lib/grantroleform.php
@@ -0,0 +1,93 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Form for granting a role
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Form
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>, Brion Vibber <brion@status.net>
+ * @copyright 2009-2010 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+/**
+ * Form for sandboxing a user
+ *
+ * @category Form
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ *
+ * @see UnSandboxForm
+ */
+
+class GrantRoleForm extends ProfileActionForm
+{
+ function __construct($role, $label, $writer, $profile, $r2args)
+ {
+ parent::__construct($writer, $profile, $r2args);
+ $this->role = $role;
+ $this->label = $label;
+ }
+
+ /**
+ * Action this form provides
+ *
+ * @return string Name of the action, lowercased.
+ */
+
+ function target()
+ {
+ return 'grantrole';
+ }
+
+ /**
+ * Title of the form
+ *
+ * @return string Title of the form, internationalized
+ */
+
+ function title()
+ {
+ return $this->label;
+ }
+
+ function formData()
+ {
+ parent::formData();
+ $this->out->hidden('role', $this->role);
+ }
+
+ /**
+ * Description of the form
+ *
+ * @return string description of the form, internationalized
+ */
+
+ function description()
+ {
+ return sprintf(_('Grant this user the "%s" role'), $this->label);
+ }
+}
diff --git a/lib/revokeroleform.php b/lib/revokeroleform.php
new file mode 100644
index 000000000..ec24b9910
--- /dev/null
+++ b/lib/revokeroleform.php
@@ -0,0 +1,93 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Form for revoking a role
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Form
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>, Brion Vibber <brion@status.net>
+ * @copyright 2009-2010 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+/**
+ * Form for sandboxing a user
+ *
+ * @category Form
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ *
+ * @see UnSandboxForm
+ */
+
+class RevokeRoleForm extends ProfileActionForm
+{
+ function __construct($role, $label, $writer, $profile, $r2args)
+ {
+ parent::__construct($writer, $profile, $r2args);
+ $this->role = $role;
+ $this->label = $label;
+ }
+
+ /**
+ * Action this form provides
+ *
+ * @return string Name of the action, lowercased.
+ */
+
+ function target()
+ {
+ return 'revokerole';
+ }
+
+ /**
+ * Title of the form
+ *
+ * @return string Title of the form, internationalized
+ */
+
+ function title()
+ {
+ return $this->label;
+ }
+
+ function formData()
+ {
+ parent::formData();
+ $this->out->hidden('role', $this->role);
+ }
+
+ /**
+ * Description of the form
+ *
+ * @return string description of the form, internationalized
+ */
+
+ function description()
+ {
+ return sprintf(_('Revoke the "%s" role from this user'), $this->label);
+ }
+}
diff --git a/lib/right.php b/lib/right.php
index 4e9c5a918..deb451fde 100644
--- a/lib/right.php
+++ b/lib/right.php
@@ -58,5 +58,7 @@ class Right
const EMAILONSUBSCRIBE = 'emailonsubscribe';
const EMAILONFAVE = 'emailonfave';
const MAKEGROUPADMIN = 'makegroupadmin';
+ const GRANTROLE = 'grantrole';
+ const REVOKEROLE = 'revokerole';
}
diff --git a/lib/router.php b/lib/router.php
index 7e8e22a7d..706120e0b 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -98,6 +98,7 @@ class Router
'groupblock', 'groupunblock',
'sandbox', 'unsandbox',
'silence', 'unsilence',
+ 'grantrole', 'revokerole',
'repeat',
'deleteuser',
'geocode',
@@ -650,6 +651,7 @@ class Router
$m->connect('admin/paths', array('action' => 'pathsadminpanel'));
$m->connect('admin/sessions', array('action' => 'sessionsadminpanel'));
$m->connect('admin/sitenotice', array('action' => 'sitenoticeadminpanel'));
+ $m->connect('admin/snapshot', array('action' => 'snapshotadminpanel'));
$m->connect('getfile/:filename',
array('action' => 'getfile'),
diff --git a/lib/statusnet.php b/lib/statusnet.php
index 7c4df84b4..eba9ab9b8 100644
--- a/lib/statusnet.php
+++ b/lib/statusnet.php
@@ -354,10 +354,10 @@ class StatusNet
class NoConfigException extends Exception
{
- public $config_files;
+ public $configFiles;
- function __construct($msg, $config_files) {
+ function __construct($msg, $configFiles) {
parent::__construct($msg);
- $this->config_files = $config_files;
+ $this->configFiles = $configFiles;
}
}
diff --git a/lib/userprofile.php b/lib/userprofile.php
index 43dfd05be..8464c2446 100644
--- a/lib/userprofile.php
+++ b/lib/userprofile.php
@@ -346,6 +346,16 @@ class UserProfile extends Widget
$this->out->elementEnd('ul');
$this->out->elementEnd('li');
}
+
+ if ($cur->hasRight(Right::GRANTROLE)) {
+ $this->out->elementStart('li', 'entity_role');
+ $this->out->element('p', null, _('User role'));
+ $this->out->elementStart('ul');
+ $this->roleButton('administrator', _m('role', 'Administrator'));
+ $this->roleButton('moderator', _m('role', 'Moderator'));
+ $this->out->elementEnd('ul');
+ $this->out->elementEnd('li');
+ }
}
}
@@ -359,6 +369,22 @@ class UserProfile extends Widget
}
}
+ function roleButton($role, $label)
+ {
+ list($action, $r2args) = $this->out->returnToArgs();
+ $r2args['action'] = $action;
+
+ $this->out->elementStart('li', "entity_role_$role");
+ if ($this->user->hasRole($role)) {
+ $rf = new RevokeRoleForm($role, $label, $this->out, $this->profile, $r2args);
+ $rf->show();
+ } else {
+ $rf = new GrantRoleForm($role, $label, $this->out, $this->profile, $r2args);
+ $rf->show();
+ }
+ $this->out->elementEnd('li');
+ }
+
function showRemoteSubscribeLink()
{
$url = common_local_url('remotesubscribe',