diff options
Diffstat (limited to 'classes')
-rw-r--r-- | classes/Design.php | 6 | ||||
-rw-r--r-- | classes/File.php | 63 | ||||
-rw-r--r-- | classes/File_oembed.php | 27 | ||||
-rw-r--r-- | classes/File_redirection.php | 10 | ||||
-rw-r--r-- | classes/File_thumbnail.php | 6 | ||||
-rw-r--r-- | classes/File_to_post.php | 6 | ||||
-rw-r--r-- | classes/Group_alias.php | 6 | ||||
-rw-r--r-- | classes/Group_block.php | 6 | ||||
-rw-r--r-- | classes/Memcached_DataObject.php | 6 | ||||
-rw-r--r-- | classes/Notice.php | 32 | ||||
-rw-r--r-- | classes/Notice_inbox.php | 6 | ||||
-rw-r--r-- | classes/Notice_tag.php | 4 | ||||
-rw-r--r-- | classes/Profile.php | 6 | ||||
-rw-r--r-- | classes/Profile_block.php | 6 | ||||
-rw-r--r-- | classes/Remote_profile.php | 6 | ||||
-rw-r--r-- | classes/Session.php | 6 | ||||
-rw-r--r-- | classes/Status_network.php | 10 | ||||
-rw-r--r-- | classes/Subscription.php | 6 | ||||
-rw-r--r-- | classes/User.php | 67 | ||||
-rw-r--r-- | classes/User_role.php | 48 | ||||
-rwxr-xr-x | classes/laconica.ini | 520 | ||||
-rw-r--r-- | classes/status_network.ini | 18 | ||||
-rwxr-xr-x[-rw-r--r--] | classes/statusnet.ini | 545 | ||||
-rw-r--r-- | classes/statusnet.links.ini (renamed from classes/laconica.links.ini) | 0 |
24 files changed, 774 insertions, 642 deletions
diff --git a/classes/Design.php b/classes/Design.php index 19c9e0292..89ae50c8c 100644 --- a/classes/Design.php +++ b/classes/Design.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - the distributed open-source microblogging tool - * Copyright (C) 2009, Control Yourself, Inc. + * 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 @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } diff --git a/classes/File.php b/classes/File.php index b2c510340..9758cf7f5 100644 --- a/classes/File.php +++ b/classes/File.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; require_once INSTALLDIR.'/classes/File_redirection.php'; @@ -78,14 +78,14 @@ class File extends Memcached_DataObject $file_id = $x->insert(); if (isset($redir_data['type']) - && ('text/html' === substr($redir_data['type'], 0, 9)) + && (('text/html' === substr($redir_data['type'], 0, 9) || 'application/xhtml+xml' === substr($redir_data['type'], 0, 21))) && ($oembed_data = File_oembed::_getOembed($given_url))) { File_oembed::saveNew($oembed_data, $file_id); } return $x; } - function processNew($given_url, $notice_id) { + function processNew($given_url, $notice_id=null) { if (empty($given_url)) return -1; // error, no url to process $given_url = File_redirection::_canonUrl($given_url); if (empty($given_url)) return -1; // error, no url to process @@ -96,7 +96,7 @@ class File extends Memcached_DataObject $redir_data = File_redirection::where($given_url); $redir_url = $redir_data['url']; // TODO: max field length - if ($redir_url === $given_url || strlen($redir_url) > 255) { + if ($redir_url === $given_url || strlen($redir_url) > 255) { $x = File::saveNew($redir_data, $given_url); $file_id = $x->id; } else { @@ -119,7 +119,9 @@ class File extends Memcached_DataObject } } - File_to_post::processNew($file_id, $notice_id); + if (!empty($notice_id)) { + File_to_post::processNew($file_id, $notice_id); + } return $x; } @@ -195,17 +197,44 @@ class File extends Memcached_DataObject return 'http://'.$server.$path.$filename; } - function isEnclosure(){ - if(isset($this->filename)){ - return true; - } - $notEnclosureMimeTypes = array('text/html','application/xhtml+xml'); - $mimetype = strtolower($this->mimetype); - $semicolon = strpos($mimetype,';'); - if($semicolon){ - $mimetype = substr($mimetype,0,$semicolon); + function getEnclosure(){ + $enclosure = (object) array(); + $enclosure->title=$this->title; + $enclosure->url=$this->url; + $enclosure->title=$this->title; + $enclosure->date=$this->date; + $enclosure->modified=$this->modified; + $enclosure->size=$this->size; + $enclosure->mimetype=$this->mimetype; + + if(! isset($this->filename)){ + $notEnclosureMimeTypes = array('text/html','application/xhtml+xml'); + $mimetype = strtolower($this->mimetype); + $semicolon = strpos($mimetype,';'); + if($semicolon){ + $mimetype = substr($mimetype,0,$semicolon); + } + if(in_array($mimetype,$notEnclosureMimeTypes)){ + $oembed = File_oembed::staticGet('file_id',$this->id); + if($oembed){ + $mimetype = strtolower($oembed->mimetype); + $semicolon = strpos($mimetype,';'); + if($semicolon){ + $mimetype = substr($mimetype,0,$semicolon); + } + if(in_array($mimetype,$notEnclosureMimeTypes)){ + return false; + }else{ + if($oembed->mimetype) $enclosure->mimetype=$oembed->mimetype; + if($oembed->url) $enclosure->url=$oembed->url; + if($oembed->title) $enclosure->title=$oembed->title; + if($oembed->modified) $enclosure->modified=$oembed->modified; + unset($oembed->size); + } + } + } } - return(! in_array($mimetype,$notEnclosureMimeTypes)); + return $enclosure; } } diff --git a/classes/File_oembed.php b/classes/File_oembed.php index bbf112729..e41ccfd09 100644 --- a/classes/File_oembed.php +++ b/classes/File_oembed.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -17,9 +17,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; +require_once INSTALLDIR.'/classes/File_redirection.php'; /** * Table Definition for file_oembed @@ -34,6 +35,7 @@ class File_oembed extends Memcached_DataObject public $file_id; // int(4) primary_key not_null public $version; // varchar(20) public $type; // varchar(20) + public $mimetype; // varchar(50) public $provider; // varchar(50) public $provider_url; // varchar(255) public $width; // int(4) @@ -93,7 +95,24 @@ class File_oembed extends Memcached_DataObject if (!empty($data->title)) $file_oembed->title = $data->title; if (!empty($data->author_name)) $file_oembed->author_name = $data->author_name; if (!empty($data->author_url)) $file_oembed->author_url = $data->author_url; - if (!empty($data->url)) $file_oembed->url = $data->url; + if (!empty($data->url)){ + $file_oembed->url = $data->url; + $given_url = File_redirection::_canonUrl($file_oembed->url); + if (! empty($given_url)){ + $file = File::staticGet('url', $given_url); + if (empty($file)) { + $file_redir = File_redirection::staticGet('url', $given_url); + if (empty($file_redir)) { + $redir_data = File_redirection::where($given_url); + $file_oembed->mimetype = $redir_data['type']; + } else { + $file_id = $file_redir->file_id; + } + } else { + $file_oembed->mimetype=$file->mimetype; + } + } + } $file_oembed->insert(); if (!empty($data->thumbnail_url)) { File_thumbnail::saveNew($data, $file_id); diff --git a/classes/File_redirection.php b/classes/File_redirection.php index d6fa0bcb6..76b18f672 100644 --- a/classes/File_redirection.php +++ b/classes/File_redirection.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -17,13 +17,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; require_once INSTALLDIR.'/classes/File.php'; require_once INSTALLDIR.'/classes/File_oembed.php'; -define('USER_AGENT', 'Laconica user agent / file probe'); +define('USER_AGENT', 'StatusNet user agent / file probe'); /** * Table Definition for file_redirection @@ -182,7 +182,7 @@ class File_redirection extends Memcached_DataObject } } - if (('ftp' == $p['scheme']) || ('http' == $p['scheme']) || ('https' == $p['scheme'])) { + if (('ftp' == $p['scheme']) || ('ftps' == $p['scheme']) || ('http' == $p['scheme']) || ('https' == $p['scheme'])) { if (empty($p['host'])) return false; if (empty($p['path'])) { $out_url .= '/'; diff --git a/classes/File_thumbnail.php b/classes/File_thumbnail.php index 0b09c6af8..f8b70356c 100644 --- a/classes/File_thumbnail.php +++ b/classes/File_thumbnail.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; diff --git a/classes/File_to_post.php b/classes/File_to_post.php index d35febb77..e3db91b20 100644 --- a/classes/File_to_post.php +++ b/classes/File_to_post.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; diff --git a/classes/Group_alias.php b/classes/Group_alias.php index e801e50e1..be3d0a6c6 100644 --- a/classes/Group_alias.php +++ b/classes/Group_alias.php @@ -2,8 +2,8 @@ /** * Table Definition for group_alias * - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2009, Control Yourself, Inc. + * 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 @@ -19,7 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; diff --git a/classes/Group_block.php b/classes/Group_block.php index 7922c19a9..de2cf5f6e 100644 --- a/classes/Group_block.php +++ b/classes/Group_block.php @@ -2,8 +2,8 @@ /** * Table Definition for group_block * - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -19,7 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index ea070ec84..9c2ac3e01 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; diff --git a/classes/Notice.php b/classes/Notice.php index 48d4a0940..2138e0561 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } /** * Table Definition for notice @@ -56,7 +56,7 @@ class Notice extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - /* Notice types */ + /* Notice types */ const LOCAL_PUBLIC = 1; const REMOTE_OMB = 0; const LOCAL_NONPUBLIC = -1; @@ -260,17 +260,6 @@ class Notice extends Memcached_DataObject $notice->saveUrls(); - // FIXME: why do we have to re-render the content? - // Remove this if it's not necessary. - - $orig2 = clone($notice); - - $notice->rendered = common_render_content($final, $notice); - if (!$notice->update($orig2)) { - common_log_db_error($notice, 'UPDATE', __FILE__); - return _('Problem saving notice.'); - } - $notice->query('COMMIT'); Event::handle('EndNoticeSave', array($notice)); @@ -755,6 +744,10 @@ class Notice extends Memcached_DataObject return new ArrayWrapper($notices); } else { $notice = new Notice(); + if (empty($ids)) { + //if no IDs requested, just return the notice object + return $notice; + } $notice->whereAdd('id in (' . implode(', ', $ids) . ')'); $notice->orderBy('id DESC'); @@ -1199,10 +1192,11 @@ class Notice extends Memcached_DataObject $attachments = $this->attachments(); if($attachments){ foreach($attachments as $attachment){ - if ($attachment->isEnclosure()) { - $attributes = array('rel'=>'enclosure','href'=>$attachment->url,'type'=>$attachment->mimetype,'length'=>$attachment->size); - if($attachment->title){ - $attributes['title']=$attachment->title; + $enclosure=$attachment->getEnclosure(); + if ($enclosure) { + $attributes = array('rel'=>'enclosure','href'=>$enclosure->url,'type'=>$enclosure->mimetype,'length'=>$enclosure->size); + if($enclosure->title){ + $attributes['title']=$enclosure->title; } $xs->element('link', $attributes, null); } diff --git a/classes/Notice_inbox.php b/classes/Notice_inbox.php index 2af34b1a4..d3e7853b1 100644 --- a/classes/Notice_inbox.php +++ b/classes/Notice_inbox.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; diff --git a/classes/Notice_tag.php b/classes/Notice_tag.php index 4e52ef269..02740280f 100644 --- a/classes/Notice_tag.php +++ b/classes/Notice_tag.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 diff --git a/classes/Profile.php b/classes/Profile.php index 8f92b386e..7f0d12758 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } /** * Table Definition for profile diff --git a/classes/Profile_block.php b/classes/Profile_block.php index feadea42d..2d87edaa0 100644 --- a/classes/Profile_block.php +++ b/classes/Profile_block.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } /** * Table Definition for profile_block diff --git a/classes/Remote_profile.php b/classes/Remote_profile.php index 975852dd9..9f7bfeadc 100644 --- a/classes/Remote_profile.php +++ b/classes/Remote_profile.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } /** * Table Definition for remote_profile diff --git a/classes/Session.php b/classes/Session.php index 5ec509f5f..d641edbbe 100644 --- a/classes/Session.php +++ b/classes/Session.php @@ -2,8 +2,8 @@ /** * Table Definition for session * - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2009, Control Yourself, Inc. + * 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 @@ -19,7 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; diff --git a/classes/Status_network.php b/classes/Status_network.php index dbd722e88..fe4f0b0c5 100644 --- a/classes/Status_network.php +++ b/classes/Status_network.php @@ -2,8 +2,8 @@ /** * Table Definition for status_network * - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2009, Control Yourself, Inc. + * 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 @@ -19,7 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } class Status_network extends DB_DataObject { @@ -54,7 +54,7 @@ class Status_network extends DB_DataObject global $config; $config['db']['database_'.$dbname] = "mysqli://$dbuser:$dbpass@$dbhost/$dbname"; - $config['db']['ini_'.$dbname] = INSTALLDIR.'/classes/statusnet.ini'; + $config['db']['ini_'.$dbname] = INSTALLDIR.'/classes/status_network.ini'; $config['db']['table_status_network'] = $dbname; self::$cache = new Memcache(); @@ -71,7 +71,7 @@ class Status_network extends DB_DataObject } static function cacheKey($k, $v) { - return 'laconica:' . self::$base . ':status_network:'.$k.':'.$v; + return 'statusnet:' . self::$base . ':status_network:'.$k.':'.$v; } static function memGet($k, $v) diff --git a/classes/Subscription.php b/classes/Subscription.php index d4580fcba..fedfd5f19 100644 --- a/classes/Subscription.php +++ b/classes/Subscription.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } /** * Table Definition for subscription diff --git a/classes/User.php b/classes/User.php index 104dfbacb..11cb4f08b 100644 --- a/classes/User.php +++ b/classes/User.php @@ -1,7 +1,7 @@ <?php /* - * Laconica - a distributed open-source microblogging tool - * Copyright (C) 2008, 2009, Control Yourself, Inc. + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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 @@ -17,7 +17,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } @@ -103,10 +103,7 @@ class User extends Memcached_DataObject } $toupdate = implode(', ', $parts); - $table = $this->tableName(); - if(common_config('db','quote_identifiers')) { - $table = '"' . $table . '"'; - } + $table = common_database_tablename($this->tableName()); $qry = 'UPDATE ' . $table . ' SET ' . $toupdate . ' WHERE id = ' . $this->id; $orig->decache(); @@ -630,11 +627,7 @@ class User extends Memcached_DataObject 'ORDER BY subscription.created DESC '; if ($offset) { - if (common_config('db','type') == 'pgsql') { - $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; - } else { - $qry .= ' LIMIT ' . $offset . ', ' . $limit; - } + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; } $profile = new Profile(); @@ -657,11 +650,7 @@ class User extends Memcached_DataObject 'AND subscription.subscribed != subscription.subscriber ' . 'ORDER BY subscription.created DESC '; - if (common_config('db','type') == 'pgsql') { - $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; - } else { - $qry .= ' LIMIT ' . $offset . ', ' . $limit; - } + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; $profile = new Profile(); @@ -674,4 +663,48 @@ class User extends Memcached_DataObject { return Design::staticGet('id', $this->design_id); } + + function hasRole($name) + { + $role = User_role::pkeyGet(array('user_id' => $this->id, + 'role' => $name)); + return (!empty($role)); + } + + function grantRole($name) + { + $role = new User_role(); + + $role->user_id = $this->id; + $role->role = $name; + $role->created = common_sql_now(); + + $result = $role->insert(); + + if (!$result) { + common_log_db_error($role, 'INSERT', __FILE__); + return false; + } + + return true; + } + + function revokeRole($name) + { + $role = User_role::pkeyGet(array('user_id' => $this->id, + 'role' => $name)); + + if (empty($role)) { + throw new Exception('Cannot revoke role "'.$name.'" for user #'.$this->id.'; does not exist.'); + } + + $result = $role->delete(); + + if (!$result) { + common_log_db_error($role, 'DELETE', __FILE__); + throw new Exception('Cannot revoke role "'.$name.'" for user #'.$this->id.'; database error.'); + } + + return true; + } } diff --git a/classes/User_role.php b/classes/User_role.php new file mode 100644 index 000000000..85ecfb422 --- /dev/null +++ b/classes/User_role.php @@ -0,0 +1,48 @@ +<?php +/* + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2008, 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/>. + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } + +/** + * Table Definition for user_role + */ + +require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; + +class User_role extends Memcached_DataObject +{ + ###START_AUTOCODE + /* the code below is auto generated do not remove the above tag */ + + public $__table = 'user_role'; // table name + public $user_id; // int(4) primary_key not_null + public $role; // varchar(32) primary_key not_null + public $created; // datetime() not_null + + /* Static get */ + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('User_role',$k,$v); } + + /* the code above is auto generated do not remove the tag below */ + ###END_AUTOCODE + + function &pkeyGet($kv) + { + return Memcached_DataObject::pkeyGet('User_role', $kv); + } +} diff --git a/classes/laconica.ini b/classes/laconica.ini deleted file mode 100755 index 7edeeebe4..000000000 --- a/classes/laconica.ini +++ /dev/null @@ -1,520 +0,0 @@ - -[avatar] -profile_id = 129 -original = 17 -width = 129 -height = 129 -mediatype = 130 -filename = 2 -url = 2 -created = 142 -modified = 384 - -[avatar__keys] -profile_id = K -width = K -height = K -url = U - -[config] -section = 130 -setting = 130 -value = 2 - -[config__keys] -section = K -setting = K - -[confirm_address] -code = 130 -user_id = 129 -address = 130 -address_extra = 130 -address_type = 130 -claimed = 14 -sent = 14 -modified = 384 - -[confirm_address__keys] -code = K - -[consumer] -consumer_key = 130 -seed = 130 -created = 142 -modified = 384 - -[consumer__keys] -consumer_key = K - -[deleted_notice] -id = 129 -profile_id = 129 -uri = 2 -created = 142 -deleted = 142 - -[deleted_notice__keys] -id = K -uri = U - -[design] -id = 129 -backgroundcolor = 1 -contentcolor = 1 -sidebarcolor = 1 -textcolor = 1 -linkcolor = 1 -backgroundimage = 2 -disposition = 17 - -[design__keys] -id = N - -[fave] -notice_id = 129 -user_id = 129 -modified = 384 - -[fave__keys] -notice_id = K -user_id = K - -[file] -id = 129 -url = 2 -mimetype = 2 -size = 1 -title = 2 -date = 1 -protected = 1 -filename = 2 -modified = 384 - -[file__keys] -id = N - -[file_oembed] -file_id = 129 -version = 2 -type = 2 -provider = 2 -provider_url = 2 -width = 1 -height = 1 -html = 34 -title = 2 -author_name = 2 -author_url = 2 -url = 2 -modified = 384 - -[file_oembed__keys] -file_id = K - -[file_redirection] -url = 130 -file_id = 1 -redirections = 1 -httpcode = 1 -modified = 384 - -[file_redirection__keys] -url = K - -[file_thumbnail] -file_id = 129 -url = 2 -width = 1 -height = 1 -modified = 384 - -[file_thumbnail__keys] -file_id = K -url = U - -[file_to_post] -file_id = 129 -post_id = 129 -modified = 384 - -[file_to_post__keys] -file_id = K -post_id = K - -[foreign_link] -user_id = 129 -foreign_id = 129 -service = 129 -credentials = 2 -noticesync = 145 -friendsync = 145 -profilesync = 145 -last_noticesync = 14 -last_friendsync = 14 -created = 142 -modified = 384 - -[foreign_link__keys] -user_id = K -foreign_id = K -service = K - -[foreign_service] -id = 129 -name = 130 -description = 2 -created = 142 -modified = 384 - -[foreign_service__keys] -id = K -name = U - -[foreign_subscription] -service = 129 -subscriber = 129 -subscribed = 129 -created = 142 - -[foreign_subscription__keys] -service = K -subscriber = K -subscribed = K - -[foreign_user] -id = 129 -service = 129 -uri = 130 -nickname = 2 -created = 142 -modified = 384 - -[foreign_user__keys] -id = K -service = K -uri = U - -[group_alias] -alias = 130 -group_id = 129 -modified = 384 - -[group_alias__keys] -alias = K - -[group_block] -group_id = 129 -blocked = 129 -blocker = 129 -modified = 384 - -[group_block__keys] -group_id = K -blocked = K - -[group_inbox] -group_id = 129 -notice_id = 129 -created = 142 - -[group_inbox__keys] -group_id = K -notice_id = K - -[group_member] -group_id = 129 -profile_id = 129 -is_admin = 17 -created = 142 -modified = 384 - -[group_member__keys] -group_id = K -profile_id = K - -[invitation] -code = 130 -user_id = 129 -address = 130 -address_type = 130 -created = 142 - -[invitation__keys] -code = K - -[message] -id = 129 -uri = 2 -from_profile = 129 -to_profile = 129 -content = 34 -rendered = 34 -url = 2 -created = 142 -modified = 384 -source = 2 - -[message__keys] -id = N - -[nonce] -consumer_key = 130 -tok = 2 -nonce = 130 -ts = 142 -created = 142 -modified = 384 - -[nonce__keys] -consumer_key = K -nonce = K -ts = K - -[notice] -id = 129 -profile_id = 129 -uri = 2 -content = 34 -rendered = 34 -url = 2 -created = 142 -modified = 384 -reply_to = 1 -is_local = 17 -source = 2 -conversation = 1 - -[notice__keys] -id = N - -[notice_inbox] -user_id = 129 -notice_id = 129 -created = 142 -source = 17 - -[notice_inbox__keys] -user_id = K -notice_id = K - -[notice_source] -code = 130 -name = 130 -url = 130 -created = 142 -modified = 384 - -[notice_source__keys] -code = K - -[notice_tag] -tag = 130 -notice_id = 129 -created = 142 - -[notice_tag__keys] -tag = K -notice_id = K - -[profile] -id = 129 -nickname = 130 -fullname = 2 -profileurl = 2 -homepage = 2 -bio = 34 -location = 2 -created = 142 -modified = 384 - -[profile__keys] -id = N - -[profile_block] -blocker = 129 -blocked = 129 -modified = 384 - -[profile_block__keys] -blocker = K -blocked = K - -[profile_tag] -tagger = 129 -tagged = 129 -tag = 130 -modified = 384 - -[profile_tag__keys] -tagger = K -tagged = K -tag = K - -[queue_item] -notice_id = 129 -transport = 130 -created = 142 -claimed = 14 - -[queue_item__keys] -notice_id = K -transport = K - -[related_group] -group_id = 129 -related_group_id = 129 -created = 142 - -[related_group__keys] -group_id = K -related_group_id = K - -[remember_me] -code = 130 -user_id = 129 -modified = 384 - -[remember_me__keys] -code = K - -[remote_profile] -id = 129 -uri = 2 -postnoticeurl = 2 -updateprofileurl = 2 -created = 142 -modified = 384 - -[remote_profile__keys] -id = K -uri = U - -[reply] -notice_id = 129 -profile_id = 129 -modified = 384 -replied_id = 1 - -[reply__keys] -notice_id = K -profile_id = K - -[session] -id = 130 -session_data = 34 -created = 142 -modified = 384 - -[session__keys] -id = K - -[sms_carrier] -id = 129 -name = 2 -email_pattern = 130 -created = 142 -modified = 384 - -[sms_carrier__keys] -id = K -name = U - -[subscription] -subscriber = 129 -subscribed = 129 -jabber = 17 -sms = 17 -token = 2 -secret = 2 -created = 142 -modified = 384 - -[subscription__keys] -subscriber = K -subscribed = K - -[token] -consumer_key = 130 -tok = 130 -secret = 130 -type = 145 -state = 17 -created = 142 -modified = 384 - -[token__keys] -consumer_key = K -tok = K - -[user] -id = 129 -nickname = 2 -password = 2 -email = 2 -incomingemail = 2 -emailnotifysub = 17 -emailnotifyfav = 17 -emailnotifynudge = 17 -emailnotifymsg = 17 -emailnotifyattn = 17 -emailmicroid = 17 -language = 2 -timezone = 2 -emailpost = 17 -jabber = 2 -jabbernotify = 17 -jabberreplies = 17 -jabbermicroid = 17 -updatefrompresence = 17 -sms = 2 -carrier = 1 -smsnotify = 17 -smsreplies = 17 -smsemail = 2 -uri = 2 -autosubscribe = 17 -urlshorteningservice = 2 -inboxed = 17 -design_id = 1 -viewdesigns = 17 -created = 142 -modified = 384 - -[user__keys] -id = K -nickname = U -email = U -incomingemail = U -jabber = U -sms = U -uri = U - -[user_group] -id = 129 -nickname = 2 -fullname = 2 -homepage = 2 -description = 34 -location = 2 -original_logo = 2 -homepage_logo = 2 -stream_logo = 2 -mini_logo = 2 -design_id = 1 -created = 142 -modified = 384 - -[user_group__keys] -id = N - -[user_openid] -canonical = 130 -display = 130 -user_id = 129 -created = 142 -modified = 384 - -[user_openid__keys] -canonical = K -display = U diff --git a/classes/status_network.ini b/classes/status_network.ini new file mode 100644 index 000000000..8123265e4 --- /dev/null +++ b/classes/status_network.ini @@ -0,0 +1,18 @@ +[status_network] +nickname = 130 +hostname = 2 +pathname = 2 +dbhost = 2 +dbuser = 2 +dbpass = 2 +dbname = 2 +sitename = 2 +theme = 2 +logo = 2 +created = 142 +modified = 384 + +[status_network__keys] +nickname = K +hostname = U +pathname = U diff --git a/classes/statusnet.ini b/classes/statusnet.ini index 8123265e4..453981cd6 100644..100755 --- a/classes/statusnet.ini +++ b/classes/statusnet.ini @@ -1,18 +1,529 @@ -[status_network] +[avatar] +profile_id = 129 +original = 17 +width = 129 +height = 129 +mediatype = 130 +filename = 2 +url = 2 +created = 142 +modified = 384 + +[avatar__keys] +profile_id = K +width = K +height = K +url = U + +[config] +section = 130 +setting = 130 +value = 2 + +[config__keys] +section = K +setting = K + +[confirm_address] +code = 130 +user_id = 129 +address = 130 +address_extra = 130 +address_type = 130 +claimed = 14 +sent = 14 +modified = 384 + +[confirm_address__keys] +code = K + +[consumer] +consumer_key = 130 +seed = 130 +created = 142 +modified = 384 + +[consumer__keys] +consumer_key = K + +[deleted_notice] +id = 129 +profile_id = 129 +uri = 2 +created = 142 +deleted = 142 + +[deleted_notice__keys] +id = K +uri = U + +[design] +id = 129 +backgroundcolor = 1 +contentcolor = 1 +sidebarcolor = 1 +textcolor = 1 +linkcolor = 1 +backgroundimage = 2 +disposition = 17 + +[design__keys] +id = N + +[fave] +notice_id = 129 +user_id = 129 +modified = 384 + +[fave__keys] +notice_id = K +user_id = K + +[file] +id = 129 +url = 2 +mimetype = 2 +size = 1 +title = 2 +date = 1 +protected = 1 +filename = 2 +modified = 384 + +[file__keys] +id = N + +[file_oembed] +file_id = 129 +version = 2 +type = 2 +mimetype = 2 +provider = 2 +provider_url = 2 +width = 1 +height = 1 +html = 34 +title = 2 +author_name = 2 +author_url = 2 +url = 2 +modified = 384 + +[file_oembed__keys] +file_id = K + +[file_redirection] +url = 130 +file_id = 1 +redirections = 1 +httpcode = 1 +modified = 384 + +[file_redirection__keys] +url = K + +[file_thumbnail] +file_id = 129 +url = 2 +width = 1 +height = 1 +modified = 384 + +[file_thumbnail__keys] +file_id = K +url = U + +[file_to_post] +file_id = 129 +post_id = 129 +modified = 384 + +[file_to_post__keys] +file_id = K +post_id = K + +[foreign_link] +user_id = 129 +foreign_id = 129 +service = 129 +credentials = 2 +noticesync = 145 +friendsync = 145 +profilesync = 145 +last_noticesync = 14 +last_friendsync = 14 +created = 142 +modified = 384 + +[foreign_link__keys] +user_id = K +foreign_id = K +service = K + +[foreign_service] +id = 129 +name = 130 +description = 2 +created = 142 +modified = 384 + +[foreign_service__keys] +id = K +name = U + +[foreign_subscription] +service = 129 +subscriber = 129 +subscribed = 129 +created = 142 + +[foreign_subscription__keys] +service = K +subscriber = K +subscribed = K + +[foreign_user] +id = 129 +service = 129 +uri = 130 +nickname = 2 +created = 142 +modified = 384 + +[foreign_user__keys] +id = K +service = K +uri = U + +[group_alias] +alias = 130 +group_id = 129 +modified = 384 + +[group_alias__keys] +alias = K + +[group_block] +group_id = 129 +blocked = 129 +blocker = 129 +modified = 384 + +[group_block__keys] +group_id = K +blocked = K + +[group_inbox] +group_id = 129 +notice_id = 129 +created = 142 + +[group_inbox__keys] +group_id = K +notice_id = K + +[group_member] +group_id = 129 +profile_id = 129 +is_admin = 17 +created = 142 +modified = 384 + +[group_member__keys] +group_id = K +profile_id = K + +[invitation] +code = 130 +user_id = 129 +address = 130 +address_type = 130 +created = 142 + +[invitation__keys] +code = K + +[message] +id = 129 +uri = 2 +from_profile = 129 +to_profile = 129 +content = 34 +rendered = 34 +url = 2 +created = 142 +modified = 384 +source = 2 + +[message__keys] +id = N + +[nonce] +consumer_key = 130 +tok = 2 +nonce = 130 +ts = 142 +created = 142 +modified = 384 + +[nonce__keys] +consumer_key = K +nonce = K +ts = K + +[notice] +id = 129 +profile_id = 129 +uri = 2 +content = 34 +rendered = 34 +url = 2 +created = 142 +modified = 384 +reply_to = 1 +is_local = 17 +source = 2 +conversation = 1 + +[notice__keys] +id = N + +[notice_inbox] +user_id = 129 +notice_id = 129 +created = 142 +source = 17 + +[notice_inbox__keys] +user_id = K +notice_id = K + +[notice_source] +code = 130 +name = 130 +url = 130 +created = 142 +modified = 384 + +[notice_source__keys] +code = K + +[notice_tag] +tag = 130 +notice_id = 129 +created = 142 + +[notice_tag__keys] +tag = K +notice_id = K + +[profile] +id = 129 nickname = 130 -hostname = 2 -pathname = 2 -dbhost = 2 -dbuser = 2 -dbpass = 2 -dbname = 2 -sitename = 2 -theme = 2 -logo = 2 -created = 142 -modified = 384 - -[status_network__keys] -nickname = K -hostname = U -pathname = U +fullname = 2 +profileurl = 2 +homepage = 2 +bio = 34 +location = 2 +created = 142 +modified = 384 + +[profile__keys] +id = N + +[profile_block] +blocker = 129 +blocked = 129 +modified = 384 + +[profile_block__keys] +blocker = K +blocked = K + +[profile_tag] +tagger = 129 +tagged = 129 +tag = 130 +modified = 384 + +[profile_tag__keys] +tagger = K +tagged = K +tag = K + +[queue_item] +notice_id = 129 +transport = 130 +created = 142 +claimed = 14 + +[queue_item__keys] +notice_id = K +transport = K + +[related_group] +group_id = 129 +related_group_id = 129 +created = 142 + +[related_group__keys] +group_id = K +related_group_id = K + +[remember_me] +code = 130 +user_id = 129 +modified = 384 + +[remember_me__keys] +code = K + +[remote_profile] +id = 129 +uri = 2 +postnoticeurl = 2 +updateprofileurl = 2 +created = 142 +modified = 384 + +[remote_profile__keys] +id = K +uri = U + +[reply] +notice_id = 129 +profile_id = 129 +modified = 384 +replied_id = 1 + +[reply__keys] +notice_id = K +profile_id = K + +[session] +id = 130 +session_data = 34 +created = 142 +modified = 384 + +[session__keys] +id = K + +[sms_carrier] +id = 129 +name = 2 +email_pattern = 130 +created = 142 +modified = 384 + +[sms_carrier__keys] +id = K +name = U + +[subscription] +subscriber = 129 +subscribed = 129 +jabber = 17 +sms = 17 +token = 2 +secret = 2 +created = 142 +modified = 384 + +[subscription__keys] +subscriber = K +subscribed = K + +[token] +consumer_key = 130 +tok = 130 +secret = 130 +type = 145 +state = 17 +created = 142 +modified = 384 + +[token__keys] +consumer_key = K +tok = K + +[user] +id = 129 +nickname = 2 +password = 2 +email = 2 +incomingemail = 2 +emailnotifysub = 17 +emailnotifyfav = 17 +emailnotifynudge = 17 +emailnotifymsg = 17 +emailnotifyattn = 17 +emailmicroid = 17 +language = 2 +timezone = 2 +emailpost = 17 +jabber = 2 +jabbernotify = 17 +jabberreplies = 17 +jabbermicroid = 17 +updatefrompresence = 17 +sms = 2 +carrier = 1 +smsnotify = 17 +smsreplies = 17 +smsemail = 2 +uri = 2 +autosubscribe = 17 +urlshorteningservice = 2 +inboxed = 17 +design_id = 1 +viewdesigns = 17 +created = 142 +modified = 384 + +[user__keys] +id = K +nickname = U +email = U +incomingemail = U +jabber = U +sms = U +uri = U + +[user_group] +id = 129 +nickname = 2 +fullname = 2 +homepage = 2 +description = 34 +location = 2 +original_logo = 2 +homepage_logo = 2 +stream_logo = 2 +mini_logo = 2 +design_id = 1 +created = 142 +modified = 384 + +[user_group__keys] +id = N + +[user_openid] +canonical = 130 +display = 130 +user_id = 129 +created = 142 +modified = 384 + +[user_openid__keys] +canonical = K +display = U + +[user_role] +user_id = 129 +role = 130 +created = 142 + +[user_role__keys] +user_id = K +role = K diff --git a/classes/laconica.links.ini b/classes/statusnet.links.ini index 95c63f3c0..95c63f3c0 100644 --- a/classes/laconica.links.ini +++ b/classes/statusnet.links.ini |