summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Authentication/AuthenticationPlugin.php28
-rw-r--r--plugins/CacheLogPlugin.php18
-rw-r--r--plugins/CasAuthentication/CasAuthenticationPlugin.php9
-rw-r--r--plugins/CasAuthentication/README6
-rw-r--r--plugins/FeedSub/FeedSubPlugin.php7
-rw-r--r--plugins/FeedSub/feedinfo.php108
-rw-r--r--plugins/MemcachePlugin.php13
-rw-r--r--plugins/XCachePlugin.php6
8 files changed, 153 insertions, 42 deletions
diff --git a/plugins/Authentication/AuthenticationPlugin.php b/plugins/Authentication/AuthenticationPlugin.php
index a76848b04..75e8d2b76 100644
--- a/plugins/Authentication/AuthenticationPlugin.php
+++ b/plugins/Authentication/AuthenticationPlugin.php
@@ -99,6 +99,23 @@ abstract class AuthenticationPlugin extends Plugin
}
}
+ /**
+ * Internal AutoRegister event handler
+ * @param nickname
+ * @param provider_name
+ * @param user - the newly registered user
+ */
+ function onAutoRegister($nickname, $provider_name, &$user)
+ {
+ if($provider_name == $this->provider_name && $this->autoregistration){
+ $user = $this->autoregister($nickname);
+ if($user){
+ User_username::register($user,$nickname,$this->provider_name);
+ return false;
+ }
+ }
+ }
+
function onStartCheckPassword($nickname, $password, &$authenticatedUser){
//map the nickname to a username
$user_username = new User_username();
@@ -127,13 +144,10 @@ abstract class AuthenticationPlugin extends Plugin
}
}
}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);
+ $authenticated = $this->checkPassword($nickname, $password);
+ if($authenticated){
+ if(Event::handle('AutoRegister', array($nickname, $this->provider_name, &$authenticatedUser))){
+ if($authenticatedUser){
return false;
}
}
diff --git a/plugins/CacheLogPlugin.php b/plugins/CacheLogPlugin.php
index 9eb04641e..f1e5dd83a 100644
--- a/plugins/CacheLogPlugin.php
+++ b/plugins/CacheLogPlugin.php
@@ -61,7 +61,7 @@ class CacheLogPlugin extends Plugin
function onEndCacheGet($key, &$value)
{
- if (is_null($value)) {
+ if ($value === false) {
$this->log(LOG_INFO, "Cache MISS for key '$key'");
} else {
$this->log(LOG_INFO, "Cache HIT for key '$key'");
@@ -71,7 +71,21 @@ class CacheLogPlugin extends Plugin
function onStartCacheSet(&$key, &$value, &$flag, &$expiry, &$success)
{
- $this->log(LOG_INFO, "Setting cache value for key '$key'");
+ if (empty($value)) {
+ if (is_array($value)) {
+ $this->log(LOG_INFO, "Setting empty array for key '$key'");
+ } else if (is_null($value)) {
+ $this->log(LOG_INFO, "Setting null value for key '$key'");
+ } else if (is_string($value)) {
+ $this->log(LOG_INFO, "Setting empty string for key '$key'");
+ } else if (is_integer($value)) {
+ $this->log(LOG_INFO, "Setting integer 0 for key '$key'");
+ } else {
+ $this->log(LOG_INFO, "Setting empty value '$value' for key '$key'");
+ }
+ } else {
+ $this->log(LOG_INFO, "Setting non-empty value for key '$key'");
+ }
return true;
}
diff --git a/plugins/CasAuthentication/CasAuthenticationPlugin.php b/plugins/CasAuthentication/CasAuthenticationPlugin.php
index 8b6ef5462..8f29c7d2a 100644
--- a/plugins/CasAuthentication/CasAuthenticationPlugin.php
+++ b/plugins/CasAuthentication/CasAuthenticationPlugin.php
@@ -40,6 +40,7 @@ class CasAuthenticationPlugin extends AuthenticationPlugin
public $server;
public $port = 443;
public $path = '';
+ public $takeOverLogin = false;
function checkPassword($username, $password)
{
@@ -62,6 +63,14 @@ class CasAuthenticationPlugin extends AuthenticationPlugin
}
}
+ function onArgsInitialize(&$args)
+ {
+ if($this->takeOverLogin && $args['action'] == 'login')
+ {
+ $args['action'] = 'caslogin';
+ }
+ }
+
function onStartInitializeRouter($m)
{
$m->connect('main/cas', array('action' => 'caslogin'));
diff --git a/plugins/CasAuthentication/README b/plugins/CasAuthentication/README
index 2ee54dc05..c17a28e54 100644
--- a/plugins/CasAuthentication/README
+++ b/plugins/CasAuthentication/README
@@ -21,6 +21,9 @@ password_changeable*: must be set to false. This plugin does not support changin
server*: CAS server to authentication against
port (443): Port the CAS server listens on. Almost always 443
path (): Path on the server to CAS. Usually blank.
+takeOverLogin (false): Take over the main login action. If takeOverLogin is
+ set, anytime the standard username/password login form would be shown,
+ a CAS login will be done instead.
* required
default values are in (parenthesis)
@@ -33,6 +36,7 @@ addPlugin('casAuthentication', array(
'autoregistration'=>true,
'server'=>'sso-cas.univ-rennes1.fr',
'port'=>443,
- 'path'=>''
+ 'path'=>'',
+ 'takeOverLogin'=>true
));
diff --git a/plugins/FeedSub/FeedSubPlugin.php b/plugins/FeedSub/FeedSubPlugin.php
index 857a9794d..e49e2a648 100644
--- a/plugins/FeedSub/FeedSubPlugin.php
+++ b/plugins/FeedSub/FeedSubPlugin.php
@@ -105,12 +105,11 @@ class FeedSubPlugin extends Plugin
return true;
}
- /*
- // auto increment seems to be broken
function onCheckSchema() {
+ // warning: the autoincrement doesn't seem to set.
+ // alter table feedinfo change column id id int(11) not null auto_increment;
$schema = Schema::get();
- $schema->ensureDataObject('Feedinfo');
+ $schema->ensureTable('feedinfo', Feedinfo::schemaDef());
return true;
}
- */
}
diff --git a/plugins/FeedSub/feedinfo.php b/plugins/FeedSub/feedinfo.php
index fff66afe9..b166bd6e1 100644
--- a/plugins/FeedSub/feedinfo.php
+++ b/plugins/FeedSub/feedinfo.php
@@ -31,7 +31,7 @@ class FeedDBException extends FeedSubException
}
}
-class Feedinfo extends Plugin_DataObject
+class Feedinfo extends Memcached_DataObject
{
public $__table = 'feedinfo';
@@ -56,34 +56,90 @@ class Feedinfo extends Plugin_DataObject
return parent::staticGet(__CLASS__, $k, $v);
}
- function tableDef()
+ /**
+ * return table definition for DB_DataObject
+ *
+ * DB_DataObject needs to know something about the table to manipulate
+ * instances. This method provides all the DB_DataObject needs to know.
+ *
+ * @return array array of column definitions
+ */
+
+ function table()
+ {
+ return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
+ 'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
+ 'feeduri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
+ 'homeuri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
+ 'huburi' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
+ 'verify_token' => DB_DATAOBJECT_STR,
+ 'sub_start' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
+ 'sub_end' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
+ 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
+ 'lastupdate' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
+ }
+
+ static function schemaDef()
+ {
+ return array(new ColumnDef('id', 'integer',
+ /*size*/ null,
+ /*nullable*/ false,
+ /*key*/ 'PRI',
+ /*default*/ '0',
+ /*extra*/ null,
+ /*auto_increment*/ true),
+ new ColumnDef('profile_id', 'integer',
+ null, false),
+ new ColumnDef('feeduri', 'varchar',
+ 255, false, 'UNI'),
+ new ColumnDef('homeuri', 'varchar',
+ 255, false),
+ new ColumnDef('huburi', 'varchar',
+ 255, false),
+ new ColumnDef('verify_token', 'varchar',
+ 32, true),
+ new ColumnDef('sub_start', 'datetime',
+ null, true),
+ new ColumnDef('sub_end', 'datetime',
+ null, true),
+ new ColumnDef('created', 'datetime',
+ null, false),
+ new ColumnDef('lastupdate', 'datetime',
+ null, false));
+ }
+
+ /**
+ * return key definitions for DB_DataObject
+ *
+ * DB_DataObject needs to know about keys that the table has; this function
+ * defines them.
+ *
+ * @return array key definitions
+ */
+
+ function keys()
{
- class_exists('Schema'); // autoload hack
- // warning: the autoincrement doesn't seem to set.
- // alter table feedinfo change column id id int(11) not null auto_increment;
- return new TableDef($this->__table,
- array(new ColumnDef('id', 'integer',
- null, false, 'PRI', '0', null, true),
- new ColumnDef('profile_id', 'integer',
- null, false),
- new ColumnDef('feeduri', 'varchar',
- 255, false, 'UNI'),
- new ColumnDef('homeuri', 'varchar',
- 255, false),
- new ColumnDef('huburi', 'varchar',
- 255, false),
- new ColumnDef('verify_token', 'varchar',
- 32, true),
- new ColumnDef('sub_start', 'datetime',
- null, true),
- new ColumnDef('sub_end', 'datetime',
- null, true),
- new ColumnDef('created', 'datetime',
- null, false),
- new ColumnDef('lastupdate', 'datetime',
- null, false)));
+ return array('id' => 'P'); //?
}
+ /**
+ * return key definitions for Memcached_DataObject
+ *
+ * Our caching system uses the same key definitions, but uses a different
+ * method to get them.
+ *
+ * @return array key definitions
+ */
+
+ function keyTypes()
+ {
+ return $this->keys();
+ }
+
+ /**
+ * Fetch the StatusNet-side profile for this feed
+ * @return Profile
+ */
public function getProfile()
{
return Profile::staticGet('id', $this->profile_id);
diff --git a/plugins/MemcachePlugin.php b/plugins/MemcachePlugin.php
index acbec135e..998766313 100644
--- a/plugins/MemcachePlugin.php
+++ b/plugins/MemcachePlugin.php
@@ -54,6 +54,9 @@ class MemcachePlugin extends Plugin
private $_conn = null;
public $servers = array('127.0.0.1;11211');
+ public $compressThreshold = 20480;
+ public $compressMinSaving = 0.2;
+
/**
* Initialize the plugin
*
@@ -156,6 +159,16 @@ class MemcachePlugin extends Plugin
}
$this->_conn->addServer($host, $port);
}
+
+ // Compress items stored in the cache if they're over threshold in size
+ // (default 2KiB) and the compression would save more than min savings
+ // ratio (default 0.2).
+
+ // Allows the cache to store objects larger than 1MB (if they
+ // compress to less than 1MB), and improves cache memory efficiency.
+
+ $this->_conn->setCompressThreshold($this->compressThreshold,
+ $this->compressMinSaving);
}
}
}
diff --git a/plugins/XCachePlugin.php b/plugins/XCachePlugin.php
index 8eed12cbc..03cb0c06e 100644
--- a/plugins/XCachePlugin.php
+++ b/plugins/XCachePlugin.php
@@ -63,8 +63,10 @@ class XCachePlugin extends Plugin
function onStartCacheGet(&$key, &$value)
{
- $value = xcache_get($key);
- if (!is_null($value)) {
+ if (!xcache_isset($key)) {
+ $value = false;
+ } else {
+ $value = xcache_get($key);
$value = unserialize($value);
}
Event::handle('EndCacheGet', array($key, &$value));