summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBrenda Wallace <shiny@cpan.org>2009-12-12 22:47:12 +0000
committerBrenda Wallace <shiny@cpan.org>2009-12-12 22:47:12 +0000
commit9d3829df9d29581c1d0281e57fda8ba4452ce2c2 (patch)
treea196e99a9de45a982b76f5c4cef24b7dfc57d21b /plugins
parenta5c11cc92a277c3af6f9b18b1ffaf6dc5f90f5cc (diff)
parent438a0d7f1c23d176f380d6f5dba181ec54722b83 (diff)
Merge commit 'origin/0.9.x' into 0.9.x
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Authentication/User_username.php15
-rw-r--r--plugins/Facebook/facebookaction.php5
-rw-r--r--plugins/Gravatar/GravatarPlugin.php188
-rw-r--r--plugins/Gravatar/README13
-rw-r--r--plugins/Gravatar/locale/Gravatar.po61
-rw-r--r--plugins/Realtime/README11
6 files changed, 291 insertions, 2 deletions
diff --git a/plugins/Authentication/User_username.php b/plugins/Authentication/User_username.php
index f30f60d83..853fd5cb8 100644
--- a/plugins/Authentication/User_username.php
+++ b/plugins/Authentication/User_username.php
@@ -43,4 +43,19 @@ class User_username extends Memcached_DataObject
return false;
}
}
+
+ function table() {
+ return array(
+ 'user_id' => DB_DATAOBJECT_INT,
+ 'username' => DB_DATAOBJECT_STR,
+ 'provider_name' => DB_DATAOBJECT_STR ,
+ 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME
+ );
+ }
+
+ // now define the keys.
+ function keys() {
+ return array('provider_name', 'username');
+ }
+
}
diff --git a/plugins/Facebook/facebookaction.php b/plugins/Facebook/facebookaction.php
index 705bb2780..24bf215fd 100644
--- a/plugins/Facebook/facebookaction.php
+++ b/plugins/Facebook/facebookaction.php
@@ -445,8 +445,9 @@ class FacebookAction extends Action
$replyto = $this->trimmed('inreplyto');
try {
- $notice = Notice::saveNew($user->id, $content,
- 'web', 1, ($replyto == 'false') ? null : $replyto);
+ $notice = Notice::saveNew($user->id, $content, 'web',
+ array('reply_to' => ($replyto == 'false') ? null : $replyto));
+
} catch (Exception $e) {
$this->showPage($e->getMessage());
return;
diff --git a/plugins/Gravatar/GravatarPlugin.php b/plugins/Gravatar/GravatarPlugin.php
new file mode 100644
index 000000000..3c61a682e
--- /dev/null
+++ b/plugins/Gravatar/GravatarPlugin.php
@@ -0,0 +1,188 @@
+<?php
+/*
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2009, StatusNet, Inc.
+ *
+ * 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/>.
+ */
+
+/**
+ * @package GravatarPlugin
+ * @maintainer Eric Helgeson <erichelgeson@gmail.com>
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ // This check helps protect against security problems;
+ // your code file can't be executed directly from the web.
+ exit(1);
+}
+
+class GravatarPlugin extends Plugin
+{
+ function onInitializePlugin() {
+ return true;
+ }
+
+ function onStartAvatarFormData($action) {
+ $user = common_current_user();
+ $hasGravatar = $this->hasGravatar($user->id);
+
+ if($hasGravatar) {
+ return false;
+ }
+ }
+
+ function onEndAvatarFormData(&$action) {
+ $user = common_current_user();
+ $hasGravatar = $this->hasGravatar($user->id);
+
+ if(!empty($user->email) && !$hasGravatar) { //and not gravatar already set
+ $action->elementStart('form', array('method' => 'post',
+ 'id' => 'form_settings_gravatar_add',
+ 'class' => 'form_settings',
+ 'action' =>
+ common_local_url('avatarsettings')));
+ $action->elementStart('fieldset', array('id' => 'settings_gravatar_add'));
+ $action->element('legend', null, _m('Set Gravatar'));
+ $action->hidden('token', common_session_token());
+ $action->element('p', 'form_guide',
+ _m('If you want to use your Gravatar image, click "Add".'));
+ $action->element('input', array('type' => 'submit',
+ 'id' => 'settings_gravatar_add_action-submit',
+ 'name' => 'add',
+ 'class' => 'submit',
+ 'value' => _m('Add')));
+ $action->elementEnd('fieldset');
+ $action->elementEnd('form');
+ } elseif($hasGravatar) {
+ $action->elementStart('form', array('method' => 'post',
+ 'id' => 'form_settings_gravatar_remove',
+ 'class' => 'form_settings',
+ 'action' =>
+ common_local_url('avatarsettings')));
+ $action->elementStart('fieldset', array('id' => 'settings_gravatar_remove'));
+ $action->element('legend', null, _m('Remove Gravatar'));
+ $action->hidden('token', common_session_token());
+ $action->element('p', 'form_guide',
+ _m('If you want to remove your Gravatar image, click "Remove".'));
+ $action->element('input', array('type' => 'submit',
+ 'id' => 'settings_gravatar_remove_action-submit',
+ 'name' => 'remove',
+ 'class' => 'submit',
+ 'value' => _m('Remove')));
+ $action->elementEnd('fieldset');
+ $action->elementEnd('form');
+ } else {
+ $action->element('p', 'form_guide',
+ _m('To use a Gravatar first enter in an email address.'));
+ }
+ }
+
+ function onStartAvatarSaveForm($action) {
+ if ($action->arg('add')) {
+ $result = $this->gravatar_save();
+
+ if($result['success']===true) {
+ common_broadcast_profile(common_current_user()->getProfile());
+ }
+
+ $action->showForm($result['message'], $result['success']);
+
+ return false;
+ } else if ($action->arg('remove')) {
+ $result = $this->gravatar_remove();
+
+ if($result['success']===true) {
+ common_broadcast_profile(common_current_user()->getProfile());
+ }
+
+ $action->showForm($result['message'], $result['success']);
+
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ function hasGravatar($id) {
+ $avatar = new Avatar();
+ $avatar->profile_id = $id;
+ if ($avatar->find()) {
+ while ($avatar->fetch()) {
+ if($avatar->filename == null) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
+ function gravatar_save()
+ {
+ $cur = common_current_user();
+
+ if(empty($cur->email)) {
+ return array('message' => _m('You do not have a email set in your profile.'),
+ 'success' => false);
+ }
+ //Get rid of previous Avatar
+ $this->gravatar_remove();
+
+ foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
+ $gravatar = new Avatar();
+ $gravatar->profile_id = $cur->id;
+ $gravatar->width = $size;
+ $gravatar->height = $size;
+ $gravatar->original = false; //No file, so no original
+ $gravatar->mediatype = 'img';//XXX: Unsure what to put here
+ //$gravatar->filename = null;//No filename. Remote
+ $gravatar->url = $this->gravatar_url($cur->email, $size);
+ $gravatar->created = DB_DataObject_Cast::dateTime(); # current time
+
+ if (!$gravatar->insert()) {
+ return array('message' => _m('Failed to save Gravatar to the DB.'),
+ 'success' => false);
+ }
+ }
+ return array('message' => _m('Gravatar added.'),
+ 'success' => true);
+ }
+
+ function gravatar_remove()
+ {
+ $user = common_current_user();
+ $profile = $user->getProfile();
+
+ $avatar = $profile->getOriginalAvatar();
+ if($avatar) $avatar->delete();
+ $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+ if($avatar) $avatar->delete();
+ $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
+ if($avatar) $avatar->delete();
+ $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
+ if($avatar) $avatar->delete();
+
+ return array('message' => _m('Gravatar removed.'),
+ 'success' => true);
+ }
+
+ function gravatar_url($email, $size) {
+ $url = "http://www.gravatar.com/avatar.php?gravatar_id=".
+ md5(strtolower($email)).
+ "&default=".urlencode(Avatar::defaultImage($size)).
+ "&size=".$size;
+ return $url;
+ }
+}
diff --git a/plugins/Gravatar/README b/plugins/Gravatar/README
new file mode 100644
index 000000000..9337e24a0
--- /dev/null
+++ b/plugins/Gravatar/README
@@ -0,0 +1,13 @@
+GravatarPlugin 0.1
+
+About
+This will allow users to use their Gravatar Avatar with your StatusNet install.
+
+Configuration
+add this to your config.php:
+addPlugin('Gravatar', array());
+
+ToDo:
+Site default all on for gravatar by default
+Migration Script
+Localize \ No newline at end of file
diff --git a/plugins/Gravatar/locale/Gravatar.po b/plugins/Gravatar/locale/Gravatar.po
new file mode 100644
index 000000000..1df62b666
--- /dev/null
+++ b/plugins/Gravatar/locale/Gravatar.po
@@ -0,0 +1,61 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-12-11 16:27-0800\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: GravatarPlugin.php:57
+msgid "Set Gravatar"
+msgstr ""
+
+#: GravatarPlugin.php:60
+msgid "If you want to use your Gravatar image, click \"Add\"."
+msgstr ""
+
+#: GravatarPlugin.php:65
+msgid "Add"
+msgstr ""
+
+#: GravatarPlugin.php:75
+msgid "Remove Gravatar"
+msgstr ""
+
+#: GravatarPlugin.php:78
+msgid "If you want to remove your Gravatar image, click \"Remove\"."
+msgstr ""
+
+#: GravatarPlugin.php:83
+msgid "Remove"
+msgstr ""
+
+#: GravatarPlugin.php:88
+msgid "To use a Gravatar first enter in an email address."
+msgstr ""
+
+#: GravatarPlugin.php:137
+msgid "You do not have a email set in your profile."
+msgstr ""
+
+#: GravatarPlugin.php:155
+msgid "Failed to save Gravatar to the DB."
+msgstr ""
+
+#: GravatarPlugin.php:159
+msgid "Gravatar added."
+msgstr ""
+
+#: GravatarPlugin.php:177
+msgid "Gravatar removed."
+msgstr ""
diff --git a/plugins/Realtime/README b/plugins/Realtime/README
new file mode 100644
index 000000000..524382696
--- /dev/null
+++ b/plugins/Realtime/README
@@ -0,0 +1,11 @@
+== TODO ==
+* i18n
+* Change in context URL to conversation (try not to construct the URL in JS)
+* Update mark behaviour (on notice send)
+* Pause, Send a notice ~ should not update counter
+* Pause ~ retain up to 50-100 most recent notices
+* Add geo data
+* Make it work for Conversation page (perhaps a little tricky)
+* IE is updating the counter in document title all the time (Not sure if this is still an issue)
+* Reconsider the timestamp approach
+