summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Auth/AuthPlugin.php172
-rw-r--r--plugins/Authentication/AuthenticationPlugin.php226
-rw-r--r--plugins/Authentication/User_username.php46
-rw-r--r--plugins/BitlyUrl/BitlyUrlPlugin.php31
-rw-r--r--plugins/EmailAuthentication/EmailAuthenticationPlugin.php54
-rw-r--r--plugins/EmailAuthentication/README7
-rw-r--r--plugins/Facebook/facebookaction.php4
-rw-r--r--plugins/Facebook/facebookhome.php4
-rw-r--r--plugins/InfiniteScroll/infinitescroll.js12
-rw-r--r--plugins/LdapAuthentication/LdapAuthenticationPlugin.php (renamed from plugins/Ldap/LdapPlugin.php)73
-rw-r--r--plugins/LdapAuthentication/README (renamed from plugins/Ldap/README)13
-rw-r--r--plugins/LilUrl/LilUrlPlugin.php38
-rw-r--r--plugins/OpenID/OpenIDPlugin.php1
-rw-r--r--plugins/OpenID/openid.php5
-rw-r--r--plugins/PtitUrl/PtitUrlPlugin.php31
-rw-r--r--plugins/Realtime/realtimeupdate.js28
-rw-r--r--plugins/ReverseUsernameAuthentication/README26
-rw-r--r--plugins/ReverseUsernameAuthentication/ReverseUsernameAuthenticationPlugin.php58
-rw-r--r--plugins/SimpleUrl/SimpleUrlPlugin.php41
-rw-r--r--plugins/TightUrl/TightUrlPlugin.php31
-rw-r--r--plugins/UrlShortener/UrlShortenerPlugin.php103
-rw-r--r--plugins/UserFlag/UserFlagPlugin.php8
-rw-r--r--plugins/UserFlag/flagprofile.php16
-rw-r--r--plugins/UserFlag/flagprofileform.php2
24 files changed, 675 insertions, 355 deletions
diff --git a/plugins/Auth/AuthPlugin.php b/plugins/Auth/AuthPlugin.php
deleted file mode 100644
index cb52730f6..000000000
--- a/plugins/Auth/AuthPlugin.php
+++ /dev/null
@@ -1,172 +0,0 @@
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * Superclass for plugins that do authentication and/or authorization
- *
- * 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 Plugin
- * @package StatusNet
- * @author Craig Andrews <candrews@integralblue.com>
- * @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') && !defined('LACONICA')) {
- exit(1);
-}
-
-/**
- * Superclass for plugins that do authentication
- *
- * @category Plugin
- * @package StatusNet
- * @author Craig Andrews <candrews@integralblue.com>
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://status.net/
- */
-
-abstract class AuthPlugin extends Plugin
-{
- //is this plugin authoritative for authentication?
- public $authn_authoritative = false;
-
- //should accounts be automatically created after a successful login attempt?
- public $autoregistration = false;
-
- //can the user change their email address
- public $email_changeable=true;
-
- //can the user change their email address
- public $password_changeable=true;
-
- //------------Auth plugin should implement some (or all) of these methods------------\\
- /**
- * Check if a nickname/password combination is valid
- * @param nickname
- * @param password
- * @return boolean true if the credentials are valid, false if they are invalid.
- */
- function checkPassword($nickname, $password)
- {
- return false;
- }
-
- /**
- * Automatically register a user when they attempt to login with valid credentials.
- * User::register($data) is a very useful method for this implementation
- * @param nickname
- * @return boolean true if the user was created, false if autoregistration is not allowed, null if this plugin is not responsible for this nickname
- */
- function autoRegister($nickname)
- {
- return null;
- }
-
- /**
- * Change a user's password
- * The old password has been verified to be valid by this plugin before this call is made
- * @param nickname
- * @param oldpassword
- * @param newpassword
- * @return boolean true if the password was changed, false if password changing failed for some reason, null if this plugin is not responsible for this nickname
- */
- function changePassword($nickname,$oldpassword,$newpassword)
- {
- return null;
- }
-
- /**
- * Can a user change this field in his own profile?
- * @param nickname
- * @param field
- * @return boolean true if the field can be changed, false if not allowed to change it, null if this plugin is not responsible for this nickname
- */
- function canUserChangeField($nickname, $field)
- {
- return null;
- }
-
- //------------Below are the methods that connect StatusNet to the implementing Auth plugin------------\\
- function __construct()
- {
- parent::__construct();
- }
-
- function StartCheckPassword($nickname, $password, &$authenticatedUser){
- if($this->password_changeable){
- $authenticated = $this->checkPassword($nickname, $password);
- if($authenticated){
- $authenticatedUser = User::staticGet('nickname', $nickname);
- if(!$authenticatedUser && $this->autoregistration){
- if($this->autoregister($nickname)){
- $authenticatedUser = User::staticGet('nickname', $nickname);
- }
- }
- return false;
- }else{
- if($this->authn_authoritative){
- return false;
- }
- }
- //we're not authoritative, so let other handlers try
- }else{
- if($this->authn_authoritative){
- //since we're authoritative, no other plugin could do this
- throw new Exception(_('Password changing is not allowed'));
- }
- }
- }
-
- function onStartChangePassword($nickname,$oldpassword,$newpassword)
- {
- if($this->password_changeable){
- $authenticated = $this->checkPassword($nickname, $oldpassword);
- if($authenticated){
- $result = $this->changePassword($nickname,$oldpassword,$newpassword);
- if($result){
- //stop handling of other handlers, because what was requested was done
- return false;
- }else{
- throw new Exception(_('Password changing failed'));
- }
- }else{
- if($this->authn_authoritative){
- //since we're authoritative, no other plugin could do this
- throw new Exception(_('Password changing failed'));
- }else{
- //let another handler try
- return null;
- }
- }
- }else{
- if($this->authn_authoritative){
- //since we're authoritative, no other plugin could do this
- throw new Exception(_('Password changing is not allowed'));
- }
- }
- }
-
- function onStartAccountSettingsPasswordMenuItem($widget)
- {
- if($this->authn_authoritative && !$this->password_changeable){
- //since we're authoritative, no other plugin could change passwords, so do render the menu item
- return false;
- }
- }
-}
-
diff --git a/plugins/Authentication/AuthenticationPlugin.php b/plugins/Authentication/AuthenticationPlugin.php
new file mode 100644
index 000000000..a76848b04
--- /dev/null
+++ b/plugins/Authentication/AuthenticationPlugin.php
@@ -0,0 +1,226 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Superclass for plugins that do authentication and/or authorization
+ *
+ * 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 Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @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') && !defined('LACONICA')) {
+ exit(1);
+}
+
+/**
+ * Superclass for plugins that do authentication
+ *
+ * @category Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+abstract class AuthenticationPlugin extends Plugin
+{
+ //is this plugin authoritative for authentication?
+ public $authoritative = false;
+
+ //should accounts be automatically created after a successful login attempt?
+ public $autoregistration = false;
+
+ //can the user change their email address
+ public $password_changeable=true;
+
+ //unique name for this authentication provider
+ public $provider_name;
+
+ //------------Auth plugin should implement some (or all) of these methods------------\\
+ /**
+ * Check if a nickname/password combination is valid
+ * @param username
+ * @param password
+ * @return boolean true if the credentials are valid, false if they are invalid.
+ */
+ function checkPassword($username, $password)
+ {
+ return false;
+ }
+
+ /**
+ * Automatically register a user when they attempt to login with valid credentials.
+ * User::register($data) is a very useful method for this implementation
+ * @param username
+ * @return mixed instance of User, or false (if user couldn't be created)
+ */
+ function autoRegister($username)
+ {
+ $registration_data = array();
+ $registration_data['nickname'] = $username ;
+ return User::register($registration_data);
+ }
+
+ /**
+ * Change a user's password
+ * The old password has been verified to be valid by this plugin before this call is made
+ * @param username
+ * @param oldpassword
+ * @param newpassword
+ * @return boolean true if the password was changed, false if password changing failed for some reason
+ */
+ function changePassword($username,$oldpassword,$newpassword)
+ {
+ return false;
+ }
+
+ //------------Below are the methods that connect StatusNet to the implementing Auth plugin------------\\
+ function onInitializePlugin(){
+ if(!isset($this->provider_name)){
+ throw new Exception("must specify a provider_name for this authentication provider");
+ }
+ }
+
+ function onStartCheckPassword($nickname, $password, &$authenticatedUser){
+ //map the nickname to a username
+ $user_username = new User_username();
+ $user_username->username=$nickname;
+ $user_username->provider_name=$this->provider_name;
+ if($user_username->find() && $user_username->fetch()){
+ $username = $user_username->username;
+ $authenticated = $this->checkPassword($username, $password);
+ if($authenticated){
+ $authenticatedUser = User::staticGet('id', $user_username->user_id);
+ return false;
+ }
+ }else{
+ $user = User::staticGet('nickname', $nickname);
+ if($user){
+ //make sure a different provider isn't handling this nickname
+ $user_username = new User_username();
+ $user_username->username=$nickname;
+ if(!$user_username->find()){
+ //no other provider claims this username, so it's safe for us to handle it
+ $authenticated = $this->checkPassword($nickname, $password);
+ if($authenticated){
+ $authenticatedUser = User::staticGet('nickname', $nickname);
+ User_username::register($authenticatedUser,$nickname,$this->provider_name);
+ return false;
+ }
+ }
+ }else{
+ if($this->autoregistration){
+ $authenticated = $this->checkPassword($nickname, $password);
+ if($authenticated){
+ $user = $this->autoregister($nickname);
+ if($user){
+ $authenticatedUser = $user;
+ User_username::register($authenticatedUser,$nickname,$this->provider_name);
+ return false;
+ }
+ }
+ }
+ }
+ }
+ if($this->authoritative){
+ return false;
+ }else{
+ //we're not authoritative, so let other handlers try
+ return;
+ }
+ }
+
+ function onStartChangePassword($user,$oldpassword,$newpassword)
+ {
+ if($this->password_changeable){
+ $user_username = new User_username();
+ $user_username->user_id=$user->id;
+ $user_username->provider_name=$this->provider_name;
+ if($user_username->find() && $user_username->fetch()){
+ $authenticated = $this->checkPassword($user_username->username, $oldpassword);
+ if($authenticated){
+ $result = $this->changePassword($user_username->username,$oldpassword,$newpassword);
+ if($result){
+ //stop handling of other handlers, because what was requested was done
+ return false;
+ }else{
+ throw new Exception(_('Password changing failed'));
+ }
+ }else{
+ if($this->authoritative){
+ //since we're authoritative, no other plugin could do this
+ throw new Exception(_('Password changing failed'));
+ }else{
+ //let another handler try
+ return null;
+ }
+ }
+ }
+ }else{
+ if($this->authoritative){
+ //since we're authoritative, no other plugin could do this
+ throw new Exception(_('Password changing is not allowed'));
+ }
+ }
+ }
+
+ function onStartAccountSettingsPasswordMenuItem($widget)
+ {
+ if($this->authoritative && !$this->password_changeable){
+ //since we're authoritative, no other plugin could change passwords, so do not render the menu item
+ return false;
+ }
+ }
+
+ function onAutoload($cls)
+ {
+ switch ($cls)
+ {
+ case 'User_username':
+ require_once(INSTALLDIR.'/plugins/Authentication/User_username.php');
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ function onCheckSchema() {
+ $schema = Schema::get();
+ $schema->ensureTable('user_username',
+ array(new ColumnDef('provider_name', 'varchar',
+ '255', false, 'PRI'),
+ new ColumnDef('username', 'varchar',
+ '255', false, 'PRI'),
+ new ColumnDef('user_id', 'integer',
+ null, false),
+ new ColumnDef('created', 'datetime',
+ null, false),
+ new ColumnDef('modified', 'timestamp')));
+ return true;
+ }
+
+ function onUserDeleteRelated($user, &$tables)
+ {
+ $tables[] = 'User_username';
+ return true;
+ }
+}
+
diff --git a/plugins/Authentication/User_username.php b/plugins/Authentication/User_username.php
new file mode 100644
index 000000000..f30f60d83
--- /dev/null
+++ b/plugins/Authentication/User_username.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Table Definition for user_username
+ */
+require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
+
+class User_username extends Memcached_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'user_username'; // table name
+ public $user_id; // int(4) not_null
+ public $provider_name; // varchar(255) primary_key not_null
+ public $username; // varchar(255) primary_key not_null
+ 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_username',$k,$v); }
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+
+ /**
+ * Register a user with a username on a given provider
+ * @param User User object
+ * @param string username on the given provider
+ * @param provider_name string name of the provider
+ * @return mixed User_username instance if the registration succeeded, false if it did not
+ */
+ static function register($user, $username, $provider_name)
+ {
+ $user_username = new User_username();
+ $user_username->user_id = $user->id;
+ $user_username->provider_name = $provider_name;
+ $user_username->username = $username;
+ $user_username->created = DB_DataObject_Cast::dateTime();
+ if($user_username->insert()){
+ return $user_username;
+ }else{
+ return false;
+ }
+ }
+}
diff --git a/plugins/BitlyUrl/BitlyUrlPlugin.php b/plugins/BitlyUrl/BitlyUrlPlugin.php
index 478ef99d2..65d0f70e6 100644
--- a/plugins/BitlyUrl/BitlyUrlPlugin.php
+++ b/plugins/BitlyUrl/BitlyUrlPlugin.php
@@ -31,31 +31,24 @@ if (!defined('STATUSNET')) {
exit(1);
}
-class BitlyUrlPlugin extends Plugin
+require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php';
+
+class BitlyUrlPlugin extends UrlShortenerPlugin
{
- function __construct()
- {
- parent::__construct();
- }
+ public $serviceUrl;
function onInitializePlugin(){
- $this->registerUrlShortener(
- 'bit.ly',
- array(),
- array('BitlyUrl',array('http://bit.ly/api?method=shorten&long_url='))
- );
+ parent::onInitializePlugin();
+ if(!isset($this->serviceUrl)){
+ throw new Exception("must specify a serviceUrl");
+ }
}
-}
-class BitlyUrl extends ShortUrlApi
-{
- protected function shorten_imp($url) {
+ protected function shorten($url) {
$response = $this->http_get($url);
- if(!$response){
- return $url;
- }else{
- return current(json_decode($response)->results)->hashUrl;
- }
+ if(!$response) return;
+ return current(json_decode($response)->results)->hashUrl;
}
}
+
diff --git a/plugins/EmailAuthentication/EmailAuthenticationPlugin.php b/plugins/EmailAuthentication/EmailAuthenticationPlugin.php
new file mode 100644
index 000000000..25e537735
--- /dev/null
+++ b/plugins/EmailAuthentication/EmailAuthenticationPlugin.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin that uses the email address as a username, and checks the password as normal
+ *
+ * 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 Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Craig Andrews http://candrews.integralblue.com
+ * @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') && !defined('LACONICA')) {
+ exit(1);
+}
+
+class EmailAuthenticationPlugin extends Plugin
+{
+ //---interface implementation---//
+
+ function onStartCheckPassword($nickname, $password, &$authenticatedUser)
+ {
+ if(strpos($nickname, '@'))
+ {
+ $user = User::staticGet('email',$nickname);
+ if($user && isset($user->email))
+ {
+ if(common_check_user($user->nickname,$password))
+ {
+ $authenticatedUser = $user;
+ return false;
+ }
+ }
+ }
+ }
+}
+
diff --git a/plugins/EmailAuthentication/README b/plugins/EmailAuthentication/README
new file mode 100644
index 000000000..320815689
--- /dev/null
+++ b/plugins/EmailAuthentication/README
@@ -0,0 +1,7 @@
+The Email Authentication plugin allows users to login using their email address.
+
+The provided email address is used to lookup the user's nickname, then that nickname and the provided password is checked.
+
+Installation
+============
+add "addPlugin('emailAuthentication');" to the bottom of your config.php
diff --git a/plugins/Facebook/facebookaction.php b/plugins/Facebook/facebookaction.php
index a10fdf90d..c852bbf5e 100644
--- a/plugins/Facebook/facebookaction.php
+++ b/plugins/Facebook/facebookaction.php
@@ -382,8 +382,7 @@ class FacebookAction extends Action
{
// Does a little before-after block for next/prev page
if ($have_before || $have_after) {
- $this->elementStart('div', array('class' => 'pagination'));
- $this->elementStart('dl', null);
+ $this->elementStart('dl', 'pagination');
$this->element('dt', null, _('Pagination'));
$this->elementStart('dd', null);
$this->elementStart('ul', array('class' => 'nav'));
@@ -408,7 +407,6 @@ class FacebookAction extends Action
$this->elementEnd('ul');
$this->elementEnd('dd');
$this->elementEnd('dl');
- $this->elementEnd('div');
}
}
diff --git a/plugins/Facebook/facebookhome.php b/plugins/Facebook/facebookhome.php
index 91c0cc6b8..ea141c2c2 100644
--- a/plugins/Facebook/facebookhome.php
+++ b/plugins/Facebook/facebookhome.php
@@ -244,8 +244,7 @@ class FacebookhomeAction extends FacebookAction
// XXX: Fix so this uses common_local_url() if possible.
if ($have_before || $have_after) {
- $this->elementStart('div', array('class' => 'pagination'));
- $this->elementStart('dl', null);
+ $this->elementStart('dl', 'pagination');
$this->element('dt', null, _('Pagination'));
$this->elementStart('dd', null);
$this->elementStart('ul', array('class' => 'nav'));
@@ -270,7 +269,6 @@ class FacebookhomeAction extends FacebookAction
$this->elementEnd('ul');
$this->elementEnd('dd');
$this->elementEnd('dl');
- $this->elementEnd('div');
}
}
diff --git a/plugins/InfiniteScroll/infinitescroll.js b/plugins/InfiniteScroll/infinitescroll.js
index ae4d53d09..0dafef6d5 100644
--- a/plugins/InfiniteScroll/infinitescroll.js
+++ b/plugins/InfiniteScroll/infinitescroll.js
@@ -2,14 +2,20 @@ jQuery(document).ready(function($){
$('notices_primary').infinitescroll({
debug: true,
infiniteScroll : false,
- nextSelector : "li.nav_next a",
+ nextSelector : 'body#public li.nav_next a,'+
+ 'body#all li.nav_next a,'+
+ 'body#showstream li.nav_next a,'+
+ 'body#replies li.nav_next a,'+
+ 'body#showfavorites li.nav_next a,'+
+ 'body#showgroup li.nav_next a,'+
+ 'body#favorited li.nav_next a',
loadingImg : $('address .url')[0].href+'plugins/InfiniteScroll/ajax-loader.gif',
text : "<em>Loading the next set of posts...</em>",
donetext : "<em>Congratulations, you\'ve reached the end of the Internet.</em>",
- navSelector : "div.pagination",
+ navSelector : ".pagination",
contentSelector : "#notices_primary ol.notices",
itemSelector : "#notices_primary ol.notices li"
},function(){
- NoticeAttachments();
+ SN.Init.Notices();
});
});
diff --git a/plugins/Ldap/LdapPlugin.php b/plugins/LdapAuthentication/LdapAuthenticationPlugin.php
index 88ca92b37..865154730 100644
--- a/plugins/Ldap/LdapPlugin.php
+++ b/plugins/LdapAuthentication/LdapAuthenticationPlugin.php
@@ -31,10 +31,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
exit(1);
}
-require_once INSTALLDIR.'/plugins/Auth/AuthPlugin.php';
+require_once INSTALLDIR.'/plugins/Authentication/AuthenticationPlugin.php';
require_once 'Net/LDAP2.php';
-class LdapPlugin extends AuthPlugin
+class LdapAuthenticationPlugin extends AuthenticationPlugin
{
public $host=null;
public $port=null;
@@ -48,20 +48,31 @@ class LdapPlugin extends AuthPlugin
public $scope=null;
public $attributes=array();
- function __construct()
- {
- parent::__construct();
+ function onInitializePlugin(){
+ parent::onInitializePlugin();
+ if(!isset($this->host)){
+ throw new Exception("must specify a host");
+ }
+ if(!isset($this->basedn)){
+ throw new Exception("must specify a basedn");
+ }
+ if(!isset($this->attributes['nickname'])){
+ throw new Exception("must specify a nickname attribute");
+ }
+ if(!isset($this->attributes['username'])){
+ throw new Exception("must specify a username attribute");
+ }
}
//---interface implementation---//
- function checkPassword($nickname, $password)
+ function checkPassword($username, $password)
{
$ldap = $this->ldap_get_connection();
if(!$ldap){
return false;
}
- $entry = $this->ldap_get_user($nickname);
+ $entry = $this->ldap_get_user($username);
if(!$entry){
return false;
}else{
@@ -76,59 +87,33 @@ class LdapPlugin extends AuthPlugin
}
}
- function autoRegister($nickname)
+ function autoRegister($username)
{
- $attributes=array();
- $config_attributes = array('nickname','email','fullname','homepage','location');
- foreach($config_attributes as $config_attribute){
- $value = common_config('ldap', $config_attribute.'_attribute');
- if($value!==false){
- array_push($attributes,$value);
- }
- }
- $entry = $this->ldap_get_user($nickname,$attributes);
+ $entry = $this->ldap_get_user($username,$this->attributes);
if($entry){
$registration_data = array();
- foreach($config_attributes as $config_attribute){
- $value = common_config('ldap', $config_attribute.'_attribute');
- if($value!==false){
- if($config_attribute=='email'){
- $registration_data[$config_attribute]=common_canonical_email($entry->getValue($value,'single'));
- }else if($config_attribute=='nickname'){
- $registration_data[$config_attribute]=common_canonical_nickname($entry->getValue($value,'single'));
- }else{
- $registration_data[$config_attribute]=$entry->getValue($value,'single');
- }
- }
+ foreach($this->attributes as $sn_attribute=>$ldap_attribute){
+ $registration_data[$sn_attribute]=$entry->getValue($ldap_attribute,'single');
+ }
+ if(isset($registration_data['email']) && !empty($registration_data['email'])){
+ $registration_data['email_confirmed']=true;
}
//set the database saved password to a random string.
$registration_data['password']=common_good_rand(16);
- $user = User::register($registration_data);
- return true;
+ return User::register($registration_data);
}else{
//user isn't in ldap, so we cannot register him
- return null;
+ return false;
}
}
- function changePassword($nickname,$oldpassword,$newpassword)
+ function changePassword($username,$oldpassword,$newpassword)
{
//TODO implement this
throw new Exception(_('Sorry, changing LDAP passwords is not supported at this time'));
return false;
}
-
- function canUserChangeField($nickname, $field)
- {
- switch($field)
- {
- case 'password':
- case 'nickname':
- case 'email':
- return false;
- }
- }
//---utility functions---//
function ldap_get_config(){
@@ -170,7 +155,7 @@ class LdapPlugin extends AuthPlugin
*/
function ldap_get_user($username,$attributes=array()){
$ldap = $this->ldap_get_connection();
- $filter = Net_LDAP2_Filter::create(common_config('ldap','nickname_attribute'), 'equals', $username);
+ $filter = Net_LDAP2_Filter::create($this->attributes['username'], 'equals', $username);
$options = array(
'scope' => 'sub',
'attributes' => $attributes
diff --git a/plugins/Ldap/README b/plugins/LdapAuthentication/README
index 063286cef..b10a1eb93 100644
--- a/plugins/Ldap/README
+++ b/plugins/LdapAuthentication/README
@@ -1,12 +1,13 @@
-The LDAP plugin allows for StatusNet to handle authentication, authorization, and user information through LDAP.
+The LDAP Authentication plugin allows for StatusNet to handle authentication through LDAP.
Installation
============
-add "addPlugin('ldap', array('setting'=>'value', 'setting2'=>'value2', ...);" to the bottom of your config.php
+add "addPlugin('ldapAuthentication', array('setting'=>'value', 'setting2'=>'value2', ...);" to the bottom of your config.php
Settings
========
-authn_authoritative (false): Set to true if LDAP's responses are authoritative (meaning if LDAP fails, do check the any other plugins or the internal password database).
+provider_name*: a unique name for this authentication provider.
+authoritative (false): Set to true if LDAP's responses are authoritative (meaning if LDAP fails, do check any other plugins or the internal password database).
autoregistration (false): Set to true if users should be automatically created when they attempt to login.
email_changeable (true): Are users allowed to change their email address? (true or false)
password_changeable (true): Are users allowed to change their passwords? (true or false)
@@ -23,6 +24,7 @@ filter: Default search filter. See http://pear.php.net/manual/en/package.network
scope: Default search scope. See http://pear.php.net/manual/en/package.networking.net-ldap2.connecting.php
attributes: an array with the key being the StatusNet user attribute name, and the value the LDAP attribute name
+ username*
nickname*
email
fullname
@@ -36,8 +38,9 @@ Example
=======
Here's an example of an LDAP plugin configuration that connects to Microsoft Active Directory.
-addPlugin('ldap', array(
- 'authn_authoritative'=>true,
+addPlugin('ldapAuthentication', array(
+ 'provider_name'=>'Example',
+ 'authoritative'=>true,
'autoregistration'=>true,
'binddn'=>'username',
'bindpw'=>'password',
diff --git a/plugins/LilUrl/LilUrlPlugin.php b/plugins/LilUrl/LilUrlPlugin.php
index 852253b02..e906751e8 100644
--- a/plugins/LilUrl/LilUrlPlugin.php
+++ b/plugins/LilUrl/LilUrlPlugin.php
@@ -31,37 +31,31 @@ if (!defined('STATUSNET')) {
exit(1);
}
-require_once(INSTALLDIR.'/lib/Shorturl_api.php');
+require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php';
-class LilUrlPlugin extends Plugin
+class LilUrlPlugin extends UrlShortenerPlugin
{
- function __construct()
- {
- parent::__construct();
- }
+ public $serviceUrl;
function onInitializePlugin(){
- $this->registerUrlShortener(
- 'ur1.ca',
- array('freeService'=>true),
- array('LilUrl',array('http://ur1.ca/'))
- );
+ parent::onInitializePlugin();
+ if(!isset($this->serviceUrl)){
+ throw new Exception("must specify a serviceUrl");
+ }
}
-}
-class LilUrl extends ShortUrlApi
-{
- protected function shorten_imp($url) {
- $data['longurl'] = $url;
- $response = $this->http_post($data);
- if (!$response) return $url;
- $y = @simplexml_load_string($response);
- if (!isset($y->body)) return $url;
+ protected function shorten($url) {
+ $data = array('longurl' => $url);
+
+ $responseBody = $this->http_post($this->serviceUrl,$data);
+
+ if (!$responseBody) return;
+ $y = @simplexml_load_string($responseBody);
+ if (!isset($y->body)) return;
$x = $y->body->p[0]->a->attributes();
if (isset($x['href'])) {
- common_log(LOG_INFO, __CLASS__ . ": shortened $url to $x[href]");
return $x['href'];
}
- return $url;
}
}
+
diff --git a/plugins/OpenID/OpenIDPlugin.php b/plugins/OpenID/OpenIDPlugin.php
index e4aed2ddb..55c0eadaf 100644
--- a/plugins/OpenID/OpenIDPlugin.php
+++ b/plugins/OpenID/OpenIDPlugin.php
@@ -302,6 +302,7 @@ class OpenIDPlugin extends Plugin
function onUserDeleteRelated($user, &$tables)
{
$tables[] = 'User_openid';
+ $tables[] = 'User_openid_trustroot';
return true;
}
}
diff --git a/plugins/OpenID/openid.php b/plugins/OpenID/openid.php
index ff7a93899..dd628e773 100644
--- a/plugins/OpenID/openid.php
+++ b/plugins/OpenID/openid.php
@@ -280,6 +280,11 @@ class AutosubmitAction extends Action
function showContent()
{
$this->raw($this->form_html);
+ }
+
+ function showScripts()
+ {
+ parent::showScripts();
$this->element('script', null,
'$(document).ready(function() { ' .
' $(\'#'. $this->form_id .'\').submit(); '.
diff --git a/plugins/PtitUrl/PtitUrlPlugin.php b/plugins/PtitUrl/PtitUrlPlugin.php
index f00d3e2f2..ef453e96d 100644
--- a/plugins/PtitUrl/PtitUrlPlugin.php
+++ b/plugins/PtitUrl/PtitUrlPlugin.php
@@ -30,33 +30,28 @@
if (!defined('STATUSNET')) {
exit(1);
}
+require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php';
-class PtitUrlPlugin extends Plugin
+class PtitUrlPlugin extends UrlShortenerPlugin
{
- function __construct()
- {
- parent::__construct();
- }
+ public $serviceUrl;
function onInitializePlugin(){
- $this->registerUrlShortener(
- 'ptiturl.com',
- array(),
- array('PtitUrl',array('http://ptiturl.com/?creer=oui&action=Reduire&url='))
- );
+ parent::onInitializePlugin();
+ if(!isset($this->serviceUrl)){
+ throw new Exception("must specify a serviceUrl");
+ }
}
-}
-class PtitUrl extends ShortUrlApi
-{
- protected function shorten_imp($url) {
- $response = $this->http_get($url);
- if (!$response) return $url;
+ protected function shorten($url)
+ {
+ $response = $this->http_get(sprintf($this->serviceUrl,urlencode($url)));
+ if (!$response) return;
$response = $this->tidy($response);
$y = @simplexml_load_string($response);
- if (!isset($y->body)) return $url;
+ if (!isset($y->body)) return;
$xml = $y->body->center->table->tr->td->pre->a->attributes();
if (isset($xml['href'])) return $xml['href'];
- return $url;
}
}
+
diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js
index ca6ea891a..9b9991b9e 100644
--- a/plugins/Realtime/realtimeupdate.js
+++ b/plugins/Realtime/realtimeupdate.js
@@ -45,15 +45,9 @@ RealtimeUpdate = {
DT = document.title;
$(window).blur(function() {
- $('#notices_primary .notice').css({
- 'border-top-color':$('#notices_primary .notice:last').css('border-top-color'),
- 'border-top-style':'dotted'
- });
+ $('#notices_primary .notice').removeClass('mark-top');
- $('#notices_primary .notice:first').css({
- 'border-top-color':'#AAAAAA',
- 'border-top-style':'solid'
- });
+ $('#notices_primary .notice:first').addClass('mark-top');
RealtimeUpdate._updatecounter = 0;
document.title = DT;
@@ -163,12 +157,14 @@ RealtimeUpdate = {
addPopup: function(url, timeline, iconurl)
{
- $('#notices_primary').css({'position':'relative'});
- $('#notices_primary').prepend('<button id="realtime_timeline" title="Pop up in a window">Pop up</button>');
+ var NP = $('#notices_primary');
+ NP.css({'position':'relative'});
+ NP.prepend('<button id="realtime_timeline" title="Pop up in a window">Pop up</button>');
- $('#realtime_timeline').css({
+ var RT = $('#realtime_timeline');
+ RT.css({
'margin':'0 0 11px 0',
- 'background':'transparent url('+ iconurl + ') no-repeat 0% 30%',
+ 'background':'transparent url('+ iconurl + ') no-repeat 0 30%',
'padding':'0 0 0 20px',
'display':'block',
'position':'absolute',
@@ -176,15 +172,16 @@ RealtimeUpdate = {
'right':'0',
'border':'none',
'cursor':'pointer',
- 'color':$("a").css("color"),
+ 'color':$('a').css('color'),
'font-weight':'bold',
'font-size':'1em'
});
+ $('#showstream #notices_primary').css({'margin-top':'18px'});
- $('#realtime_timeline').click(function() {
+ RT.click(function() {
window.open(url,
timeline,
- 'toolbar=no,resizable=yes,scrollbars=yes,status=yes');
+ 'toolbar=no,resizable=yes,scrollbars=yes,status=yes,width=500,height=550');
return false;
});
@@ -192,7 +189,6 @@ RealtimeUpdate = {
initPopupWindow: function()
{
- window.resizeTo(500, 550);
$('address').hide();
$('#content').css({'width':'93.5%'});
diff --git a/plugins/ReverseUsernameAuthentication/README b/plugins/ReverseUsernameAuthentication/README
new file mode 100644
index 000000000..e9160ed9b
--- /dev/null
+++ b/plugins/ReverseUsernameAuthentication/README
@@ -0,0 +1,26 @@
+The Reverse Username Authentication plugin allows for StatusNet to handle authentication by checking if the provided password is the same as the reverse of the username.
+
+THIS PLUGIN IS FOR TESTING PURPOSES ONLY
+
+Installation
+============
+add "addPlugin('reverseUsernameAuthentication', array('setting'=>'value', 'setting2'=>'value2', ...);" to the bottom of your config.php
+
+Settings
+========
+provider_name*: a unique name for this authentication provider.
+password_changeable*: must be set to false. This plugin does not support changing passwords.
+authoritative (false): Set to true if this plugin's responses are authoritative (meaning if this fails, do check any other plugins or the internal password database).
+autoregistration (false): Set to true if users should be automatically created when they attempt to login.
+
+* required
+default values are in (parenthesis)
+
+Example
+=======
+addPlugin('reverseUsernameAuthentication', array(
+ 'provider_name'=>'Example',
+ 'password_changeable'=>false,
+ 'authoritative'=>true,
+ 'autoregistration'=>true
+));
diff --git a/plugins/ReverseUsernameAuthentication/ReverseUsernameAuthenticationPlugin.php b/plugins/ReverseUsernameAuthentication/ReverseUsernameAuthenticationPlugin.php
new file mode 100644
index 000000000..d48283b2e
--- /dev/null
+++ b/plugins/ReverseUsernameAuthentication/ReverseUsernameAuthenticationPlugin.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Plugin that checks if the password is the reverse of username
+ *
+ * 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 Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Craig Andrews http://candrews.integralblue.com
+ * @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') && !defined('LACONICA')) {
+ exit(1);
+}
+
+require_once INSTALLDIR.'/plugins/Authentication/AuthenticationPlugin.php';
+
+class ReverseUsernameAuthenticationPlugin extends AuthenticationPlugin
+{
+ //---interface implementation---//
+
+ function onInitializePlugin(){
+ parent::onInitializePlugin();
+ if(!isset($this->password_changeable) && $this->password_changeable){
+ throw new Exception("password_changeable cannot be set to true. This plugin does not support changing passwords.");
+ }
+ }
+
+ function checkPassword($username, $password)
+ {
+ return $username == strrev($password);
+ }
+
+ function autoRegister($username)
+ {
+ $registration_data = array();
+ $registration_data['nickname'] = $username ;
+ return User::register($registration_data);
+ }
+}
diff --git a/plugins/SimpleUrl/SimpleUrlPlugin.php b/plugins/SimpleUrl/SimpleUrlPlugin.php
index d59d63e47..45b745b07 100644
--- a/plugins/SimpleUrl/SimpleUrlPlugin.php
+++ b/plugins/SimpleUrl/SimpleUrlPlugin.php
@@ -31,40 +31,21 @@ if (!defined('STATUSNET')) {
exit(1);
}
-class SimpleUrlPlugin extends Plugin
+require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php';
+
+class SimpleUrlPlugin extends UrlShortenerPlugin
{
- function __construct()
- {
- parent::__construct();
- }
+ public $serviceUrl;
function onInitializePlugin(){
- $this->registerUrlShortener(
- 'is.gd',
- array(),
- array('SimpleUrl',array('http://is.gd/api.php?longurl='))
- );
- $this->registerUrlShortener(
- 'snipr.com',
- array(),
- array('SimpleUrl',array('http://snipr.com/site/snip?r=simple&link='))
- );
- $this->registerUrlShortener(
- 'metamark.net',
- array(),
- array('SimpleUrl',array('http://metamark.net/api/rest/simple?long_url='))
- );
- $this->registerUrlShortener(
- 'tinyurl.com',
- array(),
- array('SimpleUrl',array('http://tinyurl.com/api-create.php?url='))
- );
+ parent::onInitializePlugin();
+ if(!isset($this->serviceUrl)){
+ throw new Exception("must specify a serviceUrl");
+ }
}
-}
-class SimpleUrl extends ShortUrlApi
-{
- protected function shorten_imp($url) {
- return $this->http_get($url);
+ protected function shorten($url) {
+ return $this->http_get(sprintf($this->serviceUrl,urlencode($url)));
}
}
+
diff --git a/plugins/TightUrl/TightUrlPlugin.php b/plugins/TightUrl/TightUrlPlugin.php
index 48efb355f..56414c8c8 100644
--- a/plugins/TightUrl/TightUrlPlugin.php
+++ b/plugins/TightUrl/TightUrlPlugin.php
@@ -31,32 +31,27 @@ if (!defined('STATUSNET')) {
exit(1);
}
-class TightUrlPlugin extends Plugin
+require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php';
+
+class TightUrlPlugin extends UrlShortenerPlugin
{
- function __construct()
- {
- parent::__construct();
- }
+ public $serviceUrl;
function onInitializePlugin(){
- $this->registerUrlShortener(
- '2tu.us',
- array('freeService'=>true),
- array('TightUrl',array('http://2tu.us/?save=y&url='))
- );
+ parent::onInitializePlugin();
+ if(!isset($this->serviceUrl)){
+ throw new Exception("must specify a serviceUrl");
+ }
}
-}
-class TightUrl extends ShortUrlApi
-{
- protected function shorten_imp($url) {
- $response = $this->http_get($url);
- if (!$response) return $url;
+ protected function shorten($url)
+ {
+ $response = $this->http_get(sprintf($this->serviceUrl,urlencode($url)));
+ if (!$response) return;
$response = $this->tidy($response);
$y = @simplexml_load_string($response);
- if (!isset($y->body)) return $url;
+ if (!isset($y->body)) return;
$xml = $y->body->p[0]->code[0]->a->attributes();
if (isset($xml['href'])) return $xml['href'];
- return $url;
}
}
diff --git a/plugins/UrlShortener/UrlShortenerPlugin.php b/plugins/UrlShortener/UrlShortenerPlugin.php
new file mode 100644
index 000000000..37206aa89
--- /dev/null
+++ b/plugins/UrlShortener/UrlShortenerPlugin.php
@@ -0,0 +1,103 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Superclass for plugins that do URL shortening
+ *
+ * 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 Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @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') && !defined('LACONICA')) {
+ exit(1);
+}
+
+/**
+ * Superclass for plugins that do URL shortening
+ *
+ * @category Plugin
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+abstract class UrlShortenerPlugin extends Plugin
+{
+ public $shortenerName;
+ public $freeService=false;
+ //------------Url Shortener plugin should implement some (or all) of these methods------------\\
+
+ /**
+ * Short a URL
+ * @param url
+ * @return string shortened version of the url, or null if URL shortening failed
+ */
+ protected abstract function shorten($url);
+
+ //------------These methods may help you implement your plugin------------\\
+ protected function http_get($url)
+ {
+ $request = HTTPClient::start();
+ $response = $request->get($url);
+ return $response->getBody();
+ }
+
+ protected function http_post($url,$data)
+ {
+ $request = HTTPClient::start();
+ $response = $request->post($url, null, $data);
+ return $response->getBody();
+ }
+
+ protected function tidy($response) {
+ $response = str_replace('&nbsp;', ' ', $response);
+ $config = array('output-xhtml' => true);
+ $tidy = new tidy;
+ $tidy->parseString($response, $config, 'utf8');
+ $tidy->cleanRepair();
+ return (string)$tidy;
+ }
+ //------------Below are the methods that connect StatusNet to the implementing Url Shortener plugin------------\\
+
+ function onInitializePlugin(){
+ if(!isset($this->shortenerName)){
+ throw new Exception("must specify a shortenerName");
+ }
+ }
+
+ function onGetUrlShorteners(&$shorteners)
+ {
+ $shorteners[$this->shortenerName]=array('freeService'=>$this->freeService);
+ }
+
+ function onStartShortenUrl($url,$shortenerName,&$shortenedUrl)
+ {
+ if($shortenerName == $this->shortenerName && strlen($url) >= common_config('site', 'shorturllength')){
+ $result = $this->shorten($url);
+ if(isset($result) && $result != null && $result !== false){
+ $shortenedUrl=$result;
+ common_log(LOG_INFO, __CLASS__ . ": $this->shortenerName shortened $url to $shortenedUrl");
+ return false;
+ }
+ }
+ }
+}
diff --git a/plugins/UserFlag/UserFlagPlugin.php b/plugins/UserFlag/UserFlagPlugin.php
index fe4a74869..6410ee1ce 100644
--- a/plugins/UserFlag/UserFlagPlugin.php
+++ b/plugins/UserFlag/UserFlagPlugin.php
@@ -140,4 +140,12 @@ class UserFlagPlugin extends Plugin
return true;
}
+
+ function onEndShowScripts($action)
+ {
+ $action->elementStart('script', array('type' => 'text/javascript'));
+ $action->raw('/*<![CDATA[*/ SN.U.FormXHR($(".form_entity_flag")); /*]]>*/');
+ $action->elementEnd('script');
+ return true;
+ }
}
diff --git a/plugins/UserFlag/flagprofile.php b/plugins/UserFlag/flagprofile.php
index c72b74c6a..77c86b233 100644
--- a/plugins/UserFlag/flagprofile.php
+++ b/plugins/UserFlag/flagprofile.php
@@ -108,7 +108,21 @@ class FlagprofileAction extends Action
parent::handle($args);
$this->flagProfile();
- $this->returnTo();
+
+ if ($this->boolean('ajax')) {
+ header('Content-Type: text/xml;charset=utf-8');
+ $this->xw->startDocument('1.0', 'UTF-8');
+ $this->elementStart('html');
+ $this->elementStart('head');
+ $this->element('title', null, _('Flagged for review'));
+ $this->elementEnd('head');
+ $this->elementStart('body');
+ $this->element('p', 'flagged', _('Flagged'));
+ $this->elementEnd('body');
+ $this->elementEnd('html');
+ } else {
+ $this->returnTo();
+ }
}
function title() {
diff --git a/plugins/UserFlag/flagprofileform.php b/plugins/UserFlag/flagprofileform.php
index 0811dbb9d..a8396e2d5 100644
--- a/plugins/UserFlag/flagprofileform.php
+++ b/plugins/UserFlag/flagprofileform.php
@@ -94,7 +94,7 @@ class FlagProfileForm extends Form
function formClass()
{
- return 'form_profile_flag';
+ return 'form_entity_flag';
}
/**