diff --git a/EVENTS.txt b/EVENTS.txt index cf1e39ec83..56cbe14c7a 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -363,6 +363,14 @@ EndProfileRemoteSubscribe: After showing the link to remote subscription - $userprofile: UserProfile widget - &$profile: the profile being shown +StartGroupSubscribe: Before showing the link to remote subscription +- $action: the current action +- $group: the group being shown + +EndGroupSubscribe: After showing the link to remote subscription +- $action: the current action +- $group: the group being shown + StartProfilePageProfileSection: Starting to show the section of the profile page with the actual profile data; hook to prevent showing the profile (e.g.) @@ -787,3 +795,44 @@ StartShowSubscriptionsContent: before showing the subscriptions content EndShowSubscriptionsContent: after showing the subscriptions content - $action: the current action + +StartShowUserGroupsContent: before showing the user groups content +- $action: the current action + +EndShowUserGroupsContent: after showing the user groups content +- $action: the current action + +StartShowAllContent: before showing the all (you and friends) content +- $action: the current action + +EndShowAllContent: after showing the all (you and friends) content +- $action: the current action + +StartShowSubscriptionsMiniList: at the start of subscriptions mini list +- $action: the current action + +EndShowSubscriptionsMiniList: at the end of subscriptions mini list +- $action: the current action + +StartShowGroupsMiniList: at the start of groups mini list +- $action: the current action + +EndShowGroupsMiniList: at the end of groups mini list +- $action: the current action + +StartDeleteUserForm: starting the data in the form for deleting a user +- $action: action being shown +- $user: user being deleted + +EndDeleteUserForm: Ending the data in the form for deleting a user +- $action: action being shown +- $user: user being deleted + +StartDeleteUser: handling the post for deleting a user +- $action: action being shown +- $user: user being deleted + +EndDeleteUser: handling the post for deleting a user +- $action: action being shown +- $user: user being deleted + diff --git a/README b/README index 75336eb83f..45b72e9acc 100644 --- a/README +++ b/README @@ -2,40 +2,40 @@ README ------ -StatusNet 0.9.0 ("Stand") Beta 5 -1 Feb 2010 +StatusNet 0.9.0 ("Stand") +4 Mar 2010 -This is the README file for StatusNet (formerly Laconica), the Open -Source microblogging platform. It includes installation instructions, -descriptions of options you can set, warnings, tips, and general info -for administrators. Information on using StatusNet can be found in the +This is the README file for StatusNet, the Open Source microblogging +platform. It includes installation instructions, descriptions of +options you can set, warnings, tips, and general info for +administrators. Information on using StatusNet can be found in the "doc" subdirectory or in the "help" section on-line. About ===== -StatusNet (formerly Laconica) is a Free and Open Source microblogging -platform. It helps people in a community, company or group to exchange -short (140 characters, by default) messages over the Web. Users can -choose which people to "follow" and receive only their friends' or -colleagues' status messages. It provides a similar service to sites -like Twitter, Jaiku, Yammer, and Plurk. +StatusNet is a Free and Open Source microblogging platform. It helps +people in a community, company or group to exchange short (140 +characters, by default) messages over the Web. Users can choose which +people to "follow" and receive only their friends' or colleagues' +status messages. It provides a similar service to sites like Twitter, +Google Buzz, or Yammer. With a little work, status messages can be sent to mobile phones, instant messenger programs (GTalk/Jabber), and specially-designed desktop clients that support the Twitter API. -StatusNet supports an open standard called OpenMicroBlogging - that lets users on different Web sites -or in different companies subscribe to each others' notices. It -enables a distributed social network spread all across the Web. +StatusNet supports an open standard called OStatus + that lets users in different networks follow +each other. It enables a distributed social network spread all across +the Web. StatusNet was originally developed for the Open Software Service, Identi.ca . It is shared with you in hope that you too make an Open Software Service available to your users. To learn more, please see the Open Software Service Definition 1.1: - http://www.opendefinition.org/ossd + http://www.opendefinition.org/ossd StatusNet, Inc. also offers this software as a Web service, requiring no installation on your part. The software run @@ -77,203 +77,57 @@ for additional terms. New this version ================ -This is a major feature release since version 0.8.2, released Nov 1 2009. -It is also a security release since 0.9.0beta4 January 27 2010. Beta -users are strongly encouraged to upgrade to deal with a security alert. - -http://status.net/wiki/Security_alert_0000002 +This is a major feature release since version 0.8.3, released Feb 1 +2010. It is the final release version of 0.9.0, replacing any beta +versions. Notable changes this version: -- Records of deleted notices are stored without the notice content. -- Much of the optional core featureset has been moved to plugins. -- OpenID support moved from core to a plugin. Helps test the strength of - our plugin architecture and makes it easy to disable this - functionality for e.g. intranet sites. -- Many additional hook events (see EVENTS.txt for details). -- OMB 0.1 support re-implemented using libomb. -- Re-structure database so notices, messages, bios and group - descriptions can be over 140 characters. Limit defined by - site administrator as configuration option; can be unlimited. -- Configuration data now optionally stored in the database, which - overrides any settings in config files. -- Twitter integration re-implemented as a plugin. -- Facebook integration re-implemented as a plugin. -- Role-based authorization framework. Users can have named roles, and - roles can have rights (e.g., to delete notices, change configuration - data, or ban uncooperative users). Default roles 'admin' (for - configuration) and 'moderator' (for community management) added. -- Plugin for PubSubHubBub (PuSH) support. -- Considerable code style cleanup to meet PEAR code standards. -- Made a common library for HTTP-client access which uses available - HTTP libraries where possible. -- Added statuses/home_timeline method to API. -- Hooks for plugins to handle notices offline, either by defining - their own queue handler scripts or to use a default plugin queue - handler script. -- Plugins can now modify the database schema, adding their own tables - or modifying existing ones. -- Groups API. -- Twitter API supports Web caching for some methods. -- Twitter API refactored into one-action-per-method. -- Realtime plugin supports a tear-off window. -- FOAF for groups. -- Moved all JavaScript tags to just before by default, - significantly speeding up apparent page load time. -- Added a Realtime plugin for Orbited server. -- Added a mobile plugin to give a more mobile-phone-friendly layout - when a mobile browser is detected. -- Use CSS sprites for most common icons. -- Fixes for images and buttons on Web output. -- New plugin requires that users validate their email before posting. -- New plugin UserFlag lets users flag other profiles for review. -- Considerably better i18n support. Use TranslateWiki to update - translations. -- Notices and profiles now store location information. -- New plugin, Geonames, for turning location names and lat/long pairs - into structured IDs and vice versa. Architecture reusable for other - systems. -- Better check of license compatibility between site licenses. -- Some improvements in XMPP output. -- Media upload in the API. -- Replies appear in the user's inbox. -- Improved the UI on the bookmarklet. -- StatusNet identities can be used as OpenID identities. -- Script to register a user. -- Script to make someone a group admin. -- Script to make someone a site admin or moderator. -- 'login' command. -- Pluggable authentication. -- LDAP authentication plugin. -- Script for console interaction with the site (!). -- Users don't see group posts from people they've blocked. -- Admin panel interface for changing site configuration. -- Users can be sandboxed (limited contributions) or silenced - (no contributions) by moderators. -- Many changes to make language usage more consistent. -- Sphinx search moved to a plugin. -- GeoURL plugin. -- Profile and group lists support hAtom. -- Massive refactoring of util.js. -- Mapstraction plugin to show maps on inbox and profile pages. -- Play/pause buttons for realtime notices. -- Support for geo microformat. -- Partial support for feed subscriptions, RSSCloud, PubSubHubBub. -- Support for geolocation in browser (Chrome, Firefox). -- Quit trying to negotiate HTML format. Always use text/html. - We lose, and so do Web standards. Boo. -- Better logging of request info. -- Better output for errors in Web interface. -- No longer store .mo files; these need to be generated. -- Minify plugin. -- Events to allow pluginizing logger. -- New framework for plugin localization. -- Gravatar plugin. -- Add support for "repeats" (similar to Twitter's "retweets"). -- Support for repeats in Twitter API. -- Better notification of direct messages. -- New plugin to add "powered by StatusNet" to logo. -- Returnto works for private sites. -- Localisation updates, including new Persian translation. -- CAS authentication plugin -- Get rid of DB_DataObject native cache (big memory leaker) -- setconfig.php script to set configuration variables -- Blacklist plugin, to blacklist URLs and nicknames -- Users can set flag whether they want to share location - both in notice form (for one notice) and profile settings - (any notice) -- notice inboxes moved from normalized notice_inbox table to - denormalized inbox table -- Automatic compression of Memcache -- Memory caching pluginized -- Memcache, XCache, APC and Diskcache plugins -- A script to update user locations -- cache empty query results -- A sample plugin to show best plugin practices -- CacheLog plugin to debug cache accesses -- Require users to login to view attachments on private sites -- Plugin to use Mollom spam detection service -- Plugin for RSSCloud -- Add an array of default plugins -- A version action to give credit to contributors and plugin - developers -- Daemon to read IMAP mailbox instead of using a mailbox script -- Pass session information between SSL and non-SSL server - when SSL set to 'sometimes' -- Major refactoring of queue handlers to manage very - large hosting site (like status.net) -- SubscriptionThrottle plugin to prevent subscription spamming -- Don't enqueue into plugin or SMS queues when disabled (breaks unqueuehandler if SMS queue isn't attached) -- Improve name validation checks on local File references -- fix local file include vulnerability in doc.php -- Reusing fixed selector name for 'processing' in util.js -- Removed hAtom pattern from registration page. -- restructuring of User::registerNew() lost password munging -- Add a script to clear the cache for a given key -- buggy fetch for site owner -- Added missing concat of in Realtime response -- Updated XHR binded events to work better in jQuery 1.4.1. Using .live() for event delegation instead of jQuery.data() and checking to see if an element was previously binded. -- Updated jQuery Form Plugin from v2.17 to v2.36 -- Updated jQuery JavaScript Library from v1.3.2 to v1.4.1 -- move schema.type.php to typeschema.php like other files -- Add Really Simple Discovery (RSD) support -- Add a robots.txt URL to the site root -- error clearing tags for profiles from memcached -- on exceptions, stomp logs the error and reenqueues -- add lat, lon, location and remove closing tag from geocode.php -- Use passed-in lat long in geocode.php -- better handling of null responses from geonames.org -- Globalized form notice data geo values -- Using jQuery chaining in FormNoticeXHR -- Using form object instead of form_id and find(). Slightly faster and easier to read. -- removed describeTable from base class, and fixed it up in pgsql -- getTableDef() mostly working in postgres -- move the schema DDL sql off into seperate files for each db we support -- plugin to limit number of registered users -- add hooks for user registration -- live fast, die young in bash scripts -- for single-user mode, retrieve either site owner or defined nickname -- method to get the site owner -- define a constant for the 'owner' role of a site -- add simple cache getter/setter static functions to Memcached_DataObject -- Adds notice author's name to @title in Realtime response -- Hides .author from XHR response in showstream -- Hides .author from XHR response in showstream -- Fix more fatal errors in queue edge cases -- Don't attempt to resend XMPP messages that can't be broadcast due to the profile being deleted. -- Wrap each bit of distrib queue handler's saving operation in a try/catch; log exceptions but let everything else continue. -- Log exceptions from queuedaemon.php if they're not already caught -- Move sessions settings to its own panel -- Fixes for status_network db object .ini and tag setter script -- Add a script to set tags for sites -- Adjust API authentication to also check for OAuth protocol params in the HTTP Authorization header, as defined in OAuth HTTP Authorization Scheme. -- Last-chance distribution if enqueueing fails -- Manual failover for stomp queues. -- lost config in index.php made all traffic go to master -- "Revert "move RW setup above user get in index.php so remember_me works"" -- Revert "move RW setup above user get in index.php so remember_me works" -- move RW setup above user get in index.php so remember_me works -- hide most DB_DataObject errors -- always set up database_rw, regardless, so cached sessions work -- update mysqltimestamps on insert and update -- additional debugging data for Sessions -- 'Sign in with Twitter' button img -- Update to biz theme -- Remove redundant session token field from form (was already being added by base class). -- 'Sign in with Twitter' button img -- Can now set $config['queue']['stomp_persistent'] = false; to explicitly disable persistence when we queue items -- Showing processing indicator for form_repeat on submit instead of form -- Removed avatar from repeat of username (matches noticelist) -- Removed unused variable assignment for avatar URL and added missing fn -- Don't preemptively close existing DB connections for web views (needed to keep # of conns from going insane on multi-site queue daemons, so just doing for CLI) May, or may not, help with mystery session problems -- dropping the setcookie() call from common_ensure_session() since we're pretty sure it's unnecessary -- append '/' on cookie path for now (may still need some refactoring) -- set session cookie correctly -- Fix for Mapstraction plugin's zoomed map links -- debug log line for control channel sub -- Move faceboookapp.js to the Facebook plugin -- fix for fix for bad realtime JS load -- default 24-hour expiry on Memcached objects where not specified. +- Support for the new distributed status update standard OStatus + , based on PubSubHubbub, Salmon, Webfinger, + and Activity Streams. +- Support for location using the Geolocation API. Notices are (optionally) + marked with lat-long information with geo microformats, and can be shown + on a map. +- No fixed content size. Notice size is configurable, from 1 to + unlimited number of characters. Default is still 140! +- An authorization framework, allowing different levels of users. +- A Web-based administration panel. +- A moderation system that lets site moderators sandbox, silence, + or delete uncooperative users. +- A flag system that lets users flag profiles for moderator review. +- Support for OAuth authentication in the Twitter + API. +- User roles system that lets the owner of the site to assign + administrator and moderator roles to other users. +- A pluggable authentication system. +- An authentication plugin for LDAP servers. +- Many features that were core in 0.8.x are now plugins, such + as OpenID, Twitter integration, Facebook integration +- A much-improved offline processing system +- In-browser "realtime" updates using a number of realtime + servers (Meteor, Orbited, Cometd) +- A plugin to provide an interface optimized for mobile browsers +- Support for Facebook Connect +- Support for logging in with a Twitter account +- Vastly improved translation with additional languages and + translation in plugins +- Support for all-SSL instances +- Core support for "repeats" (like Twitter's "retweets") +- Pluggable caching system, with plugins for Memcached, + APC, XCache, and a disk-based cache +- Plugin to support RSSCloud +- A framework for adding advertisements to a public site, + and plugins for Google AdSense and OpenX server +- Plugins to throttle excessive subscriptions and registrations. +- A plugin to blacklist particular URLs or nicknames. + +There are also literally thousands of bugs fixed and minor features +added. A full changelog is available at http://status.net/wiki/StatusNet_0.9.0. + +Under the covers, the software has a vastly improved plugin and +extension mechanism that makes writing powerful and flexible additions +to the core functionality much easier. Prerequisites ============= @@ -312,6 +166,8 @@ For some functionality, you will also need the following extensions: - Sphinx Search. A client for the sphinx server, an alternative to MySQL or Postgresql fulltext search. You will also need a Sphinx server to serve the search queries. +- bcmath or gmp. For Salmon signatures (part of OStatus). Needed + if you have OStatus configured. You will almost definitely get 2-3 times better performance from your site if you install a PHP bytecode cache/accelerator. Some well-known @@ -361,6 +217,9 @@ and the URLs are listed here for your convenience. - PEAR Validate is an oEmbed dependency. - PEAR Net_URL2 is an oEmbed dependency. - Console_GetOpt for parsing command-line options. +- libomb. a library for implementing OpenMicroBlogging 0.1, the + predecessor to OStatus. +- HTTP_Request2, a library for making HTTP requests. A design goal of StatusNet is that the basic Web functionality should work on even the most restrictive commercial hosting services. @@ -378,9 +237,9 @@ especially if you've previously installed PHP/MySQL packages. 1. Unpack the tarball you downloaded on your Web server. Usually a command like this will work: - tar zxf statusnet-0.8.2.tar.gz + tar zxf statusnet-0.9.0.tar.gz - ...which will make a statusnet-0.8.2 subdirectory in your current + ...which will make a statusnet-0.9.0 subdirectory in your current directory. (If you don't have shell access on your Web server, you may have to unpack the tarball on your local computer and FTP the files to the server.) @@ -388,34 +247,34 @@ especially if you've previously installed PHP/MySQL packages. 2. Move the tarball to a directory of your choosing in your Web root directory. Usually something like this will work: - mv statusnet-0.8.2 /var/www/mublog + mv statusnet-0.9.0 /var/www/statusnet - This will make your StatusNet instance available in the mublog path of - your server, like "http://example.net/mublog". "microblog" or + This will make your StatusNet instance available in the statusnet path of + your server, like "http://example.net/statusnet". "microblog" or "statusnet" might also be good path names. If you know how to configure virtual hosts on your web server, you can try setting up "http://micro.example.net/" or the like. 3. Make your target directory writeable by the Web server. - chmod a+w /var/www/mublog/ + chmod a+w /var/www/statusnet/ On some systems, this will probably work: - chgrp www-data /var/www/mublog/ - chmod g+w /var/www/mublog/ + chgrp www-data /var/www/statusnet/ + chmod g+w /var/www/statusnet/ If your Web server runs as another user besides "www-data", try that user's default group instead. As a last resort, you can create - a new group like "mublog" and add the Web server's user to the group. + a new group like "statusnet" and add the Web server's user to the group. 4. You should also take this moment to make your avatar, background, and file subdirectories writeable by the Web server. An insecure way to do this is: - chmod a+w /var/www/mublog/avatar - chmod a+w /var/www/mublog/background - chmod a+w /var/www/mublog/file + chmod a+w /var/www/statusnet/avatar + chmod a+w /var/www/statusnet/background + chmod a+w /var/www/statusnet/file You can also make the avatar, background, and file directories writeable by the Web server group, as noted above. @@ -423,7 +282,7 @@ especially if you've previously installed PHP/MySQL packages. 5. Create a database to hold your microblog data. Something like this should work: - mysqladmin -u "username" --password="password" create statusnet + mysqladmin -u "username" --password="password" create statusnet Note that StatusNet must have its own database; you can't share the database with another program. You can name it whatever you want, @@ -437,17 +296,17 @@ especially if you've previously installed PHP/MySQL packages. database. If you have shell access, this will probably work from the MySQL shell: - GRANT ALL on statusnet.* - TO 'lacuser'@'localhost' - IDENTIFIED BY 'lacpassword'; + GRANT ALL on statusnet.* + TO 'statusnetuser'@'localhost' + IDENTIFIED BY 'statusnetpassword'; - You should change 'lacuser' and 'lacpassword' to your preferred new + You should change 'statusnetuser' and 'statusnetpassword' to your preferred new username and password. You may want to test logging in to MySQL as this new user. 7. In a browser, navigate to the StatusNet install script; something like: - http://yourserver.example.com/mublog/install.php + http://yourserver.example.com/statusnet/install.php Enter the database connection information and your site name. The install program will configure your site and install the initial, @@ -467,16 +326,16 @@ By default, StatusNet will use URLs that include the main PHP program's name in them. For example, a user's home profile might be found at: - http://example.org/mublog/index.php/mublog/fred + http://example.org/statusnet/index.php/statusnet/fred On certain systems that don't support this kind of syntax, they'll look like this: - http://example.org/mublog/index.php?p=mublog/fred + http://example.org/statusnet/index.php?p=statusnet/fred It's possible to configure the software so it looks like this instead: - http://example.org/mublog/fred + http://example.org/statusnet/fred These "fancy URLs" are more readable and memorable for users. To use fancy URLs, you must either have Apache 2.x with .htaccess enabled and @@ -501,7 +360,7 @@ your server. You should now be able to navigate to a "fancy" URL on your server, like: - http://example.net/mublog/main/register + http://example.net/statusnet/main/register If you changed your HTTP server configuration, you may need to restart the server first. @@ -512,11 +371,11 @@ directory is 'All' in your Apache configuration file. This is usually /etc/apache2/sites-available/default. See the Apache documentation for .htaccess files for more details: - http://httpd.apache.org/docs/2.2/howto/htaccess.html + http://httpd.apache.org/docs/2.2/howto/htaccess.html Also, check that mod_rewrite is installed and enabled: - http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html + http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html Sphinx ------ @@ -524,8 +383,8 @@ Sphinx To use a Sphinx server to search users and notices, you'll need to enable the SphinxSearch plugin. Add to your config.php: - addPlugin('SphinxSearch'); - $config['sphinx']['server'] = 'searchhost.local'; + addPlugin('SphinxSearch'); + $config['sphinx']['server'] = 'searchhost.local'; You also need to install, compile and enable the sphinx pecl extension for php on the client side, which itself depends on the sphinx development files. @@ -553,33 +412,33 @@ For this to work, there *must* be a domain or sub-domain for which all 1. Run the SQL script carrier.sql in your StatusNet database. This will usually work: - mysql -u "lacuser" --password="lacpassword" statusnet < db/carrier.sql + mysql -u "statusnetuser" --password="statusnetpassword" statusnet < db/carrier.sql This will populate your database with a list of wireless carriers that support email SMS gateways. 2. Make sure the maildaemon.php file is executable: - chmod +x scripts/maildaemon.php + chmod +x scripts/maildaemon.php Note that "daemon" is kind of a misnomer here; the script is more of a filter than a daemon. 2. Edit /etc/aliases on your mail server and add the following line: - *: /path/to/statusnet/scripts/maildaemon.php + *: /path/to/statusnet/scripts/maildaemon.php 3. Run whatever code you need to to update your aliases database. For many mail servers (Postfix, Exim, Sendmail), this should work: - newaliases + newaliases You may need to restart your mail server for the new database to take effect. 4. Set the following in your config.php file: - $config['mail']['domain'] = 'yourdomain.example.net'; + $config['mail']['domain'] = 'yourdomain.example.net'; At this point, post-by-email and post-by-SMS-gateway should work. Note that if your mail server is on a different computer from your email @@ -633,7 +492,7 @@ search, indexing, bridging, or other cool services. To configure a downstream site to receive your public stream, add their "JID" (Jabber ID) to your config.php as follows: - $config['xmpp']['public'][] = 'downstream@example.net'; + $config['xmpp']['public'][] = 'downstream@example.net'; (Don't miss those square brackets at the end.) Note that your XMPP broadcasting must be configured as mentioned above. Although you can @@ -643,7 +502,7 @@ consider setting up queues and daemons. Queues and daemons ------------------ -Some activities that StatusNet needs to do, like broadcast OMB, SMS, +Some activities that StatusNet needs to do, like broadcast OStatus, SMS, and XMPP messages, can be 'queued' and done by off-line bots instead. For this to work, you must be able to run long-running offline processes, either on your main Web server or on another server you @@ -662,21 +521,19 @@ server is probably a good idea for high-volume sites. 3. In your config.php files (both the Web server and the queues server!), set the following variable: - $config['queue']['enabled'] = true; + $config['queue']['enabled'] = true; You may also want to look at the 'daemon' section of this file for more daemon options. Note that if you set the 'user' and/or 'group' options, you'll need to create that user and/or group by hand. They're not created automatically. -4. On the queues server, run the command scripts/startdaemons.sh. It - needs as a parameter the install path; if you run it from the - StatusNet dir, "." should suffice. +4. On the queues server, run the command scripts/startdaemons.sh. This will run the queue handlers: * queuedaemon.php - polls for queued items for inbox processing and - pushing out to OMB, SMS, XMPP, etc. + pushing out to OStatus, SMS, XMPP, etc. * xmppdaemon.php - listens for new XMPP messages from users and stores them as notices in the database; also pulls queued XMPP output from queuedaemon.php to push out to clients. @@ -685,6 +542,9 @@ These two daemons will automatically restart in most cases of failure including memory leaks (if a memory_limit is set), but may still die or behave oddly if they lose connections to the XMPP or queue servers. +Additional daemons may be also started by this script for certain +plugins, such as the Twitter bridge. + It may be a good idea to use a daemon-monitoring service, like 'monit', to check their status and keep them running. @@ -693,46 +553,11 @@ default. This can be useful for starting, stopping, and monitoring the daemons. Since version 0.8.0, it's now possible to use a STOMP server instead of -our kind of hacky home-grown DB-based queue solution. See the "queues" -config section below for how to configure to use STOMP. As of this -writing, the software has been tested with ActiveMQ. +our kind of hacky home-grown DB-based queue solution. This is strongly +recommended for best response time, especially when using XMPP. -Sitemaps --------- - -Sitemap files are a very nice way of telling -search engines and other interested bots what's available on your site -and what's changed recently. You can generate sitemap files for your -StatusNet instance. - -1. Choose your sitemap URL layout. StatusNet creates a number of - sitemap XML files for different parts of your site. You may want to - put these in a sub-directory of your StatusNet directory to avoid - clutter. The sitemap index file tells the search engines and other - bots where to find all the sitemap files; it *must* be in the main - installation directory or higher. Both types of file must be - available through HTTP. - -2. To generate your sitemaps, run the following command on your server: - - php scripts/sitemap.php -f index-file-path -d sitemap-directory -u URL-prefix-for-sitemaps - - Here, index-file-path is the full path to the sitemap index file, - like './sitemapindex.xml'. sitemap-directory is the directory where - you want the sitemaps stored, like './sitemaps/' (make sure the dir - exists). URL-prefix-for-sitemaps is the full URL for the sitemap dir, - typically something like . - -You can use several methods for submitting your sitemap index to -search engines to get your site indexed. One is to add a line like the -following to your robots.txt file: - - Sitemap: /mublog/sitemapindex.xml - -This is a good idea for letting *all* Web spiders know about your -sitemap. You can also submit sitemap files to major search engines -using their respective "Webmaster centres"; see sitemaps.org for links -to these resources. +See the "queues" config section below for how to configure to use STOMP. +As of this writing, the software has been tested with ActiveMQ 5.3. Themes ------ @@ -755,15 +580,15 @@ following files: display.css: a CSS2 file for "default" styling for all browsers. ie6.css: a CSS2 file for override styling for fixing up Internet - Explorer 6. + Explorer 6. ie7.css: a CSS2 file for override styling for fixing up Internet - Explorer 7. + Explorer 7. logo.png: a logo image for the site. default-avatar-profile.png: a 96x96 pixel image to use as the avatar for - users who don't upload their own. + users who don't upload their own. default-avatar-stream.png: Ditto, but 48x48. For streams of notices. default-avatar-mini.png: Ditto ditto, but 24x24. For subscriptions - listing on profile pages. + listing on profile pages. You may want to start by copying the files from the default theme to your own directory. @@ -803,30 +628,26 @@ not visible to non-logged-in users. This might be useful for workgroups who want to share a microblogging site for project management, but host it on a public server. -Note that this is an experimental feature; total privacy is not -guaranteed or ensured. Also, privacy is all-or-nothing for a site; you -can't have some accounts or notices private, and others public. -Finally, the interaction of private sites with OpenMicroBlogging is -undefined. Remote users won't be able to subscribe to users on a -private site, but users of the private site may be able to subscribe -to users on a remote site. (Or not... it's not well tested.) The -"proper behaviour" hasn't been defined here, so handle with care. +Total privacy is not guaranteed or ensured. Also, privacy is +all-or-nothing for a site; you can't have some accounts or notices +private, and others public. The interaction of private sites +with OStatus is undefined. Access to file attachments can also be restricted to logged-in users only. 1. Add a directory outside the web root where your file uploads will be stored. Usually a command like this will work: - mkdir /var/www/mublog-files + mkdir /var/www/statusnet-files 2. Make the file uploads directory writeable by the web server. An insecure way to do this is: - chmod a+x /var/www/mublog-files + chmod a+x /var/www/statusnet-files 3. Tell StatusNet to use this directory for file uploads. Add a line like this to your config.php: - $config['attachments']['dir'] = '/var/www/mublog-files'; + $config['attachments']['dir'] = '/var/www/statusnet-files'; Upgrading ========= @@ -841,7 +662,7 @@ with this situation. If you've been using StatusNet 0.7, 0.6, 0.5 or lower, or if you've been tracking the "git" version of the software, you will probably want to upgrade and keep your existing data. There is no automated -upgrade procedure in StatusNet 0.8.2. Try these step-by-step +upgrade procedure in StatusNet 0.9.0. Try these step-by-step instructions; read to the end first before trying them. 0. Download StatusNet and set up all the prerequisites as if you were @@ -861,29 +682,29 @@ instructions; read to the end first before trying them. maildaemon.php file, and running something like "newaliases". 5. Once all writing processes to your site are turned off, make a final backup of the Web directory and database. -6. Move your StatusNet directory to a backup spot, like "mublog.bak". -7. Unpack your StatusNet 0.8.2 tarball and move it to "mublog" or +6. Move your StatusNet directory to a backup spot, like "statusnet.bak". +7. Unpack your StatusNet 0.9.0 tarball and move it to "statusnet" or wherever your code used to be. 8. Copy the config.php file and avatar directory from your old directory to your new directory. 9. Copy htaccess.sample to .htaccess in the new directory. Change the RewriteBase to use the correct path. 10. Rebuild the database. (You can safely skip this step and go to #12 - if you're upgrading from another 0.8.x version). + if you're upgrading from another 0.9.x version). NOTE: this step is destructive and cannot be reversed. YOU CAN EASILY DESTROY YOUR SITE WITH THIS STEP. Don't do it without a known-good backup! - If your database is at version 0.7.4, you can run a special upgrade - script: + If your database is at version 0.8.0 or above, you can run a + special upgrade script: - mysql -u -p db/074to080.sql + mysql -u -p db/08to09.sql Otherwise, go to your StatusNet directory and AFTER YOU MAKE A BACKUP run the rebuilddb.sh script like this: - ./scripts/rebuilddb.sh rootuser rootpassword database db/statusnet.sql + ./scripts/rebuilddb.sh rootuser rootpassword database db/statusnet.sql Here, rootuser and rootpassword are the username and password for a user who can drop and create databases as well as tables; typically @@ -943,10 +764,17 @@ Configuration options The main configuration file for StatusNet (excepting configurations for dependency software) is config.php in your StatusNet directory. If you -edit any other file in the directory, like lib/common.php (where most +edit any other file in the directory, like lib/default.php (where most of the defaults are defined), you will lose your configuration options in any upgrade, and you will wish that you had been more careful. +Starting with version 0.9.0, a Web based configuration panel has been +added to StatusNet. The preferred method for changing config options is +to use this panel. + +A command-line script, setconfig.php, can be used to set individual +configuration options. It's in the scripts/ directory. + Starting with version 0.7.1, you can put config files in the /etc/statusnet/ directory on your server, if it exists. Config files will be included in this order: @@ -960,7 +788,7 @@ Almost all configuration options are made through a two-dimensional associative array, cleverly named $config. A typical configuration line will be: - $config['section']['option'] = value; + $config['section']['option'] = value; For brevity, the following documentation describes each section and option. @@ -972,79 +800,79 @@ This section is a catch-all for site-wide variables. name: the name of your site, like 'YourCompany Microblog'. server: the server part of your site's URLs, like 'example.net'. -path: The path part of your site's URLs, like 'mublog' or '' - (installed in root). +path: The path part of your site's URLs, like 'statusnet' or '' + (installed in root). fancy: whether or not your site uses fancy URLs (see Fancy URLs - section above). Default is false. + section above). Default is false. logfile: full path to a file for StatusNet to save logging - information to. You may want to use this if you don't have - access to syslog. + information to. You may want to use this if you don't have + access to syslog. logdebug: whether to log additional debug info like backtraces on - hard errors. Default false. + hard errors. Default false. locale_path: full path to the directory for locale data. Unless you - store all your locale data in one place, you probably - don't need to use this. + store all your locale data in one place, you probably + don't need to use this. language: default language for your site. Defaults to US English. - Note that this is overridden if a user is logged in and has - selected a different language. It is also overridden if the - user is NOT logged in, but their browser requests a different - langauge. Since pretty much everybody's browser requests a - language, that means that changing this setting has little or - no effect in practice. + Note that this is overridden if a user is logged in and has + selected a different language. It is also overridden if the + user is NOT logged in, but their browser requests a different + langauge. Since pretty much everybody's browser requests a + language, that means that changing this setting has little or + no effect in practice. languages: A list of languages supported on your site. Typically you'd - only change this if you wanted to disable support for one - or another language: - "unset($config['site']['languages']['de'])" will disable - support for German. + only change this if you wanted to disable support for one + or another language: + "unset($config['site']['languages']['de'])" will disable + support for German. theme: Theme for your site (see Theme section). Two themes are - provided by default: 'default' and 'stoica' (the one used by - Identi.ca). It's appreciated if you don't use the 'stoica' theme - except as the basis for your own. + provided by default: 'default' and 'stoica' (the one used by + Identi.ca). It's appreciated if you don't use the 'stoica' theme + except as the basis for your own. email: contact email address for your site. By default, it's extracted - from your Web server environment; you may want to customize it. + from your Web server environment; you may want to customize it. broughtbyurl: name of an organization or individual who provides the - service. Each page will include a link to this name in the - footer. A good way to link to the blog, forum, wiki, - corporate portal, or whoever is making the service available. + service. Each page will include a link to this name in the + footer. A good way to link to the blog, forum, wiki, + corporate portal, or whoever is making the service available. broughtby: text used for the "brought by" link. timezone: default timezone for message display. Users can set their - own time zone. Defaults to 'UTC', which is a pretty good default. + own time zone. Defaults to 'UTC', which is a pretty good default. closed: If set to 'true', will disallow registration on your site. - This is a cheap way to restrict accounts to only one - individual or group; just register the accounts you want on - the service, *then* set this variable to 'true'. + This is a cheap way to restrict accounts to only one + individual or group; just register the accounts you want on + the service, *then* set this variable to 'true'. inviteonly: If set to 'true', will only allow registration if the user - was invited by an existing user. + was invited by an existing user. private: If set to 'true', anonymous users will be redirected to the - 'login' page. Also, API methods that normally require no - authentication will require it. Note that this does not turn - off registration; use 'closed' or 'inviteonly' for the - behaviour you want. + 'login' page. Also, API methods that normally require no + authentication will require it. Note that this does not turn + off registration; use 'closed' or 'inviteonly' for the + behaviour you want. notice: A plain string that will appear on every page. A good place - to put introductory information about your service, or info about - upgrades and outages, or other community info. Any HTML will - be escaped. + to put introductory information about your service, or info about + upgrades and outages, or other community info. Any HTML will + be escaped. logo: URL of an image file to use as the logo for the site. Overrides - the logo in the theme, if any. + the logo in the theme, if any. ssl: Whether to use SSL and https:// URLs for some or all pages. - Possible values are 'always' (use it for all pages), 'never' - (don't use it for any pages), or 'sometimes' (use it for - sensitive pages that include passwords like login and registration, - but not for regular pages). Default to 'never'. + Possible values are 'always' (use it for all pages), 'never' + (don't use it for any pages), or 'sometimes' (use it for + sensitive pages that include passwords like login and registration, + but not for regular pages). Default to 'never'. sslserver: use an alternate server name for SSL URLs, like - 'secure.example.org'. You should be careful to set cookie - parameters correctly so that both the SSL server and the - "normal" server can access the session cookie and - preferably other cookies as well. + 'secure.example.org'. You should be careful to set cookie + parameters correctly so that both the SSL server and the + "normal" server can access the session cookie and + preferably other cookies as well. shorturllength: Length of URL at which URLs in a message exceeding 140 - characters will be sent to the user's chosen - shortening service. + characters will be sent to the user's chosen + shortening service. dupelimit: minimum time allowed for one person to say the same thing - twice. Default 60s. Anything lower is considered a user - or UI error. + twice. Default 60s. Anything lower is considered a user + or UI error. textlimit: default max size for texts in the site. Defaults to 140. - 0 means no limit. Can be fine-tuned for notices, messages, - profile bios and group descriptions. + 0 means no limit. Can be fine-tuned for notices, messages, + profile bios and group descriptions. db -- @@ -1054,44 +882,44 @@ DB_DataObject (see ). The ones that you may want to set are listed below for clarity. database: a DSN (Data Source Name) for your StatusNet database. This is - in the format 'protocol://username:password@hostname/databasename', - where 'protocol' is 'mysql' or 'mysqli' (or possibly 'postgresql', if you - really know what you're doing), 'username' is the username, - 'password' is the password, and etc. + in the format 'protocol://username:password@hostname/databasename', + where 'protocol' is 'mysql' or 'mysqli' (or possibly 'postgresql', if you + really know what you're doing), 'username' is the username, + 'password' is the password, and etc. ini_yourdbname: if your database is not named 'statusnet', you'll need - to set this to point to the location of the - statusnet.ini file. Note that the real name of your database - should go in there, not literally 'yourdbname'. + to set this to point to the location of the + statusnet.ini file. Note that the real name of your database + should go in there, not literally 'yourdbname'. db_driver: You can try changing this to 'MDB2' to use the other driver - type for DB_DataObject, but note that it breaks the OpenID - libraries, which only support PEAR::DB. + type for DB_DataObject, but note that it breaks the OpenID + libraries, which only support PEAR::DB. debug: On a database error, you may get a message saying to set this - value to 5 to see debug messages in the browser. This breaks - just about all pages, and will also expose the username and - password + value to 5 to see debug messages in the browser. This breaks + just about all pages, and will also expose the username and + password quote_identifiers: Set this to true if you're using postgresql. type: either 'mysql' or 'postgresql' (used for some bits of - database-type-specific SQL in the code). Defaults to mysql. + database-type-specific SQL in the code). Defaults to mysql. mirror: you can set this to an array of DSNs, like the above - 'database' value. If it's set, certain read-only actions will - use a random value out of this array for the database, rather - than the one in 'database' (actually, 'database' is overwritten). - You can offload a busy DB server by setting up MySQL replication - and adding the slaves to this array. Note that if you want some - requests to go to the 'database' (master) server, you'll need - to include it in this array, too. + 'database' value. If it's set, certain read-only actions will + use a random value out of this array for the database, rather + than the one in 'database' (actually, 'database' is overwritten). + You can offload a busy DB server by setting up MySQL replication + and adding the slaves to this array. Note that if you want some + requests to go to the 'database' (master) server, you'll need + to include it in this array, too. utf8: whether to talk to the database in UTF-8 mode. This is the default - with new installations, but older sites may want to turn it off - until they get their databases fixed up. See "UTF-8 database" - above for details. + with new installations, but older sites may want to turn it off + until they get their databases fixed up. See "UTF-8 database" + above for details. schemacheck: when to let plugins check the database schema to add - tables or update them. Values can be 'runtime' (default) - or 'script'. 'runtime' can be costly (plugins check the - schema on every hit, adding potentially several db - queries, some quite long), but not everyone knows how to - run a script. If you can, set this to 'script' and run - scripts/checkschema.php whenever you install or upgrade a - plugin. + tables or update them. Values can be 'runtime' (default) + or 'script'. 'runtime' can be costly (plugins check the + schema on every hit, adding potentially several db + queries, some quite long), but not everyone knows how to + run a script. If you can, set this to 'script' and run + scripts/checkschema.php whenever you install or upgrade a + plugin. syslog ------ @@ -1100,13 +928,13 @@ By default, StatusNet sites log error messages to the syslog facility. (You can override this using the 'logfile' parameter described above). appname: The name that StatusNet uses to log messages. By default it's - "statusnet", but if you have more than one installation on the - server, you may want to change the name for each instance so - you can track log messages more easily. + "statusnet", but if you have more than one installation on the + server, you may want to change the name for each instance so + you can track log messages more easily. priority: level to log at. Currently ignored. facility: what syslog facility to used. Defaults to LOG_USER, only - reset if you know what syslog is and have a good reason - to change it. + reset if you know what syslog is and have a good reason + to change it. queue ----- @@ -1117,18 +945,52 @@ sending out SMS email or XMPP messages, for off-line processing. See enabled: Whether to uses queues. Defaults to false. subsystem: Which kind of queueserver to use. Values include "db" for - our hacked-together database queuing (no other server - required) and "stomp" for a stomp server. + our hacked-together database queuing (no other server + required) and "stomp" for a stomp server. stomp_server: "broker URI" for stomp server. Something like - "tcp://hostname:61613". More complicated ones are - possible; see your stomp server's documentation for - details. + "tcp://hostname:61613". More complicated ones are + possible; see your stomp server's documentation for + details. queue_basename: a root name to use for queues (stomp only). Typically - something like '/queue/sitename/' makes sense. + something like '/queue/sitename/' makes sense. If running + multiple instances on the same server, make sure that + either this setting or $config['site']['nickname'] are + unique for each site to keep them separate. + stomp_username: username for connecting to the stomp server; defaults - to null. + to null. stomp_password: password for connecting to the stomp server; defaults - to null. + to null. + +stomp_persistent: keep items across queue server restart, if enabled. + +softlimit: an absolute or relative "soft memory limit"; daemons will + restart themselves gracefully when they find they've hit + this amount of memory usage. Defaults to 90% of PHP's global + memory_limit setting. + +inboxes: delivery of messages to receiver's inboxes can be delayed to + queue time for best interactive performance on the sender. + This may however be annoyingly slow when using the DB queues, + so you can set this to false if it's causing trouble. + +breakout: for stomp, individual queues are by default grouped up for + best scalability. If some need to be run by separate daemons, + etc they can be manually adjusted here. + + Default will share all queues for all sites within each group. + Specify as / or //, + using nickname identifier as site. + + 'main/distrib' separate "distrib" queue covering all sites + 'xmpp/xmppout/mysite' separate "xmppout" queue covering just 'mysite' + +max_retries: for stomp, drop messages after N failed attempts to process. + Defaults to 10. + +dead_letter_dir: for stomp, optional directory to dump data on failed + queue processing events after discarding them. + license ------- @@ -1138,11 +1000,11 @@ choice for any public site. Note that some other servers will not accept notices if you apply a stricter license than this. type: one of 'cc' (for Creative Commons licenses), 'allrightsreserved' - (default copyright), or 'private' (for private and confidential - information). + (default copyright), or 'private' (for private and confidential + information). owner: for 'allrightsreserved' or 'private', an assigned copyright - holder (for example, an employer for a private site). If - not specified, will be attributed to 'contributors'. + holder (for example, an employer for a private site). If + not specified, will be attributed to 'contributors'. url: URL of the license, used for links. title: Title for the license, like 'Creative Commons Attribution 3.0'. image: A button shown on each page for the license. @@ -1154,9 +1016,9 @@ This is for configuring out-going email. We use PEAR's Mail module, see: http://pear.php.net/manual/en/package.mail.mail.factory.php backend: the backend to use for mail, one of 'mail', 'sendmail', and - 'smtp'. Defaults to PEAR's default, 'mail'. + 'smtp'. Defaults to PEAR's default, 'mail'. params: if the mail backend requires any parameters, you can provide - them in an associative array. + them in an associative array. nickname -------- @@ -1164,36 +1026,36 @@ nickname This is for configuring nicknames in the service. blacklist: an array of strings for usernames that may not be - registered. A default array exists for strings that are - used by StatusNet (e.g. 'doc', 'main', 'avatar', 'theme') - but you may want to add others if you have other software - installed in a subdirectory of StatusNet or if you just - don't want certain words used as usernames. + registered. A default array exists for strings that are + used by StatusNet (e.g. 'doc', 'main', 'avatar', 'theme') + but you may want to add others if you have other software + installed in a subdirectory of StatusNet or if you just + don't want certain words used as usernames. featured: an array of nicknames of 'featured' users of the site. - Can be useful to draw attention to well-known users, or - interesting people, or whatever. + Can be useful to draw attention to well-known users, or + interesting people, or whatever. avatar ------ For configuring avatar access. -dir: Directory to look for avatar files and to put them into. - Defaults to avatar subdirectory of install directory; if - you change it, make sure to change path, too. -path: Path to avatars. Defaults to path for avatar subdirectory, - but you can change it if you wish. Note that this will - be included with the avatar server, too. +dir: Directory to look for avatar files and to put them into. + Defaults to avatar subdirectory of install directory; if + you change it, make sure to change path, too. +path: Path to avatars. Defaults to path for avatar subdirectory, + but you can change it if you wish. Note that this will + be included with the avatar server, too. server: If set, defines another server where avatars are stored in the - root directory. Note that the 'avatar' subdir still has to be - writeable. You'd typically use this to split HTTP requests on - the client to speed up page loading, either with another - virtual server or with an NFS or SAMBA share. Clients - typically only make 2 connections to a single server at a - time , so this can parallelize the job. - Defaults to null. -ssl: Whether to access avatars using HTTPS. Defaults to null, meaning - to guess based on site-wide SSL settings. + root directory. Note that the 'avatar' subdir still has to be + writeable. You'd typically use this to split HTTP requests on + the client to speed up page loading, either with another + virtual server or with an NFS or SAMBA share. Clients + typically only make 2 connections to a single server at a + time , so this can parallelize the job. + Defaults to null. +ssl: Whether to access avatars using HTTPS. Defaults to null, meaning + to guess based on site-wide SSL settings. public ------ @@ -1201,41 +1063,41 @@ public For configuring the public stream. localonly: If set to true, only messages posted by users of this - service (rather than other services, filtered through OMB) - are shown in the public stream. Default true. + service (rather than other services, filtered through OMB) + are shown in the public stream. Default true. blacklist: An array of IDs of users to hide from the public stream. - Useful if you have someone making excessive Twitterfeed posts - to the site, other kinds of automated posts, testing bots, etc. + Useful if you have someone making excessive Twitterfeed posts + to the site, other kinds of automated posts, testing bots, etc. autosource: Sources of notices that are from automatic posters, and thus - should be kept off the public timeline. Default empty. + should be kept off the public timeline. Default empty. theme ----- server: Like avatars, you can speed up page loading by pointing the - theme file lookup to another server (virtual or real). - Defaults to NULL, meaning to use the site server. -dir: Directory where theme files are stored. Used to determine - whether to show parts of a theme file. Defaults to the theme - subdirectory of the install directory. -path: Path part of theme URLs, before the theme name. Relative to the - theme server. It may make sense to change this path when upgrading, - (using version numbers as the path) to make sure that all files are - reloaded by caching clients or proxies. Defaults to null, - which means to use the site path + '/theme'. -ssl: Whether to use SSL for theme elements. Default is null, which means - guess based on site SSL settings. + theme file lookup to another server (virtual or real). + Defaults to NULL, meaning to use the site server. +dir: Directory where theme files are stored. Used to determine + whether to show parts of a theme file. Defaults to the theme + subdirectory of the install directory. +path: Path part of theme URLs, before the theme name. Relative to the + theme server. It may make sense to change this path when upgrading, + (using version numbers as the path) to make sure that all files are + reloaded by caching clients or proxies. Defaults to null, + which means to use the site path + '/theme'. +ssl: Whether to use SSL for theme elements. Default is null, which means + guess based on site SSL settings. javascript ---------- server: You can speed up page loading by pointing the - theme file lookup to another server (virtual or real). - Defaults to NULL, meaning to use the site server. -path: Path part of Javascript URLs. Defaults to null, - which means to use the site path + '/js/'. -ssl: Whether to use SSL for JavaScript files. Default is null, which means - guess based on site SSL settings. + theme file lookup to another server (virtual or real). + Defaults to NULL, meaning to use the site server. +path: Path part of Javascript URLs. Defaults to null, + which means to use the site path + '/js/'. +ssl: Whether to use SSL for JavaScript files. Default is null, which means + guess based on site SSL settings. xmpp ---- @@ -1245,27 +1107,27 @@ For configuring the XMPP sub-system. enabled: Whether to accept and send messages by XMPP. Default false. server: server part of XMPP ID for update user. port: connection port for clients. Default 5222, which you probably - shouldn't need to change. + shouldn't need to change. user: username for the client connection. Users will receive messages - from 'user'@'server'. + from 'user'@'server'. resource: a unique identifier for the connection to the server. This - is actually used as a prefix for each XMPP component in the system. + is actually used as a prefix for each XMPP component in the system. password: password for the user account. host: some XMPP domains are served by machines with a different - hostname. (For example, @gmail.com GTalk users connect to - talk.google.com). Set this to the correct hostname if that's the - case with your server. + hostname. (For example, @gmail.com GTalk users connect to + talk.google.com). Set this to the correct hostname if that's the + case with your server. encryption: Whether to encrypt the connection between StatusNet and the - XMPP server. Defaults to true, but you can get - considerably better performance turning it off if you're - connecting to a server on the same machine or on a - protected network. + XMPP server. Defaults to true, but you can get + considerably better performance turning it off if you're + connecting to a server on the same machine or on a + protected network. debug: if turned on, this will make the XMPP library blurt out all of - the incoming and outgoing messages as XML stanzas. Use as a - last resort, and never turn it on if you don't have queues - enabled, since it will spit out sensitive data to the browser. + the incoming and outgoing messages as XML stanzas. Use as a + last resort, and never turn it on if you don't have queues + enabled, since it will spit out sensitive data to the browser. public: an array of JIDs to send _all_ notices to. This is useful for - participating in third-party search and archiving services. + participating in third-party search and archiving services. invite ------ @@ -1280,8 +1142,8 @@ tag Miscellaneous tagging stuff. dropoff: Decay factor for tag listing, in seconds. - Defaults to exponential decay over ten days; you can twiddle - with it to try and get better results for your site. + Defaults to exponential decay over ten days; you can twiddle + with it to try and get better results for your site. popular ------- @@ -1289,8 +1151,8 @@ popular Settings for the "popular" section of the site. dropoff: Decay factor for popularity listing, in seconds. - Defaults to exponential decay over ten days; you can twiddle - with it to try and get better results for your site. + Defaults to exponential decay over ten days; you can twiddle + with it to try and get better results for your site. daemon ------ @@ -1298,14 +1160,14 @@ daemon For daemon processes. piddir: directory that daemon processes should write their PID file - (process ID) to. Defaults to /var/run/, which is where this - stuff should usually go on Unix-ish systems. + (process ID) to. Defaults to /var/run/, which is where this + stuff should usually go on Unix-ish systems. user: If set, the daemons will try to change their effective user ID - to this user before running. Probably a good idea, especially if - you start the daemons as root. Note: user name, like 'daemon', - not 1001. + to this user before running. Probably a good idea, especially if + you start the daemons as root. Note: user name, like 'daemon', + not 1001. group: If set, the daemons will try to change their effective group ID - to this named group. Again, a name, not a numerical ID. + to this named group. Again, a name, not a numerical ID. memcached --------- @@ -1315,13 +1177,13 @@ database data in memcached . enabled: Set to true to enable. Default false. server: a string with the hostname of the memcached server. Can also - be an array of hostnames, if you've got more than one server. + be an array of hostnames, if you've got more than one server. base: memcached uses key-value pairs to store data. We build long, - funny-looking keys to make sure we don't have any conflicts. The - base of the key is usually a simplified version of the site name - (like "Identi.ca" => "identica"), but you can overwrite this if - you need to. You can safely ignore it if you only have one - StatusNet site using your memcached server. + funny-looking keys to make sure we don't have any conflicts. The + base of the key is usually a simplified version of the site name + (like "Identi.ca" => "identica"), but you can overwrite this if + you need to. You can safely ignore it if you only have one + StatusNet site using your memcached server. port: Port to connect to; defaults to 11211. emailpost @@ -1330,7 +1192,7 @@ emailpost For post-by-email. enabled: Whether to enable post-by-email. Defaults to true. You will - also need to set up maildaemon.php. + also need to set up maildaemon.php. sms --- @@ -1338,7 +1200,7 @@ sms For SMS integration. enabled: Whether to enable SMS integration. Defaults to true. Queues - should also be enabled. + should also be enabled. integration ----------- @@ -1353,7 +1215,7 @@ inboxes For notice inboxes. enabled: No longer used. If you set this to something other than true, - StatusNet will no longer run. + StatusNet will no longer run. throttle -------- @@ -1362,8 +1224,8 @@ For notice-posting throttles. enabled: Whether to throttle posting. Defaults to false. count: Each user can make this many posts in 'timespan' seconds. So, if count - is 100 and timespan is 3600, then there can be only 100 posts - from a user every hour. + is 100 and timespan is 3600, then there can be only 100 posts + from a user every hour. timespan: see 'count'. profile @@ -1371,12 +1233,8 @@ profile Profile management. -banned: an array of usernames and/or profile IDs of 'banned' profiles. - The site will reject any notices by these users -- they will - not be accepted at all. (Compare with blacklisted users above, - whose posts just won't show up in the public stream.) biolimit: max character length of bio; 0 means no limit; null means to use - the site text limit default. + the site text limit default. newuser ------- @@ -1384,13 +1242,13 @@ newuser Options with new users. default: nickname of a user account to automatically subscribe new - users to. Typically this would be system account for e.g. - service updates or announcements. Users are able to unsub - if they want. Default is null; no auto subscribe. + users to. Typically this would be system account for e.g. + service updates or announcements. Users are able to unsub + if they want. Default is null; no auto subscribe. welcome: nickname of a user account that sends welcome messages to new - users. Can be the same as 'default' account, although on - busy servers it may be a good idea to keep that one just for - 'urgent' messages. Default is null; no message. + users. Can be the same as 'default' account, although on + busy servers it may be a good idea to keep that one just for + 'urgent' messages. Default is null; no message. If either of these special user accounts are specified, the users should be created before the configuration is updated. @@ -1407,19 +1265,19 @@ helps StatusNet developers take your needs into account when updating the software. run: string indicating when to run the statistics. Values can be 'web' - (run occasionally at Web time), 'cron' (run from a cron script), - or 'never' (don't ever run). If you set it to 'cron', remember to - schedule the script to run on a regular basis. + (run occasionally at Web time), 'cron' (run from a cron script), + or 'never' (don't ever run). If you set it to 'cron', remember to + schedule the script to run on a regular basis. frequency: if run value is 'web', how often to report statistics. - Measured in Web hits; depends on how active your site is. - Default is 10000 -- that is, one report every 10000 Web hits, - on average. + Measured in Web hits; depends on how active your site is. + Default is 10000 -- that is, one report every 10000 Web hits, + on average. reporturl: URL to post statistics to. Defaults to StatusNet developers' - report system, but if they go evil or disappear you may - need to update this to another value. Note: if you - don't want to report stats, it's much better to - set 'run' to 'never' than to set this value to something - nonsensical. + report system, but if they go evil or disappear you may + need to update this to another value. Note: if you + don't want to report stats, it's much better to + set 'run' to 'never' than to set this value to something + nonsensical. attachments ----------- @@ -1432,14 +1290,14 @@ We suggest the use of the pecl file_info extension to handle mime type detection. supported: an array of mime types you accept to store and distribute, - like 'image/gif', 'video/mpeg', 'audio/mpeg', etc. Make sure you - setup your server to properly recognize the types you want to - support. -uploads: false to disable uploading files with notices (true by default). + like 'image/gif', 'video/mpeg', 'audio/mpeg', etc. Make sure you + setup your server to properly recognize the types you want to + support. +uploads: false to disable uploading files with notices (true by default). filecommand: The required MIME_Type library may need to use the 'file' - command. It tries the one in the Web server's path, but if - you're having problems with uploads, try setting this to the - correct value. Note: 'file' must accept '-b' and '-i' options. + command. It tries the one in the Web server's path, but if + you're having problems with uploads, try setting this to the + correct value. Note: 'file' must accept '-b' and '-i' options. For quotas, be sure you've set the upload_max_filesize and post_max_size in php.ini to be large enough to handle your upload. In httpd.conf @@ -1447,26 +1305,26 @@ in php.ini to be large enough to handle your upload. In httpd.conf set too low (it's optional, so it may not be there at all). file_quota: maximum size for a single file upload in bytes. A user can send - any amount of notices with attachments as long as each attachment - is smaller than file_quota. + any amount of notices with attachments as long as each attachment + is smaller than file_quota. user_quota: total size in bytes a user can store on this server. Each user - can store any number of files as long as their total size does - not exceed the user_quota. + can store any number of files as long as their total size does + not exceed the user_quota. monthly_quota: total size permitted in the current month. This is the total - size in bytes that a user can upload each month. + size in bytes that a user can upload each month. dir: directory accessible to the Web process where uploads should go. - Defaults to the 'file' subdirectory of the install directory, which - should be writeable by the Web user. + Defaults to the 'file' subdirectory of the install directory, which + should be writeable by the Web user. server: server name to use when creating URLs for uploaded files. - Defaults to null, meaning to use the default Web server. Using - a virtual server here can speed up Web performance. + Defaults to null, meaning to use the default Web server. Using + a virtual server here can speed up Web performance. path: URL path, relative to the server, to find files. Defaults to - main path + '/file/'. + main path + '/file/'. ssl: whether to use HTTPS for file URLs. Defaults to null, meaning to - guess based on other SSL settings. + guess based on other SSL settings. filecommand: command to use for determining the type of a file. May be - skipped if fileinfo extension is installed. Defaults to - '/usr/bin/file'. + skipped if fileinfo extension is installed. Defaults to + '/usr/bin/file'. group ----- @@ -1474,10 +1332,10 @@ group Options for group functionality. maxaliases: maximum number of aliases a group can have. Default 3. Set - to 0 or less to prevent aliases in a group. + to 0 or less to prevent aliases in a group. desclimit: maximum number of characters to allow in group descriptions. - null (default) means to use the site-wide text limits. 0 - means no limit. + null (default) means to use the site-wide text limits. 0 + means no limit. oohembed -------- @@ -1492,11 +1350,11 @@ search Some stuff for search. type: type of search. Ignored if PostgreSQL or Sphinx are enabled. Can either - be 'fulltext' (default) or 'like'. The former is faster and more efficient - but requires the lame old MyISAM engine for MySQL. The latter - will work with InnoDB but could be miserably slow on large - systems. We'll probably add another type sometime in the future, - with our own indexing system (maybe like MediaWiki's). + be 'fulltext' (default) or 'like'. The former is faster and more efficient + but requires the lame old MyISAM engine for MySQL. The latter + will work with InnoDB but could be miserably slow on large + systems. We'll probably add another type sometime in the future, + with our own indexing system (maybe like MediaWiki's). sessions -------- @@ -1504,11 +1362,11 @@ sessions Session handling. handle: boolean. Whether we should register our own PHP session-handling - code (using the database and memcache if enabled). Defaults to false. - Setting this to true makes some sense on large or multi-server - sites, but it probably won't hurt for smaller ones, either. + code (using the database and memcache if enabled). Defaults to false. + Setting this to true makes some sense on large or multi-server + sites, but it probably won't hurt for smaller ones, either. debug: whether to output debugging info for session storage. Can help - with weird session bugs, sometimes. Default false. + with weird session bugs, sometimes. Default false. background ---------- @@ -1517,14 +1375,14 @@ Users can upload backgrounds for their pages; this section defines their use. server: the server to use for background. Using a separate (even - virtual) server for this can speed up load times. Default is - null; same as site server. + virtual) server for this can speed up load times. Default is + null; same as site server. dir: directory to write backgrounds too. Default is '/background/' - subdir of install dir. + subdir of install dir. path: path to backgrounds. Default is sub-path of install path; note - that you may need to change this if you change site-path too. + that you may need to change this if you change site-path too. ssl: Whether or not to use HTTPS for background files. Defaults to - null, meaning to guess from site-wide SSL settings. + null, meaning to guess from site-wide SSL settings. ping ---- @@ -1533,7 +1391,7 @@ Using the "XML-RPC Ping" method initiated by weblogs.com, the site can notify third-party servers of updates. notify: an array of URLs for ping endpoints. Default is the empty - array (no notification). + array (no notification). design ------ @@ -1555,8 +1413,8 @@ notice Configuration options specific to notices. contentlimit: max length of the plain-text content of a notice. - Default is null, meaning to use the site-wide text limit. - 0 means no limit. + Default is null, meaning to use the site-wide text limit. + 0 means no limit. message ------- @@ -1564,8 +1422,8 @@ message Configuration options specific to messages. contentlimit: max length of the plain-text content of a message. - Default is null, meaning to use the site-wide text limit. - 0 means no limit. + Default is null, meaning to use the site-wide text limit. + 0 means no limit. logincommand ------------ @@ -1573,14 +1431,14 @@ logincommand Configuration options for the login command. disabled: whether to enable this command. If enabled, users who send - the text 'login' to the site through any channel will - receive a link to login to the site automatically in return. - Possibly useful for users who primarily use an XMPP or SMS - interface and can't be bothered to remember their site - password. Note that the security implications of this are - pretty serious and have not been thoroughly tested. You - should enable it only after you've convinced yourself that - it is safe. Default is 'false'. + the text 'login' to the site through any channel will + receive a link to login to the site automatically in return. + Possibly useful for users who primarily use an XMPP or SMS + interface and can't be bothered to remember their site + password. Note that the security implications of this are + pretty serious and have not been thoroughly tested. You + should enable it only after you've convinced yourself that + it is safe. Default is 'false'. singleuser ---------- @@ -1599,11 +1457,11 @@ Web crawlers. See http://www.robotstxt.org/ for more information on the format of this file. crawldelay: if non-empty, this value is provided as the Crawl-Delay: - for the robots.txt file. see http://ur1.ca/l5a0 - for more information. Default is zero, no explicit delay. + for the robots.txt file. see http://ur1.ca/l5a0 + for more information. Default is zero, no explicit delay. disallow: Array of (virtual) directories to disallow. Default is 'main', - 'search', 'message', 'settings', 'admin'. Ignored when site - is private, in which case the entire site ('/') is disallowed. + 'search', 'message', 'settings', 'admin'. Ignored when site + is private, in which case the entire site ('/') is disallowed. Plugins ======= @@ -1662,7 +1520,7 @@ repository (see below), and you get a compilation error ("unexpected T_STRING") in the browser, check to see that you don't have any conflicts in your code. -If you upgraded to StatusNet 0.8.2 without reading the "Notice +If you upgraded to StatusNet 0.9.0 without reading the "Notice inboxes" section above, and all your users' 'Personal' tabs are empty, read the "Notice inboxes" section above. @@ -1695,7 +1553,7 @@ If you're adventurous or impatient, you may want to install the development version of StatusNet. To get it, use the git version control tool like so: - git clone git@gitorious.org:statusnet/mainline.git + git clone git@gitorious.org:statusnet/mainline.git This is the version of the software that runs on Identi.ca and the status.net hosted service. Using it is a mixed bag. On the positive @@ -1717,16 +1575,16 @@ There are several ways to get more information about StatusNet. * The #statusnet IRC channel on freenode.net . * The StatusNet wiki, http://status.net/wiki/ * The StatusNet blog, http://status.net/blog/ -* The StatusNet status update, (!) +* The StatusNet status update, (!) Feedback ======== -* Microblogging messages to http://identi.ca/evan are very welcome. -* StatusNet's Trac server has a bug tracker for any defects you may find, - or ideas for making things better. http://status.net/trac/ -* e-mail to evan@status.net will usually be read and responded to very - quickly, unless the question is really hard. +* Microblogging messages to http://support.status.net/ are very welcome. +* The microblogging group http://identi.ca/group/statusnet is a good + place to discuss the software. +* StatusNet has a bug tracker for any defects you may find, or ideas for + making things better. http://status.net/bugs Credits ======= diff --git a/actions/accessadminpanel.php b/actions/accessadminpanel.php index 4768e2faf9..73354e97a7 100644 --- a/actions/accessadminpanel.php +++ b/actions/accessadminpanel.php @@ -51,6 +51,7 @@ class AccessadminpanelAction extends AdminPanelAction function title() { + // TRANS: Page title return _('Access'); } @@ -62,6 +63,7 @@ class AccessadminpanelAction extends AdminPanelAction function getInstructions() { + // TRANS: Page notice return _('Site access settings'); } @@ -155,24 +157,34 @@ class AccessAdminPanelForm extends AdminForm function formData() { $this->out->elementStart('fieldset', array('id' => 'settings_admin_access')); + // TRANS: Form legend for registration form. $this->out->element('legend', null, _('Registration')); $this->out->elementStart('ul', 'form_data'); $this->li(); - $this->out->checkbox('private', _('Private'), + // TRANS: Checkbox instructions for admin setting "Private" + $instructions = _('Prohibit anonymous users (not logged in) from viewing site?'); + // TRANS: Checkbox label for prohibiting anonymous users from viewing site. + $this->out->checkbox('private', _m('LABEL', 'Private'), (bool) $this->value('private'), - _('Prohibit anonymous users (not logged in) from viewing site?')); + $instructions); $this->unli(); $this->li(); + // TRANS: Checkbox instructions for admin setting "Invite only" + $instructions = _('Make registration invitation only.'); + // TRANS: Checkbox label for configuring site as invite only. $this->out->checkbox('inviteonly', _('Invite only'), (bool) $this->value('inviteonly'), - _('Make registration invitation only.')); + $instructions); $this->unli(); $this->li(); + // TRANS: Checkbox instructions for admin setting "Closed" (no new registrations) + $instructions = _('Disable new registrations.'); + // TRANS: Checkbox label for disabling new user registrations. $this->out->checkbox('closed', _('Closed'), (bool) $this->value('closed'), - _('Disable new registrations.')); + $instructions); $this->unli(); $this->out->elementEnd('ul'); $this->out->elementEnd('fieldset'); @@ -186,7 +198,9 @@ class AccessAdminPanelForm extends AdminForm function formActions() { - $this->out->submit('submit', _('Save'), 'submit', null, _('Save access settings')); + // TRANS: Title / tooltip for button to save access settings in site admin panel + $title = _('Save access settings'); + $this->out->submit('submit', _m('BUTTON', 'Save'), 'submit', null, $title); } } diff --git a/actions/all.php b/actions/all.php index 3eb1852147..8c22e6f5f0 100644 --- a/actions/all.php +++ b/actions/all.php @@ -60,6 +60,7 @@ class AllAction extends ProfileAction } if ($this->page > 1 && $this->notice->N == 0) { + // TRANS: Server error when page not found (404) $this->serverError(_('No such page'), $code = 404); } @@ -81,8 +82,10 @@ class AllAction extends ProfileAction function title() { if ($this->page > 1) { + // TRANS: Page title. %1$s is user nickname, %2$d is page number return sprintf(_('%1$s and friends, page %2$d'), $this->user->nickname, $this->page); } else { + // TRANS: Page title. %1$s is user nickname return sprintf(_("%s and friends"), $this->user->nickname); } } @@ -96,6 +99,7 @@ class AllAction extends ProfileAction 'nickname' => $this->user->nickname) ), + // TRANS: %1$s is user nickname sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)), new Feed(Feed::RSS2, common_local_url( @@ -104,6 +108,7 @@ class AllAction extends ProfileAction 'id' => $this->user->nickname ) ), + // TRANS: %1$s is user nickname sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)), new Feed(Feed::ATOM, common_local_url( @@ -112,6 +117,7 @@ class AllAction extends ProfileAction 'id' => $this->user->nickname ) ), + // TRANS: %1$s is user nickname sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname)) ); } @@ -124,6 +130,7 @@ class AllAction extends ProfileAction function showEmptyListMessage() { + // TRANS: %1$s is user nickname $message = sprintf(_('This is the timeline for %s and friends but no one has posted anything yet.'), $this->user->nickname) . ' '; if (common_logged_in()) { @@ -131,6 +138,7 @@ class AllAction extends ProfileAction if ($this->user->id === $current_user->id) { $message .= _('Try subscribing to more people, [join a group](%%action.groups%%) or post something yourself.'); } else { + // TRANS: %1$s is user nickname, %2$s is user nickname, %2$s is user nickname prefixed with "@" $message .= sprintf(_('You can try to [nudge %1$s](../%2$s) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname); } } else { @@ -144,26 +152,32 @@ class AllAction extends ProfileAction function showContent() { - $nl = new NoticeList($this->notice, $this); + if (Event::handle('StartShowAllContent', array($this))) { + $nl = new NoticeList($this->notice, $this); - $cnt = $nl->show(); + $cnt = $nl->show(); - if (0 == $cnt) { - $this->showEmptyListMessage(); + if (0 == $cnt) { + $this->showEmptyListMessage(); + } + + $this->pagination( + $this->page > 1, $cnt > NOTICES_PER_PAGE, + $this->page, 'all', array('nickname' => $this->user->nickname) + ); + + Event::handle('EndShowAllContent', array($this)); } - - $this->pagination( - $this->page > 1, $cnt > NOTICES_PER_PAGE, - $this->page, 'all', array('nickname' => $this->user->nickname) - ); } function showPageTitle() { $user = common_current_user(); if ($user && ($user->id == $this->user->id)) { + // TRANS: H1 text $this->element('h1', null, _("You and friends")); } else { + // TRANS: H1 text. %1$s is user nickname $this->element('h1', null, sprintf(_('%s and friends'), $this->user->nickname)); } } diff --git a/actions/allrss.php b/actions/allrss.php index 28b1be27d8..01e737ad7b 100644 --- a/actions/allrss.php +++ b/actions/allrss.php @@ -83,6 +83,7 @@ class AllrssAction extends Rss10Action function getNotices($limit=0) { $cur = common_current_user(); + $user = $this->user; if (!empty($cur) && $cur->id == $user->id) { $notice = $this->user->noticeInbox(0, $limit); @@ -90,7 +91,6 @@ class AllrssAction extends Rss10Action $notice = $this->user->noticesWithFriends(0, $limit); } - $user = $this->user; $notice = $user->noticesWithFriends(0, $limit); $notices = array(); diff --git a/actions/apidirectmessage.php b/actions/apidirectmessage.php index 5355acf825..53da9e0c68 100644 --- a/actions/apidirectmessage.php +++ b/actions/apidirectmessage.php @@ -182,11 +182,6 @@ class ApiDirectMessageAction extends ApiAuthAction $message->whereAdd('id > ' . $this->since_id); } - if (!empty($since)) { - $d = date('Y-m-d H:i:s', $this->since); - $message->whereAdd("created > '$d'"); - } - $message->orderBy('created DESC, id DESC'); $message->limit((($this->page - 1) * $this->count), $this->count); $message->find(); diff --git a/actions/apigroupcreate.php b/actions/apigroupcreate.php index 028d76a782..145806356c 100644 --- a/actions/apigroupcreate.php +++ b/actions/apigroupcreate.php @@ -123,7 +123,9 @@ class ApiGroupCreateAction extends ApiAuthAction 'description' => $this->description, 'location' => $this->location, 'aliases' => $this->aliases, - 'userid' => $this->user->id)); + 'userid' => $this->user->id, + 'local' => true)); + switch($this->format) { case 'xml': $this->showSingleXmlGroup($group); @@ -306,9 +308,9 @@ class ApiGroupCreateAction extends ApiAuthAction function groupNicknameExists($nickname) { - $group = User_group::staticGet('nickname', $nickname); + $local = Local_group::staticGet('nickname', $nickname); - if (!empty($group)) { + if (!empty($local)) { return true; } diff --git a/actions/apigrouplist.php b/actions/apigrouplist.php index 605b382326..98fdb0497a 100644 --- a/actions/apigrouplist.php +++ b/actions/apigrouplist.php @@ -152,8 +152,7 @@ class ApiGroupListAction extends ApiBareAuthAction ($this->page - 1) * $this->count, $this->count, $this->since_id, - $this->max_id, - $this->since + $this->max_id ); while ($group->fetch()) { diff --git a/actions/apigrouplistall.php b/actions/apigrouplistall.php index d2ef2978aa..e1b54a8322 100644 --- a/actions/apigrouplistall.php +++ b/actions/apigrouplistall.php @@ -134,13 +134,13 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction function getGroups() { - $groups = array(); - - // XXX: Use the $page, $count, $max_id, $since_id, and $since parameters + $qry = 'SELECT user_group.* '. + 'from user_group join local_group on user_group.id = local_group.group_id '. + 'order by created desc '; $group = new User_group(); - $group->orderBy('created DESC'); - $group->find(); + + $group->query($qry); while ($group->fetch()) { $groups[] = clone($group); diff --git a/actions/apigroupmembership.php b/actions/apigroupmembership.php index 3c7c8e8835..9f72b527cf 100644 --- a/actions/apigroupmembership.php +++ b/actions/apigroupmembership.php @@ -125,8 +125,7 @@ class ApiGroupMembershipAction extends ApiPrivateAuthAction ($this->page - 1) * $this->count, $this->count, $this->since_id, - $this->max_id, - $this->since + $this->max_id ); while ($profile->fetch()) { diff --git a/actions/apistatusnetconfig.php b/actions/apistatusnetconfig.php index 0345a9bc07..bff8313b5c 100644 --- a/actions/apistatusnetconfig.php +++ b/actions/apistatusnetconfig.php @@ -32,8 +32,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/api.php'; - /** * Gives a full dump of configuration variables for this instance * of StatusNet, minus variables that may be security-sensitive (like diff --git a/actions/apitimelinefriends.php b/actions/apitimelinefriends.php index 2db76857e3..9ef3ace607 100644 --- a/actions/apitimelinefriends.php +++ b/actions/apitimelinefriends.php @@ -202,11 +202,11 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) { $notice = $this->user->ownFriendsTimeline(($this->page-1) * $this->count, $this->count, $this->since_id, - $this->max_id, $this->since); + $this->max_id); } else { $notice = $this->user->friendsTimeline(($this->page-1) * $this->count, $this->count, $this->since_id, - $this->max_id, $this->since); + $this->max_id); } while ($notice->fetch()) { diff --git a/actions/apitimelinegroup.php b/actions/apitimelinegroup.php index 0bb4860ea7..8f971392bf 100644 --- a/actions/apitimelinegroup.php +++ b/actions/apitimelinegroup.php @@ -104,32 +104,21 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction function showTimeline() { - $sitename = common_config('site', 'name'); - $avatar = $this->group->homepage_logo; - $title = sprintf(_("%s timeline"), $this->group->nickname); - $taguribase = TagURI::base(); - $id = "tag:$taguribase:GroupTimeline:" . $this->group->id; - - $subtitle = sprintf( - _('Updates from %1$s on %2$s!'), - $this->group->nickname, - $sitename - ); - - $logo = ($avatar) ? $avatar : User_group::defaultLogo(AVATAR_PROFILE_SIZE); + // We'll pull common formatting out of this for other formats + $atom = new AtomGroupNoticeFeed($this->group); switch($this->format) { case 'xml': $this->showXmlTimeline($this->notices); break; case 'rss': - $this->showRssTimeline( + $this->showRssTimeline( $this->notices, - $title, + $atom->title, $this->group->homeUrl(), - $subtitle, + $atom->subtitle, null, - $logo + $atom->logo ); break; case 'atom': @@ -138,46 +127,22 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction try { - // If this was called using an integer ID, i.e.: using the canonical - // URL for this group's feed, then pass the Group object into the feed, - // so the OStatus plugin, and possibly other plugins, can access it. - // Feels sorta hacky. -- Z - - $atom = null; - $id = $this->arg('id'); - - if (strval(intval($id)) === strval($id)) { - $atom = new AtomGroupNoticeFeed($this->group); - } else { - $atom = new AtomGroupNoticeFeed(); - } - - $atom->setId($id); - $atom->setTitle($title); - $atom->setSubtitle($subtitle); - $atom->setLogo($logo); - $atom->setUpdated('now'); - $atom->addAuthorRaw($this->group->asAtomAuthor()); $atom->setActivitySubject($this->group->asActivitySubject()); - $atom->addLink($this->group->homeUrl()); - $id = $this->arg('id'); $aargs = array('format' => 'atom'); if (!empty($id)) { $aargs['id'] = $id; } + $self = $this->getSelfUri('ApiTimelineGroup', $aargs); - $atom->addLink( - $this->getSelfUri('ApiTimelineGroup', $aargs), - array('rel' => 'self', 'type' => 'application/atom+xml') - ); + $atom->setId($self); + $atom->setSelfLink($self); $atom->addEntryFromNotices($this->notices); - //$this->raw($atom->getString()); - print $atom->getString(); // temp hack until PuSH feeds are redone cleanly + $this->raw($atom->getString()); } catch (Atom10FeedException $e) { $this->serverError( @@ -214,8 +179,7 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction ($this->page-1) * $this->count, $this->count, $this->since_id, - $this->max_id, - $this->since + $this->max_id ); while ($notice->fetch()) { diff --git a/actions/apitimelinehome.php b/actions/apitimelinehome.php index 0c72f4020c..abd3877860 100644 --- a/actions/apitimelinehome.php +++ b/actions/apitimelinehome.php @@ -200,13 +200,13 @@ class ApiTimelineHomeAction extends ApiBareAuthAction $notice = $this->user->noticeInbox( ($this->page-1) * $this->count, $this->count, $this->since_id, - $this->max_id, $this->since + $this->max_id ); } else { $notice = $this->user->noticesWithFriends( ($this->page-1) * $this->count, $this->count, $this->since_id, - $this->max_id, $this->since + $this->max_id ); } diff --git a/actions/apitimelinementions.php b/actions/apitimelinementions.php index a39c63346a..31627ab7bf 100644 --- a/actions/apitimelinementions.php +++ b/actions/apitimelinementions.php @@ -189,7 +189,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction $notice = $this->user->getReplies( ($this->page - 1) * $this->count, $this->count, - $this->since_id, $this->max_id, $this->since + $this->since_id, $this->max_id ); while ($notice->fetch()) { diff --git a/actions/apitimelinepublic.php b/actions/apitimelinepublic.php index 1ff0fd2617..3e4dad690e 100644 --- a/actions/apitimelinepublic.php +++ b/actions/apitimelinepublic.php @@ -75,10 +75,6 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction $this->notices = $this->getNotices(); - if ($this->since) { - throw new ServerException("since parameter is disabled for performance; use since_id", 403); - } - return true; } diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php index 3e849cc786..2d0047c046 100644 --- a/actions/apitimelineuser.php +++ b/actions/apitimelineuser.php @@ -112,21 +112,17 @@ class ApiTimelineUserAction extends ApiBareAuthAction function showTimeline() { $profile = $this->user->getProfile(); - $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); - $sitename = common_config('site', 'name'); - $title = sprintf(_("%s timeline"), $this->user->nickname); - $taguribase = TagURI::base(); - $id = "tag:$taguribase:UserTimeline:" . $this->user->id; + // We'll use the shared params from the Atom stub + // for other feed types. + $atom = new AtomUserNoticeFeed($this->user); + $title = $atom->title; $link = common_local_url( 'showstream', array('nickname' => $this->user->nickname) ); - $subtitle = sprintf( - _('Updates from %1$s on %2$s!'), - $this->user->nickname, $sitename - ); - $logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE); + $subtitle = $atom->subtitle; + $logo = $atom->logo; // FriendFeed's SUP protocol // Also added RSS and Atom feeds @@ -148,56 +144,18 @@ class ApiTimelineUserAction extends ApiBareAuthAction header('Content-Type: application/atom+xml; charset=utf-8'); - // If this was called using an integer ID, i.e.: using the canonical - // URL for this user's feed, then pass the User object into the feed, - // so the OStatus plugin, and possibly other plugins, can access it. - // Feels sorta hacky. -- Z - - $atom = null; - $id = $this->arg('id'); - - if (strval(intval($id)) === strval($id)) { - $atom = new AtomUserNoticeFeed($this->user); - } else { - $atom = new AtomUserNoticeFeed(); - } - - $atom->setId($id); - $atom->setTitle($title); - $atom->setSubtitle($subtitle); - $atom->setLogo($logo); - $atom->setUpdated('now'); - - $atom->addLink( - common_local_url( - 'showstream', - array('nickname' => $this->user->nickname) - ) - ); - $id = $this->arg('id'); $aargs = array('format' => 'atom'); if (!empty($id)) { $aargs['id'] = $id; } - - $atom->addLink( - $this->getSelfUri('ApiTimelineUser', $aargs), - array('rel' => 'self', 'type' => 'application/atom+xml') - ); - - $atom->addLink( - $suplink, - array( - 'rel' => 'http://api.friendfeed.com/2008/03#sup', - 'type' => 'application/json' - ) - ); + $self = $this->getSelfUri('ApiTimelineUser', $aargs); + $atom->setId($self); + $atom->setSelfLink($self); $atom->addEntryFromNotices($this->notices); - #$this->raw($atom->getString()); - print $atom->getString(); // temporary for output buffering + $this->raw($atom->getString()); break; case 'json': @@ -222,7 +180,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction $notice = $this->user->getNotices( ($this->page-1) * $this->count, $this->count, - $this->since_id, $this->max_id, $this->since + $this->since_id, $this->max_id ); while ($notice->fetch()) { diff --git a/actions/blockedfromgroup.php b/actions/blockedfromgroup.php index 0b4caf5bf3..a0598db270 100644 --- a/actions/blockedfromgroup.php +++ b/actions/blockedfromgroup.php @@ -74,7 +74,14 @@ class BlockedfromgroupAction extends GroupDesignAction return false; } - $this->group = User_group::staticGet('nickname', $nickname); + $local = Local_group::staticGet('nickname', $nickname); + + if (!$local) { + $this->clientError(_('No such group.'), 404); + return false; + } + + $this->group = User_group::staticGet('id', $local->group_id); if (!$this->group) { $this->clientError(_('No such group.'), 404); diff --git a/actions/deleteuser.php b/actions/deleteuser.php index 32b703aa7f..c4f84fad2d 100644 --- a/actions/deleteuser.php +++ b/actions/deleteuser.php @@ -131,18 +131,21 @@ class DeleteuserAction extends ProfileFormAction $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); $this->element('legend', _('Delete user')); - $this->element('p', null, - _('Are you sure you want to delete this user? '. - 'This will clear all data about the user from the '. - 'database, without a backup.')); - $this->element('input', array('id' => 'deleteuserto-' . $id, - 'name' => 'profileid', - 'type' => 'hidden', - 'value' => $id)); - foreach ($this->args as $k => $v) { - if (substr($k, 0, 9) == 'returnto-') { - $this->hidden($k, $v); + if (Event::handle('StartDeleteUserForm', array($this, $this->user))) { + $this->element('p', null, + _('Are you sure you want to delete this user? '. + 'This will clear all data about the user from the '. + 'database, without a backup.')); + $this->element('input', array('id' => 'deleteuserto-' . $id, + 'name' => 'profileid', + 'type' => 'hidden', + 'value' => $id)); + foreach ($this->args as $k => $v) { + if (substr($k, 0, 9) == 'returnto-') { + $this->hidden($k, $v); + } } + Event::handle('EndDeleteUserForm', array($this, $this->user)); } $this->submit('form_action-no', _('No'), 'submit form_action-primary', 'no', _("Do not block this user")); $this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Delete this user')); @@ -158,7 +161,9 @@ class DeleteuserAction extends ProfileFormAction function handlePost() { - $this->user->delete(); + if (Event::handle('StartDeleteUser', array($this, $this->user))) { + $this->user->delete(); + Event::handle('EndDeleteUser', array($this, $this->user)); + } } } - diff --git a/actions/editgroup.php b/actions/editgroup.php index ad0b6e185d..4b596cade9 100644 --- a/actions/editgroup.php +++ b/actions/editgroup.php @@ -86,10 +86,14 @@ class EditgroupAction extends GroupDesignAction } $groupid = $this->trimmed('groupid'); + if ($groupid) { $this->group = User_group::staticGet('id', $groupid); } else { - $this->group = User_group::staticGet('nickname', $nickname); + $local = Local_group::staticGet('nickname', $nickname); + if ($local) { + $this->group = User_group::staticGet('id', $local->group_id); + } } if (!$this->group) { @@ -245,6 +249,7 @@ class EditgroupAction extends GroupDesignAction $this->group->homepage = $homepage; $this->group->description = $description; $this->group->location = $location; + $this->group->mainpage = common_local_url('showgroup', array('nickname' => $nickname)); $result = $this->group->update($orig); @@ -259,6 +264,12 @@ class EditgroupAction extends GroupDesignAction $this->serverError(_('Could not create aliases.')); } + if ($nickname != $orig->nickname) { + common_log(LOG_INFO, "Saving local group info."); + $local = Local_group::staticGet('group_id', $this->group->id); + $local->setNickname($nickname); + } + $this->group->query('COMMIT'); if ($this->group->nickname != $orig->nickname) { @@ -272,10 +283,10 @@ class EditgroupAction extends GroupDesignAction function nicknameExists($nickname) { - $group = User_group::staticGet('nickname', $nickname); + $group = Local_group::staticGet('nickname', $nickname); if (!empty($group) && - $group->id != $this->group->id) { + $group->group_id != $this->group->id) { return true; } diff --git a/actions/foafgroup.php b/actions/foafgroup.php index f5fd7fe885..ebdf1cee25 100644 --- a/actions/foafgroup.php +++ b/actions/foafgroup.php @@ -56,7 +56,14 @@ class FoafGroupAction extends Action return false; } - $this->group = User_group::staticGet('nickname', $this->nickname); + $local = Local_group::staticGet('nickname', $nickname); + + if (!$local) { + $this->clientError(_('No such group.'), 404); + return false; + } + + $this->group = User_group::staticGet('id', $local->group_id); if (!$this->group) { $this->clientError(_('No such group.'), 404); @@ -113,7 +120,7 @@ class FoafGroupAction extends Action if ($this->group->homepage_logo) { $this->element('depiction', array('rdf:resource' => $this->group->homepage_logo)); } - + $members = $this->group->getMembers(); $member_details = array(); while ($members->fetch()) { @@ -123,7 +130,7 @@ class FoafGroupAction extends Action ); $this->element('member', array('rdf:resource' => $member_uri)); } - + $admins = $this->group->getAdmins(); while ($admins->fetch()) { $admin_uri = common_local_url('userbyid', array('id'=>$admins->id)); @@ -132,7 +139,7 @@ class FoafGroupAction extends Action } $this->elementEnd('Group'); - + ksort($member_details); foreach ($member_details as $uri => $details) { if ($details['is_admin']) @@ -158,7 +165,7 @@ class FoafGroupAction extends Action )); } } - + $this->elementEnd('rdf:RDF'); $this->endXML(); } diff --git a/actions/grantrole.php b/actions/grantrole.php new file mode 100644 index 0000000000..cd6bd4d79a --- /dev/null +++ b/actions/grantrole.php @@ -0,0 +1,99 @@ +. + * + * @category Action + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Sandbox a user. + * + * @category Action + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + */ + +class GrantRoleAction extends ProfileFormAction +{ + /** + * Check parameters + * + * @param array $args action arguments (URL, GET, POST) + * + * @return boolean success flag + */ + + function prepare($args) + { + if (!parent::prepare($args)) { + return false; + } + + $this->role = $this->arg('role'); + if (!Profile_role::isValid($this->role)) { + $this->clientError(_("Invalid role.")); + return false; + } + if (!Profile_role::isSettable($this->role)) { + $this->clientError(_("This role is reserved and cannot be set.")); + return false; + } + + $cur = common_current_user(); + + assert(!empty($cur)); // checked by parent + + if (!$cur->hasRight(Right::GRANTROLE)) { + $this->clientError(_("You cannot grant user roles on this site.")); + return false; + } + + assert(!empty($this->profile)); // checked by parent + + if ($this->profile->hasRole($this->role)) { + $this->clientError(_("User already has this role.")); + return false; + } + + return true; + } + + /** + * Sandbox a user. + * + * @return void + */ + + function handlePost() + { + $this->profile->grantRole($this->role); + } +} diff --git a/actions/groupdesignsettings.php b/actions/groupdesignsettings.php index e290ba5141..526226a285 100644 --- a/actions/groupdesignsettings.php +++ b/actions/groupdesignsettings.php @@ -90,7 +90,10 @@ class GroupDesignSettingsAction extends DesignSettingsAction if ($groupid) { $this->group = User_group::staticGet('id', $groupid); } else { - $this->group = User_group::staticGet('nickname', $nickname); + $local = Local_group::staticGet('nickname', $nickname); + if ($local) { + $this->group = User_group::staticGet('id', $local->group_id); + } } if (!$this->group) { diff --git a/actions/grouplogo.php b/actions/grouplogo.php index 3c9b562962..f414a23cc3 100644 --- a/actions/grouplogo.php +++ b/actions/grouplogo.php @@ -92,7 +92,10 @@ class GrouplogoAction extends GroupDesignAction if ($groupid) { $this->group = User_group::staticGet('id', $groupid); } else { - $this->group = User_group::staticGet('nickname', $nickname); + $local = Local_group::staticGet('nickname', $nickname); + if ($local) { + $this->group = User_group::staticGet('id', $local->group_id); + } } if (!$this->group) { diff --git a/actions/groupmembers.php b/actions/groupmembers.php index f16e972a41..a16debd7b0 100644 --- a/actions/groupmembers.php +++ b/actions/groupmembers.php @@ -77,7 +77,14 @@ class GroupmembersAction extends GroupDesignAction return false; } - $this->group = User_group::staticGet('nickname', $nickname); + $local = Local_group::staticGet('nickname', $nickname); + + if (!$local) { + $this->clientError(_('No such group.'), 404); + return false; + } + + $this->group = User_group::staticGet('id', $local->group_id); if (!$this->group) { $this->clientError(_('No such group.'), 404); diff --git a/actions/grouprss.php b/actions/grouprss.php index 866fc66eb1..490f6f945c 100644 --- a/actions/grouprss.php +++ b/actions/grouprss.php @@ -92,7 +92,14 @@ class groupRssAction extends Rss10Action return false; } - $this->group = User_group::staticGet('nickname', $nickname); + $local = Local_group::staticGet('nickname', $nickname); + + if (!$local) { + $this->clientError(_('No such group.'), 404); + return false; + } + + $this->group = User_group::staticGet('id', $local->group_id); if (!$this->group) { $this->clientError(_('No such group.'), 404); diff --git a/actions/groups.php b/actions/groups.php index 10a1d5964d..8aacff8b0e 100644 --- a/actions/groups.php +++ b/actions/groups.php @@ -109,17 +109,21 @@ class GroupsAction extends Action } $offset = ($this->page-1) * GROUPS_PER_PAGE; - $limit = GROUPS_PER_PAGE + 1; + $limit = GROUPS_PER_PAGE + 1; + + $qry = 'SELECT user_group.* '. + 'from user_group join local_group on user_group.id = local_group.group_id '. + 'order by user_group.created desc '. + 'limit ' . $limit . ' offset ' . $offset; $groups = new User_group(); - $groups->orderBy('created DESC'); - $groups->limit($offset, $limit); $cnt = 0; - if ($groups->find()) { - $gl = new GroupList($groups, null, $this); - $cnt = $gl->show(); - } + + $groups->query($qry); + + $gl = new GroupList($groups, null, $this); + $cnt = $gl->show(); $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE, $this->page, 'groups'); diff --git a/actions/hcard.php b/actions/hcard.php new file mode 100644 index 0000000000..55d0f65c8f --- /dev/null +++ b/actions/hcard.php @@ -0,0 +1,120 @@ +. + * + * @category Personal + * @package StatusNet + * @author Evan Prodromou + * @copyright 2010 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * User profile page + * + * @category Personal + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 + * @link http://status.net/ + */ + +class HcardAction extends Action +{ + var $user; + var $profile; + + function prepare($args) + { + parent::prepare($args); + + $nickname_arg = $this->arg('nickname'); + $nickname = common_canonical_nickname($nickname_arg); + + // Permanent redirect on non-canonical nickname + + if ($nickname_arg != $nickname) { + $args = array('nickname' => $nickname); + common_redirect(common_local_url('hcard', $args), 301); + return false; + } + + $this->user = User::staticGet('nickname', $nickname); + + if (!$this->user) { + $this->clientError(_('No such user.'), 404); + return false; + } + + $this->profile = $this->user->getProfile(); + + if (!$this->profile) { + $this->serverError(_('User has no profile.')); + return false; + } + + return true; + } + + function handle($args) + { + parent::handle($args); + $this->showPage(); + } + + function title() + { + return $this->profile->getBestName(); + } + + function showContent() + { + $up = new ShortUserProfile($this, $this->user, $this->profile); + $up->show(); + } + + function showHeader() + { + return; + } + + function showAside() + { + return; + } + + function showSecondaryNav() + { + return; + } +} + +class ShortUserProfile extends UserProfile +{ + function showEntityActions() + { + return; + } +} \ No newline at end of file diff --git a/actions/invite.php b/actions/invite.php index d0ed64ec90..54b2de62ac 100644 --- a/actions/invite.php +++ b/actions/invite.php @@ -194,7 +194,8 @@ class InviteAction extends CurrentUserDesignAction _('Optionally add a personal message to the invitation.')); $this->elementEnd('li'); $this->elementEnd('ul'); - $this->submit('send', _('Send')); + // TRANS: Send button for inviting friends + $this->submit('send', _m('BUTTON', 'Send')); $this->elementEnd('fieldset'); $this->elementEnd('form'); } diff --git a/actions/joingroup.php b/actions/joingroup.php index 235e5ab4c2..f87e5dae29 100644 --- a/actions/joingroup.php +++ b/actions/joingroup.php @@ -62,23 +62,33 @@ class JoingroupAction extends Action } $nickname_arg = $this->trimmed('nickname'); - $nickname = common_canonical_nickname($nickname_arg); + $id = intval($this->arg('id')); + if ($id) { + $this->group = User_group::staticGet('id', $id); + } else if ($nickname_arg) { + $nickname = common_canonical_nickname($nickname_arg); - // Permanent redirect on non-canonical nickname + // Permanent redirect on non-canonical nickname - if ($nickname_arg != $nickname) { - $args = array('nickname' => $nickname); - common_redirect(common_local_url('joingroup', $args), 301); + if ($nickname_arg != $nickname) { + $args = array('nickname' => $nickname); + common_redirect(common_local_url('leavegroup', $args), 301); + return false; + } + + $local = Local_group::staticGet('nickname', $nickname); + + if (!$local) { + $this->clientError(_('No such group.'), 404); + return false; + } + + $this->group = User_group::staticGet('id', $local->group_id); + } else { + $this->clientError(_('No nickname or ID.'), 404); return false; } - if (!$nickname) { - $this->clientError(_('No nickname.'), 404); - return false; - } - - $this->group = User_group::staticGet('nickname', $nickname); - if (!$this->group) { $this->clientError(_('No such group.'), 404); return false; diff --git a/actions/leavegroup.php b/actions/leavegroup.php index 9b9d83b6ca..329b5aafe1 100644 --- a/actions/leavegroup.php +++ b/actions/leavegroup.php @@ -62,23 +62,33 @@ class LeavegroupAction extends Action } $nickname_arg = $this->trimmed('nickname'); - $nickname = common_canonical_nickname($nickname_arg); + $id = intval($this->arg('id')); + if ($id) { + $this->group = User_group::staticGet('id', $id); + } else if ($nickname_arg) { + $nickname = common_canonical_nickname($nickname_arg); - // Permanent redirect on non-canonical nickname + // Permanent redirect on non-canonical nickname - if ($nickname_arg != $nickname) { - $args = array('nickname' => $nickname); - common_redirect(common_local_url('leavegroup', $args), 301); + if ($nickname_arg != $nickname) { + $args = array('nickname' => $nickname); + common_redirect(common_local_url('leavegroup', $args), 301); + return false; + } + + $local = Local_group::staticGet('nickname', $nickname); + + if (!$local) { + $this->clientError(_('No such group.'), 404); + return false; + } + + $this->group = User_group::staticGet('id', $local->group_id); + } else { + $this->clientError(_('No nickname or ID.'), 404); return false; } - if (!$nickname) { - $this->clientError(_('No nickname.'), 404); - return false; - } - - $this->group = User_group::staticGet('nickname', $nickname); - if (!$this->group) { $this->clientError(_('No such group.'), 404); return false; diff --git a/actions/newgroup.php b/actions/newgroup.php index 25da7f8fc7..75bc293ec6 100644 --- a/actions/newgroup.php +++ b/actions/newgroup.php @@ -180,6 +180,8 @@ class NewgroupAction extends Action } } + $mainpage = common_local_url('showgroup', array('nickname' => $nickname)); + $cur = common_current_user(); // Checked in prepare() above @@ -192,16 +194,18 @@ class NewgroupAction extends Action 'description' => $description, 'location' => $location, 'aliases' => $aliases, - 'userid' => $cur->id)); + 'userid' => $cur->id, + 'mainpage' => $mainpage, + 'local' => true)); common_redirect($group->homeUrl(), 303); } function nicknameExists($nickname) { - $group = User_group::staticGet('nickname', $nickname); + $local = Local_group::staticGet('nickname', $nickname); - if (!empty($group)) { + if (!empty($local)) { return true; } diff --git a/actions/newnotice.php b/actions/newnotice.php index 78480ababb..ed0fa1b2b5 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -294,6 +294,9 @@ class NewnoticeAction extends Action if ($profile) { $content = '@' . $profile->nickname . ' '; } + } else { + // @fixme most of these bits above aren't being passed on above + $inreplyto = null; } $notice_form = new NoticeForm($this, '', $content, null, $inreplyto); diff --git a/actions/oauthconnectionssettings.php b/actions/oauthconnectionssettings.php index b1467f0d04..f125f4c631 100644 --- a/actions/oauthconnectionssettings.php +++ b/actions/oauthconnectionssettings.php @@ -99,7 +99,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction $application = $profile->getApplications($offset, $limit); - $cnt == 0; + $cnt = 0; if (!empty($application)) { $al = new ApplicationList($application, $user, $this, true); @@ -112,7 +112,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction $this->pagination($this->page > 1, $cnt > APPS_PER_PAGE, $this->page, 'connectionssettings', - array('nickname' => $this->user->nickname)); + array('nickname' => $user->nickname)); } /** diff --git a/actions/postnotice.php b/actions/postnotice.php index fb06703766..b2f6f1bb95 100644 --- a/actions/postnotice.php +++ b/actions/postnotice.php @@ -54,7 +54,10 @@ class PostnoticeAction extends Action */ function prepare($argarray) { + StatusNet::setApi(true); // Send smaller error pages + parent::prepare($argarray); + try { $this->checkNotice(); } catch (Exception $e) { @@ -71,6 +74,14 @@ class PostnoticeAction extends Action $srv = new OMB_Service_Provider(null, omb_oauth_datastore(), omb_oauth_server()); $srv->handlePostNotice(); + } catch (OMB_RemoteServiceException $rse) { + $msg = $rse->getMessage(); + if (preg_match('/Revoked accesstoken/', $msg) || + preg_match('/No subscriber/', $msg)) { + $this->clientError($msg, 403); + } else { + $this->clientError($msg); + } } catch (Exception $e) { $this->serverError($e->getMessage()); return; diff --git a/actions/public.php b/actions/public.php index 50278bfced..0b3b5fde84 100644 --- a/actions/public.php +++ b/actions/public.php @@ -94,6 +94,7 @@ class PublicAction extends Action } if($this->page > 1 && $this->notice->N == 0){ + // TRANS: Server error when page not found (404) $this->serverError(_('No such page'),$code=404); } diff --git a/actions/recoverpassword.php b/actions/recoverpassword.php index dcff35f6ed..1e2775e7a7 100644 --- a/actions/recoverpassword.php +++ b/actions/recoverpassword.php @@ -21,7 +21,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } # You have 24 hours to claim your password -define(MAX_RECOVERY_TIME, 24 * 60 * 60); +define('MAX_RECOVERY_TIME', 24 * 60 * 60); class RecoverpasswordAction extends Action { diff --git a/actions/replies.php b/actions/replies.php index 164c328db3..4ff1b7a8d2 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -89,6 +89,7 @@ class RepliesAction extends OwnerDesignAction NOTICES_PER_PAGE + 1); if($this->page > 1 && $this->notice->N == 0){ + // TRANS: Server error when page not found (404) $this->serverError(_('No such page'),$code=404); } diff --git a/actions/revokerole.php b/actions/revokerole.php new file mode 100644 index 0000000000..b78c1c25a4 --- /dev/null +++ b/actions/revokerole.php @@ -0,0 +1,99 @@ +. + * + * @category Action + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Sandbox a user. + * + * @category Action + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + */ + +class RevokeRoleAction extends ProfileFormAction +{ + /** + * Check parameters + * + * @param array $args action arguments (URL, GET, POST) + * + * @return boolean success flag + */ + + function prepare($args) + { + if (!parent::prepare($args)) { + return false; + } + + $this->role = $this->arg('role'); + if (!Profile_role::isValid($this->role)) { + $this->clientError(_("Invalid role.")); + return false; + } + if (!Profile_role::isSettable($this->role)) { + $this->clientError(_("This role is reserved and cannot be set.")); + return false; + } + + $cur = common_current_user(); + + assert(!empty($cur)); // checked by parent + + if (!$cur->hasRight(Right::REVOKEROLE)) { + $this->clientError(_("You cannot revoke user roles on this site.")); + return false; + } + + assert(!empty($this->profile)); // checked by parent + + if (!$this->profile->hasRole($this->role)) { + $this->clientError(_("User doesn't have this role.")); + return false; + } + + return true; + } + + /** + * Sandbox a user. + * + * @return void + */ + + function handlePost() + { + $this->profile->revokeRole($this->role); + } +} diff --git a/actions/showfavorites.php b/actions/showfavorites.php index f2d0822936..5b85de6835 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -134,6 +134,7 @@ class ShowfavoritesAction extends OwnerDesignAction } if($this->page > 1 && $this->notice->N == 0){ + // TRANS: Server error when page not found (404) $this->serverError(_('No such page'),$code=404); } diff --git a/actions/showgroup.php b/actions/showgroup.php index eb12389029..5704b13d14 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -122,9 +122,9 @@ class ShowgroupAction extends GroupDesignAction return false; } - $this->group = User_group::staticGet('nickname', $nickname); + $local = Local_group::staticGet('nickname', $nickname); - if (!$this->group) { + if (!$local) { $alias = Group_alias::staticGet('alias', $nickname); if ($alias) { $args = array('id' => $alias->group_id); @@ -134,11 +134,19 @@ class ShowgroupAction extends GroupDesignAction common_redirect(common_local_url('groupbyid', $args), 301); return false; } else { + common_log(LOG_NOTICE, "Couldn't find local group for nickname '$nickname'"); $this->clientError(_('No such group.'), 404); return false; } } + $this->group = User_group::staticGet('id', $local->group_id); + + if (!$this->group) { + $this->clientError(_('No such group.'), 404); + return false; + } + common_set_returnto($this->selfUrl()); return true; @@ -293,19 +301,20 @@ class ShowgroupAction extends GroupDesignAction $this->element('h2', null, _('Group actions')); $this->elementStart('ul'); $this->elementStart('li', 'entity_subscribe'); - $cur = common_current_user(); - if ($cur) { - if ($cur->isMember($this->group)) { - $lf = new LeaveForm($this, $this->group); - $lf->show(); - } else if (!Group_block::isBlocked($this->group, $cur->getProfile())) { - $jf = new JoinForm($this, $this->group); - $jf->show(); + if (Event::handle('StartGroupSubscribe', array($this, $this->group))) { + $cur = common_current_user(); + if ($cur) { + if ($cur->isMember($this->group)) { + $lf = new LeaveForm($this, $this->group); + $lf->show(); + } else if (!Group_block::isBlocked($this->group, $cur->getProfile())) { + $jf = new JoinForm($this, $this->group); + $jf->show(); + } } + Event::handle('EndGroupSubscribe', array($this, $this->group)); } - $this->elementEnd('li'); - $this->elementEnd('ul'); $this->elementEnd('div'); } diff --git a/actions/siteadminpanel.php b/actions/siteadminpanel.php index 8c8f8b3742..cb3c2e8fde 100644 --- a/actions/siteadminpanel.php +++ b/actions/siteadminpanel.php @@ -66,7 +66,7 @@ class SiteadminpanelAction extends AdminPanelAction function getInstructions() { - return _('Basic settings for this StatusNet site.'); + return _('Basic settings for this StatusNet site'); } /** @@ -90,10 +90,11 @@ class SiteadminpanelAction extends AdminPanelAction function saveSettings() { - static $settings = array('site' => array('name', 'broughtby', 'broughtbyurl', - 'email', 'timezone', 'language', - 'site', 'textlimit', 'dupelimit'), - 'snapshot' => array('run', 'reporturl', 'frequency')); + static $settings = array( + 'site' => array('name', 'broughtby', 'broughtbyurl', + 'email', 'timezone', 'language', + 'site', 'textlimit', 'dupelimit'), + ); $values = array(); @@ -158,25 +159,6 @@ class SiteadminpanelAction extends AdminPanelAction $this->clientError(sprintf(_('Unknown language "%s".'), $values['site']['language'])); } - // Validate report URL - - if (!is_null($values['snapshot']['reporturl']) && - !Validate::uri($values['snapshot']['reporturl'], array('allowed_schemes' => array('http', 'https')))) { - $this->clientError(_("Invalid snapshot report URL.")); - } - - // Validate snapshot run value - - if (!in_array($values['snapshot']['run'], array('web', 'cron', 'never'))) { - $this->clientError(_("Invalid snapshot run value.")); - } - - // Validate snapshot run value - - if (!Validate::number($values['snapshot']['frequency'])) { - $this->clientError(_("Snapshot frequency must be a number.")); - } - // Validate text limit if (!Validate::number($values['site']['textlimit'], array('min' => 140))) { @@ -277,40 +259,14 @@ class SiteAdminPanelForm extends AdminForm $this->unli(); $this->li(); - $this->out->dropdown('language', _('Language'), - get_nice_language_list(), _('Default site language'), + $this->out->dropdown('language', _('Default language'), + get_nice_language_list(), _('Site language when autodetection from browser settings is not available'), false, $this->value('language')); $this->unli(); $this->out->elementEnd('ul'); $this->out->elementEnd('fieldset'); - $this->out->elementStart('fieldset', array('id' => 'settings_admin_snapshots')); - $this->out->element('legend', null, _('Snapshots')); - $this->out->elementStart('ul', 'form_data'); - $this->li(); - $snapshot = array('web' => _('Randomly during Web hit'), - 'cron' => _('In a scheduled job'), - 'never' => _('Never')); - $this->out->dropdown('run', _('Data snapshots'), - $snapshot, _('When to send statistical data to status.net servers'), - false, $this->value('run', 'snapshot')); - $this->unli(); - - $this->li(); - $this->input('frequency', _('Frequency'), - _('Snapshots will be sent once every N web hits'), - 'snapshot'); - $this->unli(); - - $this->li(); - $this->input('reporturl', _('Report URL'), - _('Snapshots will be sent to this URL'), - 'snapshot'); - $this->unli(); - $this->out->elementEnd('ul'); - $this->out->elementEnd('fieldset'); - $this->out->elementStart('fieldset', array('id' => 'settings_admin_limits')); $this->out->element('legend', null, _('Limits')); $this->out->elementStart('ul', 'form_data'); diff --git a/actions/sitenoticeadminpanel.php b/actions/sitenoticeadminpanel.php new file mode 100644 index 0000000000..3931aa9825 --- /dev/null +++ b/actions/sitenoticeadminpanel.php @@ -0,0 +1,201 @@ +. + * + * @category Settings + * @package StatusNet + * @author Zach Copley + * @copyright 2010 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php'; + +/** + * Update the site-wide notice text + * + * @category Admin + * @package StatusNet + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class SitenoticeadminpanelAction extends AdminPanelAction +{ + /** + * Returns the page title + * + * @return string page title + */ + + function title() + { + return _('Site Notice'); + } + + /** + * Instructions for using this form. + * + * @return string instructions + */ + + function getInstructions() + { + return _('Edit site-wide message'); + } + + /** + * Show the site notice admin panel form + * + * @return void + */ + + function showForm() + { + $form = new SiteNoticeAdminPanelForm($this); + $form->show(); + return; + } + + /** + * Save settings from the form + * + * @return void + */ + + function saveSettings() + { + $siteNotice = $this->trimmed('site-notice'); + + // assert(all values are valid); + // This throws an exception on validation errors + + $this->validate(&$siteNotice); + + $config = new Config(); + + $result = Config::save('site', 'notice', $siteNotice); + + if (!$result) { + $this->ServerError(_("Unable to save site notice.")); + } + } + + function validate(&$siteNotice) + { + // Validate notice text + + if (mb_strlen($siteNotice) > 255) { + $this->clientError( + _('Max length for the site-wide notice is 255 chars') + ); + } + + // scrub HTML input + + $config = array( + 'safe' => 1, + 'deny_attribute' => 'id,style,on*' + ); + + $siteNotice = htmLawed($siteNotice, $config); + } +} + +class SiteNoticeAdminPanelForm extends AdminForm +{ + /** + * ID of the form + * + * @return int ID of the form + */ + + function id() + { + return 'form_site_notice_admin_panel'; + } + + /** + * class of the form + * + * @return string class of the form + */ + + function formClass() + { + return 'form_settings'; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + return common_local_url('sitenoticeadminpanel'); + } + + /** + * Data elements of the form + * + * @return void + */ + + function formData() + { + $this->out->elementStart('ul', 'form_data'); + + $this->out->elementStart('li'); + $this->out->textarea( + 'site-notice', + _('Site notice text'), + common_config('site', 'notice'), + _('Site-wide notice text (255 chars max; HTML okay)') + ); + $this->out->elementEnd('li'); + + $this->out->elementEnd('ul'); + } + + /** + * Action elements + * + * @return void + */ + + function formActions() + { + $this->out->submit( + 'submit', + _('Save'), + 'submit', + null, + _('Save site notice') + ); + } +} diff --git a/actions/snapshotadminpanel.php b/actions/snapshotadminpanel.php new file mode 100644 index 0000000000..a0c2315bc1 --- /dev/null +++ b/actions/snapshotadminpanel.php @@ -0,0 +1,251 @@ +. + * + * @category Settings + * @package StatusNet + * @author Zach Copley + * @copyright 2010 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Manage snapshots + * + * @category Admin + * @package StatusNet + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class SnapshotadminpanelAction extends AdminPanelAction +{ + /** + * Returns the page title + * + * @return string page title + */ + + function title() + { + return _('Snapshots'); + } + + /** + * Instructions for using this form. + * + * @return string instructions + */ + + function getInstructions() + { + return _('Manage snapshot configuration'); + } + + /** + * Show the snapshots admin panel form + * + * @return void + */ + + function showForm() + { + $form = new SnapshotAdminPanelForm($this); + $form->show(); + return; + } + + /** + * Save settings from the form + * + * @return void + */ + + function saveSettings() + { + static $settings = array( + 'snapshot' => array('run', 'reporturl', 'frequency') + ); + + $values = array(); + + foreach ($settings as $section => $parts) { + foreach ($parts as $setting) { + $values[$section][$setting] = $this->trimmed($setting); + } + } + + // This throws an exception on validation errors + + $this->validate($values); + + // assert(all values are valid); + + $config = new Config(); + + $config->query('BEGIN'); + + foreach ($settings as $section => $parts) { + foreach ($parts as $setting) { + Config::save($section, $setting, $values[$section][$setting]); + } + } + + $config->query('COMMIT'); + + return; + } + + function validate(&$values) + { + // Validate snapshot run value + + if (!in_array($values['snapshot']['run'], array('web', 'cron', 'never'))) { + $this->clientError(_("Invalid snapshot run value.")); + } + + // Validate snapshot frequency value + + if (!Validate::number($values['snapshot']['frequency'])) { + $this->clientError(_("Snapshot frequency must be a number.")); + } + + // Validate report URL + + if (!is_null($values['snapshot']['reporturl']) + && !Validate::uri( + $values['snapshot']['reporturl'], + array('allowed_schemes' => array('http', 'https') + ) + )) { + $this->clientError(_("Invalid snapshot report URL.")); + } + } +} + +class SnapshotAdminPanelForm extends AdminForm +{ + /** + * ID of the form + * + * @return int ID of the form + */ + + function id() + { + return 'form_snapshot_admin_panel'; + } + + /** + * class of the form + * + * @return string class of the form + */ + + function formClass() + { + return 'form_settings'; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + return common_local_url('snapshotadminpanel'); + } + + /** + * Data elements of the form + * + * @return void + */ + + function formData() + { + $this->out->elementStart( + 'fieldset', + array('id' => 'settings_admin_snapshots') + ); + $this->out->element('legend', null, _('Snapshots')); + $this->out->elementStart('ul', 'form_data'); + $this->li(); + $snapshot = array( + 'web' => _('Randomly during Web hit'), + 'cron' => _('In a scheduled job'), + 'never' => _('Never') + ); + $this->out->dropdown( + 'run', + _('Data snapshots'), + $snapshot, + _('When to send statistical data to status.net servers'), + false, + $this->value('run', 'snapshot') + ); + $this->unli(); + + $this->li(); + $this->input( + 'frequency', + _('Frequency'), + _('Snapshots will be sent once every N web hits'), + 'snapshot' + ); + $this->unli(); + + $this->li(); + $this->input( + 'reporturl', + _('Report URL'), + _('Snapshots will be sent to this URL'), + 'snapshot' + ); + $this->unli(); + $this->out->elementEnd('ul'); + $this->out->elementEnd('fieldset'); + } + + /** + * Action elements + * + * @return void + */ + + function formActions() + { + $this->out->submit( + 'submit', + _('Save'), + 'submit', + null, + _('Save snapshot settings') + ); + } +} diff --git a/actions/subscribe.php b/actions/subscribe.php index 3745311b66..b1243f3933 100644 --- a/actions/subscribe.php +++ b/actions/subscribe.php @@ -145,7 +145,7 @@ class SubscribeAction extends Action $this->element('title', null, _('Subscribed')); $this->elementEnd('head'); $this->elementStart('body'); - $unsubscribe = new UnsubscribeForm($this, $this->other->getProfile()); + $unsubscribe = new UnsubscribeForm($this, $this->other); $unsubscribe->show(); $this->elementEnd('body'); $this->elementEnd('html'); diff --git a/actions/subscribers.php b/actions/subscribers.php index cd3e2ee5be..4bced62840 100644 --- a/actions/subscribers.php +++ b/actions/subscribers.php @@ -143,9 +143,12 @@ class SubscribersListItem extends SubscriptionListItem function showActions() { $this->startActions(); - $this->showSubscribeButton(); - // Relevant code! - $this->showBlockForm(); + if (Event::handle('StartProfileListItemActionElements', array($this))) { + $this->showSubscribeButton(); + // Relevant code! + $this->showBlockForm(); + Event::handle('EndProfileListItemActionElements', array($this)); + } $this->endActions(); } diff --git a/actions/tag.php b/actions/tag.php index e91df6ea97..ee9617b662 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -48,6 +48,7 @@ class TagAction extends Action $this->notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1); if($this->page > 1 && $this->notice->N == 0){ + // TRANS: Server error when page not found (404) $this->serverError(_('No such page'),$code=404); } diff --git a/actions/tagrss.php b/actions/tagrss.php index 75cbfa274b..467a64abed 100644 --- a/actions/tagrss.php +++ b/actions/tagrss.php @@ -35,6 +35,7 @@ class TagrssAction extends Rss10Action $this->clientError(_('No such tag.')); return false; } else { + $this->notices = $this->getNotices($this->limit); return true; } } diff --git a/actions/twitapisearchatom.php b/actions/twitapisearchatom.php index e389ddec84..24aa619bd7 100644 --- a/actions/twitapisearchatom.php +++ b/actions/twitapisearchatom.php @@ -31,8 +31,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/api.php'; - /** * Action for outputting search results in Twitter compatible Atom * format. diff --git a/actions/twitapisearchjson.php b/actions/twitapisearchjson.php index 741ed78d63..b5c006aa7b 100644 --- a/actions/twitapisearchjson.php +++ b/actions/twitapisearchjson.php @@ -31,7 +31,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/api.php'; require_once INSTALLDIR.'/lib/jsonsearchresultslist.php'; /** diff --git a/actions/twitapitrends.php b/actions/twitapitrends.php index 779405e6d6..5a04569a22 100644 --- a/actions/twitapitrends.php +++ b/actions/twitapitrends.php @@ -31,8 +31,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/api.php'; - /** * Returns the top ten queries that are currently trending * diff --git a/actions/updateprofile.php b/actions/updateprofile.php index e416a6fa93..bae6108cce 100644 --- a/actions/updateprofile.php +++ b/actions/updateprofile.php @@ -55,6 +55,8 @@ class UpdateprofileAction extends Action */ function prepare($argarray) { + StatusNet::setApi(true); // Send smaller error pages + parent::prepare($argarray); $license = $_POST['omb_listenee_license']; $site_license = common_config('license', 'url'); @@ -75,6 +77,14 @@ class UpdateprofileAction extends Action $srv = new OMB_Service_Provider(null, omb_oauth_datastore(), omb_oauth_server()); $srv->handleUpdateProfile(); + } catch (OMB_RemoteServiceException $rse) { + $msg = $rse->getMessage(); + if (preg_match('/Revoked accesstoken/', $msg) || + preg_match('/No subscriber/', $msg)) { + $this->clientError($msg, 403); + } else { + $this->clientError($msg); + } } catch (Exception $e) { $this->serverError($e->getMessage()); return; diff --git a/actions/useradminpanel.php b/actions/useradminpanel.php index 6813222f5f..ee9c230769 100644 --- a/actions/useradminpanel.php +++ b/actions/useradminpanel.php @@ -55,7 +55,8 @@ class UseradminpanelAction extends AdminPanelAction function title() { - return _('User'); + // TRANS: User admin panel title + return _m('TITLE', 'User'); } /** diff --git a/actions/usergroups.php b/actions/usergroups.php index 97faabae65..29bda0a765 100644 --- a/actions/usergroups.php +++ b/actions/usergroups.php @@ -130,22 +130,26 @@ class UsergroupsAction extends OwnerDesignAction _('Search for more groups')); $this->elementEnd('p'); - $offset = ($this->page-1) * GROUPS_PER_PAGE; - $limit = GROUPS_PER_PAGE + 1; + if (Event::handle('StartShowUserGroupsContent', array($this))) { + $offset = ($this->page-1) * GROUPS_PER_PAGE; + $limit = GROUPS_PER_PAGE + 1; - $groups = $this->user->getGroups($offset, $limit); + $groups = $this->user->getGroups($offset, $limit); - if ($groups) { - $gl = new GroupList($groups, $this->user, $this); - $cnt = $gl->show(); - if (0 == $cnt) { - $this->showEmptyListMessage(); + if ($groups) { + $gl = new GroupList($groups, $this->user, $this); + $cnt = $gl->show(); + if (0 == $cnt) { + $this->showEmptyListMessage(); + } } - } - $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE, - $this->page, 'usergroups', - array('nickname' => $this->user->nickname)); + $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE, + $this->page, 'usergroups', + array('nickname' => $this->user->nickname)); + + Event::handle('EndShowUserGroupsContent', array($this)); + } } function showEmptyListMessage() diff --git a/actions/userrss.php b/actions/userrss.php index 19e610551d..e03eb93566 100644 --- a/actions/userrss.php +++ b/actions/userrss.php @@ -29,6 +29,8 @@ class UserrssAction extends Rss10Action function prepare($args) { + common_debug("UserrssAction"); + parent::prepare($args); $nickname = $this->trimmed('nickname'); $this->user = User::staticGet('nickname', $nickname); @@ -38,20 +40,24 @@ class UserrssAction extends Rss10Action $this->clientError(_('No such user.')); return false; } else { - $this->notices = $this->getNotices($this->limit); + if (!empty($this->tag)) { + $this->notices = $this->getTaggedNotices(); + } else { + $this->notices = $this->getNotices(); + } return true; } } - function getTaggedNotices($tag = null, $limit=0) + function getTaggedNotices() { - $user = $this->user; - - if (is_null($user)) { - return null; - } - - $notice = $user->getTaggedNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit, 0, 0, null, $tag); + $notice = $this->user->getTaggedNotices( + $this->tag, + 0, + ($this->limit == 0) ? NOTICES_PER_PAGE : $this->limit, + 0, + 0 + ); $notices = array(); while ($notice->fetch()) { @@ -62,15 +68,12 @@ class UserrssAction extends Rss10Action } - function getNotices($limit=0) + function getNotices() { - $user = $this->user; - - if (is_null($user)) { - return null; - } - - $notice = $user->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit); + $notice = $this->user->getNotices( + 0, + ($limit == 0) ? NOTICES_PER_PAGE : $limit + ); $notices = array(); while ($notice->fetch()) { diff --git a/classes/Fave.php b/classes/Fave.php index 0b6eec2bc4..a04f15e9c4 100644 --- a/classes/Fave.php +++ b/classes/Fave.php @@ -77,7 +77,7 @@ class Fave extends Memcached_DataObject return $ids; } - function _streamDirect($user_id, $own, $offset, $limit, $since_id, $max_id, $since) + function _streamDirect($user_id, $own, $offset, $limit, $since_id, $max_id) { $fav = new Fave(); $qry = null; @@ -100,10 +100,6 @@ class Fave extends Memcached_DataObject $qry .= 'AND notice_id <= ' . $max_id . ' '; } - if (!is_null($since)) { - $qry .= 'AND modified > \'' . date('Y-m-d H:i:s', $since) . '\' '; - } - // NOTE: we sort by fave time, not by notice time! $qry .= 'ORDER BY modified DESC '; diff --git a/classes/File.php b/classes/File.php index 189e04ce02..4ecd3b959a 100644 --- a/classes/File.php +++ b/classes/File.php @@ -169,7 +169,11 @@ class File extends Memcached_DataObject { require_once 'MIME/Type/Extension.php'; $mte = new MIME_Type_Extension(); - $ext = $mte->getExtension($mimetype); + try { + $ext = $mte->getExtension($mimetype); + } catch ( Exception $e) { + $ext = strtolower(preg_replace('/\W/', '', $mimetype)); + } $nickname = $profile->nickname; $datestamp = strftime('%Y%m%dT%H%M%S', time()); $random = strtolower(common_confirmation_code(32)); @@ -286,5 +290,12 @@ class File extends Memcached_DataObject } return $enclosure; } + + // quick back-compat hack, since there's still code using this + function isEnclosure() + { + $enclosure = $this->getEnclosure(); + return !empty($enclosure); + } } diff --git a/classes/Foreign_link.php b/classes/Foreign_link.php index ae8c22fd84..e47b2e3096 100644 --- a/classes/Foreign_link.php +++ b/classes/Foreign_link.php @@ -113,4 +113,21 @@ class Foreign_link extends Memcached_DataObject return User::staticGet($this->user_id); } + // Make sure we only ever delete one record at a time + function safeDelete() + { + if (!empty($this->user_id) + && !empty($this->foreign_id) + && !empty($this->service)) + { + return $this->delete(); + } else { + common_debug(LOG_WARNING, + 'Foreign_link::safeDelete() tried to delete a ' + . 'Foreign_link without a fully specified compound key: ' + . var_export($this, true)); + return false; + } + } + } diff --git a/classes/Group_alias.php b/classes/Group_alias.php index be3d0a6c6f..c5a1895a11 100644 --- a/classes/Group_alias.php +++ b/classes/Group_alias.php @@ -34,7 +34,7 @@ class Group_alias extends Memcached_DataObject public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP /* Static get */ - function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('Group_alias',$k,$v); } + function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Group_alias',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE diff --git a/classes/Inbox.php b/classes/Inbox.php index be62611a16..014ba3d829 100644 --- a/classes/Inbox.php +++ b/classes/Inbox.php @@ -137,7 +137,7 @@ class Inbox extends Memcached_DataObject } } - function stream($user_id, $offset, $limit, $since_id, $max_id, $since, $own=false) + function stream($user_id, $offset, $limit, $since_id, $max_id, $own=false) { $inbox = Inbox::staticGet('user_id', $user_id); @@ -195,15 +195,15 @@ class Inbox extends Memcached_DataObject * @param int $limit * @param mixed $since_id return only notices after but not including this id * @param mixed $max_id return only notices up to and including this id - * @param mixed $since obsolete/ignored * @param mixed $own ignored? * @return array of Notice objects * * @todo consider repacking the inbox when this happens? + * @fixme reimplement $own if we need it? */ - function streamNotices($user_id, $offset, $limit, $since_id, $max_id, $since, $own=false) + function streamNotices($user_id, $offset, $limit, $since_id, $max_id, $own=false) { - $ids = self::stream($user_id, $offset, self::MAX_NOTICES, $since_id, $max_id, $since, $own); + $ids = self::stream($user_id, $offset, self::MAX_NOTICES, $since_id, $max_id, $own); // Do a bulk lookup for the first $limit items // Fast path when nothing's deleted. diff --git a/classes/Local_group.php b/classes/Local_group.php new file mode 100644 index 0000000000..42312ec63c --- /dev/null +++ b/classes/Local_group.php @@ -0,0 +1,46 @@ +decache(); + $qry = 'UPDATE local_group set nickname = "'.$nickname.'" where group_id = ' . $this->group_id; + + $result = $this->query($qry); + + if ($result) { + $this->nickname = $nickname; + $this->fixupTimestamps(); + $this->encache(); + } else { + common_log_db_error($local, 'UPDATE', __FILE__); + throw new ServerException(_('Could not update local group.')); + } + + return $result; + } +} diff --git a/classes/Notice.php b/classes/Notice.php index e8d5c45cb2..4c7e6ab4b7 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -121,6 +121,9 @@ class Notice extends Memcached_DataObject $result = parent::delete(); } + /** + * Extract #hashtags from this notice's content and save them to the database. + */ function saveTags() { /* extract all #hastags */ @@ -129,14 +132,22 @@ class Notice extends Memcached_DataObject return true; } + /* Add them to the database */ + return $this->saveKnownTags($match[1]); + } + + /** + * Record the given set of hash tags in the db for this notice. + * Given tag strings will be normalized and checked for dupes. + */ + function saveKnownTags($hashtags) + { //turn each into their canonical tag //this is needed to remove dupes before saving e.g. #hash.tag = #hashtag - $hashtags = array(); - for($i=0; $isaveTag($hashtag); @@ -145,6 +156,10 @@ class Notice extends Memcached_DataObject return true; } + /** + * Record a single hash tag as associated with this notice. + * Tag format and uniqueness must be validated by caller. + */ function saveTag($hashtag) { $tag = new Notice_tag(); @@ -194,6 +209,10 @@ class Notice extends Memcached_DataObject * place of extracting @-replies from content. * array 'groups' list of group IDs to deliver to, in place of * extracting ! tags from content + * array 'tags' list of hashtag strings to save with the notice + * in place of extracting # tags from content + * array 'urls' list of attached/referred URLs to save with the + * notice in place of extracting links from content * @fixme tag override * * @return Notice @@ -265,12 +284,6 @@ class Notice extends Memcached_DataObject $notice->content = $final; - if (!empty($rendered)) { - $notice->rendered = $rendered; - } else { - $notice->rendered = common_render_content($final, $notice); - } - $notice->source = $source; $notice->uri = $uri; $notice->url = $url; @@ -298,6 +311,12 @@ class Notice extends Memcached_DataObject $notice->location_ns = $location_ns; } + if (!empty($rendered)) { + $notice->rendered = $rendered; + } else { + $notice->rendered = common_render_content($final, $notice); + } + if (Event::handle('StartNoticeSave', array(&$notice))) { // XXX: some of these functions write to the DB @@ -343,6 +362,8 @@ class Notice extends Memcached_DataObject $notice->blowOnInsert(); + // Save per-notice metadata... + if (isset($replies)) { $notice->saveKnownReplies($replies); } else { @@ -355,6 +376,19 @@ class Notice extends Memcached_DataObject $notice->saveGroups(); } + if (isset($tags)) { + $notice->saveKnownTags($tags); + } else { + $notice->saveTags(); + } + + if (isset($urls)) { + $notice->saveKnownUrls($urls); + } else { + $notice->saveUrls(); + } + + // Prepare inbox delivery, may be queued to background. $notice->distribute(); return $notice; @@ -398,6 +432,25 @@ class Notice extends Memcached_DataObject common_replace_urls_callback($this->content, array($this, 'saveUrl'), $this->id); } + /** + * Save the given URLs as related links/attachments to the db + * + * follow redirects and save all available file information + * (mimetype, date, size, oembed, etc.) + * + * @return void + */ + function saveKnownUrls($urls) + { + // @fixme validation? + foreach ($urls as $url) { + File::processNew($url, $this->id); + } + } + + /** + * @private callback + */ function saveUrl($data) { list($url, $notice_id) = $data; File::processNew($url, $notice_id); @@ -530,17 +583,17 @@ class Notice extends Memcached_DataObject } } - function publicStream($offset=0, $limit=20, $since_id=0, $max_id=0, $since=null) + function publicStream($offset=0, $limit=20, $since_id=0, $max_id=0) { $ids = Notice::stream(array('Notice', '_publicStreamDirect'), array(), 'public', - $offset, $limit, $since_id, $max_id, $since); + $offset, $limit, $since_id, $max_id); return Notice::getStreamByIds($ids); } - function _publicStreamDirect($offset=0, $limit=20, $since_id=0, $max_id=0, $since=null) + function _publicStreamDirect($offset=0, $limit=20, $since_id=0, $max_id=0) { $notice = new Notice(); @@ -569,10 +622,6 @@ class Notice extends Memcached_DataObject $notice->whereAdd('id <= ' . $max_id); } - if (!is_null($since)) { - $notice->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\''); - } - $ids = array(); if ($notice->find()) { @@ -587,17 +636,17 @@ class Notice extends Memcached_DataObject return $ids; } - function conversationStream($id, $offset=0, $limit=20, $since_id=0, $max_id=0, $since=null) + function conversationStream($id, $offset=0, $limit=20, $since_id=0, $max_id=0) { $ids = Notice::stream(array('Notice', '_conversationStreamDirect'), array($id), 'notice:conversation_ids:'.$id, - $offset, $limit, $since_id, $max_id, $since); + $offset, $limit, $since_id, $max_id); return Notice::getStreamByIds($ids); } - function _conversationStreamDirect($id, $offset=0, $limit=20, $since_id=0, $max_id=0, $since=null) + function _conversationStreamDirect($id, $offset=0, $limit=20, $since_id=0, $max_id=0) { $notice = new Notice(); @@ -620,10 +669,6 @@ class Notice extends Memcached_DataObject $notice->whereAdd('id <= ' . $max_id); } - if (!is_null($since)) { - $notice->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\''); - } - $ids = array(); if ($notice->find()) { @@ -832,7 +877,7 @@ class Notice extends Memcached_DataObject foreach (array_unique($match[1]) as $nickname) { /* XXX: remote groups. */ - $group = User_group::getForNickname($nickname); + $group = User_group::getForNickname($nickname, $profile); if (empty($group)) { continue; @@ -915,6 +960,8 @@ class Notice extends Memcached_DataObject $reply->profile_id = $user->id; $id = $reply->insert(); + + self::blow('reply:stream:%d', $user->id); } } @@ -942,7 +989,10 @@ class Notice extends Memcached_DataObject $sender = Profile::staticGet($this->profile_id); - $mentions = common_find_mentions($this->profile_id, $this->content); + // @todo ideally this parser information would only + // be calculated once. + + $mentions = common_find_mentions($this->content, $this); $replied = array(); @@ -1056,7 +1106,7 @@ class Notice extends Memcached_DataObject return $groups; } - function asAtomEntry($namespace=false, $source=false) + function asAtomEntry($namespace=false, $source=false, $author=true) { $profile = $this->getProfile(); @@ -1067,6 +1117,7 @@ class Notice extends Memcached_DataObject 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0', 'xmlns:georss' => 'http://www.georss.org/georss', 'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/', + 'xmlns:media' => 'http://purl.org/syndication/atommedia', 'xmlns:poco' => 'http://portablecontacts.net/spec/1.0', 'xmlns:ostatus' => 'http://ostatus.org/schema/1.0'); } else { @@ -1099,10 +1150,11 @@ class Notice extends Memcached_DataObject } $xs->element('title', null, $this->content); - $xs->element('summary', null, $this->content); - $xs->raw($profile->asAtomAuthor()); - $xs->raw($profile->asActivityActor()); + if ($author) { + $xs->raw($profile->asAtomAuthor()); + $xs->raw($profile->asActivityActor()); + } $xs->element('link', array('rel' => 'alternate', 'type' => 'text/html', @@ -1235,16 +1287,16 @@ class Notice extends Memcached_DataObject } } - function stream($fn, $args, $cachekey, $offset=0, $limit=20, $since_id=0, $max_id=0, $since=null) + function stream($fn, $args, $cachekey, $offset=0, $limit=20, $since_id=0, $max_id=0) { $cache = common_memcache(); if (empty($cache) || - $since_id != 0 || $max_id != 0 || (!is_null($since) && $since > 0) || + $since_id != 0 || $max_id != 0 || is_null($limit) || ($offset + $limit) > NOTICE_CACHE_WINDOW) { return call_user_func_array($fn, array_merge($args, array($offset, $limit, $since_id, - $max_id, $since))); + $max_id))); } $idkey = common_cache_key($cachekey); diff --git a/classes/Notice_inbox.php b/classes/Notice_inbox.php index c27dcdfd61..47ed6b22db 100644 --- a/classes/Notice_inbox.php +++ b/classes/Notice_inbox.php @@ -49,12 +49,12 @@ class Notice_inbox extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - function stream($user_id, $offset, $limit, $since_id, $max_id, $since, $own=false) + function stream($user_id, $offset, $limit, $since_id, $max_id, $own=false) { throw new Exception('Notice_inbox no longer used; use Inbox'); } - function _streamDirect($user_id, $own, $offset, $limit, $since_id, $max_id, $since) + function _streamDirect($user_id, $own, $offset, $limit, $since_id, $max_id) { throw new Exception('Notice_inbox no longer used; use Inbox'); } diff --git a/classes/Notice_tag.php b/classes/Notice_tag.php index 4fd76e8ea8..a5d0716a71 100644 --- a/classes/Notice_tag.php +++ b/classes/Notice_tag.php @@ -46,7 +46,7 @@ class Notice_tag extends Memcached_DataObject return Notice::getStreamByIds($ids); } - function _streamDirect($tag, $offset, $limit, $since_id, $max_id, $since) + function _streamDirect($tag, $offset, $limit, $since_id, $max_id) { $nt = new Notice_tag(); @@ -63,10 +63,6 @@ class Notice_tag extends Memcached_DataObject $nt->whereAdd('notice_id < ' . $max_id); } - if (!is_null($since)) { - $nt->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\''); - } - $nt->orderBy('notice_id DESC'); if (!is_null($offset)) { diff --git a/classes/Profile.php b/classes/Profile.php index 78223b34a1..0322c93588 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -163,27 +163,27 @@ class Profile extends Memcached_DataObject return null; } - function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0, $since=null) + function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0) { $ids = Notice::stream(array($this, '_streamTaggedDirect'), array($tag), 'profile:notice_ids_tagged:' . $this->id . ':' . $tag, - $offset, $limit, $since_id, $max_id, $since); + $offset, $limit, $since_id, $max_id); return Notice::getStreamByIds($ids); } - function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0, $since=null) + function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0) { // XXX: I'm not sure this is going to be any faster. It probably isn't. $ids = Notice::stream(array($this, '_streamDirect'), array(), 'profile:notice_ids:' . $this->id, - $offset, $limit, $since_id, $max_id, $since); + $offset, $limit, $since_id, $max_id); return Notice::getStreamByIds($ids); } - function _streamTaggedDirect($tag, $offset, $limit, $since_id, $max_id, $since) + function _streamTaggedDirect($tag, $offset, $limit, $since_id, $max_id) { // XXX It would be nice to do this without a join @@ -202,10 +202,6 @@ class Profile extends Memcached_DataObject $query .= " and id < $max_id"; } - if (!is_null($since)) { - $query .= " and created > '" . date('Y-m-d H:i:s', $since) . "'"; - } - $query .= ' order by id DESC'; if (!is_null($offset)) { @@ -223,7 +219,7 @@ class Profile extends Memcached_DataObject return $ids; } - function _streamDirect($offset, $limit, $since_id, $max_id, $since = null) + function _streamDirect($offset, $limit, $since_id, $max_id) { $notice = new Notice(); @@ -240,10 +236,6 @@ class Profile extends Memcached_DataObject $notice->whereAdd('id <= ' . $max_id); } - if (!is_null($since)) { - $notice->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\''); - } - $notice->orderBy('id DESC'); if (!is_null($offset)) { @@ -290,6 +282,32 @@ class Profile extends Memcached_DataObject } } + function getGroups($offset=0, $limit=null) + { + $qry = + 'SELECT user_group.* ' . + 'FROM user_group JOIN group_member '. + 'ON user_group.id = group_member.group_id ' . + 'WHERE group_member.profile_id = %d ' . + 'ORDER BY group_member.created DESC '; + + if ($offset>0 && !is_null($limit)) { + if ($offset) { + if (common_config('db','type') == 'pgsql') { + $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; + } else { + $qry .= ' LIMIT ' . $offset . ', ' . $limit; + } + } + } + + $groups = new User_group(); + + $cnt = $groups->query(sprintf($qry, $this->id)); + + return $groups; + } + function avatarUrl($size=AVATAR_PROFILE_SIZE) { $avatar = $this->getAvatar($size); @@ -725,6 +743,10 @@ class Profile extends Memcached_DataObject case Right::CONFIGURESITE: $result = $this->hasRole(Profile_role::ADMINISTRATOR); break; + case Right::GRANTROLE: + case Right::REVOKEROLE: + $result = $this->hasRole(Profile_role::OWNER); + break; case Right::NEWNOTICE: case Right::NEWMESSAGE: case Right::SUBSCRIBE: diff --git a/classes/Profile_role.php b/classes/Profile_role.php index bf2c453ed0..d0a0b31f0f 100644 --- a/classes/Profile_role.php +++ b/classes/Profile_role.php @@ -53,4 +53,21 @@ class Profile_role extends Memcached_DataObject const ADMINISTRATOR = 'administrator'; const SANDBOXED = 'sandboxed'; const SILENCED = 'silenced'; + + public static function isValid($role) + { + // @fixme could probably pull this from class constants + $known = array(self::OWNER, + self::MODERATOR, + self::ADMINISTRATOR, + self::SANDBOXED, + self::SILENCED); + return in_array($role, $known); + } + + public static function isSettable($role) + { + $allowedRoles = array('administrator', 'moderator'); + return self::isValid($role) && in_array($role, $allowedRoles); + } } diff --git a/classes/Reply.php b/classes/Reply.php index 49b1e05e51..659e04c925 100644 --- a/classes/Reply.php +++ b/classes/Reply.php @@ -22,16 +22,16 @@ class Reply extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0, $since=null) + function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0) { $ids = Notice::stream(array('Reply', '_streamDirect'), array($user_id), 'reply:stream:' . $user_id, - $offset, $limit, $since_id, $max_id, $since); + $offset, $limit, $since_id, $max_id); return $ids; } - function _streamDirect($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0, $since=null) + function _streamDirect($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0) { $reply = new Reply(); $reply->profile_id = $user_id; @@ -44,10 +44,6 @@ class Reply extends Memcached_DataObject $reply->whereAdd('notice_id < ' . $max_id); } - if (!is_null($since)) { - $reply->whereAdd('modified > \'' . date('Y-m-d H:i:s', $since) . '\''); - } - $reply->orderBy('notice_id DESC'); if (!is_null($offset)) { diff --git a/classes/Subscription.php b/classes/Subscription.php index d6fb3fcbdd..9cef2df1ad 100644 --- a/classes/Subscription.php +++ b/classes/Subscription.php @@ -172,6 +172,28 @@ class Subscription extends Memcached_DataObject assert(!empty($sub)); + // @todo: move this block to EndSubscribe handler for + // OMB plugin when it exists. + + if (!empty($sub->token)) { + + $token = new Token(); + + $token->tok = $sub->token; + + if ($token->find(true)) { + + $result = $token->delete(); + + if (!$result) { + common_log_db_error($token, 'DELETE', __FILE__); + throw new Exception(_('Couldn\'t delete subscription OMB token.')); + } + } else { + common_log(LOG_ERR, "Couldn't find credentials with token {$token->tok}"); + } + } + $result = $sub->delete(); if (!$result) { diff --git a/classes/User.php b/classes/User.php index 0f84ed8133..15ec4ad946 100644 --- a/classes/User.php +++ b/classes/User.php @@ -201,6 +201,7 @@ class User extends Memcached_DataObject if(! User::allowed_nickname($nickname)){ common_log(LOG_WARNING, sprintf("Attempted to register a nickname that is not allowed: %s", $profile->nickname), __FILE__); + return false; } $profile->profileurl = common_profile_url($nickname); @@ -451,28 +452,28 @@ class User extends Memcached_DataObject return $user; } - function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) + function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - $ids = Reply::stream($this->id, $offset, $limit, $since_id, $before_id, $since); + $ids = Reply::stream($this->id, $offset, $limit, $since_id, $before_id); return Notice::getStreamByIds($ids); } - function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) { + function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { $profile = $this->getProfile(); if (!$profile) { return null; } else { - return $profile->getTaggedNotices($tag, $offset, $limit, $since_id, $before_id, $since); + return $profile->getTaggedNotices($tag, $offset, $limit, $since_id, $before_id); } } - function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) + function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { $profile = $this->getProfile(); if (!$profile) { return null; } else { - return $profile->getNotices($offset, $limit, $since_id, $before_id, $since); + return $profile->getNotices($offset, $limit, $since_id, $before_id); } } @@ -482,24 +483,24 @@ class User extends Memcached_DataObject return Notice::getStreamByIds($ids); } - function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) + function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, $since, false); + return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, false); } - function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) + function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, $since, true); + return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, true); } - function friendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) + function friendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, $since, false); + return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, false); } - function ownFriendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null) + function ownFriendsTimeline($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { - return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, $since, true); + return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, true); } function blowFavesCache() @@ -607,28 +608,8 @@ class User extends Memcached_DataObject function getGroups($offset=0, $limit=null) { - $qry = - 'SELECT user_group.* ' . - 'FROM user_group JOIN group_member '. - 'ON user_group.id = group_member.group_id ' . - 'WHERE group_member.profile_id = %d ' . - 'ORDER BY group_member.created DESC '; - - if ($offset>0 && !is_null($limit)) { - if ($offset) { - if (common_config('db','type') == 'pgsql') { - $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; - } else { - $qry .= ' LIMIT ' . $offset . ', ' . $limit; - } - } - } - - $groups = new User_group(); - - $cnt = $groups->query(sprintf($qry, $this->id)); - - return $groups; + $profile = $this->getProfile(); + return $profile->getGroups($offset, $limit); } function getSubscriptions($offset=0, $limit=null) @@ -784,7 +765,7 @@ class User extends Memcached_DataObject return Notice::getStreamByIds($ids); } - function _repeatedByMeDirect($offset, $limit, $since_id, $max_id, $since) + function _repeatedByMeDirect($offset, $limit, $since_id, $max_id) { $notice = new Notice(); @@ -808,10 +789,6 @@ class User extends Memcached_DataObject $notice->whereAdd('id <= ' . $max_id); } - if (!is_null($since)) { - $notice->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\''); - } - $ids = array(); if ($notice->find()) { @@ -831,12 +808,12 @@ class User extends Memcached_DataObject $ids = Notice::stream(array($this, '_repeatsOfMeDirect'), array(), 'user:repeats_of_me:'.$this->id, - $offset, $limit, $since_id, $max_id, null); + $offset, $limit, $since_id, $max_id); return Notice::getStreamByIds($ids); } - function _repeatsOfMeDirect($offset, $limit, $since_id, $max_id, $since) + function _repeatsOfMeDirect($offset, $limit, $since_id, $max_id) { $qry = 'SELECT DISTINCT original.id AS id ' . @@ -851,10 +828,6 @@ class User extends Memcached_DataObject $qry .= 'AND original.id <= ' . $max_id . ' '; } - if (!is_null($since)) { - $qry .= 'AND original.modified > \'' . date('Y-m-d H:i:s', $since) . '\' '; - } - // NOTE: we sort by fave time, not by notice time! $qry .= 'ORDER BY original.id DESC '; diff --git a/classes/User_group.php b/classes/User_group.php index 1382aa407c..7be55163a3 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -10,21 +10,23 @@ class User_group extends Memcached_DataObject public $__table = 'user_group'; // table name public $id; // int(4) primary_key not_null - public $nickname; // varchar(64) unique_key + public $nickname; // varchar(64) public $fullname; // varchar(255) public $homepage; // varchar(255) - public $description; // text() + public $description; // text public $location; // varchar(255) public $original_logo; // varchar(255) public $homepage_logo; // varchar(255) public $stream_logo; // varchar(255) public $mini_logo; // varchar(255) public $design_id; // int(4) - public $created; // datetime() not_null - public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP + public $created; // datetime not_null default_0000-00-00%2000%3A00%3A00 + public $modified; // timestamp not_null default_CURRENT_TIMESTAMP + public $uri; // varchar(255) unique_key + public $mainpage; // varchar(255) /* Static get */ - function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('User_group',$k,$v); } + function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('User_group',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE @@ -41,13 +43,33 @@ class User_group extends Memcached_DataObject { $url = null; if (Event::handle('StartUserGroupHomeUrl', array($this, &$url))) { - $url = common_local_url('showgroup', - array('nickname' => $this->nickname)); + // normally stored in mainpage, but older ones may be null + if (!empty($this->mainpage)) { + $url = $this->mainpage; + } else { + $url = common_local_url('showgroup', + array('nickname' => $this->nickname)); + } } Event::handle('EndUserGroupHomeUrl', array($this, &$url)); return $url; } + function getUri() + { + $uri = null; + if (Event::handle('StartUserGroupGetUri', array($this, &$uri))) { + if (!empty($this->uri)) { + $uri = $this->uri; + } else { + $uri = common_local_url('groupbyid', + array('id' => $this->id)); + } + } + Event::handle('EndUserGroupGetUri', array($this, &$uri)); + return $uri; + } + function permalink() { $url = null; @@ -69,7 +91,7 @@ class User_group extends Memcached_DataObject return Notice::getStreamByIds($ids); } - function _streamDirect($offset, $limit, $since_id, $max_id, $since) + function _streamDirect($offset, $limit, $since_id, $max_id) { $inbox = new Group_inbox(); @@ -86,10 +108,6 @@ class User_group extends Memcached_DataObject $inbox->whereAdd('notice_id <= ' . $max_id); } - if (!is_null($since)) { - $inbox->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\''); - } - $inbox->orderBy('notice_id DESC'); if (!is_null($offset)) { @@ -261,12 +279,26 @@ class User_group extends Memcached_DataObject return true; } - static function getForNickname($nickname) + static function getForNickname($nickname, $profile=null) { $nickname = common_canonical_nickname($nickname); - $group = User_group::staticGet('nickname', $nickname); + + // Are there any matching remote groups this profile's in? + if ($profile) { + $group = $profile->getGroups(); + while ($group->fetch()) { + if ($group->nickname == $nickname) { + // @fixme is this the best way? + return clone($group); + } + } + } + + // If not, check local groups. + + $group = Local_group::staticGet('nickname', $nickname); if (!empty($group)) { - return $group; + return User_group::staticGet('id', $group->group_id); } $alias = Group_alias::staticGet('alias', $nickname); if (!empty($alias)) { @@ -377,25 +409,41 @@ class User_group extends Memcached_DataObject return $xs->getString(); } + /** + * Returns an XML string fragment with group information as an + * Activity Streams element. + * + * Assumes that 'activity' namespace has been previously defined. + * + * @return string + */ function asActivitySubject() { - $xs = new XMLStringer(true); + return $this->asActivityNoun('subject'); + } - $xs->elementStart('activity:subject'); - $xs->element('activity:object', null, 'http://activitystrea.ms/schema/1.0/group'); - $xs->element('id', null, $this->permalink()); - $xs->element('title', null, $this->getBestName()); - $xs->element( - 'link', array( - 'rel' => 'avatar', - 'href' => empty($this->homepage_logo) - ? User_group::defaultLogo(AVATAR_PROFILE_SIZE) - : $this->homepage_logo - ) - ); - $xs->elementEnd('activity:subject'); + /** + * Returns an XML string fragment with group information as an + * Activity Streams noun object with the given element type. + * + * Assumes that 'activity', 'georss', and 'poco' namespace has been + * previously defined. + * + * @param string $element one of 'actor', 'subject', 'object', 'target' + * + * @return string + */ + function asActivityNoun($element) + { + $noun = ActivityObject::fromGroup($this); + return $noun->asString('activity:' . $element); + } - return $xs->getString(); + function getAvatar() + { + return empty($this->homepage_logo) + ? User_group::defaultLogo(AVATAR_PROFILE_SIZE) + : $this->homepage_logo; } static function register($fields) { @@ -407,34 +455,42 @@ class User_group extends Memcached_DataObject $group = new User_group(); $group->query('BEGIN'); + + if (empty($uri)) { + // fill in later... + $uri = null; + } $group->nickname = $nickname; $group->fullname = $fullname; $group->homepage = $homepage; $group->description = $description; $group->location = $location; + $group->uri = $uri; + $group->mainpage = $mainpage; $group->created = common_sql_now(); $result = $group->insert(); if (!$result) { common_log_db_error($group, 'INSERT', __FILE__); - $this->serverError( - _('Could not create group.'), - 500, - $this->format - ); - return; + throw new ServerException(_('Could not create group.')); } + + if (!isset($uri) || empty($uri)) { + $orig = clone($group); + $group->uri = common_local_url('groupbyid', array('id' => $group->id)); + $result = $group->update($orig); + if (!$result) { + common_log_db_error($group, 'UPDATE', __FILE__); + throw new ServerException(_('Could not set group URI.')); + } + } + $result = $group->setAliases($aliases); if (!$result) { - $this->serverError( - _('Could not create aliases.'), - 500, - $this->format - ); - return; + throw new ServerException(_('Could not create aliases.')); } $member = new Group_member(); @@ -448,12 +504,22 @@ class User_group extends Memcached_DataObject if (!$result) { common_log_db_error($member, 'INSERT', __FILE__); - $this->serverError( - _('Could not set group membership.'), - 500, - $this->format - ); - return; + throw new ServerException(_('Could not set group membership.')); + } + + if ($local) { + $local_group = new Local_group(); + + $local_group->group_id = $group->id; + $local_group->nickname = $nickname; + $local_group->created = common_sql_now(); + + $result = $local_group->insert(); + + if (!$result) { + common_log_db_error($local_group, 'INSERT', __FILE__); + throw new ServerException(_('Could not save local group info.')); + } } $group->query('COMMIT'); diff --git a/classes/User_username.php b/classes/User_username.php index 853fd5cb86..8d99cddd3f 100644 --- a/classes/User_username.php +++ b/classes/User_username.php @@ -55,7 +55,7 @@ class User_username extends Memcached_DataObject // now define the keys. function keys() { - return array('provider_name', 'username'); + return array('provider_name' => 'K', 'username' => 'K'); } } diff --git a/classes/statusnet.ini b/classes/statusnet.ini index d116b16a38..473bd6ff5f 100644 --- a/classes/statusnet.ini +++ b/classes/statusnet.ini @@ -245,13 +245,6 @@ modified = 384 group_id = K profile_id = K -[invitation] -code = 130 -user_id = 129 -address = 130 -address_type = 130 -created = 142 - [inbox] user_id = 129 notice_ids = 66 @@ -259,9 +252,26 @@ notice_ids = 66 [inbox__keys] user_id = K +[invitation] +code = 130 +user_id = 129 +address = 130 +address_type = 130 +created = 142 + [invitation__keys] code = K +[local_group] +group_id = 129 +nickname = 2 +created = 142 +modified = 384 + +[local_group__keys] +group_id = K +nickname = U + [location_namespace] id = 129 description = 2 @@ -369,7 +379,7 @@ icon = 130 source_url = 2 organization = 2 homepage = 2 -callback_url = 130 +callback_url = 2 type = 17 access_type = 17 created = 142 @@ -440,13 +450,13 @@ tag = K [queue_item] id = 129 -frame = 66 +frame = 194 transport = 130 created = 142 claimed = 14 [queue_item__keys] -id = K +id = N [related_group] group_id = 129 @@ -587,10 +597,11 @@ mini_logo = 2 design_id = 1 created = 142 modified = 384 +uri = 2 +mainpage = 2 [user_group__keys] id = N -nickname = U [user_openid] canonical = 130 diff --git a/config.php.sample b/config.php.sample index b8852dc672..75f5c7d557 100644 --- a/config.php.sample +++ b/config.php.sample @@ -124,6 +124,8 @@ $config['sphinx']['port'] = 3312; // Email info, used for all outbound email // $config['mail']['notifyfrom'] = 'microblog@example.net'; +// Domain for generating no-reply and incoming email addresses, if enabled. +// Defaults to site server name. // $config['mail']['domain'] = 'microblog.example.net'; // See http://pear.php.net/manual/en/package.mail.mail.factory.php for options // $config['mail']['backend'] = 'smtp'; @@ -131,8 +133,6 @@ $config['sphinx']['port'] = 3312; // 'host' => 'localhost', // 'port' => 25, // ); -// For incoming email, if enabled. Defaults to site server name. -// $config['mail']['domain'] = 'incoming.example.net'; // exponential decay factor for tags, default 10 days // raise this if traffic is slow, lower it if it's fast @@ -188,9 +188,6 @@ $config['sphinx']['port'] = 3312; // Disable SMS // $config['sms']['enabled'] = false; -// Disable Twitter integration -// $config['twitter']['enabled'] = false; - // Twitter integration source attribute. Note: default is StatusNet // $config['integration']['source'] = 'StatusNet'; @@ -198,7 +195,7 @@ $config['sphinx']['port'] = 3312; // // NOTE: if you enable this you must also set $config['avatar']['path'] // -// $config['twitterbridge']['enabled'] = true; +// $config['twitterimport']['enabled'] = true; // Twitter OAuth settings // $config['twitter']['consumer_key'] = 'YOURKEY'; @@ -212,10 +209,6 @@ $config['sphinx']['port'] = 3312; // $config['throttle']['count'] = 100; // $config['throttle']['timespan'] = 3600; -// List of users banned from posting (nicknames and/or IDs) -// $config['profile']['banned'][] = 'hacker'; -// $config['profile']['banned'][] = 12345; - // Config section for the built-in Facebook application // $config['facebook']['apikey'] = 'APIKEY'; // $config['facebook']['secret'] = 'SECRET'; @@ -275,6 +268,8 @@ $config['sphinx']['port'] = 3312; // Support for file uploads (attachments), // select supported mimetypes and quotas (in bytes) // $config['attachments']['supported'] = array('image/png', 'application/ogg'); +// $config['attachments']['supported'] = true; //allow all file types to be uploaded + // $config['attachments']['file_quota'] = 5000000; // $config['attachments']['user_quota'] = 50000000; // $config['attachments']['monthly_quota'] = 15000000; diff --git a/db/08to09.sql b/db/08to09.sql index d5f30a26b9..ba6f382005 100644 --- a/db/08to09.sql +++ b/db/08to09.sql @@ -111,7 +111,11 @@ alter table queue_item rename to queue_item_old; alter table queue_item_new rename to queue_item; alter table consumer - add column consumer_secret varchar(255) not null comment 'secret value'; + add consumer_secret varchar(255) not null comment 'secret value'; + +alter table token + add verifier varchar(255) comment 'verifier string for OAuth 1.0a', + add verified_callback varchar(255) comment 'verified callback URL for OAuth 1.0a'; create table oauth_application ( id integer auto_increment primary key comment 'unique identifier', @@ -140,4 +144,47 @@ create table oauth_application_user ( constraint primary key (profile_id, application_id) ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; +create table inbox ( + + user_id integer not null comment 'user receiving the notice' references user (id), + notice_ids blob comment 'packed list of notice ids', + + constraint primary key (user_id) + +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + +create table conversation ( + id integer auto_increment primary key comment 'unique identifier', + uri varchar(225) unique comment 'URI of the conversation', + created datetime not null comment 'date this record was created', + modified timestamp comment 'date this record was modified' +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + +-- stub entry to push the autoincrement past existing notice ids +insert into conversation (id,created) + select max(id)+1, now() from notice; + +alter table user_group + add uri varchar(255) unique key comment 'universal identifier', + add mainpage varchar(255) comment 'page for group info to link to', + drop index nickname; + +create table local_group ( + + group_id integer primary key comment 'group represented' references user_group (id), + nickname varchar(64) unique key comment 'group represented', + + created datetime not null comment 'date this record was created', + modified timestamp comment 'date this record was modified' + +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + +insert into local_group (group_id, nickname, created) + select id, nickname, created from user_group; + +alter table file_to_post + add index post_id_idx (post_id); + +alter table group_inbox + add index group_inbox_notice_id_idx (notice_id); diff --git a/db/beta5tobeta6.sql b/db/beta5tobeta6.sql new file mode 100644 index 0000000000..e9dff17efe --- /dev/null +++ b/db/beta5tobeta6.sql @@ -0,0 +1,28 @@ +alter table oauth_application + modify column name varchar(255) not null unique key comment 'name of the application', + modify column access_type tinyint default 0 comment 'access type, bit 1 = read, bit 2 = write'; + +alter table user_group +add column uri varchar(255) unique key comment 'universal identifier', +add column mainpage varchar(255) comment 'page for group info to link to', +drop index nickname; + +create table conversation ( + id integer auto_increment primary key comment 'unique identifier', + uri varchar(225) unique comment 'URI of the conversation', + created datetime not null comment 'date this record was created', + modified timestamp comment 'date this record was modified' +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + +create table local_group ( + group_id integer primary key comment 'group represented' references user_group (id), + nickname varchar(64) unique key comment 'group represented', + + created datetime not null comment 'date this record was created', + modified timestamp comment 'date this record was modified' + +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + +insert into local_group (group_id, nickname, created) +select id, nickname, created from user_group; + diff --git a/db/statusnet.sql b/db/statusnet.sql index d6f0f54a2d..d1cd670750 100644 --- a/db/statusnet.sql +++ b/db/statusnet.sql @@ -401,7 +401,7 @@ create table profile_block ( create table user_group ( id integer auto_increment primary key comment 'unique identifier', - nickname varchar(64) unique key comment 'nickname for addressing', + nickname varchar(64) comment 'nickname for addressing', fullname varchar(255) comment 'display name', homepage varchar(255) comment 'URL, cached so we dont regenerate', description text comment 'group description', @@ -416,6 +416,9 @@ create table user_group ( created datetime not null comment 'date this record was created', modified timestamp comment 'date this record was modified', + uri varchar(255) unique key comment 'universal identifier', + mainpage varchar(255) comment 'page for group info to link to', + index user_group_nickname_idx (nickname) ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci; @@ -450,7 +453,8 @@ create table group_inbox ( created datetime not null comment 'date the notice was created', constraint primary key (group_id, notice_id), - index group_inbox_created_idx (created) + index group_inbox_created_idx (created), + index group_inbox_notice_id_idx (notice_id) ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; @@ -515,7 +519,8 @@ create table file_to_post ( post_id integer comment 'id of the notice it belongs to' references notice (id), modified timestamp comment 'date this record was modified', - constraint primary key (file_id, post_id) + constraint primary key (file_id, post_id), + index post_id_idx (post_id) ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; @@ -650,3 +655,13 @@ create table conversation ( created datetime not null comment 'date this record was created', modified timestamp comment 'date this record was modified' ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; + +create table local_group ( + + group_id integer primary key comment 'group represented' references user_group (id), + nickname varchar(64) unique key comment 'group represented', + + created datetime not null comment 'date this record was created', + modified timestamp comment 'date this record was modified' + +) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; diff --git a/index.php b/index.php index 06ff9900fd..65f251bcce 100644 --- a/index.php +++ b/index.php @@ -37,8 +37,6 @@ define('INSTALLDIR', dirname(__FILE__)); define('STATUSNET', true); define('LACONICA', true); // compatibility -require_once INSTALLDIR . '/lib/common.php'; - $user = null; $action = null; @@ -68,52 +66,69 @@ function getPath($req) */ function handleError($error) { - if ($error->getCode() == DB_DATAOBJECT_ERROR_NODATA) { - return; - } + try { - $logmsg = "PEAR error: " . $error->getMessage(); - if (common_config('site', 'logdebug')) { - $logmsg .= " : ". $error->getDebugInfo(); - } - // DB queries often end up with a lot of newlines; merge to a single line - // for easier grepability... - $logmsg = str_replace("\n", " ", $logmsg); - common_log(LOG_ERR, $logmsg); - - // @fixme backtrace output should be consistent with exception handling - if (common_config('site', 'logdebug')) { - $bt = $error->getBacktrace(); - foreach ($bt as $n => $line) { - common_log(LOG_ERR, formatBacktraceLine($n, $line)); + if ($error->getCode() == DB_DATAOBJECT_ERROR_NODATA) { + return; } - } - if ($error instanceof DB_DataObject_Error - || $error instanceof DB_Error - ) { - $msg = sprintf( - _( - 'The database for %s isn\'t responding correctly, '. - 'so the site won\'t work properly. '. - 'The site admins probably know about the problem, '. - 'but you can contact them at %s to make sure. '. - 'Otherwise, wait a few minutes and try again.' - ), - common_config('site', 'name'), - common_config('site', 'email') - ); - } else { - $msg = _( - 'An important error occured, probably related to email setup. '. - 'Check logfiles for more info..' - ); - } - $dac = new DBErrorAction($msg, 500); - $dac->showPage(); + $logmsg = "PEAR error: " . $error->getMessage(); + if ($error instanceof PEAR_Exception && common_config('site', 'logdebug')) { + $logmsg .= " : ". $error->toText(); + } + // DB queries often end up with a lot of newlines; merge to a single line + // for easier grepability... + $logmsg = str_replace("\n", " ", $logmsg); + common_log(LOG_ERR, $logmsg); + + // @fixme backtrace output should be consistent with exception handling + if (common_config('site', 'logdebug')) { + $bt = $error->getTrace(); + foreach ($bt as $n => $line) { + common_log(LOG_ERR, formatBacktraceLine($n, $line)); + } + } + if ($error instanceof DB_DataObject_Error + || $error instanceof DB_Error + || ($error instanceof PEAR_Exception && $error->getCode() == -24) + ) { + //If we run into a DB error, assume we can't connect to the DB at all + //so set the current user to null, so we don't try to access the DB + //while rendering the error page. + global $_cur; + $_cur = null; + + $msg = sprintf( + _( + 'The database for %s isn\'t responding correctly, '. + 'so the site won\'t work properly. '. + 'The site admins probably know about the problem, '. + 'but you can contact them at %s to make sure. '. + 'Otherwise, wait a few minutes and try again.' + ), + common_config('site', 'name'), + common_config('site', 'email') + ); + } else { + $msg = _( + 'An important error occured, probably related to email setup. '. + 'Check logfiles for more info..' + ); + } + + $dac = new DBErrorAction($msg, 500); + $dac->showPage(); + + } catch (Exception $e) { + echo _('An error occurred.'); + } exit(-1); } +set_exception_handler('handleError'); + +require_once INSTALLDIR . '/lib/common.php'; + /** * Format a backtrace line for debug output roughly like debug_print_backtrace() does. * Exceptions already have this built in, but PEAR error objects just give us the array. @@ -185,7 +200,7 @@ function checkMirror($action_obj, $args) function isLoginAction($action) { - static $loginActions = array('login', 'recoverpassword', 'api', 'doc', 'register', 'publicxrds'); + static $loginActions = array('login', 'recoverpassword', 'api', 'doc', 'register', 'publicxrds', 'otp'); $login = null; @@ -238,10 +253,6 @@ function main() return; } - // For database errors - - PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handleError'); - // Make sure RW database is setup setupRW(); diff --git a/install.php b/install.php index 435f6d63bf..929277e5e8 100644 --- a/install.php +++ b/install.php @@ -31,6 +31,7 @@ * @author Robin Millette * @author Sarven Capadisli * @author Tom Adams + * @author Zach Copley * @license GNU Affero General Public License http://www.gnu.org/licenses/ * @version 0.9.x * @link http://status.net @@ -300,6 +301,19 @@ function checkPrereqs() $pass = false; } + // Look for known library bugs + $str = "abcdefghijklmnopqrstuvwxyz"; + $replaced = preg_replace('/[\p{Cc}\p{Cs}]/u', '*', $str); + if ($str != $replaced) { + printf('

PHP is linked to a version of the PCRE library ' . + 'that does not support Unicode properties. ' . + 'If you are running Red Hat Enterprise Linux / ' . + 'CentOS 5.4 or earlier, see our documentation page on fixing this.

'); + $pass = false; + } + $reqs = array('gd', 'curl', 'xmlwriter', 'mbstring', 'xml', 'dom', 'simplexml'); @@ -434,72 +448,119 @@ E_O_T; E_O_T; } +/** + * Helper class for building form + */ +class Posted { + function value($name) + { + if (isset($_POST[$name])) { + return htmlspecialchars(strval($_POST[$name])); + } else { + return ''; + } + } +} + function showForm() { global $dbModules; + $post = new Posted(); $dbRadios = ''; - $checked = 'checked="checked" '; // Check the first one which exists + if (isset($_POST['dbtype'])) { + $dbtype = $_POST['dbtype']; + } else { + $dbtype = null; + } foreach ($dbModules as $type => $info) { if (checkExtension($info['check_module'])) { + if ($dbtype == null || $dbtype == $type) { + $checked = 'checked="checked" '; + $dbtype = $type; // if we didn't have one checked, hit the first + } else { + $checked = ''; + } $dbRadios .= " $info[name]
\n"; - $checked = ''; } } echo<< -
-
Page notice
-
-
-

Enter your database connection information below to initialize the database.

-
-
-
- Connection settings -
    -
  • - - -

    The name of your site

    -
  • -
  • - - enable
    - disable
    -

    Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.

    -
  • -
  • - - -

    Database hostname

    -
  • -
  • +
    + Site settings +
      +
    • + + +

      The name of your site

      +
    • +
    • + + enable
      + disable
      +

      Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.

      +
    • +
    +
    - - $dbRadios -

    Database type

    -
  • +
    + Database settings +
      +
    • + + +

      Database hostname

      +
    • +
    • + + $dbRadios +

      Database type

      +
    • +
    • + + +

      Database name

      +
    • +
    • + + +

      Database username

      +
    • +
    • + + +

      Database password (optional)

      +
    • +
    +
    -
  • - - -

    Database name

    -
  • -
  • - - -

    Database username

    -
  • -
  • - - -

    Database password (optional)

    -
  • -
+
+ Administrator settings +
    +
  • + + +

    Nickname for the initial StatusNet user (administrator)

    +
  • +
  • + + +

    Password for the initial StatusNet user (administrator)

    +
  • +
  • + + +
  • +
  • + + +

    Optional email address for the initial StatusNet user (administrator)

    +
  • +
+
@@ -517,10 +578,16 @@ function handlePost() $host = $_POST['host']; $dbtype = $_POST['dbtype']; $database = $_POST['database']; - $username = $_POST['username']; - $password = $_POST['password']; + $username = $_POST['dbusername']; + $password = $_POST['dbpassword']; $sitename = $_POST['sitename']; $fancy = !empty($_POST['fancy']); + + $adminNick = $_POST['admin_nickname']; + $adminPass = $_POST['admin_password']; + $adminPass2 = $_POST['admin_password2']; + $adminEmail = $_POST['admin_email']; + $server = $_SERVER['HTTP_HOST']; $path = substr(dirname($_SERVER['PHP_SELF']), 1); @@ -552,6 +619,21 @@ STR; $fail = true; } + if (empty($adminNick)) { + updateStatus("No initial StatusNet user nickname specified.", true); + $fail = true; + } + + if (empty($adminPass)) { + updateStatus("No initial StatusNet user password specified.", true); + $fail = true; + } + + if ($adminPass != $adminPass2) { + updateStatus("Administrator passwords do not match. Did you mistype?", true); + $fail = true; + } + if ($fail) { showForm(); return; @@ -574,13 +656,29 @@ STR; return; } + // Okay, cross fingers and try to register an initial user + if (registerInitialUser($adminNick, $adminPass, $adminEmail)) { + updateStatus( + "An initial user with the administrator role has been created." + ); + } else { + updateStatus( + "Could not create initial StatusNet user (administrator).", + true + ); + showForm(); + return; + } + /* TODO https needs to be considered */ $link = "http://".$server.'/'.$path; updateStatus("StatusNet has been installed at $link"); - updateStatus("You can visit your new StatusNet site."); + updateStatus( + "DONE! You can visit your new StatusNet site (login as '$adminNick'). If this is your first StatusNet install, you may want to poke around our Getting Started guide." + ); } function Pgsql_Db_installer($host, $database, $username, $password) @@ -756,6 +854,47 @@ function runDbScript($filename, $conn, $type = 'mysqli') return true; } +function registerInitialUser($nickname, $password, $email) +{ + define('STATUSNET', true); + define('LACONICA', true); // compatibility + + require_once INSTALLDIR . '/lib/common.php'; + + $data = array('nickname' => $nickname, + 'password' => $password, + 'fullname' => $nickname); + if ($email) { + $data['email'] = $email; + } + $user = User::register($data); + + if (empty($user)) { + return false; + } + + // give initial user carte blanche + + $user->grantRole('owner'); + $user->grantRole('moderator'); + $user->grantRole('administrator'); + + // Attempt to do a remote subscribe to update@status.net + // Will fail if instance is on a private network. + + if (class_exists('Ostatus_profile')) { + try { + $oprofile = Ostatus_profile::ensureProfile('http://update.status.net/'); + Subscription::start($user->getProfile(), $oprofile->localProfile()); + updateStatus("Set up subscription to update@status.net."); + } catch (Exception $e) { + updateStatus("Could not set up subscription to update@status.net."); + } + } + + return true; +} + ?> xml version="1.0" encoding="UTF-8" "; ?> Install StatusNet - - - - + + + + @@ -784,8 +923,10 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-

Install StatusNet

+
+

Install StatusNet

+
diff --git a/js/jquery.js b/js/jquery.js index 237e1b9081..b3b95307a1 100644 --- a/js/jquery.js +++ b/js/jquery.js @@ -1,5 +1,5 @@ /*! - * jQuery JavaScript Library v1.4.1 + * jQuery JavaScript Library v1.4.2 * http://jquery.com/ * * Copyright 2010, John Resig @@ -11,7 +11,7 @@ * Copyright 2010, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. * - * Date: Mon Jan 25 19:43:33 2010 -0500 + * Date: Sat Feb 13 22:33:48 2010 -0500 */ (function( window, undefined ) { @@ -86,6 +86,15 @@ jQuery.fn = jQuery.prototype = { this.length = 1; return this; } + + // The body element only exists once, optimize finding it + if ( selector === "body" && !context ) { + this.context = document; + this[0] = document.body; + this.selector = "body"; + this.length = 1; + return this; + } // Handle HTML strings if ( typeof selector === "string" ) { @@ -116,7 +125,9 @@ jQuery.fn = jQuery.prototype = { ret = buildFragment( [ match[1] ], [ doc ] ); selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; } - + + return jQuery.merge( this, selector ); + // HANDLE: $("#id") } else { elem = document.getElementById( match[2] ); @@ -143,6 +154,7 @@ jQuery.fn = jQuery.prototype = { this.selector = selector; this.context = document; selector = document.getElementsByTagName( selector ); + return jQuery.merge( this, selector ); // HANDLE: $(expr, $(...)) } else if ( !context || context.jquery ) { @@ -165,16 +177,14 @@ jQuery.fn = jQuery.prototype = { this.context = selector.context; } - return jQuery.isArray( selector ) ? - this.setArray( selector ) : - jQuery.makeArray( selector, this ); + return jQuery.makeArray( selector, this ); }, // Start with an empty selector selector: "", // The current version of jQuery being used - jquery: "1.4.1", + jquery: "1.4.2", // The default length of a jQuery object is 0 length: 0, @@ -204,7 +214,14 @@ jQuery.fn = jQuery.prototype = { // (returning the new matched element set) pushStack: function( elems, name, selector ) { // Build a new jQuery matched element set - var ret = jQuery( elems || null ); + var ret = jQuery(); + + if ( jQuery.isArray( elems ) ) { + push.apply( ret, elems ); + + } else { + jQuery.merge( ret, elems ); + } // Add the old object onto the stack (as a reference) ret.prevObject = this; @@ -221,18 +238,6 @@ jQuery.fn = jQuery.prototype = { return ret; }, - // Force the current matched set of elements to become - // the specified array of elements (destroying the stack in the process) - // You should use pushStack() in order to do this, but maintain the stack - setArray: function( elems ) { - // Resetting the length to 0, then using the native Array push - // is a super-fast way to populate an object with array-like properties - this.length = 0; - push.apply( this, elems ); - - return this; - }, - // Execute a callback for every element in the matched set. // (You can seed the arguments with an array of args, but this is // only used internally.) @@ -492,6 +497,9 @@ jQuery.extend({ if ( typeof data !== "string" || !data ) { return null; } + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); // Make sure the incoming data is actual JSON // Logic borrowed from http://json.org/json2.js @@ -619,6 +627,7 @@ jQuery.extend({ for ( var l = second.length; j < l; j++ ) { first[ i++ ] = second[ j ]; } + } else { while ( second[j] !== undefined ) { first[ i++ ] = second[ j++ ]; @@ -807,7 +816,7 @@ function access( elems, key, value, exec, fn, pass ) { } // Getting an attribute - return length ? fn( elems[0], key ) : null; + return length ? fn( elems[0], key ) : undefined; } function now() { @@ -871,7 +880,10 @@ function now() { // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected, + parentNode: div.removeChild( div.appendChild( document.createElement("div") ) ).parentNode === null, + // Will be defined later + deleteExpando: true, checkClone: false, scriptEval: false, noCloneEvent: true, @@ -893,6 +905,15 @@ function now() { delete window[ id ]; } + // Test to see if it's possible to delete an expando from an element + // Fails in Internet Explorer + try { + delete script.test; + + } catch(e) { + jQuery.support.deleteExpando = false; + } + root.removeChild( script ); if ( div.attachEvent && div.fireEvent ) { @@ -923,6 +944,7 @@ function now() { document.body.appendChild( div ); jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; document.body.removeChild( div ).style.display = 'none'; + div = null; }); @@ -962,7 +984,6 @@ jQuery.props = { frameborder: "frameBorder" }; var expando = "jQuery" + now(), uuid = 0, windowData = {}; -var emptyObject = {}; jQuery.extend({ cache: {}, @@ -988,8 +1009,7 @@ jQuery.extend({ var id = elem[ expando ], cache = jQuery.cache, thisCache; - // Handle the case where there's no name immediately - if ( !name && !id ) { + if ( !id && typeof name === "string" && data === undefined ) { return null; } @@ -1003,17 +1023,16 @@ jQuery.extend({ if ( typeof name === "object" ) { elem[ expando ] = id; thisCache = cache[ id ] = jQuery.extend(true, {}, name); - } else if ( cache[ id ] ) { - thisCache = cache[ id ]; - } else if ( typeof data === "undefined" ) { - thisCache = emptyObject; - } else { - thisCache = cache[ id ] = {}; + + } else if ( !cache[ id ] ) { + elem[ expando ] = id; + cache[ id ] = {}; } + thisCache = cache[ id ]; + // Prevent overriding the named cache with undefined values if ( data !== undefined ) { - elem[ expando ] = id; thisCache[ name ] = data; } @@ -1045,15 +1064,11 @@ jQuery.extend({ // Otherwise, we want to remove all of the element's data } else { - // Clean up the element expando - try { - delete elem[ expando ]; - } catch( e ) { - // IE has trouble directly removing the expando - // but it's ok with using removeAttribute - if ( elem.removeAttribute ) { - elem.removeAttribute( expando ); - } + if ( jQuery.support.deleteExpando ) { + delete elem[ jQuery.expando ]; + + } else if ( elem.removeAttribute ) { + elem.removeAttribute( jQuery.expando ); } // Completely remove the data cache @@ -1230,12 +1245,13 @@ jQuery.fn.extend({ elem.className = value; } else { - var className = " " + elem.className + " "; + var className = " " + elem.className + " ", setClass = elem.className; for ( var c = 0, cl = classNames.length; c < cl; c++ ) { if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { - elem.className += " " + classNames[c]; + setClass += " " + classNames[c]; } } + elem.className = jQuery.trim( setClass ); } } } @@ -1264,7 +1280,7 @@ jQuery.fn.extend({ for ( var c = 0, cl = classNames.length; c < cl; c++ ) { className = className.replace(" " + classNames[c] + " ", " "); } - elem.className = className.substring(1, className.length - 1); + elem.className = jQuery.trim( className ); } else { elem.className = ""; @@ -1520,15 +1536,16 @@ jQuery.extend({ } // elem is actually elem.style ... set the style - // Using attr for specific style information is now deprecated. Use style insead. + // Using attr for specific style information is now deprecated. Use style instead. return jQuery.style( elem, name, value ); } }); -var fcleanup = function( nm ) { - return nm.replace(/[^\w\s\.\|`]/g, function( ch ) { - return "\\" + ch; - }); -}; +var rnamespaces = /\.(.*)$/, + fcleanup = function( nm ) { + return nm.replace(/[^\w\s\.\|`]/g, function( ch ) { + return "\\" + ch; + }); + }; /* * A number of helper functions used for managing events. @@ -1550,107 +1567,104 @@ jQuery.event = { elem = window; } + var handleObjIn, handleObj; + + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + } + // Make sure that the function being executed has a unique ID if ( !handler.guid ) { handler.guid = jQuery.guid++; } - // if data is passed, bind to handler - if ( data !== undefined ) { - // Create temporary function pointer to original handler - var fn = handler; + // Init the element's event structure + var elemData = jQuery.data( elem ); - // Create unique handler function, wrapped around original handler - handler = jQuery.proxy( fn ); - - // Store data in unique handler - handler.data = data; + // If no elemData is found then we must be trying to bind to one of the + // banned noData elements + if ( !elemData ) { + return; } - // Init the element's event structure - var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ), - handle = jQuery.data( elem, "handle" ), eventHandle; + var events = elemData.events = elemData.events || {}, + eventHandle = elemData.handle, eventHandle; - if ( !handle ) { - eventHandle = function() { + if ( !eventHandle ) { + elemData.handle = eventHandle = function() { // Handle the second event of a trigger and when // an event is called after a page has unloaded return typeof jQuery !== "undefined" && !jQuery.event.triggered ? jQuery.event.handle.apply( eventHandle.elem, arguments ) : undefined; }; - - handle = jQuery.data( elem, "handle", eventHandle ); - } - - // If no handle is found then we must be trying to bind to one of the - // banned noData elements - if ( !handle ) { - return; } // Add elem as a property of the handle function - // This is to prevent a memory leak with non-native - // event in IE. - handle.elem = elem; + // This is to prevent a memory leak with non-native events in IE. + eventHandle.elem = elem; // Handle multiple events separated by a space // jQuery(...).bind("mouseover mouseout", fn); - types = types.split( /\s+/ ); + types = types.split(" "); - var type, i = 0; + var type, i = 0, namespaces; while ( (type = types[ i++ ]) ) { + handleObj = handleObjIn ? + jQuery.extend({}, handleObjIn) : + { handler: handler, data: data }; + // Namespaced event handlers - var namespaces = type.split("."); - type = namespaces.shift(); + if ( type.indexOf(".") > -1 ) { + namespaces = type.split("."); + type = namespaces.shift(); + handleObj.namespace = namespaces.slice(0).sort().join("."); - if ( i > 1 ) { - handler = jQuery.proxy( handler ); - - if ( data !== undefined ) { - handler.data = data; - } + } else { + namespaces = []; + handleObj.namespace = ""; } - handler.type = namespaces.slice(0).sort().join("."); + handleObj.type = type; + handleObj.guid = handler.guid; // Get the current list of functions bound to this event var handlers = events[ type ], - special = this.special[ type ] || {}; + special = jQuery.event.special[ type ] || {}; // Init the event handler queue if ( !handlers ) { - handlers = events[ type ] = {}; + handlers = events[ type ] = []; // Check for a special event handler // Only use addEventListener/attachEvent if the special // events handler returns false - if ( !special.setup || special.setup.call( elem, data, namespaces, handler) === false ) { + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { // Bind the global event handler to the element if ( elem.addEventListener ) { - elem.addEventListener( type, handle, false ); + elem.addEventListener( type, eventHandle, false ); + } else if ( elem.attachEvent ) { - elem.attachEvent( "on" + type, handle ); + elem.attachEvent( "on" + type, eventHandle ); } } } if ( special.add ) { - var modifiedHandler = special.add.call( elem, handler, data, namespaces, handlers ); - if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) { - modifiedHandler.guid = modifiedHandler.guid || handler.guid; - modifiedHandler.data = modifiedHandler.data || handler.data; - modifiedHandler.type = modifiedHandler.type || handler.type; - handler = modifiedHandler; - } - } - + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + // Add the function to the element's handler list - handlers[ handler.guid ] = handler; + handlers.push( handleObj ); // Keep track of which events have been used, for global triggering - this.global[ type ] = true; + jQuery.event.global[ type ] = true; } // Nullify elem to prevent memory leaks in IE @@ -1660,90 +1674,121 @@ jQuery.event = { global: {}, // Detach an event or set of events from an element - remove: function( elem, types, handler ) { + remove: function( elem, types, handler, pos ) { // don't do events on text and comment nodes if ( elem.nodeType === 3 || elem.nodeType === 8 ) { return; } - var events = jQuery.data( elem, "events" ), ret, type, fn; + var ret, type, fn, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, + elemData = jQuery.data( elem ), + events = elemData && elemData.events; - if ( events ) { - // Unbind all events for the element - if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) { - for ( type in events ) { - this.remove( elem, type + (types || "") ); - } - } else { - // types is actually an event object here - if ( types.type ) { - handler = types.handler; - types = types.type; + if ( !elemData || !events ) { + return; + } + + // types is actually an event object here + if ( types && types.type ) { + handler = types.handler; + types = types.type; + } + + // Unbind all events for the element + if ( !types || typeof types === "string" && types.charAt(0) === "." ) { + types = types || ""; + + for ( type in events ) { + jQuery.event.remove( elem, type + types ); + } + + return; + } + + // Handle multiple events separated by a space + // jQuery(...).unbind("mouseover mouseout", fn); + types = types.split(" "); + + while ( (type = types[ i++ ]) ) { + origType = type; + handleObj = null; + all = type.indexOf(".") < 0; + namespaces = []; + + if ( !all ) { + // Namespaced event handlers + namespaces = type.split("."); + type = namespaces.shift(); + + namespace = new RegExp("(^|\\.)" + + jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)") + } + + eventType = events[ type ]; + + if ( !eventType ) { + continue; + } + + if ( !handler ) { + for ( var j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( all || namespace.test( handleObj.namespace ) ) { + jQuery.event.remove( elem, origType, handleObj.handler, j ); + eventType.splice( j--, 1 ); + } } - // Handle multiple events separated by a space - // jQuery(...).unbind("mouseover mouseout", fn); - types = types.split(/\s+/); - var i = 0; - while ( (type = types[ i++ ]) ) { - // Namespaced event handlers - var namespaces = type.split("."); - type = namespaces.shift(); - var all = !namespaces.length, - cleaned = jQuery.map( namespaces.slice(0).sort(), fcleanup ), - namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"), - special = this.special[ type ] || {}; + continue; + } - if ( events[ type ] ) { - // remove the given handler for the given type - if ( handler ) { - fn = events[ type ][ handler.guid ]; - delete events[ type ][ handler.guid ]; + special = jQuery.event.special[ type ] || {}; - // remove all handlers for the given type - } else { - for ( var handle in events[ type ] ) { - // Handle the removal of namespaced events - if ( all || namespace.test( events[ type ][ handle ].type ) ) { - delete events[ type ][ handle ]; - } - } + for ( var j = pos || 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( handler.guid === handleObj.guid ) { + // remove the given handler for the given type + if ( all || namespace.test( handleObj.namespace ) ) { + if ( pos == null ) { + eventType.splice( j--, 1 ); } if ( special.remove ) { - special.remove.call( elem, namespaces, fn); + special.remove.call( elem, handleObj ); } + } - // remove generic event handler if no more handlers exist - for ( ret in events[ type ] ) { - break; - } - if ( !ret ) { - if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { - if ( elem.removeEventListener ) { - elem.removeEventListener( type, jQuery.data( elem, "handle" ), false ); - } else if ( elem.detachEvent ) { - elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) ); - } - } - ret = null; - delete events[ type ]; - } + if ( pos != null ) { + break; } } } - // Remove the expando if it's no longer used - for ( ret in events ) { - break; - } - if ( !ret ) { - var handle = jQuery.data( elem, "handle" ); - if ( handle ) { - handle.elem = null; + // remove generic event handler if no more handlers exist + if ( eventType.length === 0 || pos != null && eventType.length === 1 ) { + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { + removeEvent( elem, type, elemData.handle ); } - jQuery.removeData( elem, "events" ); - jQuery.removeData( elem, "handle" ); + + ret = null; + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + var handle = elemData.handle; + if ( handle ) { + handle.elem = null; + } + + delete elemData.events; + delete elemData.handle; + + if ( jQuery.isEmptyObject( elemData ) ) { + jQuery.removeData( elem ); } } }, @@ -1774,7 +1819,7 @@ jQuery.event = { event.stopPropagation(); // Only trigger if we've ever bound an event for it - if ( this.global[ type ] ) { + if ( jQuery.event.global[ type ] ) { jQuery.each( jQuery.cache, function() { if ( this.events && this.events[type] ) { jQuery.event.trigger( event, data, this.handle.elem ); @@ -1825,9 +1870,12 @@ jQuery.event = { } else if ( !event.isDefaultPrevented() ) { var target = event.target, old, - isClick = jQuery.nodeName(target, "a") && type === "click"; + isClick = jQuery.nodeName(target, "a") && type === "click", + special = jQuery.event.special[ type ] || {}; + + if ( (!special._default || special._default.call( elem, event ) === false) && + !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) { - if ( !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) { try { if ( target[ type ] ) { // Make sure that we don't accidentally re-trigger the onFOO events @@ -1837,7 +1885,7 @@ jQuery.event = { target[ "on" + type ] = null; } - this.triggered = true; + jQuery.event.triggered = true; target[ type ](); } @@ -1848,53 +1896,57 @@ jQuery.event = { target[ "on" + type ] = old; } - this.triggered = false; + jQuery.event.triggered = false; } } }, handle: function( event ) { - // returned undefined or false - var all, handlers; + var all, handlers, namespaces, namespace, events; event = arguments[0] = jQuery.event.fix( event || window.event ); event.currentTarget = this; // Namespaced event handlers - var namespaces = event.type.split("."); - event.type = namespaces.shift(); + all = event.type.indexOf(".") < 0 && !event.exclusive; - // Cache this now, all = true means, any handler - all = !namespaces.length && !event.exclusive; + if ( !all ) { + namespaces = event.type.split("."); + event.type = namespaces.shift(); + namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)"); + } - var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)"); + var events = jQuery.data(this, "events"), handlers = events[ event.type ]; - handlers = ( jQuery.data(this, "events") || {} )[ event.type ]; + if ( events && handlers ) { + // Clone the handlers to prevent manipulation + handlers = handlers.slice(0); - for ( var j in handlers ) { - var handler = handlers[ j ]; + for ( var j = 0, l = handlers.length; j < l; j++ ) { + var handleObj = handlers[ j ]; - // Filter the functions by class - if ( all || namespace.test(handler.type) ) { - // Pass in a reference to the handler function itself - // So that we can later remove it - event.handler = handler; - event.data = handler.data; + // Filter the functions by class + if ( all || namespace.test( handleObj.namespace ) ) { + // Pass in a reference to the handler function itself + // So that we can later remove it + event.handler = handleObj.handler; + event.data = handleObj.data; + event.handleObj = handleObj; + + var ret = handleObj.handler.apply( this, arguments ); - var ret = handler.apply( this, arguments ); + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } - if ( ret !== undefined ) { - event.result = ret; - if ( ret === false ) { - event.preventDefault(); - event.stopPropagation(); + if ( event.isImmediatePropagationStopped() ) { + break; } } - - if ( event.isImmediatePropagationStopped() ) { - break; - } - } } @@ -1973,44 +2025,39 @@ jQuery.event = { }, live: { - add: function( proxy, data, namespaces, live ) { - jQuery.extend( proxy, data || {} ); + add: function( handleObj ) { + jQuery.event.add( this, handleObj.origType, jQuery.extend({}, handleObj, {handler: liveHandler}) ); + }, - proxy.guid += data.selector + data.live; - data.liveProxy = proxy; - - jQuery.event.add( this, data.live, liveHandler, data ); + remove: function( handleObj ) { + var remove = true, + type = handleObj.origType.replace(rnamespaces, ""); - }, - - remove: function( namespaces ) { - if ( namespaces.length ) { - var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); - - jQuery.each( (jQuery.data(this, "events").live || {}), function() { - if ( name.test(this.type) ) { - remove++; - } - }); - - if ( remove < 1 ) { - jQuery.event.remove( this, namespaces[0], liveHandler ); + jQuery.each( jQuery.data(this, "events").live || [], function() { + if ( type === this.origType.replace(rnamespaces, "") ) { + remove = false; + return false; } + }); + + if ( remove ) { + jQuery.event.remove( this, handleObj.origType, liveHandler ); } - }, - special: {} + } + }, + beforeunload: { - setup: function( data, namespaces, fn ) { + setup: function( data, namespaces, eventHandle ) { // We only want to do this special case on windows if ( this.setInterval ) { - this.onbeforeunload = fn; + this.onbeforeunload = eventHandle; } return false; }, - teardown: function( namespaces, fn ) { - if ( this.onbeforeunload === fn ) { + teardown: function( namespaces, eventHandle ) { + if ( this.onbeforeunload === eventHandle ) { this.onbeforeunload = null; } } @@ -2018,6 +2065,14 @@ jQuery.event = { } }; +var removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + elem.removeEventListener( type, handle, false ); + } : + function( elem, type, handle ) { + elem.detachEvent( "on" + type, handle ); + }; + jQuery.Event = function( src ) { // Allow instantiation without the 'new' keyword if ( !this.preventDefault ) { @@ -2095,27 +2150,24 @@ var withinElement = function( event ) { // Check if mouse(over|out) are still within the same parent element var parent = event.relatedTarget; - // Traverse up the tree - while ( parent && parent !== this ) { - // Firefox sometimes assigns relatedTarget a XUL element - // which we cannot access the parentNode property of - try { + // Firefox sometimes assigns relatedTarget a XUL element + // which we cannot access the parentNode property of + try { + // Traverse up the tree + while ( parent && parent !== this ) { parent = parent.parentNode; - - // assuming we've left the element since we most likely mousedover a xul element - } catch(e) { - break; } - } - if ( parent !== this ) { - // set the correct event type - event.type = event.data; + if ( parent !== this ) { + // set the correct event type + event.type = event.data; - // handle event if we actually just moused on to a non sub-element - jQuery.event.handle.apply( this, arguments ); - } + // handle event if we actually just moused on to a non sub-element + jQuery.event.handle.apply( this, arguments ); + } + // assuming we've left the element since we most likely mousedover a xul element + } catch(e) { } }, // In case of event delegation, we only need to rename the event.type, @@ -2143,64 +2195,65 @@ jQuery.each({ // submit delegation if ( !jQuery.support.submitBubbles ) { -jQuery.event.special.submit = { - setup: function( data, namespaces, fn ) { - if ( this.nodeName.toLowerCase() !== "form" ) { - jQuery.event.add(this, "click.specialSubmit." + fn.guid, function( e ) { - var elem = e.target, type = elem.type; + jQuery.event.special.submit = { + setup: function( data, namespaces ) { + if ( this.nodeName.toLowerCase() !== "form" ) { + jQuery.event.add(this, "click.specialSubmit", function( e ) { + var elem = e.target, type = elem.type; - if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { - return trigger( "submit", this, arguments ); - } - }); + if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { + return trigger( "submit", this, arguments ); + } + }); - jQuery.event.add(this, "keypress.specialSubmit." + fn.guid, function( e ) { - var elem = e.target, type = elem.type; + jQuery.event.add(this, "keypress.specialSubmit", function( e ) { + var elem = e.target, type = elem.type; - if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { - return trigger( "submit", this, arguments ); - } - }); + if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { + return trigger( "submit", this, arguments ); + } + }); - } else { - return false; + } else { + return false; + } + }, + + teardown: function( namespaces ) { + jQuery.event.remove( this, ".specialSubmit" ); } - }, - - remove: function( namespaces, fn ) { - jQuery.event.remove( this, "click.specialSubmit" + (fn ? "."+fn.guid : "") ); - jQuery.event.remove( this, "keypress.specialSubmit" + (fn ? "."+fn.guid : "") ); - } -}; + }; } // change delegation, happens here so we have bind. if ( !jQuery.support.changeBubbles ) { -var formElems = /textarea|input|select/i; + var formElems = /textarea|input|select/i, -function getVal( elem ) { - var type = elem.type, val = elem.value; + changeFilters, - if ( type === "radio" || type === "checkbox" ) { - val = elem.checked; + getVal = function( elem ) { + var type = elem.type, val = elem.value; - } else if ( type === "select-multiple" ) { - val = elem.selectedIndex > -1 ? - jQuery.map( elem.options, function( elem ) { - return elem.selected; - }).join("-") : - ""; + if ( type === "radio" || type === "checkbox" ) { + val = elem.checked; - } else if ( elem.nodeName.toLowerCase() === "select" ) { - val = elem.selectedIndex; - } + } else if ( type === "select-multiple" ) { + val = elem.selectedIndex > -1 ? + jQuery.map( elem.options, function( elem ) { + return elem.selected; + }).join("-") : + ""; - return val; -} + } else if ( elem.nodeName.toLowerCase() === "select" ) { + val = elem.selectedIndex; + } -function testChange( e ) { + return val; + }, + + testChange = function testChange( e ) { var elem = e.target, data, val; if ( !formElems.test( elem.nodeName ) || elem.readOnly ) { @@ -2223,61 +2276,61 @@ function testChange( e ) { e.type = "change"; return jQuery.event.trigger( e, arguments[1], elem ); } -} + }; -jQuery.event.special.change = { - filters: { - focusout: testChange, + jQuery.event.special.change = { + filters: { + focusout: testChange, - click: function( e ) { - var elem = e.target, type = elem.type; + click: function( e ) { + var elem = e.target, type = elem.type; - if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) { - return testChange.call( this, e ); - } - }, + if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) { + return testChange.call( this, e ); + } + }, - // Change has to be called before submit - // Keydown will be called before keypress, which is used in submit-event delegation - keydown: function( e ) { - var elem = e.target, type = elem.type; + // Change has to be called before submit + // Keydown will be called before keypress, which is used in submit-event delegation + keydown: function( e ) { + var elem = e.target, type = elem.type; - if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") || - (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || - type === "select-multiple" ) { - return testChange.call( this, e ); - } - }, + if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") || + (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || + type === "select-multiple" ) { + return testChange.call( this, e ); + } + }, - // Beforeactivate happens also before the previous element is blurred - // with this event you can't trigger a change event, but you can store - // information/focus[in] is not needed anymore - beforeactivate: function( e ) { - var elem = e.target; - - if ( elem.nodeName.toLowerCase() === "input" && elem.type === "radio" ) { + // Beforeactivate happens also before the previous element is blurred + // with this event you can't trigger a change event, but you can store + // information/focus[in] is not needed anymore + beforeactivate: function( e ) { + var elem = e.target; jQuery.data( elem, "_change_data", getVal(elem) ); } + }, + + setup: function( data, namespaces ) { + if ( this.type === "file" ) { + return false; + } + + for ( var type in changeFilters ) { + jQuery.event.add( this, type + ".specialChange", changeFilters[type] ); + } + + return formElems.test( this.nodeName ); + }, + + teardown: function( namespaces ) { + jQuery.event.remove( this, ".specialChange" ); + + return formElems.test( this.nodeName ); } - }, - setup: function( data, namespaces, fn ) { - for ( var type in changeFilters ) { - jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] ); - } - - return formElems.test( this.nodeName ); - }, - remove: function( namespaces, fn ) { - for ( var type in changeFilters ) { - jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] ); - } - - return formElems.test( this.nodeName ); - } -}; - -var changeFilters = jQuery.event.special.change.filters; + }; + changeFilters = jQuery.event.special.change.filters; } function trigger( type, elem, args ) { @@ -2325,11 +2378,16 @@ jQuery.each(["bind", "one"], function( i, name ) { return fn.apply( this, arguments ); }) : fn; - return type === "unload" && name !== "one" ? - this.one( type, data, fn ) : - this.each(function() { - jQuery.event.add( this, type, handler, data ); - }); + if ( type === "unload" && name !== "one" ) { + this.one( type, data, fn ); + + } else { + for ( var i = 0, l = this.length; i < l; i++ ) { + jQuery.event.add( this[i], type, handler, data ); + } + } + + return this; }; }); @@ -2340,13 +2398,29 @@ jQuery.fn.extend({ for ( var key in type ) { this.unbind(key, type[key]); } - return this; + + } else { + for ( var i = 0, l = this.length; i < l; i++ ) { + jQuery.event.remove( this[i], type, fn ); + } } - return this.each(function() { - jQuery.event.remove( this, type, fn ); - }); + return this; }, + + delegate: function( selector, types, data, fn ) { + return this.live( types, data, fn, selector ); + }, + + undelegate: function( selector, types, fn ) { + if ( arguments.length === 0 ) { + return this.unbind( "live" ); + + } else { + return this.die( types, null, fn, selector ); + } + }, + trigger: function( type, data ) { return this.each(function() { jQuery.event.trigger( type, data, this ); @@ -2390,32 +2464,60 @@ jQuery.fn.extend({ } }); +var liveMap = { + focus: "focusin", + blur: "focusout", + mouseenter: "mouseover", + mouseleave: "mouseout" +}; + jQuery.each(["live", "die"], function( i, name ) { - jQuery.fn[ name ] = function( types, data, fn ) { - var type, i = 0; + jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) { + var type, i = 0, match, namespaces, preType, + selector = origSelector || this.selector, + context = origSelector ? this : jQuery( this.context ); if ( jQuery.isFunction( data ) ) { fn = data; data = undefined; } - types = (types || "").split( /\s+/ ); + types = (types || "").split(" "); while ( (type = types[ i++ ]) != null ) { - type = type === "focus" ? "focusin" : // focus --> focusin - type === "blur" ? "focusout" : // blur --> focusout - type === "hover" ? types.push("mouseleave") && "mouseenter" : // hover support - type; - + match = rnamespaces.exec( type ); + namespaces = ""; + + if ( match ) { + namespaces = match[0]; + type = type.replace( rnamespaces, "" ); + } + + if ( type === "hover" ) { + types.push( "mouseenter" + namespaces, "mouseleave" + namespaces ); + continue; + } + + preType = type; + + if ( type === "focus" || type === "blur" ) { + types.push( liveMap[ type ] + namespaces ); + type = type + namespaces; + + } else { + type = (liveMap[ type ] || type) + namespaces; + } + if ( name === "live" ) { // bind live handler - jQuery( this.context ).bind( liveConvert( type, this.selector ), { - data: data, selector: this.selector, live: type - }, fn ); + context.each(function(){ + jQuery.event.add( this, liveConvert( type, selector ), + { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } ); + }); } else { // unbind live handler - jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null ); + context.unbind( liveConvert( type, selector ), fn ); } } @@ -2425,45 +2527,46 @@ jQuery.each(["live", "die"], function( i, name ) { function liveHandler( event ) { var stop, elems = [], selectors = [], args = arguments, - related, match, fn, elem, j, i, l, data, - live = jQuery.extend({}, jQuery.data( this, "events" ).live); + related, match, handleObj, elem, j, i, l, data, + events = jQuery.data( this, "events" ); // Make sure we avoid non-left-click bubbling in Firefox (#3861) - if ( event.button && event.type === "click" ) { + if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) { return; } - for ( j in live ) { - fn = live[j]; - if ( fn.live === event.type || - fn.altLive && jQuery.inArray(event.type, fn.altLive) > -1 ) { + event.liveFired = this; + + var live = events.live.slice(0); + + for ( j = 0; j < live.length; j++ ) { + handleObj = live[j]; + + if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) { + selectors.push( handleObj.selector ); - data = fn.data; - if ( !(data.beforeFilter && data.beforeFilter[event.type] && - !data.beforeFilter[event.type](event)) ) { - selectors.push( fn.selector ); - } } else { - delete live[j]; + live.splice( j--, 1 ); } } match = jQuery( event.target ).closest( selectors, event.currentTarget ); for ( i = 0, l = match.length; i < l; i++ ) { - for ( j in live ) { - fn = live[j]; - elem = match[i].elem; - related = null; + for ( j = 0; j < live.length; j++ ) { + handleObj = live[j]; + + if ( match[i].selector === handleObj.selector ) { + elem = match[i].elem; + related = null; - if ( match[i].selector === fn.selector ) { // Those two events require additional checking - if ( fn.live === "mouseenter" || fn.live === "mouseleave" ) { - related = jQuery( event.relatedTarget ).closest( fn.selector )[0]; + if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) { + related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0]; } if ( !related || related !== elem ) { - elems.push({ elem: elem, fn: fn }); + elems.push({ elem: elem, handleObj: handleObj }); } } } @@ -2472,8 +2575,10 @@ function liveHandler( event ) { for ( i = 0, l = elems.length; i < l; i++ ) { match = elems[i]; event.currentTarget = match.elem; - event.data = match.fn.data; - if ( match.fn.apply( match.elem, args ) === false ) { + event.data = match.handleObj.data; + event.handleObj = match.handleObj; + + if ( match.handleObj.origHandler.apply( match.elem, args ) === false ) { stop = false; break; } @@ -2483,7 +2588,7 @@ function liveHandler( event ) { } function liveConvert( type, selector ) { - return "live." + (type ? type + "." : "") + selector.replace(/\./g, "`").replace(/ /g, "&"); + return "live." + (type && type !== "*" ? type + "." : "") + selector.replace(/\./g, "`").replace(/ /g, "&"); } jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + @@ -3228,8 +3333,10 @@ var makeArray = function(array, results) { // Perform a simple check to determine if the browser is capable of // converting a NodeList to an array using builtin methods. +// Also verifies that the returned array holds DOM nodes +// (which is not the case in the Blackberry browser) try { - Array.prototype.slice.call( document.documentElement.childNodes, 0 ); + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; // Provide a fallback method if it does not work } catch(e){ @@ -3533,7 +3640,7 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { } var contains = document.compareDocumentPosition ? function(a, b){ - return a.compareDocumentPosition(b) & 16; + return !!(a.compareDocumentPosition(b) & 16); } : function(a, b){ return a !== b && (a.contains ? a.contains(b) : true); }; @@ -3570,7 +3677,7 @@ jQuery.find = Sizzle; jQuery.expr = Sizzle.selectors; jQuery.expr[":"] = jQuery.expr.filters; jQuery.unique = Sizzle.uniqueSort; -jQuery.getText = getText; +jQuery.text = getText; jQuery.isXMLDoc = isXML; jQuery.contains = contains; @@ -3856,7 +3963,8 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i, rtagName = /<([\w:]+)/, rtbody = / self-closes a tag + .replace(/=([^="'>\s]+\/)>/g, '="$1">') .replace(rleadingWhitespace, "")], ownerDocument)[0]; } else { return this.cloneNode(true); @@ -4044,7 +4188,7 @@ jQuery.fn.extend({ null; // See if we can take a shortcut and just use innerHTML - } else if ( typeof value === "string" && !/