]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
All line endings are now Unix-style.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 31 Aug 2009 19:05:21 +0000 (19:05 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 31 Aug 2009 19:05:21 +0000 (19:05 +0000)
git-svn-id: https://code.elgg.org/elgg/trunk@3451 36083f99-b078-4883-b0ff-0f9b5a30f544

231 files changed:
CONTRIBUTORS.txt
INSTALL.txt
README.txt
_css/css.php
_css/js.php
account/register.php
actions/admin/plugins/disable.php
actions/admin/plugins/disableall.php
actions/admin/plugins/enable.php
actions/admin/plugins/reorder.php
actions/admin/site/update_basic.php
actions/admin/user/ban.php
actions/comments/add.php
actions/comments/delete.php
actions/email/save.php
actions/friends/add.php
actions/friends/addcollection.php
actions/friends/deletecollection.php
actions/friends/editcollection.php
actions/friends/remove.php
actions/login.php
actions/logout.php
actions/register.php
actions/systemsettings/install.php
actions/user/default_access.php
actions/user/requestnewpassword.php
actions/user/spotlight.php
actions/useradd.php
actions/usersettings/save.php
actions/widgets/add.php
actions/widgets/reorder.php
actions/widgets/save.php
admin/index.php
admin/plugins.php
admin/site.php
admin/user.php
dashboard/index.php
dashboard/latest.php
engine/handlers/action_handler.php
engine/handlers/cron_handler.php
engine/handlers/pagehandler.php
engine/handlers/xml-rpc_handler.php
engine/lib/access.php
engine/lib/activity.php
engine/lib/admin.php
engine/lib/api.php
engine/lib/configuration.php
engine/lib/database.php
engine/lib/elgglib.php
engine/lib/entities.php
engine/lib/extender.php
engine/lib/input.php
engine/lib/install.php
engine/lib/languages.php
engine/lib/metadata.php
engine/lib/metastrings.php
engine/lib/notification.php
engine/lib/objects.php
engine/lib/pagehandler.php
engine/lib/pageowner.php
engine/lib/pam.php
engine/lib/plugins.php
engine/lib/query.php
engine/lib/relationships.php
engine/lib/river2.php
engine/lib/sessions.php
engine/lib/sites.php
engine/lib/social.php
engine/lib/statistics.php
engine/lib/tags.php
engine/lib/upgrades/2008101303.php
engine/lib/users.php
engine/lib/version.php
engine/lib/widgets.php
engine/settings.example.php
engine/start.php
entities/index.php
entities/list.php
friends/add.php
friends/collections.php
friends/edit.php
friends/index.php
friends/of.php
friends/pickercallback.php
index.php
install.php
languages/en.php
mod/garbagecollector/languages/en.php
mod/logbrowser/index.php
mod/logbrowser/languages/en.php
mod/logbrowser/start.php
mod/logbrowser/views/default/logbrowser/adminlinks.php
mod/logbrowser/views/default/logbrowser/form.php
mod/logbrowser/views/default/object/logwrapper.php
mod/uservalidationbyemail/start.php
settings/index.php
simplecache/view.php
upgrade.php
vendors/calendarpopup/CalendarPopup.js
vendors/jquery/jquery.form.js
version.php
views/default/account/forms/login.php
views/default/account/forms/register.php
views/default/admin/main.php
views/default/admin/plugins_opt/plugin.php
views/default/admin/statistics.php
views/default/admin/statistics_opt/numentities.php
views/default/admin/statistics_opt/online.php
views/default/admin/user_opt/search.php
views/default/ajax/loader.php
views/default/annotation/annotate.php
views/default/annotation/generic_comment.php
views/default/basic_elements/welcome.php
views/default/canvas/default.php
views/default/canvas/layouts/edit_layout.php
views/default/canvas/layouts/sidebar_boxes.php
views/default/canvas_header/submenu_group.php
views/default/canvas_header/submenu_template.php
views/default/comments/forms/edit.php
views/default/dashboard/blurb.php
views/default/embed/addcontentjs.php
views/default/embed/js.php
views/default/friends/collection.php
views/default/friends/collections.php
views/default/friends/collectiontabs.php
views/default/friends/forms/collectionfields.php
views/default/friends/forms/edit.php
views/default/friends/list.php
views/default/friends/picker.php
views/default/friends/river/create.php
views/default/friends/tablelistcountupdate.php
views/default/input/access.php
views/default/input/calendar.php
views/default/input/checkboxes.php
views/default/input/email.php
views/default/input/file.php
views/default/input/longtext.php
views/default/input/password.php
views/default/input/plaintext.php
views/default/input/pulldown.php
views/default/input/radio.php
views/default/input/tags.php
views/default/input/text.php
views/default/input/url.php
views/default/js/friendsPickerv1.php
views/default/js/initialise_elgg.php
views/default/js/upload_js.php
views/default/messages/errors/error.php
views/default/messages/errors/list.php
views/default/messages/exceptions/exception.php
views/default/messages/list.php
views/default/messages/messages/list.php
views/default/messages/messages/message.php
views/default/navigation/viewtype.php
views/default/notifications/settings/usersettings.php
views/default/object/widget.php
views/default/output/calendar.php
views/default/output/checkboxes.php
views/default/output/confirmlink.php
views/default/output/date.php
views/default/output/email.php
views/default/output/longtext.php
views/default/output/pulldown.php
views/default/output/radio.php
views/default/output/tagcloud.php
views/default/output/tags.php
views/default/output/text.php
views/default/output/url.php
views/default/page_elements/contentwrapper.php
views/default/page_elements/header_contents.php
views/default/page_elements/owner_block.php
views/default/river/item/list.php
views/default/river/item/noaccess.php
views/default/river/item/wrapper.php
views/default/river/wrapper.php
views/default/settings/install.php
views/default/settings/system.php
views/default/settings/upgrading.php
views/default/spotlight/default.php
views/default/text/about.php
views/default/text/privacy_view.php
views/default/text/tos_view.php
views/default/upload/upload_form_content.php
views/default/user/default.php
views/default/user/settings/default_access.php
views/default/user/settings/email.php
views/default/user/settings/name.php
views/default/user/settings/password.php
views/default/usersettings/statistics_opt/numentities.php
views/default/welcome.php
views/default/widgets/editwrapper.php
views/default/widgets/wrapper.php
views/failsafe/canvas/default.php
views/failsafe/input/access.php
views/failsafe/input/checkboxes.php
views/failsafe/input/longtext.php
views/failsafe/input/pulldown.php
views/failsafe/input/text.php
views/failsafe/messages/errors/error.php
views/failsafe/messages/errors/list.php
views/failsafe/messages/list.php
views/failsafe/messages/messages/list.php
views/failsafe/messages/messages/message.php
views/failsafe/messages/sanitisation/htaccess.php
views/failsafe/settings/install.php
views/failsafe/settings/system.php
views/foaf/canvas/default.php
views/foaf/page_elements/contentwrapper.php
views/foaf/pageshells/pageshell.php
views/foaf/user/default.php
views/js/object/default.php
views/js/pageshells/pageshell.php
views/js/user/default.php
views/json/api/output.php
views/json/canvas/default.php
views/json/export/entity.php
views/json/export/metadata.php
views/json/export/relationship.php
views/json/messages/exceptions/exception.php
views/json/page_elements/contentwrapper.php
views/json/pageshells/pageshell.php
views/json/river/item/list.php
views/opendd/messages/exceptions/exception.php
views/rss/annotation/default.php
views/rss/canvas/default.php
views/rss/group/default.php
views/rss/object/default.php
views/rss/page_elements/contentwrapper.php
views/rss/river/item/list.php
views/rss/user/default.php
views/xml/messages/exceptions/exception.php

index af850a2b488660a3503fdcb237b1882b374b2489..dc10fafaf0fd7518baec572a3530ab3c6e67fdf9 100644 (file)
@@ -1,36 +1,36 @@
-\r
-CONTRIBUTORS\r
-\r
-The core Elgg team:\r
-\r
-David Tosh <dave@elgg.com>\r
-http://twitter.com/davetosh\r
-\r
-Marcus Povey <marcus@elgg.com>\r
-http://marcuspovey.co.uk/\r
-http://twitter.com/mapkyca\r
-\r
-Brett Profitt <brett@elgg.com>\r
-http://twitter.com/brettprofitt\r
-\r
-Pete Harris <pete@elgg.com>\r
-\r
-\r
-CONTRIBUTING/ALUMNI DEVELOPERS\r
-\r
-Kevin Jardine <kevin@radagast.biz>\r
-http://radagast.biz/\r
-\r
-Milan Magudia <milan.magudia@thematiccapital.com>\r
-\r
-Ben Werdmuller <ben@elgg.com>\r
-http://benwerd.com/\r
-http://twitter.com/benwerd\r
-\r
-\r
-Thanks to the following developers for contributing patches and/or suggestions\r
-\r
-Diego Andrés Ramírez Aragón <diego@somosmas.org>\r
-Corporación Somos Más\r
-\r
+
+CONTRIBUTORS
+
+The core Elgg team:
+
+David Tosh <dave@elgg.com>
+http://twitter.com/davetosh
+
+Marcus Povey <marcus@elgg.com>
+http://marcuspovey.co.uk/
+http://twitter.com/mapkyca
+
+Brett Profitt <brett@elgg.com>
+http://twitter.com/brettprofitt
+
+Pete Harris <pete@elgg.com>
+
+
+CONTRIBUTING/ALUMNI DEVELOPERS
+
+Kevin Jardine <kevin@radagast.biz>
+http://radagast.biz/
+
+Milan Magudia <milan.magudia@thematiccapital.com>
+
+Ben Werdmuller <ben@elgg.com>
+http://benwerd.com/
+http://twitter.com/benwerd
+
+
+Thanks to the following developers for contributing patches and/or suggestions
+
+Diego Andrés Ramírez Aragón <diego@somosmas.org>
+Corporación Somos Más
+
 Cash Costello <cash.costello@gmail.com>
\ No newline at end of file
index 2df994a876cae252239788f02d3fca4f381ff554..b5a6e1e8bf0935d1da65c264f7770582683dc85c 100644 (file)
-\r
-ELGG INSTALLATION INSTRUCTIONS\r
-\r
-TECHNICAL REQUIREMENTS\r
-\r
-Elgg runs on a combination of the Apache web server, MySQL database \r
-system and the PHP interpreted scripting language. This is the most \r
-popular web server environment in the world.\r
-\r
-Due to Elgg's advanced functionality, there are some extra \r
-configuration requirements:\r
-\r
-    * The Apache web server needs to be installed with the following\r
-      modules:\r
-          o mod_rewrite\r
-          o PHP \r
-    * MySQL 5+ is needed for data storage\r
-    * PHP 5.2+ needs to be installed as an Apache module (not in CGI\r
-      mode or safe mode) with the following libraries:\r
-          o GD (for graphics processing, eg user icon rescaling)\r
-          o JSON (for API functionality) \r
-\r
-It is recommended that you increase the memory available to PHP \r
-threads beyond the standard 8 or 12M, and increase the maximum \r
-uploaded filesize (which defaults to 2M). In both cases, this can be\r
-found in your php.ini.\r
-\r
-    * The following PHP libraries are also recommended for some \r
-      plugins and extra functionality:\r
-          o mbstring (to allow emails to be sent with non-Latin \r
-            characters)\r
-          o SOAP\r
-          o DOM \r
-\r
-\r
-INSTALLING ELGG\r
-\r
-Before you begin, make sure you have read Elgg's technical \r
-requirements. If you discover problems after following these \r
-instructions, check out the troubleshooting page at \r
-[http://docs.elgg.org/wiki/Troubleshooting].\r
-\r
-\r
-1. Upload Elgg\r
-\r
-Unzip Elgg and upload it to your site's document root.\r
-\r
-\r
-2. Create a data folder\r
-\r
-Elgg needs a special folder to store uploaded files, including \r
-profile icons and photos. You will need to create this for it.\r
-\r
-We recommend that this folder is called data, and is stored outside \r
-of your document root. For example, if Elgg is installed in \r
-/home/elgg/html/, you might create it in /home/elgg/data.\r
-\r
-Once this folder has been created, you'll need to make sure Elgg has\r
-permission to write to it. This shouldn't be a problem on Windows-\r
-based servers, but if your server runs Linux or a UNIX variant, \r
-you'll need to type something like:\r
-\r
-chmod 777 /home/elgg/data/\r
-\r
-If you use a graphical client to upload files, you can usually set \r
-this by right or shift-clicking on the folder and selecting \r
-'properties'.\r
-\r
-\r
-3. Create a database\r
-\r
-Using your database administration tool of choice (if you're unsure \r
-about this, ask your system administrator), create a new database for \r
-Elgg. Make sure you know the username and password necessary to \r
-access this.\r
-\r
-4. Install your crontab (UNIX ONLY)\r
-\r
-Cron is a UNIX command which allows programs to be run at set \r
-times of the day.\r
-\r
-If you want to take advantage of some of the maintenance \r
-functions such as log rotation or garbage collection, you must \r
-install a cron tab to trigger these events.\r
-\r
-We have provided an example crontab as /crontab.example. Edit this \r
-with a text editor to provide the details of your site, rename it\r
-to another filename (eg 'crontab.mine') and install it with the \r
-following command:\r
-\r
-                       crontab crontab.mine \r
-                       \r
-Substitute your filename for 'crontab.mine'.\r
-\r
-5. Visit your Elgg site\r
-\r
-Once you've performed these steps, visit your Elgg site in your web \r
-browser. Elgg will take you through the rest of the installation \r
-process from there.\r
-\r
-A note on settings and .htaccess\r
-\r
-The Elgg installer will try and create two files for you:\r
-\r
-    * engine/settings.php, which contains the database settings for \r
-      your installation\r
-    * .htaccess, which allows Elgg to generate dynamic URLs \r
-\r
-If these files can't be automatically generated, for example because\r
-you don't have the correct directory permissions, Elgg will tell you\r
-how to create them. If, for some reason, this won't work, you will \r
-need to:\r
-\r
-    * Copy engine/settings.example.php to engine/settings.php, open \r
-      it up in a text editor and fill in your database details\r
-    * Copy /htaccess_dist to /.htaccess \r
-\r
-\r
-The latest version of this document is available at:\r
+
+ELGG INSTALLATION INSTRUCTIONS
+
+TECHNICAL REQUIREMENTS
+
+Elgg runs on a combination of the Apache web server, MySQL database 
+system and the PHP interpreted scripting language. This is the most 
+popular web server environment in the world.
+
+Due to Elgg's advanced functionality, there are some extra 
+configuration requirements:
+
+    * The Apache web server needs to be installed with the following
+      modules:
+          o mod_rewrite
+          o PHP 
+    * MySQL 5+ is needed for data storage
+    * PHP 5.2+ needs to be installed as an Apache module (not in CGI
+      mode or safe mode) with the following libraries:
+          o GD (for graphics processing, eg user icon rescaling)
+          o JSON (for API functionality) 
+
+It is recommended that you increase the memory available to PHP 
+threads beyond the standard 8 or 12M, and increase the maximum 
+uploaded filesize (which defaults to 2M). In both cases, this can be
+found in your php.ini.
+
+    * The following PHP libraries are also recommended for some 
+      plugins and extra functionality:
+          o mbstring (to allow emails to be sent with non-Latin 
+            characters)
+          o SOAP
+          o DOM 
+
+
+INSTALLING ELGG
+
+Before you begin, make sure you have read Elgg's technical 
+requirements. If you discover problems after following these 
+instructions, check out the troubleshooting page at 
+[http://docs.elgg.org/wiki/Troubleshooting].
+
+
+1. Upload Elgg
+
+Unzip Elgg and upload it to your site's document root.
+
+
+2. Create a data folder
+
+Elgg needs a special folder to store uploaded files, including 
+profile icons and photos. You will need to create this for it.
+
+We recommend that this folder is called data, and is stored outside 
+of your document root. For example, if Elgg is installed in 
+/home/elgg/html/, you might create it in /home/elgg/data.
+
+Once this folder has been created, you'll need to make sure Elgg has
+permission to write to it. This shouldn't be a problem on Windows-
+based servers, but if your server runs Linux or a UNIX variant, 
+you'll need to type something like:
+
+chmod 777 /home/elgg/data/
+
+If you use a graphical client to upload files, you can usually set 
+this by right or shift-clicking on the folder and selecting 
+'properties'.
+
+
+3. Create a database
+
+Using your database administration tool of choice (if you're unsure 
+about this, ask your system administrator), create a new database for 
+Elgg. Make sure you know the username and password necessary to 
+access this.
+
+4. Install your crontab (UNIX ONLY)
+
+Cron is a UNIX command which allows programs to be run at set 
+times of the day.
+
+If you want to take advantage of some of the maintenance 
+functions such as log rotation or garbage collection, you must 
+install a cron tab to trigger these events.
+
+We have provided an example crontab as /crontab.example. Edit this 
+with a text editor to provide the details of your site, rename it
+to another filename (eg 'crontab.mine') and install it with the 
+following command:
+
+                       crontab crontab.mine 
+                       
+Substitute your filename for 'crontab.mine'.
+
+5. Visit your Elgg site
+
+Once you've performed these steps, visit your Elgg site in your web 
+browser. Elgg will take you through the rest of the installation 
+process from there.
+
+A note on settings and .htaccess
+
+The Elgg installer will try and create two files for you:
+
+    * engine/settings.php, which contains the database settings for 
+      your installation
+    * .htaccess, which allows Elgg to generate dynamic URLs 
+
+If these files can't be automatically generated, for example because
+you don't have the correct directory permissions, Elgg will tell you
+how to create them. If, for some reason, this won't work, you will 
+need to:
+
+    * Copy engine/settings.example.php to engine/settings.php, open 
+      it up in a text editor and fill in your database details
+    * Copy /htaccess_dist to /.htaccess 
+
+
+The latest version of this document is available at:
 [http://docs.elgg.org/wiki/Installation]
\ No newline at end of file
index b7196c8424a862192bcf451b7b0e1a0f03b034f7..4ae9a4358113dd0aa426c48c49e9193ce27a7428 100644 (file)
@@ -1,35 +1,35 @@
-Elgg version 1.5\r
-Copyright (c) 2008-2009 Curverider Ltd\r
-\r
-This program is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-This program is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with this program; if not, write to the Free Software\r
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  \r
-USA\r
-\r
-\r
-ABOUT:\r
-\r
-See CONTRIBUTORS.txt for development credits.\r
-\r
-Elgg concept originally by:\r
-Ben Werdmuller <ben@elgg.com> and David Tosh <dave@elgg.com>\r
-\r
-Commercial services:  http://elgg.com/\r
-\r
-The open source project site can be found at http://elgg.org/\r
-\r
-Elgg 1.5 is released under the GNU Public License (GPL), which\r
-is supplied in this distribution as LICENSE.\r
-\r
-For installation instructions, please see the INSTALL file.\r
-\r
+Elgg version 1.5
+Copyright (c) 2008-2009 Curverider Ltd
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  
+USA
+
+
+ABOUT:
+
+See CONTRIBUTORS.txt for development credits.
+
+Elgg concept originally by:
+Ben Werdmuller <ben@elgg.com> and David Tosh <dave@elgg.com>
+
+Commercial services:  http://elgg.com/
+
+The open source project site can be found at http://elgg.org/
+
+Elgg 1.5 is released under the GNU Public License (GPL), which
+is supplied in this distribution as LICENSE.
+
+For installation instructions, please see the INSTALL file.
+
index 1cc3eb038f6c41c4306af6bc450b362baca080ac..0db16d8a939d21aad81eed0fd7d0e7d48e3b0914 100644 (file)
@@ -1,44 +1,44 @@
-<?php\r
-\r
-       /**\r
-        * Elgg CSS file\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg CSS file
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+       
+               /*
 
-        * @link http://elgg.org/\r
-        */\r
-       \r
-               /*\r
-\r
            require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
            
            $default_css = elgg_view("css");
-           \r
+           
            header("Content-type: text/css", true);
                header('Expires: ' . date('r',time() + 864000), true);
                header("Pragma: public", true);
                header("Cache-Control: public", true);
-           header("Content-Length: " . strlen($default_css));\r
-              \r
-           echo $default_css;\r
-               */\r
-\r
-               define('externalpage',true);\r
-\r
-               global $viewinput, $override;\r
-               $viewinput['view'] = 'css';\r
-               $viewinput['viewtype'] = $_GET['viewtype'];\r
-\r
-               //$override = true;\r
-               \r
-               header("Content-type: text/css", true);\r
-               header('Expires: ' . date('r',time() + 86400000), true);\r
-               header("Pragma: public", true);\r
-               header("Cache-Control: public", true);\r
-           // header("Content-Length: " . strlen($default_css));\r
-               require_once(dirname(dirname(__FILE__)) . '/simplecache/view.php');\r
-    \r
+           header("Content-Length: " . strlen($default_css));
+              
+           echo $default_css;
+               */
+
+               define('externalpage',true);
+
+               global $viewinput, $override;
+               $viewinput['view'] = 'css';
+               $viewinput['viewtype'] = $_GET['viewtype'];
+
+               //$override = true;
+               
+               header("Content-type: text/css", true);
+               header('Expires: ' . date('r',time() + 86400000), true);
+               header("Pragma: public", true);
+               header("Cache-Control: public", true);
+           // header("Content-Length: " . strlen($default_css));
+               require_once(dirname(dirname(__FILE__)) . '/simplecache/view.php');
+    
 ?>
\ No newline at end of file
index 3839b76e48495399036e09c185c15d3dfbe59117..89c748caba86469005b695986c324410edcd3114 100644 (file)
@@ -1,44 +1,44 @@
-<?php\r
-\r
-       /**\r
-        * Elgg CSS file\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg CSS file
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-       \r
-               /*\r
-\r
-           require_once(dirname(dirname(__FILE__)) . "/engine/start.php");\r
-           \r
-           $default_css = elgg_view("css");\r
-           \r
-           header("Content-type: text/css", true);\r
-               header('Expires: ' . date('r',time() + 864000), true);\r
-               header("Pragma: public", true);\r
-               header("Cache-Control: public", true);\r
-           header("Content-Length: " . strlen($default_css));\r
-              \r
-           echo $default_css;\r
-               */\r
-\r
-               define('externalpage',true);\r
-\r
-               global $viewinput, $override;\r
-               //$override = true;\r
-               $viewinput['view'] = 'js/' . $_GET['js'];\r
-               $viewinput['viewtype'] = $_GET['viewtype'];\r
-\r
-               header('Content-type: text/javascript');\r
-               header('Expires: ' . date('r',time() + 864000000));\r
-               header("Pragma: public");\r
-               header("Cache-Control: public"); \r
-               // header("Content-Length: " . strlen($return));\r
-               \r
-               require_once(dirname(dirname(__FILE__)) . '/simplecache/view.php');\r
-    \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+       
+               /*
+
+           require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+           
+           $default_css = elgg_view("css");
+           
+           header("Content-type: text/css", true);
+               header('Expires: ' . date('r',time() + 864000), true);
+               header("Pragma: public", true);
+               header("Cache-Control: public", true);
+           header("Content-Length: " . strlen($default_css));
+              
+           echo $default_css;
+               */
+
+               define('externalpage',true);
+
+               global $viewinput, $override;
+               //$override = true;
+               $viewinput['view'] = 'js/' . $_GET['js'];
+               $viewinput['viewtype'] = $_GET['viewtype'];
+
+               header('Content-type: text/javascript');
+               header('Expires: ' . date('r',time() + 864000000));
+               header("Pragma: public");
+               header("Cache-Control: public"); 
+               // header("Content-Length: " . strlen($return));
+               
+               require_once(dirname(dirname(__FILE__)) . '/simplecache/view.php');
+    
 ?>
\ No newline at end of file
index 350a770e9733568f001e48df703101977e98b32f..be7f9892ea689f446fa98e179ea820e7b04ced1c 100644 (file)
@@ -1,30 +1,30 @@
-<?php\r
-\r
-       /**\r
-        * Elgg registration page\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg registration page
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /**\r
-        * Start the Elgg engine\r
-        */\r
-               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");\r
-\r
-               $friend_guid = (int) get_input('friend_guid',0);\r
-               $invitecode = get_input('invitecode');\r
-               \r
-       // If we're not logged in, display the registration page\r
-               if (!isloggedin()) {\r
-                       page_draw(elgg_echo('register'), elgg_view("account/forms/register", array('friend_guid' => $friend_guid, 'invitecode' => $invitecode)));\r
-       // Otherwise, forward to the index page\r
-               } else {\r
-                       forward();\r
-               }\r
-               \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       /**
+        * Start the Elgg engine
+        */
+               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+
+               $friend_guid = (int) get_input('friend_guid',0);
+               $invitecode = get_input('invitecode');
+               
+       // If we're not logged in, display the registration page
+               if (!isloggedin()) {
+                       page_draw(elgg_echo('register'), elgg_view("account/forms/register", array('friend_guid' => $friend_guid, 'invitecode' => $invitecode)));
+       // Otherwise, forward to the index page
+               } else {
+                       forward();
+               }
+               
 ?>
\ No newline at end of file
index 2241730add6841262d06bdde27910712ee34a322..90825bc2f587216cd9734c4a82b40b15b28e96d0 100644 (file)
@@ -29,9 +29,9 @@
                else
                        register_error(sprintf(elgg_echo('admin:plugins:disable:no'), $p));
        }               
-       \r
+       
        elgg_view_regenerate_simplecache();
-       elgg_filepath_cache_reset();\r
+       elgg_filepath_cache_reset();
                
        forward($_SERVER['HTTP_REFERER']);
        exit;
index 5d0be4ad66e2b65ac1a184265e7de057fc82da3f..672915bcef830c0f4caa4ec9e284299be31d1477 100644 (file)
@@ -26,9 +26,9 @@
                else
                        register_error(sprintf(elgg_echo('admin:plugins:disable:no'), $p));
        }               
-       \r
+       
        elgg_view_regenerate_simplecache();
-       elgg_filepath_cache_reset();\r
+       elgg_filepath_cache_reset();
                
        forward($_SERVER['HTTP_REFERER']);
        exit;
index 26d7abaf4766a4354592fea15ea1f912ae6fd9b2..890e6648eaeeffd10f7992a19a5b6e2fc7edb88f 100644 (file)
@@ -29,7 +29,7 @@
                else
                        register_error(sprintf(elgg_echo('admin:plugins:enable:no'), $p));              
        }
-               \r
+               
        elgg_view_regenerate_simplecache();
        elgg_filepath_cache_reset();
        
index 50409df95e40920b0096caed5115d620e2d53acc..36ba1f66d85e007943c828ac5ae5580592826b5c 100644 (file)
@@ -1,54 +1,54 @@
-<?php\r
-       /**\r
+<?php
+       /**
         * Reorder plugin action.
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php");\r
-       \r
-       // block non-admin users\r
-       admin_gatekeeper();\r
-       \r
-       // Validate the action\r
-       action_gatekeeper();\r
-       \r
-       // Get the plugin \r
-       $mod = get_input('plugin');\r
-       $mod = str_replace('.','',$mod);\r
-       $mod = str_replace('/','',$mod);\r
-       \r
-       // Get the new order\r
-       $order = (int) get_input('order');\r
-       \r
-       // Get the current plugin list\r
-       $plugins = get_plugin_list();\r
-\r
-       // Inject the plugin order back into the list\r
-       if ($key = array_search($mod, $plugins)) {\r
-               \r
-               unset($plugins[$key]);\r
-               while (isset($plugins[$order])) {\r
-                       $order++;\r
-               }\r
-               \r
-               $plugins[$order] = $mod;\r
-       }\r
-       \r
-       // Disable\r
-       if (regenerate_plugin_list($plugins))\r
-               system_message(sprintf(elgg_echo('admin:plugins:reorder:yes'), $plugin));\r
-       else\r
-               register_error(sprintf(elgg_echo('admin:plugins:reorder:no'), $plugin));                \r
-               \r
+        * @link http://elgg.org/
+        */
+
+       require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php");
+       
+       // block non-admin users
+       admin_gatekeeper();
+       
+       // Validate the action
+       action_gatekeeper();
+       
+       // Get the plugin 
+       $mod = get_input('plugin');
+       $mod = str_replace('.','',$mod);
+       $mod = str_replace('/','',$mod);
+       
+       // Get the new order
+       $order = (int) get_input('order');
+       
+       // Get the current plugin list
+       $plugins = get_plugin_list();
+
+       // Inject the plugin order back into the list
+       if ($key = array_search($mod, $plugins)) {
+               
+               unset($plugins[$key]);
+               while (isset($plugins[$order])) {
+                       $order++;
+               }
+               
+               $plugins[$order] = $mod;
+       }
+       
+       // Disable
+       if (regenerate_plugin_list($plugins))
+               system_message(sprintf(elgg_echo('admin:plugins:reorder:yes'), $plugin));
+       else
+               register_error(sprintf(elgg_echo('admin:plugins:reorder:no'), $plugin));                
+               
        elgg_view_regenerate_simplecache();
-       elgg_filepath_cache_reset();\r
-               \r
-       forward($_SERVER['HTTP_REFERER']);\r
-\r
+       elgg_filepath_cache_reset();
+               
+       forward($_SERVER['HTTP_REFERER']);
+
 ?>
\ No newline at end of file
index d56e1d2969e522a69d1d5e3760b0bb977b3a1e0f..31a6b401eeb3d5ed74d02c191671a30080bf5059 100644 (file)
-<?php\r
-\r
-       /**\r
-        * Elgg update site action\r
-        * \r
-        * This is an update version of the sitesettings/install action which is used by the admin panel to modify basic settings.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg update site action
+        * 
+        * This is an update version of the sitesettings/install action which is used by the admin panel to modify basic settings.
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       global $CONFIG;\r
-       \r
-       // block non-admin users\r
-       admin_gatekeeper();\r
-       action_gatekeeper();\r
-       \r
-       if (get_input('settings') == 'go') {\r
-               \r
-               if (datalist_get('default_site')) {\r
-                       \r
-                       $site = get_entity(datalist_get('default_site'));\r
-                       if (!($site instanceof ElggSite)) \r
-                               throw new InstallationException(elgg_echo('InvalidParameterException:NonElggSite'));\r
-                       \r
-                       $site->description = get_input('sitedescription');\r
-                       $site->name = get_input('sitename');\r
-                       $site->email = get_input('siteemail');\r
-                       $site->url = get_input('wwwroot');\r
-                       \r
-                       datalist_set('path',sanitise_filepath(get_input('path')));\r
-                       datalist_set('dataroot',sanitise_filepath(get_input('dataroot')));\r
-                       if (get_input('simplecache_enabled')) {\r
-                               elgg_view_enable_simplecache();\r
-                       } else {\r
-                               elgg_view_disable_simplecache();\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       global $CONFIG;
+       
+       // block non-admin users
+       admin_gatekeeper();
+       action_gatekeeper();
+       
+       if (get_input('settings') == 'go') {
+               
+               if (datalist_get('default_site')) {
+                       
+                       $site = get_entity(datalist_get('default_site'));
+                       if (!($site instanceof ElggSite)) 
+                               throw new InstallationException(elgg_echo('InvalidParameterException:NonElggSite'));
+                       
+                       $site->description = get_input('sitedescription');
+                       $site->name = get_input('sitename');
+                       $site->email = get_input('siteemail');
+                       $site->url = get_input('wwwroot');
+                       
+                       datalist_set('path',sanitise_filepath(get_input('path')));
+                       datalist_set('dataroot',sanitise_filepath(get_input('dataroot')));
+                       if (get_input('simplecache_enabled')) {
+                               elgg_view_enable_simplecache();
+                       } else {
+                               elgg_view_disable_simplecache();
                        }
                        if (get_input('viewpath_cache_enabled')) {
                                elgg_enable_filepath_cache();
                        } else {
                                elgg_disable_filepath_cache();
-                       }\r
-                       \r
-                       set_config('language', get_input('language'), $site->getGUID());\r
-                       \r
-                       set_config('default_access', get_input('default_access'), $site->getGUID());\r
-                       \r
-                       if (get_input('allow_user_default_access')) {\r
-                               set_config('allow_user_default_access', 1, $site->getGUID());\r
-                       } else {\r
-                               set_config('allow_user_default_access', 0, $site->getGUID());\r
-                       }\r
-                       \r
-                       set_config('view', get_input('view'), $site->getGUID());\r
-                       \r
-                       $debug = get_input('debug');\r
-                       if ($debug)\r
-                               set_config('debug', 1, $site->getGUID());\r
-                       else\r
-                               unset_config('debug', $site->getGUID());\r
-                               \r
-                       $https_login = get_input('https_login'); \r
-                       if ($https_login)\r
-                               set_config('https_login', 1, $site->getGUID());\r
-                       else\r
-                               unset_config('https_login', $site->getGUID());\r
-                               \r
-                       $usage = get_input('usage');\r
-                       if ($usage)\r
-                               unset_config('ping_home', $site->getGUID());\r
-                       else\r
-                               set_config('ping_home', 'disabled', $site->getGUID());\r
-                               \r
-                       $api = get_input('api');\r
-                       if ($api)\r
-                               unset_config('disable_api', $site->getGUID());\r
-                       else\r
-                               set_config('disable_api', 'disabled', $site->getGUID());\r
-                       \r
-                       // Now ping home\r
-                       //if ((!isset($usage)) || ($usage!='disabled'))\r
-                       //{\r
-                       //      ping_home($site);\r
-                       //}\r
-                               \r
-                       if ($site->save())\r
-                               system_message(elgg_echo("admin:configuration:success"));\r
-                       else\r
-                               register_error(elgg_echo("admin:configuration:fail"));\r
-                       \r
-                       //header("Location: {$CONFIG->wwwroot}admin/site/");\r
-                       forward($_SERVER['HTTP_REFERER']);\r
-                       exit;\r
-                       \r
-               }\r
-               \r
-       }\r
-\r
+                       }
+                       
+                       set_config('language', get_input('language'), $site->getGUID());
+                       
+                       set_config('default_access', get_input('default_access'), $site->getGUID());
+                       
+                       if (get_input('allow_user_default_access')) {
+                               set_config('allow_user_default_access', 1, $site->getGUID());
+                       } else {
+                               set_config('allow_user_default_access', 0, $site->getGUID());
+                       }
+                       
+                       set_config('view', get_input('view'), $site->getGUID());
+                       
+                       $debug = get_input('debug');
+                       if ($debug)
+                               set_config('debug', 1, $site->getGUID());
+                       else
+                               unset_config('debug', $site->getGUID());
+                               
+                       $https_login = get_input('https_login'); 
+                       if ($https_login)
+                               set_config('https_login', 1, $site->getGUID());
+                       else
+                               unset_config('https_login', $site->getGUID());
+                               
+                       $usage = get_input('usage');
+                       if ($usage)
+                               unset_config('ping_home', $site->getGUID());
+                       else
+                               set_config('ping_home', 'disabled', $site->getGUID());
+                               
+                       $api = get_input('api');
+                       if ($api)
+                               unset_config('disable_api', $site->getGUID());
+                       else
+                               set_config('disable_api', 'disabled', $site->getGUID());
+                       
+                       // Now ping home
+                       //if ((!isset($usage)) || ($usage!='disabled'))
+                       //{
+                       //      ping_home($site);
+                       //}
+                               
+                       if ($site->save())
+                               system_message(elgg_echo("admin:configuration:success"));
+                       else
+                               register_error(elgg_echo("admin:configuration:fail"));
+                       
+                       //header("Location: {$CONFIG->wwwroot}admin/site/");
+                       forward($_SERVER['HTTP_REFERER']);
+                       exit;
+                       
+               }
+               
+       }
+
 ?>
\ No newline at end of file
index 831513a29d1314450a440e3e482072687bb23b2d..1033ec00a4a336ffba085e6683d0b30bb2d97e56 100644 (file)
        if ( ($obj instanceof ElggUser) && ($obj->canEdit()))
        {
                // Now actually disable it
-               if ($obj->ban('banned')) {\r
-                       system_message(elgg_echo('admin:user:ban:yes'));\r
+               if ($obj->ban('banned')) {
+                       system_message(elgg_echo('admin:user:ban:yes'));
                }
                else
                        register_error(elgg_echo('admin:user:ban:no'));
-       } else {\r
-               $canedit = $obj->canEdit();\r
-               $isinstance = ($obj instanceof ElggUser);\r
-               register_error(elgg_echo('admin:user:ban:no'));\r
+       } else {
+               $canedit = $obj->canEdit();
+               $isinstance = ($obj instanceof ElggUser);
+               register_error(elgg_echo('admin:user:ban:no'));
        }
                
        forward('pg/admin/user/');
index b026c64f04acd8876bb774bd0958d09903034f35..80478b9ad063d9ce0db2a5a5fe95414a915d2521 100644 (file)
@@ -1,58 +1,58 @@
-<?php\r
-\r
-       /**\r
-        * Elgg add comment action\r
-        * \r
-        * @package Elgg\r
+<?php
 
-        * @author Curverider <curverider.co.uk>\r
+       /**
+        * Elgg add comment action
+        * 
+        * @package Elgg
+
+        * @author Curverider <curverider.co.uk>
+
+        * @link http://elgg.org/
+        */
+
+       // Make sure we're logged in; forward to the front page if not
+               gatekeeper();
+               action_gatekeeper();
+               
+       // Get input
+               $entity_guid = (int) get_input('entity_guid');
+               $comment_text = get_input('generic_comment');
+               
+       // Let's see if we can get an entity with the specified GUID
+               if ($entity = get_entity($entity_guid)) {
+                       
+               // If posting the comment was successful, say so
+                               if ($entity->annotate('generic_comment',$comment_text,$entity->access_id, $_SESSION['guid'])) {
+                                       
+                                       if ($entity->owner_guid != $_SESSION['user']->getGUID())
+                                       notify_user($entity->owner_guid, $_SESSION['user']->getGUID(), elgg_echo('generic_comment:email:subject'), 
+                                               sprintf(
+                                                                       elgg_echo('generic_comment:email:body'),
+                                                                       $entity->title,
+                                                                       $_SESSION['user']->name,
+                                                                       $comment_text,
+                                                                       $entity->getURL(),
+                                                                       $_SESSION['user']->name,
+                                                                       $_SESSION['user']->getURL()
+                                                               )
+                                       ); 
+                                       
+                                       system_message(elgg_echo("generic_comment:posted"));
+                                       //add to river
+                                       add_to_river('annotation/annotate','comment',$_SESSION['user']->guid,$entity->guid);
+
+                                       
+                               } else {
+                                       register_error(elgg_echo("generic_comment:failure"));
+                               }
+                               
+               } else {
+               
+                       register_error(elgg_echo("generic_comment:notfound"));
+                       
+               }
+               
+       // Forward to the 
+               forward($entity->getURL());
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Make sure we're logged in; forward to the front page if not\r
-               gatekeeper();\r
-               action_gatekeeper();\r
-               \r
-       // Get input\r
-               $entity_guid = (int) get_input('entity_guid');\r
-               $comment_text = get_input('generic_comment');\r
-               \r
-       // Let's see if we can get an entity with the specified GUID\r
-               if ($entity = get_entity($entity_guid)) {\r
-                       \r
-               // If posting the comment was successful, say so\r
-                               if ($entity->annotate('generic_comment',$comment_text,$entity->access_id, $_SESSION['guid'])) {\r
-                                       \r
-                                       if ($entity->owner_guid != $_SESSION['user']->getGUID())\r
-                                       notify_user($entity->owner_guid, $_SESSION['user']->getGUID(), elgg_echo('generic_comment:email:subject'), \r
-                                               sprintf(\r
-                                                                       elgg_echo('generic_comment:email:body'),\r
-                                                                       $entity->title,\r
-                                                                       $_SESSION['user']->name,\r
-                                                                       $comment_text,\r
-                                                                       $entity->getURL(),\r
-                                                                       $_SESSION['user']->name,\r
-                                                                       $_SESSION['user']->getURL()\r
-                                                               )\r
-                                       ); \r
-                                       \r
-                                       system_message(elgg_echo("generic_comment:posted"));\r
-                                       //add to river\r
-                                       add_to_river('annotation/annotate','comment',$_SESSION['user']->guid,$entity->guid);\r
-\r
-                                       \r
-                               } else {\r
-                                       register_error(elgg_echo("generic_comment:failure"));\r
-                               }\r
-                               \r
-               } else {\r
-               \r
-                       register_error(elgg_echo("generic_comment:notfound"));\r
-                       \r
-               }\r
-               \r
-       // Forward to the \r
-               forward($entity->getURL());\r
-\r
 ?>
\ No newline at end of file
index 2d3b9b3fdb4ba33840bbbf7107a7ee4707dab069..dc701973b4d42854939e10c9856dfe2fa6176e90 100644 (file)
@@ -1,35 +1,35 @@
-<?php\r
-\r
-       /**\r
-        * Elgg delete comment action\r
-        * \r
-        * @package Elgg\r
+<?php
 
-        * @author Curverider <curverider.co.uk>\r
+       /**
+        * Elgg delete comment action
+        * 
+        * @package Elgg
+
+        * @author Curverider <curverider.co.uk>
+
+        * @link http://elgg.org/
+        */
+
+       // Ensure we're logged in
+               if (!isloggedin()) forward();
+               
+       // Make sure we can get the comment in question
+               $annotation_id = (int) get_input('annotation_id');
+               if ($comment = get_annotation($annotation_id)) {
+               
+               $entity = get_entity($comment->entity_guid);
+                       
+                       if ($comment->canEdit()) {
+                               $comment->delete();
+                               system_message(elgg_echo("generic_comment:deleted"));
+                               forward($entity->getURL());
+                       }
+                       
+               } else {
+                       $url = "";
+               }
+               
+               register_error(elgg_echo("generic_comment:notdeleted"));
+               forward($entity->getURL());
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Ensure we're logged in\r
-               if (!isloggedin()) forward();\r
-               \r
-       // Make sure we can get the comment in question\r
-               $annotation_id = (int) get_input('annotation_id');\r
-               if ($comment = get_annotation($annotation_id)) {\r
-               \r
-               $entity = get_entity($comment->entity_guid);\r
-                       \r
-                       if ($comment->canEdit()) {\r
-                               $comment->delete();\r
-                               system_message(elgg_echo("generic_comment:deleted"));\r
-                               forward($entity->getURL());\r
-                       }\r
-                       \r
-               } else {\r
-                       $url = "";\r
-               }\r
-               \r
-               register_error(elgg_echo("generic_comment:notdeleted"));\r
-               forward($entity->getURL());\r
-\r
 ?>
\ No newline at end of file
index 6c166242b456cfed2de5bfc7e3c323c9f8fd7e1c..2d226552a8482f3fc98151e66883537836ca277e 100644 (file)
@@ -29,7 +29,7 @@
        
                        if (!get_user_by_email($email))
                        {
-                       \r
+                       
                                if ($user->email != $email) {
                                        $user->email = $email;
                                        if ($user->save())
@@ -38,7 +38,7 @@
                                                system_message(elgg_echo('email:save:success'));
                                        }
                                        else
-                                               register_error(elgg_echo('email:save:fail'));\r
+                                               register_error(elgg_echo('email:save:fail'));
                                }
                        }
                        else
index 004b0eaad2dc9c83eefe32a719d8f8f5cd75416a..63f1e2d94a94e5831ee18557792d055af107275c 100644 (file)
@@ -1,40 +1,40 @@
-<?php\r
-\r
-       /**\r
-        * Elgg add friend action\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg add friend action
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Ensure we are logged in\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Ensure we are logged in
                gatekeeper();
-               action_gatekeeper();\r
-               \r
-       // Get the GUID of the user to friend\r
-               $friend_guid = get_input('friend');\r
-               $friend = get_entity($friend_guid);\r
-\r
-               $errors = false;\r
-               \r
-       // Get the user\r
-               try {\r
-                       if (!$_SESSION['user']->addFriend($friend_guid)) $errors = true;\r
-               } catch (Exception $e) {\r
-                       register_error(sprintf(elgg_echo("friends:add:failure"),$friend->name));\r
-                       $errors = true;\r
-               }\r
-               if (!$errors){\r
-                       // add to river\r
-               add_to_river('friends/river/create','friend',$_SESSION['user']->guid,$friend_guid);\r
-                       system_message(sprintf(elgg_echo("friends:add:successful"),$friend->name));\r
-               }\r
-               \r
-       // Forward to the user friends page\r
-               forward("pg/friends/" . $_SESSION['user']->username . "/");\r
-               \r
+               action_gatekeeper();
+               
+       // Get the GUID of the user to friend
+               $friend_guid = get_input('friend');
+               $friend = get_entity($friend_guid);
+
+               $errors = false;
+               
+       // Get the user
+               try {
+                       if (!$_SESSION['user']->addFriend($friend_guid)) $errors = true;
+               } catch (Exception $e) {
+                       register_error(sprintf(elgg_echo("friends:add:failure"),$friend->name));
+                       $errors = true;
+               }
+               if (!$errors){
+                       // add to river
+               add_to_river('friends/river/create','friend',$_SESSION['user']->guid,$friend_guid);
+                       system_message(sprintf(elgg_echo("friends:add:successful"),$friend->name));
+               }
+               
+       // Forward to the user friends page
+               forward("pg/friends/" . $_SESSION['user']->username . "/");
+               
 ?>
\ No newline at end of file
index bda98984b536b9e8ddf606245c2c04d1b4d331c1..7dfba1ee7aae1bbf9c52098b046dfe536a861838 100644 (file)
@@ -1,50 +1,50 @@
-<?php\r
-\r
-       /**\r
-        * Elgg collection add page\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg collection add page
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-        \r
-        //must be logged in\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+        
+        //must be logged in
         gatekeeper();
-        action_gatekeeper();\r
-        \r
-        $collection_name = get_input('collection_name');\r
-        $friends = get_input('friends_collection');\r
-        \r
-    //first check to make sure that a collection name has been set and create the new colection\r
-    if($collection_name){\r
-        \r
-        //create the collection\r
-        $create_collection = create_access_collection($collection_name, $_SESSION['user']->getGUID());\r
-        \r
-        //if the collection was created and the user passed some friends from the form, add them\r
-        if($create_collection && (!empty($friends))){\r
-            \r
-            //add friends to the collection\r
-            foreach($friends as $friend){\r
-                add_user_to_access_collection($friend, $create_collection);\r
-               }\r
-               \r
-        }\r
-        \r
-        // Success message\r
-               system_message(elgg_echo("friends:collectionadded"));\r
-               // Forward to the collections page\r
-               forward("pg/collections/" . $_SESSION['user']->username);\r
-        \r
-    } else {\r
-        \r
-        register_error(elgg_echo("friends:nocollectionname"));\r
-        // Forward to the add collection page\r
-               forward("pg/collections/add");\r
-               \r
-    }\r
-        \r
+        action_gatekeeper();
+        
+        $collection_name = get_input('collection_name');
+        $friends = get_input('friends_collection');
+        
+    //first check to make sure that a collection name has been set and create the new colection
+    if($collection_name){
+        
+        //create the collection
+        $create_collection = create_access_collection($collection_name, $_SESSION['user']->getGUID());
+        
+        //if the collection was created and the user passed some friends from the form, add them
+        if($create_collection && (!empty($friends))){
+            
+            //add friends to the collection
+            foreach($friends as $friend){
+                add_user_to_access_collection($friend, $create_collection);
+               }
+               
+        }
+        
+        // Success message
+               system_message(elgg_echo("friends:collectionadded"));
+               // Forward to the collections page
+               forward("pg/collections/" . $_SESSION['user']->username);
+        
+    } else {
+        
+        register_error(elgg_echo("friends:nocollectionname"));
+        // Forward to the add collection page
+               forward("pg/collections/add");
+               
+    }
+        
 ?>
\ No newline at end of file
index 674e6875112c434bdf87ad9b9bc4e88a80fbc848..bdfcc9b2cd6a73646a6af0ecff3db6061df037e5 100644 (file)
@@ -1,52 +1,52 @@
-<?php\r
-\r
-       /**\r
-        * Elgg friends: delete collection action\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg friends: delete collection action
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Make sure we're logged in (send us to the front page if not)\r
-               gatekeeper();\r
-               \r
-               // Get input data\r
-               $collection_id = (int) get_input('collection');\r
-               \r
-               // Check to see that the access collection exist and grab its owner\r
-               $get_collection = get_access_collection($collection_id);\r
-               \r
-               if($get_collection){\r
-               \r
-               if($get_collection->owner_guid == $_SESSION['user']->getGUID()){\r
-                   \r
-                   $delete_collection = delete_access_collection($collection_id);\r
-               \r
-                   // Success message\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Make sure we're logged in (send us to the front page if not)
+               gatekeeper();
+               
+               // Get input data
+               $collection_id = (int) get_input('collection');
+               
+               // Check to see that the access collection exist and grab its owner
+               $get_collection = get_access_collection($collection_id);
+               
+               if($get_collection){
+               
+               if($get_collection->owner_guid == $_SESSION['user']->getGUID()){
+                   
+                   $delete_collection = delete_access_collection($collection_id);
+               
+                   // Success message
                        if ($delete_collection) 
                                system_message(elgg_echo("friends:collectiondeleted"));
                        else
-                               register_error(elgg_echo("friends:collectiondeletefailed"));\r
-                       \r
-               } else {\r
-               \r
-               // Failure message\r
-                       register_error(elgg_echo("friends:collectiondeletefailed"));\r
-                       \r
-               }\r
-               \r
-               } else {\r
-               \r
-               // Failure message\r
-                   register_error(elgg_echo("friends:collectiondeletefailed"));\r
-                   \r
-           }\r
-           \r
-            // Forward to the collections page\r
-                forward("pg/collections/" . $_SESSION['user']->username);\r
-               \r
+                               register_error(elgg_echo("friends:collectiondeletefailed"));
+                       
+               } else {
+               
+               // Failure message
+                       register_error(elgg_echo("friends:collectiondeletefailed"));
+                       
+               }
+               
+               } else {
+               
+               // Failure message
+                   register_error(elgg_echo("friends:collectiondeletefailed"));
+                   
+           }
+           
+            // Forward to the collections page
+                forward("pg/collections/" . $_SESSION['user']->username);
+               
 ?>
\ No newline at end of file
index a1a38845f3f24d6583c396162f32319016860ddb..ede61b4b0e4a6831af887fffcfbf296003264f82 100644 (file)
@@ -1,20 +1,20 @@
-<?php\r
-\r
-       /**\r
-        * Elgg collection add page\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg collection add page
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-        \r
-        $collection_id = get_input('collection_id');\r
-        $friends = get_input('friend');\r
-        \r
-        //chech the collection exists and the current user owners it\r
-        update_access_collection($collection_id, $friends);\r
-        \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+        
+        $collection_id = get_input('collection_id');
+        $friends = get_input('friend');
+        
+        //chech the collection exists and the current user owners it
+        update_access_collection($collection_id, $friends);
+        
 ?>
\ No newline at end of file
index d1911bb904360260c4ab54bd9c32fccdae7e30c7..20181bc84c58fe9add63774ed26bbcfa9d412639 100644 (file)
@@ -1,42 +1,42 @@
-<?php\r
-\r
-       /**\r
-        * Elgg remove friend action\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg remove friend action
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Ensure we are logged in\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Ensure we are logged in
                gatekeeper();
-               action_gatekeeper();\r
-               \r
-       // Get the GUID of the user to friend\r
-               $friend_guid = get_input('friend');\r
-               $friend = get_entity($friend_guid);\r
-               $errors = false;\r
-\r
-       // Get the user\r
+               action_gatekeeper();
+               
+       // Get the GUID of the user to friend
+               $friend_guid = get_input('friend');
+               $friend = get_entity($friend_guid);
+               $errors = false;
+
+       // Get the user
                try{
-                       if ($friend instanceof ElggUser)\r
+                       if ($friend instanceof ElggUser)
                                $_SESSION['user']->removeFriend($friend_guid);
                        else
                        {
                                register_error(sprintf(elgg_echo("friends:remove:failure"),$friend->name));
                                $errors = true;
-                       }\r
-               } catch (Exception $e) {\r
-                       register_error(sprintf(elgg_echo("friends:remove:failure"),$friend->name));\r
-                       $errors = true;\r
-               }\r
-               if (!$errors)\r
-                       system_message(sprintf(elgg_echo("friends:remove:successful"),$friend->name));                  \r
-               \r
-       // Forward to the user friends page\r
-               forward("pg/friends/" . $_SESSION['user']->username . "/");\r
-               \r
+                       }
+               } catch (Exception $e) {
+                       register_error(sprintf(elgg_echo("friends:remove:failure"),$friend->name));
+                       $errors = true;
+               }
+               if (!$errors)
+                       system_message(sprintf(elgg_echo("friends:remove:successful"),$friend->name));                  
+               
+       // Forward to the user friends page
+               forward("pg/friends/" . $_SESSION['user']->username . "/");
+               
 ?>
\ No newline at end of file
index 1d2b7bc076ab8219d61911ae05cd9dc46c50632c..f3a60af6df9f42fc13f73348d4970ee3f2734f9e 100644 (file)
@@ -1,37 +1,37 @@
-<?php\r
-\r
-    /**\r
-        * Elgg login action\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+    /**
+        * Elgg login action
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
         
        // Safety first
                action_gatekeeper();
-\r
-    // Get username and password\r
-    \r
-        $username = get_input('username');\r
-        $password = get_input("password");\r
-        $persistent = get_input("persistent", false);\r
-        \r
-    // If all is present and correct, try to log in  \r
-       $result = false;          \r
-        if (!empty($username) && !empty($password)) {\r
-               if ($user = authenticate($username,$password)) {\r
-                       $result = login($user, $persistent);\r
-               }\r
-        }\r
-        \r
-    // Set the system_message as appropriate\r
-        \r
-        if ($result) {\r
-            system_message(elgg_echo('loginok'));\r
+
+    // Get username and password
+    
+        $username = get_input('username');
+        $password = get_input("password");
+        $persistent = get_input("persistent", false);
+        
+    // If all is present and correct, try to log in  
+       $result = false;          
+        if (!empty($username) && !empty($password)) {
+               if ($user = authenticate($username,$password)) {
+                       $result = login($user, $persistent);
+               }
+        }
+        
+    // Set the system_message as appropriate
+        
+        if ($result) {
+            system_message(elgg_echo('loginok'));
             if ($_SESSION['last_forward_from'])
             {
                $forward_url = $_SESSION['last_forward_from'];
                        forward($_SERVER['HTTP_REFERER']);
                } else
                        forward("pg/dashboard/");
-            }\r
-        } else {\r
-               $error_msg = elgg_echo('loginerror');\r
-               // figure out why the login failed\r
-               if (!empty($username) && !empty($password)) {\r
-                       // See if it exists and is disabled\r
-                               $access_status = access_get_show_hidden_status();\r
-                               access_show_hidden_entities(true);\r
-                       if (($user = get_user_by_username($username)) && !$user->validated) {\r
-                               // give plugins a chance to respond\r
-                               if (!trigger_plugin_hook('unvalidated_login_attempt','user',array('entity'=>$user))) {\r
-                                       // if plugins have not registered an action, the default action is to\r
-                                       // trigger the validation event again and assume that the validation\r
-                                       // event will display an appropriate message\r
-                                               trigger_elgg_event('validate', 'user', $user);\r
-                               }\r
-                       } else {\r
-                                register_error(elgg_echo('loginerror'));\r
-                       }\r
-                       access_show_hidden_entities($access_status);\r
-               } else {\r
-               register_error(elgg_echo('loginerror'));\r
-               }\r
-        }\r
-      \r
+            }
+        } else {
+               $error_msg = elgg_echo('loginerror');
+               // figure out why the login failed
+               if (!empty($username) && !empty($password)) {
+                       // See if it exists and is disabled
+                               $access_status = access_get_show_hidden_status();
+                               access_show_hidden_entities(true);
+                       if (($user = get_user_by_username($username)) && !$user->validated) {
+                               // give plugins a chance to respond
+                               if (!trigger_plugin_hook('unvalidated_login_attempt','user',array('entity'=>$user))) {
+                                       // if plugins have not registered an action, the default action is to
+                                       // trigger the validation event again and assume that the validation
+                                       // event will display an appropriate message
+                                               trigger_elgg_event('validate', 'user', $user);
+                               }
+                       } else {
+                                register_error(elgg_echo('loginerror'));
+                       }
+                       access_show_hidden_entities($access_status);
+               } else {
+               register_error(elgg_echo('loginerror'));
+               }
+        }
+      
 ?>
\ No newline at end of file
index 078e5a7aa10401eeae60360c028d5774981f6bec..67ca6ad655d6f6b7c832363b9463a734fb6898f1 100644 (file)
@@ -1,25 +1,25 @@
-<?php\r
-\r
-    /**\r
-        * Elgg logout action\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+    /**
+        * Elgg logout action
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+           
+    // Log out
+        $result = logout();
+            
+    // Set the system_message as appropriate
+        
+        if ($result) {
+            system_message(elgg_echo('logoutok'));
+        } else {
+            register_error(elgg_echo('logouterror'));
+        }
 
-        * @link http://elgg.org/\r
-        */\r
-           \r
-    // Log out\r
-        $result = logout();\r
-            \r
-    // Set the system_message as appropriate\r
-        \r
-        if ($result) {\r
-            system_message(elgg_echo('logoutok'));\r
-        } else {\r
-            register_error(elgg_echo('logouterror'));\r
-        }\r
-\r
 ?>
\ No newline at end of file
index 75721822cf212775b94b6056dbe5edc75ed1213e..5c69624b3c560eff36a1381ccae04a598206c649 100644 (file)
@@ -1,39 +1,39 @@
-<?php\r
-\r
-       /**\r
-        * Elgg registration action\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg registration action
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
 
        require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
        global $CONFIG;
        
        action_gatekeeper();
-\r
-       // Get variables\r
-               $username = get_input('username');\r
-               $password = get_input('password');\r
-               $password2 = get_input('password2');\r
-               $email = get_input('email');\r
-               $name = get_input('name');\r
-               $friend_guid = (int) get_input('friend_guid',0);\r
-               $invitecode = get_input('invitecode');\r
+
+       // Get variables
+               $username = get_input('username');
+               $password = get_input('password');
+               $password2 = get_input('password2');
+               $email = get_input('email');
+               $name = get_input('name');
+               $friend_guid = (int) get_input('friend_guid',0);
+               $invitecode = get_input('invitecode');
                
                $admin = get_input('admin');
                if (is_array($admin)) $admin = $admin[0];
                
                
                if (!$CONFIG->disable_registration)
-               {\r
+               {
        // For now, just try and register the user
        
-                       try {\r
+                       try {
                                if (
                                        (
                                                (trim($password)!="") &&
                                                $new_user->admin = 'yes';
                                        }
                                        
-                                       // Send user validation request on register only\r
-                                       global $registering_admin;\r
+                                       // Send user validation request on register only
+                                       global $registering_admin;
                                        if (!$registering_admin)
                                                request_user_validation($guid);
                                        
                                        if (!$new_user->admin)
-                                               $new_user->disable('new_user', false);  // Now disable if not an admin\r
-                                               // Don't do a recursive disable.  Any entities owned by the user at this point\r
+                                               $new_user->disable('new_user', false);  // Now disable if not an admin
+                                               // Don't do a recursive disable.  Any entities owned by the user at this point
                                                // are products of plugins that
-                                       \r
+                                       
                                        system_message(sprintf(elgg_echo("registerok"),$CONFIG->sitename));
                                        
-                                       forward(); // Forward on success, assume everything else is an error...\r
-                               } else {\r
-                                       register_error(elgg_echo("registerbad"));\r
+                                       forward(); // Forward on success, assume everything else is an error...
+                               } else {
+                                       register_error(elgg_echo("registerbad"));
                                }
                        } catch (RegistrationException $r) {
                                register_error($r->getMessage());
@@ -76,6 +76,6 @@
                $qs = $qs[0];
                $qs .= "?u=" . urlencode($username) . "&e=" . urlencode($email) . "&n=" . urlencode($name) . "&friend_guid=" . $friend_guid;
                
-               forward($qs);\r
-\r
+               forward($qs);
+
 ?>
\ No newline at end of file
index 1d9f63a9fbc5d74ea86ce538779c1d29bf25db67..8b0a31cedf2dba43108676d96bca6e71c25d732d 100644 (file)
-<?php\r
-\r
-       /**\r
-        * Elgg install site action\r
-        * \r
-        * Creates a nwe site and sets it as the default\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg install site action
+        * 
+        * Creates a nwe site and sets it as the default
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       elgg_set_viewtype('failsafe'); // Set failsafe again incase we get an exception thrown\r
-       \r
-       if (is_installed()) forward();\r
-\r
-       if (get_input('settings') == 'go') {\r
-               \r
-               if (!datalist_get('default_site')) {\r
-                       \r
-                       // Sanitise\r
-                       $path = sanitise_filepath(get_input('path'));\r
-                       $dataroot = sanitise_filepath(get_input('dataroot'));\r
-                       \r
-                       // Blank?\r
-                       if ($dataroot == "/")\r
-                               throw new InstallationException(elgg_echo('InstallationException:DatarootBlank'));\r
-                               \r
-                       // That it's valid\r
-                       if (stripos($dataroot, $path)!==false)\r
-                               throw new InstallationException(sprintf(elgg_echo('InstallationException:DatarootUnderPath'), $dataroot));\r
-                       \r
-                       // Check data root is writable\r
-                       if (!is_writable($dataroot))\r
-                               throw new InstallationException(sprintf(elgg_echo('InstallationException:DatarootNotWritable'), $dataroot));\r
-                       \r
-                       \r
-                       $site = new ElggSite();\r
-                       $site->name = get_input('sitename');\r
-                       $site->url = get_input('wwwroot');\r
-                       $site->description = get_input('sitedescription');\r
-                       $site->email = get_input('siteemail');\r
-                       $site->access_id = ACCESS_PUBLIC;\r
-                       $guid = $site->save();\r
-                       \r
-                       if (!$guid)\r
-                               throw new InstallationException(sprintf(elgg_echo('InstallationException:CantCreateSite'), get_input('sitename'), get_input('wwwroot')));\r
-                       \r
-                       datalist_set('installed',time());\r
-                       \r
-                       datalist_set('path', $path);\r
-                       datalist_set('dataroot', $dataroot);\r
-                       \r
-                       datalist_set('default_site',$site->getGUID());\r
-                       \r
-                       set_config('view', get_input('view'), $site->getGUID());\r
-                       set_config('language', get_input('language'), $site->getGUID());\r
-                       set_config('default_access', get_input('default_access'), $site->getGUID());\r
-                       \r
-                       $debug = get_input('debug');\r
-                       if ($debug)\r
-                               set_config('debug', 1, $site->getGUID());\r
-                       else\r
-                               unset_config('debug', $site->getGUID());\r
-                               \r
-                       $usage = get_input('usage');\r
-                       if (is_array($usage)) $usage = $usage[0];\r
-                       \r
-                       if ($usage)\r
-                               unset_config('ping_home', $site->getGUID());\r
-                       else\r
-                               set_config('ping_home', 'disabled', $site->getGUID());\r
-                               \r
-                       $api = get_input('api');\r
-                       if ($api)\r
-                               unset_config('disable_api', $site->getGUID());\r
-                       else\r
-                               set_config('disable_api', 'disabled', $site->getGUID());\r
-                               \r
-                       $https_login = get_input('https_login'); \r
-                       if ($https_login)\r
-                               set_config('https_login', 1, $site->getGUID());\r
-                       else\r
-                               unset_config('https_login', $site->getGUID());\r
-                       \r
-                       // activate some plugins by default\r
-                       if (isset($CONFIG->default_plugins))\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       elgg_set_viewtype('failsafe'); // Set failsafe again incase we get an exception thrown
+       
+       if (is_installed()) forward();
+
+       if (get_input('settings') == 'go') {
+               
+               if (!datalist_get('default_site')) {
+                       
+                       // Sanitise
+                       $path = sanitise_filepath(get_input('path'));
+                       $dataroot = sanitise_filepath(get_input('dataroot'));
+                       
+                       // Blank?
+                       if ($dataroot == "/")
+                               throw new InstallationException(elgg_echo('InstallationException:DatarootBlank'));
+                               
+                       // That it's valid
+                       if (stripos($dataroot, $path)!==false)
+                               throw new InstallationException(sprintf(elgg_echo('InstallationException:DatarootUnderPath'), $dataroot));
+                       
+                       // Check data root is writable
+                       if (!is_writable($dataroot))
+                               throw new InstallationException(sprintf(elgg_echo('InstallationException:DatarootNotWritable'), $dataroot));
+                       
+                       
+                       $site = new ElggSite();
+                       $site->name = get_input('sitename');
+                       $site->url = get_input('wwwroot');
+                       $site->description = get_input('sitedescription');
+                       $site->email = get_input('siteemail');
+                       $site->access_id = ACCESS_PUBLIC;
+                       $guid = $site->save();
+                       
+                       if (!$guid)
+                               throw new InstallationException(sprintf(elgg_echo('InstallationException:CantCreateSite'), get_input('sitename'), get_input('wwwroot')));
+                       
+                       datalist_set('installed',time());
+                       
+                       datalist_set('path', $path);
+                       datalist_set('dataroot', $dataroot);
+                       
+                       datalist_set('default_site',$site->getGUID());
+                       
+                       set_config('view', get_input('view'), $site->getGUID());
+                       set_config('language', get_input('language'), $site->getGUID());
+                       set_config('default_access', get_input('default_access'), $site->getGUID());
+                       
+                       $debug = get_input('debug');
+                       if ($debug)
+                               set_config('debug', 1, $site->getGUID());
+                       else
+                               unset_config('debug', $site->getGUID());
+                               
+                       $usage = get_input('usage');
+                       if (is_array($usage)) $usage = $usage[0];
+                       
+                       if ($usage)
+                               unset_config('ping_home', $site->getGUID());
+                       else
+                               set_config('ping_home', 'disabled', $site->getGUID());
+                               
+                       $api = get_input('api');
+                       if ($api)
+                               unset_config('disable_api', $site->getGUID());
+                       else
+                               set_config('disable_api', 'disabled', $site->getGUID());
+                               
+                       $https_login = get_input('https_login'); 
+                       if ($https_login)
+                               set_config('https_login', 1, $site->getGUID());
+                       else
+                               unset_config('https_login', $site->getGUID());
+                       
+                       // activate some plugins by default
+                       if (isset($CONFIG->default_plugins))
                        {
-                               if (!is_array($CONFIG->default_plugins))\r
+                               if (!is_array($CONFIG->default_plugins))
                                        $plugins = explode(',', $CONFIG->default_plugins);
                                else
                                        $CONFIG->default_plugins = $CONFIG->default_plugins;
-                                       \r
-                               foreach ($plugins as $plugin)\r
-                                       enable_plugin(trim($plugin), $site->getGUID());\r
-                       }\r
-                       else\r
-                       {\r
-                               enable_plugin('profile', $site->getGUID());\r
-                               enable_plugin('river', $site->getGUID());\r
-                               enable_plugin('logbrowser', $site->getGUID());\r
-                               enable_plugin('diagnostics', $site->getGUID());\r
+                                       
+                               foreach ($plugins as $plugin)
+                                       enable_plugin(trim($plugin), $site->getGUID());
+                       }
+                       else
+                       {
+                               enable_plugin('profile', $site->getGUID());
+                               enable_plugin('river', $site->getGUID());
+                               enable_plugin('logbrowser', $site->getGUID());
+                               enable_plugin('diagnostics', $site->getGUID());
                                enable_plugin('uservalidationbyemail', $site->getGUID());
-                               enable_plugin('htmlawed', $site->getGUID());\r
-                       }\r
-                               \r
-                       // Now ping home\r
-                       if ($usage)\r
-                       {\r
-                               ping_home($site);\r
-                       }\r
-                               \r
-                       system_message(elgg_echo("installation:configuration:success"));\r
-                       \r
-                       header("Location: ../../account/register.php");\r
-                       exit;\r
-                       \r
-               }\r
-               \r
-       }\r
-\r
+                               enable_plugin('htmlawed', $site->getGUID());
+                       }
+                               
+                       // Now ping home
+                       if ($usage)
+                       {
+                               ping_home($site);
+                       }
+                               
+                       system_message(elgg_echo("installation:configuration:success"));
+                       
+                       header("Location: ../../account/register.php");
+                       exit;
+                       
+               }
+               
+       }
+
 ?>
\ No newline at end of file
index 0f062ed1965640db3ef20550aa64f856e5df7e4c..b79200ad0ed5dca806fb571da072cdb5280f1e25 100644 (file)
@@ -9,8 +9,8 @@
         */
 
        require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-       global $CONFIG;\r
-       \r
+       global $CONFIG;
+       
        if ($CONFIG->allow_user_default_access) {
 
                gatekeeper();
@@ -25,7 +25,7 @@
                        $user = get_entity($user_id);
                        
                if ($user)
-               {\r
+               {
                        $current_default_access = $user->getPrivateSetting('elgg_default_access');
                        if ($default_access != $current_default_access)
                        {
@@ -36,7 +36,7 @@
                        }
                }
                else
-                       register_error(elgg_echo('user:default_access:fail'));\r
+                       register_error(elgg_echo('user:default_access:fail'));
        }
        
        //forward($_SERVER['HTTP_REFERER']);
index 2dff5f34de693457348092169cb73a66d1827cae..a54e71b7e47c0a0b1b89d74fee8104d6b471f30d 100644 (file)
        action_gatekeeper();
        
        $username = get_input('username');
-       \r
-       $access_status = access_get_show_hidden_status();\r
+       
+       $access_status = access_get_show_hidden_status();
        access_show_hidden_entities(true);
        $user = get_user_by_username($username);
        if ($user)
-       {\r
+       {
                if ($user->validated) {
                        if (send_new_password_request($user->guid))
                                system_message(elgg_echo('user:password:resetreq:success'));
                        else
-                               register_error(elgg_echo('user:password:resetreq:fail'));\r
-               } else if (!trigger_plugin_hook('unvalidated_requestnewpassword','user',array('entity'=>$user))) {\r
-               // if plugins have not registered an action, the default action is to\r
-               // trigger the validation event again and assume that the validation\r
-               // event will display an appropriate message\r
-                       trigger_elgg_event('validate', 'user', $user);\r
+                               register_error(elgg_echo('user:password:resetreq:fail'));
+               } else if (!trigger_plugin_hook('unvalidated_requestnewpassword','user',array('entity'=>$user))) {
+               // if plugins have not registered an action, the default action is to
+               // trigger the validation event again and assume that the validation
+               // event will display an appropriate message
+                       trigger_elgg_event('validate', 'user', $user);
         }
        }
        else
-               register_error(sprintf(elgg_echo('user:username:notfound'), $username));\r
+               register_error(sprintf(elgg_echo('user:username:notfound'), $username));
                
        access_show_hidden_entities($access_status);
        forward();
index b43af2f167bb2cfd3787cced9796fda9dac45eb5..8f50df2c82c08911fb36e1ceef52aeb0c5e41a89 100644 (file)
@@ -1,15 +1,15 @@
-<?php\r
-\r
-               gatekeeper();\r
-               \r
-               $closed = get_input('closed','true');\r
-               if ($closed != 'true') {\r
-                       $closed = false;\r
-               } else {\r
-                       $closed = true;\r
-               }\r
-               \r
-               $_SESSION['user']->spotlightclosed = $closed;\r
-               exit;\r
-\r
+<?php
+
+               gatekeeper();
+               
+               $closed = get_input('closed','true');
+               if ($closed != 'true') {
+                       $closed = false;
+               } else {
+                       $closed = true;
+               }
+               
+               $_SESSION['user']->spotlightclosed = $closed;
+               exit;
+
 ?>
\ No newline at end of file
index cf4f03ffed3d69c088768695006244b477a1960f..0149a9753c070556f6d3eed10d4e283f89882099 100644 (file)
@@ -14,7 +14,7 @@
        admin_gatekeeper(); // Only admins can add a user
        action_gatekeeper();
        
-       // Get variables\r
+       // Get variables
        global $CONFIG;
        $username = get_input('username');
        $password = get_input('password');
@@ -40,9 +40,9 @@
                        
                        $new_user->admin_created = true;
                        $new_user->created_by_guid = get_loggedin_userid();
-                       \r
-                       \r
-                       notify_user($new_user->guid, $CONFIG->site->guid, elgg_echo('useradd:subject'), sprintf(elgg_echo('useradd:body'), $name, $CONFIG->site->name, $CONFIG->site->url, $username, $password));\r
+                       
+                       
+                       notify_user($new_user->guid, $CONFIG->site->guid, elgg_echo('useradd:subject'), sprintf(elgg_echo('useradd:body'), $name, $CONFIG->site->name, $CONFIG->site->url, $username, $password));
                        
                        system_message(sprintf(elgg_echo("adduser:ok"),$CONFIG->sitename));
                } else {
index b720c371ac02d6b12a4080e8ec06a0eae6bd6444..8c920def15c4e4c0fad4a000832b2e0f6366271c 100644 (file)
@@ -1,22 +1,22 @@
-<?php\r
-       /**\r
-        * Aggregate action for saving settings\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Aggregate action for saving settings
+        * 
+        * @package Elgg
+        * @subpackage Core
 
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");\r
-       global $CONFIG;\r
-\r
+        * @link http://elgg.org/
+        */
+
+       require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+       global $CONFIG;
+
        gatekeeper();
-       action_gatekeeper();\r
-       \r
-       trigger_plugin_hook('usersettings:save','user');\r
-       \r
-       forward($_SERVER['HTTP_REFERER']);\r
-       \r
-?>\r
+       action_gatekeeper();
+       
+       trigger_plugin_hook('usersettings:save','user');
+       
+       forward($_SERVER['HTTP_REFERER']);
+       
+?>
index 76aaa3b175f3c596f719d552f42df70b46978694..14653eb18913fca8ade25ea66d9ce01122fdd83a 100644 (file)
@@ -1,43 +1,43 @@
-<?php\r
-\r
-       /**\r
-        * Elgg widget add action\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg widget add action
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+               $guid = get_input('user');
+               $handler = get_input('handler');
+               $context = get_input('context');
+               $column = get_input('column');
+               
+               $result = false;
+               
+               if (!empty($guid)) {
+                       
+                       if ($user = get_entity($guid)) {
+                               
+                               if ($user->canEdit()) {
+                                       
+                                       $result = add_widget($user->getGUID(),$handler,$context,0,$column);
+                                       
+                               }
+                               
+                       }
+                       
+               }
+               
+               if ($result) {
+                       system_message(elgg_echo('widgets:save:success'));
+               } else {
+                       register_error(elgg_echo('widgets:save:failure'));
+               }
+               
+               forward($_SERVER['HTTP_REFERER']);
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-               $guid = get_input('user');\r
-               $handler = get_input('handler');\r
-               $context = get_input('context');\r
-               $column = get_input('column');\r
-               \r
-               $result = false;\r
-               \r
-               if (!empty($guid)) {\r
-                       \r
-                       if ($user = get_entity($guid)) {\r
-                               \r
-                               if ($user->canEdit()) {\r
-                                       \r
-                                       $result = add_widget($user->getGUID(),$handler,$context,0,$column);\r
-                                       \r
-                               }\r
-                               \r
-                       }\r
-                       \r
-               }\r
-               \r
-               if ($result) {\r
-                       system_message(elgg_echo('widgets:save:success'));\r
-               } else {\r
-                       register_error(elgg_echo('widgets:save:failure'));\r
-               }\r
-               \r
-               forward($_SERVER['HTTP_REFERER']);\r
-\r
 ?>
\ No newline at end of file
index 6f3142e8d05e9c2f16cd8bff59c8a70bca3faf29..3e3a98ebb99ae1305a6760670b5c68a3968e707d 100644 (file)
@@ -1,32 +1,32 @@
-<?php\r
-\r
-       /**\r
-        * Elgg widget reorder action\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg widget reorder action
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+
+               $owner = get_input('owner');
+               $context = get_input('context');
+               
+               $maincontent = get_input('debugField1');
+               $sidebar = get_input('debugField2');
+               $rightbar = get_input('debugField3');
+               
+               $result = reorder_widgets_from_panel($maincontent, $sidebar, $rightbar, $context, $owner);
+               
+               if ($result) {
+                       system_message(elgg_echo('widgets:panel:save:success'));
+               } else {
+                       register_error(elgg_echo('widgets:panel:save:failure'));
+               }
+               
+               forward($_SERVER['HTTP_REFERER']);
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-\r
-               $owner = get_input('owner');\r
-               $context = get_input('context');\r
-               \r
-               $maincontent = get_input('debugField1');\r
-               $sidebar = get_input('debugField2');\r
-               $rightbar = get_input('debugField3');\r
-               \r
-               $result = reorder_widgets_from_panel($maincontent, $sidebar, $rightbar, $context, $owner);\r
-               \r
-               if ($result) {\r
-                       system_message(elgg_echo('widgets:panel:save:success'));\r
-               } else {\r
-                       register_error(elgg_echo('widgets:panel:save:failure'));\r
-               }\r
-               \r
-               forward($_SERVER['HTTP_REFERER']);\r
-\r
 ?>
\ No newline at end of file
index c6e06a12f52d86a966338526f64d69f0abb57b06..6fdf79c114def3037cdd2fca56d0c1e17d7233cc 100644 (file)
@@ -1,38 +1,38 @@
-<?php\r
-\r
-       /**\r
-        * Elgg widget save action\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg widget save action
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
 
-        * @link http://elgg.org/\r
-        */\r
-\r
                action_gatekeeper();
-               \r
-               $guid = get_input('guid');\r
-               $params = $_REQUEST['params'];\r
-               $pageurl = get_input('pageurl');\r
-               $noforward = get_input('noforward',false);\r
-\r
-               $result = false;\r
-               \r
-               if (!empty($guid)) {\r
-                       \r
-                       $result = save_widget_info($guid,$params);\r
-                       \r
-               }\r
-               \r
-               if ($result) {\r
-                       system_message(elgg_echo('widgets:save:success'));\r
-               } else {\r
-                       register_error(elgg_echo('widgets:save:failure'));\r
-               }\r
-               \r
-               if (!$noforward)\r
-                       forward($_SERVER['HTTP_REFERER']);\r
-\r
+               
+               $guid = get_input('guid');
+               $params = $_REQUEST['params'];
+               $pageurl = get_input('pageurl');
+               $noforward = get_input('noforward',false);
+
+               $result = false;
+               
+               if (!empty($guid)) {
+                       
+                       $result = save_widget_info($guid,$params);
+                       
+               }
+               
+               if ($result) {
+                       system_message(elgg_echo('widgets:save:success'));
+               } else {
+                       register_error(elgg_echo('widgets:save:failure'));
+               }
+               
+               if (!$noforward)
+                       forward($_SERVER['HTTP_REFERER']);
+
 ?>
\ No newline at end of file
index 969d91f7e9d1087d69e61fbf85d32f65e7a17694..98466cb207cd5fcb2b5042ee8fbb9712df8664eb 100644 (file)
@@ -1,21 +1,21 @@
-<?php\r
-\r
-       /**\r
-        * Elgg administration system index\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg administration system index
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Get the Elgg framework\r
-               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");\r
-\r
-       // Make sure only valid admin users can see this\r
-               admin_gatekeeper();\r
-               forward('pg/admin/statistics/')\r
-               \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Get the Elgg framework
+               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+
+       // Make sure only valid admin users can see this
+               admin_gatekeeper();
+               forward('pg/admin/statistics/')
+               
 ?>
\ No newline at end of file
index dcf0fead0d6348e7c5499522c246392717c0f9a4..9900c98e9c845f8be0f40860f32f472d631a7a9c 100644 (file)
@@ -17,9 +17,9 @@
                admin_gatekeeper();
                
     // Set admin user for user block
-               //set_page_owner($_SESSION['guid']);\r
-               \r
-       // Regenerate plugin list\r
+               //set_page_owner($_SESSION['guid']);
+               
+       // Regenerate plugin list
                regenerate_plugin_list();
                
        // Display main admin menu
index dc8aed1a11d4982f72726ad16af3298bbbd522d7..c66dc290a28127fe1f8c6720060e9eef8c506d0c 100644 (file)
@@ -1,26 +1,26 @@
-<?php\r
-\r
-       /**\r
-        * Elgg administration site system index\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg administration site system index
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Get the Elgg framework\r
-               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");\r
-\r
-       // Make sure only valid admin users can see this\r
-               admin_gatekeeper();\r
-               \r
-    // Set admin user for user block\r
-               //set_page_owner($_SESSION['guid']);\r
-               \r
-       // Display main admin menu\r
-               page_draw(elgg_echo("admin:site"),elgg_view_layout("two_column_left_sidebar",'', elgg_view_title(elgg_echo('admin:site')) . elgg_view("admin/site")));\r
-               \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Get the Elgg framework
+               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+
+       // Make sure only valid admin users can see this
+               admin_gatekeeper();
+               
+    // Set admin user for user block
+               //set_page_owner($_SESSION['guid']);
+               
+       // Display main admin menu
+               page_draw(elgg_echo("admin:site"),elgg_view_layout("two_column_left_sidebar",'', elgg_view_title(elgg_echo('admin:site')) . elgg_view("admin/site")));
+               
 ?>
\ No newline at end of file
index 84e4f1d830bb2754625eb892167afc42e510cde8..16b5bf172a367e98af4ebf896b370000e774cee9 100644 (file)
@@ -1,45 +1,45 @@
-<?php\r
-\r
-       /**\r
-        * Elgg administration user system index\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Get the Elgg framework\r
-               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");\r
-\r
-       // Make sure only valid admin users can see this\r
-               admin_gatekeeper();\r
-               \r
-       // Set admin user for user block\r
-               //set_page_owner($_SESSION['guid']);\r
-\r
-       // Are we performing a search\r
-               $search = get_input('s');\r
-               $limit = get_input('limit', 10);\r
-               $offset = get_input('offset', 0);\r
-               \r
-               $context = get_context();\r
-               \r
-               $title = elgg_view_title(elgg_echo('admin:user'));\r
-               \r
-               set_context('search');\r
-\r
-               $result = list_entities('user');\r
-               \r
-               set_context('admin');\r
-                       \r
-       // Display main admin menu\r
-               page_draw(elgg_echo("admin:user"),\r
-                                               elgg_view_layout("two_column_left_sidebar", \r
-                                                                               '', \r
-                                                                               $title . elgg_view("admin/user") . $result)\r
-                                                                               );\r
-\r
+<?php
+
+       /**
+        * Elgg administration user system index
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Get the Elgg framework
+               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+
+       // Make sure only valid admin users can see this
+               admin_gatekeeper();
+               
+       // Set admin user for user block
+               //set_page_owner($_SESSION['guid']);
+
+       // Are we performing a search
+               $search = get_input('s');
+               $limit = get_input('limit', 10);
+               $offset = get_input('offset', 0);
+               
+               $context = get_context();
+               
+               $title = elgg_view_title(elgg_echo('admin:user'));
+               
+               set_context('search');
+
+               $result = list_entities('user');
+               
+               set_context('admin');
+                       
+       // Display main admin menu
+               page_draw(elgg_echo("admin:user"),
+                                               elgg_view_layout("two_column_left_sidebar", 
+                                                                               '', 
+                                                                               $title . elgg_view("admin/user") . $result)
+                                                                               );
+
 ?>
\ No newline at end of file
index 260d5b46eb6f023c842612b35d7b7483953399be..101e74d6d4e767969d1ac700b8c4bdf23cd5038b 100644 (file)
@@ -1,33 +1,33 @@
-<?php\r
-\r
-       /**\r
-        * Elgg dashboard\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg dashboard
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Get the Elgg engine\r
-               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");\r
-\r
-       // Ensure that only logged-in users can see this page\r
-               gatekeeper();\r
-               \r
-       // Set context and title\r
-               set_context('dashboard');\r
-               set_page_owner(get_loggedin_userid());\r
-               $title = elgg_echo('dashboard');\r
-               \r
-       // wrap intro message in a div\r
-               $intro_message = elgg_view('dashboard/blurb');\r
-               \r
-       // Try and get the user from the username and set the page body accordingly\r
-               $body = elgg_view_layout('widgets',"","",$intro_message);\r
-               \r
-               page_draw($title, $body);\r
-               \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Get the Elgg engine
+               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+
+       // Ensure that only logged-in users can see this page
+               gatekeeper();
+               
+       // Set context and title
+               set_context('dashboard');
+               set_page_owner(get_loggedin_userid());
+               $title = elgg_echo('dashboard');
+               
+       // wrap intro message in a div
+               $intro_message = elgg_view('dashboard/blurb');
+               
+       // Try and get the user from the username and set the page body accordingly
+               $body = elgg_view_layout('widgets',"","",$intro_message);
+               
+               page_draw($title, $body);
+               
 ?>
\ No newline at end of file
index c49b6fc20b4afe1c58a3892c299e56bcc14ae90d..cf214a0605b7a0c90b7f0c32043421ba89472338 100644 (file)
@@ -1,30 +1,30 @@
-<?php\r
-\r
-       /**\r
-        * Elgg latest content page\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg latest content page
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       /**
+        * Start the Elgg engine
+        */
+               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+               
+               
+       // Load the front page
+        global $CONFIG;
+        $title = elgg_view_title(elgg_echo('content:latest'));
+        set_context('search');
+        $content = list_registered_entities(0,10,true,false,array('object','group'));
+        set_context('latest');
+        $content = elgg_view_layout('two_column_left_sidebar', '', $title . $content);
+        page_draw(elgg_echo('content:latest'), $content);
+               
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /**\r
-        * Start the Elgg engine\r
-        */\r
-               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");\r
-               \r
-               \r
-       // Load the front page\r
-        global $CONFIG;\r
-        $title = elgg_view_title(elgg_echo('content:latest'));\r
-        set_context('search');\r
-        $content = list_registered_entities(0,10,true,false,array('object','group'));\r
-        set_context('latest');\r
-        $content = elgg_view_layout('two_column_left_sidebar', '', $title . $content);\r
-        page_draw(elgg_echo('content:latest'), $content);\r
-               \r
-\r
 ?>
\ No newline at end of file
index 1e769eebde006734fbef7392792ba620e28ad91b..4878084adcb1db0bbd42c20b73bfcbe09c719129 100644 (file)
@@ -1,21 +1,21 @@
-<?php\r
-\r
-    /**\r
-        * Elgg action handler\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+    /**
+        * Elgg action handler
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-    /**\r
-     *  Load Elgg framework\r
-     */\r
-               define('externalpage',true);\r
-        require_once("../start.php");\r
-        $action = get_input("action");\r
-        action($action);\r
-    \r
-?>\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+    /**
+     *  Load Elgg framework
+     */
+               define('externalpage',true);
+        require_once("../start.php");
+        $action = get_input("action");
+        action($action);
+    
+?>
index a379a0e20c01f7756089f4fd23359aeb55c6cb36..71a8cf2a4980d39f5974130c08d2bc6bed70a9b4 100644 (file)
@@ -8,7 +8,7 @@
         * @link http://elgg.org/
         */
 
-       // Load Elgg engine\r
+       // Load Elgg engine
        define('externalpage',true);
        require_once("../start.php");
        global $CONFIG;
index 167d54957be5130bcb61b7e1a7b563ed0570eb07..506ae980219d5f464aee32ed40a87aa17b25c8c4 100644 (file)
@@ -1,27 +1,27 @@
-<?php\r
-\r
-       /**\r
-        * Elgg page handler\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg page handler
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Load Elgg engine
+               // define('externalpage',true);
+               require_once("../start.php");
+
+       // Get input
+               $handler = get_input('handler');
+               $page = get_input('page');
+               
+       // Call the page handler functions
+               if (!page_handler($handler, $page)) {
+                       forward();
+               }
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Load Elgg engine\r
-               // define('externalpage',true);\r
-               require_once("../start.php");\r
-\r
-       // Get input\r
-               $handler = get_input('handler');\r
-               $page = get_input('page');\r
-               \r
-       // Call the page handler functions\r
-               if (!page_handler($handler, $page)) {\r
-                       forward();\r
-               }\r
-\r
 ?>
\ No newline at end of file
index 6be9b4a09d20b77f2697b2712feb0a5eec585132..bc87306c72249e4109d5111d291b5aceb44be634 100644 (file)
@@ -8,7 +8,7 @@
         * @link http://elgg.org/
         */
 
-       // Load Elgg engine\r
+       // Load Elgg engine
        define('externalpage',true);
        require_once("../start.php");
        global $CONFIG;
index 7f3a8131fa7c23db5787141dac4813282d7df150..392c89a2ffddfeab39d03dc67c60a66ef12826f5 100644 (file)
-<?php\r
-\r
-       /**\r
-        * Elgg access permissions\r
-        * For users, objects, collections and all metadata\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg access permissions
+        * For users, objects, collections and all metadata
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /**\r
-        * Get the list of access restrictions the given user is allowed to see on this site\r
-        *\r
-        * @uses get_access_array\r
-        * @param int $user_id User ID; defaults to currently logged in user\r
-        * @param int $site_id Site ID; defaults to current site \r
-        * @param boolean $flush If set to true, will refresh the access list from the database\r
-        * @return string A list of access collections suitable for injection in an SQL call\r
-        */\r
-               function get_access_list($user_id = 0, $site_id = 0, $flush = false) {\r
-                       \r
-                       global $CONFIG, $init_finished, $SESSION;\r
-                       static $access_list;\r
-                       \r
-                       if (!isset($access_list) || !$init_finished)\r
-                               $access_list = array();\r
-                               \r
-                       if ($user_id == 0) $user_id = $SESSION['id'];\r
-                       if (($site_id == 0) && (isset($CONFIG->site_id))) $site_id = $CONFIG->site_id;\r
-                       $user_id = (int) $user_id;\r
-                       $site_id = (int) $site_id;\r
-                       \r
-                       if (isset($access_list[$user_id])) return $access_list[$user_id];\r
-                       \r
-                       $access_list[$user_id] = "(" . implode(",",get_access_array($user_id, $site_id, $flush)) . ")";\r
-                       \r
-                       return $access_list[$user_id];\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * Gets an array of access restrictions the given user is allowed to see on this site\r
-        *\r
-        * @param int $user_id User ID; defaults to currently logged in user\r
-        * @param int $site_id Site ID; defaults to current site \r
-        * @param boolean $flush If set to true, will refresh the access list from the database\r
-        * @return array An array of access collections suitable for injection in an SQL call\r
-        */\r
-               function get_access_array($user_id = 0, $site_id = 0, $flush = false) {\r
-                       \r
-                       global $CONFIG, $init_finished;\r
-                       static $access_array, $acm, $ac; // Caches. $ac* flag whether we have executed a query previously, and stop it being run again if no data is returned.\r
-                       \r
-                       if (!isset($access_array) || (!isset($init_finished)) || (!$init_finished))\r
-                               $access_array = array(); \r
-                               \r
-                       if ($user_id == 0) $user_id = get_loggedin_userid();\r
-                       \r
-                       if (($site_id == 0) && (isset($CONFIG->site_guid))) $site_id = $CONFIG->site_guid;\r
-                       $user_id = (int) $user_id;\r
-                       $site_id = (int) $site_id;\r
-                       \r
-                       if (empty($access_array[$user_id]) || $flush == true) {\r
-                               \r
-                               $query = "SELECT am.access_collection_id FROM {$CONFIG->dbprefix}access_collection_membership am ";\r
-                               $query .= " LEFT JOIN {$CONFIG->dbprefix}access_collections ag ON ag.id = am.access_collection_id ";\r
-                               $query .= " WHERE am.user_guid = {$user_id} AND (ag.site_guid = {$site_id} OR ag.site_guid = 0)";\r
-                               \r
-                               $tmp_access_array = array(ACCESS_PUBLIC); \r
-                               if (isloggedin()) {\r
-                                       $tmp_access_array[] = ACCESS_LOGGED_IN;\r
-                                       \r
-                                       // The following can only return sensible data if the user is logged in.\r
-                                       \r
-                                       if ($collections = get_data($query)) {\r
-                                               foreach($collections as $collection)\r
-                                                       if (!empty($collection->access_collection_id)) $tmp_access_array[] = $collection->access_collection_id;\r
-                                                       \r
-                                       }\r
-                                               \r
-                                       $query = "SELECT ag.id FROM {$CONFIG->dbprefix}access_collections ag  ";\r
-                                       $query .= " WHERE ag.owner_guid = {$user_id} AND (ag.site_guid = {$site_id} OR ag.site_guid = 0)";\r
-                                       \r
-                                       if ($collections = get_data($query)) {\r
-                                               foreach($collections as $collection)\r
-                                                       if (!empty($collection->id)) $tmp_access_array[] = $collection->id;\r
-                                       }\r
-                                        \r
-                                       \r
-                                       global $is_admin;\r
-                                       \r
-                                       if (isset($is_admin) && $is_admin == true) {\r
-                                               $tmp_access_array[] = ACCESS_PRIVATE;\r
-                                       }\r
-\r
-                                       $access_array[$user_id] = $tmp_access_array;\r
-                               }\r
-                               else\r
-                                       $tmp_return = $tmp_access_array; // No user id logged in so we can only access public info\r
-                               \r
-                               \r
-                       } else {\r
-                               $tmp_access_array = $access_array[$user_id];\r
-                       }\r
-                       \r
-                       $tmp_return = $access_array[$user_id];\r
-                       \r
-                       return trigger_plugin_hook('access:collections:read','user',array('user_id' => $user_id, 'site_id' => $site_id),$tmp_access_array);\r
-               }\r
-               \r
-       /**\r
-        * Gets the default access permission for new content\r
-        *\r
-        * @return int default access id (see ACCESS defines in elgglib.php)  \r
-        */\r
-               function get_default_access($user=null)\r
-               {\r
-                       global $CONFIG;\r
-                       \r
-                       if (!$CONFIG->allow_user_default_access) {\r
-                               return $CONFIG->default_access;\r
-                       }\r
-                       \r
-                       if (!$user) {\r
-                               if (isloggedin()) {\r
-                                       $user = $_SESSION['user'];\r
-                               } else {\r
-                                       return $CONFIG->default_access;\r
-                               }\r
-                       }\r
-                       \r
-                       if (false !== ($default_access = $user->getPrivateSetting('elgg_default_access'))) {\r
-                               return $default_access;\r
-                       } else {                        \r
-                               return $CONFIG->default_access;\r
-                       }\r
-               }\r
-               \r
-               /**\r
-                * Override the default behaviour and allow results to show hidden entities as well.\r
-                * THIS IS A HACK.\r
-                * \r
-                * TODO: Replace this with query object!\r
-                */\r
-               $ENTITY_SHOW_HIDDEN_OVERRIDE = false;\r
-               \r
-               /**\r
-                * This will be replaced. Do not use in plugins!\r
-                *\r
-                * @param bool $show\r
-                */\r
-               function access_show_hidden_entities($show_hidden)\r
-               {\r
-                       global $ENTITY_SHOW_HIDDEN_OVERRIDE;  \r
-                       $ENTITY_SHOW_HIDDEN_OVERRIDE = $show_hidden;  \r
-               }\r
-               \r
-               /**\r
-                * This will be replaced. Do not use in plugins!\r
-                */\r
-               function access_get_show_hidden_status()\r
-               {\r
-                       global $ENTITY_SHOW_HIDDEN_OVERRIDE;  \r
-                       return $ENTITY_SHOW_HIDDEN_OVERRIDE;\r
-               }\r
-               \r
-               /**\r
-                * Add annotation restriction\r
-                * \r
-                * Returns an SQL fragment that is true (or optionally false) if the given user has \r
-                * added an annotation with the given name to the given entity.\r
-                * \r
-                * TODO: This is fairly generic so perhaps it could be moved to annotations.php\r
-                * \r
-                * @param string $annotation_name name of the annotation\r
-                * @param string $entity_guid SQL string that evaluates to the GUID of the entity the annotation should be attached to\r
-                * @param string $owner_guid SQL string that evaluates to the GUID of the owner of the annotation                * \r
-                * @param boolean $exists If set to true, will return true if the annotation exists, otherwise returns false\r
-                * @return string An SQL fragment suitable for inserting into a WHERE clause\r
-                */\r
-               \r
-               function get_annotation_sql($annotation_name,$entity_guid,$owner_guid,$exists) {\r
-                       global $CONFIG;\r
-                       \r
-                       if ($exists) {\r
-                               $not = '';\r
-                       } else {\r
-                               $not = 'NOT';\r
-                       }\r
-                       \r
-                       $sql = <<<END\r
-$not EXISTS (SELECT * FROM {$CONFIG->dbprefix}annotations a \r
-INNER JOIN {$CONFIG->dbprefix}metastrings ms ON (a.name_id = ms.id)\r
-WHERE ms.string = '$annotation_name'\r
-AND a.entity_guid = $entity_guid\r
-AND a.owner_guid = $owner_guid)\r
-END;\r
-                       return $sql;\r
-               }\r
-               \r
-               /**\r
-                * Add access restriction sql code to a given query.\r
-                * \r
-                * Note that if this code is executed in privileged mode it will return blank.\r
-                * \r
-                * TODO: DELETE once Query classes are fully integrated\r
-                * \r
-                * @param string $table_prefix Optional xxx. prefix for the access code.\r
-                */\r
-               function get_access_sql_suffix($table_prefix = "",$owner=null)\r
-               {\r
-                       global $ENTITY_SHOW_HIDDEN_OVERRIDE, $CONFIG;  \r
-                       \r
-                       $sql = "";\r
-                       $friends_bit = "";\r
-                       $enemies_bit = "";\r
-                       \r
-                       if ($table_prefix)\r
-                                       $table_prefix = sanitise_string($table_prefix) . ".";\r
-                       \r
-                       $access = get_access_list();\r
-                       \r
-                       if (!isset($owner)) {\r
-                               $owner = get_loggedin_userid();\r
-                       }\r
-                       if (!$owner) $owner = -1;\r
-                       \r
-                       global $is_admin;\r
-                       \r
-                       if (isset($is_admin) && $is_admin == true) {\r
-                               $sql = " (1 = 1) ";\r
-                       } else if ($owner != -1) {                              \r
-                               $friends_bit = $table_prefix.'access_id = '.ACCESS_FRIENDS.' AND ';\r
-                               $friends_bit .= "{$table_prefix}owner_guid IN (SELECT guid_one FROM {$CONFIG->dbprefix}entity_relationships WHERE relationship='friend' AND guid_two=$owner)";\r
-                               $friends_bit = '('.$friends_bit.') OR ';\r
-                               \r
-                               if ((isset($CONFIG->user_block_and_filter_enabled)) && ($CONFIG->user_block_and_filter_enabled)) {\r
-                                       // check to see if the user is in the entity owner's block list\r
-                                       // or if the entity owner is in the user's filter list\r
-                                       // if so, disallow access\r
-                                       \r
-                                       $enemies_bit = get_annotation_sql('elgg_block_list',"{$table_prefix}owner_guid",$owner,false);\r
-                                       $enemies_bit = '('.$enemies_bit. ' AND '.get_annotation_sql('elgg_filter_list',$owner,"{$table_prefix}owner_guid",false).')';\r
-                               }\r
-                       }\r
-\r
-                       if (empty($sql))\r
-                               $sql = " $friends_bit ({$table_prefix}access_id in {$access} or ({$table_prefix}owner_guid = {$owner}) or ({$table_prefix}access_id = " . ACCESS_PRIVATE . " and {$table_prefix}owner_guid = $owner))";\r
-                       \r
-                       if ($enemies_bit) {\r
-                               $sql = "$enemies_bit AND ($sql)";\r
-                       }\r
-                               \r
-                       if (!$ENTITY_SHOW_HIDDEN_OVERRIDE)\r
-                               $sql .= " and {$table_prefix}enabled='yes'";\r
-                       return '('.$sql.')';\r
-               }\r
-               \r
-               /**\r
-                * Determines whether the given user has access to the given entity\r
-                * \r
-                * @param ElggEntity $entity The entity to check access for.\r
-                * @param ElggUser $user Optionally the user to check access for.\r
-                * \r
-                * @return boolean True if the user can access the entity\r
-                */\r
-               \r
-               function has_access_to_entity($entity,$user = null) {\r
-                       global $CONFIG;\r
-                       \r
-                       if (!isset($user)) {\r
-                               $access_bit = get_access_sql_suffix("e");\r
-                       } else {\r
-                               $access_bit = get_access_sql_suffix("e",$user->getGUID());\r
-                       }\r
-                       \r
-                       $query = "SELECT guid from {$CONFIG->dbprefix}entities e WHERE e.guid = ".$entity->getGUID();\r
-                       $query .= " AND ".$access_bit; // Add access controls\r
-                       if (get_data($query)) {\r
-                               return true;\r
-                       } else {\r
-                               return false;\r
-                       }                       \r
-               }\r
-               \r
-               /**\r
-                * Returns an array of access permissions that the specified user is allowed to save objects with.\r
-                * Permissions are of the form ('id' => 'Description')\r
-                *\r
-                * @param int $user_id The user's GUID.\r
-                * @param int $site_id The current site.\r
-                * @param true|false $flush If this is set to true, this will shun any cached version\r
-                * @return array List of access permissions=\r
-                */\r
-               function get_write_access_array($user_id = 0, $site_id = 0, $flush = false) {\r
-                       \r
-                       global $CONFIG;\r
-                       static $access_array;\r
-                       \r
-                       if ($user_id == 0) $user_id = get_loggedin_userid();\r
-                       if (($site_id == 0) && (isset($CONFIG->site_id))) $site_id = $CONFIG->site_id;\r
-                       $user_id = (int) $user_id;\r
-                       $site_id = (int) $site_id;\r
-                       \r
-                       if (empty($access_array[$user_id]) || $flush == true) {\r
-                               \r
-                               $query = "SELECT ag.* FROM {$CONFIG->dbprefix}access_collections ag ";\r
-                               $query .= " WHERE (ag.site_guid = {$site_id} OR ag.site_guid = 0)";\r
-                               $query .= " AND (ag.owner_guid = {$user_id})";\r
-                               $query .= " AND ag.id >= 3";\r
-                               \r
-                               $tmp_access_array = array(0 => elgg_echo("PRIVATE"), ACCESS_FRIENDS => elgg_echo("access:friends:label"), 1 => elgg_echo("LOGGED_IN"), 2 => elgg_echo("PUBLIC"));\r
-                               if ($collections = get_data($query)) {\r
-                                       foreach($collections as $collection)\r
-                                               $tmp_access_array[$collection->id] = $collection->name;\r
-                               }\r
-                               \r
-                               $access_array[$user_id] = $tmp_access_array;\r
-                               \r
-                       } else {\r
-                               $tmp_access_array = $access_array[$user_id];\r
-                       }\r
-                       \r
-                       $tmp_access_array = trigger_plugin_hook('access:collections:write','user',array('user_id' => $user_id, 'site_id' => $site_id),$tmp_access_array);\r
-                       \r
-                       return $tmp_access_array;\r
-                       \r
-               }\r
-\r
-               /**\r
-                * Creates a new access control collection owned by the specified user.\r
-                *\r
-                * @param string $name The name of the collection.\r
-                * @param int $owner_guid The GUID of the owner (default: currently logged in user).\r
-                * @param int $site_guid The GUID of the site (default: current site).\r
-                * @return int|false Depending on success (the collection ID if successful).\r
-                */\r
-               function create_access_collection($name, $owner_guid = 0, $site_guid = 0) {\r
-                       \r
-                       global $CONFIG;\r
-                       \r
-                       $name = trim($name);\r
-                       if (empty($name)) return false;\r
-                       \r
-                       if ($owner_guid == 0) $owner_guid = get_loggedin_userid();\r
-                       if (($site_id == 0) && (isset($CONFIG->site_guid))) $site_id = $CONFIG->site_guid;\r
-                       $name = sanitise_string($name);\r
-                       \r
-                       return insert_data("insert into {$CONFIG->dbprefix}access_collections set name = '{$name}', owner_guid = {$owner_guid}, site_guid = {$site_id}");\r
-                       \r
-               }\r
-               \r
-               /**\r
-                * Updates the membership in an access collection.\r
-                *\r
-                * @param int $collection_id The ID of the collection.\r
-                * @param array $members Array of member GUIDs\r
-                * @return true|false Depending on success\r
-                */\r
-               function update_access_collection($collection_id, $members) {\r
-                       \r
-                       global $CONFIG;\r
-                       $collection_id = (int) $collection_id;\r
-                       \r
-                       $collections = get_write_access_array();\r
-                       \r
-                       if (array_key_exists($collection_id, $collections)) {\r
-                       \r
-                               delete_data("delete from {$CONFIG->dbprefix}access_collection_membership where access_collection_id = {$collection_id}");\r
-                               \r
-                               if (is_array($members) && sizeof($members) > 0) {\r
-                                       foreach($members as $member) {\r
-                                               $member = (int) $member;\r
-                                               if (get_user($member))\r
-                                                       insert_data("insert into {$CONFIG->dbprefix}access_collection_membership set access_collection_id = {$collection_id}, user_guid = {$member}");\r
-                                       }\r
-                                       return true;\r
-                               }\r
-                       \r
-                       }\r
-                       \r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * Deletes a specified access collection\r
-                *\r
-                * @param int $collection_id The collection ID\r
-                * @return true|false Depending on success\r
-                */\r
-               function delete_access_collection($collection_id) {\r
-                       \r
-                       $collection_id = (int) $collection_id;\r
-                       $collections = get_write_access_array();\r
-                       if (array_key_exists($collection_id, $collections)) {\r
-                               global $CONFIG;\r
-                               delete_data("delete from {$CONFIG->dbprefix}access_collection_membership where access_collection_id = {$collection_id}");\r
-                               delete_data("delete from {$CONFIG->dbprefix}access_collections where id = {$collection_id}");\r
-                               return true;\r
-                       } else {\r
-                               return false;\r
-                       }\r
-                       \r
-               }\r
-               \r
-               /**\r
-                * Get a specified access collection\r
-                *\r
-                * @param int $collection_id The collection ID\r
-                * @return array|false Depending on success\r
-                */\r
-               function get_access_collection($collection_id) {\r
-               \r
-               $collection_id = (int) $collection_id;\r
-               global $CONFIG;\r
-               $get_collection = get_data_row("SELECT * FROM {$CONFIG->dbprefix}access_collections WHERE id = {$collection_id}");\r
-               \r
-               return $get_collection;\r
-               \r
-               }\r
-               \r
-               /**\r
-                * Adds a user to the specified user collection\r
-                *\r
-                * @param int $user_guid The GUID of the user to add\r
-                * @param int $collection_id The ID of the collection to add them to\r
-                * @return true|false Depending on success\r
-                */\r
-               function add_user_to_access_collection($user_guid, $collection_id) {\r
-                       \r
-                       $collection_id = (int) $collection_id;\r
-                       $user_guid = (int) $user_guid;\r
-                       $collections = get_write_access_array();\r
-                       \r
-                       if (!($collection = get_access_collection($collection_id)))\r
-                               return false;\r
-                               \r
-                       if ((array_key_exists($collection_id, $collections) || $collection->owner_guid == 0)\r
-                                       && $user = get_user($user_guid)) {\r
-\r
-                               global $CONFIG;\r
-                               try {\r
-                                       insert_data("insert into {$CONFIG->dbprefix}access_collection_membership set access_collection_id = {$collection_id}, user_guid = {$user_guid}");\r
-                               } catch (DatabaseException $e) {}\r
-                               return true;\r
-                               \r
-                       }\r
-                       \r
-                       return false;\r
-                       \r
-               }\r
-\r
-               /**\r
-                * Removes a user from an access collection\r
-                *\r
-                * @param int $user_guid The user GUID\r
-                * @param int $collection_id The access collection ID\r
-                * @return true|false Depending on success\r
-                */\r
-               function remove_user_from_access_collection($user_guid, $collection_id) {\r
-                       \r
-                       $collection_id = (int) $collection_id;\r
-                       $user_guid = (int) $user_guid;\r
-                       $collections = get_write_access_array();\r
-                       \r
-                       if (!($collection = get_access_collection($collection_id)))\r
-                               return false;\r
-                       \r
-                       if ((array_key_exists($collection_id, $collections) || $collection->owner_guid == 0) && $user = get_user($user_guid)) {\r
-                               \r
-                               global $CONFIG;\r
-                               delete_data("delete from {$CONFIG->dbprefix}access_collection_membership where access_collection_id = {$collection_id} and user_guid = {$user_guid}");\r
-                               return true;\r
-                               \r
-                       }\r
-                       \r
-                       return false;\r
-                       \r
-               }\r
-               \r
-               /**\r
-                * Get all of a users collections\r
-                *\r
-                * @param int $owner_guid The user ID\r
-                * @return true|false Depending on success\r
-                */\r
-               function get_user_access_collections($owner_guid) {\r
-                       \r
-                       $owner_guid = (int) $owner_guid;\r
-                       \r
-                       global $CONFIG;\r
-                       \r
-                       $collections = get_data("SELECT * FROM {$CONFIG->dbprefix}access_collections WHERE owner_guid = {$owner_guid}");\r
-                       \r
-                       return $collections;\r
-                       \r
-               }\r
-               \r
-               /**\r
-                * Get all of members of a friend collection\r
-                *\r
-                * @param int $collection The collection's ID\r
-                * @param true|false $idonly If set to true, will only return the members' IDs (default: false)\r
-                * @return ElggUser entities if successful, false if not\r
-                */\r
-               function get_members_of_access_collection($collection, $idonly = false) {\r
-               \r
-               $collection = (int)$collection;\r
-               \r
-               global $CONFIG;\r
-               \r
-               if (!$idonly) {\r
-                       $query = "SELECT e.* FROM {$CONFIG->dbprefix}access_collection_membership m JOIN {$CONFIG->dbprefix}entities e ON e.guid = m.user_guid WHERE m.access_collection_id = {$collection}";       \r
-                               $collection_members = get_data($query, "entity_row_to_elggstar");\r
-               } else {\r
-                       $query = "SELECT e.guid FROM {$CONFIG->dbprefix}access_collection_membership m JOIN {$CONFIG->dbprefix}entities e ON e.guid = m.user_guid WHERE m.access_collection_id = {$collection}";\r
-                       $collection_members = get_data($query);\r
-                       foreach($collection_members as $key => $val)\r
-                               $collection_members[$key] = $val->guid;\r
-               }\r
-                       \r
-                       return $collection_members;\r
-                       \r
-               }\r
-               \r
-               /**\r
-                * Displays a user's access collections, using the friends/collections view\r
-                *\r
-                * @param int $owner_guid The GUID of the owning user\r
-                * @return string A formatted rendition of the collections\r
-                */\r
-               function elgg_view_access_collections($owner_guid) {\r
-                       \r
-                       if ($collections = get_user_access_collections($owner_guid)) {\r
-                               \r
-                               foreach($collections as $key => $collection) {\r
-                                       $collections[$key]->members = get_members_of_access_collection($collection->id, true);\r
-                                       $collections[$key]->entities = get_user_friends($owner_guid,"",9999);\r
-                               }\r
-                               \r
-                       }\r
-                       \r
-                       return elgg_view('friends/collections',array('collections' => $collections));\r
-                       \r
-               }\r
-               \r
-               /**\r
-                * Get entities with the specified access collection id.\r
-                * \r
-                * @param $collection_id\r
-                * @param $entity_type\r
-                * @param $entity_subtype\r
-                * @param $owner_guid\r
-                * @param $limit\r
-                * @param $offset\r
-                * @param $order_by\r
-                * @param $site_guid\r
-                * @param $count\r
-                * @return unknown_type\r
-                */\r
-               function get_entities_from_access_collection($collection_id, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {\r
-                       global $CONFIG;\r
-                       \r
-                       if (!$collection_id)\r
-                               return false;\r
-                               \r
-                       $entity_type = sanitise_string($entity_type);\r
-                       $entity_subtype = get_subtype_id($entity_type, $entity_subtype);\r
-                       $limit = (int)$limit;\r
-                       $offset = (int)$offset;\r
-                       if ($order_by == "") \r
-                               $order_by = "e.time_created desc";\r
-                       else\r
-                               $order_by = "e.time_created, {$order_by}";\r
-                       $order_by = sanitise_string($order_by);\r
-                       $site_guid = (int) $site_guid;\r
-                       if ((is_array($owner_guid) && (count($owner_guid)))) {\r
-                               foreach($owner_guid as $key => $guid) {\r
-                                       $owner_guid[$key] = (int) $guid;\r
-                               }\r
-                       } else {\r
-                               $owner_guid = (int) $owner_guid;\r
-                       }\r
-                       if ($site_guid == 0)\r
-                               $site_guid = $CONFIG->site_guid;\r
-                               \r
-                       //$access = get_access_list();\r
-                               \r
-                       $where = array("e.access_id = $collection_id");\r
-                       \r
-                       if ($entity_type!=="")\r
-                               $where[] = "e.type='$entity_type'";\r
-                       if ($entity_subtype)\r
-                               $where[] = "e.subtype=$entity_subtype";\r
-                       if ($site_guid > 0)\r
-                               $where[] = "e.site_guid = {$site_guid}";\r
-                       if (is_array($owner_guid)) {\r
-                               $where[] = "e.container_guid in (".implode(",",$owner_guid).")";\r
-                       } else if ($owner_guid > 0)\r
-                               $where[] = "e.container_guid = {$owner_guid}";\r
-                       \r
-                       if (!$count) {\r
-                               $query = "SELECT distinct e.* "; \r
-                       } else {\r
-                               $query = "SELECT count(distinct e.guid) as total ";\r
-                       }\r
-                               \r
-                       $query .= "from {$CONFIG->dbprefix}entities e where";\r
-                       foreach ($where as $w)\r
-                               $query .= " $w and ";\r
-                       $query .= get_access_sql_suffix("e"); // Add access controls\r
-                       //$query .= ' and ' . get_access_sql_suffix("m"); // Add access controls\r
-                       \r
-                       if (!$count) {\r
-                               $query .= " order by $order_by limit $offset, $limit"; // Add order and limit\r
-                               return get_data($query, "entity_row_to_elggstar");\r
-                       } else {\r
-                               if ($row = get_data_row($query))\r
-                                       return $row->total;\r
-                       }\r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * Lists entities from an access collection\r
-                * \r
-                * @param $collection_id\r
-                * @param $entity_type\r
-                * @param $entity_subtype\r
-                * @param $owner_guid\r
-                * @param $limit\r
-                * @param $fullview\r
-                * @param $viewtypetoggle\r
-                * @param $pagination\r
-                * @return str\r
-                */\r
-               function list_entities_from_access_collection($collection_id, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = true, $pagination = true) {\r
-                       $offset = (int) get_input('offset');\r
-                       $limit = (int) $limit;\r
-                       $count = get_entities_from_access_collection($collection_id, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", 0, true);\r
-                       $entities = get_entities_from_access_collection($collection_id, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", 0, false);\r
-                       \r
-                       return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);\r
-               }\r
-               \r
-               global $init_finished;\r
-               $init_finished = false;\r
-               \r
-       /**\r
-        * A quick and dirty way to make sure the access permissions have been correctly set up\r
-        *\r
-        */\r
-               function access_init() {\r
-                       global $init_finished;\r
-                       $init_finished = true;\r
-               }\r
-               \r
-       // This function will let us know when 'init' has finished\r
-               register_elgg_event_handler('init','system','access_init',9999);\r
-               \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       /**
+        * Get the list of access restrictions the given user is allowed to see on this site
+        *
+        * @uses get_access_array
+        * @param int $user_id User ID; defaults to currently logged in user
+        * @param int $site_id Site ID; defaults to current site 
+        * @param boolean $flush If set to true, will refresh the access list from the database
+        * @return string A list of access collections suitable for injection in an SQL call
+        */
+               function get_access_list($user_id = 0, $site_id = 0, $flush = false) {
+                       
+                       global $CONFIG, $init_finished, $SESSION;
+                       static $access_list;
+                       
+                       if (!isset($access_list) || !$init_finished)
+                               $access_list = array();
+                               
+                       if ($user_id == 0) $user_id = $SESSION['id'];
+                       if (($site_id == 0) && (isset($CONFIG->site_id))) $site_id = $CONFIG->site_id;
+                       $user_id = (int) $user_id;
+                       $site_id = (int) $site_id;
+                       
+                       if (isset($access_list[$user_id])) return $access_list[$user_id];
+                       
+                       $access_list[$user_id] = "(" . implode(",",get_access_array($user_id, $site_id, $flush)) . ")";
+                       
+                       return $access_list[$user_id];
+                       
+               }
+               
+       /**
+        * Gets an array of access restrictions the given user is allowed to see on this site
+        *
+        * @param int $user_id User ID; defaults to currently logged in user
+        * @param int $site_id Site ID; defaults to current site 
+        * @param boolean $flush If set to true, will refresh the access list from the database
+        * @return array An array of access collections suitable for injection in an SQL call
+        */
+               function get_access_array($user_id = 0, $site_id = 0, $flush = false) {
+                       
+                       global $CONFIG, $init_finished;
+                       static $access_array, $acm, $ac; // Caches. $ac* flag whether we have executed a query previously, and stop it being run again if no data is returned.
+                       
+                       if (!isset($access_array) || (!isset($init_finished)) || (!$init_finished))
+                               $access_array = array(); 
+                               
+                       if ($user_id == 0) $user_id = get_loggedin_userid();
+                       
+                       if (($site_id == 0) && (isset($CONFIG->site_guid))) $site_id = $CONFIG->site_guid;
+                       $user_id = (int) $user_id;
+                       $site_id = (int) $site_id;
+                       
+                       if (empty($access_array[$user_id]) || $flush == true) {
+                               
+                               $query = "SELECT am.access_collection_id FROM {$CONFIG->dbprefix}access_collection_membership am ";
+                               $query .= " LEFT JOIN {$CONFIG->dbprefix}access_collections ag ON ag.id = am.access_collection_id ";
+                               $query .= " WHERE am.user_guid = {$user_id} AND (ag.site_guid = {$site_id} OR ag.site_guid = 0)";
+                               
+                               $tmp_access_array = array(ACCESS_PUBLIC); 
+                               if (isloggedin()) {
+                                       $tmp_access_array[] = ACCESS_LOGGED_IN;
+                                       
+                                       // The following can only return sensible data if the user is logged in.
+                                       
+                                       if ($collections = get_data($query)) {
+                                               foreach($collections as $collection)
+                                                       if (!empty($collection->access_collection_id)) $tmp_access_array[] = $collection->access_collection_id;
+                                                       
+                                       }
+                                               
+                                       $query = "SELECT ag.id FROM {$CONFIG->dbprefix}access_collections ag  ";
+                                       $query .= " WHERE ag.owner_guid = {$user_id} AND (ag.site_guid = {$site_id} OR ag.site_guid = 0)";
+                                       
+                                       if ($collections = get_data($query)) {
+                                               foreach($collections as $collection)
+                                                       if (!empty($collection->id)) $tmp_access_array[] = $collection->id;
+                                       }
+                                        
+                                       
+                                       global $is_admin;
+                                       
+                                       if (isset($is_admin) && $is_admin == true) {
+                                               $tmp_access_array[] = ACCESS_PRIVATE;
+                                       }
+
+                                       $access_array[$user_id] = $tmp_access_array;
+                               }
+                               else
+                                       $tmp_return = $tmp_access_array; // No user id logged in so we can only access public info
+                               
+                               
+                       } else {
+                               $tmp_access_array = $access_array[$user_id];
+                       }
+                       
+                       $tmp_return = $access_array[$user_id];
+                       
+                       return trigger_plugin_hook('access:collections:read','user',array('user_id' => $user_id, 'site_id' => $site_id),$tmp_access_array);
+               }
+               
+       /**
+        * Gets the default access permission for new content
+        *
+        * @return int default access id (see ACCESS defines in elgglib.php)  
+        */
+               function get_default_access($user=null)
+               {
+                       global $CONFIG;
+                       
+                       if (!$CONFIG->allow_user_default_access) {
+                               return $CONFIG->default_access;
+                       }
+                       
+                       if (!$user) {
+                               if (isloggedin()) {
+                                       $user = $_SESSION['user'];
+                               } else {
+                                       return $CONFIG->default_access;
+                               }
+                       }
+                       
+                       if (false !== ($default_access = $user->getPrivateSetting('elgg_default_access'))) {
+                               return $default_access;
+                       } else {                        
+                               return $CONFIG->default_access;
+                       }
+               }
+               
+               /**
+                * Override the default behaviour and allow results to show hidden entities as well.
+                * THIS IS A HACK.
+                * 
+                * TODO: Replace this with query object!
+                */
+               $ENTITY_SHOW_HIDDEN_OVERRIDE = false;
+               
+               /**
+                * This will be replaced. Do not use in plugins!
+                *
+                * @param bool $show
+                */
+               function access_show_hidden_entities($show_hidden)
+               {
+                       global $ENTITY_SHOW_HIDDEN_OVERRIDE;  
+                       $ENTITY_SHOW_HIDDEN_OVERRIDE = $show_hidden;  
+               }
+               
+               /**
+                * This will be replaced. Do not use in plugins!
+                */
+               function access_get_show_hidden_status()
+               {
+                       global $ENTITY_SHOW_HIDDEN_OVERRIDE;  
+                       return $ENTITY_SHOW_HIDDEN_OVERRIDE;
+               }
+               
+               /**
+                * Add annotation restriction
+                * 
+                * Returns an SQL fragment that is true (or optionally false) if the given user has 
+                * added an annotation with the given name to the given entity.
+                * 
+                * TODO: This is fairly generic so perhaps it could be moved to annotations.php
+                * 
+                * @param string $annotation_name name of the annotation
+                * @param string $entity_guid SQL string that evaluates to the GUID of the entity the annotation should be attached to
+                * @param string $owner_guid SQL string that evaluates to the GUID of the owner of the annotation                * 
+                * @param boolean $exists If set to true, will return true if the annotation exists, otherwise returns false
+                * @return string An SQL fragment suitable for inserting into a WHERE clause
+                */
+               
+               function get_annotation_sql($annotation_name,$entity_guid,$owner_guid,$exists) {
+                       global $CONFIG;
+                       
+                       if ($exists) {
+                               $not = '';
+                       } else {
+                               $not = 'NOT';
+                       }
+                       
+                       $sql = <<<END
+$not EXISTS (SELECT * FROM {$CONFIG->dbprefix}annotations a 
+INNER JOIN {$CONFIG->dbprefix}metastrings ms ON (a.name_id = ms.id)
+WHERE ms.string = '$annotation_name'
+AND a.entity_guid = $entity_guid
+AND a.owner_guid = $owner_guid)
+END;
+                       return $sql;
+               }
+               
+               /**
+                * Add access restriction sql code to a given query.
+                * 
+                * Note that if this code is executed in privileged mode it will return blank.
+                * 
+                * TODO: DELETE once Query classes are fully integrated
+                * 
+                * @param string $table_prefix Optional xxx. prefix for the access code.
+                */
+               function get_access_sql_suffix($table_prefix = "",$owner=null)
+               {
+                       global $ENTITY_SHOW_HIDDEN_OVERRIDE, $CONFIG;  
+                       
+                       $sql = "";
+                       $friends_bit = "";
+                       $enemies_bit = "";
+                       
+                       if ($table_prefix)
+                                       $table_prefix = sanitise_string($table_prefix) . ".";
+                       
+                       $access = get_access_list();
+                       
+                       if (!isset($owner)) {
+                               $owner = get_loggedin_userid();
+                       }
+                       if (!$owner) $owner = -1;
+                       
+                       global $is_admin;
+                       
+                       if (isset($is_admin) && $is_admin == true) {
+                               $sql = " (1 = 1) ";
+                       } else if ($owner != -1) {                              
+                               $friends_bit = $table_prefix.'access_id = '.ACCESS_FRIENDS.' AND ';
+                               $friends_bit .= "{$table_prefix}owner_guid IN (SELECT guid_one FROM {$CONFIG->dbprefix}entity_relationships WHERE relationship='friend' AND guid_two=$owner)";
+                               $friends_bit = '('.$friends_bit.') OR ';
+                               
+                               if ((isset($CONFIG->user_block_and_filter_enabled)) && ($CONFIG->user_block_and_filter_enabled)) {
+                                       // check to see if the user is in the entity owner's block list
+                                       // or if the entity owner is in the user's filter list
+                                       // if so, disallow access
+                                       
+                                       $enemies_bit = get_annotation_sql('elgg_block_list',"{$table_prefix}owner_guid",$owner,false);
+                                       $enemies_bit = '('.$enemies_bit. ' AND '.get_annotation_sql('elgg_filter_list',$owner,"{$table_prefix}owner_guid",false).')';
+                               }
+                       }
+
+                       if (empty($sql))
+                               $sql = " $friends_bit ({$table_prefix}access_id in {$access} or ({$table_prefix}owner_guid = {$owner}) or ({$table_prefix}access_id = " . ACCESS_PRIVATE . " and {$table_prefix}owner_guid = $owner))";
+                       
+                       if ($enemies_bit) {
+                               $sql = "$enemies_bit AND ($sql)";
+                       }
+                               
+                       if (!$ENTITY_SHOW_HIDDEN_OVERRIDE)
+                               $sql .= " and {$table_prefix}enabled='yes'";
+                       return '('.$sql.')';
+               }
+               
+               /**
+                * Determines whether the given user has access to the given entity
+                * 
+                * @param ElggEntity $entity The entity to check access for.
+                * @param ElggUser $user Optionally the user to check access for.
+                * 
+                * @return boolean True if the user can access the entity
+                */
+               
+               function has_access_to_entity($entity,$user = null) {
+                       global $CONFIG;
+                       
+                       if (!isset($user)) {
+                               $access_bit = get_access_sql_suffix("e");
+                       } else {
+                               $access_bit = get_access_sql_suffix("e",$user->getGUID());
+                       }
+                       
+                       $query = "SELECT guid from {$CONFIG->dbprefix}entities e WHERE e.guid = ".$entity->getGUID();
+                       $query .= " AND ".$access_bit; // Add access controls
+                       if (get_data($query)) {
+                               return true;
+                       } else {
+                               return false;
+                       }                       
+               }
+               
+               /**
+                * Returns an array of access permissions that the specified user is allowed to save objects with.
+                * Permissions are of the form ('id' => 'Description')
+                *
+                * @param int $user_id The user's GUID.
+                * @param int $site_id The current site.
+                * @param true|false $flush If this is set to true, this will shun any cached version
+                * @return array List of access permissions=
+                */
+               function get_write_access_array($user_id = 0, $site_id = 0, $flush = false) {
+                       
+                       global $CONFIG;
+                       static $access_array;
+                       
+                       if ($user_id == 0) $user_id = get_loggedin_userid();
+                       if (($site_id == 0) && (isset($CONFIG->site_id))) $site_id = $CONFIG->site_id;
+                       $user_id = (int) $user_id;
+                       $site_id = (int) $site_id;
+                       
+                       if (empty($access_array[$user_id]) || $flush == true) {
+                               
+                               $query = "SELECT ag.* FROM {$CONFIG->dbprefix}access_collections ag ";
+                               $query .= " WHERE (ag.site_guid = {$site_id} OR ag.site_guid = 0)";
+                               $query .= " AND (ag.owner_guid = {$user_id})";
+                               $query .= " AND ag.id >= 3";
+                               
+                               $tmp_access_array = array(0 => elgg_echo("PRIVATE"), ACCESS_FRIENDS => elgg_echo("access:friends:label"), 1 => elgg_echo("LOGGED_IN"), 2 => elgg_echo("PUBLIC"));
+                               if ($collections = get_data($query)) {
+                                       foreach($collections as $collection)
+                                               $tmp_access_array[$collection->id] = $collection->name;
+                               }
+                               
+                               $access_array[$user_id] = $tmp_access_array;
+                               
+                       } else {
+                               $tmp_access_array = $access_array[$user_id];
+                       }
+                       
+                       $tmp_access_array = trigger_plugin_hook('access:collections:write','user',array('user_id' => $user_id, 'site_id' => $site_id),$tmp_access_array);
+                       
+                       return $tmp_access_array;
+                       
+               }
+
+               /**
+                * Creates a new access control collection owned by the specified user.
+                *
+                * @param string $name The name of the collection.
+                * @param int $owner_guid The GUID of the owner (default: currently logged in user).
+                * @param int $site_guid The GUID of the site (default: current site).
+                * @return int|false Depending on success (the collection ID if successful).
+                */
+               function create_access_collection($name, $owner_guid = 0, $site_guid = 0) {
+                       
+                       global $CONFIG;
+                       
+                       $name = trim($name);
+                       if (empty($name)) return false;
+                       
+                       if ($owner_guid == 0) $owner_guid = get_loggedin_userid();
+                       if (($site_id == 0) && (isset($CONFIG->site_guid))) $site_id = $CONFIG->site_guid;
+                       $name = sanitise_string($name);
+                       
+                       return insert_data("insert into {$CONFIG->dbprefix}access_collections set name = '{$name}', owner_guid = {$owner_guid}, site_guid = {$site_id}");
+                       
+               }
+               
+               /**
+                * Updates the membership in an access collection.
+                *
+                * @param int $collection_id The ID of the collection.
+                * @param array $members Array of member GUIDs
+                * @return true|false Depending on success
+                */
+               function update_access_collection($collection_id, $members) {
+                       
+                       global $CONFIG;
+                       $collection_id = (int) $collection_id;
+                       
+                       $collections = get_write_access_array();
+                       
+                       if (array_key_exists($collection_id, $collections)) {
+                       
+                               delete_data("delete from {$CONFIG->dbprefix}access_collection_membership where access_collection_id = {$collection_id}");
+                               
+                               if (is_array($members) && sizeof($members) > 0) {
+                                       foreach($members as $member) {
+                                               $member = (int) $member;
+                                               if (get_user($member))
+                                                       insert_data("insert into {$CONFIG->dbprefix}access_collection_membership set access_collection_id = {$collection_id}, user_guid = {$member}");
+                                       }
+                                       return true;
+                               }
+                       
+                       }
+                       
+                       return false;
+               }
+               
+               /**
+                * Deletes a specified access collection
+                *
+                * @param int $collection_id The collection ID
+                * @return true|false Depending on success
+                */
+               function delete_access_collection($collection_id) {
+                       
+                       $collection_id = (int) $collection_id;
+                       $collections = get_write_access_array();
+                       if (array_key_exists($collection_id, $collections)) {
+                               global $CONFIG;
+                               delete_data("delete from {$CONFIG->dbprefix}access_collection_membership where access_collection_id = {$collection_id}");
+                               delete_data("delete from {$CONFIG->dbprefix}access_collections where id = {$collection_id}");
+                               return true;
+                       } else {
+                               return false;
+                       }
+                       
+               }
+               
+               /**
+                * Get a specified access collection
+                *
+                * @param int $collection_id The collection ID
+                * @return array|false Depending on success
+                */
+               function get_access_collection($collection_id) {
+               
+               $collection_id = (int) $collection_id;
+               global $CONFIG;
+               $get_collection = get_data_row("SELECT * FROM {$CONFIG->dbprefix}access_collections WHERE id = {$collection_id}");
+               
+               return $get_collection;
+               
+               }
+               
+               /**
+                * Adds a user to the specified user collection
+                *
+                * @param int $user_guid The GUID of the user to add
+                * @param int $collection_id The ID of the collection to add them to
+                * @return true|false Depending on success
+                */
+               function add_user_to_access_collection($user_guid, $collection_id) {
+                       
+                       $collection_id = (int) $collection_id;
+                       $user_guid = (int) $user_guid;
+                       $collections = get_write_access_array();
+                       
+                       if (!($collection = get_access_collection($collection_id)))
+                               return false;
+                               
+                       if ((array_key_exists($collection_id, $collections) || $collection->owner_guid == 0)
+                                       && $user = get_user($user_guid)) {
+
+                               global $CONFIG;
+                               try {
+                                       insert_data("insert into {$CONFIG->dbprefix}access_collection_membership set access_collection_id = {$collection_id}, user_guid = {$user_guid}");
+                               } catch (DatabaseException $e) {}
+                               return true;
+                               
+                       }
+                       
+                       return false;
+                       
+               }
+
+               /**
+                * Removes a user from an access collection
+                *
+                * @param int $user_guid The user GUID
+                * @param int $collection_id The access collection ID
+                * @return true|false Depending on success
+                */
+               function remove_user_from_access_collection($user_guid, $collection_id) {
+                       
+                       $collection_id = (int) $collection_id;
+                       $user_guid = (int) $user_guid;
+                       $collections = get_write_access_array();
+                       
+                       if (!($collection = get_access_collection($collection_id)))
+                               return false;
+                       
+                       if ((array_key_exists($collection_id, $collections) || $collection->owner_guid == 0) && $user = get_user($user_guid)) {
+                               
+                               global $CONFIG;
+                               delete_data("delete from {$CONFIG->dbprefix}access_collection_membership where access_collection_id = {$collection_id} and user_guid = {$user_guid}");
+                               return true;
+                               
+                       }
+                       
+                       return false;
+                       
+               }
+               
+               /**
+                * Get all of a users collections
+                *
+                * @param int $owner_guid The user ID
+                * @return true|false Depending on success
+                */
+               function get_user_access_collections($owner_guid) {
+                       
+                       $owner_guid = (int) $owner_guid;
+                       
+                       global $CONFIG;
+                       
+                       $collections = get_data("SELECT * FROM {$CONFIG->dbprefix}access_collections WHERE owner_guid = {$owner_guid}");
+                       
+                       return $collections;
+                       
+               }
+               
+               /**
+                * Get all of members of a friend collection
+                *
+                * @param int $collection The collection's ID
+                * @param true|false $idonly If set to true, will only return the members' IDs (default: false)
+                * @return ElggUser entities if successful, false if not
+                */
+               function get_members_of_access_collection($collection, $idonly = false) {
+               
+               $collection = (int)$collection;
+               
+               global $CONFIG;
+               
+               if (!$idonly) {
+                       $query = "SELECT e.* FROM {$CONFIG->dbprefix}access_collection_membership m JOIN {$CONFIG->dbprefix}entities e ON e.guid = m.user_guid WHERE m.access_collection_id = {$collection}";       
+                               $collection_members = get_data($query, "entity_row_to_elggstar");
+               } else {
+                       $query = "SELECT e.guid FROM {$CONFIG->dbprefix}access_collection_membership m JOIN {$CONFIG->dbprefix}entities e ON e.guid = m.user_guid WHERE m.access_collection_id = {$collection}";
+                       $collection_members = get_data($query);
+                       foreach($collection_members as $key => $val)
+                               $collection_members[$key] = $val->guid;
+               }
+                       
+                       return $collection_members;
+                       
+               }
+               
+               /**
+                * Displays a user's access collections, using the friends/collections view
+                *
+                * @param int $owner_guid The GUID of the owning user
+                * @return string A formatted rendition of the collections
+                */
+               function elgg_view_access_collections($owner_guid) {
+                       
+                       if ($collections = get_user_access_collections($owner_guid)) {
+                               
+                               foreach($collections as $key => $collection) {
+                                       $collections[$key]->members = get_members_of_access_collection($collection->id, true);
+                                       $collections[$key]->entities = get_user_friends($owner_guid,"",9999);
+                               }
+                               
+                       }
+                       
+                       return elgg_view('friends/collections',array('collections' => $collections));
+                       
+               }
+               
+               /**
+                * Get entities with the specified access collection id.
+                * 
+                * @param $collection_id
+                * @param $entity_type
+                * @param $entity_subtype
+                * @param $owner_guid
+                * @param $limit
+                * @param $offset
+                * @param $order_by
+                * @param $site_guid
+                * @param $count
+                * @return unknown_type
+                */
+               function get_entities_from_access_collection($collection_id, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) {
+                       global $CONFIG;
+                       
+                       if (!$collection_id)
+                               return false;
+                               
+                       $entity_type = sanitise_string($entity_type);
+                       $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
+                       $limit = (int)$limit;
+                       $offset = (int)$offset;
+                       if ($order_by == "") 
+                               $order_by = "e.time_created desc";
+                       else
+                               $order_by = "e.time_created, {$order_by}";
+                       $order_by = sanitise_string($order_by);
+                       $site_guid = (int) $site_guid;
+                       if ((is_array($owner_guid) && (count($owner_guid)))) {
+                               foreach($owner_guid as $key => $guid) {
+                                       $owner_guid[$key] = (int) $guid;
+                               }
+                       } else {
+                               $owner_guid = (int) $owner_guid;
+                       }
+                       if ($site_guid == 0)
+                               $site_guid = $CONFIG->site_guid;
+                               
+                       //$access = get_access_list();
+                               
+                       $where = array("e.access_id = $collection_id");
+                       
+                       if ($entity_type!=="")
+                               $where[] = "e.type='$entity_type'";
+                       if ($entity_subtype)
+                               $where[] = "e.subtype=$entity_subtype";
+                       if ($site_guid > 0)
+                               $where[] = "e.site_guid = {$site_guid}";
+                       if (is_array($owner_guid)) {
+                               $where[] = "e.container_guid in (".implode(",",$owner_guid).")";
+                       } else if ($owner_guid > 0)
+                               $where[] = "e.container_guid = {$owner_guid}";
+                       
+                       if (!$count) {
+                               $query = "SELECT distinct e.* "; 
+                       } else {
+                               $query = "SELECT count(distinct e.guid) as total ";
+                       }
+                               
+                       $query .= "from {$CONFIG->dbprefix}entities e where";
+                       foreach ($where as $w)
+                               $query .= " $w and ";
+                       $query .= get_access_sql_suffix("e"); // Add access controls
+                       //$query .= ' and ' . get_access_sql_suffix("m"); // Add access controls
+                       
+                       if (!$count) {
+                               $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
+                               return get_data($query, "entity_row_to_elggstar");
+                       } else {
+                               if ($row = get_data_row($query))
+                                       return $row->total;
+                       }
+                       return false;
+               }
+               
+               /**
+                * Lists entities from an access collection
+                * 
+                * @param $collection_id
+                * @param $entity_type
+                * @param $entity_subtype
+                * @param $owner_guid
+                * @param $limit
+                * @param $fullview
+                * @param $viewtypetoggle
+                * @param $pagination
+                * @return str
+                */
+               function list_entities_from_access_collection($collection_id, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = true, $pagination = true) {
+                       $offset = (int) get_input('offset');
+                       $limit = (int) $limit;
+                       $count = get_entities_from_access_collection($collection_id, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", 0, true);
+                       $entities = get_entities_from_access_collection($collection_id, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", 0, false);
+                       
+                       return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);
+               }
+               
+               global $init_finished;
+               $init_finished = false;
+               
+       /**
+        * A quick and dirty way to make sure the access permissions have been correctly set up
+        *
+        */
+               function access_init() {
+                       global $init_finished;
+                       $init_finished = true;
+               }
+               
+       // This function will let us know when 'init' has finished
+               register_elgg_event_handler('init','system','access_init',9999);
+               
 ?>
\ No newline at end of file
index 2528f2d3cf0106f2aefbf6fca8b8afef05d9d530..10374e386e2dad40c36141a52336238c2e85e993 100644 (file)
-<?php\r
-       /**\r
-        * Elgg activity stream.\r
-        * Functions for listening for and generating the rich activity stream from the \r
-        * system log.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Elgg activity stream.
+        * Functions for listening for and generating the rich activity stream from the 
+        * system log.
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /**\r
-        * Construct and execute the query required for the activity stream.\r
-        *\r
-        * @param int $limit Limit the query.\r
-        * @param int $offset Execute from the given object\r
-        * @param mixed $type A type, or array of types to look for. Note: This is how they appear in the SYSTEM LOG.\r
-        * @param mixed $subtype A subtype, or array of types to look for. Note: This is how they appear in the SYSTEM LOG.\r
-        * @param mixed $owner_guid The guid or a collection of GUIDs\r
-        * @param string $owner_relationship If defined, the relationship between $owner_guid and the entity owner_guid - so "is $owner_guid $owner_relationship with $entity->owner_guid"\r
-        * @return array An array of system log entries.\r
-        */\r
-       function get_activity_stream_data($limit = 10, $offset = 0, $type = "", $subtype = "", $owner_guid = "", $owner_relationship = "")\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $limit = (int)$limit;\r
-               $offset = (int)$offset;\r
-       \r
-               if ($type) {\r
-                       if (!is_array($type))\r
-                               $type = array(sanitise_string($type));\r
-                       else\r
-                               foreach ($type as $k => $v)\r
-                                       $type[$k] = sanitise_string($v);\r
-               }\r
-               \r
-               if ($subtype) {\r
-                       if (!is_array($subtype))\r
-                               $subtype = array(sanitise_string($subtype));\r
-                       else\r
-                               foreach ($subtype as $k => $v)\r
-                                       $subtype[$k] = sanitise_string($v);\r
-               }\r
-               \r
-               if ($owner_guid) {\r
-                       if (is_array($owner_guid))\r
-                               foreach ($owner_guid as $k => $v)\r
-                                       $owner_guid[$k] = (int)$v;\r
-                       else\r
-                               $owner_guid = array((int)$owner_guid);\r
-               }\r
-                       \r
-               $owner_relationship = sanitise_string($owner_relationship);\r
-               \r
-               // Get a list of possible views\r
-               $activity_events= array(); \r
-               $activity_views = array_merge(elgg_view_tree('activity', 'default'), elgg_view_tree('river', 'default')); // Join activity with river\r
-\r
-               $done = array();\r
-                       \r
-               foreach ($activity_views as $view)\r
-               {\r
-                       $fragments = explode('/', $view);\r
-                       $tmp = explode('/',$view, 2);\r
-                       $tmp = $tmp[1];\r
-                       \r
-                       if ((isset($fragments[0])) && (($fragments[0] == 'river') || ($fragments[0] == 'activity')) \r
-                               && (!in_array($tmp, $done)))\r
-                       {\r
-                               if (isset($fragments[1]))\r
-                               {\r
-                                       $f = array();\r
-                                       for ($n = 1; $n < count($fragments); $n++)\r
-                                       {\r
-                                               $val = sanitise_string($fragments[$n]);\r
-                                               switch($n)\r
-                                               {\r
-                                                       case 1: $key = 'type'; break;\r
-                                                       case 2: $key = 'subtype'; break;\r
-                                                       case 3: $key = 'event'; break;\r
-                                               }\r
-                                               $f[$key] = $val;\r
-                                       }\r
-                                       \r
-                                       // Filter result based on parameters\r
-                                       $add = true;\r
-                                       if ($type) {\r
-                                               if (!in_array($f['type'], $type)) $add = false;\r
-                                       }\r
-                                       if (($add) && ($subtype)) {\r
-                                               if (!in_array($f['subtype'], $subtype)) $add = false;\r
-                                       }\r
-                                       if (($add) && ($event)) {\r
-                                               if (!in_array($f['event'], $event)) $add = false;\r
-                                       }\r
-                                       \r
-                                       if ($add)\r
-                                               $activity_events[] = $f;\r
-                               }\r
-                               \r
-                               $done[] = $tmp; \r
-                       }\r
-                       \r
-                       \r
-               }\r
-\r
-               $n = 0;\r
-               foreach ($activity_events as $details)\r
-               {\r
-                       // Get what we're talking about\r
-               \r
-                       if ($details['subtype'] == 'default') $details['subtype'] = '';\r
-                       \r
-                       if (($details['type']) && ($details['event'])) {\r
-                               if ($n>0) $obj_query .= " or ";\r
-                               \r
-                               $access = "";\r
-                               if ($details['type']!='relationship')\r
-                                       $access = " and " . get_access_sql_suffix('sl');\r
-                                \r
-                               $obj_query .= "( sl.object_type='{$details['type']}' and sl.object_subtype='{$details['subtype']}' and sl.event='{$details['event']}' $access )";\r
-                               \r
-                               $n++;\r
-                       }\r
-               \r
-               }               \r
-       \r
-               // User\r
-               if ((count($owner_guid)) &&  ($owner_guid[0]!=0)) {\r
-                       $user = " and sl.performed_by_guid in (".implode(',', $owner_guid).")";\r
-                       \r
-                       if ($owner_relationship)\r
-                       {\r
-                               $friendsarray = "";\r
-                               if ($friends = get_entities_from_relationship($owner_relationship,$owner_guid[0],false,"user",$subtype,0,"time_created desc",9999)) {\r
-                                       $friendsarray = array();\r
-                                       foreach($friends as $friend) {\r
-                                               $friendsarray[] = $friend->getGUID();\r
-                                       }\r
-                                       \r
-                                       $user = " and sl.performed_by_guid in (".implode(',', $friendsarray).")";\r
-                               }\r
-                               \r
-                       }\r
-               }\r
-               \r
-               $query = "SELECT sl.* from {$CONFIG->dbprefix}system_log sl  where 1 $user and ($obj_query) order by sl.time_created desc  limit $offset, $limit";\r
-               return get_data($query);\r
-       }\r
+        * @link http://elgg.org/
+        */
+
+       /**
+        * Construct and execute the query required for the activity stream.
+        *
+        * @param int $limit Limit the query.
+        * @param int $offset Execute from the given object
+        * @param mixed $type A type, or array of types to look for. Note: This is how they appear in the SYSTEM LOG.
+        * @param mixed $subtype A subtype, or array of types to look for. Note: This is how they appear in the SYSTEM LOG.
+        * @param mixed $owner_guid The guid or a collection of GUIDs
+        * @param string $owner_relationship If defined, the relationship between $owner_guid and the entity owner_guid - so "is $owner_guid $owner_relationship with $entity->owner_guid"
+        * @return array An array of system log entries.
+        */
+       function get_activity_stream_data($limit = 10, $offset = 0, $type = "", $subtype = "", $owner_guid = "", $owner_relationship = "")
+       {
+               global $CONFIG;
+               
+               $limit = (int)$limit;
+               $offset = (int)$offset;
+       
+               if ($type) {
+                       if (!is_array($type))
+                               $type = array(sanitise_string($type));
+                       else
+                               foreach ($type as $k => $v)
+                                       $type[$k] = sanitise_string($v);
+               }
+               
+               if ($subtype) {
+                       if (!is_array($subtype))
+                               $subtype = array(sanitise_string($subtype));
+                       else
+                               foreach ($subtype as $k => $v)
+                                       $subtype[$k] = sanitise_string($v);
+               }
+               
+               if ($owner_guid) {
+                       if (is_array($owner_guid))
+                               foreach ($owner_guid as $k => $v)
+                                       $owner_guid[$k] = (int)$v;
+                       else
+                               $owner_guid = array((int)$owner_guid);
+               }
+                       
+               $owner_relationship = sanitise_string($owner_relationship);
+               
+               // Get a list of possible views
+               $activity_events= array(); 
+               $activity_views = array_merge(elgg_view_tree('activity', 'default'), elgg_view_tree('river', 'default')); // Join activity with river
+
+               $done = array();
+                       
+               foreach ($activity_views as $view)
+               {
+                       $fragments = explode('/', $view);
+                       $tmp = explode('/',$view, 2);
+                       $tmp = $tmp[1];
+                       
+                       if ((isset($fragments[0])) && (($fragments[0] == 'river') || ($fragments[0] == 'activity')) 
+                               && (!in_array($tmp, $done)))
+                       {
+                               if (isset($fragments[1]))
+                               {
+                                       $f = array();
+                                       for ($n = 1; $n < count($fragments); $n++)
+                                       {
+                                               $val = sanitise_string($fragments[$n]);
+                                               switch($n)
+                                               {
+                                                       case 1: $key = 'type'; break;
+                                                       case 2: $key = 'subtype'; break;
+                                                       case 3: $key = 'event'; break;
+                                               }
+                                               $f[$key] = $val;
+                                       }
+                                       
+                                       // Filter result based on parameters
+                                       $add = true;
+                                       if ($type) {
+                                               if (!in_array($f['type'], $type)) $add = false;
+                                       }
+                                       if (($add) && ($subtype)) {
+                                               if (!in_array($f['subtype'], $subtype)) $add = false;
+                                       }
+                                       if (($add) && ($event)) {
+                                               if (!in_array($f['event'], $event)) $add = false;
+                                       }
+                                       
+                                       if ($add)
+                                               $activity_events[] = $f;
+                               }
+                               
+                               $done[] = $tmp; 
+                       }
+                       
+                       
+               }
+
+               $n = 0;
+               foreach ($activity_events as $details)
+               {
+                       // Get what we're talking about
+               
+                       if ($details['subtype'] == 'default') $details['subtype'] = '';
+                       
+                       if (($details['type']) && ($details['event'])) {
+                               if ($n>0) $obj_query .= " or ";
+                               
+                               $access = "";
+                               if ($details['type']!='relationship')
+                                       $access = " and " . get_access_sql_suffix('sl');
+                                
+                               $obj_query .= "( sl.object_type='{$details['type']}' and sl.object_subtype='{$details['subtype']}' and sl.event='{$details['event']}' $access )";
+                               
+                               $n++;
+                       }
+               
+               }               
+       
+               // User
+               if ((count($owner_guid)) &&  ($owner_guid[0]!=0)) {
+                       $user = " and sl.performed_by_guid in (".implode(',', $owner_guid).")";
+                       
+                       if ($owner_relationship)
+                       {
+                               $friendsarray = "";
+                               if ($friends = get_entities_from_relationship($owner_relationship,$owner_guid[0],false,"user",$subtype,0,"time_created desc",9999)) {
+                                       $friendsarray = array();
+                                       foreach($friends as $friend) {
+                                               $friendsarray[] = $friend->getGUID();
+                                       }
+                                       
+                                       $user = " and sl.performed_by_guid in (".implode(',', $friendsarray).")";
+                               }
+                               
+                       }
+               }
+               
+               $query = "SELECT sl.* from {$CONFIG->dbprefix}system_log sl  where 1 $user and ($obj_query) order by sl.time_created desc  limit $offset, $limit";
+               return get_data($query);
+       }
 ?>
\ No newline at end of file
index a8272dc83223bab78e7d86b0178b9e03da9a277b..f09167bfacad6a46eea321100bab2b01f1050da3 100644 (file)
-<?php\r
-       /**\r
-        * Elgg admin functions.\r
-        * Functions for adding and manipulating options on the admin panel.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Elgg admin functions.
+        * Functions for adding and manipulating options on the admin panel.
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd \r
+        * @author Curverider Ltd 
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       \r
-       /**\r
-        * Register an admin page with the admin panel.\r
-        * This function extends the view "admin/main" with the provided view. This view should provide a description\r
-        * and either a control or a link to.\r
-        * \r
-        * Usage:\r
-        *      - To add a control to the main admin panel then extend admin/main\r
-        *  - To add a control to a new page create a page which renders a view admin/subpage (where subpage is your new page - \r
-        *    nb. some pages already exist that you can extend), extend the main view to point to it, and add controls to your \r
-        *        new view.\r
-        * \r
-        * At the moment this is essentially a wrapper around extend_view.\r
-        * \r
-        * @param string $new_admin_view The view associated with the control you're adding  \r
-        * @param string $view The view to extend, by default this is 'admin/main'.\r
-        * @param int $priority Optional priority to govern the appearance in the list.\r
-        */\r
-       function extend_elgg_admin_page( $new_admin_view, $view = 'admin/main', $priority = 500)\r
-       {\r
-               return extend_view($view, $new_admin_view, $priority);\r
-       }\r
-       \r
-       /**\r
-        * Initialise the admin page.\r
-        */\r
-       function admin_init()\r
-       {\r
-               // Add plugin main menu option (last)\r
-               extend_elgg_admin_page('admin/main_opt/statistics', 'admin/main');\r
-               extend_elgg_admin_page('admin/main_opt/site', 'admin/main'); \r
-               extend_elgg_admin_page('admin/main_opt/user', 'admin/main'); \r
-               extend_elgg_admin_page('admin/main_opt/plugins', 'admin/main', 999); // Always last\r
-\r
-               register_action('admin/user/ban', false, "", true);\r
-               register_action('admin/user/unban', false, "", true);\r
-               register_action('admin/user/delete', false, "", true);\r
-               register_action('admin/user/resetpassword', false, "", true);\r
+        * @link http://elgg.org/
+        */
+
+       
+       /**
+        * Register an admin page with the admin panel.
+        * This function extends the view "admin/main" with the provided view. This view should provide a description
+        * and either a control or a link to.
+        * 
+        * Usage:
+        *      - To add a control to the main admin panel then extend admin/main
+        *  - To add a control to a new page create a page which renders a view admin/subpage (where subpage is your new page - 
+        *    nb. some pages already exist that you can extend), extend the main view to point to it, and add controls to your 
+        *        new view.
+        * 
+        * At the moment this is essentially a wrapper around extend_view.
+        * 
+        * @param string $new_admin_view The view associated with the control you're adding  
+        * @param string $view The view to extend, by default this is 'admin/main'.
+        * @param int $priority Optional priority to govern the appearance in the list.
+        */
+       function extend_elgg_admin_page( $new_admin_view, $view = 'admin/main', $priority = 500)
+       {
+               return extend_view($view, $new_admin_view, $priority);
+       }
+       
+       /**
+        * Initialise the admin page.
+        */
+       function admin_init()
+       {
+               // Add plugin main menu option (last)
+               extend_elgg_admin_page('admin/main_opt/statistics', 'admin/main');
+               extend_elgg_admin_page('admin/main_opt/site', 'admin/main'); 
+               extend_elgg_admin_page('admin/main_opt/user', 'admin/main'); 
+               extend_elgg_admin_page('admin/main_opt/plugins', 'admin/main', 999); // Always last
+
+               register_action('admin/user/ban', false, "", true);
+               register_action('admin/user/unban', false, "", true);
+               register_action('admin/user/delete', false, "", true);
+               register_action('admin/user/resetpassword', false, "", true);
                register_action('admin/user/makeadmin', false, "", true);
-               register_action('admin/user/removeadmin', false, "", true);\r
-               \r
-               // Register some actions\r
-               register_action('admin/site/update_basic', false, "", true); // Register basic site admin action\r
-               \r
-               // Page handler\r
-               register_page_handler('admin','admin_settings_page_handler');\r
-               \r
-               if (isadminloggedin()) {\r
-                       global $is_admin;\r
-                       $is_admin = true;\r
-               }\r
-               \r
-       }\r
-       \r
-       function admin_pagesetup() {\r
-               \r
-               if (get_context() == 'admin') {\r
-                       \r
-                       global $CONFIG;\r
-                       add_submenu_item(elgg_echo('admin:statistics'), $CONFIG->wwwroot . 'pg/admin/statistics/');\r
-                       add_submenu_item(elgg_echo('admin:site'), $CONFIG->wwwroot . 'pg/admin/site/');\r
-                       add_submenu_item(elgg_echo('admin:user'), $CONFIG->wwwroot . 'pg/admin/user/');\r
-                       add_submenu_item(elgg_echo('admin:plugins'), $CONFIG->wwwroot . 'pg/admin/plugins/');\r
-                       \r
-               }\r
-               \r
-       }\r
-       \r
-       function admin_settings_page_handler($page)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $path = $CONFIG->path . "admin/index.php";\r
-               \r
-               if ($page[0])\r
-               {\r
-                       switch ($page[0])\r
-                       {\r
-                               case 'user' : $path = $CONFIG->path . "admin/user.php"; break;\r
-                               case 'statistics' : $path = $CONFIG->path . "admin/statistics.php"; break;\r
-                               case 'plugins' : $path = $CONFIG->path . "admin/plugins.php"; break;\r
-                               case 'site' : $path = $CONFIG->path . "admin/site.php"; break;\r
-                       }\r
-               }\r
-               \r
-               if ($page[1])\r
-                       set_input('username', $page[1]);\r
-                       \r
-               include($path);\r
-       }\r
-       \r
-\r
-       /**\r
-        * Admin permissions system\r
-        *\r
-        * @return true|null True if the current user is an admin.\r
-        */\r
-       function admin_permissions($hook, $type, $returnval, $params) {\r
-               \r
-               if (is_array($params) && !empty($params['user']) && $params['user'] instanceof ElggUser) {\r
-                       $admin = $params['user']->admin;\r
-                       if ($admin) {\r
-                               return true;\r
-                       }\r
-               }\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Write a persistent message to the administrator's notification window.\r
-        * \r
-        * Currently this writes a message to the admin store, we may want to come up with another way at some point.\r
-        *\r
-        * @param string $subject Subject of the message\r
-        * @param string $message Body of the message\r
-        */\r
-       function send_admin_message($subject, $message)\r
-       {\r
-               $subject = sanitise_string($subject);\r
-               $message = sanitise_string($message);\r
-               \r
-               if (($subject) && ($message))\r
-               {\r
-                       $admin_message = new ElggObject();\r
-                       $admin_message->subtype = 'admin_message';\r
-                       $admin_message->access_id = ACCESS_PUBLIC;\r
-                       $admin_message->title = $subject;\r
-                       $admin_message->description = $message;\r
-                       \r
-                       return $admin_message->save();\r
-               }\r
-               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * List all admin messages.\r
-        *\r
-        * @param int $limit Limit\r
-        */\r
-       function list_admin_messages($limit = 10)\r
-       {\r
-               return list_entities('object','admin_message',0,$limit);\r
-       }\r
-       \r
-       /**\r
-        * Remove an admin message.\r
-        *\r
-        * @param int $guid The \r
-        */\r
-       function clear_admin_message($guid)\r
-       {\r
-               return delete_entity($guid);\r
-       }\r
-       \r
-       /// Register init functions\r
-       register_elgg_event_handler('init','system','admin_init');\r
-       register_elgg_event_handler('pagesetup','system','admin_pagesetup');\r
-       \r
-       // Register a plugin hook for permissions\r
-       register_plugin_hook('permissions_check','all','admin_permissions');\r
-       register_plugin_hook('container_permissions_check','all','admin_permissions');\r
-       \r
-?>\r
+               register_action('admin/user/removeadmin', false, "", true);
+               
+               // Register some actions
+               register_action('admin/site/update_basic', false, "", true); // Register basic site admin action
+               
+               // Page handler
+               register_page_handler('admin','admin_settings_page_handler');
+               
+               if (isadminloggedin()) {
+                       global $is_admin;
+                       $is_admin = true;
+               }
+               
+       }
+       
+       function admin_pagesetup() {
+               
+               if (get_context() == 'admin') {
+                       
+                       global $CONFIG;
+                       add_submenu_item(elgg_echo('admin:statistics'), $CONFIG->wwwroot . 'pg/admin/statistics/');
+                       add_submenu_item(elgg_echo('admin:site'), $CONFIG->wwwroot . 'pg/admin/site/');
+                       add_submenu_item(elgg_echo('admin:user'), $CONFIG->wwwroot . 'pg/admin/user/');
+                       add_submenu_item(elgg_echo('admin:plugins'), $CONFIG->wwwroot . 'pg/admin/plugins/');
+                       
+               }
+               
+       }
+       
+       function admin_settings_page_handler($page)
+       {
+               global $CONFIG;
+               
+               $path = $CONFIG->path . "admin/index.php";
+               
+               if ($page[0])
+               {
+                       switch ($page[0])
+                       {
+                               case 'user' : $path = $CONFIG->path . "admin/user.php"; break;
+                               case 'statistics' : $path = $CONFIG->path . "admin/statistics.php"; break;
+                               case 'plugins' : $path = $CONFIG->path . "admin/plugins.php"; break;
+                               case 'site' : $path = $CONFIG->path . "admin/site.php"; break;
+                       }
+               }
+               
+               if ($page[1])
+                       set_input('username', $page[1]);
+                       
+               include($path);
+       }
+       
+
+       /**
+        * Admin permissions system
+        *
+        * @return true|null True if the current user is an admin.
+        */
+       function admin_permissions($hook, $type, $returnval, $params) {
+               
+               if (is_array($params) && !empty($params['user']) && $params['user'] instanceof ElggUser) {
+                       $admin = $params['user']->admin;
+                       if ($admin) {
+                               return true;
+                       }
+               }
+               
+       }
+       
+       /**
+        * Write a persistent message to the administrator's notification window.
+        * 
+        * Currently this writes a message to the admin store, we may want to come up with another way at some point.
+        *
+        * @param string $subject Subject of the message
+        * @param string $message Body of the message
+        */
+       function send_admin_message($subject, $message)
+       {
+               $subject = sanitise_string($subject);
+               $message = sanitise_string($message);
+               
+               if (($subject) && ($message))
+               {
+                       $admin_message = new ElggObject();
+                       $admin_message->subtype = 'admin_message';
+                       $admin_message->access_id = ACCESS_PUBLIC;
+                       $admin_message->title = $subject;
+                       $admin_message->description = $message;
+                       
+                       return $admin_message->save();
+               }
+               
+               return false;
+       }
+       
+       /**
+        * List all admin messages.
+        *
+        * @param int $limit Limit
+        */
+       function list_admin_messages($limit = 10)
+       {
+               return list_entities('object','admin_message',0,$limit);
+       }
+       
+       /**
+        * Remove an admin message.
+        *
+        * @param int $guid The 
+        */
+       function clear_admin_message($guid)
+       {
+               return delete_entity($guid);
+       }
+       
+       /// Register init functions
+       register_elgg_event_handler('init','system','admin_init');
+       register_elgg_event_handler('pagesetup','system','admin_pagesetup');
+       
+       // Register a plugin hook for permissions
+       register_plugin_hook('permissions_check','all','admin_permissions');
+       register_plugin_hook('container_permissions_check','all','admin_permissions');
+       
+?>
index a8e8549fc8f3d2d12f53a025471d8524080f563c..3f5cd198f3cd35ed5b191edcbc9854d969839225 100644 (file)
                /**
                 * Clean out old stuff.
                 *
-                */\r
+                */
                public function __destruct()
                {
                        global $CONFIG;
                        $expires = $time-$age;
                        
                        delete_data("DELETE from {$CONFIG->dbprefix}hmac_cache where ts<$expires");
-               }\r
+               }
        }
 
        // API Call functions /////////////////////////////////////////////////////////////////////     
index 0317c821cff06ba5a70a039bd032511cb4a03100..9aa5d21747735b9c1c2869614c38fae758593798 100644 (file)
@@ -1,17 +1,17 @@
-<?php\r
-\r
-       /**\r
-        * Elgg configuration library\r
-        * Contains functions for managing system configuration\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg configuration library
+        * Contains functions for managing system configuration
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
 
-        * @link http://elgg.org/\r
-        */\r
-\r
        
        /**
         * Unset a config option.
                                
                        return delete_data("delete from {$CONFIG->dbprefix}config where name='$name' and site_guid=$site_guid");
                }
-\r
-       /**\r
-        * Sets a configuration value\r
-        *\r
-        * @param string $name The name of the configuration value\r
-        * @param string $value Its value\r
-        * @param int $site_guid Optionally, the GUID of the site (current site is assumed by default)\r
-        * @return false|int 1 or false depending on success or failure \r
-        */\r
-               function set_config($name, $value, $site_guid = 0) {\r
-                       \r
+
+       /**
+        * Sets a configuration value
+        *
+        * @param string $name The name of the configuration value
+        * @param string $value Its value
+        * @param int $site_guid Optionally, the GUID of the site (current site is assumed by default)
+        * @return false|int 1 or false depending on success or failure 
+        */
+               function set_config($name, $value, $site_guid = 0) {
+                       
                        global $CONFIG;
                        
                        // Unset existing
                        unset_config($name,$site_guid);
-                       \r
-                       $name = mysql_real_escape_string($name);\r
-                       $value = mysql_real_escape_string($value);\r
-                       $site_guid = (int) $site_guid;\r
-                       if ($site_guid == 0)\r
-                               $site_guid = (int) $CONFIG->site_id;\r
-                       $CONFIG->$name = $value;\r
+                       
+                       $name = mysql_real_escape_string($name);
+                       $value = mysql_real_escape_string($value);
+                       $site_guid = (int) $site_guid;
+                       if ($site_guid == 0)
+                               $site_guid = (int) $CONFIG->site_id;
+                       $CONFIG->$name = $value;
                        $value = sanitise_string(serialize($value));
-                       \r
-                       return insert_data("insert into {$CONFIG->dbprefix}config set name = '{$name}', value = '{$value}', site_guid = {$site_guid}");\r
-                       \r
-               }\r
-\r
-       /**\r
-        * Gets a configuration value\r
-        *\r
-        * @param string $name The name of the config value\r
-        * @param int $site_guid Optionally, the GUID of the site (current site is assumed by default)\r
-        * @return mixed|false Depending on success\r
-        */\r
-               function get_config($name, $site_guid = 0) {\r
-                       \r
-                       global $CONFIG;\r
-                       if (isset($CONFIG->$name))\r
-                               return $CONFIG->$name;\r
-                       $name = mysql_real_escape_string($name);\r
-                       $site_guid = (int) $site_guid;\r
-                       if ($site_guid == 0)\r
-                               $site_guid = (int) $CONFIG->site_id;\r
-                       if ($result = get_data_row("SELECT value from {$CONFIG->dbprefix}config where name = '{$name}' and site_guid = {$site_guid}")) {\r
-                               $result = $result->value;\r
-                               $result = unserialize($result->value);\r
-                               $CONFIG->$name = $result;\r
-                               return $result;\r
-                       }\r
-                       return false;\r
-                       \r
+                       
+                       return insert_data("insert into {$CONFIG->dbprefix}config set name = '{$name}', value = '{$value}', site_guid = {$site_guid}");
+                       
+               }
+
+       /**
+        * Gets a configuration value
+        *
+        * @param string $name The name of the config value
+        * @param int $site_guid Optionally, the GUID of the site (current site is assumed by default)
+        * @return mixed|false Depending on success
+        */
+               function get_config($name, $site_guid = 0) {
+                       
+                       global $CONFIG;
+                       if (isset($CONFIG->$name))
+                               return $CONFIG->$name;
+                       $name = mysql_real_escape_string($name);
+                       $site_guid = (int) $site_guid;
+                       if ($site_guid == 0)
+                               $site_guid = (int) $CONFIG->site_id;
+                       if ($result = get_data_row("SELECT value from {$CONFIG->dbprefix}config where name = '{$name}' and site_guid = {$site_guid}")) {
+                               $result = $result->value;
+                               $result = unserialize($result->value);
+                               $CONFIG->$name = $result;
+                               return $result;
+                       }
+                       return false;
+                       
                }
                
                /**
                                return true;
                        }
                        return false;
-               }\r
-\r
-       /**\r
-        * If certain configuration elements don't exist, autodetect sensible defaults \r
-        * \r
-        * @uses $CONFIG The main configuration global\r
-        *\r
-        */\r
-               function set_default_config() {\r
-                       \r
-                       global $CONFIG;\r
-                       if (empty($CONFIG->path))\r
-                               $CONFIG->path = str_replace("\\","/",dirname(dirname(dirname(__FILE__)))) . "/";\r
-                               \r
-                       if (empty($CONFIG->viewpath))\r
-                               $CONFIG->viewpath = $CONFIG->path . "views/";   \r
-\r
-                       if (empty($CONFIG->pluginspath))\r
-                               $CONFIG->pluginspath = $CONFIG->path . "mod/";\r
-                               \r
-                       if (empty($CONFIG->wwwroot)) {\r
-                               /*\r
+               }
+
+       /**
+        * If certain configuration elements don't exist, autodetect sensible defaults 
+        * 
+        * @uses $CONFIG The main configuration global
+        *
+        */
+               function set_default_config() {
+                       
+                       global $CONFIG;
+                       if (empty($CONFIG->path))
+                               $CONFIG->path = str_replace("\\","/",dirname(dirname(dirname(__FILE__)))) . "/";
+                               
+                       if (empty($CONFIG->viewpath))
+                               $CONFIG->viewpath = $CONFIG->path . "views/";   
+
+                       if (empty($CONFIG->pluginspath))
+                               $CONFIG->pluginspath = $CONFIG->path . "mod/";
+                               
+                       if (empty($CONFIG->wwwroot)) {
+                               /*
                                $CONFIG->wwwroot = "http://" . $_SERVER['SERVER_NAME'];
                                
                                $request = $_SERVER['REQUEST_URI'];
                                }
                                
                                $CONFIG->wwwroot .= $request;
-                               */\r
-                               $pathpart = str_replace("//","/",str_replace($_SERVER['DOCUMENT_ROOT'],"",$CONFIG->path));\r
-                               if (substr($pathpart,0,1) != "/") $pathpart = "/" . $pathpart; \r
+                               */
+                               $pathpart = str_replace("//","/",str_replace($_SERVER['DOCUMENT_ROOT'],"",$CONFIG->path));
+                               if (substr($pathpart,0,1) != "/") $pathpart = "/" . $pathpart; 
                                $CONFIG->wwwroot = "http://" . $_SERVER['HTTP_HOST'] . $pathpart;
-               \r
-                       }\r
-               \r
-                       if (empty($CONFIG->url))\r
-                               $CONFIG->url = $CONFIG->wwwroot;\r
-                       \r
-                       if (empty($CONFIG->sitename))\r
-                               $CONFIG->sitename = "New Elgg site";\r
+               
+                       }
+               
+                       if (empty($CONFIG->url))
+                               $CONFIG->url = $CONFIG->wwwroot;
+                       
+                       if (empty($CONFIG->sitename))
+                               $CONFIG->sitename = "New Elgg site";
                                
                        if (empty($CONFIG->language))
                                $CONFIG->language = "en";
-\r
-               }\r
-               \r
-       /**\r
-        * Function that provides some config initialisation on system init\r
-        *\r
-        */\r
-               \r
-               function configuration_init() {\r
-                       \r
-                       global $CONFIG;\r
-                       \r
+
+               }
+               
+       /**
+        * Function that provides some config initialisation on system init
+        *
+        */
+               
+               function configuration_init() {
+                       
+                       global $CONFIG;
+                       
                        if (is_installed() || is_db_installed()) {
-                               \r
-                               $path = datalist_get('path');\r
-                               if (!empty($path))\r
-                                       $CONFIG->path = $path;\r
-                               $dataroot = datalist_get('dataroot');\r
-                               if (!empty($dataroot))\r
-                                       $CONFIG->dataroot = $dataroot;\r
-                               $simplecache_enabled = datalist_get('simplecache_enabled');\r
-                               if ($simplecache_enabled !== false) {\r
-                                       $CONFIG->simplecache_enabled = $simplecache_enabled;\r
-                               } else {\r
-                                       $CONFIG->simplecache_enabled = 1;\r
+                               
+                               $path = datalist_get('path');
+                               if (!empty($path))
+                                       $CONFIG->path = $path;
+                               $dataroot = datalist_get('dataroot');
+                               if (!empty($dataroot))
+                                       $CONFIG->dataroot = $dataroot;
+                               $simplecache_enabled = datalist_get('simplecache_enabled');
+                               if ($simplecache_enabled !== false) {
+                                       $CONFIG->simplecache_enabled = $simplecache_enabled;
+                               } else {
+                                       $CONFIG->simplecache_enabled = 1;
                                }
                                $viewpath_cache_enabled = datalist_get('viewpath_cache_enabled');
                                if ($viewpath_cache_enabled !== false) {
                                        $CONFIG->viewpath_cache_enabled = $viewpath_cache_enabled;
                                } else {
                                        $CONFIG->viewpath_cache_enabled = 1;
-                               }\r
-                               if (isset($CONFIG->site) && ($CONFIG->site instanceof ElggSite)) {\r
-                                       $CONFIG->wwwroot = $CONFIG->site->url;\r
+                               }
+                               if (isset($CONFIG->site) && ($CONFIG->site instanceof ElggSite)) {
+                                       $CONFIG->wwwroot = $CONFIG->site->url;
                                        $CONFIG->sitename = $CONFIG->site->name;
                                        $CONFIG->sitedescription = $CONFIG->site->description;
-                                       $CONFIG->siteemail = $CONFIG->site->email;\r
-                               }\r
-                               $CONFIG->url = $CONFIG->wwwroot;\r
+                                       $CONFIG->siteemail = $CONFIG->site->email;
+                               }
+                               $CONFIG->url = $CONFIG->wwwroot;
                                
                                // Load default settings from database
                                get_all_config();
-                               \r
-                               return true;\r
-                       }\r
-               }\r
-               \r
-       /**\r
-        * Register config_init\r
-        */\r
-\r
-               register_elgg_event_handler('boot','system','configuration_init',10);\r
-               \r
+                               
+                               return true;
+                       }
+               }
+               
+       /**
+        * Register config_init
+        */
+
+               register_elgg_event_handler('boot','system','configuration_init',10);
+               
 ?>
\ No newline at end of file
index 8b154eefeb04ae11326011697586259507c20636..fa3a91fbb02374791f8aab055183ca63ed9e5c08 100644 (file)
@@ -1,60 +1,60 @@
-<?php\r
-\r
-       /**\r
-        * Elgg database\r
-        * Contains database connection and transfer functionality\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg database
+        * Contains database connection and transfer functionality
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
 
-        * @link http://elgg.org/\r
+        * @link http://elgg.org/
         */
 
        $DB_PROFILE = array();
        $DB_QUERY_CACHE = array();
        $DB_DELAYED_QUERIES = array();
-       \r
-       /**\r
-        * Connect to the database server and use the Elgg database for a particular database link\r
-        *\r
-        * @param string $dblinkname Default "readwrite"; you can change this to set up additional global database links, eg "read" and "write" \r
-        */\r
-               function establish_db_link($dblinkname = "readwrite") {\r
-                       \r
-                       // Get configuration, and globalise database link\r
-                       global $CONFIG, $dblink, $DB_QUERY_CACHE, $dbcalls;\r
-                       \r
-                       if (!isset($dblink)) {\r
-                               $dblink = array();\r
-                       }\r
-                       \r
-                       if ($dblinkname != "readwrite" && isset($CONFIG->db[$dblinkname])) {\r
-                               if (is_array($CONFIG->db[$dblinkname])) {\r
-                                       $index = rand(0,sizeof($CONFIG->db[$dblinkname]));\r
-                                       $dbhost = $CONFIG->db[$dblinkname][$index]->dbhost;\r
-                                               $dbuser = $CONFIG->db[$dblinkname][$index]->dbuser;\r
-                                               $dbpass = $CONFIG->db[$dblinkname][$index]->dbpass;\r
-                                               $dbname = $CONFIG->db[$dblinkname][$index]->dbname;\r
-                               } else {\r
-                                               $dbhost = $CONFIG->db[$dblinkname]->dbhost;\r
-                                               $dbuser = $CONFIG->db[$dblinkname]->dbuser;\r
-                                               $dbpass = $CONFIG->db[$dblinkname]->dbpass;\r
-                                               $dbname = $CONFIG->db[$dblinkname]->dbname;\r
-                               }\r
-                       } else {\r
-                               $dbhost = $CONFIG->dbhost;\r
-                                       $dbuser = $CONFIG->dbuser;\r
-                                       $dbpass = $CONFIG->dbpass;\r
-                                       $dbname = $CONFIG->dbname;\r
-                       }\r
-                       \r
-                   // Connect to database\r
-                       if (!$dblink[$dblinkname] = mysql_connect($CONFIG->dbhost, $CONFIG->dbuser, $CONFIG->dbpass, true))\r
-                               throw new DatabaseException(sprintf(elgg_echo('DatabaseException:WrongCredentials'), $CONFIG->dbuser, $CONFIG->dbhost, $CONFIG->debug ? $CONFIG->dbpass : "****"));\r
-                       if (!mysql_select_db($CONFIG->dbname, $dblink[$dblinkname]))\r
-                               throw new DatabaseException(sprintf(elgg_echo('DatabaseException:NoConnect'), $CONFIG->dbname));\r
+       
+       /**
+        * Connect to the database server and use the Elgg database for a particular database link
+        *
+        * @param string $dblinkname Default "readwrite"; you can change this to set up additional global database links, eg "read" and "write" 
+        */
+               function establish_db_link($dblinkname = "readwrite") {
+                       
+                       // Get configuration, and globalise database link
+                       global $CONFIG, $dblink, $DB_QUERY_CACHE, $dbcalls;
+                       
+                       if (!isset($dblink)) {
+                               $dblink = array();
+                       }
+                       
+                       if ($dblinkname != "readwrite" && isset($CONFIG->db[$dblinkname])) {
+                               if (is_array($CONFIG->db[$dblinkname])) {
+                                       $index = rand(0,sizeof($CONFIG->db[$dblinkname]));
+                                       $dbhost = $CONFIG->db[$dblinkname][$index]->dbhost;
+                                               $dbuser = $CONFIG->db[$dblinkname][$index]->dbuser;
+                                               $dbpass = $CONFIG->db[$dblinkname][$index]->dbpass;
+                                               $dbname = $CONFIG->db[$dblinkname][$index]->dbname;
+                               } else {
+                                               $dbhost = $CONFIG->db[$dblinkname]->dbhost;
+                                               $dbuser = $CONFIG->db[$dblinkname]->dbuser;
+                                               $dbpass = $CONFIG->db[$dblinkname]->dbpass;
+                                               $dbname = $CONFIG->db[$dblinkname]->dbname;
+                               }
+                       } else {
+                               $dbhost = $CONFIG->dbhost;
+                                       $dbuser = $CONFIG->dbuser;
+                                       $dbpass = $CONFIG->dbpass;
+                                       $dbname = $CONFIG->dbname;
+                       }
+                       
+                   // Connect to database
+                       if (!$dblink[$dblinkname] = mysql_connect($CONFIG->dbhost, $CONFIG->dbuser, $CONFIG->dbpass, true))
+                               throw new DatabaseException(sprintf(elgg_echo('DatabaseException:WrongCredentials'), $CONFIG->dbuser, $CONFIG->dbhost, $CONFIG->debug ? $CONFIG->dbpass : "****"));
+                       if (!mysql_select_db($CONFIG->dbname, $dblink[$dblinkname]))
+                               throw new DatabaseException(sprintf(elgg_echo('DatabaseException:NoConnect'), $CONFIG->dbname));
                        
                    // Set up cache
                        if ((!$DB_QUERY_CACHE) && (!$CONFIG->db_disable_query_cache)) 
                                //$DB_QUERY_CACHE = select_default_memcache('db_query_cache'); //array();
                                
                        //if ($DB_QUERY_CACHE instanceof ElggMemcache)
-                       //      $DB_QUERY_CACHE->setDefaultExpiry(30);\r
-               }\r
-               \r
-       /**\r
-        * Establish all database connections\r
-        * \r
-        * If the configuration has been set up for multiple read/write databases, set those\r
-        * links up separately; otherwise just create the one database link\r
-        *\r
-        */\r
-               \r
-               function setup_db_connections() {\r
-                       \r
-                       // Get configuration and globalise database link\r
-                               global $CONFIG, $dblink;\r
-                               \r
-                               if (!empty($CONFIG->db->split)) {\r
-                                       establish_db_link('read');\r
-                                       establish_db_link('write');\r
-                               } else {\r
-                                       establish_db_link('readwrite');\r
-                               }\r
-                       \r
+                       //      $DB_QUERY_CACHE->setDefaultExpiry(30);
+               }
+               
+       /**
+        * Establish all database connections
+        * 
+        * If the configuration has been set up for multiple read/write databases, set those
+        * links up separately; otherwise just create the one database link
+        *
+        */
+               
+               function setup_db_connections() {
+                       
+                       // Get configuration and globalise database link
+                               global $CONFIG, $dblink;
+                               
+                               if (!empty($CONFIG->db->split)) {
+                                       establish_db_link('read');
+                                       establish_db_link('write');
+                               } else {
+                                       establish_db_link('readwrite');
+                               }
+                       
                }
                
        /**
                                if (isset($CONFIG->debug) && $CONFIG->debug) error_log($e);
                        }
                }
-       }\r
-               \r
-       /**\r
-        * Alias to setup_db_connections, for use in the event handler\r
-        *\r
-        * @param string $event The event type\r
-        * @param string $object_type The object type\r
-        * @param mixed $object Used for nothing in this context\r
-        */\r
+       }
+               
+       /**
+        * Alias to setup_db_connections, for use in the event handler
+        *
+        * @param string $event The event type
+        * @param string $object_type The object type
+        * @param mixed $object Used for nothing in this context
+        */
                function init_db($event, $object_type, $object = null) {
                        register_shutdown_function('db_delayedexecution_shutdown_hook');
-                       register_shutdown_function('db_profiling_shutdown_hook');\r
-                       //setup_db_connections(); // [Marcus Povey 20090213: Db connection moved to first db connection attempt]\r
-                       return true;\r
-               }\r
-               \r
-       /**\r
-        * Gets the appropriate db link for the operation mode requested\r
-        *\r
-        * @param string $dblinktype The type of link we want - "read", "write" or "readwrite" (the default)\r
-        * @return object Database link\r
-        */\r
-               function get_db_link($dblinktype) {\r
-                       \r
-                       global $dblink;\r
-                       \r
-                               \r
-                       if (isset($dblink[$dblinktype])) {\r
-                               return $dblink[$dblinktype];\r
-                       } else if (isset($dblink['readwrite'])) {\r
-                               return $dblink['readwrite'];\r
-                       }\r
-                       else\r
-                       {\r
-                               setup_db_connections();\r
-                               return get_db_link($dblinktype);\r
-                       }\r
+                       register_shutdown_function('db_profiling_shutdown_hook');
+                       //setup_db_connections(); // [Marcus Povey 20090213: Db connection moved to first db connection attempt]
+                       return true;
+               }
+               
+       /**
+        * Gets the appropriate db link for the operation mode requested
+        *
+        * @param string $dblinktype The type of link we want - "read", "write" or "readwrite" (the default)
+        * @return object Database link
+        */
+               function get_db_link($dblinktype) {
+                       
+                       global $dblink;
+                       
+                               
+                       if (isset($dblink[$dblinktype])) {
+                               return $dblink[$dblinktype];
+                       } else if (isset($dblink['readwrite'])) {
+                               return $dblink['readwrite'];
+                       }
+                       else
+                       {
+                               setup_db_connections();
+                               return get_db_link($dblinktype);
+                       }
                }
                
                /**
                 */
                function execute_query($query, $dblink)
                {
-                       global $CONFIG, $dbcalls, $DB_PROFILE, $DB_QUERY_CACHE;\r
+                       global $CONFIG, $dbcalls, $DB_PROFILE, $DB_QUERY_CACHE;
                                                
             $dbcalls++;
             
                 * @param string $query The query to execute
                 * @param string $handler The handler if you care about the result.
                 */
-               function execute_delayed_read_query($query, $handler = "") { return execute_delayed_query($query, get_db_link('read'), $handler); }\r
-               \r
-       /**\r
-     * Use this function to get data from the database\r
-     * @param mixed $query The query being passed.\r
-     * @param string $call Optionally, the name of a function to call back to on each row (which takes $row as a single parameter)\r
-     * @return array An array of database result objects\r
-     */\r
-    \r
-        function get_data($query, $callback = "") {\r
-            \r
-            global $CONFIG, $DB_QUERY_CACHE;\r
+               function execute_delayed_read_query($query, $handler = "") { return execute_delayed_query($query, get_db_link('read'), $handler); }
+               
+       /**
+     * Use this function to get data from the database
+     * @param mixed $query The query being passed.
+     * @param string $call Optionally, the name of a function to call back to on each row (which takes $row as a single parameter)
+     * @return array An array of database result objects
+     */
+    
+        function get_data($query, $callback = "") {
+            
+            global $CONFIG, $DB_QUERY_CACHE;
             
                // Is cached?
                if ($DB_QUERY_CACHE) $cached_query = $DB_QUERY_CACHE[$query];
             }
             
             $dblink = get_db_link('read');
-            \r
-            $resultarray = array();\r
-            \r
-            if ($result = execute_query("$query", $dblink)) {\r
-                while ($row = mysql_fetch_object($result)) {\r
-                       if (!empty($callback) && is_callable($callback)) {\r
-                               $row = $callback($row);\r
-                       }\r
-                    if ($row) $resultarray[] = $row;\r
-                }\r
-            }\r
+            
+            $resultarray = array();
+            
+            if ($result = execute_query("$query", $dblink)) {
+                while ($row = mysql_fetch_object($result)) {
+                       if (!empty($callback) && is_callable($callback)) {
+                               $row = $callback($row);
+                       }
+                    if ($row) $resultarray[] = $row;
+                }
+            }
             
                        if (empty($resultarray)) {
                                if ((isset($CONFIG->debug)) && ($CONFIG->debug==true))
             if ((isset($CONFIG->debug)) && ($CONFIG->debug==true))
                error_log("$query results cached");
             if ($DB_QUERY_CACHE) $DB_QUERY_CACHE[$query] = $resultarray;
-            \r
-            return $resultarray;\r
-        }\r
-        \r
-    /**\r
-     * Use this function to get a single data row from the database\r
-     * @param mixed $query The query to run.\r
-     * @return object A single database result object\r
-     */ \r
-    \r
-        function get_data_row($query, $callback = "") {\r
-            \r
+            
+            return $resultarray;
+        }
+        
+    /**
+     * Use this function to get a single data row from the database
+     * @param mixed $query The query to run.
+     * @return object A single database result object
+     */ 
+    
+        function get_data_row($query, $callback = "") {
+            
             global $CONFIG, $DB_QUERY_CACHE;
             
                // Is cached
                        return false; // Last time this query returned nothing, so return false
                        
                return $cached_query;
-            }\r
-            \r
+            }
+            
             $dblink = get_db_link('read');
-            \r
+            
             if ($result = execute_query("$query", $dblink)) {
                
                $row = mysql_fetch_object($result);
                if (!empty($callback) && is_callable($callback)) {
                        $row = $callback($row);
                 }
-               \r
-                if ($row) return $row;\r
+               
+                if ($row) return $row;
             }
             
                        if ((isset($CONFIG->debug)) && ($CONFIG->debug==true))
                                        error_log("WARNING: DB query \"$query\" returned no results.");
-                                       \r
-            return false;\r
-        }\r
-        \r
-    /**\r
-     * Use this function to insert database data; returns id or false\r
-     * \r
-     * @param mixed $query The query to run.\r
-     * @return int $id the database id of the inserted row.\r
-     */ \r
-    \r
-        function insert_data($query) {\r
-            \r
-            global $CONFIG, $DB_QUERY_CACHE;\r
-            \r
-            $dblink = get_db_link('write');\r
+                                       
+            return false;
+        }
+        
+    /**
+     * Use this function to insert database data; returns id or false
+     * 
+     * @param mixed $query The query to run.
+     * @return int $id the database id of the inserted row.
+     */ 
+    
+        function insert_data($query) {
+            
+            global $CONFIG, $DB_QUERY_CACHE;
+            
+            $dblink = get_db_link('write');
             
             // Invalidate query cache
             if ($DB_QUERY_CACHE) $DB_QUERY_CACHE->clear();
             if ((isset($CONFIG->debug)) && ($CONFIG->debug==true))
-               error_log("Query cache invalidated");\r
-            \r
-            if (execute_query("$query", $dblink)) \r
+               error_log("Query cache invalidated");
+            
+            if (execute_query("$query", $dblink)) 
                 return mysql_insert_id($dblink);
                 
                 
-                       return false;\r
-        }\r
-        \r
-    /**\r
-     * Update database data\r
-     * \r
-     * @param mixed $query The query to run.\r
-     * @return int|false Either the number of affected rows, or false on failure\r
-     */ \r
-    \r
-        function update_data($query) {\r
-            \r
-            global $CONFIG, $DB_QUERY_CACHE;\r
-            \r
+                       return false;
+        }
+        
+    /**
+     * Update database data
+     * 
+     * @param mixed $query The query to run.
+     * @return int|false Either the number of affected rows, or false on failure
+     */ 
+    
+        function update_data($query) {
+            
+            global $CONFIG, $DB_QUERY_CACHE;
+            
             $dblink = get_db_link('write');
             
             // Invalidate query cache
             if ($DB_QUERY_CACHE) $DB_QUERY_CACHE->clear();
             if ((isset($CONFIG->debug)) && ($CONFIG->debug==true))
-               error_log("Query cache invalidated");\r
-            \r
-            if (execute_query("$query", $dblink))\r
+               error_log("Query cache invalidated");
+            
+            if (execute_query("$query", $dblink))
                return true; //return mysql_affected_rows();
-\r
-               return false;   \r
-            \r
-        }\r
-\r
-       /**\r
-        * Use this function to delete data\r
-        *\r
-        * @param mixed $query The SQL query to run\r
-        * @return int|false Either the number of affected rows, or false on failure\r
-        */\r
-    \r
-        function delete_data($query) {\r
-            \r
-            global $CONFIG, $DB_QUERY_CACHE;\r
-            \r
-            $dblink = get_db_link('write');\r
+
+               return false;   
+            
+        }
+
+       /**
+        * Use this function to delete data
+        *
+        * @param mixed $query The SQL query to run
+        * @return int|false Either the number of affected rows, or false on failure
+        */
+    
+        function delete_data($query) {
+            
+            global $CONFIG, $DB_QUERY_CACHE;
+            
+            $dblink = get_db_link('write');
             
             // Invalidate query cache
             if ($DB_QUERY_CACHE) $DB_QUERY_CACHE->clear();
             if ((isset($CONFIG->debug)) && ($CONFIG->debug==true))
                error_log("Query cache invalidated");
-            \r
-            if (execute_query("$query", $dblink)) \r
-                return mysql_affected_rows($dblink);\r
+            
+            if (execute_query("$query", $dblink)) 
+                return mysql_affected_rows($dblink);
         
-                       return false;      \r
-        }\r
-    \r
\r
-       /**\r
-        * Get the tables currently installed in the Elgg database\r
-        *\r
-        * @return array List of tables\r
-        */\r
-        function get_db_tables() {\r
-               global $CONFIG;\r
-               static $tables, $count;\r
-               \r
-               if (isset($tables)) {\r
-                       return $tables;\r
-               }\r
+                       return false;      
+        }
+    
+       /**
+        * Get the tables currently installed in the Elgg database
+        *
+        * @return array List of tables
+        */
+        function get_db_tables() {
+               global $CONFIG;
+               static $tables, $count;
+               
+               if (isset($tables)) {
+                       return $tables;
+               }
                
-               try{\r
+               try{
                        $result = get_data("show tables like '" . $CONFIG->dbprefix . "%'");
                } catch (DatabaseException $d)
                {
                        // Likely we can't handle an exception here, so just return false.
                        return false;
-               }\r
-                                       \r
-               $tables = array();\r
-               \r
-               if (is_array($result) && !empty($result)) {\r
-                       foreach($result as $row) {\r
-                               $row = (array) $row;\r
-                               if (is_array($row) && !empty($row))\r
-                                       foreach($row as $element) {\r
-                                               $tables[] = $element;\r
-                                       }\r
-                       }\r
+               }
+                                       
+               $tables = array();
+               
+               if (is_array($result) && !empty($result)) {
+                       foreach($result as $row) {
+                               $row = (array) $row;
+                               if (is_array($row) && !empty($row))
+                                       foreach($row as $element) {
+                                               $tables[] = $element;
+                                       }
+                       }
                }
                else
-                       return false;\r
-               \r
-               return $tables;\r
+                       return false;
+               
+               return $tables;
         }
         
     /**
        {
                $table = sanitise_string($table);
                return update_data("optimize table $table");
-       }\r
-        \r
-       /**\r
-        * Get the last database error for a particular database link\r
-        *\r
-        * @param database link $dblink\r
-        * @return string Database error message\r
-        */\r
-        function get_db_error($dblink) {\r
-               return mysql_error($dblink);\r
-        }\r
-        \r
-       /**\r
-        * Runs a full database script from disk\r
-        *\r
-        * @uses $CONFIG\r
-        * @param string $scriptlocation The full path to the script\r
-        */\r
-        function run_sql_script($scriptlocation) {\r
-               \r
-               if ($script = file_get_contents($scriptlocation)) {\r
-\r
-                       global $CONFIG;\r
-                       \r
-                       $errors = array();\r
-                       \r
-                       $script = preg_replace('/\-\-.*\n/', '', $script);\r
-                       $sql_statements =  preg_split('/;[\n\r]+/', $script);\r
-                       foreach($sql_statements as $statement) {\r
-                               $statement = trim($statement);\r
-                               $statement = str_replace("prefix_",$CONFIG->dbprefix,$statement);\r
-                               if (!empty($statement)) {\r
-                                       try {\r
-                                               $result = update_data($statement);\r
-                                       } catch (DatabaseException $e) {\r
-                                               $errors[] = $e->getMessage();\r
-                                       }\r
-                               }\r
-                       }\r
-                       if (!empty($errors)) {\r
-                               $errortxt = "";\r
-                               foreach($errors as $error)\r
-                                       $errortxt .= " {$error};";\r
-                               throw new DatabaseException(elgg_echo('DatabaseException:DBSetupIssues') . $errortxt);\r
-                       }\r
-                       \r
-               } else {\r
-                       throw new DatabaseException(sprintf(elgg_echo('DatabaseException:ScriptNotFound'), $scriptlocation));\r
-               }\r
-               \r
-        }\r
+       }
+        
+       /**
+        * Get the last database error for a particular database link
+        *
+        * @param database link $dblink
+        * @return string Database error message
+        */
+        function get_db_error($dblink) {
+               return mysql_error($dblink);
+        }
+        
+       /**
+        * Runs a full database script from disk
+        *
+        * @uses $CONFIG
+        * @param string $scriptlocation The full path to the script
+        */
+        function run_sql_script($scriptlocation) {
+               
+               if ($script = file_get_contents($scriptlocation)) {
+
+                       global $CONFIG;
+                       
+                       $errors = array();
+                       
+                       $script = preg_replace('/\-\-.*\n/', '', $script);
+                       $sql_statements =  preg_split('/;[\n\r]+/', $script);
+                       foreach($sql_statements as $statement) {
+                               $statement = trim($statement);
+                               $statement = str_replace("prefix_",$CONFIG->dbprefix,$statement);
+                               if (!empty($statement)) {
+                                       try {
+                                               $result = update_data($statement);
+                                       } catch (DatabaseException $e) {
+                                               $errors[] = $e->getMessage();
+                                       }
+                               }
+                       }
+                       if (!empty($errors)) {
+                               $errortxt = "";
+                               foreach($errors as $error)
+                                       $errortxt .= " {$error};";
+                               throw new DatabaseException(elgg_echo('DatabaseException:DBSetupIssues') . $errortxt);
+                       }
+                       
+               } else {
+                       throw new DatabaseException(sprintf(elgg_echo('DatabaseException:ScriptNotFound'), $scriptlocation));
+               }
+               
+        }
         
         /**
          * Upgrade the database schema in an ordered sequence.
          * @param int $version The version you are upgrading from (usually given in the Elgg version format of YYYYMMDDXX - see version.php for example)
          * @param string $fromdir Optional directory to load upgrades from (default: engine/schema/upgrades/)
          * @return bool
-         */\r
-        function db_upgrade($version, $fromdir = "") {\r
-               \r
-               global $CONFIG;\r
-               \r
-               // Elgg and its database must be installed to upgrade it!\r
+         */
+        function db_upgrade($version, $fromdir = "") {
+               
+               global $CONFIG;
+               
+               // Elgg and its database must be installed to upgrade it!
                if (!is_db_installed() || !is_installed()) return false;
-               \r
+               
                $version = (int) $version;
                if (!$fromdir)
-                       $fromdir = $CONFIG->path . 'engine/schema/upgrades/';\r
-               \r
-               if ($handle = opendir($fromdir)) {\r
-                       \r
-                       $sqlupgrades = array();\r
-                       \r
-                       while ($sqlfile = readdir($handle)) {\r
-                               \r
-                               if (!is_dir($fromdir . $sqlfile)) {\r
-                                       if (preg_match('/([0-9]*)\.sql/',$sqlfile,$matches)) {\r
-                                               $sql_version = (int) $matches[1];\r
-                                               if ($sql_version > $version) {\r
-                                                       $sqlupgrades[] = $sqlfile;\r
-                                               }\r
-                                       }\r
-                               }\r
-                               \r
-                       }\r
-                       \r
-                       asort($sqlupgrades);\r
-                       if (sizeof($sqlupgrades) > 0) {\r
-                               foreach($sqlupgrades as $sqlfile) {\r
-                                       try {\r
-                                               run_sql_script($fromdir . $sqlfile);\r
-                                       } catch (DatabaseException $e) {\r
-                                               error_log($e->getmessage());\r
-                                       }\r
-                               }\r
-                       }\r
-                       \r
-               }\r
+                       $fromdir = $CONFIG->path . 'engine/schema/upgrades/';
                
-               return true;\r
+               if ($handle = opendir($fromdir)) {
+                       
+                       $sqlupgrades = array();
+                       
+                       while ($sqlfile = readdir($handle)) {
+                               
+                               if (!is_dir($fromdir . $sqlfile)) {
+                                       if (preg_match('/([0-9]*)\.sql/',$sqlfile,$matches)) {
+                                               $sql_version = (int) $matches[1];
+                                               if ($sql_version > $version) {
+                                                       $sqlupgrades[] = $sqlfile;
+                                               }
+                                       }
+                               }
+                               
+                       }
+                       
+                       asort($sqlupgrades);
+                       if (sizeof($sqlupgrades) > 0) {
+                               foreach($sqlupgrades as $sqlfile) {
+                                       try {
+                                               run_sql_script($fromdir . $sqlfile);
+                                       } catch (DatabaseException $e) {
+                                               error_log($e->getmessage());
+                                       }
+                               }
+                       }
+                       
+               }
+               
+               return true;
         }
         
         /**
                        $string = str_replace($extra_escapeable[$n], "\\" . $extra_escapeable[$n], $string);
                        
                return $string;
-        }\r
-        \r
-       /**\r
-        * Sanitise a string for database use\r
-        *\r
-        * @param string $string The string to sanitise\r
-        * @return string Sanitised string\r
-        */\r
-        function sanitise_string($string) {\r
-               return mysql_real_escape_string(trim($string));\r
-        }\r
-        \r
-       /**\r
-        * Wrapper function for alternate English spelling\r
-        *\r
-        * @param string $string The string to sanitise\r
-        * @return string Sanitised string\r
-        * @uses sanitise_string\r
-        */\r
-        function sanitize_string($string) {\r
-               return sanitise_string($string);\r
-        }\r
-        \r
-       /**\r
-        * Sanitises an integer for database use\r
-        *\r
-        * @param int $int\r
-        * @return int Sanitised integer\r
-        */\r
-        function sanitise_int($int) {\r
-               return (int) $int;\r
-        }\r
-        \r
-       /**\r
-        * Wrapper function for alternate English spelling\r
-        *\r
-        * @param int $int\r
-        * @return int Sanitised integer\r
-        * @uses sanitise_string\r
-        */\r
-        function sanitize_int($int) {\r
-               return (int) $int;\r
-        }\r
-        \r
-       // Stuff for initialisation\r
-\r
-               register_elgg_event_handler('boot','system','init_db',0);\r
-\r
+        }
+        
+       /**
+        * Sanitise a string for database use
+        *
+        * @param string $string The string to sanitise
+        * @return string Sanitised string
+        */
+        function sanitise_string($string) {
+               return mysql_real_escape_string(trim($string));
+        }
+        
+       /**
+        * Wrapper function for alternate English spelling
+        *
+        * @param string $string The string to sanitise
+        * @return string Sanitised string
+        * @uses sanitise_string
+        */
+        function sanitize_string($string) {
+               return sanitise_string($string);
+        }
+        
+       /**
+        * Sanitises an integer for database use
+        *
+        * @param int $int
+        * @return int Sanitised integer
+        */
+        function sanitise_int($int) {
+               return (int) $int;
+        }
+        
+       /**
+        * Wrapper function for alternate English spelling
+        *
+        * @param int $int
+        * @return int Sanitised integer
+        * @uses sanitise_string
+        */
+        function sanitize_int($int) {
+               return (int) $int;
+        }
+        
+       // Stuff for initialisation
+
+               register_elgg_event_handler('boot','system','init_db',0);
+
 ?>
\ No newline at end of file
index 06af14fcbea32609fd825e975b9740b46e935b9b..fc87c1dc1151f3b3c2e72a9973d1a39c8509581c 100644 (file)
                /**
                 * Return the location of a given view.
                 *
-                * @param string $view The view.\r
+                * @param string $view The view.
                 * @param string $viewtype The viewtype
                 */
                function elgg_get_view_location($view, $viewtype = '')
                {
                        global $CONFIG;
-               \r
+               
                        if (empty($viewtype))
                                $viewtype = elgg_get_viewtype();
                        
         * @param string $view The name and location of the view to use
         * @param array $vars Any variables that the view requires, passed as an array
         * @param boolean $bypass If set to true, elgg_view will bypass any specified alternative template handler; by default, it will hand off to this if requested (see set_template_handler)
-        * @param boolean $debug If set to true, the viewer will complain if it can't find a view\r
+        * @param boolean $debug If set to true, the viewer will complain if it can't find a view
         * @param string $viewtype If set, forces the viewtype for the elgg_view call to be this value (default: standard detection) 
         * @return string The HTML content
         */
                    }
                
                
-               // Get the current viewtype\r
+               // Get the current viewtype
                        if (empty($viewtype))
                                $viewtype = elgg_get_viewtype(); 
                
        /**
         * Returns whether the specified view exists
         *
-        * @param string $view The view name\r
+        * @param string $view The view name
         * @param string $viewtype If set, forces the viewtype
         * @return true|false Depending on success
         */
                        
                                global $CONFIG;
                        
-                       // Detect view type\r
+                       // Detect view type
                                if (empty($viewtype))
                                $viewtype = elgg_get_viewtype();
                            
                        
                        $subtype = $entity->getSubtype();
                        if (empty($subtype)) { $subtype = $entity_type; }
-\r
+
                        $contents = '';
                        if (elgg_view_exists("{$entity_type}/{$subtype}")) {
                                $contents = elgg_view("{$entity_type}/{$subtype}",array(
                                                                                                                                        'entity' => $entity,
                                                                                                                                        'full' => $full
                                                                                                                                        ), $bypass, $debug);
-                       } \r
+                       } 
                        if (empty($contents)) {
                                $contents = elgg_view("{$entity_type}/default",array(
                                                                                                                                'entity' => $entity,
                                                                
                                if ($annotations)
                                        $contents .= $annotations;
-                       }\r
+                       }
                        return $contents;
                }
 
                define('ACCESS_DEFAULT',-1);
                define('ACCESS_PRIVATE',0);
                define('ACCESS_LOGGED_IN',1);
-               define('ACCESS_PUBLIC',2);\r
+               define('ACCESS_PUBLIC',2);
                define('ACCESS_FRIENDS',-2);
        
        register_elgg_event_handler('init','system','elgg_init');
index b8c92ec429b888747c446f05a75b14950a0c14e6..4d2e17b563ec8f9b88b0e1ed8afb2bd9f51bd3cf 100644 (file)
-<?php\r
-       /**\r
-        * Elgg entities.\r
-        * Functions to manage all elgg entities (sites, collections, objects and users).\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Elgg entities.
+        * Functions to manage all elgg entities (sites, collections, objects and users).
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd <info@elgg.com>
+
+        * @link http://elgg.org/
+        */
+
+       /// Cache objects in order to minimise database access.
+       $ENTITY_CACHE = NULL;
+       
+       /// Cache subtype searches
+       $SUBTYPE_CACHE = NULL;
+       
+       /// Require the locatable interface TODO: Move this into start.php?
+       require_once('location.php');
+       
+       /**
+        * ElggEntity The elgg entity superclass
+        * This class holds methods for accessing the main entities table.
+        * 
+        * @author Curverider Ltd <info@elgg.com>
+        * @package Elgg
+        * @subpackage Core
+        */
+       abstract class ElggEntity implements 
+               Notable,    // Calendar interface
+               Locatable,  // Geocoding interface
+               Exportable, // Allow export of data
+               Importable, // Allow import of data
+               Loggable,       // Can events related to this object class be logged
+               Iterator,       // Override foreach behaviour
+               ArrayAccess // Override for array access
+       {
+               /** 
+                * The main attributes of an entity.
+                * Blank entries for all database fields should be created by the constructor.
+                * Subclasses should add to this in their constructors.
+                * Any field not appearing in this will be viewed as a 
+                */
+               protected $attributes;
+
+               /**
+                * If set, overrides the value of getURL()
+                */
+               protected $url_override;
+               
+               /**
+                * Icon override, overrides the value of getIcon().
+                */
+               protected $icon_override;
+               
+               /**
+                * Temporary cache for metadata, permitting meta data access before a guid has obtained.
+                */
+               protected $temp_metadata;
+                               
+               /**
+                * Temporary cache for annotations, permitting meta data access before a guid has obtained.
+                */
+               protected $temp_annotations;
+               
+               /**
+                * Initialise the attributes array. 
+                * This is vital to distinguish between metadata and base parameters.
+                * 
+                * Place your base parameters here.
+                * 
+                * @return void
+                */
+               protected function initialise_attributes()
+               {
+                       initialise_entity_cache();
+
+                       // Create attributes array if not already created
+                       if (!is_array($this->attributes)) $this->attributes = array();
+                       if (!is_array($this->temp_metadata)) $this->temp_metadata = array();
+                       if (!is_array($this->temp_annotations)) $this->temp_annotations = array();
+                       
+                       $this->attributes['guid'] = "";
+                       $this->attributes['type'] = "";
+                       $this->attributes['subtype'] = "";
+                       
+                       $this->attributes['owner_guid'] = get_loggedin_userid();
+                       $this->attributes['container_guid'] = get_loggedin_userid();
+                       
+                       $this->attributes['site_guid'] = 0;
+                       $this->attributes['access_id'] = ACCESS_PRIVATE;
+                       $this->attributes['time_created'] = "";
+                       $this->attributes['time_updated'] = "";
+                       $this->attributes['enabled'] = "yes";
+                       
+                       // There now follows a bit of a hack
+                       /* Problem: To speed things up, some objects are split over several tables, this means that it requires
+                        * n number of database reads to fully populate an entity. This causes problems for caching and create events
+                        * since it is not possible to tell whether a subclassed entity is complete.
+                        * Solution: We have two counters, one 'tables_split' which tells whatever is interested how many tables 
+                        * are going to need to be searched in order to fully populate this object, and 'tables_loaded' which is how
+                        * many have been loaded thus far.
+                        * If the two are the same then this object is complete.
+                        * 
+                        * Use: isFullyLoaded() to check
+                        */
+                       $this->attributes['tables_split'] = 1;
+                       $this->attributes['tables_loaded'] = 0;
+               }
+                               
+               /**
+                * Return the value of a given key.
+                * If $name is a key field (as defined in $this->attributes) that value is returned, otherwise it will
+                * then look to see if the value is in this object's metadata.
+                * 
+                * Q: Why are we not using __get overload here?
+                * A: Because overload operators cause problems during subclassing, so we put the code here and
+                * create overloads in subclasses. 
+                * 
+                * @param string $name
+                * @return mixed Returns the value of a given value, or null.
+                */
+               public function get($name)
+               {
+                       // See if its in our base attribute
+                       if (isset($this->attributes[$name])) {
+                               return $this->attributes[$name];
+                       }
+                       
+                       // No, so see if its in the meta data for this entity
+                       $meta = $this->getMetaData($name);
+                       if ($meta)
+                               return $meta;
+                       
+                       // Can't find it, so return null
+                       return null;
+               }
 
-        * @author Curverider Ltd <info@elgg.com>\r
+               /**
+                * Set the value of a given key, replacing it if necessary.
+                * If $name is a base attribute (as defined in $this->attributes) that value is set, otherwise it will
+                * set the appropriate item of metadata.
+                * 
+                * Note: It is important that your class populates $this->attributes with keys for all base attributes, anything
+                * not in their gets set as METADATA.
+                * 
+                * Q: Why are we not using __set overload here?
+                * A: Because overload operators cause problems during subclassing, so we put the code here and
+                * create overloads in subclasses.
+                * 
+                * @param string $name
+                * @param mixed $value  
+                */
+               public function set($name, $value)
+               {
+                       if (array_key_exists($name, $this->attributes))
+                       {
+                               // Check that we're not trying to change the guid! 
+                               if ((array_key_exists('guid', $this->attributes)) && ($name=='guid'))
+                                       return false;
+                                       
+                               $this->attributes[$name] = $value;
+                       }
+                       else 
+                               return $this->setMetaData($name, $value);
+               
+                       return true;
+               }
+                       
+               /**
+                * Get a given piece of metadata.
+                * 
+                * @param string $name
+                */
+               public function getMetaData($name)
+               {
+                       if ((int) ($this->guid) > 0) {
+                               $md = get_metadata_byname($this->getGUID(), $name);
+                       } else {
+                               if (isset($this->temp_metadata[$name]))
+                                       return $this->temp_metadata[$name];
+                       }
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /// Cache objects in order to minimise database access.\r
-       $ENTITY_CACHE = NULL;\r
-       \r
-       /// Cache subtype searches\r
-       $SUBTYPE_CACHE = NULL;\r
-       \r
-       /// Require the locatable interface TODO: Move this into start.php?\r
-       require_once('location.php');\r
-       \r
-       /**\r
-        * ElggEntity The elgg entity superclass\r
-        * This class holds methods for accessing the main entities table.\r
-        * \r
-        * @author Curverider Ltd <info@elgg.com>\r
-        * @package Elgg\r
-        * @subpackage Core\r
-        */\r
-       abstract class ElggEntity implements \r
-               Notable,    // Calendar interface\r
-               Locatable,  // Geocoding interface\r
-               Exportable, // Allow export of data\r
-               Importable, // Allow import of data\r
-               Loggable,       // Can events related to this object class be logged\r
-               Iterator,       // Override foreach behaviour\r
-               ArrayAccess // Override for array access\r
-       {\r
-               /** \r
-                * The main attributes of an entity.\r
-                * Blank entries for all database fields should be created by the constructor.\r
-                * Subclasses should add to this in their constructors.\r
-                * Any field not appearing in this will be viewed as a \r
-                */\r
-               protected $attributes;\r
-\r
-               /**\r
-                * If set, overrides the value of getURL()\r
-                */\r
-               protected $url_override;\r
-               \r
-               /**\r
-                * Icon override, overrides the value of getIcon().\r
-                */\r
-               protected $icon_override;\r
-               \r
-               /**\r
-                * Temporary cache for metadata, permitting meta data access before a guid has obtained.\r
-                */\r
-               protected $temp_metadata;\r
-                               \r
-               /**\r
-                * Temporary cache for annotations, permitting meta data access before a guid has obtained.\r
-                */\r
-               protected $temp_annotations;\r
-               \r
-               /**\r
-                * Initialise the attributes array. \r
-                * This is vital to distinguish between metadata and base parameters.\r
-                * \r
-                * Place your base parameters here.\r
-                * \r
-                * @return void\r
-                */\r
-               protected function initialise_attributes()\r
-               {\r
-                       initialise_entity_cache();\r
-\r
-                       // Create attributes array if not already created\r
-                       if (!is_array($this->attributes)) $this->attributes = array();\r
-                       if (!is_array($this->temp_metadata)) $this->temp_metadata = array();\r
-                       if (!is_array($this->temp_annotations)) $this->temp_annotations = array();\r
-                       \r
-                       $this->attributes['guid'] = "";\r
-                       $this->attributes['type'] = "";\r
-                       $this->attributes['subtype'] = "";\r
-                       \r
-                       $this->attributes['owner_guid'] = get_loggedin_userid();\r
-                       $this->attributes['container_guid'] = get_loggedin_userid();\r
-                       \r
-                       $this->attributes['site_guid'] = 0;\r
-                       $this->attributes['access_id'] = ACCESS_PRIVATE;\r
-                       $this->attributes['time_created'] = "";\r
-                       $this->attributes['time_updated'] = "";\r
-                       $this->attributes['enabled'] = "yes";\r
-                       \r
-                       // There now follows a bit of a hack\r
-                       /* Problem: To speed things up, some objects are split over several tables, this means that it requires\r
-                        * n number of database reads to fully populate an entity. This causes problems for caching and create events\r
-                        * since it is not possible to tell whether a subclassed entity is complete.\r
-                        * Solution: We have two counters, one 'tables_split' which tells whatever is interested how many tables \r
-                        * are going to need to be searched in order to fully populate this object, and 'tables_loaded' which is how\r
-                        * many have been loaded thus far.\r
-                        * If the two are the same then this object is complete.\r
-                        * \r
-                        * Use: isFullyLoaded() to check\r
-                        */\r
-                       $this->attributes['tables_split'] = 1;\r
-                       $this->attributes['tables_loaded'] = 0;\r
-               }\r
-                               \r
-               /**\r
-                * Return the value of a given key.\r
-                * If $name is a key field (as defined in $this->attributes) that value is returned, otherwise it will\r
-                * then look to see if the value is in this object's metadata.\r
-                * \r
-                * Q: Why are we not using __get overload here?\r
-                * A: Because overload operators cause problems during subclassing, so we put the code here and\r
-                * create overloads in subclasses. \r
-                * \r
-                * @param string $name\r
-                * @return mixed Returns the value of a given value, or null.\r
-                */\r
-               public function get($name)\r
-               {\r
-                       // See if its in our base attribute\r
-                       if (isset($this->attributes[$name])) {\r
-                               return $this->attributes[$name];\r
-                       }\r
-                       \r
-                       // No, so see if its in the meta data for this entity\r
-                       $meta = $this->getMetaData($name);\r
-                       if ($meta)\r
-                               return $meta;\r
-                       \r
-                       // Can't find it, so return null\r
-                       return null;\r
-               }\r
-\r
-               /**\r
-                * Set the value of a given key, replacing it if necessary.\r
-                * If $name is a base attribute (as defined in $this->attributes) that value is set, otherwise it will\r
-                * set the appropriate item of metadata.\r
-                * \r
-                * Note: It is important that your class populates $this->attributes with keys for all base attributes, anything\r
-                * not in their gets set as METADATA.\r
-                * \r
-                * Q: Why are we not using __set overload here?\r
-                * A: Because overload operators cause problems during subclassing, so we put the code here and\r
-                * create overloads in subclasses.\r
-                * \r
-                * @param string $name\r
-                * @param mixed $value  \r
-                */\r
-               public function set($name, $value)\r
-               {\r
-                       if (array_key_exists($name, $this->attributes))\r
-                       {\r
-                               // Check that we're not trying to change the guid! \r
-                               if ((array_key_exists('guid', $this->attributes)) && ($name=='guid'))\r
-                                       return false;\r
-                                       \r
-                               $this->attributes[$name] = $value;\r
-                       }\r
-                       else \r
-                               return $this->setMetaData($name, $value);\r
-               \r
-                       return true;\r
-               }\r
-                       \r
-               /**\r
-                * Get a given piece of metadata.\r
-                * \r
-                * @param string $name\r
-                */\r
-               public function getMetaData($name)\r
-               {\r
-                       if ((int) ($this->guid) > 0) {\r
-                               $md = get_metadata_byname($this->getGUID(), $name);\r
-                       } else {\r
-                               if (isset($this->temp_metadata[$name]))\r
-                                       return $this->temp_metadata[$name];\r
-                       }\r
-\r
-                       if ($md && !is_array($md)) {\r
-                               return $md->value;\r
-                       } else if ($md && is_array($md)) {\r
-                               return metadata_array_to_values($md);\r
-                       }\r
-                               \r
-                       return null;\r
-               }\r
-               \r
-               /**\r
-                * Class member get overloading\r
-                *\r
-                * @param string $name\r
-                * @return mixed\r
-                */\r
-               function __get($name) { return $this->get($name); }\r
-               \r
-               /**\r
-                * Class member set overloading\r
-                *\r
-                * @param string $name\r
-                * @param mixed $value\r
-                * @return mixed\r
-                */\r
-               function __set($name, $value) { return $this->set($name, $value); }\r
-               \r
-               /**\r
-                * Supporting isset.\r
-                *\r
-                * @param string $name The name of the attribute or metadata.\r
-                * @return bool\r
-                */\r
-               function __isset($name) { if ($this->$name!="") return true; else return false; }\r
-               \r
-               /**\r
-                * Supporting unsetting of magic attributes.\r
-                *\r
-                * @param string $name The name of the attribute or metadata.\r
-                */\r
-               function __unset($name)\r
-               {\r
-                       if (array_key_exists($name, $this->attributes))\r
-                               $this->attributes[$name] = "";\r
-                       else\r
-                               $this->clearMetaData($name);\r
-               }\r
-               \r
-               /**\r
-                * Set a piece of metadata.\r
-                * \r
-                * @param string $name\r
-                * @param mixed $value\r
-                * @param string $value_type\r
-                * @param bool $multiple\r
-                * @return bool\r
-                */\r
-               public function setMetaData($name, $value, $value_type = "", $multiple = false)\r
-               {\r
-                       if (is_array($value))\r
-                       {\r
-                               unset($this->temp_metadata[$name]);\r
-                               remove_metadata($this->getGUID(), $name);\r
-                               foreach ($value as $v) {\r
-                                       if ((int) $this->guid > 0) {\r
-                                               $multiple = true;\r
-                                               if (!create_metadata($this->getGUID(), $name, $v, $value_type, $this->getOwner(), $this->getAccessID(), $multiple)) return false;\r
-                                       } else {\r
-                                               if (($multiple) && (isset($this->temp_metadata[$name])))\r
-                                               {\r
-                                                       if (!is_array($this->temp_metadata[$name]))\r
-                                                       {\r
-                                                               $tmp = $this->temp_metadata[$name];\r
-                                                               $this->temp_metadata[$name] = array();\r
-                                                               $this->temp_metadata[$name][] = $tmp;\r
-                                                       }\r
-                                                       \r
-                                                       $this->temp_metadata[$name][] = $value;\r
-                                               }\r
-                                               else\r
-                                                       $this->temp_metadata[$name] = $value;\r
-                                       }\r
-                               }\r
-                                       \r
-                               return true;\r
-                       }\r
-                       else\r
-                       {\r
-                               unset($this->temp_metadata[$name]);\r
-                               if ((int) $this->guid > 0) {\r
-                                       return create_metadata($this->getGUID(), $name, $value, $value_type, $this->getOwner(), $this->getAccessID(), $multiple);\r
-                               } else {\r
-                                       //$this->temp_metadata[$name] = $value;\r
-                                       \r
-                                       if (($multiple) && (isset($this->temp_metadata[$name])))\r
-                                       {\r
-                                               if (!is_array($this->temp_metadata[$name]))\r
-                                               {\r
-                                                       $tmp = $this->temp_metadata[$name];\r
-                                                       $this->temp_metadata[$name] = array();\r
-                                                       $this->temp_metadata[$name][] = $tmp;\r
-                                               }\r
-                                               \r
-                                               $this->temp_metadata[$name][] = $value;\r
-                                       }\r
-                                       else\r
-                                               $this->temp_metadata[$name] = $value;\r
-                                                       \r
-                                       return true;\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               /**\r
-                * Clear metadata.\r
-                */\r
-               public function clearMetaData($name = "")\r
-               {\r
-                       if (empty($name)) {\r
-                               return clear_metadata($this->getGUID());\r
-                       } else {\r
-                               return remove_metadata($this->getGUID(),$name);\r
-                       }\r
-               }\r
-               \r
-               /**\r
-                * Remove all entities associated with this entity\r
-                *\r
-                * @return true\r
-                */\r
-               public function clearRelationships() {\r
-                       remove_entity_relationships($this->getGUID());\r
-                       remove_entity_relationships($this->getGUID(),"",true);\r
-                       return true;\r
-               }\r
-               \r
-               /**\r
-                * Add a relationship.\r
-                *\r
-                * @param int $guid Relationship to link to.\r
-                * @param string $relationship The type of relationship.\r
-                */\r
-               public function addRelationship($guid, $relationship)\r
-               {\r
-                       return add_entity_relationship($this->getGUID(), $relationship, $guid);\r
-               }\r
-               \r
-               function setPrivateSetting($name, $value) {\r
-                       return set_private_setting($this->getGUID(), $name, $value);\r
-               }\r
-               \r
-               function getPrivateSetting($name) {\r
-                       return get_private_setting($this->getGUID(), $name);\r
-               }\r
-               \r
-               function removePrivateSetting($name) {\r
-                       return remove_private_setting($this->getGUID(), $name);\r
-               }\r
-               \r
-               /**\r
-                * Adds an annotation to an entity. By default, the type is detected automatically; however, \r
-                * it can also be set. Note that by default, annotations are private.\r
-                * \r
-                * @param string $name\r
-                * @param mixed $value\r
-                * @param int $access_id\r
-                * @param int $owner_id\r
-                * @param string $vartype\r
-                */\r
-               function annotate($name, $value, $access_id = ACCESS_PRIVATE, $owner_id = 0, $vartype = "") \r
-               { \r
-                       if ((int) $this->guid > 0) {\r
-                               return create_annotation($this->getGUID(), $name, $value, $vartype, $owner_id, $access_id);\r
-                       } else {\r
-                               $this->temp_annotations[$name] = $value;\r
-                       }\r
-                       return true;\r
-               }\r
-               \r
-               /**\r
-                * Get the annotations for an entity.\r
-                *\r
-                * @param string $name\r
-                * @param int $limit\r
-                * @param int $offset\r
-                * @param string $order\r
-                */\r
-               function getAnnotations($name, $limit = 50, $offset = 0, $order="asc") \r
-               { \r
-                       if ((int) ($this->guid) > 0) {\r
-                               return get_annotations($this->getGUID(), "", "", $name, "", 0, $limit, $offset, $order);\r
-                       } else {\r
-                               return $this->temp_annotations[$name];\r
-                       }\r
-               }\r
-               \r
-               /**\r
-                * Remove all annotations or all annotations for this entity.\r
-                *\r
-                * @param string $name\r
-                */\r
-               function clearAnnotations($name = "")\r
-               {\r
-                       return clear_annotations($this->getGUID(), $name);\r
-               }\r
-               \r
-               /**\r
-                * Return the annotations for the entity.\r
-                *\r
-                * @param string $name The type of annotation.\r
-                */\r
-               function countAnnotations($name = "") \r
-               { \r
-                       return count_annotations($this->getGUID(), "","",$name);\r
-               }\r
-\r
-               /**\r
-                * Get the average of an integer type annotation.\r
-                *\r
-                * @param string $name\r
-                */\r
-               function getAnnotationsAvg($name) \r
-               {\r
-                       return get_annotations_avg($this->getGUID(), "","",$name);\r
-               }\r
-               \r
-               /**\r
-                * Get the sum of integer type annotations of a given name.\r
-                *\r
-                * @param string $name\r
-                */\r
-               function getAnnotationsSum($name) \r
-               {\r
-                       return get_annotations_sum($this->getGUID(), "","",$name);\r
-               }\r
-               \r
-               /**\r
-                * Get the minimum of integer type annotations of given name.\r
-                *\r
-                * @param string $name\r
-                */\r
-               function getAnnotationsMin($name)\r
-               {\r
-                       return get_annotations_min($this->getGUID(), "","",$name);\r
-               }\r
-               \r
-               /**\r
-                * Get the maximum of integer type annotations of a given name.\r
-                *\r
-                * @param string $name\r
-                */\r
-               function getAnnotationsMax($name)\r
-               {\r
-                       return get_annotations_max($this->getGUID(), "","",$name);\r
-               }\r
-               \r
-               /**\r
-                * Gets an array of entities from a specific relationship type\r
-                *\r
-                * @param string $relationship Relationship type (eg "friends")\r
-                * @param true|false $inverse Is this an inverse relationship?\r
-                * @param int $limit Number of elements to return\r
-                * @param int $offset Indexing offset\r
-                * @return array|false An array of entities or false on failure\r
-                */             \r
-               function getEntitiesFromRelationship($relationship, $inverse = false, $limit = 50, $offset = 0) {\r
-                       return get_entities_from_relationship($relationship,$this->getGUID(),$inverse,"","","","time_created desc",$limit,$offset);                     \r
-               }\r
-               \r
-               /**\r
-                * Gets the number of of entities from a specific relationship type\r
-                *\r
-                * @param string $relationship Relationship type (eg "friends")\r
-                * @return int|false The number of entities or false on failure\r
-                */             \r
-               function countEntitiesFromRelationship($relationship) {\r
-                       return get_entities_from_relationship($relationship,$this->getGUID(),false,"","","","time_created desc",null,null,true);                        \r
-               }\r
-               \r
-               /**\r
-                * Determines whether or not the specified user (by default the current one) can edit the entity \r
-                *\r
-                * @param int $user_guid The user GUID, optionally (defaults to the currently logged in user)\r
-                * @return true|false\r
-                */\r
-               function canEdit($user_guid = 0) {\r
-                       return can_edit_entity($this->getGUID(),$user_guid);\r
-               }\r
-               \r
-               /**\r
-                * Determines whether or not the specified user (by default the current one) can edit metadata on the entity \r
-                *\r
-                * @param ElggMetadata $metadata The piece of metadata to specifically check\r
-                * @param int $user_guid The user GUID, optionally (defaults to the currently logged in user)\r
-                * @return true|false\r
-                */\r
-               function canEditMetadata($metadata = null, $user_guid = 0) {\r
-                       return can_edit_entity_metadata($this->getGUID(), $user_guid, $metadata);\r
-               }\r
-               \r
-               /**\r
-                * Returns whether the given user (or current user) has the ability to write to this group.\r
-                *\r
-                * @param int $user_guid The user.\r
-                * @return bool\r
-                */\r
-               public function canWriteToContainer($user_guid = 0)\r
-               {\r
-                       return can_write_to_container($user_guid, $this->getGUID());\r
-               }\r
-               \r
-               /**\r
-                * Obtain this entity's access ID\r
-                *\r
-                * @return int The access ID\r
-                */\r
-               public function getAccessID() { return $this->get('access_id'); }\r
-               \r
-               /**\r
-                * Obtain this entity's GUID\r
-                *\r
-                * @return int GUID\r
-                */\r
-               public function getGUID() { return $this->get('guid'); }\r
-               \r
-               /**\r
-                * Get the owner of this entity\r
-                *\r
-                * @return int The owner GUID\r
-                */\r
-               public function getOwner() { return $this->get('owner_guid'); }\r
-               \r
-               /**\r
-                * Returns the actual entity of the user who owns this entity, if any\r
-                *\r
-                * @return ElggEntity The owning user\r
-                */\r
-               public function getOwnerEntity() { return get_entity($this->get('owner_guid')); }\r
-               \r
-               /**\r
-                * Gets the type of entity this is\r
-                *\r
-                * @return string Entity type\r
-                */\r
-               public function getType() { return $this->get('type'); }\r
-               \r
-               /**\r
-                * Returns the subtype of this entity\r
-                *\r
-                * @return string The entity subtype\r
-                */\r
-               public function getSubtype() {\r
-                       if (!((int) $this->guid > 0)) return $this->get('subtype'); // If this object hasn't been saved, then return the subtype string.\r
-                       \r
-                       return get_subtype_from_id($this->get('subtype')); \r
-               }\r
-               \r
-               /**\r
-                * Gets the UNIX epoch time that this entity was created\r
-                *\r
-                * @return int UNIX epoch time\r
-                */\r
-               public function getTimeCreated() { return $this->get('time_created'); }\r
-               \r
-               /**\r
-                * Gets the UNIX epoch time that this entity was last updated\r
-                *\r
-                * @return int UNIX epoch time\r
-                */\r
-               public function getTimeUpdated() { return $this->get('time_updated'); }\r
-               \r
-               /**\r
-                * Gets the display URL for this entity\r
-                *\r
-                * @return string The URL\r
-                */\r
-               public function getURL() {\r
-                       if (!empty($this->url_override)) return $this->url_override;\r
-                       return get_entity_url($this->getGUID()); \r
-               }\r
-               \r
-               /**\r
-                * Overrides the URL returned by getURL\r
-                *\r
-                * @param string $url The new item URL\r
-                * @return string The URL\r
-                */\r
-               public function setURL($url) {\r
-                       $this->url_override = $url;\r
-                       return $url;\r
-               }\r
-               \r
-               /**\r
-                * Return a url for the entity's icon, trying multiple alternatives.\r
-                *\r
-                * @param string $size Either 'large','medium','small' or 'tiny'\r
-                * @return string The url or false if no url could be worked out.\r
-                */\r
-               public function getIcon($size = 'medium')\r
-               {\r
-                       if (isset($this->icon_override[$size])) return $this->icon_override[$size];\r
-                       return get_entity_icon_url($this, $size);\r
-               }\r
-               \r
-               /**\r
-                * Set an icon override for an icon and size.\r
-                *\r
-                * @param string $url The url of the icon.\r
-                * @param string $size The size its for.\r
-                * @return bool\r
-                */\r
-               public function setIcon($url, $size = 'medium')\r
-               {\r
-                       $url = sanitise_string($url);\r
-                       $size = sanitise_string($size);\r
-                       \r
-                       if (!$this->icon_override) $this->icon_override = array();\r
-                       $this->icon_override[$size] = $url;\r
-                       \r
-                       return true;\r
-               }\r
-               \r
-               /**\r
-                * Tests to see whether the object has been fully loaded.\r
-                * \r
-                * @return bool\r
-                */\r
-               public function isFullyLoaded() { return ! ($this->attributes['tables_loaded'] < $this->attributes['tables_split']); }\r
-               \r
-               /**\r
-                * Save generic attributes to the entities table.\r
-                */\r
-               public function save()\r
-               {\r
-                       $guid = (int) $this->guid;\r
-                       if ($guid > 0)\r
-                       { \r
-                               cache_entity($this);\r
-\r
-                               return update_entity(\r
-                                       $this->get('guid'),\r
-                                       $this->get('owner_guid'),\r
-                                       $this->get('access_id'),\r
-                                       $this->get('container_guid')\r
-                               );\r
-                       }\r
-                       else\r
-                       { \r
-                               $this->attributes['guid'] = create_entity($this->attributes['type'], $this->attributes['subtype'], $this->attributes['owner_guid'], $this->attributes['access_id'], $this->attributes['site_guid'], $this->attributes['container_guid']); // Create a new entity (nb: using attribute array directly 'cos set function does something special!)\r
-                               if (!$this->attributes['guid']) throw new IOException(elgg_echo('IOException:BaseEntitySaveFailed')); \r
-                               \r
-                               // Save any unsaved metadata TODO: How to capture extra information (access id etc)\r
-                               if (sizeof($this->temp_metadata) > 0) {\r
-                                       foreach($this->temp_metadata as $name => $value) {\r
-                                               $this->$name = $value;\r
-                                               unset($this->temp_metadata[$name]);\r
-                                       }\r
-                               }\r
-                               \r
-                               // Save any unsaved annotations metadata. TODO: How to capture extra information (access id etc)\r
-                               if (sizeof($this->temp_annotations) > 0) {\r
-                                       foreach($this->temp_annotations as $name => $value) {\r
-                                               $this->annotate($name, $value);\r
-                                               unset($this->temp_annotations[$name]);\r
-                                       }\r
-                               }\r
-                               \r
-                               // Cache object handle\r
-                               if ($this->attributes['guid']) cache_entity($this); \r
-                               \r
-                               return $this->attributes['guid'];\r
-                       }\r
-               }\r
-               \r
-               /**\r
-                * Load the basic entity information and populate base attributes array.\r
-                * \r
-                * @param int $guid \r
-                */\r
-               protected function load($guid)\r
-               {               \r
-                       $row = get_entity_as_row($guid); \r
-                       \r
-                       if ($row)\r
-                       {\r
-                               // Create the array if necessary - all subclasses should test before creating\r
-                               if (!is_array($this->attributes)) $this->attributes = array();\r
-                               \r
-                               // Now put these into the attributes array as core values\r
-                               $objarray = (array) $row;\r
-                               foreach($objarray as $key => $value) \r
-                                       $this->attributes[$key] = $value;\r
-                               \r
-                               // Increment the portion counter\r
-                               if (!$this->isFullyLoaded()) $this->attributes['tables_loaded'] ++;\r
-                               \r
-                               // Cache object handle\r
-                               if ($this->attributes['guid']) cache_entity($this); \r
-                                       \r
-                               return true;\r
-                       }\r
-                       \r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * Disable this entity.\r
-                * \r
-                * @param string $reason Optional reason\r
-                * @param bool $recursive Recursively disable all contained entities?\r
-                */\r
-               public function disable($reason = "", $recursive = true)\r
-               {\r
-                       return disable_entity($this->get('guid'), $reason, $recursive);\r
-               }\r
-               \r
-               /**\r
-                * Re-enable this entity.\r
-                */\r
-               public function enable()\r
-               {\r
-                       return enable_entity($this->get('guid'));\r
-               }\r
-               \r
-               /**\r
-                * Is this entity enabled?\r
-                *\r
-                * @return boolean\r
-                */\r
-               public function isEnabled()\r
-               {\r
-                       if ($this->enabled == 'yes')\r
-                               return true;\r
-                               \r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * Delete this entity.\r
-                */\r
-               public function delete() \r
-               { \r
-                       return delete_entity($this->get('guid'));\r
-               }\r
-               \r
-               // LOCATABLE INTERFACE /////////////////////////////////////////////////////////////\r
-               \r
-               /** Interface to set the location */\r
-               public function setLocation($location)\r
-               {\r
-                       $location = sanitise_string($location);\r
-                       \r
-                       $this->location = $location;\r
-                       \r
-                       return true;\r
-               }\r
-               \r
-               /**\r
-                * Set latitude and longitude tags for a given entity.\r
-                *\r
-                * @param float $lat\r
-                * @param float $long\r
-                */\r
-               public function setLatLong($lat, $long)\r
-               {\r
-                       $lat = sanitise_string($lat);\r
-                       $long = sanitise_string($long);\r
-                       \r
-                       $this->set('geo:lat', $lat);\r
-                       $this->set('geo:long', $long);\r
-                       \r
-                       return true;\r
-               }\r
-               \r
-               /**\r
-                * Get the contents of the ->geo:lat field.\r
-                *\r
-                */\r
-               public function getLatitude() { return $this->get('geo:lat'); }\r
-               \r
-               /**\r
-                * Get the contents of the ->geo:lat field.\r
-                *\r
-                */\r
-               public function getLongitude() { return $this->get('geo:long'); }\r
-               \r
-               /**\r
-                * Get the ->location metadata. \r
-                *\r
-                */\r
-               public function getLocation() { return $this->get('location'); }\r
-               \r
-               // NOTABLE INTERFACE ///////////////////////////////////////////////////////////////\r
-               \r
-               /**\r
-                * Calendar functionality.\r
-                * This function sets the time of an object on a calendar listing.\r
-                *\r
-                * @param int $hour If ommitted, now is assumed.\r
-                * @param int $minute If ommitted, now is assumed.\r
-                * @param int $second If ommitted, now is assumed.\r
-                * @param int $day If ommitted, now is assumed.\r
-                * @param int $month If ommitted, now is assumed.\r
-                * @param int $year If ommitted, now is assumed.\r
-                * @param int $duration Duration of event, remainder of the day is assumed.\r
-                */\r
-               public function setCalendarTimeAndDuration($hour = NULL, $minute = NULL, $second = NULL, $day = NULL, $month = NULL, $year = NULL, $duration = NULL)\r
-               {\r
-                       $start = mktime($hour, $minute, $second, $month, $day, $year);\r
-                       $end = $start + abs($duration);\r
-                       if (!$duration)\r
-                               $end = get_day_end($day,$month,$year);\r
-                       \r
-                       $this->calendar_start = $start; \r
-                       $this->calendar_end = $end;\r
-                               \r
-                       return true;\r
-               }\r
-               \r
-               /**\r
-                * Return the start timestamp.\r
-                */\r
-               public function getCalendarStartTime() { return (int)$this->calendar_start; }\r
-               \r
-               /**\r
-                * Return the end timestamp.\r
-                */\r
-               public function getCalendarEndTime() { return (int)$this->calendar_end; }\r
-               \r
-               // EXPORTABLE INTERFACE ////////////////////////////////////////////////////////////\r
-               \r
-               /**\r
-                * Return an array of fields which can be exported.\r
-                */\r
-               public function getExportableValues()\r
-               {\r
-                       return array(\r
-                               'guid',\r
-                               'type',\r
-                               'subtype',\r
-                               'time_created',\r
-                               'container_guid',\r
-                               'owner_guid', \r
-                       );\r
-               }\r
-               \r
-               /**\r
-                * Export this class into an array of ODD Elements containing all necessary fields.\r
-                * Override if you wish to return more information than can be found in $this->attributes (shouldn't happen) \r
-                */\r
-               public function export() \r
-               { \r
-                       $tmp = array();\r
-                       \r
-                       // Generate uuid\r
-                       $uuid = guid_to_uuid($this->getGUID());\r
-                       \r
-                       // Create entity \r
-                       $odd = new ODDEntity(\r
-                               $uuid,\r
-                               $this->attributes['type'], \r
-                               get_subtype_from_id($this->attributes['subtype'])\r
-                       );\r
-                       \r
-                       $tmp[] = $odd;\r
-                       \r
-                       $exportable_values = $this->getExportableValues();\r
-                       \r
-                       // Now add its attributes\r
-                       foreach ($this->attributes as $k => $v)\r
-                       {\r
-                               $meta = NULL;\r
-                               \r
-                               if (in_array( $k, $exportable_values)) { \r
-                                       switch ($k)\r
-                                       {\r
-                                               case 'guid' :                   // Dont use guid in OpenDD\r
-                                               case 'type' :                   // Type and subtype already taken care of\r
-                                               case 'subtype' : \r
-                                               break;\r
-                                               \r
-                                               case 'time_created' :   // Created = published\r
-                                                       $odd->setAttribute('published', date("r", $v));\r
-                                               break;\r
-                                               \r
-                                               case 'site_guid' : // Container\r
-                                                       $k = 'site_uuid';\r
-                                                       $v = guid_to_uuid($v);\r
-                                                       $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v);\r
-                                               break;\r
-                                               \r
-                                               case 'container_guid' : // Container\r
-                                                       $k = 'container_uuid';\r
-                                                       $v = guid_to_uuid($v);\r
-                                                       $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v);\r
-                                               break;\r
-       \r
-                                               case 'owner_guid' :                     // Convert owner guid to uuid, this will be stored in metadata\r
-                                                        $k = 'owner_uuid';\r
-                                                        $v = guid_to_uuid($v);\r
-                                                        $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v);\r
-                                               break;  \r
-                                               \r
-                                               default : \r
-                                                       $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v);\r
-                                       }\r
-                                       \r
-                                       // set the time of any metadata created\r
-                                       if ($meta)\r
-                                       {\r
-                                               $meta->setAttribute('published', date("r",$this->time_created));\r
-                                               $tmp[] = $meta;\r
-                                       }\r
-                               }\r
-                       }\r
-                       \r
-                       // Now we do something a bit special.\r
-                       /*\r
-                        * This provides a rendered view of the entity to foreign sites.\r
-                        */\r
-                       \r
-                       elgg_set_viewtype('default');\r
-                       $view = elgg_view_entity($this, true);\r
-                       elgg_set_viewtype();\r
-                                       \r
-                       $tmp[] = new ODDMetaData($uuid . "volatile/renderedentity/", $uuid, 'renderedentity', $view , 'volatile');\r
-                       \r
-                       \r
-                       return $tmp;\r
-               }\r
-               \r
-               // IMPORTABLE INTERFACE ////////////////////////////////////////////////////////////\r
-               \r
-               /**\r
-                * Import data from an parsed xml data array.\r
-                * \r
-                * @param array $data\r
-                * @param int $version \r
-                */\r
-               public function import(ODD $data)\r
-               {\r
-                       if (!($data instanceof ODDEntity))\r
-                               throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnexpectedODDClass')); \r
-                       \r
-                       // Set type and subtype\r
-                       $this->attributes['type'] = $data->getAttribute('class');\r
-                       $this->attributes['subtype'] = $data->getAttribute('subclass');\r
-                       \r
-                       // Set owner\r
-                       $this->attributes['owner_guid'] = get_loggedin_userid(); // Import as belonging to importer.\r
-                       \r
-                       // Set time\r
-                       $this->attributes['time_created'] = strtotime($data->getAttribute('published'));\r
-                       $this->attributes['time_updated'] = time();\r
-                       \r
-                       return true;\r
-               }\r
-               \r
-               // SYSTEM LOG INTERFACE ////////////////////////////////////////////////////////////\r
-               \r
-               /**\r
-                * Return an identification for the object for storage in the system log. \r
-                * This id must be an integer.\r
-                * \r
-                * @return int \r
-                */\r
-               public function getSystemLogID() { return $this->getGUID();     }\r
-               \r
-               /**\r
-                * Return the class name of the object.\r
-                */\r
-               public function getClassName() { return get_class($this); }\r
-               \r
-               /**\r
-                * For a given ID, return the object associated with it.\r
-                * This is used by the river functionality primarily.\r
-                * This is useful for checking access permissions etc on objects.\r
-                */\r
-               public function getObjectFromID($id) { return get_entity($id); }\r
-               \r
-               /**\r
-                * Return the GUID of the owner of this object.\r
-                */\r
-               public function getObjectOwnerGUID() { return $this->owner_guid; }\r
-\r
-               // ITERATOR INTERFACE //////////////////////////////////////////////////////////////\r
-               /*\r
-                * This lets an entity's attributes be displayed using foreach as a normal array.\r
-                * Example: http://www.sitepoint.com/print/php5-standard-library\r
-                */\r
-               \r
-               private $valid = FALSE; \r
-               \r
-               function rewind() \r
-               { \r
-                       $this->valid = (FALSE !== reset($this->attributes));  \r
-               }\r
-   \r
-               function current() \r
-               { \r
-                       return current($this->attributes); \r
-               }\r
-               \r
-               function key() \r
-               { \r
-                       return key($this->attributes); \r
-               }\r
-               \r
-               function next() \r
-               {\r
-                       $this->valid = (FALSE !== next($this->attributes));  \r
-               }\r
-               \r
-               function valid() \r
-               { \r
-                       return $this->valid;  \r
-               }\r
-       \r
-               // ARRAY ACCESS INTERFACE //////////////////////////////////////////////////////////\r
-               /*\r
-                * This lets an entity's attributes be accessed like an associative array.\r
-                * Example: http://www.sitepoint.com/print/php5-standard-library\r
-                */\r
-\r
-               function offsetSet($key, $value)\r
-               {\r
-                       if ( array_key_exists($key, $this->attributes) ) {\r
-                       $this->attributes[$key] = $value;\r
-                       }\r
-               } \r
-               \r
-               function offsetGet($key) \r
-               {\r
-                       if ( array_key_exists($key, $this->attributes) ) {\r
-                       return $this->attributes[$key];\r
-                       }\r
-               } \r
-               \r
-               function offsetUnset($key) \r
-               {\r
-                       if ( array_key_exists($key, $this->attributes) ) {\r
-                       $this->attributes[$key] = ""; // Full unsetting is dangerious for our objects\r
-                       }\r
-               } \r
-               \r
-               function offsetExists($offset) \r
-               {\r
-                       return array_key_exists($offset, $this->attributes);\r
-               } \r
-       }\r
-\r
-       /**\r
-        * Initialise the entity cache.\r
-        */\r
-       function initialise_entity_cache()\r
-       {\r
-               global $ENTITY_CACHE;\r
-               \r
-               if (!$ENTITY_CACHE)\r
-                       $ENTITY_CACHE = array(); //select_default_memcache('entity_cache'); // TODO: Replace with memcache?\r
-       }\r
-       \r
-       /**\r
-        * Invalidate this class' entry in the cache.\r
-        * \r
-        * @param int $guid The guid\r
-        */\r
-       function invalidate_cache_for_entity($guid)\r
-       {\r
-               global $ENTITY_CACHE;\r
-               \r
-               $guid = (int)$guid;\r
-                       \r
-               unset($ENTITY_CACHE[$guid]);\r
-               //$ENTITY_CACHE->delete($guid);         \r
-       }\r
-       \r
-       /**\r
-        * Cache an entity.\r
-        * \r
-        * @param ElggEntity $entity Entity to cache\r
-        */\r
-       function cache_entity(ElggEntity $entity)\r
-       {\r
-               global $ENTITY_CACHE;\r
-               \r
-               $ENTITY_CACHE[$entity->guid] = $entity;\r
-       }\r
-       \r
-       /**\r
-        * Retrieve a entity from the cache.\r
-        * \r
-        * @param int $guid The guid\r
-        */\r
-       function retrieve_cached_entity($guid)\r
-       {\r
-               global $ENTITY_CACHE;\r
-               \r
-               $guid = (int)$guid;\r
-                       \r
-               if (isset($ENTITY_CACHE[$guid])) \r
-                       if ($ENTITY_CACHE[$guid]->isFullyLoaded()) return $ENTITY_CACHE[$guid];\r
-                               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * As retrieve_cached_entity, but returns the result as a stdClass (compatible with load functions that\r
-        * expect a database row.)\r
-        * \r
-        * @param int $guid The guid\r
-        */\r
-       function retrieve_cached_entity_row($guid)\r
-       {\r
-               $obj = retrieve_cached_entity($guid);\r
-               if ($obj)\r
-               {\r
-                       $tmp = new stdClass;\r
-                       \r
-                       foreach ($obj as $k => $v)\r
-                               $tmp->$k = $v;\r
-                               \r
-                       return $tmp;\r
-               }\r
-\r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Return the integer ID for a given subtype, or false.\r
-        * \r
-        * TODO: Move to a nicer place?\r
-        * \r
-        * @param string $type\r
-        * @param string $subtype\r
-        */\r
-       function get_subtype_id($type, $subtype)\r
-       {\r
-               global $CONFIG, $SUBTYPE_CACHE;\r
-               \r
-               $type = sanitise_string($type);\r
-               $subtype = sanitise_string($subtype);\r
-       \r
-               if ($subtype=="") return $subtype;\r
-               \r
-               // Todo: cache here? Or is looping less efficient that going to the db each time?\r
-               \r
-               $result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where type='$type' and subtype='$subtype'");\r
-\r
-               if ($result) {\r
-                       \r
-                       if (!$SUBTYPE_CACHE) \r
-                               $SUBTYPE_CACHE = array(); //select_default_memcache('subtype_cache');\r
-                       \r
-                       $SUBTYPE_CACHE[$result->id] = $result;\r
-                       return $result->id;\r
-               }\r
-               \r
-               return 0;\r
-       }\r
-       \r
-       /**\r
-        * For a given subtype ID, return its identifier text.\r
-        *  \r
-        * TODO: Move to a nicer place?\r
-        * \r
-        * @param int $subtype_id\r
-        */\r
-       function get_subtype_from_id($subtype_id)\r
-       {\r
-               global $CONFIG, $SUBTYPE_CACHE;\r
-               \r
-               $subtype_id = (int)$subtype_id;\r
-               \r
-               if (!$subtype_id) return false;\r
-               \r
-               if (isset($SUBTYPE_CACHE[$subtype_id]))\r
-                       return $SUBTYPE_CACHE[$subtype_id]->subtype;\r
-               \r
-               $result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where id=$subtype_id");\r
-               if ($result) {\r
-                       \r
-                       if (!$SUBTYPE_CACHE) \r
-                               $SUBTYPE_CACHE = array(); //select_default_memcache('subtype_cache');\r
-                       \r
-                       $SUBTYPE_CACHE[$subtype_id] = $result;\r
-                       return $result->subtype;\r
-               }\r
-               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * This function tests to see if a subtype has a registered class handler.\r
-        * \r
-        * @param string $type The type\r
-        * @param string $subtype The subtype\r
-        * @return a class name or null\r
-        */\r
-       function get_subtype_class($type, $subtype)\r
-       {\r
-               global $CONFIG, $SUBTYPE_CACHE;\r
-               \r
-               $type = sanitise_string($type);\r
-               $subtype = sanitise_string($subtype);\r
-               \r
-               // Todo: cache here? Or is looping less efficient that going to the db each time?\r
-               \r
-               $result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where type='$type' and subtype='$subtype'");\r
-               if ($result) {\r
-                       \r
-                       if (!$SUBTYPE_CACHE) \r
-                               $SUBTYPE_CACHE = array(); //select_default_memcache('subtype_cache');\r
-                       \r
-                       $SUBTYPE_CACHE[$result->id] = $result;\r
-                       return $result->class;\r
-               }\r
-               \r
-               return NULL;\r
-       }\r
-       \r
-       /**\r
-        * This function tests to see if a subtype has a registered class handler by its id.\r
-        * \r
-        * @param int $subtype_id The subtype\r
-        * @return a class name or null\r
-        */\r
-       function get_subtype_class_from_id($subtype_id)\r
-       {\r
-               global $CONFIG, $SUBTYPE_CACHE;\r
-               \r
-               $subtype_id = (int)$subtype_id;\r
-               \r
-               if (!$subtype_id) return false;\r
-               \r
-               if (isset($SUBTYPE_CACHE[$subtype_id]))\r
-                       return $SUBTYPE_CACHE[$subtype_id]->class;\r
-               \r
-               $result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where id=$subtype_id");\r
-               if ($result) {\r
-                       \r
-                       if (!$SUBTYPE_CACHE) \r
-                               $SUBTYPE_CACHE = array(); //select_default_memcache('subtype_cache');\r
-                       \r
-                       $SUBTYPE_CACHE[$subtype_id] = $result;\r
-                       return $result->class;\r
-               }\r
-               \r
-               return NULL;\r
-       }\r
-       \r
-       /**\r
-        * This function will register a new subtype, returning its ID as required.\r
-        * \r
-        * @param string $type The type you're subtyping\r
-        * @param string $subtype The subtype label\r
-        * @param string $class Optional class handler (if you don't want it handled by the generic elgg handler for the type)\r
-        */\r
-       function add_subtype($type, $subtype, $class = "")\r
-       {\r
-               global $CONFIG;\r
-               $type = sanitise_string($type);\r
-               $subtype = sanitise_string($subtype);\r
-               $class = sanitise_string($class);\r
-       \r
-               // Short circuit if no subtype is given\r
-               if ($subtype == "")\r
-                       return 0;\r
-\r
-               $id = get_subtype_id($type, $subtype);\r
-       \r
-               if ($id==0)\r
-                       return insert_data("insert into {$CONFIG->dbprefix}entity_subtypes (type, subtype, class) values ('$type','$subtype','$class')");\r
-               \r
-               return $id;\r
-       }\r
-       \r
-       /**\r
-        * Update an existing entity.\r
-        *\r
-        * @param int $guid\r
-        * @param int $owner_guid\r
-        * @param int $access_id\r
-        * @param int $container_guid\r
-        */\r
-       function update_entity($guid, $owner_guid, $access_id, $container_guid = null)\r
-       {\r
-               global $CONFIG, $ENTITY_CACHE;\r
-               \r
-               $guid = (int)$guid;\r
-               $owner_guid = (int)$owner_guid;\r
-               $access_id = (int)$access_id;\r
-               $container_guid = (int) $container_guid;\r
-               if (is_null($container_guid)) $container_guid = $owner_guid;\r
-               $time = time();\r
-\r
-               $entity = get_entity($guid);\r
-               \r
-               if ($entity->canEdit()) {\r
-                       \r
-                       if (trigger_elgg_event('update',$entity->type,$entity)) {\r
-                               $ret = update_data("UPDATE {$CONFIG->dbprefix}entities set owner_guid='$owner_guid', access_id='$access_id', container_guid='$container_guid', time_updated='$time' WHERE guid=$guid");\r
-                               \r
-                               if ($entity instanceof ElggObject)\r
-                                       update_river_access_by_object($guid,$access_id);\r
-                               \r
-                               // If memcache is available then delete this entry from the cache\r
-                               static $newentity_cache;\r
-                               if ((!$newentity_cache) && (is_memcache_available())) \r
-                                       $newentity_cache = new ElggMemcache('new_entity_cache');\r
-                               if ($newentity_cache) $new_entity = $newentity_cache->delete($guid);\r
-                               \r
-                               // Handle cases where there was no error BUT no rows were updated!\r
-                               if ($ret===false)\r
-                                       return false;\r
-                                       \r
-                               return true;\r
-                       }\r
-                       \r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Determine whether a given user is able to write to a given container.\r
-        *\r
-        * @param int $user_guid The user guid, or 0 for get_loggedin_userid()\r
-        * @param int $container_guid The container, or 0 for the current page owner.\r
-        */\r
-       function can_write_to_container($user_guid = 0, $container_guid = 0, $entity_type = 'all')\r
-       {\r
-               global $CONFIG;\r
-       \r
-               $user_guid = (int)$user_guid;\r
-               $user = get_entity($user_guid);\r
-               if (!$user) $user = get_loggedin_user();\r
-               \r
-               $container_guid = (int)$container_guid;\r
-               if (!$container_guid) $container_guid = page_owner();\r
-               if (!$container_guid) return true;\r
-\r
-               $container = get_entity($container_guid);\r
-               \r
-               if ($container)\r
-               {\r
-\r
-                       // If the user can edit the container, they can also write to it\r
-                       if ($container->canEdit($user_guid)) return true;\r
-               \r
-                       // Basics, see if the user is a member of the group.\r
-                       if ($user && $container instanceof ElggGroup) {\r
-                               if (!$container->isMember($user)) {\r
-                                       return false;\r
-                               } else {\r
-                                       return true;\r
-                               }\r
-                       }\r
-                       \r
-                       // See if anyone else has anything to say\r
-                       return trigger_plugin_hook('container_permissions_check',$entity_type,array('container' => $container, 'user' => $user), false);\r
-                       \r
-               }\r
-               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Create a new entity of a given type.\r
-        * \r
-        * @param string $type The type of the entity (site, user, object).\r
-        * @param string $subtype The subtype of the entity.\r
-        * @param int $owner_guid The GUID of the object's owner.\r
-        * @param int $access_id The access control group to create the entity with.\r
-        * @param int $site_guid The site to add this entity to. Leave as 0 (default) for the current site.\r
-        * @return mixed The new entity's GUID, or false on failure\r
-        */\r
-       function create_entity($type, $subtype, $owner_guid, $access_id, $site_guid = 0, $container_guid = 0)\r
-       {\r
-               global $CONFIG;\r
-       \r
-               $type = sanitise_string($type);\r
-               $subtype = add_subtype($type, $subtype);\r
-               $owner_guid = (int)$owner_guid; \r
-               $access_id = (int)$access_id;\r
-               $time = time();\r
-               if ($site_guid == 0)\r
-                       $site_guid = $CONFIG->site_guid;\r
-               $site_guid = (int) $site_guid;\r
-               if ($container_guid == 0) $container_guid = $owner_guid;\r
-               \r
-               $user = get_loggedin_user();\r
-               if (!can_write_to_container($user->guid, $owner_guid, $type)) return false;\r
-               if ($owner_guid != $container_guid)\r
-                       if (!can_write_to_container($user->guid, $container_guid, $type)) return false; \r
-               \r
-               if ($type=="") throw new InvalidParameterException(elgg_echo('InvalidParameterException:EntityTypeNotSet'));\r
-\r
-               return insert_data("INSERT into {$CONFIG->dbprefix}entities (type, subtype, owner_guid, site_guid, container_guid, access_id, time_created, time_updated) values ('$type',$subtype, $owner_guid, $site_guid, $container_guid, $access_id, $time, $time)"); \r
-       }\r
-       \r
-       /**\r
-        * Retrieve the entity details for a specific GUID, returning it as a stdClass db row.\r
-        * \r
-        * You will only get an object if a) it exists, b) you have access to it.\r
-        *\r
-        * @param int $guid The GUID of the object to extract\r
-        */\r
-       function get_entity_as_row($guid)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               if (!$guid) return false;\r
-               \r
-               $guid = (int) $guid;\r
-               \r
-               /*$row = retrieve_cached_entity_row($guid);\r
-               if ($row)\r
-               {\r
-                       // We have already cached this object, so retrieve its value from the cache\r
-                       if (isset($CONFIG->debug) && $CONFIG->debug)\r
-                               error_log("** Retrieving GUID:$guid from cache");\r
-\r
-                       return $row;\r
-               }\r
-               else\r
-               {*/     \r
-                       // Object not cached, load it.\r
-                       if (isset($CONFIG->debug) && $CONFIG->debug == true)\r
-                               error_log("** GUID:$guid loaded from DB");\r
-                       \r
-                       $access = get_access_sql_suffix();\r
-               \r
-                       return get_data_row("SELECT * from {$CONFIG->dbprefix}entities where guid=$guid and $access");\r
-               //}\r
-       }\r
-       \r
-       /**\r
-        * Create an Elgg* object from a given entity row. \r
-        */\r
-       function entity_row_to_elggstar($row)\r
-       {\r
-               if (!($row instanceof stdClass))\r
-                       return $row;\r
-                       \r
-               if ((!isset($row->guid)) || (!isset($row->subtype)))\r
-                       return $row;\r
-                       \r
-               $new_entity = false;\r
-                       \r
-               // Create a memcache cache if we can\r
-               static $newentity_cache;\r
-               if ((!$newentity_cache) && (is_memcache_available())) \r
-                       $newentity_cache = new ElggMemcache('new_entity_cache');\r
-               if ($newentity_cache) $new_entity = $newentity_cache->load($row->guid);\r
-               if ($new_entity) return $new_entity;\r
-\r
-               $classname = get_subtype_class_from_id($row->subtype);\r
-               if ($classname!="")\r
-               {\r
-                       if (class_exists($classname))\r
-                       {\r
-                               $new_entity = new $classname($row);\r
-                               \r
-                               if (!($new_entity instanceof ElggEntity))\r
-                                       throw new ClassException(sprintf(elgg_echo('ClassException:ClassnameNotClass'), $classname, 'ElggEntity'));\r
-                       }\r
-                       else\r
-                               error_log(sprintf(elgg_echo('ClassNotFoundException:MissingClass'), $classname));\r
-               }\r
-               else\r
-               {\r
-                       switch ($row->type)\r
-                       {\r
-                               case 'object' : \r
-                                       $new_entity = new ElggObject($row); break;\r
-                               case 'user' : \r
-                                       $new_entity = new ElggUser($row); break;\r
-                               case 'group' : \r
-                                       $new_entity = new ElggGroup($row); break;\r
-                               case 'site' : \r
-                                       $new_entity = new ElggSite($row); break;\r
-                               default: throw new InstallationException(sprintf(elgg_echo('InstallationException:TypeNotSupported'), $row->type));\r
-                       }\r
-                       \r
-               }\r
-               \r
-               // Cache entity if we have a cache available\r
-               if (($newentity_cache) && ($new_entity)) $newentity_cache->save($new_entity->guid, $new_entity);\r
-               \r
-               return $new_entity;\r
-       }\r
-       \r
-       /**\r
-        * Return the entity for a given guid as the correct object.\r
-        * @param int $guid The GUID of the entity\r
-        * @return a child of ElggEntity appropriate for the type.\r
-        */\r
-       function get_entity($guid)\r
-       {\r
-               static $newentity_cache;\r
-               $new_entity = false;\r
-               if ((!$newentity_cache) && (is_memcache_available())) \r
-                       $newentity_cache = new ElggMemcache('new_entity_cache');\r
-               if ($newentity_cache) $new_entity = $newentity_cache->load($guid);\r
-               if ($new_entity) return $new_entity;\r
-               \r
-               return entity_row_to_elggstar(get_entity_as_row($guid));\r
-       }\r
-       \r
-       /**\r
-        * Return entities matching a given query, or the number thereof\r
-        * \r
-        * @param string $type The type of entity (eg "user", "object" etc)\r
-        * @param string|array $subtype The arbitrary subtype of the entity or array(type1 => array('subtype1', ...'subtypeN'), ...)\r
-        * @param int $owner_guid The GUID of the owning user\r
-        * @param string $order_by The field to order by; by default, time_created desc\r
-        * @param int $limit The number of entities to return; 10 by default\r
-        * @param int $offset The indexing offset, 0 by default\r
-        * @param boolean $count Set to true to get a count rather than the entities themselves (limits and offsets don't apply in this context). Defaults to false.\r
-        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.\r
-        * @param int|array $container_guid The container or containers to get entities from (default: all containers).\r
-        * @param int $timelower The earliest time the entity can have been created. Default: all\r
-        * @param int $timeupper The latest time the entity can have been created. Default: all\r
-        * @return array A list of entities. \r
-        */\r
-       function get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null, $timelower = 0, $timeupper = 0)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               if ($subtype === false || $subtype === null || $subtype === 0)\r
-                       return false;\r
-               \r
-               if ($order_by == "") $order_by = "time_created desc";\r
-               $order_by = sanitise_string($order_by);\r
-               $limit = (int)$limit;\r
-               $offset = (int)$offset;\r
-               $site_guid = (int) $site_guid;\r
-               $timelower = (int) $timelower;\r
-               $timeupper = (int) $timeupper;\r
-               if ($site_guid == 0)\r
-                       $site_guid = $CONFIG->site_guid;\r
-                               \r
-               $where = array();\r
-               \r
-               if (is_array($subtype)) {\r
-                       $tempwhere = "";\r
-                       if (sizeof($subtype))\r
-                       foreach($subtype as $typekey => $subtypearray) {\r
-                               foreach($subtypearray as $subtypeval) {\r
-                                       $typekey = sanitise_string($typekey);\r
-                                       if (!empty($subtypeval)) {\r
-                                               if (!$subtypeval = (int) get_subtype_id($typekey, $subtypeval))\r
-                                                       return false;\r
-                                       } else {\r
-                                               // @todo: Setting subtype to 0 when $subtype = '' returns entities with\r
-                                               // no subtype.  This is different to the non-array behavior\r
-                                               // but may be required in some cases.\r
-                                               $subtypeval = 0;\r
-                                       }\r
-                                       if (!empty($tempwhere)) $tempwhere .= " or ";\r
-                                       $tempwhere .= "(type = '{$typekey}' and subtype = {$subtypeval})";\r
-                               }\r
-                       }\r
-                       if (!empty($tempwhere)) $where[] = "({$tempwhere})";\r
-                       \r
-               } else {\r
-               \r
-                       $type = sanitise_string($type);\r
-                       if ($subtype !== "" AND !$subtype = get_subtype_id($type, $subtype))\r
-                               return false;\r
-                       \r
-                       if ($type != "")\r
-                               $where[] = "type='$type'";\r
-                       if ($subtype!=="")\r
-                               $where[] = "subtype=$subtype";\r
-               }\r
-\r
-               if ($owner_guid != "") {\r
-                       if (!is_array($owner_guid)) {\r
-                               $owner_array = array($owner_guid);\r
-                               $owner_guid = (int) $owner_guid;\r
-                       //      $where[] = "owner_guid = '$owner_guid'";\r
-                       } else if (sizeof($owner_guid) > 0) {\r
-                               $owner_array = array_map('sanitise_int', $owner_guid);\r
-                               // Cast every element to the owner_guid array to int\r
-                       //      $owner_guid = array_map("sanitise_int", $owner_guid);\r
-                       //      $owner_guid = implode(",",$owner_guid);\r
-                       //      $where[] = "owner_guid in ({$owner_guid})";\r
-                       }\r
-                       if (is_null($container_guid)) {\r
-                               $container_guid = $owner_array;\r
-                       }\r
-               }\r
-               if ($site_guid > 0)\r
-                       $where[] = "site_guid = {$site_guid}";\r
-\r
-               if (!is_null($container_guid)) {\r
-                       if (is_array($container_guid)) {\r
-                               foreach($container_guid as $key => $val) $container_guid[$key] = (int) $val;\r
-                               $where[] = "container_guid in (" . implode(",",$container_guid) . ")";\r
-                       } else {\r
-                               $container_guid = (int) $container_guid;\r
-                               $where[] = "container_guid = {$container_guid}";\r
-                       }\r
-               }\r
-               if ($timelower)\r
-                       $where[] = "time_created >= {$timelower}";\r
-               if ($timeupper)\r
-                       $where[] = "time_created <= {$timeupper}";\r
-                       \r
-               if (!$count) {\r
-                       $query = "SELECT * from {$CONFIG->dbprefix}entities where ";\r
-               } else {\r
-                       $query = "SELECT count(guid) as total from {$CONFIG->dbprefix}entities where ";\r
-               }\r
-               foreach ($where as $w)\r
-                       $query .= " $w and ";\r
-               $query .= get_access_sql_suffix(); // Add access controls\r
-               if (!$count) {\r
-                       $query .= " order by $order_by";\r
-                       if ($limit) $query .= " limit $offset, $limit"; // Add order and limit\r
-                       $dt = get_data($query, "entity_row_to_elggstar");\r
-                       return $dt;\r
-               } else {\r
-                       $total = get_data_row($query);\r
-                       return $total->total;\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Returns a viewable list of entities\r
-        *\r
-        * @see elgg_view_entity_list\r
-        * \r
-        * @param string $type The type of entity (eg "user", "object" etc)\r
-        * @param string $subtype The arbitrary subtype of the entity\r
-        * @param int $owner_guid The GUID of the owning user\r
-        * @param int $limit The number of entities to display per page (default: 10)\r
-        * @param true|false $fullview Whether or not to display the full view (default: true)\r
-        * @param true|false $viewtypetoggle Whether or not to allow gallery view \r
-        * @param true|false $pagination Display pagination? Default: true\r
-        * @return string A viewable list of entities\r
-        */\r
-       function list_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = false, $pagination = true) {\r
-               \r
-               $offset = (int) get_input('offset');\r
-               $count = get_entities($type, $subtype, $owner_guid, "", $limit, $offset, true);\r
-               $entities = get_entities($type, $subtype, $owner_guid, "", $limit, $offset);\r
-\r
-               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Returns a viewable list of entities contained in a number of groups.\r
-        *\r
-        * @param string $subtype The arbitrary subtype of the entity\r
-        * @param int $owner_guid The GUID of the owning user\r
-        * @param int $container_guid The GUID of the containing group\r
-        * @param int $limit The number of entities to display per page (default: 10)\r
-        * @param true|false $fullview Whether or not to display the full view (default: true)\r
-        * @return string A viewable list of entities\r
-        */\r
-       function list_entities_groups($subtype = "", $owner_guid = 0, $container_guid = 0, $limit = 10, $fullview = true)\r
-       {\r
-               $offset = (int) get_input('offset');\r
-               $count = get_objects_in_group($container_guid, $subtype, $owner_guid, 0, "", $limit, $offset, true);\r
-               $entities = get_objects_in_group($container_guid, $subtype, $owner_guid, 0, "", $limit, $offset);\r
-\r
-               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview);\r
-       }\r
-       \r
-       /**\r
-        * Returns a list of months containing content specified by the parameters\r
-        *\r
-        * @param string $type The type of entity\r
-        * @param string $subtype The subtype of entity\r
-        * @param int $container_guid The container GUID that the entinties belong to\r
-        * @param int $site_guid The site GUID\r
-        * @return array|false Either an array of timestamps, or false on failure\r
-        */\r
-       function get_entity_dates($type = '', $subtype = '', $container_guid = 0, $site_guid = 0) {\r
-               \r
-               global $CONFIG;\r
-               \r
-               $site_guid = (int) $site_guid;\r
-               if ($site_guid == 0)\r
-                       $site_guid = $CONFIG->site_guid;\r
-                               \r
-               $where = array();\r
-               \r
-               if ($type != "") {\r
-                       $type = sanitise_string($type);\r
-                       $where[] = "type='$type'";\r
-               }\r
-               \r
-               if (is_array($subtype)) {                       \r
-                       $tempwhere = "";\r
-                       if (sizeof($subtype))\r
-                       foreach($subtype as $typekey => $subtypearray) {\r
-                               foreach($subtypearray as $subtypeval) {\r
-                                       $typekey = sanitise_string($typekey);\r
-                                       if (!empty($subtypeval)) {\r
-                                               if (!$subtypeval = (int) get_subtype_id($typekey, $subtypeval))\r
-                                                       return false;\r
-                                       } else {\r
-                                               $subtypeval = 0;\r
-                                       }\r
-                                       if (!empty($tempwhere)) $tempwhere .= " or ";\r
-                                       $tempwhere .= "(type = '{$typekey}' and subtype = {$subtypeval})";\r
-                               }                                                               \r
-                       }\r
-                       if (!empty($tempwhere)) $where[] = "({$tempwhere})";\r
-                       \r
-               } else {\r
-                       if ($subtype AND !$subtype = get_subtype_id($type, $subtype)) {\r
-                               return false;\r
-                       } else {\r
-                               $where[] = "subtype=$subtype";\r
-                       }\r
-               }\r
-               \r
-               if ($container_guid !== 0) {\r
-                       if (is_array($container_guid)) {\r
-                               foreach($container_guid as $key => $val) $container_guid[$key] = (int) $val;\r
-                               $where[] = "container_guid in (" . implode(",",$container_guid) . ")";\r
-                       } else {\r
-                               $container_guid = (int) $container_guid;\r
-                               $where[] = "container_guid = {$container_guid}";\r
-                       }\r
-               }\r
-               \r
-               if ($site_guid > 0)\r
-                       $where[] = "site_guid = {$site_guid}";\r
-               \r
-               $where[] = get_access_sql_suffix();\r
-                       \r
-               $sql = "SELECT DISTINCT EXTRACT(YEAR_MONTH FROM FROM_UNIXTIME(time_created)) AS yearmonth FROM {$CONFIG->dbprefix}entities where ";\r
-               foreach ($where as $w) \r
-                       $sql .= " $w and ";\r
-               $sql .= "1=1";\r
-               if ($result = get_data($sql)) {\r
-                       $endresult = array();\r
-                       foreach($result as $res) {\r
-                               $endresult[] = $res->yearmonth;\r
-                       }\r
-                       return $endresult;\r
-               }\r
-               return false;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Disable an entity but not delete it.\r
-        *\r
-        * @param int $guid The guid\r
-        * @param string $reason Optional reason\r
-        */\r
-       function disable_entity($guid, $reason = "", $recursive = true)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $guid = (int)$guid;\r
-               $reason = sanitise_string($reason);\r
-               \r
-               if ($entity = get_entity($guid)) {              \r
-                       if (trigger_elgg_event('disable',$entity->type,$entity)) {      \r
-                               if ($entity->canEdit()) {\r
-                                       \r
-                                       if ($reason)\r
-                                               create_metadata($guid, 'disable_reason', $reason,'', 0, ACCESS_PUBLIC);\r
-\r
-                                       if ($recursive)\r
-                                       {\r
-                                               // Temporary token overriding access controls TODO: Do this better.\r
-                                               static $__RECURSIVE_DELETE_TOKEN;\r
-                                               $__RECURSIVE_DELETE_TOKEN = md5(get_loggedin_userid()); // Make it slightly harder to guess\r
-                                               \r
-                                               $sub_entities = get_data("SELECT * from {$CONFIG->dbprefix}entities WHERE container_guid=$guid or owner_guid=$guid or site_guid=$guid", 'entity_row_to_elggstar');\r
-                                               if ($sub_entities) {\r
-                                                       foreach ($sub_entities as $e)\r
-                                                               $e->disable($reason);\r
-                                               }\r
-                                                       \r
-                                               $__RECURSIVE_DELETE_TOKEN = null; \r
-                                       }\r
-                                                                                       \r
-                                       $res = update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='no' where guid={$guid}");\r
-                                       \r
-                                       return $res;\r
-                               } \r
-                       }\r
-               }\r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Enable an entity again.\r
-        *\r
-        * @param int $guid\r
-        */\r
-       function enable_entity($guid)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $guid = (int)$guid;\r
-               \r
-               // Override access only visible entities\r
-               $access_status = access_get_show_hidden_status();\r
-               access_show_hidden_entities(true);\r
-               \r
-               if ($entity = get_entity($guid)) {\r
-                       if (trigger_elgg_event('enable',$entity->type,$entity)) {\r
-                               if ($entity->canEdit()) {\r
-                                       \r
-                                       access_show_hidden_entities($access_status);\r
-                               \r
-                                       $result = update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='yes' where guid={$guid}");\r
-                                       $entity->clearMetaData('disable_reason');\r
-                                       \r
-                                       return $result;\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               access_show_hidden_entities($access_status);\r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Delete a given entity.\r
-        * \r
-        * @param int $guid\r
-        * @param bool $recursive If true (default) then all entities which are owned or contained by $guid will also be deleted.\r
-        *                                                 Note: this bypasses ownership of sub items.\r
-        */\r
-       function delete_entity($guid, $recursive = true)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $guid = (int)$guid;\r
-               if ($entity = get_entity($guid)) {\r
-                       if (trigger_elgg_event('delete',$entity->type,$entity)) {\r
-                               if ($entity->canEdit()) {\r
-                                       \r
-                                       // Delete contained owned and otherwise releated objects (depth first)\r
-                                       if ($recursive)\r
-                                       {\r
-                                               // Temporary token overriding access controls TODO: Do this better.\r
-                                               static $__RECURSIVE_DELETE_TOKEN;\r
-                                               $__RECURSIVE_DELETE_TOKEN = md5(get_loggedin_userid()); // Make it slightly harder to guess\r
-                                               \r
-                                               $sub_entities = get_data("SELECT * from {$CONFIG->dbprefix}entities WHERE container_guid=$guid or owner_guid=$guid or site_guid=$guid", 'entity_row_to_elggstar');\r
-                                               if ($sub_entities) {\r
-                                                       foreach ($sub_entities as $e)\r
-                                                               $e->delete();\r
-                                               }\r
-                                                       \r
-                                               $__RECURSIVE_DELETE_TOKEN = null; \r
-                                       }\r
-                                       \r
-                                       // Now delete the entity itself\r
-                                       $entity->clearMetadata();\r
-                                       $entity->clearAnnotations();\r
-                                       $entity->clearRelationships();\r
-                                       remove_from_river_by_subject($guid);\r
+                       if ($md && !is_array($md)) {
+                               return $md->value;
+                       } else if ($md && is_array($md)) {
+                               return metadata_array_to_values($md);
+                       }
+                               
+                       return null;
+               }
+               
+               /**
+                * Class member get overloading
+                *
+                * @param string $name
+                * @return mixed
+                */
+               function __get($name) { return $this->get($name); }
+               
+               /**
+                * Class member set overloading
+                *
+                * @param string $name
+                * @param mixed $value
+                * @return mixed
+                */
+               function __set($name, $value) { return $this->set($name, $value); }
+               
+               /**
+                * Supporting isset.
+                *
+                * @param string $name The name of the attribute or metadata.
+                * @return bool
+                */
+               function __isset($name) { if ($this->$name!="") return true; else return false; }
+               
+               /**
+                * Supporting unsetting of magic attributes.
+                *
+                * @param string $name The name of the attribute or metadata.
+                */
+               function __unset($name)
+               {
+                       if (array_key_exists($name, $this->attributes))
+                               $this->attributes[$name] = "";
+                       else
+                               $this->clearMetaData($name);
+               }
+               
+               /**
+                * Set a piece of metadata.
+                * 
+                * @param string $name
+                * @param mixed $value
+                * @param string $value_type
+                * @param bool $multiple
+                * @return bool
+                */
+               public function setMetaData($name, $value, $value_type = "", $multiple = false)
+               {
+                       if (is_array($value))
+                       {
+                               unset($this->temp_metadata[$name]);
+                               remove_metadata($this->getGUID(), $name);
+                               foreach ($value as $v) {
+                                       if ((int) $this->guid > 0) {
+                                               $multiple = true;
+                                               if (!create_metadata($this->getGUID(), $name, $v, $value_type, $this->getOwner(), $this->getAccessID(), $multiple)) return false;
+                                       } else {
+                                               if (($multiple) && (isset($this->temp_metadata[$name])))
+                                               {
+                                                       if (!is_array($this->temp_metadata[$name]))
+                                                       {
+                                                               $tmp = $this->temp_metadata[$name];
+                                                               $this->temp_metadata[$name] = array();
+                                                               $this->temp_metadata[$name][] = $tmp;
+                                                       }
+                                                       
+                                                       $this->temp_metadata[$name][] = $value;
+                                               }
+                                               else
+                                                       $this->temp_metadata[$name] = $value;
+                                       }
+                               }
+                                       
+                               return true;
+                       }
+                       else
+                       {
+                               unset($this->temp_metadata[$name]);
+                               if ((int) $this->guid > 0) {
+                                       return create_metadata($this->getGUID(), $name, $value, $value_type, $this->getOwner(), $this->getAccessID(), $multiple);
+                               } else {
+                                       //$this->temp_metadata[$name] = $value;
+                                       
+                                       if (($multiple) && (isset($this->temp_metadata[$name])))
+                                       {
+                                               if (!is_array($this->temp_metadata[$name]))
+                                               {
+                                                       $tmp = $this->temp_metadata[$name];
+                                                       $this->temp_metadata[$name] = array();
+                                                       $this->temp_metadata[$name][] = $tmp;
+                                               }
+                                               
+                                               $this->temp_metadata[$name][] = $value;
+                                       }
+                                       else
+                                               $this->temp_metadata[$name] = $value;
+                                                       
+                                       return true;
+                               }
+                       }
+               }
+               
+               /**
+                * Clear metadata.
+                */
+               public function clearMetaData($name = "")
+               {
+                       if (empty($name)) {
+                               return clear_metadata($this->getGUID());
+                       } else {
+                               return remove_metadata($this->getGUID(),$name);
+                       }
+               }
+               
+               /**
+                * Remove all entities associated with this entity
+                *
+                * @return true
+                */
+               public function clearRelationships() {
+                       remove_entity_relationships($this->getGUID());
+                       remove_entity_relationships($this->getGUID(),"",true);
+                       return true;
+               }
+               
+               /**
+                * Add a relationship.
+                *
+                * @param int $guid Relationship to link to.
+                * @param string $relationship The type of relationship.
+                */
+               public function addRelationship($guid, $relationship)
+               {
+                       return add_entity_relationship($this->getGUID(), $relationship, $guid);
+               }
+               
+               function setPrivateSetting($name, $value) {
+                       return set_private_setting($this->getGUID(), $name, $value);
+               }
+               
+               function getPrivateSetting($name) {
+                       return get_private_setting($this->getGUID(), $name);
+               }
+               
+               function removePrivateSetting($name) {
+                       return remove_private_setting($this->getGUID(), $name);
+               }
+               
+               /**
+                * Adds an annotation to an entity. By default, the type is detected automatically; however, 
+                * it can also be set. Note that by default, annotations are private.
+                * 
+                * @param string $name
+                * @param mixed $value
+                * @param int $access_id
+                * @param int $owner_id
+                * @param string $vartype
+                */
+               function annotate($name, $value, $access_id = ACCESS_PRIVATE, $owner_id = 0, $vartype = "") 
+               { 
+                       if ((int) $this->guid > 0) {
+                               return create_annotation($this->getGUID(), $name, $value, $vartype, $owner_id, $access_id);
+                       } else {
+                               $this->temp_annotations[$name] = $value;
+                       }
+                       return true;
+               }
+               
+               /**
+                * Get the annotations for an entity.
+                *
+                * @param string $name
+                * @param int $limit
+                * @param int $offset
+                * @param string $order
+                */
+               function getAnnotations($name, $limit = 50, $offset = 0, $order="asc") 
+               { 
+                       if ((int) ($this->guid) > 0) {
+                               return get_annotations($this->getGUID(), "", "", $name, "", 0, $limit, $offset, $order);
+                       } else {
+                               return $this->temp_annotations[$name];
+                       }
+               }
+               
+               /**
+                * Remove all annotations or all annotations for this entity.
+                *
+                * @param string $name
+                */
+               function clearAnnotations($name = "")
+               {
+                       return clear_annotations($this->getGUID(), $name);
+               }
+               
+               /**
+                * Return the annotations for the entity.
+                *
+                * @param string $name The type of annotation.
+                */
+               function countAnnotations($name = "") 
+               { 
+                       return count_annotations($this->getGUID(), "","",$name);
+               }
+
+               /**
+                * Get the average of an integer type annotation.
+                *
+                * @param string $name
+                */
+               function getAnnotationsAvg($name) 
+               {
+                       return get_annotations_avg($this->getGUID(), "","",$name);
+               }
+               
+               /**
+                * Get the sum of integer type annotations of a given name.
+                *
+                * @param string $name
+                */
+               function getAnnotationsSum($name) 
+               {
+                       return get_annotations_sum($this->getGUID(), "","",$name);
+               }
+               
+               /**
+                * Get the minimum of integer type annotations of given name.
+                *
+                * @param string $name
+                */
+               function getAnnotationsMin($name)
+               {
+                       return get_annotations_min($this->getGUID(), "","",$name);
+               }
+               
+               /**
+                * Get the maximum of integer type annotations of a given name.
+                *
+                * @param string $name
+                */
+               function getAnnotationsMax($name)
+               {
+                       return get_annotations_max($this->getGUID(), "","",$name);
+               }
+               
+               /**
+                * Gets an array of entities from a specific relationship type
+                *
+                * @param string $relationship Relationship type (eg "friends")
+                * @param true|false $inverse Is this an inverse relationship?
+                * @param int $limit Number of elements to return
+                * @param int $offset Indexing offset
+                * @return array|false An array of entities or false on failure
+                */             
+               function getEntitiesFromRelationship($relationship, $inverse = false, $limit = 50, $offset = 0) {
+                       return get_entities_from_relationship($relationship,$this->getGUID(),$inverse,"","","","time_created desc",$limit,$offset);                     
+               }
+               
+               /**
+                * Gets the number of of entities from a specific relationship type
+                *
+                * @param string $relationship Relationship type (eg "friends")
+                * @return int|false The number of entities or false on failure
+                */             
+               function countEntitiesFromRelationship($relationship) {
+                       return get_entities_from_relationship($relationship,$this->getGUID(),false,"","","","time_created desc",null,null,true);                        
+               }
+               
+               /**
+                * Determines whether or not the specified user (by default the current one) can edit the entity 
+                *
+                * @param int $user_guid The user GUID, optionally (defaults to the currently logged in user)
+                * @return true|false
+                */
+               function canEdit($user_guid = 0) {
+                       return can_edit_entity($this->getGUID(),$user_guid);
+               }
+               
+               /**
+                * Determines whether or not the specified user (by default the current one) can edit metadata on the entity 
+                *
+                * @param ElggMetadata $metadata The piece of metadata to specifically check
+                * @param int $user_guid The user GUID, optionally (defaults to the currently logged in user)
+                * @return true|false
+                */
+               function canEditMetadata($metadata = null, $user_guid = 0) {
+                       return can_edit_entity_metadata($this->getGUID(), $user_guid, $metadata);
+               }
+               
+               /**
+                * Returns whether the given user (or current user) has the ability to write to this group.
+                *
+                * @param int $user_guid The user.
+                * @return bool
+                */
+               public function canWriteToContainer($user_guid = 0)
+               {
+                       return can_write_to_container($user_guid, $this->getGUID());
+               }
+               
+               /**
+                * Obtain this entity's access ID
+                *
+                * @return int The access ID
+                */
+               public function getAccessID() { return $this->get('access_id'); }
+               
+               /**
+                * Obtain this entity's GUID
+                *
+                * @return int GUID
+                */
+               public function getGUID() { return $this->get('guid'); }
+               
+               /**
+                * Get the owner of this entity
+                *
+                * @return int The owner GUID
+                */
+               public function getOwner() { return $this->get('owner_guid'); }
+               
+               /**
+                * Returns the actual entity of the user who owns this entity, if any
+                *
+                * @return ElggEntity The owning user
+                */
+               public function getOwnerEntity() { return get_entity($this->get('owner_guid')); }
+               
+               /**
+                * Gets the type of entity this is
+                *
+                * @return string Entity type
+                */
+               public function getType() { return $this->get('type'); }
+               
+               /**
+                * Returns the subtype of this entity
+                *
+                * @return string The entity subtype
+                */
+               public function getSubtype() {
+                       if (!((int) $this->guid > 0)) return $this->get('subtype'); // If this object hasn't been saved, then return the subtype string.
+                       
+                       return get_subtype_from_id($this->get('subtype')); 
+               }
+               
+               /**
+                * Gets the UNIX epoch time that this entity was created
+                *
+                * @return int UNIX epoch time
+                */
+               public function getTimeCreated() { return $this->get('time_created'); }
+               
+               /**
+                * Gets the UNIX epoch time that this entity was last updated
+                *
+                * @return int UNIX epoch time
+                */
+               public function getTimeUpdated() { return $this->get('time_updated'); }
+               
+               /**
+                * Gets the display URL for this entity
+                *
+                * @return string The URL
+                */
+               public function getURL() {
+                       if (!empty($this->url_override)) return $this->url_override;
+                       return get_entity_url($this->getGUID()); 
+               }
+               
+               /**
+                * Overrides the URL returned by getURL
+                *
+                * @param string $url The new item URL
+                * @return string The URL
+                */
+               public function setURL($url) {
+                       $this->url_override = $url;
+                       return $url;
+               }
+               
+               /**
+                * Return a url for the entity's icon, trying multiple alternatives.
+                *
+                * @param string $size Either 'large','medium','small' or 'tiny'
+                * @return string The url or false if no url could be worked out.
+                */
+               public function getIcon($size = 'medium')
+               {
+                       if (isset($this->icon_override[$size])) return $this->icon_override[$size];
+                       return get_entity_icon_url($this, $size);
+               }
+               
+               /**
+                * Set an icon override for an icon and size.
+                *
+                * @param string $url The url of the icon.
+                * @param string $size The size its for.
+                * @return bool
+                */
+               public function setIcon($url, $size = 'medium')
+               {
+                       $url = sanitise_string($url);
+                       $size = sanitise_string($size);
+                       
+                       if (!$this->icon_override) $this->icon_override = array();
+                       $this->icon_override[$size] = $url;
+                       
+                       return true;
+               }
+               
+               /**
+                * Tests to see whether the object has been fully loaded.
+                * 
+                * @return bool
+                */
+               public function isFullyLoaded() { return ! ($this->attributes['tables_loaded'] < $this->attributes['tables_split']); }
+               
+               /**
+                * Save generic attributes to the entities table.
+                */
+               public function save()
+               {
+                       $guid = (int) $this->guid;
+                       if ($guid > 0)
+                       { 
+                               cache_entity($this);
+
+                               return update_entity(
+                                       $this->get('guid'),
+                                       $this->get('owner_guid'),
+                                       $this->get('access_id'),
+                                       $this->get('container_guid')
+                               );
+                       }
+                       else
+                       { 
+                               $this->attributes['guid'] = create_entity($this->attributes['type'], $this->attributes['subtype'], $this->attributes['owner_guid'], $this->attributes['access_id'], $this->attributes['site_guid'], $this->attributes['container_guid']); // Create a new entity (nb: using attribute array directly 'cos set function does something special!)
+                               if (!$this->attributes['guid']) throw new IOException(elgg_echo('IOException:BaseEntitySaveFailed')); 
+                               
+                               // Save any unsaved metadata TODO: How to capture extra information (access id etc)
+                               if (sizeof($this->temp_metadata) > 0) {
+                                       foreach($this->temp_metadata as $name => $value) {
+                                               $this->$name = $value;
+                                               unset($this->temp_metadata[$name]);
+                                       }
+                               }
+                               
+                               // Save any unsaved annotations metadata. TODO: How to capture extra information (access id etc)
+                               if (sizeof($this->temp_annotations) > 0) {
+                                       foreach($this->temp_annotations as $name => $value) {
+                                               $this->annotate($name, $value);
+                                               unset($this->temp_annotations[$name]);
+                                       }
+                               }
+                               
+                               // Cache object handle
+                               if ($this->attributes['guid']) cache_entity($this); 
+                               
+                               return $this->attributes['guid'];
+                       }
+               }
+               
+               /**
+                * Load the basic entity information and populate base attributes array.
+                * 
+                * @param int $guid 
+                */
+               protected function load($guid)
+               {               
+                       $row = get_entity_as_row($guid); 
+                       
+                       if ($row)
+                       {
+                               // Create the array if necessary - all subclasses should test before creating
+                               if (!is_array($this->attributes)) $this->attributes = array();
+                               
+                               // Now put these into the attributes array as core values
+                               $objarray = (array) $row;
+                               foreach($objarray as $key => $value) 
+                                       $this->attributes[$key] = $value;
+                               
+                               // Increment the portion counter
+                               if (!$this->isFullyLoaded()) $this->attributes['tables_loaded'] ++;
+                               
+                               // Cache object handle
+                               if ($this->attributes['guid']) cache_entity($this); 
+                                       
+                               return true;
+                       }
+                       
+                       return false;
+               }
+               
+               /**
+                * Disable this entity.
+                * 
+                * @param string $reason Optional reason
+                * @param bool $recursive Recursively disable all contained entities?
+                */
+               public function disable($reason = "", $recursive = true)
+               {
+                       return disable_entity($this->get('guid'), $reason, $recursive);
+               }
+               
+               /**
+                * Re-enable this entity.
+                */
+               public function enable()
+               {
+                       return enable_entity($this->get('guid'));
+               }
+               
+               /**
+                * Is this entity enabled?
+                *
+                * @return boolean
+                */
+               public function isEnabled()
+               {
+                       if ($this->enabled == 'yes')
+                               return true;
+                               
+                       return false;
+               }
+               
+               /**
+                * Delete this entity.
+                */
+               public function delete() 
+               { 
+                       return delete_entity($this->get('guid'));
+               }
+               
+               // LOCATABLE INTERFACE /////////////////////////////////////////////////////////////
+               
+               /** Interface to set the location */
+               public function setLocation($location)
+               {
+                       $location = sanitise_string($location);
+                       
+                       $this->location = $location;
+                       
+                       return true;
+               }
+               
+               /**
+                * Set latitude and longitude tags for a given entity.
+                *
+                * @param float $lat
+                * @param float $long
+                */
+               public function setLatLong($lat, $long)
+               {
+                       $lat = sanitise_string($lat);
+                       $long = sanitise_string($long);
+                       
+                       $this->set('geo:lat', $lat);
+                       $this->set('geo:long', $long);
+                       
+                       return true;
+               }
+               
+               /**
+                * Get the contents of the ->geo:lat field.
+                *
+                */
+               public function getLatitude() { return $this->get('geo:lat'); }
+               
+               /**
+                * Get the contents of the ->geo:lat field.
+                *
+                */
+               public function getLongitude() { return $this->get('geo:long'); }
+               
+               /**
+                * Get the ->location metadata. 
+                *
+                */
+               public function getLocation() { return $this->get('location'); }
+               
+               // NOTABLE INTERFACE ///////////////////////////////////////////////////////////////
+               
+               /**
+                * Calendar functionality.
+                * This function sets the time of an object on a calendar listing.
+                *
+                * @param int $hour If ommitted, now is assumed.
+                * @param int $minute If ommitted, now is assumed.
+                * @param int $second If ommitted, now is assumed.
+                * @param int $day If ommitted, now is assumed.
+                * @param int $month If ommitted, now is assumed.
+                * @param int $year If ommitted, now is assumed.
+                * @param int $duration Duration of event, remainder of the day is assumed.
+                */
+               public function setCalendarTimeAndDuration($hour = NULL, $minute = NULL, $second = NULL, $day = NULL, $month = NULL, $year = NULL, $duration = NULL)
+               {
+                       $start = mktime($hour, $minute, $second, $month, $day, $year);
+                       $end = $start + abs($duration);
+                       if (!$duration)
+                               $end = get_day_end($day,$month,$year);
+                       
+                       $this->calendar_start = $start; 
+                       $this->calendar_end = $end;
+                               
+                       return true;
+               }
+               
+               /**
+                * Return the start timestamp.
+                */
+               public function getCalendarStartTime() { return (int)$this->calendar_start; }
+               
+               /**
+                * Return the end timestamp.
+                */
+               public function getCalendarEndTime() { return (int)$this->calendar_end; }
+               
+               // EXPORTABLE INTERFACE ////////////////////////////////////////////////////////////
+               
+               /**
+                * Return an array of fields which can be exported.
+                */
+               public function getExportableValues()
+               {
+                       return array(
+                               'guid',
+                               'type',
+                               'subtype',
+                               'time_created',
+                               'container_guid',
+                               'owner_guid', 
+                       );
+               }
+               
+               /**
+                * Export this class into an array of ODD Elements containing all necessary fields.
+                * Override if you wish to return more information than can be found in $this->attributes (shouldn't happen) 
+                */
+               public function export() 
+               { 
+                       $tmp = array();
+                       
+                       // Generate uuid
+                       $uuid = guid_to_uuid($this->getGUID());
+                       
+                       // Create entity 
+                       $odd = new ODDEntity(
+                               $uuid,
+                               $this->attributes['type'], 
+                               get_subtype_from_id($this->attributes['subtype'])
+                       );
+                       
+                       $tmp[] = $odd;
+                       
+                       $exportable_values = $this->getExportableValues();
+                       
+                       // Now add its attributes
+                       foreach ($this->attributes as $k => $v)
+                       {
+                               $meta = NULL;
+                               
+                               if (in_array( $k, $exportable_values)) { 
+                                       switch ($k)
+                                       {
+                                               case 'guid' :                   // Dont use guid in OpenDD
+                                               case 'type' :                   // Type and subtype already taken care of
+                                               case 'subtype' : 
+                                               break;
+                                               
+                                               case 'time_created' :   // Created = published
+                                                       $odd->setAttribute('published', date("r", $v));
+                                               break;
+                                               
+                                               case 'site_guid' : // Container
+                                                       $k = 'site_uuid';
+                                                       $v = guid_to_uuid($v);
+                                                       $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v);
+                                               break;
+                                               
+                                               case 'container_guid' : // Container
+                                                       $k = 'container_uuid';
+                                                       $v = guid_to_uuid($v);
+                                                       $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v);
+                                               break;
+       
+                                               case 'owner_guid' :                     // Convert owner guid to uuid, this will be stored in metadata
+                                                        $k = 'owner_uuid';
+                                                        $v = guid_to_uuid($v);
+                                                        $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v);
+                                               break;  
+                                               
+                                               default : 
+                                                       $meta = new ODDMetaData($uuid . "attr/$k/", $uuid, $k, $v);
+                                       }
+                                       
+                                       // set the time of any metadata created
+                                       if ($meta)
+                                       {
+                                               $meta->setAttribute('published', date("r",$this->time_created));
+                                               $tmp[] = $meta;
+                                       }
+                               }
+                       }
+                       
+                       // Now we do something a bit special.
+                       /*
+                        * This provides a rendered view of the entity to foreign sites.
+                        */
+                       
+                       elgg_set_viewtype('default');
+                       $view = elgg_view_entity($this, true);
+                       elgg_set_viewtype();
+                                       
+                       $tmp[] = new ODDMetaData($uuid . "volatile/renderedentity/", $uuid, 'renderedentity', $view , 'volatile');
+                       
+                       
+                       return $tmp;
+               }
+               
+               // IMPORTABLE INTERFACE ////////////////////////////////////////////////////////////
+               
+               /**
+                * Import data from an parsed xml data array.
+                * 
+                * @param array $data
+                * @param int $version 
+                */
+               public function import(ODD $data)
+               {
+                       if (!($data instanceof ODDEntity))
+                               throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnexpectedODDClass')); 
+                       
+                       // Set type and subtype
+                       $this->attributes['type'] = $data->getAttribute('class');
+                       $this->attributes['subtype'] = $data->getAttribute('subclass');
+                       
+                       // Set owner
+                       $this->attributes['owner_guid'] = get_loggedin_userid(); // Import as belonging to importer.
+                       
+                       // Set time
+                       $this->attributes['time_created'] = strtotime($data->getAttribute('published'));
+                       $this->attributes['time_updated'] = time();
+                       
+                       return true;
+               }
+               
+               // SYSTEM LOG INTERFACE ////////////////////////////////////////////////////////////
+               
+               /**
+                * Return an identification for the object for storage in the system log. 
+                * This id must be an integer.
+                * 
+                * @return int 
+                */
+               public function getSystemLogID() { return $this->getGUID();     }
+               
+               /**
+                * Return the class name of the object.
+                */
+               public function getClassName() { return get_class($this); }
+               
+               /**
+                * For a given ID, return the object associated with it.
+                * This is used by the river functionality primarily.
+                * This is useful for checking access permissions etc on objects.
+                */
+               public function getObjectFromID($id) { return get_entity($id); }
+               
+               /**
+                * Return the GUID of the owner of this object.
+                */
+               public function getObjectOwnerGUID() { return $this->owner_guid; }
+
+               // ITERATOR INTERFACE //////////////////////////////////////////////////////////////
+               /*
+                * This lets an entity's attributes be displayed using foreach as a normal array.
+                * Example: http://www.sitepoint.com/print/php5-standard-library
+                */
+               
+               private $valid = FALSE; 
+               
+               function rewind() 
+               { 
+                       $this->valid = (FALSE !== reset($this->attributes));  
+               }
+   
+               function current() 
+               { 
+                       return current($this->attributes); 
+               }
+               
+               function key() 
+               { 
+                       return key($this->attributes); 
+               }
+               
+               function next() 
+               {
+                       $this->valid = (FALSE !== next($this->attributes));  
+               }
+               
+               function valid() 
+               { 
+                       return $this->valid;  
+               }
+       
+               // ARRAY ACCESS INTERFACE //////////////////////////////////////////////////////////
+               /*
+                * This lets an entity's attributes be accessed like an associative array.
+                * Example: http://www.sitepoint.com/print/php5-standard-library
+                */
+
+               function offsetSet($key, $value)
+               {
+                       if ( array_key_exists($key, $this->attributes) ) {
+                       $this->attributes[$key] = $value;
+                       }
+               } 
+               
+               function offsetGet($key) 
+               {
+                       if ( array_key_exists($key, $this->attributes) ) {
+                       return $this->attributes[$key];
+                       }
+               } 
+               
+               function offsetUnset($key) 
+               {
+                       if ( array_key_exists($key, $this->attributes) ) {
+                       $this->attributes[$key] = ""; // Full unsetting is dangerious for our objects
+                       }
+               } 
+               
+               function offsetExists($offset) 
+               {
+                       return array_key_exists($offset, $this->attributes);
+               } 
+       }
+
+       /**
+        * Initialise the entity cache.
+        */
+       function initialise_entity_cache()
+       {
+               global $ENTITY_CACHE;
+               
+               if (!$ENTITY_CACHE)
+                       $ENTITY_CACHE = array(); //select_default_memcache('entity_cache'); // TODO: Replace with memcache?
+       }
+       
+       /**
+        * Invalidate this class' entry in the cache.
+        * 
+        * @param int $guid The guid
+        */
+       function invalidate_cache_for_entity($guid)
+       {
+               global $ENTITY_CACHE;
+               
+               $guid = (int)$guid;
+                       
+               unset($ENTITY_CACHE[$guid]);
+               //$ENTITY_CACHE->delete($guid);         
+       }
+       
+       /**
+        * Cache an entity.
+        * 
+        * @param ElggEntity $entity Entity to cache
+        */
+       function cache_entity(ElggEntity $entity)
+       {
+               global $ENTITY_CACHE;
+               
+               $ENTITY_CACHE[$entity->guid] = $entity;
+       }
+       
+       /**
+        * Retrieve a entity from the cache.
+        * 
+        * @param int $guid The guid
+        */
+       function retrieve_cached_entity($guid)
+       {
+               global $ENTITY_CACHE;
+               
+               $guid = (int)$guid;
+                       
+               if (isset($ENTITY_CACHE[$guid])) 
+                       if ($ENTITY_CACHE[$guid]->isFullyLoaded()) return $ENTITY_CACHE[$guid];
+                               
+               return false;
+       }
+       
+       /**
+        * As retrieve_cached_entity, but returns the result as a stdClass (compatible with load functions that
+        * expect a database row.)
+        * 
+        * @param int $guid The guid
+        */
+       function retrieve_cached_entity_row($guid)
+       {
+               $obj = retrieve_cached_entity($guid);
+               if ($obj)
+               {
+                       $tmp = new stdClass;
+                       
+                       foreach ($obj as $k => $v)
+                               $tmp->$k = $v;
+                               
+                       return $tmp;
+               }
+
+               return false;
+       }
+       
+       /**
+        * Return the integer ID for a given subtype, or false.
+        * 
+        * TODO: Move to a nicer place?
+        * 
+        * @param string $type
+        * @param string $subtype
+        */
+       function get_subtype_id($type, $subtype)
+       {
+               global $CONFIG, $SUBTYPE_CACHE;
+               
+               $type = sanitise_string($type);
+               $subtype = sanitise_string($subtype);
+       
+               if ($subtype=="") return $subtype;
+               
+               // Todo: cache here? Or is looping less efficient that going to the db each time?
+               
+               $result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where type='$type' and subtype='$subtype'");
+
+               if ($result) {
+                       
+                       if (!$SUBTYPE_CACHE) 
+                               $SUBTYPE_CACHE = array(); //select_default_memcache('subtype_cache');
+                       
+                       $SUBTYPE_CACHE[$result->id] = $result;
+                       return $result->id;
+               }
+               
+               return 0;
+       }
+       
+       /**
+        * For a given subtype ID, return its identifier text.
+        *  
+        * TODO: Move to a nicer place?
+        * 
+        * @param int $subtype_id
+        */
+       function get_subtype_from_id($subtype_id)
+       {
+               global $CONFIG, $SUBTYPE_CACHE;
+               
+               $subtype_id = (int)$subtype_id;
+               
+               if (!$subtype_id) return false;
+               
+               if (isset($SUBTYPE_CACHE[$subtype_id]))
+                       return $SUBTYPE_CACHE[$subtype_id]->subtype;
+               
+               $result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where id=$subtype_id");
+               if ($result) {
+                       
+                       if (!$SUBTYPE_CACHE) 
+                               $SUBTYPE_CACHE = array(); //select_default_memcache('subtype_cache');
+                       
+                       $SUBTYPE_CACHE[$subtype_id] = $result;
+                       return $result->subtype;
+               }
+               
+               return false;
+       }
+       
+       /**
+        * This function tests to see if a subtype has a registered class handler.
+        * 
+        * @param string $type The type
+        * @param string $subtype The subtype
+        * @return a class name or null
+        */
+       function get_subtype_class($type, $subtype)
+       {
+               global $CONFIG, $SUBTYPE_CACHE;
+               
+               $type = sanitise_string($type);
+               $subtype = sanitise_string($subtype);
+               
+               // Todo: cache here? Or is looping less efficient that going to the db each time?
+               
+               $result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where type='$type' and subtype='$subtype'");
+               if ($result) {
+                       
+                       if (!$SUBTYPE_CACHE) 
+                               $SUBTYPE_CACHE = array(); //select_default_memcache('subtype_cache');
+                       
+                       $SUBTYPE_CACHE[$result->id] = $result;
+                       return $result->class;
+               }
+               
+               return NULL;
+       }
+       
+       /**
+        * This function tests to see if a subtype has a registered class handler by its id.
+        * 
+        * @param int $subtype_id The subtype
+        * @return a class name or null
+        */
+       function get_subtype_class_from_id($subtype_id)
+       {
+               global $CONFIG, $SUBTYPE_CACHE;
+               
+               $subtype_id = (int)$subtype_id;
+               
+               if (!$subtype_id) return false;
+               
+               if (isset($SUBTYPE_CACHE[$subtype_id]))
+                       return $SUBTYPE_CACHE[$subtype_id]->class;
+               
+               $result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where id=$subtype_id");
+               if ($result) {
+                       
+                       if (!$SUBTYPE_CACHE) 
+                               $SUBTYPE_CACHE = array(); //select_default_memcache('subtype_cache');
+                       
+                       $SUBTYPE_CACHE[$subtype_id] = $result;
+                       return $result->class;
+               }
+               
+               return NULL;
+       }
+       
+       /**
+        * This function will register a new subtype, returning its ID as required.
+        * 
+        * @param string $type The type you're subtyping
+        * @param string $subtype The subtype label
+        * @param string $class Optional class handler (if you don't want it handled by the generic elgg handler for the type)
+        */
+       function add_subtype($type, $subtype, $class = "")
+       {
+               global $CONFIG;
+               $type = sanitise_string($type);
+               $subtype = sanitise_string($subtype);
+               $class = sanitise_string($class);
+       
+               // Short circuit if no subtype is given
+               if ($subtype == "")
+                       return 0;
+
+               $id = get_subtype_id($type, $subtype);
+       
+               if ($id==0)
+                       return insert_data("insert into {$CONFIG->dbprefix}entity_subtypes (type, subtype, class) values ('$type','$subtype','$class')");
+               
+               return $id;
+       }
+       
+       /**
+        * Update an existing entity.
+        *
+        * @param int $guid
+        * @param int $owner_guid
+        * @param int $access_id
+        * @param int $container_guid
+        */
+       function update_entity($guid, $owner_guid, $access_id, $container_guid = null)
+       {
+               global $CONFIG, $ENTITY_CACHE;
+               
+               $guid = (int)$guid;
+               $owner_guid = (int)$owner_guid;
+               $access_id = (int)$access_id;
+               $container_guid = (int) $container_guid;
+               if (is_null($container_guid)) $container_guid = $owner_guid;
+               $time = time();
+
+               $entity = get_entity($guid);
+               
+               if ($entity->canEdit()) {
+                       
+                       if (trigger_elgg_event('update',$entity->type,$entity)) {
+                               $ret = update_data("UPDATE {$CONFIG->dbprefix}entities set owner_guid='$owner_guid', access_id='$access_id', container_guid='$container_guid', time_updated='$time' WHERE guid=$guid");
+                               
+                               if ($entity instanceof ElggObject)
+                                       update_river_access_by_object($guid,$access_id);
+                               
+                               // If memcache is available then delete this entry from the cache
+                               static $newentity_cache;
+                               if ((!$newentity_cache) && (is_memcache_available())) 
+                                       $newentity_cache = new ElggMemcache('new_entity_cache');
+                               if ($newentity_cache) $new_entity = $newentity_cache->delete($guid);
+                               
+                               // Handle cases where there was no error BUT no rows were updated!
+                               if ($ret===false)
+                                       return false;
+                                       
+                               return true;
+                       }
+                       
+               }
+       }
+       
+       /**
+        * Determine whether a given user is able to write to a given container.
+        *
+        * @param int $user_guid The user guid, or 0 for get_loggedin_userid()
+        * @param int $container_guid The container, or 0 for the current page owner.
+        */
+       function can_write_to_container($user_guid = 0, $container_guid = 0, $entity_type = 'all')
+       {
+               global $CONFIG;
+       
+               $user_guid = (int)$user_guid;
+               $user = get_entity($user_guid);
+               if (!$user) $user = get_loggedin_user();
+               
+               $container_guid = (int)$container_guid;
+               if (!$container_guid) $container_guid = page_owner();
+               if (!$container_guid) return true;
+
+               $container = get_entity($container_guid);
+               
+               if ($container)
+               {
+
+                       // If the user can edit the container, they can also write to it
+                       if ($container->canEdit($user_guid)) return true;
+               
+                       // Basics, see if the user is a member of the group.
+                       if ($user && $container instanceof ElggGroup) {
+                               if (!$container->isMember($user)) {
+                                       return false;
+                               } else {
+                                       return true;
+                               }
+                       }
+                       
+                       // See if anyone else has anything to say
+                       return trigger_plugin_hook('container_permissions_check',$entity_type,array('container' => $container, 'user' => $user), false);
+                       
+               }
+               
+               return false;
+       }
+       
+       /**
+        * Create a new entity of a given type.
+        * 
+        * @param string $type The type of the entity (site, user, object).
+        * @param string $subtype The subtype of the entity.
+        * @param int $owner_guid The GUID of the object's owner.
+        * @param int $access_id The access control group to create the entity with.
+        * @param int $site_guid The site to add this entity to. Leave as 0 (default) for the current site.
+        * @return mixed The new entity's GUID, or false on failure
+        */
+       function create_entity($type, $subtype, $owner_guid, $access_id, $site_guid = 0, $container_guid = 0)
+       {
+               global $CONFIG;
+       
+               $type = sanitise_string($type);
+               $subtype = add_subtype($type, $subtype);
+               $owner_guid = (int)$owner_guid; 
+               $access_id = (int)$access_id;
+               $time = time();
+               if ($site_guid == 0)
+                       $site_guid = $CONFIG->site_guid;
+               $site_guid = (int) $site_guid;
+               if ($container_guid == 0) $container_guid = $owner_guid;
+               
+               $user = get_loggedin_user();
+               if (!can_write_to_container($user->guid, $owner_guid, $type)) return false;
+               if ($owner_guid != $container_guid)
+                       if (!can_write_to_container($user->guid, $container_guid, $type)) return false; 
+               
+               if ($type=="") throw new InvalidParameterException(elgg_echo('InvalidParameterException:EntityTypeNotSet'));
+
+               return insert_data("INSERT into {$CONFIG->dbprefix}entities (type, subtype, owner_guid, site_guid, container_guid, access_id, time_created, time_updated) values ('$type',$subtype, $owner_guid, $site_guid, $container_guid, $access_id, $time, $time)"); 
+       }
+       
+       /**
+        * Retrieve the entity details for a specific GUID, returning it as a stdClass db row.
+        * 
+        * You will only get an object if a) it exists, b) you have access to it.
+        *
+        * @param int $guid The GUID of the object to extract
+        */
+       function get_entity_as_row($guid)
+       {
+               global $CONFIG;
+               
+               if (!$guid) return false;
+               
+               $guid = (int) $guid;
+               
+               /*$row = retrieve_cached_entity_row($guid);
+               if ($row)
+               {
+                       // We have already cached this object, so retrieve its value from the cache
+                       if (isset($CONFIG->debug) && $CONFIG->debug)
+                               error_log("** Retrieving GUID:$guid from cache");
+
+                       return $row;
+               }
+               else
+               {*/     
+                       // Object not cached, load it.
+                       if (isset($CONFIG->debug) && $CONFIG->debug == true)
+                               error_log("** GUID:$guid loaded from DB");
+                       
+                       $access = get_access_sql_suffix();
+               
+                       return get_data_row("SELECT * from {$CONFIG->dbprefix}entities where guid=$guid and $access");
+               //}
+       }
+       
+       /**
+        * Create an Elgg* object from a given entity row. 
+        */
+       function entity_row_to_elggstar($row)
+       {
+               if (!($row instanceof stdClass))
+                       return $row;
+                       
+               if ((!isset($row->guid)) || (!isset($row->subtype)))
+                       return $row;
+                       
+               $new_entity = false;
+                       
+               // Create a memcache cache if we can
+               static $newentity_cache;
+               if ((!$newentity_cache) && (is_memcache_available())) 
+                       $newentity_cache = new ElggMemcache('new_entity_cache');
+               if ($newentity_cache) $new_entity = $newentity_cache->load($row->guid);
+               if ($new_entity) return $new_entity;
+
+               $classname = get_subtype_class_from_id($row->subtype);
+               if ($classname!="")
+               {
+                       if (class_exists($classname))
+                       {
+                               $new_entity = new $classname($row);
+                               
+                               if (!($new_entity instanceof ElggEntity))
+                                       throw new ClassException(sprintf(elgg_echo('ClassException:ClassnameNotClass'), $classname, 'ElggEntity'));
+                       }
+                       else
+                               error_log(sprintf(elgg_echo('ClassNotFoundException:MissingClass'), $classname));
+               }
+               else
+               {
+                       switch ($row->type)
+                       {
+                               case 'object' : 
+                                       $new_entity = new ElggObject($row); break;
+                               case 'user' : 
+                                       $new_entity = new ElggUser($row); break;
+                               case 'group' : 
+                                       $new_entity = new ElggGroup($row); break;
+                               case 'site' : 
+                                       $new_entity = new ElggSite($row); break;
+                               default: throw new InstallationException(sprintf(elgg_echo('InstallationException:TypeNotSupported'), $row->type));
+                       }
+                       
+               }
+               
+               // Cache entity if we have a cache available
+               if (($newentity_cache) && ($new_entity)) $newentity_cache->save($new_entity->guid, $new_entity);
+               
+               return $new_entity;
+       }
+       
+       /**
+        * Return the entity for a given guid as the correct object.
+        * @param int $guid The GUID of the entity
+        * @return a child of ElggEntity appropriate for the type.
+        */
+       function get_entity($guid)
+       {
+               static $newentity_cache;
+               $new_entity = false;
+               if ((!$newentity_cache) && (is_memcache_available())) 
+                       $newentity_cache = new ElggMemcache('new_entity_cache');
+               if ($newentity_cache) $new_entity = $newentity_cache->load($guid);
+               if ($new_entity) return $new_entity;
+               
+               return entity_row_to_elggstar(get_entity_as_row($guid));
+       }
+       
+       /**
+        * Return entities matching a given query, or the number thereof
+        * 
+        * @param string $type The type of entity (eg "user", "object" etc)
+        * @param string|array $subtype The arbitrary subtype of the entity or array(type1 => array('subtype1', ...'subtypeN'), ...)
+        * @param int $owner_guid The GUID of the owning user
+        * @param string $order_by The field to order by; by default, time_created desc
+        * @param int $limit The number of entities to return; 10 by default
+        * @param int $offset The indexing offset, 0 by default
+        * @param boolean $count Set to true to get a count rather than the entities themselves (limits and offsets don't apply in this context). Defaults to false.
+        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
+        * @param int|array $container_guid The container or containers to get entities from (default: all containers).
+        * @param int $timelower The earliest time the entity can have been created. Default: all
+        * @param int $timeupper The latest time the entity can have been created. Default: all
+        * @return array A list of entities. 
+        */
+       function get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null, $timelower = 0, $timeupper = 0)
+       {
+               global $CONFIG;
+               
+               if ($subtype === false || $subtype === null || $subtype === 0)
+                       return false;
+               
+               if ($order_by == "") $order_by = "time_created desc";
+               $order_by = sanitise_string($order_by);
+               $limit = (int)$limit;
+               $offset = (int)$offset;
+               $site_guid = (int) $site_guid;
+               $timelower = (int) $timelower;
+               $timeupper = (int) $timeupper;
+               if ($site_guid == 0)
+                       $site_guid = $CONFIG->site_guid;
+                               
+               $where = array();
+               
+               if (is_array($subtype)) {
+                       $tempwhere = "";
+                       if (sizeof($subtype))
+                       foreach($subtype as $typekey => $subtypearray) {
+                               foreach($subtypearray as $subtypeval) {
+                                       $typekey = sanitise_string($typekey);
+                                       if (!empty($subtypeval)) {
+                                               if (!$subtypeval = (int) get_subtype_id($typekey, $subtypeval))
+                                                       return false;
+                                       } else {
+                                               // @todo: Setting subtype to 0 when $subtype = '' returns entities with
+                                               // no subtype.  This is different to the non-array behavior
+                                               // but may be required in some cases.
+                                               $subtypeval = 0;
+                                       }
+                                       if (!empty($tempwhere)) $tempwhere .= " or ";
+                                       $tempwhere .= "(type = '{$typekey}' and subtype = {$subtypeval})";
+                               }
+                       }
+                       if (!empty($tempwhere)) $where[] = "({$tempwhere})";
+                       
+               } else {
+               
+                       $type = sanitise_string($type);
+                       if ($subtype !== "" AND !$subtype = get_subtype_id($type, $subtype))
+                               return false;
+                       
+                       if ($type != "")
+                               $where[] = "type='$type'";
+                       if ($subtype!=="")
+                               $where[] = "subtype=$subtype";
+               }
+
+               if ($owner_guid != "") {
+                       if (!is_array($owner_guid)) {
+                               $owner_array = array($owner_guid);
+                               $owner_guid = (int) $owner_guid;
+                       //      $where[] = "owner_guid = '$owner_guid'";
+                       } else if (sizeof($owner_guid) > 0) {
+                               $owner_array = array_map('sanitise_int', $owner_guid);
+                               // Cast every element to the owner_guid array to int
+                       //      $owner_guid = array_map("sanitise_int", $owner_guid);
+                       //      $owner_guid = implode(",",$owner_guid);
+                       //      $where[] = "owner_guid in ({$owner_guid})";
+                       }
+                       if (is_null($container_guid)) {
+                               $container_guid = $owner_array;
+                       }
+               }
+               if ($site_guid > 0)
+                       $where[] = "site_guid = {$site_guid}";
+
+               if (!is_null($container_guid)) {
+                       if (is_array($container_guid)) {
+                               foreach($container_guid as $key => $val) $container_guid[$key] = (int) $val;
+                               $where[] = "container_guid in (" . implode(",",$container_guid) . ")";
+                       } else {
+                               $container_guid = (int) $container_guid;
+                               $where[] = "container_guid = {$container_guid}";
+                       }
+               }
+               if ($timelower)
+                       $where[] = "time_created >= {$timelower}";
+               if ($timeupper)
+                       $where[] = "time_created <= {$timeupper}";
+                       
+               if (!$count) {
+                       $query = "SELECT * from {$CONFIG->dbprefix}entities where ";
+               } else {
+                       $query = "SELECT count(guid) as total from {$CONFIG->dbprefix}entities where ";
+               }
+               foreach ($where as $w)
+                       $query .= " $w and ";
+               $query .= get_access_sql_suffix(); // Add access controls
+               if (!$count) {
+                       $query .= " order by $order_by";
+                       if ($limit) $query .= " limit $offset, $limit"; // Add order and limit
+                       $dt = get_data($query, "entity_row_to_elggstar");
+                       return $dt;
+               } else {
+                       $total = get_data_row($query);
+                       return $total->total;
+               }
+       }
+       
+       /**
+        * Returns a viewable list of entities
+        *
+        * @see elgg_view_entity_list
+        * 
+        * @param string $type The type of entity (eg "user", "object" etc)
+        * @param string $subtype The arbitrary subtype of the entity
+        * @param int $owner_guid The GUID of the owning user
+        * @param int $limit The number of entities to display per page (default: 10)
+        * @param true|false $fullview Whether or not to display the full view (default: true)
+        * @param true|false $viewtypetoggle Whether or not to allow gallery view 
+        * @param true|false $pagination Display pagination? Default: true
+        * @return string A viewable list of entities
+        */
+       function list_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = false, $pagination = true) {
+               
+               $offset = (int) get_input('offset');
+               $count = get_entities($type, $subtype, $owner_guid, "", $limit, $offset, true);
+               $entities = get_entities($type, $subtype, $owner_guid, "", $limit, $offset);
+
+               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);
+               
+       }
+       
+       /**
+        * Returns a viewable list of entities contained in a number of groups.
+        *
+        * @param string $subtype The arbitrary subtype of the entity
+        * @param int $owner_guid The GUID of the owning user
+        * @param int $container_guid The GUID of the containing group
+        * @param int $limit The number of entities to display per page (default: 10)
+        * @param true|false $fullview Whether or not to display the full view (default: true)
+        * @return string A viewable list of entities
+        */
+       function list_entities_groups($subtype = "", $owner_guid = 0, $container_guid = 0, $limit = 10, $fullview = true)
+       {
+               $offset = (int) get_input('offset');
+               $count = get_objects_in_group($container_guid, $subtype, $owner_guid, 0, "", $limit, $offset, true);
+               $entities = get_objects_in_group($container_guid, $subtype, $owner_guid, 0, "", $limit, $offset);
+
+               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview);
+       }
+       
+       /**
+        * Returns a list of months containing content specified by the parameters
+        *
+        * @param string $type The type of entity
+        * @param string $subtype The subtype of entity
+        * @param int $container_guid The container GUID that the entinties belong to
+        * @param int $site_guid The site GUID
+        * @return array|false Either an array of timestamps, or false on failure
+        */
+       function get_entity_dates($type = '', $subtype = '', $container_guid = 0, $site_guid = 0) {
+               
+               global $CONFIG;
+               
+               $site_guid = (int) $site_guid;
+               if ($site_guid == 0)
+                       $site_guid = $CONFIG->site_guid;
+                               
+               $where = array();
+               
+               if ($type != "") {
+                       $type = sanitise_string($type);
+                       $where[] = "type='$type'";
+               }
+               
+               if (is_array($subtype)) {                       
+                       $tempwhere = "";
+                       if (sizeof($subtype))
+                       foreach($subtype as $typekey => $subtypearray) {
+                               foreach($subtypearray as $subtypeval) {
+                                       $typekey = sanitise_string($typekey);
+                                       if (!empty($subtypeval)) {
+                                               if (!$subtypeval = (int) get_subtype_id($typekey, $subtypeval))
+                                                       return false;
+                                       } else {
+                                               $subtypeval = 0;
+                                       }
+                                       if (!empty($tempwhere)) $tempwhere .= " or ";
+                                       $tempwhere .= "(type = '{$typekey}' and subtype = {$subtypeval})";
+                               }                                                               
+                       }
+                       if (!empty($tempwhere)) $where[] = "({$tempwhere})";
+                       
+               } else {
+                       if ($subtype AND !$subtype = get_subtype_id($type, $subtype)) {
+                               return false;
+                       } else {
+                               $where[] = "subtype=$subtype";
+                       }
+               }
+               
+               if ($container_guid !== 0) {
+                       if (is_array($container_guid)) {
+                               foreach($container_guid as $key => $val) $container_guid[$key] = (int) $val;
+                               $where[] = "container_guid in (" . implode(",",$container_guid) . ")";
+                       } else {
+                               $container_guid = (int) $container_guid;
+                               $where[] = "container_guid = {$container_guid}";
+                       }
+               }
+               
+               if ($site_guid > 0)
+                       $where[] = "site_guid = {$site_guid}";
+               
+               $where[] = get_access_sql_suffix();
+                       
+               $sql = "SELECT DISTINCT EXTRACT(YEAR_MONTH FROM FROM_UNIXTIME(time_created)) AS yearmonth FROM {$CONFIG->dbprefix}entities where ";
+               foreach ($where as $w) 
+                       $sql .= " $w and ";
+               $sql .= "1=1";
+               if ($result = get_data($sql)) {
+                       $endresult = array();
+                       foreach($result as $res) {
+                               $endresult[] = $res->yearmonth;
+                       }
+                       return $endresult;
+               }
+               return false;
+               
+       }
+       
+       /**
+        * Disable an entity but not delete it.
+        *
+        * @param int $guid The guid
+        * @param string $reason Optional reason
+        */
+       function disable_entity($guid, $reason = "", $recursive = true)
+       {
+               global $CONFIG;
+               
+               $guid = (int)$guid;
+               $reason = sanitise_string($reason);
+               
+               if ($entity = get_entity($guid)) {              
+                       if (trigger_elgg_event('disable',$entity->type,$entity)) {      
+                               if ($entity->canEdit()) {
+                                       
+                                       if ($reason)
+                                               create_metadata($guid, 'disable_reason', $reason,'', 0, ACCESS_PUBLIC);
+
+                                       if ($recursive)
+                                       {
+                                               // Temporary token overriding access controls TODO: Do this better.
+                                               static $__RECURSIVE_DELETE_TOKEN;
+                                               $__RECURSIVE_DELETE_TOKEN = md5(get_loggedin_userid()); // Make it slightly harder to guess
+                                               
+                                               $sub_entities = get_data("SELECT * from {$CONFIG->dbprefix}entities WHERE container_guid=$guid or owner_guid=$guid or site_guid=$guid", 'entity_row_to_elggstar');
+                                               if ($sub_entities) {
+                                                       foreach ($sub_entities as $e)
+                                                               $e->disable($reason);
+                                               }
+                                                       
+                                               $__RECURSIVE_DELETE_TOKEN = null; 
+                                       }
+                                                                                       
+                                       $res = update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='no' where guid={$guid}");
+                                       
+                                       return $res;
+                               } 
+                       }
+               }
+               return false;
+       }
+       
+       /**
+        * Enable an entity again.
+        *
+        * @param int $guid
+        */
+       function enable_entity($guid)
+       {
+               global $CONFIG;
+               
+               $guid = (int)$guid;
+               
+               // Override access only visible entities
+               $access_status = access_get_show_hidden_status();
+               access_show_hidden_entities(true);
+               
+               if ($entity = get_entity($guid)) {
+                       if (trigger_elgg_event('enable',$entity->type,$entity)) {
+                               if ($entity->canEdit()) {
+                                       
+                                       access_show_hidden_entities($access_status);
+                               
+                                       $result = update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='yes' where guid={$guid}");
+                                       $entity->clearMetaData('disable_reason');
+                                       
+                                       return $result;
+                               }
+                       }
+               }
+               
+               access_show_hidden_entities($access_status);
+               return false;
+       }
+       
+       /**
+        * Delete a given entity.
+        * 
+        * @param int $guid
+        * @param bool $recursive If true (default) then all entities which are owned or contained by $guid will also be deleted.
+        *                                                 Note: this bypasses ownership of sub items.
+        */
+       function delete_entity($guid, $recursive = true)
+       {
+               global $CONFIG;
+               
+               $guid = (int)$guid;
+               if ($entity = get_entity($guid)) {
+                       if (trigger_elgg_event('delete',$entity->type,$entity)) {
+                               if ($entity->canEdit()) {
+                                       
+                                       // Delete contained owned and otherwise releated objects (depth first)
+                                       if ($recursive)
+                                       {
+                                               // Temporary token overriding access controls TODO: Do this better.
+                                               static $__RECURSIVE_DELETE_TOKEN;
+                                               $__RECURSIVE_DELETE_TOKEN = md5(get_loggedin_userid()); // Make it slightly harder to guess
+                                               
+                                               $sub_entities = get_data("SELECT * from {$CONFIG->dbprefix}entities WHERE container_guid=$guid or owner_guid=$guid or site_guid=$guid", 'entity_row_to_elggstar');
+                                               if ($sub_entities) {
+                                                       foreach ($sub_entities as $e)
+                                                               $e->delete();
+                                               }
+                                                       
+                                               $__RECURSIVE_DELETE_TOKEN = null; 
+                                       }
+                                       
+                                       // Now delete the entity itself
+                                       $entity->clearMetadata();
+                                       $entity->clearAnnotations();
+                                       $entity->clearRelationships();
+                                       remove_from_river_by_subject($guid);
                                        remove_from_river_by_object($guid);     
-                                       remove_all_private_settings($guid);\r
+                                       remove_all_private_settings($guid);
                                        $res = delete_data("DELETE from {$CONFIG->dbprefix}entities where guid={$guid}");
                                        if ($res)
                                        {
                                                $sub_table = "";
                                                
-                                               // Where appropriate delete the sub table
-                                               switch ($entity->type)
-                                               {
-                                                       case 'object' : $sub_table = $CONFIG->dbprefix . 'objects_entity'; break;
-                                                       case 'user' :  $sub_table = $CONFIG->dbprefix . 'users_entity'; break;
-                                                       case 'group' :  $sub_table = $CONFIG->dbprefix . 'groups_entity'; break;
-                                                       case 'site' :  $sub_table = $CONFIG->dbprefix . 'sites_entity'; break;
-                                               }
+                                               // Where appropriate delete the sub table
+                                               switch ($entity->type)
+                                               {
+                                                       case 'object' : $sub_table = $CONFIG->dbprefix . 'objects_entity'; break;
+                                                       case 'user' :  $sub_table = $CONFIG->dbprefix . 'users_entity'; break;
+                                                       case 'group' :  $sub_table = $CONFIG->dbprefix . 'groups_entity'; break;
+                                                       case 'site' :  $sub_table = $CONFIG->dbprefix . 'sites_entity'; break;
+                                               }
+                                               
+                                               if ($sub_table)
+                                                       delete_data("DELETE from $sub_table where guid={$guid}");
+                                       }
+                                       
+                                       return $res;
+                               } 
+                       }
+               }
+               return false;
+               
+       }
+       
+       /**
+        * Delete multiple entities that match a given query.
+        * This function itterates through and calls delete_entity on each one, this is somewhat inefficient but lets 
+        * the 'delete' even be called for each entity.
+        * 
+        * @param string $type The type of entity (eg "user", "object" etc)
+        * @param string $subtype The arbitrary subtype of the entity
+        * @param int $owner_guid The GUID of the owning user
+        */
+       function delete_entities($type = "", $subtype = "", $owner_guid = 0)
+       {
+               $entities = get_entities($type, $subtype, $owner_guid, "time_created desc", 0);
+               
+               foreach ($entities as $entity)
+                       delete_entity($entity->guid);
+               
+               return true;
+       }
+       
+       /**
+        * A plugin hook to get certain volitile (generated on the fly) attributes about an entity in order to export them.
+        *
+        * @param unknown_type $hook
+        * @param unknown_type $entity_type
+        * @param unknown_type $returnvalue
+        * @param unknown_type $params The parameters, passed 'guid' and 'varname'
+        * @return unknown
+        */
+       function volatile_data_export_plugin_hook($hook, $entity_type, $returnvalue, $params)
+       {
+               $guid = (int)$params['guid'];
+               $variable_name = sanitise_string($params['varname']);
+               
+               if (($hook == 'volatile') && ($entity_type == 'metadata'))
+               {
+                       if (($guid) && ($variable_name))
+                       {
+                               switch ($variable_name)
+                               {
+                                       case 'renderedentity' :
+                                               elgg_set_viewtype('default');
+                                               $view = elgg_view_entity(get_entity($guid));
+                                               elgg_set_viewtype();
+                                               
+                                               $tmp = new ElggMetadata();
+                                               $tmp->type = 'volatile';
+                                               $tmp->name = 'renderedentity';
+                                               $tmp->value = $view;
+                                               $tmp->entity_guid = $guid;
                                                
-                                               if ($sub_table)
-                                                       delete_data("DELETE from $sub_table where guid={$guid}");
-                                       }\r
-                                       \r
-                                       return $res;\r
-                               } \r
-                       }\r
-               }\r
-               return false;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Delete multiple entities that match a given query.\r
-        * This function itterates through and calls delete_entity on each one, this is somewhat inefficient but lets \r
-        * the 'delete' even be called for each entity.\r
-        * \r
-        * @param string $type The type of entity (eg "user", "object" etc)\r
-        * @param string $subtype The arbitrary subtype of the entity\r
-        * @param int $owner_guid The GUID of the owning user\r
-        */\r
-       function delete_entities($type = "", $subtype = "", $owner_guid = 0)\r
-       {\r
-               $entities = get_entities($type, $subtype, $owner_guid, "time_created desc", 0);\r
-               \r
-               foreach ($entities as $entity)\r
-                       delete_entity($entity->guid);\r
-               \r
-               return true;\r
-       }\r
-       \r
-       /**\r
-        * A plugin hook to get certain volitile (generated on the fly) attributes about an entity in order to export them.\r
-        *\r
-        * @param unknown_type $hook\r
-        * @param unknown_type $entity_type\r
-        * @param unknown_type $returnvalue\r
-        * @param unknown_type $params The parameters, passed 'guid' and 'varname'\r
-        * @return unknown\r
-        */\r
-       function volatile_data_export_plugin_hook($hook, $entity_type, $returnvalue, $params)\r
-       {\r
-               $guid = (int)$params['guid'];\r
-               $variable_name = sanitise_string($params['varname']);\r
-               \r
-               if (($hook == 'volatile') && ($entity_type == 'metadata'))\r
-               {\r
-                       if (($guid) && ($variable_name))\r
-                       {\r
-                               switch ($variable_name)\r
-                               {\r
-                                       case 'renderedentity' :\r
-                                               elgg_set_viewtype('default');\r
-                                               $view = elgg_view_entity(get_entity($guid));\r
-                                               elgg_set_viewtype();\r
-                                               \r
-                                               $tmp = new ElggMetadata();\r
-                                               $tmp->type = 'volatile';\r
-                                               $tmp->name = 'renderedentity';\r
-                                               $tmp->value = $view;\r
-                                               $tmp->entity_guid = $guid;\r
-                                               \r
-                                               return $tmp;\r
-                               \r
-                                       break;\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Handler called by trigger_plugin_hook on the "export" event.\r
-        */\r
-       function export_entity_plugin_hook($hook, $entity_type, $returnvalue, $params)\r
-       {\r
-               // Sanity check values\r
-               if ((!is_array($params)) && (!isset($params['guid'])))\r
-                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:GUIDNotForExport'));\r
-                       \r
-               if (!is_array($returnvalue))\r
-                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonArrayReturnValue'));\r
-                       \r
-               $guid = (int)$params['guid'];\r
-               \r
-               // Get the entity\r
-               $entity = get_entity($guid);\r
-               if (!($entity instanceof ElggEntity))\r
-                       throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()));\r
-               \r
-               $export = $entity->export();\r
-               \r
-               if (is_array($export))\r
-                       foreach ($export as $e)\r
-                               $returnvalue[] = $e;\r
-               else\r
-                       $returnvalue[] = $export;\r
-               \r
-               return $returnvalue;\r
-       }\r
-       \r
-       /**\r
-        * Utility function used by import_entity_plugin_hook() to process an ODDEntity into an unsaved ElggEntity.\r
-        *\r
-        * @param ODDEntity $element The OpenDD element\r
-        * @return ElggEntity the unsaved entity which should be populated by items.\r
-        */\r
-       function oddentity_to_elggentity(ODDEntity $element)\r
-       {\r
-               $class = $element->getAttribute('class');\r
-               $subclass = $element->getAttribute('subclass');\r
-               \r
-               // See if we already have imported this uuid\r
-               $tmp = get_entity_from_uuid($element->getAttribute('uuid'));\r
-               \r
-               if (!$tmp)\r
-               {\r
-                       // Construct new class with owner from session\r
-                       $classname = get_subtype_class($class, $subclass);\r
-                       if ($classname!="")\r
-                       {\r
-                               if (class_exists($classname))\r
-                               {\r
-                                       $tmp = new $classname();\r
-                                       \r
-                                       if (!($tmp instanceof ElggEntity))\r
-                                               throw new ClassException(sprintf(elgg_echo('ClassException:ClassnameNotClass', $classname, get_class())));\r
-                               }\r
-                               else\r
-                                       error_log(sprintf(elgg_echo('ClassNotFoundException:MissingClass'), $classname));       \r
-                       }\r
-                       else\r
-                       {\r
-                               switch ($class)\r
-                               {\r
-                                       case 'object' : $tmp = new ElggObject($row); break;\r
-                                       case 'user' : $tmp = new ElggUser($row); break;\r
-                                       case 'group' : $tmp = new ElggGroup($row); break; \r
-                                       case 'site' : $tmp = new ElggSite($row); break; \r
-                                       default: throw new InstallationException(sprintf(elgg_echo('InstallationException:TypeNotSupported'), $class));\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               if ($tmp)\r
-               {\r
-                       if (!$tmp->import($element))\r
-                               throw new ImportException(sprintf(elgg_echo('ImportException:ImportFailed'), $element->getAttribute('uuid')));\r
-                       \r
-                       return $tmp;\r
-               }\r
-               \r
-               return NULL;\r
-       }\r
-       \r
-       /**\r
-        * Import an entity.\r
-        * This function checks the passed XML doc (as array) to see if it is a user, if so it constructs a new \r
-        * elgg user and returns "true" to inform the importer that it's been handled.\r
-        */\r
-       function import_entity_plugin_hook($hook, $entity_type, $returnvalue, $params)\r
-       {\r
-               $element = $params['element'];\r
-               \r
-               $tmp = NULL;\r
-               \r
-               if ($element instanceof ODDEntity)\r
-               {\r
-                       $tmp = oddentity_to_elggentity($element);\r
-                       \r
-                       if ($tmp)\r
-                       {\r
-                               if (!$tmp->save()) // Make sure its saved\r
-                                       throw new ImportException(sprintf(elgg_echo('ImportException:ProblemSaving'), $element->getAttribute('uuid')));\r
-       \r
-                               // Belts and braces\r
-                               if (!$tmp->guid)\r
-                                       throw new ImportException(elgg_echo('ImportException:NoGUID')); \r
-                               \r
-                               add_uuid_to_guid($tmp->guid, $element->getAttribute('uuid')); // We have saved, so now tag\r
-                               \r
-                               return $tmp;\r
-                       }\r
-                       \r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Determines whether or not the specified user can edit the specified entity.\r
-        * \r
-        * This is extendible by registering a plugin hook taking in the parameters 'entity' and 'user',\r
-        * which are the entity and user entities respectively\r
-        * \r
-        * @see register_plugin_hook \r
-        *\r
-        * @param int $entity_guid The GUID of the entity\r
-        * @param int $user_guid The GUID of the user\r
-        * @return true|false Whether the specified user can edit the specified entity.\r
-        */\r
-       function can_edit_entity($entity_guid, $user_guid = 0) {\r
-               global $CONFIG;\r
-               \r
-               $user_guid = (int)$user_guid;\r
-               $user = get_entity($user_guid);\r
-               if (!$user) $user = get_loggedin_user();\r
-\r
-               if ($entity = get_entity($entity_guid)) {\r
-                       \r
-                       $return = false;\r
-                       \r
-                       // Test user if possible - should default to false unless a plugin hook says otherwise\r
-                       if (!is_null($user))\r
-                       {\r
-                               if ($entity->getOwner() == $user->getGUID()) $return = true;\r
-                               if ($entity->container_guid == $user->getGUID()) $return = true;\r
-                               if ($entity->type == "user" && $entity->getGUID() == $user->getGUID()) $return = true;\r
-                               if ($container_entity = get_entity($entity->container_guid)) {\r
-                                       if ($container_entity->canEdit()) $return = true;\r
-                               }\r
-                       }\r
-                               \r
-                       return trigger_plugin_hook('permissions_check',$entity->type,array('entity' => $entity, 'user' => $user), $return);\r
-               \r
-               } else {                \r
-                       return false;\r
-                       \r
-               }\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Determines whether or not the specified user can edit metadata on the specified entity.\r
-        * \r
-        * This is extendible by registering a plugin hook taking in the parameters 'entity' and 'user',\r
-        * which are the entity and user entities respectively\r
-        * \r
-        * @see register_plugin_hook \r
-        *\r
-        * @param int $entity_guid The GUID of the entity\r
-        * @param int $user_guid The GUID of the user\r
-        * @param ElggMetadata $metadata The metadata to specifically check (if any; default null)\r
-        * @return true|false Whether the specified user can edit the specified entity.\r
-        */\r
-       function can_edit_entity_metadata($entity_guid, $user_guid = 0, $metadata = null) {\r
-               \r
-               if ($entity = get_entity($entity_guid)) {\r
-                       \r
-                       $return = null;\r
-               \r
-                       if ($metadata->owner_guid == 0) $return = true;\r
-                       if (is_null($return))\r
-                               $return = can_edit_entity($entity_guid, $user_guid);\r
-                       \r
-                       $user = get_entity($user_guid);\r
-                       $return = trigger_plugin_hook('permissions_check:metadata',$entity->type,array('entity' => $entity, 'user' => $user, 'metadata' => $metadata),$return);\r
-                       return $return;\r
-\r
-               } else {\r
-                       return false;\r
-               }\r
-               \r
-       }\r
-       \r
-               \r
-       /**\r
-        * Get the icon for an entity\r
-        *\r
-        * @param ElggEntity $entity The entity (passed an entity rather than a guid to handle non-created entities)\r
-        * @param string $size\r
-        */\r
-       function get_entity_icon_url(ElggEntity $entity, $size = 'medium')\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $size = sanitise_string($size);\r
-               switch (strtolower($size))\r
-               {\r
+                                               return $tmp;
+                               
+                                       break;
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Handler called by trigger_plugin_hook on the "export" event.
+        */
+       function export_entity_plugin_hook($hook, $entity_type, $returnvalue, $params)
+       {
+               // Sanity check values
+               if ((!is_array($params)) && (!isset($params['guid'])))
+                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:GUIDNotForExport'));
+                       
+               if (!is_array($returnvalue))
+                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonArrayReturnValue'));
+                       
+               $guid = (int)$params['guid'];
+               
+               // Get the entity
+               $entity = get_entity($guid);
+               if (!($entity instanceof ElggEntity))
+                       throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()));
+               
+               $export = $entity->export();
+               
+               if (is_array($export))
+                       foreach ($export as $e)
+                               $returnvalue[] = $e;
+               else
+                       $returnvalue[] = $export;
+               
+               return $returnvalue;
+       }
+       
+       /**
+        * Utility function used by import_entity_plugin_hook() to process an ODDEntity into an unsaved ElggEntity.
+        *
+        * @param ODDEntity $element The OpenDD element
+        * @return ElggEntity the unsaved entity which should be populated by items.
+        */
+       function oddentity_to_elggentity(ODDEntity $element)
+       {
+               $class = $element->getAttribute('class');
+               $subclass = $element->getAttribute('subclass');
+               
+               // See if we already have imported this uuid
+               $tmp = get_entity_from_uuid($element->getAttribute('uuid'));
+               
+               if (!$tmp)
+               {
+                       // Construct new class with owner from session
+                       $classname = get_subtype_class($class, $subclass);
+                       if ($classname!="")
+                       {
+                               if (class_exists($classname))
+                               {
+                                       $tmp = new $classname();
+                                       
+                                       if (!($tmp instanceof ElggEntity))
+                                               throw new ClassException(sprintf(elgg_echo('ClassException:ClassnameNotClass', $classname, get_class())));
+                               }
+                               else
+                                       error_log(sprintf(elgg_echo('ClassNotFoundException:MissingClass'), $classname));       
+                       }
+                       else
+                       {
+                               switch ($class)
+                               {
+                                       case 'object' : $tmp = new ElggObject($row); break;
+                                       case 'user' : $tmp = new ElggUser($row); break;
+                                       case 'group' : $tmp = new ElggGroup($row); break; 
+                                       case 'site' : $tmp = new ElggSite($row); break; 
+                                       default: throw new InstallationException(sprintf(elgg_echo('InstallationException:TypeNotSupported'), $class));
+                               }
+                       }
+               }
+               
+               if ($tmp)
+               {
+                       if (!$tmp->import($element))
+                               throw new ImportException(sprintf(elgg_echo('ImportException:ImportFailed'), $element->getAttribute('uuid')));
+                       
+                       return $tmp;
+               }
+               
+               return NULL;
+       }
+       
+       /**
+        * Import an entity.
+        * This function checks the passed XML doc (as array) to see if it is a user, if so it constructs a new 
+        * elgg user and returns "true" to inform the importer that it's been handled.
+        */
+       function import_entity_plugin_hook($hook, $entity_type, $returnvalue, $params)
+       {
+               $element = $params['element'];
+               
+               $tmp = NULL;
+               
+               if ($element instanceof ODDEntity)
+               {
+                       $tmp = oddentity_to_elggentity($element);
+                       
+                       if ($tmp)
+                       {
+                               if (!$tmp->save()) // Make sure its saved
+                                       throw new ImportException(sprintf(elgg_echo('ImportException:ProblemSaving'), $element->getAttribute('uuid')));
+       
+                               // Belts and braces
+                               if (!$tmp->guid)
+                                       throw new ImportException(elgg_echo('ImportException:NoGUID')); 
+                               
+                               add_uuid_to_guid($tmp->guid, $element->getAttribute('uuid')); // We have saved, so now tag
+                               
+                               return $tmp;
+                       }
+                       
+               }
+       }
+       
+       /**
+        * Determines whether or not the specified user can edit the specified entity.
+        * 
+        * This is extendible by registering a plugin hook taking in the parameters 'entity' and 'user',
+        * which are the entity and user entities respectively
+        * 
+        * @see register_plugin_hook 
+        *
+        * @param int $entity_guid The GUID of the entity
+        * @param int $user_guid The GUID of the user
+        * @return true|false Whether the specified user can edit the specified entity.
+        */
+       function can_edit_entity($entity_guid, $user_guid = 0) {
+               global $CONFIG;
+               
+               $user_guid = (int)$user_guid;
+               $user = get_entity($user_guid);
+               if (!$user) $user = get_loggedin_user();
+
+               if ($entity = get_entity($entity_guid)) {
+                       
+                       $return = false;
+                       
+                       // Test user if possible - should default to false unless a plugin hook says otherwise
+                       if (!is_null($user))
+                       {
+                               if ($entity->getOwner() == $user->getGUID()) $return = true;
+                               if ($entity->container_guid == $user->getGUID()) $return = true;
+                               if ($entity->type == "user" && $entity->getGUID() == $user->getGUID()) $return = true;
+                               if ($container_entity = get_entity($entity->container_guid)) {
+                                       if ($container_entity->canEdit()) $return = true;
+                               }
+                       }
+                               
+                       return trigger_plugin_hook('permissions_check',$entity->type,array('entity' => $entity, 'user' => $user), $return);
+               
+               } else {                
+                       return false;
+                       
+               }
+               
+       }
+       
+       /**
+        * Determines whether or not the specified user can edit metadata on the specified entity.
+        * 
+        * This is extendible by registering a plugin hook taking in the parameters 'entity' and 'user',
+        * which are the entity and user entities respectively
+        * 
+        * @see register_plugin_hook 
+        *
+        * @param int $entity_guid The GUID of the entity
+        * @param int $user_guid The GUID of the user
+        * @param ElggMetadata $metadata The metadata to specifically check (if any; default null)
+        * @return true|false Whether the specified user can edit the specified entity.
+        */
+       function can_edit_entity_metadata($entity_guid, $user_guid = 0, $metadata = null) {
+               
+               if ($entity = get_entity($entity_guid)) {
+                       
+                       $return = null;
+               
+                       if ($metadata->owner_guid == 0) $return = true;
+                       if (is_null($return))
+                               $return = can_edit_entity($entity_guid, $user_guid);
+                       
+                       $user = get_entity($user_guid);
+                       $return = trigger_plugin_hook('permissions_check:metadata',$entity->type,array('entity' => $entity, 'user' => $user, 'metadata' => $metadata),$return);
+                       return $return;
+
+               } else {
+                       return false;
+               }
+               
+       }
+       
+               
+       /**
+        * Get the icon for an entity
+        *
+        * @param ElggEntity $entity The entity (passed an entity rather than a guid to handle non-created entities)
+        * @param string $size
+        */
+       function get_entity_icon_url(ElggEntity $entity, $size = 'medium')
+       {
+               global $CONFIG;
+               
+               $size = sanitise_string($size);
+               switch (strtolower($size))
+               {
                        case 'master': $size = 'master'; break;
-                        \r
-                       case 'large' : $size = 'large'; break;\r
-                       \r
-                       case 'topbar' : $size = 'topbar'; break;\r
-                       \r
-                       case 'tiny' : $size = 'tiny'; break;\r
-                       \r
-                       case 'small' : $size = 'small'; break;\r
-                       \r
-                       case 'medium' :\r
-                       default: $size = 'medium';\r
-               }\r
-               \r
-               $url = false;\r
-               \r
-               $viewtype = elgg_get_viewtype(); \r
-               \r
-               // Step one, see if anyone knows how to render this in the current view\r
-               $url = trigger_plugin_hook('entity:icon:url', $entity->getType(), array('entity' => $entity, 'viewtype' => $viewtype, 'size' => $size), $url);\r
-               \r
-               // Fail, so use default\r
-               if (!$url) {\r
-\r
-                       $type = $entity->getType();\r
-                       $subtype = $entity->getSubtype();\r
-                       \r
-                       if (!empty($subtype)) {\r
-                               $overrideurl = elgg_view("icon/{$type}/{$subtype}/{$size}",array('entity' => $entity));\r
-                               if (!empty($overrideurl)) return $overrideurl;\r
-                       }\r
-\r
-                       $overrideurl = elgg_view("icon/{$type}/default/{$size}",array('entity' => $entity));\r
-                       if (!empty($overrideurl)) return $overrideurl;\r
-                       \r
-                       $url = $CONFIG->url . "_graphics/icons/default/$size.png";\r
-               }\r
-       \r
-               return $url;\r
-       }\r
-               \r
-       /**\r
-        * Gets the URL for an entity, given a particular GUID\r
-        *\r
-        * @param int $entity_guid The GUID of the entity\r
-        * @return string The URL of the entity\r
-        */\r
-       function get_entity_url($entity_guid) {\r
-               \r
-               global $CONFIG;\r
-               if ($entity = get_entity($entity_guid)) {\r
-\r
-                       $url = "";\r
-                       \r
-                       if (isset($CONFIG->entity_url_handler[$entity->getType()][$entity->getSubType()])) {\r
-                               $function =  $CONFIG->entity_url_handler[$entity->getType()][$entity->getSubType()];\r
-                               if (is_callable($function)) {\r
-                                       $url = $function($entity);\r
-                               }\r
-                       } elseif (isset($CONFIG->entity_url_handler[$entity->getType()]['all'])) {\r
-                               $function =  $CONFIG->entity_url_handler[$entity->getType()]['all'];\r
-                               if (is_callable($function)) {\r
-                                       $url = $function($entity);\r
-                               }\r
-                       } elseif (isset($CONFIG->entity_url_handler['all']['all'])) {\r
-                               $function =  $CONFIG->entity_url_handler['all']['all'];\r
-                               if (is_callable($function)) {\r
-                                       $url = $function($entity);\r
-                               }\r
-                       }\r
-\r
-                       if ($url == "") {\r
-                               $url = $CONFIG->url . "pg/view/" . $entity_guid;\r
-                       }\r
-                       return $url;\r
-                       \r
-               }\r
-               return false;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Sets the URL handler for a particular entity type and subtype\r
-        *\r
-        * @param string $function_name The function to register\r
-        * @param string $entity_type The entity type\r
-        * @param string $entity_subtype The entity subtype\r
-        * @return true|false Depending on success\r
-        */\r
-       function register_entity_url_handler($function_name, $entity_type = "all", $entity_subtype = "all") {\r
-               global $CONFIG;\r
-               \r
-               if (!is_callable($function_name)) return false;\r
-               \r
-               if (!isset($CONFIG->entity_url_handler)) {\r
-                       $CONFIG->entity_url_handler = array();\r
-               }\r
-               if (!isset($CONFIG->entity_url_handler[$entity_type])) {\r
-                       $CONFIG->entity_url_handler[$entity_type] = array();\r
-               }\r
-               $CONFIG->entity_url_handler[$entity_type][$entity_subtype] = $function_name;\r
-               \r
-               return true;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Default Icon URL handler for entities.\r
-        * This will attempt to find a default entity for the current view and return a url. This is registered at\r
-        * a low priority so that other handlers will pick it up first.\r
-        *\r
-        * @param unknown_type $hook\r
-        * @param unknown_type $entity_type\r
-        * @param unknown_type $returnvalue\r
-        * @param unknown_type $params\r
-        */\r
-       function default_entity_icon_hook($hook, $entity_type, $returnvalue, $params)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               if ((!$returnvalue) && ($hook == 'entity:icon:url'))\r
-               {\r
-                       $entity = $params['entity'];\r
-                       $type = $entity->type;\r
-                       $subtype = get_subtype_from_id($entity->subtype);\r
-                       $viewtype = $params['viewtype'];\r
-                       $size = $params['size'];\r
-                       \r
-                       $url = "views/$viewtype/graphics/icons/$type/$subtype/$size.png";\r
-                       \r
-                       if (!@file_exists($CONFIG->path . $url))\r
-                               $url = "views/$viewtype/graphics/icons/$type/default/$size.png";\r
-                       \r
-                       if(!@file_exists($CONFIG->path . $url))\r
-                               $url = "views/$viewtype/graphics/icons/default/$size.png";\r
-               \r
-                       if (@file_exists($CONFIG->path . $url))\r
-                               return $CONFIG->url . $url;\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Registers and entity type and subtype to return in search and other places.\r
-        * A description in the elgg_echo languages file of the form item:type:subtype\r
-        * is also expected.\r
-        *\r
-        * @param string $type The type of entity (object, site, user, group)\r
-        * @param string $subtype The subtype to register (may be blank)\r
-        * @return true|false Depending on success\r
-        */\r
-       function register_entity_type($type, $subtype) {\r
-               \r
-               global $CONFIG;\r
-               \r
-               $type = strtolower($type);\r
-               if (!in_array($type,array('object','site','group','user'))) return false;\r
-               \r
-               if (!isset($CONFIG->registered_entities)) $CONFIG->registered_entities = array();\r
-               $CONFIG->registered_entities[$type][] = $subtype;\r
-               \r
-               return true;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Returns registered entity types and subtypes\r
-        * \r
-        * @see register_entity_type\r
-        *\r
-        * @param string $type The type of entity (object, site, user, group) or blank for all\r
-        * @return array|false Depending on whether entities have been registered\r
-        */\r
-       function get_registered_entity_types($type = '') {\r
-               \r
-               global $CONFIG;\r
-               \r
-               if (!isset($CONFIG->registered_entities)) return false;\r
-               if (!empty($type)) $type = strtolower($type);\r
-               if (!empty($type) && empty($CONFIG->registered_entities[$type])) return false;\r
-               \r
-               if (empty($type))\r
-                       return $CONFIG->registered_entities;\r
-                       \r
-               return $CONFIG->registered_entities[$type];\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Determines whether or not the specified entity type and subtype have been registered in the system\r
-        *\r
-        * @param string $type The type of entity (object, site, user, group)\r
-        * @param string $subtype The subtype (may be blank)\r
-        * @return true|false Depending on whether or not the type has been registered\r
-        */\r
-       function is_registered_entity_type($type, $subtype) {\r
-               \r
-               global $CONFIG;\r
-               \r
-               if (!isset($CONFIG->registered_entities)) return false;\r
-               $type = strtolower($type);\r
-               if (empty($CONFIG->registered_entities[$type])) return false;\r
-               if (in_array($subtype, $CONFIG->registered_entities[$type])) return true;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Page handler for generic entities view system\r
-        *\r
-        * @param array $page Page elements from pain page handler\r
-        */\r
-       function entities_page_handler($page) {\r
-               if (isset($page[0])) {\r
-                       global $CONFIG;\r
-                       set_input('guid',$page[0]);\r
-                       @include($CONFIG->path . "entities/index.php");\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Returns a viewable list of entities based on the registered types\r
-        *\r
-        * @see elgg_view_entity_list\r
-        * \r
-        * @param string $type The type of entity (eg "user", "object" etc)\r
-        * @param string $subtype The arbitrary subtype of the entity\r
-        * @param int $owner_guid The GUID of the owning user\r
-        * @param int $limit The number of entities to display per page (default: 10)\r
-        * @param true|false $fullview Whether or not to display the full view (default: true)\r
-        * @param true|false $viewtypetoggle Whether or not to allow gallery view \r
-        * @return string A viewable list of entities\r
-        */\r
-       function list_registered_entities($owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = false, $allowedtypes = true) {\r
-               \r
-               $typearray = array();\r
-               \r
-               if ($object_types = get_registered_entity_types()) {\r
-                       foreach($object_types as $object_type => $subtype_array) {\r
-                               if (is_array($subtype_array) && sizeof($subtype_array) && (in_array($object_type,$allowedtypes) || $allowedtypes === true))\r
-                                       foreach($subtype_array as $object_subtype) {\r
-                                               $typearray[$object_type][] = $object_subtype;\r
-                                       }\r
-                       }\r
-               }\r
-               \r
-               $offset = (int) get_input('offset');\r
-               $count = get_entities('', $typearray, $owner_guid, "", $limit, $offset, true); \r
-               $entities = get_entities('', $typearray,$owner_guid, "", $limit, $offset); \r
-\r
-               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle);\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Get entities based on their private data, in a similar way to metadata.\r
-        *\r
-        * @param string $name The name of the setting\r
-        * @param string $value The value of the setting\r
-        * @param string $type The type of entity (eg "user", "object" etc)\r
-        * @param string $subtype The arbitrary subtype of the entity\r
-        * @param int $owner_guid The GUID of the owning user\r
-        * @param string $order_by The field to order by; by default, time_created desc\r
-        * @param int $limit The number of entities to return; 10 by default\r
-        * @param int $offset The indexing offset, 0 by default\r
-        * @param boolean $count Set to true to get a count rather than the entities themselves (limits and offsets don't apply in this context). Defaults to false.\r
-        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.\r
-        * @param int|array $container_guid The container or containers to get entities from (default: all containers).\r
-        * @return array A list of entities. \r
-        */\r
-       function get_entities_from_private_setting($name = "", $value = "", $type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               if ($subtype === false || $subtype === null || $subtype === 0)\r
-                       return false;\r
-                                       \r
-               $name = sanitise_string($name);\r
-               $value = sanitise_string($value);\r
-                       \r
-               if ($order_by == "") $order_by = "e.time_created desc";\r
-               $order_by = sanitise_string($order_by);\r
-               $limit = (int)$limit;\r
-               $offset = (int)$offset;\r
-               $site_guid = (int) $site_guid;\r
-               if ($site_guid == 0)\r
-                       $site_guid = $CONFIG->site_guid;\r
-                               \r
-               $where = array();\r
-               \r
-               if (is_array($type)) {                  \r
-                       $tempwhere = "";\r
-                       if (sizeof($type))\r
-                       foreach($type as $typekey => $subtypearray) {\r
-                               foreach($subtypearray as $subtypeval) {\r
-                                       $typekey = sanitise_string($typekey);\r
-                                       if (!empty($subtypeval)) {\r
-                                               if (!$subtypeval = (int) get_subtype_id($typekey, $subtypeval)) {\r
-                                                       return false;\r
-                                               }\r
-                                       } else {\r
-                                               $subtypeval = 0;\r
-                                       }\r
-                                       if (!empty($tempwhere)) $tempwhere .= " or ";\r
-                                       $tempwhere .= "(e.type = '{$typekey}' and e.subtype = {$subtypeval})";\r
-                               }                                                               \r
-                       }\r
-                       if (!empty($tempwhere)) $where[] = "({$tempwhere})";\r
-                       \r
-               } else {\r
-               \r
-                       $type = sanitise_string($type);\r
-                       if ($subtype AND !$subtype = get_subtype_id($type, $subtype)) {\r
-                               return false;\r
-                       }\r
-                       \r
-                       if ($type != "")\r
-                               $where[] = "e.type='$type'";\r
-                       if ($subtype!=="")\r
-                               $where[] = "e.subtype=$subtype";\r
-                               \r
-               }\r
-                               \r
-               if ($owner_guid != "") {\r
-                       if (!is_array($owner_guid)) {\r
-                               $owner_array = array($owner_guid);\r
-                               $owner_guid = (int) $owner_guid;\r
-                       //      $where[] = "owner_guid = '$owner_guid'";\r
-                       } else if (sizeof($owner_guid) > 0) {\r
-                               $owner_array = array_map('sanitise_int', $owner_guid);\r
-                               // Cast every element to the owner_guid array to int\r
-                       //      $owner_guid = array_map("sanitise_int", $owner_guid);\r
-                       //      $owner_guid = implode(",",$owner_guid);\r
-                       //      $where[] = "owner_guid in ({$owner_guid})";\r
-                       }\r
-                       if (is_null($container_guid)) {\r
-                               $container_guid = $owner_array;\r
-                       }\r
-               }\r
-               if ($site_guid > 0)\r
-                       $where[] = "e.site_guid = {$site_guid}";\r
-                       \r
-               if (!is_null($container_guid)) {\r
-                       if (is_array($container_guid)) {\r
-                               foreach($container_guid as $key => $val) $container_guid[$key] = (int) $val;\r
-                               $where[] = "e.container_guid in (" . implode(",",$container_guid) . ")";\r
-                       } else {\r
-                               $container_guid = (int) $container_guid;\r
-                               $where[] = "e.container_guid = {$container_guid}";\r
-                       }\r
-               }\r
-                       \r
-               if ($name!="")\r
-                       $where[] = "s.name = '$name'";\r
-               if ($value!="")\r
-                       $where[] = "s.value='$value'";  \r
-               \r
-               if (!$count) {\r
-                       $query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}private_settings s ON e.guid=s.entity_guid where ";\r
-               } else {\r
-                       $query = "SELECT count(distinct e.guid) as total from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}private_settings s ON e.guid=s.entity_guid where ";\r
-               }\r
-               foreach ($where as $w)\r
-                       $query .= " $w and ";\r
-               $query .= get_access_sql_suffix('e'); // Add access controls\r
-               if (!$count) {\r
-                       $query .= " order by $order_by";\r
-                       if ($limit) $query .= " limit $offset, $limit"; // Add order and limit\r
-                               \r
-                       $dt = get_data($query, "entity_row_to_elggstar");\r
-                       return $dt;\r
-               } else {\r
-                       $total = get_data_row($query);\r
-                       return $total->total;\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Get entities based on their private data by multiple keys, in a similar way to metadata.\r
-        *\r
-        * @param string $name The name of the setting\r
-        * @param string $value The value of the setting\r
-        * @param string|array $type The type of entity (eg "user", "object" etc) or array(type1 => array('subtype1', ...'subtypeN'), ...)\r
-        * @param string $subtype The arbitrary subtype of the entity\r
-        * @param int $owner_guid The GUID of the owning user\r
-        * @param string $order_by The field to order by; by default, time_created desc\r
-        * @param int $limit The number of entities to return; 10 by default\r
-        * @param int $offset The indexing offset, 0 by default\r
-        * @param boolean $count Set to true to get a count rather than the entities themselves (limits and offsets don't apply in this context). Defaults to false.\r
-        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.\r
-        * @param int|array $container_guid The container or containers to get entities from (default: all containers).\r
-        * @return array A list of entities. \r
-        */\r
-       function get_entities_from_private_setting_multi(array $name, $type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               if ($subtype === false || $subtype === null || $subtype === 0)\r
-                       return false;\r
-                       \r
-               if ($order_by == "") $order_by = "e.time_created desc";\r
-               $order_by = sanitise_string($order_by);\r
-               $limit = (int)$limit;\r
-               $offset = (int)$offset;\r
-               $site_guid = (int) $site_guid;\r
-               if ($site_guid == 0)\r
-                       $site_guid = $CONFIG->site_guid;\r
-                               \r
-               $where = array();\r
-               \r
-               if (is_array($type)) {\r
-                       $tempwhere = "";\r
-                       if (sizeof($type))\r
-                       foreach($type as $typekey => $subtypearray) {\r
-                               foreach($subtypearray as $subtypeval) {\r
-                                       $typekey = sanitise_string($typekey);\r
-                                       if (!empty($subtypeval)) {\r
-                                               if (!$subtypeval = (int) get_subtype_id($typekey, $subtypeval)) {\r
-                                                       return false;\r
-                                               }\r
-                                       } else {\r
-                                               $subtypeval = 0;\r
-                                       }\r
-                                       if (!empty($tempwhere)) $tempwhere .= " or ";\r
-                                       $tempwhere .= "(e.type = '{$typekey}' and e.subtype = {$subtypeval})";\r
-                               }\r
-                       }\r
-                       if (!empty($tempwhere)) $where[] = "({$tempwhere})";\r
-                       \r
-               } else {\r
-                       $type = sanitise_string($type);\r
-                       if ($subtype AND !$subtype = get_subtype_id($type, $subtype))\r
-                               return false;\r
-                       \r
-                       if ($type != "")\r
-                               $where[] = "e.type='$type'";\r
-                       if ($subtype!=="")\r
-                               $where[] = "e.subtype=$subtype";\r
-                               \r
-               }\r
-                               \r
-               if ($owner_guid != "") {\r
-                       if (!is_array($owner_guid)) {\r
-                               $owner_array = array($owner_guid);\r
-                               $owner_guid = (int) $owner_guid;\r
-                       //      $where[] = "owner_guid = '$owner_guid'";\r
-                       } else if (sizeof($owner_guid) > 0) {\r
-                               $owner_array = array_map('sanitise_int', $owner_guid);\r
-                               // Cast every element to the owner_guid array to int\r
-                       //      $owner_guid = array_map("sanitise_int", $owner_guid);\r
-                       //      $owner_guid = implode(",",$owner_guid);\r
-                       //      $where[] = "owner_guid in ({$owner_guid})";\r
-                       }\r
-                       if (is_null($container_guid)) {\r
-                               $container_guid = $owner_array;\r
-                       }\r
-               }\r
-               if ($site_guid > 0)\r
-                       $where[] = "e.site_guid = {$site_guid}";\r
-                       \r
-               if (!is_null($container_guid)) {\r
-                       if (is_array($container_guid)) {\r
-                               foreach($container_guid as $key => $val) $container_guid[$key] = (int) $val;\r
-                               $where[] = "e.container_guid in (" . implode(",",$container_guid) . ")";\r
-                       } else {\r
-                               $container_guid = (int) $container_guid;\r
-                               $where[] = "e.container_guid = {$container_guid}";\r
-                       }\r
-               }\r
-                       \r
-               if ($name)\r
-               {\r
-                       $s_join = "";\r
-                       $i = 1;\r
-                       foreach ($name as $k => $n)\r
-                       {\r
-                               $k = sanitise_string($k);\r
-                               $s_join .= " JOIN {$CONFIG->dbprefix}private_settings s$i ON e.guid=s$i.entity_guid";\r
-                               $where[] = "s$i.name = '$k'";\r
-                               $where[] = "s$i.value = '$n'";\r
-                               $i++;\r
-                       }\r
-               }\r
-                       \r
-               if (!$count) {\r
-                       $query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e $s_join where ";\r
-               } else {\r
-                       $query = "SELECT count(distinct e.guid) as total from {$CONFIG->dbprefix}entities e $s_join where ";\r
-               }\r
-               foreach ($where as $w)\r
-                       $query .= " $w and ";\r
-               $query .= get_access_sql_suffix('e'); // Add access controls\r
-               if (!$count) {\r
-                       $query .= " order by $order_by";\r
-                       if ($limit) $query .= " limit $offset, $limit"; // Add order and limit\r
-                       \r
-                       $dt = get_data($query, "entity_row_to_elggstar");\r
-                       return $dt;\r
-               } else {\r
-                       $total = get_data_row($query);\r
-                       return $total->total;\r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Gets a private setting for an entity.\r
-        *\r
-        * @param int $entity_guid The entity GUID\r
-        * @param string $name The name of the setting\r
-        * @return mixed The setting value, or false on failure\r
-        */\r
-       function get_private_setting($entity_guid, $name) {\r
-               \r
-               global $CONFIG;\r
-               $entity_guid = (int) $entity_guid;\r
-               $name = sanitise_string($name);\r
-               \r
-               if ($setting = get_data_row("SELECT value from {$CONFIG->dbprefix}private_settings where name = '{$name}' and entity_guid = {$entity_guid}")) {\r
-                       return $setting->value;\r
-               }\r
-               return false;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Return an array of all private settings for a given\r
-        *\r
-        * @param int $entity_guid The entity GUID\r
-        */\r
-       function get_all_private_settings($entity_guid) {\r
-               global $CONFIG;\r
-               \r
-               $entity_guid = (int) $entity_guid;\r
-               \r
-               $result = get_data("SELECT * from {$CONFIG->dbprefix}private_settings where entity_guid = {$entity_guid}");\r
-               if ($result)\r
-               {\r
-                       $return = array();\r
-                       foreach ($result as $r)\r
-                               $return[$r->name] = $r->value;\r
-                       \r
-                       return $return;\r
-               }\r
-               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Sets a private setting for an entity.\r
-        *\r
-        * @param int $entity_guid The entity GUID\r
-        * @param string $name The name of the setting\r
-        * @param string $value The value of the setting\r
-        * @return mixed The setting ID, or false on failure\r
-        */\r
-       function set_private_setting($entity_guid, $name, $value) {\r
-               \r
-               global $CONFIG;\r
-               $entity_guid = (int) $entity_guid;\r
-               $name = sanitise_string($name);\r
-               $value = sanitise_string($value);\r
-               \r
-               $result = insert_data("INSERT into {$CONFIG->dbprefix}private_settings (entity_guid, name, value) VALUES ($entity_guid, '{$name}', '{$value}') ON DUPLICATE KEY UPDATE value='$value'");\r
-               if ($result === 0) return true;\r
-               return $result;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Deletes a private setting for an entity.\r
-        *\r
-        * @param int $entity_guid The Entity GUID\r
-        * @param string $name The name of the setting\r
-        * @return true|false depending on success\r
-        * \r
-        */\r
-       function remove_private_setting($entity_guid, $name) {\r
-               \r
-               global $CONFIG;\r
-               $entity_guid = (int) $entity_guid;\r
-               $name = sanitise_string($name); \r
-               return delete_data("DELETE from {$CONFIG->dbprefix}private_settings where name = '{$name}' and entity_guid = {$entity_guid}");\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Deletes all private settings for an entity.\r
-        *\r
-        * @param int $entity_guid The Entity GUID\r
-        * @return true|false depending on success\r
-        * \r
-        */\r
-       function remove_all_private_settings($entity_guid) {\r
-               \r
-               global $CONFIG;\r
-               $entity_guid = (int) $entity_guid;\r
-               return delete_data("DELETE from {$CONFIG->dbprefix}private_settings where entity_guid = {$entity_guid}");\r
-       }\r
-       \r
-       function recursive_delete_permissions_check($hook, $entity_type, $returnvalue, $params)\r
-       {\r
-               static $__RECURSIVE_DELETE_TOKEN;\r
-               \r
-               $entity = $params['entity'];\r
-               \r
-               if ((isloggedin()) && ($__RECURSIVE_DELETE_TOKEN) && (strcmp($__RECURSIVE_DELETE_TOKEN, md5(get_loggedin_userid()))))\r
-                       return true;\r
-               \r
+                        
+                       case 'large' : $size = 'large'; break;
+                       
+                       case 'topbar' : $size = 'topbar'; break;
+                       
+                       case 'tiny' : $size = 'tiny'; break;
+                       
+                       case 'small' : $size = 'small'; break;
+                       
+                       case 'medium' :
+                       default: $size = 'medium';
+               }
+               
+               $url = false;
+               
+               $viewtype = elgg_get_viewtype(); 
+               
+               // Step one, see if anyone knows how to render this in the current view
+               $url = trigger_plugin_hook('entity:icon:url', $entity->getType(), array('entity' => $entity, 'viewtype' => $viewtype, 'size' => $size), $url);
+               
+               // Fail, so use default
+               if (!$url) {
+
+                       $type = $entity->getType();
+                       $subtype = $entity->getSubtype();
+                       
+                       if (!empty($subtype)) {
+                               $overrideurl = elgg_view("icon/{$type}/{$subtype}/{$size}",array('entity' => $entity));
+                               if (!empty($overrideurl)) return $overrideurl;
+                       }
+
+                       $overrideurl = elgg_view("icon/{$type}/default/{$size}",array('entity' => $entity));
+                       if (!empty($overrideurl)) return $overrideurl;
+                       
+                       $url = $CONFIG->url . "_graphics/icons/default/$size.png";
+               }
+       
+               return $url;
+       }
+               
+       /**
+        * Gets the URL for an entity, given a particular GUID
+        *
+        * @param int $entity_guid The GUID of the entity
+        * @return string The URL of the entity
+        */
+       function get_entity_url($entity_guid) {
+               
+               global $CONFIG;
+               if ($entity = get_entity($entity_guid)) {
+
+                       $url = "";
+                       
+                       if (isset($CONFIG->entity_url_handler[$entity->getType()][$entity->getSubType()])) {
+                               $function =  $CONFIG->entity_url_handler[$entity->getType()][$entity->getSubType()];
+                               if (is_callable($function)) {
+                                       $url = $function($entity);
+                               }
+                       } elseif (isset($CONFIG->entity_url_handler[$entity->getType()]['all'])) {
+                               $function =  $CONFIG->entity_url_handler[$entity->getType()]['all'];
+                               if (is_callable($function)) {
+                                       $url = $function($entity);
+                               }
+                       } elseif (isset($CONFIG->entity_url_handler['all']['all'])) {
+                               $function =  $CONFIG->entity_url_handler['all']['all'];
+                               if (is_callable($function)) {
+                                       $url = $function($entity);
+                               }
+                       }
+
+                       if ($url == "") {
+                               $url = $CONFIG->url . "pg/view/" . $entity_guid;
+                       }
+                       return $url;
+                       
+               }
+               return false;
+               
+       }
+       
+       /**
+        * Sets the URL handler for a particular entity type and subtype
+        *
+        * @param string $function_name The function to register
+        * @param string $entity_type The entity type
+        * @param string $entity_subtype The entity subtype
+        * @return true|false Depending on success
+        */
+       function register_entity_url_handler($function_name, $entity_type = "all", $entity_subtype = "all") {
+               global $CONFIG;
+               
+               if (!is_callable($function_name)) return false;
+               
+               if (!isset($CONFIG->entity_url_handler)) {
+                       $CONFIG->entity_url_handler = array();
+               }
+               if (!isset($CONFIG->entity_url_handler[$entity_type])) {
+                       $CONFIG->entity_url_handler[$entity_type] = array();
+               }
+               $CONFIG->entity_url_handler[$entity_type][$entity_subtype] = $function_name;
+               
+               return true;
+               
+       }
+       
+       /**
+        * Default Icon URL handler for entities.
+        * This will attempt to find a default entity for the current view and return a url. This is registered at
+        * a low priority so that other handlers will pick it up first.
+        *
+        * @param unknown_type $hook
+        * @param unknown_type $entity_type
+        * @param unknown_type $returnvalue
+        * @param unknown_type $params
+        */
+       function default_entity_icon_hook($hook, $entity_type, $returnvalue, $params)
+       {
+               global $CONFIG;
+               
+               if ((!$returnvalue) && ($hook == 'entity:icon:url'))
+               {
+                       $entity = $params['entity'];
+                       $type = $entity->type;
+                       $subtype = get_subtype_from_id($entity->subtype);
+                       $viewtype = $params['viewtype'];
+                       $size = $params['size'];
+                       
+                       $url = "views/$viewtype/graphics/icons/$type/$subtype/$size.png";
+                       
+                       if (!@file_exists($CONFIG->path . $url))
+                               $url = "views/$viewtype/graphics/icons/$type/default/$size.png";
+                       
+                       if(!@file_exists($CONFIG->path . $url))
+                               $url = "views/$viewtype/graphics/icons/default/$size.png";
+               
+                       if (@file_exists($CONFIG->path . $url))
+                               return $CONFIG->url . $url;
+               }
+       }
+       
+       /**
+        * Registers and entity type and subtype to return in search and other places.
+        * A description in the elgg_echo languages file of the form item:type:subtype
+        * is also expected.
+        *
+        * @param string $type The type of entity (object, site, user, group)
+        * @param string $subtype The subtype to register (may be blank)
+        * @return true|false Depending on success
+        */
+       function register_entity_type($type, $subtype) {
+               
+               global $CONFIG;
+               
+               $type = strtolower($type);
+               if (!in_array($type,array('object','site','group','user'))) return false;
+               
+               if (!isset($CONFIG->registered_entities)) $CONFIG->registered_entities = array();
+               $CONFIG->registered_entities[$type][] = $subtype;
+               
+               return true;
+               
+       }
+       
+       /**
+        * Returns registered entity types and subtypes
+        * 
+        * @see register_entity_type
+        *
+        * @param string $type The type of entity (object, site, user, group) or blank for all
+        * @return array|false Depending on whether entities have been registered
+        */
+       function get_registered_entity_types($type = '') {
+               
+               global $CONFIG;
+               
+               if (!isset($CONFIG->registered_entities)) return false;
+               if (!empty($type)) $type = strtolower($type);
+               if (!empty($type) && empty($CONFIG->registered_entities[$type])) return false;
+               
+               if (empty($type))
+                       return $CONFIG->registered_entities;
+                       
+               return $CONFIG->registered_entities[$type];
+               
+       }
+       
+       /**
+        * Determines whether or not the specified entity type and subtype have been registered in the system
+        *
+        * @param string $type The type of entity (object, site, user, group)
+        * @param string $subtype The subtype (may be blank)
+        * @return true|false Depending on whether or not the type has been registered
+        */
+       function is_registered_entity_type($type, $subtype) {
+               
+               global $CONFIG;
+               
+               if (!isset($CONFIG->registered_entities)) return false;
+               $type = strtolower($type);
+               if (empty($CONFIG->registered_entities[$type])) return false;
+               if (in_array($subtype, $CONFIG->registered_entities[$type])) return true;
+               
+       }
+       
+       /**
+        * Page handler for generic entities view system
+        *
+        * @param array $page Page elements from pain page handler
+        */
+       function entities_page_handler($page) {
+               if (isset($page[0])) {
+                       global $CONFIG;
+                       set_input('guid',$page[0]);
+                       @include($CONFIG->path . "entities/index.php");
+               }
+       }
+       
+       /**
+        * Returns a viewable list of entities based on the registered types
+        *
+        * @see elgg_view_entity_list
+        * 
+        * @param string $type The type of entity (eg "user", "object" etc)
+        * @param string $subtype The arbitrary subtype of the entity
+        * @param int $owner_guid The GUID of the owning user
+        * @param int $limit The number of entities to display per page (default: 10)
+        * @param true|false $fullview Whether or not to display the full view (default: true)
+        * @param true|false $viewtypetoggle Whether or not to allow gallery view 
+        * @return string A viewable list of entities
+        */
+       function list_registered_entities($owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = false, $allowedtypes = true) {
+               
+               $typearray = array();
+               
+               if ($object_types = get_registered_entity_types()) {
+                       foreach($object_types as $object_type => $subtype_array) {
+                               if (is_array($subtype_array) && sizeof($subtype_array) && (in_array($object_type,$allowedtypes) || $allowedtypes === true))
+                                       foreach($subtype_array as $object_subtype) {
+                                               $typearray[$object_type][] = $object_subtype;
+                                       }
+                       }
+               }
+               
+               $offset = (int) get_input('offset');
+               $count = get_entities('', $typearray, $owner_guid, "", $limit, $offset, true); 
+               $entities = get_entities('', $typearray,$owner_guid, "", $limit, $offset); 
+
+               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle);
+               
+       }
+       
+       /**
+        * Get entities based on their private data, in a similar way to metadata.
+        *
+        * @param string $name The name of the setting
+        * @param string $value The value of the setting
+        * @param string $type The type of entity (eg "user", "object" etc)
+        * @param string $subtype The arbitrary subtype of the entity
+        * @param int $owner_guid The GUID of the owning user
+        * @param string $order_by The field to order by; by default, time_created desc
+        * @param int $limit The number of entities to return; 10 by default
+        * @param int $offset The indexing offset, 0 by default
+        * @param boolean $count Set to true to get a count rather than the entities themselves (limits and offsets don't apply in this context). Defaults to false.
+        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
+        * @param int|array $container_guid The container or containers to get entities from (default: all containers).
+        * @return array A list of entities. 
+        */
+       function get_entities_from_private_setting($name = "", $value = "", $type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null)
+       {
+               global $CONFIG;
+               
+               if ($subtype === false || $subtype === null || $subtype === 0)
+                       return false;
+                                       
+               $name = sanitise_string($name);
+               $value = sanitise_string($value);
+                       
+               if ($order_by == "") $order_by = "e.time_created desc";
+               $order_by = sanitise_string($order_by);
+               $limit = (int)$limit;
+               $offset = (int)$offset;
+               $site_guid = (int) $site_guid;
+               if ($site_guid == 0)
+                       $site_guid = $CONFIG->site_guid;
+                               
+               $where = array();
+               
+               if (is_array($type)) {                  
+                       $tempwhere = "";
+                       if (sizeof($type))
+                       foreach($type as $typekey => $subtypearray) {
+                               foreach($subtypearray as $subtypeval) {
+                                       $typekey = sanitise_string($typekey);
+                                       if (!empty($subtypeval)) {
+                                               if (!$subtypeval = (int) get_subtype_id($typekey, $subtypeval)) {
+                                                       return false;
+                                               }
+                                       } else {
+                                               $subtypeval = 0;
+                                       }
+                                       if (!empty($tempwhere)) $tempwhere .= " or ";
+                                       $tempwhere .= "(e.type = '{$typekey}' and e.subtype = {$subtypeval})";
+                               }                                                               
+                       }
+                       if (!empty($tempwhere)) $where[] = "({$tempwhere})";
+                       
+               } else {
+               
+                       $type = sanitise_string($type);
+                       if ($subtype AND !$subtype = get_subtype_id($type, $subtype)) {
+                               return false;
+                       }
+                       
+                       if ($type != "")
+                               $where[] = "e.type='$type'";
+                       if ($subtype!=="")
+                               $where[] = "e.subtype=$subtype";
+                               
+               }
+                               
+               if ($owner_guid != "") {
+                       if (!is_array($owner_guid)) {
+                               $owner_array = array($owner_guid);
+                               $owner_guid = (int) $owner_guid;
+                       //      $where[] = "owner_guid = '$owner_guid'";
+                       } else if (sizeof($owner_guid) > 0) {
+                               $owner_array = array_map('sanitise_int', $owner_guid);
+                               // Cast every element to the owner_guid array to int
+                       //      $owner_guid = array_map("sanitise_int", $owner_guid);
+                       //      $owner_guid = implode(",",$owner_guid);
+                       //      $where[] = "owner_guid in ({$owner_guid})";
+                       }
+                       if (is_null($container_guid)) {
+                               $container_guid = $owner_array;
+                       }
+               }
+               if ($site_guid > 0)
+                       $where[] = "e.site_guid = {$site_guid}";
+                       
+               if (!is_null($container_guid)) {
+                       if (is_array($container_guid)) {
+                               foreach($container_guid as $key => $val) $container_guid[$key] = (int) $val;
+                               $where[] = "e.container_guid in (" . implode(",",$container_guid) . ")";
+                       } else {
+                               $container_guid = (int) $container_guid;
+                               $where[] = "e.container_guid = {$container_guid}";
+                       }
+               }
+                       
+               if ($name!="")
+                       $where[] = "s.name = '$name'";
+               if ($value!="")
+                       $where[] = "s.value='$value'";  
+               
+               if (!$count) {
+                       $query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}private_settings s ON e.guid=s.entity_guid where ";
+               } else {
+                       $query = "SELECT count(distinct e.guid) as total from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}private_settings s ON e.guid=s.entity_guid where ";
+               }
+               foreach ($where as $w)
+                       $query .= " $w and ";
+               $query .= get_access_sql_suffix('e'); // Add access controls
+               if (!$count) {
+                       $query .= " order by $order_by";
+                       if ($limit) $query .= " limit $offset, $limit"; // Add order and limit
+                               
+                       $dt = get_data($query, "entity_row_to_elggstar");
+                       return $dt;
+               } else {
+                       $total = get_data_row($query);
+                       return $total->total;
+               }
+       }
+       
+       /**
+        * Get entities based on their private data by multiple keys, in a similar way to metadata.
+        *
+        * @param string $name The name of the setting
+        * @param string $value The value of the setting
+        * @param string|array $type The type of entity (eg "user", "object" etc) or array(type1 => array('subtype1', ...'subtypeN'), ...)
+        * @param string $subtype The arbitrary subtype of the entity
+        * @param int $owner_guid The GUID of the owning user
+        * @param string $order_by The field to order by; by default, time_created desc
+        * @param int $limit The number of entities to return; 10 by default
+        * @param int $offset The indexing offset, 0 by default
+        * @param boolean $count Set to true to get a count rather than the entities themselves (limits and offsets don't apply in this context). Defaults to false.
+        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
+        * @param int|array $container_guid The container or containers to get entities from (default: all containers).
+        * @return array A list of entities. 
+        */
+       function get_entities_from_private_setting_multi(array $name, $type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null)
+       {
+               global $CONFIG;
+               
+               if ($subtype === false || $subtype === null || $subtype === 0)
+                       return false;
+                       
+               if ($order_by == "") $order_by = "e.time_created desc";
+               $order_by = sanitise_string($order_by);
+               $limit = (int)$limit;
+               $offset = (int)$offset;
+               $site_guid = (int) $site_guid;
+               if ($site_guid == 0)
+                       $site_guid = $CONFIG->site_guid;
+                               
+               $where = array();
+               
+               if (is_array($type)) {
+                       $tempwhere = "";
+                       if (sizeof($type))
+                       foreach($type as $typekey => $subtypearray) {
+                               foreach($subtypearray as $subtypeval) {
+                                       $typekey = sanitise_string($typekey);
+                                       if (!empty($subtypeval)) {
+                                               if (!$subtypeval = (int) get_subtype_id($typekey, $subtypeval)) {
+                                                       return false;
+                                               }
+                                       } else {
+                                               $subtypeval = 0;
+                                       }
+                                       if (!empty($tempwhere)) $tempwhere .= " or ";
+                                       $tempwhere .= "(e.type = '{$typekey}' and e.subtype = {$subtypeval})";
+                               }
+                       }
+                       if (!empty($tempwhere)) $where[] = "({$tempwhere})";
+                       
+               } else {
+                       $type = sanitise_string($type);
+                       if ($subtype AND !$subtype = get_subtype_id($type, $subtype))
+                               return false;
+                       
+                       if ($type != "")
+                               $where[] = "e.type='$type'";
+                       if ($subtype!=="")
+                               $where[] = "e.subtype=$subtype";
+                               
+               }
+                               
+               if ($owner_guid != "") {
+                       if (!is_array($owner_guid)) {
+                               $owner_array = array($owner_guid);
+                               $owner_guid = (int) $owner_guid;
+                       //      $where[] = "owner_guid = '$owner_guid'";
+                       } else if (sizeof($owner_guid) > 0) {
+                               $owner_array = array_map('sanitise_int', $owner_guid);
+                               // Cast every element to the owner_guid array to int
+                       //      $owner_guid = array_map("sanitise_int", $owner_guid);
+                       //      $owner_guid = implode(",",$owner_guid);
+                       //      $where[] = "owner_guid in ({$owner_guid})";
+                       }
+                       if (is_null($container_guid)) {
+                               $container_guid = $owner_array;
+                       }
+               }
+               if ($site_guid > 0)
+                       $where[] = "e.site_guid = {$site_guid}";
+                       
+               if (!is_null($container_guid)) {
+                       if (is_array($container_guid)) {
+                               foreach($container_guid as $key => $val) $container_guid[$key] = (int) $val;
+                               $where[] = "e.container_guid in (" . implode(",",$container_guid) . ")";
+                       } else {
+                               $container_guid = (int) $container_guid;
+                               $where[] = "e.container_guid = {$container_guid}";
+                       }
+               }
+                       
+               if ($name)
+               {
+                       $s_join = "";
+                       $i = 1;
+                       foreach ($name as $k => $n)
+                       {
+                               $k = sanitise_string($k);
+                               $s_join .= " JOIN {$CONFIG->dbprefix}private_settings s$i ON e.guid=s$i.entity_guid";
+                               $where[] = "s$i.name = '$k'";
+                               $where[] = "s$i.value = '$n'";
+                               $i++;
+                       }
+               }
+                       
+               if (!$count) {
+                       $query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e $s_join where ";
+               } else {
+                       $query = "SELECT count(distinct e.guid) as total from {$CONFIG->dbprefix}entities e $s_join where ";
+               }
+               foreach ($where as $w)
+                       $query .= " $w and ";
+               $query .= get_access_sql_suffix('e'); // Add access controls
+               if (!$count) {
+                       $query .= " order by $order_by";
+                       if ($limit) $query .= " limit $offset, $limit"; // Add order and limit
+                       
+                       $dt = get_data($query, "entity_row_to_elggstar");
+                       return $dt;
+               } else {
+                       $total = get_data_row($query);
+                       return $total->total;
+               }
+       }
+       
+       /**
+        * Gets a private setting for an entity.
+        *
+        * @param int $entity_guid The entity GUID
+        * @param string $name The name of the setting
+        * @return mixed The setting value, or false on failure
+        */
+       function get_private_setting($entity_guid, $name) {
+               
+               global $CONFIG;
+               $entity_guid = (int) $entity_guid;
+               $name = sanitise_string($name);
+               
+               if ($setting = get_data_row("SELECT value from {$CONFIG->dbprefix}private_settings where name = '{$name}' and entity_guid = {$entity_guid}")) {
+                       return $setting->value;
+               }
+               return false;
+               
+       }
+       
+       /**
+        * Return an array of all private settings for a given
+        *
+        * @param int $entity_guid The entity GUID
+        */
+       function get_all_private_settings($entity_guid) {
+               global $CONFIG;
+               
+               $entity_guid = (int) $entity_guid;
+               
+               $result = get_data("SELECT * from {$CONFIG->dbprefix}private_settings where entity_guid = {$entity_guid}");
+               if ($result)
+               {
+                       $return = array();
+                       foreach ($result as $r)
+                               $return[$r->name] = $r->value;
+                       
+                       return $return;
+               }
+               
+               return false;
+       }
+       
+       /**
+        * Sets a private setting for an entity.
+        *
+        * @param int $entity_guid The entity GUID
+        * @param string $name The name of the setting
+        * @param string $value The value of the setting
+        * @return mixed The setting ID, or false on failure
+        */
+       function set_private_setting($entity_guid, $name, $value) {
+               
+               global $CONFIG;
+               $entity_guid = (int) $entity_guid;
+               $name = sanitise_string($name);
+               $value = sanitise_string($value);
+               
+               $result = insert_data("INSERT into {$CONFIG->dbprefix}private_settings (entity_guid, name, value) VALUES ($entity_guid, '{$name}', '{$value}') ON DUPLICATE KEY UPDATE value='$value'");
+               if ($result === 0) return true;
+               return $result;
+               
+       }
+       
+       /**
+        * Deletes a private setting for an entity.
+        *
+        * @param int $entity_guid The Entity GUID
+        * @param string $name The name of the setting
+        * @return true|false depending on success
+        * 
+        */
+       function remove_private_setting($entity_guid, $name) {
+               
+               global $CONFIG;
+               $entity_guid = (int) $entity_guid;
+               $name = sanitise_string($name); 
+               return delete_data("DELETE from {$CONFIG->dbprefix}private_settings where name = '{$name}' and entity_guid = {$entity_guid}");
+               
+       }
+       
+       /**
+        * Deletes all private settings for an entity.
+        *
+        * @param int $entity_guid The Entity GUID
+        * @return true|false depending on success
+        * 
+        */
+       function remove_all_private_settings($entity_guid) {
+               
+               global $CONFIG;
+               $entity_guid = (int) $entity_guid;
+               return delete_data("DELETE from {$CONFIG->dbprefix}private_settings where entity_guid = {$entity_guid}");
+       }
+       
+       function recursive_delete_permissions_check($hook, $entity_type, $returnvalue, $params)
+       {
+               static $__RECURSIVE_DELETE_TOKEN;
+               
+               $entity = $params['entity'];
+               
+               if ((isloggedin()) && ($__RECURSIVE_DELETE_TOKEN) && (strcmp($__RECURSIVE_DELETE_TOKEN, md5(get_loggedin_userid()))))
+                       return true;
+               
        }
        
        /**
                foreach ($tables as $table) {
                        delete_data("DELETE from {$CONFIG->dbprefix}{$table} where guid NOT IN (SELECT guid from {$CONFIG->dbprefix}entities)");
                }
-       }\r
-       \r
-       /**\r
-        * Entities init function; establishes the page handler\r
-        *\r
-        */\r
+       }
+       
+       /**
+        * Entities init function; establishes the page handler
+        *
+        */
        function entities_init() 
-       {\r
-               register_page_handler('view','entities_page_handler');\r
-               \r
-               // Allow a permission override for recursive entity deletion\r
-               // TODO: Can this be done better?\r
+       {
+               register_page_handler('view','entities_page_handler');
+               
+               // Allow a permission override for recursive entity deletion
+               // TODO: Can this be done better?
                register_plugin_hook('permissions_check','all','recursive_delete_permissions_check');
                register_plugin_hook('permissions_check:metadata','all','recursive_delete_permissions_check');
                
-               register_plugin_hook('gc','system','entities_gc');\r
-       }\r
-       \r
-       /** Register the import hook */\r
-       register_plugin_hook("import", "all", "import_entity_plugin_hook", 0);\r
-       \r
-       /** Register the hook, ensuring entities are serialised first */\r
-       register_plugin_hook("export", "all", "export_entity_plugin_hook", 0);\r
-       \r
-       /** Hook to get certain named bits of volatile data about an entity */\r
-       register_plugin_hook('volatile', 'metadata', 'volatile_data_export_plugin_hook');\r
-       \r
-       /** Hook for rendering a default icon for entities */\r
-       register_plugin_hook('entity:icon:url', 'all', 'default_entity_icon_hook', 1000);\r
-       \r
-       /** Register init system event **/\r
-       register_elgg_event_handler('init','system','entities_init');\r
-       \r
-?>\r
+               register_plugin_hook('gc','system','entities_gc');
+       }
+       
+       /** Register the import hook */
+       register_plugin_hook("import", "all", "import_entity_plugin_hook", 0);
+       
+       /** Register the hook, ensuring entities are serialised first */
+       register_plugin_hook("export", "all", "export_entity_plugin_hook", 0);
+       
+       /** Hook to get certain named bits of volatile data about an entity */
+       register_plugin_hook('volatile', 'metadata', 'volatile_data_export_plugin_hook');
+       
+       /** Hook for rendering a default icon for entities */
+       register_plugin_hook('entity:icon:url', 'all', 'default_entity_icon_hook', 1000);
+       
+       /** Register init system event **/
+       register_elgg_event_handler('init','system','entities_init');
+       
+?>
index a298671f3e44436f5f3557d597a0e141cb180a0b..f3f3753bcdd456c7ac19fa44653a90cd245d3133 100644 (file)
@@ -66,7 +66,7 @@
                 */
                protected function set($name, $value, $value_type = "") {
 
-                       $this->attributes[$name] = $value;\r
+                       $this->attributes[$name] = $value;
                        if ($name == 'value')
                                $this->attributes['value_type'] = detect_extender_valuetype($value, $value_type);
                        
                { 
                        return get_user($this->owner_guid); 
                }
-               \r
-               /**\r
-                * Returns the entity this is attached to\r
-                *\r
-                * @return ElggEntity The enttiy\r
-                */\r
-               public function getEntity() {\r
-                       return get_entity($this->entity_guid);\r
-               }\r
+               
+               /**
+                * Returns the entity this is attached to
+                *
+                * @return ElggEntity The enttiy
+                */
+               public function getEntity() {
+                       return get_entity($this->entity_guid);
+               }
                
                /**
                 * Save this data to the appropriate database table.
                 * Delete this data.
                 */
                abstract public function delete();
-               \r
-               /**\r
-                * Determines whether or not the specified user can edit this\r
-                *\r
-                * @param int $user_guid The GUID of the user (defaults to currently logged in user)\r
-                * @return true|false\r
-                */\r
-               public function canEdit($user_guid = 0) {\r
-                       return can_edit_extender($this->id,$this->type,$user_guid);\r
+               
+               /**
+                * Determines whether or not the specified user can edit this
+                *
+                * @param int $user_guid The GUID of the user (defaults to currently logged in user)
+                * @return true|false
+                */
+               public function canEdit($user_guid = 0) {
+                       return can_edit_extender($this->id,$this->type,$user_guid);
                }
                
                /**
                        return true;
                }
        }
-       \r
-       /**\r
-        * Determines whether or not the specified user can edit the specified piece of extender\r
-        *\r
-        * @param int $extender_id The ID of the piece of extender\r
-        * @param string $type 'metadata' or 'annotation'\r
-        * @param int $user_guid The GUID of the user\r
-        * @return true|false\r
-        */\r
+       
+       /**
+        * Determines whether or not the specified user can edit the specified piece of extender
+        *
+        * @param int $extender_id The ID of the piece of extender
+        * @param string $type 'metadata' or 'annotation'
+        * @param int $user_guid The GUID of the user
+        * @return true|false
+        */
        function can_edit_extender($extender_id, $type, $user_guid = 0) {
-               \r
-               if (!isloggedin())\r
-                       return false;\r
+               
+               if (!isloggedin())
+                       return false;
                
                $user_guid = (int)$user_guid;
                $user = get_entity($user_guid);
-               if (!$user) $user = get_loggedin_user(); \r
-\r
-               $functionname = "get_{$type}";\r
-               if (is_callable($functionname)) {\r
-                       $extender = $functionname($extender_id);\r
-               } else return false;\r
-               \r
-               if (!is_a($extender,"ElggExtender")) return false;\r
-               \r
-               // If the owner is the specified user, great! They can edit.\r
-               if ($extender->getOwner() == $user->getGUID()) return true;\r
-               \r
-               // If the user can edit the entity this is attached to, great! They can edit.\r
-               if (can_edit_entity($extender->entity_guid,$user->getGUID())) return true;\r
-               \r
-               // Trigger plugin hooks\r
-               return trigger_plugin_hook('permissions_check',$type,array('entity' => $entity, 'user' => $user),false);\r
-               \r
+               if (!$user) $user = get_loggedin_user(); 
+
+               $functionname = "get_{$type}";
+               if (is_callable($functionname)) {
+                       $extender = $functionname($extender_id);
+               } else return false;
+               
+               if (!is_a($extender,"ElggExtender")) return false;
+               
+               // If the owner is the specified user, great! They can edit.
+               if ($extender->getOwner() == $user->getGUID()) return true;
+               
+               // If the user can edit the entity this is attached to, great! They can edit.
+               if (can_edit_entity($extender->entity_guid,$user->getGUID())) return true;
+               
+               // Trigger plugin hooks
+               return trigger_plugin_hook('permissions_check',$type,array('entity' => $entity, 'user' => $user),false);
+               
        }
        
        /**
                        $url = $CONFIG->wwwroot  . "export/$view/$guid/$type/$nameid/";
                } 
                return $url;
-       }\r
+       }
        
        /** Register the hook */
        register_plugin_hook("import", "all", "import_extender_plugin_hook", 2);
index 338df2a081dd66f6fb7f10377126a83be50b430a..71abbb33023c5641590bc657a0b17bc3f281cbc0 100644 (file)
@@ -1,66 +1,66 @@
-<?php\r
-       /**\r
-        * Parameter input functions.\r
-        * This file contains functions for getting input from get/post variables.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Parameter input functions.
+        * This file contains functions for getting input from get/post variables.
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd <info@elgg.com>
 
-        * @author Curverider Ltd <info@elgg.com>\r
+        * @link http://elgg.org/
+        */
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /**\r
-        * Get some input from variables passed on the GET or POST line.\r
-        * \r
-        * @param $variable string The variable we want to return.\r
+       /**
+        * Get some input from variables passed on the GET or POST line.
+        * 
+        * @param $variable string The variable we want to return.
         * @param $default mixed A default value for the variable if it is not found.
-        * @param $filter_result If true then the result is filtered for bad tags.\r
-        */\r
-       function get_input($variable, $default = "", $filter_result = true)\r
-       {\r
-\r
-               global $CONFIG;\r
-               \r
-               if (isset($CONFIG->input[$variable])) {\r
+        * @param $filter_result If true then the result is filtered for bad tags.
+        */
+       function get_input($variable, $default = "", $filter_result = true)
+       {
+
+               global $CONFIG;
+               
+               if (isset($CONFIG->input[$variable])) {
                        $var = $CONFIG->input[$variable];
                        
                        if ($filter_result)
                                $var = filter_tags($var);
                                
                        return $var;
-               }\r
-               \r
+               }
+               
                if (isset($_REQUEST[$variable])) {
-                       \r
+                       
                        if (is_array($_REQUEST[$variable])) {
                                $var = $_REQUEST[$variable];
                        } else {
-                               $var = trim($_REQUEST[$variable]);\r
-                       }\r
+                               $var = trim($_REQUEST[$variable]);
+                       }
                        
                        if ($filter_result)
-                               $var = filter_tags($var);\r
-\r
-                       return $var;\r
-                       \r
-               }\r
-\r
-               return $default;\r
-\r
-       }\r
-       \r
-       /**\r
-        * Sets an input value that may later be retrieved by get_input\r
-        *\r
-        * @param string $variable The name of the variable\r
-        * @param string $value The value of the variable\r
-        */\r
-       function set_input($variable, $value) {\r
-               \r
-               global $CONFIG;\r
-               if (!isset($CONFIG->input))\r
+                               $var = filter_tags($var);
+
+                       return $var;
+                       
+               }
+
+               return $default;
+
+       }
+       
+       /**
+        * Sets an input value that may later be retrieved by get_input
+        *
+        * @param string $variable The name of the variable
+        * @param string $value The value of the variable
+        */
+       function set_input($variable, $value) {
+               
+               global $CONFIG;
+               if (!isset($CONFIG->input))
                        $CONFIG->input = array();
                                        
                if (is_array($value))
                        
                        $CONFIG->input[trim($variable)] = $value;
                }
-               else\r
-                       $CONFIG->input[trim($variable)] = trim($value);\r
-                       \r
-       }\r
-       \r
-       /**\r
-        * Filter tags from a given string based on registered hooks.\r
-        * @param $var\r
-        * @return mixed The filtered result\r
-        */\r
-       function filter_tags($var)\r
-       {\r
-               return trigger_plugin_hook('validate', 'input', null, $var);\r
+               else
+                       $CONFIG->input[trim($variable)] = trim($value);
+                       
+       }
+       
+       /**
+        * Filter tags from a given string based on registered hooks.
+        * @param $var
+        * @return mixed The filtered result
+        */
+       function filter_tags($var)
+       {
+               return trigger_plugin_hook('validate', 'input', null, $var);
        }
        
        /**
                $path = $path . "/";
                
                return $path;
-       }\r
+       }
+       
        
-       \r
-    /**\r
-     * Takes a string and turns any URLs into formatted links\r
-     * \r
-     * @param string $text The input string\r
-     * @return string The output stirng with formatted links\r
-     **/\r
+    /**
+     * Takes a string and turns any URLs into formatted links
+     * 
+     * @param string $text The input string
+     * @return string The output stirng with formatted links
+     **/
     function parse_urls($text) {
        
                return preg_replace_callback('/(?<!=["\'])((ht|f)tps?:\/\/[^\s\r\n\t<>"\'\!\(\)]+)/i', 
                $urltext = str_replace("/", "/<wbr />", $url);
                return "<a href=\"$url\" style=\"text-decoration:underline;\">$urltext</a>";
             '
-        ), $text);\r
-    }\r
-       \r
-       function autop($pee, $br = 1) {\r
-               $pee = $pee . "\n"; // just to make things a little easier, pad the end\r
-               $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);\r
-               // Space things out a little\r
-               $allblocks = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr)';\r
-               $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);\r
-               $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);\r
-               $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines\r
-               if ( strpos($pee, '<object') !== false ) {\r
-                       $pee = preg_replace('|\s*<param([^>]*)>\s*|', "<param$1>", $pee); // no pee inside object/embed\r
-                       $pee = preg_replace('|\s*</embed>\s*|', '</embed>', $pee);\r
-               }\r
-               $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates\r
-               $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end\r
-               $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace\r
-               $pee = preg_replace('!<p>([^<]+)\s*?(</(?:div|address|form)[^>]*>)!', "<p>$1</p>$2", $pee);\r
-               $pee = preg_replace( '|<p>|', "$1<p>", $pee );\r
-               $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag\r
-               $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists\r
-               $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);\r
-               $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);\r
-               $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);\r
-               $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);\r
-               if ($br) {\r
-                       $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', create_function('$matches', 'return str_replace("\n", "<WPPreserveNewline />", $matches[0]);'), $pee);\r
-                       $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks\r
-                       $pee = str_replace('<WPPreserveNewline />', "\n", $pee);\r
-               }\r
-               $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);\r
-               $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);\r
-               if (strpos($pee, '<pre') !== false)\r
-                       $pee = preg_replace_callback('!(<pre.*?>)(.*?)</pre>!is', 'clean_pre', $pee );\r
-               $pee = preg_replace( "|\n</p>$|", '</p>', $pee );\r
-       \r
-               return $pee;\r
-       }\r
-        \r
-       function input_init() {\r
-               \r
-               if (ini_get_bool('magic_quotes_gpc') ) {\r
-                   \r
-                   //do keys as well, cos array_map ignores them\r
-                   function stripslashes_arraykeys($array) {\r
-                       if (is_array($array)) {\r
-                           $array2 = array();\r
-                           foreach ($array as $key => $data) {\r
-                               if ($key != stripslashes($key)) {\r
-                                   $array2[stripslashes($key)] = $data;\r
-                               } else {\r
-                                   $array2[$key] = $data;\r
-                               }\r
-                           }\r
-                           return $array2;\r
-                       } else {\r
-                           return $array;\r
-                       }\r
-                   }\r
-                   \r
-                   function stripslashes_deep($value) {\r
-                       if (is_array($value)) {\r
-                           $value = stripslashes_arraykeys($value);\r
-                           $value = array_map('stripslashes_deep', $value);\r
-                       } else {\r
-                           $value = stripslashes($value);\r
-                       }\r
-                       return $value;\r
-                   }\r
-                   \r
-                   $_POST = stripslashes_arraykeys($_POST);\r
-                   $_GET = stripslashes_arraykeys($_GET);\r
-                   $_COOKIE = stripslashes_arraykeys($_COOKIE);\r
-                   $_REQUEST = stripslashes_arraykeys($_REQUEST);\r
-                   \r
-                   $_POST = array_map('stripslashes_deep', $_POST);\r
-                   $_GET = array_map('stripslashes_deep', $_GET);\r
-                   $_COOKIE = array_map('stripslashes_deep', $_COOKIE);\r
-                   $_REQUEST = array_map('stripslashes_deep', $_REQUEST);\r
-                   if (!empty($_SERVER['REQUEST_URI'])) {\r
-                       $_SERVER['REQUEST_URI'] = stripslashes($_SERVER['REQUEST_URI']);\r
-                   }\r
-                   if (!empty($_SERVER['QUERY_STRING'])) {\r
-                       $_SERVER['QUERY_STRING'] = stripslashes($_SERVER['QUERY_STRING']);\r
-                   }\r
-                   if (!empty($_SERVER['HTTP_REFERER'])) {\r
-                       $_SERVER['HTTP_REFERER'] = stripslashes($_SERVER['HTTP_REFERER']);\r
-                   }\r
-                   if (!empty($_SERVER['PATH_INFO'])) {\r
-                       $_SERVER['PATH_INFO'] = stripslashes($_SERVER['PATH_INFO']);\r
-                   }\r
-                   if (!empty($_SERVER['PHP_SELF'])) {\r
-                       $_SERVER['PHP_SELF'] = stripslashes($_SERVER['PHP_SELF']);\r
-                   }\r
-                   if (!empty($_SERVER['PATH_TRANSLATED'])) {\r
-                       $_SERVER['PATH_TRANSLATED'] = stripslashes($_SERVER['PATH_TRANSLATED']);\r
-                   }\r
-                   \r
+        ), $text);
+    }
+       
+       function autop($pee, $br = 1) {
+               $pee = $pee . "\n"; // just to make things a little easier, pad the end
+               $pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
+               // Space things out a little
+               $allblocks = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr)';
+               $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee);
+               $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
+               $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
+               if ( strpos($pee, '<object') !== false ) {
+                       $pee = preg_replace('|\s*<param([^>]*)>\s*|', "<param$1>", $pee); // no pee inside object/embed
+                       $pee = preg_replace('|\s*</embed>\s*|', '</embed>', $pee);
+               }
+               $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
+               $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
+               $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
+               $pee = preg_replace('!<p>([^<]+)\s*?(</(?:div|address|form)[^>]*>)!', "<p>$1</p>$2", $pee);
+               $pee = preg_replace( '|<p>|', "$1<p>", $pee );
+               $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
+               $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
+               $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
+               $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
+               $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
+               $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
+               if ($br) {
+                       $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', create_function('$matches', 'return str_replace("\n", "<WPPreserveNewline />", $matches[0]);'), $pee);
+                       $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
+                       $pee = str_replace('<WPPreserveNewline />', "\n", $pee);
+               }
+               $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee);
+               $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
+               if (strpos($pee, '<pre') !== false)
+                       $pee = preg_replace_callback('!(<pre.*?>)(.*?)</pre>!is', 'clean_pre', $pee );
+               $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
+       
+               return $pee;
+       }
+        
+       function input_init() {
+               
+               if (ini_get_bool('magic_quotes_gpc') ) {
+                   
+                   //do keys as well, cos array_map ignores them
+                   function stripslashes_arraykeys($array) {
+                       if (is_array($array)) {
+                           $array2 = array();
+                           foreach ($array as $key => $data) {
+                               if ($key != stripslashes($key)) {
+                                   $array2[stripslashes($key)] = $data;
+                               } else {
+                                   $array2[$key] = $data;
+                               }
+                           }
+                           return $array2;
+                       } else {
+                           return $array;
+                       }
+                   }
+                   
+                   function stripslashes_deep($value) {
+                       if (is_array($value)) {
+                           $value = stripslashes_arraykeys($value);
+                           $value = array_map('stripslashes_deep', $value);
+                       } else {
+                           $value = stripslashes($value);
+                       }
+                       return $value;
+                   }
+                   
+                   $_POST = stripslashes_arraykeys($_POST);
+                   $_GET = stripslashes_arraykeys($_GET);
+                   $_COOKIE = stripslashes_arraykeys($_COOKIE);
+                   $_REQUEST = stripslashes_arraykeys($_REQUEST);
+                   
+                   $_POST = array_map('stripslashes_deep', $_POST);
+                   $_GET = array_map('stripslashes_deep', $_GET);
+                   $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
+                   $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
+                   if (!empty($_SERVER['REQUEST_URI'])) {
+                       $_SERVER['REQUEST_URI'] = stripslashes($_SERVER['REQUEST_URI']);
+                   }
+                   if (!empty($_SERVER['QUERY_STRING'])) {
+                       $_SERVER['QUERY_STRING'] = stripslashes($_SERVER['QUERY_STRING']);
+                   }
+                   if (!empty($_SERVER['HTTP_REFERER'])) {
+                       $_SERVER['HTTP_REFERER'] = stripslashes($_SERVER['HTTP_REFERER']);
+                   }
+                   if (!empty($_SERVER['PATH_INFO'])) {
+                       $_SERVER['PATH_INFO'] = stripslashes($_SERVER['PATH_INFO']);
+                   }
+                   if (!empty($_SERVER['PHP_SELF'])) {
+                       $_SERVER['PHP_SELF'] = stripslashes($_SERVER['PHP_SELF']);
+                   }
+                   if (!empty($_SERVER['PATH_TRANSLATED'])) {
+                       $_SERVER['PATH_TRANSLATED'] = stripslashes($_SERVER['PATH_TRANSLATED']);
+                   }
+                   
                }
-               \r
-       }\r
-       \r
-       register_elgg_event_handler('init','system','input_init');\r
-        \r
-       \r
+               
+       }
+       
+       register_elgg_event_handler('init','system','input_init');
+        
+       
 ?>
\ No newline at end of file
index 6faa70ef5f3d152edf2d13a8e64bd5d0a2c4b468..03abede141c20b2414d61b0909f965e4c1a83d1b 100644 (file)
@@ -1,16 +1,16 @@
-<?php\r
-\r
-       /**\r
-        * Elgg installation\r
-        * Various functions to assist with installing and upgrading the system\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg installation
+        * Various functions to assist with installing and upgrading the system
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
 
                /**
                 * Check that the installed version of PHP meets the minimum requirements (currently 5.2 or greater).
                 * @return bool
                 */
                function php_check_version()
-               {\r
+               {
                        /*
                        if ( // TODO: Remove this when Redhat pulls its finger out
                                (version_compare(phpversion(), '5.1.6', '>=')) &&
                                (version_compare(phpversion(), '5.2.0', '<'))
                        )
-                               register_error(elgg_echo('configurationwarning:phpversion'));\r
+                               register_error(elgg_echo('configurationwarning:phpversion'));
                        */
                        
                        if (version_compare(phpversion(), '5.1.2', '>='))
                                
                        return true;
                }
-\r
-       /**\r
-        * Returns whether or not the database has been installed\r
-        *\r
-        * @return true|false Whether the database has been installed\r
-        */\r
+
+       /**
+        * Returns whether or not the database has been installed
+        *
+        * @return true|false Whether the database has been installed
+        */
                function is_db_installed() {
                        
                        global $CONFIG;
                        if (isset($CONFIG->db_installed)) {
                                return $CONFIG->db_installed;
                        }
-\r
-                       if ($dblink = get_db_link('read')) {\r
-                               mysql_query("select name from {$CONFIG->dbprefix}datalists limit 1",$dblink);\r
-                               if (mysql_errno($dblink) > 0) return false;\r
+
+                       if ($dblink = get_db_link('read')) {
+                               mysql_query("select name from {$CONFIG->dbprefix}datalists limit 1",$dblink);
+                               if (mysql_errno($dblink) > 0) return false;
                        } else return false; 
                        
                        $CONFIG->db_installed = true; // Set flag if db is installed (if false then we want to check every time)
-                       \r
-                       return true;\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * Returns whether or not other settings have been set\r
-        *\r
-        * @return true|false Whether or not the rest of the installation has been followed through with\r
-        */\r
-               function is_installed() {\r
-                       \r
-                       global $CONFIG;\r
-                       return datalist_get('installed');\r
-                       \r
-               }\r
+                       
+                       return true;
+                       
+               }
+               
+       /**
+        * Returns whether or not other settings have been set
+        *
+        * @return true|false Whether or not the rest of the installation has been followed through with
+        */
+               function is_installed() {
+                       
+                       global $CONFIG;
+                       return datalist_get('installed');
+                       
+               }
                
                /**
                 * Copy and create a new settings.php from settings.example.php, substituting the variables in
                        
                        return $file;
                }
-               \r
-       /**\r
-        * Initialisation for installation functions\r
-        *\r
-        */\r
-               function install_init() {\r
-                       register_action("systemsettings/install",true);                 \r
-               }\r
-               \r
-               register_elgg_event_handler("boot","system","install_init");\r
-               \r
+               
+       /**
+        * Initialisation for installation functions
+        *
+        */
+               function install_init() {
+                       register_action("systemsettings/install",true);                 
+               }
+               
+               register_elgg_event_handler("boot","system","install_init");
+               
 ?>
\ No newline at end of file
index bca0466eab56d11bed1bfb88db27ea41c2c9fcc3..dd97d0927fd320d2db62697b09534ffaf2e6933f 100644 (file)
@@ -1,51 +1,51 @@
-<?php\r
-\r
-       /**\r
-        * Elgg language module\r
-        * Functions to manage language and translations.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg language module
+        * Functions to manage language and translations.
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       /**
+        * Add a translation.
+        * 
+        * Translations are arrays in the Zend Translation array format, eg:
+        * 
+        *      $english = array('message1' => 'message1', 'message2' => 'message2');
+        *  $german = array('message1' => 'Nachricht1','message2' => 'Nachricht2');
+        *
+        * @param string $country_code Standard country code (eg 'en', 'nl', 'es')
+        * @param array $language_array Formatted array of strings
+        * @return true|false Depending on success
+        */
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /**\r
-        * Add a translation.\r
-        * \r
-        * Translations are arrays in the Zend Translation array format, eg:\r
-        * \r
-        *      $english = array('message1' => 'message1', 'message2' => 'message2');\r
-        *  $german = array('message1' => 'Nachricht1','message2' => 'Nachricht2');\r
-        *\r
-        * @param string $country_code Standard country code (eg 'en', 'nl', 'es')\r
-        * @param array $language_array Formatted array of strings\r
-        * @return true|false Depending on success\r
-        */\r
-\r
-               function add_translation($country_code, $language_array) {\r
-                       \r
-                       global $CONFIG;\r
-                       if (!isset($CONFIG->translations))\r
-                               $CONFIG->translations = array();\r
-                                                       \r
-                       $country_code = strtolower($country_code);\r
-                       $country_code = trim($country_code);\r
-                       if (is_array($language_array) && sizeof($language_array) > 0 && $country_code != "") {\r
-                               \r
-                               if (!isset($CONFIG->translations[$country_code])) {\r
-                                       $CONFIG->translations[$country_code] = $language_array;\r
-                               } else {\r
-                                       $CONFIG->translations[$country_code] = $language_array + $CONFIG->translations[$country_code];\r
-                               }\r
-                               \r
-                               return true;\r
-                               \r
-                       }\r
-                       return false;\r
-                       \r
+               function add_translation($country_code, $language_array) {
+                       
+                       global $CONFIG;
+                       if (!isset($CONFIG->translations))
+                               $CONFIG->translations = array();
+                                                       
+                       $country_code = strtolower($country_code);
+                       $country_code = trim($country_code);
+                       if (is_array($language_array) && sizeof($language_array) > 0 && $country_code != "") {
+                               
+                               if (!isset($CONFIG->translations[$country_code])) {
+                                       $CONFIG->translations[$country_code] = $language_array;
+                               } else {
+                                       $CONFIG->translations[$country_code] = $language_array + $CONFIG->translations[$country_code];
+                               }
+                               
+                               return true;
+                               
+                       }
+                       return false;
+                       
                }
                
        /**
                        $language = 'en';
                        
                return $language;
-       }\r
-               \r
-       /**\r
-        * Gets the current language in use by the system or user.\r
-        * \r
-        * [Marcus Povey 20090216: Not sure why this func is necessary.]\r
-        *\r
-        * @return string The language code (eg "en")\r
-        */\r
-               function get_language() {\r
-                       \r
-                       global $CONFIG;\r
-               \r
+       }
+               
+       /**
+        * Gets the current language in use by the system or user.
+        * 
+        * [Marcus Povey 20090216: Not sure why this func is necessary.]
+        *
+        * @return string The language code (eg "en")
+        */
+               function get_language() {
+                       
+                       global $CONFIG;
+               
                        $user = get_loggedin_user();  
-                       $language = false;\r
-       \r
-                       if (($user) && ($user->language))\r
-                               $language = $user->language;\r
-\r
-                       if ((!$language) && (isset($CONFIG->language)) && ($CONFIG->language))\r
+                       $language = false;
+       
+                       if (($user) && ($user->language))
+                               $language = $user->language;
+
+                       if ((!$language) && (isset($CONFIG->language)) && ($CONFIG->language))
                                $language = $CONFIG->language;
                                
-                       if ($language) {\r
-                               return $language;\r
-                       }               \r
-                       return false;\r
-                       \r
-               }\r
-       \r
-       /**\r
-        * Given a message shortcode, returns an appropriately translated full-text string \r
-        *\r
-        * @param string $message_key The short message code\r
-        * @param string $language Optionally, the standard language code (defaults to the site default, then English)\r
-        * @return string Either the translated string, or the original English string, or an empty string\r
-        */\r
-               function elgg_echo($message_key, $language = "") {\r
-                       \r
+                       if ($language) {
+                               return $language;
+                       }               
+                       return false;
+                       
+               }
+       
+       /**
+        * Given a message shortcode, returns an appropriately translated full-text string 
+        *
+        * @param string $message_key The short message code
+        * @param string $language Optionally, the standard language code (defaults to the site default, then English)
+        * @return string Either the translated string, or the original English string, or an empty string
+        */
+               function elgg_echo($message_key, $language = "") {
+                       
                        global $CONFIG;
                                
                        static $CURRENT_LANGUAGE;
-                       if ((!$CURRENT_LANGUAGE) && (!$language)) \r
+                       if ((!$CURRENT_LANGUAGE) && (!$language)) 
                                $CURRENT_LANGUAGE = $language = get_language();
                        else 
-                               $language = $CURRENT_LANGUAGE;\r
-\r
-                       if (isset($CONFIG->translations[$language][$message_key])) {\r
-                               return $CONFIG->translations[$language][$message_key];\r
-                       } else if (isset($CONFIG->translations["en"][$message_key])) {\r
-                               return $CONFIG->translations["en"][$message_key];\r
-                       }\r
-                               \r
-                       return $message_key;\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * When given a full path, finds translation files and loads them\r
-        *\r
-        * @param string $path Full path\r
-        * @param bool $load_all If true all languages are loaded, if false only the current language + en are loaded\r
-        */\r
+                               $language = $CURRENT_LANGUAGE;
+
+                       if (isset($CONFIG->translations[$language][$message_key])) {
+                               return $CONFIG->translations[$language][$message_key];
+                       } else if (isset($CONFIG->translations["en"][$message_key])) {
+                               return $CONFIG->translations["en"][$message_key];
+                       }
+                               
+                       return $message_key;
+                       
+               }
+               
+       /**
+        * When given a full path, finds translation files and loads them
+        *
+        * @param string $path Full path
+        * @param bool $load_all If true all languages are loaded, if false only the current language + en are loaded
+        */
                function register_translations($path, $load_all = false) {
                        global $CONFIG;
-                       \r
-                       // Make a note of this path just incase we need to register this language later\r
-                       if(!isset($CONFIG->language_paths)) $CONFIG->language_paths = array();\r
-                       $CONFIG->language_paths[$path] = true;\r
-                       \r
-                       // Get the current language based on site defaults and user preference\r
-                       $current_language = get_current_language();\r
-\r
-                       if (isset($CONFIG->debug) && $CONFIG->debug == true) error_log("Translations loaded from : $path");\r
+                       
+                       // Make a note of this path just incase we need to register this language later
+                       if(!isset($CONFIG->language_paths)) $CONFIG->language_paths = array();
+                       $CONFIG->language_paths[$path] = true;
+                       
+                       // Get the current language based on site defaults and user preference
+                       $current_language = get_current_language();
+
+                       if (isset($CONFIG->debug) && $CONFIG->debug == true) error_log("Translations loaded from : $path");
                
-                       if ($handle = opendir($path)) {\r
-                               while ($language = readdir($handle)) {\r
-                               \r
-                                       if (\r
-                                               ((in_array($language, array('en.php', $current_language . '.php'))) /*&& (!is_dir($path . $language))*/) ||\r
-                                               (($load_all) && (strpos($language, '.php')!==false)/* && (!is_dir($path . $language))*/) \r
-                                       )\r
-                                               include_once($path . $language);\r
-                                       \r
-                               }\r
+                       if ($handle = opendir($path)) {
+                               while ($language = readdir($handle)) {
+                               
+                                       if (
+                                               ((in_array($language, array('en.php', $current_language . '.php'))) /*&& (!is_dir($path . $language))*/) ||
+                                               (($load_all) && (strpos($language, '.php')!==false)/* && (!is_dir($path . $language))*/) 
+                                       )
+                                               include_once($path . $language);
+                                       
+                               }
                        }
                        else
-                               error_log("Missing translation path $path");\r
-                               \r
-               }\r
-               \r
-               /** \r
-                * Reload all translations from all registered paths.\r
-                * \r
-                * This is only called by functions which need to know all possible translations, namely the\r
-                * statistic gathering ones.\r
-                * \r
-                * TODO: Better on demand loading based on language_paths array\r
-                * \r
-                * @return bool\r
-                */\r
-               function reload_all_translations() \r
-               {\r
-                       global $CONFIG;\r
-                       \r
-                       static $LANG_RELOAD_ALL_RUN;\r
-                       if ($LANG_RELOAD_ALL_RUN) return null;\r
-                       \r
-                       foreach ($CONFIG->language_paths as $path => $dummy)\r
-                               register_translations($path, true);\r
-\r
-                       $LANG_RELOAD_ALL_RUN = true;\r
-               }\r
+                               error_log("Missing translation path $path");
+                               
+               }
+               
+               /** 
+                * Reload all translations from all registered paths.
+                * 
+                * This is only called by functions which need to know all possible translations, namely the
+                * statistic gathering ones.
+                * 
+                * TODO: Better on demand loading based on language_paths array
+                * 
+                * @return bool
+                */
+               function reload_all_translations() 
+               {
+                       global $CONFIG;
+                       
+                       static $LANG_RELOAD_ALL_RUN;
+                       if ($LANG_RELOAD_ALL_RUN) return null;
+                       
+                       foreach ($CONFIG->language_paths as $path => $dummy)
+                               register_translations($path, true);
+
+                       $LANG_RELOAD_ALL_RUN = true;
+               }
                
        /**
         * Return an array of installed translations as an associative array "two letter code" => "native language name".
         */
                function get_installed_translations()
                {
-                       global $CONFIG;\r
-                       \r
-                       // Ensure that all possible translations are loaded\r
+                       global $CONFIG;
+                       
+                       // Ensure that all possible translations are loaded
                        reload_all_translations();
                        
-                       $installed = array();\r
+                       $installed = array();
                        
                        foreach ($CONFIG->translations as $k => $v)
                        {
         */
                function get_language_completeness($language)
                {
-                       global $CONFIG;\r
-                       \r
-                       // Ensure that all possible translations are loaded\r
+                       global $CONFIG;
+                       
+                       // Ensure that all possible translations are loaded
                        reload_all_translations();
                        
                        $language = sanitise_string($language);
         */
                function get_missing_language_keys($language)
                {
-                       global $CONFIG;\r
-                       \r
-                       // Ensure that all possible translations are loaded\r
+                       global $CONFIG;
+                       
+                       // Ensure that all possible translations are loaded
                        reload_all_translations();
                        
                        $missing = array();
                }
                
                register_translations(dirname(dirname(dirname(__FILE__))) . "/languages/");
-               \r
+               
 ?>
\ No newline at end of file
index 9aa033061f08fb4a1b613a42a8f49f1bb3fe5db2..c6e5db4cdc8155ab8aacc1f6c33b5cda4a854317 100644 (file)
-<?php\r
-       /**\r
-        * Elgg metadata\r
-        * Functions to manage object metadata.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Elgg metadata
+        * Functions to manage object metadata.
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd <info@elgg.com>\r
+        * @author Curverider Ltd <info@elgg.com>
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /**\r
-        * ElggMetadata\r
-        * This class describes metadata that can be attached to ElggEntities.\r
-        * \r
-        * @author Curverider Ltd <info@elgg.com>\r
-        * @package Elgg\r
-        * @subpackage Core\r
-        */\r
-       class ElggMetadata extends ElggExtender\r
-       {\r
-                       \r
-               /**\r
-                * Construct a new site object, optionally from a given id value or row.\r
-                *\r
-                * @param mixed $id\r
-                */\r
-               function __construct($id = null) \r
-               {\r
-                       $this->attributes = array();\r
-                       \r
-                       if (!empty($id)) {\r
-                               \r
-                               if ($id instanceof stdClass)\r
-                                       $metadata = $id; // Create from db row\r
-                               else\r
-                                       $metadata = get_metadata($id);  \r
-                               \r
-                               if ($metadata) {\r
-                                       $objarray = (array) $metadata;\r
-                                       foreach($objarray as $key => $value) {\r
-                                               $this->attributes[$key] = $value;\r
-                                       }\r
-                                       $this->attributes['type'] = "metadata";\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               /**\r
-                * Class member get overloading\r
-                *\r
-                * @param string $name\r
-                * @return mixed\r
-                */\r
-               function __get($name) {\r
-                       return $this->get($name);\r
-               }\r
-               \r
-               /**\r
-                * Class member set overloading\r
-                *\r
-                * @param string $name\r
-                * @param mixed $value\r
-                * @return mixed\r
-                */\r
-               function __set($name, $value) {\r
-                       return $this->set($name, $value);\r
-               }\r
-\r
-               /**\r
-                * Determines whether or not the user can edit this piece of metadata\r
-                *\r
-                * @return true|false Depending on permissions\r
-                */\r
-               function canEdit() {\r
-                       \r
-                       if ($entity = get_entity($this->get('entity_guid'))) {\r
-                               return $entity->canEditMetadata($this);\r
-                       }\r
-                       return false;\r
-                       \r
-               }\r
-               \r
-               /**\r
-                * Save matadata object\r
-                *\r
-                * @return int the metadata object id\r
-                */\r
-               function save()\r
-               {\r
-                       if ($this->id > 0)\r
-                               return update_metadata($this->id, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);\r
-                       else\r
-                       { \r
-                               $this->id = create_metadata($this->entity_guid, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);\r
-                               if (!$this->id) throw new IOException(sprintf(elgg_new('IOException:UnableToSaveNew'), get_class()));\r
-                               return $this->id;\r
-                       }\r
-                       \r
-               }\r
-               \r
-               /**\r
-                * Delete a given metadata.\r
-                */\r
-               function delete() \r
-               { \r
-                       return delete_metadata($this->id); \r
-               }\r
-               \r
-               /**\r
-                * Get a url for this item of metadata.\r
-                *\r
-                * @return string\r
-                */\r
-               public function getURL() { return get_metadata_url($this->id); }\r
-       \r
-               // SYSTEM LOG INTERFACE ////////////////////////////////////////////////////////////\r
-\r
-               /**\r
-                * For a given ID, return the object associated with it.\r
-                * This is used by the river functionality primarily.\r
-                * This is useful for checking access permissions etc on objects.\r
-                */\r
-               public function getObjectFromID($id) { return get_metadata($id); }\r
-       }\r
-\r
-       /**\r
-        * Convert a database row to a new ElggMetadata\r
-        *\r
-        * @param stdClass $row\r
-        * @return stdClass or ElggMetadata\r
-        */\r
-       function row_to_elggmetadata($row) \r
-       {\r
-               if (!($row instanceof stdClass))\r
-                       return $row;\r
-                       \r
-               return new ElggMetadata($row);\r
-       }\r
-\r
-                       \r
-       /**\r
-        * Get a specific item of metadata.\r
-        * \r
-        * @param $id int The item of metadata being retrieved.\r
-        */\r
-       function get_metadata($id)\r
-       {\r
-               global $CONFIG;\r
-\r
-               $id = (int)$id;\r
-               $access = get_access_sql_suffix("e");\r
-               $md_access = get_access_sql_suffix("m");\r
-\r
-               return row_to_elggmetadata(get_data_row("SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}metadata m JOIN {$CONFIG->dbprefix}entities e on e.guid = m.entity_guid JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where m.id=$id and $access and $md_access"));\r
-       }\r
-       \r
-       /**\r
-        * Removes metadata on an entity with a particular name, optionally with a given value.\r
-        *\r
-        * @param int $entity_guid The entity GUID\r
-        * @param string $name The name of the metadata\r
-        * @param string $value The optional value of the item (useful for removing a single item in a multiple set)\r
-        * @return true|false Depending on success\r
-        */\r
-       function remove_metadata($entity_guid, $name, $value = "") {\r
-               \r
-               global $CONFIG;\r
-               $entity_guid = (int) $entity_guid;\r
-               $name = sanitise_string($name);\r
-               $value = sanitise_string($value);\r
-\r
-               $query = "SELECT * from {$CONFIG->dbprefix}metadata WHERE entity_guid = $entity_guid and name_id=" . add_metastring($name);\r
-               if ($value!="")\r
-                       $query .= " and value_id=" . add_metastring($value);\r
-               \r
-               if ($existing = get_data($query)) {\r
-                       foreach($existing as $ex)\r
-                               delete_metadata($ex->id);\r
-                       return true;\r
-               }\r
-               return false;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Create a new metadata object, or update an existing one.\r
-        *\r
-        * @param int $entity_guid\r
-        * @param string $name\r
-        * @param string $value\r
-        * @param string $value_type\r
-        * @param int $owner_guid\r
-        * @param int $access_id\r
-        * @param bool $allow_multiple\r
-        */\r
-       function create_metadata($entity_guid, $name, $value, $value_type, $owner_guid, $access_id = ACCESS_PRIVATE, $allow_multiple = false)\r
-       {\r
-               global $CONFIG;\r
-\r
-               $entity_guid = (int)$entity_guid;\r
-               //$name = sanitise_string(trim($name));\r
-               //$value = sanitise_string(trim($value));\r
-               $value_type = detect_extender_valuetype($value, sanitise_string(trim($value_type)));\r
-               $time = time();         \r
-               $owner_guid = (int)$owner_guid;\r
-               $allow_multiple = (boolean)$allow_multiple;\r
-               \r
-               if ($owner_guid==0) $owner_guid = get_loggedin_userid();\r
-               \r
-               $access_id = (int)$access_id;\r
-\r
-               $id = false;\r
-       \r
-               $existing = get_data_row("SELECT * from {$CONFIG->dbprefix}metadata WHERE entity_guid = $entity_guid and name_id=" . add_metastring($name) . " limit 1");\r
-               if (($existing) && (!$allow_multiple) && (isset($value))) \r
-               { \r
-                       $id = $existing->id;\r
-                       $result = update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id);\r
-                       \r
-                       if (!$result) return false;\r
-               }\r
-               else if (isset($value))\r
-               {\r
-                       // Support boolean types\r
-                       if (is_bool($value)) {\r
-                               if ($value)\r
-                                       $value = 1;\r
-                               else\r
-                                       $value = 0;\r
-                       }\r
-                       \r
-                       // Add the metastrings\r
-                       $value = add_metastring($value);\r
-                       if (!$value) return false;\r
-                       \r
-                       $name = add_metastring($name);\r
-                       if (!$name) return false;\r
-                       \r
-                       // If ok then add it\r
-                       $id = insert_data("INSERT into {$CONFIG->dbprefix}metadata (entity_guid, name_id, value_id, value_type, owner_guid, time_created, access_id) VALUES ($entity_guid, '$name','$value','$value_type', $owner_guid, $time, $access_id)");\r
-                       \r
-                       if ($id!==false) {\r
-                               $obj = get_metadata($id);\r
-                               if (trigger_elgg_event('create', 'metadata', $obj)) {\r
-                                       return true;\r
-                               } else {\r
-                                       delete_metadata($id);\r
-                               }\r
-                       }\r
-                       \r
-               } else if ($existing) {\r
-// TODO: Check... are you sure you meant to do this Ben? :)                    \r
-                       $id = $existing->id;\r
-                       delete_metadata($id);\r
-                       \r
-               }\r
-               \r
-               return $id;\r
-       }\r
-       \r
-       /**\r
-        * Update an item of metadata.\r
-        *\r
-        * @param int $id\r
-        * @param string $name\r
-        * @param string $value\r
-        * @param string $value_type\r
-        * @param int $owner_guid\r
-        * @param int $access_id\r
-        */\r
-       function update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id)\r
-       {\r
-               global $CONFIG;\r
-\r
-               $id = (int)$id;\r
-\r
-               if (!$md = get_metadata($id)) return false;     \r
-               if (!$md->canEdit()) return false;\r
-\r
-               // If memcached then we invalidate the cache for this entry\r
-               static $metabyname_memcache;\r
-               if ((!$metabyname_memcache) && (is_memcache_available()))\r
-                       $metabyname_memcache = new ElggMemcache('metabyname_memcache');\r
-               if ($metabyname_memcache) $metabyname_memcache->delete("{$md->entity_guid}:{$md->name_id}");\r
-               \r
-               //$name = sanitise_string(trim($name));\r
-               //$value = sanitise_string(trim($value));\r
-               $value_type = detect_extender_valuetype($value, sanitise_string(trim($value_type)));\r
-               \r
-               $owner_guid = (int)$owner_guid;\r
-               if ($owner_guid==0) $owner_guid = get_loggedin_userid();\r
-               \r
-               $access_id = (int)$access_id;\r
-               \r
-               $access = get_access_sql_suffix();\r
-               \r
-               // Support boolean types (as integers)\r
-               if (is_bool($value)) {\r
-                       if ($value)\r
-                               $value = 1;\r
-                       else\r
-                               $value = 0;\r
-               }\r
-               \r
-               // Add the metastring\r
-               $value = add_metastring($value);\r
-               if (!$value) return false;\r
-               \r
-               $name = add_metastring($name);\r
-               if (!$name) return false;\r
-\r
-                               // If ok then add it\r
-               $result = update_data("UPDATE {$CONFIG->dbprefix}metadata set value_id='$value', value_type='$value_type', access_id=$access_id, owner_guid=$owner_guid where id=$id and name_id='$name'");\r
-               if ($result!==false) {\r
-                       $obj = get_metadata($id);\r
-                       if (trigger_elgg_event('update', 'metadata', $obj)) {\r
-                               return true;\r
-                       } else {\r
-                               delete_metadata($id);\r
-                       }\r
-               }\r
-                       \r
-               return $result;\r
-       }\r
-       \r
-       /**\r
-        * This function creates metadata from an associative array of "key => value" pairs.\r
-        * \r
-        * @param int $entity_guid\r
-        * @param string $name_and_values\r
-        * @param string $value_type\r
-        * @param int $owner_guid\r
-        * @param int $access_id\r
-        * @param bool $allow_multiple\r
-        */\r
-       function create_metadata_from_array($entity_guid, array $name_and_values, $value_type, $owner_guid, $access_id = ACCESS_PRIVATE, $allow_multiple = false)\r
-       {\r
-               foreach ($name_and_values as $k => $v)\r
-                       if (!create_metadata($entity_guid, $k, $v, $value_type, $owner_guid, $access_id, $allow_multiple)) return false;\r
-               \r
-               return true;\r
-       }\r
-       \r
-       /**\r
-        * Delete an item of metadata, where the current user has access.\r
-        * \r
-        * @param $id int The item of metadata to delete.\r
-        */\r
-       function delete_metadata($id)\r
-       {\r
-               global $CONFIG;\r
-\r
-               $id = (int)$id;\r
-               $metadata = get_metadata($id);\r
-               \r
-               if ($metadata) {\r
-                       // Tidy up if memcache is enabled.\r
-                       static $metabyname_memcache;\r
-                       if ((!$metabyname_memcache) && (is_memcache_available()))\r
-                               $metabyname_memcache = new ElggMemcache('metabyname_memcache');\r
-                       if ($metabyname_memcache) $metabyname_memcache->delete("{$metadata->entity_guid}:{$metadata->name_id}");\r
-                       \r
-                       if (($metadata->canEdit()) && (trigger_elgg_event('delete', 'metadata', $metadata)))\r
-                               return delete_data("DELETE from {$CONFIG->dbprefix}metadata where id=$id");\r
-               }\r
-               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Return the metadata values that match your query.\r
-        * \r
-        * @param string $meta_name\r
-        * @return mixed either a value, an array of ElggMetadata or false.\r
-        */\r
-       function get_metadata_byname($entity_guid,  $meta_name)\r
-       {\r
-               global $CONFIG;\r
-       \r
-               $meta_name = get_metastring_id($meta_name);\r
-               \r
-               if (empty($meta_name)) return false;\r
-               \r
-               $entity_guid = (int)$entity_guid;\r
-               $access = get_access_sql_suffix("e");\r
-               $md_access = get_access_sql_suffix("m");\r
-               \r
-               // If memcache is available then cache this (cache only by name for now since this is the most common query)\r
-               $meta = null;\r
-               static $metabyname_memcache;\r
-               if ((!$metabyname_memcache) && (is_memcache_available()))\r
-                       $metabyname_memcache = new ElggMemcache('metabyname_memcache');\r
-               if ($metabyname_memcache) $meta = $metabyname_memcache->load("{$entity_guid}:{$meta_name}");\r
-               if ($meta) return $meta;        \r
-\r
-               $result = get_data("SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}metadata m JOIN {$CONFIG->dbprefix}entities e ON e.guid = m.entity_guid JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where m.entity_guid=$entity_guid and m.name_id='$meta_name' and $access and $md_access", "row_to_elggmetadata");\r
-               if (!$result) \r
-                       return false;\r
-                       \r
-               // Cache if memcache available\r
-               if ($metabyname_memcache)\r
-               { \r
-                       if (count($result) == 1) $r = $result[0]; else $r = $result;\r
-                       $metabyname_memcache->setDefaultExpiry(3600); // This is a bit of a hack - we shorten the expiry on object metadata so that it'll be gone in an hour. This means that deletions and more importantly updates will filter through eventually.\r
-                       $metabyname_memcache->save("{$entity_guid}:{$meta_name}", $r);\r
-                       \r
-               }\r
-               if (count($result) == 1)\r
-                       return $result[0];\r
-                       \r
-               return $result;\r
-       }\r
-       \r
-       /**\r
-        * Return all the metadata for a given GUID.\r
-        * \r
-        * @param int $entity_guid\r
-        */\r
-       function get_metadata_for_entity($entity_guid)\r
-       {\r
-               global $CONFIG;\r
-       \r
-               $entity_guid = (int)$entity_guid;\r
-               $access = get_access_sql_suffix("e");\r
-               $md_access = get_access_sql_suffix("m");\r
-               \r
-               return get_data("SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}metadata m JOIN {$CONFIG->dbprefix}entities e ON e.guid = m.entity_guid JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where m.entity_guid=$entity_guid and $access and $md_access", "row_to_elggmetadata");\r
-       }\r
-\r
-       /**\r
-        * Get the metadata where the entities they are referring to match a given criteria.\r
-        * \r
-        * @param mixed $meta_name \r
-        * @param mixed $meta_value\r
-        * @param string $entity_type The type of entity to look for, eg 'site' or 'object'\r
-        * @param string $entity_subtype The subtype of the entity.\r
-        * @param int $limit \r
-        * @param int $offset\r
-        * @param string $order_by Optional ordering.\r
-        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.\r
-        */\r
-       function find_metadata($meta_name = "", $meta_value = "", $entity_type = "", $entity_subtype = "", $limit = 10, $offset = 0, $order_by = "", $site_guid = 0)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $meta_n = get_metastring_id($meta_name);\r
-               $meta_v = get_metastring_id($meta_value);\r
-               \r
-               $entity_type = sanitise_string($entity_type);\r
-               $entity_subtype = get_subtype_id($entity_type, $entity_subtype);\r
-               $limit = (int)$limit;\r
-               $offset = (int)$offset;\r
-               if ($order_by == "") $order_by = "e.time_created desc";\r
-               $order_by = sanitise_string($order_by);\r
-               $site_guid = (int) $site_guid;\r
-               if ($site_guid == 0)\r
-                       $site_guid = $CONFIG->site_guid;\r
-                       \r
-                       \r
-               $where = array();\r
-               \r
-               if ($entity_type!="")\r
-                       $where[] = "e.type='$entity_type'";\r
-               if ($entity_subtype)\r
-                       $where[] = "e.subtype=$entity_subtype";\r
-               if ($meta_name!="") {\r
-                       if (!$meta_v) return false; // The value is set, but we didn't get a value... so something went wrong.\r
-                       $where[] = "m.name_id='$meta_n'";\r
-               }\r
-               if ($meta_value!="") {\r
-                       if (!$meta_v) return false; // The value is set, but we didn't get a value... so something went wrong.\r
-                       $where[] = "m.value_id='$meta_v'";\r
-               }\r
-               if ($site_guid > 0)\r
-                       $where[] = "e.site_guid = {$site_guid}";\r
-               \r
-               $query = "SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where";\r
-               foreach ($where as $w)\r
-                       $query .= " $w and ";\r
-               $query .= get_access_sql_suffix("e"); // Add access controls\r
-               $query .= ' and ' . get_access_sql_suffix("m"); // Add access controls\r
-               $query .= " order by $order_by limit $offset, $limit"; // Add order and limit\r
-\r
-               return get_data($query, "row_to_elggmetadata");\r
-       }\r
-       \r
-       /**\r
-        * Return a list of entities based on the given search criteria.\r
-        * \r
-        * @param mixed $meta_name \r
-        * @param mixed $meta_value\r
-        * @param string $entity_type The type of entity to look for, eg 'site' or 'object'\r
-        * @param string $entity_subtype The subtype of the entity.\r
-        * @param int $limit \r
-        * @param int $offset\r
-        * @param string $order_by Optional ordering.\r
-        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.\r
-        * @param true|false $count If set to true, returns the total number of entities rather than a list. (Default: false)\r
-        * \r
-        * @return int|array A list of entities, or a count if $count is set to true\r
-        */\r
-       function get_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $meta_n = get_metastring_id($meta_name);\r
-               $meta_v = get_metastring_id($meta_value);\r
-                       \r
-               $entity_type = sanitise_string($entity_type);\r
-               $entity_subtype = get_subtype_id($entity_type, $entity_subtype);\r
-               $limit = (int)$limit;\r
-               $offset = (int)$offset;\r
-               if ($order_by == "") \r
-                       $order_by = "e.time_created desc";\r
-               else\r
-                       $order_by = "e.time_created, {$order_by}";\r
-               $order_by = sanitise_string($order_by);\r
-               $site_guid = (int) $site_guid;\r
-               if ((is_array($owner_guid) && (count($owner_guid)))) {\r
-                       foreach($owner_guid as $key => $guid) {\r
-                               $owner_guid[$key] = (int) $guid;\r
-                       }\r
-               } else {\r
-                       $owner_guid = (int) $owner_guid;\r
-               }\r
-               if ($site_guid == 0)\r
-                       $site_guid = $CONFIG->site_guid;\r
-                       \r
-               //$access = get_access_list();\r
-                       \r
-               $where = array();\r
-               \r
-               if ($entity_type!=="")\r
-                       $where[] = "e.type='$entity_type'";\r
-               if ($entity_subtype)\r
-                       $where[] = "e.subtype=$entity_subtype";\r
-               if ($meta_name!=="")\r
-                       $where[] = "m.name_id='$meta_n'";\r
-               if ($meta_value!=="")\r
-                       $where[] = "m.value_id='$meta_v'";\r
-               if ($site_guid > 0)\r
-                       $where[] = "e.site_guid = {$site_guid}";\r
-               if (is_array($owner_guid)) {\r
-                       $where[] = "e.container_guid in (".implode(",",$owner_guid).")";\r
-               } else if ($owner_guid > 0)\r
-                       $where[] = "e.container_guid = {$owner_guid}";\r
-               \r
-               if (!$count) {\r
-                       $query = "SELECT distinct e.* "; \r
-               } else {\r
-                       $query = "SELECT count(distinct e.guid) as total ";\r
-               }\r
-                       \r
-               $query .= "from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid where";\r
-               foreach ($where as $w)\r
-                       $query .= " $w and ";\r
-               $query .= get_access_sql_suffix("e"); // Add access controls\r
-               $query .= ' and ' . get_access_sql_suffix("m"); // Add access controls\r
-               \r
-               if (!$count) {\r
-                       $query .= " order by $order_by limit $offset, $limit"; // Add order and limit\r
-                       return get_data($query, "entity_row_to_elggstar");\r
-               } else {\r
-                       if ($row = get_data_row($query))\r
-                               return $row->total;\r
-               }\r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Return a list of entities suitable for display based on the given search criteria.\r
-        * \r
-        * @see elgg_view_entity_list\r
-        * \r
-        * @param mixed $meta_name Metadata name to search on\r
-        * @param mixed $meta_value The value to match, optionally\r
-        * @param string $entity_type The type of entity to look for, eg 'site' or 'object'\r
-        * @param string $entity_subtype The subtype of the entity\r
-        * @param int $limit Number of entities to display per page\r
-        * @param true|false $fullview Whether or not to display the full view (default: true)\r
-        * @param true|false $viewtypetoggle Whether or not to allow users to toggle to the gallery view. Default: true\r
-        * @param true|false $pagination Display pagination? Default: true\r
-        * \r
-        * @return string A list of entities suitable for display\r
-        */\r
-       function list_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = true, $pagination = true) {\r
-               \r
-               $offset = (int) get_input('offset');\r
-               $limit = (int) $limit;\r
-               $count = get_entities_from_metadata($meta_name, $meta_value, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", 0, true);\r
-               $entities = get_entities_from_metadata($meta_name, $meta_value, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", 0, false);\r
-               \r
-               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);\r
-               \r
-       }\r
-\r
-       /**\r
-        * Returns a list of entities based on the given search criteria.\r
-        *\r
-        * @param array $meta_array Array of 'name' => 'value' pairs\r
-        * @param string $entity_type The type of entity to look for, eg 'site' or 'object'\r
-        * @param string $entity_subtype The subtype of the entity.\r
-        * @param int $limit \r
-        * @param int $offset\r
-        * @param string $order_by Optional ordering.\r
-        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.\r
-        * @param true|false $count If set to true, returns the total number of entities rather than a list. (Default: false)\r
-        * @param string $meta_array_operator Operator used for joining the metadata array together\r
-        * @return int|array List of ElggEntities, or the total number if count is set to false\r
-        */\r
-       function get_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false, $meta_array_operator = 'and')\r
-       {\r
-               global $CONFIG;\r
-               \r
-               if (!is_array($meta_array) || sizeof($meta_array) == 0) {\r
-                       return false;\r
-               }\r
-               \r
-               $where = array();\r
-               \r
-               $mindex = 1;\r
-               $join = "";\r
-               $metawhere = array();\r
-               $meta_array_operator = sanitise_string($meta_array_operator);\r
-               foreach($meta_array as $meta_name => $meta_value) {\r
-                       $meta_n = get_metastring_id($meta_name);\r
-                       $meta_v = get_metastring_id($meta_value);\r
-                       $join .= " JOIN {$CONFIG->dbprefix}metadata m{$mindex} on e.guid = m{$mindex}.entity_guid "; \r
-                       /*if ($meta_name!=="")\r
-                               $where[] = "m{$mindex}.name_id='$meta_n'";\r
-                       if ($meta_value!=="")\r
-                               $where[] = "m{$mindex}.value_id='$meta_v'";*/\r
-                       $metawhere[] = "(m{$mindex}.name_id='$meta_n' AND m{$mindex}.value_id='$meta_v')";\r
-                       $mindex++;\r
-               }\r
-               $where[] = "(".implode($meta_array_operator, $metawhere).")";\r
-                       \r
-               $entity_type = sanitise_string($entity_type);\r
-               $entity_subtype = get_subtype_id($entity_type, $entity_subtype);\r
-               $limit = (int)$limit;\r
-               $offset = (int)$offset;\r
-               if ($order_by == "") $order_by = "e.time_created desc";\r
-               $order_by = sanitise_string($order_by);\r
-               if ((is_array($owner_guid) && (count($owner_guid)))) {\r
-                       foreach($owner_guid as $key => $guid) {\r
-                               $owner_guid[$key] = (int) $guid;\r
-                       }\r
-               } else {\r
-                       $owner_guid = (int) $owner_guid;\r
-               }\r
-               \r
-               $site_guid = (int) $site_guid;\r
-               if ($site_guid == 0)\r
-                       $site_guid = $CONFIG->site_guid;\r
-                       \r
-               //$access = get_access_list();\r
-               \r
-               if ($entity_type!="")\r
-                       $where[] = "e.type = '{$entity_type}'";\r
-               if ($entity_subtype)\r
-                       $where[] = "e.subtype = {$entity_subtype}";\r
-               if ($site_guid > 0)\r
-                       $where[] = "e.site_guid = {$site_guid}";\r
-               if (is_array($owner_guid)) {\r
-                       $where[] = "e.container_guid in (".implode(",",$owner_guid).")";\r
-               } else if ($owner_guid > 0)\r
-                       $where[] = "e.container_guid = {$owner_guid}";\r
-               //if ($owner_guid > 0)\r
-               //      $where[] = "e.container_guid = {$owner_guid}";\r
-               \r
-               if ($count) {\r
-                       $query = "SELECT count(distinct e.guid) as total ";\r
-               } else {\r
-                       $query = "SELECT distinct e.* "; \r
-               }\r
-                       \r
-               $query .= " from {$CONFIG->dbprefix}entities e {$join} where";\r
-               foreach ($where as $w)\r
-                       $query .= " $w and ";\r
-               $query .= get_access_sql_suffix("e"); // Add access controls\r
-       \r
-               $mindex = 1;\r
-               foreach($meta_array as $meta_name => $meta_value) {\r
-                       $query .= ' and ' . get_access_sql_suffix("m{$mindex}"); // Add access controls\r
-                       $mindex++;\r
-               }\r
-               \r
-               if (!$count) {\r
-                       $query .= " order by $order_by limit $offset, $limit"; // Add order and limit\r
-                       return get_data($query, "entity_row_to_elggstar");\r
-               } else {\r
-                       if ($count = get_data_row($query)) {\r
-                               return $count->total;\r
-                       }\r
-               }\r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Returns a viewable list of entities based on the given search criteria.\r
-        *\r
-        * @see elgg_view_entity_list\r
-        * \r
-        * @param array $meta_array Array of 'name' => 'value' pairs\r
-        * @param string $entity_type The type of entity to look for, eg 'site' or 'object'\r
-        * @param string $entity_subtype The subtype of the entity.\r
-        * @param int $limit \r
-        * @param int $offset\r
-        * @param string $order_by Optional ordering.\r
-        * @param true|false $fullview Whether or not to display the full view (default: true)\r
-        * @param true|false $viewtypetoggle Whether or not to allow users to toggle to the gallery view. Default: true\r
-        * @param true|false $pagination Display pagination? Default: true\r
-        * @return string List of ElggEntities suitable for display\r
-        */\r
-       function list_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = true, $pagination = true) {\r
-               \r
-               $offset = (int) get_input('offset');\r
-               $limit = (int) $limit;\r
-               $count = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", $site_guid, true);\r
-               $entities = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", $site_guid, false);\r
-       \r
-               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Clear all the metadata for a given entity, assuming you have access to that metadata.\r
-        * \r
-        * @param int $guid\r
-        */\r
-       function clear_metadata($entity_guid)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $entity_guid = (int)$entity_guid;\r
-               if ($entity = get_entity($entity_guid)) {\r
-                       if ($entity->canEdit())\r
-                               return delete_data("DELETE from {$CONFIG->dbprefix}metadata where entity_guid={$entity_guid}");\r
-               }\r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Clear all annotations belonging to a given owner_guid\r
-        *\r
-        * @param int $owner_guid The owner\r
-        */\r
-       function clear_metadata_by_owner($owner_guid)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $owner_guid = (int)$owner_guid;\r
-               \r
-               $metas = get_data("SELECT id from {$CONFIG->dbprefix}metadata WHERE owner_guid=$owner_guid");\r
-               $deleted = 0;\r
-               \r
-               foreach ($metas as $id)\r
-               {\r
-                       if (delete_metadata($id->id)) // Is this the best way?\r
-                               $deleted++;\r
-               }\r
-               \r
-               return $deleted;\r
-       }\r
-       \r
-       /**\r
-        * Handler called by trigger_plugin_hook on the "export" event.\r
-        */\r
-       function export_metadata_plugin_hook($hook, $entity_type, $returnvalue, $params)\r
-       {\r
-               // Sanity check values\r
-               if ((!is_array($params)) && (!isset($params['guid'])))\r
-                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:GUIDNotForExport'));\r
-                       \r
-               if (!is_array($returnvalue))\r
-                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonArrayReturnValue'));\r
-               \r
-               $guid = (int)$params['guid'];\r
-               $name = $params['name'];        \r
-               \r
-               $result = get_metadata_for_entity($guid); \r
-                               \r
-               if ($result)\r
-               {\r
-                       foreach ($result as $r)\r
-                               $returnvalue[] = $r->export();\r
-               }\r
-               \r
-               return $returnvalue;\r
-       }\r
-       \r
-       /**\r
-        * Takes in a comma-separated string and returns an array of tags which have been trimmed and set to lower case\r
-        *\r
-        * @param string $string Comma-separated tag string\r
-        * @return array|false An array of strings, or false on failure\r
-        */\r
-       function string_to_tag_array($string) {\r
-               \r
-               if (is_string($string)) {\r
-                       $ar = explode(",",$string);\r
-                       $ar = array_map('trim', $ar); // trim blank spaces\r
-                       $ar = array_map('elgg_strtolower', $ar); // make lower case : [Marcus Povey 20090605 - Using mb wrapper function using UTF8 safe function where available]\r
-                       $ar = array_filter($ar, 'is_not_null'); // Remove null values\r
-                       return $ar;\r
-               }\r
-               return false;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Takes a metadata array (which has all kinds of properties) and turns it into a simple array of strings \r
-        *\r
-        * @param array $array Metadata array\r
-        * @return array Array of strings\r
-        */\r
-       function metadata_array_to_values($array) {\r
-               \r
-               $valuearray = array();\r
-               \r
-               if (is_array($array)) {\r
-                       foreach($array as $element) {\r
-                               $valuearray[] = $element->value;\r
-                       }\r
-               }\r
-               \r
-               return $valuearray;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Get the URL for this item of metadata, by default this links to the export handler in the current view.\r
-        *\r
-        * @param int $id\r
-        */\r
-       function get_metadata_url($id)\r
-       {\r
-               $id = (int)$id;\r
-               \r
-               if ($extender = get_metadata($id)) {\r
-                       return get_extender_url($extender);     \r
-               } \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Mark entities with a particular type and subtype as having access permissions\r
-        * that can be changed independently from their parent entity\r
-        *\r
-        * @param string $type The type - object, user, etc\r
-        * @param string $subtype The subtype; all subtypes by default\r
-        */\r
-       function register_metadata_as_independent($type, $subtype = '*') {\r
-               global $CONFIG;\r
-               if (!isset($CONFIG->independents)) $CONFIG->independents = array();\r
-               $CONFIG->independents[$type][$subtype] = true;\r
-       }\r
-       \r
-       /**\r
-        * Determines whether entities of a given type and subtype should not change\r
-        * their metadata in line with their parent entity \r
-        *\r
-        * @param string $type The type - object, user, etc\r
-        * @param string $subtype The entity subtype\r
-        * @return true|false\r
-        */\r
-       function is_metadata_independent($type, $subtype) {\r
-               global $CONFIG;\r
-               if (empty($CONFIG->independents)) return false;\r
-               if (!empty($CONFIG->independents[$type][$subtype])\r
-                       || !empty($CONFIG->independents[$type]['*'])) return true;\r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * When an entity is updated, resets the access ID on all of its child metadata\r
-        *\r
-        * @param string $event The name of the event\r
-        * @param string $object_type The type of object\r
-        * @param ElggEntity $object The entity itself\r
-        */\r
-       function metadata_update($event, $object_type, $object) {\r
-               if ($object instanceof ElggEntity) {\r
-                       if (!is_metadata_independent($object->getType(), $object->getSubtype())) {\r
-                               global $CONFIG;\r
-                               $access_id = (int) $object->access_id;\r
-                               $guid = (int) $object->getGUID();\r
-                               update_data("update {$CONFIG->dbprefix}metadata set access_id = {$access_id} where entity_guid = {$guid}");\r
-                       }\r
-               }       \r
-               return true;    \r
-       }\r
-       \r
-       /**\r
-        * Register a metadata url handler.\r
-        *\r
-        * @param string $function_name The function.\r
-        * @param string $extender_name The name, default 'all'.\r
-        */\r
-       function register_metadata_url_handler($function_name, $extender_name = "all") {\r
-               return register_extender_url_handler($function_name, 'metadata', $extender_name);\r
-       }\r
-               \r
-       /** Register the hook */\r
-       register_plugin_hook("export", "all", "export_metadata_plugin_hook", 2);\r
-       /** Call a function whenever an entity is updated **/\r
-       register_elgg_event_handler('update','all','metadata_update');\r
-       \r
-?>\r
+        * @link http://elgg.org/
+        */
+
+       /**
+        * ElggMetadata
+        * This class describes metadata that can be attached to ElggEntities.
+        * 
+        * @author Curverider Ltd <info@elgg.com>
+        * @package Elgg
+        * @subpackage Core
+        */
+       class ElggMetadata extends ElggExtender
+       {
+                       
+               /**
+                * Construct a new site object, optionally from a given id value or row.
+                *
+                * @param mixed $id
+                */
+               function __construct($id = null) 
+               {
+                       $this->attributes = array();
+                       
+                       if (!empty($id)) {
+                               
+                               if ($id instanceof stdClass)
+                                       $metadata = $id; // Create from db row
+                               else
+                                       $metadata = get_metadata($id);  
+                               
+                               if ($metadata) {
+                                       $objarray = (array) $metadata;
+                                       foreach($objarray as $key => $value) {
+                                               $this->attributes[$key] = $value;
+                                       }
+                                       $this->attributes['type'] = "metadata";
+                               }
+                       }
+               }
+               
+               /**
+                * Class member get overloading
+                *
+                * @param string $name
+                * @return mixed
+                */
+               function __get($name) {
+                       return $this->get($name);
+               }
+               
+               /**
+                * Class member set overloading
+                *
+                * @param string $name
+                * @param mixed $value
+                * @return mixed
+                */
+               function __set($name, $value) {
+                       return $this->set($name, $value);
+               }
+
+               /**
+                * Determines whether or not the user can edit this piece of metadata
+                *
+                * @return true|false Depending on permissions
+                */
+               function canEdit() {
+                       
+                       if ($entity = get_entity($this->get('entity_guid'))) {
+                               return $entity->canEditMetadata($this);
+                       }
+                       return false;
+                       
+               }
+               
+               /**
+                * Save matadata object
+                *
+                * @return int the metadata object id
+                */
+               function save()
+               {
+                       if ($this->id > 0)
+                               return update_metadata($this->id, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
+                       else
+                       { 
+                               $this->id = create_metadata($this->entity_guid, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
+                               if (!$this->id) throw new IOException(sprintf(elgg_new('IOException:UnableToSaveNew'), get_class()));
+                               return $this->id;
+                       }
+                       
+               }
+               
+               /**
+                * Delete a given metadata.
+                */
+               function delete() 
+               { 
+                       return delete_metadata($this->id); 
+               }
+               
+               /**
+                * Get a url for this item of metadata.
+                *
+                * @return string
+                */
+               public function getURL() { return get_metadata_url($this->id); }
+       
+               // SYSTEM LOG INTERFACE ////////////////////////////////////////////////////////////
+
+               /**
+                * For a given ID, return the object associated with it.
+                * This is used by the river functionality primarily.
+                * This is useful for checking access permissions etc on objects.
+                */
+               public function getObjectFromID($id) { return get_metadata($id); }
+       }
+
+       /**
+        * Convert a database row to a new ElggMetadata
+        *
+        * @param stdClass $row
+        * @return stdClass or ElggMetadata
+        */
+       function row_to_elggmetadata($row) 
+       {
+               if (!($row instanceof stdClass))
+                       return $row;
+                       
+               return new ElggMetadata($row);
+       }
+
+                       
+       /**
+        * Get a specific item of metadata.
+        * 
+        * @param $id int The item of metadata being retrieved.
+        */
+       function get_metadata($id)
+       {
+               global $CONFIG;
+
+               $id = (int)$id;
+               $access = get_access_sql_suffix("e");
+               $md_access = get_access_sql_suffix("m");
+
+               return row_to_elggmetadata(get_data_row("SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}metadata m JOIN {$CONFIG->dbprefix}entities e on e.guid = m.entity_guid JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where m.id=$id and $access and $md_access"));
+       }
+       
+       /**
+        * Removes metadata on an entity with a particular name, optionally with a given value.
+        *
+        * @param int $entity_guid The entity GUID
+        * @param string $name The name of the metadata
+        * @param string $value The optional value of the item (useful for removing a single item in a multiple set)
+        * @return true|false Depending on success
+        */
+       function remove_metadata($entity_guid, $name, $value = "") {
+               
+               global $CONFIG;
+               $entity_guid = (int) $entity_guid;
+               $name = sanitise_string($name);
+               $value = sanitise_string($value);
+
+               $query = "SELECT * from {$CONFIG->dbprefix}metadata WHERE entity_guid = $entity_guid and name_id=" . add_metastring($name);
+               if ($value!="")
+                       $query .= " and value_id=" . add_metastring($value);
+               
+               if ($existing = get_data($query)) {
+                       foreach($existing as $ex)
+                               delete_metadata($ex->id);
+                       return true;
+               }
+               return false;
+               
+       }
+       
+       /**
+        * Create a new metadata object, or update an existing one.
+        *
+        * @param int $entity_guid
+        * @param string $name
+        * @param string $value
+        * @param string $value_type
+        * @param int $owner_guid
+        * @param int $access_id
+        * @param bool $allow_multiple
+        */
+       function create_metadata($entity_guid, $name, $value, $value_type, $owner_guid, $access_id = ACCESS_PRIVATE, $allow_multiple = false)
+       {
+               global $CONFIG;
+
+               $entity_guid = (int)$entity_guid;
+               //$name = sanitise_string(trim($name));
+               //$value = sanitise_string(trim($value));
+               $value_type = detect_extender_valuetype($value, sanitise_string(trim($value_type)));
+               $time = time();         
+               $owner_guid = (int)$owner_guid;
+               $allow_multiple = (boolean)$allow_multiple;
+               
+               if ($owner_guid==0) $owner_guid = get_loggedin_userid();
+               
+               $access_id = (int)$access_id;
+
+               $id = false;
+       
+               $existing = get_data_row("SELECT * from {$CONFIG->dbprefix}metadata WHERE entity_guid = $entity_guid and name_id=" . add_metastring($name) . " limit 1");
+               if (($existing) && (!$allow_multiple) && (isset($value))) 
+               { 
+                       $id = $existing->id;
+                       $result = update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id);
+                       
+                       if (!$result) return false;
+               }
+               else if (isset($value))
+               {
+                       // Support boolean types
+                       if (is_bool($value)) {
+                               if ($value)
+                                       $value = 1;
+                               else
+                                       $value = 0;
+                       }
+                       
+                       // Add the metastrings
+                       $value = add_metastring($value);
+                       if (!$value) return false;
+                       
+                       $name = add_metastring($name);
+                       if (!$name) return false;
+                       
+                       // If ok then add it
+                       $id = insert_data("INSERT into {$CONFIG->dbprefix}metadata (entity_guid, name_id, value_id, value_type, owner_guid, time_created, access_id) VALUES ($entity_guid, '$name','$value','$value_type', $owner_guid, $time, $access_id)");
+                       
+                       if ($id!==false) {
+                               $obj = get_metadata($id);
+                               if (trigger_elgg_event('create', 'metadata', $obj)) {
+                                       return true;
+                               } else {
+                                       delete_metadata($id);
+                               }
+                       }
+                       
+               } else if ($existing) {
+// TODO: Check... are you sure you meant to do this Ben? :)                    
+                       $id = $existing->id;
+                       delete_metadata($id);
+                       
+               }
+               
+               return $id;
+       }
+       
+       /**
+        * Update an item of metadata.
+        *
+        * @param int $id
+        * @param string $name
+        * @param string $value
+        * @param string $value_type
+        * @param int $owner_guid
+        * @param int $access_id
+        */
+       function update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id)
+       {
+               global $CONFIG;
+
+               $id = (int)$id;
+
+               if (!$md = get_metadata($id)) return false;     
+               if (!$md->canEdit()) return false;
+
+               // If memcached then we invalidate the cache for this entry
+               static $metabyname_memcache;
+               if ((!$metabyname_memcache) && (is_memcache_available()))
+                       $metabyname_memcache = new ElggMemcache('metabyname_memcache');
+               if ($metabyname_memcache) $metabyname_memcache->delete("{$md->entity_guid}:{$md->name_id}");
+               
+               //$name = sanitise_string(trim($name));
+               //$value = sanitise_string(trim($value));
+               $value_type = detect_extender_valuetype($value, sanitise_string(trim($value_type)));
+               
+               $owner_guid = (int)$owner_guid;
+               if ($owner_guid==0) $owner_guid = get_loggedin_userid();
+               
+               $access_id = (int)$access_id;
+               
+               $access = get_access_sql_suffix();
+               
+               // Support boolean types (as integers)
+               if (is_bool($value)) {
+                       if ($value)
+                               $value = 1;
+                       else
+                               $value = 0;
+               }
+               
+               // Add the metastring
+               $value = add_metastring($value);
+               if (!$value) return false;
+               
+               $name = add_metastring($name);
+               if (!$name) return false;
+
+                               // If ok then add it
+               $result = update_data("UPDATE {$CONFIG->dbprefix}metadata set value_id='$value', value_type='$value_type', access_id=$access_id, owner_guid=$owner_guid where id=$id and name_id='$name'");
+               if ($result!==false) {
+                       $obj = get_metadata($id);
+                       if (trigger_elgg_event('update', 'metadata', $obj)) {
+                               return true;
+                       } else {
+                               delete_metadata($id);
+                       }
+               }
+                       
+               return $result;
+       }
+       
+       /**
+        * This function creates metadata from an associative array of "key => value" pairs.
+        * 
+        * @param int $entity_guid
+        * @param string $name_and_values
+        * @param string $value_type
+        * @param int $owner_guid
+        * @param int $access_id
+        * @param bool $allow_multiple
+        */
+       function create_metadata_from_array($entity_guid, array $name_and_values, $value_type, $owner_guid, $access_id = ACCESS_PRIVATE, $allow_multiple = false)
+       {
+               foreach ($name_and_values as $k => $v)
+                       if (!create_metadata($entity_guid, $k, $v, $value_type, $owner_guid, $access_id, $allow_multiple)) return false;
+               
+               return true;
+       }
+       
+       /**
+        * Delete an item of metadata, where the current user has access.
+        * 
+        * @param $id int The item of metadata to delete.
+        */
+       function delete_metadata($id)
+       {
+               global $CONFIG;
+
+               $id = (int)$id;
+               $metadata = get_metadata($id);
+               
+               if ($metadata) {
+                       // Tidy up if memcache is enabled.
+                       static $metabyname_memcache;
+                       if ((!$metabyname_memcache) && (is_memcache_available()))
+                               $metabyname_memcache = new ElggMemcache('metabyname_memcache');
+                       if ($metabyname_memcache) $metabyname_memcache->delete("{$metadata->entity_guid}:{$metadata->name_id}");
+                       
+                       if (($metadata->canEdit()) && (trigger_elgg_event('delete', 'metadata', $metadata)))
+                               return delete_data("DELETE from {$CONFIG->dbprefix}metadata where id=$id");
+               }
+               
+               return false;
+       }
+       
+       /**
+        * Return the metadata values that match your query.
+        * 
+        * @param string $meta_name
+        * @return mixed either a value, an array of ElggMetadata or false.
+        */
+       function get_metadata_byname($entity_guid,  $meta_name)
+       {
+               global $CONFIG;
+       
+               $meta_name = get_metastring_id($meta_name);
+               
+               if (empty($meta_name)) return false;
+               
+               $entity_guid = (int)$entity_guid;
+               $access = get_access_sql_suffix("e");
+               $md_access = get_access_sql_suffix("m");
+               
+               // If memcache is available then cache this (cache only by name for now since this is the most common query)
+               $meta = null;
+               static $metabyname_memcache;
+               if ((!$metabyname_memcache) && (is_memcache_available()))
+                       $metabyname_memcache = new ElggMemcache('metabyname_memcache');
+               if ($metabyname_memcache) $meta = $metabyname_memcache->load("{$entity_guid}:{$meta_name}");
+               if ($meta) return $meta;        
+
+               $result = get_data("SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}metadata m JOIN {$CONFIG->dbprefix}entities e ON e.guid = m.entity_guid JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where m.entity_guid=$entity_guid and m.name_id='$meta_name' and $access and $md_access", "row_to_elggmetadata");
+               if (!$result) 
+                       return false;
+                       
+               // Cache if memcache available
+               if ($metabyname_memcache)
+               { 
+                       if (count($result) == 1) $r = $result[0]; else $r = $result;
+                       $metabyname_memcache->setDefaultExpiry(3600); // This is a bit of a hack - we shorten the expiry on object metadata so that it'll be gone in an hour. This means that deletions and more importantly updates will filter through eventually.
+                       $metabyname_memcache->save("{$entity_guid}:{$meta_name}", $r);
+                       
+               }
+               if (count($result) == 1)
+                       return $result[0];
+                       
+               return $result;
+       }
+       
+       /**
+        * Return all the metadata for a given GUID.
+        * 
+        * @param int $entity_guid
+        */
+       function get_metadata_for_entity($entity_guid)
+       {
+               global $CONFIG;
+       
+               $entity_guid = (int)$entity_guid;
+               $access = get_access_sql_suffix("e");
+               $md_access = get_access_sql_suffix("m");
+               
+               return get_data("SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}metadata m JOIN {$CONFIG->dbprefix}entities e ON e.guid = m.entity_guid JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where m.entity_guid=$entity_guid and $access and $md_access", "row_to_elggmetadata");
+       }
+
+       /**
+        * Get the metadata where the entities they are referring to match a given criteria.
+        * 
+        * @param mixed $meta_name 
+        * @param mixed $meta_value
+        * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
+        * @param string $entity_subtype The subtype of the entity.
+        * @param int $limit 
+        * @param int $offset
+        * @param string $order_by Optional ordering.
+        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
+        */
+       function find_metadata($meta_name = "", $meta_value = "", $entity_type = "", $entity_subtype = "", $limit = 10, $offset = 0, $order_by = "", $site_guid = 0)
+       {
+               global $CONFIG;
+               
+               $meta_n = get_metastring_id($meta_name);
+               $meta_v = get_metastring_id($meta_value);
+               
+               $entity_type = sanitise_string($entity_type);
+               $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
+               $limit = (int)$limit;
+               $offset = (int)$offset;
+               if ($order_by == "") $order_by = "e.time_created desc";
+               $order_by = sanitise_string($order_by);
+               $site_guid = (int) $site_guid;
+               if ($site_guid == 0)
+                       $site_guid = $CONFIG->site_guid;
+                       
+                       
+               $where = array();
+               
+               if ($entity_type!="")
+                       $where[] = "e.type='$entity_type'";
+               if ($entity_subtype)
+                       $where[] = "e.subtype=$entity_subtype";
+               if ($meta_name!="") {
+                       if (!$meta_v) return false; // The value is set, but we didn't get a value... so something went wrong.
+                       $where[] = "m.name_id='$meta_n'";
+               }
+               if ($meta_value!="") {
+                       if (!$meta_v) return false; // The value is set, but we didn't get a value... so something went wrong.
+                       $where[] = "m.value_id='$meta_v'";
+               }
+               if ($site_guid > 0)
+                       $where[] = "e.site_guid = {$site_guid}";
+               
+               $query = "SELECT m.*, n.string as name, v.string as value from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid JOIN {$CONFIG->dbprefix}metastrings v on m.value_id = v.id JOIN {$CONFIG->dbprefix}metastrings n on m.name_id = n.id where";
+               foreach ($where as $w)
+                       $query .= " $w and ";
+               $query .= get_access_sql_suffix("e"); // Add access controls
+               $query .= ' and ' . get_access_sql_suffix("m"); // Add access controls
+               $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
+
+               return get_data($query, "row_to_elggmetadata");
+       }
+       
+       /**
+        * Return a list of entities based on the given search criteria.
+        * 
+        * @param mixed $meta_name 
+        * @param mixed $meta_value
+        * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
+        * @param string $entity_subtype The subtype of the entity.
+        * @param int $limit 
+        * @param int $offset
+        * @param string $order_by Optional ordering.
+        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
+        * @param true|false $count If set to true, returns the total number of entities rather than a list. (Default: false)
+        * 
+        * @return int|array A list of entities, or a count if $count is set to true
+        */
+       function get_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false)
+       {
+               global $CONFIG;
+               
+               $meta_n = get_metastring_id($meta_name);
+               $meta_v = get_metastring_id($meta_value);
+                       
+               $entity_type = sanitise_string($entity_type);
+               $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
+               $limit = (int)$limit;
+               $offset = (int)$offset;
+               if ($order_by == "") 
+                       $order_by = "e.time_created desc";
+               else
+                       $order_by = "e.time_created, {$order_by}";
+               $order_by = sanitise_string($order_by);
+               $site_guid = (int) $site_guid;
+               if ((is_array($owner_guid) && (count($owner_guid)))) {
+                       foreach($owner_guid as $key => $guid) {
+                               $owner_guid[$key] = (int) $guid;
+                       }
+               } else {
+                       $owner_guid = (int) $owner_guid;
+               }
+               if ($site_guid == 0)
+                       $site_guid = $CONFIG->site_guid;
+                       
+               //$access = get_access_list();
+                       
+               $where = array();
+               
+               if ($entity_type!=="")
+                       $where[] = "e.type='$entity_type'";
+               if ($entity_subtype)
+                       $where[] = "e.subtype=$entity_subtype";
+               if ($meta_name!=="")
+                       $where[] = "m.name_id='$meta_n'";
+               if ($meta_value!=="")
+                       $where[] = "m.value_id='$meta_v'";
+               if ($site_guid > 0)
+                       $where[] = "e.site_guid = {$site_guid}";
+               if (is_array($owner_guid)) {
+                       $where[] = "e.container_guid in (".implode(",",$owner_guid).")";
+               } else if ($owner_guid > 0)
+                       $where[] = "e.container_guid = {$owner_guid}";
+               
+               if (!$count) {
+                       $query = "SELECT distinct e.* "; 
+               } else {
+                       $query = "SELECT count(distinct e.guid) as total ";
+               }
+                       
+               $query .= "from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid where";
+               foreach ($where as $w)
+                       $query .= " $w and ";
+               $query .= get_access_sql_suffix("e"); // Add access controls
+               $query .= ' and ' . get_access_sql_suffix("m"); // Add access controls
+               
+               if (!$count) {
+                       $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
+                       return get_data($query, "entity_row_to_elggstar");
+               } else {
+                       if ($row = get_data_row($query))
+                               return $row->total;
+               }
+               return false;
+       }
+       
+       /**
+        * Return a list of entities suitable for display based on the given search criteria.
+        * 
+        * @see elgg_view_entity_list
+        * 
+        * @param mixed $meta_name Metadata name to search on
+        * @param mixed $meta_value The value to match, optionally
+        * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
+        * @param string $entity_subtype The subtype of the entity
+        * @param int $limit Number of entities to display per page
+        * @param true|false $fullview Whether or not to display the full view (default: true)
+        * @param true|false $viewtypetoggle Whether or not to allow users to toggle to the gallery view. Default: true
+        * @param true|false $pagination Display pagination? Default: true
+        * 
+        * @return string A list of entities suitable for display
+        */
+       function list_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = true, $pagination = true) {
+               
+               $offset = (int) get_input('offset');
+               $limit = (int) $limit;
+               $count = get_entities_from_metadata($meta_name, $meta_value, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", 0, true);
+               $entities = get_entities_from_metadata($meta_name, $meta_value, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", 0, false);
+               
+               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);
+               
+       }
+
+       /**
+        * Returns a list of entities based on the given search criteria.
+        *
+        * @param array $meta_array Array of 'name' => 'value' pairs
+        * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
+        * @param string $entity_subtype The subtype of the entity.
+        * @param int $limit 
+        * @param int $offset
+        * @param string $order_by Optional ordering.
+        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
+        * @param true|false $count If set to true, returns the total number of entities rather than a list. (Default: false)
+        * @param string $meta_array_operator Operator used for joining the metadata array together
+        * @return int|array List of ElggEntities, or the total number if count is set to false
+        */
+       function get_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false, $meta_array_operator = 'and')
+       {
+               global $CONFIG;
+               
+               if (!is_array($meta_array) || sizeof($meta_array) == 0) {
+                       return false;
+               }
+               
+               $where = array();
+               
+               $mindex = 1;
+               $join = "";
+               $metawhere = array();
+               $meta_array_operator = sanitise_string($meta_array_operator);
+               foreach($meta_array as $meta_name => $meta_value) {
+                       $meta_n = get_metastring_id($meta_name);
+                       $meta_v = get_metastring_id($meta_value);
+                       $join .= " JOIN {$CONFIG->dbprefix}metadata m{$mindex} on e.guid = m{$mindex}.entity_guid "; 
+                       /*if ($meta_name!=="")
+                               $where[] = "m{$mindex}.name_id='$meta_n'";
+                       if ($meta_value!=="")
+                               $where[] = "m{$mindex}.value_id='$meta_v'";*/
+                       $metawhere[] = "(m{$mindex}.name_id='$meta_n' AND m{$mindex}.value_id='$meta_v')";
+                       $mindex++;
+               }
+               $where[] = "(".implode($meta_array_operator, $metawhere).")";
+                       
+               $entity_type = sanitise_string($entity_type);
+               $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
+               $limit = (int)$limit;
+               $offset = (int)$offset;
+               if ($order_by == "") $order_by = "e.time_created desc";
+               $order_by = sanitise_string($order_by);
+               if ((is_array($owner_guid) && (count($owner_guid)))) {
+                       foreach($owner_guid as $key => $guid) {
+                               $owner_guid[$key] = (int) $guid;
+                       }
+               } else {
+                       $owner_guid = (int) $owner_guid;
+               }
+               
+               $site_guid = (int) $site_guid;
+               if ($site_guid == 0)
+                       $site_guid = $CONFIG->site_guid;
+                       
+               //$access = get_access_list();
+               
+               if ($entity_type!="")
+                       $where[] = "e.type = '{$entity_type}'";
+               if ($entity_subtype)
+                       $where[] = "e.subtype = {$entity_subtype}";
+               if ($site_guid > 0)
+                       $where[] = "e.site_guid = {$site_guid}";
+               if (is_array($owner_guid)) {
+                       $where[] = "e.container_guid in (".implode(",",$owner_guid).")";
+               } else if ($owner_guid > 0)
+                       $where[] = "e.container_guid = {$owner_guid}";
+               //if ($owner_guid > 0)
+               //      $where[] = "e.container_guid = {$owner_guid}";
+               
+               if ($count) {
+                       $query = "SELECT count(distinct e.guid) as total ";
+               } else {
+                       $query = "SELECT distinct e.* "; 
+               }
+                       
+               $query .= " from {$CONFIG->dbprefix}entities e {$join} where";
+               foreach ($where as $w)
+                       $query .= " $w and ";
+               $query .= get_access_sql_suffix("e"); // Add access controls
+       
+               $mindex = 1;
+               foreach($meta_array as $meta_name => $meta_value) {
+                       $query .= ' and ' . get_access_sql_suffix("m{$mindex}"); // Add access controls
+                       $mindex++;
+               }
+               
+               if (!$count) {
+                       $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
+                       return get_data($query, "entity_row_to_elggstar");
+               } else {
+                       if ($count = get_data_row($query)) {
+                               return $count->total;
+                       }
+               }
+               return false;
+       }
+       
+       /**
+        * Returns a viewable list of entities based on the given search criteria.
+        *
+        * @see elgg_view_entity_list
+        * 
+        * @param array $meta_array Array of 'name' => 'value' pairs
+        * @param string $entity_type The type of entity to look for, eg 'site' or 'object'
+        * @param string $entity_subtype The subtype of the entity.
+        * @param int $limit 
+        * @param int $offset
+        * @param string $order_by Optional ordering.
+        * @param true|false $fullview Whether or not to display the full view (default: true)
+        * @param true|false $viewtypetoggle Whether or not to allow users to toggle to the gallery view. Default: true
+        * @param true|false $pagination Display pagination? Default: true
+        * @return string List of ElggEntities suitable for display
+        */
+       function list_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = true, $pagination = true) {
+               
+               $offset = (int) get_input('offset');
+               $limit = (int) $limit;
+               $count = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", $site_guid, true);
+               $entities = get_entities_from_metadata_multi($meta_array, $entity_type, $entity_subtype, $owner_guid, $limit, $offset, "", $site_guid, false);
+       
+               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);
+               
+       }
+       
+       /**
+        * Clear all the metadata for a given entity, assuming you have access to that metadata.
+        * 
+        * @param int $guid
+        */
+       function clear_metadata($entity_guid)
+       {
+               global $CONFIG;
+               
+               $entity_guid = (int)$entity_guid;
+               if ($entity = get_entity($entity_guid)) {
+                       if ($entity->canEdit())
+                               return delete_data("DELETE from {$CONFIG->dbprefix}metadata where entity_guid={$entity_guid}");
+               }
+               return false;
+       }
+       
+       /**
+        * Clear all annotations belonging to a given owner_guid
+        *
+        * @param int $owner_guid The owner
+        */
+       function clear_metadata_by_owner($owner_guid)
+       {
+               global $CONFIG;
+               
+               $owner_guid = (int)$owner_guid;
+               
+               $metas = get_data("SELECT id from {$CONFIG->dbprefix}metadata WHERE owner_guid=$owner_guid");
+               $deleted = 0;
+               
+               foreach ($metas as $id)
+               {
+                       if (delete_metadata($id->id)) // Is this the best way?
+                               $deleted++;
+               }
+               
+               return $deleted;
+       }
+       
+       /**
+        * Handler called by trigger_plugin_hook on the "export" event.
+        */
+       function export_metadata_plugin_hook($hook, $entity_type, $returnvalue, $params)
+       {
+               // Sanity check values
+               if ((!is_array($params)) && (!isset($params['guid'])))
+                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:GUIDNotForExport'));
+                       
+               if (!is_array($returnvalue))
+                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonArrayReturnValue'));
+               
+               $guid = (int)$params['guid'];
+               $name = $params['name'];        
+               
+               $result = get_metadata_for_entity($guid); 
+                               
+               if ($result)
+               {
+                       foreach ($result as $r)
+                               $returnvalue[] = $r->export();
+               }
+               
+               return $returnvalue;
+       }
+       
+       /**
+        * Takes in a comma-separated string and returns an array of tags which have been trimmed and set to lower case
+        *
+        * @param string $string Comma-separated tag string
+        * @return array|false An array of strings, or false on failure
+        */
+       function string_to_tag_array($string) {
+               
+               if (is_string($string)) {
+                       $ar = explode(",",$string);
+                       $ar = array_map('trim', $ar); // trim blank spaces
+                       $ar = array_map('elgg_strtolower', $ar); // make lower case : [Marcus Povey 20090605 - Using mb wrapper function using UTF8 safe function where available]
+                       $ar = array_filter($ar, 'is_not_null'); // Remove null values
+                       return $ar;
+               }
+               return false;
+               
+       }
+       
+       /**
+        * Takes a metadata array (which has all kinds of properties) and turns it into a simple array of strings 
+        *
+        * @param array $array Metadata array
+        * @return array Array of strings
+        */
+       function metadata_array_to_values($array) {
+               
+               $valuearray = array();
+               
+               if (is_array($array)) {
+                       foreach($array as $element) {
+                               $valuearray[] = $element->value;
+                       }
+               }
+               
+               return $valuearray;
+               
+       }
+       
+       /**
+        * Get the URL for this item of metadata, by default this links to the export handler in the current view.
+        *
+        * @param int $id
+        */
+       function get_metadata_url($id)
+       {
+               $id = (int)$id;
+               
+               if ($extender = get_metadata($id)) {
+                       return get_extender_url($extender);     
+               } 
+               return false;
+       }
+       
+       /**
+        * Mark entities with a particular type and subtype as having access permissions
+        * that can be changed independently from their parent entity
+        *
+        * @param string $type The type - object, user, etc
+        * @param string $subtype The subtype; all subtypes by default
+        */
+       function register_metadata_as_independent($type, $subtype = '*') {
+               global $CONFIG;
+               if (!isset($CONFIG->independents)) $CONFIG->independents = array();
+               $CONFIG->independents[$type][$subtype] = true;
+       }
+       
+       /**
+        * Determines whether entities of a given type and subtype should not change
+        * their metadata in line with their parent entity 
+        *
+        * @param string $type The type - object, user, etc
+        * @param string $subtype The entity subtype
+        * @return true|false
+        */
+       function is_metadata_independent($type, $subtype) {
+               global $CONFIG;
+               if (empty($CONFIG->independents)) return false;
+               if (!empty($CONFIG->independents[$type][$subtype])
+                       || !empty($CONFIG->independents[$type]['*'])) return true;
+               return false;
+       }
+       
+       /**
+        * When an entity is updated, resets the access ID on all of its child metadata
+        *
+        * @param string $event The name of the event
+        * @param string $object_type The type of object
+        * @param ElggEntity $object The entity itself
+        */
+       function metadata_update($event, $object_type, $object) {
+               if ($object instanceof ElggEntity) {
+                       if (!is_metadata_independent($object->getType(), $object->getSubtype())) {
+                               global $CONFIG;
+                               $access_id = (int) $object->access_id;
+                               $guid = (int) $object->getGUID();
+                               update_data("update {$CONFIG->dbprefix}metadata set access_id = {$access_id} where entity_guid = {$guid}");
+                       }
+               }       
+               return true;    
+       }
+       
+       /**
+        * Register a metadata url handler.
+        *
+        * @param string $function_name The function.
+        * @param string $extender_name The name, default 'all'.
+        */
+       function register_metadata_url_handler($function_name, $extender_name = "all") {
+               return register_extender_url_handler($function_name, 'metadata', $extender_name);
+       }
+               
+       /** Register the hook */
+       register_plugin_hook("export", "all", "export_metadata_plugin_hook", 2);
+       /** Call a function whenever an entity is updated **/
+       register_elgg_event_handler('update','all','metadata_update');
+       
+?>
index 94529e16f993a597132464a5d07dafa914b82818..31981efab8b7add07d07058b8bf6720f6bcb51c2 100644 (file)
                        $METASTRINGS_DEADNAME_CACHE[$string] = $string;
                        
                return false;
-       }\r
-       \r
-       /**\r
-        * When given an ID, returns the corresponding metastring\r
-        *\r
-        * @param int $id Metastring ID\r
-        * @return string Metastring\r
-        */\r
-       function get_metastring($id) {\r
-               \r
-               global $CONFIG, $METASTRINGS_CACHE;\r
-               \r
+       }
+       
+       /**
+        * When given an ID, returns the corresponding metastring
+        *
+        * @param int $id Metastring ID
+        * @return string Metastring
+        */
+       function get_metastring($id) {
+               
+               global $CONFIG, $METASTRINGS_CACHE;
+               
                $id = (int) $id;
                
                if (isset($METASTRINGS_CACHE[$id])) {
                                error_log("** Returning string for id:$id from cache.");
                        
                        return $METASTRINGS_CACHE[$id];
-               }\r
-               \r
-               $row = get_data_row("SELECT * from {$CONFIG->dbprefix}metastrings where id='$id' limit 1");\r
+               }
+               
+               $row = get_data_row("SELECT * from {$CONFIG->dbprefix}metastrings where id='$id' limit 1");
                if ($row) {
                        $METASTRINGS_CACHE[$id] = $row->string; // Cache it
                        
                        if ($CONFIG->debug)
                                error_log("** Cacheing string '{$row->string}'");
-                       \r
+                       
                        return $row->string;
-               }\r
-                       \r
-               return false;\r
-               \r
+               }
+                       
+               return false;
+               
        }
 
        /**
index f1336d1b85d46f3389696a3526a4665840dc604e..6b91a67cf02a64cd571e2c114cef0a1b38ba7aad 100644 (file)
-<?php\r
-       /**\r
-        * Notifications\r
-        * This file contains classes and functions which allow plugins to register and send notifications.\r
-        * \r
-        * There are notification methods which are provided out of the box (see notification_init() ). Each method\r
-        * is identified by a string, e.g. "email".\r
-        * \r
-        * To register an event use register_notification_handler() and pass the method name and a handler function.\r
-        * \r
-        * To send a notification call notify() passing it the method you wish to use combined with a number of method \r
-        * specific addressing parameters.\r
-        * \r
-        * Catch NotificationException to trap errors.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage API\r
+<?php
+       /**
+        * Notifications
+        * This file contains classes and functions which allow plugins to register and send notifications.
+        * 
+        * There are notification methods which are provided out of the box (see notification_init() ). Each method
+        * is identified by a string, e.g. "email".
+        * 
+        * To register an event use register_notification_handler() and pass the method name and a handler function.
+        * 
+        * To send a notification call notify() passing it the method you wish to use combined with a number of method 
+        * specific addressing parameters.
+        * 
+        * Catch NotificationException to trap errors.
+        * 
+        * @package Elgg
+        * @subpackage API
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /** Notification handlers */\r
-       $NOTIFICATION_HANDLERS = array();\r
-       \r
-       /**\r
-        * This function registers a handler for a given notification type (eg "email")\r
-        *\r
-        * @param string $method The method\r
-        * @param string $handler The handler function, in the format "handler(ElggEntity $from, ElggUser $to, $subject, $message, array $params = NULL)". This function should return false on failure, and true/a tracking message ID on success.\r
-        * @param array $params A associated array of other parameters for this handler defining some properties eg. supported message length or rich text support.\r
-        */\r
-       function register_notification_handler($method, $handler, $params = NULL)\r
-       {\r
-               global $NOTIFICATION_HANDLERS;\r
-               \r
-               if (is_callable($handler)) \r
-               {\r
-                       $NOTIFICATION_HANDLERS[$method] = new stdClass;\r
-\r
-                       $NOTIFICATION_HANDLERS[$method]->handler = $handler;\r
-                       if ($params)\r
-                       {\r
-                               foreach ($params as $k => $v)\r
-                                       $NOTIFICATION_HANDLERS[$method]->$k = $v;\r
-                       }\r
-                       \r
-                       return true;\r
-               }\r
-               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Notify a user via their preferences.\r
-        *\r
-        * @param mixed $to Either a guid or an array of guid's to notify.\r
-        * @param int $from GUID of the sender, which may be a user, site or object.\r
-        * @param string $subject Message subject.\r
-        * @param string $message Message body.\r
-        * @param array $params Misc additional parameters specific to various methods.\r
-        * @param mixed $methods_override A string, or an array of strings specifying the delivery methods to use - or leave blank\r
-        *                              for delivery using the user's chosen delivery methods.\r
-        * @return array Compound array of each delivery user/delivery method's success or failure.\r
-        * @throws NotificationException\r
-        */\r
-       function notify_user($to, $from, $subject, $message, array $params = NULL, $methods_override = "")\r
-       {\r
-               global $NOTIFICATION_HANDLERS, $CONFIG;\r
-       \r
-               // Sanitise\r
-               if (!is_array($to))\r
-                       $to = array((int)$to);\r
-               $from = (int)$from;\r
-               //$subject = sanitise_string($subject);\r
-                       \r
-               // Get notification methods\r
-               if (($methods_override) && (!is_array($methods_override)))\r
-                       $methods_override = array($methods_override);\r
-                       \r
-               $result = array();\r
-               \r
-               foreach ($to as $guid)\r
-               {\r
-                       // Results for a user are...\r
-                       $result[$guid] = array();\r
-                       \r
-                       if ($guid) { // Is the guid > 0? \r
-                               // Are we overriding delivery?\r
-                               $methods = $methods_override;\r
-                               if (!$methods)\r
-                               {\r
-                                       $tmp = (array)get_user_notification_settings($guid);\r
-                                       $methods = array(); \r
-                                       foreach($tmp as $k => $v)\r
-                                               if ($v) $methods[] = $k; // Add method if method is turned on for user!\r
-                               }\r
-                               \r
-                               if ($methods)\r
-                               {\r
-                                       // Deliver\r
-                                       foreach ($methods as $method)\r
-                                       {\r
-                                               // Extract method details from list\r
-                                               $details = $NOTIFICATION_HANDLERS[$method];\r
-                                               $handler = $details->handler;\r
-                                       \r
-                                               if ((!$NOTIFICATION_HANDLERS[$method]) || (!$handler))\r
-                                                       error_log(sprintf(elgg_echo('NotificationException:NoHandlerFound'), $method));\r
-               \r
-                                               if ($CONFIG->debug)\r
-                                                       error_log("Sending message to $guid using $method");                                    \r
-                                                       \r
-                                               // Trigger handler and retrieve result.\r
-                                               try {\r
-                                                       $result[$guid][$method] = $handler(\r
-                                                               $from ? get_entity($from) : NULL,       // From entity\r
-                                                               get_entity($guid),                                      // To entity\r
-                                                               $subject,                                                       // The subject\r
-                                                               $message,                       // Message\r
-                                                               $params                                                         // Params\r
-                                                       );\r
-                                               } catch (Exception $e) {\r
-                                                       error_log($e->getMessage());\r
-                                               }\r
-                                               \r
-                                       }\r
-                               }\r
-                       }               \r
-               }\r
-       \r
-               return $result;\r
-       }\r
-       \r
-       /**\r
-        * Get the notification settings for a given user.\r
-        *\r
-        * @param int $user_guid The user id\r
-        * @return stdClass \r
-        */\r
-       function get_user_notification_settings($user_guid = 0)\r
-       {\r
-               $user_guid = (int)$user_guid;\r
-               \r
-               if ($user_guid == 0) $user_guid = get_loggedin_userid();\r
-               \r
-               $all_metadata = get_metadata_for_entity($user_guid);\r
-               if ($all_metadata)\r
-               {\r
-                       $prefix = "notification:method:";\r
-                       $return = new stdClass;\r
-                       \r
-                       foreach ($all_metadata as $meta)\r
-                       {\r
-                               $name = substr($meta->name, strlen($prefix));\r
-                               $value = $meta->value;\r
-                       \r
-                               if (strpos($meta->name, $prefix) === 0)\r
-                                       $return->$name = $value;\r
-                       }\r
-\r
-                       return $return;                 \r
-               }\r
-               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Set a user notification pref.\r
-        *\r
-        * @param int $user_guid The user id.\r
-        * @param string $method The delivery method (eg. email)\r
-        * @param bool $value On(true) or off(false).\r
-        * @return bool\r
-        */\r
-       function set_user_notification_setting($user_guid, $method, $value)\r
-       {\r
-               $user_guid = (int)$user_guid;\r
-               $method = sanitise_string($method);\r
-                       \r
-               $user = get_entity($user_guid);\r
-               if (!$user) $user = get_loggedin_user();\r
-               \r
-               if (($user) && ($user instanceof ElggUser))\r
-               {                       \r
-                       $prefix = "notification:method:$method";\r
-                       $user->$prefix = $value;\r
-                       $user->save();\r
-               \r
-                       return true;\r
-               }\r
-                       \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Notification exception.\r
-        * @author Curverider Ltd\r
-        */\r
-       class NotificationException extends Exception {}\r
-\r
-       \r
-       /**\r
-        * Send a notification via email.\r
-        *\r
-        * @param ElggEntity $from The from user/site/object\r
-        * @param ElggUser $to To which user?\r
-        * @param string $subject The subject of the message.\r
-        * @param string $message The message body\r
-        * @param array $params Optional parameters (none taken in this instance)\r
-        * @return bool\r
-        */\r
-       function email_notify_handler(ElggEntity $from, ElggUser $to, $subject, $message, array $params = NULL)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               if (!$from)\r
-                       throw new NotificationException(sprintf(elgg_echo('NotificationException:MissingParameter'), 'from'));\r
-                        \r
-               if (!$to)\r
-                       throw new NotificationException(sprintf(elgg_echo('NotificationException:MissingParameter'), 'to'));\r
-               \r
-               if ($to->email=="")\r
-                       throw new NotificationException(sprintf(elgg_echo('NotificationException:NoEmailAddress'), $to->guid));                 \r
-\r
-               // Sanitise subject\r
-               $subject = preg_replace("/(\r\n|\r|\n)/", " ", $subject); // Strip line endings\r
-                       \r
-               // To \r
-               $to = $to->email;\r
-               \r
-               // From\r
-               $site = get_entity($CONFIG->site_guid);\r
-               if ((isset($from->email)) && (!($from instanceof ElggUser))) // If there's an email address, use it - but only if its not from a user.\r
-                       $from = $from->email;\r
-               else if (($site) && (isset($site->email))) // Has the current site got a from email address?\r
-                       $from = $site->email;\r
-               else if (isset($from->url)) // If we have a url then try and use that.\r
-               {\r
-                       $breakdown = parse_url($from->url);\r
-                       $from = 'noreply@' . $breakdown['host']; // Handle anything with a url\r
-               }\r
-               else // If all else fails, use the domain of the site.\r
-                       $from = 'noreply@' . get_site_domain($CONFIG->site_guid); \r
-       \r
-               if (is_callable('mb_internal_encoding')) {\r
-                       mb_internal_encoding('UTF-8');\r
-               }\r
-               $site = get_entity($CONFIG->site_guid);\r
-               $sitename = $site->name;\r
-               if (is_callable('mb_encode_mimeheader')) {\r
-                       $sitename = mb_encode_mimeheader($site->name,"UTF-8", "B");\r
-               }\r
-               \r
-               $header_eol = "\r\n";\r
-               if ( \r
-                       (isset($CONFIG->broken_mta)) &&\r
-                       ($CONFIG->broken_mta)\r
-               )\r
-                       $header_eol = "\n"; // Allow non-RFC 2822 mail headers to support some broken MTAs\r
+        * @link http://elgg.org/
+        */
+
+       /** Notification handlers */
+       $NOTIFICATION_HANDLERS = array();
+       
+       /**
+        * This function registers a handler for a given notification type (eg "email")
+        *
+        * @param string $method The method
+        * @param string $handler The handler function, in the format "handler(ElggEntity $from, ElggUser $to, $subject, $message, array $params = NULL)". This function should return false on failure, and true/a tracking message ID on success.
+        * @param array $params A associated array of other parameters for this handler defining some properties eg. supported message length or rich text support.
+        */
+       function register_notification_handler($method, $handler, $params = NULL)
+       {
+               global $NOTIFICATION_HANDLERS;
+               
+               if (is_callable($handler)) 
+               {
+                       $NOTIFICATION_HANDLERS[$method] = new stdClass;
+
+                       $NOTIFICATION_HANDLERS[$method]->handler = $handler;
+                       if ($params)
+                       {
+                               foreach ($params as $k => $v)
+                                       $NOTIFICATION_HANDLERS[$method]->$k = $v;
+                       }
+                       
+                       return true;
+               }
+               
+               return false;
+       }
+       
+       /**
+        * Notify a user via their preferences.
+        *
+        * @param mixed $to Either a guid or an array of guid's to notify.
+        * @param int $from GUID of the sender, which may be a user, site or object.
+        * @param string $subject Message subject.
+        * @param string $message Message body.
+        * @param array $params Misc additional parameters specific to various methods.
+        * @param mixed $methods_override A string, or an array of strings specifying the delivery methods to use - or leave blank
+        *                              for delivery using the user's chosen delivery methods.
+        * @return array Compound array of each delivery user/delivery method's success or failure.
+        * @throws NotificationException
+        */
+       function notify_user($to, $from, $subject, $message, array $params = NULL, $methods_override = "")
+       {
+               global $NOTIFICATION_HANDLERS, $CONFIG;
+       
+               // Sanitise
+               if (!is_array($to))
+                       $to = array((int)$to);
+               $from = (int)$from;
+               //$subject = sanitise_string($subject);
+                       
+               // Get notification methods
+               if (($methods_override) && (!is_array($methods_override)))
+                       $methods_override = array($methods_override);
+                       
+               $result = array();
+               
+               foreach ($to as $guid)
+               {
+                       // Results for a user are...
+                       $result[$guid] = array();
+                       
+                       if ($guid) { // Is the guid > 0? 
+                               // Are we overriding delivery?
+                               $methods = $methods_override;
+                               if (!$methods)
+                               {
+                                       $tmp = (array)get_user_notification_settings($guid);
+                                       $methods = array(); 
+                                       foreach($tmp as $k => $v)
+                                               if ($v) $methods[] = $k; // Add method if method is turned on for user!
+                               }
+                               
+                               if ($methods)
+                               {
+                                       // Deliver
+                                       foreach ($methods as $method)
+                                       {
+                                               // Extract method details from list
+                                               $details = $NOTIFICATION_HANDLERS[$method];
+                                               $handler = $details->handler;
+                                       
+                                               if ((!$NOTIFICATION_HANDLERS[$method]) || (!$handler))
+                                                       error_log(sprintf(elgg_echo('NotificationException:NoHandlerFound'), $method));
+               
+                                               if ($CONFIG->debug)
+                                                       error_log("Sending message to $guid using $method");                                    
+                                                       
+                                               // Trigger handler and retrieve result.
+                                               try {
+                                                       $result[$guid][$method] = $handler(
+                                                               $from ? get_entity($from) : NULL,       // From entity
+                                                               get_entity($guid),                                      // To entity
+                                                               $subject,                                                       // The subject
+                                                               $message,                       // Message
+                                                               $params                                                         // Params
+                                                       );
+                                               } catch (Exception $e) {
+                                                       error_log($e->getMessage());
+                                               }
+                                               
+                                       }
+                               }
+                       }               
+               }
+       
+               return $result;
+       }
+       
+       /**
+        * Get the notification settings for a given user.
+        *
+        * @param int $user_guid The user id
+        * @return stdClass 
+        */
+       function get_user_notification_settings($user_guid = 0)
+       {
+               $user_guid = (int)$user_guid;
+               
+               if ($user_guid == 0) $user_guid = get_loggedin_userid();
+               
+               $all_metadata = get_metadata_for_entity($user_guid);
+               if ($all_metadata)
+               {
+                       $prefix = "notification:method:";
+                       $return = new stdClass;
+                       
+                       foreach ($all_metadata as $meta)
+                       {
+                               $name = substr($meta->name, strlen($prefix));
+                               $value = $meta->value;
+                       
+                               if (strpos($meta->name, $prefix) === 0)
+                                       $return->$name = $value;
+                       }
+
+                       return $return;                 
+               }
+               
+               return false;
+       }
+       
+       /**
+        * Set a user notification pref.
+        *
+        * @param int $user_guid The user id.
+        * @param string $method The delivery method (eg. email)
+        * @param bool $value On(true) or off(false).
+        * @return bool
+        */
+       function set_user_notification_setting($user_guid, $method, $value)
+       {
+               $user_guid = (int)$user_guid;
+               $method = sanitise_string($method);
+                       
+               $user = get_entity($user_guid);
+               if (!$user) $user = get_loggedin_user();
+               
+               if (($user) && ($user instanceof ElggUser))
+               {                       
+                       $prefix = "notification:method:$method";
+                       $user->$prefix = $value;
+                       $user->save();
+               
+                       return true;
+               }
+                       
+               return false;
+       }
+       
+       /**
+        * Notification exception.
+        * @author Curverider Ltd
+        */
+       class NotificationException extends Exception {}
+
+       
+       /**
+        * Send a notification via email.
+        *
+        * @param ElggEntity $from The from user/site/object
+        * @param ElggUser $to To which user?
+        * @param string $subject The subject of the message.
+        * @param string $message The message body
+        * @param array $params Optional parameters (none taken in this instance)
+        * @return bool
+        */
+       function email_notify_handler(ElggEntity $from, ElggUser $to, $subject, $message, array $params = NULL)
+       {
+               global $CONFIG;
+               
+               if (!$from)
+                       throw new NotificationException(sprintf(elgg_echo('NotificationException:MissingParameter'), 'from'));
+                        
+               if (!$to)
+                       throw new NotificationException(sprintf(elgg_echo('NotificationException:MissingParameter'), 'to'));
+               
+               if ($to->email=="")
+                       throw new NotificationException(sprintf(elgg_echo('NotificationException:NoEmailAddress'), $to->guid));                 
+
+               // Sanitise subject
+               $subject = preg_replace("/(\r\n|\r|\n)/", " ", $subject); // Strip line endings
+                       
+               // To 
+               $to = $to->email;
+               
+               // From
+               $site = get_entity($CONFIG->site_guid);
+               if ((isset($from->email)) && (!($from instanceof ElggUser))) // If there's an email address, use it - but only if its not from a user.
+                       $from = $from->email;
+               else if (($site) && (isset($site->email))) // Has the current site got a from email address?
+                       $from = $site->email;
+               else if (isset($from->url)) // If we have a url then try and use that.
+               {
+                       $breakdown = parse_url($from->url);
+                       $from = 'noreply@' . $breakdown['host']; // Handle anything with a url
+               }
+               else // If all else fails, use the domain of the site.
+                       $from = 'noreply@' . get_site_domain($CONFIG->site_guid); 
+       
+               if (is_callable('mb_internal_encoding')) {
+                       mb_internal_encoding('UTF-8');
+               }
+               $site = get_entity($CONFIG->site_guid);
+               $sitename = $site->name;
+               if (is_callable('mb_encode_mimeheader')) {
+                       $sitename = mb_encode_mimeheader($site->name,"UTF-8", "B");
+               }
+               
+               $header_eol = "\r\n";
+               if ( 
+                       (isset($CONFIG->broken_mta)) &&
+                       ($CONFIG->broken_mta)
+               )
+                       $header_eol = "\n"; // Allow non-RFC 2822 mail headers to support some broken MTAs
                
                $from_email = "\"$sitename\" <$from>";
                if (strtolower(substr(PHP_OS, 0 , 3)) == 'win')
                        $from_email = "$from"; // Windows is somewhat broken, so we use a different format from header
-                       \r
-               $headers = "From: $from_email{$header_eol}"\r
-                       . "Content-Type: text/plain; charset=UTF-8; format=flowed{$header_eol}"\r
-               . "MIME-Version: 1.0{$header_eol}"\r
-               . "Content-Transfer-Encoding: 8bit{$header_eol}";\r
-\r
-       if (is_callable('mb_encode_mimeheader')) {\r
-                       $subject = mb_encode_mimeheader($subject,"UTF-8", "B");\r
-       }       \r
-       \r
+                       
+               $headers = "From: $from_email{$header_eol}"
+                       . "Content-Type: text/plain; charset=UTF-8; format=flowed{$header_eol}"
+               . "MIME-Version: 1.0{$header_eol}"
+               . "Content-Transfer-Encoding: 8bit{$header_eol}";
+
+       if (is_callable('mb_encode_mimeheader')) {
+                       $subject = mb_encode_mimeheader($subject,"UTF-8", "B");
+       }       
+       
                // Format message
-               $message = html_entity_decode($message, ENT_COMPAT, 'UTF-8'); // Decode any html entities\r
-       $message = strip_tags($message); // Strip tags from message\r
-       $message = preg_replace("/(\r\n|\r)/", "\n", $message); // Convert to unix line endings in body\r
-       $message = preg_replace("/^From/", ">From", $message); // Change lines starting with From to >From      \r
-               \r
-               return mail($to, $subject, wordwrap($message), $headers);\r
-       }\r
-\r
-       /**\r
-        * Correctly initialise notifications and register the email handler.\r
-        *\r
-        */\r
-       function notification_init()\r
-       {\r
-               // Register a notification handler for the default email method\r
-               register_notification_handler("email", "email_notify_handler");\r
-               \r
-               // Add settings view to user settings & register action\r
-               extend_elgg_settings_page('notifications/settings/usersettings', 'usersettings/user');\r
-               \r
-               register_plugin_hook('usersettings:save','user','notification_user_settings_save');\r
-               \r
-               //register_action("notifications/settings/usersettings/save");\r
-               \r
-               \r
-               // Register some APIs\r
-               expose_function('user.notification.get', 'get_user_notification_settings', array(\r
-                       'user_guid' => array ('type' => 'int')\r
-               ), elgg_echo('user.notification.get'));\r
-               \r
-               expose_function('user.notification.set', 'set_user_notification_settings', array(\r
-                       'user_guid' => array ('type' => 'int'),\r
-                       'method' => array ('type' => 'string'),\r
-                       'value' => array ('type' => 'bool')\r
-               ), elgg_echo('user.notification.set'));\r
-               \r
-       }\r
-       \r
-       function notification_user_settings_save() {\r
-               \r
-               global $CONFIG;\r
-               @include($CONFIG->path . "actions/notifications/settings/usersettings/save.php");\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Register an entity type and subtype to be eligible for notifications\r
-        *\r
-        * @param string $entity_type The type of entity\r
-        * @param string $object_subtype Its subtype\r
-        * @param string $english_name It's English notification string (eg "New blog post")\r
-        */\r
-       function register_notification_object($entity_type, $object_subtype, $english_name) {\r
-               global $CONFIG;\r
-               \r
-               if ($entity_type == '') $entity_type = '__BLANK__';\r
-               if ($object_subtype == '') $object_subtype = '__BLANK__';\r
-               \r
-               if (!isset($CONFIG->register_objects)) {\r
-                       $CONFIG->register_objects = array();\r
-               }\r
-               if (!isset($CONFIG->register_objects[$entity_type])) {\r
-                       $CONFIG->register_objects[$entity_type] = array();\r
-               }\r
-               $CONFIG->register_objects[$entity_type][$object_subtype] = $english_name;\r
-       }\r
-       \r
-       /**\r
-        * Establish a 'notify' relationship between the user and a content author\r
-        *\r
-        * @param int $user_guid The GUID of the user who wants to follow a user's content\r
-        * @param int $author_guid The GUID of the user whose content the user wants to follow\r
-        * @return true|false Depending on success\r
-        */\r
-       function register_notification_interest($user_guid, $author_guid) {\r
-               return add_entity_relationship($user_guid, 'notify', $author_guid);\r
-       }\r
-       \r
-       /**\r
-        * Remove a 'notify' relationship between the user and a content author\r
-        *\r
-        * @param int $user_guid The GUID of the user who is following a user's content\r
-        * @param int $author_guid The GUID of the user whose content the user wants to unfollow\r
-        * @return true|false Depending on success\r
-        */\r
-       function remove_notification_interest($user_guid, $author_guid) {\r
-               return remove_entity_relationship($user_guid, 'notify', $author_guid);\r
-       }\r
-       \r
-       /**\r
-        * Automatically triggered notification on 'create' events that looks at registered\r
-        * objects and attempts to send notifications to anybody who's interested\r
-        *\r
-        * @see register_notification_object\r
-        */\r
-       function object_notifications($event, $object_type, $object) {\r
-               \r
-               // We only want to trigger notification events for ElggEntities\r
-               if ($object instanceof ElggEntity) {\r
-                       \r
-                       // Get config data\r
-                       global $CONFIG, $SESSION, $NOTIFICATION_HANDLERS;\r
-                       \r
-                       $hookresult = trigger_plugin_hook('object:notifications',$object_type,array(\r
-                                                                               'event' => $event,\r
-                                                                               'object_type' => $object_type,\r
-                                                                               'object' => $object,\r
-                                                                       ),false);\r
-                       if ($hookresult === true) return true;\r
-                       \r
-                       // Have we registered notifications for this type of entity?\r
-                       $object_type = $object->getType(); if (empty($object_type)) $object_type = '__BLANK__';\r
-                       $object_subtype = $object->getSubtype(); if (empty($object_subtype)) $object_subtype = '__BLANK__';\r
-                       if (isset($CONFIG->register_objects[$object_type][$object_subtype])) {\r
-\r
-                               $descr = $CONFIG->register_objects[$object_type][$object_subtype];\r
-                               $string = $descr . ": " . $object->getURL();\r
-                               \r
-                               // Get users interested in content from this person and notify them\r
-                               // (Person defined by container_guid so we can also subscribe to groups if we want)\r
-                               foreach($NOTIFICATION_HANDLERS as $method => $foo)\r
-                               if ($interested_users = get_entities_from_relationship('notify' . $method,$object->container_guid,true,'user','',0,'',99999)) {\r
-                                       \r
-                                       if (is_array($interested_users))\r
-                                               foreach($interested_users as $user) {\r
-                                                       if ($user instanceof ElggUser) {\r
-                                                               \r
-                                                               if (!$user->isBanned())\r
-                                                               if (($user->guid != $SESSION['user']->guid) && has_access_to_entity($object,$user)\r
-                                                                       && $object->access_id != ACCESS_PRIVATE) { \r
-               \r
-                                                                                               $methodstring = trigger_plugin_hook('notify:entity:message',$object->getType(),array(\r
-                                                                                                       'entity' => $object,\r
-                                                                                                       'to_entity' => $user,\r
-                                                                                                       'method' => $method),$string);\r
-                                                                                               if (empty($methodstring) && $methodstring !== false) $methodstring = $string;\r
-                                                                                               if ($methodstring !== false)\r
-                                                                                                       notify_user($user->guid,$object->container_guid,$descr,$methodstring,NULL,array($method));\r
-                                                               }\r
-                                                       }                                               \r
-                                               }\r
-                               }\r
-                               \r
-                       }\r
-                       \r
-               }\r
-               \r
-       }\r
-\r
-       // Register a startup event\r
-       register_elgg_event_handler('init','system','notification_init',0);\r
-       register_elgg_event_handler('create','object','object_notifications');\r
-\r
-?>\r
+               $message = html_entity_decode($message, ENT_COMPAT, 'UTF-8'); // Decode any html entities
+       $message = strip_tags($message); // Strip tags from message
+       $message = preg_replace("/(\r\n|\r)/", "\n", $message); // Convert to unix line endings in body
+       $message = preg_replace("/^From/", ">From", $message); // Change lines starting with From to >From      
+               
+               return mail($to, $subject, wordwrap($message), $headers);
+       }
+
+       /**
+        * Correctly initialise notifications and register the email handler.
+        *
+        */
+       function notification_init()
+       {
+               // Register a notification handler for the default email method
+               register_notification_handler("email", "email_notify_handler");
+               
+               // Add settings view to user settings & register action
+               extend_elgg_settings_page('notifications/settings/usersettings', 'usersettings/user');
+               
+               register_plugin_hook('usersettings:save','user','notification_user_settings_save');
+               
+               //register_action("notifications/settings/usersettings/save");
+               
+               
+               // Register some APIs
+               expose_function('user.notification.get', 'get_user_notification_settings', array(
+                       'user_guid' => array ('type' => 'int')
+               ), elgg_echo('user.notification.get'));
+               
+               expose_function('user.notification.set', 'set_user_notification_settings', array(
+                       'user_guid' => array ('type' => 'int'),
+                       'method' => array ('type' => 'string'),
+                       'value' => array ('type' => 'bool')
+               ), elgg_echo('user.notification.set'));
+               
+       }
+       
+       function notification_user_settings_save() {
+               
+               global $CONFIG;
+               @include($CONFIG->path . "actions/notifications/settings/usersettings/save.php");
+               
+       }
+       
+       /**
+        * Register an entity type and subtype to be eligible for notifications
+        *
+        * @param string $entity_type The type of entity
+        * @param string $object_subtype Its subtype
+        * @param string $english_name It's English notification string (eg "New blog post")
+        */
+       function register_notification_object($entity_type, $object_subtype, $english_name) {
+               global $CONFIG;
+               
+               if ($entity_type == '') $entity_type = '__BLANK__';
+               if ($object_subtype == '') $object_subtype = '__BLANK__';
+               
+               if (!isset($CONFIG->register_objects)) {
+                       $CONFIG->register_objects = array();
+               }
+               if (!isset($CONFIG->register_objects[$entity_type])) {
+                       $CONFIG->register_objects[$entity_type] = array();
+               }
+               $CONFIG->register_objects[$entity_type][$object_subtype] = $english_name;
+       }
+       
+       /**
+        * Establish a 'notify' relationship between the user and a content author
+        *
+        * @param int $user_guid The GUID of the user who wants to follow a user's content
+        * @param int $author_guid The GUID of the user whose content the user wants to follow
+        * @return true|false Depending on success
+        */
+       function register_notification_interest($user_guid, $author_guid) {
+               return add_entity_relationship($user_guid, 'notify', $author_guid);
+       }
+       
+       /**
+        * Remove a 'notify' relationship between the user and a content author
+        *
+        * @param int $user_guid The GUID of the user who is following a user's content
+        * @param int $author_guid The GUID of the user whose content the user wants to unfollow
+        * @return true|false Depending on success
+        */
+       function remove_notification_interest($user_guid, $author_guid) {
+               return remove_entity_relationship($user_guid, 'notify', $author_guid);
+       }
+       
+       /**
+        * Automatically triggered notification on 'create' events that looks at registered
+        * objects and attempts to send notifications to anybody who's interested
+        *
+        * @see register_notification_object
+        */
+       function object_notifications($event, $object_type, $object) {
+               
+               // We only want to trigger notification events for ElggEntities
+               if ($object instanceof ElggEntity) {
+                       
+                       // Get config data
+                       global $CONFIG, $SESSION, $NOTIFICATION_HANDLERS;
+                       
+                       $hookresult = trigger_plugin_hook('object:notifications',$object_type,array(
+                                                                               'event' => $event,
+                                                                               'object_type' => $object_type,
+                                                                               'object' => $object,
+                                                                       ),false);
+                       if ($hookresult === true) return true;
+                       
+                       // Have we registered notifications for this type of entity?
+                       $object_type = $object->getType(); if (empty($object_type)) $object_type = '__BLANK__';
+                       $object_subtype = $object->getSubtype(); if (empty($object_subtype)) $object_subtype = '__BLANK__';
+                       if (isset($CONFIG->register_objects[$object_type][$object_subtype])) {
+
+                               $descr = $CONFIG->register_objects[$object_type][$object_subtype];
+                               $string = $descr . ": " . $object->getURL();
+                               
+                               // Get users interested in content from this person and notify them
+                               // (Person defined by container_guid so we can also subscribe to groups if we want)
+                               foreach($NOTIFICATION_HANDLERS as $method => $foo)
+                               if ($interested_users = get_entities_from_relationship('notify' . $method,$object->container_guid,true,'user','',0,'',99999)) {
+                                       
+                                       if (is_array($interested_users))
+                                               foreach($interested_users as $user) {
+                                                       if ($user instanceof ElggUser) {
+                                                               
+                                                               if (!$user->isBanned())
+                                                               if (($user->guid != $SESSION['user']->guid) && has_access_to_entity($object,$user)
+                                                                       && $object->access_id != ACCESS_PRIVATE) { 
+               
+                                                                                               $methodstring = trigger_plugin_hook('notify:entity:message',$object->getType(),array(
+                                                                                                       'entity' => $object,
+                                                                                                       'to_entity' => $user,
+                                                                                                       'method' => $method),$string);
+                                                                                               if (empty($methodstring) && $methodstring !== false) $methodstring = $string;
+                                                                                               if ($methodstring !== false)
+                                                                                                       notify_user($user->guid,$object->container_guid,$descr,$methodstring,NULL,array($method));
+                                                               }
+                                                       }                                               
+                                               }
+                               }
+                               
+                       }
+                       
+               }
+               
+       }
+
+       // Register a startup event
+       register_elgg_event_handler('init','system','notification_init',0);
+       register_elgg_event_handler('create','object','object_notifications');
+
+?>
index 4090c1c247aeb1968d8493483982d201adeaef1a..7e7e956a41fa44f332a6d19fc02e59579b119b0c 100644 (file)
-<?php\r
-\r
-       /**\r
-        * Elgg objects\r
-        * Functions to manage multiple or single objects in an Elgg install\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg objects
+        * Functions to manage multiple or single objects in an Elgg install
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /**\r
-        * ElggObject\r
+       /**
+        * ElggObject
         * Representation of an "object" in the system.
         * 
         * @package Elgg
-        * @subpackage Core\r
-        */\r
-       class ElggObject extends ElggEntity\r
-       {\r
-               /**\r
-                * Initialise the attributes array. \r
-                * This is vital to distinguish between metadata and base parameters.\r
-                * \r
-                * Place your base parameters here.\r
-                */\r
-               protected function initialise_attributes()\r
-               {\r
-                       parent::initialise_attributes();\r
-                       \r
-                       $this->attributes['type'] = "object";\r
-                       $this->attributes['title'] = "";\r
+        * @subpackage Core
+        */
+       class ElggObject extends ElggEntity
+       {
+               /**
+                * Initialise the attributes array. 
+                * This is vital to distinguish between metadata and base parameters.
+                * 
+                * Place your base parameters here.
+                */
+               protected function initialise_attributes()
+               {
+                       parent::initialise_attributes();
+                       
+                       $this->attributes['type'] = "object";
+                       $this->attributes['title'] = "";
                        $this->attributes['description'] = "";
-                       $this->attributes['tables_split'] = 2;\r
-               }\r
-                               \r
-               /**\r
-                * Construct a new object entity, optionally from a given id value.\r
-                *\r
-                * @param mixed $guid If an int, load that GUID. \r
-                *      If a db row then will attempt to load the rest of the data.\r
-                * @throws Exception if there was a problem creating the object. \r
-                */\r
-               function __construct($guid = null) \r
-               {                       \r
+                       $this->attributes['tables_split'] = 2;
+               }
+                               
+               /**
+                * Construct a new object entity, optionally from a given id value.
+                *
+                * @param mixed $guid If an int, load that GUID. 
+                *      If a db row then will attempt to load the rest of the data.
+                * @throws Exception if there was a problem creating the object. 
+                */
+               function __construct($guid = null) 
+               {                       
                        $this->initialise_attributes();
-                       \r
-                       if (!empty($guid))\r
-                       {\r
-                               // Is $guid is a DB row - either a entity row, or a object table row.\r
-                               if ($guid instanceof stdClass) {                                        \r
-                                       // Load the rest\r
+                       
+                       if (!empty($guid))
+                       {
+                               // Is $guid is a DB row - either a entity row, or a object table row.
+                               if ($guid instanceof stdClass) {                                        
+                                       // Load the rest
                                        if (!$this->load($guid->guid))
-                                               throw new IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid->guid)); \r
-                               }\r
-                               \r
-                               // Is $guid is an ElggObject? Use a copy constructor\r
-                               else if ($guid instanceof ElggObject)\r
-                               {                                       \r
-                                        foreach ($guid->attributes as $key => $value) \r
-                                               $this->attributes[$key] = $value;\r
-                               }\r
-                               \r
-                               // Is this is an ElggEntity but not an ElggObject = ERROR!\r
-                               else if ($guid instanceof ElggEntity)\r
-                                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonElggObject'));\r
-                                                                               \r
-                               // We assume if we have got this far, $guid is an int\r
-                               else if (is_numeric($guid)) {                                   \r
-                                       if (!$this->load($guid)) IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid));\r
+                                               throw new IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid->guid)); 
+                               }
+                               
+                               // Is $guid is an ElggObject? Use a copy constructor
+                               else if ($guid instanceof ElggObject)
+                               {                                       
+                                        foreach ($guid->attributes as $key => $value) 
+                                               $this->attributes[$key] = $value;
+                               }
+                               
+                               // Is this is an ElggEntity but not an ElggObject = ERROR!
+                               else if ($guid instanceof ElggEntity)
+                                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonElggObject'));
+                                                                               
+                               // We assume if we have got this far, $guid is an int
+                               else if (is_numeric($guid)) {                                   
+                                       if (!$this->load($guid)) IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid));
                                }
                                
                                else
-                                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnrecognisedValue'));\r
-                       }\r
-               }\r
-               \r
-               /**\r
-                * Override the load function.\r
-                * This function will ensure that all data is loaded (were possible), so\r
-                * if only part of the ElggObject is loaded, it'll load the rest.\r
-                * \r
-                * @param int $guid\r
-                * @return true|false \r
-                */\r
-               protected function load($guid)\r
-               {                       \r
-                       // Test to see if we have the generic stuff\r
-                       if (!parent::load($guid)) \r
-                               return false;\r
-\r
-                       // Check the type\r
-                       if ($this->attributes['type']!='object')\r
-                               throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()));\r
-                               \r
-                       // Load missing data\r
+                                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnrecognisedValue'));
+                       }
+               }
+               
+               /**
+                * Override the load function.
+                * This function will ensure that all data is loaded (were possible), so
+                * if only part of the ElggObject is loaded, it'll load the rest.
+                * 
+                * @param int $guid
+                * @return true|false 
+                */
+               protected function load($guid)
+               {                       
+                       // Test to see if we have the generic stuff
+                       if (!parent::load($guid)) 
+                               return false;
+
+                       // Check the type
+                       if ($this->attributes['type']!='object')
+                               throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()));
+                               
+                       // Load missing data
                        $row = get_object_entity_as_row($guid);
-                       if (($row) && (!$this->isFullyLoaded())) $this->attributes['tables_loaded'] ++; // If $row isn't a cached copy then increment the counter\r
-                                               \r
-                       // Now put these into the attributes array as core values\r
-                       $objarray = (array) $row;\r
-                       foreach($objarray as $key => $value) \r
-                               $this->attributes[$key] = $value;\r
-               \r
-                       return true;\r
-               }\r
-               \r
-               /**\r
-                * Override the save function.\r
-                * @return true|false\r
-                */\r
-               public function save()\r
-               {\r
-                       // Save generic stuff\r
-                       if (!parent::save())\r
-                               return false;\r
-                       \r
-                       // Now save specific stuff\r
+                       if (($row) && (!$this->isFullyLoaded())) $this->attributes['tables_loaded'] ++; // If $row isn't a cached copy then increment the counter
+                                               
+                       // Now put these into the attributes array as core values
+                       $objarray = (array) $row;
+                       foreach($objarray as $key => $value) 
+                               $this->attributes[$key] = $value;
+               
+                       return true;
+               }
+               
+               /**
+                * Override the save function.
+                * @return true|false
+                */
+               public function save()
+               {
+                       // Save generic stuff
+                       if (!parent::save())
+                               return false;
+                       
+                       // Now save specific stuff
                        return create_object_entity($this->get('guid'), $this->get('title'), $this->get('description'), $this->get('container_guid'));
                }
-               \r
-               /**\r
-                * Get sites that this object is a member of\r
-                *\r
-                * @param string $subtype Optionally, the subtype of result we want to limit to\r
-                * @param int $limit The number of results to return\r
-                * @param int $offset Any indexing offset\r
-                */\r
-               function getSites($subtype="", $limit = 10, $offset = 0) {\r
-                       return get_site_objects($this->getGUID(), $subtype, $limit, $offset);\r
-               }\r
-               \r
-               /**\r
-                * Add this object to a particular site\r
-                *\r
-                * @param int $site_guid The guid of the site to add it to\r
-                * @return true|false\r
-                */\r
-               function addToSite($site_guid) {\r
-                       return add_site_object($this->getGUID(), $site_guid); \r
-               }\r
+               
+               /**
+                * Get sites that this object is a member of
+                *
+                * @param string $subtype Optionally, the subtype of result we want to limit to
+                * @param int $limit The number of results to return
+                * @param int $offset Any indexing offset
+                */
+               function getSites($subtype="", $limit = 10, $offset = 0) {
+                       return get_site_objects($this->getGUID(), $subtype, $limit, $offset);
+               }
+               
+               /**
+                * Add this object to a particular site
+                *
+                * @param int $site_guid The guid of the site to add it to
+                * @return true|false
+                */
+               function addToSite($site_guid) {
+                       return add_site_object($this->getGUID(), $site_guid); 
+               }
 
                /**
                 * Set the container for this object.
                                
                        return false;
                }
-               \r
-               /**\r
-                * Get the collections associated with a object.\r
-                *\r
-                * @param string $subtype Optionally, the subtype of result we want to limit to\r
-                * @param int $limit The number of results to return\r
-                * @param int $offset Any indexing offset\r
-                * @return unknown\r
-                */\r
-               //public function getCollections($subtype="", $limit = 10, $offset = 0) { get_object_collections($this->getGUID(), $subtype, $limit, $offset); }\r
+               
+               /**
+                * Get the collections associated with a object.
+                *
+                * @param string $subtype Optionally, the subtype of result we want to limit to
+                * @param int $limit The number of results to return
+                * @param int $offset Any indexing offset
+                * @return unknown
+                */
+               //public function getCollections($subtype="", $limit = 10, $offset = 0) { get_object_collections($this->getGUID(), $subtype, $limit, $offset); }
                
                // EXPORTABLE INTERFACE ////////////////////////////////////////////////////////////
                
                                'title',
                                'description',
                        ));
-               }\r
-       }\r
-\r
-       /**\r
-        * Return the object specific details of a object by a row.\r
-        * \r
-        * @param int $guid\r
-        */\r
-       function get_object_entity_as_row($guid)\r
-       {\r
-               global $CONFIG;\r
-               \r
+               }
+       }
+
+       /**
+        * Return the object specific details of a object by a row.
+        * 
+        * @param int $guid
+        */
+       function get_object_entity_as_row($guid)
+       {
+               global $CONFIG;
+               
                $guid = (int)$guid;
                
                /*$row = retrieve_cached_entity_row($guid);
                {*/
                        // Object not cached, load it.
                        if ($CONFIG->debug)
-                               error_log("** Sub part of GUID:$guid loaded from DB");\r
-               \r
+                               error_log("** Sub part of GUID:$guid loaded from DB");
+               
                        return get_data_row("SELECT * from {$CONFIG->dbprefix}objects_entity where guid=$guid");
-               //}\r
-       }\r
-       \r
-       /**\r
-        * Create or update the extras table for a given object.\r
-        * Call create_entity first.\r
-        * \r
-        * @param int $guid The guid of the entity you're creating (as obtained by create_entity)\r
-        * @param string $title The title of the object\r
-        * @param string $description The object's description\r
-        */\r
-       function create_object_entity($guid, $title, $description)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $guid = (int)$guid;\r
-               $title = sanitise_string($title);\r
+               //}
+       }
+       
+       /**
+        * Create or update the extras table for a given object.
+        * Call create_entity first.
+        * 
+        * @param int $guid The guid of the entity you're creating (as obtained by create_entity)
+        * @param string $title The title of the object
+        * @param string $description The object's description
+        */
+       function create_object_entity($guid, $title, $description)
+       {
+               global $CONFIG;
+               
+               $guid = (int)$guid;
+               $title = sanitise_string($title);
                $description = sanitise_string($description);
-               \r
-               $row = get_entity_as_row($guid);\r
-               \r
-               if ($row)\r
+               
+               $row = get_entity_as_row($guid);
+               
+               if ($row)
                {
                        // Core entities row exists and we have access to it
                        if ($exists = get_data_row("SELECT guid from {$CONFIG->dbprefix}objects_entity where guid = {$guid}")) {
                                        } else {
                                                $entity->delete();
                                        }
-                               }\r
+                               }
                        }
                        else
                        {
                                                //delete_entity($guid);
                                        }
                                }
-                       }\r
-                       \r
-               }\r
-               \r
-               return false;\r
-       }\r
-       \r
+                       }
+                       
+               }
+               
+               return false;
+       }
+       
        /**
         * THIS FUNCTION IS DEPRECATED.
-        * \r
-        * Delete a object's extra data.\r
-        * \r
-        * @param int $guid\r
-        */\r
-       function delete_object_entity($guid)\r
+        * 
+        * Delete a object's extra data.
+        * 
+        * @param int $guid
+        */
+       function delete_object_entity($guid)
        {
                system_message(sprintf(elgg_echo('deprecatedfunction'), 'delete_user_entity'));
                
-               return 1; // Always return that we have deleted one row in order to not break existing code.\r
+               return 1; // Always return that we have deleted one row in order to not break existing code.
        }
        
        /**
                        }
                }
                return false;
-       }\r
-\r
-       /**\r
-        * Get the sites this object is part of\r
-        *\r
-        * @param int $object_guid The object's GUID\r
-        * @param int $limit Number of results to return\r
-        * @param int $offset Any indexing offset\r
-        * @return false|array On success, an array of ElggSites\r
-        */\r
-       function get_object_sites($object_guid, $limit = 10, $offset = 0) {\r
-               $object_guid = (int)$object_guid;\r
-               $limit = (int)$limit;\r
-               $offset = (int)$offset;\r
-               \r
-               return get_entities_from_relationship("member_of_site", $object_guid, false, "site", "", 0, "time_created desc", $limit, $offset);\r
-       }\r
-               \r
+       }
+
+       /**
+        * Get the sites this object is part of
+        *
+        * @param int $object_guid The object's GUID
+        * @param int $limit Number of results to return
+        * @param int $offset Any indexing offset
+        * @return false|array On success, an array of ElggSites
+        */
+       function get_object_sites($object_guid, $limit = 10, $offset = 0) {
+               $object_guid = (int)$object_guid;
+               $limit = (int)$limit;
+               $offset = (int)$offset;
+               
+               return get_entities_from_relationship("member_of_site", $object_guid, false, "site", "", 0, "time_created desc", $limit, $offset);
+       }
+               
 ?>
\ No newline at end of file
index 3669635e2d9b134eeadda7b3fe22e032d005a5e3..e602590b35596436792916ac55ed715bc98d0804 100644 (file)
-<?php\r
-\r
-       /**\r
-        * Elgg page handler functions\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg page handler functions
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /**\r
-        * Turns the current page over to the page handler, allowing registered handlers to take over\r
-        *\r
-        * @param string $handler The name of the handler type (eg 'blog')\r
-        * @param array $page The parameters to the page, as an array (exploded by '/' slashes)\r
-        * @return true|false Depending on whether a registered page handler was found\r
-        */\r
-       function page_handler($handler, $page) {\r
-               \r
-               global $CONFIG;\r
-               \r
-               set_context($handler);\r
-               \r
-               $query = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?')+1);//parse_url($_SERVER['REQUEST_URI']);\r
-               if (isset($query)) {\r
-                       parse_str($query, $query_arr);\r
-                       if (is_array($query_arr)) {\r
-                               foreach($query_arr as $name => $val) {\r
-                                       set_input($name, $val);\r
-                               }\r
-                       }\r
-               } \r
-               $page = explode('/',$page);\r
-               \r
-               if (!isset($CONFIG->pagehandler) || empty($handler)) {\r
-                       $result = false;\r
-               } else if (isset($CONFIG->pagehandler[$handler]) && is_callable($CONFIG->pagehandler[$handler])) {\r
-                       $function = $CONFIG->pagehandler[$handler];\r
-                       $result = $function($page, $handler);\r
-                       if ($result !== false) {\r
-                               $result = true;\r
-                       }\r
-               } else {\r
-                       $result = false;\r
-               }\r
-               \r
-               if (!$result) {\r
-                       $result = default_page_handler($page, $handler);\r
-               }\r
-               if ($result !== false) $result = true;          \r
-               \r
-               return $result;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Registers a page handler for a particular identifier\r
-        * \r
-        * eg, you can register a function called 'blog_page_handler' for handler type 'blog'\r
-        * \r
-        * Now for all URLs of type http://yoururl/blog/*, the blog_page_handler function will be called.\r
-        * The part of the URL marked with * above will be exploded on '/' characters and passed as an\r
-        * array to that function, eg:\r
-        * \r
-        * For the URL http://yoururl/blog/username/friends/:\r
-        * blog_page_handler('blog', array('username','friends')); \r
-        *\r
-        * @param string $handler The page type to handle\r
-        * @param string $function Your function name\r
-        * @return true|false Depending on success\r
-        */\r
-       function register_page_handler($handler, $function) {\r
-               \r
-               global $CONFIG;\r
-               if (!isset($CONFIG->pagehandler))\r
-                       $CONFIG->pagehandler = array();\r
-               if (is_callable($function)) {\r
-                       $CONFIG->pagehandler[$handler] = $function;\r
-                       return true;\r
-               } \r
-               return false;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * A default page handler that attempts to load the actual file at a given page handler location\r
-        *\r
-        * @param array $page The page URL elements\r
-        * @param string $handler The base handler\r
-        * @return true|false Depending on success\r
-        */\r
-       function default_page_handler($page, $handler) {\r
-               \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       /**
+        * Turns the current page over to the page handler, allowing registered handlers to take over
+        *
+        * @param string $handler The name of the handler type (eg 'blog')
+        * @param array $page The parameters to the page, as an array (exploded by '/' slashes)
+        * @return true|false Depending on whether a registered page handler was found
+        */
+       function page_handler($handler, $page) {
+               
+               global $CONFIG;
+               
+               set_context($handler);
+               
+               $query = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], '?')+1);//parse_url($_SERVER['REQUEST_URI']);
+               if (isset($query)) {
+                       parse_str($query, $query_arr);
+                       if (is_array($query_arr)) {
+                               foreach($query_arr as $name => $val) {
+                                       set_input($name, $val);
+                               }
+                       }
+               } 
+               $page = explode('/',$page);
+               
+               if (!isset($CONFIG->pagehandler) || empty($handler)) {
+                       $result = false;
+               } else if (isset($CONFIG->pagehandler[$handler]) && is_callable($CONFIG->pagehandler[$handler])) {
+                       $function = $CONFIG->pagehandler[$handler];
+                       $result = $function($page, $handler);
+                       if ($result !== false) {
+                               $result = true;
+                       }
+               } else {
+                       $result = false;
+               }
+               
+               if (!$result) {
+                       $result = default_page_handler($page, $handler);
+               }
+               if ($result !== false) $result = true;          
+               
+               return $result;
+               
+       }
+       
+       /**
+        * Registers a page handler for a particular identifier
+        * 
+        * eg, you can register a function called 'blog_page_handler' for handler type 'blog'
+        * 
+        * Now for all URLs of type http://yoururl/blog/*, the blog_page_handler function will be called.
+        * The part of the URL marked with * above will be exploded on '/' characters and passed as an
+        * array to that function, eg:
+        * 
+        * For the URL http://yoururl/blog/username/friends/:
+        * blog_page_handler('blog', array('username','friends')); 
+        *
+        * @param string $handler The page type to handle
+        * @param string $function Your function name
+        * @return true|false Depending on success
+        */
+       function register_page_handler($handler, $function) {
+               
+               global $CONFIG;
+               if (!isset($CONFIG->pagehandler))
+                       $CONFIG->pagehandler = array();
+               if (is_callable($function)) {
+                       $CONFIG->pagehandler[$handler] = $function;
+                       return true;
+               } 
+               return false;
+               
+       }
+       
+       /**
+        * A default page handler that attempts to load the actual file at a given page handler location
+        *
+        * @param array $page The page URL elements
+        * @param string $handler The base handler
+        * @return true|false Depending on success
+        */
+       function default_page_handler($page, $handler) {
+               
                global $CONFIG;
                $script = "";
-               \r
-               $page = implode('/',$page);\r
-               if (($questionmark = strripos($page, '?')))\r
-                       $page = substr($page, 0, $questionmark);\r
-\r
-               $script = str_replace("..","",$script);\r
-               $callpath = $CONFIG->path . $handler . "/" . $page;\r
-               if (!file_exists($callpath) || is_dir($callpath) || substr_count($callpath,'.php') == 0) {\r
-                               if (substr($callpath,strlen($callpath) - 1, 1) != "/")\r
-                                       $callpath .= "/";\r
-                               $callpath .= "index.php";\r
-                               if (!include($callpath))\r
-                                       return false; \r
-               } else {\r
-                        include($callpath);\r
-               }\r
-               \r
-               return true;\r
-               \r
-       }\r
-\r
+               
+               $page = implode('/',$page);
+               if (($questionmark = strripos($page, '?')))
+                       $page = substr($page, 0, $questionmark);
+
+               $script = str_replace("..","",$script);
+               $callpath = $CONFIG->path . $handler . "/" . $page;
+               if (!file_exists($callpath) || is_dir($callpath) || substr_count($callpath,'.php') == 0) {
+                               if (substr($callpath,strlen($callpath) - 1, 1) != "/")
+                                       $callpath .= "/";
+                               $callpath .= "index.php";
+                               if (!include($callpath))
+                                       return false; 
+               } else {
+                        include($callpath);
+               }
+               
+               return true;
+               
+       }
+
 ?>
\ No newline at end of file
index 3737f42f47f33dd5ee288a87ec4c67cf13fc30bf..cc3e2e8a3a708d57ee224862dd1dae8b8024858a 100644 (file)
@@ -1,61 +1,61 @@
-<?php\r
-\r
-    /**\r
-        * Elgg page owner library\r
-        * Contains functions for managing page ownership\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+    /**
+        * Elgg page owner library
+        * Contains functions for managing page ownership
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+    /**
+     * Gets the page owner for the current page.
+     * @uses $CONFIG
+     * @return int|false The current page owner guid (0 if none).
+     */
+
+        function page_owner() {
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-    /**\r
-     * Gets the page owner for the current page.\r
-     * @uses $CONFIG\r
-     * @return int|false The current page owner guid (0 if none).\r
-     */\r
-\r
-        function page_owner() {\r
-\r
             global $CONFIG;
             
-            $returnval = NULL;\r
-            \r
-            $setpageowner = set_page_owner();\r
-            if ($setpageowner !== false) {\r
-               return $setpageowner;\r
-            }\r
-            \r
-               if ((!isset($returnval)) && ($username = get_input("username"))) {\r
-                       if (substr_count($username,'group:')) {\r
-                       preg_match('/group\:([0-9]+)/i',$username,$matches);\r
-                       $guid = $matches[1];\r
+            $returnval = NULL;
+            
+            $setpageowner = set_page_owner();
+            if ($setpageowner !== false) {
+               return $setpageowner;
+            }
+            
+               if ((!isset($returnval)) && ($username = get_input("username"))) {
+                       if (substr_count($username,'group:')) {
+                       preg_match('/group\:([0-9]+)/i',$username,$matches);
+                       $guid = $matches[1];
                        if ($entity = get_entity($guid)) {
-                               $returnval = $entity->getGUID();\r
-                       }\r
-                   }\r
-                   if ((!isset($returnval)) && ($user = get_user_by_username($username))) {\r
-                       $returnval = $user->getGUID();\r
-                   }\r
+                               $returnval = $entity->getGUID();
+                       }
+                   }
+                   if ((!isset($returnval)) && ($user = get_user_by_username($username))) {
+                       $returnval = $user->getGUID();
+                   }
                }
                
-               \r
-               if ((!isset($returnval)) && ($owner = get_input("owner_guid"))) {\r
-                   if ($user = get_entity($owner)) {\r
-                       $returnval = $user->getGUID();\r
-                   }\r
+               
+               if ((!isset($returnval)) && ($owner = get_input("owner_guid"))) {
+                   if ($user = get_entity($owner)) {
+                       $returnval = $user->getGUID();
+                   }
                }
                
-               \r
-            if ((!isset($returnval)) && (!empty($CONFIG->page_owner_handlers) && is_array($CONFIG->page_owner_handlers))) {\r
-                foreach($CONFIG->page_owner_handlers as $handler) {\r
-                    if ((!isset($returnval)) && ($guid = $handler())) {\r
-                        $returnval = $guid;\r
-                    }\r
-                }\r
+               
+            if ((!isset($returnval)) && (!empty($CONFIG->page_owner_handlers) && is_array($CONFIG->page_owner_handlers))) {
+                foreach($CONFIG->page_owner_handlers as $handler) {
+                    if ((!isset($returnval)) && ($guid = $handler())) {
+                        $returnval = $guid;
+                    }
+                }
             }
             
             if (isset($returnval)) {
                
                return $returnval;
             }
-            \r
-            return 0;\r
-            \r
-        }\r
-        \r
-       /**\r
-     * Gets the page owner for the current page.\r
-     * @uses $CONFIG\r
-     * @return ElggUser|false The current page owner (false if none).\r
-     */\r
-               function page_owner_entity() {\r
-\r
-            global $CONFIG;\r
-               $page_owner = page_owner();\r
-               if ($page_owner > 0)\r
-                       return get_entity($page_owner);\r
-                       \r
-                       return false;\r
-            //return new ElggDummy();\r
-        }\r
-        \r
-    /**\r
-     * Adds a page owner handler - a function that will\r
-     * return the page owner if required\r
-     * (Such functions are required to return false if they don't know)\r
-     * @uses $CONFIG\r
+            
+            return 0;
+            
+        }
+        
+       /**
+     * Gets the page owner for the current page.
+     * @uses $CONFIG
+     * @return ElggUser|false The current page owner (false if none).
+     */
+               function page_owner_entity() {
+
+            global $CONFIG;
+               $page_owner = page_owner();
+               if ($page_owner > 0)
+                       return get_entity($page_owner);
+                       
+                       return false;
+            //return new ElggDummy();
+        }
+        
+    /**
+     * Adds a page owner handler - a function that will
+     * return the page owner if required
+     * (Such functions are required to return false if they don't know)
+     * @uses $CONFIG
      * @param string $functionname The name of the function to call
-     * @return mixed The guid of the owner or false\r
-     */\r
-\r
-        function add_page_owner_handler($functionname) {\r
-            \r
-            global $CONFIG;\r
-            if (empty($CONFIG->page_owner_handlers)) {\r
-                $CONFIG->page_owner_handlers = array();\r
-            }\r
-            if (is_callable($functionname)) {\r
-                $CONFIG->page_owner_handlers[] = $functionname;\r
-            }\r
-            \r
-        }\r
-        \r
-       /**\r
-        * Allows a page to manually set a page owner\r
-        *\r
-        * @param int $entitytoset The GUID of the page owner\r
-        * @return int|false Either the page owner we've just set, or false if unset\r
-        */\r
-        function set_page_owner($entitytoset = -1) {\r
-               \r
-               static $entity;\r
-               \r
-               if (!isset($entity)) $entity = false;\r
-               \r
-               if ($entitytoset > -1) {\r
-                       $entity = $entitytoset;\r
-               }\r
-               \r
-               return $entity;\r
-               \r
-        }\r
-        \r
-       /**\r
-        * Sets the functional context of a page\r
-        *\r
-        * @param string $context The context of the page\r
-        * @return string|false Either the context string, or false on failure\r
-        */\r
-        function set_context($context) {\r
-               \r
-               global $CONFIG;\r
-               if (!empty($context)) {\r
-                       $context = trim($context);\r
-                       $context = strtolower($context);\r
-                       $CONFIG->context = $context;\r
-                       return $context;\r
-               } else {\r
-                       return false;\r
-               }\r
-                       \r
-        }\r
-        \r
-       /**\r
-        * Returns the functional context of a page\r
-        *\r
-        * @return string The context, or 'main' if no context has been provided\r
-        */\r
-        function get_context() {\r
-               \r
-               global $CONFIG;\r
-               if (isset($CONFIG->context) && !empty($CONFIG->context)) {\r
-                       return $CONFIG->context;\r
-               }\r
-               if ($context = get_plugin_name(true)) {\r
-                       return $context;\r
-               }\r
-               return "main";\r
-               \r
-        }\r
-        \r
-        if (defined('context')) {\r
-               global $CONFIG;\r
-               $CONFIG->context = context;\r
-        }\r
-        \r
+     * @return mixed The guid of the owner or false
+     */
+
+        function add_page_owner_handler($functionname) {
+            
+            global $CONFIG;
+            if (empty($CONFIG->page_owner_handlers)) {
+                $CONFIG->page_owner_handlers = array();
+            }
+            if (is_callable($functionname)) {
+                $CONFIG->page_owner_handlers[] = $functionname;
+            }
+            
+        }
+        
+       /**
+        * Allows a page to manually set a page owner
+        *
+        * @param int $entitytoset The GUID of the page owner
+        * @return int|false Either the page owner we've just set, or false if unset
+        */
+        function set_page_owner($entitytoset = -1) {
+               
+               static $entity;
+               
+               if (!isset($entity)) $entity = false;
+               
+               if ($entitytoset > -1) {
+                       $entity = $entitytoset;
+               }
+               
+               return $entity;
+               
+        }
+        
+       /**
+        * Sets the functional context of a page
+        *
+        * @param string $context The context of the page
+        * @return string|false Either the context string, or false on failure
+        */
+        function set_context($context) {
+               
+               global $CONFIG;
+               if (!empty($context)) {
+                       $context = trim($context);
+                       $context = strtolower($context);
+                       $CONFIG->context = $context;
+                       return $context;
+               } else {
+                       return false;
+               }
+                       
+        }
+        
+       /**
+        * Returns the functional context of a page
+        *
+        * @return string The context, or 'main' if no context has been provided
+        */
+        function get_context() {
+               
+               global $CONFIG;
+               if (isset($CONFIG->context) && !empty($CONFIG->context)) {
+                       return $CONFIG->context;
+               }
+               if ($context = get_plugin_name(true)) {
+                       return $context;
+               }
+               return "main";
+               
+        }
+        
+        if (defined('context')) {
+               global $CONFIG;
+               $CONFIG->context = context;
+        }
+        
 ?>
\ No newline at end of file
index 255a10089127f98e677fb6d9dc3a6da4084f3bb3..efebb45ecb3414d9cf50c045f07c975313b27c11 100644 (file)
@@ -1,16 +1,16 @@
-<?php\r
-\r
-       /**\r
-        * Elgg PAM library\r
-        * Contains functions for managing authentication using various arbitrary methods\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg PAM library
+        * Contains functions for managing authentication using various arbitrary methods
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
 
        $_PAM_HANDLERS = array();
        $_PAM_HANDLERS_MSG = array();
@@ -91,5 +91,5 @@
                
                return $authenticated;
        }
-       \r
+       
 ?>
\ No newline at end of file
index 4f8cd8bbeafc23091fb50f2201b0612e250a268b..1fcd2d1381a10da4146c3e8386b51e1f02002818 100644 (file)
-<?php\r
-\r
-               /**\r
-                * Elgg plugins library\r
-                * Contains functions for managing plugins\r
-                * \r
-                * @package Elgg\r
-                * @subpackage Core\r
+<?php
 
-                * @author Curverider Ltd\r
+               /**
+                * Elgg plugins library
+                * Contains functions for managing plugins
+                * 
+                * @package Elgg
+                * @subpackage Core
+
+                * @author Curverider Ltd
+
+                * @link http://elgg.org/
+                */
+
+               
+               /// Cache enabled plugins per page
+               $ENABLED_PLUGINS_CACHE = NULL;
+
+               /**
+                * PluginException
+                *  
+                * A plugin Exception, thrown when an Exception occurs relating to the plugin mechanism. Subclass for specific plugin Exceptions.
+                * 
+                * @package Elgg
+                * @subpackage Exceptions
+                */
+               class PluginException extends Exception {}
+               
+               /**
+                * @class ElggPlugin Object representing a plugin's settings for a given site.
+                * This class is currently a stub, allowing a plugin to saving settings in an object's metadata for each site.
+                * @author Curverider Ltd
+                */
+               class ElggPlugin extends ElggObject
+               {
+                       protected function initialise_attributes()
+                       {
+                               parent::initialise_attributes();
+                               
+                               $this->attributes['subtype'] = "plugin";
+                       }
+                       
+                       public function __construct($guid = null) 
+                       {                       
+                               parent::__construct($guid);
+                       }
+                       
+                       /**
+                        * Override entity get and sets in order to save data to private data store.
+                        */
+                       public function get($name)
+                       {
+                               // See if its in our base attribute
+                               if (isset($this->attributes[$name])) {
+                                       return $this->attributes[$name];
+                               }
+                               
+                               // No, so see if its in the private data store.
+                               $meta = get_private_setting($this->guid, $name);
+                               if ($meta)
+                                       return $meta;
+                               
+                               // Can't find it, so return null
+                               return null;
+                       }
+
+                       /**
+                        * Override entity get and sets in order to save data to private data store.
+                        */
+                       public function set($name, $value)
+                       {
+                               if (array_key_exists($name, $this->attributes))
+                               {
+                                       // Check that we're not trying to change the guid! 
+                                       if ((array_key_exists('guid', $this->attributes)) && ($name=='guid'))
+                                               return false;
+                                               
+                                       $this->attributes[$name] = $value;
+                               }
+                               else 
+                                       return set_private_setting($this->guid, $name, $value);
+                       
+                               return true;
+                       }
+               }
+               
+               /**
+                * Returns a list of plugins to load, in the order that they should be loaded.
+                *
+                * @return array List of plugins
+                */
+               function get_plugin_list() {
 
-                * @link http://elgg.org/\r
-                */\r
-\r
-               \r
-               /// Cache enabled plugins per page\r
-               $ENABLED_PLUGINS_CACHE = NULL;\r
-\r
-               /**\r
-                * PluginException\r
-                *  \r
-                * A plugin Exception, thrown when an Exception occurs relating to the plugin mechanism. Subclass for specific plugin Exceptions.\r
-                * \r
-                * @package Elgg\r
-                * @subpackage Exceptions\r
-                */\r
-               class PluginException extends Exception {}\r
-               \r
-               /**\r
-                * @class ElggPlugin Object representing a plugin's settings for a given site.\r
-                * This class is currently a stub, allowing a plugin to saving settings in an object's metadata for each site.\r
-                * @author Curverider Ltd\r
-                */\r
-               class ElggPlugin extends ElggObject\r
-               {\r
-                       protected function initialise_attributes()\r
-                       {\r
-                               parent::initialise_attributes();\r
-                               \r
-                               $this->attributes['subtype'] = "plugin";\r
-                       }\r
-                       \r
-                       public function __construct($guid = null) \r
-                       {                       \r
-                               parent::__construct($guid);\r
-                       }\r
-                       \r
-                       /**\r
-                        * Override entity get and sets in order to save data to private data store.\r
-                        */\r
-                       public function get($name)\r
-                       {\r
-                               // See if its in our base attribute\r
-                               if (isset($this->attributes[$name])) {\r
-                                       return $this->attributes[$name];\r
-                               }\r
-                               \r
-                               // No, so see if its in the private data store.\r
-                               $meta = get_private_setting($this->guid, $name);\r
-                               if ($meta)\r
-                                       return $meta;\r
-                               \r
-                               // Can't find it, so return null\r
-                               return null;\r
-                       }\r
-\r
-                       /**\r
-                        * Override entity get and sets in order to save data to private data store.\r
-                        */\r
-                       public function set($name, $value)\r
-                       {\r
-                               if (array_key_exists($name, $this->attributes))\r
-                               {\r
-                                       // Check that we're not trying to change the guid! \r
-                                       if ((array_key_exists('guid', $this->attributes)) && ($name=='guid'))\r
-                                               return false;\r
-                                               \r
-                                       $this->attributes[$name] = $value;\r
-                               }\r
-                               else \r
-                                       return set_private_setting($this->guid, $name, $value);\r
-                       \r
-                               return true;\r
-                       }\r
-               }\r
-               \r
-               /**\r
-                * Returns a list of plugins to load, in the order that they should be loaded.\r
-                *\r
-                * @return array List of plugins\r
-                */\r
-               function get_plugin_list() {\r
-\r
-                       global $CONFIG;\r
-                       \r
-                       if (!empty($CONFIG->pluginlistcache))\r
-                               return $CONFIG->pluginlistcache;\r
-                       \r
-                       if ($site = get_entity($CONFIG->site_guid)) {\r
-                               \r
-                               $pluginorder = $site->pluginorder;\r
-                               if (!empty($pluginorder)) {\r
-                                       \r
-                                       $plugins = unserialize($pluginorder);\r
-                                       \r
-                                       $CONFIG->pluginlistcache = $plugins;\r
-                                       return $plugins;\r
-                                       \r
-                               } else {\r
-                                       \r
-                                       $plugins = array();\r
-                                               \r
-                                       if ($handle = opendir($CONFIG->pluginspath)) {\r
-                                               while ($mod = readdir($handle)) {\r
-                                                       if (!in_array($mod,array('.','..','.svn','CVS')) && is_dir($CONFIG->pluginspath . "/" . $mod)) {\r
-                                                               $plugins[] = $mod;\r
-                                                       }\r
-                                               }\r
-                                       }\r
-                                               \r
-                                       sort($plugins);\r
-                                       \r
-                                       $CONFIG->pluginlistcache = $plugins;\r
-                                       return $plugins;\r
-                                       \r
-                               }\r
-                               \r
-                       }\r
-                       \r
-                       return false;\r
-                       \r
-               }\r
-               \r
-               /**\r
+                       global $CONFIG;
+                       
+                       if (!empty($CONFIG->pluginlistcache))
+                               return $CONFIG->pluginlistcache;
+                       
+                       if ($site = get_entity($CONFIG->site_guid)) {
+                               
+                               $pluginorder = $site->pluginorder;
+                               if (!empty($pluginorder)) {
+                                       
+                                       $plugins = unserialize($pluginorder);
+                                       
+                                       $CONFIG->pluginlistcache = $plugins;
+                                       return $plugins;
+                                       
+                               } else {
+                                       
+                                       $plugins = array();
+                                               
+                                       if ($handle = opendir($CONFIG->pluginspath)) {
+                                               while ($mod = readdir($handle)) {
+                                                       if (!in_array($mod,array('.','..','.svn','CVS')) && is_dir($CONFIG->pluginspath . "/" . $mod)) {
+                                                               $plugins[] = $mod;
+                                                       }
+                                               }
+                                       }
+                                               
+                                       sort($plugins);
+                                       
+                                       $CONFIG->pluginlistcache = $plugins;
+                                       return $plugins;
+                                       
+                               }
+                               
+                       }
+                       
+                       return false;
+                       
+               }
+               
+               /**
                 * Regenerates the list of known plugins and saves it to the current site
                 * 
                 * Important: You should regenerate simplecache and the viewpath cache after executing this function
                 * otherwise you may experience view display artifacts. Do this with the following code:
                 * 
                 *              elgg_view_regenerate_simplecache();
-                *              elgg_filepath_cache_reset();\r
-                *\r
-                * @param array $pluginorder Optionally, a list of existing plugins and their orders\r
-                * @return array The new list of plugins and their orders\r
-                */\r
-               function regenerate_plugin_list($pluginorder = false) {\r
-                       \r
-                       global $CONFIG;\r
-                       \r
-                       $CONFIG->pluginlistcache = null;\r
-                       \r
-                       if ($site = get_entity($CONFIG->site_guid)) {\r
-                               \r
-                               if (empty($pluginorder)) {\r
-                                       $pluginorder = $site->pluginorder;\r
-                                       $pluginorder = unserialize($pluginorder);\r
-                               } else {\r
-                                       ksort($pluginorder);\r
-                               }\r
-\r
-                               if (empty($pluginorder)) {\r
-                                       $pluginorder = array();\r
-                               }\r
-                               \r
-                               $max = 0;\r
-                               if (sizeof($pluginorder))\r
-                                       foreach($pluginorder as $key => $plugin) {\r
-                                               if (is_dir($CONFIG->pluginspath . "/" . $plugin)) { \r
-                                                       if ($key > $max)\r
-                                                               $max = $key;\r
-                                               } else {\r
-                                                       unset($pluginorder[$key]);\r
-                                               }\r
-                                       }\r
-                                       \r
-                               // Add new plugins to the end\r
-                               if ($handle = opendir($CONFIG->pluginspath)) {\r
-                                       while ($mod = readdir($handle)) {\r
-                                               if (!in_array($mod,array('.','..','.svn','CVS')) && is_dir($CONFIG->pluginspath . "/" . $mod)) {\r
-                                                       if (!in_array($mod, $pluginorder)) {\r
-                                                               $max = $max + 10;\r
-                                                               $pluginorder[$max] = $mod;\r
-                                                       }\r
-                                               }\r
-                                       }\r
-                               }\r
-                               \r
-                               ksort($pluginorder);\r
-                               \r
-                               // Now reorder the keys ..\r
-                               $key = 10;\r
-                               $plugins = array();\r
-                               if (sizeof($pluginorder))\r
-                                       foreach($pluginorder as $plugin) {\r
-                                               $plugins[$key] = $plugin;\r
-                                               $key = $key + 10;\r
-                                       }\r
-                               \r
-                               $plugins = serialize($plugins);\r
-                               \r
+                *              elgg_filepath_cache_reset();
+                *
+                * @param array $pluginorder Optionally, a list of existing plugins and their orders
+                * @return array The new list of plugins and their orders
+                */
+               function regenerate_plugin_list($pluginorder = false) {
+                       
+                       global $CONFIG;
+                       
+                       $CONFIG->pluginlistcache = null;
+                       
+                       if ($site = get_entity($CONFIG->site_guid)) {
+                               
+                               if (empty($pluginorder)) {
+                                       $pluginorder = $site->pluginorder;
+                                       $pluginorder = unserialize($pluginorder);
+                               } else {
+                                       ksort($pluginorder);
+                               }
+
+                               if (empty($pluginorder)) {
+                                       $pluginorder = array();
+                               }
+                               
+                               $max = 0;
+                               if (sizeof($pluginorder))
+                                       foreach($pluginorder as $key => $plugin) {
+                                               if (is_dir($CONFIG->pluginspath . "/" . $plugin)) { 
+                                                       if ($key > $max)
+                                                               $max = $key;
+                                               } else {
+                                                       unset($pluginorder[$key]);
+                                               }
+                                       }
+                                       
+                               // Add new plugins to the end
+                               if ($handle = opendir($CONFIG->pluginspath)) {
+                                       while ($mod = readdir($handle)) {
+                                               if (!in_array($mod,array('.','..','.svn','CVS')) && is_dir($CONFIG->pluginspath . "/" . $mod)) {
+                                                       if (!in_array($mod, $pluginorder)) {
+                                                               $max = $max + 10;
+                                                               $pluginorder[$max] = $mod;
+                                                       }
+                                               }
+                                       }
+                               }
+                               
+                               ksort($pluginorder);
+                               
+                               // Now reorder the keys ..
+                               $key = 10;
+                               $plugins = array();
+                               if (sizeof($pluginorder))
+                                       foreach($pluginorder as $plugin) {
+                                               $plugins[$key] = $plugin;
+                                               $key = $key + 10;
+                                       }
+                               
+                               $plugins = serialize($plugins);
+                               
                                $site->pluginorder = $plugins;
                                
                                // Regenerate caches
                                elgg_view_regenerate_simplecache();
-                               elgg_filepath_cache_reset();\r
-                               \r
-                               return $plugins;\r
-                                       \r
-                       }\r
-                       \r
-                       return false;\r
-                       \r
-               }\r
-               \r
-\r
-               /**\r
-                * For now, loads plugins directly\r
-                *\r
-                * @todo Add proper plugin handler that launches plugins in an admin-defined order and activates them on admin request\r
-                * @package Elgg\r
-                * @subpackage Core\r
-                */\r
+                               elgg_filepath_cache_reset();
+                               
+                               return $plugins;
+                                       
+                       }
+                       
+                       return false;
+                       
+               }
+               
+
+               /**
+                * For now, loads plugins directly
+                *
+                * @todo Add proper plugin handler that launches plugins in an admin-defined order and activates them on admin request
+                * @package Elgg
+                * @subpackage Core
+                */
                function load_plugins() {
-                       \r
+                       
                        global $CONFIG;
-                       \r
+                       
                        if (!empty($CONFIG->pluginspath)) {
                                
                                // See if we have cached values for things
                                $cached_view_paths = elgg_filepath_cache_load();
                                if ($cached_view_paths) $CONFIG->views = unserialize($cached_view_paths);
-                               \r
-                               // temporary disable all plugins if there is a file called 'disabled' in the plugin dir\r
-                               if (file_exists($CONFIG->pluginspath . "disabled"))\r
-                                       return;\r
-                               \r
-                               $plugins = get_plugin_list();\r
-                               \r
+                               
+                               // temporary disable all plugins if there is a file called 'disabled' in the plugin dir
+                               if (file_exists($CONFIG->pluginspath . "disabled"))
+                                       return;
+                               
+                               $plugins = get_plugin_list();
+                               
                                if (sizeof($plugins))
-                               {\r
-                                       foreach($plugins as $mod) {\r
-                                               if (is_plugin_enabled($mod)) {\r
-                                                       if (file_exists($CONFIG->pluginspath . $mod)) {\r
-                                                               if (!include($CONFIG->pluginspath . $mod . "/start.php"))\r
+                               {
+                                       foreach($plugins as $mod) {
+                                               if (is_plugin_enabled($mod)) {
+                                                       if (file_exists($CONFIG->pluginspath . $mod)) {
+                                                               if (!include($CONFIG->pluginspath . $mod . "/start.php"))
                                                                        throw new PluginException(sprintf(elgg_echo('PluginException:MisconfiguredPlugin'), $mod));
                                                                        
                                                                if (!$cached_view_paths)
-                                                               {\r
-                                                                       if (is_dir($CONFIG->pluginspath . $mod . "/views")) {\r
-                                                                               if ($handle = opendir($CONFIG->pluginspath . $mod . "/views")) {\r
-                                                                                       while ($viewtype = readdir($handle)) {\r
-                                                                                               if (!in_array($viewtype,array('.','..','.svn','CVS')) && is_dir($CONFIG->pluginspath . $mod . "/views/" . $viewtype)) {\r
-                                                                                                       autoregister_views("",$CONFIG->pluginspath . $mod . "/views/" . $viewtype,$CONFIG->pluginspath . $mod . "/views/", $viewtype);\r
-                                                                                               }\r
-                                                                                       }\r
-                                                                               }\r
+                                                               {
+                                                                       if (is_dir($CONFIG->pluginspath . $mod . "/views")) {
+                                                                               if ($handle = opendir($CONFIG->pluginspath . $mod . "/views")) {
+                                                                                       while ($viewtype = readdir($handle)) {
+                                                                                               if (!in_array($viewtype,array('.','..','.svn','CVS')) && is_dir($CONFIG->pluginspath . $mod . "/views/" . $viewtype)) {
+                                                                                                       autoregister_views("",$CONFIG->pluginspath . $mod . "/views/" . $viewtype,$CONFIG->pluginspath . $mod . "/views/", $viewtype);
+                                                                                               }
+                                                                                       }
+                                                                               }
                                                                        }
                                                                }
-                                                               \r
-                                                               if (is_dir($CONFIG->pluginspath . $mod . "/languages")) {\r
-                                                                       register_translations($CONFIG->pluginspath . $mod . "/languages/");\r
-                                                               }\r
-                                                       }\r
-                                               }\r
-                                       }\r
+                                                               
+                                                               if (is_dir($CONFIG->pluginspath . $mod . "/languages")) {
+                                                                       register_translations($CONFIG->pluginspath . $mod . "/languages/");
+                                                               }
+                                                       }
+                                               }
+                                       }
                                }
 
                                // Cache results
                                if (!$cached_view_paths)
                                        elgg_filepath_cache_save(serialize($CONFIG->views));
-                       }\r
-                       \r
-               }\r
-               \r
-               /**\r
-                * Get the name of the most recent plugin to be called in the call stack (or the plugin that owns the current page, if any).\r
-                * \r
-                * i.e., if the last plugin was in /mod/foobar/, get_plugin_name would return foo_bar.\r
-                *\r
-                * @param boolean $mainfilename If set to true, this will instead determine the context from the main script filename called by the browser. Default = false. \r
-                * @return string|false Plugin name, or false if no plugin name was called\r
-                */\r
-               function get_plugin_name($mainfilename = false) {\r
-                       if (!$mainfilename) {\r
-                               if ($backtrace = debug_backtrace()) { \r
-                                       foreach($backtrace as $step) {\r
-                                               $file = $step['file'];\r
-                                               $file = str_replace("\\","/",$file);\r
-                                               $file = str_replace("//","/",$file);\r
-                                               if (preg_match("/mod\/([a-zA-Z0-9\-\_]*)\/start\.php$/",$file,$matches)) {\r
-                                                       return $matches[1];\r
-                                               }\r
-                                       }\r
-                               }\r
-                       } else {\r
-                               //if (substr_count($file,'handlers/pagehandler')) {\r
-                               if (preg_match("/pg\/([a-zA-Z0-9\-\_]*)\//",$_SERVER['REQUEST_URI'],$matches)) {\r
-                                       return $matches[1];\r
-                               } else {\r
-                                       $file = $_SERVER["SCRIPT_NAME"];\r
-                                       $file = str_replace("\\","/",$file);\r
-                                       $file = str_replace("//","/",$file);\r
-                                       if (preg_match("/mod\/([a-zA-Z0-9\-\_]*)\//",$file,$matches)) {\r
-                                               return $matches[1];\r
-                                       }\r
-                               }\r
-                       }\r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * Load and parse a plugin manifest from a plugin XML file.\r
-                * \r
-                * Example file:\r
-                * \r
-                * <plugin_manifest>\r
-                *      <field key="author" value="Curverider Ltd" />\r
-                *  <field key="version" value="1.0" />\r
-                *      <field key="description" value="My plugin description, keep it short" />\r
-                *  <field key="website" value="http://www.elgg.org/" />\r
-                *  <field key="copyright" value="(C) Curverider 2008-2009" />\r
-                *  <field key="licence" value="GNU Public License version 2" />\r
-                * </plugin_manifest>\r
-                *\r
-                * @param string $plugin Plugin name.\r
-                * @return array of values\r
-                */\r
-               function load_plugin_manifest($plugin)\r
-               {\r
-                       global $CONFIG;\r
-                       \r
-                       $xml = xml_2_object(file_get_contents($CONFIG->pluginspath . $plugin. "/manifest.xml"));\r
-                       \r
-                       if ($xml)\r
-                       {\r
-                               $elements = array();\r
-                               \r
-                               foreach ($xml->children as $element)\r
-                               {\r
-                                       $key = $element->attributes['key'];\r
-                                       $value = $element->attributes['value'];\r
-                                       \r
-                                       $elements[$key] = $value;\r
-                               }\r
-                               \r
-                               return $elements;\r
-                       }\r
-                       \r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * This function checks a plugin manifest 'elgg_version' value against the current install\r
-                * returning TRUE if the elgg_version is <= the current install's version.\r
-                * @param $manifest_elgg_version_string The build version (eg 2009010201). \r
-                * @return bool\r
-                */\r
-               function check_plugin_compatibility($manifest_elgg_version_string)\r
-               {\r
-                       $version = get_version();\r
-                       \r
-                       if (strpos($manifest_elgg_version_string, '.')===false)\r
-                       {\r
-                               // Using version\r
-                               $req_version = (int)$manifest_elgg_version_string;\r
-                               \r
-                               return ($version >= $req_version);\r
-                       }\r
-                       \r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * Shorthand function for finding the plugin settings.\r
-                * \r
-                * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you\r
-                *                                                              are calling from.\r
-                */\r
-               function find_plugin_settings($plugin_name = "")\r
-               {\r
-                       $plugins = get_entities('object', 'plugin', 0, "", 9999);\r
-                       $plugin_name = sanitise_string($plugin_name);\r
-                       if (!$plugin_name)\r
-                               $plugin_name = get_plugin_name();\r
-       \r
-                       if ($plugins)\r
-                       {\r
-                               foreach ($plugins as $plugin)                   \r
-                                       if (strcmp($plugin->title, $plugin_name)==0)\r
-                                               return $plugin;\r
-                       }\r
-                       \r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * Find the plugin settings for a user.\r
-                *\r
-                * @param string $plugin_name Plugin name.\r
-                * @param int $user_guid The guid who's settings to retrieve.\r
-                * @return array of settings in an associative array minus prefix.\r
-                */\r
-               function find_plugin_usersettings($plugin_name = "", $user_guid = 0)\r
-               {\r
-                       $plugin_name = sanitise_string($plugin_name);\r
-                       $user_guid = (int)$user_guid;\r
-                       \r
-                       if (!$plugin_name)\r
-                               $plugin_name = get_plugin_name();\r
-                               \r
-                       if ($user_guid == 0) $user_guid = get_loggedin_userid();\r
-                       \r
-                       // Get metadata for user\r
-                       $all_metadata = get_all_private_settings($user_guid); //get_metadata_for_entity($user_guid);\r
-                       if ($all_metadata)\r
-                       {\r
-                               $prefix = "plugin:settings:$plugin_name:";\r
-                               $return = new stdClass;\r
-                               \r
-                               foreach ($all_metadata as $key => $meta)\r
-                               {\r
-                                       $name = substr($key, strlen($prefix));\r
-                                       $value = $meta;\r
-                                       \r
-                                       if (strpos($key, $prefix) === 0)\r
-                                               $return->$name = $value;\r
-                               }\r
-\r
-                               return $return;                 \r
-                       }\r
-                       \r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * Set a user specific setting for a plugin.\r
-                *\r
-                * @param string $name The name - note, can't be "title".\r
-                * @param mixed $value The value.\r
-                * @param int $user_guid Optional user.\r
-                * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from.\r
-                */\r
-               function set_plugin_usersetting($name, $value, $user_guid = 0, $plugin_name = "")\r
-               {\r
-                       $plugin_name = sanitise_string($plugin_name);\r
-                       $user_guid = (int)$user_guid;\r
-                       $name = sanitise_string($name);\r
-                       \r
-                       if (!$plugin_name)\r
-                               $plugin_name = get_plugin_name();\r
-                                                       \r
-                       $user = get_entity($user_guid);\r
-                       if (!$user) $user = get_loggedin_user();\r
-                       \r
-                       if (($user) && ($user instanceof ElggUser))\r
-                       {\r
-                               $prefix = "plugin:settings:$plugin_name:$name";\r
-                               //$user->$prefix = $value;\r
-                               //$user->save();\r
-                               \r
-                               // Hook to validate setting\r
-                               $value = trigger_plugin_hook('plugin:usersetting', 'user', array(\r
-                                       'user' => $user,\r
-                                       'plugin' => $plugin_name,\r
-                                       'name' => $name,\r
-                                       'value' => $value\r
-                               ), $value);\r
-                                       \r
-                               return set_private_setting($user->guid, $prefix, $value);\r
-                       }\r
-                       \r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * Get a user specific setting for a plugin.\r
-                *\r
-                * @param string $name The name.\r
-                * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from.\r
-                */\r
-               function get_plugin_usersetting($name, $user_guid = 0, $plugin_name = "")\r
-               {\r
-                       $plugin_name = sanitise_string($plugin_name);\r
-                       $user_guid = (int)$user_guid;\r
-                       $name = sanitise_string($name);\r
-                       \r
-                       if (!$plugin_name)\r
-                               $plugin_name = get_plugin_name();\r
-                               \r
-                       $user = get_entity($user_guid);\r
-                       if (!$user) $user = get_loggedin_user();\r
-                       \r
-                       if (($user) && ($user instanceof ElggUser))\r
-                       {\r
-                               $prefix = "plugin:settings:$plugin_name:$name";\r
-                               return get_private_setting($user->guid, $prefix); //$user->$prefix;\r
-                       }\r
-                       \r
-                       return false;\r
-               }\r
-                       \r
-               /**\r
-                * Set a setting for a plugin.\r
-                *\r
-                * @param string $name The name - note, can't be "title".\r
-                * @param mixed $value The value.\r
-                * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from.\r
-                */\r
-               function set_plugin_setting($name, $value, $plugin_name = "")\r
-               {       \r
-                       if (!$plugin_name) $plugin_name = get_plugin_name();    \r
-                       $plugin = find_plugin_settings($plugin_name);\r
-                       \r
-                       if (!$plugin) \r
-                               $plugin = new ElggPlugin();\r
-                               \r
-                       if ($name!='title') \r
-                       {\r
-                               // Hook to validate setting\r
-                               $value = trigger_plugin_hook('plugin:setting', 'plugin', array(\r
-                                       'plugin' => $plugin_name,\r
-                                       'name' => $name,\r
-                                       'value' => $value\r
-                               ), $value);\r
-                               \r
-                               $plugin->title = $plugin_name;\r
-                               $plugin->access_id = ACCESS_PUBLIC;\r
-                               $plugin->save();\r
-                               $plugin->$name = $value;\r
-                               \r
-                               return $plugin->getGUID();\r
-                       }\r
-                       \r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * Get setting for a plugin.\r
-                *\r
-                * @param string $name The name.\r
-                * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from.\r
-                */\r
-               function get_plugin_setting($name, $plugin_name = "")\r
-               {\r
-                       $plugin = find_plugin_settings($plugin_name);\r
-               \r
-                       if ($plugin)\r
-                               return $plugin->$name;\r
-                       \r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * Clear a plugin setting.\r
-                *\r
-                * @param string $name The name.\r
-                * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from.\r
-                */\r
-               function clear_plugin_setting($name, $plugin_name = "")\r
-               {\r
-                       $plugin = find_plugin_settings($plugin_name);\r
-                       \r
-                       if ($plugin)\r
-                               return remove_all_private_settings($plugin->guid); //$plugin->clearMetaData($name);\r
-                       \r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * Return an array of installed plugins.\r
-                */\r
-               function get_installed_plugins()\r
-               {\r
-                       global $CONFIG;\r
-                       \r
-                       $installed_plugins = array();\r
-                       \r
-                       if (!empty($CONFIG->pluginspath)) {\r
-                               \r
-                               $plugins = get_plugin_list();\r
-                               \r
-                               foreach($plugins as $mod) {\r
-                                       $installed_plugins[$mod] = array();\r
-                                       $installed_plugins[$mod]['active'] = is_plugin_enabled($mod);\r
-                                       $installed_plugins[$mod]['manifest'] = load_plugin_manifest($mod);\r
-                               }\r
-                               \r
-                       }\r
-                       \r
-                       return $installed_plugins;\r
-               }\r
-               \r
-               /**\r
+                       }
+                       
+               }
+               
+               /**
+                * Get the name of the most recent plugin to be called in the call stack (or the plugin that owns the current page, if any).
+                * 
+                * i.e., if the last plugin was in /mod/foobar/, get_plugin_name would return foo_bar.
+                *
+                * @param boolean $mainfilename If set to true, this will instead determine the context from the main script filename called by the browser. Default = false. 
+                * @return string|false Plugin name, or false if no plugin name was called
+                */
+               function get_plugin_name($mainfilename = false) {
+                       if (!$mainfilename) {
+                               if ($backtrace = debug_backtrace()) { 
+                                       foreach($backtrace as $step) {
+                                               $file = $step['file'];
+                                               $file = str_replace("\\","/",$file);
+                                               $file = str_replace("//","/",$file);
+                                               if (preg_match("/mod\/([a-zA-Z0-9\-\_]*)\/start\.php$/",$file,$matches)) {
+                                                       return $matches[1];
+                                               }
+                                       }
+                               }
+                       } else {
+                               //if (substr_count($file,'handlers/pagehandler')) {
+                               if (preg_match("/pg\/([a-zA-Z0-9\-\_]*)\//",$_SERVER['REQUEST_URI'],$matches)) {
+                                       return $matches[1];
+                               } else {
+                                       $file = $_SERVER["SCRIPT_NAME"];
+                                       $file = str_replace("\\","/",$file);
+                                       $file = str_replace("//","/",$file);
+                                       if (preg_match("/mod\/([a-zA-Z0-9\-\_]*)\//",$file,$matches)) {
+                                               return $matches[1];
+                                       }
+                               }
+                       }
+                       return false;
+               }
+               
+               /**
+                * Load and parse a plugin manifest from a plugin XML file.
+                * 
+                * Example file:
+                * 
+                * <plugin_manifest>
+                *      <field key="author" value="Curverider Ltd" />
+                *  <field key="version" value="1.0" />
+                *      <field key="description" value="My plugin description, keep it short" />
+                *  <field key="website" value="http://www.elgg.org/" />
+                *  <field key="copyright" value="(C) Curverider 2008-2009" />
+                *  <field key="licence" value="GNU Public License version 2" />
+                * </plugin_manifest>
+                *
+                * @param string $plugin Plugin name.
+                * @return array of values
+                */
+               function load_plugin_manifest($plugin)
+               {
+                       global $CONFIG;
+                       
+                       $xml = xml_2_object(file_get_contents($CONFIG->pluginspath . $plugin. "/manifest.xml"));
+                       
+                       if ($xml)
+                       {
+                               $elements = array();
+                               
+                               foreach ($xml->children as $element)
+                               {
+                                       $key = $element->attributes['key'];
+                                       $value = $element->attributes['value'];
+                                       
+                                       $elements[$key] = $value;
+                               }
+                               
+                               return $elements;
+                       }
+                       
+                       return false;
+               }
+               
+               /**
+                * This function checks a plugin manifest 'elgg_version' value against the current install
+                * returning TRUE if the elgg_version is <= the current install's version.
+                * @param $manifest_elgg_version_string The build version (eg 2009010201). 
+                * @return bool
+                */
+               function check_plugin_compatibility($manifest_elgg_version_string)
+               {
+                       $version = get_version();
+                       
+                       if (strpos($manifest_elgg_version_string, '.')===false)
+                       {
+                               // Using version
+                               $req_version = (int)$manifest_elgg_version_string;
+                               
+                               return ($version >= $req_version);
+                       }
+                       
+                       return false;
+               }
+               
+               /**
+                * Shorthand function for finding the plugin settings.
+                * 
+                * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you
+                *                                                              are calling from.
+                */
+               function find_plugin_settings($plugin_name = "")
+               {
+                       $plugins = get_entities('object', 'plugin', 0, "", 9999);
+                       $plugin_name = sanitise_string($plugin_name);
+                       if (!$plugin_name)
+                               $plugin_name = get_plugin_name();
+       
+                       if ($plugins)
+                       {
+                               foreach ($plugins as $plugin)                   
+                                       if (strcmp($plugin->title, $plugin_name)==0)
+                                               return $plugin;
+                       }
+                       
+                       return false;
+               }
+               
+               /**
+                * Find the plugin settings for a user.
+                *
+                * @param string $plugin_name Plugin name.
+                * @param int $user_guid The guid who's settings to retrieve.
+                * @return array of settings in an associative array minus prefix.
+                */
+               function find_plugin_usersettings($plugin_name = "", $user_guid = 0)
+               {
+                       $plugin_name = sanitise_string($plugin_name);
+                       $user_guid = (int)$user_guid;
+                       
+                       if (!$plugin_name)
+                               $plugin_name = get_plugin_name();
+                               
+                       if ($user_guid == 0) $user_guid = get_loggedin_userid();
+                       
+                       // Get metadata for user
+                       $all_metadata = get_all_private_settings($user_guid); //get_metadata_for_entity($user_guid);
+                       if ($all_metadata)
+                       {
+                               $prefix = "plugin:settings:$plugin_name:";
+                               $return = new stdClass;
+                               
+                               foreach ($all_metadata as $key => $meta)
+                               {
+                                       $name = substr($key, strlen($prefix));
+                                       $value = $meta;
+                                       
+                                       if (strpos($key, $prefix) === 0)
+                                               $return->$name = $value;
+                               }
+
+                               return $return;                 
+                       }
+                       
+                       return false;
+               }
+               
+               /**
+                * Set a user specific setting for a plugin.
+                *
+                * @param string $name The name - note, can't be "title".
+                * @param mixed $value The value.
+                * @param int $user_guid Optional user.
+                * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from.
+                */
+               function set_plugin_usersetting($name, $value, $user_guid = 0, $plugin_name = "")
+               {
+                       $plugin_name = sanitise_string($plugin_name);
+                       $user_guid = (int)$user_guid;
+                       $name = sanitise_string($name);
+                       
+                       if (!$plugin_name)
+                               $plugin_name = get_plugin_name();
+                                                       
+                       $user = get_entity($user_guid);
+                       if (!$user) $user = get_loggedin_user();
+                       
+                       if (($user) && ($user instanceof ElggUser))
+                       {
+                               $prefix = "plugin:settings:$plugin_name:$name";
+                               //$user->$prefix = $value;
+                               //$user->save();
+                               
+                               // Hook to validate setting
+                               $value = trigger_plugin_hook('plugin:usersetting', 'user', array(
+                                       'user' => $user,
+                                       'plugin' => $plugin_name,
+                                       'name' => $name,
+                                       'value' => $value
+                               ), $value);
+                                       
+                               return set_private_setting($user->guid, $prefix, $value);
+                       }
+                       
+                       return false;
+               }
+               
+               /**
+                * Get a user specific setting for a plugin.
+                *
+                * @param string $name The name.
+                * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from.
+                */
+               function get_plugin_usersetting($name, $user_guid = 0, $plugin_name = "")
+               {
+                       $plugin_name = sanitise_string($plugin_name);
+                       $user_guid = (int)$user_guid;
+                       $name = sanitise_string($name);
+                       
+                       if (!$plugin_name)
+                               $plugin_name = get_plugin_name();
+                               
+                       $user = get_entity($user_guid);
+                       if (!$user) $user = get_loggedin_user();
+                       
+                       if (($user) && ($user instanceof ElggUser))
+                       {
+                               $prefix = "plugin:settings:$plugin_name:$name";
+                               return get_private_setting($user->guid, $prefix); //$user->$prefix;
+                       }
+                       
+                       return false;
+               }
+                       
+               /**
+                * Set a setting for a plugin.
+                *
+                * @param string $name The name - note, can't be "title".
+                * @param mixed $value The value.
+                * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from.
+                */
+               function set_plugin_setting($name, $value, $plugin_name = "")
+               {       
+                       if (!$plugin_name) $plugin_name = get_plugin_name();    
+                       $plugin = find_plugin_settings($plugin_name);
+                       
+                       if (!$plugin) 
+                               $plugin = new ElggPlugin();
+                               
+                       if ($name!='title') 
+                       {
+                               // Hook to validate setting
+                               $value = trigger_plugin_hook('plugin:setting', 'plugin', array(
+                                       'plugin' => $plugin_name,
+                                       'name' => $name,
+                                       'value' => $value
+                               ), $value);
+                               
+                               $plugin->title = $plugin_name;
+                               $plugin->access_id = ACCESS_PUBLIC;
+                               $plugin->save();
+                               $plugin->$name = $value;
+                               
+                               return $plugin->getGUID();
+                       }
+                       
+                       return false;
+               }
+               
+               /**
+                * Get setting for a plugin.
+                *
+                * @param string $name The name.
+                * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from.
+                */
+               function get_plugin_setting($name, $plugin_name = "")
+               {
+                       $plugin = find_plugin_settings($plugin_name);
+               
+                       if ($plugin)
+                               return $plugin->$name;
+                       
+                       return false;
+               }
+               
+               /**
+                * Clear a plugin setting.
+                *
+                * @param string $name The name.
+                * @param string $plugin_name Optional plugin name, if not specified then it is detected from where you are calling from.
+                */
+               function clear_plugin_setting($name, $plugin_name = "")
+               {
+                       $plugin = find_plugin_settings($plugin_name);
+                       
+                       if ($plugin)
+                               return remove_all_private_settings($plugin->guid); //$plugin->clearMetaData($name);
+                       
+                       return false;
+               }
+               
+               /**
+                * Return an array of installed plugins.
+                */
+               function get_installed_plugins()
+               {
+                       global $CONFIG;
+                       
+                       $installed_plugins = array();
+                       
+                       if (!empty($CONFIG->pluginspath)) {
+                               
+                               $plugins = get_plugin_list();
+                               
+                               foreach($plugins as $mod) {
+                                       $installed_plugins[$mod] = array();
+                                       $installed_plugins[$mod]['active'] = is_plugin_enabled($mod);
+                                       $installed_plugins[$mod]['manifest'] = load_plugin_manifest($mod);
+                               }
+                               
+                       }
+                       
+                       return $installed_plugins;
+               }
+               
+               /**
                 * Enable a plugin for a site (default current site)
                 * 
                 * Important: You should regenerate simplecache and the viewpath cache after executing this function
                 * otherwise you may experience view display artifacts. Do this with the following code:
                 * 
                 *              elgg_view_regenerate_simplecache();
-                *              elgg_filepath_cache_reset();\r
-                *\r
-                * @param string $plugin The plugin name.\r
-                * @param int $site_guid The site id, if not specified then this is detected.\r
-                */\r
-               function enable_plugin($plugin, $site_guid = 0)\r
-               {\r
-                       global $CONFIG, $ENABLED_PLUGINS_CACHE;\r
-                       \r
-                       $plugin = sanitise_string($plugin);\r
-                       $site_guid = (int) $site_guid;\r
-                       if ($site_guid == 0)\r
-                               $site_guid = $CONFIG->site_guid;\r
-                               \r
-                       $site = get_entity($site_guid);\r
-                       if (!($site instanceof ElggSite))\r
-                               throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $site_guid, "ElggSite"));\r
-                               \r
-                       $enabled = $site->getMetaData('enabled_plugins');\r
-                       $new_enabled = array();\r
-                       if ($enabled)\r
-                       {\r
-                               if (!is_array($enabled))\r
-                                       $new_enabled[] = $enabled;\r
-                               else\r
-                                       $new_enabled = $enabled;\r
-                       }\r
-                       $new_enabled[] = $plugin;\r
-                       $new_enabled = array_unique($new_enabled);\r
-                       \r
+                *              elgg_filepath_cache_reset();
+                *
+                * @param string $plugin The plugin name.
+                * @param int $site_guid The site id, if not specified then this is detected.
+                */
+               function enable_plugin($plugin, $site_guid = 0)
+               {
+                       global $CONFIG, $ENABLED_PLUGINS_CACHE;
+                       
+                       $plugin = sanitise_string($plugin);
+                       $site_guid = (int) $site_guid;
+                       if ($site_guid == 0)
+                               $site_guid = $CONFIG->site_guid;
+                               
+                       $site = get_entity($site_guid);
+                       if (!($site instanceof ElggSite))
+                               throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $site_guid, "ElggSite"));
+                               
+                       $enabled = $site->getMetaData('enabled_plugins');
+                       $new_enabled = array();
+                       if ($enabled)
+                       {
+                               if (!is_array($enabled))
+                                       $new_enabled[] = $enabled;
+                               else
+                                       $new_enabled = $enabled;
+                       }
+                       $new_enabled[] = $plugin;
+                       $new_enabled = array_unique($new_enabled);
+                       
                        $return = $site->setMetaData('enabled_plugins', $new_enabled);
-                       $ENABLED_PLUGINS_CACHE = $new_enabled;\r
-                       \r
-                       return $return; \r
-               }\r
-               \r
-               /**\r
-                * Disable a plugin for a site (default current site)\r
+                       $ENABLED_PLUGINS_CACHE = $new_enabled;
+                       
+                       return $return; 
+               }
+               
+               /**
+                * Disable a plugin for a site (default current site)
                 * 
                 * Important: You should regenerate simplecache and the viewpath cache after executing this function
                 * otherwise you may experience view display artifacts. Do this with the following code:
                 * 
                 *              elgg_view_regenerate_simplecache();
                 *              elgg_filepath_cache_reset();
-                * \r
-                * @param string $plugin The plugin name.\r
-                * @param int $site_guid The site id, if not specified then this is detected.\r
-                */\r
-               function disable_plugin($plugin, $site_guid = 0)\r
-               {\r
-                       global $CONFIG, $ENABLED_PLUGINS_CACHE;\r
-                       \r
-                       $plugin = sanitise_string($plugin);\r
-                       $site_guid = (int) $site_guid;\r
-                       if ($site_guid == 0)\r
-                               $site_guid = $CONFIG->site_guid;\r
-                               \r
-                       $site = get_entity($site_guid);\r
-                       if (!($site instanceof ElggSite))\r
-                               throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $site_guid, "ElggSite"));\r
-                               \r
-                       $enabled = $site->getMetaData('enabled_plugins');\r
-                       $new_enabled = array();\r
-               \r
-                       foreach ($enabled as $plug)\r
-                               if ($plugin != $plug)\r
-                                       $new_enabled[] = $plug;\r
-                                       \r
+                * 
+                * @param string $plugin The plugin name.
+                * @param int $site_guid The site id, if not specified then this is detected.
+                */
+               function disable_plugin($plugin, $site_guid = 0)
+               {
+                       global $CONFIG, $ENABLED_PLUGINS_CACHE;
+                       
+                       $plugin = sanitise_string($plugin);
+                       $site_guid = (int) $site_guid;
+                       if ($site_guid == 0)
+                               $site_guid = $CONFIG->site_guid;
+                               
+                       $site = get_entity($site_guid);
+                       if (!($site instanceof ElggSite))
+                               throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $site_guid, "ElggSite"));
+                               
+                       $enabled = $site->getMetaData('enabled_plugins');
+                       $new_enabled = array();
+               
+                       foreach ($enabled as $plug)
+                               if ($plugin != $plug)
+                                       $new_enabled[] = $plug;
+                                       
                        $return = $site->setMetaData('enabled_plugins', $new_enabled);
-                       $ENABLED_PLUGINS_CACHE = $new_enabled;\r
-                                       \r
-                       return $return;\r
-               }\r
-               \r
-               /**\r
-                * Return whether a plugin is enabled or not.\r
-                *\r
-                * @param string $plugin The plugin name.\r
-                * @param int $site_guid The site id, if not specified then this is detected.\r
-                * @return bool\r
-                */\r
-               function is_plugin_enabled($plugin, $site_guid = 0)\r
-               {\r
-                       global $CONFIG, $ENABLED_PLUGINS_CACHE;\r
-                       \r
-                       if (!file_exists($CONFIG->pluginspath . $plugin)) return false;\r
-                       \r
-                       $site_guid = (int) $site_guid;\r
-                       if ($site_guid == 0)\r
-                               $site_guid = $CONFIG->site_guid;\r
-                               \r
-                               \r
-                       if (!$ENABLED_PLUGINS_CACHE) {\r
-                               $site = get_entity($site_guid);\r
-                               if (!($site instanceof ElggSite))\r
-                                       throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $site_guid, "ElggSite"));\r
-                       \r
-                               $ENABLED_PLUGINS_CACHE = $site->enabled_plugins;\r
-                       }\r
-                               \r
-                       foreach ($ENABLED_PLUGINS_CACHE as $e)\r
-                               if ($e == $plugin) return true;\r
-                               \r
-                       return false;\r
-               }\r
-               \r
-               /**\r
-                * Run once and only once.\r
-                */\r
-               function plugin_run_once()\r
-               {\r
-                       // Register a class\r
-                       add_subtype("object", "plugin", "ElggPlugin");  \r
-               }\r
-               \r
-               /** \r
-                * Initialise the file modules. \r
-                * Listens to system boot and registers any appropriate file types and classes \r
-                */\r
-               function plugin_init()\r
-               {\r
-                       // Now run this stuff, but only once\r
-                       run_function_once("plugin_run_once");\r
-                       \r
-                       // Register some actions\r
-                       register_action("plugins/settings/save", false, "", true);\r
-                       register_action("plugins/usersettings/save");\r
-                       \r
-                       register_action('admin/plugins/enable', false, "", true); // Enable\r
+                       $ENABLED_PLUGINS_CACHE = $new_enabled;
+                                       
+                       return $return;
+               }
+               
+               /**
+                * Return whether a plugin is enabled or not.
+                *
+                * @param string $plugin The plugin name.
+                * @param int $site_guid The site id, if not specified then this is detected.
+                * @return bool
+                */
+               function is_plugin_enabled($plugin, $site_guid = 0)
+               {
+                       global $CONFIG, $ENABLED_PLUGINS_CACHE;
+                       
+                       if (!file_exists($CONFIG->pluginspath . $plugin)) return false;
+                       
+                       $site_guid = (int) $site_guid;
+                       if ($site_guid == 0)
+                               $site_guid = $CONFIG->site_guid;
+                               
+                               
+                       if (!$ENABLED_PLUGINS_CACHE) {
+                               $site = get_entity($site_guid);
+                               if (!($site instanceof ElggSite))
+                                       throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $site_guid, "ElggSite"));
+                       
+                               $ENABLED_PLUGINS_CACHE = $site->enabled_plugins;
+                       }
+                               
+                       foreach ($ENABLED_PLUGINS_CACHE as $e)
+                               if ($e == $plugin) return true;
+                               
+                       return false;
+               }
+               
+               /**
+                * Run once and only once.
+                */
+               function plugin_run_once()
+               {
+                       // Register a class
+                       add_subtype("object", "plugin", "ElggPlugin");  
+               }
+               
+               /** 
+                * Initialise the file modules. 
+                * Listens to system boot and registers any appropriate file types and classes 
+                */
+               function plugin_init()
+               {
+                       // Now run this stuff, but only once
+                       run_function_once("plugin_run_once");
+                       
+                       // Register some actions
+                       register_action("plugins/settings/save", false, "", true);
+                       register_action("plugins/usersettings/save");
+                       
+                       register_action('admin/plugins/enable', false, "", true); // Enable
                        register_action('admin/plugins/disable', false, "", true); // Disable
                        register_action('admin/plugins/enableall', false, "", true); // Enable all
-                       register_action('admin/plugins/disableall', false, "", true); // Disable all\r
-                       \r
-                       register_action('admin/plugins/reorder', false, "", true); // Reorder\r
-                       \r
-               }\r
-               \r
-               // Register a startup event\r
-               register_elgg_event_handler('init','system','plugin_init');     \r
+                       register_action('admin/plugins/disableall', false, "", true); // Disable all
+                       
+                       register_action('admin/plugins/reorder', false, "", true); // Reorder
+                       
+               }
+               
+               // Register a startup event
+               register_elgg_event_handler('init','system','plugin_init');     
 ?>
\ No newline at end of file
index 9d8b00be207e5ec454c4d3d951bc42a43ab4a9ce..75b9eddeb7605a6599f21894b3645700f758c1ac 100644 (file)
                
                function __toString()
                {
-                       //$access = get_access_list();\r
-                       // KJ - changed to use get_access_sql_suffix\r
-                       // Note: currently get_access_sql_suffix is hardwired to use\r
-                       // $acl_field = "access_id", $object_owner_table = $acl_table, and\r
-                       // $object_owner_id_field = "owner_guid"\r
-                       // TODO: recode get_access_sql_suffix to make it possible to specify alternate field names\r
+                       //$access = get_access_list();
+                       // KJ - changed to use get_access_sql_suffix
+                       // Note: currently get_access_sql_suffix is hardwired to use
+                       // $acl_field = "access_id", $object_owner_table = $acl_table, and
+                       // $object_owner_id_field = "owner_guid"
+                       // TODO: recode get_access_sql_suffix to make it possible to specify alternate field names
                        return "and ".get_access_sql_suffix($this->acl_table); // Add access controls
                        
                        //return "and ({$this->acl_table}.{$this->acl_field} in {$access} or ({$this->acl_table}.{$this->acl_field} = 0 and {$this->object_owner_table}.{$this->object_owner_id_field} = {$_SESSION['id']}))";
index 92a88781f18a05fc9d8d53951ba59c8a8afad64d..2ba8a553e9fd739b70e15a2687194e98e10b62fc 100644 (file)
                $guid_one = (int)$guid_one;
                $relationship = sanitise_string($relationship);
                $guid_two = (int)$guid_two;
-               \r
-               $obj = check_entity_relationship($guid_one, $relationship, $guid_two);\r
-               if ($obj == false) return false;\r
-               \r
-               if (trigger_elgg_event('delete', $relationship, $obj)) {\r
-                       return delete_data("DELETE from {$CONFIG->dbprefix}entity_relationships where guid_one=$guid_one and relationship='$relationship' and guid_two=$guid_two");\r
-               } else {\r
-                       return false;\r
+               
+               $obj = check_entity_relationship($guid_one, $relationship, $guid_two);
+               if ($obj == false) return false;
+               
+               if (trigger_elgg_event('delete', $relationship, $obj)) {
+                       return delete_data("DELETE from {$CONFIG->dbprefix}entity_relationships where guid_one=$guid_one and relationship='$relationship' and guid_two=$guid_two");
+               } else {
+                       return false;
                }
        }
 
         *
         * @param int $guid_one The GUID of the entity 
         * @param string $relationship The name of the relationship (optionally)
-        * @param true|false $inverse Whether we're deleting inverse relationships (default false)\r
+        * @param true|false $inverse Whether we're deleting inverse relationships (default false)
         * @param string $type The type of entity to limit this relationship delete to (defaults to all)
         * @return true|false Depending on success
         */
                        $where = "and er.relationship='$relationship'";
                } else {
                        $where = "";
-               }\r
-               \r
-               if (!empty($type)) {\r
-                       $type = sanitise_string($type);\r
-                       if (!$inverse) {\r
-                               $join = " join {$CONFIG->dbprefix}entities e on e.guid = er.guid_two ";\r
-                       } else {\r
-                               $join = " join {$CONFIG->dbprefix}entities e on e.guid = er.guid_one ";\r
-                               $where .= " and ";\r
-                       }\r
-                       $where .= " and e.type = '{$type}' ";\r
-               } else {\r
-                       $join = "";\r
                }
                
-               if (!$inverse) {\r
+               if (!empty($type)) {
+                       $type = sanitise_string($type);
+                       if (!$inverse) {
+                               $join = " join {$CONFIG->dbprefix}entities e on e.guid = er.guid_two ";
+                       } else {
+                               $join = " join {$CONFIG->dbprefix}entities e on e.guid = er.guid_one ";
+                               $where .= " and ";
+                       }
+                       $where .= " and e.type = '{$type}' ";
+               } else {
+                       $join = "";
+               }
+               
+               if (!$inverse) {
                        $sql = "DELETE er from {$CONFIG->dbprefix}entity_relationships as er {$join} where guid_one={$guid_one} {$where}";
                        return delete_data($sql);
-               } else {\r
+               } else {
                        $sql = "DELETE er from {$CONFIG->dbprefix}entity_relationships as er {$join} where guid_two={$guid_one} {$where}";
                        return delete_data($sql);
                }
                $type = sanitise_string($type);
                if ($subtype AND !$subtype = get_subtype_id($type, $subtype))
                        return false;
-               $owner_guid = (int)$owner_guid;\r
+               $owner_guid = (int)$owner_guid;
                if ($order_by == "") $order_by = "time_created desc";
                $order_by = sanitise_string($order_by);
                $limit = (int)$limit;
                }
                return false;
                
-       }\r
-\r
-       /**\r
-        * Returns a viewable list of entities by relationship\r
-        *\r
-        * @see elgg_view_entity_list\r
-        * \r
-        * @param string $relationship The relationship eg "friends_of"\r
-        * @param int $relationship_guid The guid of the entity to use query\r
-        * @param bool $inverse_relationship Reverse the normal function of the query to instead say "give me all entities for whome $relationship_guid is a $relationship of"\r
-        * @param string $type The type of entity (eg 'object')\r
-        * @param string $subtype The entity subtype\r
-        * @param int $owner_guid The owner (default: all)\r
-        * @param int $limit The number of entities to display on a page\r
-        * @param true|false $fullview Whether or not to display the full view (default: true)\r
-        * @param true|false $viewtypetoggle Whether or not to allow gallery view \r
-        * @param true|false $pagination Whether to display pagination (default: true)\r
-        * @return string The viewable list of entities\r
-        */\r
-       function list_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = false, $pagination = true) {\r
-               \r
-               $limit = (int) $limit;\r
-               $offset = (int) get_input('offset');\r
-               $count = get_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, "", $limit, $offset, true);\r
-               $entities = get_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, "", $limit, $offset);\r
-\r
-               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);\r
-               \r
-       }\r
-\r
-       /**\r
-        * Gets the number of entities by a the number of entities related to them in a particular way.\r
-        * This is a good way to get out the users with the most friends, or the groups with the most members.\r
-        *\r
-        * @param string $relationship The relationship eg "friends_of"\r
-        * @param bool $inverse_relationship Reverse the normal function of the query to instead say "give me all entities for whome $relationship_guid is a $relationship of" (default: true)\r
-        * @param string $type The type of entity (default: all)\r
-        * @param string $subtype The entity subtype (default: all)\r
-        * @param int $owner_guid The owner of the entities (default: none)\r
-        * @param int $limit\r
-        * @param int $offset\r
-        * @param boolean $count Set to true if you want to count the number of entities instead (default false)\r
-        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.\r
-        * @return array|int|false An array of entities, or the number of entities, or false on failure\r
-        */\r
-       \r
-       function get_entities_by_relationship_count($relationship, $inverse_relationship = true, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $count = false, $site_guid = 0) {\r
-               \r
-               global $CONFIG;\r
-               \r
-               $relationship = sanitise_string($relationship);\r
-               $inverse_relationship = (bool)$inverse_relationship;\r
-               $type = sanitise_string($type);\r
+       }
+
+       /**
+        * Returns a viewable list of entities by relationship
+        *
+        * @see elgg_view_entity_list
+        * 
+        * @param string $relationship The relationship eg "friends_of"
+        * @param int $relationship_guid The guid of the entity to use query
+        * @param bool $inverse_relationship Reverse the normal function of the query to instead say "give me all entities for whome $relationship_guid is a $relationship of"
+        * @param string $type The type of entity (eg 'object')
+        * @param string $subtype The entity subtype
+        * @param int $owner_guid The owner (default: all)
+        * @param int $limit The number of entities to display on a page
+        * @param true|false $fullview Whether or not to display the full view (default: true)
+        * @param true|false $viewtypetoggle Whether or not to allow gallery view 
+        * @param true|false $pagination Whether to display pagination (default: true)
+        * @return string The viewable list of entities
+        */
+       function list_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = false, $pagination = true) {
+               
+               $limit = (int) $limit;
+               $offset = (int) get_input('offset');
+               $count = get_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, "", $limit, $offset, true);
+               $entities = get_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, "", $limit, $offset);
+
+               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);
+               
+       }
+
+       /**
+        * Gets the number of entities by a the number of entities related to them in a particular way.
+        * This is a good way to get out the users with the most friends, or the groups with the most members.
+        *
+        * @param string $relationship The relationship eg "friends_of"
+        * @param bool $inverse_relationship Reverse the normal function of the query to instead say "give me all entities for whome $relationship_guid is a $relationship of" (default: true)
+        * @param string $type The type of entity (default: all)
+        * @param string $subtype The entity subtype (default: all)
+        * @param int $owner_guid The owner of the entities (default: none)
+        * @param int $limit
+        * @param int $offset
+        * @param boolean $count Set to true if you want to count the number of entities instead (default false)
+        * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
+        * @return array|int|false An array of entities, or the number of entities, or false on failure
+        */
+       
+       function get_entities_by_relationship_count($relationship, $inverse_relationship = true, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $count = false, $site_guid = 0) {
+               
+               global $CONFIG;
+               
+               $relationship = sanitise_string($relationship);
+               $inverse_relationship = (bool)$inverse_relationship;
+               $type = sanitise_string($type);
                if ($subtype AND !$subtype = get_subtype_id($type, $subtype))
-                       return false;\r
-               $owner_guid = (int)$owner_guid;\r
-               $order_by = sanitise_string($order_by);\r
-               $limit = (int)$limit;\r
-               $offset = (int)$offset;\r
-               $site_guid = (int) $site_guid;\r
-               if ($site_guid == 0)\r
-                       $site_guid = $CONFIG->site_guid;\r
-               \r
-               //$access = get_access_list();\r
-               \r
-               $where = array();\r
-               \r
-               if ($relationship!="")\r
-                       $where[] = "r.relationship='$relationship'";\r
-               if ($inverse_relationship) {\r
-                       $on = 'e.guid = r.guid_two';\r
-               } else {\r
-                       $on = 'e.guid = r.guid_one';\r
-               }\r
-               if ($type != "")\r
-                       $where[] = "e.type='$type'";\r
-               if ($subtype)\r
-                       $where[] = "e.subtype=$subtype";\r
-               if ($owner_guid != "")\r
-                       $where[] = "e.container_guid='$owner_guid'";\r
-               if ($site_guid > 0)\r
-                       $where[] = "e.site_guid = {$site_guid}";\r
-               \r
-               if ($count) {\r
-                       $query = "SELECT count(distinct e.guid) as total ";\r
-               } else {\r
-                       $query = "SELECT e.*, count(e.guid) as total ";\r
-               }\r
-               \r
-               $query .= " from {$CONFIG->dbprefix}entity_relationships r JOIN {$CONFIG->dbprefix}entities e on {$on} where ";\r
-               \r
-               if (!empty($where))\r
-               foreach ($where as $w)\r
-                       $query .= " $w and ";\r
-               $query .= get_access_sql_suffix("e"); // Add access controls\r
-               \r
-               if (!$count) {\r
-                       $query .= " group by e.guid ";\r
-                       $query .= " order by total desc limit {$offset}, {$limit}"; // Add order and limit\r
-                       return get_data($query, "entity_row_to_elggstar");\r
-               } else {\r
-                       if ($count = get_data_row($query)) {\r
-                               return $count->total;\r
-                       }\r
-               }\r
-               \r
-               return false;\r
-                       \r
-       }\r
-       \r
-       /**\r
-        * Displays a human-readable list of entities\r
-        * \r
-        * @param string $relationship The relationship eg "friends_of"\r
-        * @param bool $inverse_relationship Reverse the normal function of the query to instead say "give me all entities for whome $relationship_guid is a $relationship of" (default: true)\r
-        * @param string $type The type of entity (eg 'object')\r
-        * @param string $subtype The entity subtype\r
-        * @param int $owner_guid The owner (default: all)\r
-        * @param int $limit The number of entities to display on a page\r
-        * @param true|false $fullview Whether or not to display the full view (default: true)\r
-        * @param true|false $viewtypetoggle Whether or not to allow gallery view \r
-        * @param true|false $pagination Whether to display pagination (default: true)\r
-        * @return string The viewable list of entities\r
-        */\r
-       \r
-       function list_entities_by_relationship_count($relationship, $inverse_relationship = true, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = false, $pagination = true) {\r
-               \r
-               $limit = (int) $limit;\r
-               $offset = (int) get_input('offset');\r
-               $count = get_entities_by_relationship_count($relationship,$inverse_relationship,$type,$subtype,$owner_guid,0,0,true);\r
-               $entities = get_entities_by_relationship_count($relationship,$inverse_relationship,$type,$subtype,$owner_guid,$limit,$offset);\r
-\r
-               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);\r
-               \r
+                       return false;
+               $owner_guid = (int)$owner_guid;
+               $order_by = sanitise_string($order_by);
+               $limit = (int)$limit;
+               $offset = (int)$offset;
+               $site_guid = (int) $site_guid;
+               if ($site_guid == 0)
+                       $site_guid = $CONFIG->site_guid;
+               
+               //$access = get_access_list();
+               
+               $where = array();
+               
+               if ($relationship!="")
+                       $where[] = "r.relationship='$relationship'";
+               if ($inverse_relationship) {
+                       $on = 'e.guid = r.guid_two';
+               } else {
+                       $on = 'e.guid = r.guid_one';
+               }
+               if ($type != "")
+                       $where[] = "e.type='$type'";
+               if ($subtype)
+                       $where[] = "e.subtype=$subtype";
+               if ($owner_guid != "")
+                       $where[] = "e.container_guid='$owner_guid'";
+               if ($site_guid > 0)
+                       $where[] = "e.site_guid = {$site_guid}";
+               
+               if ($count) {
+                       $query = "SELECT count(distinct e.guid) as total ";
+               } else {
+                       $query = "SELECT e.*, count(e.guid) as total ";
+               }
+               
+               $query .= " from {$CONFIG->dbprefix}entity_relationships r JOIN {$CONFIG->dbprefix}entities e on {$on} where ";
+               
+               if (!empty($where))
+               foreach ($where as $w)
+                       $query .= " $w and ";
+               $query .= get_access_sql_suffix("e"); // Add access controls
+               
+               if (!$count) {
+                       $query .= " group by e.guid ";
+                       $query .= " order by total desc limit {$offset}, {$limit}"; // Add order and limit
+                       return get_data($query, "entity_row_to_elggstar");
+               } else {
+                       if ($count = get_data_row($query)) {
+                               return $count->total;
+                       }
+               }
+               
+               return false;
+                       
+       }
+       
+       /**
+        * Displays a human-readable list of entities
+        * 
+        * @param string $relationship The relationship eg "friends_of"
+        * @param bool $inverse_relationship Reverse the normal function of the query to instead say "give me all entities for whome $relationship_guid is a $relationship of" (default: true)
+        * @param string $type The type of entity (eg 'object')
+        * @param string $subtype The entity subtype
+        * @param int $owner_guid The owner (default: all)
+        * @param int $limit The number of entities to display on a page
+        * @param true|false $fullview Whether or not to display the full view (default: true)
+        * @param true|false $viewtypetoggle Whether or not to allow gallery view 
+        * @param true|false $pagination Whether to display pagination (default: true)
+        * @return string The viewable list of entities
+        */
+       
+       function list_entities_by_relationship_count($relationship, $inverse_relationship = true, $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = false, $pagination = true) {
+               
+               $limit = (int) $limit;
+               $offset = (int) get_input('offset');
+               $count = get_entities_by_relationship_count($relationship,$inverse_relationship,$type,$subtype,$owner_guid,0,0,true);
+               $entities = get_entities_by_relationship_count($relationship,$inverse_relationship,$type,$subtype,$owner_guid,$limit,$offset);
+
+               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);
+               
        }
        
        /**
index dd0d2f76f81b9c742204cb8fd92c2f2c6631bc05..1a982e6a4e41b46f4cf2b4c1697158c70802ce9b 100644 (file)
-<?php\r
-\r
-       /**\r
-        * Elgg river 2.0.\r
-        * Functions for listening for and generating the river separately from the system log.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg river 2.0.
+        * Functions for listening for and generating the river separately from the system log.
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       /**
+        * Adds an item to the river.
+        *
+        * @param string $view The view that will handle the river item (must exist)
+        * @param string $action_type An arbitrary one-word string to define the action (eg 'comment', 'create')
+        * @param int $subject_guid The GUID of the entity doing the action
+        * @param int $object_guid The GUID of the entity being acted upon
+        * @param int $access_id The access ID of the river item (default: same as the object) 
+        * @param int $posted The UNIX epoch timestamp of the river item (default: now)
+        * @return true|false Depending on success
+        */
+               function add_to_river(
+                                                               $view,
+                                                               $action_type,
+                                                               $subject_guid,
+                                                               $object_guid,
+                                                               $access_id = "",
+                                                               $posted = 0
+                                                         ) {
+                                                               
+                       // Sanitise variables
+                               if (!elgg_view_exists($view)) return false;
+                               if (!($subject = get_entity($subject_guid))) return false;
+                               if (!($object = get_entity($object_guid))) return false;
+                               if (empty($action_type)) return false;
+                               if ($posted == 0) $posted = time();
+                               if ($access_id === "") $access_id = $object->access_id;
+                               
+                               $type = $object->getType();
+                               $subtype = $object->getSubtype();
+                               
+                               $action_type = sanitise_string($action_type);
+                               
+                       // Load config
+                               global $CONFIG;
+                               
+                       // Attempt to save river item; return success status
+                               return insert_data("insert into {$CONFIG->dbprefix}river " .
+                                                                               " set type = '{$type}', " .
+                                                                               " subtype = '{$subtype}', " .
+                                                                               " action_type = '{$action_type}', " .
+                                                                               " access_id = {$access_id}, " .
+                                                                               " view = '{$view}', " .
+                                                                               " subject_guid = {$subject_guid}, " .
+                                                                               " object_guid = {$object_guid}, " .
+                                                                               " posted = {$posted} ");
+                                                               
+               }
+               
+       /**
+        * Removes all items relating to a particular acting entity from the river
+        *
+        * @param int $subject_guid The GUID of the entity
+        * @return true|false Depending on success
+        */
+               function remove_from_river_by_subject(
+                                                                       $subject_guid
+                                                                                       ) {
+                       
+                       // Sanitise
+                               $subject_guid = (int) $subject_guid;
+                               
+                       // Load config
+                               global $CONFIG;
+                               
+                       // Remove
+                               return delete_data("delete from {$CONFIG->dbprefix}river where subject_guid = {$subject_guid}");
+                                                                                               
+               }
+               
+       /**
+        * Removes all items relating to a particular entity being acted upon from the river
+        *
+        * @param int $object_guid The GUID of the entity
+        * @return true|false Depending on success
+        */
+               function remove_from_river_by_object(
+                                                                       $object_guid
+                                                                                       ) {
+                       
+                       // Sanitise
+                               $object_guid = (int) $object_guid;
+                               
+                       // Load config
+                               global $CONFIG;
+                               
+                       // Remove
+                               return delete_data("delete from {$CONFIG->dbprefix}river where object_guid = {$object_guid}");
+                                                                                               
+               }
+
+       /**
+        * Sets the access ID on river items for a particular object
+        *
+        * @param int $object_guid The GUID of the entity
+        * @param int $access_id The access ID
+        * @return true|false Depending on success
+        */
+               function update_river_access_by_object(
+                                                                       $object_guid, $access_id
+                                                                                       ) {
+                       
+                       // Sanitise
+                               $object_guid = (int) $object_guid;
+                               $access_id = (int) $access_id;
+                               
+                       // Load config
+                               global $CONFIG;
+                               
+                       // Remove
+                               return update_data("update {$CONFIG->dbprefix}river set access_id = {$access_id} where object_guid = {$object_guid}");
+                                                                                               
+               }
+               
+       /**
+        * Retrieves items from the river. All parameters are optional.
+        *
+        * @param int|array $subject_guid Acting entity to restrict to. Default: all
+        * @param int|array $object_guid Entity being acted on to restrict to. Default: all
+        * @param string $subject_relationship If set to a relationship type, this will use $subject_guid as the starting point and set the subjects to be all users this entity has this relationship with (eg 'friend'). Default: blank
+        * @param string $type The type of entity to restrict to. Default: all
+        * @param string $subtype The subtype of entity to restrict to. Default: all
+        * @param string $action_type The type of river action to restrict to. Default: all
+        * @param int $limit The number of items to retrieve. Default: 20
+        * @param int $offset The page offset. Default: 0
+        * @param int $posted_min The minimum time period to look at. Default: none
+        * @param int $posted_max The maximum time period to look at. Default: none
+        * @return array|false Depending on success
+        */
+               function get_river_items(
+                                                       $subject_guid = 0,
+                                                       $object_guid = 0,
+                                                       $subject_relationship = '',
+                                                       $type = '',
+                                                       $subtype = '',
+                                                       $action_type = '',
+                                                       $limit = 20,
+                                                       $offset = 0,
+                                                       $posted_min = 0,
+                                                       $posted_max = 0
+                         ) { 
+                               
+            // Get config
+               global $CONFIG;
+                               
+                       // Sanitise variables
+                               if (!is_array($subject_guid)) {
+                                       $subject_guid = (int) $subject_guid;
+                               } else {
+                                       foreach($subject_guid as $key => $temp) {
+                                               $subject_guid[$key] = (int) $temp;
+                                       }
+                               }
+                if (!is_array($object_guid)) {
+                                       $object_guid = (int) $object_guid;
+                               } else {
+                                       foreach($object_guid as $key => $temp) {
+                                               $object_guid[$key] = (int) $temp;
+                                       }
+                               }
+                               if (!empty($type)) $type = sanitise_string($type);
+                               if (!empty($subtype)) $subtype = sanitise_string($subtype);
+                               if (!empty($action_type)) $action_type = sanitise_string($action_type);
+                               $limit = (int) $limit;
+                               $offset = (int) $offset;
+                               $posted_min = (int) $posted_min;
+                               $posted_max = (int) $posted_max;
+                               
+                       // Construct 'where' clauses for the river
+                               $where = array();
+                               $where[] = str_replace("and enabled='yes'",'',str_replace('owner_guid','subject_guid',get_access_sql_suffix()));
+                               
+                               if (empty($subject_relationship)) {
+                                       if (!empty($subject_guid))
+                                               if (!is_array($subject_guid)) {
+                                                       $where[] = " subject_guid = {$subject_guid} ";
+                                               } else {
+                                                       $where[] = " subject_guid in (" . implode(',',$subject_guid) . ") ";
+                                               }
+                               } else {
+                                       if (!is_array($subject_guid))
+                                               if ($entities = get_entities_from_relationship($subject_relationship,$subject_guid,false,'','',0,'',9999)) {
+                                                       $guids = array();
+                                                       foreach($entities as $entity) $guids[] = (int) $entity->guid;
+                                                       // $guids[] = $subject_guid;
+                                                       $where[] = " subject_guid in (" . implode(',',$guids) . ") "; 
+                                               } else {
+                                                       return array();
+                                               }
+                               }
+                               if (!empty($object_guid))
+                       if (!is_array($object_guid)) {
+                                               $where[] = " object_guid = {$object_guid} ";
+                                       } else {
+                                               $where[] = " object_guid in (" . implode(',',$object_guid) . ") ";
+                                       }
+                               if (!empty($type)) $where[] = " type = '{$type}' ";
+                               if (!empty($subtype)) $where[] = " subtype = '{$subtype}' ";
+                               if (!empty($action_type)) $where[] = " action_type = '{$action_type}' ";
+                               if (!empty($posted_min)) $where[] = " posted > {$posted_min} ";
+                               if (!empty($posted_max)) $where[] = " posted < {$posted_max} ";
+                               
+                               $whereclause = implode(' and ', $where);
+                               
+                       // Construct main SQL
+                               $sql = "select id,type,subtype,action_type,access_id,view,subject_guid,object_guid,posted from {$CONFIG->dbprefix}river where {$whereclause} order by posted desc limit {$offset},{$limit}";
+                               
+                       // Get data
+                               return get_data($sql);
+                       
+               }
+               
+       /**
+        * Returns a human-readable representation of a river item
+        *
+        * @see get_river_items
+        * 
+        * @param stdClass $item A river item object as returned from get_river_items
+        * @return string|false Depending on success
+        */
+               function elgg_view_river_item($item) {
+                       if (isset($item->view)) {
+
+                               $object = get_entity($item->object_guid);
+                               if (!$object) {
+                                       $body = elgg_view('river/item/noaccess');
+                               } else {
+                                       if (elgg_view_exists($item->view)) {
+                                               $body = elgg_view($item->view,array(
+                                                                                       'item' => $item
+                                                                                ));
+                                       }
+                               }
+                               return elgg_view('river/item/wrapper',array(
+                                                                       'item' => $item,
+                                                                       'body' => $body
+                                                                ));
+                               
+                       }
+                       return false;
+               }
+               
+       /**
+        * Returns a human-readable version of the river.
+        *
+        * @param int|array $subject_guid Acting entity to restrict to. Default: all
+        * @param int|array $object_guid Entity being acted on to restrict to. Default: all
+        * @param string $subject_relationship If set to a relationship type, this will use $subject_guid as the starting point and set the subjects to be all users this entity has this relationship with (eg 'friend'). Default: blank
+        * @param string $type The type of entity to restrict to. Default: all
+        * @param string $subtype The subtype of entity to restrict to. Default: all
+        * @param string $action_type The type of river action to restrict to. Default: all
+        * @param int $limit The number of items to retrieve. Default: 20
+        * @param int $posted_min The minimum time period to look at. Default: none
+        * @param int $posted_max The maximum time period to look at. Default: none
+        * @return string Human-readable river.
+        */
+               function elgg_view_river_items($subject_guid = 0,
+                                                       $object_guid = 0,
+                                                       $subject_relationship = '',
+                                                       $type = '',
+                                                       $subtype = '',
+                                                       $action_type = '',
+                                                       $limit = 20,
+                                                       $posted_min = 0,
+                                                       $posted_max = 0,
+                                                       $pagination = true) {
+                                                               
+                       // Get input from outside world and sanitise it
+                               $offset = (int) get_input('offset',0);
+                               
+                       // Get river items, if they exist
+                               if ($riveritems = get_river_items($subject_guid,$object_guid,$subject_relationship,$type,$subtype,$action_type,($limit + 1),$offset,$posted_min,$posted_max)) {
+
+                                       return elgg_view('river/item/list',array(
+                                                                                       'limit' => $limit,
+                                                                                       'offset' => $offset,
+                                                                                       'items' => $riveritems,
+                                                                                       'pagination' => $pagination
+                                                                               ));
+                                       
+                               }
+                               
+                       return '';
+                               
+               }
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /**\r
-        * Adds an item to the river.\r
-        *\r
-        * @param string $view The view that will handle the river item (must exist)\r
-        * @param string $action_type An arbitrary one-word string to define the action (eg 'comment', 'create')\r
-        * @param int $subject_guid The GUID of the entity doing the action\r
-        * @param int $object_guid The GUID of the entity being acted upon\r
-        * @param int $access_id The access ID of the river item (default: same as the object) \r
-        * @param int $posted The UNIX epoch timestamp of the river item (default: now)\r
-        * @return true|false Depending on success\r
-        */\r
-               function add_to_river(\r
-                                                               $view,\r
-                                                               $action_type,\r
-                                                               $subject_guid,\r
-                                                               $object_guid,\r
-                                                               $access_id = "",\r
-                                                               $posted = 0\r
-                                                         ) {\r
-                                                               \r
-                       // Sanitise variables\r
-                               if (!elgg_view_exists($view)) return false;\r
-                               if (!($subject = get_entity($subject_guid))) return false;\r
-                               if (!($object = get_entity($object_guid))) return false;\r
-                               if (empty($action_type)) return false;\r
-                               if ($posted == 0) $posted = time();\r
-                               if ($access_id === "") $access_id = $object->access_id;\r
-                               \r
-                               $type = $object->getType();\r
-                               $subtype = $object->getSubtype();\r
-                               \r
-                               $action_type = sanitise_string($action_type);\r
-                               \r
-                       // Load config\r
-                               global $CONFIG;\r
-                               \r
-                       // Attempt to save river item; return success status\r
-                               return insert_data("insert into {$CONFIG->dbprefix}river " .\r
-                                                                               " set type = '{$type}', " .\r
-                                                                               " subtype = '{$subtype}', " .\r
-                                                                               " action_type = '{$action_type}', " .\r
-                                                                               " access_id = {$access_id}, " .\r
-                                                                               " view = '{$view}', " .\r
-                                                                               " subject_guid = {$subject_guid}, " .\r
-                                                                               " object_guid = {$object_guid}, " .\r
-                                                                               " posted = {$posted} ");\r
-                                                               \r
-               }\r
-               \r
-       /**\r
-        * Removes all items relating to a particular acting entity from the river\r
-        *\r
-        * @param int $subject_guid The GUID of the entity\r
-        * @return true|false Depending on success\r
-        */\r
-               function remove_from_river_by_subject(\r
-                                                                       $subject_guid\r
-                                                                                       ) {\r
-                       \r
-                       // Sanitise\r
-                               $subject_guid = (int) $subject_guid;\r
-                               \r
-                       // Load config\r
-                               global $CONFIG;\r
-                               \r
-                       // Remove\r
-                               return delete_data("delete from {$CONFIG->dbprefix}river where subject_guid = {$subject_guid}");\r
-                                                                                               \r
-               }\r
-               \r
-       /**\r
-        * Removes all items relating to a particular entity being acted upon from the river\r
-        *\r
-        * @param int $object_guid The GUID of the entity\r
-        * @return true|false Depending on success\r
-        */\r
-               function remove_from_river_by_object(\r
-                                                                       $object_guid\r
-                                                                                       ) {\r
-                       \r
-                       // Sanitise\r
-                               $object_guid = (int) $object_guid;\r
-                               \r
-                       // Load config\r
-                               global $CONFIG;\r
-                               \r
-                       // Remove\r
-                               return delete_data("delete from {$CONFIG->dbprefix}river where object_guid = {$object_guid}");\r
-                                                                                               \r
-               }\r
-\r
-       /**\r
-        * Sets the access ID on river items for a particular object\r
-        *\r
-        * @param int $object_guid The GUID of the entity\r
-        * @param int $access_id The access ID\r
-        * @return true|false Depending on success\r
-        */\r
-               function update_river_access_by_object(\r
-                                                                       $object_guid, $access_id\r
-                                                                                       ) {\r
-                       \r
-                       // Sanitise\r
-                               $object_guid = (int) $object_guid;\r
-                               $access_id = (int) $access_id;\r
-                               \r
-                       // Load config\r
-                               global $CONFIG;\r
-                               \r
-                       // Remove\r
-                               return update_data("update {$CONFIG->dbprefix}river set access_id = {$access_id} where object_guid = {$object_guid}");\r
-                                                                                               \r
-               }\r
-               \r
-       /**\r
-        * Retrieves items from the river. All parameters are optional.\r
-        *\r
-        * @param int|array $subject_guid Acting entity to restrict to. Default: all\r
-        * @param int|array $object_guid Entity being acted on to restrict to. Default: all\r
-        * @param string $subject_relationship If set to a relationship type, this will use $subject_guid as the starting point and set the subjects to be all users this entity has this relationship with (eg 'friend'). Default: blank\r
-        * @param string $type The type of entity to restrict to. Default: all\r
-        * @param string $subtype The subtype of entity to restrict to. Default: all\r
-        * @param string $action_type The type of river action to restrict to. Default: all\r
-        * @param int $limit The number of items to retrieve. Default: 20\r
-        * @param int $offset The page offset. Default: 0\r
-        * @param int $posted_min The minimum time period to look at. Default: none\r
-        * @param int $posted_max The maximum time period to look at. Default: none\r
-        * @return array|false Depending on success\r
-        */\r
-               function get_river_items(\r
-                                                       $subject_guid = 0,\r
-                                                       $object_guid = 0,\r
-                                                       $subject_relationship = '',\r
-                                                       $type = '',\r
-                                                       $subtype = '',\r
-                                                       $action_type = '',\r
-                                                       $limit = 20,\r
-                                                       $offset = 0,\r
-                                                       $posted_min = 0,\r
-                                                       $posted_max = 0\r
-                         ) { \r
-                               \r
-            // Get config\r
-               global $CONFIG;\r
-                               \r
-                       // Sanitise variables\r
-                               if (!is_array($subject_guid)) {\r
-                                       $subject_guid = (int) $subject_guid;\r
-                               } else {\r
-                                       foreach($subject_guid as $key => $temp) {\r
-                                               $subject_guid[$key] = (int) $temp;\r
-                                       }\r
-                               }\r
-                if (!is_array($object_guid)) {\r
-                                       $object_guid = (int) $object_guid;\r
-                               } else {\r
-                                       foreach($object_guid as $key => $temp) {\r
-                                               $object_guid[$key] = (int) $temp;\r
-                                       }\r
-                               }\r
-                               if (!empty($type)) $type = sanitise_string($type);\r
-                               if (!empty($subtype)) $subtype = sanitise_string($subtype);\r
-                               if (!empty($action_type)) $action_type = sanitise_string($action_type);\r
-                               $limit = (int) $limit;\r
-                               $offset = (int) $offset;\r
-                               $posted_min = (int) $posted_min;\r
-                               $posted_max = (int) $posted_max;\r
-                               \r
-                       // Construct 'where' clauses for the river\r
-                               $where = array();\r
-                               $where[] = str_replace("and enabled='yes'",'',str_replace('owner_guid','subject_guid',get_access_sql_suffix()));\r
-                               \r
-                               if (empty($subject_relationship)) {\r
-                                       if (!empty($subject_guid))\r
-                                               if (!is_array($subject_guid)) {\r
-                                                       $where[] = " subject_guid = {$subject_guid} ";\r
-                                               } else {\r
-                                                       $where[] = " subject_guid in (" . implode(',',$subject_guid) . ") ";\r
-                                               }\r
-                               } else {\r
-                                       if (!is_array($subject_guid))\r
-                                               if ($entities = get_entities_from_relationship($subject_relationship,$subject_guid,false,'','',0,'',9999)) {\r
-                                                       $guids = array();\r
-                                                       foreach($entities as $entity) $guids[] = (int) $entity->guid;\r
-                                                       // $guids[] = $subject_guid;\r
-                                                       $where[] = " subject_guid in (" . implode(',',$guids) . ") "; \r
-                                               } else {\r
-                                                       return array();\r
-                                               }\r
-                               }\r
-                               if (!empty($object_guid))\r
-                       if (!is_array($object_guid)) {\r
-                                               $where[] = " object_guid = {$object_guid} ";\r
-                                       } else {\r
-                                               $where[] = " object_guid in (" . implode(',',$object_guid) . ") ";\r
-                                       }\r
-                               if (!empty($type)) $where[] = " type = '{$type}' ";\r
-                               if (!empty($subtype)) $where[] = " subtype = '{$subtype}' ";\r
-                               if (!empty($action_type)) $where[] = " action_type = '{$action_type}' ";\r
-                               if (!empty($posted_min)) $where[] = " posted > {$posted_min} ";\r
-                               if (!empty($posted_max)) $where[] = " posted < {$posted_max} ";\r
-                               \r
-                               $whereclause = implode(' and ', $where);\r
-                               \r
-                       // Construct main SQL\r
-                               $sql = "select id,type,subtype,action_type,access_id,view,subject_guid,object_guid,posted from {$CONFIG->dbprefix}river where {$whereclause} order by posted desc limit {$offset},{$limit}";\r
-                               \r
-                       // Get data\r
-                               return get_data($sql);\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * Returns a human-readable representation of a river item\r
-        *\r
-        * @see get_river_items\r
-        * \r
-        * @param stdClass $item A river item object as returned from get_river_items\r
-        * @return string|false Depending on success\r
-        */\r
-               function elgg_view_river_item($item) {\r
-                       if (isset($item->view)) {\r
-\r
-                               $object = get_entity($item->object_guid);\r
-                               if (!$object) {\r
-                                       $body = elgg_view('river/item/noaccess');\r
-                               } else {\r
-                                       if (elgg_view_exists($item->view)) {\r
-                                               $body = elgg_view($item->view,array(\r
-                                                                                       'item' => $item\r
-                                                                                ));\r
-                                       }\r
-                               }\r
-                               return elgg_view('river/item/wrapper',array(\r
-                                                                       'item' => $item,\r
-                                                                       'body' => $body\r
-                                                                ));\r
-                               \r
-                       }\r
-                       return false;\r
-               }\r
-               \r
-       /**\r
-        * Returns a human-readable version of the river.\r
-        *\r
-        * @param int|array $subject_guid Acting entity to restrict to. Default: all\r
-        * @param int|array $object_guid Entity being acted on to restrict to. Default: all\r
-        * @param string $subject_relationship If set to a relationship type, this will use $subject_guid as the starting point and set the subjects to be all users this entity has this relationship with (eg 'friend'). Default: blank\r
-        * @param string $type The type of entity to restrict to. Default: all\r
-        * @param string $subtype The subtype of entity to restrict to. Default: all\r
-        * @param string $action_type The type of river action to restrict to. Default: all\r
-        * @param int $limit The number of items to retrieve. Default: 20\r
-        * @param int $posted_min The minimum time period to look at. Default: none\r
-        * @param int $posted_max The maximum time period to look at. Default: none\r
-        * @return string Human-readable river.\r
-        */\r
-               function elgg_view_river_items($subject_guid = 0,\r
-                                                       $object_guid = 0,\r
-                                                       $subject_relationship = '',\r
-                                                       $type = '',\r
-                                                       $subtype = '',\r
-                                                       $action_type = '',\r
-                                                       $limit = 20,\r
-                                                       $posted_min = 0,\r
-                                                       $posted_max = 0,\r
-                                                       $pagination = true) {\r
-                                                               \r
-                       // Get input from outside world and sanitise it\r
-                               $offset = (int) get_input('offset',0);\r
-                               \r
-                       // Get river items, if they exist\r
-                               if ($riveritems = get_river_items($subject_guid,$object_guid,$subject_relationship,$type,$subtype,$action_type,($limit + 1),$offset,$posted_min,$posted_max)) {\r
-\r
-                                       return elgg_view('river/item/list',array(\r
-                                                                                       'limit' => $limit,\r
-                                                                                       'offset' => $offset,\r
-                                                                                       'items' => $riveritems,\r
-                                                                                       'pagination' => $pagination\r
-                                                                               ));\r
-                                       \r
-                               }\r
-                               \r
-                       return '';\r
-                               \r
-               }\r
-\r
 ?>
\ No newline at end of file
index fd569a0e1ccc8cf50fd441a4615688555cec0886..18fb9e73cd4d569c9b588053a41387bf61c1f619 100644 (file)
@@ -1,19 +1,19 @@
-<?php\r
-\r
-       /**\r
-        * Elgg session management\r
-        * Functions to manage logins\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg session management
+        * Functions to manage logins
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
 
-        * @link http://elgg.org/\r
+        * @link http://elgg.org/
         */
 
        /** Elgg magic session */
-       global $SESSION;\r
+       global $SESSION;
 
        /**
         * Magic session class.
@@ -99,9 +99,9 @@
                {
                        global $SESSION;
                
-                       if (isset($SESSION))\r
-                               return $SESSION['user'];\r
-                               \r
+                       if (isset($SESSION))
+                               return $SESSION['user'];
+                               
                        return false;
                }
                
                                
                        return 0;
                }
-\r
-       /**\r
-        * Returns whether or not the user is currently logged in\r
-        *\r
-        * @return true|false\r
-        */\r
-               function isloggedin() {\r
-                                               \r
+
+       /**
+        * Returns whether or not the user is currently logged in
+        *
+        * @return true|false
+        */
+               function isloggedin() {
+                                               
                        if (!is_installed()) return false; 
                        
                        $user = get_loggedin_user();
-               \r
-                       if ((isset($user)) && ($user instanceof ElggUser) && ($user->guid > 0))\r
+               
+                       if ((isset($user)) && ($user instanceof ElggUser) && ($user->guid > 0))
                                return true;
-                               \r
-                       return false;\r
-                       \r
-               }\r
+                               
+                       return false;
+                       
+               }
 
        /**
         * Returns whether or not the user is currently logged in and that they are an admin user.
                                
                        return false;
                }
-               \r
-       /**\r
-        * Perform standard authentication with a given username and password.\r
-        * Returns an ElggUser object for use with login.\r
-        *\r
-        * @see login\r
-        * @param string $username The username, optionally (for standard logins)\r
-        * @param string $password The password, optionally (for standard logins)\r
-        * @return ElggUser|false The authenticated user object, or false on failure.\r
-        */\r
-               \r
-               function authenticate($username, $password) {\r
+               
+       /**
+        * Perform standard authentication with a given username and password.
+        * Returns an ElggUser object for use with login.
+        *
+        * @see login
+        * @param string $username The username, optionally (for standard logins)
+        * @param string $password The password, optionally (for standard logins)
+        * @return ElggUser|false The authenticated user object, or false on failure.
+        */
+               
+               function authenticate($username, $password) {
             
                        if (pam_authenticate(array('username' => $username, 'password' => $password)))
-                               return get_user_by_username($username);\r
-            \r
-            return false;\r
-                       \r
+                               return get_user_by_username($username);
+            
+            return false;
+                       
                }
                
                /**
                        // Let admins log in without validating their email, but normal users must have validated their email or been admin created
                                        if ((!$user->admin) && (!$user->validated) && (!$user->admin_created))
                                                return false;
-                       \r
-                                        // User has been banned, so bin them.\r
-                                        if ($user->isBanned()) return false;\r
+                       
+                                        // User has been banned, so bin them.
+                                        if ($user->isBanned()) return false;
                                                
                         if ($user->password == generate_user_password($user, $credentials['password'])) 
                                
                        }
                        
                        return false;
-               }\r
-               \r
-       /**\r
-        * Logs in a specified ElggUser. For standard registration, use in conjunction\r
-        * with authenticate.\r
-        * \r
-        * @see authenticate\r
-        * @param ElggUser $user A valid Elgg user object\r
-        * @param boolean $persistent Should this be a persistent login?\r
-        * @return true|false Whether login was successful\r
-        */\r
-               function login(ElggUser $user, $persistent = false) {\r
-            \r
+               }
+               
+       /**
+        * Logs in a specified ElggUser. For standard registration, use in conjunction
+        * with authenticate.
+        * 
+        * @see authenticate
+        * @param ElggUser $user A valid Elgg user object
+        * @param boolean $persistent Should this be a persistent login?
+        * @return true|false Whether login was successful
+        */
+               function login(ElggUser $user, $persistent = false) {
+            
             global $CONFIG;
             
             if ($user->isBanned()) return false; // User is banned, return false.
             if (check_rate_limit_exceeded($user->guid)) return false; // Check rate limit
-          \r
-            $_SESSION['user'] = $user;\r
-            $_SESSION['guid'] = $user->getGUID();\r
-            $_SESSION['id'] = $_SESSION['guid'];\r
-            $_SESSION['username'] = $user->username;\r
-            $_SESSION['name'] = $user->name;\r
-                     \r
-            $code = (md5($user->name . $user->username . time() . rand()));\r
-\r
-            $user->code = md5($code);\r
-            \r
-            $_SESSION['code'] = $code;\r
-            \r
-            if (($persistent))\r
-                               setcookie("elggperm", $code, (time()+(86400 * 30)),"/");\r
-         \r
-            if (!$user->save() || !trigger_elgg_event('login','user',$user)) {\r
-               unset($_SESSION['username']);\r
-                   unset($_SESSION['name']);\r
-                   unset($_SESSION['code']);\r
-                   unset($_SESSION['guid']);\r
-                   unset($_SESSION['id']);\r
-                   unset($_SESSION['user']);\r
-                   setcookie("elggperm", "", (time()-(86400 * 30)),"/");\r
-               return false;\r
+          
+            $_SESSION['user'] = $user;
+            $_SESSION['guid'] = $user->getGUID();
+            $_SESSION['id'] = $_SESSION['guid'];
+            $_SESSION['username'] = $user->username;
+            $_SESSION['name'] = $user->name;
+                     
+            $code = (md5($user->name . $user->username . time() . rand()));
+
+            $user->code = md5($code);
+            
+            $_SESSION['code'] = $code;
+            
+            if (($persistent))
+                               setcookie("elggperm", $code, (time()+(86400 * 30)),"/");
+         
+            if (!$user->save() || !trigger_elgg_event('login','user',$user)) {
+               unset($_SESSION['username']);
+                   unset($_SESSION['name']);
+                   unset($_SESSION['code']);
+                   unset($_SESSION['guid']);
+                   unset($_SESSION['id']);
+                   unset($_SESSION['user']);
+                   setcookie("elggperm", "", (time()-(86400 * 30)),"/");
+               return false;
             }
             
             // Users privilege has been elevated, so change the session id (help prevent session hijacking)
-               session_regenerate_id(); \r
+               session_regenerate_id(); 
 
                // Update statistics
                set_last_login($_SESSION['guid']);
                                global $is_admin;
                                $is_admin = true;
                        }
-               \r
-                       return true;\r
-                               \r
-               }\r
-        \r
-       /**\r
-        * Log the current user out\r
-        *\r
-        * @return true|false\r
-        */\r
-               function logout() {\r
-            global $CONFIG;\r
-\r
-            if (isset($_SESSION['user'])) {\r
-               if (!trigger_elgg_event('logout','user',$_SESSION['user'])) return false;\r
-               $_SESSION['user']->code = "";\r
-               $_SESSION['user']->save();\r
+               
+                       return true;
+                               
+               }
+        
+       /**
+        * Log the current user out
+        *
+        * @return true|false
+        */
+               function logout() {
+            global $CONFIG;
+
+            if (isset($_SESSION['user'])) {
+               if (!trigger_elgg_event('logout','user',$_SESSION['user'])) return false;
+               $_SESSION['user']->code = "";
+               $_SESSION['user']->save();
             }
-            \r
-            unset($_SESSION['username']);\r
-            unset($_SESSION['name']);\r
-            unset($_SESSION['code']);\r
-            unset($_SESSION['guid']);\r
-            unset($_SESSION['id']);\r
-            unset($_SESSION['user']);\r
-            \r
+            
+            unset($_SESSION['username']);
+            unset($_SESSION['name']);
+            unset($_SESSION['code']);
+            unset($_SESSION['guid']);
+            unset($_SESSION['id']);
+            unset($_SESSION['user']);
+            
             setcookie("elggperm", "", (time()-(86400 * 30)),"/");
             
-            session_destroy();\r
-            \r
-            return true;\r
+            session_destroy();
+            
+            return true;
         }
         
         function get_session_fingerprint()
                global $CONFIG;
                
                return md5($_SERVER['HTTP_USER_AGENT'] . get_site_secret());
-        }\r
-               \r
-       /**\r
-        * Initialises the system session and potentially logs the user in\r
-        * \r
-        * This function looks for:\r
-        * \r
-        * 1. $_SESSION['id'] - if not present, we're logged out, and this is set to 0\r
-        * 2. The cookie 'elggperm' - if present, checks it for an authentication token, validates it, and potentially logs the user in \r
-        *\r
-        * @uses $_SESSION\r
-        * @param unknown_type $event\r
-        * @param unknown_type $object_type\r
-        * @param unknown_type $object\r
-        */\r
-               function session_init($event, $object_type, $object) {\r
+        }
+               
+       /**
+        * Initialises the system session and potentially logs the user in
+        * 
+        * This function looks for:
+        * 
+        * 1. $_SESSION['id'] - if not present, we're logged out, and this is set to 0
+        * 2. The cookie 'elggperm' - if present, checks it for an authentication token, validates it, and potentially logs the user in 
+        *
+        * @uses $_SESSION
+        * @param unknown_type $event
+        * @param unknown_type $object_type
+        * @param unknown_type $object
+        */
+               function session_init($event, $object_type, $object) {
                        
                        global $DB_PREFIX, $CONFIG;
-                       \r
+                       
                        if (!is_db_installed()) return false;
                        
                        // Use database for sessions
                        $DB_PREFIX = $CONFIG->dbprefix; // HACK to allow access to prefix after object distruction
                        if ((!isset($CONFIG->use_file_sessions)))
                                session_set_save_handler("__elgg_session_open", "__elgg_session_close", "__elgg_session_read", "__elgg_session_write", "__elgg_session_destroy", "__elgg_session_gc");
-                               \r
-                       session_name('Elgg');\r
+                               
+                       session_name('Elgg');
                session_start();
                
                // Do some sanity checking by generating a fingerprint (makes some XSS attacks harder)
                        
                        // Generate a simple token (private from potentially public session id)
                        if (!isset($_SESSION['__elgg_session'])) $_SESSION['__elgg_session'] = md5(microtime().rand());
-               \r
-               if (empty($_SESSION['guid'])) {\r
-                   if (isset($_COOKIE['elggperm'])) {            \r
-                       $code = $_COOKIE['elggperm'];\r
-                       $code = md5($code);\r
-                       unset($_SESSION['guid']);//$_SESSION['guid'] = 0;\r
-                       unset($_SESSION['id']);//$_SESSION['id'] = 0;\r
-                       if ($user = get_user_by_code($code)) {\r
-                       $_SESSION['user'] = $user;\r
-                        $_SESSION['id'] = $user->getGUID();\r
-                        $_SESSION['guid'] = $_SESSION['id'];\r
-                        $_SESSION['code'] = $_COOKIE['elggperm'];\r
-                       }\r
+               
+               if (empty($_SESSION['guid'])) {
+                   if (isset($_COOKIE['elggperm'])) {            
+                       $code = $_COOKIE['elggperm'];
+                       $code = md5($code);
+                       unset($_SESSION['guid']);//$_SESSION['guid'] = 0;
+                       unset($_SESSION['id']);//$_SESSION['id'] = 0;
+                       if ($user = get_user_by_code($code)) {
+                       $_SESSION['user'] = $user;
+                        $_SESSION['id'] = $user->getGUID();
+                        $_SESSION['guid'] = $_SESSION['id'];
+                        $_SESSION['code'] = $_COOKIE['elggperm'];
+                       }
                    } else {
-                       unset($_SESSION['id']); //$_SESSION['id'] = 0;\r
+                       unset($_SESSION['id']); //$_SESSION['id'] = 0;
                        unset($_SESSION['guid']);//$_SESSION['guid'] = 0;
-                       unset($_SESSION['code']);//$_SESSION['code'] = "";\r
-                   }\r
-               } else {\r
-                   if (!empty($_SESSION['code'])) {\r
-                       $code = md5($_SESSION['code']);\r
-                       if ($user = get_user_by_code($code)) {\r
+                       unset($_SESSION['code']);//$_SESSION['code'] = "";
+                   }
+               } else {
+                   if (!empty($_SESSION['code'])) {
+                       $code = md5($_SESSION['code']);
+                       if ($user = get_user_by_code($code)) {
                                $_SESSION['user'] = $user;
                                $_SESSION['id'] = $user->getGUID();
-                        $_SESSION['guid'] = $_SESSION['id'];\r
-                       } else {\r
-                               unset($_SESSION['user']);\r
+                        $_SESSION['guid'] = $_SESSION['id'];
+                       } else {
+                               unset($_SESSION['user']);
                                unset($_SESSION['id']); //$_SESSION['id'] = 0;
                                unset($_SESSION['guid']);//$_SESSION['guid'] = 0;
-                               unset($_SESSION['code']);//$_SESSION['code'] = "";\r
-                       }\r
+                               unset($_SESSION['code']);//$_SESSION['code'] = "";
+                       }
                    } else {
-                       //$_SESSION['user'] = new ElggDummy();\r
+                       //$_SESSION['user'] = new ElggDummy();
                        unset($_SESSION['id']); //$_SESSION['id'] = 0;
                        unset($_SESSION['guid']);//$_SESSION['guid'] = 0;
-                       unset($_SESSION['code']);//$_SESSION['code'] = "";\r
-                   }\r
-               }\r
-               if ($_SESSION['id'] > 0) {\r
-                   set_last_action($_SESSION['id']);\r
-               }\r
-               \r
-               register_action("login",true);\r
-               register_action("logout");\r
+                       unset($_SESSION['code']);//$_SESSION['code'] = "";
+                   }
+               }
+               if ($_SESSION['id'] > 0) {
+                   set_last_action($_SESSION['id']);
+               }
+               
+               register_action("login",true);
+               register_action("logout");
                
                // Register a default PAM handler
                register_pam_handler('pam_auth_userpass');
                {
                        session_destroy();
                            return false;
-               }\r
-               \r
-               // Since we have loaded a new user, this user may have different language preferences\r
+               }
+               
+               // Since we have loaded a new user, this user may have different language preferences
                register_translations(dirname(dirname(dirname(__FILE__))) . "/languages/");
-               \r
-               return true;\r
-               \r
+               
+               return true;
+               
                }
-               \r
-       /**\r
-        * Used at the top of a page to mark it as logged in users only.\r
-        *\r
-        */\r
-               function gatekeeper() {\r
-                       if (!isloggedin()) {\r
-                               $_SESSION['last_forward_from'] = current_page_url();\r
-                               forward();\r
-                       }\r
+               
+       /**
+        * Used at the top of a page to mark it as logged in users only.
+        *
+        */
+               function gatekeeper() {
+                       if (!isloggedin()) {
+                               $_SESSION['last_forward_from'] = current_page_url();
+                               forward();
+                       }
                }
                
                /**
                function admin_gatekeeper()
                {
                        gatekeeper();
-                       if (!isadminloggedin()) {\r
-                               $_SESSION['last_forward_from'] = current_page_url();\r
-                               forward();\r
+                       if (!isadminloggedin()) {
+                               $_SESSION['last_forward_from'] = current_page_url();
+                               forward();
                        }
-               }\r
+               }
                
                /**
                 * DB Based session handling code.
                        
                        return true;
                }
-               \r
-               register_elgg_event_handler("boot","system","session_init",20);\r
-\r
-\r
+               
+               register_elgg_event_handler("boot","system","session_init",20);
+
+
 ?>
\ No newline at end of file
index c088e24763b299e56373779e216152767760d936..14cc2039da9cb196237406568ffd473428758815 100644 (file)
@@ -1,16 +1,16 @@
-<?php\r
-\r
-       /**\r
-        * Elgg sites\r
-        * Functions to manage multiple or single sites in an Elgg install\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd <info@elgg.com>\r
+       /**
+        * Elgg sites
+        * Functions to manage multiple or single sites in an Elgg install
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
+        * @author Curverider Ltd <info@elgg.com>
+
+        * @link http://elgg.org/
+        */
 
        /**
         * ElggSite
                
                if ($row)
                {
-                       // Exists and you have access to it\r
+                       // Exists and you have access to it
                        if ($exists = get_data_row("SELECT guid from {$CONFIG->dbprefix}sites_entity where guid = {$guid}")) {
                                $result = update_data("UPDATE {$CONFIG->dbprefix}sites_entity set name='$name', description='$description', url='$url' where guid=$guid");
                                if ($result!=false)
                                                $entity->delete();
                                                //delete_entity($guid);
                                        }
-                               }\r
+                               }
                        }
                        else
                        {
                $offset = (int)$offset;
                
                return get_entities_from_relationship("member_of_site", $site_guid, true, "user", "", 0, "time_created desc", $limit, $offset);
-       }\r
-       \r
-       /**\r
-        * Display a list of site members\r
-        *\r
-        * @param int $site_guid The GUID of the site\r
-        * @param int $limit The number of members to display on a page\r
-        * @param true|false $fullview Whether or not to display the full view (default: true)\r
-        * @return string A displayable list of members\r
-        */\r
-       function list_site_members($site_guid, $limit = 10, $fullview = true) {\r
-               \r
-               $offset = (int) get_input('offset');\r
-               $limit = (int) $limit;\r
-               $count = (int) get_entities_from_relationship("member_of_site", $site_guid, true, "user", "", 0, "time_created desc", $limit, $offset, true);\r
-               $entities = get_site_members($site_guid, $limit, $offset);\r
-               \r
-               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview);\r
-               \r
+       }
+       
+       /**
+        * Display a list of site members
+        *
+        * @param int $site_guid The GUID of the site
+        * @param int $limit The number of members to display on a page
+        * @param true|false $fullview Whether or not to display the full view (default: true)
+        * @return string A displayable list of members
+        */
+       function list_site_members($site_guid, $limit = 10, $fullview = true) {
+               
+               $offset = (int) get_input('offset');
+               $limit = (int) $limit;
+               $count = (int) get_entities_from_relationship("member_of_site", $site_guid, true, "user", "", 0, "time_created desc", $limit, $offset, true);
+               $entities = get_site_members($site_guid, $limit, $offset);
+               
+               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview);
+               
        }
        
        /**
                $offset = (int)$offset;
                
                return get_entities_from_relationship("member_of_site", $site_guid, true, "object", $subtype, 0, "time_created desc", $limit, $offset);
-       }\r
-       \r
+       }
+       
        /**
         * Add a collection to a site.
         * 
                
                return false;
        }
-       \r
-       /**\r
-        * Initialise site handling\r
-        *\r
-        * Called at the beginning of system running, to set the ID of the current site.\r
-        * This is 0 by default, but plugins may alter this behaviour by attaching functions\r
-        * to the sites init event and changing $CONFIG->site_id.\r
-        * \r
-        * @uses $CONFIG\r
-        * @param string $event Event API required parameter\r
-        * @param string $object_type Event API required parameter\r
-        * @param null $object Event API required parameter\r
-        * @return true\r
-        */\r
-               function sites_init($event, $object_type, $object) {\r
-                       \r
-                       global $CONFIG;\r
-                       \r
+       
+       /**
+        * Initialise site handling
+        *
+        * Called at the beginning of system running, to set the ID of the current site.
+        * This is 0 by default, but plugins may alter this behaviour by attaching functions
+        * to the sites init event and changing $CONFIG->site_id.
+        * 
+        * @uses $CONFIG
+        * @param string $event Event API required parameter
+        * @param string $object_type Event API required parameter
+        * @param null $object Event API required parameter
+        * @return true
+        */
+               function sites_init($event, $object_type, $object) {
+                       
+                       global $CONFIG;
+                       
                        if (is_installed() && is_db_installed()) {
-                               \r
-                               $site = trigger_plugin_hook("siteid","system");\r
-                               if ($site === null || $site === false) {\r
-                                       $CONFIG->site_id = (int) datalist_get('default_site');\r
-                               } else {\r
-                                       $CONFIG->site_id = $site;\r
-                               }\r
-                               $CONFIG->site_guid = $CONFIG->site_id;\r
-                               $CONFIG->site = get_entity($CONFIG->site_guid);\r
-                               \r
-                               return true;\r
+                               
+                               $site = trigger_plugin_hook("siteid","system");
+                               if ($site === null || $site === false) {
+                                       $CONFIG->site_id = (int) datalist_get('default_site');
+                               } else {
+                                       $CONFIG->site_id = $site;
+                               }
+                               $CONFIG->site_guid = $CONFIG->site_id;
+                               $CONFIG->site = get_entity($CONFIG->site_guid);
+                               
+                               return true;
                        }
                        
-                       return true;\r
-               }\r
-               \r
-       // Register event handlers\r
-\r
-               register_elgg_event_handler('boot','system','sites_init',2);\r
-\r
+                       return true;
+               }
+               
+       // Register event handlers
+
+               register_elgg_event_handler('boot','system','sites_init',2);
+
 ?>
\ No newline at end of file
index b00b56d7930667375089f3af064a5be49f7461e8..e8bfccda59a927ab8f526454bcb97311af7e861e 100644 (file)
@@ -1,76 +1,76 @@
-<?php\r
-\r
-    /**\r
-        * Elgg Social\r
-        * Functions and objects which provide powerful social aspects within Elgg\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider\r
+    /**
+        * Elgg Social
+        * Functions and objects which provide powerful social aspects within Elgg
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        \r
-        /**\r
-      * Filters a string into an array of significant words\r
-      *\r
-      * @param string $string\r
-      * @return array\r
-      */\r
-        function filter_string($string) {\r
-            \r
-               // Convert it to lower and trim\r
-                  $string = strtolower($string);\r
-                  $string = trim($string);\r
-               \r
-               // Remove links and email addresses\r
-                  // match protocol://address/path/file.extension?some=variable&another=asf%\r
-                          $string = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu"," ", $string);\r
-               // match www.something.domain/path/file.extension?some=variable&another=asf%\r
-                          $string = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu"," ", $string);\r
-               // match name@address\r
-                          $string = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/iu"," ", $string);\r
-               \r
-               // Sanitise the string; remove unwanted characters\r
-                  $string = preg_replace('/\W/ui', ' ', $string);\r
-                  \r
-            // Explode it into an array\r
-                  $terms = explode(' ',$string);\r
-                  \r
-            // Remove any blacklist terms\r
-               //$terms = array_filter($terms, 'remove_blacklist');\r
-                   \r
-               return $terms;\r
-\r
-        }\r
-        \r
-        /**\r
-         * Returns true if the word in $input is considered significant\r
-         *\r
-         * @param string $input\r
-         * @return true|false\r
-         */\r
-        function remove_blacklist($input) {\r
-               \r
-               global $CONFIG;\r
-               \r
-               if (!is_array($CONFIG->wordblacklist))\r
-                       return $input;\r
-               \r
-               if (strlen($input) < 3 || in_array($input,$CONFIG->wordblacklist))\r
-                  return false;\r
-               \r
-            return true;               \r
-               \r
-        }\r
-        \r
+        * @author Curverider
+
+        * @link http://elgg.org/
+        
+        /**
+      * Filters a string into an array of significant words
+      *
+      * @param string $string
+      * @return array
+      */
+        function filter_string($string) {
+            
+               // Convert it to lower and trim
+                  $string = strtolower($string);
+                  $string = trim($string);
+               
+               // Remove links and email addresses
+                  // match protocol://address/path/file.extension?some=variable&another=asf%
+                          $string = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu"," ", $string);
+               // match www.something.domain/path/file.extension?some=variable&another=asf%
+                          $string = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%\=]*)([\s|\.|\,])/iu"," ", $string);
+               // match name@address
+                          $string = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/iu"," ", $string);
+               
+               // Sanitise the string; remove unwanted characters
+                  $string = preg_replace('/\W/ui', ' ', $string);
+                  
+            // Explode it into an array
+                  $terms = explode(' ',$string);
+                  
+            // Remove any blacklist terms
+               //$terms = array_filter($terms, 'remove_blacklist');
+                   
+               return $terms;
+
+        }
+        
+        /**
+         * Returns true if the word in $input is considered significant
+         *
+         * @param string $input
+         * @return true|false
+         */
+        function remove_blacklist($input) {
+               
+               global $CONFIG;
+               
+               if (!is_array($CONFIG->wordblacklist))
+                       return $input;
+               
+               if (strlen($input) < 3 || in_array($input,$CONFIG->wordblacklist))
+                  return false;
+               
+            return true;               
+               
+        }
+        
 
         /**
          * Initialise.
          *
          * Sets a blacklist of words in the current language. This is a comma separated list in word:blacklist.
-         */       \r
-        function social_init() {\r
+         */       
+        function social_init() {
             global $CONFIG;
             
                $CONFIG->wordblacklist = array();
                }
                else    
                {                   
-                       // Fallback - shouldn't happen\r
-                                       $CONFIG->wordblacklist = array(\r
-                                   'and',\r
-                                   'the',\r
-                                   'then',\r
-                                   'but',\r
-                                   'she',\r
-                                   'his',\r
-                                   'her',\r
-                                   'him',\r
-                                   'one',\r
-                                   'not',\r
-                                   'also',\r
-                                   'about',\r
-                                   'now',\r
-                                               'hence',\r
-                                               'however',\r
-                                               'still',\r
-                                               'likewise',\r
-                                               'otherwise',\r
-                                               'therefore',\r
-                                               'conversely',\r
-                                               'rather',\r
-                                   'consequently',\r
-                                               'furthermore',\r
-                                               'nevertheless',\r
-                                               'instead',\r
-                                               'meanwhile',\r
-                                               'accordingly',\r
-                                               'this',\r
-                                               'seems',\r
-                                               'what',\r
-                                               'whom',\r
-                                               'whose',\r
-                                               'whoever',\r
-                                               'whomever',\r
+                       // Fallback - shouldn't happen
+                                       $CONFIG->wordblacklist = array(
+                                   'and',
+                                   'the',
+                                   'then',
+                                   'but',
+                                   'she',
+                                   'his',
+                                   'her',
+                                   'him',
+                                   'one',
+                                   'not',
+                                   'also',
+                                   'about',
+                                   'now',
+                                               'hence',
+                                               'however',
+                                               'still',
+                                               'likewise',
+                                               'otherwise',
+                                               'therefore',
+                                               'conversely',
+                                               'rather',
+                                   'consequently',
+                                               'furthermore',
+                                               'nevertheless',
+                                               'instead',
+                                               'meanwhile',
+                                               'accordingly',
+                                               'this',
+                                               'seems',
+                                               'what',
+                                               'whom',
+                                               'whose',
+                                               'whoever',
+                                               'whomever',
                                );
-               }\r
-        }\r
-\r
-        register_elgg_event_handler("init","system","social_init");\r
-        \r
+               }
+        }
+
+        register_elgg_event_handler("init","system","social_init");
+        
 ?>
\ No newline at end of file
index b79938aab267ad19ae3cd77c2439f401aad3cfa6..24d2e41558a6a2659a05bc5b92994bb750dfa38f 100644 (file)
@@ -79,8 +79,8 @@
         * Return a list of how many users are currently online, rendered as a view.
         */
        function get_online_users()
-       {\r
-               $offset = get_input('offset',0);\r
+       {
+               $offset = get_input('offset',0);
                $count = count(find_active_users(600,9999));
                $objects = find_active_users(600,10,$offset);
                
index 8fdb6ecb7bd7f6084842a4fb32099d8341f143e0..d3db842d15144cfa02359c385514c1ea467f3444 100644 (file)
-<?php\r
-       /**\r
-        * Elgg tags\r
-        * Functions for managing tags and tag clouds.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Elgg tags
+        * Functions for managing tags and tag clouds.
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd <info@elgg.com>\r
+        * @author Curverider Ltd <info@elgg.com>
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       \r
-       /** \r
-        * The algorithm working out the size of font based on the number of tags.\r
-        * This is quick and dirty.\r
-        */\r
-       function calculate_tag_size($min, $max, $number_of_tags, $buckets = 6)\r
-       {\r
-\r
-               $delta =  (($max - $min) / $buckets);\r
-               $thresholds = array();\r
-\r
-               for ($n=1; $n <= $buckets; $n++) {\r
-                       $thresholds[$n-1] = ($min + $n) * $delta;\r
-               }\r
-       \r
-               // Correction\r
-               if ($thresholds[$buckets-1]>$max) $thresholds[$buckets-1] = $max;\r
-\r
-               $size = 0;\r
-               for ($n = 0; $n < count($thresholds); $n++) {\r
-                       if ($number_of_tags >= $thresholds[$n]) \r
-                               $size = $n;\r
-               }\r
-\r
-               return $size;\r
-       }\r
-       \r
-       /**\r
-        * This function generates an array of tags with a weighting.\r
-        *\r
-        * @param array $tags The array of tags.\r
-        * @return An associated array of tags with a weighting, this can then be mapped to a display class. \r
-        */\r
-       function generate_tag_cloud(array $tags, $buckets = 6)\r
-       {\r
-               $cloud = array();\r
-               \r
-               $min = 65535;\r
-               $max = 0;\r
-               \r
-               foreach ($tags as $tag)\r
-               {\r
-                       $cloud[$tag]++;\r
-                       \r
-                       if ($cloud[$tag]>$max) $max = $cloud[$tag];\r
-                       if ($cloud[$tag]<$min) $min = $cloud[$tag];\r
-               }\r
-               \r
-               foreach ($cloud as $k => $v)\r
-                       $cloud[$k] = calculate_tag_size($min, $max, $v, $buckets);\r
-               \r
-               return $cloud;\r
-       }\r
-       \r
-       /**\r
-        * Get an array of tags with weights for use with the output/tagcloud view.\r
-        *\r
-        * @param int $threshold Get the threshold of minimum number of each tags to bother with (ie only show tags where there are more than $threshold occurances)\r
-        * @param int $limit Number of tags to return\r
-        * @param string $metadata_name Optionally, the name of the field you want to grab for\r
-        * @param string $entity_type Optionally, the entity type ('object' etc)\r
-        * @param string $entity_subtype The entity subtype, optionally\r
-        * @param int $owner_guid The GUID of the tags owner, optionally\r
+        * @link http://elgg.org/
+        */
+
+       
+       /** 
+        * The algorithm working out the size of font based on the number of tags.
+        * This is quick and dirty.
+        */
+       function calculate_tag_size($min, $max, $number_of_tags, $buckets = 6)
+       {
+
+               $delta =  (($max - $min) / $buckets);
+               $thresholds = array();
+
+               for ($n=1; $n <= $buckets; $n++) {
+                       $thresholds[$n-1] = ($min + $n) * $delta;
+               }
+       
+               // Correction
+               if ($thresholds[$buckets-1]>$max) $thresholds[$buckets-1] = $max;
+
+               $size = 0;
+               for ($n = 0; $n < count($thresholds); $n++) {
+                       if ($number_of_tags >= $thresholds[$n]) 
+                               $size = $n;
+               }
+
+               return $size;
+       }
+       
+       /**
+        * This function generates an array of tags with a weighting.
+        *
+        * @param array $tags The array of tags.
+        * @return An associated array of tags with a weighting, this can then be mapped to a display class. 
+        */
+       function generate_tag_cloud(array $tags, $buckets = 6)
+       {
+               $cloud = array();
+               
+               $min = 65535;
+               $max = 0;
+               
+               foreach ($tags as $tag)
+               {
+                       $cloud[$tag]++;
+                       
+                       if ($cloud[$tag]>$max) $max = $cloud[$tag];
+                       if ($cloud[$tag]<$min) $min = $cloud[$tag];
+               }
+               
+               foreach ($cloud as $k => $v)
+                       $cloud[$k] = calculate_tag_size($min, $max, $v, $buckets);
+               
+               return $cloud;
+       }
+       
+       /**
+        * Get an array of tags with weights for use with the output/tagcloud view.
+        *
+        * @param int $threshold Get the threshold of minimum number of each tags to bother with (ie only show tags where there are more than $threshold occurances)
+        * @param int $limit Number of tags to return
+        * @param string $metadata_name Optionally, the name of the field you want to grab for
+        * @param string $entity_type Optionally, the entity type ('object' etc)
+        * @param string $entity_subtype The entity subtype, optionally
+        * @param int $owner_guid The GUID of the tags owner, optionally
         * @param int $site_guid Optionally, the site to restrict to (default is the current site)
         * @param int $start_ts Optionally specify a start timestamp for tags used to generate cloud.
-        * @param int $ent_ts Optionally specify an end timestamp for tags used to generate cloud.\r
-        * @return array|false Array of objects with ->tag and ->total values, or false on failure\r
-        */\r
-       \r
-       function get_tags($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object", $entity_subtype = "", $owner_guid = "", $site_guid = -1, $start_ts = "", $end_ts = "") {\r
-               \r
-               global $CONFIG;\r
-               \r
-               $threshold = (int) $threshold;\r
-               $limit = (int) $limit;\r
-               \r
-               if (!empty($metadata_name)) {\r
-                       $metadata_name = (int) get_metastring_id($metadata_name);\r
-               } else {\r
-                       $metadata_name = 0;\r
-               }\r
-               $entity_subtype = get_subtype_id($entity_type, $entity_subtype);\r
-               $entity_type = sanitise_string($entity_type);\r
-               \r
-               if ($owner_guid != "")\r
-               if (is_array($owner_guid)) {\r
-                       foreach($owner_guid as $key => $val)\r
-                               $owner_guid[$key] = (int) $val;\r
-               } else {\r
-                       $owner_guid = (int) $owner_guid;\r
-               }\r
-               \r
-               if ($site_guid < 0) {\r
-                       $site_guid = $CONFIG->site_id;\r
-               }\r
-               \r
-               //$access = get_access_list();\r
-               \r
-               $query = "SELECT msvalue.string as tag, count(msvalue.id) as total ";\r
+        * @param int $ent_ts Optionally specify an end timestamp for tags used to generate cloud.
+        * @return array|false Array of objects with ->tag and ->total values, or false on failure
+        */
+       
+       function get_tags($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object", $entity_subtype = "", $owner_guid = "", $site_guid = -1, $start_ts = "", $end_ts = "") {
+               
+               global $CONFIG;
+               
+               $threshold = (int) $threshold;
+               $limit = (int) $limit;
+               
+               if (!empty($metadata_name)) {
+                       $metadata_name = (int) get_metastring_id($metadata_name);
+               } else {
+                       $metadata_name = 0;
+               }
+               $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
+               $entity_type = sanitise_string($entity_type);
+               
+               if ($owner_guid != "")
+               if (is_array($owner_guid)) {
+                       foreach($owner_guid as $key => $val)
+                               $owner_guid[$key] = (int) $val;
+               } else {
+                       $owner_guid = (int) $owner_guid;
+               }
+               
+               if ($site_guid < 0) {
+                       $site_guid = $CONFIG->site_id;
+               }
+               
+               //$access = get_access_list();
+               
+               $query = "SELECT msvalue.string as tag, count(msvalue.id) as total ";
                $query .= "FROM {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}metadata md on md.entity_guid = e.guid ";
-               if ($entity_subtype > 0)\r
-                       $query .= " join {$CONFIG->dbprefix}entity_subtypes subtype on subtype.id = e.subtype ";\r
-               $query .= " join {$CONFIG->dbprefix}metastrings msvalue on msvalue.id = md.value_id ";\r
-               \r
-               $query .= " where msvalue.string != '' ";\r
-               \r
-               if ($metadata_name > 0) {\r
-                       $query .= " and md.name_id = {$metadata_name} ";\r
-               }\r
-               if ($site_guid > 0) {\r
-                       $query .= " and e.site_guid = {$site_guid} ";\r
-               }\r
-               if ($entity_subtype > 0) {\r
-                       $query .= " and e.subtype = {$entity_subtype} ";\r
-               }\r
-               if ($entity_type != "") {\r
-                       $query .= " and e.type = '{$entity_type}' ";\r
-               }\r
-               if (is_array($owner_guid)) {\r
-                       $query .= " and e.container_guid in (".implode(",",$owner_guid).")";\r
-               } else if (is_int($owner_guid)) {\r
-                       $query .= " and e.container_guid = {$owner_guid} ";\r
+               if ($entity_subtype > 0)
+                       $query .= " join {$CONFIG->dbprefix}entity_subtypes subtype on subtype.id = e.subtype ";
+               $query .= " join {$CONFIG->dbprefix}metastrings msvalue on msvalue.id = md.value_id ";
+               
+               $query .= " where msvalue.string != '' ";
+               
+               if ($metadata_name > 0) {
+                       $query .= " and md.name_id = {$metadata_name} ";
+               }
+               if ($site_guid > 0) {
+                       $query .= " and e.site_guid = {$site_guid} ";
+               }
+               if ($entity_subtype > 0) {
+                       $query .= " and e.subtype = {$entity_subtype} ";
+               }
+               if ($entity_type != "") {
+                       $query .= " and e.type = '{$entity_type}' ";
+               }
+               if (is_array($owner_guid)) {
+                       $query .= " and e.container_guid in (".implode(",",$owner_guid).")";
+               } else if (is_int($owner_guid)) {
+                       $query .= " and e.container_guid = {$owner_guid} ";
                }
                if ($start_ts) {
                        $start_ts = (int)$start_ts;
                if ($end_ts) {
                        $end_ts = (int)$end_ts;
                        $query .= " and e.time_created<=$end_ts";
-               }\r
-               \r
-               //$userid = get_loggedin_userid();\r
-               //$query .= " and (e.access_id in {$access} or (e.access_id = " . ACCESS_PRIVATE . " and e.owner_guid = {$userid}))";\r
-               $query .= ' and ' . get_access_sql_suffix("e"); // Add access controls\r
-               \r
-               $query .= " group by msvalue.string having total > {$threshold} order by total desc limit {$limit} ";\r
-\r
-               return get_data($query);\r
-               \r
-       }\r
-\r
-       /**\r
-        * Loads and displays a tagcloud given particular criteria.\r
-        *\r
-        * @param int $threshold Get the threshold of minimum number of each tags to bother with (ie only show tags where there are more than $threshold occurances)\r
-        * @param int $limit Number of tags to return\r
-        * @param string $metadata_name Optionally, the name of the field you want to grab for\r
-        * @param string $entity_type Optionally, the entity type ('object' etc)\r
-        * @param string $entity_subtype The entity subtype, optionally\r
-        * @param int $owner_guid The GUID of the tags owner, optionally\r
-        * @param int $site_guid Optionally, the site to restrict to (default is the current site)\r
-        * @return string THe HTML (or other, depending on view type) of the tagcloud.\r
-        */\r
-       \r
-       function display_tagcloud($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object", $entity_subtype = "", $owner_guid = "", $site_guid = -1) {\r
-               \r
-               return elgg_view("output/tagcloud",array('value' => get_tags($threshold, $limit, $metadata_name, $entity_type, $entity_subtype, $owner_guid, $site_guid),'object' => $entity_type, 'subtype' => $entity_subtype));\r
-               \r
-       }\r
-\r
+               }
+               
+               //$userid = get_loggedin_userid();
+               //$query .= " and (e.access_id in {$access} or (e.access_id = " . ACCESS_PRIVATE . " and e.owner_guid = {$userid}))";
+               $query .= ' and ' . get_access_sql_suffix("e"); // Add access controls
+               
+               $query .= " group by msvalue.string having total > {$threshold} order by total desc limit {$limit} ";
+
+               return get_data($query);
+               
+       }
+
+       /**
+        * Loads and displays a tagcloud given particular criteria.
+        *
+        * @param int $threshold Get the threshold of minimum number of each tags to bother with (ie only show tags where there are more than $threshold occurances)
+        * @param int $limit Number of tags to return
+        * @param string $metadata_name Optionally, the name of the field you want to grab for
+        * @param string $entity_type Optionally, the entity type ('object' etc)
+        * @param string $entity_subtype The entity subtype, optionally
+        * @param int $owner_guid The GUID of the tags owner, optionally
+        * @param int $site_guid Optionally, the site to restrict to (default is the current site)
+        * @return string THe HTML (or other, depending on view type) of the tagcloud.
+        */
+       
+       function display_tagcloud($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object", $entity_subtype = "", $owner_guid = "", $site_guid = -1) {
+               
+               return elgg_view("output/tagcloud",array('value' => get_tags($threshold, $limit, $metadata_name, $entity_type, $entity_subtype, $owner_guid, $site_guid),'object' => $entity_type, 'subtype' => $entity_subtype));
+               
+       }
+
 ?>
\ No newline at end of file
index ac189b956b12ceb9644575452c8ca09b1a659f32..c98eace7404a11a13574903968ae07fdc2cae9ba 100644 (file)
@@ -1,11 +1,11 @@
-<?php\r
-\r
-       // Upgrade to solve login issue\r
-               \r
-               if ($users = get_entities_from_metadata('validated_email', '', 'user', '', 0,9999)) {\r
-                       foreach($users as $user) {\r
-                               set_user_validation_status($user->guid, true, 'email');\r
-                       }\r
-               }\r
-               \r
+<?php
+
+       // Upgrade to solve login issue
+               
+               if ($users = get_entities_from_metadata('validated_email', '', 'user', '', 0,9999)) {
+                       foreach($users as $user) {
+                               set_user_validation_status($user->guid, true, 'email');
+                       }
+               }
+               
 ?>
\ No newline at end of file
index b56ecdcf6d5e80d2bf70d3044efb82713f7200f6..e086c8236d8060d2ab017ab6195480f48aed2f89 100644 (file)
-<?php\r
-\r
-       /**\r
-        * Elgg users\r
-        * Functions to manage multiple or single users in an Elgg install\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg users
+        * Functions to manage multiple or single users in an Elgg install
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       /// Map a username to a cached GUID
+       $USERNAME_TO_GUID_MAP_CACHE = array();
+       
+       /// Map a user code to a cached GUID
+       $CODE_TO_GUID_MAP_CACHE = array();
+
+       /**
+        * ElggUser
+        * 
+        * Representation of a "user" in the system.
+        * 
+        * @package Elgg
+        * @subpackage Core
+        */
+       class ElggUser extends ElggEntity
+               implements Friendable
+       {
+               /**
+                * Initialise the attributes array. 
+                * This is vital to distinguish between metadata and base parameters.
+                * 
+                * Place your base parameters here.
+                */
+               protected function initialise_attributes()
+               {
+                       parent::initialise_attributes();
+                       
+                       $this->attributes['type'] = "user";
+                       $this->attributes['name'] = "";
+                       $this->attributes['username'] = "";
+                       $this->attributes['password'] = "";
+                       $this->attributes['salt'] = "";
+                       $this->attributes['email'] = "";
+                       $this->attributes['language'] = "";
+                       $this->attributes['code'] = "";
+                       $this->attributes['banned'] = "no";
+                       $this->attributes['tables_split'] = 2;
+               }
+                               
+               /**
+                * Construct a new user entity, optionally from a given id value.
+                *
+                * @param mixed $guid If an int, load that GUID. 
+                *      If a db row then will attempt to load the rest of the data.
+                * @throws Exception if there was a problem creating the user. 
+                */
+               function __construct($guid = null) 
+               {                       
+                       $this->initialise_attributes();
+                       
+                       if (!empty($guid))
+                       {
+                               // Is $guid is a DB row - either a entity row, or a user table row.
+                               if ($guid instanceof stdClass) {                                        
+                                       // Load the rest
+                                       if (!$this->load($guid->guid))
+                                               throw new IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid->guid)); 
+                               }
+                               
+                               // See if this is a username
+                               else if (is_string($guid))
+                               {                                       
+                                       $guid = get_user_by_username($guid);
+                                       foreach ($guid->attributes as $key => $value)
+                                               $this->attributes[$key] = $value;
+                                               
+                               }
+                               
+                               // Is $guid is an ElggUser? Use a copy constructor
+                               else if ($guid instanceof ElggUser)
+                               {                                       
+                                        foreach ($guid->attributes as $key => $value)
+                                               $this->attributes[$key] = $value;
+                               }
+                               
+                               // Is this is an ElggEntity but not an ElggUser = ERROR!
+                               else if ($guid instanceof ElggEntity)
+                                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonElggUser'));
+                                                                               
+                               // We assume if we have got this far, $guid is an int
+                               else if (is_numeric($guid)) {                                   
+                                       if (!$this->load($guid)) IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid));
+                               }
+                               
+                               else
+                                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnrecognisedValue'));
+                       }
+               }
+               
+               /**
+                * Override the load function.
+                * This function will ensure that all data is loaded (were possible), so
+                * if only part of the ElggUser is loaded, it'll load the rest.
+                * 
+                * @param int $guid
+                * @return true|false 
+                */
+               protected function load($guid)
+               {                       
+                       // Test to see if we have the generic stuff
+                       if (!parent::load($guid)) 
+                               return false;
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /// Map a username to a cached GUID\r
-       $USERNAME_TO_GUID_MAP_CACHE = array();\r
-       \r
-       /// Map a user code to a cached GUID\r
-       $CODE_TO_GUID_MAP_CACHE = array();\r
-\r
-       /**\r
-        * ElggUser\r
-        * \r
-        * Representation of a "user" in the system.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-        */\r
-       class ElggUser extends ElggEntity\r
-               implements Friendable\r
-       {\r
-               /**\r
-                * Initialise the attributes array. \r
-                * This is vital to distinguish between metadata and base parameters.\r
-                * \r
-                * Place your base parameters here.\r
-                */\r
-               protected function initialise_attributes()\r
-               {\r
-                       parent::initialise_attributes();\r
-                       \r
-                       $this->attributes['type'] = "user";\r
-                       $this->attributes['name'] = "";\r
-                       $this->attributes['username'] = "";\r
-                       $this->attributes['password'] = "";\r
-                       $this->attributes['salt'] = "";\r
-                       $this->attributes['email'] = "";\r
-                       $this->attributes['language'] = "";\r
-                       $this->attributes['code'] = "";\r
-                       $this->attributes['banned'] = "no";\r
-                       $this->attributes['tables_split'] = 2;\r
-               }\r
-                               \r
-               /**\r
-                * Construct a new user entity, optionally from a given id value.\r
-                *\r
-                * @param mixed $guid If an int, load that GUID. \r
-                *      If a db row then will attempt to load the rest of the data.\r
-                * @throws Exception if there was a problem creating the user. \r
-                */\r
-               function __construct($guid = null) \r
-               {                       \r
-                       $this->initialise_attributes();\r
-                       \r
-                       if (!empty($guid))\r
-                       {\r
-                               // Is $guid is a DB row - either a entity row, or a user table row.\r
-                               if ($guid instanceof stdClass) {                                        \r
-                                       // Load the rest\r
-                                       if (!$this->load($guid->guid))\r
-                                               throw new IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid->guid)); \r
-                               }\r
-                               \r
-                               // See if this is a username\r
-                               else if (is_string($guid))\r
-                               {                                       \r
-                                       $guid = get_user_by_username($guid);\r
-                                       foreach ($guid->attributes as $key => $value)\r
-                                               $this->attributes[$key] = $value;\r
-                                               \r
-                               }\r
-                               \r
-                               // Is $guid is an ElggUser? Use a copy constructor\r
-                               else if ($guid instanceof ElggUser)\r
-                               {                                       \r
-                                        foreach ($guid->attributes as $key => $value)\r
-                                               $this->attributes[$key] = $value;\r
-                               }\r
-                               \r
-                               // Is this is an ElggEntity but not an ElggUser = ERROR!\r
-                               else if ($guid instanceof ElggEntity)\r
-                                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonElggUser'));\r
-                                                                               \r
-                               // We assume if we have got this far, $guid is an int\r
-                               else if (is_numeric($guid)) {                                   \r
-                                       if (!$this->load($guid)) IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid));\r
-                               }\r
-                               \r
-                               else\r
-                                       throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnrecognisedValue'));\r
-                       }\r
-               }\r
-               \r
-               /**\r
-                * Override the load function.\r
-                * This function will ensure that all data is loaded (were possible), so\r
-                * if only part of the ElggUser is loaded, it'll load the rest.\r
-                * \r
-                * @param int $guid\r
-                * @return true|false \r
-                */\r
-               protected function load($guid)\r
-               {                       \r
-                       // Test to see if we have the generic stuff\r
-                       if (!parent::load($guid)) \r
-                               return false;\r
-\r
-                       // Check the type\r
-                       if ($this->attributes['type']!='user')\r
-                               throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()));\r
-                               \r
-                       // Load missing data\r
-                       $row = get_user_entity_as_row($guid);\r
-                       if (($row) && (!$this->isFullyLoaded())) $this->attributes['tables_loaded'] ++; // If $row isn't a cached copy then increment the counter               \r
-                                               \r
-                       // Now put these into the attributes array as core values\r
-                       $objarray = (array) $row;\r
-                       foreach($objarray as $key => $value) \r
-                               $this->attributes[$key] = $value;\r
-                       \r
-                       return true;\r
-               }\r
-               \r
-               /**\r
-                * Saves this user to the database.\r
-                * @return true|false\r
-                */\r
-               public function save()\r
-               {\r
-                       // Save generic stuff\r
-                       if (!parent::save())\r
-                               return false;\r
-               \r
-                       // Now save specific stuff\r
-                       return create_user_entity($this->get('guid'), $this->get('name'), $this->get('username'), $this->get('password'), $this->get('salt'), $this->get('email'), $this->get('language'), $this->get('code'));\r
+                       // Check the type
+                       if ($this->attributes['type']!='user')
+                               throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()));
+                               
+                       // Load missing data
+                       $row = get_user_entity_as_row($guid);
+                       if (($row) && (!$this->isFullyLoaded())) $this->attributes['tables_loaded'] ++; // If $row isn't a cached copy then increment the counter               
+                                               
+                       // Now put these into the attributes array as core values
+                       $objarray = (array) $row;
+                       foreach($objarray as $key => $value) 
+                               $this->attributes[$key] = $value;
+                       
+                       return true;
+               }
+               
+               /**
+                * Saves this user to the database.
+                * @return true|false
+                */
+               public function save()
+               {
+                       // Save generic stuff
+                       if (!parent::save())
+                               return false;
+               
+                       // Now save specific stuff
+                       return create_user_entity($this->get('guid'), $this->get('name'), $this->get('username'), $this->get('password'), $this->get('salt'), $this->get('email'), $this->get('language'), $this->get('code'));
                }
                
                /**
                        
                        // Delete entity
                        return parent::delete();
-               }\r
-               \r
-               /**\r
-                * Ban this user.\r
-                *\r
-                * @param string $reason Optional reason\r
-                */\r
-               public function ban($reason = "") { return ban_user($this->guid, $reason); }\r
-               \r
-               /**\r
-                * Unban this user.\r
-                */\r
-               public function unban() { return unban_user($this->guid); }\r
-               \r
-               /**\r
-                * Is this user banned or not?\r
-                *\r
-                * @return bool\r
-                */\r
-               public function isBanned() { return $this->banned == 'yes'; }\r
-                               \r
-               /**\r
-                * Get sites that this user is a member of\r
-                *\r
-                * @param string $subtype Optionally, the subtype of result we want to limit to\r
-                * @param int $limit The number of results to return\r
-                * @param int $offset Any indexing offset\r
-                */\r
-               function getSites($subtype="", $limit = 10, $offset = 0) {\r
-                       // return get_site_users($this->getGUID(), $subtype, $limit, $offset);\r
-                       return get_user_sites($this->getGUID(), $subtype, $limit, $offset);\r
-               }\r
-               \r
-               /**\r
-                * Add this user to a particular site\r
-                *\r
-                * @param int $site_guid The guid of the site to add it to\r
-                * @return true|false\r
-                */\r
-               function addToSite($site_guid) {\r
-                       // return add_site_user($this->getGUID(), $site_guid); \r
-                       return add_site_user($site_guid, $this->getGUID());\r
-               }\r
-               \r
-               /**\r
-                * Remove this user from a particular site\r
-                *\r
-                * @param int $site_guid The guid of the site to remove it from\r
-                * @return true|false\r
-                */\r
-               function removeFromSite($site_guid) {\r
-                       //return remove_site_user($this->getGUID(), $site_guid);\r
-                       return remove_site_user($site_guid, $this->getGUID());\r
-               }\r
-               \r
-               /**\r
-                * Adds a user to this user's friends list\r
-                *\r
-                * @param int $friend_guid The GUID of the user to add\r
-                * @return true|false Depending on success\r
-                */\r
-               function addFriend($friend_guid) { return user_add_friend($this->getGUID(), $friend_guid); }\r
-               \r
-               /**\r
-                * Removes a user from this user's friends list\r
-                *\r
-                * @param int $friend_guid The GUID of the user to remove\r
-                * @return true|false Depending on success\r
-                */\r
-               function removeFriend($friend_guid) { return user_remove_friend($this->getGUID(), $friend_guid); }\r
-               \r
-               /**\r
-                * Determines whether or not this user is a friend of the currently logged in user\r
-                *\r
-                * @return true|false\r
-                */\r
-               function isFriend() { return user_is_friend(get_loggedin_userid(), $this->getGUID()); }\r
-               \r
-               /**\r
-                * Determines whether this user is friends with another user\r
-                *\r
-                * @param int $user_guid The GUID of the user to check is on this user's friends list\r
-                * @return true|false\r
-                */\r
-               function isFriendsWith($user_guid) { return user_is_friend($this->getGUID(), $user_guid); }\r
-               \r
-               /**\r
-                * Determines whether or not this user is on another user's friends list\r
-                *\r
-                * @param int $user_guid The GUID of the user to check against\r
-                * @return true|false\r
-                */\r
-               function isFriendOf($user_guid) { return user_is_friend($user_guid, $this->getGUID()); }\r
-               \r
-               /**\r
-                * Retrieves a list of this user's friends\r
-                *\r
-                * @param string $subtype Optionally, the subtype of user to filter to (leave blank for all)\r
-                * @param int $limit The number of users to retrieve\r
-                * @param int $offset Indexing offset, if any\r
-                * @return array|false Array of ElggUsers, or false, depending on success\r
-                */\r
-               function getFriends($subtype = "", $limit = 10, $offset = 0) { return get_user_friends($this->getGUID(), $subtype, $limit, $offset); }\r
-               \r
-               /**\r
-                * Retrieves a list of people who have made this user a friend\r
-                *\r
-                * @param string $subtype Optionally, the subtype of user to filter to (leave blank for all)\r
-                * @param int $limit The number of users to retrieve\r
-                * @param int $offset Indexing offset, if any\r
-                * @return array|false Array of ElggUsers, or false, depending on success\r
-                */\r
-               function getFriendsOf($subtype = "", $limit = 10, $offset = 0) { return get_user_friends_of($this->getGUID(), $subtype, $limit, $offset); }\r
-               \r
-               /**\r
-                * Get an array of ElggObjects owned by this user.\r
-                *\r
-                * @param string $subtype The subtype of the objects, if any\r
-                * @param int $limit Number of results to return\r
-                * @param int $offset Any indexing offset\r
-                */\r
-               public function getObjects($subtype="", $limit = 10, $offset = 0) { return get_user_objects($this->getGUID(), $subtype, $limit, $offset); }\r
-\r
-               /**\r
-                * Get an array of ElggObjects owned by this user's friends.\r
-                *\r
-                * @param string $subtype The subtype of the objects, if any\r
-                * @param int $limit Number of results to return\r
-                * @param int $offset Any indexing offset\r
-                */\r
-               public function getFriendsObjects($subtype = "", $limit = 10, $offset = 0) { return get_user_friends_objects($this->getGUID(), $subtype, $limit, $offset); }\r
-               \r
-               /**\r
-                * Counts the number of ElggObjects owned by this user\r
-                *\r
-                * @param string $subtype The subtypes of the objects, if any\r
-                * @return int The number of ElggObjects\r
-                */\r
-               public function countObjects($subtype = "") {\r
-                       return count_user_objects($this->getGUID(), $subtype);\r
-               }\r
-\r
-               /**\r
-                * Get the collections associated with a user.\r
-                *\r
-                * @param string $subtype Optionally, the subtype of result we want to limit to\r
-                * @param int $limit The number of results to return\r
-                * @param int $offset Any indexing offset\r
-                * @return unknown\r
-                */\r
-               public function getCollections($subtype="", $limit = 10, $offset = 0) { return get_user_collections($this->getGUID(), $subtype, $limit, $offset); }\r
-               \r
-               /**\r
-                * If a user's owner is blank, return its own GUID as the owner\r
-                *\r
-                * @return int User GUID\r
-                */\r
-               function getOwner() {\r
-                       if ($this->owner_guid == 0)\r
-                               return $this->getGUID();\r
-                               \r
-                       return $this->owner_guid;\r
-               }\r
-               \r
-               // EXPORTABLE INTERFACE ////////////////////////////////////////////////////////////\r
-               \r
-               /**\r
-                * Return an array of fields which can be exported.\r
-                */\r
-               public function getExportableValues()\r
-               {\r
-                       return array_merge(parent::getExportableValues(), array(\r
-                               'name',\r
-                               'username',\r
-                               'language',\r
-                       ));\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Return the user specific details of a user by a row.\r
-        * \r
-        * @param int $guid\r
-        */\r
-       function get_user_entity_as_row($guid)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               /*$row = retrieve_cached_entity_row($guid);\r
-               if ($row)\r
-               {\r
-                       // We have already cached this object, so retrieve its value from the cache\r
-                       if (isset($CONFIG->debug) && $CONFIG->debug == true)\r
-                               error_log("** Retrieving sub part of GUID:$guid from cache");\r
-                               \r
-                       return $row;\r
-               }\r
-               else\r
-               {*/\r
-                       // Object not cached, load it.\r
-                       if (isset($CONFIG->debug) && $CONFIG->debug == true)\r
-                               error_log("** Sub part of GUID:$guid loaded from DB");\r
-                       \r
-                       $guid = (int)$guid;\r
-               \r
-                       return get_data_row("SELECT * from {$CONFIG->dbprefix}users_entity where guid=$guid");\r
-               //}\r
-       }\r
-       \r
-       /**\r
-        * Create or update the extras table for a given user.\r
-        * Call create_entity first.\r
-        * \r
-        * @param int $guid\r
-        * @param string $name\r
-        * @param string $description\r
-        * @param string $url\r
-        */\r
-       function create_user_entity($guid, $name, $username, $password, $salt, $email, $language, $code)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $guid = (int)$guid;     \r
-               $name = sanitise_string($name); \r
-               $username = sanitise_string($username);         \r
-               $password = sanitise_string($password);\r
-               $salt = sanitise_string($salt);\r
-               $email = sanitise_string($email);\r
-               $language = sanitise_string($language);\r
-               $code = sanitise_string($code);\r
-               \r
-               $row = get_entity_as_row($guid);\r
-               if ($row)\r
-               {\r
-                       // Exists and you have access to it\r
-\r
-                       if ($exists = get_data_row("SELECT guid from {$CONFIG->dbprefix}users_entity where guid = {$guid}")) {\r
-                               $result = update_data("UPDATE {$CONFIG->dbprefix}users_entity set name='$name', username='$username', password='$password', salt='$salt', email='$email', language='$language', code='$code', last_action = ". time() ." where guid = {$guid}");\r
-                               if ($result != false)\r
-                               {\r
-                                       // Update succeeded, continue\r
-                                       $entity = get_entity($guid);\r
-                                       if (trigger_elgg_event('update',$entity->type,$entity)) {\r
-                                               return $guid;\r
-                                       } else {\r
-                                               $entity->delete();\r
-                                       }\r
-                               }\r
-                       }\r
-                       else\r
-                       {\r
-                               // Update failed, attempt an insert.\r
-                               $result = insert_data("INSERT into {$CONFIG->dbprefix}users_entity (guid, name, username, password, salt, email, language, code) values ($guid, '$name', '$username', '$password', '$salt', '$email', '$language', '$code')");\r
-                               if ($result!==false) {\r
-                                       $entity = get_entity($guid);\r
-                                       if (trigger_elgg_event('create',$entity->type,$entity)) {\r
-                                               return $guid;\r
-                                       } else {\r
-                                               $entity->delete(); //delete_entity($guid);\r
-                                       }\r
-                               }\r
-                       }\r
-                                       \r
-               }\r
-               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Disables all of a user's entities\r
-        *\r
-        * @param int $owner_guid The owner GUID\r
-        * @return true|false Depending on success\r
-        */\r
-       function disable_user_entities($owner_guid) {\r
-\r
-               global $CONFIG;\r
-               $owner_guid = (int) $owner_guid;\r
-               if ($entity = get_entity($owner_guid)) {\r
-                       if (trigger_elgg_event('disable',$entity->type,$entity)) {\r
-                               if ($entity->canEdit()) {\r
-                                       $res = update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='no' where owner_guid={$owner_guid} or container_guid = {$owner_guid}");\r
-                                       return $res;\r
-                               }\r
-                       }\r
-               }\r
-               return false;\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Ban a user\r
-        *\r
-        * @param int $user_guid The user guid\r
-        * @param string $reason A reason\r
-        */\r
-       function ban_user($user_guid, $reason = "")\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $user_guid = (int)$user_guid;\r
-               $reason = sanitise_string($reason);\r
-               \r
-               $user = get_entity($user_guid);\r
-               \r
-               if (($user) && ($user->canEdit()) && ($user instanceof ElggUser))\r
+               }
+               
+               /**
+                * Ban this user.
+                *
+                * @param string $reason Optional reason
+                */
+               public function ban($reason = "") { return ban_user($this->guid, $reason); }
+               
+               /**
+                * Unban this user.
+                */
+               public function unban() { return unban_user($this->guid); }
+               
+               /**
+                * Is this user banned or not?
+                *
+                * @return bool
+                */
+               public function isBanned() { return $this->banned == 'yes'; }
+                               
+               /**
+                * Get sites that this user is a member of
+                *
+                * @param string $subtype Optionally, the subtype of result we want to limit to
+                * @param int $limit The number of results to return
+                * @param int $offset Any indexing offset
+                */
+               function getSites($subtype="", $limit = 10, $offset = 0) {
+                       // return get_site_users($this->getGUID(), $subtype, $limit, $offset);
+                       return get_user_sites($this->getGUID(), $subtype, $limit, $offset);
+               }
+               
+               /**
+                * Add this user to a particular site
+                *
+                * @param int $site_guid The guid of the site to add it to
+                * @return true|false
+                */
+               function addToSite($site_guid) {
+                       // return add_site_user($this->getGUID(), $site_guid); 
+                       return add_site_user($site_guid, $this->getGUID());
+               }
+               
+               /**
+                * Remove this user from a particular site
+                *
+                * @param int $site_guid The guid of the site to remove it from
+                * @return true|false
+                */
+               function removeFromSite($site_guid) {
+                       //return remove_site_user($this->getGUID(), $site_guid);
+                       return remove_site_user($site_guid, $this->getGUID());
+               }
+               
+               /**
+                * Adds a user to this user's friends list
+                *
+                * @param int $friend_guid The GUID of the user to add
+                * @return true|false Depending on success
+                */
+               function addFriend($friend_guid) { return user_add_friend($this->getGUID(), $friend_guid); }
+               
+               /**
+                * Removes a user from this user's friends list
+                *
+                * @param int $friend_guid The GUID of the user to remove
+                * @return true|false Depending on success
+                */
+               function removeFriend($friend_guid) { return user_remove_friend($this->getGUID(), $friend_guid); }
+               
+               /**
+                * Determines whether or not this user is a friend of the currently logged in user
+                *
+                * @return true|false
+                */
+               function isFriend() { return user_is_friend(get_loggedin_userid(), $this->getGUID()); }
+               
+               /**
+                * Determines whether this user is friends with another user
+                *
+                * @param int $user_guid The GUID of the user to check is on this user's friends list
+                * @return true|false
+                */
+               function isFriendsWith($user_guid) { return user_is_friend($this->getGUID(), $user_guid); }
+               
+               /**
+                * Determines whether or not this user is on another user's friends list
+                *
+                * @param int $user_guid The GUID of the user to check against
+                * @return true|false
+                */
+               function isFriendOf($user_guid) { return user_is_friend($user_guid, $this->getGUID()); }
+               
+               /**
+                * Retrieves a list of this user's friends
+                *
+                * @param string $subtype Optionally, the subtype of user to filter to (leave blank for all)
+                * @param int $limit The number of users to retrieve
+                * @param int $offset Indexing offset, if any
+                * @return array|false Array of ElggUsers, or false, depending on success
+                */
+               function getFriends($subtype = "", $limit = 10, $offset = 0) { return get_user_friends($this->getGUID(), $subtype, $limit, $offset); }
+               
+               /**
+                * Retrieves a list of people who have made this user a friend
+                *
+                * @param string $subtype Optionally, the subtype of user to filter to (leave blank for all)
+                * @param int $limit The number of users to retrieve
+                * @param int $offset Indexing offset, if any
+                * @return array|false Array of ElggUsers, or false, depending on success
+                */
+               function getFriendsOf($subtype = "", $limit = 10, $offset = 0) { return get_user_friends_of($this->getGUID(), $subtype, $limit, $offset); }
+               
+               /**
+                * Get an array of ElggObjects owned by this user.
+                *
+                * @param string $subtype The subtype of the objects, if any
+                * @param int $limit Number of results to return
+                * @param int $offset Any indexing offset
+                */
+               public function getObjects($subtype="", $limit = 10, $offset = 0) { return get_user_objects($this->getGUID(), $subtype, $limit, $offset); }
+
+               /**
+                * Get an array of ElggObjects owned by this user's friends.
+                *
+                * @param string $subtype The subtype of the objects, if any
+                * @param int $limit Number of results to return
+                * @param int $offset Any indexing offset
+                */
+               public function getFriendsObjects($subtype = "", $limit = 10, $offset = 0) { return get_user_friends_objects($this->getGUID(), $subtype, $limit, $offset); }
+               
+               /**
+                * Counts the number of ElggObjects owned by this user
+                *
+                * @param string $subtype The subtypes of the objects, if any
+                * @return int The number of ElggObjects
+                */
+               public function countObjects($subtype = "") {
+                       return count_user_objects($this->getGUID(), $subtype);
+               }
+
+               /**
+                * Get the collections associated with a user.
+                *
+                * @param string $subtype Optionally, the subtype of result we want to limit to
+                * @param int $limit The number of results to return
+                * @param int $offset Any indexing offset
+                * @return unknown
+                */
+               public function getCollections($subtype="", $limit = 10, $offset = 0) { return get_user_collections($this->getGUID(), $subtype, $limit, $offset); }
+               
+               /**
+                * If a user's owner is blank, return its own GUID as the owner
+                *
+                * @return int User GUID
+                */
+               function getOwner() {
+                       if ($this->owner_guid == 0)
+                               return $this->getGUID();
+                               
+                       return $this->owner_guid;
+               }
+               
+               // EXPORTABLE INTERFACE ////////////////////////////////////////////////////////////
+               
+               /**
+                * Return an array of fields which can be exported.
+                */
+               public function getExportableValues()
+               {
+                       return array_merge(parent::getExportableValues(), array(
+                               'name',
+                               'username',
+                               'language',
+                       ));
+               }
+       }
+
+       /**
+        * Return the user specific details of a user by a row.
+        * 
+        * @param int $guid
+        */
+       function get_user_entity_as_row($guid)
+       {
+               global $CONFIG;
+               
+               /*$row = retrieve_cached_entity_row($guid);
+               if ($row)
+               {
+                       // We have already cached this object, so retrieve its value from the cache
+                       if (isset($CONFIG->debug) && $CONFIG->debug == true)
+                               error_log("** Retrieving sub part of GUID:$guid from cache");
+                               
+                       return $row;
+               }
+               else
+               {*/
+                       // Object not cached, load it.
+                       if (isset($CONFIG->debug) && $CONFIG->debug == true)
+                               error_log("** Sub part of GUID:$guid loaded from DB");
+                       
+                       $guid = (int)$guid;
+               
+                       return get_data_row("SELECT * from {$CONFIG->dbprefix}users_entity where guid=$guid");
+               //}
+       }
+       
+       /**
+        * Create or update the extras table for a given user.
+        * Call create_entity first.
+        * 
+        * @param int $guid
+        * @param string $name
+        * @param string $description
+        * @param string $url
+        */
+       function create_user_entity($guid, $name, $username, $password, $salt, $email, $language, $code)
+       {
+               global $CONFIG;
+               
+               $guid = (int)$guid;     
+               $name = sanitise_string($name); 
+               $username = sanitise_string($username);         
+               $password = sanitise_string($password);
+               $salt = sanitise_string($salt);
+               $email = sanitise_string($email);
+               $language = sanitise_string($language);
+               $code = sanitise_string($code);
+               
+               $row = get_entity_as_row($guid);
+               if ($row)
+               {
+                       // Exists and you have access to it
+
+                       if ($exists = get_data_row("SELECT guid from {$CONFIG->dbprefix}users_entity where guid = {$guid}")) {
+                               $result = update_data("UPDATE {$CONFIG->dbprefix}users_entity set name='$name', username='$username', password='$password', salt='$salt', email='$email', language='$language', code='$code', last_action = ". time() ." where guid = {$guid}");
+                               if ($result != false)
+                               {
+                                       // Update succeeded, continue
+                                       $entity = get_entity($guid);
+                                       if (trigger_elgg_event('update',$entity->type,$entity)) {
+                                               return $guid;
+                                       } else {
+                                               $entity->delete();
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               // Update failed, attempt an insert.
+                               $result = insert_data("INSERT into {$CONFIG->dbprefix}users_entity (guid, name, username, password, salt, email, language, code) values ($guid, '$name', '$username', '$password', '$salt', '$email', '$language', '$code')");
+                               if ($result!==false) {
+                                       $entity = get_entity($guid);
+                                       if (trigger_elgg_event('create',$entity->type,$entity)) {
+                                               return $guid;
+                                       } else {
+                                               $entity->delete(); //delete_entity($guid);
+                                       }
+                               }
+                       }
+                                       
+               }
+               
+               return false;
+       }
+       
+       /**
+        * Disables all of a user's entities
+        *
+        * @param int $owner_guid The owner GUID
+        * @return true|false Depending on success
+        */
+       function disable_user_entities($owner_guid) {
+
+               global $CONFIG;
+               $owner_guid = (int) $owner_guid;
+               if ($entity = get_entity($owner_guid)) {
+                       if (trigger_elgg_event('disable',$entity->type,$entity)) {
+                               if ($entity->canEdit()) {
+                                       $res = update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='no' where owner_guid={$owner_guid} or container_guid = {$owner_guid}");
+                                       return $res;
+                               }
+                       }
+               }
+               return false;
+               
+       }
+       
+       /**
+        * Ban a user
+        *
+        * @param int $user_guid The user guid
+        * @param string $reason A reason
+        */
+       function ban_user($user_guid, $reason = "")
+       {
+               global $CONFIG;
+               
+               $user_guid = (int)$user_guid;
+               $reason = sanitise_string($reason);
+               
+               $user = get_entity($user_guid);
+               
+               if (($user) && ($user->canEdit()) && ($user instanceof ElggUser))
                {
-                       if (trigger_elgg_event('ban', 'user', $user)) {\r
-                               // Add reason\r
-                               if ($reason)\r
-                                       create_metadata($user_guid, 'ban_reason', $reason,'', 0, ACCESS_PUBLIC);\r
-                               \r
-                               // Set ban flag\r
+                       if (trigger_elgg_event('ban', 'user', $user)) {
+                               // Add reason
+                               if ($reason)
+                                       create_metadata($user_guid, 'ban_reason', $reason,'', 0, ACCESS_PUBLIC);
+                               
+                               // Set ban flag
                                return update_data("UPDATE {$CONFIG->dbprefix}users_entity set banned='yes' where guid=$user_guid");
-                       }\r
-               }               \r
-\r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Unban a user.\r
-        *\r
-        * @param int $user_guid Unban a user.\r
-        */\r
-       function unban_user($user_guid)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $user_guid = (int)$user_guid;\r
-               \r
-               $user = get_entity($user_guid);\r
-               \r
-               if (($user) && ($user->canEdit()) && ($user instanceof ElggUser))\r
+                       }
+               }               
+
+               return false;
+       }
+       
+       /**
+        * Unban a user.
+        *
+        * @param int $user_guid Unban a user.
+        */
+       function unban_user($user_guid)
+       {
+               global $CONFIG;
+               
+               $user_guid = (int)$user_guid;
+               
+               $user = get_entity($user_guid);
+               
+               if (($user) && ($user->canEdit()) && ($user instanceof ElggUser))
                {
-                       if (trigger_elgg_event('unban', 'user', $user)) {\r
-                               create_metadata($user_guid, 'ban_reason', '','', 0, ACCESS_PUBLIC);\r
+                       if (trigger_elgg_event('unban', 'user', $user)) {
+                               create_metadata($user_guid, 'ban_reason', '','', 0, ACCESS_PUBLIC);
                                return update_data("UPDATE {$CONFIG->dbprefix}users_entity set banned='no' where guid=$user_guid");
-                       }\r
-               }\r
-               \r
-               return false;\r
-       }\r
-       \r
+                       }
+               }
+               
+               return false;
+       }
+       
        /**
         * THIS FUNCTION IS DEPRECATED.
-        * \r
-        * Delete a user's extra data. \r
-        * \r
-        * @param int $guid\r
-        */\r
-       function delete_user_entity($guid)\r
+        * 
+        * Delete a user's extra data. 
+        * 
+        * @param int $guid
+        */
+       function delete_user_entity($guid)
        {
                system_message(sprintf(elgg_echo('deprecatedfunction'), 'delete_user_entity'));
                
-               return 1; // Always return that we have deleted one row in order to not break existing code.\r
-       }\r
-\r
-       /**\r
-        * Get the sites this user is part of\r
-        *\r
-        * @param int $user_guid The user's GUID\r
-        * @param int $limit Number of results to return\r
-        * @param int $offset Any indexing offset\r
-        * @return false|array On success, an array of ElggSites\r
-        */\r
-       function get_user_sites($user_guid, $limit = 10, $offset = 0) {\r
-               $user_guid = (int)$user_guid;\r
-               $limit = (int)$limit;\r
-               $offset = (int)$offset;\r
-               \r
-               return get_entities_from_relationship("member_of_site", $user_guid, false, "site", "", 0, "time_created desc", $limit, $offset);\r
-       }\r
-       \r
-       /**\r
-        * Adds a user to another user's friends list.\r
-        *\r
-        * @param int $user_guid The GUID of the friending user\r
-        * @param int $friend_guid The GUID of the user to friend\r
-        * @return true|false Depending on success\r
-        */\r
-       function user_add_friend($user_guid, $friend_guid) {\r
-               $user_guid = (int) $user_guid; \r
-               $friend_guid = (int) $friend_guid;\r
-               if ($user_guid == $friend_guid) return false;\r
-               if (!$friend = get_entity($friend_guid)) return false;\r
-               if (!$user = get_entity($user_guid)) return false;\r
-               if ( (!($user instanceof ElggUser)) || (!($friend instanceof ElggUser)) ) return false;\r
-               return add_entity_relationship($user_guid, "friend", $friend_guid);\r
-       }\r
-       \r
-       /**\r
-        * Removes a user from another user's friends list.\r
-        *\r
-        * @param int $user_guid The GUID of the friending user\r
-        * @param int $friend_guid The GUID of the user on the friends list\r
-        * @return true|false Depending on success\r
-        */\r
-       function user_remove_friend($user_guid, $friend_guid) {\r
-               global $CONFIG;\r
-               \r
-               $user_guid = (int) $user_guid; \r
-               $friend_guid = (int) $friend_guid;\r
-               \r
-               // perform cleanup for access lists.\r
-               $collections = get_user_access_collections($user_guid);\r
-               foreach ($collections as $collection) {\r
-                       remove_user_from_access_collection($friend_guid, $collection->id);\r
-               }\r
-               \r
-               return remove_entity_relationship($user_guid, "friend", $friend_guid);\r
-       }\r
-       \r
-       /**\r
-        * Determines whether or not a user is another user's friend.\r
-        *\r
-        * @param int $user_guid The GUID of the user\r
-        * @param int $friend_guid The GUID of the friend\r
-        * @return true|false\r
-        */\r
-       function user_is_friend($user_guid, $friend_guid) {\r
-               return check_entity_relationship($user_guid, "friend", $friend_guid);\r
-       }\r
-\r
-       /**\r
-        * Obtains a given user's friends\r
-        *\r
-        * @param int $user_guid The user's GUID\r
-        * @param string $subtype The subtype of users, if any\r
-        * @param int $limit Number of results to return (default 10)\r
-        * @param int $offset Indexing offset, if any\r
-        * @return false|array Either an array of ElggUsers or false, depending on success\r
-        */\r
-       function get_user_friends($user_guid, $subtype = "", $limit = 10, $offset = 0) {\r
-               return get_entities_from_relationship("friend",$user_guid,false,"user",$subtype,0,"time_created desc",$limit,$offset);\r
-       }\r
-       \r
-       /**\r
-        * Obtains the people who have made a given user a friend\r
-        *\r
-        * @param int $user_guid The user's GUID\r
-        * @param string $subtype The subtype of users, if any\r
-        * @param int $limit Number of results to return (default 10)\r
-        * @param int $offset Indexing offset, if any\r
-        * @return false|array Either an array of ElggUsers or false, depending on success\r
-        */\r
-       function get_user_friends_of($user_guid, $subtype = "", $limit = 10, $offset = 0) {\r
-               return get_entities_from_relationship("friend",$user_guid,true,"user",$subtype,0,"time_created desc",$limit,$offset);\r
-       }\r
-\r
-       /**\r
-        * Obtains a list of objects owned by a user\r
-        *\r
-        * @param int $user_guid The GUID of the owning user\r
-        * @param string $subtype Optionally, the subtype of objects\r
-        * @param int $limit The number of results to return (default 10)\r
-        * @param int $offset Indexing offset, if any\r
-        * @param int $timelower The earliest time the entity can have been created. Default: all\r
-        * @param int $timeupper The latest time the entity can have been created. Default: all\r
-        * @return false|array An array of ElggObjects or false, depending on success\r
-        */\r
-       function get_user_objects($user_guid, $subtype = "", $limit = 10, $offset = 0, $timelower = 0, $timeupper = 0) {\r
-               $ntt = get_entities('object',$subtype, $user_guid, "time_created desc", $limit, $offset,false,0,$user_guid,$timelower, $timeupper);\r
-               return $ntt;\r
-       }\r
-       \r
-       /**\r
-        * Counts the objects (optionally of a particular subtype) owned by a user\r
-        *\r
-        * @param int $user_guid The GUID of the owning user\r
-        * @param string $subtype Optionally, the subtype of objects\r
-        * @param int $timelower The earliest time the entity can have been created. Default: all\r
-        * @param int $timeupper The latest time the entity can have been created. Default: all\r
-        * @return int The number of objects the user owns (of this subtype)\r
-        */\r
-       function count_user_objects($user_guid, $subtype = "", $timelower, $timeupper) {\r
-               $total = get_entities('object', $subtype, $user_guid, "time_created desc", null, null, true, 0, $user_guid,$timelower,$timeupper);\r
-               return $total;\r
-       }\r
-\r
-       /**\r
-        * Displays a list of user objects of a particular subtype, with navigation.\r
-        *\r
-        * @see elgg_view_entity_list\r
-        * \r
-        * @param int $user_guid The GUID of the user\r
-        * @param string $subtype The object subtype\r
-        * @param int $limit The number of entities to display on a page\r
-        * @param true|false $fullview Whether or not to display the full view (default: true)\r
-        * @param int $timelower The earliest time the entity can have been created. Default: all\r
-        * @param int $timeupper The latest time the entity can have been created. Default: all\r
-        * @return string The list in a form suitable to display\r
-        */\r
-       function list_user_objects($user_guid, $subtype = "", $limit = 10, $fullview = true, $viewtypetoggle = true, $pagination = true, $timelower = 0, $timeupper = 0) {\r
-               \r
-               $offset = (int) get_input('offset');\r
-               $limit = (int) $limit;\r
-               $count = (int) count_user_objects($user_guid, $subtype,$timelower,$timeupper);\r
-               $entities = get_user_objects($user_guid, $subtype, $limit, $offset, $timelower, $timeupper);\r
-               \r
-               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Obtains a list of objects owned by a user's friends\r
-        *\r
-        * @param int $user_guid The GUID of the user to get the friends of\r
-        * @param string $subtype Optionally, the subtype of objects\r
-        * @param int $limit The number of results to return (default 10)\r
-        * @param int $offset Indexing offset, if any\r
-        * @return false|array An array of ElggObjects or false, depending on success\r
-        */\r
-       function get_user_friends_objects($user_guid, $subtype = "", $limit = 10, $offset = 0) {\r
-               if ($friends = get_user_friends($user_guid, $subtype, 999999, 0)) {\r
-                       $friendguids = array();\r
-                       foreach($friends as $friend) {\r
-                               $friendguids[] = $friend->getGUID();\r
-                       }\r
-                       return get_entities('object',$subtype,$friendguids, "time_created desc", $limit, $offset, false, 0, $friendguids);\r
-               }\r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Counts the number of objects owned by a user's friends\r
-        *\r
-        * @param int $user_guid The GUID of the user to get the friends of\r
-        * @param string $subtype Optionally, the subtype of objects\r
-        * @return int The number of objects\r
-        */\r
-       function count_user_friends_objects($user_guid, $subtype = "") {\r
-               if ($friends = get_user_friends($user_guid, $subtype, 999999, 0)) {\r
-                       $friendguids = array();\r
-                       foreach($friends as $friend) {\r
-                               $friendguids[] = $friend->getGUID();\r
-                       }\r
-                       return get_entities('object',$subtype,$friendguids, "time_created desc", $limit, $offset, true, 0, $friendguids);\r
-               }\r
-               return 0;\r
-       }\r
-\r
-       /**\r
-        * Displays a list of a user's friends' objects of a particular subtype, with navigation.\r
-        *\r
-        * @see elgg_view_entity_list\r
-        * \r
-        * @param int $user_guid The GUID of the user\r
-        * @param string $subtype The object subtype\r
-        * @param int $limit The number of entities to display on a page\r
-        * @param true|false $fullview Whether or not to display the full view (default: true)\r
-        * @param true|false $viewtypetoggle Whether or not to allow you to flip to gallery mode (default: true)\r
-        * @return string The list in a form suitable to display\r
-        */\r
-       function list_user_friends_objects($user_guid, $subtype = "", $limit = 10, $fullview = true, $viewtypetoggle = true, $pagination = true) {\r
-               \r
-               $offset = (int) get_input('offset');\r
-               $limit = (int) $limit;\r
-               $count = (int) count_user_friends_objects($user_guid, $subtype);\r
-               $entities = get_user_friends_objects($user_guid, $subtype, $limit, $offset);\r
-               \r
-               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Get user objects by an array of metadata\r
-        *\r
-        * @param int $user_guid The GUID of the owning user\r
-        * @param string $subtype Optionally, the subtype of objects\r
-        * @paran array $metadata An array of metadata\r
-        * @param int $limit The number of results to return (default 10)\r
-        * @param int $offset Indexing offset, if any\r
-        * @return false|array An array of ElggObjects or false, depending on success\r
-        * @return unknown\r
-        */\r
-       function get_user_objects_by_metadata($user_guid, $subtype = "", $metadata = array(), $limit = 0, $offset = 0) {\r
-               \r
-               return get_entities_from_metadata_multi($metadata,"object",$subtype,$user_guid,$limit,$offset);\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Get a user object from a GUID.\r
-        * \r
-        * This function returns an ElggUser from a given GUID.\r
-        * @param int $guid The GUID\r
-        * @return ElggUser|false \r
-        */\r
-       function get_user($guid)\r
-       {\r
-               if (!empty($guid)) // Fixes "Exception thrown without stack frame" when db_select fails\r
-                       $result = get_entity($guid);\r
-               \r
-               if ((!empty($result)) && (!($result instanceof ElggUser)))\r
-                       //throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, 'ElggUser'));\r
-                       return false;\r
-                       \r
-               if (!empty($result))\r
-                       return $result;\r
-               \r
-               return false;   \r
-       }\r
-       \r
-       /**\r
-        * Get user by username\r
-        *\r
-        * @param string $username The user's username\r
-        * @return ElggUser|false Depending on success\r
-        */\r
-       function get_user_by_username($username)\r
-       {\r
-               global $CONFIG, $USERNAME_TO_GUID_MAP_CACHE;\r
-               \r
-               $username = sanitise_string($username);\r
-               $access = get_access_sql_suffix('e');\r
-               \r
-               // Caching\r
-               if ( (isset($USERNAME_TO_GUID_MAP_CACHE[$username])) && (retrieve_cached_entity($USERNAME_TO_GUID_MAP_CACHE[$username])) )\r
-                       return retrieve_cached_entity($USERNAME_TO_GUID_MAP_CACHE[$username]);\r
-               \r
-               $row = get_data_row("SELECT e.* from {$CONFIG->dbprefix}users_entity u join {$CONFIG->dbprefix}entities e on e.guid=u.guid where u.username='$username' and $access ");\r
-               if ($row) {\r
-                       $USERNAME_TO_GUID_MAP_CACHE[$username] = $row->guid;\r
-                       return new ElggUser($row);\r
-               } \r
-               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Get user by session code\r
-        *\r
-        * @param string $code The session code\r
-        * @return ElggUser|false Depending on success\r
-        */\r
-       function get_user_by_code($code)\r
-       {\r
-               global $CONFIG, $CODE_TO_GUID_MAP_CACHE;\r
-               \r
-               $code = sanitise_string($code);\r
-               \r
-               $access = get_access_sql_suffix('e');\r
-               \r
-               // Caching\r
-               if ( (isset($CODE_TO_GUID_MAP_CACHE[$code])) && (retrieve_cached_entity($CODE_TO_GUID_MAP_CACHE[$code])) )\r
-                       return retrieve_cached_entity($CODE_TO_GUID_MAP_CACHE[$code]);\r
-               \r
-               $row = get_data_row("SELECT e.* from {$CONFIG->dbprefix}users_entity u join {$CONFIG->dbprefix}entities e on e.guid=u.guid where u.code='$code' and $access");\r
-               if ($row) {\r
-                       $CODE_TO_GUID_MAP_CACHE[$code] = $row->guid;\r
-                       return new ElggUser($row);\r
-               } \r
-               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Get an array of users from their\r
-        *\r
-        * @param string $email Email address.\r
-        * @return Array of users\r
-        */\r
-       function get_user_by_email($email)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $email = sanitise_string($email);\r
-               \r
-               $access = get_access_sql_suffix('e');\r
-               \r
-               $query = "SELECT e.* from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid=u.guid where email='$email' and $access";\r
-               \r
-               return get_data($query, 'entity_row_to_elggstar');\r
-       }\r
-       \r
-       /**\r
-        * Searches for a user based on a complete or partial name or username.\r
-        *\r
-        * @param string $criteria The partial or full name or username.\r
-        * @param int $limit Limit of the search.\r
-        * @param int $offset Offset.\r
-        * @param string $order_by The order.\r
-        * @param boolean $count Whether to return the count of results or just the results. \r
-        */\r
-       function search_for_user($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $criteria = sanitise_string($criteria);\r
-               $limit = (int)$limit;\r
-               $offset = (int)$offset;\r
-               $order_by = sanitise_string($order_by);\r
-               \r
-               $access = get_access_sql_suffix("e");\r
-               \r
-               if ($order_by == "") $order_by = "e.time_created desc";\r
-               \r
-               if ($count) {\r
-                       $query = "SELECT count(e.guid) as total ";\r
-               } else {\r
-                       $query = "SELECT e.* "; \r
-               }\r
-               $query .= "from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid=u.guid where ";\r
-               // $query .= " match(u.name,u.username) against ('$criteria') ";\r
-               $query .= "(u.name like \"%{$criteria}%\" or u.username like \"%{$criteria}%\")";\r
-               $query .= " and $access";\r
-               \r
-               if (!$count) {\r
-                       $query .= " order by $order_by limit $offset, $limit"; // Add order and limit\r
-                       return get_data($query, "entity_row_to_elggstar");\r
-               } else {\r
-                       if ($count = get_data_row($query)) {\r
-                               return $count->total;\r
-                       }\r
-               }\r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Displays a list of user objects that have been searched for.\r
-        *\r
-        * @see elgg_view_entity_list\r
-        * \r
+               return 1; // Always return that we have deleted one row in order to not break existing code.
+       }
+
+       /**
+        * Get the sites this user is part of
+        *
+        * @param int $user_guid The user's GUID
+        * @param int $limit Number of results to return
+        * @param int $offset Any indexing offset
+        * @return false|array On success, an array of ElggSites
+        */
+       function get_user_sites($user_guid, $limit = 10, $offset = 0) {
+               $user_guid = (int)$user_guid;
+               $limit = (int)$limit;
+               $offset = (int)$offset;
+               
+               return get_entities_from_relationship("member_of_site", $user_guid, false, "site", "", 0, "time_created desc", $limit, $offset);
+       }
+       
+       /**
+        * Adds a user to another user's friends list.
+        *
+        * @param int $user_guid The GUID of the friending user
+        * @param int $friend_guid The GUID of the user to friend
+        * @return true|false Depending on success
+        */
+       function user_add_friend($user_guid, $friend_guid) {
+               $user_guid = (int) $user_guid; 
+               $friend_guid = (int) $friend_guid;
+               if ($user_guid == $friend_guid) return false;
+               if (!$friend = get_entity($friend_guid)) return false;
+               if (!$user = get_entity($user_guid)) return false;
+               if ( (!($user instanceof ElggUser)) || (!($friend instanceof ElggUser)) ) return false;
+               return add_entity_relationship($user_guid, "friend", $friend_guid);
+       }
+       
+       /**
+        * Removes a user from another user's friends list.
+        *
+        * @param int $user_guid The GUID of the friending user
+        * @param int $friend_guid The GUID of the user on the friends list
+        * @return true|false Depending on success
+        */
+       function user_remove_friend($user_guid, $friend_guid) {
+               global $CONFIG;
+               
+               $user_guid = (int) $user_guid; 
+               $friend_guid = (int) $friend_guid;
+               
+               // perform cleanup for access lists.
+               $collections = get_user_access_collections($user_guid);
+               foreach ($collections as $collection) {
+                       remove_user_from_access_collection($friend_guid, $collection->id);
+               }
+               
+               return remove_entity_relationship($user_guid, "friend", $friend_guid);
+       }
+       
+       /**
+        * Determines whether or not a user is another user's friend.
+        *
+        * @param int $user_guid The GUID of the user
+        * @param int $friend_guid The GUID of the friend
+        * @return true|false
+        */
+       function user_is_friend($user_guid, $friend_guid) {
+               return check_entity_relationship($user_guid, "friend", $friend_guid);
+       }
+
+       /**
+        * Obtains a given user's friends
+        *
+        * @param int $user_guid The user's GUID
+        * @param string $subtype The subtype of users, if any
+        * @param int $limit Number of results to return (default 10)
+        * @param int $offset Indexing offset, if any
+        * @return false|array Either an array of ElggUsers or false, depending on success
+        */
+       function get_user_friends($user_guid, $subtype = "", $limit = 10, $offset = 0) {
+               return get_entities_from_relationship("friend",$user_guid,false,"user",$subtype,0,"time_created desc",$limit,$offset);
+       }
+       
+       /**
+        * Obtains the people who have made a given user a friend
+        *
+        * @param int $user_guid The user's GUID
+        * @param string $subtype The subtype of users, if any
+        * @param int $limit Number of results to return (default 10)
+        * @param int $offset Indexing offset, if any
+        * @return false|array Either an array of ElggUsers or false, depending on success
+        */
+       function get_user_friends_of($user_guid, $subtype = "", $limit = 10, $offset = 0) {
+               return get_entities_from_relationship("friend",$user_guid,true,"user",$subtype,0,"time_created desc",$limit,$offset);
+       }
+
+       /**
+        * Obtains a list of objects owned by a user
+        *
+        * @param int $user_guid The GUID of the owning user
+        * @param string $subtype Optionally, the subtype of objects
+        * @param int $limit The number of results to return (default 10)
+        * @param int $offset Indexing offset, if any
+        * @param int $timelower The earliest time the entity can have been created. Default: all
+        * @param int $timeupper The latest time the entity can have been created. Default: all
+        * @return false|array An array of ElggObjects or false, depending on success
+        */
+       function get_user_objects($user_guid, $subtype = "", $limit = 10, $offset = 0, $timelower = 0, $timeupper = 0) {
+               $ntt = get_entities('object',$subtype, $user_guid, "time_created desc", $limit, $offset,false,0,$user_guid,$timelower, $timeupper);
+               return $ntt;
+       }
+       
+       /**
+        * Counts the objects (optionally of a particular subtype) owned by a user
+        *
+        * @param int $user_guid The GUID of the owning user
+        * @param string $subtype Optionally, the subtype of objects
+        * @param int $timelower The earliest time the entity can have been created. Default: all
+        * @param int $timeupper The latest time the entity can have been created. Default: all
+        * @return int The number of objects the user owns (of this subtype)
+        */
+       function count_user_objects($user_guid, $subtype = "", $timelower, $timeupper) {
+               $total = get_entities('object', $subtype, $user_guid, "time_created desc", null, null, true, 0, $user_guid,$timelower,$timeupper);
+               return $total;
+       }
+
+       /**
+        * Displays a list of user objects of a particular subtype, with navigation.
+        *
+        * @see elgg_view_entity_list
+        * 
+        * @param int $user_guid The GUID of the user
+        * @param string $subtype The object subtype
+        * @param int $limit The number of entities to display on a page
+        * @param true|false $fullview Whether or not to display the full view (default: true)
+        * @param int $timelower The earliest time the entity can have been created. Default: all
+        * @param int $timeupper The latest time the entity can have been created. Default: all
+        * @return string The list in a form suitable to display
+        */
+       function list_user_objects($user_guid, $subtype = "", $limit = 10, $fullview = true, $viewtypetoggle = true, $pagination = true, $timelower = 0, $timeupper = 0) {
+               
+               $offset = (int) get_input('offset');
+               $limit = (int) $limit;
+               $count = (int) count_user_objects($user_guid, $subtype,$timelower,$timeupper);
+               $entities = get_user_objects($user_guid, $subtype, $limit, $offset, $timelower, $timeupper);
+               
+               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);
+               
+       }
+       
+       /**
+        * Obtains a list of objects owned by a user's friends
+        *
+        * @param int $user_guid The GUID of the user to get the friends of
+        * @param string $subtype Optionally, the subtype of objects
+        * @param int $limit The number of results to return (default 10)
+        * @param int $offset Indexing offset, if any
+        * @return false|array An array of ElggObjects or false, depending on success
+        */
+       function get_user_friends_objects($user_guid, $subtype = "", $limit = 10, $offset = 0) {
+               if ($friends = get_user_friends($user_guid, $subtype, 999999, 0)) {
+                       $friendguids = array();
+                       foreach($friends as $friend) {
+                               $friendguids[] = $friend->getGUID();
+                       }
+                       return get_entities('object',$subtype,$friendguids, "time_created desc", $limit, $offset, false, 0, $friendguids);
+               }
+               return false;
+       }
+       
+       /**
+        * Counts the number of objects owned by a user's friends
+        *
+        * @param int $user_guid The GUID of the user to get the friends of
+        * @param string $subtype Optionally, the subtype of objects
+        * @return int The number of objects
+        */
+       function count_user_friends_objects($user_guid, $subtype = "") {
+               if ($friends = get_user_friends($user_guid, $subtype, 999999, 0)) {
+                       $friendguids = array();
+                       foreach($friends as $friend) {
+                               $friendguids[] = $friend->getGUID();
+                       }
+                       return get_entities('object',$subtype,$friendguids, "time_created desc", $limit, $offset, true, 0, $friendguids);
+               }
+               return 0;
+       }
+
+       /**
+        * Displays a list of a user's friends' objects of a particular subtype, with navigation.
+        *
+        * @see elgg_view_entity_list
+        * 
+        * @param int $user_guid The GUID of the user
+        * @param string $subtype The object subtype
+        * @param int $limit The number of entities to display on a page
+        * @param true|false $fullview Whether or not to display the full view (default: true)
+        * @param true|false $viewtypetoggle Whether or not to allow you to flip to gallery mode (default: true)
+        * @return string The list in a form suitable to display
+        */
+       function list_user_friends_objects($user_guid, $subtype = "", $limit = 10, $fullview = true, $viewtypetoggle = true, $pagination = true) {
+               
+               $offset = (int) get_input('offset');
+               $limit = (int) $limit;
+               $count = (int) count_user_friends_objects($user_guid, $subtype);
+               $entities = get_user_friends_objects($user_guid, $subtype, $limit, $offset);
+               
+               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination);
+               
+       }
+       
+       /**
+        * Get user objects by an array of metadata
+        *
+        * @param int $user_guid The GUID of the owning user
+        * @param string $subtype Optionally, the subtype of objects
+        * @paran array $metadata An array of metadata
+        * @param int $limit The number of results to return (default 10)
+        * @param int $offset Indexing offset, if any
+        * @return false|array An array of ElggObjects or false, depending on success
+        * @return unknown
+        */
+       function get_user_objects_by_metadata($user_guid, $subtype = "", $metadata = array(), $limit = 0, $offset = 0) {
+               
+               return get_entities_from_metadata_multi($metadata,"object",$subtype,$user_guid,$limit,$offset);
+               
+       }
+       
+       /**
+        * Get a user object from a GUID.
+        * 
+        * This function returns an ElggUser from a given GUID.
+        * @param int $guid The GUID
+        * @return ElggUser|false 
+        */
+       function get_user($guid)
+       {
+               if (!empty($guid)) // Fixes "Exception thrown without stack frame" when db_select fails
+                       $result = get_entity($guid);
+               
+               if ((!empty($result)) && (!($result instanceof ElggUser)))
+                       //throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, 'ElggUser'));
+                       return false;
+                       
+               if (!empty($result))
+                       return $result;
+               
+               return false;   
+       }
+       
+       /**
+        * Get user by username
+        *
+        * @param string $username The user's username
+        * @return ElggUser|false Depending on success
+        */
+       function get_user_by_username($username)
+       {
+               global $CONFIG, $USERNAME_TO_GUID_MAP_CACHE;
+               
+               $username = sanitise_string($username);
+               $access = get_access_sql_suffix('e');
+               
+               // Caching
+               if ( (isset($USERNAME_TO_GUID_MAP_CACHE[$username])) && (retrieve_cached_entity($USERNAME_TO_GUID_MAP_CACHE[$username])) )
+                       return retrieve_cached_entity($USERNAME_TO_GUID_MAP_CACHE[$username]);
+               
+               $row = get_data_row("SELECT e.* from {$CONFIG->dbprefix}users_entity u join {$CONFIG->dbprefix}entities e on e.guid=u.guid where u.username='$username' and $access ");
+               if ($row) {
+                       $USERNAME_TO_GUID_MAP_CACHE[$username] = $row->guid;
+                       return new ElggUser($row);
+               } 
+               
+               return false;
+       }
+       
+       /**
+        * Get user by session code
+        *
+        * @param string $code The session code
+        * @return ElggUser|false Depending on success
+        */
+       function get_user_by_code($code)
+       {
+               global $CONFIG, $CODE_TO_GUID_MAP_CACHE;
+               
+               $code = sanitise_string($code);
+               
+               $access = get_access_sql_suffix('e');
+               
+               // Caching
+               if ( (isset($CODE_TO_GUID_MAP_CACHE[$code])) && (retrieve_cached_entity($CODE_TO_GUID_MAP_CACHE[$code])) )
+                       return retrieve_cached_entity($CODE_TO_GUID_MAP_CACHE[$code]);
+               
+               $row = get_data_row("SELECT e.* from {$CONFIG->dbprefix}users_entity u join {$CONFIG->dbprefix}entities e on e.guid=u.guid where u.code='$code' and $access");
+               if ($row) {
+                       $CODE_TO_GUID_MAP_CACHE[$code] = $row->guid;
+                       return new ElggUser($row);
+               } 
+               
+               return false;
+       }
+       
+       /**
+        * Get an array of users from their
+        *
+        * @param string $email Email address.
+        * @return Array of users
+        */
+       function get_user_by_email($email)
+       {
+               global $CONFIG;
+               
+               $email = sanitise_string($email);
+               
+               $access = get_access_sql_suffix('e');
+               
+               $query = "SELECT e.* from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid=u.guid where email='$email' and $access";
+               
+               return get_data($query, 'entity_row_to_elggstar');
+       }
+       
+       /**
+        * Searches for a user based on a complete or partial name or username.
+        *
+        * @param string $criteria The partial or full name or username.
+        * @param int $limit Limit of the search.
+        * @param int $offset Offset.
+        * @param string $order_by The order.
+        * @param boolean $count Whether to return the count of results or just the results. 
+        */
+       function search_for_user($criteria, $limit = 10, $offset = 0, $order_by = "", $count = false)
+       {
+               global $CONFIG;
+               
+               $criteria = sanitise_string($criteria);
+               $limit = (int)$limit;
+               $offset = (int)$offset;
+               $order_by = sanitise_string($order_by);
+               
+               $access = get_access_sql_suffix("e");
+               
+               if ($order_by == "") $order_by = "e.time_created desc";
+               
+               if ($count) {
+                       $query = "SELECT count(e.guid) as total ";
+               } else {
+                       $query = "SELECT e.* "; 
+               }
+               $query .= "from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid=u.guid where ";
+               // $query .= " match(u.name,u.username) against ('$criteria') ";
+               $query .= "(u.name like \"%{$criteria}%\" or u.username like \"%{$criteria}%\")";
+               $query .= " and $access";
+               
+               if (!$count) {
+                       $query .= " order by $order_by limit $offset, $limit"; // Add order and limit
+                       return get_data($query, "entity_row_to_elggstar");
+               } else {
+                       if ($count = get_data_row($query)) {
+                               return $count->total;
+                       }
+               }
+               return false;
+       }
+       
+       /**
+        * Displays a list of user objects that have been searched for.
+        *
+        * @see elgg_view_entity_list
+        * 
         * @param string $tag Search criteria
         * @param int $limit The number of entities to display on a page
-        * @return string The list in a form suitable to display\r
-        */\r
-       function list_user_search($tag, $limit = 10) {\r
-               \r
-               $offset = (int) get_input('offset');\r
-               $limit = (int) $limit;\r
-               $count = (int) search_for_user($tag, 10, 0, '', true);\r
-               $entities = search_for_user($tag, $limit, $offset);\r
-               \r
-               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, false);\r
-               \r
-       }\r
-       \r
-       /**\r
-        * A function that returns a maximum of $limit users who have done something within the last \r
-        * $seconds seconds.\r
-        *\r
-        * @param int $seconds Number of seconds (default 600 = 10min)\r
-        * @param int $limit Limit, default 10.\r
-        * @param int $offset Offset, defualt 0.\r
-        */\r
-       function find_active_users($seconds = 600, $limit = 10, $offset = 0)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $seconds = (int)$seconds;\r
-               $limit = (int)$limit;\r
-               $offset = (int)$offset;\r
-               \r
-               $time = time() - $seconds;\r
-\r
-               $access = get_access_sql_suffix("e");\r
-               \r
-               $query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid = u.guid where u.last_action >= {$time} and $access order by u.last_action desc limit {$offset},{$limit}";\r
-               \r
-               return get_data($query, "entity_row_to_elggstar");\r
-       }\r
-       \r
-       /**\r
-        * Generate and send a password request email to a given user's registered email address.\r
-        *\r
-        * @param int $user_guid\r
-        */\r
-       function send_new_password_request($user_guid)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $user_guid = (int)$user_guid;\r
-               \r
-               $user = get_entity($user_guid);\r
-               if ($user)\r
-               {\r
-                       // generate code\r
-                       $code = generate_random_cleartext_password();\r
-                       //create_metadata($user_guid, 'conf_code', $code,'', 0, ACCESS_PRIVATE);\r
-                       set_private_setting($user_guid, 'passwd_conf_code', $code);\r
-                       \r
-                       // generate link\r
-                       $link = $CONFIG->site->url . "action/user/passwordreset?u=$user_guid&c=$code";\r
-                       \r
-                       // generate email\r
-                       $email = sprintf(elgg_echo('email:resetreq:body'), $user->name, $_SERVER['REMOTE_ADDR'], $link);\r
-                       \r
-                       return notify_user($user->guid, $CONFIG->site->guid, elgg_echo('email:resetreq:subject'), $email, NULL, 'email');\r
-\r
-               }\r
-               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Low level function to reset a given user's password. \r
-        * \r
-        * This can only be called from execute_new_password_request().\r
-        * \r
-        * @param int $user_guid The user.\r
-        * @param string $password password text (which will then be converted into a hash and stored)\r
-        */\r
-       function force_user_password_reset($user_guid, $password)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               if (call_gatekeeper('execute_new_password_request', __FILE__))\r
-               {\r
-                       $user = get_entity($user_guid);\r
-                       \r
-                       if ($user)\r
-                       {\r
+        * @return string The list in a form suitable to display
+        */
+       function list_user_search($tag, $limit = 10) {
+               
+               $offset = (int) get_input('offset');
+               $limit = (int) $limit;
+               $count = (int) search_for_user($tag, 10, 0, '', true);
+               $entities = search_for_user($tag, $limit, $offset);
+               
+               return elgg_view_entity_list($entities, $count, $offset, $limit, $fullview, false);
+               
+       }
+       
+       /**
+        * A function that returns a maximum of $limit users who have done something within the last 
+        * $seconds seconds.
+        *
+        * @param int $seconds Number of seconds (default 600 = 10min)
+        * @param int $limit Limit, default 10.
+        * @param int $offset Offset, defualt 0.
+        */
+       function find_active_users($seconds = 600, $limit = 10, $offset = 0)
+       {
+               global $CONFIG;
+               
+               $seconds = (int)$seconds;
+               $limit = (int)$limit;
+               $offset = (int)$offset;
+               
+               $time = time() - $seconds;
+
+               $access = get_access_sql_suffix("e");
+               
+               $query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}users_entity u on e.guid = u.guid where u.last_action >= {$time} and $access order by u.last_action desc limit {$offset},{$limit}";
+               
+               return get_data($query, "entity_row_to_elggstar");
+       }
+       
+       /**
+        * Generate and send a password request email to a given user's registered email address.
+        *
+        * @param int $user_guid
+        */
+       function send_new_password_request($user_guid)
+       {
+               global $CONFIG;
+               
+               $user_guid = (int)$user_guid;
+               
+               $user = get_entity($user_guid);
+               if ($user)
+               {
+                       // generate code
+                       $code = generate_random_cleartext_password();
+                       //create_metadata($user_guid, 'conf_code', $code,'', 0, ACCESS_PRIVATE);
+                       set_private_setting($user_guid, 'passwd_conf_code', $code);
+                       
+                       // generate link
+                       $link = $CONFIG->site->url . "action/user/passwordreset?u=$user_guid&c=$code";
+                       
+                       // generate email
+                       $email = sprintf(elgg_echo('email:resetreq:body'), $user->name, $_SERVER['REMOTE_ADDR'], $link);
+                       
+                       return notify_user($user->guid, $CONFIG->site->guid, elgg_echo('email:resetreq:subject'), $email, NULL, 'email');
+
+               }
+               
+               return false;
+       }
+       
+       /**
+        * Low level function to reset a given user's password. 
+        * 
+        * This can only be called from execute_new_password_request().
+        * 
+        * @param int $user_guid The user.
+        * @param string $password password text (which will then be converted into a hash and stored)
+        */
+       function force_user_password_reset($user_guid, $password)
+       {
+               global $CONFIG;
+               
+               if (call_gatekeeper('execute_new_password_request', __FILE__))
+               {
+                       $user = get_entity($user_guid);
+                       
+                       if ($user)
+                       {
                                $salt = generate_random_cleartext_password(); // Reset the salt
                                $user->salt = $salt;
-                               \r
-                               $hash = generate_user_password($user, $password);\r
-                               \r
-                               return update_data("UPDATE {$CONFIG->dbprefix}users_entity set password='$hash', salt='$salt' where guid=$user_guid");\r
-                       }\r
-               }\r
-               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Validate and execute a password reset for a user.\r
-        *\r
-        * @param int $user_guid The user id\r
-        * @param string $conf_code Confirmation code as sent in the request email.\r
-        */\r
-       function execute_new_password_request($user_guid, $conf_code)\r
-       {\r
-               global $CONFIG;\r
-               \r
-               $user_guid = (int)$user_guid;\r
-               \r
-               $user = get_entity($user_guid);\r
-               if (($user) && (get_private_setting($user_guid, 'passwd_conf_code') == $conf_code))\r
-               {\r
-                       $password = generate_random_cleartext_password();\r
-                       \r
-                       if (force_user_password_reset($user_guid, $password))\r
-                       {\r
-                               //remove_metadata($user_guid, 'conf_code');\r
-                               remove_private_setting($user_guid, 'passwd_conf_code');\r
-                               \r
-                               $email = sprintf(elgg_echo('email:resetpassword:body'), $user->name, $password);\r
-                               \r
-                               return notify_user($user->guid, $CONFIG->site->guid, elgg_echo('email:resetpassword:subject'), $email, NULL, 'email');\r
-                       }\r
-               }\r
-               \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Set the validation status for a user.\r
-        *\r
-        * @param bool $status Validated (true) or false\r
-        * @param string $method Optional method to say how a user was validated\r
-        * @return bool\r
-        */\r
-       function set_user_validation_status($user_guid, $status, $method = '')\r
-       {\r
-               if (!$status) $method = '';\r
+                               
+                               $hash = generate_user_password($user, $password);
+                               
+                               return update_data("UPDATE {$CONFIG->dbprefix}users_entity set password='$hash', salt='$salt' where guid=$user_guid");
+                       }
+               }
+               
+               return false;
+       }
+       
+       /**
+        * Validate and execute a password reset for a user.
+        *
+        * @param int $user_guid The user id
+        * @param string $conf_code Confirmation code as sent in the request email.
+        */
+       function execute_new_password_request($user_guid, $conf_code)
+       {
+               global $CONFIG;
+               
+               $user_guid = (int)$user_guid;
+               
+               $user = get_entity($user_guid);
+               if (($user) && (get_private_setting($user_guid, 'passwd_conf_code') == $conf_code))
+               {
+                       $password = generate_random_cleartext_password();
+                       
+                       if (force_user_password_reset($user_guid, $password))
+                       {
+                               //remove_metadata($user_guid, 'conf_code');
+                               remove_private_setting($user_guid, 'passwd_conf_code');
+                               
+                               $email = sprintf(elgg_echo('email:resetpassword:body'), $user->name, $password);
+                               
+                               return notify_user($user->guid, $CONFIG->site->guid, elgg_echo('email:resetpassword:subject'), $email, NULL, 'email');
+                       }
+               }
+               
+               return false;
+       }
+       
+       /**
+        * Set the validation status for a user.
+        *
+        * @param bool $status Validated (true) or false
+        * @param string $method Optional method to say how a user was validated
+        * @return bool
+        */
+       function set_user_validation_status($user_guid, $status, $method = '')
+       {
+               if (!$status) $method = '';
                
                if ($status)
-               {\r
+               {
                        if (
                                (create_metadata($user_guid, 'validated', $status,'', 0, ACCESS_PUBLIC)) &&
                                (create_metadata($user_guid, 'validated_method', $method,'', 0, ACCESS_PUBLIC))
                                (delete_metadata($validated_method->id))
                        )
                                return true;
-               }\r
-                       \r
-               return false;\r
-       }\r
-       \r
-       /**\r
-        * Trigger an event requesting that a user guid be validated somehow - either by email address or some other way.\r
-        *\r
-        * This event invalidates any existing values and returns\r
-        * \r
-        * @param unknown_type $user_guid\r
-        */\r
-       function request_user_validation($user_guid)\r
-       {\r
-               $user = get_entity($user_guid);\r
-\r
-               if (($user) && ($user instanceof ElggUser))\r
-               {\r
-                       // invalidate any existing validations\r
-                       set_user_validation_status($user_guid, false);\r
-                       \r
-                       // request validation\r
-                       trigger_elgg_event('validate', 'user', $user);\r
-                       \r
-               }\r
-       }\r
-       \r
-       /**\r
-        * Validates an email address.\r
-        *\r
-        * @param string $address Email address.\r
-        * @return bool\r
-        */\r
-       function is_email_address($address)\r
-       {\r
-               // TODO: Make this better!\r
-               \r
-               if (strpos($address, '@')=== false) \r
-                       return false;\r
-               \r
-               if (strpos($address, '.')=== false)\r
-                       return false;\r
-                       \r
-               return true;\r
-       }\r
-       \r
-       /**\r
-        * Simple function that will generate a random clear text password suitable for feeding into generate_user_password().\r
-        *\r
-        * @see generate_user_password\r
-        * @return string\r
-        */\r
-       function generate_random_cleartext_password()\r
-       {\r
-               return substr(md5(microtime() . rand()), 0, 8);\r
-       }\r
-       \r
-       /**\r
-        * Generate a password for a user, currently uses MD5.\r
-        * \r
-        * Later may introduce salting etc.\r
-        *\r
-        * @param ElggUser $user The user this is being generated for.\r
-        * @param string $password Password in clear text\r
-        */\r
-       function generate_user_password(ElggUser $user, $password)\r
-       {\r
-               return md5($password . $user->salt);\r
-       }\r
-       \r
-       /**\r
-        * Simple function which ensures that a username contains only valid characters.\r
-        * \r
-        * This should only permit chars that are valid on the file system as well.\r
-        *\r
-        * @param string $username\r
-        * @throws RegistrationException on invalid\r
-        */\r
-       function validate_username($username)\r
+               }
+                       
+               return false;
+       }
+       
+       /**
+        * Trigger an event requesting that a user guid be validated somehow - either by email address or some other way.
+        *
+        * This event invalidates any existing values and returns
+        * 
+        * @param unknown_type $user_guid
+        */
+       function request_user_validation($user_guid)
+       {
+               $user = get_entity($user_guid);
+
+               if (($user) && ($user instanceof ElggUser))
+               {
+                       // invalidate any existing validations
+                       set_user_validation_status($user_guid, false);
+                       
+                       // request validation
+                       trigger_elgg_event('validate', 'user', $user);
+                       
+               }
+       }
+       
+       /**
+        * Validates an email address.
+        *
+        * @param string $address Email address.
+        * @return bool
+        */
+       function is_email_address($address)
+       {
+               // TODO: Make this better!
+               
+               if (strpos($address, '@')=== false) 
+                       return false;
+               
+               if (strpos($address, '.')=== false)
+                       return false;
+                       
+               return true;
+       }
+       
+       /**
+        * Simple function that will generate a random clear text password suitable for feeding into generate_user_password().
+        *
+        * @see generate_user_password
+        * @return string
+        */
+       function generate_random_cleartext_password()
+       {
+               return substr(md5(microtime() . rand()), 0, 8);
+       }
+       
+       /**
+        * Generate a password for a user, currently uses MD5.
+        * 
+        * Later may introduce salting etc.
+        *
+        * @param ElggUser $user The user this is being generated for.
+        * @param string $password Password in clear text
+        */
+       function generate_user_password(ElggUser $user, $password)
+       {
+               return md5($password . $user->salt);
+       }
+       
+       /**
+        * Simple function which ensures that a username contains only valid characters.
+        * 
+        * This should only permit chars that are valid on the file system as well.
+        *
+        * @param string $username
+        * @throws RegistrationException on invalid
+        */
+       function validate_username($username)
        {
                global $CONFIG;
-               \r
+               
                // Basic, check length
                if (!isset($CONFIG->minusername)) {
                        $CONFIG->minusername = 4;
                }
-               \r
+               
                if (strlen($username) < $CONFIG->minusername)
-                       throw new RegistrationException(elgg_echo('registration:usernametooshort'));\r
-               \r
-               // Blacklist for bad characters (partially nicked from mediawiki)\r
-               \r
-               $blacklist = '/[' .\r
-                       '\x{0080}-\x{009f}' . # iso-8859-1 control chars\r
-                       '\x{00a0}' .          # non-breaking space\r
-                       '\x{2000}-\x{200f}' . # various whitespace\r
-                       '\x{2028}-\x{202f}' . # breaks and control chars\r
-                       '\x{3000}' .          # ideographic space\r
-                       '\x{e000}-\x{f8ff}' . # private use\r
-                       ']/u';\r
-               \r
-               if (\r
-                       preg_match($blacklist, $username) \r
-               )\r
+                       throw new RegistrationException(elgg_echo('registration:usernametooshort'));
+               
+               // Blacklist for bad characters (partially nicked from mediawiki)
+               
+               $blacklist = '/[' .
+                       '\x{0080}-\x{009f}' . # iso-8859-1 control chars
+                       '\x{00a0}' .          # non-breaking space
+                       '\x{2000}-\x{200f}' . # various whitespace
+                       '\x{2028}-\x{202f}' . # breaks and control chars
+                       '\x{3000}' .          # ideographic space
+                       '\x{e000}-\x{f8ff}' . # private use
+                       ']/u';
+               
+               if (
+                       preg_match($blacklist, $username) 
+               )
                        throw new RegistrationException(elgg_echo('registration:invalidchars'));
                        
                // Belts and braces TODO: Tidy into main unicode
                $blacklist2 = '/\\"\'*& ?#%^(){}[]~?<>;|¬`@-+=';
                for ($n=0; $n < strlen($blacklist2); $n++)
                        if (strpos($username, $blacklist2[$n])!==false)
-                               throw new RegistrationException(elgg_echo('registration:invalidchars'));\r
-                \r
-               $result = true;\r
-               return trigger_plugin_hook('registeruser:validate:username', 'all', array('username' => $username), $result);\r
-       }\r
-       \r
-       /**\r
-        * Simple validation of a password.\r
-        *\r
-        * @param string $password\r
-        * @throws RegistrationException on invalid\r
-        */\r
-       function validate_password($password)\r
-       {\r
-               if (strlen($password)<6) throw new RegistrationException(elgg_echo('registration:passwordtooshort'));\r
-                       \r
-               $result = true;\r
-               return trigger_plugin_hook('registeruser:validate:password', 'all', array('password' => $password), $result);\r
-       }\r
-       \r
-       /**\r
-        * Simple validation of a email.\r
-        *\r
-        * @param string $address\r
-        * @throws RegistrationException on invalid\r
-        * @return bool\r
-        */\r
-       function validate_email_address($address)\r
-       {\r
-               if (!is_email_address($address)) throw new RegistrationException(elgg_echo('registration:notemail'));\r
-               \r
-               // Got here, so lets try a hook (defaulting to ok)\r
-               $result = true;\r
-               return trigger_plugin_hook('registeruser:validate:email', 'all', array('email' => $address), $result);\r
-       }\r
-       \r
-       /**\r
-        * Registers a user, returning false if the username already exists\r
-        *\r
-        * @param string $username The username of the new user\r
-        * @param string $password The password\r
-        * @param string $name The user's display name\r
-        * @param string $email Their email address\r
-        * @param bool $allow_multiple_emails Allow the same email address to be registered multiple times?\r
-        * @param int $friend_guid Optionally, GUID of a user this user will friend once fully registered \r
-        * @return int|false The new user's GUID; false on failure\r
-        */\r
-       function register_user($username, $password, $name, $email, $allow_multiple_emails = false, $friend_guid = 0, $invitecode = '') {\r
-               \r
-               // Load the configuration\r
-                       global $CONFIG;\r
-                       \r
-                       $username = trim($username);\r
-                       $password = trim($password);\r
-                       $name = trim($name);\r
-                       $email = trim($email);\r
-                       \r
-               // A little sanity checking\r
-                       if (empty($username)\r
-                               || empty($password)\r
-                               || empty($name)\r
-                               || empty($email)) {\r
-                                       return false;\r
-                               }       \r
-                       \r
-                       // See if it exists and is disabled\r
-                       $access_status = access_get_show_hidden_status();\r
-                       access_show_hidden_entities(true);\r
-                               \r
-                       // Validate email address\r
-                       if (!validate_email_address($email)) throw new RegistrationException(elgg_echo('registration:emailnotvalid'));\r
-                       \r
-                       // Validate password\r
-                       if (!validate_password($password)) throw new RegistrationException(elgg_echo('registration:passwordnotvalid'));\r
-                       \r
-                       // Validate the username\r
-                       if (!validate_username($username)) throw new RegistrationException(elgg_echo('registration:usernamenotvalid'));\r
-                               \r
-               // Check to see if $username exists already\r
-                       if ($user = get_user_by_username($username)) {\r
-                               //return false;\r
-                               throw new RegistrationException(elgg_echo('registration:userexists'));\r
-                       }\r
-                       \r
-               // If we're not allowed multiple emails then see if this address has been used before\r
-                       if ((!$allow_multiple_emails) && (get_user_by_email($email)))\r
-                       {\r
-                               throw new RegistrationException(elgg_echo('registration:dupeemail'));\r
-                       }\r
-                       \r
-                       access_show_hidden_entities($access_status);\r
-                       \r
-               // Check to see if we've registered the first admin yet.\r
-               // If not, this is the first admin user!\r
-                       $admin = datalist_get('admin_registered');\r
-                       \r
-               // Otherwise ...\r
-                       $user = new ElggUser();\r
-                       $user->username = $username;\r
-                       $user->email = $email;\r
-                       $user->name = $name;\r
-                       $user->access_id = ACCESS_PUBLIC;\r
-                       $user->salt = generate_random_cleartext_password(); // Note salt generated before password!\r
+                               throw new RegistrationException(elgg_echo('registration:invalidchars'));
+                
+               $result = true;
+               return trigger_plugin_hook('registeruser:validate:username', 'all', array('username' => $username), $result);
+       }
+       
+       /**
+        * Simple validation of a password.
+        *
+        * @param string $password
+        * @throws RegistrationException on invalid
+        */
+       function validate_password($password)
+       {
+               if (strlen($password)<6) throw new RegistrationException(elgg_echo('registration:passwordtooshort'));
+                       
+               $result = true;
+               return trigger_plugin_hook('registeruser:validate:password', 'all', array('password' => $password), $result);
+       }
+       
+       /**
+        * Simple validation of a email.
+        *
+        * @param string $address
+        * @throws RegistrationException on invalid
+        * @return bool
+        */
+       function validate_email_address($address)
+       {
+               if (!is_email_address($address)) throw new RegistrationException(elgg_echo('registration:notemail'));
+               
+               // Got here, so lets try a hook (defaulting to ok)
+               $result = true;
+               return trigger_plugin_hook('registeruser:validate:email', 'all', array('email' => $address), $result);
+       }
+       
+       /**
+        * Registers a user, returning false if the username already exists
+        *
+        * @param string $username The username of the new user
+        * @param string $password The password
+        * @param string $name The user's display name
+        * @param string $email Their email address
+        * @param bool $allow_multiple_emails Allow the same email address to be registered multiple times?
+        * @param int $friend_guid Optionally, GUID of a user this user will friend once fully registered 
+        * @return int|false The new user's GUID; false on failure
+        */
+       function register_user($username, $password, $name, $email, $allow_multiple_emails = false, $friend_guid = 0, $invitecode = '') {
+               
+               // Load the configuration
+                       global $CONFIG;
+                       
+                       $username = trim($username);
+                       $password = trim($password);
+                       $name = trim($name);
+                       $email = trim($email);
+                       
+               // A little sanity checking
+                       if (empty($username)
+                               || empty($password)
+                               || empty($name)
+                               || empty($email)) {
+                                       return false;
+                               }       
+                       
+                       // See if it exists and is disabled
+                       $access_status = access_get_show_hidden_status();
+                       access_show_hidden_entities(true);
+                               
+                       // Validate email address
+                       if (!validate_email_address($email)) throw new RegistrationException(elgg_echo('registration:emailnotvalid'));
+                       
+                       // Validate password
+                       if (!validate_password($password)) throw new RegistrationException(elgg_echo('registration:passwordnotvalid'));
+                       
+                       // Validate the username
+                       if (!validate_username($username)) throw new RegistrationException(elgg_echo('registration:usernamenotvalid'));
+                               
+               // Check to see if $username exists already
+                       if ($user = get_user_by_username($username)) {
+                               //return false;
+                               throw new RegistrationException(elgg_echo('registration:userexists'));
+                       }
+                       
+               // If we're not allowed multiple emails then see if this address has been used before
+                       if ((!$allow_multiple_emails) && (get_user_by_email($email)))
+                       {
+                               throw new RegistrationException(elgg_echo('registration:dupeemail'));
+                       }
+                       
+                       access_show_hidden_entities($access_status);
+                       
+               // Check to see if we've registered the first admin yet.
+               // If not, this is the first admin user!
+                       $admin = datalist_get('admin_registered');
+                       
+               // Otherwise ...
+                       $user = new ElggUser();
+                       $user->username = $username;
+                       $user->email = $email;
+                       $user->name = $name;
+                       $user->access_id = ACCESS_PUBLIC;
+                       $user->salt = generate_random_cleartext_password(); // Note salt generated before password!
                        $user->password = generate_user_password($user, $password); 
                        $user->owner_guid = 0; // Users aren't owned by anyone, even if they are admin created.
-                       $user->container_guid = 0; // Users aren't contained by anyone, even if they are admin created.\r
-                       $user->save();\r
-                       \r
-               // If $friend_guid has been set, make mutual friends\r
-                       if ($friend_guid) {\r
-                               if ($friend_user = get_user($friend_guid)) {\r
-                                       if ($invitecode == generate_invite_code($friend_user->username)) {\r
-                                               $user->addFriend($friend_guid);\r
-                                               $friend_user->addFriend($user->guid);\r
-                                       }\r
-                               }\r
-                       }\r
-                       \r
-                       global $registering_admin;\r
-                       if (!$admin) {\r
-                               $user->admin = true;\r
-                               datalist_set('admin_registered',1);\r
-                               $registering_admin = true;\r
-                       } else {\r
-                               $registering_admin = false;\r
-                       }\r
-                       \r
-                       // Turn on email notifications by default\r
-                       set_user_notification_setting($user->getGUID(), 'email', true);\r
-                       \r
-                       return $user->getGUID();\r
-       }\r
-       \r
-       /**\r
-        * Generates a unique invite code for a user\r
-        *\r
-        * @param string $username The username of the user sending the invitation\r
-        * @return string Invite code\r
-        */\r
-       function generate_invite_code($username) {\r
-               \r
-               $secret = datalist_get('__site_secret__');\r
-               return md5($username . $secret);\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Adds collection submenu items \r
-        *\r
-        */\r
-       function collections_submenu_items() {\r
-               global $CONFIG;\r
-               $user = get_loggedin_user();\r
-               add_submenu_item(elgg_echo('friends:collections'), $CONFIG->wwwroot . "pg/collections/" . $user->username);\r
-               add_submenu_item(elgg_echo('friends:collections:add'),$CONFIG->wwwroot."pg/collections/add");\r
-       }\r
-       \r
-       /**\r
-        * Page handler for friends\r
-        *\r
-        */\r
-       function friends_page_handler($page_elements) {\r
-               \r
-               if (isset($page_elements[0]) && $user = get_user_by_username($page_elements[0])) {\r
-                       set_page_owner($user->getGUID());\r
-               }\r
-               if ($_SESSION['guid'] == page_owner()) {\r
-                       collections_submenu_items();\r
-               }\r
-               require_once(dirname(dirname(dirname(__FILE__))) . "/friends/index.php");\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Page handler for friends of\r
-        *\r
-        */\r
-       function friends_of_page_handler($page_elements) {\r
-               \r
-               if (isset($page_elements[0]) && $user = get_user_by_username($page_elements[0])) {\r
-                       set_page_owner($user->getGUID());\r
-               }\r
-               if ($_SESSION['guid'] == page_owner()) {\r
-                       collections_submenu_items();\r
-               }\r
-               require_once(dirname(dirname(dirname(__FILE__))) . "/friends/of.php");\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Page handler for friends of\r
-        *\r
-        */\r
-       function collections_page_handler($page_elements) {\r
-               \r
-               if (isset($page_elements[0])) {\r
-                       if ($page_elements[0] == "add") {\r
-                               set_page_owner($_SESSION['guid']);\r
-                               collections_submenu_items();\r
-                               require_once(dirname(dirname(dirname(__FILE__))) . "/friends/add.php"); \r
-                       } else {\r
-                               if ($user = get_user_by_username($page_elements[0])) {\r
-                                       set_page_owner($user->getGUID());\r
-                                       if ($_SESSION['guid'] == page_owner()) {\r
-                                               collections_submenu_items();\r
-                                       }\r
-                                       require_once(dirname(dirname(dirname(__FILE__))) . "/friends/collections.php");\r
-                               }\r
-                       }\r
-               }\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Page handler for dashboard\r
-        */\r
-       function dashboard_page_handler($page_elements) {\r
-               @require_once(dirname(dirname(dirname(__FILE__))) . "/dashboard/index.php");\r
-       }\r
-\r
-       /**\r
-        * Sets the last action time of the given user to right now.\r
-        *\r
-        * @param int $user_guid The user GUID\r
-        */\r
-       function set_last_action($user_guid) {\r
-               \r
-               $user_guid = (int) $user_guid;\r
-               global $CONFIG;\r
-               $time = time();\r
-               \r
-               execute_delayed_write_query("UPDATE {$CONFIG->dbprefix}users_entity set prev_last_action = last_action, last_action = {$time} where guid = {$user_guid}");\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Sets the last logon time of the given user to right now.\r
-        *\r
-        * @param int $user_guid The user GUID\r
-        */\r
-       function set_last_login($user_guid) {\r
-               \r
-               $user_guid = (int) $user_guid;\r
-               global $CONFIG;\r
-               $time = time();\r
-               \r
-               execute_delayed_write_query("UPDATE {$CONFIG->dbprefix}users_entity set prev_last_login = last_login, last_login = {$time} where guid = {$user_guid}");\r
-               \r
-       }\r
-       \r
-       /**\r
-        * A permissions plugin hook that grants access to users if they are newly created - allows\r
-        * for email activation.\r
-        * \r
-        * TODO: Do this in a better way!\r
-        *\r
-        * @param unknown_type $hook\r
-        * @param unknown_type $entity_type\r
-        * @param unknown_type $returnvalue\r
-        * @param unknown_type $params\r
-        */\r
-       function new_user_enable_permissions_check($hook, $entity_type, $returnvalue, $params)\r
-       {\r
-               $entity = $params['entity'];\r
-               $user = $params['user'];\r
-               if (($entity) && ($entity instanceof ElggUser))\r
-               {\r
-                       if (\r
-                               (($entity->disable_reason == 'new_user') || (\r
-                                       // if this isn't set at all they're a "new user"\r
-                                       !$entity->validated\r
-                               ))\r
-                               && (!isloggedin()))\r
-                               return true;\r
-                       \r
-               }\r
-               \r
-               return $returnvalue;\r
-       }\r
-       \r
-       /**\r
-        * Sets up user-related menu items\r
-        *\r
-        */\r
-       function users_pagesetup() {\r
-               \r
-               // Load config\r
-                       global $CONFIG;\r
-                       \r
-               //add submenu options\r
-                       if (get_context() == "friends" || \r
-                               get_context() == "friendsof" || \r
-                               get_context() == "collections") {\r
-                               add_submenu_item(elgg_echo('friends'),$CONFIG->wwwroot."pg/friends/" . page_owner_entity()->username);\r
-                               add_submenu_item(elgg_echo('friends:of'),$CONFIG->wwwroot."pg/friendsof/" . page_owner_entity()->username);\r
-                       }\r
-               \r
-       }\r
-       \r
-       /**\r
-        * Users initialisation function, which establishes the page handler\r
-        *\r
-        */\r
-       function users_init() {\r
-               \r
-               // Load config\r
-                       global $CONFIG;\r
-               \r
-               // Set up menu for logged in users\r
-                       if (isloggedin()) {\r
-                               $user = get_loggedin_user();\r
-                               add_menu(elgg_echo('friends'), $CONFIG->wwwroot . "pg/friends/" . $user->username);\r
-                       }\r
-               \r
-               register_page_handler('friends','friends_page_handler');\r
-               register_page_handler('friendsof','friends_of_page_handler');\r
-               register_page_handler('collections','collections_page_handler');\r
-               register_page_handler('dashboard','dashboard_page_handler');\r
-               register_action("register",true);\r
-               register_action("useradd",true);\r
-               register_action("friends/add");\r
-               register_action("friends/remove");\r
-               register_action('friends/addcollection');\r
-               register_action('friends/deletecollection');\r
-        register_action('friends/editcollection');\r
-        register_action("user/spotlight");\r
-\r
-               register_action("usersettings/save");\r
-               \r
-               register_action("user/passwordreset");\r
-               register_action("user/requestnewpassword");\r
-               \r
-               // User name change\r
-               extend_elgg_settings_page('user/settings/name', 'usersettings/user', 1);\r
-               //register_action("user/name");\r
-               \r
-               // User password change\r
-               extend_elgg_settings_page('user/settings/password', 'usersettings/user', 1);\r
-               //register_action("user/password");\r
-               \r
-               // Add email settings\r
-               extend_elgg_settings_page('user/settings/email', 'usersettings/user', 1);\r
-               //register_action("email/save");\r
-               \r
-               // Add language settings\r
-               extend_elgg_settings_page('user/settings/language', 'usersettings/user', 1);\r
-               \r
-               // Add default access settings\r
-               extend_elgg_settings_page('user/settings/default_access', 'usersettings/user', 1);\r
-               \r
-               //register_action("user/language");\r
-               \r
-               // Register the user type\r
-               register_entity_type('user','');\r
-               \r
-               register_plugin_hook('usersettings:save','user','users_settings_save');\r
-               register_plugin_hook('search','all','search_list_users_by_name');\r
-               \r
-               \r
-               // Handle a special case for newly created users when the user is not logged in\r
-               // TODO: handle this better!\r
-               register_plugin_hook('permissions_check','all','new_user_enable_permissions_check');\r
-       }\r
-       \r
-       /**\r
-        * Returns a formatted list of users suitable for injecting into search.\r
-        *\r
-        */\r
-       function search_list_users_by_name($hook, $user, $returnvalue, $tag) {\r
-\r
-               // Change this to set the number of users that display on the search page\r
-               $threshold = 4;\r
-\r
-               $object = get_input('object');\r
-               \r
-               if (!get_input('offset') && (empty($object) || $object == 'user'))\r
-               if ($users = search_for_user($tag,$threshold)) {\r
-                       \r
-                       $countusers = search_for_user($tag,0,0,"",true);\r
-                       \r
-                       $return = elgg_view('user/search/startblurb',array('count' => $countusers, 'tag' => $tag));\r
-                       foreach($users as $user) {\r
-                               $return .= elgg_view_entity($user);\r
-                       }\r
-                       $return .= elgg_view('user/search/finishblurb',array('count' => $countusers, 'threshold' => $threshold, 'tag' => $tag));\r
-                       return $return;\r
-                       \r
-               }\r
-               \r
-       }\r
-       \r
-       function users_settings_save() {\r
-               \r
-               global $CONFIG;\r
-               @include($CONFIG->path . "actions/user/name.php");\r
-               @include($CONFIG->path . "actions/user/password.php");\r
-               @include($CONFIG->path . "actions/email/save.php");\r
-               @include($CONFIG->path . "actions/user/language.php");\r
-               @include($CONFIG->path . "actions/user/default_access.php");\r
-               \r
-       }\r
-       \r
-       //register actions *************************************************************\r
-   \r
-               register_elgg_event_handler('init','system','users_init',0);\r
-               register_elgg_event_handler('pagesetup','system','users_pagesetup',0);\r
-       \r
+                       $user->container_guid = 0; // Users aren't contained by anyone, even if they are admin created.
+                       $user->save();
+                       
+               // If $friend_guid has been set, make mutual friends
+                       if ($friend_guid) {
+                               if ($friend_user = get_user($friend_guid)) {
+                                       if ($invitecode == generate_invite_code($friend_user->username)) {
+                                               $user->addFriend($friend_guid);
+                                               $friend_user->addFriend($user->guid);
+                                       }
+                               }
+                       }
+                       
+                       global $registering_admin;
+                       if (!$admin) {
+                               $user->admin = true;
+                               datalist_set('admin_registered',1);
+                               $registering_admin = true;
+                       } else {
+                               $registering_admin = false;
+                       }
+                       
+                       // Turn on email notifications by default
+                       set_user_notification_setting($user->getGUID(), 'email', true);
+                       
+                       return $user->getGUID();
+       }
+       
+       /**
+        * Generates a unique invite code for a user
+        *
+        * @param string $username The username of the user sending the invitation
+        * @return string Invite code
+        */
+       function generate_invite_code($username) {
+               
+               $secret = datalist_get('__site_secret__');
+               return md5($username . $secret);
+               
+       }
+       
+       /**
+        * Adds collection submenu items 
+        *
+        */
+       function collections_submenu_items() {
+               global $CONFIG;
+               $user = get_loggedin_user();
+               add_submenu_item(elgg_echo('friends:collections'), $CONFIG->wwwroot . "pg/collections/" . $user->username);
+               add_submenu_item(elgg_echo('friends:collections:add'),$CONFIG->wwwroot."pg/collections/add");
+       }
+       
+       /**
+        * Page handler for friends
+        *
+        */
+       function friends_page_handler($page_elements) {
+               
+               if (isset($page_elements[0]) && $user = get_user_by_username($page_elements[0])) {
+                       set_page_owner($user->getGUID());
+               }
+               if ($_SESSION['guid'] == page_owner()) {
+                       collections_submenu_items();
+               }
+               require_once(dirname(dirname(dirname(__FILE__))) . "/friends/index.php");
+               
+       }
+       
+       /**
+        * Page handler for friends of
+        *
+        */
+       function friends_of_page_handler($page_elements) {
+               
+               if (isset($page_elements[0]) && $user = get_user_by_username($page_elements[0])) {
+                       set_page_owner($user->getGUID());
+               }
+               if ($_SESSION['guid'] == page_owner()) {
+                       collections_submenu_items();
+               }
+               require_once(dirname(dirname(dirname(__FILE__))) . "/friends/of.php");
+               
+       }
+       
+       /**
+        * Page handler for friends of
+        *
+        */
+       function collections_page_handler($page_elements) {
+               
+               if (isset($page_elements[0])) {
+                       if ($page_elements[0] == "add") {
+                               set_page_owner($_SESSION['guid']);
+                               collections_submenu_items();
+                               require_once(dirname(dirname(dirname(__FILE__))) . "/friends/add.php"); 
+                       } else {
+                               if ($user = get_user_by_username($page_elements[0])) {
+                                       set_page_owner($user->getGUID());
+                                       if ($_SESSION['guid'] == page_owner()) {
+                                               collections_submenu_items();
+                                       }
+                                       require_once(dirname(dirname(dirname(__FILE__))) . "/friends/collections.php");
+                               }
+                       }
+               }
+               
+       }
+       
+       /**
+        * Page handler for dashboard
+        */
+       function dashboard_page_handler($page_elements) {
+               @require_once(dirname(dirname(dirname(__FILE__))) . "/dashboard/index.php");
+       }
+
+       /**
+        * Sets the last action time of the given user to right now.
+        *
+        * @param int $user_guid The user GUID
+        */
+       function set_last_action($user_guid) {
+               
+               $user_guid = (int) $user_guid;
+               global $CONFIG;
+               $time = time();
+               
+               execute_delayed_write_query("UPDATE {$CONFIG->dbprefix}users_entity set prev_last_action = last_action, last_action = {$time} where guid = {$user_guid}");
+               
+       }
+       
+       /**
+        * Sets the last logon time of the given user to right now.
+        *
+        * @param int $user_guid The user GUID
+        */
+       function set_last_login($user_guid) {
+               
+               $user_guid = (int) $user_guid;
+               global $CONFIG;
+               $time = time();
+               
+               execute_delayed_write_query("UPDATE {$CONFIG->dbprefix}users_entity set prev_last_login = last_login, last_login = {$time} where guid = {$user_guid}");
+               
+       }
+       
+       /**
+        * A permissions plugin hook that grants access to users if they are newly created - allows
+        * for email activation.
+        * 
+        * TODO: Do this in a better way!
+        *
+        * @param unknown_type $hook
+        * @param unknown_type $entity_type
+        * @param unknown_type $returnvalue
+        * @param unknown_type $params
+        */
+       function new_user_enable_permissions_check($hook, $entity_type, $returnvalue, $params)
+       {
+               $entity = $params['entity'];
+               $user = $params['user'];
+               if (($entity) && ($entity instanceof ElggUser))
+               {
+                       if (
+                               (($entity->disable_reason == 'new_user') || (
+                                       // if this isn't set at all they're a "new user"
+                                       !$entity->validated
+                               ))
+                               && (!isloggedin()))
+                               return true;
+                       
+               }
+               
+               return $returnvalue;
+       }
+       
+       /**
+        * Sets up user-related menu items
+        *
+        */
+       function users_pagesetup() {
+               
+               // Load config
+                       global $CONFIG;
+                       
+               //add submenu options
+                       if (get_context() == "friends" || 
+                               get_context() == "friendsof" || 
+                               get_context() == "collections") {
+                               add_submenu_item(elgg_echo('friends'),$CONFIG->wwwroot."pg/friends/" . page_owner_entity()->username);
+                               add_submenu_item(elgg_echo('friends:of'),$CONFIG->wwwroot."pg/friendsof/" . page_owner_entity()->username);
+                       }
+               
+       }
+       
+       /**
+        * Users initialisation function, which establishes the page handler
+        *
+        */
+       function users_init() {
+               
+               // Load config
+                       global $CONFIG;
+               
+               // Set up menu for logged in users
+                       if (isloggedin()) {
+                               $user = get_loggedin_user();
+                               add_menu(elgg_echo('friends'), $CONFIG->wwwroot . "pg/friends/" . $user->username);
+                       }
+               
+               register_page_handler('friends','friends_page_handler');
+               register_page_handler('friendsof','friends_of_page_handler');
+               register_page_handler('collections','collections_page_handler');
+               register_page_handler('dashboard','dashboard_page_handler');
+               register_action("register",true);
+               register_action("useradd",true);
+               register_action("friends/add");
+               register_action("friends/remove");
+               register_action('friends/addcollection');
+               register_action('friends/deletecollection');
+        register_action('friends/editcollection');
+        register_action("user/spotlight");
+
+               register_action("usersettings/save");
+               
+               register_action("user/passwordreset");
+               register_action("user/requestnewpassword");
+               
+               // User name change
+               extend_elgg_settings_page('user/settings/name', 'usersettings/user', 1);
+               //register_action("user/name");
+               
+               // User password change
+               extend_elgg_settings_page('user/settings/password', 'usersettings/user', 1);
+               //register_action("user/password");
+               
+               // Add email settings
+               extend_elgg_settings_page('user/settings/email', 'usersettings/user', 1);
+               //register_action("email/save");
+               
+               // Add language settings
+               extend_elgg_settings_page('user/settings/language', 'usersettings/user', 1);
+               
+               // Add default access settings
+               extend_elgg_settings_page('user/settings/default_access', 'usersettings/user', 1);
+               
+               //register_action("user/language");
+               
+               // Register the user type
+               register_entity_type('user','');
+               
+               register_plugin_hook('usersettings:save','user','users_settings_save');
+               register_plugin_hook('search','all','search_list_users_by_name');
+               
+               
+               // Handle a special case for newly created users when the user is not logged in
+               // TODO: handle this better!
+               register_plugin_hook('permissions_check','all','new_user_enable_permissions_check');
+       }
+       
+       /**
+        * Returns a formatted list of users suitable for injecting into search.
+        *
+        */
+       function search_list_users_by_name($hook, $user, $returnvalue, $tag) {
+
+               // Change this to set the number of users that display on the search page
+               $threshold = 4;
+
+               $object = get_input('object');
+               
+               if (!get_input('offset') && (empty($object) || $object == 'user'))
+               if ($users = search_for_user($tag,$threshold)) {
+                       
+                       $countusers = search_for_user($tag,0,0,"",true);
+                       
+                       $return = elgg_view('user/search/startblurb',array('count' => $countusers, 'tag' => $tag));
+                       foreach($users as $user) {
+                               $return .= elgg_view_entity($user);
+                       }
+                       $return .= elgg_view('user/search/finishblurb',array('count' => $countusers, 'threshold' => $threshold, 'tag' => $tag));
+                       return $return;
+                       
+               }
+               
+       }
+       
+       function users_settings_save() {
+               
+               global $CONFIG;
+               @include($CONFIG->path . "actions/user/name.php");
+               @include($CONFIG->path . "actions/user/password.php");
+               @include($CONFIG->path . "actions/email/save.php");
+               @include($CONFIG->path . "actions/user/language.php");
+               @include($CONFIG->path . "actions/user/default_access.php");
+               
+       }
+       
+       //register actions *************************************************************
+   
+               register_elgg_event_handler('init','system','users_init',0);
+               register_elgg_event_handler('pagesetup','system','users_pagesetup',0);
+       
 ?>
\ No newline at end of file
index 47bb36972a2ba90a9c147dd75e7461452e848800..2476a0b7511e797d32dcf61b0a589cc8e913a281 100644 (file)
@@ -1,14 +1,14 @@
-<?php\r
-\r
-       /**\r
-        * Elgg version library.\r
-        * Contains code for handling versioning and upgrades.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+
+       /**
+        * Elgg version library.
+        * Contains code for handling versioning and upgrades.
+        * 
+        * @package Elgg
+        * @subpackage Core
 
 
-        * @link http://elgg.org/\r
+        * @link http://elgg.org/
         */
 
        /**
         }
                
         return false;
-       }\r
-\r
-       /**\r
-        * Get the current version information\r
-        *\r
-        * @param true|false $humanreadable Whether to return a human readable version (default: false)\r
-        * @return string|false Depending on success\r
-        */\r
-               function get_version($humanreadable = false) {\r
-                       \r
-                       global $CONFIG;\r
-                       if (@include($CONFIG->path . "version.php")) {\r
-                               if (!$humanreadable) return $version;\r
-                               return $release;\r
-                       }\r
-                       \r
-                       return false;\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * Determines whether or not the database needs to be upgraded.\r
-        *\r
-        * @return true|false Depending on whether or not the db version matches the code version\r
-        */\r
-               function version_upgrade_check() {\r
-                       \r
-                       $dbversion = (int) datalist_get('version');\r
-                       $version = get_version();\r
-                       \r
-                       if ($version > $dbversion) {\r
-                               return true;\r
-                       }\r
-                       return false;\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * Upgrades Elgg\r
-        *\r
-        */\r
-               function version_upgrade() {\r
-                       \r
-                       $dbversion = (int) datalist_get('version');\r
+       }
+
+       /**
+        * Get the current version information
+        *
+        * @param true|false $humanreadable Whether to return a human readable version (default: false)
+        * @return string|false Depending on success
+        */
+               function get_version($humanreadable = false) {
+                       
+                       global $CONFIG;
+                       if (@include($CONFIG->path . "version.php")) {
+                               if (!$humanreadable) return $version;
+                               return $release;
+                       }
+                       
+                       return false;
+                       
+               }
+               
+       /**
+        * Determines whether or not the database needs to be upgraded.
+        *
+        * @return true|false Depending on whether or not the db version matches the code version
+        */
+               function version_upgrade_check() {
+                       
+                       $dbversion = (int) datalist_get('version');
+                       $version = get_version();
+                       
+                       if ($version > $dbversion) {
+                               return true;
+                       }
+                       return false;
+                       
+               }
+               
+       /**
+        * Upgrades Elgg
+        *
+        */
+               function version_upgrade() {
+                       
+                       $dbversion = (int) datalist_get('version');
                        
                        // Upgrade database
-                       db_upgrade($dbversion);\r
+                       db_upgrade($dbversion);
                        system_message(elgg_echo('upgrade:db'));
                        
                        // Upgrade core
                        trigger_elgg_event('upgrade', 'upgrade', $upgrade_details);
                                
                        // Update the version
-                       datalist_set('version', get_version());\r
-                       \r
-               }\r
-               \r
+                       datalist_set('version', get_version());
+                       
+               }
+               
 ?>
\ No newline at end of file
index 8793370efe0c1b5c0d4aed5c17823b8d9f29e61a..f6f01f660e04503e6b8a47e07c1713d33d6bb79a 100644 (file)
-<?php\r
-\r
-       /**\r
-        * Elgg widgets library.\r
-        * Contains code for handling widgets.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+
+       /**
+        * Elgg widgets library.
+        * Contains code for handling widgets.
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+
+        * @link http://elgg.org/
+        */
+
+       /**
+        * Override ElggObject in order to store widget data in ultra-private stores.
+        */
+       class ElggWidget extends ElggObject
+       {
+               protected function initialise_attributes()
+               {
+                       parent::initialise_attributes();
+                       
+                       $this->attributes['subtype'] = "widget";
+               }
+
+               public function __construct($guid = null) {     parent::__construct($guid); }
+                       
+               /**
+                * Override entity get and sets in order to save data to private data store.
+                */
+               public function get($name)
+               {
+                       // See if its in our base attribute
+                       if (isset($this->attributes[$name])) {
+                               return $this->attributes[$name];
+                       }
+                       
+                       // No, so see if its in the private data store.
+                       $meta = get_private_setting($this->guid, $name);
+                       if ($meta)
+                               return $meta;
+                       
+                       // Can't find it, so return null
+                       return null;
+               }
+
+               /**
+                * Override entity get and sets in order to save data to private data store.
+                */
+               public function set($name, $value)
+               {
+                       if (array_key_exists($name, $this->attributes))
+                       {
+                               // Check that we're not trying to change the guid! 
+                               if ((array_key_exists('guid', $this->attributes)) && ($name=='guid'))
+                                       return false;
+                                       
+                               $this->attributes[$name] = $value;
+                       }
+                       else 
+                               return set_private_setting($this->guid, $name, $value);
+               
+                       return true;
+               }
+       }
+
+       /**
+        * Register a particular context for use with widgets.
+        *
+        * @param string $context The context we wish to enable context for
+        */
+               function use_widgets($context) {
+                       
+                       global $CONFIG;
+                       if (!isset($CONFIG->widgets))
+                               $CONFIG->widgets = new stdClass;
+                       if (!isset($CONFIG->widgets->contexts)) {
+                               $CONFIG->widgets->contexts = array();
+                       }
+                       if (!empty($context)) {
+                               $CONFIG->widgets->contexts[] = $context;
+                       }
+                       
+               }
+               
+       /**
+        * Determines whether or not the current context is using widgets
+        *
+        * @return true|false Depending on widget status
+        */
+               function using_widgets() {
+                       
+                       global $CONFIG;
+                       $context = get_context();
+                       if (isset($CONFIG->widgets->contexts) && is_array($CONFIG->widgets->contexts)) {
+                               if (in_array($context, $CONFIG->widgets->contexts)) return true;
+                       }
+                       
+                       return false;
+                       
+               }
+               
+       /**
+        * When given a widget entity and a new requested location, saves the new location
+        * and also provides a sensible ordering for all widgets in that column
+        *
+        * @param ElggObject $widget The widget entity
+        * @param int $order The order within the column
+        * @param int $column The column (1, 2 or 3)
+        * @return true|false Depending on success
+        */
+               function save_widget_location(ElggObject $widget, $order, $column) {
+                       
+                       if ($widget instanceof ElggObject) {
+                               if ($widget->subtype == "widget") {
+                                       
+                                       // If you can't move the widget, don't save a new location
+                                       if (!$widget->draggable)
+                                               return false;
+                                       
+                                       // Sanitise the column value
+                                       if ($column != 1 || $column != 2 || $column != 3)
+                                               $column = 1;
+                                               
+                                       $widget->column = (int) $column;
+                                       
+                                       $ordertmp = array();
+                                       
+                                       if ($entities = get_entities_from_metadata_multi(array(                                                                                                                                         
+                                                       'context' => $widget->context,
+                                                       'column' => $column,
+                                                       ),'object','widget')) {
+                                               foreach($entities as $entity) {
+                                                       $entityorder = $entity->order;
+                                                       if ($entityorder < $order) {
+                                                               $ordertmp[$entityorder] = $entity;                                                               
+                                                       }
+                                                       if ($entityorder >= $order) {
+                                                               $ordertmp[$entityorder + 10000] = $entity;
+                                                       }
+                                               }       
+                                       }
+                                       
+                                       $ordertmp[$order] = $widget;
+                                       ksort($ordertmp);
+                                       
+                                       $orderticker = 10;
+                                       foreach($ordertmp as $orderval => $entity) {
+                                               $entity->order = $orderticker;
+                                               $orderticker += 10;
+                                       }
+                                       
+                                       return true;
+                                       
+                               } else {
+                                       register_error($widget->subtype);
+                               }
+                               
+                       }
+                       
+                       return false;
+                       
+               }
+               
+       /**
+        * Get widgets for a particular context and column, in order of display
+        *
+        * @param int $user_guid The owner user GUID
+        * @param string $context The context (profile, dashboard etc)
+        * @param int $column The column (1 or 2)
+        * @return array|false An array of widget ElggObjects, or false
+        */
+               function get_widgets($user_guid, $context, $column) {
+                       
+                       if ($widgets = get_entities_from_private_setting_multi(array(
+                                                                                               'column' => $column,
+                                                                                               'context' => $context), "object", "widget", $user_guid, "", 10000))
+                       /*if ($widgets = get_user_objects_by_metadata($user_guid, "widget", array(
+                                                                                               'column' => $column,
+                                                                                               'context' => $context, 
+                                                                                                                                       ), 10000)) {
+                       */
+                       {
+                                                                                                                                               
+                               $widgetorder = array();
+                               foreach($widgets as $widget) {
+                                       $order = $widget->order;
+                                       while(isset($widgetorder[$order])) {
+                                               $order++;
+                                       }
+                                       $widgetorder[$order] = $widget; 
+                               }
+                               
+                               ksort($widgetorder);
+                               
+                               return $widgetorder;
+                                                                                                                                               
+                       }
+                       
+                       return false;
+                       
+               }
+
+       /**
+        * Displays a particular widget
+        *
+        * @param ElggObject $widget The widget to display
+        * @return string The HTML for the widget, including JavaScript wrapper
+        */
+               function display_widget(ElggObject $widget) {
+                       
+                       return elgg_view_entity($widget);
+                       
+               }
+               
+       /**
+        * Add a new widget
+        *
+        * @param int $user_guid User GUID to associate this widget with
+        * @param string $handler The handler for this widget
+        * @param string $context The page context for this widget
+        * @param int $order The order to display this widget in
+        * @param int $column The column to display this widget in (1, 2 or 3)
+        * @param int $access_id If not specified, it is set to the default access level
+        * @return true|false Depending on success
+        */
+               function add_widget($user_guid, $handler, $context, $order = 0, $column = 1, $access_id = null) {
+                       
+                       if (empty($user_guid) || empty($context) || empty($handler) || !widget_type_exists($handler))
+                               return false;
+                       
+                       if ($user = get_user($user_guid)) {
+                               
+                               $widget = new ElggWidget;
+                               $widget->owner_guid = $user_guid;
+                               $widget->container_guid = $user_guid;
+                               if (isset($access_id)) {
+                                       $widget->access_id = $access_id;
+                               } else {
+                                       $widget->access_id = get_default_access();
+                               }
+
+                               if (!$widget->save())
+                                       return false;
+                                       
+                               $widget->handler = $handler;
+                               $widget->context = $context;
+                               $widget->column = $column;
+                               $widget->order = $order;
+                               
+                               // save_widget_location($widget, $order, $column);
+                               return true;
+                               
+                       }
+                       
+                       return false;
+                       
+               }
+               
+       /**
+        * Define a new widget type
+        *
+        * @param string $handler The identifier for the widget handler
+        * @param string $name The name of the widget type
+        * @param string $description A description for the widget type
+        * @param string $context A comma-separated list of contexts where this widget is allowed (default: 'all')
+        * @param true|false $multiple Whether or not multiple instances of this widget are allowed on a single dashboard (default: false)
+        * @param string $position A comma-separated list of positions on the page (side or main) where this widget is allowed (default: "side,main")
+        * @return true|false Depending on success
+        */
+               
+               function add_widget_type($handler, $name, $description, $context = "all", $multiple = false, $positions = "side,main") {
+
+                       if (!empty($handler) && !empty($name)) {
+                               
+                               global $CONFIG;
+                               
+                               if (!isset($CONFIG->widgets))
+                                       $CONFIG->widgets = new stdClass;
+                                       
+                               if (!isset($CONFIG->widgets->handlers))
+                                       $CONFIG->widgets->handlers = array();
+                               
+                               $handlerobj = new stdClass;
+                               $handlerobj->name = $name;
+                               $handlerobj->description = $description;
+                               $handlerobj->context = explode(",",$context);
+                               $handlerobj->multiple = $multiple;
+                               $handlerobj->positions = explode(",",$positions);
+                                       
+                               $CONFIG->widgets->handlers[$handler] = $handlerobj;
+
+                               return true;
+                                       
+                       }
+                       
+                       return false;
+                       
+               }
+               
+       /**
+        * Determines whether or not widgets with the specified handler have been defined
+        *
+        * @param string $handler The widget handler identifying string
+        * @return true|false Whether or not those widgets exist
+        */
+               function widget_type_exists($handler) {
+                       
+                       global $CONFIG;
+                       if (!empty($CONFIG->widgets) 
+                               && !empty($CONFIG->widgets->handlers) 
+                               && is_array($CONFIG->widgets->handlers) 
+                               && array_key_exists($handler, $CONFIG->widgets->handlers))
+                                       return true;
+
+                       return false;
+                       
+               }
+               
+       /**
+        * Returns an array of stdClass objects representing the defined widget types
+        *
+        * @return array A list of types defined (if any)
+        */
+               function get_widget_types() {
+                       
+                       global $CONFIG;
+                       if (!empty($CONFIG->widgets) 
+                               && !empty($CONFIG->widgets->handlers) 
+                               && is_array($CONFIG->widgets->handlers)) {
+                                       
+                                       $context = get_context();
+                                       
+                                       foreach($CONFIG->widgets->handlers as $key => $handler) {
+                                               if (!in_array('all',$handler->context) &&
+                                                       !in_array($context,$handler->context)) {
+                                                               unset($CONFIG->widgets->handlers[$key]);
+                                               }
+                                       }
+                                       
+                                       return $CONFIG->widgets->handlers;
+                                       
+                               }
+                               
+                       return array();
+                       
+               }
+               
+       /**
+        * Saves a widget's settings (by passing an array of (name => value) pairs to save_{$handler}_widget)
+        *
+        * @param int $widget_guid The GUID of the widget we're saving to
+        * @param array $params An array of name => value parameters 
+        */
+               function save_widget_info($widget_guid, $params) {
+                       
+                       if ($widget = get_entity($widget_guid)) {
+                               
+                               $subtype = $widget->getSubtype();
+                               
+                               if ($subtype != "widget") return false;
+                               $handler = $widget->handler;
+                               if (empty($handler) || !widget_type_exists($handler)) return false;
+                               
+                               if (!$widget->canEdit()) return false;
+                               
+                               // Save the params to the widget 
+                               if (is_array($params) && sizeof($params) > 0) {
+                                       foreach($params as $name => $value) {
+                                               
+                                               if (!empty($name) && !in_array($name,array(
+                                                               'guid','owner_guid','site_guid'
+                                                                                                                                       ))) {
+                                                       if (is_array($value))
+                                                       {
+                                                               // TODO: Handle arrays securely
+                                                               $widget->setMetaData($name, $value, "", true);
+                                                       }else
+                                                               $widget->$name = $value;
+                                               }
+                                       }
+                                       $widget->save();
+                               }
+                               
+                               $function = "save_{$handler}_widget";
+                               if (is_callable($function)) {
+                                       return $function($params);
+                               }
+                               
+                               return true;
+                               
+                       }
+                       
+                       return false;
+                       
+               }
+               
+               function reorder_widgets_from_panel($panelstring1, $panelstring2, $panelstring3, $context, $owner) {
+                       
+                       $return = true;
+                       
+                       $mainwidgets = explode('::',$panelstring1);
+                       $sidewidgets = explode('::',$panelstring2);
+                       $rightwidgets = explode('::',$panelstring3);
+                       
+                       $handlers = array();
+                       $guids = array();
+                       
+                       if (is_array($mainwidgets) && sizeof($mainwidgets) > 0) {
+                               foreach($mainwidgets as $widget) {
+                                       
+                                       $guid = (int) $widget;
+
+                                       if ("{$guid}" == "{$widget}") {
+                                               $guids[1][] = $widget;
+                                       } else {
+                                               $handlers[1][] = $widget;
+                                       }
+                                       
+                               }
+                       }
+                       if (is_array($sidewidgets) && sizeof($sidewidgets) > 0) {
+                               foreach($sidewidgets as $widget) {
+                                       
+                                       $guid = (int) $widget;
+
+                                       if ("{$guid}" == "{$widget}") {
+                                               $guids[2][] = $widget;
+                                       } else {
+                                               $handlers[2][] = $widget;
+                                       }
+                                       
+                               }
+                       }
+                       if (is_array($rightwidgets) && sizeof($rightwidgets) > 0) {
+                               foreach($rightwidgets as $widget) {
+                                       
+                                       $guid = (int) $widget;
+
+                                       if ("{$guid}" == "{$widget}") {
+                                               $guids[3][] = $widget;
+                                       } else {
+                                               $handlers[3][] = $widget;
+                                       }
+                                       
+                               }
+                       }
+                       
+                       // Reorder existing widgets or delete ones that have vanished
+                       foreach (array(1,2,3) as $column) {
+                               if ($dbwidgets = get_widgets($owner,$context,$column)) {
+                                       
+                                       foreach($dbwidgets as $dbwidget) {
+                                               if (in_array($dbwidget->getGUID(),$guids[1]) || in_array($dbwidget->getGUID(),$guids[2]) || in_array($dbwidget->getGUID(),$guids[3])) {
+                                                       if (in_array($dbwidget->getGUID(),$guids[1])) {
+                                                               $pos = array_search($dbwidget->getGUID(),$guids[1]);
+                                                               $col = 1;
+                                                       } else if (in_array($dbwidget->getGUID(),$guids[2])) {
+                                                               $pos = array_search($dbwidget->getGUID(),$guids[2]);
+                                                               $col = 2;
+                                                       } else {
+                                                               $pos = array_search($dbwidget->getGUID(),$guids[3]);
+                                                               $col = 3;
+                                                       }
+                                                       $pos = ($pos + 1) * 10;
+                                                       $dbwidget->column = $col;
+                                                       $dbwidget->order = $pos;
+                                               } else {
+                                                       $dbguid = $dbwidget->getGUID();
+                                                       if (!$dbwidget->delete()) {
+                                                               $return = false;
+                                                       } else {
+                                                               // Remove state cookie
+                                                               setcookie('widget' + $dbguid, null);
+                                                       }
+                                               }
+                                       }
+                                       
+                               }
+                               // Add new ones
+                               if (sizeof($guids[$column]) > 0) {
+                                       foreach($guids[$column] as $key => $guid) {
+                                               if ($guid == 0) {
+                                                       $pos = ($key + 1) * 10;
+                                                       $handler = $handlers[$column][$key];
+                                                       if (!add_widget($owner,$handler,$context,$pos,$column))
+                                                               $return = false;
+                                               }
+                                       }
+                               }
+                       }
+                       
+                       return $return;
+                       
+               }
+               
+               /**
+                * Run some things once.
+                *
+                */
+               function widget_run_once()
+               {
+                       // Register a class
+                       add_subtype("object", "widget", "ElggWidget");  
+               }
+
+       /**
+        * Function to initialise widgets functionality on Elgg init
+        *
+        */
+               function widgets_init() {
+                       
+                       register_action('widgets/reorder');
+                       register_action('widgets/save');
+                       register_action('widgets/add');
+                       
+                       // Now run this stuff, but only once
+                       run_function_once("widget_run_once");
+               }
+               
+       // Register event
+               register_elgg_event_handler('init','system','widgets_init');
+
+       // Use widgets on the dashboard
+               use_widgets('dashboard');
 
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /**\r
-        * Override ElggObject in order to store widget data in ultra-private stores.\r
-        */\r
-       class ElggWidget extends ElggObject\r
-       {\r
-               protected function initialise_attributes()\r
-               {\r
-                       parent::initialise_attributes();\r
-                       \r
-                       $this->attributes['subtype'] = "widget";\r
-               }\r
-\r
-               public function __construct($guid = null) {     parent::__construct($guid); }\r
-                       \r
-               /**\r
-                * Override entity get and sets in order to save data to private data store.\r
-                */\r
-               public function get($name)\r
-               {\r
-                       // See if its in our base attribute\r
-                       if (isset($this->attributes[$name])) {\r
-                               return $this->attributes[$name];\r
-                       }\r
-                       \r
-                       // No, so see if its in the private data store.\r
-                       $meta = get_private_setting($this->guid, $name);\r
-                       if ($meta)\r
-                               return $meta;\r
-                       \r
-                       // Can't find it, so return null\r
-                       return null;\r
-               }\r
-\r
-               /**\r
-                * Override entity get and sets in order to save data to private data store.\r
-                */\r
-               public function set($name, $value)\r
-               {\r
-                       if (array_key_exists($name, $this->attributes))\r
-                       {\r
-                               // Check that we're not trying to change the guid! \r
-                               if ((array_key_exists('guid', $this->attributes)) && ($name=='guid'))\r
-                                       return false;\r
-                                       \r
-                               $this->attributes[$name] = $value;\r
-                       }\r
-                       else \r
-                               return set_private_setting($this->guid, $name, $value);\r
-               \r
-                       return true;\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Register a particular context for use with widgets.\r
-        *\r
-        * @param string $context The context we wish to enable context for\r
-        */\r
-               function use_widgets($context) {\r
-                       \r
-                       global $CONFIG;\r
-                       if (!isset($CONFIG->widgets))\r
-                               $CONFIG->widgets = new stdClass;\r
-                       if (!isset($CONFIG->widgets->contexts)) {\r
-                               $CONFIG->widgets->contexts = array();\r
-                       }\r
-                       if (!empty($context)) {\r
-                               $CONFIG->widgets->contexts[] = $context;\r
-                       }\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * Determines whether or not the current context is using widgets\r
-        *\r
-        * @return true|false Depending on widget status\r
-        */\r
-               function using_widgets() {\r
-                       \r
-                       global $CONFIG;\r
-                       $context = get_context();\r
-                       if (isset($CONFIG->widgets->contexts) && is_array($CONFIG->widgets->contexts)) {\r
-                               if (in_array($context, $CONFIG->widgets->contexts)) return true;\r
-                       }\r
-                       \r
-                       return false;\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * When given a widget entity and a new requested location, saves the new location\r
-        * and also provides a sensible ordering for all widgets in that column\r
-        *\r
-        * @param ElggObject $widget The widget entity\r
-        * @param int $order The order within the column\r
-        * @param int $column The column (1, 2 or 3)\r
-        * @return true|false Depending on success\r
-        */\r
-               function save_widget_location(ElggObject $widget, $order, $column) {\r
-                       \r
-                       if ($widget instanceof ElggObject) {\r
-                               if ($widget->subtype == "widget") {\r
-                                       \r
-                                       // If you can't move the widget, don't save a new location\r
-                                       if (!$widget->draggable)\r
-                                               return false;\r
-                                       \r
-                                       // Sanitise the column value\r
-                                       if ($column != 1 || $column != 2 || $column != 3)\r
-                                               $column = 1;\r
-                                               \r
-                                       $widget->column = (int) $column;\r
-                                       \r
-                                       $ordertmp = array();\r
-                                       \r
-                                       if ($entities = get_entities_from_metadata_multi(array(                                                                                                                                         \r
-                                                       'context' => $widget->context,\r
-                                                       'column' => $column,\r
-                                                       ),'object','widget')) {\r
-                                               foreach($entities as $entity) {\r
-                                                       $entityorder = $entity->order;\r
-                                                       if ($entityorder < $order) {\r
-                                                               $ordertmp[$entityorder] = $entity;                                                               \r
-                                                       }\r
-                                                       if ($entityorder >= $order) {\r
-                                                               $ordertmp[$entityorder + 10000] = $entity;\r
-                                                       }\r
-                                               }       \r
-                                       }\r
-                                       \r
-                                       $ordertmp[$order] = $widget;\r
-                                       ksort($ordertmp);\r
-                                       \r
-                                       $orderticker = 10;\r
-                                       foreach($ordertmp as $orderval => $entity) {\r
-                                               $entity->order = $orderticker;\r
-                                               $orderticker += 10;\r
-                                       }\r
-                                       \r
-                                       return true;\r
-                                       \r
-                               } else {\r
-                                       register_error($widget->subtype);\r
-                               }\r
-                               \r
-                       }\r
-                       \r
-                       return false;\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * Get widgets for a particular context and column, in order of display\r
-        *\r
-        * @param int $user_guid The owner user GUID\r
-        * @param string $context The context (profile, dashboard etc)\r
-        * @param int $column The column (1 or 2)\r
-        * @return array|false An array of widget ElggObjects, or false\r
-        */\r
-               function get_widgets($user_guid, $context, $column) {\r
-                       \r
-                       if ($widgets = get_entities_from_private_setting_multi(array(\r
-                                                                                               'column' => $column,\r
-                                                                                               'context' => $context), "object", "widget", $user_guid, "", 10000))\r
-                       /*if ($widgets = get_user_objects_by_metadata($user_guid, "widget", array(\r
-                                                                                               'column' => $column,\r
-                                                                                               'context' => $context, \r
-                                                                                                                                       ), 10000)) {\r
-                       */\r
-                       {\r
-                                                                                                                                               \r
-                               $widgetorder = array();\r
-                               foreach($widgets as $widget) {\r
-                                       $order = $widget->order;\r
-                                       while(isset($widgetorder[$order])) {\r
-                                               $order++;\r
-                                       }\r
-                                       $widgetorder[$order] = $widget; \r
-                               }\r
-                               \r
-                               ksort($widgetorder);\r
-                               \r
-                               return $widgetorder;\r
-                                                                                                                                               \r
-                       }\r
-                       \r
-                       return false;\r
-                       \r
-               }\r
-\r
-       /**\r
-        * Displays a particular widget\r
-        *\r
-        * @param ElggObject $widget The widget to display\r
-        * @return string The HTML for the widget, including JavaScript wrapper\r
-        */\r
-               function display_widget(ElggObject $widget) {\r
-                       \r
-                       return elgg_view_entity($widget);\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * Add a new widget\r
-        *\r
-        * @param int $user_guid User GUID to associate this widget with\r
-        * @param string $handler The handler for this widget\r
-        * @param string $context The page context for this widget\r
-        * @param int $order The order to display this widget in\r
-        * @param int $column The column to display this widget in (1, 2 or 3)\r
-        * @param int $access_id If not specified, it is set to the default access level\r
-        * @return true|false Depending on success\r
-        */\r
-               function add_widget($user_guid, $handler, $context, $order = 0, $column = 1, $access_id = null) {\r
-                       \r
-                       if (empty($user_guid) || empty($context) || empty($handler) || !widget_type_exists($handler))\r
-                               return false;\r
-                       \r
-                       if ($user = get_user($user_guid)) {\r
-                               \r
-                               $widget = new ElggWidget;\r
-                               $widget->owner_guid = $user_guid;\r
-                               $widget->container_guid = $user_guid;\r
-                               if (isset($access_id)) {\r
-                                       $widget->access_id = $access_id;\r
-                               } else {\r
-                                       $widget->access_id = get_default_access();\r
-                               }\r
-\r
-                               if (!$widget->save())\r
-                                       return false;\r
-                                       \r
-                               $widget->handler = $handler;\r
-                               $widget->context = $context;\r
-                               $widget->column = $column;\r
-                               $widget->order = $order;\r
-                               \r
-                               // save_widget_location($widget, $order, $column);\r
-                               return true;\r
-                               \r
-                       }\r
-                       \r
-                       return false;\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * Define a new widget type\r
-        *\r
-        * @param string $handler The identifier for the widget handler\r
-        * @param string $name The name of the widget type\r
-        * @param string $description A description for the widget type\r
-        * @param string $context A comma-separated list of contexts where this widget is allowed (default: 'all')\r
-        * @param true|false $multiple Whether or not multiple instances of this widget are allowed on a single dashboard (default: false)\r
-        * @param string $position A comma-separated list of positions on the page (side or main) where this widget is allowed (default: "side,main")\r
-        * @return true|false Depending on success\r
-        */\r
-               \r
-               function add_widget_type($handler, $name, $description, $context = "all", $multiple = false, $positions = "side,main") {\r
-\r
-                       if (!empty($handler) && !empty($name)) {\r
-                               \r
-                               global $CONFIG;\r
-                               \r
-                               if (!isset($CONFIG->widgets))\r
-                                       $CONFIG->widgets = new stdClass;\r
-                                       \r
-                               if (!isset($CONFIG->widgets->handlers))\r
-                                       $CONFIG->widgets->handlers = array();\r
-                               \r
-                               $handlerobj = new stdClass;\r
-                               $handlerobj->name = $name;\r
-                               $handlerobj->description = $description;\r
-                               $handlerobj->context = explode(",",$context);\r
-                               $handlerobj->multiple = $multiple;\r
-                               $handlerobj->positions = explode(",",$positions);\r
-                                       \r
-                               $CONFIG->widgets->handlers[$handler] = $handlerobj;\r
-\r
-                               return true;\r
-                                       \r
-                       }\r
-                       \r
-                       return false;\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * Determines whether or not widgets with the specified handler have been defined\r
-        *\r
-        * @param string $handler The widget handler identifying string\r
-        * @return true|false Whether or not those widgets exist\r
-        */\r
-               function widget_type_exists($handler) {\r
-                       \r
-                       global $CONFIG;\r
-                       if (!empty($CONFIG->widgets) \r
-                               && !empty($CONFIG->widgets->handlers) \r
-                               && is_array($CONFIG->widgets->handlers) \r
-                               && array_key_exists($handler, $CONFIG->widgets->handlers))\r
-                                       return true;\r
-\r
-                       return false;\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * Returns an array of stdClass objects representing the defined widget types\r
-        *\r
-        * @return array A list of types defined (if any)\r
-        */\r
-               function get_widget_types() {\r
-                       \r
-                       global $CONFIG;\r
-                       if (!empty($CONFIG->widgets) \r
-                               && !empty($CONFIG->widgets->handlers) \r
-                               && is_array($CONFIG->widgets->handlers)) {\r
-                                       \r
-                                       $context = get_context();\r
-                                       \r
-                                       foreach($CONFIG->widgets->handlers as $key => $handler) {\r
-                                               if (!in_array('all',$handler->context) &&\r
-                                                       !in_array($context,$handler->context)) {\r
-                                                               unset($CONFIG->widgets->handlers[$key]);\r
-                                               }\r
-                                       }\r
-                                       \r
-                                       return $CONFIG->widgets->handlers;\r
-                                       \r
-                               }\r
-                               \r
-                       return array();\r
-                       \r
-               }\r
-               \r
-       /**\r
-        * Saves a widget's settings (by passing an array of (name => value) pairs to save_{$handler}_widget)\r
-        *\r
-        * @param int $widget_guid The GUID of the widget we're saving to\r
-        * @param array $params An array of name => value parameters \r
-        */\r
-               function save_widget_info($widget_guid, $params) {\r
-                       \r
-                       if ($widget = get_entity($widget_guid)) {\r
-                               \r
-                               $subtype = $widget->getSubtype();\r
-                               \r
-                               if ($subtype != "widget") return false;\r
-                               $handler = $widget->handler;\r
-                               if (empty($handler) || !widget_type_exists($handler)) return false;\r
-                               \r
-                               if (!$widget->canEdit()) return false;\r
-                               \r
-                               // Save the params to the widget \r
-                               if (is_array($params) && sizeof($params) > 0) {\r
-                                       foreach($params as $name => $value) {\r
-                                               \r
-                                               if (!empty($name) && !in_array($name,array(\r
-                                                               'guid','owner_guid','site_guid'\r
-                                                                                                                                       ))) {\r
-                                                       if (is_array($value))\r
-                                                       {\r
-                                                               // TODO: Handle arrays securely\r
-                                                               $widget->setMetaData($name, $value, "", true);\r
-                                                       }else\r
-                                                               $widget->$name = $value;\r
-                                               }\r
-                                       }\r
-                                       $widget->save();\r
-                               }\r
-                               \r
-                               $function = "save_{$handler}_widget";\r
-                               if (is_callable($function)) {\r
-                                       return $function($params);\r
-                               }\r
-                               \r
-                               return true;\r
-                               \r
-                       }\r
-                       \r
-                       return false;\r
-                       \r
-               }\r
-               \r
-               function reorder_widgets_from_panel($panelstring1, $panelstring2, $panelstring3, $context, $owner) {\r
-                       \r
-                       $return = true;\r
-                       \r
-                       $mainwidgets = explode('::',$panelstring1);\r
-                       $sidewidgets = explode('::',$panelstring2);\r
-                       $rightwidgets = explode('::',$panelstring3);\r
-                       \r
-                       $handlers = array();\r
-                       $guids = array();\r
-                       \r
-                       if (is_array($mainwidgets) && sizeof($mainwidgets) > 0) {\r
-                               foreach($mainwidgets as $widget) {\r
-                                       \r
-                                       $guid = (int) $widget;\r
-\r
-                                       if ("{$guid}" == "{$widget}") {\r
-                                               $guids[1][] = $widget;\r
-                                       } else {\r
-                                               $handlers[1][] = $widget;\r
-                                       }\r
-                                       \r
-                               }\r
-                       }\r
-                       if (is_array($sidewidgets) && sizeof($sidewidgets) > 0) {\r
-                               foreach($sidewidgets as $widget) {\r
-                                       \r
-                                       $guid = (int) $widget;\r
-\r
-                                       if ("{$guid}" == "{$widget}") {\r
-                                               $guids[2][] = $widget;\r
-                                       } else {\r
-                                               $handlers[2][] = $widget;\r
-                                       }\r
-                                       \r
-                               }\r
-                       }\r
-                       if (is_array($rightwidgets) && sizeof($rightwidgets) > 0) {\r
-                               foreach($rightwidgets as $widget) {\r
-                                       \r
-                                       $guid = (int) $widget;\r
-\r
-                                       if ("{$guid}" == "{$widget}") {\r
-                                               $guids[3][] = $widget;\r
-                                       } else {\r
-                                               $handlers[3][] = $widget;\r
-                                       }\r
-                                       \r
-                               }\r
-                       }\r
-                       \r
-                       // Reorder existing widgets or delete ones that have vanished\r
-                       foreach (array(1,2,3) as $column) {\r
-                               if ($dbwidgets = get_widgets($owner,$context,$column)) {\r
-                                       \r
-                                       foreach($dbwidgets as $dbwidget) {\r
-                                               if (in_array($dbwidget->getGUID(),$guids[1]) || in_array($dbwidget->getGUID(),$guids[2]) || in_array($dbwidget->getGUID(),$guids[3])) {\r
-                                                       if (in_array($dbwidget->getGUID(),$guids[1])) {\r
-                                                               $pos = array_search($dbwidget->getGUID(),$guids[1]);\r
-                                                               $col = 1;\r
-                                                       } else if (in_array($dbwidget->getGUID(),$guids[2])) {\r
-                                                               $pos = array_search($dbwidget->getGUID(),$guids[2]);\r
-                                                               $col = 2;\r
-                                                       } else {\r
-                                                               $pos = array_search($dbwidget->getGUID(),$guids[3]);\r
-                                                               $col = 3;\r
-                                                       }\r
-                                                       $pos = ($pos + 1) * 10;\r
-                                                       $dbwidget->column = $col;\r
-                                                       $dbwidget->order = $pos;\r
-                                               } else {\r
-                                                       $dbguid = $dbwidget->getGUID();\r
-                                                       if (!$dbwidget->delete()) {\r
-                                                               $return = false;\r
-                                                       } else {\r
-                                                               // Remove state cookie\r
-                                                               setcookie('widget' + $dbguid, null);\r
-                                                       }\r
-                                               }\r
-                                       }\r
-                                       \r
-                               }\r
-                               // Add new ones\r
-                               if (sizeof($guids[$column]) > 0) {\r
-                                       foreach($guids[$column] as $key => $guid) {\r
-                                               if ($guid == 0) {\r
-                                                       $pos = ($key + 1) * 10;\r
-                                                       $handler = $handlers[$column][$key];\r
-                                                       if (!add_widget($owner,$handler,$context,$pos,$column))\r
-                                                               $return = false;\r
-                                               }\r
-                                       }\r
-                               }\r
-                       }\r
-                       \r
-                       return $return;\r
-                       \r
-               }\r
-               \r
-               /**\r
-                * Run some things once.\r
-                *\r
-                */\r
-               function widget_run_once()\r
-               {\r
-                       // Register a class\r
-                       add_subtype("object", "widget", "ElggWidget");  \r
-               }\r
-\r
-       /**\r
-        * Function to initialise widgets functionality on Elgg init\r
-        *\r
-        */\r
-               function widgets_init() {\r
-                       \r
-                       register_action('widgets/reorder');\r
-                       register_action('widgets/save');\r
-                       register_action('widgets/add');\r
-                       \r
-                       // Now run this stuff, but only once\r
-                       run_function_once("widget_run_once");\r
-               }\r
-               \r
-       // Register event\r
-               register_elgg_event_handler('init','system','widgets_init');\r
-\r
-       // Use widgets on the dashboard\r
-               use_widgets('dashboard');\r
-\r
-\r
 ?>
\ No newline at end of file
index 50af236e40c3f18365b9794885666784df3ec6dd..4fbc716a3fdd41058772865268dfa8b553717c44 100644 (file)
@@ -1,98 +1,98 @@
-<?php\r
-\r
-       /**\r
-        * Elgg settings\r
-        * \r
-        * Elgg manages most of its configuration from the admin panel. However, we need you to\r
-        * include your database settings below.\r
-        * \r
-        * @todo Turn this into something we handle more automatically. \r
-        */\r
-\r
-               global $CONFIG;\r
-               if (!isset($CONFIG))\r
-                       $CONFIG = new stdClass;\r
-\r
-       /*\r
-        * Standard configuration\r
-        * \r
-        * You will use the same database connection for reads and writes.\r
-        * This is the easiest configuration, and will suit 99.99% of setups. However, if you're\r
-        * running a really popular site, you'll probably want to spread out your database connections\r
-        * and implement database replication.  That's beyond the scope of this configuration file\r
-        * to explain, but if you know you need it, skip past this section. \r
-        */\r
-               \r
-               // Database username\r
-                       $CONFIG->dbuser = '{{CONFIG_DBUSER}}';\r
-                       \r
-               // Database password\r
-                       $CONFIG->dbpass = '{{CONFIG_DBPASS}}';\r
-\r
-               // Database name\r
-                       $CONFIG->dbname = '{{CONFIG_DBNAME}}';\r
-                       \r
-               // Database server\r
-               // (For most configurations, you can leave this as 'localhost')\r
-                       $CONFIG->dbhost = '{{CONFIG_DBHOST}}';\r
-                       \r
-               // Database table prefix\r
-               // If you're sharing a database with other applications, you will want to use this\r
-               // to differentiate Elgg's tables.\r
-                       $CONFIG->dbprefix = '{{CONFIG_DBPREFIX}}';\r
-\r
-       /*\r
-        * Multiple database connections\r
-        * \r
-        * Here you can set up multiple connections for reads and writes. To do this, uncomment out\r
-        * the lines below. \r
-        */\r
-                       \r
-       /*\r
-\r
-               // Yes! We want to split reads and writes\r
-                       $CONFIG->db->split = true;\r
-        \r
-               // READS\r
-               // Database username\r
-                       $CONFIG->db['read']->dbuser = "";\r
-                       \r
-               // Database password\r
-                       $CONFIG->db['read']->dbpass = "";\r
-\r
-               // Database name\r
-                       $CONFIG->db['read']->dbname = "";\r
-                       \r
-               // Database server\r
-               // (For most configurations, you can leave this as 'localhost')\r
-                       $CONFIG->db['read']->dbhost = "localhost";\r
-\r
-               // WRITES\r
-               // Database username\r
-                       $CONFIG->db['write']->dbuser = "";\r
-                       \r
-               // Database password\r
-                       $CONFIG->db['write']->dbpass = "";\r
-\r
-               // Database name\r
-                       $CONFIG->db['write']->dbname = "";\r
-                       \r
-               // Database server\r
-               // (For most configurations, you can leave this as 'localhost')\r
-                       $CONFIG->db['write']->dbhost = "localhost";\r
-\r
-\r
-        */\r
-                       \r
-       /*\r
-        * For extra connections for both reads and writes, you can turn both\r
-        * $CONFIG->db['read'] and $CONFIG->db['write'] into an array, eg:\r
-        * \r
-        *      $CONFIG->db['read'][0]->dbhost = "localhost";\r
-        * \r
-        * Note that the array keys must be numeric and consecutive, i.e., they start\r
-        * at 0, the next one must be at 1, etc.\r
-        */\r
+<?php
+
+       /**
+        * Elgg settings
+        * 
+        * Elgg manages most of its configuration from the admin panel. However, we need you to
+        * include your database settings below.
+        * 
+        * @todo Turn this into something we handle more automatically. 
+        */
+
+               global $CONFIG;
+               if (!isset($CONFIG))
+                       $CONFIG = new stdClass;
+
+       /*
+        * Standard configuration
+        * 
+        * You will use the same database connection for reads and writes.
+        * This is the easiest configuration, and will suit 99.99% of setups. However, if you're
+        * running a really popular site, you'll probably want to spread out your database connections
+        * and implement database replication.  That's beyond the scope of this configuration file
+        * to explain, but if you know you need it, skip past this section. 
+        */
+               
+               // Database username
+                       $CONFIG->dbuser = '{{CONFIG_DBUSER}}';
+                       
+               // Database password
+                       $CONFIG->dbpass = '{{CONFIG_DBPASS}}';
+
+               // Database name
+                       $CONFIG->dbname = '{{CONFIG_DBNAME}}';
+                       
+               // Database server
+               // (For most configurations, you can leave this as 'localhost')
+                       $CONFIG->dbhost = '{{CONFIG_DBHOST}}';
+                       
+               // Database table prefix
+               // If you're sharing a database with other applications, you will want to use this
+               // to differentiate Elgg's tables.
+                       $CONFIG->dbprefix = '{{CONFIG_DBPREFIX}}';
+
+       /*
+        * Multiple database connections
+        * 
+        * Here you can set up multiple connections for reads and writes. To do this, uncomment out
+        * the lines below. 
+        */
+                       
+       /*
+
+               // Yes! We want to split reads and writes
+                       $CONFIG->db->split = true;
+        
+               // READS
+               // Database username
+                       $CONFIG->db['read']->dbuser = "";
+                       
+               // Database password
+                       $CONFIG->db['read']->dbpass = "";
+
+               // Database name
+                       $CONFIG->db['read']->dbname = "";
+                       
+               // Database server
+               // (For most configurations, you can leave this as 'localhost')
+                       $CONFIG->db['read']->dbhost = "localhost";
+
+               // WRITES
+               // Database username
+                       $CONFIG->db['write']->dbuser = "";
+                       
+               // Database password
+                       $CONFIG->db['write']->dbpass = "";
+
+               // Database name
+                       $CONFIG->db['write']->dbname = "";
+                       
+               // Database server
+               // (For most configurations, you can leave this as 'localhost')
+                       $CONFIG->db['write']->dbhost = "localhost";
+
+
+        */
+                       
+       /*
+        * For extra connections for both reads and writes, you can turn both
+        * $CONFIG->db['read'] and $CONFIG->db['write'] into an array, eg:
+        * 
+        *      $CONFIG->db['read'][0]->dbhost = "localhost";
+        * 
+        * Note that the array keys must be numeric and consecutive, i.e., they start
+        * at 0, the next one must be at 1, etc.
+        */
         
                        
        /**
        //$CONFIG->memcache_servers = array (
        //      array('server1', 11211),
        //      array('server2', 11211)
-       //);            \r
+       //);            
        
        /**
         * Some work-around flags.
        
        // Try uncommenting the below if your notification emails are not being sent
        // $CONFIG->broken_mta = true; 
-                       \r
-       /**\r
-         * Url - I am not sure if this will be here ?\r
-        **/\r
-        \r
-        // URL\r
-           $CONFIG->url = "";\r
-                       \r
+                       
+       /**
+         * Url - I am not sure if this will be here ?
+        **/
+        
+        // URL
+           $CONFIG->url = "";
+                       
 ?>
\ No newline at end of file
index c387e2fce08117193782b7bcd425d29706925097..23a04cb60cf2a8c5c928efbf3ccf4d17621aa326 100644 (file)
-<?php\r
-\r
-       /**\r
-        * Elgg engine bootstrapper\r
-        * Loads the various elements of the Elgg engine\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg engine bootstrapper
+        * Loads the various elements of the Elgg engine
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /*\r
-        * Basic profiling\r
-        */\r
-       global $START_MICROTIME; \r
-       $START_MICROTIME = microtime(true);\r
-\r
-       /**\r
-        * Load important prerequisites\r
-        */\r
-               \r
-               if (!include_once(dirname(__FILE__) . "/lib/exceptions.php")) {         // Exceptions \r
-                       echo "Error in installation: could not load the Exceptions library.";\r
-                       exit;\r
-               }\r
-               \r
-               if (!include_once(dirname(__FILE__) . "/lib/elgglib.php")) {            // Main Elgg library\r
-                       echo "Elgg could not load its main library.";\r
-                       exit;\r
-               }\r
-               \r
-               if (!include_once(dirname(__FILE__) . "/lib/access.php")) {             // Access library\r
-                       echo "Error in installation: could not load the Access library.";\r
-                       exit;\r
-               }\r
-       \r
-               if (!include_once(dirname(__FILE__) . "/lib/system_log.php")) {         // Logging library\r
-                       echo "Error in installation: could not load the System Log library.";\r
-                       exit;\r
-               }\r
-       \r
-               if (!include_once(dirname(__FILE__) . "/lib/export.php")) {             // Export library\r
-                       echo "Error in installation: could not load the Export library.";\r
-                       exit;\r
-               }\r
-               \r
-               if (!include_once(dirname(__FILE__) . "/lib/sessions.php")) {\r
-                       echo ("Error in installation: Elgg could not load the Sessions library");\r
-                       exit;\r
-               }\r
-               \r
-               if (!include_once(dirname(__FILE__) . "/lib/languages.php")) {          // Languages library\r
-                       echo "Error in installation: could not load the languages library.";\r
-                       exit;\r
-               }\r
-               \r
-               if (!include_once(dirname(__FILE__) . "/lib/input.php")) {              // Input library\r
-                       echo "Error in installation: could not load the input library.";\r
-                       exit;\r
-               }\r
-               \r
-               if (!include_once(dirname(__FILE__) . "/lib/install.php")) {            // Installation library\r
-                       echo "Error in installation: could not load the installation library.";\r
-                       exit;\r
-               }\r
-               \r
-               if (!include_once(dirname(__FILE__) . "/lib/cache.php")) {              // Installation library\r
-                       echo "Error in installation: could not load the cache library.";\r
-                       exit;\r
-               }\r
-               \r
-               \r
-               \r
-               // Use fallback view until sanitised\r
-               $oldview = get_input('view');\r
-               set_input('view', 'failsafe');\r
-               \r
-       /**\r
-        * Set light mode default\r
-        */\r
-               $lightmode = false;\r
-               \r
-       /**\r
-        * Establish handlers\r
-        */\r
-               \r
-       // Register the error handler\r
-               set_error_handler('__elgg_php_error_handler');\r
-               set_exception_handler('__elgg_php_exception_handler');\r
-               \r
-       /**\r
-        * If there are basic issues with the way the installation is formed, don't bother trying\r
-        * to load any more files\r
-        */\r
-               \r
-               if ($sanitised = sanitised()) { // Begin portion for sanitised installs only\r
-       \r
-                /**\r
-                * Load the system settings\r
-                */\r
-                       \r
-                       if (!include_once(dirname(__FILE__) . "/settings.php"))                 // Global settings\r
-                               throw new InstallationException("Elgg could not load the settings file.");\r
-                               \r
-               /**\r
-                * Load and initialise the database\r
-                */\r
-       \r
-                       if (!include_once(dirname(__FILE__) . "/lib/database.php"))     // Database connection\r
-                               throw new InstallationException("Elgg could not load the main Elgg database library.");\r
-                               \r
-               /**\r
-                * Load the remaining libraries from /lib/ in alphabetical order,\r
-                * except for a few exceptions\r
-                */\r
-                       \r
-                       if (!include_once(dirname(__FILE__) . "/lib/actions.php")) {\r
-                               throw new InstallationException("Elgg could not load the Actions library");\r
-                       }       \r
-\r
-                               \r
-\r
-               // We don't want to load or reload these files\r
-       \r
-                       $file_exceptions = array(\r
-                                                                               '.','..',\r
-                                                                               '.DS_Store',\r
-                                                                               'Thumbs.db',\r
-                                                                               '.svn',\r
-                                                                               'CVS','cvs',\r
-                                                                               'settings.php','settings.example.php','languages.php','exceptions.php','elgglib.php','access.php','database.php','actions.php','sessions.php'\r
-                                                                       );\r
-       \r
-               // Get the list of files to include, and alphabetically sort them\r
-       \r
-                       $files = get_library_files(dirname(__FILE__) . "/lib",$file_exceptions);\r
-                       asort($files);\r
-                       \r
-               // Get config\r
-                       global $CONFIG;\r
-       \r
-               // Include them\r
-                       foreach($files as $file) {\r
-                               if (isset($CONFIG->debug) && $CONFIG->debug) error_log("Loading $file..."); \r
-                               if (!include_once($file))\r
-                                       throw new InstallationException("Could not load {$file}");\r
-                       }\r
-               \r
-               } else {        // End portion for sanitised installs only\r
-                       \r
-                       throw new InstallationException(elgg_echo('installation:error:configuration'));\r
-                       \r
-               }\r
-               \r
-               // Autodetect some default configuration settings\r
-                       set_default_config();\r
-       \r
-               // Trigger events\r
-                       trigger_elgg_event('boot', 'system');\r
-                       \r
-               // Load plugins\r
-               \r
-                       $installed = is_installed();\r
-                       $db_installed = is_db_installed();\r
-                       \r
-                       // Determine light mode\r
-                       $lm = strtolower(get_input('lightmode'));\r
-                       if ($lm == 'true') $lightmode = true;\r
-                       \r
-                       // Load plugins, if we're not in light mode\r
-                       if (($installed) && ($db_installed) && ($sanitised) && (!$lightmode)) {\r
-                               load_plugins();\r
-                               \r
-                               trigger_elgg_event('plugins_boot', 'system');\r
-                       }\r
-                       \r
-               // Forward if we haven't been installed\r
-                       if ((!$installed || !$db_installed) && !substr_count($_SERVER["PHP_SELF"],"install.php") && !substr_count($_SERVER["PHP_SELF"],"css.php") && !substr_count($_SERVER["PHP_SELF"],"action_handler.php")) {\r
-                                       header("Location: install.php");\r
-                                       exit;\r
-                       }\r
-                       \r
-               // Trigger events\r
-                       if (!substr_count($_SERVER["PHP_SELF"],"install.php") &&\r
-                               !substr_count($_SERVER["PHP_SELF"],"setup.php") &&\r
-                               !$lightmode\r
-                               && !(defined('upgrading') && upgrading == 'upgrading')) {\r
-                               // If default settings haven't been installed, forward to the default settings page\r
-                               trigger_elgg_event('init', 'system');\r
-                               //if (!datalist_get('default_settings')) {\r
-                                       //forward("setup.php");\r
-                               //}\r
-                       }\r
-                       \r
-               // System booted, return to normal view\r
-                       set_input('view', $oldview);\r
-                       if (empty($oldview)) {\r
-                               if (empty($CONFIG->view)) \r
-                                       $oldview = 'default';\r
-                               else\r
-                                       $oldview = $CONFIG->view;\r
-                       }\r
-                       \r
-                       if (($installed) && ($db_installed)) \r
-                       {\r
-                               $lastupdate = datalist_get('simplecache_lastupdate');\r
-                               $lastcached = datalist_get('simplecache_'.$oldview);\r
-                               if ($lastupdate == 0 || $lastcached < $lastupdate) {\r
-                                       elgg_view_regenerate_simplecache();\r
-                                       $lastcached = time();\r
-                                       datalist_set('simplecache_lastupdate',$lastcached);\r
-                                       datalist_set('simplecache_'.$oldview,$lastcached);\r
-                               }\r
-                               $CONFIG->lastcache = $lastcached;\r
-                       }\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       /*
+        * Basic profiling
+        */
+       global $START_MICROTIME; 
+       $START_MICROTIME = microtime(true);
+
+       /**
+        * Load important prerequisites
+        */
+               
+               if (!include_once(dirname(__FILE__) . "/lib/exceptions.php")) {         // Exceptions 
+                       echo "Error in installation: could not load the Exceptions library.";
+                       exit;
+               }
+               
+               if (!include_once(dirname(__FILE__) . "/lib/elgglib.php")) {            // Main Elgg library
+                       echo "Elgg could not load its main library.";
+                       exit;
+               }
+               
+               if (!include_once(dirname(__FILE__) . "/lib/access.php")) {             // Access library
+                       echo "Error in installation: could not load the Access library.";
+                       exit;
+               }
+       
+               if (!include_once(dirname(__FILE__) . "/lib/system_log.php")) {         // Logging library
+                       echo "Error in installation: could not load the System Log library.";
+                       exit;
+               }
+       
+               if (!include_once(dirname(__FILE__) . "/lib/export.php")) {             // Export library
+                       echo "Error in installation: could not load the Export library.";
+                       exit;
+               }
+               
+               if (!include_once(dirname(__FILE__) . "/lib/sessions.php")) {
+                       echo ("Error in installation: Elgg could not load the Sessions library");
+                       exit;
+               }
+               
+               if (!include_once(dirname(__FILE__) . "/lib/languages.php")) {          // Languages library
+                       echo "Error in installation: could not load the languages library.";
+                       exit;
+               }
+               
+               if (!include_once(dirname(__FILE__) . "/lib/input.php")) {              // Input library
+                       echo "Error in installation: could not load the input library.";
+                       exit;
+               }
+               
+               if (!include_once(dirname(__FILE__) . "/lib/install.php")) {            // Installation library
+                       echo "Error in installation: could not load the installation library.";
+                       exit;
+               }
+               
+               if (!include_once(dirname(__FILE__) . "/lib/cache.php")) {              // Installation library
+                       echo "Error in installation: could not load the cache library.";
+                       exit;
+               }
+               
+               
+               
+               // Use fallback view until sanitised
+               $oldview = get_input('view');
+               set_input('view', 'failsafe');
+               
+       /**
+        * Set light mode default
+        */
+               $lightmode = false;
+               
+       /**
+        * Establish handlers
+        */
+               
+       // Register the error handler
+               set_error_handler('__elgg_php_error_handler');
+               set_exception_handler('__elgg_php_exception_handler');
+               
+       /**
+        * If there are basic issues with the way the installation is formed, don't bother trying
+        * to load any more files
+        */
+               
+               if ($sanitised = sanitised()) { // Begin portion for sanitised installs only
+       
+                /**
+                * Load the system settings
+                */
+                       
+                       if (!include_once(dirname(__FILE__) . "/settings.php"))                 // Global settings
+                               throw new InstallationException("Elgg could not load the settings file.");
+                               
+               /**
+                * Load and initialise the database
+                */
+       
+                       if (!include_once(dirname(__FILE__) . "/lib/database.php"))     // Database connection
+                               throw new InstallationException("Elgg could not load the main Elgg database library.");
+                               
+               /**
+                * Load the remaining libraries from /lib/ in alphabetical order,
+                * except for a few exceptions
+                */
+                       
+                       if (!include_once(dirname(__FILE__) . "/lib/actions.php")) {
+                               throw new InstallationException("Elgg could not load the Actions library");
+                       }       
+
+                               
+
+               // We don't want to load or reload these files
+       
+                       $file_exceptions = array(
+                                                                               '.','..',
+                                                                               '.DS_Store',
+                                                                               'Thumbs.db',
+                                                                               '.svn',
+                                                                               'CVS','cvs',
+                                                                               'settings.php','settings.example.php','languages.php','exceptions.php','elgglib.php','access.php','database.php','actions.php','sessions.php'
+                                                                       );
+       
+               // Get the list of files to include, and alphabetically sort them
+       
+                       $files = get_library_files(dirname(__FILE__) . "/lib",$file_exceptions);
+                       asort($files);
+                       
+               // Get config
+                       global $CONFIG;
+       
+               // Include them
+                       foreach($files as $file) {
+                               if (isset($CONFIG->debug) && $CONFIG->debug) error_log("Loading $file..."); 
+                               if (!include_once($file))
+                                       throw new InstallationException("Could not load {$file}");
+                       }
+               
+               } else {        // End portion for sanitised installs only
+                       
+                       throw new InstallationException(elgg_echo('installation:error:configuration'));
+                       
+               }
+               
+               // Autodetect some default configuration settings
+                       set_default_config();
+       
+               // Trigger events
+                       trigger_elgg_event('boot', 'system');
+                       
+               // Load plugins
+               
+                       $installed = is_installed();
+                       $db_installed = is_db_installed();
+                       
+                       // Determine light mode
+                       $lm = strtolower(get_input('lightmode'));
+                       if ($lm == 'true') $lightmode = true;
+                       
+                       // Load plugins, if we're not in light mode
+                       if (($installed) && ($db_installed) && ($sanitised) && (!$lightmode)) {
+                               load_plugins();
+                               
+                               trigger_elgg_event('plugins_boot', 'system');
+                       }
+                       
+               // Forward if we haven't been installed
+                       if ((!$installed || !$db_installed) && !substr_count($_SERVER["PHP_SELF"],"install.php") && !substr_count($_SERVER["PHP_SELF"],"css.php") && !substr_count($_SERVER["PHP_SELF"],"action_handler.php")) {
+                                       header("Location: install.php");
+                                       exit;
+                       }
+                       
+               // Trigger events
+                       if (!substr_count($_SERVER["PHP_SELF"],"install.php") &&
+                               !substr_count($_SERVER["PHP_SELF"],"setup.php") &&
+                               !$lightmode
+                               && !(defined('upgrading') && upgrading == 'upgrading')) {
+                               // If default settings haven't been installed, forward to the default settings page
+                               trigger_elgg_event('init', 'system');
+                               //if (!datalist_get('default_settings')) {
+                                       //forward("setup.php");
+                               //}
+                       }
+                       
+               // System booted, return to normal view
+                       set_input('view', $oldview);
+                       if (empty($oldview)) {
+                               if (empty($CONFIG->view)) 
+                                       $oldview = 'default';
+                               else
+                                       $oldview = $CONFIG->view;
+                       }
+                       
+                       if (($installed) && ($db_installed)) 
+                       {
+                               $lastupdate = datalist_get('simplecache_lastupdate');
+                               $lastcached = datalist_get('simplecache_'.$oldview);
+                               if ($lastupdate == 0 || $lastcached < $lastupdate) {
+                                       elgg_view_regenerate_simplecache();
+                                       $lastcached = time();
+                                       datalist_set('simplecache_lastupdate',$lastcached);
+                                       datalist_set('simplecache_'.$oldview,$lastcached);
+                               }
+                               $CONFIG->lastcache = $lastcached;
+                       }
 ?>
\ No newline at end of file
index 5b6b104b6b42260ff2d24ccc084f180da62ab139..85395b78dba005edf6644321b8fe5b8eb6176b5f 100644 (file)
@@ -1,68 +1,68 @@
-<?php\r
-\r
-       /**\r
-        * Generic entity viewer\r
-        * Given a GUID, this page will try and display any entity\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Generic entity viewer
+        * Given a GUID, this page will try and display any entity
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Load Elgg engine
+               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+
+       // Get the GUID of the entity we want to view
+               $guid = (int) get_input('guid');
+               $shell = get_input('shell');
+               if ($shell == "no") {
+                       $shell = false;
+               } else {
+                       $shell = true;
+               }
+               
+               $context = get_input('context');
+               if ($context) set_context($context);
+               
+       // Get the entity, if possible
+               if ($entity = get_entity($guid)) {
+
+                       if ($entity->container_guid) {
+                               set_page_owner($entity->container_guid);
+                       } else {
+                               set_page_owner($entity->owner_guid);
+                       }
+                       
+       // Set the body to be the full view of the entity, and the title to be its title
+                       if ($entity instanceof ElggObject) {
+                               $title = $entity->title;
+                       } else if ($entity instanceof ElggEntity) {
+                               $title = $entity->name;
+                       }
+                       $area2 = elgg_view_entity($entity,true);
+                       if ($shell) {
+                               $body = elgg_view_layout('two_column_left_sidebar', '', $area1 . $area2);
+                       } else {
+                               $body = $area2;
+                       }
+                       
+       // Otherwise?
+               } else {
+                       
+                       $body = elgg_echo('notfound');
+                       
+               }
+               
+       // Display the page
+               if ($shell) {
+                       page_draw($title, $body);
+               } else {
+                       header("Content-type: text/html; charset=UTF-8");
+                       echo $title;
+                       echo $body;
+               }
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Load Elgg engine\r
-               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");\r
-\r
-       // Get the GUID of the entity we want to view\r
-               $guid = (int) get_input('guid');\r
-               $shell = get_input('shell');\r
-               if ($shell == "no") {\r
-                       $shell = false;\r
-               } else {\r
-                       $shell = true;\r
-               }\r
-               \r
-               $context = get_input('context');\r
-               if ($context) set_context($context);\r
-               \r
-       // Get the entity, if possible\r
-               if ($entity = get_entity($guid)) {\r
-\r
-                       if ($entity->container_guid) {\r
-                               set_page_owner($entity->container_guid);\r
-                       } else {\r
-                               set_page_owner($entity->owner_guid);\r
-                       }\r
-                       \r
-       // Set the body to be the full view of the entity, and the title to be its title\r
-                       if ($entity instanceof ElggObject) {\r
-                               $title = $entity->title;\r
-                       } else if ($entity instanceof ElggEntity) {\r
-                               $title = $entity->name;\r
-                       }\r
-                       $area2 = elgg_view_entity($entity,true);\r
-                       if ($shell) {\r
-                               $body = elgg_view_layout('two_column_left_sidebar', '', $area1 . $area2);\r
-                       } else {\r
-                               $body = $area2;\r
-                       }\r
-                       \r
-       // Otherwise?\r
-               } else {\r
-                       \r
-                       $body = elgg_echo('notfound');\r
-                       \r
-               }\r
-               \r
-       // Display the page\r
-               if ($shell) {\r
-                       page_draw($title, $body);\r
-               } else {\r
-                       header("Content-type: text/html; charset=UTF-8");\r
-                       echo $title;\r
-                       echo $body;\r
-               }\r
-\r
 ?>
\ No newline at end of file
index e6505a6e95785c7687dc84e45bb38971da21ed52..3b02efc1566d389d0c37e3b569c61db7c274e6e7 100644 (file)
@@ -1,21 +1,21 @@
-<?php\r
-\r
-       /**\r
-        * Activity viewer\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Activity viewer
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+               set_context('search');
+               $area2 = list_entities("","",0,10,false);
+               set_context('entities');
+               $body = elgg_view_layout('two_column_left_sidebar',$area1, $area2);
+               page_draw("",$body);
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");\r
-               set_context('search');\r
-               $area2 = list_entities("","",0,10,false);\r
-               set_context('entities');\r
-               $body = elgg_view_layout('two_column_left_sidebar',$area1, $area2);\r
-               page_draw("",$body);\r
-\r
 ?>
\ No newline at end of file
index edca9d96eb72db96aa0c9eb620b27e8b59b8bb5e..60cbd28dba483af57b88df17832ede74761a7141 100644 (file)
@@ -1,28 +1,28 @@
-<?php\r
-\r
-       /**\r
-        * Elgg add a collection of friends\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg add a collection of friends
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Start engine
+               require_once(dirname(dirname((__FILE__))) . "/engine/start.php");
+               
+       // You need to be logged in for this one
+               gatekeeper();
+               
+           $area2 = elgg_view('friends/forms/edit', array('friends' => get_user_friends($_SESSION['user']->getGUID(),"",9999)));
+               
+       // Format page
+               $body = elgg_view_layout('two_column_left_sidebar','', elgg_view_title(elgg_echo('friends:collections:add')) . $area2);
+               
+       // Draw it
+               page_draw(elgg_echo('friends:collections:add'),$body);
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Start engine\r
-               require_once(dirname(dirname((__FILE__))) . "/engine/start.php");\r
-               \r
-       // You need to be logged in for this one\r
-               gatekeeper();\r
-               \r
-           $area2 = elgg_view('friends/forms/edit', array('friends' => get_user_friends($_SESSION['user']->getGUID(),"",9999)));\r
-               \r
-       // Format page\r
-               $body = elgg_view_layout('two_column_left_sidebar','', elgg_view_title(elgg_echo('friends:collections:add')) . $area2);\r
-               \r
-       // Draw it\r
-               page_draw(elgg_echo('friends:collections:add'),$body);\r
-\r
 ?>
\ No newline at end of file
index f507654e42c793a220a140ed6261c473bdcdf832..6c023f005a1144553cb9e98d70c65efb317c6577 100644 (file)
@@ -1,28 +1,28 @@
-<?php\r
-\r
-       /**\r
-        * Elgg collections of friends\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg collections of friends
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Start engine
+               require_once(dirname(dirname((__FILE__))) . "/engine/start.php");
+               
+       // You need to be logged in for this one
+               gatekeeper();
+           
+               $area2 = elgg_view_access_collections($_SESSION['user']->getGUID());
+               
+       // Format page
+               $body = elgg_view_layout('two_column_left_sidebar', '', elgg_view_title(elgg_echo('friends:collections')) . $area2);
+               
+       // Draw it
+               page_draw(elgg_echo('friends:collections'),$body);
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Start engine\r
-               require_once(dirname(dirname((__FILE__))) . "/engine/start.php");\r
-               \r
-       // You need to be logged in for this one\r
-               gatekeeper();\r
-           \r
-               $area2 = elgg_view_access_collections($_SESSION['user']->getGUID());\r
-               \r
-       // Format page\r
-               $body = elgg_view_layout('two_column_left_sidebar', '', elgg_view_title(elgg_echo('friends:collections')) . $area2);\r
-               \r
-       // Draw it\r
-               page_draw(elgg_echo('friends:collections'),$body);\r
-\r
 ?>
\ No newline at end of file
index 5ece2596abb0a0768f7202f4df66592e3308d67e..cd9f37b9561e24f5721cd27218383fbc0cd507b8 100644 (file)
@@ -1,39 +1,39 @@
-<?php\r
-\r
-       /**\r
-        * Elgg add a collection of friends\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg add a collection of friends
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Start engine
+               require_once(dirname(dirname((__FILE__))) . "/engine/start.php");
+               
+       // You need to be logged in for this one
+               gatekeeper();
+               
+               //set the title
+               $area1 = elgg_view_title(elgg_echo('friends:collectionedit'), false);
+               
+               //grab the collection id passed to the edit form
+               $collection_id = get_input('collection');
+               
+               //get the full collection
+               $collection = get_access_collection($collection_id);
+               //get all members of the collection
+               $collection_members = get_members_of_access_collection($collection_id);
+               
+           $area2 = elgg_view('friends/forms/edit', array('collection' => $collection, 'collection_members' => $collection_members));
+               
+       // Format page
+               $body = elgg_view_layout('two_column_left_sidebar',$area1. $area2);
+               
+       // Draw it
+               page_draw(elgg_echo('friends:add'),$body);
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Start engine\r
-               require_once(dirname(dirname((__FILE__))) . "/engine/start.php");\r
-               \r
-       // You need to be logged in for this one\r
-               gatekeeper();\r
-               \r
-               //set the title\r
-               $area1 = elgg_view_title(elgg_echo('friends:collectionedit'), false);\r
-               \r
-               //grab the collection id passed to the edit form\r
-               $collection_id = get_input('collection');\r
-               \r
-               //get the full collection\r
-               $collection = get_access_collection($collection_id);\r
-               //get all members of the collection\r
-               $collection_members = get_members_of_access_collection($collection_id);\r
-               \r
-           $area2 = elgg_view('friends/forms/edit', array('collection' => $collection, 'collection_members' => $collection_members));\r
-               \r
-       // Format page\r
-               $body = elgg_view_layout('two_column_left_sidebar',$area1. $area2);\r
-               \r
-       // Draw it\r
-               page_draw(elgg_echo('friends:add'),$body);\r
-\r
 ?>
\ No newline at end of file
index 1c85cdc6fd2861336ed1fb9fa1b0f4087fec0ed6..e9e4f73743caf9bbe78d121b3f677e0ee58be908 100644 (file)
@@ -1,26 +1,26 @@
-<?php\r
-\r
-       /**\r
-        * Elgg friends page\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg friends page
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+               if (!$owner = page_owner_entity()) {
+                       gatekeeper();
+                       set_page_owner($_SESSION['user']->getGUID());
+                       $owner = $_SESSION['user'];
+               }
+               
+               $area1 = elgg_view_title(elgg_echo('friends'));
+               $area2 = list_entities_from_relationship('friend',$owner->getGUID(),false,'user','',0,10,false);
+               $body = elgg_view_layout('two_column_left_sidebar', '', $area1 . $area2);
+               
+               page_draw(sprintf(elgg_echo("friends:owned"),$owner->name),$body);
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-               if (!$owner = page_owner_entity()) {\r
-                       gatekeeper();\r
-                       set_page_owner($_SESSION['user']->getGUID());\r
-                       $owner = $_SESSION['user'];\r
-               }\r
-               \r
-               $area1 = elgg_view_title(elgg_echo('friends'));\r
-               $area2 = list_entities_from_relationship('friend',$owner->getGUID(),false,'user','',0,10,false);\r
-               $body = elgg_view_layout('two_column_left_sidebar', '', $area1 . $area2);\r
-               \r
-               page_draw(sprintf(elgg_echo("friends:owned"),$owner->name),$body);\r
-\r
 ?>
\ No newline at end of file
index 4ae20dc7d65685e4b36eaffd6e2fc8a5878fa6d4..f1231750ce538f2b038673b401924c0c2df85959 100644 (file)
@@ -1,26 +1,26 @@
-<?php\r
-\r
-       /**\r
-        * Elgg friends of page\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg friends of page
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+               if (!$owner = page_owner_entity()) {
+                       gatekeeper();
+                       set_page_owner($_SESSION['user']->getGUID());
+                       $owner = $_SESSION['user'];
+               }
+               
+               $area1 = elgg_view_title(elgg_echo('friends:of'));
+               $area2 = list_entities_from_relationship('friend',$owner->getGUID(),true,'user','',0,10,false);
+               $body = elgg_view_layout('two_column_left_sidebar', '', $area1 . $area2);
+               
+               page_draw(sprintf(elgg_echo("friends:of:owned"),$owner->name),$body);
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-               if (!$owner = page_owner_entity()) {\r
-                       gatekeeper();\r
-                       set_page_owner($_SESSION['user']->getGUID());\r
-                       $owner = $_SESSION['user'];\r
-               }\r
-               \r
-               $area1 = elgg_view_title(elgg_echo('friends:of'));\r
-               $area2 = list_entities_from_relationship('friend',$owner->getGUID(),true,'user','',0,10,false);\r
-               $body = elgg_view_layout('two_column_left_sidebar', '', $area1 . $area2);\r
-               \r
-               page_draw(sprintf(elgg_echo("friends:of:owned"),$owner->name),$body);\r
-\r
 ?>
\ No newline at end of file
index 2cbe82506031ccb664bdd239f7bb12ef740fd007..57406b94d8f956967108d2320182ecc3add9a88a 100644 (file)
@@ -1,61 +1,61 @@
-<?php\r
-\r
-       /**\r
-        * Elgg friends picker callback\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg friends picker callback
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Load Elgg engine\r
-               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");\r
-               global $CONFIG;\r
-\r
-       // Get callback type (list or picker)\r
-               $type = get_input('type','picker');\r
-               \r
-       // Get list of members if applicable\r
-               /*$members = get_input('members','');\r
-               if (!empty($members)) {\r
-                       $members = explode(',',$members);\r
-               } else {\r
-                       $members = array();\r
-               }*/\r
-               $collection = (int) get_input('collection',0);\r
-               $members = get_members_of_access_collection($collection, true);\r
-               if (!$members) $members = array();\r
-               \r
-               $friendspicker = (int) get_input('friendspicker',0);\r
-               \r
-       // Get page owner (bomb out if there isn't one)\r
-               $pageowner = page_owner_entity();\r
-               if (!$pageowner) { forward(); exit; }\r
-               \r
-       // Depending on the view type, launch a different view\r
-               switch($type) {\r
-                       \r
-                       case 'list':            \r
-                                                               $js_segment = elgg_view('friends/tablelistcountupdate',array('friendspicker' => $friendspicker, 'count' => sizeof($members)));\r
-                                                               $content = elgg_view('friends/tablelist',array('entities' => $members, 'content' => $js_segment));\r
-                                                               break;\r
-                       default:                        $friends = $pageowner->getFriends('',9999);\r
-                                                               $content = elgg_view('friends/picker',array(\r
-                                                                                               'entities' => $friends,\r
-                                                                                               'value' => $members,\r
-                                                                                               'callback' => true,\r
-                                                                                               'friendspicker' => $friendspicker,\r
-                                                                                               'formcontents' => elgg_view('friends/forms/collectionfields',array('collection' => get_access_collection($collection))),\r
-                                                                                               'formtarget' => $CONFIG->wwwroot . 'action/friends/editcollection', \r
-                                                                                                                                                       ));\r
-                                                               break;\r
-                       \r
-               }\r
-               \r
-       // Output the content\r
-               echo $content;\r
-               \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Load Elgg engine
+               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+               global $CONFIG;
+
+       // Get callback type (list or picker)
+               $type = get_input('type','picker');
+               
+       // Get list of members if applicable
+               /*$members = get_input('members','');
+               if (!empty($members)) {
+                       $members = explode(',',$members);
+               } else {
+                       $members = array();
+               }*/
+               $collection = (int) get_input('collection',0);
+               $members = get_members_of_access_collection($collection, true);
+               if (!$members) $members = array();
+               
+               $friendspicker = (int) get_input('friendspicker',0);
+               
+       // Get page owner (bomb out if there isn't one)
+               $pageowner = page_owner_entity();
+               if (!$pageowner) { forward(); exit; }
+               
+       // Depending on the view type, launch a different view
+               switch($type) {
+                       
+                       case 'list':            
+                                                               $js_segment = elgg_view('friends/tablelistcountupdate',array('friendspicker' => $friendspicker, 'count' => sizeof($members)));
+                                                               $content = elgg_view('friends/tablelist',array('entities' => $members, 'content' => $js_segment));
+                                                               break;
+                       default:                        $friends = $pageowner->getFriends('',9999);
+                                                               $content = elgg_view('friends/picker',array(
+                                                                                               'entities' => $friends,
+                                                                                               'value' => $members,
+                                                                                               'callback' => true,
+                                                                                               'friendspicker' => $friendspicker,
+                                                                                               'formcontents' => elgg_view('friends/forms/collectionfields',array('collection' => get_access_collection($collection))),
+                                                                                               'formtarget' => $CONFIG->wwwroot . 'action/friends/editcollection', 
+                                                                                                                                                       ));
+                                                               break;
+                       
+               }
+               
+       // Output the content
+               echo $content;
+               
 ?>
\ No newline at end of file
index 8da033bd9553d44ad5d276bee0c4a4a5df39fa9f..effdac99d50fee0edb58ec29d8c29f1f8d07b5da 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,44 +1,44 @@
-<?php\r
-\r
-       /**\r
-        * Elgg index page for web-based applications\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg index page for web-based applications
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /**\r
-        * Start the Elgg engine\r
-        */\r
-               define('externalpage',true);\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       /**
+        * Start the Elgg engine
+        */
+               define('externalpage',true);
                require_once(dirname(__FILE__) . "/engine/start.php");
                
                
                if (!trigger_plugin_hook('index','system',null,false)) {
        
-                       /**\r
-                     * Check to see if user is logged in, if not display login form\r
-                     **/\r
-                               \r
-                               if (isloggedin()) forward('pg/dashboard/');\r
-                       \r
-               //Load the front page\r
-                       global $CONFIG;\r
-                       $title = elgg_view_title(elgg_echo('content:latest'));\r
-                       set_context('search');\r
-                       $content = list_registered_entities(0,10,true,false,array('object','group'));\r
-                       set_context('main');\r
-                       global $autofeed;\r
-                       $autofeed = false;\r
-                       $content = elgg_view_layout('two_column_left_sidebar', '', $title . $content, elgg_view("account/forms/login"));\r
-                       page_draw(null, $content);\r
-               \r
+                       /**
+                     * Check to see if user is logged in, if not display login form
+                     **/
+                               
+                               if (isloggedin()) forward('pg/dashboard/');
+                       
+               //Load the front page
+                       global $CONFIG;
+                       $title = elgg_view_title(elgg_echo('content:latest'));
+                       set_context('search');
+                       $content = list_registered_entities(0,10,true,false,array('object','group'));
+                       set_context('main');
+                       global $autofeed;
+                       $autofeed = false;
+                       $content = elgg_view_layout('two_column_left_sidebar', '', $title . $content, elgg_view("account/forms/login"));
+                       page_draw(null, $content);
+               
                }
 
 
-\r
+
 ?>
\ No newline at end of file
index 50447941af317c0b3aee15b0944f23208ec3cead..48290fdf0f9fe3fda5526ba5a57a11fd0f493deb 100644 (file)
@@ -1,42 +1,42 @@
-<?php\r
-\r
-       /**\r
-        * Elgg install script\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg install script
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       /**\r
-        * Start the Elgg engine\r
-        */\r
-               require_once(dirname(__FILE__) . "/engine/start.php");\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       /**
+        * Start the Elgg engine
+        */
+               require_once(dirname(__FILE__) . "/engine/start.php");
                global $CONFIG;
                
-               elgg_set_viewtype('failsafe');\r
-       /**\r
-        * If we're installed, go back to the homepage\r
-        */\r
-               if ((is_installed() && is_db_installed() && datalist_get('installed')))\r
-                       forward("index.php");\r
-               \r
-       /**\r
-        * Install the database\r
-        */\r
+               elgg_set_viewtype('failsafe');
+       /**
+        * If we're installed, go back to the homepage
+        */
+               if ((is_installed() && is_db_installed() && datalist_get('installed')))
+                       forward("index.php");
+               
+       /**
+        * Install the database
+        */
                if (!is_db_installed()) {
-                       validate_platform();\r
+                       validate_platform();
                        run_sql_script(dirname(__FILE__) . "/engine/schema/mysql.sql");
-                       init_site_secret();\r
-                       system_message(elgg_echo("installation:success"));\r
-               }\r
-               \r
-       /**\r
-        * Load the front page\r
-        */\r
-               page_draw(elgg_echo("installation:settings"), elgg_view_layout("one_column", elgg_view("settings/install")));\r
-\r
+                       init_site_secret();
+                       system_message(elgg_echo("installation:success"));
+               }
+               
+       /**
+        * Load the front page
+        */
+               page_draw(elgg_echo("installation:settings"), elgg_view_layout("one_column", elgg_view("settings/install")));
+
 ?>
\ No newline at end of file
index 5bd856fb892d38c421eb2d79447ffef5b7f513bc..8878fa0d978102eabde508fb07f7fba7e41ce6c6 100644 (file)
-<?php\r
-\r
-       $english = array(\r
-\r
-               /**\r
-                * Sites\r
-                */\r
-       \r
-                       'item:site' => 'Sites',\r
-       \r
-               /**\r
-                * Sessions\r
-                */\r
-                       \r
-                       'login' => "Log in",\r
-                       'loginok' => "You have been logged in.",\r
-                       'loginerror' => "We couldn't log you in. This may be because you haven't validated your account yet, the details you supplied were incorrect, or you have made too many incorrect login attempts. Make sure your details are correct and please try again.",\r
-       \r
-                       'logout' => "Log out",\r
-                       'logoutok' => "You have been logged out.",\r
-                       'logouterror' => "We couldn't log you out. Please try again.",\r
-       \r
-               /**\r
-                * Errors\r
-                */\r
-                       'exception:title' => "Welcome to Elgg.",\r
-       \r
-                       'InstallationException:CantCreateSite' => "Unable to create a default ElggSite with credentials Name:%s, Url: %s",\r
-               \r
-                       'actionundefined' => "The requested action (%s) was not defined in the system.",\r
-                       'actionloggedout' => "Sorry, you cannot perform this action while logged out.",\r
-       \r
-                       'notfound' => "The requested resource could not be found, or you do not have access to it.",\r
-                       \r
-                       'SecurityException:Codeblock' => "Denied access to execute privileged code block",\r
-                       'DatabaseException:WrongCredentials' => "Elgg couldn't connect to the database using the given credentials.",\r
-                       'DatabaseException:NoConnect' => "Elgg couldn't select the database '%s', please check that the database is created and you have access to it.",\r
-                       'SecurityException:FunctionDenied' => "Access to privileged function '%s' is denied.",\r
-                       'DatabaseException:DBSetupIssues' => "There were a number of issues: ",\r
-                       'DatabaseException:ScriptNotFound' => "Elgg couldn't find the requested database script at %s.",\r
-                       \r
-                       'IOException:FailedToLoadGUID' => "Failed to load new %s from GUID:%d",\r
-                       'InvalidParameterException:NonElggObject' => "Passing a non-ElggObject to an ElggObject constructor!",\r
-                       'InvalidParameterException:UnrecognisedValue' => "Unrecognised value passed to constuctor.",\r
-                       \r
-                       'InvalidClassException:NotValidElggStar' => "GUID:%d is not a valid %s",\r
-                       \r
-                       'PluginException:MisconfiguredPlugin' => "%s is a misconfigured plugin.",\r
-                       \r
-                       'InvalidParameterException:NonElggUser' => "Passing a non-ElggUser to an ElggUser constructor!",\r
-                       \r
-                       'InvalidParameterException:NonElggSite' => "Passing a non-ElggSite to an ElggSite constructor!",\r
-                       \r
-                       'InvalidParameterException:NonElggGroup' => "Passing a non-ElggGroup to an ElggGroup constructor!",\r
-       \r
-                       'IOException:UnableToSaveNew' => "Unable to save new %s",\r
-                       \r
-                       'InvalidParameterException:GUIDNotForExport' => "GUID has not been specified during export, this should never happen.",\r
-                       'InvalidParameterException:NonArrayReturnValue' => "Entity serialisation function passed a non-array returnvalue parameter",\r
-                       \r
-                       'ConfigurationException:NoCachePath' => "Cache path set to nothing!",\r
-                       'IOException:NotDirectory' => "%s is not a directory.",\r
-                       \r
-                       'IOException:BaseEntitySaveFailed' => "Unable to save new object's base entity information!",\r
-                       'InvalidParameterException:UnexpectedODDClass' => "import() passed an unexpected ODD class",\r
-                       'InvalidParameterException:EntityTypeNotSet' => "Entity type must be set.",\r
-                       \r
-                       'ClassException:ClassnameNotClass' => "%s is not a %s.",\r
-                       'ClassNotFoundException:MissingClass' => "Class '%s' was not found, missing plugin?",\r
-                       'InstallationException:TypeNotSupported' => "Type %s is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade.",\r
-\r
-                       'ImportException:ImportFailed' => "Could not import element %d",\r
-                       'ImportException:ProblemSaving' => "There was a problem saving %s",\r
-                       'ImportException:NoGUID' => "New entity created but has no GUID, this should not happen.",\r
-                       \r
-                       'ImportException:GUIDNotFound' => "Entity '%d' could not be found.",\r
-                       'ImportException:ProblemUpdatingMeta' => "There was a problem updating '%s' on entity '%d'",\r
-                       \r
-                       'ExportException:NoSuchEntity' => "No such entity GUID:%d", \r
-                       \r
-                       'ImportException:NoODDElements' => "No OpenDD elements found in import data, import failed.",\r
-                       'ImportException:NotAllImported' => "Not all elements were imported.",\r
-                       \r
-                       'InvalidParameterException:UnrecognisedFileMode' => "Unrecognised file mode '%s'",\r
-                       'InvalidParameterException:MissingOwner' => "File %s (%d) is missing an owner!",\r
-                       'IOException:CouldNotMake' => "Could not make %s",\r
-                       'IOException:MissingFileName' => "You must specify a name before opening a file.",\r
-                       'ClassNotFoundException:NotFoundNotSavedWithFile' => "Filestore not found or class not saved with file!",\r
-                       'NotificationException:NoNotificationMethod' => "No notification method specified.",\r
-                       'NotificationException:NoHandlerFound' => "No handler found for '%s' or it was not callable.",\r
-                       'NotificationException:ErrorNotifyingGuid' => "There was an error while notifying %d",\r
-                       'NotificationException:NoEmailAddress' => "Could not get the email address for GUID:%d",\r
-                       'NotificationException:MissingParameter' => "Missing a required parameter, '%s'",\r
-                       \r
-                       'DatabaseException:WhereSetNonQuery' => "Where set contains non WhereQueryComponent",\r
-                       'DatabaseException:SelectFieldsMissing' => "Fields missing on a select style query",\r
-                       'DatabaseException:UnspecifiedQueryType' => "Unrecognised or unspecified query type.",\r
-                       'DatabaseException:NoTablesSpecified' => "No tables specified for query.",\r
-                       'DatabaseException:NoACL' => "No access control was provided on query",\r
-                       \r
-                       'InvalidParameterException:NoEntityFound' => "No entity found, it either doesn't exist or you don't have access to it.",\r
-                       \r
-                       'InvalidParameterException:GUIDNotFound' => "GUID:%s could not be found, or you can not access it.",\r
-                       'InvalidParameterException:IdNotExistForGUID' => "Sorry, '%s' does not exist for guid:%d",\r
-                       'InvalidParameterException:CanNotExportType' => "Sorry, I don't know how to export '%s'",\r
-                       'InvalidParameterException:NoDataFound' => "Could not find any data.",\r
-                       'InvalidParameterException:DoesNotBelong' => "Does not belong to entity.",\r
-                       'InvalidParameterException:DoesNotBelongOrRefer' => "Does not belong to entity or refer to entity.",\r
-                       'InvalidParameterException:MissingParameter' => "Missing parameter, you need to provide a GUID.",\r
-                       \r
-                       'SecurityException:APIAccessDenied' => "Sorry, API access has been disabled by the administrator.",\r
-                       'SecurityException:NoAuthMethods' => "No authentication methods were found that could authenticate this API request.",\r
-                       'APIException:ApiResultUnknown' => "API Result is of an unknown type, this should never happen.", \r
-                       \r
-                       'ConfigurationException:NoSiteID' => "No site ID has been specified.",\r
-                       'InvalidParameterException:UnrecognisedMethod' => "Unrecognised call method '%s'",\r
-                       'APIException:MissingParameterInMethod' => "Missing parameter %s in method %s",\r
-                       'APIException:ParameterNotArray' => "%s does not appear to be an array.",\r
-                       'APIException:UnrecognisedTypeCast' => "Unrecognised type in cast %s for variable '%s' in method '%s'",\r
-                       'APIException:InvalidParameter' => "Invalid parameter found for '%s' in method '%s'.",\r
-                       'APIException:FunctionParseError' => "%s(%s) has a parsing error.",\r
-                       'APIException:FunctionNoReturn' => "%s(%s) returned no value.",\r
-                       'SecurityException:AuthTokenExpired' => "Authentication token either missing, invalid or expired.",\r
-                       'CallException:InvalidCallMethod' => "%s must be called using '%s'",\r
-                       'APIException:MethodCallNotImplemented' => "Method call '%s' has not been implemented.",\r
-                       'APIException:AlgorithmNotSupported' => "Algorithm '%s' is not supported or has been disabled.",\r
-                       'ConfigurationException:CacheDirNotSet' => "Cache directory 'cache_path' not set.",\r
-                       'APIException:NotGetOrPost' => "Request method must be GET or POST",\r
-                       'APIException:MissingAPIKey' => "Missing X-Elgg-apikey HTTP header",\r
-                       'APIException:MissingHmac' => "Missing X-Elgg-hmac header",\r
-                       'APIException:MissingHmacAlgo' => "Missing X-Elgg-hmac-algo header",\r
-                       'APIException:MissingTime' => "Missing X-Elgg-time header",\r
-                       'APIException:TemporalDrift' => "X-Elgg-time is too far in the past or future. Epoch fail.",\r
-                       'APIException:NoQueryString' => "No data on the query string",\r
-                       'APIException:MissingPOSTHash' => "Missing X-Elgg-posthash header",\r
-                       'APIException:MissingPOSTAlgo' => "Missing X-Elgg-posthash_algo header",\r
-                       'APIException:MissingContentType' => "Missing content type for post data",\r
-                       'SecurityException:InvalidPostHash' => "POST data hash is invalid - Expected %s but got %s.",\r
-                       'SecurityException:DupePacket' => "Packet signature already seen.",\r
-                       'SecurityException:InvalidAPIKey' => "Invalid or missing API Key.",\r
-                       'NotImplementedException:CallMethodNotImplemented' => "Call method '%s' is currently not supported.",\r
-       \r
-                       'NotImplementedException:XMLRPCMethodNotImplemented' => "XML-RPC method call '%s' not implemented.",\r
-                       'InvalidParameterException:UnexpectedReturnFormat' => "Call to method '%s' returned an unexpected result.",\r
-                       'CallException:NotRPCCall' => "Call does not appear to be a valid XML-RPC call",\r
-       \r
-                       'PluginException:NoPluginName' => "The plugin name could not be found",\r
-       \r
-                       'ConfigurationException:BadDatabaseVersion' => "The database backend you have installed doesn't meet the basic requirements to run Elgg. Please consult your documentation.",\r
-                       'ConfigurationException:BadPHPVersion' => "You need at least PHP version 5.2 to run Elgg.",\r
-                       'configurationwarning:phpversion' => "Elgg requires at least PHP version 5.2, you can install it on 5.1.6 but some features may not work. Use at your own risk.",\r
-       \r
-       \r
-                       'InstallationException:DatarootNotWritable' => "Your data directory %s is not writable.",\r
-                       'InstallationException:DatarootUnderPath' => "Your data directory %s must be outside of your install path.",\r
-                       'InstallationException:DatarootBlank' => "You have not specified a data directory.",\r
-       \r
-                       'SecurityException:authenticationfailed' => "User could not be authenticated",\r
-       \r
-                       'CronException:unknownperiod' => '%s is not a recognised period.',\r
-       \r
-                       'SecurityException:deletedisablecurrentsite' => 'You can not delete or disable the site you are currently viewing!',\r
-       \r
-                       'memcache:notinstalled' => 'PHP memcache module not installed, you must install php5-memcache',\r
-                       'memcache:noservers' => 'No memcache servers defined, please populate the $CONFIG->memcache_servers variable',\r
-                       'memcache:versiontoolow' => 'Memcache needs at least version %s to run, you are running %s',\r
-                       'memcache:noaddserver' => 'Multiple server support disabled, you may need to upgrade your PECL memcache library',\r
-       \r
-                       'deprecatedfunction' => 'Warning: This code uses the deprecated function \'%s\' and is not compatible with this version of Elgg',\r
-       \r
-                       'pageownerunavailable' => 'Warning: The page owner %d is not accessible!',\r
-               /**\r
-                * API\r
-                */\r
-                       'system.api.list' => "List all available API calls on the system.",\r
-                       'auth.gettoken' => "This API call lets a user log in, returning an authentication token which can be used in leu of a username and password for authenticating further calls.",\r
-       \r
-               /**\r
-                * User details\r
-                */\r
-\r
-                       'name' => "Display name",\r
-                       'email' => "Email address",\r
-                       'username' => "Username",\r
-                       'password' => "Password",\r
-                       'passwordagain' => "Password (again for verification)",\r
-                       'admin_option' => "Make this user an admin?",\r
-       \r
-               /**\r
-                * Access\r
-                */\r
-       \r
-                       'PRIVATE' => "Private",\r
-                       'LOGGED_IN' => "Logged in users",\r
-                       'PUBLIC' => "Public",\r
-                       'access:friends:label' => "Friends",\r
-                       'access' => "Access",\r
-       \r
-               /**\r
-                * Dashboard and widgets\r
-                */\r
-       \r
-                       'dashboard' => "Dashboard",\r
-            'dashboard:configure' => "Edit page",\r
-                       'dashboard:nowidgets' => "Your dashboard is your gateway into the site. Click 'Edit page' to add widgets to keep track of content and your life within the system.",\r
-\r
-                       'widgets:add' => 'Add widgets to your page',\r
-                       'widgets:add:description' => "Choose the features you want to add to your page by dragging them from the <b>Widget gallery</b> on the right, to any of the three widget areas below, and position them where you would like them to appear.\r
-\r
-To remove a widget drag it back to the <b>Widget gallery</b>.",\r
-                       'widgets:position:fixed' => '(Fixed position on page)',\r
-       \r
-                       'widgets' => "Widgets",\r
-                       'widget' => "Widget",\r
-                       'item:object:widget' => "Widgets",\r
-                       'layout:customise' => "Customise layout",\r
-                       'widgets:gallery' => "Widget gallery",\r
-                       'widgets:leftcolumn' => "Left widgets",\r
-                       'widgets:fixed' => "Fixed position",\r
-                       'widgets:middlecolumn' => "Middle widgets",\r
-                       'widgets:rightcolumn' => "Right widgets",\r
-                       'widgets:profilebox' => "Profile box",\r
-                       'widgets:panel:save:success' => "Your widgets were successfully saved.",\r
-                       'widgets:panel:save:failure' => "There was a problem saving your widgets. Please try again.",\r
-                       'widgets:save:success' => "The widget was successfully saved.",\r
-                       'widgets:save:failure' => "We could not save your widget. Please try again.",\r
-                       'widgets:handlernotfound' => 'This widget is either broken or has been disabled by the site administrator.',\r
-       \r
-               /**\r
-                * Groups\r
-                */\r
-       \r
-                       'group' => "Group", \r
-                       'item:group' => "Groups",\r
-       \r
-               /**\r
-                * Profile\r
-                */\r
-       \r
-                       'profile' => "Profile",\r
+<?php
+
+       $english = array(
+
+               /**
+                * Sites
+                */
+       
+                       'item:site' => 'Sites',
+       
+               /**
+                * Sessions
+                */
+                       
+                       'login' => "Log in",
+                       'loginok' => "You have been logged in.",
+                       'loginerror' => "We couldn't log you in. This may be because you haven't validated your account yet, the details you supplied were incorrect, or you have made too many incorrect login attempts. Make sure your details are correct and please try again.",
+       
+                       'logout' => "Log out",
+                       'logoutok' => "You have been logged out.",
+                       'logouterror' => "We couldn't log you out. Please try again.",
+       
+               /**
+                * Errors
+                */
+                       'exception:title' => "Welcome to Elgg.",
+       
+                       'InstallationException:CantCreateSite' => "Unable to create a default ElggSite with credentials Name:%s, Url: %s",
+               
+                       'actionundefined' => "The requested action (%s) was not defined in the system.",
+                       'actionloggedout' => "Sorry, you cannot perform this action while logged out.",
+       
+                       'notfound' => "The requested resource could not be found, or you do not have access to it.",
+                       
+                       'SecurityException:Codeblock' => "Denied access to execute privileged code block",
+                       'DatabaseException:WrongCredentials' => "Elgg couldn't connect to the database using the given credentials.",
+                       'DatabaseException:NoConnect' => "Elgg couldn't select the database '%s', please check that the database is created and you have access to it.",
+                       'SecurityException:FunctionDenied' => "Access to privileged function '%s' is denied.",
+                       'DatabaseException:DBSetupIssues' => "There were a number of issues: ",
+                       'DatabaseException:ScriptNotFound' => "Elgg couldn't find the requested database script at %s.",
+                       
+                       'IOException:FailedToLoadGUID' => "Failed to load new %s from GUID:%d",
+                       'InvalidParameterException:NonElggObject' => "Passing a non-ElggObject to an ElggObject constructor!",
+                       'InvalidParameterException:UnrecognisedValue' => "Unrecognised value passed to constuctor.",
+                       
+                       'InvalidClassException:NotValidElggStar' => "GUID:%d is not a valid %s",
+                       
+                       'PluginException:MisconfiguredPlugin' => "%s is a misconfigured plugin.",
+                       
+                       'InvalidParameterException:NonElggUser' => "Passing a non-ElggUser to an ElggUser constructor!",
+                       
+                       'InvalidParameterException:NonElggSite' => "Passing a non-ElggSite to an ElggSite constructor!",
+                       
+                       'InvalidParameterException:NonElggGroup' => "Passing a non-ElggGroup to an ElggGroup constructor!",
+       
+                       'IOException:UnableToSaveNew' => "Unable to save new %s",
+                       
+                       'InvalidParameterException:GUIDNotForExport' => "GUID has not been specified during export, this should never happen.",
+                       'InvalidParameterException:NonArrayReturnValue' => "Entity serialisation function passed a non-array returnvalue parameter",
+                       
+                       'ConfigurationException:NoCachePath' => "Cache path set to nothing!",
+                       'IOException:NotDirectory' => "%s is not a directory.",
+                       
+                       'IOException:BaseEntitySaveFailed' => "Unable to save new object's base entity information!",
+                       'InvalidParameterException:UnexpectedODDClass' => "import() passed an unexpected ODD class",
+                       'InvalidParameterException:EntityTypeNotSet' => "Entity type must be set.",
+                       
+                       'ClassException:ClassnameNotClass' => "%s is not a %s.",
+                       'ClassNotFoundException:MissingClass' => "Class '%s' was not found, missing plugin?",
+                       'InstallationException:TypeNotSupported' => "Type %s is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade.",
+
+                       'ImportException:ImportFailed' => "Could not import element %d",
+                       'ImportException:ProblemSaving' => "There was a problem saving %s",
+                       'ImportException:NoGUID' => "New entity created but has no GUID, this should not happen.",
+                       
+                       'ImportException:GUIDNotFound' => "Entity '%d' could not be found.",
+                       'ImportException:ProblemUpdatingMeta' => "There was a problem updating '%s' on entity '%d'",
+                       
+                       'ExportException:NoSuchEntity' => "No such entity GUID:%d", 
+                       
+                       'ImportException:NoODDElements' => "No OpenDD elements found in import data, import failed.",
+                       'ImportException:NotAllImported' => "Not all elements were imported.",
+                       
+                       'InvalidParameterException:UnrecognisedFileMode' => "Unrecognised file mode '%s'",
+                       'InvalidParameterException:MissingOwner' => "File %s (%d) is missing an owner!",
+                       'IOException:CouldNotMake' => "Could not make %s",
+                       'IOException:MissingFileName' => "You must specify a name before opening a file.",
+                       'ClassNotFoundException:NotFoundNotSavedWithFile' => "Filestore not found or class not saved with file!",
+                       'NotificationException:NoNotificationMethod' => "No notification method specified.",
+                       'NotificationException:NoHandlerFound' => "No handler found for '%s' or it was not callable.",
+                       'NotificationException:ErrorNotifyingGuid' => "There was an error while notifying %d",
+                       'NotificationException:NoEmailAddress' => "Could not get the email address for GUID:%d",
+                       'NotificationException:MissingParameter' => "Missing a required parameter, '%s'",
+                       
+                       'DatabaseException:WhereSetNonQuery' => "Where set contains non WhereQueryComponent",
+                       'DatabaseException:SelectFieldsMissing' => "Fields missing on a select style query",
+                       'DatabaseException:UnspecifiedQueryType' => "Unrecognised or unspecified query type.",
+                       'DatabaseException:NoTablesSpecified' => "No tables specified for query.",
+                       'DatabaseException:NoACL' => "No access control was provided on query",
+                       
+                       'InvalidParameterException:NoEntityFound' => "No entity found, it either doesn't exist or you don't have access to it.",
+                       
+                       'InvalidParameterException:GUIDNotFound' => "GUID:%s could not be found, or you can not access it.",
+                       'InvalidParameterException:IdNotExistForGUID' => "Sorry, '%s' does not exist for guid:%d",
+                       'InvalidParameterException:CanNotExportType' => "Sorry, I don't know how to export '%s'",
+                       'InvalidParameterException:NoDataFound' => "Could not find any data.",
+                       'InvalidParameterException:DoesNotBelong' => "Does not belong to entity.",
+                       'InvalidParameterException:DoesNotBelongOrRefer' => "Does not belong to entity or refer to entity.",
+                       'InvalidParameterException:MissingParameter' => "Missing parameter, you need to provide a GUID.",
+                       
+                       'SecurityException:APIAccessDenied' => "Sorry, API access has been disabled by the administrator.",
+                       'SecurityException:NoAuthMethods' => "No authentication methods were found that could authenticate this API request.",
+                       'APIException:ApiResultUnknown' => "API Result is of an unknown type, this should never happen.", 
+                       
+                       'ConfigurationException:NoSiteID' => "No site ID has been specified.",
+                       'InvalidParameterException:UnrecognisedMethod' => "Unrecognised call method '%s'",
+                       'APIException:MissingParameterInMethod' => "Missing parameter %s in method %s",
+                       'APIException:ParameterNotArray' => "%s does not appear to be an array.",
+                       'APIException:UnrecognisedTypeCast' => "Unrecognised type in cast %s for variable '%s' in method '%s'",
+                       'APIException:InvalidParameter' => "Invalid parameter found for '%s' in method '%s'.",
+                       'APIException:FunctionParseError' => "%s(%s) has a parsing error.",
+                       'APIException:FunctionNoReturn' => "%s(%s) returned no value.",
+                       'SecurityException:AuthTokenExpired' => "Authentication token either missing, invalid or expired.",
+                       'CallException:InvalidCallMethod' => "%s must be called using '%s'",
+                       'APIException:MethodCallNotImplemented' => "Method call '%s' has not been implemented.",
+                       'APIException:AlgorithmNotSupported' => "Algorithm '%s' is not supported or has been disabled.",
+                       'ConfigurationException:CacheDirNotSet' => "Cache directory 'cache_path' not set.",
+                       'APIException:NotGetOrPost' => "Request method must be GET or POST",
+                       'APIException:MissingAPIKey' => "Missing X-Elgg-apikey HTTP header",
+                       'APIException:MissingHmac' => "Missing X-Elgg-hmac header",
+                       'APIException:MissingHmacAlgo' => "Missing X-Elgg-hmac-algo header",
+                       'APIException:MissingTime' => "Missing X-Elgg-time header",
+                       'APIException:TemporalDrift' => "X-Elgg-time is too far in the past or future. Epoch fail.",
+                       'APIException:NoQueryString' => "No data on the query string",
+                       'APIException:MissingPOSTHash' => "Missing X-Elgg-posthash header",
+                       'APIException:MissingPOSTAlgo' => "Missing X-Elgg-posthash_algo header",
+                       'APIException:MissingContentType' => "Missing content type for post data",
+                       'SecurityException:InvalidPostHash' => "POST data hash is invalid - Expected %s but got %s.",
+                       'SecurityException:DupePacket' => "Packet signature already seen.",
+                       'SecurityException:InvalidAPIKey' => "Invalid or missing API Key.",
+                       'NotImplementedException:CallMethodNotImplemented' => "Call method '%s' is currently not supported.",
+       
+                       'NotImplementedException:XMLRPCMethodNotImplemented' => "XML-RPC method call '%s' not implemented.",
+                       'InvalidParameterException:UnexpectedReturnFormat' => "Call to method '%s' returned an unexpected result.",
+                       'CallException:NotRPCCall' => "Call does not appear to be a valid XML-RPC call",
+       
+                       'PluginException:NoPluginName' => "The plugin name could not be found",
+       
+                       'ConfigurationException:BadDatabaseVersion' => "The database backend you have installed doesn't meet the basic requirements to run Elgg. Please consult your documentation.",
+                       'ConfigurationException:BadPHPVersion' => "You need at least PHP version 5.2 to run Elgg.",
+                       'configurationwarning:phpversion' => "Elgg requires at least PHP version 5.2, you can install it on 5.1.6 but some features may not work. Use at your own risk.",
+       
+       
+                       'InstallationException:DatarootNotWritable' => "Your data directory %s is not writable.",
+                       'InstallationException:DatarootUnderPath' => "Your data directory %s must be outside of your install path.",
+                       'InstallationException:DatarootBlank' => "You have not specified a data directory.",
+       
+                       'SecurityException:authenticationfailed' => "User could not be authenticated",
+       
+                       'CronException:unknownperiod' => '%s is not a recognised period.',
+       
+                       'SecurityException:deletedisablecurrentsite' => 'You can not delete or disable the site you are currently viewing!',
+       
+                       'memcache:notinstalled' => 'PHP memcache module not installed, you must install php5-memcache',
+                       'memcache:noservers' => 'No memcache servers defined, please populate the $CONFIG->memcache_servers variable',
+                       'memcache:versiontoolow' => 'Memcache needs at least version %s to run, you are running %s',
+                       'memcache:noaddserver' => 'Multiple server support disabled, you may need to upgrade your PECL memcache library',
+       
+                       'deprecatedfunction' => 'Warning: This code uses the deprecated function \'%s\' and is not compatible with this version of Elgg',
+       
+                       'pageownerunavailable' => 'Warning: The page owner %d is not accessible!',
+               /**
+                * API
+                */
+                       'system.api.list' => "List all available API calls on the system.",
+                       'auth.gettoken' => "This API call lets a user log in, returning an authentication token which can be used in leu of a username and password for authenticating further calls.",
+       
+               /**
+                * User details
+                */
+
+                       'name' => "Display name",
+                       'email' => "Email address",
+                       'username' => "Username",
+                       'password' => "Password",
+                       'passwordagain' => "Password (again for verification)",
+                       'admin_option' => "Make this user an admin?",
+       
+               /**
+                * Access
+                */
+       
+                       'PRIVATE' => "Private",
+                       'LOGGED_IN' => "Logged in users",
+                       'PUBLIC' => "Public",
+                       'access:friends:label' => "Friends",
+                       'access' => "Access",
+       
+               /**
+                * Dashboard and widgets
+                */
+       
+                       'dashboard' => "Dashboard",
+            'dashboard:configure' => "Edit page",
+                       'dashboard:nowidgets' => "Your dashboard is your gateway into the site. Click 'Edit page' to add widgets to keep track of content and your life within the system.",
+
+                       'widgets:add' => 'Add widgets to your page',
+                       'widgets:add:description' => "Choose the features you want to add to your page by dragging them from the <b>Widget gallery</b> on the right, to any of the three widget areas below, and position them where you would like them to appear.
+
+To remove a widget drag it back to the <b>Widget gallery</b>.",
+                       'widgets:position:fixed' => '(Fixed position on page)',
+       
+                       'widgets' => "Widgets",
+                       'widget' => "Widget",
+                       'item:object:widget' => "Widgets",
+                       'layout:customise' => "Customise layout",
+                       'widgets:gallery' => "Widget gallery",
+                       'widgets:leftcolumn' => "Left widgets",
+                       'widgets:fixed' => "Fixed position",
+                       'widgets:middlecolumn' => "Middle widgets",
+                       'widgets:rightcolumn' => "Right widgets",
+                       'widgets:profilebox' => "Profile box",
+                       'widgets:panel:save:success' => "Your widgets were successfully saved.",
+                       'widgets:panel:save:failure' => "There was a problem saving your widgets. Please try again.",
+                       'widgets:save:success' => "The widget was successfully saved.",
+                       'widgets:save:failure' => "We could not save your widget. Please try again.",
+                       'widgets:handlernotfound' => 'This widget is either broken or has been disabled by the site administrator.',
+       
+               /**
+                * Groups
+                */
+       
+                       'group' => "Group", 
+                       'item:group' => "Groups",
+       
+               /**
+                * Profile
+                */
+       
+                       'profile' => "Profile",
                        'profile:edit:default' => 'Replace profile fields',
-                       'profile:preview' => 'Preview',\r
-                       'user' => "User",\r
-                       'item:user' => "Users",\r
-                       'riveritem:single:user' => 'a user',\r
+                       'profile:preview' => 'Preview',
+                       'user' => "User",
+                       'item:user' => "Users",
+                       'riveritem:single:user' => 'a user',
                        'riveritem:plural:user' => 'some users',
-       \r
-       \r
-\r
-               /**\r
-                * Profile menu items and titles\r
-                */\r
-       \r
-                       'profile:yours' => "Your profile",\r
-                       'profile:user' => "%s's profile",\r
-       \r
-                       'profile:edit' => "Edit profile",\r
-                       'profile:profilepictureinstructions' => "The profile picture is the image that's displayed on your profile page. <br /> You can change it as often as you'd like. (File formats accepted: GIF, JPG or PNG)",\r
-                       'profile:icon' => "Profile picture",\r
-                       'profile:createicon' => "Create your avatar",\r
-                       'profile:currentavatar' => "Current avatar",\r
-                       'profile:createicon:header' => "Profile picture",\r
-                       'profile:profilepicturecroppingtool' => "Profile picture cropping tool",\r
-                       'profile:createicon:instructions' => "Click and drag a square below to match how you want your picture cropped.  A preview of your cropped picture will appear in the box on the right.  When you are happy with the preview, click 'Create your avatar'. This cropped image will be used throughout the site as your avatar. ",\r
-       \r
-                       'profile:editdetails' => "Edit details",\r
-                       'profile:editicon' => "Edit profile icon",\r
-       \r
-                       'profile:aboutme' => "About me", \r
-                       'profile:description' => "About me",\r
-                       'profile:briefdescription' => "Brief description",\r
-                       'profile:location' => "Location",\r
-                       'profile:skills' => "Skills",  \r
-                       'profile:interests' => "Interests", \r
-                       'profile:contactemail' => "Contact email",\r
-                       'profile:phone' => "Telephone",\r
-                       'profile:mobile' => "Mobile phone",\r
-                       'profile:website' => "Website",\r
-       \r
-                       'profile:banned' => 'This user account has been suspended.',\r
-                       'profile:deleteduser' => 'Deleted user',\r
-\r
-                       'profile:river:update' => "%s updated their profile",\r
-                       'profile:river:iconupdate' => "%s updated their profile icon",\r
-       \r
-                       'profile:label' => "Profile label",\r
-                       'profile:type' => "Profile type",\r
-       \r
-                       'profile:editdefault:fail' => 'Default profile could not be saved',\r
-                       'profile:editdefault:success' => 'Item successfully added to default profile',\r
-       \r
-                       \r
-                       'profile:editdefault:delete:fail' => 'Removed default profile item field failed',\r
-                       'profile:editdefault:delete:success' => 'Default profile item deleted!',\r
-       \r
-                       'profile:defaultprofile:reset' => 'Default system profile reset',\r
-       \r
-                       'profile:resetdefault' => 'Reset default profile',\r
-                       'profile:explainchangefields' => 'You can replace the existing profile fields with your own using the form below. First you give the new profile field a label, for example, \'Favourite team\'. Next you need to select the field type, for example, tags, url, text and so on. At any time you can revert back to the default profile set up.',\r
-       \r
-\r
-       \r
-               /**\r
-                * Profile status messages\r
-                */\r
-       \r
-                       'profile:saved' => "Your profile was successfully saved.",\r
-                       'profile:icon:uploaded' => "Your profile picture was successfully uploaded.",\r
-       \r
-               /**\r
-                * Profile error messages\r
-                */\r
-       \r
-                       'profile:noaccess' => "You do not have permission to edit this profile.",\r
-                       'profile:notfound' => "Sorry; we could not find the specified profile.",\r
-                       'profile:cantedit' => "Sorry; you do not have permission to edit this profile.",\r
-                       'profile:icon:notfound' => "Sorry; there was a problem uploading your profile picture.",\r
-       \r
-               /**\r
-                * Friends\r
-                */\r
-       \r
-                       'friends' => "Friends",\r
-                       'friends:yours' => "Your friends",\r
-                       'friends:owned' => "%s's friends",\r
-                       'friend:add' => "Add friend",\r
-                       'friend:remove' => "Remove friend",\r
-       \r
-                       'friends:add:successful' => "You have successfully added %s as a friend.",\r
-                       'friends:add:failure' => "We couldn't add %s as a friend. Please try again.",\r
-       \r
-                       'friends:remove:successful' => "You have successfully removed %s from your friends.",\r
-                       'friends:remove:failure' => "We couldn't remove %s from your friends. Please try again.",\r
-       \r
-                       'friends:none' => "This user hasn't added anyone as a friend yet.",\r
-                       'friends:none:you' => "You haven't added anyone as a friend! Search for your interests to begin finding people to follow.",\r
-       \r
-                       'friends:none:found' => "No friends were found.",\r
-       \r
-                       'friends:of:none' => "Nobody has added this user as a friend yet.",\r
-                       'friends:of:none:you' => "Nobody has added you as a friend yet. Start adding content and fill in your profile to let people find you!",\r
-       \r
-                       'friends:of:owned' => "People who have made %s a friend",\r
-\r
-                        'friends:num_display' => "Number of friends to display",\r
-                        'friends:icon_size' => "Icon size",\r
-                        'friends:tiny' => "tiny",\r
-                        'friends:small' => "small",\r
-                        'friends:of' => "Friends of",\r
-                        'friends:collections' => "Collections of friends",\r
-                        'friends:collections:add' => "New friends collection",\r
-                        'friends:addfriends' => "Add friends",\r
-                        'friends:collectionname' => "Collection name",\r
-                        'friends:collectionfriends' => "Friends in collection",\r
-                        'friends:collectionedit' => "Edit this collection",\r
-                        'friends:nocollections' => "You do not yet have any collections.",\r
-                        'friends:collectiondeleted' => "Your collection has been deleted.",\r
-                        'friends:collectiondeletefailed' => "We were unable to delete the collection. Either you don't have permission, or some other problem has occurred.",\r
-                        'friends:collectionadded' => "Your collection was successfuly created",\r
-                        'friends:nocollectionname' => "You need to give your collection a name before it can be created.",\r
-                       'friends:collections:members' => "Collection members",\r
-                       'friends:collections:edit' => "Edit collection",\r
-               \r
-               'friends:river:created' => "%s added the friends widget.",\r
-               'friends:river:updated' => "%s updated their friends widget.",\r
-               'friends:river:delete' => "%s removed their friends widget.",\r
-               'friends:river:add' => "%s is now a friend with",\r
-       \r
-                       'friendspicker:chararray' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',\r
-       \r
-               /**\r
-                * Feeds\r
-                */\r
-                       'feed:rss' => 'Subscribe to feed',\r
-                       'feed:odd' => 'Syndicate OpenDD',\r
-                       \r
-               /**\r
-          * links\r
-                **/\r
-\r
-                       'link:view' => 'view link',\r
-\r
-       \r
-               /**\r
-                * River\r
-                */\r
-                       'river' => "River",                     \r
-                       'river:relationship:friend' => 'is now friends with',\r
-                       'river:noaccess' => 'You do not have permission to view this item.',\r
-                       'river:posted:generic' => '%s posted',\r
-\r
-               /**\r
-                * Plugins\r
-                */\r
-                       'plugins:settings:save:ok' => "Settings for the %s plugin were saved successfully.",\r
-                       'plugins:settings:save:fail' => "There was a problem saving settings for the %s plugin.",\r
-                       'plugins:usersettings:save:ok' => "User settings for the %s plugin were saved successfully.",\r
-                       'plugins:usersettings:save:fail' => "There was a problem saving  user settings for the %s plugin.",\r
-                       'admin:plugins:label:version' => "Version",\r
-                       'item:object:plugin' => 'Plugin configuration settings',\r
-                       \r
-               /**\r
-                * Notifications\r
-                */\r
-                       'notifications:usersettings' => "Notification settings",\r
-                       'notifications:methods' => "Please specify which methods you want to permit.",\r
-       \r
-                       'notifications:usersettings:save:ok' => "Your notification settings were successfully saved.",\r
-                       'notifications:usersettings:save:fail' => "There was a problem saving your notification settings.",\r
-       \r
-                       'user.notification.get' => 'Return the notification settings for a given user.',\r
-                       'user.notification.set' => 'Set the notification settings for a given user.',\r
-               /**\r
-                * Search\r
-                */\r
-       \r
-                       'search' => "Search",\r
-                       'searchtitle' => "Search: %s",\r
-                       'users:searchtitle' => "Searching for users: %s",\r
-                       'groups:searchtitle' => "Searching for groups: %s",\r
-                       'advancedsearchtitle' => "%s with results matching %s",\r
-                       'notfound' => "No results found.",\r
-                       'next' => "Next",\r
-                       'previous' => "Previous",\r
-       \r
-                       'viewtype:change' => "Change listing type",\r
-                       'viewtype:list' => "List view",\r
-                       'viewtype:gallery' => "Gallery",\r
-       \r
-                       'tag:search:startblurb' => "Items with tags matching '%s':",\r
-\r
-                       'user:search:startblurb' => "Users matching '%s':",\r
-                       'user:search:finishblurb' => "To view more, click here.",\r
-       \r
-                       'group:search:startblurb' => "Groups matching '%s':",\r
-                       'group:search:finishblurb' => "To view more, click here.",\r
-                       'search:go' => 'Go',\r
-       \r
-               /**\r
-                * Account\r
-                */\r
-       \r
-                       'account' => "Account",\r
-                       'settings' => "Settings",\r
-            'tools' => "Tools",\r
-            'tools:yours' => "Your tools",\r
-       \r
-                       'register' => "Register",\r
-                       'registerok' => "You have successfully registered for %s.",\r
-                       'registerbad' => "Your registration was unsuccessful. The username may already exist, your passwords might not match, or your username or password may be too short.",\r
-                       'registerdisabled' => "Registration has been disabled by the system administrator",\r
-       \r
-                       'firstadminlogininstructions' => 'Your new Elgg site has been successfully installed and your administrator account created. You can now configure your site further by enabling various installed plugin tools.',\r
-       \r
-                       'registration:notemail' => 'The email address you provided does not appear to be a valid email address.',\r
-                       'registration:userexists' => 'That username already exists',\r
-                       'registration:usernametooshort' => 'Your username must be a minimum of 4 characters long.',\r
-                       'registration:passwordtooshort' => 'The password must be a minimum of 6 characters long.',\r
-                       'registration:dupeemail' => 'This email address has already been registered.',\r
-                       'registration:invalidchars' => 'Sorry, your username contains invalid characters.',\r
-                       'registration:emailnotvalid' => 'Sorry, the email address you entered is invalid on this system',\r
-                       'registration:passwordnotvalid' => 'Sorry, the password you entered is invalid on this system',\r
-                       'registration:usernamenotvalid' => 'Sorry, the username you entered is invalid on this system',\r
-       \r
-                       'adduser' => "Add User",\r
-                       'adduser:ok' => "You have successfully added a new user.",\r
-                       'adduser:bad' => "The new user could not be created.",\r
-                       \r
-                       'item:object:reported_content' => "Reported items",\r
-       \r
-                       'user:set:name' => "Account name settings",\r
-                       'user:name:label' => "Your name",\r
-                       'user:name:success' => "Successfully changed your name on the system.",\r
-                       'user:name:fail' => "Could not change your name on the system.",\r
-       \r
-                       'user:set:password' => "Account password",\r
-                       'user:password:label' => "Your new password",\r
-                       'user:password2:label' => "Your new password again",\r
-                       'user:password:success' => "Password changed",\r
-                       'user:password:fail' => "Could not change your password on the system.",\r
-                       'user:password:fail:notsame' => "The two passwords are not the same!",\r
-                       'user:password:fail:tooshort' => "Password is too short!",\r
-       \r
-                       'user:set:language' => "Language settings",\r
-                       'user:language:label' => "Your language",\r
-                       'user:language:success' => "Your language settings have been updated.",\r
-                       'user:language:fail' => "Your language settings could not be saved.",\r
-       \r
-                       'user:username:notfound' => 'Username %s not found.',\r
-       \r
-                       'user:password:lost' => 'Lost password',\r
-                       'user:password:resetreq:success' => 'Successfully requested a new password, email sent',\r
-                       'user:password:resetreq:fail' => 'Could not request a new password.',\r
-       \r
-                       'user:password:text' => 'To generate a new password, enter your username below. We will send the address of a unique verification page to you via email click on the link in the body of the message and a new password will be sent to you.',\r
-       \r
-                       'user:persistent' => 'Remember me',\r
-               /**\r
-                * Administration\r
-                */\r
-\r
-                       'admin:configuration:success' => "Your settings have been saved.",\r
-                       'admin:configuration:fail' => "Your settings could not be saved.",\r
-       \r
-                       'admin' => "Administration",\r
-                       'admin:description' => "The admin panel allows you to control all aspects of the system, from user management to how plugins behave. Choose an option below to get started.",\r
-                       \r
-                       'admin:user' => "User Administration",\r
-                       'admin:user:description' => "This admin panel allows you to control user settings for your site. Choose an option below to get started.",\r
-                       'admin:user:adduser:label' => "Click here to add a new user...",\r
-                       'admin:user:opt:linktext' => "Configure users...",\r
-                       'admin:user:opt:description' => "Configure users and account information. ",\r
-                       \r
-                       'admin:site' => "Site Administration",\r
-                       'admin:site:description' => "This admin panel allows you to control global settings for your site. Choose an option below to get started.",\r
-                       'admin:site:opt:linktext' => "Configure site...",\r
-                       'admin:site:opt:description' => "Configure the site technical and non-technical settings. ",\r
-                       'admin:site:access:warning' => "Changing the access setting only affects the permissions on content created in the future.", \r
-                       \r
-                       'admin:plugins' => "Tool Administration",\r
-                       'admin:plugins:description' => "This admin panel allows you to control and configure tools installed on your site.",\r
-                       'admin:plugins:opt:linktext' => "Configure tools...",\r
-                       'admin:plugins:opt:description' => "Configure the tools installed on the site. ",\r
-                       'admin:plugins:label:author' => "Author",\r
-                       'admin:plugins:label:copyright' => "Copyright",\r
-                       'admin:plugins:label:licence' => "Licence",\r
-                       'admin:plugins:label:website' => "URL",\r
-                       'admin:plugins:label:moreinfo' => 'more info',\r
-                       'admin:plugins:label:version' => 'Version',\r
-                       'admin:plugins:warning:elggversionunknown' => 'Warning: This plugin does not specify a compatible Elgg version.',\r
-                       'admin:plugins:warning:elggtoolow' => 'Warning: This plugin requires a later version of Elgg!',\r
-                       'admin:plugins:reorder:yes' => "Plugin %s was reordered successfully.",\r
-                       'admin:plugins:reorder:no' => "Plugin %s could not be reordered.",\r
-                       'admin:plugins:disable:yes' => "Plugin %s was disabled successfully.",\r
-                       'admin:plugins:disable:no' => "Plugin %s could not be disabled.",\r
-                       'admin:plugins:enable:yes' => "Plugin %s was enabled successfully.",\r
-                       'admin:plugins:enable:no' => "Plugin %s could not be enabled.",\r
-       \r
-                       'admin:statistics' => "Statistics",\r
-                       'admin:statistics:description' => "This is an overview of statistics on your site. If you need more detailed statistics, a professional administration feature is available.",\r
-                       'admin:statistics:opt:description' => "View statistical information about users and objects on your site.",\r
-                       'admin:statistics:opt:linktext' => "View statistics...",\r
-                       'admin:statistics:label:basic' => "Basic site statistics",\r
-                       'admin:statistics:label:numentities' => "Entities on site",\r
-                       'admin:statistics:label:numusers' => "Number of users",\r
-                       'admin:statistics:label:numonline' => "Number of users online",\r
-                       'admin:statistics:label:onlineusers' => "Users online now",\r
-                       'admin:statistics:label:version' => "Elgg version",\r
-                       'admin:statistics:label:version:release' => "Release",\r
-                       'admin:statistics:label:version:version' => "Version",\r
-       \r
-                       'admin:user:label:search' => "Find users:",\r
-                       'admin:user:label:seachbutton' => "Search", \r
-       \r
-                       'admin:user:ban:no' => "Can not ban user",\r
-                       'admin:user:ban:yes' => "User banned.",\r
-                       'admin:user:unban:no' => "Can not unban user",\r
-                       'admin:user:unban:yes' => "User un-banned.",\r
-                       'admin:user:delete:no' => "Can not delete user",\r
-                       'admin:user:delete:yes' => "User deleted",\r
-       \r
-                       'admin:user:resetpassword:yes' => "Password reset, user notified.",\r
-                       'admin:user:resetpassword:no' => "Password could not be reset.",\r
-       \r
-                       'admin:user:makeadmin:yes' => "User is now an admin.",\r
-                       'admin:user:makeadmin:no' => "We could not make this user an admin.",\r
-       \r
-                       'admin:user:removeadmin:yes' => "User is no longer an admin.",\r
-                       'admin:user:removeadmin:no' => "We could not remove administrator privileges from this user.",\r
-                       \r
-               /**\r
-                * User settings\r
-                */\r
-                       'usersettings:description' => "The user settings panel allows you to control all your personal settings, from user management to how plugins behave. Choose an option below to get started.",\r
-       \r
-                       'usersettings:statistics' => "Your statistics",\r
-                       'usersettings:statistics:opt:description' => "View statistical information about users and objects on your site.",\r
-                       'usersettings:statistics:opt:linktext' => "Account statistics",\r
-       \r
-                       'usersettings:user' => "Your settings",\r
-                       'usersettings:user:opt:description' => "This allows you to control user settings.",\r
-                       'usersettings:user:opt:linktext' => "Change your settings",\r
-       \r
-                       'usersettings:plugins' => "Tools",\r
-                       'usersettings:plugins:opt:description' => "Configure settings (if any) for your active tools.",\r
-                       'usersettings:plugins:opt:linktext' => "Configure your tools",\r
-       \r
-                       'usersettings:plugins:description' => "This panel allows you to control and configure the personal settings for the tools installed by your system administrator.",\r
-                       'usersettings:statistics:label:numentities' => "Your entities",\r
-       \r
-                       'usersettings:statistics:yourdetails' => "Your details",\r
-                       'usersettings:statistics:label:name' => "Full name",\r
-                       'usersettings:statistics:label:email' => "Email",\r
-                       'usersettings:statistics:label:membersince' => "Member since",\r
-                       'usersettings:statistics:label:lastlogin' => "Last logged in",\r
-       \r
-                       \r
-       \r
-               /**\r
-                * Generic action words\r
-                */\r
-       \r
-                       'save' => "Save",\r
-                       'publish' => "Publish",\r
-                       'cancel' => "Cancel",\r
-                       'saving' => "Saving ...",\r
-                       'update' => "Update",\r
-                       'edit' => "Edit",\r
-                       'delete' => "Delete",\r
-                       'accept' => "Accept",\r
-                       'load' => "Load",\r
-                       'upload' => "Upload",\r
-                       'ban' => "Ban",\r
-                       'unban' => "Unban",\r
-                       'enable' => "Enable",\r
-                       'disable' => "Disable",\r
-                       'request' => "Request",\r
-                       'complete' => "Complete",\r
-                       'open' => 'Open',\r
-                       'close' => 'Close',\r
-                       'reply' => "Reply",\r
-                       'more' => 'More',\r
-                       'comments' => 'Comments',\r
-                       'import' => 'Import',\r
-                       'export' => 'Export',\r
-       \r
-                       'up' => 'Up',\r
-                       'down' => 'Down',\r
-                       'top' => 'Top',\r
-                       'bottom' => 'Bottom',\r
-       \r
-                       'invite' => "Invite",\r
-       \r
-                       'resetpassword' => "Reset password",\r
-                       'makeadmin' => "Make admin",\r
-                       'removeadmin' => "Remove admin",\r
-       \r
-                       'option:yes' => "Yes",\r
-                       'option:no' => "No",\r
-       \r
-                       'unknown' => 'Unknown',\r
-       \r
-                       'active' => 'Active',\r
-                       'total' => 'Total',\r
-       \r
-                       'learnmore' => "Click here to learn more.",\r
-       \r
-                       'content' => "content",\r
-                       'content:latest' => 'Latest activity',\r
-                       'content:latest:blurb' => 'Alternatively, click here to view the latest content from across the site.',\r
-       \r
-                       'link:text' => 'view link',\r
-       \r
-                       'enableall' => 'Enable All',\r
-                       'disableall' => 'Disable All',\r
-       \r
-               /**\r
-                * Generic questions\r
-                */\r
-       \r
-                       'question:areyousure' => 'Are you sure?',\r
-       \r
-               /**\r
-                * Generic data words\r
-                */\r
-       \r
-                       'title' => "Title",\r
-                       'description' => "Description",\r
-                       'tags' => "Tags",\r
-                       'spotlight' => "Spotlight",\r
-                       'all' => "All",\r
-       \r
-                       'by' => 'by',\r
-       \r
-                       'annotations' => "Annotations",\r
-                       'relationships' => "Relationships",\r
-                       'metadata' => "Metadata",\r
-       \r
-               /**\r
-                * Input / output strings\r
-                */\r
-\r
-                       'deleteconfirm' => "Are you sure you want to delete this item?",\r
-                       'fileexists' => "A file has already been uploaded. To replace it, select it below:",\r
-                       \r
-               /**\r
-                * User add\r
-                */\r
-\r
-                       'useradd:subject' => 'User account created',\r
-                       'useradd:body' => '\r
-%s,\r
-\r
-A user account has been created for you at %s. To log in, visit:\r
-\r
-       %s\r
-\r
-And log in with these user credentials:\r
-\r
-       Username: %s\r
-       Password: %s\r
-       \r
-Once you have logged in, we highly recommend that you change your password.\r
-',\r
-                       \r
-           /**\r
-         * System messages\r
-         **/\r
-\r
-                       'systemmessages:dismiss' => "click to dismiss",\r
-\r
-       \r
-               /**\r
-                * Import / export\r
-                */\r
-                       'importsuccess' => "Import of data was successful",\r
-                       'importfail' => "OpenDD import of data failed.",\r
-       \r
-               /**\r
-                * Time\r
-                */\r
-       \r
-                       'friendlytime:justnow' => "just now",\r
-                       'friendlytime:minutes' => "%s minutes ago",\r
-                       'friendlytime:minutes:singular' => "a minute ago",\r
-                       'friendlytime:hours' => "%s hours ago",\r
-                       'friendlytime:hours:singular' => "an hour ago",\r
-                       'friendlytime:days' => "%s days ago",\r
-                       'friendlytime:days:singular' => "yesterday",\r
-       \r
-                       'date:month:01' => 'January %s',\r
-                       'date:month:02' => 'February %s',\r
-                       'date:month:03' => 'March %s',\r
-                       'date:month:04' => 'April %s',\r
-                       'date:month:05' => 'May %s',\r
-                       'date:month:06' => 'June %s',\r
-                       'date:month:07' => 'July %s',\r
-                       'date:month:08' => 'August %s',\r
-                       'date:month:09' => 'September %s',\r
-                       'date:month:10' => 'October %s',\r
-                       'date:month:11' => 'November %s',\r
-                       'date:month:12' => 'December %s',\r
-       \r
-       \r
-               /**\r
-                * Installation and system settings\r
-                */\r
-       \r
-                       'installation:error:htaccess' => "Elgg requires a file called .htaccess to be set in the root directory of its installation. We tried to create it for you, but Elgg doesn't have permission to write to that directory. \r
-\r
-Creating this is easy. Copy the contents of the textbox below into a text editor and save it as .htaccess\r
-\r
-",\r
-                       'installation:error:settings' => "Elgg couldn't find its settings file. Most of Elgg's settings will be handled for you, but we need you to supply your database details. To do this:\r
-\r
-1. Rename engine/settings.example.php to settings.php in your Elgg installation.\r
-\r
-2. Open it with a text editor and enter your MySQL database details. If you don't know these, ask your system administrator or technical support for help.\r
-\r
-Alternatively, you can enter your database settings below and we will try and do this for you...",\r
-       \r
-                       'installation:error:configuration' => "Once you've corrected any configuration issues, press reload to try again.",\r
-       \r
-                       'installation' => "Installation",\r
-                       'installation:success' => "Elgg's database was installed successfully.",\r
-                       'installation:configuration:success' => "Your initial configuration settings have been saved. Now register your initial user; this will be your first system administrator.",\r
-       \r
-                       'installation:settings' => "System settings",\r
-                       'installation:settings:description' => "Now that the Elgg database has been successfully installed, you need to enter a couple of pieces of information to get your site fully up and running. We've tried to guess where we could, but <b>you should check these details.</b>",\r
-       \r
-                       'installation:settings:dbwizard:prompt' => "Enter your database settings below and hit save:",\r
-                       'installation:settings:dbwizard:label:user' => "Database user",\r
-                       'installation:settings:dbwizard:label:pass' => "Database password",\r
-                       'installation:settings:dbwizard:label:dbname' => "Elgg database",\r
-                       'installation:settings:dbwizard:label:host' => "Database hostname (usually 'localhost')",\r
-                       'installation:settings:dbwizard:label:prefix' => "Database table prefix (usually 'elgg')",\r
-       \r
-                       'installation:settings:dbwizard:savefail' => "We were unable to save the new settings.php. Please save the following file as engine/settings.php using a text editor.",\r
-       \r
-                       'installation:sitename' => "The name of your site (eg \"My social networking site\"):",\r
-                       'installation:sitedescription' => "Short description of your site (optional)",\r
-                       'installation:wwwroot' => "The site URL, followed by a trailing slash:",\r
-                       'installation:path' => "The full path to your site root on your disk, followed by a trailing slash:",\r
-                       'installation:dataroot' => "The full path to the directory where uploaded files will be stored, followed by a trailing slash:",\r
-                       'installation:dataroot:warning' => "You must create this directory manually. It should sit in a different directory to your Elgg installation.",\r
-                       'installation:sitepermissions' => "The default access permissions:",\r
-                       'installation:language' => "The default language for your site:",\r
-                       'installation:debug' => "Debug mode provides extra information which can be used to diagnose faults, however it can slow your system down so should only be used if you are having problems:",\r
-                       'installation:debug:label' => "Turn on debug mode",\r
-                       'installation:httpslogin' => "Enable this to have user logins performed over HTTPS. You will need to have https enabled on your server for this to work.",\r
-                       'installation:httpslogin:label' => "Enable HTTPS logins",\r
-                       'installation:usage' => "This option lets Elgg send anonymous usage statistics back to Curverider.",\r
-                       'installation:usage:label' => "Send anonymous usage statistics",\r
-                       'installation:view' => "Enter the view which will be used as the default for your site or leave this blank for the default view (if in doubt, leave as default):",\r
-\r
-                       'installation:siteemail' => "Site email address (used when sending system emails)",\r
-       \r
-                       'installation:disableapi' => "The RESTful API is a flexible and extensible interface that enables applications to use certain Elgg features remotely.",\r
-                       'installation:disableapi:label' => "Enable the RESTful API",\r
-                       \r
-                       'installation:allow_user_default_access:description' => "If checked, individual users will be allowed to set their own default access level that can over-ride the system default access level.",\r
-                       'installation:allow_user_default_access:label' => "Allow user default access",\r
-       \r
-                       'installation:simplecache:description' => "The simple cache increases performance by caching static content including some CSS and JavaScript files. Normally you will want this on.",\r
-                       'installation:simplecache:label' => "Use simple cache (recommended)",\r
-       \r
-                       'installation:viewpathcache:description' => "The view filepath cache decreases the loading times of plugins by caching the location of their views.",\r
-                       'installation:viewpathcache:label' => "Use view filepath cache (recommended)",\r
-       \r
-                       'upgrading' => 'Upgrading',\r
-                       'upgrade:db' => 'Your database was upgraded.',\r
-                       'upgrade:core' => 'Your elgg installation was upgraded',\r
-       \r
-               /**\r
-                * Welcome\r
-                */\r
-       \r
-                       'welcome' => "Welcome",\r
-                       'welcome:user' => 'Welcome %s',\r
-                       'welcome_message' => "Welcome to this Elgg installation.",\r
-       \r
-               /**\r
-                * Emails\r
-                */\r
-                       'email:settings' => "Email settings",\r
-                       'email:address:label' => "Your email address",\r
-                       \r
-                       'email:save:success' => "New email address saved, verification requested.",\r
-                       'email:save:fail' => "Your new email address could not be saved.",\r
-       \r
-                       'friend:newfriend:subject' => "%s has made you a friend!",\r
-                       'friend:newfriend:body' => "%s has made you a friend!\r
-\r
-To view their profile, click here:\r
-\r
-       %s\r
-\r
-You cannot reply to this email.",\r
-       \r
-       \r
-       \r
-                       'email:resetpassword:subject' => "Password reset!",\r
-                       'email:resetpassword:body' => "Hi %s,\r
-                       \r
-Your password has been reset to: %s",\r
-       \r
-       \r
-                       'email:resetreq:subject' => "Request for new password.",\r
-                       'email:resetreq:body' => "Hi %s,\r
-                       \r
-Somebody (from the IP address %s) has requested a new password for their account.\r
-\r
-If you requested this click on the link below, otherwise ignore this email.\r
-\r
-%s\r
-",\r
-\r
-               /**\r
-                * user default access\r
-                */\r
-       \r
-               'default_access:settings' => "Your default access level",\r
-               'default_access:label' => "Default access",\r
-               'user:default_access:success' => "Your new default access level was saved.",\r
-               'user:default_access:failure' => "Your new default access level could not be saved.",\r
-       \r
-               /**\r
-                * XML-RPC\r
-                */\r
-                       'xmlrpc:noinputdata'    =>      "Input data missing",\r
-       \r
-               /**\r
-                * Comments\r
-                */\r
-       \r
-                       'comments:count' => "%s comments",\r
-                       \r
-                       'riveraction:annotation:generic_comment' => '%s commented on %s',\r
-       \r
-                       'generic_comments:add' => "Add a comment",\r
-                       'generic_comments:text' => "Comment",\r
-                       'generic_comment:posted' => "Your comment was successfully posted.",\r
-                       'generic_comment:deleted' => "Your comment was successfully deleted.",\r
-                       'generic_comment:blank' => "Sorry; you need to actually put something in your comment before we can save it.",\r
-                       'generic_comment:notfound' => "Sorry; we could not find the specified item.",\r
-                       'generic_comment:notdeleted' => "Sorry; we could not delete this comment.",\r
-                       'generic_comment:failure' => "An unexpected error occurred when adding your comment. Please try again.",\r
-       \r
-                       'generic_comment:email:subject' => 'You have a new comment!',\r
-                       'generic_comment:email:body' => "You have a new comment on your item \"%s\" from %s. It reads:\r
-\r
-                       \r
-%s\r
-\r
-\r
-To reply or view the original item, click here:\r
-\r
-       %s\r
-\r
-To view %s's profile, click here:\r
-\r
-       %s\r
-\r
-You cannot reply to this email.",\r
-       \r
-               /**\r
-                * Entities\r
-                */\r
-                       'entity:default:strapline' => 'Created %s by %s',\r
-                       'entity:default:missingsupport:popup' => 'This entity cannot be displayed correctly. This may be because it requires support provided by a plugin that is no longer installed.',\r
-       \r
-                       'entity:delete:success' => 'Entity %s has been deleted',\r
-                       'entity:delete:fail' => 'Entity %s could not be deleted',\r
-       \r
-       \r
-               /**\r
-                * Action gatekeeper\r
-                */\r
-                       'actiongatekeeper:missingfields' => 'Form is missing __token or __ts fields',\r
-                       'actiongatekeeper:tokeninvalid' => "We encountered an error (token mismatch). This probably means that the page you were using expired. Please try again.",\r
-                       'actiongatekeeper:timeerror' => 'The page you were using has expired. Please refresh and try again.',\r
-                       'actiongatekeeper:pluginprevents' => 'A extension has prevented this form from being submitted.',\r
-       \r
-               /**\r
-                * Word blacklists\r
-                */\r
-                       'word:blacklist' => 'and, the, then, but, she, his, her, him, one, not, also, about, now, hence, however, still, likewise, otherwise, therefore, conversely, rather, consequently, furthermore, nevertheless, instead, meanwhile, accordingly, this, seems, what, whom, whose, whoever, whomever',\r
-       \r
-               /**\r
-                * Languages according to ISO 639-1\r
-                */\r
-                       "aa" => "Afar",\r
-                       "ab" => "Abkhazian",\r
-                       "af" => "Afrikaans",\r
-                       "am" => "Amharic",\r
-                       "ar" => "Arabic",\r
-                       "as" => "Assamese",\r
-                       "ay" => "Aymara",\r
-                       "az" => "Azerbaijani",\r
-                       "ba" => "Bashkir",\r
-                       "be" => "Byelorussian",\r
-                       "bg" => "Bulgarian",\r
-                       "bh" => "Bihari",\r
-                       "bi" => "Bislama",\r
-                       "bn" => "Bengali; Bangla",\r
-                       "bo" => "Tibetan",\r
-                       "br" => "Breton",\r
-                       "ca" => "Catalan",\r
-                       "co" => "Corsican",\r
-                       "cs" => "Czech",\r
-                       "cy" => "Welsh",\r
-                       "da" => "Danish",\r
-                       "de" => "German",\r
-                       "dz" => "Bhutani",\r
-                       "el" => "Greek",\r
-                       "en" => "English",\r
-                       "eo" => "Esperanto",\r
-                       "es" => "Spanish",\r
-                       "et" => "Estonian",\r
-                       "eu" => "Basque",\r
-                       "fa" => "Persian",\r
-                       "fi" => "Finnish",\r
-                       "fj" => "Fiji",\r
-                       "fo" => "Faeroese",\r
-                       "fr" => "French",\r
-                       "fy" => "Frisian",\r
-                       "ga" => "Irish",\r
-                       "gd" => "Scots / Gaelic",\r
-                       "gl" => "Galician",\r
-                       "gn" => "Guarani",\r
-                       "gu" => "Gujarati",\r
-                       "he" => "Hebrew",\r
-                       "ha" => "Hausa",\r
-                       "hi" => "Hindi",\r
-                       "hr" => "Croatian",\r
-                       "hu" => "Hungarian",\r
-                       "hy" => "Armenian",\r
-                       "ia" => "Interlingua",\r
-                       "id" => "Indonesian",\r
-                       "ie" => "Interlingue",\r
-                       "ik" => "Inupiak",\r
-                       //"in" => "Indonesian",\r
-                       "is" => "Icelandic",\r
-                       "it" => "Italian",\r
-                       "iu" => "Inuktitut",\r
-                       "iw" => "Hebrew (obsolete)",\r
-                       "ja" => "Japanese",\r
-                       "ji" => "Yiddish (obsolete)",\r
-                       "jw" => "Javanese",\r
-                       "ka" => "Georgian",\r
-                       "kk" => "Kazakh",\r
-                       "kl" => "Greenlandic",\r
-                       "km" => "Cambodian",\r
-                       "kn" => "Kannada",\r
-                       "ko" => "Korean",\r
-                       "ks" => "Kashmiri",\r
-                       "ku" => "Kurdish",\r
-                       "ky" => "Kirghiz",\r
-                       "la" => "Latin",\r
-                       "ln" => "Lingala",\r
-                       "lo" => "Laothian",\r
-                       "lt" => "Lithuanian",\r
-                       "lv" => "Latvian/Lettish",\r
-                       "mg" => "Malagasy",\r
-                       "mi" => "Maori",\r
-                       "mk" => "Macedonian",\r
-                       "ml" => "Malayalam",\r
-                       "mn" => "Mongolian",\r
-                       "mo" => "Moldavian",\r
-                       "mr" => "Marathi",\r
-                       "ms" => "Malay",\r
-                       "mt" => "Maltese",\r
-                       "my" => "Burmese",\r
-                       "na" => "Nauru",\r
-                       "ne" => "Nepali",\r
-                       "nl" => "Dutch",\r
-                       "no" => "Norwegian",\r
-                       "oc" => "Occitan",\r
-                       "om" => "(Afan) Oromo",\r
-                       "or" => "Oriya",\r
-                       "pa" => "Punjabi",\r
-                       "pl" => "Polish",\r
-                       "ps" => "Pashto / Pushto",\r
-                       "pt" => "Portuguese",\r
-                       "qu" => "Quechua",\r
-                       "rm" => "Rhaeto-Romance",\r
-                       "rn" => "Kirundi",\r
-                       "ro" => "Romanian",\r
-                       "ru" => "Russian",\r
-                       "rw" => "Kinyarwanda",\r
-                       "sa" => "Sanskrit",\r
-                       "sd" => "Sindhi",\r
-                       "sg" => "Sangro",\r
-                       "sh" => "Serbo-Croatian",\r
-                       "si" => "Singhalese",\r
-                       "sk" => "Slovak",\r
-                       "sl" => "Slovenian",\r
-                       "sm" => "Samoan",\r
-                       "sn" => "Shona",\r
-                       "so" => "Somali",\r
-                       "sq" => "Albanian",\r
-                       "sr" => "Serbian",\r
-                       "ss" => "Siswati",\r
-                       "st" => "Sesotho",\r
-                       "su" => "Sundanese",\r
-                       "sv" => "Swedish",\r
-                       "sw" => "Swahili",\r
-                       "ta" => "Tamil",\r
-                       "te" => "Tegulu",\r
-                       "tg" => "Tajik",\r
-                       "th" => "Thai",\r
-                       "ti" => "Tigrinya",\r
-                       "tk" => "Turkmen",\r
-                       "tl" => "Tagalog",\r
-                       "tn" => "Setswana",\r
-                       "to" => "Tonga",\r
-                       "tr" => "Turkish",\r
-                       "ts" => "Tsonga",\r
-                       "tt" => "Tatar",\r
-                       "tw" => "Twi",\r
-                       "ug" => "Uigur",\r
-                       "uk" => "Ukrainian",\r
-                       "ur" => "Urdu",\r
-                       "uz" => "Uzbek",\r
-                       "vi" => "Vietnamese",\r
-                       "vo" => "Volapuk",\r
-                       "wo" => "Wolof",\r
-                       "xh" => "Xhosa",\r
-                       //"y" => "Yiddish",\r
-                       "yi" => "Yiddish",\r
-                       "yo" => "Yoruba",\r
-                       "za" => "Zuang",\r
-                       "zh" => "Chinese",\r
-                       "zu" => "Zulu",\r
-       );\r
-       \r
-       add_translation("en",$english);\r
-\r
-?>\r
+       
+       
+
+               /**
+                * Profile menu items and titles
+                */
+       
+                       'profile:yours' => "Your profile",
+                       'profile:user' => "%s's profile",
+       
+                       'profile:edit' => "Edit profile",
+                       'profile:profilepictureinstructions' => "The profile picture is the image that's displayed on your profile page. <br /> You can change it as often as you'd like. (File formats accepted: GIF, JPG or PNG)",
+                       'profile:icon' => "Profile picture",
+                       'profile:createicon' => "Create your avatar",
+                       'profile:currentavatar' => "Current avatar",
+                       'profile:createicon:header' => "Profile picture",
+                       'profile:profilepicturecroppingtool' => "Profile picture cropping tool",
+                       'profile:createicon:instructions' => "Click and drag a square below to match how you want your picture cropped.  A preview of your cropped picture will appear in the box on the right.  When you are happy with the preview, click 'Create your avatar'. This cropped image will be used throughout the site as your avatar. ",
+       
+                       'profile:editdetails' => "Edit details",
+                       'profile:editicon' => "Edit profile icon",
+       
+                       'profile:aboutme' => "About me", 
+                       'profile:description' => "About me",
+                       'profile:briefdescription' => "Brief description",
+                       'profile:location' => "Location",
+                       'profile:skills' => "Skills",  
+                       'profile:interests' => "Interests", 
+                       'profile:contactemail' => "Contact email",
+                       'profile:phone' => "Telephone",
+                       'profile:mobile' => "Mobile phone",
+                       'profile:website' => "Website",
+       
+                       'profile:banned' => 'This user account has been suspended.',
+                       'profile:deleteduser' => 'Deleted user',
+
+                       'profile:river:update' => "%s updated their profile",
+                       'profile:river:iconupdate' => "%s updated their profile icon",
+       
+                       'profile:label' => "Profile label",
+                       'profile:type' => "Profile type",
+       
+                       'profile:editdefault:fail' => 'Default profile could not be saved',
+                       'profile:editdefault:success' => 'Item successfully added to default profile',
+       
+                       
+                       'profile:editdefault:delete:fail' => 'Removed default profile item field failed',
+                       'profile:editdefault:delete:success' => 'Default profile item deleted!',
+       
+                       'profile:defaultprofile:reset' => 'Default system profile reset',
+       
+                       'profile:resetdefault' => 'Reset default profile',
+                       'profile:explainchangefields' => 'You can replace the existing profile fields with your own using the form below. First you give the new profile field a label, for example, \'Favourite team\'. Next you need to select the field type, for example, tags, url, text and so on. At any time you can revert back to the default profile set up.',
+       
+
+       
+               /**
+                * Profile status messages
+                */
+       
+                       'profile:saved' => "Your profile was successfully saved.",
+                       'profile:icon:uploaded' => "Your profile picture was successfully uploaded.",
+       
+               /**
+                * Profile error messages
+                */
+       
+                       'profile:noaccess' => "You do not have permission to edit this profile.",
+                       'profile:notfound' => "Sorry; we could not find the specified profile.",
+                       'profile:cantedit' => "Sorry; you do not have permission to edit this profile.",
+                       'profile:icon:notfound' => "Sorry; there was a problem uploading your profile picture.",
+       
+               /**
+                * Friends
+                */
+       
+                       'friends' => "Friends",
+                       'friends:yours' => "Your friends",
+                       'friends:owned' => "%s's friends",
+                       'friend:add' => "Add friend",
+                       'friend:remove' => "Remove friend",
+       
+                       'friends:add:successful' => "You have successfully added %s as a friend.",
+                       'friends:add:failure' => "We couldn't add %s as a friend. Please try again.",
+       
+                       'friends:remove:successful' => "You have successfully removed %s from your friends.",
+                       'friends:remove:failure' => "We couldn't remove %s from your friends. Please try again.",
+       
+                       'friends:none' => "This user hasn't added anyone as a friend yet.",
+                       'friends:none:you' => "You haven't added anyone as a friend! Search for your interests to begin finding people to follow.",
+       
+                       'friends:none:found' => "No friends were found.",
+       
+                       'friends:of:none' => "Nobody has added this user as a friend yet.",
+                       'friends:of:none:you' => "Nobody has added you as a friend yet. Start adding content and fill in your profile to let people find you!",
+       
+                       'friends:of:owned' => "People who have made %s a friend",
+
+                        'friends:num_display' => "Number of friends to display",
+                        'friends:icon_size' => "Icon size",
+                        'friends:tiny' => "tiny",
+                        'friends:small' => "small",
+                        'friends:of' => "Friends of",
+                        'friends:collections' => "Collections of friends",
+                        'friends:collections:add' => "New friends collection",
+                        'friends:addfriends' => "Add friends",
+                        'friends:collectionname' => "Collection name",
+                        'friends:collectionfriends' => "Friends in collection",
+                        'friends:collectionedit' => "Edit this collection",
+                        'friends:nocollections' => "You do not yet have any collections.",
+                        'friends:collectiondeleted' => "Your collection has been deleted.",
+                        'friends:collectiondeletefailed' => "We were unable to delete the collection. Either you don't have permission, or some other problem has occurred.",
+                        'friends:collectionadded' => "Your collection was successfuly created",
+                        'friends:nocollectionname' => "You need to give your collection a name before it can be created.",
+                       'friends:collections:members' => "Collection members",
+                       'friends:collections:edit' => "Edit collection",
+               
+               'friends:river:created' => "%s added the friends widget.",
+               'friends:river:updated' => "%s updated their friends widget.",
+               'friends:river:delete' => "%s removed their friends widget.",
+               'friends:river:add' => "%s is now a friend with",
+       
+                       'friendspicker:chararray' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
+       
+               /**
+                * Feeds
+                */
+                       'feed:rss' => 'Subscribe to feed',
+                       'feed:odd' => 'Syndicate OpenDD',
+                       
+               /**
+          * links
+                **/
+
+                       'link:view' => 'view link',
+
+       
+               /**
+                * River
+                */
+                       'river' => "River",                     
+                       'river:relationship:friend' => 'is now friends with',
+                       'river:noaccess' => 'You do not have permission to view this item.',
+                       'river:posted:generic' => '%s posted',
+
+               /**
+                * Plugins
+                */
+                       'plugins:settings:save:ok' => "Settings for the %s plugin were saved successfully.",
+                       'plugins:settings:save:fail' => "There was a problem saving settings for the %s plugin.",
+                       'plugins:usersettings:save:ok' => "User settings for the %s plugin were saved successfully.",
+                       'plugins:usersettings:save:fail' => "There was a problem saving  user settings for the %s plugin.",
+                       'admin:plugins:label:version' => "Version",
+                       'item:object:plugin' => 'Plugin configuration settings',
+                       
+               /**
+                * Notifications
+                */
+                       'notifications:usersettings' => "Notification settings",
+                       'notifications:methods' => "Please specify which methods you want to permit.",
+       
+                       'notifications:usersettings:save:ok' => "Your notification settings were successfully saved.",
+                       'notifications:usersettings:save:fail' => "There was a problem saving your notification settings.",
+       
+                       'user.notification.get' => 'Return the notification settings for a given user.',
+                       'user.notification.set' => 'Set the notification settings for a given user.',
+               /**
+                * Search
+                */
+       
+                       'search' => "Search",
+                       'searchtitle' => "Search: %s",
+                       'users:searchtitle' => "Searching for users: %s",
+                       'groups:searchtitle' => "Searching for groups: %s",
+                       'advancedsearchtitle' => "%s with results matching %s",
+                       'notfound' => "No results found.",
+                       'next' => "Next",
+                       'previous' => "Previous",
+       
+                       'viewtype:change' => "Change listing type",
+                       'viewtype:list' => "List view",
+                       'viewtype:gallery' => "Gallery",
+       
+                       'tag:search:startblurb' => "Items with tags matching '%s':",
+
+                       'user:search:startblurb' => "Users matching '%s':",
+                       'user:search:finishblurb' => "To view more, click here.",
+       
+                       'group:search:startblurb' => "Groups matching '%s':",
+                       'group:search:finishblurb' => "To view more, click here.",
+                       'search:go' => 'Go',
+       
+               /**
+                * Account
+                */
+       
+                       'account' => "Account",
+                       'settings' => "Settings",
+            'tools' => "Tools",
+            'tools:yours' => "Your tools",
+       
+                       'register' => "Register",
+                       'registerok' => "You have successfully registered for %s.",
+                       'registerbad' => "Your registration was unsuccessful. The username may already exist, your passwords might not match, or your username or password may be too short.",
+                       'registerdisabled' => "Registration has been disabled by the system administrator",
+       
+                       'firstadminlogininstructions' => 'Your new Elgg site has been successfully installed and your administrator account created. You can now configure your site further by enabling various installed plugin tools.',
+       
+                       'registration:notemail' => 'The email address you provided does not appear to be a valid email address.',
+                       'registration:userexists' => 'That username already exists',
+                       'registration:usernametooshort' => 'Your username must be a minimum of 4 characters long.',
+                       'registration:passwordtooshort' => 'The password must be a minimum of 6 characters long.',
+                       'registration:dupeemail' => 'This email address has already been registered.',
+                       'registration:invalidchars' => 'Sorry, your username contains invalid characters.',
+                       'registration:emailnotvalid' => 'Sorry, the email address you entered is invalid on this system',
+                       'registration:passwordnotvalid' => 'Sorry, the password you entered is invalid on this system',
+                       'registration:usernamenotvalid' => 'Sorry, the username you entered is invalid on this system',
+       
+                       'adduser' => "Add User",
+                       'adduser:ok' => "You have successfully added a new user.",
+                       'adduser:bad' => "The new user could not be created.",
+                       
+                       'item:object:reported_content' => "Reported items",
+       
+                       'user:set:name' => "Account name settings",
+                       'user:name:label' => "Your name",
+                       'user:name:success' => "Successfully changed your name on the system.",
+                       'user:name:fail' => "Could not change your name on the system.",
+       
+                       'user:set:password' => "Account password",
+                       'user:password:label' => "Your new password",
+                       'user:password2:label' => "Your new password again",
+                       'user:password:success' => "Password changed",
+                       'user:password:fail' => "Could not change your password on the system.",
+                       'user:password:fail:notsame' => "The two passwords are not the same!",
+                       'user:password:fail:tooshort' => "Password is too short!",
+       
+                       'user:set:language' => "Language settings",
+                       'user:language:label' => "Your language",
+                       'user:language:success' => "Your language settings have been updated.",
+                       'user:language:fail' => "Your language settings could not be saved.",
+       
+                       'user:username:notfound' => 'Username %s not found.',
+       
+                       'user:password:lost' => 'Lost password',
+                       'user:password:resetreq:success' => 'Successfully requested a new password, email sent',
+                       'user:password:resetreq:fail' => 'Could not request a new password.',
+       
+                       'user:password:text' => 'To generate a new password, enter your username below. We will send the address of a unique verification page to you via email click on the link in the body of the message and a new password will be sent to you.',
+       
+                       'user:persistent' => 'Remember me',
+               /**
+                * Administration
+                */
+
+                       'admin:configuration:success' => "Your settings have been saved.",
+                       'admin:configuration:fail' => "Your settings could not be saved.",
+       
+                       'admin' => "Administration",
+                       'admin:description' => "The admin panel allows you to control all aspects of the system, from user management to how plugins behave. Choose an option below to get started.",
+                       
+                       'admin:user' => "User Administration",
+                       'admin:user:description' => "This admin panel allows you to control user settings for your site. Choose an option below to get started.",
+                       'admin:user:adduser:label' => "Click here to add a new user...",
+                       'admin:user:opt:linktext' => "Configure users...",
+                       'admin:user:opt:description' => "Configure users and account information. ",
+                       
+                       'admin:site' => "Site Administration",
+                       'admin:site:description' => "This admin panel allows you to control global settings for your site. Choose an option below to get started.",
+                       'admin:site:opt:linktext' => "Configure site...",
+                       'admin:site:opt:description' => "Configure the site technical and non-technical settings. ",
+                       'admin:site:access:warning' => "Changing the access setting only affects the permissions on content created in the future.", 
+                       
+                       'admin:plugins' => "Tool Administration",
+                       'admin:plugins:description' => "This admin panel allows you to control and configure tools installed on your site.",
+                       'admin:plugins:opt:linktext' => "Configure tools...",
+                       'admin:plugins:opt:description' => "Configure the tools installed on the site. ",
+                       'admin:plugins:label:author' => "Author",
+                       'admin:plugins:label:copyright' => "Copyright",
+                       'admin:plugins:label:licence' => "Licence",
+                       'admin:plugins:label:website' => "URL",
+                       'admin:plugins:label:moreinfo' => 'more info',
+                       'admin:plugins:label:version' => 'Version',
+                       'admin:plugins:warning:elggversionunknown' => 'Warning: This plugin does not specify a compatible Elgg version.',
+                       'admin:plugins:warning:elggtoolow' => 'Warning: This plugin requires a later version of Elgg!',
+                       'admin:plugins:reorder:yes' => "Plugin %s was reordered successfully.",
+                       'admin:plugins:reorder:no' => "Plugin %s could not be reordered.",
+                       'admin:plugins:disable:yes' => "Plugin %s was disabled successfully.",
+                       'admin:plugins:disable:no' => "Plugin %s could not be disabled.",
+                       'admin:plugins:enable:yes' => "Plugin %s was enabled successfully.",
+                       'admin:plugins:enable:no' => "Plugin %s could not be enabled.",
+       
+                       'admin:statistics' => "Statistics",
+                       'admin:statistics:description' => "This is an overview of statistics on your site. If you need more detailed statistics, a professional administration feature is available.",
+                       'admin:statistics:opt:description' => "View statistical information about users and objects on your site.",
+                       'admin:statistics:opt:linktext' => "View statistics...",
+                       'admin:statistics:label:basic' => "Basic site statistics",
+                       'admin:statistics:label:numentities' => "Entities on site",
+                       'admin:statistics:label:numusers' => "Number of users",
+                       'admin:statistics:label:numonline' => "Number of users online",
+                       'admin:statistics:label:onlineusers' => "Users online now",
+                       'admin:statistics:label:version' => "Elgg version",
+                       'admin:statistics:label:version:release' => "Release",
+                       'admin:statistics:label:version:version' => "Version",
+       
+                       'admin:user:label:search' => "Find users:",
+                       'admin:user:label:seachbutton' => "Search", 
+       
+                       'admin:user:ban:no' => "Can not ban user",
+                       'admin:user:ban:yes' => "User banned.",
+                       'admin:user:unban:no' => "Can not unban user",
+                       'admin:user:unban:yes' => "User un-banned.",
+                       'admin:user:delete:no' => "Can not delete user",
+                       'admin:user:delete:yes' => "User deleted",
+       
+                       'admin:user:resetpassword:yes' => "Password reset, user notified.",
+                       'admin:user:resetpassword:no' => "Password could not be reset.",
+       
+                       'admin:user:makeadmin:yes' => "User is now an admin.",
+                       'admin:user:makeadmin:no' => "We could not make this user an admin.",
+       
+                       'admin:user:removeadmin:yes' => "User is no longer an admin.",
+                       'admin:user:removeadmin:no' => "We could not remove administrator privileges from this user.",
+                       
+               /**
+                * User settings
+                */
+                       'usersettings:description' => "The user settings panel allows you to control all your personal settings, from user management to how plugins behave. Choose an option below to get started.",
+       
+                       'usersettings:statistics' => "Your statistics",
+                       'usersettings:statistics:opt:description' => "View statistical information about users and objects on your site.",
+                       'usersettings:statistics:opt:linktext' => "Account statistics",
+       
+                       'usersettings:user' => "Your settings",
+                       'usersettings:user:opt:description' => "This allows you to control user settings.",
+                       'usersettings:user:opt:linktext' => "Change your settings",
+       
+                       'usersettings:plugins' => "Tools",
+                       'usersettings:plugins:opt:description' => "Configure settings (if any) for your active tools.",
+                       'usersettings:plugins:opt:linktext' => "Configure your tools",
+       
+                       'usersettings:plugins:description' => "This panel allows you to control and configure the personal settings for the tools installed by your system administrator.",
+                       'usersettings:statistics:label:numentities' => "Your entities",
+       
+                       'usersettings:statistics:yourdetails' => "Your details",
+                       'usersettings:statistics:label:name' => "Full name",
+                       'usersettings:statistics:label:email' => "Email",
+                       'usersettings:statistics:label:membersince' => "Member since",
+                       'usersettings:statistics:label:lastlogin' => "Last logged in",
+       
+                       
+       
+               /**
+                * Generic action words
+                */
+       
+                       'save' => "Save",
+                       'publish' => "Publish",
+                       'cancel' => "Cancel",
+                       'saving' => "Saving ...",
+                       'update' => "Update",
+                       'edit' => "Edit",
+                       'delete' => "Delete",
+                       'accept' => "Accept",
+                       'load' => "Load",
+                       'upload' => "Upload",
+                       'ban' => "Ban",
+                       'unban' => "Unban",
+                       'enable' => "Enable",
+                       'disable' => "Disable",
+                       'request' => "Request",
+                       'complete' => "Complete",
+                       'open' => 'Open',
+                       'close' => 'Close',
+                       'reply' => "Reply",
+                       'more' => 'More',
+                       'comments' => 'Comments',
+                       'import' => 'Import',
+                       'export' => 'Export',
+       
+                       'up' => 'Up',
+                       'down' => 'Down',
+                       'top' => 'Top',
+                       'bottom' => 'Bottom',
+       
+                       'invite' => "Invite",
+       
+                       'resetpassword' => "Reset password",
+                       'makeadmin' => "Make admin",
+                       'removeadmin' => "Remove admin",
+       
+                       'option:yes' => "Yes",
+                       'option:no' => "No",
+       
+                       'unknown' => 'Unknown',
+       
+                       'active' => 'Active',
+                       'total' => 'Total',
+       
+                       'learnmore' => "Click here to learn more.",
+       
+                       'content' => "content",
+                       'content:latest' => 'Latest activity',
+                       'content:latest:blurb' => 'Alternatively, click here to view the latest content from across the site.',
+       
+                       'link:text' => 'view link',
+       
+                       'enableall' => 'Enable All',
+                       'disableall' => 'Disable All',
+       
+               /**
+                * Generic questions
+                */
+       
+                       'question:areyousure' => 'Are you sure?',
+       
+               /**
+                * Generic data words
+                */
+       
+                       'title' => "Title",
+                       'description' => "Description",
+                       'tags' => "Tags",
+                       'spotlight' => "Spotlight",
+                       'all' => "All",
+       
+                       'by' => 'by',
+       
+                       'annotations' => "Annotations",
+                       'relationships' => "Relationships",
+                       'metadata' => "Metadata",
+       
+               /**
+                * Input / output strings
+                */
+
+                       'deleteconfirm' => "Are you sure you want to delete this item?",
+                       'fileexists' => "A file has already been uploaded. To replace it, select it below:",
+                       
+               /**
+                * User add
+                */
+
+                       'useradd:subject' => 'User account created',
+                       'useradd:body' => '
+%s,
+
+A user account has been created for you at %s. To log in, visit:
+
+       %s
+
+And log in with these user credentials:
+
+       Username: %s
+       Password: %s
+       
+Once you have logged in, we highly recommend that you change your password.
+',
+                       
+           /**
+         * System messages
+         **/
+
+                       'systemmessages:dismiss' => "click to dismiss",
+
+       
+               /**
+                * Import / export
+                */
+                       'importsuccess' => "Import of data was successful",
+                       'importfail' => "OpenDD import of data failed.",
+       
+               /**
+                * Time
+                */
+       
+                       'friendlytime:justnow' => "just now",
+                       'friendlytime:minutes' => "%s minutes ago",
+                       'friendlytime:minutes:singular' => "a minute ago",
+                       'friendlytime:hours' => "%s hours ago",
+                       'friendlytime:hours:singular' => "an hour ago",
+                       'friendlytime:days' => "%s days ago",
+                       'friendlytime:days:singular' => "yesterday",
+       
+                       'date:month:01' => 'January %s',
+                       'date:month:02' => 'February %s',
+                       'date:month:03' => 'March %s',
+                       'date:month:04' => 'April %s',
+                       'date:month:05' => 'May %s',
+                       'date:month:06' => 'June %s',
+                       'date:month:07' => 'July %s',
+                       'date:month:08' => 'August %s',
+                       'date:month:09' => 'September %s',
+                       'date:month:10' => 'October %s',
+                       'date:month:11' => 'November %s',
+                       'date:month:12' => 'December %s',
+       
+       
+               /**
+                * Installation and system settings
+                */
+       
+                       'installation:error:htaccess' => "Elgg requires a file called .htaccess to be set in the root directory of its installation. We tried to create it for you, but Elgg doesn't have permission to write to that directory. 
+
+Creating this is easy. Copy the contents of the textbox below into a text editor and save it as .htaccess
+
+",
+                       'installation:error:settings' => "Elgg couldn't find its settings file. Most of Elgg's settings will be handled for you, but we need you to supply your database details. To do this:
+
+1. Rename engine/settings.example.php to settings.php in your Elgg installation.
+
+2. Open it with a text editor and enter your MySQL database details. If you don't know these, ask your system administrator or technical support for help.
+
+Alternatively, you can enter your database settings below and we will try and do this for you...",
+       
+                       'installation:error:configuration' => "Once you've corrected any configuration issues, press reload to try again.",
+       
+                       'installation' => "Installation",
+                       'installation:success' => "Elgg's database was installed successfully.",
+                       'installation:configuration:success' => "Your initial configuration settings have been saved. Now register your initial user; this will be your first system administrator.",
+       
+                       'installation:settings' => "System settings",
+                       'installation:settings:description' => "Now that the Elgg database has been successfully installed, you need to enter a couple of pieces of information to get your site fully up and running. We've tried to guess where we could, but <b>you should check these details.</b>",
+       
+                       'installation:settings:dbwizard:prompt' => "Enter your database settings below and hit save:",
+                       'installation:settings:dbwizard:label:user' => "Database user",
+                       'installation:settings:dbwizard:label:pass' => "Database password",
+                       'installation:settings:dbwizard:label:dbname' => "Elgg database",
+                       'installation:settings:dbwizard:label:host' => "Database hostname (usually 'localhost')",
+                       'installation:settings:dbwizard:label:prefix' => "Database table prefix (usually 'elgg')",
+       
+                       'installation:settings:dbwizard:savefail' => "We were unable to save the new settings.php. Please save the following file as engine/settings.php using a text editor.",
+       
+                       'installation:sitename' => "The name of your site (eg \"My social networking site\"):",
+                       'installation:sitedescription' => "Short description of your site (optional)",
+                       'installation:wwwroot' => "The site URL, followed by a trailing slash:",
+                       'installation:path' => "The full path to your site root on your disk, followed by a trailing slash:",
+                       'installation:dataroot' => "The full path to the directory where uploaded files will be stored, followed by a trailing slash:",
+                       'installation:dataroot:warning' => "You must create this directory manually. It should sit in a different directory to your Elgg installation.",
+                       'installation:sitepermissions' => "The default access permissions:",
+                       'installation:language' => "The default language for your site:",
+                       'installation:debug' => "Debug mode provides extra information which can be used to diagnose faults, however it can slow your system down so should only be used if you are having problems:",
+                       'installation:debug:label' => "Turn on debug mode",
+                       'installation:httpslogin' => "Enable this to have user logins performed over HTTPS. You will need to have https enabled on your server for this to work.",
+                       'installation:httpslogin:label' => "Enable HTTPS logins",
+                       'installation:usage' => "This option lets Elgg send anonymous usage statistics back to Curverider.",
+                       'installation:usage:label' => "Send anonymous usage statistics",
+                       'installation:view' => "Enter the view which will be used as the default for your site or leave this blank for the default view (if in doubt, leave as default):",
+
+                       'installation:siteemail' => "Site email address (used when sending system emails)",
+       
+                       'installation:disableapi' => "The RESTful API is a flexible and extensible interface that enables applications to use certain Elgg features remotely.",
+                       'installation:disableapi:label' => "Enable the RESTful API",
+                       
+                       'installation:allow_user_default_access:description' => "If checked, individual users will be allowed to set their own default access level that can over-ride the system default access level.",
+                       'installation:allow_user_default_access:label' => "Allow user default access",
+       
+                       'installation:simplecache:description' => "The simple cache increases performance by caching static content including some CSS and JavaScript files. Normally you will want this on.",
+                       'installation:simplecache:label' => "Use simple cache (recommended)",
+       
+                       'installation:viewpathcache:description' => "The view filepath cache decreases the loading times of plugins by caching the location of their views.",
+                       'installation:viewpathcache:label' => "Use view filepath cache (recommended)",
+       
+                       'upgrading' => 'Upgrading',
+                       'upgrade:db' => 'Your database was upgraded.',
+                       'upgrade:core' => 'Your elgg installation was upgraded',
+       
+               /**
+                * Welcome
+                */
+       
+                       'welcome' => "Welcome",
+                       'welcome:user' => 'Welcome %s',
+                       'welcome_message' => "Welcome to this Elgg installation.",
+       
+               /**
+                * Emails
+                */
+                       'email:settings' => "Email settings",
+                       'email:address:label' => "Your email address",
+                       
+                       'email:save:success' => "New email address saved, verification requested.",
+                       'email:save:fail' => "Your new email address could not be saved.",
+       
+                       'friend:newfriend:subject' => "%s has made you a friend!",
+                       'friend:newfriend:body' => "%s has made you a friend!
+
+To view their profile, click here:
+
+       %s
+
+You cannot reply to this email.",
+       
+       
+       
+                       'email:resetpassword:subject' => "Password reset!",
+                       'email:resetpassword:body' => "Hi %s,
+                       
+Your password has been reset to: %s",
+       
+       
+                       'email:resetreq:subject' => "Request for new password.",
+                       'email:resetreq:body' => "Hi %s,
+                       
+Somebody (from the IP address %s) has requested a new password for their account.
+
+If you requested this click on the link below, otherwise ignore this email.
+
+%s
+",
+
+               /**
+                * user default access
+                */
+       
+               'default_access:settings' => "Your default access level",
+               'default_access:label' => "Default access",
+               'user:default_access:success' => "Your new default access level was saved.",
+               'user:default_access:failure' => "Your new default access level could not be saved.",
+       
+               /**
+                * XML-RPC
+                */
+                       'xmlrpc:noinputdata'    =>      "Input data missing",
+       
+               /**
+                * Comments
+                */
+       
+                       'comments:count' => "%s comments",
+                       
+                       'riveraction:annotation:generic_comment' => '%s commented on %s',
+       
+                       'generic_comments:add' => "Add a comment",
+                       'generic_comments:text' => "Comment",
+                       'generic_comment:posted' => "Your comment was successfully posted.",
+                       'generic_comment:deleted' => "Your comment was successfully deleted.",
+                       'generic_comment:blank' => "Sorry; you need to actually put something in your comment before we can save it.",
+                       'generic_comment:notfound' => "Sorry; we could not find the specified item.",
+                       'generic_comment:notdeleted' => "Sorry; we could not delete this comment.",
+                       'generic_comment:failure' => "An unexpected error occurred when adding your comment. Please try again.",
+       
+                       'generic_comment:email:subject' => 'You have a new comment!',
+                       'generic_comment:email:body' => "You have a new comment on your item \"%s\" from %s. It reads:
+
+                       
+%s
+
+
+To reply or view the original item, click here:
+
+       %s
+
+To view %s's profile, click here:
+
+       %s
+
+You cannot reply to this email.",
+       
+               /**
+                * Entities
+                */
+                       'entity:default:strapline' => 'Created %s by %s',
+                       'entity:default:missingsupport:popup' => 'This entity cannot be displayed correctly. This may be because it requires support provided by a plugin that is no longer installed.',
+       
+                       'entity:delete:success' => 'Entity %s has been deleted',
+                       'entity:delete:fail' => 'Entity %s could not be deleted',
+       
+       
+               /**
+                * Action gatekeeper
+                */
+                       'actiongatekeeper:missingfields' => 'Form is missing __token or __ts fields',
+                       'actiongatekeeper:tokeninvalid' => "We encountered an error (token mismatch). This probably means that the page you were using expired. Please try again.",
+                       'actiongatekeeper:timeerror' => 'The page you were using has expired. Please refresh and try again.',
+                       'actiongatekeeper:pluginprevents' => 'A extension has prevented this form from being submitted.',
+       
+               /**
+                * Word blacklists
+                */
+                       'word:blacklist' => 'and, the, then, but, she, his, her, him, one, not, also, about, now, hence, however, still, likewise, otherwise, therefore, conversely, rather, consequently, furthermore, nevertheless, instead, meanwhile, accordingly, this, seems, what, whom, whose, whoever, whomever',
+       
+               /**
+                * Languages according to ISO 639-1
+                */
+                       "aa" => "Afar",
+                       "ab" => "Abkhazian",
+                       "af" => "Afrikaans",
+                       "am" => "Amharic",
+                       "ar" => "Arabic",
+                       "as" => "Assamese",
+                       "ay" => "Aymara",
+                       "az" => "Azerbaijani",
+                       "ba" => "Bashkir",
+                       "be" => "Byelorussian",
+                       "bg" => "Bulgarian",
+                       "bh" => "Bihari",
+                       "bi" => "Bislama",
+                       "bn" => "Bengali; Bangla",
+                       "bo" => "Tibetan",
+                       "br" => "Breton",
+                       "ca" => "Catalan",
+                       "co" => "Corsican",
+                       "cs" => "Czech",
+                       "cy" => "Welsh",
+                       "da" => "Danish",
+                       "de" => "German",
+                       "dz" => "Bhutani",
+                       "el" => "Greek",
+                       "en" => "English",
+                       "eo" => "Esperanto",
+                       "es" => "Spanish",
+                       "et" => "Estonian",
+                       "eu" => "Basque",
+                       "fa" => "Persian",
+                       "fi" => "Finnish",
+                       "fj" => "Fiji",
+                       "fo" => "Faeroese",
+                       "fr" => "French",
+                       "fy" => "Frisian",
+                       "ga" => "Irish",
+                       "gd" => "Scots / Gaelic",
+                       "gl" => "Galician",
+                       "gn" => "Guarani",
+                       "gu" => "Gujarati",
+                       "he" => "Hebrew",
+                       "ha" => "Hausa",
+                       "hi" => "Hindi",
+                       "hr" => "Croatian",
+                       "hu" => "Hungarian",
+                       "hy" => "Armenian",
+                       "ia" => "Interlingua",
+                       "id" => "Indonesian",
+                       "ie" => "Interlingue",
+                       "ik" => "Inupiak",
+                       //"in" => "Indonesian",
+                       "is" => "Icelandic",
+                       "it" => "Italian",
+                       "iu" => "Inuktitut",
+                       "iw" => "Hebrew (obsolete)",
+                       "ja" => "Japanese",
+                       "ji" => "Yiddish (obsolete)",
+                       "jw" => "Javanese",
+                       "ka" => "Georgian",
+                       "kk" => "Kazakh",
+                       "kl" => "Greenlandic",
+                       "km" => "Cambodian",
+                       "kn" => "Kannada",
+                       "ko" => "Korean",
+                       "ks" => "Kashmiri",
+                       "ku" => "Kurdish",
+                       "ky" => "Kirghiz",
+                       "la" => "Latin",
+                       "ln" => "Lingala",
+                       "lo" => "Laothian",
+                       "lt" => "Lithuanian",
+                       "lv" => "Latvian/Lettish",
+                       "mg" => "Malagasy",
+                       "mi" => "Maori",
+                       "mk" => "Macedonian",
+                       "ml" => "Malayalam",
+                       "mn" => "Mongolian",
+                       "mo" => "Moldavian",
+                       "mr" => "Marathi",
+                       "ms" => "Malay",
+                       "mt" => "Maltese",
+                       "my" => "Burmese",
+                       "na" => "Nauru",
+                       "ne" => "Nepali",
+                       "nl" => "Dutch",
+                       "no" => "Norwegian",
+                       "oc" => "Occitan",
+                       "om" => "(Afan) Oromo",
+                       "or" => "Oriya",
+                       "pa" => "Punjabi",
+                       "pl" => "Polish",
+                       "ps" => "Pashto / Pushto",
+                       "pt" => "Portuguese",
+                       "qu" => "Quechua",
+                       "rm" => "Rhaeto-Romance",
+                       "rn" => "Kirundi",
+                       "ro" => "Romanian",
+                       "ru" => "Russian",
+                       "rw" => "Kinyarwanda",
+                       "sa" => "Sanskrit",
+                       "sd" => "Sindhi",
+                       "sg" => "Sangro",
+                       "sh" => "Serbo-Croatian",
+                       "si" => "Singhalese",
+                       "sk" => "Slovak",
+                       "sl" => "Slovenian",
+                       "sm" => "Samoan",
+                       "sn" => "Shona",
+                       "so" => "Somali",
+                       "sq" => "Albanian",
+                       "sr" => "Serbian",
+                       "ss" => "Siswati",
+                       "st" => "Sesotho",
+                       "su" => "Sundanese",
+                       "sv" => "Swedish",
+                       "sw" => "Swahili",
+                       "ta" => "Tamil",
+                       "te" => "Tegulu",
+                       "tg" => "Tajik",
+                       "th" => "Thai",
+                       "ti" => "Tigrinya",
+                       "tk" => "Turkmen",
+                       "tl" => "Tagalog",
+                       "tn" => "Setswana",
+                       "to" => "Tonga",
+                       "tr" => "Turkish",
+                       "ts" => "Tsonga",
+                       "tt" => "Tatar",
+                       "tw" => "Twi",
+                       "ug" => "Uigur",
+                       "uk" => "Ukrainian",
+                       "ur" => "Urdu",
+                       "uz" => "Uzbek",
+                       "vi" => "Vietnamese",
+                       "vo" => "Volapuk",
+                       "wo" => "Wolof",
+                       "xh" => "Xhosa",
+                       //"y" => "Yiddish",
+                       "yi" => "Yiddish",
+                       "yo" => "Yoruba",
+                       "za" => "Zuang",
+                       "zh" => "Chinese",
+                       "zu" => "Zulu",
+       );
+       
+       add_translation("en",$english);
+
+?>
index bfc56bdaaf63295045a618e8240055b47ca49318..480ec00424f3cc8c055f8fa8a20246e61318eeb0 100644 (file)
@@ -17,7 +17,7 @@
        
                        'garbagecollector:weekly' => 'Once a week',
                        'garbagecollector:monthly' => 'Once a month',
-                       'garbagecollector:yearly' => 'Once a year',\r
+                       'garbagecollector:yearly' => 'Once a year',
        
                        'garbagecollector' => "GARBAGE COLLECTOR\n",
                        'garbagecollector:done' => "DONE\n",
index 9751737001214721370e4c0549bd8b3f9752a1c6..18a15bfa4cd43f843116b8f65a00ccd647fbb696 100644 (file)
@@ -1,66 +1,66 @@
-<?php\r
-       /**\r
-        * Elgg log browser.\r
-        * \r
-        * @package ElggLogBrowser\r
+<?php
+       /**
+        * Elgg log browser.
+        * 
+        * @package ElggLogBrowser
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.com/
+        */
+
+       require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
+
+       admin_gatekeeper();
+       set_context('admin');
+       // Set admin user for user block
+               set_page_owner($_SESSION['guid']);
+
+       
+       $limit = get_input('limit', 40);
+       $offset = get_input('offset');
+       
+       $search_username = get_input('search_username');
+       if ($search_username) {
+               if ($user = get_user_by_username($search_username)) {
+                       $user = $user->guid;
+               }
+       } else {
+               $user_guid = get_input('user_guid',0);
+               if ($user_guid) {
+                       $user = (int) $user_guid;
+               } else {
+                       $user = "";
+               }
+       }
+       
+       $timelower = get_input('timelower');
+       if ($timelower) $timelower = strtotime($timelower);
+       $timeupper = get_input('timeupper');
+       if ($timeupper) $timeupper = strtotime($timeupper);
+       
+       $title = elgg_view_title(elgg_echo('logbrowser'));
+       
+       // Get log entries
+       $log = get_system_log($user, "", "", "","", $limit, $offset, false, $timeupper, $timelower);
+       $count = get_system_log($user, "", "", "","", $limit, $offset, true, $timeupper, $timelower);
+       $log_entries = array();
+       
+       foreach ($log as $l)
+       {
+               $tmp = new ElggObject();
+               $tmp->subtype = 'logwrapper';
+               $tmp->entry = $l;
+               $log_entries[] = $tmp;
+       }
+       
+       $form = elgg_view('logbrowser/form',array('user_guid' => $user, 'timeupper' => $timeupper, 'timelower' => $timelower));
+       
+       set_context('search');
+       $result = elgg_view_entity_list($log_entries, $count, $offset, $limit, false, false);
+       set_context('admin');
+               
+// Display main admin menu
+       page_draw(elgg_echo('logbrowser'),elgg_view_layout("two_column_left_sidebar", '', $title . $form . $result));
 
-        * @link http://elgg.com/\r
-        */\r
-\r
-       require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");\r
-\r
-       admin_gatekeeper();\r
-       set_context('admin');\r
-       // Set admin user for user block\r
-               set_page_owner($_SESSION['guid']);\r
-\r
-       \r
-       $limit = get_input('limit', 40);\r
-       $offset = get_input('offset');\r
-       \r
-       $search_username = get_input('search_username');\r
-       if ($search_username) {\r
-               if ($user = get_user_by_username($search_username)) {\r
-                       $user = $user->guid;\r
-               }\r
-       } else {\r
-               $user_guid = get_input('user_guid',0);\r
-               if ($user_guid) {\r
-                       $user = (int) $user_guid;\r
-               } else {\r
-                       $user = "";\r
-               }\r
-       }\r
-       \r
-       $timelower = get_input('timelower');\r
-       if ($timelower) $timelower = strtotime($timelower);\r
-       $timeupper = get_input('timeupper');\r
-       if ($timeupper) $timeupper = strtotime($timeupper);\r
-       \r
-       $title = elgg_view_title(elgg_echo('logbrowser'));\r
-       \r
-       // Get log entries\r
-       $log = get_system_log($user, "", "", "","", $limit, $offset, false, $timeupper, $timelower);\r
-       $count = get_system_log($user, "", "", "","", $limit, $offset, true, $timeupper, $timelower);\r
-       $log_entries = array();\r
-       \r
-       foreach ($log as $l)\r
-       {\r
-               $tmp = new ElggObject();\r
-               $tmp->subtype = 'logwrapper';\r
-               $tmp->entry = $l;\r
-               $log_entries[] = $tmp;\r
-       }\r
-       \r
-       $form = elgg_view('logbrowser/form',array('user_guid' => $user, 'timeupper' => $timeupper, 'timelower' => $timelower));\r
-       \r
-       set_context('search');\r
-       $result = elgg_view_entity_list($log_entries, $count, $offset, $limit, false, false);\r
-       set_context('admin');\r
-               \r
-// Display main admin menu\r
-       page_draw(elgg_echo('logbrowser'),elgg_view_layout("two_column_left_sidebar", '', $title . $form . $result));\r
-\r
 ?>
\ No newline at end of file
index a100e7ff7fa6d52acd7b3343a2a965f51e45712b..aa06edd9af84f358e3a40aedc076407bfc309a53 100644 (file)
                 */
        
                        'logbrowser' => 'Log browser',
-                       'logbrowser:browse' => 'Browse system log',\r
-                       'logbrowser:search' => 'Refine results',\r
-                       'logbrowser:user' => 'Username to search by',\r
-                       'logbrowser:starttime' => 'Beginning time (for example "last monday", "1 hour ago")',\r
-                       'logbrowser:endtime' => 'End time',\r
-       \r
-                       'logbrowser:explore' => 'Explore log',\r
+                       'logbrowser:browse' => 'Browse system log',
+                       'logbrowser:search' => 'Refine results',
+                       'logbrowser:user' => 'Username to search by',
+                       'logbrowser:starttime' => 'Beginning time (for example "last monday", "1 hour ago")',
+                       'logbrowser:endtime' => 'End time',
+       
+                       'logbrowser:explore' => 'Explore log',
        
        );
                                        
index 52e1f8617b5c839f8bab4c375adaecf0e3788761..47a78c24309c4dffafbd1b491d164ade9238da00 100644 (file)
                global $CONFIG;
                
                // Register a page handler, so we can have nice URLs
-               register_page_handler('logbrowser','logbrowser_page_handler');\r
-               \r
-               // Extend CSS\r
-               extend_view('css','logbrowser/css');\r
-               \r
-               // Extend context menu with admin logbrowsre link\r
-                       if (isadminloggedin())\r
-                       {\r
-                                extend_view('profile/menu/adminlinks','logbrowser/adminlinks',10000);\r
+               register_page_handler('logbrowser','logbrowser_page_handler');
+               
+               // Extend CSS
+               extend_view('css','logbrowser/css');
+               
+               // Extend context menu with admin logbrowsre link
+                       if (isadminloggedin())
+                       {
+                                extend_view('profile/menu/adminlinks','logbrowser/adminlinks',10000);
                        }
-       }\r
-       \r
-       /**\r
-        * Adding the log browser to the admin menu\r
-        *\r
-        */\r
-       function logbrowser_pagesetup()\r
-       {\r
-               if (get_context() == 'admin' && isadminloggedin()) {\r
-                       global $CONFIG;\r
-                       add_submenu_item(elgg_echo('logbrowser'), $CONFIG->wwwroot . 'pg/logbrowser/');\r
-               }\r
+       }
+       
+       /**
+        * Adding the log browser to the admin menu
+        *
+        */
+       function logbrowser_pagesetup()
+       {
+               if (get_context() == 'admin' && isadminloggedin()) {
+                       global $CONFIG;
+                       add_submenu_item(elgg_echo('logbrowser'), $CONFIG->wwwroot . 'pg/logbrowser/');
+               }
        }
        
        /**
@@ -56,6 +56,6 @@
        
        
        // Initialise log browser
-       register_elgg_event_handler('init','system','logbrowser_init');\r
+       register_elgg_event_handler('init','system','logbrowser_init');
        register_elgg_event_handler('pagesetup','system','logbrowser_pagesetup');
 ?>
\ No newline at end of file
index abe83707d513507276f5f9f0ae90c8dc320d086f..e84e385edb0277d9cdd2bb1dae12beda602761a2 100644 (file)
@@ -1,4 +1,4 @@
-<?php\r
-\r
-?>\r
+<?php
+
+?>
 <a href="<?php echo $vars['url']; ?>mod/logbrowser/?user_guid=<?php echo $vars['entity']->guid; ?>"><?php echo elgg_echo("logbrowser:explore"); ?></a>
\ No newline at end of file
index 2b0c787201c7547b7152700dd912069efaf7ac4a..4a1e40d6af1de5fc6bbf3c7e33ef794b8d2d6884 100644 (file)
@@ -1,66 +1,66 @@
-\r
-<div id="logbrowser_search_area">\r
-<?php\r
-       \r
-       // Time lower limit\r
-\r
-               if ($vars['timelower']) {\r
-                       $lowerval = date('r',$vars['timelower']);\r
-               } else {\r
-                       $lowerval = "";\r
-               }\r
-               if ($vars['timeupper']) {\r
-                       $upperval = date('r',$vars['timeupper']);\r
-               } else {\r
-                       $upperval = "";\r
-               }\r
-               if ($vars['user_guid']) {\r
-                       if ($user = get_entity($vars['user_guid']))\r
-                               $userval = $user->username;\r
-               } else {\r
-                       $userval = "";\r
-               }\r
-               \r
-\r
-               $form = "";\r
-               \r
-               $form .= "<p>" . elgg_echo('logbrowser:user');\r
-               $form .= elgg_view('input/text',array(\r
-                                                                                                               'internalname' => 'search_username',\r
-                                                                                                               'value' => $userval \r
-                                                                                                       )) . "</p>";\r
-               \r
-               $form .= "<p>" . elgg_echo('logbrowser:starttime');\r
-               $form .= elgg_view('input/text',array(\r
-                                                                                                               'internalname' => 'timelower',\r
-                                                                                                               'value' => $lowerval \r
-                                                                                                       )) . "</p>";\r
-\r
-               $form .= "<p>" . elgg_echo('logbrowser:endtime');\r
-               $form .= elgg_view('input/text',array(\r
-                                                                                                               'internalname' => 'timeupper',\r
-                                                                                                               'value' => $upperval\r
-                                                                                                       ))  . "</p>";\r
-               $form .= elgg_view('input/submit',array(\r
-                                                                                                               'value' => elgg_echo('search')\r
-                                                                                                       ));\r
-                                                                                                       \r
-               $wrappedform = elgg_view('input/form',array(\r
-                                                                                                               'body' => $form,\r
-                                                                                                               'method' => 'get',\r
-                                                                                                               'action' => $vars['url'] . "mod/logbrowser/"\r
-                                                                               ));\r
-\r
-               if ($upperval || $lowerval || $userval) {\r
-                       $hidden = "";\r
-               } else {\r
-                       $hidden = "style=\"display:none\"";\r
-               }\r
-                                                                               \r
-?>\r
-\r
-               <div id="logbrowserSearchform" <?php echo $hidden; ?>><?php echo $wrappedform; ?></div>\r
-               <p>\r
-                       <a href="#" onclick="$('#logbrowserSearchform').toggle()"><?php echo elgg_echo('logbrowser:search'); ?></a>\r
-               </p>\r
+
+<div id="logbrowser_search_area">
+<?php
+       
+       // Time lower limit
+
+               if ($vars['timelower']) {
+                       $lowerval = date('r',$vars['timelower']);
+               } else {
+                       $lowerval = "";
+               }
+               if ($vars['timeupper']) {
+                       $upperval = date('r',$vars['timeupper']);
+               } else {
+                       $upperval = "";
+               }
+               if ($vars['user_guid']) {
+                       if ($user = get_entity($vars['user_guid']))
+                               $userval = $user->username;
+               } else {
+                       $userval = "";
+               }
+               
+
+               $form = "";
+               
+               $form .= "<p>" . elgg_echo('logbrowser:user');
+               $form .= elgg_view('input/text',array(
+                                                                                                               'internalname' => 'search_username',
+                                                                                                               'value' => $userval 
+                                                                                                       )) . "</p>";
+               
+               $form .= "<p>" . elgg_echo('logbrowser:starttime');
+               $form .= elgg_view('input/text',array(
+                                                                                                               'internalname' => 'timelower',
+                                                                                                               'value' => $lowerval 
+                                                                                                       )) . "</p>";
+
+               $form .= "<p>" . elgg_echo('logbrowser:endtime');
+               $form .= elgg_view('input/text',array(
+                                                                                                               'internalname' => 'timeupper',
+                                                                                                               'value' => $upperval
+                                                                                                       ))  . "</p>";
+               $form .= elgg_view('input/submit',array(
+                                                                                                               'value' => elgg_echo('search')
+                                                                                                       ));
+                                                                                                       
+               $wrappedform = elgg_view('input/form',array(
+                                                                                                               'body' => $form,
+                                                                                                               'method' => 'get',
+                                                                                                               'action' => $vars['url'] . "mod/logbrowser/"
+                                                                               ));
+
+               if ($upperval || $lowerval || $userval) {
+                       $hidden = "";
+               } else {
+                       $hidden = "style=\"display:none\"";
+               }
+                                                                               
+?>
+
+               <div id="logbrowserSearchform" <?php echo $hidden; ?>><?php echo $wrappedform; ?></div>
+               <p>
+                       <a href="#" onclick="$('#logbrowserSearchform').toggle()"><?php echo elgg_echo('logbrowser:search'); ?></a>
+               </p>
        </div>
\ No newline at end of file
index bae5d4240728c3cb7518a2dfaf348b8f7dbf2b78..923ce7c5289b2a787ffc30f78d6d3bd43eaea743 100644 (file)
@@ -1,50 +1,50 @@
-<?php\r
-       /**\r
-        * Elgg log browser.\r
-        * \r
-        * @package ElggLogBrowser\r
+<?php
+       /**
+        * Elgg log browser.
+        * 
+        * @package ElggLogBrowser
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
 
-        * @link http://elgg.com/\r
-        */\r
-\r
-       $entry = $vars['entity']->entry;\r
-       \r
-       $by = get_entity($entry->performed_by_guid);\r
-       $object = get_object_from_log_entry($entry->id);\r
-       \r
-       if (is_callable(array($object, 'getURL')))\r
-               $obj_url = $object->getURL();\r
-       \r
-       //echo elgg_view_listing($icon, $info);\r
-?>\r
-       <table class="log_entry">\r
-               <tr>\r
-                       <td class="log_entry_time">\r
-                       <?php echo date('r', $entry->time_created ); ?>\r
-                       </td>\r
-                       <td class="log_entry_user">\r
-                       <?php if ($by) {\r
-                                                               echo "<a href=\"".$by->getURL()."\">{$by->name}</a>";\r
-                                                               echo " <a href=\"?user_guid={$by->guid}\">" . $by->guid . "</a>"; \r
-                                                       } \r
-                                                       else echo "&nbsp;"; ?>\r
-                       <td>\r
-                       <td class="log_entry_item">\r
-                       <?php \r
-                                       if ($obj_url) echo "<a href=\"$obj_url\">";\r
-                                       echo "{$entry->object_class}";\r
-                                       if ($obj_url) echo "</a>";\r
-                                       echo " " . $entry->object_id;\r
-                                       \r
-                       ?>\r
-                       </td>\r
-                       <td class="log_entry_action">\r
-                               <div class="log_entry_action_<?php echo $entry->event; ?>">\r
-                                       <?php echo elgg_echo($entry->event); ?>\r
-                               </div>\r
-                       </td>\r
-               </tr>\r
-       </table>\r
+        * @link http://elgg.com/
+        */
+
+       $entry = $vars['entity']->entry;
+       
+       $by = get_entity($entry->performed_by_guid);
+       $object = get_object_from_log_entry($entry->id);
+       
+       if (is_callable(array($object, 'getURL')))
+               $obj_url = $object->getURL();
+       
+       //echo elgg_view_listing($icon, $info);
+?>
+       <table class="log_entry">
+               <tr>
+                       <td class="log_entry_time">
+                       <?php echo date('r', $entry->time_created ); ?>
+                       </td>
+                       <td class="log_entry_user">
+                       <?php if ($by) {
+                                                               echo "<a href=\"".$by->getURL()."\">{$by->name}</a>";
+                                                               echo " <a href=\"?user_guid={$by->guid}\">" . $by->guid . "</a>"; 
+                                                       } 
+                                                       else echo "&nbsp;"; ?>
+                       <td>
+                       <td class="log_entry_item">
+                       <?php 
+                                       if ($obj_url) echo "<a href=\"$obj_url\">";
+                                       echo "{$entry->object_class}";
+                                       if ($obj_url) echo "</a>";
+                                       echo " " . $entry->object_id;
+                                       
+                       ?>
+                       </td>
+                       <td class="log_entry_action">
+                               <div class="log_entry_action_<?php echo $entry->event; ?>">
+                                       <?php echo elgg_echo($entry->event); ?>
+                               </div>
+                       </td>
+               </tr>
+       </table>
        
\ No newline at end of file
index fc6f5cc14feadab737d54360ce8fefaadaa62d30..583415a5dd8c9302dca9e8f0268b0f94b237dfe1 100644 (file)
@@ -27,8 +27,8 @@
                if (($object) && ($object instanceof ElggUser))
                {
                        uservalidationbyemail_request_validation($object->guid);
-               }\r
-               \r
+               }
+               
                return true;
        }
        
index 7bf02273a958fe8469b57cf8267bdbedf42329ac..736dfe4c79a39a74d90ad67f9407a96633212005 100644 (file)
@@ -9,17 +9,17 @@
         */
 
        // Get the Elgg framework
-               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");\r
-               \r
-               if (!page_owner())\r
-                       set_page_owner($_SESSION['guid']);\r
-                       \r
-       // Make sure we don't open a security hole ...\r
-               if ((!page_owner_entity()) || (!page_owner_entity()->canEdit())) {\r
-                       set_page_owner($_SESSION['guid']);\r
-               }\r
-               \r
+               require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+               
+               if (!page_owner())
+                       set_page_owner($_SESSION['guid']);
+                       
+       // Make sure we don't open a security hole ...
+               if ((!page_owner_entity()) || (!page_owner_entity()->canEdit())) {
+                       set_page_owner($_SESSION['guid']);
+               }
+               
        // Forward to the user settings
-               forward('pg/settings/user/' . page_owner_entity()->username . "/");\r
+               forward('pg/settings/user/' . page_owner_entity()->username . "/");
                
 ?>
\ No newline at end of file
index bb5eb2e03775386824cf1a346e7fb66ddb79a5c2..0913ddb3e1aa26c54105846a0dee9bfbca1d2968 100644 (file)
@@ -1,71 +1,71 @@
-<?php\r
-\r
-       /**\r
-        * Simple cache viewer\r
-        * Bypasses the engine to view simple cached CSS views.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-        * @author Curverider Ltd\r
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Get DB settings, connect\r
-               require_once(dirname(dirname(__FILE__)). '/engine/settings.php');\r
-               \r
-               global $CONFIG, $viewinput, $override;\r
-               if (!isset($override)) $override = false;\r
-               \r
-               $contents = '';\r
-               if (!isset($viewinput)) $viewinput = $_GET;\r
-               \r
-               if ($mysql_dblink = @mysql_connect($CONFIG->dbhost,$CONFIG->dbuser,$CONFIG->dbpass, true)) {\r
-\r
-                       $view = $viewinput['view'];\r
-                       $viewtype = $viewinput['viewtype'];\r
-                       if (empty($viewtype)) $viewtype = 'default';\r
-                       \r
-                       if (@mysql_select_db($CONFIG->dbname,$mysql_dblink)) {\r
-                               // get dataroot and simplecache_enabled in one select for efficiency\r
-                               $simplecache_enabled = true;\r
-                               if (!isset($dataroot)) {\r
-                                       if ($result = mysql_query("select name, value from {$CONFIG->dbprefix}datalists where name in ('dataroot','simplecache_enabled')",$mysql_dblink)) {\r
-                                               $row = mysql_fetch_object($result);\r
-                                               \r
-                                               while ($row) {\r
-                                                       if ($row->name == 'dataroot') {\r
-                                                               $dataroot = $row->value;\r
-                                                       } else if ($row->name == 'simplecache_enabled') {\r
-                                                               $simplecache_enabled = $row->value;\r
-                                                       }\r
-                                                       $row = mysql_fetch_object($result);\r
-                                               }\r
-                                       }\r
-                               }\r
-                               \r
-                               if ($simplecache_enabled || $override) {\r
-                                       $filename = $dataroot . 'views_simplecache/' . md5($viewtype . $view);\r
-                                       if (file_exists($filename)) {\r
-                                               $contents = file_get_contents($filename);\r
-                                               header("Content-Length: " . strlen($contents));\r
+<?php
+
+       /**
+        * Simple cache viewer
+        * Bypasses the engine to view simple cached CSS views.
+        * 
+        * @package Elgg
+        * @subpackage Core
+        * @author Curverider Ltd
+        * @link http://elgg.org/
+        */
+
+       // Get DB settings, connect
+               require_once(dirname(dirname(__FILE__)). '/engine/settings.php');
+               
+               global $CONFIG, $viewinput, $override;
+               if (!isset($override)) $override = false;
+               
+               $contents = '';
+               if (!isset($viewinput)) $viewinput = $_GET;
+               
+               if ($mysql_dblink = @mysql_connect($CONFIG->dbhost,$CONFIG->dbuser,$CONFIG->dbpass, true)) {
+
+                       $view = $viewinput['view'];
+                       $viewtype = $viewinput['viewtype'];
+                       if (empty($viewtype)) $viewtype = 'default';
+                       
+                       if (@mysql_select_db($CONFIG->dbname,$mysql_dblink)) {
+                               // get dataroot and simplecache_enabled in one select for efficiency
+                               $simplecache_enabled = true;
+                               if (!isset($dataroot)) {
+                                       if ($result = mysql_query("select name, value from {$CONFIG->dbprefix}datalists where name in ('dataroot','simplecache_enabled')",$mysql_dblink)) {
+                                               $row = mysql_fetch_object($result);
+                                               
+                                               while ($row) {
+                                                       if ($row->name == 'dataroot') {
+                                                               $dataroot = $row->value;
+                                                       } else if ($row->name == 'simplecache_enabled') {
+                                                               $simplecache_enabled = $row->value;
+                                                       }
+                                                       $row = mysql_fetch_object($result);
+                                               }
+                                       }
+                               }
+                               
+                               if ($simplecache_enabled || $override) {
+                                       $filename = $dataroot . 'views_simplecache/' . md5($viewtype . $view);
+                                       if (file_exists($filename)) {
+                                               $contents = file_get_contents($filename);
+                                               header("Content-Length: " . strlen($contents));
                                         } else {
                                                mysql_query("INSERT into {$CONFIG->dbprefix}datalists set name = 'simplecache_lastupdate', value = '0' ON DUPLICATE KEY UPDATE value='0'");
-                       \r
-                                               echo ''; exit;\r
-                                        }\r
-                               } else {\r
-                                       mysql_close($mysql_dblink);\r
-                                       require_once(dirname(dirname(__FILE__)) . "/engine/start.php");    \r
-                                       $contents = elgg_view($view);\r
-                                       header("Content-Length: " . strlen($contents));\r
-                               }\r
-                       }\r
+                       
+                                               echo ''; exit;
+                                        }
+                               } else {
+                                       mysql_close($mysql_dblink);
+                                       require_once(dirname(dirname(__FILE__)) . "/engine/start.php");    
+                                       $contents = elgg_view($view);
+                                       header("Content-Length: " . strlen($contents));
+                               }
+                       }
                }
                
                $split_output = str_split($contents, 1024);
 
        foreach($split_output as $chunk)
-               echo $chunk; \r
+               echo $chunk; 
+
 
-\r
 ?>
index e1b297d83c08196030d835f594884e23f1c6277d..8de74ad5485c15a0f2d923ed17c62c97bb2567a6 100644 (file)
         * @link http://elgg.org/
         */
 
-       // Include elgg engine\r
-       define('upgrading','upgrading');\r
+       // Include elgg engine
+       define('upgrading','upgrading');
        define('externalpage',true);
-       require_once(dirname(__FILE__) . "/engine/start.php");\r
-       \r
+       require_once(dirname(__FILE__) . "/engine/start.php");
+       
        if (get_input('upgrade') == 'upgrade') {
                if (version_upgrade_check()) {
                        version_upgrade();
-               }\r
+               }
                datalist_set('simplecache_lastupdate',0);
                
-               elgg_filepath_cache_reset();\r
-       } else {\r
-               global $CONFIG;\r
-               echo elgg_view('settings/upgrading');\r
-               exit;\r
+               elgg_filepath_cache_reset();
+       } else {
+               global $CONFIG;
+               echo elgg_view('settings/upgrading');
+               exit;
        }
        
        forward();
index 2eb92ec17fd1116b03699ffd08ef73aa5f7d94cc..664c3c066e5c97045695b71b11ba732f5bfb7bbd 100644 (file)
-// ===================================================================\r
-// Author: Matt Kruse <matt@mattkruse.com>\r
-// WWW: http://www.mattkruse.com/\r
-//\r
-// NOTICE: You may use this code for any purpose, commercial or\r
-// private, without any further permission from the author. You may\r
-// remove this notice from your final code if you wish, however it is\r
-// appreciated by the author if at least my web site address is kept.\r
-//\r
-// You may *NOT* re-distribute this code in any way except through its\r
-// use. That means, you can include it in your product, or your web\r
-// site, or any other form where the code is actually being used. You\r
-// may not put the plain javascript up on your site for download or\r
-// include it in your javascript libraries for download. \r
-// If you wish to share this code with others, please just point them\r
-// to the URL instead.\r
-// Please DO NOT link directly to my .js files from your site. Copy\r
-// the files to your server and use them there. Thank you.\r
-// ===================================================================\r
-\r
-\r
-/* SOURCE FILE: AnchorPosition.js */\r
-\r
-/* \r
-AnchorPosition.js\r
-Author: Matt Kruse\r
-Last modified: 10/11/02\r
-\r
-DESCRIPTION: These functions find the position of an <A> tag in a document,\r
-so other elements can be positioned relative to it.\r
-\r
-COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small\r
-positioning errors - usually with Window positioning - occur on the \r
-Macintosh platform.\r
-\r
-FUNCTIONS:\r
-getAnchorPosition(anchorname)\r
-  Returns an Object() having .x and .y properties of the pixel coordinates\r
-  of the upper-left corner of the anchor. Position is relative to the PAGE.\r
-\r
-getAnchorWindowPosition(anchorname)\r
-  Returns an Object() having .x and .y properties of the pixel coordinates\r
-  of the upper-left corner of the anchor, relative to the WHOLE SCREEN.\r
-\r
-NOTES:\r
-\r
-1) For popping up separate browser windows, use getAnchorWindowPosition. \r
-   Otherwise, use getAnchorPosition\r
-\r
-2) Your anchor tag MUST contain both NAME and ID attributes which are the \r
-   same. For example:\r
-   <A NAME="test" ID="test"> </A>\r
-\r
-3) There must be at least a space between <A> </A> for IE5.5 to see the \r
-   anchor tag correctly. Do not do <A></A> with no space.\r
-*/ \r
-\r
-// getAnchorPosition(anchorname)\r
-//   This function returns an object having .x and .y properties which are the coordinates\r
-//   of the named anchor, relative to the page.\r
-function getAnchorPosition(anchorname) {\r
-       // This function will return an Object with x and y properties\r
-       var useWindow=false;\r
-       var coordinates=new Object();\r
-       var x=0,y=0;\r
-       // Browser capability sniffing\r
-       var use_gebi=false, use_css=false, use_layers=false;\r
-       if (document.getElementById) { use_gebi=true; }\r
-       else if (document.all) { use_css=true; }\r
-       else if (document.layers) { use_layers=true; }\r
-       // Logic to find position\r
-       if (use_gebi && document.all) {\r
-               x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);\r
-               y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);\r
-               }\r
-       else if (use_gebi) {\r
-               var o=document.getElementById(anchorname);\r
-               x=AnchorPosition_getPageOffsetLeft(o);\r
-               y=AnchorPosition_getPageOffsetTop(o);\r
-               }\r
-       else if (use_css) {\r
-               x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);\r
-               y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);\r
-               }\r
-       else if (use_layers) {\r
-               var found=0;\r
-               for (var i=0; i<document.anchors.length; i++) {\r
-                       if (document.anchors[i].name==anchorname) { found=1; break; }\r
-                       }\r
-               if (found==0) {\r
-                       coordinates.x=0; coordinates.y=0; return coordinates;\r
-                       }\r
-               x=document.anchors[i].x;\r
-               y=document.anchors[i].y;\r
-               }\r
-       else {\r
-               coordinates.x=0; coordinates.y=0; return coordinates;\r
-               }\r
-       coordinates.x=x;\r
-       coordinates.y=y;\r
-       return coordinates;\r
-       }\r
-\r
-// getAnchorWindowPosition(anchorname)\r
-//   This function returns an object having .x and .y properties which are the coordinates\r
-//   of the named anchor, relative to the window\r
-function getAnchorWindowPosition(anchorname) {\r
-       var coordinates=getAnchorPosition(anchorname);\r
-       var x=0;\r
-       var y=0;\r
-       if (document.getElementById) {\r
-               if (isNaN(window.screenX)) {\r
-                       x=coordinates.x-document.body.scrollLeft+window.screenLeft;\r
-                       y=coordinates.y-document.body.scrollTop+window.screenTop;\r
-                       }\r
-               else {\r
-                       x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;\r
-                       y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;\r
-                       }\r
-               }\r
-       else if (document.all) {\r
-               x=coordinates.x-document.body.scrollLeft+window.screenLeft;\r
-               y=coordinates.y-document.body.scrollTop+window.screenTop;\r
-               }\r
-       else if (document.layers) {\r
-               x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;\r
-               y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;\r
-               }\r
-       coordinates.x=x;\r
-       coordinates.y=y;\r
-       return coordinates;\r
-       }\r
-\r
-// Functions for IE to get position of an object\r
-function AnchorPosition_getPageOffsetLeft (el) {\r
-       var ol=el.offsetLeft;\r
-       while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }\r
-       return ol;\r
-       }\r
-function AnchorPosition_getWindowOffsetLeft (el) {\r
-       return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;\r
-       }       \r
-function AnchorPosition_getPageOffsetTop (el) {\r
-       var ot=el.offsetTop;\r
-       while((el=el.offsetParent) != null) { ot += el.offsetTop; }\r
-       return ot;\r
-       }\r
-function AnchorPosition_getWindowOffsetTop (el) {\r
-       return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;\r
-       }\r
-\r
-/* SOURCE FILE: date.js */\r
-\r
-// HISTORY\r
-// ------------------------------------------------------------------\r
-// May 17, 2003: Fixed bug in parseDate() for dates <1970\r
-// March 11, 2003: Added parseDate() function\r
-// March 11, 2003: Added "NNN" formatting option. Doesn't match up\r
-//                 perfectly with SimpleDateFormat formats, but \r
-//                 backwards-compatability was required.\r
-\r
-// ------------------------------------------------------------------\r
-// These functions use the same 'format' strings as the \r
-// java.text.SimpleDateFormat class, with minor exceptions.\r
-// The format string consists of the following abbreviations:\r
-// \r
-// Field        | Full Form          | Short Form\r
-// -------------+--------------------+-----------------------\r
-// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)\r
-// Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)\r
-//              | NNN (abbr.)        |\r
-// Day of Month | dd (2 digits)      | d (1 or 2 digits)\r
-// Day of Week  | EE (name)          | E (abbr)\r
-// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)\r
-// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)\r
-// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)\r
-// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)\r
-// Minute       | mm (2 digits)      | m (1 or 2 digits)\r
-// Second       | ss (2 digits)      | s (1 or 2 digits)\r
-// AM/PM        | a                  |\r
-//\r
-// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!\r
-// Examples:\r
-//  "MMM d, y" matches: January 01, 2000\r
-//                      Dec 1, 1900\r
-//                      Nov 20, 00\r
-//  "M/d/yy"   matches: 01/20/00\r
-//                      9/2/00\r
-//  "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"\r
-// ------------------------------------------------------------------\r
-\r
-var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');\r
-var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');\r
-function LZ(x) {return(x<0||x>9?"":"0")+x}\r
-\r
-// ------------------------------------------------------------------\r
-// isDate ( date_string, format_string )\r
-// Returns true if date string matches format of format string and\r
-// is a valid date. Else returns false.\r
-// It is recommended that you trim whitespace around the value before\r
-// passing it to this function, as whitespace is NOT ignored!\r
-// ------------------------------------------------------------------\r
-function isDate(val,format) {\r
-       var date=getDateFromFormat(val,format);\r
-       if (date==0) { return false; }\r
-       return true;\r
-       }\r
-\r
-// -------------------------------------------------------------------\r
-// compareDates(date1,date1format,date2,date2format)\r
-//   Compare two date strings to see which is greater.\r
-//   Returns:\r
-//   1 if date1 is greater than date2\r
-//   0 if date2 is greater than date1 of if they are the same\r
-//  -1 if either of the dates is in an invalid format\r
-// -------------------------------------------------------------------\r
-function compareDates(date1,dateformat1,date2,dateformat2) {\r
-       var d1=getDateFromFormat(date1,dateformat1);\r
-       var d2=getDateFromFormat(date2,dateformat2);\r
-       if (d1==0 || d2==0) {\r
-               return -1;\r
-               }\r
-       else if (d1 > d2) {\r
-               return 1;\r
-               }\r
-       return 0;\r
-       }\r
-\r
-// ------------------------------------------------------------------\r
-// formatDate (date_object, format)\r
-// Returns a date in the output format specified.\r
-// The format string uses the same abbreviations as in getDateFromFormat()\r
-// ------------------------------------------------------------------\r
-function formatDate(date,format) {\r
-       format=format+"";\r
-       var result="";\r
-       var i_format=0;\r
-       var c="";\r
-       var token="";\r
-       var y=date.getYear()+"";\r
-       var M=date.getMonth()+1;\r
-       var d=date.getDate();\r
-       var E=date.getDay();\r
-       var H=date.getHours();\r
-       var m=date.getMinutes();\r
-       var s=date.getSeconds();\r
-       var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;\r
-       // Convert real date parts into formatted versions\r
-       var value=new Object();\r
-       if (y.length < 4) {y=""+(y-0+1900);}\r
-       value["y"]=""+y;\r
-       value["yyyy"]=y;\r
-       value["yy"]=y.substring(2,4);\r
-       value["M"]=M;\r
-       value["MM"]=LZ(M);\r
-       value["MMM"]=MONTH_NAMES[M-1];\r
-       value["NNN"]=MONTH_NAMES[M+11];\r
-       value["d"]=d;\r
-       value["dd"]=LZ(d);\r
-       value["E"]=DAY_NAMES[E+7];\r
-       value["EE"]=DAY_NAMES[E];\r
-       value["H"]=H;\r
-       value["HH"]=LZ(H);\r
-       if (H==0){value["h"]=12;}\r
-       else if (H>12){value["h"]=H-12;}\r
-       else {value["h"]=H;}\r
-       value["hh"]=LZ(value["h"]);\r
-       if (H>11){value["K"]=H-12;} else {value["K"]=H;}\r
-       value["k"]=H+1;\r
-       value["KK"]=LZ(value["K"]);\r
-       value["kk"]=LZ(value["k"]);\r
-       if (H > 11) { value["a"]="PM"; }\r
-       else { value["a"]="AM"; }\r
-       value["m"]=m;\r
-       value["mm"]=LZ(m);\r
-       value["s"]=s;\r
-       value["ss"]=LZ(s);\r
-       while (i_format < format.length) {\r
-               c=format.charAt(i_format);\r
-               token="";\r
-               while ((format.charAt(i_format)==c) && (i_format < format.length)) {\r
-                       token += format.charAt(i_format++);\r
-                       }\r
-               if (value[token] != null) { result=result + value[token]; }\r
-               else { result=result + token; }\r
-               }\r
-       return result;\r
-       }\r
-       \r
-// ------------------------------------------------------------------\r
-// Utility functions for parsing in getDateFromFormat()\r
-// ------------------------------------------------------------------\r
-function _isInteger(val) {\r
-       var digits="1234567890";\r
-       for (var i=0; i < val.length; i++) {\r
-               if (digits.indexOf(val.charAt(i))==-1) { return false; }\r
-               }\r
-       return true;\r
-       }\r
-function _getInt(str,i,minlength,maxlength) {\r
-       for (var x=maxlength; x>=minlength; x--) {\r
-               var token=str.substring(i,i+x);\r
-               if (token.length < minlength) { return null; }\r
-               if (_isInteger(token)) { return token; }\r
-               }\r
-       return null;\r
-       }\r
-       \r
-// ------------------------------------------------------------------\r
-// getDateFromFormat( date_string , format_string )\r
-//\r
-// This function takes a date string and a format string. It matches\r
-// If the date string matches the format string, it returns the \r
-// getTime() of the date. If it does not match, it returns 0.\r
-// ------------------------------------------------------------------\r
-function getDateFromFormat(val,format) {\r
-       val=val+"";\r
-       format=format+"";\r
-       var i_val=0;\r
-       var i_format=0;\r
-       var c="";\r
-       var token="";\r
-       var token2="";\r
-       var x,y;\r
-       var now=new Date();\r
-       var year=now.getYear();\r
-       var month=now.getMonth()+1;\r
-       var date=1;\r
-       var hh=now.getHours();\r
-       var mm=now.getMinutes();\r
-       var ss=now.getSeconds();\r
-       var ampm="";\r
-       \r
-       while (i_format < format.length) {\r
-               // Get next token from format string\r
-               c=format.charAt(i_format);\r
-               token="";\r
-               while ((format.charAt(i_format)==c) && (i_format < format.length)) {\r
-                       token += format.charAt(i_format++);\r
-                       }\r
-               // Extract contents of value based on format token\r
-               if (token=="yyyy" || token=="yy" || token=="y") {\r
-                       if (token=="yyyy") { x=4;y=4; }\r
-                       if (token=="yy")   { x=2;y=2; }\r
-                       if (token=="y")    { x=2;y=4; }\r
-                       year=_getInt(val,i_val,x,y);\r
-                       if (year==null) { return 0; }\r
-                       i_val += year.length;\r
-                       if (year.length==2) {\r
-                               if (year > 70) { year=1900+(year-0); }\r
-                               else { year=2000+(year-0); }\r
-                               }\r
-                       }\r
-               else if (token=="MMM"||token=="NNN"){\r
-                       month=0;\r
-                       for (var i=0; i<MONTH_NAMES.length; i++) {\r
-                               var month_name=MONTH_NAMES[i];\r
-                               if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {\r
-                                       if (token=="MMM"||(token=="NNN"&&i>11)) {\r
-                                               month=i+1;\r
-                                               if (month>12) { month -= 12; }\r
-                                               i_val += month_name.length;\r
-                                               break;\r
-                                               }\r
-                                       }\r
-                               }\r
-                       if ((month < 1)||(month>12)){return 0;}\r
-                       }\r
-               else if (token=="EE"||token=="E"){\r
-                       for (var i=0; i<DAY_NAMES.length; i++) {\r
-                               var day_name=DAY_NAMES[i];\r
-                               if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {\r
-                                       i_val += day_name.length;\r
-                                       break;\r
-                                       }\r
-                               }\r
-                       }\r
-               else if (token=="MM"||token=="M") {\r
-                       month=_getInt(val,i_val,token.length,2);\r
-                       if(month==null||(month<1)||(month>12)){return 0;}\r
-                       i_val+=month.length;}\r
-               else if (token=="dd"||token=="d") {\r
-                       date=_getInt(val,i_val,token.length,2);\r
-                       if(date==null||(date<1)||(date>31)){return 0;}\r
-                       i_val+=date.length;}\r
-               else if (token=="hh"||token=="h") {\r
-                       hh=_getInt(val,i_val,token.length,2);\r
-                       if(hh==null||(hh<1)||(hh>12)){return 0;}\r
-                       i_val+=hh.length;}\r
-               else if (token=="HH"||token=="H") {\r
-                       hh=_getInt(val,i_val,token.length,2);\r
-                       if(hh==null||(hh<0)||(hh>23)){return 0;}\r
-                       i_val+=hh.length;}\r
-               else if (token=="KK"||token=="K") {\r
-                       hh=_getInt(val,i_val,token.length,2);\r
-                       if(hh==null||(hh<0)||(hh>11)){return 0;}\r
-                       i_val+=hh.length;}\r
-               else if (token=="kk"||token=="k") {\r
-                       hh=_getInt(val,i_val,token.length,2);\r
-                       if(hh==null||(hh<1)||(hh>24)){return 0;}\r
-                       i_val+=hh.length;hh--;}\r
-               else if (token=="mm"||token=="m") {\r
-                       mm=_getInt(val,i_val,token.length,2);\r
-                       if(mm==null||(mm<0)||(mm>59)){return 0;}\r
-                       i_val+=mm.length;}\r
-               else if (token=="ss"||token=="s") {\r
-                       ss=_getInt(val,i_val,token.length,2);\r
-                       if(ss==null||(ss<0)||(ss>59)){return 0;}\r
-                       i_val+=ss.length;}\r
-               else if (token=="a") {\r
-                       if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}\r
-                       else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}\r
-                       else {return 0;}\r
-                       i_val+=2;}\r
-               else {\r
-                       if (val.substring(i_val,i_val+token.length)!=token) {return 0;}\r
-                       else {i_val+=token.length;}\r
-                       }\r
-               }\r
-       // If there are any trailing characters left in the value, it doesn't match\r
-       if (i_val != val.length) { return 0; }\r
-       // Is date valid for month?\r
-       if (month==2) {\r
-               // Check for leap year\r
-               if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year\r
-                       if (date > 29){ return 0; }\r
-                       }\r
-               else { if (date > 28) { return 0; } }\r
-               }\r
-       if ((month==4)||(month==6)||(month==9)||(month==11)) {\r
-               if (date > 30) { return 0; }\r
-               }\r
-       // Correct hours value\r
-       if (hh<12 && ampm=="PM") { hh=hh-0+12; }\r
-       else if (hh>11 && ampm=="AM") { hh-=12; }\r
-       var newdate=new Date(year,month-1,date,hh,mm,ss);\r
-       return newdate.getTime();\r
-       }\r
-\r
-// ------------------------------------------------------------------\r
-// parseDate( date_string [, prefer_euro_format] )\r
-//\r
-// This function takes a date string and tries to match it to a\r
-// number of possible date formats to get the value. It will try to\r
-// match against the following international formats, in this order:\r
-// y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d\r
-// M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d\r
-// d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M\r
-// A second argument may be passed to instruct the method to search\r
-// for formats like d/M/y (european format) before M/d/y (American).\r
-// Returns a Date object or null if no patterns match.\r
-// ------------------------------------------------------------------\r
-function parseDate(val) {\r
-       var preferEuro=(arguments.length==2)?arguments[1]:false;\r
-       generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');\r
-       monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');\r
-       dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');\r
-       var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');\r
-       var d=null;\r
-       for (var i=0; i<checkList.length; i++) {\r
-               var l=window[checkList[i]];\r
-               for (var j=0; j<l.length; j++) {\r
-                       d=getDateFromFormat(val,l[j]);\r
-                       if (d!=0) { return new Date(d); }\r
-                       }\r
-               }\r
-       return null;\r
-       }\r
-\r
-/* SOURCE FILE: PopupWindow.js */\r
-\r
-/* \r
-PopupWindow.js\r
-Author: Matt Kruse\r
-Last modified: 02/16/04\r
-\r
-DESCRIPTION: This object allows you to easily and quickly popup a window\r
-in a certain place. The window can either be a DIV or a separate browser\r
-window.\r
-\r
-COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small\r
-positioning errors - usually with Window positioning - occur on the \r
-Macintosh platform. Due to bugs in Netscape 4.x, populating the popup \r
-window with <STYLE> tags may cause errors.\r
-\r
-USAGE:\r
-// Create an object for a WINDOW popup\r
-var win = new PopupWindow(); \r
-\r
-// Create an object for a DIV window using the DIV named 'mydiv'\r
-var win = new PopupWindow('mydiv'); \r
-\r
-// Set the window to automatically hide itself when the user clicks \r
-// anywhere else on the page except the popup\r
-win.autoHide(); \r
-\r
-// Show the window relative to the anchor name passed in\r
-win.showPopup(anchorname);\r
-\r
-// Hide the popup\r
-win.hidePopup();\r
-\r
-// Set the size of the popup window (only applies to WINDOW popups\r
-win.setSize(width,height);\r
-\r
-// Populate the contents of the popup window that will be shown. If you \r
-// change the contents while it is displayed, you will need to refresh()\r
-win.populate(string);\r
-\r
-// set the URL of the window, rather than populating its contents\r
-// manually\r
-win.setUrl("http://www.site.com/");\r
-\r
-// Refresh the contents of the popup\r
-win.refresh();\r
-\r
-// Specify how many pixels to the right of the anchor the popup will appear\r
-win.offsetX = 50;\r
-\r
-// Specify how many pixels below the anchor the popup will appear\r
-win.offsetY = 100;\r
-\r
-NOTES:\r
-1) Requires the functions in AnchorPosition.js\r
-\r
-2) Your anchor tag MUST contain both NAME and ID attributes which are the \r
-   same. For example:\r
-   <A NAME="test" ID="test"> </A>\r
-\r
-3) There must be at least a space between <A> </A> for IE5.5 to see the \r
-   anchor tag correctly. Do not do <A></A> with no space.\r
-\r
-4) When a PopupWindow object is created, a handler for 'onmouseup' is\r
-   attached to any event handler you may have already defined. Do NOT define\r
-   an event handler for 'onmouseup' after you define a PopupWindow object or\r
-   the autoHide() will not work correctly.\r
-*/ \r
-\r
-// Set the position of the popup window based on the anchor\r
-function PopupWindow_getXYPosition(anchorname) {\r
-       var coordinates;\r
-       if (this.type == "WINDOW") {\r
-               coordinates = getAnchorWindowPosition(anchorname);\r
-               }\r
-       else {\r
-               coordinates = getAnchorPosition(anchorname);\r
-               }\r
-       this.x = coordinates.x;\r
-       this.y = coordinates.y;\r
-       }\r
-// Set width/height of DIV/popup window\r
-function PopupWindow_setSize(width,height) {\r
-       this.width = width;\r
-       this.height = height;\r
-       }\r
-// Fill the window with contents\r
-function PopupWindow_populate(contents) {\r
-       this.contents = contents;\r
-       this.populated = false;\r
-       }\r
-// Set the URL to go to\r
-function PopupWindow_setUrl(url) {\r
-       this.url = url;\r
-       }\r
-// Set the window popup properties\r
-function PopupWindow_setWindowProperties(props) {\r
-       this.windowProperties = props;\r
-       }\r
-// Refresh the displayed contents of the popup\r
-function PopupWindow_refresh() {\r
-       if (this.divName != null) {\r
-               // refresh the DIV object\r
-               if (this.use_gebi) {\r
-                       document.getElementById(this.divName).innerHTML = this.contents;\r
-                       }\r
-               else if (this.use_css) { \r
-                       document.all[this.divName].innerHTML = this.contents;\r
-                       }\r
-               else if (this.use_layers) { \r
-                       var d = document.layers[this.divName]; \r
-                       d.document.open();\r
-                       d.document.writeln(this.contents);\r
-                       d.document.close();\r
-                       }\r
-               }\r
-       else {\r
-               if (this.popupWindow != null && !this.popupWindow.closed) {\r
-                       if (this.url!="") {\r
-                               this.popupWindow.location.href=this.url;\r
-                               }\r
-                       else {\r
-                               this.popupWindow.document.open();\r
-                               this.popupWindow.document.writeln(this.contents);\r
-                               this.popupWindow.document.close();\r
-                       }\r
-                       this.popupWindow.focus();\r
-                       }\r
-               }\r
-       }\r
-// Position and show the popup, relative to an anchor object\r
-function PopupWindow_showPopup(anchorname) {\r
-       this.getXYPosition(anchorname);\r
-       this.x += this.offsetX;\r
-       this.y += this.offsetY;\r
-       if (!this.populated && (this.contents != "")) {\r
-               this.populated = true;\r
-               this.refresh();\r
-               }\r
-       if (this.divName != null) {\r
-               // Show the DIV object\r
-               if (this.use_gebi) {\r
-                       document.getElementById(this.divName).style.left = this.x + "px";\r
-                       document.getElementById(this.divName).style.top = this.y + "px";\r
-                       document.getElementById(this.divName).style.visibility = "visible";\r
-                       }\r
-               else if (this.use_css) {\r
-                       document.all[this.divName].style.left = this.x;\r
-                       document.all[this.divName].style.top = this.y;\r
-                       document.all[this.divName].style.visibility = "visible";\r
-                       }\r
-               else if (this.use_layers) {\r
-                       document.layers[this.divName].left = this.x;\r
-                       document.layers[this.divName].top = this.y;\r
-                       document.layers[this.divName].visibility = "visible";\r
-                       }\r
-               }\r
-       else {\r
-               if (this.popupWindow == null || this.popupWindow.closed) {\r
-                       // If the popup window will go off-screen, move it so it doesn't\r
-                       if (this.x<0) { this.x=0; }\r
-                       if (this.y<0) { this.y=0; }\r
-                       if (screen && screen.availHeight) {\r
-                               if ((this.y + this.height) > screen.availHeight) {\r
-                                       this.y = screen.availHeight - this.height;\r
-                                       }\r
-                               }\r
-                       if (screen && screen.availWidth) {\r
-                               if ((this.x + this.width) > screen.availWidth) {\r
-                                       this.x = screen.availWidth - this.width;\r
-                                       }\r
-                               }\r
-                       var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled );\r
-                       this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");\r
-                       }\r
-               this.refresh();\r
-               }\r
-       }\r
-// Hide the popup\r
-function PopupWindow_hidePopup() {\r
-       if (this.divName != null) {\r
-               if (this.use_gebi) {\r
-                       document.getElementById(this.divName).style.visibility = "hidden";\r
-                       }\r
-               else if (this.use_css) {\r
-                       document.all[this.divName].style.visibility = "hidden";\r
-                       }\r
-               else if (this.use_layers) {\r
-                       document.layers[this.divName].visibility = "hidden";\r
-                       }\r
-               }\r
-       else {\r
-               if (this.popupWindow && !this.popupWindow.closed) {\r
-                       this.popupWindow.close();\r
-                       this.popupWindow = null;\r
-                       }\r
-               }\r
-       }\r
-// Pass an event and return whether or not it was the popup DIV that was clicked\r
-function PopupWindow_isClicked(e) {\r
-       if (this.divName != null) {\r
-               if (this.use_layers) {\r
-                       var clickX = e.pageX;\r
-                       var clickY = e.pageY;\r
-                       var t = document.layers[this.divName];\r
-                       if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {\r
-                               return true;\r
-                               }\r
-                       else { return false; }\r
-                       }\r
-               else if (document.all) { // Need to hard-code this to trap IE for error-handling\r
-                       var t = window.event.srcElement;\r
-                       while (t.parentElement != null) {\r
-                               if (t.id==this.divName) {\r
-                                       return true;\r
-                                       }\r
-                               t = t.parentElement;\r
-                               }\r
-                       return false;\r
-                       }\r
-               else if (this.use_gebi && e) {\r
-                       var t = e.originalTarget;\r
-                       while (t.parentNode != null) {\r
-                               if (t.id==this.divName) {\r
-                                       return true;\r
-                                       }\r
-                               t = t.parentNode;\r
-                               }\r
-                       return false;\r
-                       }\r
-               return false;\r
-               }\r
-       return false;\r
-       }\r
-\r
-// Check an onMouseDown event to see if we should hide\r
-function PopupWindow_hideIfNotClicked(e) {\r
-       if (this.autoHideEnabled && !this.isClicked(e)) {\r
-               this.hidePopup();\r
-               }\r
-       }\r
-// Call this to make the DIV disable automatically when mouse is clicked outside it\r
-function PopupWindow_autoHide() {\r
-       this.autoHideEnabled = true;\r
-       }\r
-// This global function checks all PopupWindow objects onmouseup to see if they should be hidden\r
-function PopupWindow_hidePopupWindows(e) {\r
-       for (var i=0; i<popupWindowObjects.length; i++) {\r
-               if (popupWindowObjects[i] != null) {\r
-                       var p = popupWindowObjects[i];\r
-                       p.hideIfNotClicked(e);\r
-                       }\r
-               }\r
-       }\r
-// Run this immediately to attach the event listener\r
-function PopupWindow_attachListener() {\r
-       if (document.layers) {\r
-               document.captureEvents(Event.MOUSEUP);\r
-               }\r
-       window.popupWindowOldEventListener = document.onmouseup;\r
-       if (window.popupWindowOldEventListener != null) {\r
-               document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");\r
-               }\r
-       else {\r
-               document.onmouseup = PopupWindow_hidePopupWindows;\r
-               }\r
-       }\r
-// CONSTRUCTOR for the PopupWindow object\r
-// Pass it a DIV name to use a DHTML popup, otherwise will default to window popup\r
-function PopupWindow() {\r
-       if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }\r
-       if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }\r
-       if (!window.listenerAttached) {\r
-               window.listenerAttached = true;\r
-               PopupWindow_attachListener();\r
-               }\r
-       this.index = popupWindowIndex++;\r
-       popupWindowObjects[this.index] = this;\r
-       this.divName = null;\r
-       this.popupWindow = null;\r
-       this.width=0;\r
-       this.height=0;\r
-       this.populated = false;\r
-       this.visible = false;\r
-       this.autoHideEnabled = false;\r
-       \r
-       this.contents = "";\r
-       this.url="";\r
-       this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";\r
-       if (arguments.length>0) {\r
-               this.type="DIV";\r
-               this.divName = arguments[0];\r
-               }\r
-       else {\r
-               this.type="WINDOW";\r
-               }\r
-       this.use_gebi = false;\r
-       this.use_css = false;\r
-       this.use_layers = false;\r
-       if (document.getElementById) { this.use_gebi = true; }\r
-       else if (document.all) { this.use_css = true; }\r
-       else if (document.layers) { this.use_layers = true; }\r
-       else { this.type = "WINDOW"; }\r
-       this.offsetX = 0;\r
-       this.offsetY = 0;\r
-       // Method mappings\r
-       this.getXYPosition = PopupWindow_getXYPosition;\r
-       this.populate = PopupWindow_populate;\r
-       this.setUrl = PopupWindow_setUrl;\r
-       this.setWindowProperties = PopupWindow_setWindowProperties;\r
-       this.refresh = PopupWindow_refresh;\r
-       this.showPopup = PopupWindow_showPopup;\r
-       this.hidePopup = PopupWindow_hidePopup;\r
-       this.setSize = PopupWindow_setSize;\r
-       this.isClicked = PopupWindow_isClicked;\r
-       this.autoHide = PopupWindow_autoHide;\r
-       this.hideIfNotClicked = PopupWindow_hideIfNotClicked;\r
-       }\r
-\r
-/* SOURCE FILE: CalendarPopup.js */\r
-\r
-// HISTORY\r
-// ------------------------------------------------------------------\r
-// Feb 7, 2005: Fixed a CSS styles to use px unit\r
-// March 29, 2004: Added check in select() method for the form field\r
-//      being disabled. If it is, just return and don't do anything.\r
-// March 24, 2004: Fixed bug - when month name and abbreviations were\r
-//      changed, date format still used original values.\r
-// January 26, 2004: Added support for drop-down month and year\r
-//      navigation (Thanks to Chris Reid for the idea)\r
-// September 22, 2003: Fixed a minor problem in YEAR calendar with\r
-//      CSS prefix.\r
-// August 19, 2003: Renamed the function to get styles, and made it\r
-//      work correctly without an object reference\r
-// August 18, 2003: Changed showYearNavigation and \r
-//      showYearNavigationInput to optionally take an argument of\r
-//      true or false\r
-// July 31, 2003: Added text input option for year navigation.\r
-//      Added a per-calendar CSS prefix option to optionally use \r
-//      different styles for different calendars.\r
-// July 29, 2003: Fixed bug causing the Today link to be clickable \r
-//      even though today falls in a disabled date range.\r
-//      Changed formatting to use pure CSS, allowing greater control\r
-//      over look-and-feel options.\r
-// June 11, 2003: Fixed bug causing the Today link to be unselectable\r
-//      under certain cases when some days of week are disabled\r
-// March 14, 2003: Added ability to disable individual dates or date\r
-//      ranges, display as light gray and strike-through\r
-// March 14, 2003: Removed dependency on graypixel.gif and instead \r
-///     use table border coloring\r
-// March 12, 2003: Modified showCalendar() function to allow optional\r
-//      start-date parameter\r
-// March 11, 2003: Modified select() function to allow optional\r
-//      start-date parameter\r
-/* \r
-DESCRIPTION: This object implements a popup calendar to allow the user to\r
-select a date, month, quarter, or year.\r
-\r
-COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small\r
-positioning errors - usually with Window positioning - occur on the \r
-Macintosh platform.\r
-The calendar can be modified to work for any location in the world by \r
-changing which weekday is displayed as the first column, changing the month\r
-names, and changing the column headers for each day.\r
-\r
-USAGE:\r
-// Create a new CalendarPopup object of type WINDOW\r
-var cal = new CalendarPopup(); \r
-\r
-// Create a new CalendarPopup object of type DIV using the DIV named 'mydiv'\r
-var cal = new CalendarPopup('mydiv'); \r
-\r
-// Easy method to link the popup calendar with an input box. \r
-cal.select(inputObject, anchorname, dateFormat);\r
-// Same method, but passing a default date other than the field's current value\r
-cal.select(inputObject, anchorname, dateFormat, '01/02/2000');\r
-// This is an example call to the popup calendar from a link to populate an \r
-// input box. Note that to use this, date.js must also be included!!\r
-<A HREF="#" onClick="cal.select(document.forms[0].date,'anchorname','MM/dd/yyyy'); return false;">Select</A>\r
-\r
-// Set the type of date select to be used. By default it is 'date'.\r
-cal.setDisplayType(type);\r
-\r
-// When a date, month, quarter, or year is clicked, a function is called and\r
-// passed the details. You must write this function, and tell the calendar\r
-// popup what the function name is.\r
-// Function to be called for 'date' select receives y, m, d\r
-cal.setReturnFunction(functionname);\r
-// Function to be called for 'month' select receives y, m\r
-cal.setReturnMonthFunction(functionname);\r
-// Function to be called for 'quarter' select receives y, q\r
-cal.setReturnQuarterFunction(functionname);\r
-// Function to be called for 'year' select receives y\r
-cal.setReturnYearFunction(functionname);\r
-\r
-// Show the calendar relative to a given anchor\r
-cal.showCalendar(anchorname);\r
-\r
-// Hide the calendar. The calendar is set to autoHide automatically\r
-cal.hideCalendar();\r
-\r
-// Set the month names to be used. Default are English month names\r
-cal.setMonthNames("January","February","March",...);\r
-\r
-// Set the month abbreviations to be used. Default are English month abbreviations\r
-cal.setMonthAbbreviations("Jan","Feb","Mar",...);\r
-\r
-// Show navigation for changing by the year, not just one month at a time\r
-cal.showYearNavigation();\r
-\r
-// Show month and year dropdowns, for quicker selection of month of dates\r
-cal.showNavigationDropdowns();\r
-\r
-// Set the text to be used above each day column. The days start with \r
-// sunday regardless of the value of WeekStartDay\r
-cal.setDayHeaders("S","M","T",...);\r
-\r
-// Set the day for the first column in the calendar grid. By default this\r
-// is Sunday (0) but it may be changed to fit the conventions of other\r
-// countries.\r
-cal.setWeekStartDay(1); // week is Monday - Sunday\r
-\r
-// Set the weekdays which should be disabled in the 'date' select popup. You can\r
-// then allow someone to only select week end dates, or Tuedays, for example\r
-cal.setDisabledWeekDays(0,1); // To disable selecting the 1st or 2nd days of the week\r
-\r
-// Selectively disable individual days or date ranges. Disabled days will not\r
-// be clickable, and show as strike-through text on current browsers.\r
-// Date format is any format recognized by parseDate() in date.js\r
-// Pass a single date to disable:\r
-cal.addDisabledDates("2003-01-01");\r
-// Pass null as the first parameter to mean "anything up to and including" the\r
-// passed date:\r
-cal.addDisabledDates(null, "01/02/03");\r
-// Pass null as the second parameter to mean "including the passed date and\r
-// anything after it:\r
-cal.addDisabledDates("Jan 01, 2003", null);\r
-// Pass two dates to disable all dates inbetween and including the two\r
-cal.addDisabledDates("January 01, 2003", "Dec 31, 2003");\r
-\r
-// When the 'year' select is displayed, set the number of years back from the \r
-// current year to start listing years. Default is 2.\r
-// This is also used for year drop-down, to decide how many years +/- to display\r
-cal.setYearSelectStartOffset(2);\r
-\r
-// Text for the word "Today" appearing on the calendar\r
-cal.setTodayText("Today");\r
-\r
-// The calendar uses CSS classes for formatting. If you want your calendar to\r
-// have unique styles, you can set the prefix that will be added to all the\r
-// classes in the output.\r
-// For example, normal output may have this:\r
-//     <SPAN CLASS="cpTodayTextDisabled">Today<SPAN>\r
-// But if you set the prefix like this:\r
-cal.setCssPrefix("Test");\r
-// The output will then look like:\r
-//     <SPAN CLASS="TestcpTodayTextDisabled">Today<SPAN>\r
-// And you can define that style somewhere in your page.\r
-\r
-// When using Year navigation, you can make the year be an input box, so\r
-// the user can manually change it and jump to any year\r
-cal.showYearNavigationInput();\r
-\r
-// Set the calendar offset to be different than the default. By default it\r
-// will appear just below and to the right of the anchorname. So if you have\r
-// a text box where the date will go and and anchor immediately after the\r
-// text box, the calendar will display immediately under the text box.\r
-cal.offsetX = 20;\r
-cal.offsetY = 20;\r
-\r
-NOTES:\r
-1) Requires the functions in AnchorPosition.js and PopupWindow.js\r
-\r
-2) Your anchor tag MUST contain both NAME and ID attributes which are the \r
-   same. For example:\r
-   <A NAME="test" ID="test"> </A>\r
-\r
-3) There must be at least a space between <A> </A> for IE5.5 to see the \r
-   anchor tag correctly. Do not do <A></A> with no space.\r
-\r
-4) When a CalendarPopup object is created, a handler for 'onmouseup' is\r
-   attached to any event handler you may have already defined. Do NOT define\r
-   an event handler for 'onmouseup' after you define a CalendarPopup object \r
-   or the autoHide() will not work correctly.\r
-   \r
-5) The calendar popup display uses style sheets to make it look nice.\r
-\r
-*/ \r
-\r
-// CONSTRUCTOR for the CalendarPopup Object\r
-function CalendarPopup() {\r
-       var c;\r
-       if (arguments.length>0) {\r
-               c = new PopupWindow(arguments[0]);\r
-               }\r
-       else {\r
-               c = new PopupWindow();\r
-               c.setSize(150,175);\r
-               }\r
-       c.offsetX = -152;\r
-       c.offsetY = 25;\r
-       c.autoHide();\r
-       // Calendar-specific properties\r
-       c.monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");\r
-       c.monthAbbreviations = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");\r
-       c.dayHeaders = new Array("S","M","T","W","T","F","S");\r
-       c.returnFunction = "CP_tmpReturnFunction";\r
-       c.returnMonthFunction = "CP_tmpReturnMonthFunction";\r
-       c.returnQuarterFunction = "CP_tmpReturnQuarterFunction";\r
-       c.returnYearFunction = "CP_tmpReturnYearFunction";\r
-       c.weekStartDay = 0;\r
-       c.isShowYearNavigation = false;\r
-       c.displayType = "date";\r
-       c.disabledWeekDays = new Object();\r
-       c.disabledDatesExpression = "";\r
-       c.yearSelectStartOffset = 2;\r
-       c.currentDate = null;\r
-       c.todayText="Today";\r
-       c.cssPrefix="";\r
-       c.isShowNavigationDropdowns=false;\r
-       c.isShowYearNavigationInput=false;\r
-       window.CP_calendarObject = null;\r
-       window.CP_targetInput = null;\r
-       window.CP_dateFormat = "MM/dd/yyyy";\r
-       // Method mappings\r
-       c.copyMonthNamesToWindow = CP_copyMonthNamesToWindow;\r
-       c.setReturnFunction = CP_setReturnFunction;\r
-       c.setReturnMonthFunction = CP_setReturnMonthFunction;\r
-       c.setReturnQuarterFunction = CP_setReturnQuarterFunction;\r
-       c.setReturnYearFunction = CP_setReturnYearFunction;\r
-       c.setMonthNames = CP_setMonthNames;\r
-       c.setMonthAbbreviations = CP_setMonthAbbreviations;\r
-       c.setDayHeaders = CP_setDayHeaders;\r
-       c.setWeekStartDay = CP_setWeekStartDay;\r
-       c.setDisplayType = CP_setDisplayType;\r
-       c.setDisabledWeekDays = CP_setDisabledWeekDays;\r
-       c.addDisabledDates = CP_addDisabledDates;\r
-       c.setYearSelectStartOffset = CP_setYearSelectStartOffset;\r
-       c.setTodayText = CP_setTodayText;\r
-       c.showYearNavigation = CP_showYearNavigation;\r
-       c.showCalendar = CP_showCalendar;\r
-       c.hideCalendar = CP_hideCalendar;\r
-       c.getStyles = getCalendarStyles;\r
-       c.refreshCalendar = CP_refreshCalendar;\r
-       c.getCalendar = CP_getCalendar;\r
-       c.select = CP_select;\r
-       c.setCssPrefix = CP_setCssPrefix;\r
-       c.showNavigationDropdowns = CP_showNavigationDropdowns;\r
-       c.showYearNavigationInput = CP_showYearNavigationInput;\r
-       c.copyMonthNamesToWindow();\r
-       // Return the object\r
-       return c;\r
-       }\r
-function CP_copyMonthNamesToWindow() {\r
-       // Copy these values over to the date.js \r
-       if (typeof(window.MONTH_NAMES)!="undefined" && window.MONTH_NAMES!=null) {\r
-               window.MONTH_NAMES = new Array();\r
-               for (var i=0; i<this.monthNames.length; i++) {\r
-                       window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthNames[i];\r
-               }\r
-               for (var i=0; i<this.monthAbbreviations.length; i++) {\r
-                       window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthAbbreviations[i];\r
-               }\r
-       }\r
-}\r
-// Temporary default functions to be called when items clicked, so no error is thrown\r
-function CP_tmpReturnFunction(y,m,d) { \r
-       if (window.CP_targetInput!=null) {\r
-               var dt = new Date(y,m-1,d,0,0,0);\r
-               if (window.CP_calendarObject!=null) { window.CP_calendarObject.copyMonthNamesToWindow(); }\r
-               window.CP_targetInput.value = formatDate(dt,window.CP_dateFormat);\r
-               }\r
-       else {\r
-               alert('Use setReturnFunction() to define which function will get the clicked results!'); \r
-               }\r
-       }\r
-function CP_tmpReturnMonthFunction(y,m) { \r
-       alert('Use setReturnMonthFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , month='+m); \r
-       }\r
-function CP_tmpReturnQuarterFunction(y,q) { \r
-       alert('Use setReturnQuarterFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , quarter='+q); \r
-       }\r
-function CP_tmpReturnYearFunction(y) { \r
-       alert('Use setReturnYearFunction() to define which function will get the clicked results!\nYou clicked: year='+y); \r
-       }\r
-\r
-// Set the name of the functions to call to get the clicked item\r
-function CP_setReturnFunction(name) { this.returnFunction = name; }\r
-function CP_setReturnMonthFunction(name) { this.returnMonthFunction = name; }\r
-function CP_setReturnQuarterFunction(name) { this.returnQuarterFunction = name; }\r
-function CP_setReturnYearFunction(name) { this.returnYearFunction = name; }\r
-\r
-// Over-ride the built-in month names\r
-function CP_setMonthNames() {\r
-       for (var i=0; i<arguments.length; i++) { this.monthNames[i] = arguments[i]; }\r
-       this.copyMonthNamesToWindow();\r
-       }\r
-\r
-// Over-ride the built-in month abbreviations\r
-function CP_setMonthAbbreviations() {\r
-       for (var i=0; i<arguments.length; i++) { this.monthAbbreviations[i] = arguments[i]; }\r
-       this.copyMonthNamesToWindow();\r
-       }\r
-\r
-// Over-ride the built-in column headers for each day\r
-function CP_setDayHeaders() {\r
-       for (var i=0; i<arguments.length; i++) { this.dayHeaders[i] = arguments[i]; }\r
-       }\r
-\r
-// Set the day of the week (0-7) that the calendar display starts on\r
-// This is for countries other than the US whose calendar displays start on Monday(1), for example\r
-function CP_setWeekStartDay(day) { this.weekStartDay = day; }\r
-\r
-// Show next/last year navigation links\r
-function CP_showYearNavigation() { this.isShowYearNavigation = (arguments.length>0)?arguments[0]:true; }\r
-\r
-// Which type of calendar to display\r
-function CP_setDisplayType(type) {\r
-       if (type!="date"&&type!="week-end"&&type!="month"&&type!="quarter"&&type!="year") { alert("Invalid display type! Must be one of: date,week-end,month,quarter,year"); return false; }\r
-       this.displayType=type;\r
-       }\r
-\r
-// How many years back to start by default for year display\r
-function CP_setYearSelectStartOffset(num) { this.yearSelectStartOffset=num; }\r
-\r
-// Set which weekdays should not be clickable\r
-function CP_setDisabledWeekDays() {\r
-       this.disabledWeekDays = new Object();\r
-       for (var i=0; i<arguments.length; i++) { this.disabledWeekDays[arguments[i]] = true; }\r
-       }\r
-       \r
-// Disable individual dates or ranges\r
-// Builds an internal logical test which is run via eval() for efficiency\r
-function CP_addDisabledDates(start, end) {\r
-       if (arguments.length==1) { end=start; }\r
-       if (start==null && end==null) { return; }\r
-       if (this.disabledDatesExpression!="") { this.disabledDatesExpression+= "||"; }\r
-       if (start!=null) { start = parseDate(start); start=""+start.getFullYear()+LZ(start.getMonth()+1)+LZ(start.getDate());}\r
-       if (end!=null) { end=parseDate(end); end=""+end.getFullYear()+LZ(end.getMonth()+1)+LZ(end.getDate());}\r
-       if (start==null) { this.disabledDatesExpression+="(ds<="+end+")"; }\r
-       else if (end  ==null) { this.disabledDatesExpression+="(ds>="+start+")"; }\r
-       else { this.disabledDatesExpression+="(ds>="+start+"&&ds<="+end+")"; }\r
-       }\r
-       \r
-// Set the text to use for the "Today" link\r
-function CP_setTodayText(text) {\r
-       this.todayText = text;\r
-       }\r
-\r
-// Set the prefix to be added to all CSS classes when writing output\r
-function CP_setCssPrefix(val) { \r
-       this.cssPrefix = val; \r
-       }\r
-\r
-// Show the navigation as an dropdowns that can be manually changed\r
-function CP_showNavigationDropdowns() { this.isShowNavigationDropdowns = (arguments.length>0)?arguments[0]:true; }\r
-\r
-// Show the year navigation as an input box that can be manually changed\r
-function CP_showYearNavigationInput() { this.isShowYearNavigationInput = (arguments.length>0)?arguments[0]:true; }\r
-\r
-// Hide a calendar object\r
-function CP_hideCalendar() {\r
-       if (arguments.length > 0) { window.popupWindowObjects[arguments[0]].hidePopup(); }\r
-       else { this.hidePopup(); }\r
-       }\r
-\r
-// Refresh the contents of the calendar display\r
-function CP_refreshCalendar(index) {\r
-       var calObject = window.popupWindowObjects[index];\r
-       if (arguments.length>1) { \r
-               calObject.populate(calObject.getCalendar(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]));\r
-               }\r
-       else {\r
-               calObject.populate(calObject.getCalendar());\r
-               }\r
-       calObject.refresh();\r
-       }\r
-\r
-// Populate the calendar and display it\r
-function CP_showCalendar(anchorname) {\r
-       if (arguments.length>1) {\r
-               if (arguments[1]==null||arguments[1]=="") {\r
-                       this.currentDate=new Date();\r
-                       }\r
-               else {\r
-                       this.currentDate=new Date(parseDate(arguments[1]));\r
-                       }\r
-               }\r
-       this.populate(this.getCalendar());\r
-       this.showPopup(anchorname);\r
-       }\r
-\r
-// Simple method to interface popup calendar with a text-entry box\r
-function CP_select(inputobj, linkname, format) {\r
-       var selectedDate=(arguments.length>3)?arguments[3]:null;\r
-       if (!window.getDateFromFormat) {\r
-               alert("calendar.select: To use this method you must also include 'date.js' for date formatting");\r
-               return;\r
-               }\r
-       if (this.displayType!="date"&&this.displayType!="week-end") {\r
-               alert("calendar.select: This function can only be used with displayType 'date' or 'week-end'");\r
-               return;\r
-               }\r
-       if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { \r
-               alert("calendar.select: Input object passed is not a valid form input object"); \r
-               window.CP_targetInput=null;\r
-               return;\r
-               }\r
-       if (inputobj.disabled) { return; } // Can't use calendar input on disabled form input!\r
-       window.CP_targetInput = inputobj;\r
-       window.CP_calendarObject = this;\r
-       this.currentDate=null;\r
-       var time=0;\r
-       if (selectedDate!=null) {\r
-               time = getDateFromFormat(selectedDate,format)\r
-               }\r
-       else if (inputobj.value!="") {\r
-               time = getDateFromFormat(inputobj.value,format);\r
-               }\r
-       if (selectedDate!=null || inputobj.value!="") {\r
-               if (time==0) { this.currentDate=null; }\r
-               else { this.currentDate=new Date(time); }\r
-               }\r
-       window.CP_dateFormat = format;\r
-       this.showCalendar(linkname);\r
-       }\r
-       \r
-// Get style block needed to display the calendar correctly\r
-function getCalendarStyles() {\r
-       var result = "";\r
-       var p = "";\r
-       if (this!=null && typeof(this.cssPrefix)!="undefined" && this.cssPrefix!=null && this.cssPrefix!="") { p=this.cssPrefix; }\r
-       result += "<STYLE>\n";\r
-       result += "."+p+"cpYearNavigation,."+p+"cpMonthNavigation { background-color:#C0C0C0; text-align:center; vertical-align:center; text-decoration:none; color:#000000; font-weight:bold; }\n";\r
-       result += "."+p+"cpDayColumnHeader, ."+p+"cpYearNavigation,."+p+"cpMonthNavigation,."+p+"cpCurrentMonthDate,."+p+"cpCurrentMonthDateDisabled,."+p+"cpOtherMonthDate,."+p+"cpOtherMonthDateDisabled,."+p+"cpCurrentDate,."+p+"cpCurrentDateDisabled,."+p+"cpTodayText,."+p+"cpTodayTextDisabled,."+p+"cpText { font-family:arial; font-size:8pt; }\n";\r
-       result += "TD."+p+"cpDayColumnHeader { text-align:right; border:solid thin #C0C0C0;border-width:0px 0px 1px 0px; }\n";\r
-       result += "."+p+"cpCurrentMonthDate, ."+p+"cpOtherMonthDate, ."+p+"cpCurrentDate  { text-align:right; text-decoration:none; }\n";\r
-       result += "."+p+"cpCurrentMonthDateDisabled, ."+p+"cpOtherMonthDateDisabled, ."+p+"cpCurrentDateDisabled { color:#D0D0D0; text-align:right; text-decoration:line-through; }\n";\r
-       result += "."+p+"cpCurrentMonthDate, .cpCurrentDate { color:#000000; }\n";\r
-       result += "."+p+"cpOtherMonthDate { color:#808080; }\n";\r
-       result += "TD."+p+"cpCurrentDate { color:white; background-color: #C0C0C0; border-width:1px; border:solid thin #800000; }\n";\r
-       result += "TD."+p+"cpCurrentDateDisabled { border-width:1px; border:solid thin #FFAAAA; }\n";\r
-       result += "TD."+p+"cpTodayText, TD."+p+"cpTodayTextDisabled { border:solid thin #C0C0C0; border-width:1px 0px 0px 0px;}\n";\r
-       result += "A."+p+"cpTodayText, SPAN."+p+"cpTodayTextDisabled { height:20px; }\n";\r
-       result += "A."+p+"cpTodayText { color:black; }\n";\r
-       result += "."+p+"cpTodayTextDisabled { color:#D0D0D0; }\n";\r
-       result += "."+p+"cpBorder { border:solid thin #808080; }\n";\r
-       result += "</STYLE>\n";\r
-       return result;\r
-       }\r
-\r
-// Return a string containing all the calendar code to be displayed\r
-function CP_getCalendar() {\r
-       var now = new Date();\r
-       // Reference to window\r
-       if (this.type == "WINDOW") { var windowref = "window.opener."; }\r
-       else { var windowref = ""; }\r
-       var result = "";\r
-       // If POPUP, write entire HTML document\r
-       if (this.type == "WINDOW") {\r
-               result += "<HTML><HEAD><TITLE>Calendar</TITLE>"+this.getStyles()+"</HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 RIGHTMARGIN=0 LEFTMARGIN=0>\n";\r
-               result += '<CENTER><TABLE WIDTH=100% BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>\n';\r
-               }\r
-       else {\r
-               result += '<TABLE CLASS="'+this.cssPrefix+'cpBorder" WIDTH=144 BORDER=1 BORDERWIDTH=1 CELLSPACING=0 CELLPADDING=1>\n';\r
-               result += '<TR><TD ALIGN=CENTER>\n';\r
-               result += '<CENTER>\n';\r
-               }\r
-       // Code for DATE display (default)\r
-       // -------------------------------\r
-       if (this.displayType=="date" || this.displayType=="week-end") {\r
-               if (this.currentDate==null) { this.currentDate = now; }\r
-               if (arguments.length > 0) { var month = arguments[0]; }\r
-                       else { var month = this.currentDate.getMonth()+1; }\r
-               if (arguments.length > 1 && arguments[1]>0 && arguments[1]-0==arguments[1]) { var year = arguments[1]; }\r
-                       else { var year = this.currentDate.getFullYear(); }\r
-               var daysinmonth= new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);\r
-               if ( ( (year%4 == 0)&&(year%100 != 0) ) || (year%400 == 0) ) {\r
-                       daysinmonth[2] = 29;\r
-                       }\r
-               var current_month = new Date(year,month-1,1);\r
-               var display_year = year;\r
-               var display_month = month;\r
-               var display_date = 1;\r
-               var weekday= current_month.getDay();\r
-               var offset = 0;\r
-               \r
-               offset = (weekday >= this.weekStartDay) ? weekday-this.weekStartDay : 7-this.weekStartDay+weekday ;\r
-               if (offset > 0) {\r
-                       display_month--;\r
-                       if (display_month < 1) { display_month = 12; display_year--; }\r
-                       display_date = daysinmonth[display_month]-offset+1;\r
-                       }\r
-               var next_month = month+1;\r
-               var next_month_year = year;\r
-               if (next_month > 12) { next_month=1; next_month_year++; }\r
-               var last_month = month-1;\r
-               var last_month_year = year;\r
-               if (last_month < 1) { last_month=12; last_month_year--; }\r
-               var date_class;\r
-               if (this.type!="WINDOW") {\r
-                       result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";\r
-                       }\r
-               result += '<TR>\n';\r
-               var refresh = windowref+'CP_refreshCalendar';\r
-               var refreshLink = 'javascript:' + refresh;\r
-               if (this.isShowNavigationDropdowns) {\r
-                       result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="78" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpMonthNavigation" name="cpMonth" onChange="'+refresh+'('+this.index+',this.options[this.selectedIndex].value-0,'+(year-0)+');">';\r
-                       for( var monthCounter=1; monthCounter<=12; monthCounter++ ) {\r
-                               var selected = (monthCounter==month) ? 'SELECTED' : '';\r
-                               result += '<option value="'+monthCounter+'" '+selected+'>'+this.monthNames[monthCounter-1]+'</option>';\r
-                               }\r
-                       result += '</select></TD>';\r
-                       result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';\r
-\r
-                       result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="56" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpYearNavigation" name="cpYear" onChange="'+refresh+'('+this.index+','+month+',this.options[this.selectedIndex].value-0);">';\r
-                       for( var yearCounter=year-this.yearSelectStartOffset; yearCounter<=year+this.yearSelectStartOffset; yearCounter++ ) {\r
-                               var selected = (yearCounter==year) ? 'SELECTED' : '';\r
-                               result += '<option value="'+yearCounter+'" '+selected+'>'+yearCounter+'</option>';\r
-                               }\r
-                       result += '</select></TD>';\r
-                       }\r
-               else {\r
-                       if (this.isShowYearNavigation) {\r
-                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;</A></TD>';\r
-                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="58"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+'</SPAN></TD>';\r
-                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;</A></TD>';\r
-                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';\r
-\r
-                               result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year-1)+');">&lt;</A></TD>';\r
-                               if (this.isShowYearNavigationInput) {\r
-                                       result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><INPUT NAME="cpYear" CLASS="'+this.cssPrefix+'cpYearNavigation" SIZE="4" MAXLENGTH="4" VALUE="'+year+'" onBlur="'+refresh+'('+this.index+','+month+',this.value-0);"></TD>';\r
-                                       }\r
-                               else {\r
-                                       result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><SPAN CLASS="'+this.cssPrefix+'cpYearNavigation">'+year+'</SPAN></TD>';\r
-                                       }\r
-                               result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year+1)+');">&gt;</A></TD>';\r
-                               }\r
-                       else {\r
-                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;&lt;</A></TD>\n';\r
-                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="100"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+' '+year+'</SPAN></TD>\n';\r
-                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;&gt;</A></TD>\n';\r
-                               }\r
-                       }\r
-               result += '</TR></TABLE>\n';\r
-               result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=0 CELLPADDING=1 ALIGN=CENTER>\n';\r
-               result += '<TR>\n';\r
-               for (var j=0; j<7; j++) {\r
-\r
-                       result += '<TD CLASS="'+this.cssPrefix+'cpDayColumnHeader" WIDTH="14%"><SPAN CLASS="'+this.cssPrefix+'cpDayColumnHeader">'+this.dayHeaders[(this.weekStartDay+j)%7]+'</TD>\n';\r
-                       }\r
-               result += '</TR>\n';\r
-               for (var row=1; row<=6; row++) {\r
-                       result += '<TR>\n';\r
-                       for (var col=1; col<=7; col++) {\r
-                               var disabled=false;\r
-                               if (this.disabledDatesExpression!="") {\r
-                                       var ds=""+display_year+LZ(display_month)+LZ(display_date);\r
-                                       eval("disabled=("+this.disabledDatesExpression+")");\r
-                                       }\r
-                               var dateClass = "";\r
-                               if ((display_month == this.currentDate.getMonth()+1) && (display_date==this.currentDate.getDate()) && (display_year==this.currentDate.getFullYear())) {\r
-                                       dateClass = "cpCurrentDate";\r
-                                       }\r
-                               else if (display_month == month) {\r
-                                       dateClass = "cpCurrentMonthDate";\r
-                                       }\r
-                               else {\r
-                                       dateClass = "cpOtherMonthDate";\r
-                                       }\r
-                               if (disabled || this.disabledWeekDays[col-1]) {\r
-                                       result += '     <TD CLASS="'+this.cssPrefix+dateClass+'"><SPAN CLASS="'+this.cssPrefix+dateClass+'Disabled">'+display_date+'</SPAN></TD>\n';\r
-                                       }\r
-                               else {\r
-                                       var selected_date = display_date;\r
-                                       var selected_month = display_month;\r
-                                       var selected_year = display_year;\r
-                                       if (this.displayType=="week-end") {\r
-                                               var d = new Date(selected_year,selected_month-1,selected_date,0,0,0,0);\r
-                                               d.setDate(d.getDate() + (7-col));\r
-                                               selected_year = d.getYear();\r
-                                               if (selected_year < 1000) { selected_year += 1900; }\r
-                                               selected_month = d.getMonth()+1;\r
-                                               selected_date = d.getDate();\r
-                                               }\r
-                                       result += '     <TD CLASS="'+this.cssPrefix+dateClass+'"><A HREF="javascript:'+windowref+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+this.cssPrefix+dateClass+'">'+display_date+'</A></TD>\n';\r
-                                       }\r
-                               display_date++;\r
-                               if (display_date > daysinmonth[display_month]) {\r
-                                       display_date=1;\r
-                                       display_month++;\r
-                                       }\r
-                               if (display_month > 12) {\r
-                                       display_month=1;\r
-                                       display_year++;\r
-                                       }\r
-                               }\r
-                       result += '</TR>';\r
-                       }\r
-               var current_weekday = now.getDay() - this.weekStartDay;\r
-               if (current_weekday < 0) {\r
-                       current_weekday += 7;\r
-                       }\r
-               result += '<TR>\n';\r
-               result += '     <TD COLSPAN=7 ALIGN=CENTER CLASS="'+this.cssPrefix+'cpTodayText">\n';\r
-               if (this.disabledDatesExpression!="") {\r
-                       var ds=""+now.getFullYear()+LZ(now.getMonth()+1)+LZ(now.getDate());\r
-                       eval("disabled=("+this.disabledDatesExpression+")");\r
-                       }\r
-               if (disabled || this.disabledWeekDays[current_weekday+1]) {\r
-                       result += '             <SPAN CLASS="'+this.cssPrefix+'cpTodayTextDisabled">'+this.todayText+'</SPAN>\n';\r
-                       }\r
-               else {\r
-                       result += '             <A CLASS="'+this.cssPrefix+'cpTodayText" HREF="javascript:'+windowref+this.returnFunction+'(\''+now.getFullYear()+'\',\''+(now.getMonth()+1)+'\',\''+now.getDate()+'\');'+windowref+'CP_hideCalendar(\''+this.index+'\');">'+this.todayText+'</A>\n';\r
-                       }\r
-               result += '             <BR>\n';\r
-               result += '     </TD></TR></TABLE></CENTER></TD></TR></TABLE>\n';\r
-       }\r
-\r
-       // Code common for MONTH, QUARTER, YEAR\r
-       // ------------------------------------\r
-       if (this.displayType=="month" || this.displayType=="quarter" || this.displayType=="year") {\r
-               if (arguments.length > 0) { var year = arguments[0]; }\r
-               else { \r
-                       if (this.displayType=="year") { var year = now.getFullYear()-this.yearSelectStartOffset; }\r
-                       else { var year = now.getFullYear(); }\r
-                       }\r
-               if (this.displayType!="year" && this.isShowYearNavigation) {\r
-                       result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";\r
-                       result += '<TR>\n';\r
-                       result += '     <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-1)+');">&lt;&lt;</A></TD>\n';\r
-                       result += '     <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="100">'+year+'</TD>\n';\r
-                       result += '     <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+1)+');">&gt;&gt;</A></TD>\n';\r
-                       result += '</TR></TABLE>\n';\r
-                       }\r
-               }\r
-               \r
-       // Code for MONTH display \r
-       // ----------------------\r
-       if (this.displayType=="month") {\r
-               // If POPUP, write entire HTML document\r
-               result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';\r
-               for (var i=0; i<4; i++) {\r
-                       result += '<TR>';\r
-                       for (var j=0; j<3; j++) {\r
-                               var monthindex = ((i*3)+j);\r
-                               result += '<TD WIDTH=33% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnMonthFunction+'('+year+','+(monthindex+1)+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+this.monthAbbreviations[monthindex]+'</A></TD>';\r
-                               }\r
-                       result += '</TR>';\r
-                       }\r
-               result += '</TABLE></CENTER></TD></TR></TABLE>\n';\r
-               }\r
-       \r
-       // Code for QUARTER display\r
-       // ------------------------\r
-       if (this.displayType=="quarter") {\r
-               result += '<BR><TABLE WIDTH=120 BORDER=1 CELLSPACING=0 CELLPADDING=0 ALIGN=CENTER>\n';\r
-               for (var i=0; i<2; i++) {\r
-                       result += '<TR>';\r
-                       for (var j=0; j<2; j++) {\r
-                               var quarter = ((i*2)+j+1);\r
-                               result += '<TD WIDTH=50% ALIGN=CENTER><BR><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnQuarterFunction+'('+year+','+quarter+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">Q'+quarter+'</A><BR><BR></TD>';\r
-                               }\r
-                       result += '</TR>';\r
-                       }\r
-               result += '</TABLE></CENTER></TD></TR></TABLE>\n';\r
-               }\r
-\r
-       // Code for YEAR display\r
-       // ---------------------\r
-       if (this.displayType=="year") {\r
-               var yearColumnSize = 4;\r
-               result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";\r
-               result += '<TR>\n';\r
-               result += '     <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-(yearColumnSize*2))+');">&lt;&lt;</A></TD>\n';\r
-               result += '     <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+(yearColumnSize*2))+');">&gt;&gt;</A></TD>\n';\r
-               result += '</TR></TABLE>\n';\r
-               result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';\r
-               for (var i=0; i<yearColumnSize; i++) {\r
-                       for (var j=0; j<2; j++) {\r
-                               var currentyear = year+(j*yearColumnSize)+i;\r
-                               result += '<TD WIDTH=50% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnYearFunction+'('+currentyear+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+currentyear+'</A></TD>';\r
-                               }\r
-                       result += '</TR>';\r
-                       }\r
-               result += '</TABLE></CENTER></TD></TR></TABLE>\n';\r
-               }\r
-       // Common\r
-       if (this.type == "WINDOW") {\r
-               result += "</BODY></HTML>\n";\r
-               }\r
-       return result;\r
-       }\r
+// ===================================================================
+// Author: Matt Kruse <matt@mattkruse.com>
+// WWW: http://www.mattkruse.com/
+//
+// NOTICE: You may use this code for any purpose, commercial or
+// private, without any further permission from the author. You may
+// remove this notice from your final code if you wish, however it is
+// appreciated by the author if at least my web site address is kept.
+//
+// You may *NOT* re-distribute this code in any way except through its
+// use. That means, you can include it in your product, or your web
+// site, or any other form where the code is actually being used. You
+// may not put the plain javascript up on your site for download or
+// include it in your javascript libraries for download. 
+// If you wish to share this code with others, please just point them
+// to the URL instead.
+// Please DO NOT link directly to my .js files from your site. Copy
+// the files to your server and use them there. Thank you.
+// ===================================================================
+
+
+/* SOURCE FILE: AnchorPosition.js */
+
+/* 
+AnchorPosition.js
+Author: Matt Kruse
+Last modified: 10/11/02
+
+DESCRIPTION: These functions find the position of an <A> tag in a document,
+so other elements can be positioned relative to it.
+
+COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small
+positioning errors - usually with Window positioning - occur on the 
+Macintosh platform.
+
+FUNCTIONS:
+getAnchorPosition(anchorname)
+  Returns an Object() having .x and .y properties of the pixel coordinates
+  of the upper-left corner of the anchor. Position is relative to the PAGE.
+
+getAnchorWindowPosition(anchorname)
+  Returns an Object() having .x and .y properties of the pixel coordinates
+  of the upper-left corner of the anchor, relative to the WHOLE SCREEN.
+
+NOTES:
+
+1) For popping up separate browser windows, use getAnchorWindowPosition. 
+   Otherwise, use getAnchorPosition
+
+2) Your anchor tag MUST contain both NAME and ID attributes which are the 
+   same. For example:
+   <A NAME="test" ID="test"> </A>
+
+3) There must be at least a space between <A> </A> for IE5.5 to see the 
+   anchor tag correctly. Do not do <A></A> with no space.
+*/ 
+
+// getAnchorPosition(anchorname)
+//   This function returns an object having .x and .y properties which are the coordinates
+//   of the named anchor, relative to the page.
+function getAnchorPosition(anchorname) {
+       // This function will return an Object with x and y properties
+       var useWindow=false;
+       var coordinates=new Object();
+       var x=0,y=0;
+       // Browser capability sniffing
+       var use_gebi=false, use_css=false, use_layers=false;
+       if (document.getElementById) { use_gebi=true; }
+       else if (document.all) { use_css=true; }
+       else if (document.layers) { use_layers=true; }
+       // Logic to find position
+       if (use_gebi && document.all) {
+               x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
+               y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
+               }
+       else if (use_gebi) {
+               var o=document.getElementById(anchorname);
+               x=AnchorPosition_getPageOffsetLeft(o);
+               y=AnchorPosition_getPageOffsetTop(o);
+               }
+       else if (use_css) {
+               x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
+               y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
+               }
+       else if (use_layers) {
+               var found=0;
+               for (var i=0; i<document.anchors.length; i++) {
+                       if (document.anchors[i].name==anchorname) { found=1; break; }
+                       }
+               if (found==0) {
+                       coordinates.x=0; coordinates.y=0; return coordinates;
+                       }
+               x=document.anchors[i].x;
+               y=document.anchors[i].y;
+               }
+       else {
+               coordinates.x=0; coordinates.y=0; return coordinates;
+               }
+       coordinates.x=x;
+       coordinates.y=y;
+       return coordinates;
+       }
+
+// getAnchorWindowPosition(anchorname)
+//   This function returns an object having .x and .y properties which are the coordinates
+//   of the named anchor, relative to the window
+function getAnchorWindowPosition(anchorname) {
+       var coordinates=getAnchorPosition(anchorname);
+       var x=0;
+       var y=0;
+       if (document.getElementById) {
+               if (isNaN(window.screenX)) {
+                       x=coordinates.x-document.body.scrollLeft+window.screenLeft;
+                       y=coordinates.y-document.body.scrollTop+window.screenTop;
+                       }
+               else {
+                       x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
+                       y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
+                       }
+               }
+       else if (document.all) {
+               x=coordinates.x-document.body.scrollLeft+window.screenLeft;
+               y=coordinates.y-document.body.scrollTop+window.screenTop;
+               }
+       else if (document.layers) {
+               x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
+               y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
+               }
+       coordinates.x=x;
+       coordinates.y=y;
+       return coordinates;
+       }
+
+// Functions for IE to get position of an object
+function AnchorPosition_getPageOffsetLeft (el) {
+       var ol=el.offsetLeft;
+       while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
+       return ol;
+       }
+function AnchorPosition_getWindowOffsetLeft (el) {
+       return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
+       }       
+function AnchorPosition_getPageOffsetTop (el) {
+       var ot=el.offsetTop;
+       while((el=el.offsetParent) != null) { ot += el.offsetTop; }
+       return ot;
+       }
+function AnchorPosition_getWindowOffsetTop (el) {
+       return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
+       }
+
+/* SOURCE FILE: date.js */
+
+// HISTORY
+// ------------------------------------------------------------------
+// May 17, 2003: Fixed bug in parseDate() for dates <1970
+// March 11, 2003: Added parseDate() function
+// March 11, 2003: Added "NNN" formatting option. Doesn't match up
+//                 perfectly with SimpleDateFormat formats, but 
+//                 backwards-compatability was required.
+
+// ------------------------------------------------------------------
+// These functions use the same 'format' strings as the 
+// java.text.SimpleDateFormat class, with minor exceptions.
+// The format string consists of the following abbreviations:
+// 
+// Field        | Full Form          | Short Form
+// -------------+--------------------+-----------------------
+// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)
+// Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
+//              | NNN (abbr.)        |
+// Day of Month | dd (2 digits)      | d (1 or 2 digits)
+// Day of Week  | EE (name)          | E (abbr)
+// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)
+// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)
+// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)
+// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)
+// Minute       | mm (2 digits)      | m (1 or 2 digits)
+// Second       | ss (2 digits)      | s (1 or 2 digits)
+// AM/PM        | a                  |
+//
+// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
+// Examples:
+//  "MMM d, y" matches: January 01, 2000
+//                      Dec 1, 1900
+//                      Nov 20, 00
+//  "M/d/yy"   matches: 01/20/00
+//                      9/2/00
+//  "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
+// ------------------------------------------------------------------
+
+var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
+var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
+function LZ(x) {return(x<0||x>9?"":"0")+x}
+
+// ------------------------------------------------------------------
+// isDate ( date_string, format_string )
+// Returns true if date string matches format of format string and
+// is a valid date. Else returns false.
+// It is recommended that you trim whitespace around the value before
+// passing it to this function, as whitespace is NOT ignored!
+// ------------------------------------------------------------------
+function isDate(val,format) {
+       var date=getDateFromFormat(val,format);
+       if (date==0) { return false; }
+       return true;
+       }
+
+// -------------------------------------------------------------------
+// compareDates(date1,date1format,date2,date2format)
+//   Compare two date strings to see which is greater.
+//   Returns:
+//   1 if date1 is greater than date2
+//   0 if date2 is greater than date1 of if they are the same
+//  -1 if either of the dates is in an invalid format
+// -------------------------------------------------------------------
+function compareDates(date1,dateformat1,date2,dateformat2) {
+       var d1=getDateFromFormat(date1,dateformat1);
+       var d2=getDateFromFormat(date2,dateformat2);
+       if (d1==0 || d2==0) {
+               return -1;
+               }
+       else if (d1 > d2) {
+               return 1;
+               }
+       return 0;
+       }
+
+// ------------------------------------------------------------------
+// formatDate (date_object, format)
+// Returns a date in the output format specified.
+// The format string uses the same abbreviations as in getDateFromFormat()
+// ------------------------------------------------------------------
+function formatDate(date,format) {
+       format=format+"";
+       var result="";
+       var i_format=0;
+       var c="";
+       var token="";
+       var y=date.getYear()+"";
+       var M=date.getMonth()+1;
+       var d=date.getDate();
+       var E=date.getDay();
+       var H=date.getHours();
+       var m=date.getMinutes();
+       var s=date.getSeconds();
+       var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
+       // Convert real date parts into formatted versions
+       var value=new Object();
+       if (y.length < 4) {y=""+(y-0+1900);}
+       value["y"]=""+y;
+       value["yyyy"]=y;
+       value["yy"]=y.substring(2,4);
+       value["M"]=M;
+       value["MM"]=LZ(M);
+       value["MMM"]=MONTH_NAMES[M-1];
+       value["NNN"]=MONTH_NAMES[M+11];
+       value["d"]=d;
+       value["dd"]=LZ(d);
+       value["E"]=DAY_NAMES[E+7];
+       value["EE"]=DAY_NAMES[E];
+       value["H"]=H;
+       value["HH"]=LZ(H);
+       if (H==0){value["h"]=12;}
+       else if (H>12){value["h"]=H-12;}
+       else {value["h"]=H;}
+       value["hh"]=LZ(value["h"]);
+       if (H>11){value["K"]=H-12;} else {value["K"]=H;}
+       value["k"]=H+1;
+       value["KK"]=LZ(value["K"]);
+       value["kk"]=LZ(value["k"]);
+       if (H > 11) { value["a"]="PM"; }
+       else { value["a"]="AM"; }
+       value["m"]=m;
+       value["mm"]=LZ(m);
+       value["s"]=s;
+       value["ss"]=LZ(s);
+       while (i_format < format.length) {
+               c=format.charAt(i_format);
+               token="";
+               while ((format.charAt(i_format)==c) && (i_format < format.length)) {
+                       token += format.charAt(i_format++);
+                       }
+               if (value[token] != null) { result=result + value[token]; }
+               else { result=result + token; }
+               }
+       return result;
+       }
+       
+// ------------------------------------------------------------------
+// Utility functions for parsing in getDateFromFormat()
+// ------------------------------------------------------------------
+function _isInteger(val) {
+       var digits="1234567890";
+       for (var i=0; i < val.length; i++) {
+               if (digits.indexOf(val.charAt(i))==-1) { return false; }
+               }
+       return true;
+       }
+function _getInt(str,i,minlength,maxlength) {
+       for (var x=maxlength; x>=minlength; x--) {
+               var token=str.substring(i,i+x);
+               if (token.length < minlength) { return null; }
+               if (_isInteger(token)) { return token; }
+               }
+       return null;
+       }
+       
+// ------------------------------------------------------------------
+// getDateFromFormat( date_string , format_string )
+//
+// This function takes a date string and a format string. It matches
+// If the date string matches the format string, it returns the 
+// getTime() of the date. If it does not match, it returns 0.
+// ------------------------------------------------------------------
+function getDateFromFormat(val,format) {
+       val=val+"";
+       format=format+"";
+       var i_val=0;
+       var i_format=0;
+       var c="";
+       var token="";
+       var token2="";
+       var x,y;
+       var now=new Date();
+       var year=now.getYear();
+       var month=now.getMonth()+1;
+       var date=1;
+       var hh=now.getHours();
+       var mm=now.getMinutes();
+       var ss=now.getSeconds();
+       var ampm="";
+       
+       while (i_format < format.length) {
+               // Get next token from format string
+               c=format.charAt(i_format);
+               token="";
+               while ((format.charAt(i_format)==c) && (i_format < format.length)) {
+                       token += format.charAt(i_format++);
+                       }
+               // Extract contents of value based on format token
+               if (token=="yyyy" || token=="yy" || token=="y") {
+                       if (token=="yyyy") { x=4;y=4; }
+                       if (token=="yy")   { x=2;y=2; }
+                       if (token=="y")    { x=2;y=4; }
+                       year=_getInt(val,i_val,x,y);
+                       if (year==null) { return 0; }
+                       i_val += year.length;
+                       if (year.length==2) {
+                               if (year > 70) { year=1900+(year-0); }
+                               else { year=2000+(year-0); }
+                               }
+                       }
+               else if (token=="MMM"||token=="NNN"){
+                       month=0;
+                       for (var i=0; i<MONTH_NAMES.length; i++) {
+                               var month_name=MONTH_NAMES[i];
+                               if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
+                                       if (token=="MMM"||(token=="NNN"&&i>11)) {
+                                               month=i+1;
+                                               if (month>12) { month -= 12; }
+                                               i_val += month_name.length;
+                                               break;
+                                               }
+                                       }
+                               }
+                       if ((month < 1)||(month>12)){return 0;}
+                       }
+               else if (token=="EE"||token=="E"){
+                       for (var i=0; i<DAY_NAMES.length; i++) {
+                               var day_name=DAY_NAMES[i];
+                               if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
+                                       i_val += day_name.length;
+                                       break;
+                                       }
+                               }
+                       }
+               else if (token=="MM"||token=="M") {
+                       month=_getInt(val,i_val,token.length,2);
+                       if(month==null||(month<1)||(month>12)){return 0;}
+                       i_val+=month.length;}
+               else if (token=="dd"||token=="d") {
+                       date=_getInt(val,i_val,token.length,2);
+                       if(date==null||(date<1)||(date>31)){return 0;}
+                       i_val+=date.length;}
+               else if (token=="hh"||token=="h") {
+                       hh=_getInt(val,i_val,token.length,2);
+                       if(hh==null||(hh<1)||(hh>12)){return 0;}
+                       i_val+=hh.length;}
+               else if (token=="HH"||token=="H") {
+                       hh=_getInt(val,i_val,token.length,2);
+                       if(hh==null||(hh<0)||(hh>23)){return 0;}
+                       i_val+=hh.length;}
+               else if (token=="KK"||token=="K") {
+                       hh=_getInt(val,i_val,token.length,2);
+                       if(hh==null||(hh<0)||(hh>11)){return 0;}
+                       i_val+=hh.length;}
+               else if (token=="kk"||token=="k") {
+                       hh=_getInt(val,i_val,token.length,2);
+                       if(hh==null||(hh<1)||(hh>24)){return 0;}
+                       i_val+=hh.length;hh--;}
+               else if (token=="mm"||token=="m") {
+                       mm=_getInt(val,i_val,token.length,2);
+                       if(mm==null||(mm<0)||(mm>59)){return 0;}
+                       i_val+=mm.length;}
+               else if (token=="ss"||token=="s") {
+                       ss=_getInt(val,i_val,token.length,2);
+                       if(ss==null||(ss<0)||(ss>59)){return 0;}
+                       i_val+=ss.length;}
+               else if (token=="a") {
+                       if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
+                       else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
+                       else {return 0;}
+                       i_val+=2;}
+               else {
+                       if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
+                       else {i_val+=token.length;}
+                       }
+               }
+       // If there are any trailing characters left in the value, it doesn't match
+       if (i_val != val.length) { return 0; }
+       // Is date valid for month?
+       if (month==2) {
+               // Check for leap year
+               if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
+                       if (date > 29){ return 0; }
+                       }
+               else { if (date > 28) { return 0; } }
+               }
+       if ((month==4)||(month==6)||(month==9)||(month==11)) {
+               if (date > 30) { return 0; }
+               }
+       // Correct hours value
+       if (hh<12 && ampm=="PM") { hh=hh-0+12; }
+       else if (hh>11 && ampm=="AM") { hh-=12; }
+       var newdate=new Date(year,month-1,date,hh,mm,ss);
+       return newdate.getTime();
+       }
+
+// ------------------------------------------------------------------
+// parseDate( date_string [, prefer_euro_format] )
+//
+// This function takes a date string and tries to match it to a
+// number of possible date formats to get the value. It will try to
+// match against the following international formats, in this order:
+// y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d
+// M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d
+// d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M
+// A second argument may be passed to instruct the method to search
+// for formats like d/M/y (european format) before M/d/y (American).
+// Returns a Date object or null if no patterns match.
+// ------------------------------------------------------------------
+function parseDate(val) {
+       var preferEuro=(arguments.length==2)?arguments[1]:false;
+       generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
+       monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
+       dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
+       var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
+       var d=null;
+       for (var i=0; i<checkList.length; i++) {
+               var l=window[checkList[i]];
+               for (var j=0; j<l.length; j++) {
+                       d=getDateFromFormat(val,l[j]);
+                       if (d!=0) { return new Date(d); }
+                       }
+               }
+       return null;
+       }
+
+/* SOURCE FILE: PopupWindow.js */
+
+/* 
+PopupWindow.js
+Author: Matt Kruse
+Last modified: 02/16/04
+
+DESCRIPTION: This object allows you to easily and quickly popup a window
+in a certain place. The window can either be a DIV or a separate browser
+window.
+
+COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
+positioning errors - usually with Window positioning - occur on the 
+Macintosh platform. Due to bugs in Netscape 4.x, populating the popup 
+window with <STYLE> tags may cause errors.
+
+USAGE:
+// Create an object for a WINDOW popup
+var win = new PopupWindow(); 
+
+// Create an object for a DIV window using the DIV named 'mydiv'
+var win = new PopupWindow('mydiv'); 
+
+// Set the window to automatically hide itself when the user clicks 
+// anywhere else on the page except the popup
+win.autoHide(); 
+
+// Show the window relative to the anchor name passed in
+win.showPopup(anchorname);
+
+// Hide the popup
+win.hidePopup();
+
+// Set the size of the popup window (only applies to WINDOW popups
+win.setSize(width,height);
+
+// Populate the contents of the popup window that will be shown. If you 
+// change the contents while it is displayed, you will need to refresh()
+win.populate(string);
+
+// set the URL of the window, rather than populating its contents
+// manually
+win.setUrl("http://www.site.com/");
+
+// Refresh the contents of the popup
+win.refresh();
+
+// Specify how many pixels to the right of the anchor the popup will appear
+win.offsetX = 50;
+
+// Specify how many pixels below the anchor the popup will appear
+win.offsetY = 100;
+
+NOTES:
+1) Requires the functions in AnchorPosition.js
+
+2) Your anchor tag MUST contain both NAME and ID attributes which are the 
+   same. For example:
+   <A NAME="test" ID="test"> </A>
+
+3) There must be at least a space between <A> </A> for IE5.5 to see the 
+   anchor tag correctly. Do not do <A></A> with no space.
+
+4) When a PopupWindow object is created, a handler for 'onmouseup' is
+   attached to any event handler you may have already defined. Do NOT define
+   an event handler for 'onmouseup' after you define a PopupWindow object or
+   the autoHide() will not work correctly.
+*/ 
+
+// Set the position of the popup window based on the anchor
+function PopupWindow_getXYPosition(anchorname) {
+       var coordinates;
+       if (this.type == "WINDOW") {
+               coordinates = getAnchorWindowPosition(anchorname);
+               }
+       else {
+               coordinates = getAnchorPosition(anchorname);
+               }
+       this.x = coordinates.x;
+       this.y = coordinates.y;
+       }
+// Set width/height of DIV/popup window
+function PopupWindow_setSize(width,height) {
+       this.width = width;
+       this.height = height;
+       }
+// Fill the window with contents
+function PopupWindow_populate(contents) {
+       this.contents = contents;
+       this.populated = false;
+       }
+// Set the URL to go to
+function PopupWindow_setUrl(url) {
+       this.url = url;
+       }
+// Set the window popup properties
+function PopupWindow_setWindowProperties(props) {
+       this.windowProperties = props;
+       }
+// Refresh the displayed contents of the popup
+function PopupWindow_refresh() {
+       if (this.divName != null) {
+               // refresh the DIV object
+               if (this.use_gebi) {
+                       document.getElementById(this.divName).innerHTML = this.contents;
+                       }
+               else if (this.use_css) { 
+                       document.all[this.divName].innerHTML = this.contents;
+                       }
+               else if (this.use_layers) { 
+                       var d = document.layers[this.divName]; 
+                       d.document.open();
+                       d.document.writeln(this.contents);
+                       d.document.close();
+                       }
+               }
+       else {
+               if (this.popupWindow != null && !this.popupWindow.closed) {
+                       if (this.url!="") {
+                               this.popupWindow.location.href=this.url;
+                               }
+                       else {
+                               this.popupWindow.document.open();
+                               this.popupWindow.document.writeln(this.contents);
+                               this.popupWindow.document.close();
+                       }
+                       this.popupWindow.focus();
+                       }
+               }
+       }
+// Position and show the popup, relative to an anchor object
+function PopupWindow_showPopup(anchorname) {
+       this.getXYPosition(anchorname);
+       this.x += this.offsetX;
+       this.y += this.offsetY;
+       if (!this.populated && (this.contents != "")) {
+               this.populated = true;
+               this.refresh();
+               }
+       if (this.divName != null) {
+               // Show the DIV object
+               if (this.use_gebi) {
+                       document.getElementById(this.divName).style.left = this.x + "px";
+                       document.getElementById(this.divName).style.top = this.y + "px";
+                       document.getElementById(this.divName).style.visibility = "visible";
+                       }
+               else if (this.use_css) {
+                       document.all[this.divName].style.left = this.x;
+                       document.all[this.divName].style.top = this.y;
+                       document.all[this.divName].style.visibility = "visible";
+                       }
+               else if (this.use_layers) {
+                       document.layers[this.divName].left = this.x;
+                       document.layers[this.divName].top = this.y;
+                       document.layers[this.divName].visibility = "visible";
+                       }
+               }
+       else {
+               if (this.popupWindow == null || this.popupWindow.closed) {
+                       // If the popup window will go off-screen, move it so it doesn't
+                       if (this.x<0) { this.x=0; }
+                       if (this.y<0) { this.y=0; }
+                       if (screen && screen.availHeight) {
+                               if ((this.y + this.height) > screen.availHeight) {
+                                       this.y = screen.availHeight - this.height;
+                                       }
+                               }
+                       if (screen && screen.availWidth) {
+                               if ((this.x + this.width) > screen.availWidth) {
+                                       this.x = screen.availWidth - this.width;
+                                       }
+                               }
+                       var avoidAboutBlank = window.opera || ( document.layers && !navigator.mimeTypes['*'] ) || navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled );
+                       this.popupWindow = window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");
+                       }
+               this.refresh();
+               }
+       }
+// Hide the popup
+function PopupWindow_hidePopup() {
+       if (this.divName != null) {
+               if (this.use_gebi) {
+                       document.getElementById(this.divName).style.visibility = "hidden";
+                       }
+               else if (this.use_css) {
+                       document.all[this.divName].style.visibility = "hidden";
+                       }
+               else if (this.use_layers) {
+                       document.layers[this.divName].visibility = "hidden";
+                       }
+               }
+       else {
+               if (this.popupWindow && !this.popupWindow.closed) {
+                       this.popupWindow.close();
+                       this.popupWindow = null;
+                       }
+               }
+       }
+// Pass an event and return whether or not it was the popup DIV that was clicked
+function PopupWindow_isClicked(e) {
+       if (this.divName != null) {
+               if (this.use_layers) {
+                       var clickX = e.pageX;
+                       var clickY = e.pageY;
+                       var t = document.layers[this.divName];
+                       if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {
+                               return true;
+                               }
+                       else { return false; }
+                       }
+               else if (document.all) { // Need to hard-code this to trap IE for error-handling
+                       var t = window.event.srcElement;
+                       while (t.parentElement != null) {
+                               if (t.id==this.divName) {
+                                       return true;
+                                       }
+                               t = t.parentElement;
+                               }
+                       return false;
+                       }
+               else if (this.use_gebi && e) {
+                       var t = e.originalTarget;
+                       while (t.parentNode != null) {
+                               if (t.id==this.divName) {
+                                       return true;
+                                       }
+                               t = t.parentNode;
+                               }
+                       return false;
+                       }
+               return false;
+               }
+       return false;
+       }
+
+// Check an onMouseDown event to see if we should hide
+function PopupWindow_hideIfNotClicked(e) {
+       if (this.autoHideEnabled && !this.isClicked(e)) {
+               this.hidePopup();
+               }
+       }
+// Call this to make the DIV disable automatically when mouse is clicked outside it
+function PopupWindow_autoHide() {
+       this.autoHideEnabled = true;
+       }
+// This global function checks all PopupWindow objects onmouseup to see if they should be hidden
+function PopupWindow_hidePopupWindows(e) {
+       for (var i=0; i<popupWindowObjects.length; i++) {
+               if (popupWindowObjects[i] != null) {
+                       var p = popupWindowObjects[i];
+                       p.hideIfNotClicked(e);
+                       }
+               }
+       }
+// Run this immediately to attach the event listener
+function PopupWindow_attachListener() {
+       if (document.layers) {
+               document.captureEvents(Event.MOUSEUP);
+               }
+       window.popupWindowOldEventListener = document.onmouseup;
+       if (window.popupWindowOldEventListener != null) {
+               document.onmouseup = new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");
+               }
+       else {
+               document.onmouseup = PopupWindow_hidePopupWindows;
+               }
+       }
+// CONSTRUCTOR for the PopupWindow object
+// Pass it a DIV name to use a DHTML popup, otherwise will default to window popup
+function PopupWindow() {
+       if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
+       if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
+       if (!window.listenerAttached) {
+               window.listenerAttached = true;
+               PopupWindow_attachListener();
+               }
+       this.index = popupWindowIndex++;
+       popupWindowObjects[this.index] = this;
+       this.divName = null;
+       this.popupWindow = null;
+       this.width=0;
+       this.height=0;
+       this.populated = false;
+       this.visible = false;
+       this.autoHideEnabled = false;
+       
+       this.contents = "";
+       this.url="";
+       this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
+       if (arguments.length>0) {
+               this.type="DIV";
+               this.divName = arguments[0];
+               }
+       else {
+               this.type="WINDOW";
+               }
+       this.use_gebi = false;
+       this.use_css = false;
+       this.use_layers = false;
+       if (document.getElementById) { this.use_gebi = true; }
+       else if (document.all) { this.use_css = true; }
+       else if (document.layers) { this.use_layers = true; }
+       else { this.type = "WINDOW"; }
+       this.offsetX = 0;
+       this.offsetY = 0;
+       // Method mappings
+       this.getXYPosition = PopupWindow_getXYPosition;
+       this.populate = PopupWindow_populate;
+       this.setUrl = PopupWindow_setUrl;
+       this.setWindowProperties = PopupWindow_setWindowProperties;
+       this.refresh = PopupWindow_refresh;
+       this.showPopup = PopupWindow_showPopup;
+       this.hidePopup = PopupWindow_hidePopup;
+       this.setSize = PopupWindow_setSize;
+       this.isClicked = PopupWindow_isClicked;
+       this.autoHide = PopupWindow_autoHide;
+       this.hideIfNotClicked = PopupWindow_hideIfNotClicked;
+       }
+
+/* SOURCE FILE: CalendarPopup.js */
+
+// HISTORY
+// ------------------------------------------------------------------
+// Feb 7, 2005: Fixed a CSS styles to use px unit
+// March 29, 2004: Added check in select() method for the form field
+//      being disabled. If it is, just return and don't do anything.
+// March 24, 2004: Fixed bug - when month name and abbreviations were
+//      changed, date format still used original values.
+// January 26, 2004: Added support for drop-down month and year
+//      navigation (Thanks to Chris Reid for the idea)
+// September 22, 2003: Fixed a minor problem in YEAR calendar with
+//      CSS prefix.
+// August 19, 2003: Renamed the function to get styles, and made it
+//      work correctly without an object reference
+// August 18, 2003: Changed showYearNavigation and 
+//      showYearNavigationInput to optionally take an argument of
+//      true or false
+// July 31, 2003: Added text input option for year navigation.
+//      Added a per-calendar CSS prefix option to optionally use 
+//      different styles for different calendars.
+// July 29, 2003: Fixed bug causing the Today link to be clickable 
+//      even though today falls in a disabled date range.
+//      Changed formatting to use pure CSS, allowing greater control
+//      over look-and-feel options.
+// June 11, 2003: Fixed bug causing the Today link to be unselectable
+//      under certain cases when some days of week are disabled
+// March 14, 2003: Added ability to disable individual dates or date
+//      ranges, display as light gray and strike-through
+// March 14, 2003: Removed dependency on graypixel.gif and instead 
+///     use table border coloring
+// March 12, 2003: Modified showCalendar() function to allow optional
+//      start-date parameter
+// March 11, 2003: Modified select() function to allow optional
+//      start-date parameter
+/* 
+DESCRIPTION: This object implements a popup calendar to allow the user to
+select a date, month, quarter, or year.
+
+COMPATABILITY: Works with Netscape 4.x, 6.x, IE 5.x on Windows. Some small
+positioning errors - usually with Window positioning - occur on the 
+Macintosh platform.
+The calendar can be modified to work for any location in the world by 
+changing which weekday is displayed as the first column, changing the month
+names, and changing the column headers for each day.
+
+USAGE:
+// Create a new CalendarPopup object of type WINDOW
+var cal = new CalendarPopup(); 
+
+// Create a new CalendarPopup object of type DIV using the DIV named 'mydiv'
+var cal = new CalendarPopup('mydiv'); 
+
+// Easy method to link the popup calendar with an input box. 
+cal.select(inputObject, anchorname, dateFormat);
+// Same method, but passing a default date other than the field's current value
+cal.select(inputObject, anchorname, dateFormat, '01/02/2000');
+// This is an example call to the popup calendar from a link to populate an 
+// input box. Note that to use this, date.js must also be included!!
+<A HREF="#" onClick="cal.select(document.forms[0].date,'anchorname','MM/dd/yyyy'); return false;">Select</A>
+
+// Set the type of date select to be used. By default it is 'date'.
+cal.setDisplayType(type);
+
+// When a date, month, quarter, or year is clicked, a function is called and
+// passed the details. You must write this function, and tell the calendar
+// popup what the function name is.
+// Function to be called for 'date' select receives y, m, d
+cal.setReturnFunction(functionname);
+// Function to be called for 'month' select receives y, m
+cal.setReturnMonthFunction(functionname);
+// Function to be called for 'quarter' select receives y, q
+cal.setReturnQuarterFunction(functionname);
+// Function to be called for 'year' select receives y
+cal.setReturnYearFunction(functionname);
+
+// Show the calendar relative to a given anchor
+cal.showCalendar(anchorname);
+
+// Hide the calendar. The calendar is set to autoHide automatically
+cal.hideCalendar();
+
+// Set the month names to be used. Default are English month names
+cal.setMonthNames("January","February","March",...);
+
+// Set the month abbreviations to be used. Default are English month abbreviations
+cal.setMonthAbbreviations("Jan","Feb","Mar",...);
+
+// Show navigation for changing by the year, not just one month at a time
+cal.showYearNavigation();
+
+// Show month and year dropdowns, for quicker selection of month of dates
+cal.showNavigationDropdowns();
+
+// Set the text to be used above each day column. The days start with 
+// sunday regardless of the value of WeekStartDay
+cal.setDayHeaders("S","M","T",...);
+
+// Set the day for the first column in the calendar grid. By default this
+// is Sunday (0) but it may be changed to fit the conventions of other
+// countries.
+cal.setWeekStartDay(1); // week is Monday - Sunday
+
+// Set the weekdays which should be disabled in the 'date' select popup. You can
+// then allow someone to only select week end dates, or Tuedays, for example
+cal.setDisabledWeekDays(0,1); // To disable selecting the 1st or 2nd days of the week
+
+// Selectively disable individual days or date ranges. Disabled days will not
+// be clickable, and show as strike-through text on current browsers.
+// Date format is any format recognized by parseDate() in date.js
+// Pass a single date to disable:
+cal.addDisabledDates("2003-01-01");
+// Pass null as the first parameter to mean "anything up to and including" the
+// passed date:
+cal.addDisabledDates(null, "01/02/03");
+// Pass null as the second parameter to mean "including the passed date and
+// anything after it:
+cal.addDisabledDates("Jan 01, 2003", null);
+// Pass two dates to disable all dates inbetween and including the two
+cal.addDisabledDates("January 01, 2003", "Dec 31, 2003");
+
+// When the 'year' select is displayed, set the number of years back from the 
+// current year to start listing years. Default is 2.
+// This is also used for year drop-down, to decide how many years +/- to display
+cal.setYearSelectStartOffset(2);
+
+// Text for the word "Today" appearing on the calendar
+cal.setTodayText("Today");
+
+// The calendar uses CSS classes for formatting. If you want your calendar to
+// have unique styles, you can set the prefix that will be added to all the
+// classes in the output.
+// For example, normal output may have this:
+//     <SPAN CLASS="cpTodayTextDisabled">Today<SPAN>
+// But if you set the prefix like this:
+cal.setCssPrefix("Test");
+// The output will then look like:
+//     <SPAN CLASS="TestcpTodayTextDisabled">Today<SPAN>
+// And you can define that style somewhere in your page.
+
+// When using Year navigation, you can make the year be an input box, so
+// the user can manually change it and jump to any year
+cal.showYearNavigationInput();
+
+// Set the calendar offset to be different than the default. By default it
+// will appear just below and to the right of the anchorname. So if you have
+// a text box where the date will go and and anchor immediately after the
+// text box, the calendar will display immediately under the text box.
+cal.offsetX = 20;
+cal.offsetY = 20;
+
+NOTES:
+1) Requires the functions in AnchorPosition.js and PopupWindow.js
+
+2) Your anchor tag MUST contain both NAME and ID attributes which are the 
+   same. For example:
+   <A NAME="test" ID="test"> </A>
+
+3) There must be at least a space between <A> </A> for IE5.5 to see the 
+   anchor tag correctly. Do not do <A></A> with no space.
+
+4) When a CalendarPopup object is created, a handler for 'onmouseup' is
+   attached to any event handler you may have already defined. Do NOT define
+   an event handler for 'onmouseup' after you define a CalendarPopup object 
+   or the autoHide() will not work correctly.
+   
+5) The calendar popup display uses style sheets to make it look nice.
+
+*/ 
+
+// CONSTRUCTOR for the CalendarPopup Object
+function CalendarPopup() {
+       var c;
+       if (arguments.length>0) {
+               c = new PopupWindow(arguments[0]);
+               }
+       else {
+               c = new PopupWindow();
+               c.setSize(150,175);
+               }
+       c.offsetX = -152;
+       c.offsetY = 25;
+       c.autoHide();
+       // Calendar-specific properties
+       c.monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
+       c.monthAbbreviations = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
+       c.dayHeaders = new Array("S","M","T","W","T","F","S");
+       c.returnFunction = "CP_tmpReturnFunction";
+       c.returnMonthFunction = "CP_tmpReturnMonthFunction";
+       c.returnQuarterFunction = "CP_tmpReturnQuarterFunction";
+       c.returnYearFunction = "CP_tmpReturnYearFunction";
+       c.weekStartDay = 0;
+       c.isShowYearNavigation = false;
+       c.displayType = "date";
+       c.disabledWeekDays = new Object();
+       c.disabledDatesExpression = "";
+       c.yearSelectStartOffset = 2;
+       c.currentDate = null;
+       c.todayText="Today";
+       c.cssPrefix="";
+       c.isShowNavigationDropdowns=false;
+       c.isShowYearNavigationInput=false;
+       window.CP_calendarObject = null;
+       window.CP_targetInput = null;
+       window.CP_dateFormat = "MM/dd/yyyy";
+       // Method mappings
+       c.copyMonthNamesToWindow = CP_copyMonthNamesToWindow;
+       c.setReturnFunction = CP_setReturnFunction;
+       c.setReturnMonthFunction = CP_setReturnMonthFunction;
+       c.setReturnQuarterFunction = CP_setReturnQuarterFunction;
+       c.setReturnYearFunction = CP_setReturnYearFunction;
+       c.setMonthNames = CP_setMonthNames;
+       c.setMonthAbbreviations = CP_setMonthAbbreviations;
+       c.setDayHeaders = CP_setDayHeaders;
+       c.setWeekStartDay = CP_setWeekStartDay;
+       c.setDisplayType = CP_setDisplayType;
+       c.setDisabledWeekDays = CP_setDisabledWeekDays;
+       c.addDisabledDates = CP_addDisabledDates;
+       c.setYearSelectStartOffset = CP_setYearSelectStartOffset;
+       c.setTodayText = CP_setTodayText;
+       c.showYearNavigation = CP_showYearNavigation;
+       c.showCalendar = CP_showCalendar;
+       c.hideCalendar = CP_hideCalendar;
+       c.getStyles = getCalendarStyles;
+       c.refreshCalendar = CP_refreshCalendar;
+       c.getCalendar = CP_getCalendar;
+       c.select = CP_select;
+       c.setCssPrefix = CP_setCssPrefix;
+       c.showNavigationDropdowns = CP_showNavigationDropdowns;
+       c.showYearNavigationInput = CP_showYearNavigationInput;
+       c.copyMonthNamesToWindow();
+       // Return the object
+       return c;
+       }
+function CP_copyMonthNamesToWindow() {
+       // Copy these values over to the date.js 
+       if (typeof(window.MONTH_NAMES)!="undefined" && window.MONTH_NAMES!=null) {
+               window.MONTH_NAMES = new Array();
+               for (var i=0; i<this.monthNames.length; i++) {
+                       window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthNames[i];
+               }
+               for (var i=0; i<this.monthAbbreviations.length; i++) {
+                       window.MONTH_NAMES[window.MONTH_NAMES.length] = this.monthAbbreviations[i];
+               }
+       }
+}
+// Temporary default functions to be called when items clicked, so no error is thrown
+function CP_tmpReturnFunction(y,m,d) { 
+       if (window.CP_targetInput!=null) {
+               var dt = new Date(y,m-1,d,0,0,0);
+               if (window.CP_calendarObject!=null) { window.CP_calendarObject.copyMonthNamesToWindow(); }
+               window.CP_targetInput.value = formatDate(dt,window.CP_dateFormat);
+               }
+       else {
+               alert('Use setReturnFunction() to define which function will get the clicked results!'); 
+               }
+       }
+function CP_tmpReturnMonthFunction(y,m) { 
+       alert('Use setReturnMonthFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , month='+m); 
+       }
+function CP_tmpReturnQuarterFunction(y,q) { 
+       alert('Use setReturnQuarterFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , quarter='+q); 
+       }
+function CP_tmpReturnYearFunction(y) { 
+       alert('Use setReturnYearFunction() to define which function will get the clicked results!\nYou clicked: year='+y); 
+       }
+
+// Set the name of the functions to call to get the clicked item
+function CP_setReturnFunction(name) { this.returnFunction = name; }
+function CP_setReturnMonthFunction(name) { this.returnMonthFunction = name; }
+function CP_setReturnQuarterFunction(name) { this.returnQuarterFunction = name; }
+function CP_setReturnYearFunction(name) { this.returnYearFunction = name; }
+
+// Over-ride the built-in month names
+function CP_setMonthNames() {
+       for (var i=0; i<arguments.length; i++) { this.monthNames[i] = arguments[i]; }
+       this.copyMonthNamesToWindow();
+       }
+
+// Over-ride the built-in month abbreviations
+function CP_setMonthAbbreviations() {
+       for (var i=0; i<arguments.length; i++) { this.monthAbbreviations[i] = arguments[i]; }
+       this.copyMonthNamesToWindow();
+       }
+
+// Over-ride the built-in column headers for each day
+function CP_setDayHeaders() {
+       for (var i=0; i<arguments.length; i++) { this.dayHeaders[i] = arguments[i]; }
+       }
+
+// Set the day of the week (0-7) that the calendar display starts on
+// This is for countries other than the US whose calendar displays start on Monday(1), for example
+function CP_setWeekStartDay(day) { this.weekStartDay = day; }
+
+// Show next/last year navigation links
+function CP_showYearNavigation() { this.isShowYearNavigation = (arguments.length>0)?arguments[0]:true; }
+
+// Which type of calendar to display
+function CP_setDisplayType(type) {
+       if (type!="date"&&type!="week-end"&&type!="month"&&type!="quarter"&&type!="year") { alert("Invalid display type! Must be one of: date,week-end,month,quarter,year"); return false; }
+       this.displayType=type;
+       }
+
+// How many years back to start by default for year display
+function CP_setYearSelectStartOffset(num) { this.yearSelectStartOffset=num; }
+
+// Set which weekdays should not be clickable
+function CP_setDisabledWeekDays() {
+       this.disabledWeekDays = new Object();
+       for (var i=0; i<arguments.length; i++) { this.disabledWeekDays[arguments[i]] = true; }
+       }
+       
+// Disable individual dates or ranges
+// Builds an internal logical test which is run via eval() for efficiency
+function CP_addDisabledDates(start, end) {
+       if (arguments.length==1) { end=start; }
+       if (start==null && end==null) { return; }
+       if (this.disabledDatesExpression!="") { this.disabledDatesExpression+= "||"; }
+       if (start!=null) { start = parseDate(start); start=""+start.getFullYear()+LZ(start.getMonth()+1)+LZ(start.getDate());}
+       if (end!=null) { end=parseDate(end); end=""+end.getFullYear()+LZ(end.getMonth()+1)+LZ(end.getDate());}
+       if (start==null) { this.disabledDatesExpression+="(ds<="+end+")"; }
+       else if (end  ==null) { this.disabledDatesExpression+="(ds>="+start+")"; }
+       else { this.disabledDatesExpression+="(ds>="+start+"&&ds<="+end+")"; }
+       }
+       
+// Set the text to use for the "Today" link
+function CP_setTodayText(text) {
+       this.todayText = text;
+       }
+
+// Set the prefix to be added to all CSS classes when writing output
+function CP_setCssPrefix(val) { 
+       this.cssPrefix = val; 
+       }
+
+// Show the navigation as an dropdowns that can be manually changed
+function CP_showNavigationDropdowns() { this.isShowNavigationDropdowns = (arguments.length>0)?arguments[0]:true; }
+
+// Show the year navigation as an input box that can be manually changed
+function CP_showYearNavigationInput() { this.isShowYearNavigationInput = (arguments.length>0)?arguments[0]:true; }
+
+// Hide a calendar object
+function CP_hideCalendar() {
+       if (arguments.length > 0) { window.popupWindowObjects[arguments[0]].hidePopup(); }
+       else { this.hidePopup(); }
+       }
+
+// Refresh the contents of the calendar display
+function CP_refreshCalendar(index) {
+       var calObject = window.popupWindowObjects[index];
+       if (arguments.length>1) { 
+               calObject.populate(calObject.getCalendar(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]));
+               }
+       else {
+               calObject.populate(calObject.getCalendar());
+               }
+       calObject.refresh();
+       }
+
+// Populate the calendar and display it
+function CP_showCalendar(anchorname) {
+       if (arguments.length>1) {
+               if (arguments[1]==null||arguments[1]=="") {
+                       this.currentDate=new Date();
+                       }
+               else {
+                       this.currentDate=new Date(parseDate(arguments[1]));
+                       }
+               }
+       this.populate(this.getCalendar());
+       this.showPopup(anchorname);
+       }
+
+// Simple method to interface popup calendar with a text-entry box
+function CP_select(inputobj, linkname, format) {
+       var selectedDate=(arguments.length>3)?arguments[3]:null;
+       if (!window.getDateFromFormat) {
+               alert("calendar.select: To use this method you must also include 'date.js' for date formatting");
+               return;
+               }
+       if (this.displayType!="date"&&this.displayType!="week-end") {
+               alert("calendar.select: This function can only be used with displayType 'date' or 'week-end'");
+               return;
+               }
+       if (inputobj.type!="text" && inputobj.type!="hidden" && inputobj.type!="textarea") { 
+               alert("calendar.select: Input object passed is not a valid form input object"); 
+               window.CP_targetInput=null;
+               return;
+               }
+       if (inputobj.disabled) { return; } // Can't use calendar input on disabled form input!
+       window.CP_targetInput = inputobj;
+       window.CP_calendarObject = this;
+       this.currentDate=null;
+       var time=0;
+       if (selectedDate!=null) {
+               time = getDateFromFormat(selectedDate,format)
+               }
+       else if (inputobj.value!="") {
+               time = getDateFromFormat(inputobj.value,format);
+               }
+       if (selectedDate!=null || inputobj.value!="") {
+               if (time==0) { this.currentDate=null; }
+               else { this.currentDate=new Date(time); }
+               }
+       window.CP_dateFormat = format;
+       this.showCalendar(linkname);
+       }
+       
+// Get style block needed to display the calendar correctly
+function getCalendarStyles() {
+       var result = "";
+       var p = "";
+       if (this!=null && typeof(this.cssPrefix)!="undefined" && this.cssPrefix!=null && this.cssPrefix!="") { p=this.cssPrefix; }
+       result += "<STYLE>\n";
+       result += "."+p+"cpYearNavigation,."+p+"cpMonthNavigation { background-color:#C0C0C0; text-align:center; vertical-align:center; text-decoration:none; color:#000000; font-weight:bold; }\n";
+       result += "."+p+"cpDayColumnHeader, ."+p+"cpYearNavigation,."+p+"cpMonthNavigation,."+p+"cpCurrentMonthDate,."+p+"cpCurrentMonthDateDisabled,."+p+"cpOtherMonthDate,."+p+"cpOtherMonthDateDisabled,."+p+"cpCurrentDate,."+p+"cpCurrentDateDisabled,."+p+"cpTodayText,."+p+"cpTodayTextDisabled,."+p+"cpText { font-family:arial; font-size:8pt; }\n";
+       result += "TD."+p+"cpDayColumnHeader { text-align:right; border:solid thin #C0C0C0;border-width:0px 0px 1px 0px; }\n";
+       result += "."+p+"cpCurrentMonthDate, ."+p+"cpOtherMonthDate, ."+p+"cpCurrentDate  { text-align:right; text-decoration:none; }\n";
+       result += "."+p+"cpCurrentMonthDateDisabled, ."+p+"cpOtherMonthDateDisabled, ."+p+"cpCurrentDateDisabled { color:#D0D0D0; text-align:right; text-decoration:line-through; }\n";
+       result += "."+p+"cpCurrentMonthDate, .cpCurrentDate { color:#000000; }\n";
+       result += "."+p+"cpOtherMonthDate { color:#808080; }\n";
+       result += "TD."+p+"cpCurrentDate { color:white; background-color: #C0C0C0; border-width:1px; border:solid thin #800000; }\n";
+       result += "TD."+p+"cpCurrentDateDisabled { border-width:1px; border:solid thin #FFAAAA; }\n";
+       result += "TD."+p+"cpTodayText, TD."+p+"cpTodayTextDisabled { border:solid thin #C0C0C0; border-width:1px 0px 0px 0px;}\n";
+       result += "A."+p+"cpTodayText, SPAN."+p+"cpTodayTextDisabled { height:20px; }\n";
+       result += "A."+p+"cpTodayText { color:black; }\n";
+       result += "."+p+"cpTodayTextDisabled { color:#D0D0D0; }\n";
+       result += "."+p+"cpBorder { border:solid thin #808080; }\n";
+       result += "</STYLE>\n";
+       return result;
+       }
+
+// Return a string containing all the calendar code to be displayed
+function CP_getCalendar() {
+       var now = new Date();
+       // Reference to window
+       if (this.type == "WINDOW") { var windowref = "window.opener."; }
+       else { var windowref = ""; }
+       var result = "";
+       // If POPUP, write entire HTML document
+       if (this.type == "WINDOW") {
+               result += "<HTML><HEAD><TITLE>Calendar</TITLE>"+this.getStyles()+"</HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 RIGHTMARGIN=0 LEFTMARGIN=0>\n";
+               result += '<CENTER><TABLE WIDTH=100% BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>\n';
+               }
+       else {
+               result += '<TABLE CLASS="'+this.cssPrefix+'cpBorder" WIDTH=144 BORDER=1 BORDERWIDTH=1 CELLSPACING=0 CELLPADDING=1>\n';
+               result += '<TR><TD ALIGN=CENTER>\n';
+               result += '<CENTER>\n';
+               }
+       // Code for DATE display (default)
+       // -------------------------------
+       if (this.displayType=="date" || this.displayType=="week-end") {
+               if (this.currentDate==null) { this.currentDate = now; }
+               if (arguments.length > 0) { var month = arguments[0]; }
+                       else { var month = this.currentDate.getMonth()+1; }
+               if (arguments.length > 1 && arguments[1]>0 && arguments[1]-0==arguments[1]) { var year = arguments[1]; }
+                       else { var year = this.currentDate.getFullYear(); }
+               var daysinmonth= new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
+               if ( ( (year%4 == 0)&&(year%100 != 0) ) || (year%400 == 0) ) {
+                       daysinmonth[2] = 29;
+                       }
+               var current_month = new Date(year,month-1,1);
+               var display_year = year;
+               var display_month = month;
+               var display_date = 1;
+               var weekday= current_month.getDay();
+               var offset = 0;
+               
+               offset = (weekday >= this.weekStartDay) ? weekday-this.weekStartDay : 7-this.weekStartDay+weekday ;
+               if (offset > 0) {
+                       display_month--;
+                       if (display_month < 1) { display_month = 12; display_year--; }
+                       display_date = daysinmonth[display_month]-offset+1;
+                       }
+               var next_month = month+1;
+               var next_month_year = year;
+               if (next_month > 12) { next_month=1; next_month_year++; }
+               var last_month = month-1;
+               var last_month_year = year;
+               if (last_month < 1) { last_month=12; last_month_year--; }
+               var date_class;
+               if (this.type!="WINDOW") {
+                       result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
+                       }
+               result += '<TR>\n';
+               var refresh = windowref+'CP_refreshCalendar';
+               var refreshLink = 'javascript:' + refresh;
+               if (this.isShowNavigationDropdowns) {
+                       result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="78" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpMonthNavigation" name="cpMonth" onChange="'+refresh+'('+this.index+',this.options[this.selectedIndex].value-0,'+(year-0)+');">';
+                       for( var monthCounter=1; monthCounter<=12; monthCounter++ ) {
+                               var selected = (monthCounter==month) ? 'SELECTED' : '';
+                               result += '<option value="'+monthCounter+'" '+selected+'>'+this.monthNames[monthCounter-1]+'</option>';
+                               }
+                       result += '</select></TD>';
+                       result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';
+
+                       result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="56" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpYearNavigation" name="cpYear" onChange="'+refresh+'('+this.index+','+month+',this.options[this.selectedIndex].value-0);">';
+                       for( var yearCounter=year-this.yearSelectStartOffset; yearCounter<=year+this.yearSelectStartOffset; yearCounter++ ) {
+                               var selected = (yearCounter==year) ? 'SELECTED' : '';
+                               result += '<option value="'+yearCounter+'" '+selected+'>'+yearCounter+'</option>';
+                               }
+                       result += '</select></TD>';
+                       }
+               else {
+                       if (this.isShowYearNavigation) {
+                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;</A></TD>';
+                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="58"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+'</SPAN></TD>';
+                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;</A></TD>';
+                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';
+
+                               result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year-1)+');">&lt;</A></TD>';
+                               if (this.isShowYearNavigationInput) {
+                                       result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><INPUT NAME="cpYear" CLASS="'+this.cssPrefix+'cpYearNavigation" SIZE="4" MAXLENGTH="4" VALUE="'+year+'" onBlur="'+refresh+'('+this.index+','+month+',this.value-0);"></TD>';
+                                       }
+                               else {
+                                       result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><SPAN CLASS="'+this.cssPrefix+'cpYearNavigation">'+year+'</SPAN></TD>';
+                                       }
+                               result += '<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year+1)+');">&gt;</A></TD>';
+                               }
+                       else {
+                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;&lt;</A></TD>\n';
+                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="100"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+' '+year+'</SPAN></TD>\n';
+                               result += '<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;&gt;</A></TD>\n';
+                               }
+                       }
+               result += '</TR></TABLE>\n';
+               result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=0 CELLPADDING=1 ALIGN=CENTER>\n';
+               result += '<TR>\n';
+               for (var j=0; j<7; j++) {
+
+                       result += '<TD CLASS="'+this.cssPrefix+'cpDayColumnHeader" WIDTH="14%"><SPAN CLASS="'+this.cssPrefix+'cpDayColumnHeader">'+this.dayHeaders[(this.weekStartDay+j)%7]+'</TD>\n';
+                       }
+               result += '</TR>\n';
+               for (var row=1; row<=6; row++) {
+                       result += '<TR>\n';
+                       for (var col=1; col<=7; col++) {
+                               var disabled=false;
+                               if (this.disabledDatesExpression!="") {
+                                       var ds=""+display_year+LZ(display_month)+LZ(display_date);
+                                       eval("disabled=("+this.disabledDatesExpression+")");
+                                       }
+                               var dateClass = "";
+                               if ((display_month == this.currentDate.getMonth()+1) && (display_date==this.currentDate.getDate()) && (display_year==this.currentDate.getFullYear())) {
+                                       dateClass = "cpCurrentDate";
+                                       }
+                               else if (display_month == month) {
+                                       dateClass = "cpCurrentMonthDate";
+                                       }
+                               else {
+                                       dateClass = "cpOtherMonthDate";
+                                       }
+                               if (disabled || this.disabledWeekDays[col-1]) {
+                                       result += '     <TD CLASS="'+this.cssPrefix+dateClass+'"><SPAN CLASS="'+this.cssPrefix+dateClass+'Disabled">'+display_date+'</SPAN></TD>\n';
+                                       }
+                               else {
+                                       var selected_date = display_date;
+                                       var selected_month = display_month;
+                                       var selected_year = display_year;
+                                       if (this.displayType=="week-end") {
+                                               var d = new Date(selected_year,selected_month-1,selected_date,0,0,0,0);
+                                               d.setDate(d.getDate() + (7-col));
+                                               selected_year = d.getYear();
+                                               if (selected_year < 1000) { selected_year += 1900; }
+                                               selected_month = d.getMonth()+1;
+                                               selected_date = d.getDate();
+                                               }
+                                       result += '     <TD CLASS="'+this.cssPrefix+dateClass+'"><A HREF="javascript:'+windowref+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+this.cssPrefix+dateClass+'">'+display_date+'</A></TD>\n';
+                                       }
+                               display_date++;
+                               if (display_date > daysinmonth[display_month]) {
+                                       display_date=1;
+                                       display_month++;
+                                       }
+                               if (display_month > 12) {
+                                       display_month=1;
+                                       display_year++;
+                                       }
+                               }
+                       result += '</TR>';
+                       }
+               var current_weekday = now.getDay() - this.weekStartDay;
+               if (current_weekday < 0) {
+                       current_weekday += 7;
+                       }
+               result += '<TR>\n';
+               result += '     <TD COLSPAN=7 ALIGN=CENTER CLASS="'+this.cssPrefix+'cpTodayText">\n';
+               if (this.disabledDatesExpression!="") {
+                       var ds=""+now.getFullYear()+LZ(now.getMonth()+1)+LZ(now.getDate());
+                       eval("disabled=("+this.disabledDatesExpression+")");
+                       }
+               if (disabled || this.disabledWeekDays[current_weekday+1]) {
+                       result += '             <SPAN CLASS="'+this.cssPrefix+'cpTodayTextDisabled">'+this.todayText+'</SPAN>\n';
+                       }
+               else {
+                       result += '             <A CLASS="'+this.cssPrefix+'cpTodayText" HREF="javascript:'+windowref+this.returnFunction+'(\''+now.getFullYear()+'\',\''+(now.getMonth()+1)+'\',\''+now.getDate()+'\');'+windowref+'CP_hideCalendar(\''+this.index+'\');">'+this.todayText+'</A>\n';
+                       }
+               result += '             <BR>\n';
+               result += '     </TD></TR></TABLE></CENTER></TD></TR></TABLE>\n';
+       }
+
+       // Code common for MONTH, QUARTER, YEAR
+       // ------------------------------------
+       if (this.displayType=="month" || this.displayType=="quarter" || this.displayType=="year") {
+               if (arguments.length > 0) { var year = arguments[0]; }
+               else { 
+                       if (this.displayType=="year") { var year = now.getFullYear()-this.yearSelectStartOffset; }
+                       else { var year = now.getFullYear(); }
+                       }
+               if (this.displayType!="year" && this.isShowYearNavigation) {
+                       result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
+                       result += '<TR>\n';
+                       result += '     <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-1)+');">&lt;&lt;</A></TD>\n';
+                       result += '     <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="100">'+year+'</TD>\n';
+                       result += '     <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+1)+');">&gt;&gt;</A></TD>\n';
+                       result += '</TR></TABLE>\n';
+                       }
+               }
+               
+       // Code for MONTH display 
+       // ----------------------
+       if (this.displayType=="month") {
+               // If POPUP, write entire HTML document
+               result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';
+               for (var i=0; i<4; i++) {
+                       result += '<TR>';
+                       for (var j=0; j<3; j++) {
+                               var monthindex = ((i*3)+j);
+                               result += '<TD WIDTH=33% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnMonthFunction+'('+year+','+(monthindex+1)+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+this.monthAbbreviations[monthindex]+'</A></TD>';
+                               }
+                       result += '</TR>';
+                       }
+               result += '</TABLE></CENTER></TD></TR></TABLE>\n';
+               }
+       
+       // Code for QUARTER display
+       // ------------------------
+       if (this.displayType=="quarter") {
+               result += '<BR><TABLE WIDTH=120 BORDER=1 CELLSPACING=0 CELLPADDING=0 ALIGN=CENTER>\n';
+               for (var i=0; i<2; i++) {
+                       result += '<TR>';
+                       for (var j=0; j<2; j++) {
+                               var quarter = ((i*2)+j+1);
+                               result += '<TD WIDTH=50% ALIGN=CENTER><BR><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnQuarterFunction+'('+year+','+quarter+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">Q'+quarter+'</A><BR><BR></TD>';
+                               }
+                       result += '</TR>';
+                       }
+               result += '</TABLE></CENTER></TD></TR></TABLE>\n';
+               }
+
+       // Code for YEAR display
+       // ---------------------
+       if (this.displayType=="year") {
+               var yearColumnSize = 4;
+               result += "<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
+               result += '<TR>\n';
+               result += '     <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-(yearColumnSize*2))+');">&lt;&lt;</A></TD>\n';
+               result += '     <TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+(yearColumnSize*2))+');">&gt;&gt;</A></TD>\n';
+               result += '</TR></TABLE>\n';
+               result += '<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';
+               for (var i=0; i<yearColumnSize; i++) {
+                       for (var j=0; j<2; j++) {
+                               var currentyear = year+(j*yearColumnSize)+i;
+                               result += '<TD WIDTH=50% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnYearFunction+'('+currentyear+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+currentyear+'</A></TD>';
+                               }
+                       result += '</TR>';
+                       }
+               result += '</TABLE></CENTER></TD></TR></TABLE>\n';
+               }
+       // Common
+       if (this.type == "WINDOW") {
+               result += "</BODY></HTML>\n";
+               }
+       return result;
+       }
index f46ff55d0e511f5b26e381edfdc1f3c1845fa41d..c027f19c05f75a0bd68196b9a9730fa9e7d04bdd 100644 (file)
-/*\r
- * jQuery Form Plugin\r
- * version: 2.28 (10-MAY-2009)\r
- * @requires jQuery v1.2.2 or later\r
- *\r
- * Examples and documentation at: http://malsup.com/jquery/form/\r
- * Dual licensed under the MIT and GPL licenses:\r
- *   http://www.opensource.org/licenses/mit-license.php\r
- *   http://www.gnu.org/licenses/gpl.html\r
- */\r
-;(function($) {\r
-\r
-/*\r
-    Usage Note:\r
-    -----------\r
-    Do not use both ajaxSubmit and ajaxForm on the same form.  These\r
-    functions are intended to be exclusive.  Use ajaxSubmit if you want\r
-    to bind your own submit handler to the form.  For example,\r
-\r
-    $(document).ready(function() {\r
-        $('#myForm').bind('submit', function() {\r
-            $(this).ajaxSubmit({\r
-                target: '#output'\r
-            });\r
-            return false; // <-- important!\r
-        });\r
-    });\r
-\r
-    Use ajaxForm when you want the plugin to manage all the event binding\r
-    for you.  For example,\r
-\r
-    $(document).ready(function() {\r
-        $('#myForm').ajaxForm({\r
-            target: '#output'\r
-        });\r
-    });\r
-\r
-    When using ajaxForm, the ajaxSubmit function will be invoked for you\r
-    at the appropriate time.\r
-*/\r
-\r
-/**\r
- * ajaxSubmit() provides a mechanism for immediately submitting\r
- * an HTML form using AJAX.\r
- */\r
-$.fn.ajaxSubmit = function(options) {\r
-    // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)\r
-    if (!this.length) {\r
-        log('ajaxSubmit: skipping submit process - no element selected');\r
-        return this;\r
-    }\r
-\r
-    if (typeof options == 'function')\r
-        options = { success: options };\r
-\r
-    var url = $.trim(this.attr('action'));\r
-    if (url) {\r
-           // clean url (don't include hash vaue)\r
-           url = (url.match(/^([^#]+)/)||[])[1];\r
-       }\r
-       url = url || window.location.href || ''\r
-\r
-    options = $.extend({\r
-        url:  url,\r
-        type: this.attr('method') || 'GET'\r
-    }, options || {});\r
-\r
-    // hook for manipulating the form data before it is extracted;\r
-    // convenient for use with rich editors like tinyMCE or FCKEditor\r
-    var veto = {};\r
-    this.trigger('form-pre-serialize', [this, options, veto]);\r
-    if (veto.veto) {\r
-        log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');\r
-        return this;\r
-    }\r
-\r
-    // provide opportunity to alter form data before it is serialized\r
-    if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {\r
-        log('ajaxSubmit: submit aborted via beforeSerialize callback');\r
-        return this;\r
-    }\r
-\r
-    var a = this.formToArray(options.semantic);\r
-    if (options.data) {\r
-        options.extraData = options.data;\r
-        for (var n in options.data) {\r
-          if(options.data[n] instanceof Array) {\r
-            for (var k in options.data[n])\r
-              a.push( { name: n, value: options.data[n][k] } );\r
-          }\r
-          else\r
-             a.push( { name: n, value: options.data[n] } );\r
-        }\r
-    }\r
-\r
-    // give pre-submit callback an opportunity to abort the submit\r
-    if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {\r
-        log('ajaxSubmit: submit aborted via beforeSubmit callback');\r
-        return this;\r
-    }\r
-\r
-    // fire vetoable 'validate' event\r
-    this.trigger('form-submit-validate', [a, this, options, veto]);\r
-    if (veto.veto) {\r
-        log('ajaxSubmit: submit vetoed via form-submit-validate trigger');\r
-        return this;\r
-    }\r
-\r
-    var q = $.param(a);\r
-\r
-    if (options.type.toUpperCase() == 'GET') {\r
-        options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;\r
-        options.data = null;  // data is null for 'get'\r
-    }\r
-    else\r
-        options.data = q; // data is the query string for 'post'\r
-\r
-    var $form = this, callbacks = [];\r
-    if (options.resetForm) callbacks.push(function() { $form.resetForm(); });\r
-    if (options.clearForm) callbacks.push(function() { $form.clearForm(); });\r
-\r
-    // perform a load on the target only if dataType is not provided\r
-    if (!options.dataType && options.target) {\r
-        var oldSuccess = options.success || function(){};\r
-        callbacks.push(function(data) {\r
-            $(options.target).html(data).each(oldSuccess, arguments);\r
-        });\r
-    }\r
-    else if (options.success)\r
-        callbacks.push(options.success);\r
-\r
-    options.success = function(data, status) {\r
-        for (var i=0, max=callbacks.length; i < max; i++)\r
-            callbacks[i].apply(options, [data, status, $form]);\r
-    };\r
-\r
-    // are there files to upload?\r
-    var files = $('input:file', this).fieldValue();\r
-    var found = false;\r
-    for (var j=0; j < files.length; j++)\r
-        if (files[j])\r
-            found = true;\r
-\r
-       var multipart = false;\r
-//     var mp = 'multipart/form-data';\r
-//     multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);\r
-\r
-    // options.iframe allows user to force iframe mode\r
-   if (options.iframe || found || multipart) {\r
-       // hack to fix Safari hang (thanks to Tim Molendijk for this)\r
-       // see:  http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d\r
-       if (options.closeKeepAlive)\r
-           $.get(options.closeKeepAlive, fileUpload);\r
-       else\r
-           fileUpload();\r
-       }\r
-   else\r
-       $.ajax(options);\r
-\r
-    // fire 'notify' event\r
-    this.trigger('form-submit-notify', [this, options]);\r
-    return this;\r
-\r
-\r
-    // private function for handling file uploads (hat tip to YAHOO!)\r
-    function fileUpload() {\r
-        var form = $form[0];\r
-\r
-        if ($(':input[name=submit]', form).length) {\r
-            alert('Error: Form elements must not be named "submit".');\r
-            return;\r
-        }\r
-\r
-        var opts = $.extend({}, $.ajaxSettings, options);\r
-               var s = $.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts);\r
-\r
-        var id = 'jqFormIO' + (new Date().getTime());\r
-        var $io = $('<iframe id="' + id + '" name="' + id + '" src="about:blank" />');\r
-        var io = $io[0];\r
-\r
-        $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });\r
-\r
-        var xhr = { // mock object\r
-            aborted: 0,\r
-            responseText: null,\r
-            responseXML: null,\r
-            status: 0,\r
-            statusText: 'n/a',\r
-            getAllResponseHeaders: function() {},\r
-            getResponseHeader: function() {},\r
-            setRequestHeader: function() {},\r
-            abort: function() {\r
-                this.aborted = 1;\r
-                $io.attr('src','about:blank'); // abort op in progress\r
-            }\r
-        };\r
-\r
-        var g = opts.global;\r
-        // trigger ajax global events so that activity/block indicators work like normal\r
-        if (g && ! $.active++) $.event.trigger("ajaxStart");\r
-        if (g) $.event.trigger("ajaxSend", [xhr, opts]);\r
-\r
-               if (s.beforeSend && s.beforeSend(xhr, s) === false) {\r
-                       s.global && $.active--;\r
-                       return;\r
-        }\r
-        if (xhr.aborted)\r
-            return;\r
-\r
-        var cbInvoked = 0;\r
-        var timedOut = 0;\r
-\r
-        // add submitting element to data if we know it\r
-        var sub = form.clk;\r
-        if (sub) {\r
-            var n = sub.name;\r
-            if (n && !sub.disabled) {\r
-                options.extraData = options.extraData || {};\r
-                options.extraData[n] = sub.value;\r
-                if (sub.type == "image") {\r
-                    options.extraData[name+'.x'] = form.clk_x;\r
-                    options.extraData[name+'.y'] = form.clk_y;\r
-                }\r
-            }\r
-        }\r
-\r
-        // take a breath so that pending repaints get some cpu time before the upload starts\r
-        setTimeout(function() {\r
-            // make sure form attrs are set\r
-            var t = $form.attr('target'), a = $form.attr('action');\r
-\r
-                       // update form attrs in IE friendly way\r
-                       form.setAttribute('target',id);\r
-                       if (form.getAttribute('method') != 'POST')\r
-                               form.setAttribute('method', 'POST');\r
-                       if (form.getAttribute('action') != opts.url)\r
-                               form.setAttribute('action', opts.url);\r
-\r
-            // ie borks in some cases when setting encoding\r
-            if (! options.skipEncodingOverride) {\r
-                $form.attr({\r
-                    encoding: 'multipart/form-data',\r
-                    enctype:  'multipart/form-data'\r
-                });\r
-            }\r
-\r
-            // support timout\r
-            if (opts.timeout)\r
-                setTimeout(function() { timedOut = true; cb(); }, opts.timeout);\r
-\r
-            // add "extra" data to form if provided in options\r
-            var extraInputs = [];\r
-            try {\r
-                if (options.extraData)\r
-                    for (var n in options.extraData)\r
-                        extraInputs.push(\r
-                            $('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />')\r
-                                .appendTo(form)[0]);\r
-\r
-                // add iframe to doc and submit the form\r
-                $io.appendTo('body');\r
-                io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);\r
-                form.submit();\r
-            }\r
-            finally {\r
-                // reset attrs and remove "extra" input elements\r
-                               form.setAttribute('action',a);\r
-                t ? form.setAttribute('target', t) : $form.removeAttr('target');\r
-                $(extraInputs).remove();\r
-            }\r
-        }, 10);\r
-\r
-        var nullCheckFlag = 0;\r
-\r
-        function cb() {\r
-            if (cbInvoked++) return;\r
-\r
-            io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);\r
-\r
-            var ok = true;\r
-            try {\r
-                if (timedOut) throw 'timeout';\r
-                // extract the server response from the iframe\r
-                var data, doc;\r
-\r
-                doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;\r
-\r
-                if ((doc.body == null || doc.body.innerHTML == '') && !nullCheckFlag) {\r
-                    // in some browsers (cough, Opera 9.2.x) the iframe DOM is not always traversable when\r
-                    // the onload callback fires, so we give them a 2nd chance\r
-                    nullCheckFlag = 1;\r
-                    cbInvoked--;\r
-                    setTimeout(cb, 100);\r
-                    return;\r
-                }\r
-\r
-                xhr.responseText = doc.body ? doc.body.innerHTML : null;\r
-                xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;\r
-                xhr.getResponseHeader = function(header){\r
-                    var headers = {'content-type': opts.dataType};\r
-                    return headers[header];\r
-                };\r
-\r
-                if (opts.dataType == 'json' || opts.dataType == 'script') {\r
-                    var ta = doc.getElementsByTagName('textarea')[0];\r
-                    xhr.responseText = ta ? ta.value : xhr.responseText;\r
-                }\r
-                else if (opts.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {\r
-                    xhr.responseXML = toXml(xhr.responseText);\r
-                }\r
-                data = $.httpData(xhr, opts.dataType);\r
-            }\r
-            catch(e){\r
-                ok = false;\r
-                $.handleError(opts, xhr, 'error', e);\r
-            }\r
-\r
-            // ordering of these callbacks/triggers is odd, but that's how $.ajax does it\r
-            if (ok) {\r
-                opts.success(data, 'success');\r
-                if (g) $.event.trigger("ajaxSuccess", [xhr, opts]);\r
-            }\r
-            if (g) $.event.trigger("ajaxComplete", [xhr, opts]);\r
-            if (g && ! --$.active) $.event.trigger("ajaxStop");\r
-            if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');\r
-\r
-            // clean up\r
-            setTimeout(function() {\r
-                $io.remove();\r
-                xhr.responseXML = null;\r
-            }, 100);\r
-        };\r
-\r
-        function toXml(s, doc) {\r
-            if (window.ActiveXObject) {\r
-                doc = new ActiveXObject('Microsoft.XMLDOM');\r
-                doc.async = 'false';\r
-                doc.loadXML(s);\r
-            }\r
-            else\r
-                doc = (new DOMParser()).parseFromString(s, 'text/xml');\r
-            return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;\r
-        };\r
-    };\r
-};\r
-\r
-/**\r
- * ajaxForm() provides a mechanism for fully automating form submission.\r
- *\r
- * The advantages of using this method instead of ajaxSubmit() are:\r
- *\r
- * 1: This method will include coordinates for <input type="image" /> elements (if the element\r
- *    is used to submit the form).\r
- * 2. This method will include the submit element's name/value data (for the element that was\r
- *    used to submit the form).\r
- * 3. This method binds the submit() method to the form for you.\r
- *\r
- * The options argument for ajaxForm works exactly as it does for ajaxSubmit.  ajaxForm merely\r
- * passes the options argument along after properly binding events for submit elements and\r
- * the form itself.\r
- */\r
-$.fn.ajaxForm = function(options) {\r
-    return this.ajaxFormUnbind().bind('submit.form-plugin',function() {\r
-        $(this).ajaxSubmit(options);\r
-        return false;\r
-    }).each(function() {\r
-        // store options in hash\r
-        $(":submit,input:image", this).bind('click.form-plugin',function(e) {\r
-            var form = this.form;\r
-            form.clk = this;\r
-            if (this.type == 'image') {\r
-                if (e.offsetX != undefined) {\r
-                    form.clk_x = e.offsetX;\r
-                    form.clk_y = e.offsetY;\r
-                } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin\r
-                    var offset = $(this).offset();\r
-                    form.clk_x = e.pageX - offset.left;\r
-                    form.clk_y = e.pageY - offset.top;\r
-                } else {\r
-                    form.clk_x = e.pageX - this.offsetLeft;\r
-                    form.clk_y = e.pageY - this.offsetTop;\r
-                }\r
-            }\r
-            // clear form vars\r
-            setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 10);\r
-        });\r
-    });\r
-};\r
-\r
-// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm\r
-$.fn.ajaxFormUnbind = function() {\r
-    this.unbind('submit.form-plugin');\r
-    return this.each(function() {\r
-        $(":submit,input:image", this).unbind('click.form-plugin');\r
-    });\r
-\r
-};\r
-\r
-/**\r
- * formToArray() gathers form element data into an array of objects that can\r
- * be passed to any of the following ajax functions: $.get, $.post, or load.\r
- * Each object in the array has both a 'name' and 'value' property.  An example of\r
- * an array for a simple login form might be:\r
- *\r
- * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]\r
- *\r
- * It is this array that is passed to pre-submit callback functions provided to the\r
- * ajaxSubmit() and ajaxForm() methods.\r
- */\r
-$.fn.formToArray = function(semantic) {\r
-    var a = [];\r
-    if (this.length == 0) return a;\r
-\r
-    var form = this[0];\r
-    var els = semantic ? form.getElementsByTagName('*') : form.elements;\r
-    if (!els) return a;\r
-    for(var i=0, max=els.length; i < max; i++) {\r
-        var el = els[i];\r
-        var n = el.name;\r
-        if (!n) continue;\r
-\r
-        if (semantic && form.clk && el.type == "image") {\r
-            // handle image inputs on the fly when semantic == true\r
-            if(!el.disabled && form.clk == el) {\r
-               a.push({name: n, value: $(el).val()});\r
-                a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});\r
-            }\r
-            continue;\r
-        }\r
-\r
-        var v = $.fieldValue(el, true);\r
-        if (v && v.constructor == Array) {\r
-            for(var j=0, jmax=v.length; j < jmax; j++)\r
-                a.push({name: n, value: v[j]});\r
-        }\r
-        else if (v !== null && typeof v != 'undefined')\r
-            a.push({name: n, value: v});\r
-    }\r
-\r
-    if (!semantic && form.clk) {\r
-        // input type=='image' are not found in elements array! handle it here\r
-        var $input = $(form.clk), input = $input[0], n = input.name;\r
-        if (n && !input.disabled && input.type == 'image') {\r
-               a.push({name: n, value: $input.val()});\r
-            a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});\r
-        }\r
-    }\r
-    return a;\r
-};\r
-\r
-/**\r
- * Serializes form data into a 'submittable' string. This method will return a string\r
- * in the format: name1=value1&amp;name2=value2\r
- */\r
-$.fn.formSerialize = function(semantic) {\r
-    //hand off to jQuery.param for proper encoding\r
-    return $.param(this.formToArray(semantic));\r
-};\r
-\r
-/**\r
- * Serializes all field elements in the jQuery object into a query string.\r
- * This method will return a string in the format: name1=value1&amp;name2=value2\r
- */\r
-$.fn.fieldSerialize = function(successful) {\r
-    var a = [];\r
-    this.each(function() {\r
-        var n = this.name;\r
-        if (!n) return;\r
-        var v = $.fieldValue(this, successful);\r
-        if (v && v.constructor == Array) {\r
-            for (var i=0,max=v.length; i < max; i++)\r
-                a.push({name: n, value: v[i]});\r
-        }\r
-        else if (v !== null && typeof v != 'undefined')\r
-            a.push({name: this.name, value: v});\r
-    });\r
-    //hand off to jQuery.param for proper encoding\r
-    return $.param(a);\r
-};\r
-\r
-/**\r
- * Returns the value(s) of the element in the matched set.  For example, consider the following form:\r
- *\r
- *  <form><fieldset>\r
- *      <input name="A" type="text" />\r
- *      <input name="A" type="text" />\r
- *      <input name="B" type="checkbox" value="B1" />\r
- *      <input name="B" type="checkbox" value="B2"/>\r
- *      <input name="C" type="radio" value="C1" />\r
- *      <input name="C" type="radio" value="C2" />\r
- *  </fieldset></form>\r
- *\r
- *  var v = $(':text').fieldValue();\r
- *  // if no values are entered into the text inputs\r
- *  v == ['','']\r
- *  // if values entered into the text inputs are 'foo' and 'bar'\r
- *  v == ['foo','bar']\r
- *\r
- *  var v = $(':checkbox').fieldValue();\r
- *  // if neither checkbox is checked\r
- *  v === undefined\r
- *  // if both checkboxes are checked\r
- *  v == ['B1', 'B2']\r
- *\r
- *  var v = $(':radio').fieldValue();\r
- *  // if neither radio is checked\r
- *  v === undefined\r
- *  // if first radio is checked\r
- *  v == ['C1']\r
- *\r
- * The successful argument controls whether or not the field element must be 'successful'\r
- * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).\r
- * The default value of the successful argument is true.  If this value is false the value(s)\r
- * for each element is returned.\r
- *\r
- * Note: This method *always* returns an array.  If no valid value can be determined the\r
- *       array will be empty, otherwise it will contain one or more values.\r
- */\r
-$.fn.fieldValue = function(successful) {\r
-    for (var val=[], i=0, max=this.length; i < max; i++) {\r
-        var el = this[i];\r
-        var v = $.fieldValue(el, successful);\r
-        if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length))\r
-            continue;\r
-        v.constructor == Array ? $.merge(val, v) : val.push(v);\r
-    }\r
-    return val;\r
-};\r
-\r
-/**\r
- * Returns the value of the field element.\r
- */\r
-$.fieldValue = function(el, successful) {\r
-    var n = el.name, t = el.type, tag = el.tagName.toLowerCase();\r
-    if (typeof successful == 'undefined') successful = true;\r
-\r
-    if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||\r
-        (t == 'checkbox' || t == 'radio') && !el.checked ||\r
-        (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||\r
-        tag == 'select' && el.selectedIndex == -1))\r
-            return null;\r
-\r
-    if (tag == 'select') {\r
-        var index = el.selectedIndex;\r
-        if (index < 0) return null;\r
-        var a = [], ops = el.options;\r
-        var one = (t == 'select-one');\r
-        var max = (one ? index+1 : ops.length);\r
-        for(var i=(one ? index : 0); i < max; i++) {\r
-            var op = ops[i];\r
-            if (op.selected) {\r
-                               var v = op.value;\r
-                               if (!v) // extra pain for IE...\r
-                       v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;\r
-                if (one) return v;\r
-                a.push(v);\r
-            }\r
-        }\r
-        return a;\r
-    }\r
-    return el.value;\r
-};\r
-\r
-/**\r
- * Clears the form data.  Takes the following actions on the form's input fields:\r
- *  - input text fields will have their 'value' property set to the empty string\r
- *  - select elements will have their 'selectedIndex' property set to -1\r
- *  - checkbox and radio inputs will have their 'checked' property set to false\r
- *  - inputs of type submit, button, reset, and hidden will *not* be effected\r
- *  - button elements will *not* be effected\r
- */\r
-$.fn.clearForm = function() {\r
-    return this.each(function() {\r
-        $('input,select,textarea', this).clearFields();\r
-    });\r
-};\r
-\r
-/**\r
- * Clears the selected form elements.\r
- */\r
-$.fn.clearFields = $.fn.clearInputs = function() {\r
-    return this.each(function() {\r
-        var t = this.type, tag = this.tagName.toLowerCase();\r
-        if (t == 'text' || t == 'password' || tag == 'textarea')\r
-            this.value = '';\r
-        else if (t == 'checkbox' || t == 'radio')\r
-            this.checked = false;\r
-        else if (tag == 'select')\r
-            this.selectedIndex = -1;\r
-    });\r
-};\r
-\r
-/**\r
- * Resets the form data.  Causes all form elements to be reset to their original value.\r
- */\r
-$.fn.resetForm = function() {\r
-    return this.each(function() {\r
-        // guard against an input with the name of 'reset'\r
-        // note that IE reports the reset function as an 'object'\r
-        if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType))\r
-            this.reset();\r
-    });\r
-};\r
-\r
-/**\r
- * Enables or disables any matching elements.\r
- */\r
-$.fn.enable = function(b) {\r
-    if (b == undefined) b = true;\r
-    return this.each(function() {\r
-        this.disabled = !b;\r
-    });\r
-};\r
-\r
-/**\r
- * Checks/unchecks any matching checkboxes or radio buttons and\r
- * selects/deselects and matching option elements.\r
- */\r
-$.fn.selected = function(select) {\r
-    if (select == undefined) select = true;\r
-    return this.each(function() {\r
-        var t = this.type;\r
-        if (t == 'checkbox' || t == 'radio')\r
-            this.checked = select;\r
-        else if (this.tagName.toLowerCase() == 'option') {\r
-            var $sel = $(this).parent('select');\r
-            if (select && $sel[0] && $sel[0].type == 'select-one') {\r
-                // deselect all other options\r
-                $sel.find('option').selected(false);\r
-            }\r
-            this.selected = select;\r
-        }\r
-    });\r
-};\r
-\r
-// helper fn for console logging\r
-// set $.fn.ajaxSubmit.debug to true to enable debug logging\r
-function log() {\r
-    if ($.fn.ajaxSubmit.debug && window.console && window.console.log)\r
-        window.console.log('[jquery.form] ' + Array.prototype.join.call(arguments,''));\r
-};\r
-\r
-})(jQuery);\r
+/*
+ * jQuery Form Plugin
+ * version: 2.28 (10-MAY-2009)
+ * @requires jQuery v1.2.2 or later
+ *
+ * Examples and documentation at: http://malsup.com/jquery/form/
+ * Dual licensed under the MIT and GPL licenses:
+ *   http://www.opensource.org/licenses/mit-license.php
+ *   http://www.gnu.org/licenses/gpl.html
+ */
+;(function($) {
+
+/*
+    Usage Note:
+    -----------
+    Do not use both ajaxSubmit and ajaxForm on the same form.  These
+    functions are intended to be exclusive.  Use ajaxSubmit if you want
+    to bind your own submit handler to the form.  For example,
+
+    $(document).ready(function() {
+        $('#myForm').bind('submit', function() {
+            $(this).ajaxSubmit({
+                target: '#output'
+            });
+            return false; // <-- important!
+        });
+    });
+
+    Use ajaxForm when you want the plugin to manage all the event binding
+    for you.  For example,
+
+    $(document).ready(function() {
+        $('#myForm').ajaxForm({
+            target: '#output'
+        });
+    });
+
+    When using ajaxForm, the ajaxSubmit function will be invoked for you
+    at the appropriate time.
+*/
+
+/**
+ * ajaxSubmit() provides a mechanism for immediately submitting
+ * an HTML form using AJAX.
+ */
+$.fn.ajaxSubmit = function(options) {
+    // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
+    if (!this.length) {
+        log('ajaxSubmit: skipping submit process - no element selected');
+        return this;
+    }
+
+    if (typeof options == 'function')
+        options = { success: options };
+
+    var url = $.trim(this.attr('action'));
+    if (url) {
+           // clean url (don't include hash vaue)
+           url = (url.match(/^([^#]+)/)||[])[1];
+       }
+       url = url || window.location.href || ''
+
+    options = $.extend({
+        url:  url,
+        type: this.attr('method') || 'GET'
+    }, options || {});
+
+    // hook for manipulating the form data before it is extracted;
+    // convenient for use with rich editors like tinyMCE or FCKEditor
+    var veto = {};
+    this.trigger('form-pre-serialize', [this, options, veto]);
+    if (veto.veto) {
+        log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
+        return this;
+    }
+
+    // provide opportunity to alter form data before it is serialized
+    if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
+        log('ajaxSubmit: submit aborted via beforeSerialize callback');
+        return this;
+    }
+
+    var a = this.formToArray(options.semantic);
+    if (options.data) {
+        options.extraData = options.data;
+        for (var n in options.data) {
+          if(options.data[n] instanceof Array) {
+            for (var k in options.data[n])
+              a.push( { name: n, value: options.data[n][k] } );
+          }
+          else
+             a.push( { name: n, value: options.data[n] } );
+        }
+    }
+
+    // give pre-submit callback an opportunity to abort the submit
+    if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
+        log('ajaxSubmit: submit aborted via beforeSubmit callback');
+        return this;
+    }
+
+    // fire vetoable 'validate' event
+    this.trigger('form-submit-validate', [a, this, options, veto]);
+    if (veto.veto) {
+        log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
+        return this;
+    }
+
+    var q = $.param(a);
+
+    if (options.type.toUpperCase() == 'GET') {
+        options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
+        options.data = null;  // data is null for 'get'
+    }
+    else
+        options.data = q; // data is the query string for 'post'
+
+    var $form = this, callbacks = [];
+    if (options.resetForm) callbacks.push(function() { $form.resetForm(); });
+    if (options.clearForm) callbacks.push(function() { $form.clearForm(); });
+
+    // perform a load on the target only if dataType is not provided
+    if (!options.dataType && options.target) {
+        var oldSuccess = options.success || function(){};
+        callbacks.push(function(data) {
+            $(options.target).html(data).each(oldSuccess, arguments);
+        });
+    }
+    else if (options.success)
+        callbacks.push(options.success);
+
+    options.success = function(data, status) {
+        for (var i=0, max=callbacks.length; i < max; i++)
+            callbacks[i].apply(options, [data, status, $form]);
+    };
+
+    // are there files to upload?
+    var files = $('input:file', this).fieldValue();
+    var found = false;
+    for (var j=0; j < files.length; j++)
+        if (files[j])
+            found = true;
+
+       var multipart = false;
+//     var mp = 'multipart/form-data';
+//     multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
+
+    // options.iframe allows user to force iframe mode
+   if (options.iframe || found || multipart) {
+       // hack to fix Safari hang (thanks to Tim Molendijk for this)
+       // see:  http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
+       if (options.closeKeepAlive)
+           $.get(options.closeKeepAlive, fileUpload);
+       else
+           fileUpload();
+       }
+   else
+       $.ajax(options);
+
+    // fire 'notify' event
+    this.trigger('form-submit-notify', [this, options]);
+    return this;
+
+
+    // private function for handling file uploads (hat tip to YAHOO!)
+    function fileUpload() {
+        var form = $form[0];
+
+        if ($(':input[name=submit]', form).length) {
+            alert('Error: Form elements must not be named "submit".');
+            return;
+        }
+
+        var opts = $.extend({}, $.ajaxSettings, options);
+               var s = $.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts);
+
+        var id = 'jqFormIO' + (new Date().getTime());
+        var $io = $('<iframe id="' + id + '" name="' + id + '" src="about:blank" />');
+        var io = $io[0];
+
+        $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
+
+        var xhr = { // mock object
+            aborted: 0,
+            responseText: null,
+            responseXML: null,
+            status: 0,
+            statusText: 'n/a',
+            getAllResponseHeaders: function() {},
+            getResponseHeader: function() {},
+            setRequestHeader: function() {},
+            abort: function() {
+                this.aborted = 1;
+                $io.attr('src','about:blank'); // abort op in progress
+            }
+        };
+
+        var g = opts.global;
+        // trigger ajax global events so that activity/block indicators work like normal
+        if (g && ! $.active++) $.event.trigger("ajaxStart");
+        if (g) $.event.trigger("ajaxSend", [xhr, opts]);
+
+               if (s.beforeSend && s.beforeSend(xhr, s) === false) {
+                       s.global && $.active--;
+                       return;
+        }
+        if (xhr.aborted)
+            return;
+
+        var cbInvoked = 0;
+        var timedOut = 0;
+
+        // add submitting element to data if we know it
+        var sub = form.clk;
+        if (sub) {
+            var n = sub.name;
+            if (n && !sub.disabled) {
+                options.extraData = options.extraData || {};
+                options.extraData[n] = sub.value;
+                if (sub.type == "image") {
+                    options.extraData[name+'.x'] = form.clk_x;
+                    options.extraData[name+'.y'] = form.clk_y;
+                }
+            }
+        }
+
+        // take a breath so that pending repaints get some cpu time before the upload starts
+        setTimeout(function() {
+            // make sure form attrs are set
+            var t = $form.attr('target'), a = $form.attr('action');
+
+                       // update form attrs in IE friendly way
+                       form.setAttribute('target',id);
+                       if (form.getAttribute('method') != 'POST')
+                               form.setAttribute('method', 'POST');
+                       if (form.getAttribute('action') != opts.url)
+                               form.setAttribute('action', opts.url);
+
+            // ie borks in some cases when setting encoding
+            if (! options.skipEncodingOverride) {
+                $form.attr({
+                    encoding: 'multipart/form-data',
+                    enctype:  'multipart/form-data'
+                });
+            }
+
+            // support timout
+            if (opts.timeout)
+                setTimeout(function() { timedOut = true; cb(); }, opts.timeout);
+
+            // add "extra" data to form if provided in options
+            var extraInputs = [];
+            try {
+                if (options.extraData)
+                    for (var n in options.extraData)
+                        extraInputs.push(
+                            $('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />')
+                                .appendTo(form)[0]);
+
+                // add iframe to doc and submit the form
+                $io.appendTo('body');
+                io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
+                form.submit();
+            }
+            finally {
+                // reset attrs and remove "extra" input elements
+                               form.setAttribute('action',a);
+                t ? form.setAttribute('target', t) : $form.removeAttr('target');
+                $(extraInputs).remove();
+            }
+        }, 10);
+
+        var nullCheckFlag = 0;
+
+        function cb() {
+            if (cbInvoked++) return;
+
+            io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
+
+            var ok = true;
+            try {
+                if (timedOut) throw 'timeout';
+                // extract the server response from the iframe
+                var data, doc;
+
+                doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
+
+                if ((doc.body == null || doc.body.innerHTML == '') && !nullCheckFlag) {
+                    // in some browsers (cough, Opera 9.2.x) the iframe DOM is not always traversable when
+                    // the onload callback fires, so we give them a 2nd chance
+                    nullCheckFlag = 1;
+                    cbInvoked--;
+                    setTimeout(cb, 100);
+                    return;
+                }
+
+                xhr.responseText = doc.body ? doc.body.innerHTML : null;
+                xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
+                xhr.getResponseHeader = function(header){
+                    var headers = {'content-type': opts.dataType};
+                    return headers[header];
+                };
+
+                if (opts.dataType == 'json' || opts.dataType == 'script') {
+                    var ta = doc.getElementsByTagName('textarea')[0];
+                    xhr.responseText = ta ? ta.value : xhr.responseText;
+                }
+                else if (opts.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
+                    xhr.responseXML = toXml(xhr.responseText);
+                }
+                data = $.httpData(xhr, opts.dataType);
+            }
+            catch(e){
+                ok = false;
+                $.handleError(opts, xhr, 'error', e);
+            }
+
+            // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
+            if (ok) {
+                opts.success(data, 'success');
+                if (g) $.event.trigger("ajaxSuccess", [xhr, opts]);
+            }
+            if (g) $.event.trigger("ajaxComplete", [xhr, opts]);
+            if (g && ! --$.active) $.event.trigger("ajaxStop");
+            if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');
+
+            // clean up
+            setTimeout(function() {
+                $io.remove();
+                xhr.responseXML = null;
+            }, 100);
+        };
+
+        function toXml(s, doc) {
+            if (window.ActiveXObject) {
+                doc = new ActiveXObject('Microsoft.XMLDOM');
+                doc.async = 'false';
+                doc.loadXML(s);
+            }
+            else
+                doc = (new DOMParser()).parseFromString(s, 'text/xml');
+            return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
+        };
+    };
+};
+
+/**
+ * ajaxForm() provides a mechanism for fully automating form submission.
+ *
+ * The advantages of using this method instead of ajaxSubmit() are:
+ *
+ * 1: This method will include coordinates for <input type="image" /> elements (if the element
+ *    is used to submit the form).
+ * 2. This method will include the submit element's name/value data (for the element that was
+ *    used to submit the form).
+ * 3. This method binds the submit() method to the form for you.
+ *
+ * The options argument for ajaxForm works exactly as it does for ajaxSubmit.  ajaxForm merely
+ * passes the options argument along after properly binding events for submit elements and
+ * the form itself.
+ */
+$.fn.ajaxForm = function(options) {
+    return this.ajaxFormUnbind().bind('submit.form-plugin',function() {
+        $(this).ajaxSubmit(options);
+        return false;
+    }).each(function() {
+        // store options in hash
+        $(":submit,input:image", this).bind('click.form-plugin',function(e) {
+            var form = this.form;
+            form.clk = this;
+            if (this.type == 'image') {
+                if (e.offsetX != undefined) {
+                    form.clk_x = e.offsetX;
+                    form.clk_y = e.offsetY;
+                } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
+                    var offset = $(this).offset();
+                    form.clk_x = e.pageX - offset.left;
+                    form.clk_y = e.pageY - offset.top;
+                } else {
+                    form.clk_x = e.pageX - this.offsetLeft;
+                    form.clk_y = e.pageY - this.offsetTop;
+                }
+            }
+            // clear form vars
+            setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 10);
+        });
+    });
+};
+
+// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
+$.fn.ajaxFormUnbind = function() {
+    this.unbind('submit.form-plugin');
+    return this.each(function() {
+        $(":submit,input:image", this).unbind('click.form-plugin');
+    });
+
+};
+
+/**
+ * formToArray() gathers form element data into an array of objects that can
+ * be passed to any of the following ajax functions: $.get, $.post, or load.
+ * Each object in the array has both a 'name' and 'value' property.  An example of
+ * an array for a simple login form might be:
+ *
+ * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
+ *
+ * It is this array that is passed to pre-submit callback functions provided to the
+ * ajaxSubmit() and ajaxForm() methods.
+ */
+$.fn.formToArray = function(semantic) {
+    var a = [];
+    if (this.length == 0) return a;
+
+    var form = this[0];
+    var els = semantic ? form.getElementsByTagName('*') : form.elements;
+    if (!els) return a;
+    for(var i=0, max=els.length; i < max; i++) {
+        var el = els[i];
+        var n = el.name;
+        if (!n) continue;
+
+        if (semantic && form.clk && el.type == "image") {
+            // handle image inputs on the fly when semantic == true
+            if(!el.disabled && form.clk == el) {
+               a.push({name: n, value: $(el).val()});
+                a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
+            }
+            continue;
+        }
+
+        var v = $.fieldValue(el, true);
+        if (v && v.constructor == Array) {
+            for(var j=0, jmax=v.length; j < jmax; j++)
+                a.push({name: n, value: v[j]});
+        }
+        else if (v !== null && typeof v != 'undefined')
+            a.push({name: n, value: v});
+    }
+
+    if (!semantic && form.clk) {
+        // input type=='image' are not found in elements array! handle it here
+        var $input = $(form.clk), input = $input[0], n = input.name;
+        if (n && !input.disabled && input.type == 'image') {
+               a.push({name: n, value: $input.val()});
+            a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
+        }
+    }
+    return a;
+};
+
+/**
+ * Serializes form data into a 'submittable' string. This method will return a string
+ * in the format: name1=value1&amp;name2=value2
+ */
+$.fn.formSerialize = function(semantic) {
+    //hand off to jQuery.param for proper encoding
+    return $.param(this.formToArray(semantic));
+};
+
+/**
+ * Serializes all field elements in the jQuery object into a query string.
+ * This method will return a string in the format: name1=value1&amp;name2=value2
+ */
+$.fn.fieldSerialize = function(successful) {
+    var a = [];
+    this.each(function() {
+        var n = this.name;
+        if (!n) return;
+        var v = $.fieldValue(this, successful);
+        if (v && v.constructor == Array) {
+            for (var i=0,max=v.length; i < max; i++)
+                a.push({name: n, value: v[i]});
+        }
+        else if (v !== null && typeof v != 'undefined')
+            a.push({name: this.name, value: v});
+    });
+    //hand off to jQuery.param for proper encoding
+    return $.param(a);
+};
+
+/**
+ * Returns the value(s) of the element in the matched set.  For example, consider the following form:
+ *
+ *  <form><fieldset>
+ *      <input name="A" type="text" />
+ *      <input name="A" type="text" />
+ *      <input name="B" type="checkbox" value="B1" />
+ *      <input name="B" type="checkbox" value="B2"/>
+ *      <input name="C" type="radio" value="C1" />
+ *      <input name="C" type="radio" value="C2" />
+ *  </fieldset></form>
+ *
+ *  var v = $(':text').fieldValue();
+ *  // if no values are entered into the text inputs
+ *  v == ['','']
+ *  // if values entered into the text inputs are 'foo' and 'bar'
+ *  v == ['foo','bar']
+ *
+ *  var v = $(':checkbox').fieldValue();
+ *  // if neither checkbox is checked
+ *  v === undefined
+ *  // if both checkboxes are checked
+ *  v == ['B1', 'B2']
+ *
+ *  var v = $(':radio').fieldValue();
+ *  // if neither radio is checked
+ *  v === undefined
+ *  // if first radio is checked
+ *  v == ['C1']
+ *
+ * The successful argument controls whether or not the field element must be 'successful'
+ * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
+ * The default value of the successful argument is true.  If this value is false the value(s)
+ * for each element is returned.
+ *
+ * Note: This method *always* returns an array.  If no valid value can be determined the
+ *       array will be empty, otherwise it will contain one or more values.
+ */
+$.fn.fieldValue = function(successful) {
+    for (var val=[], i=0, max=this.length; i < max; i++) {
+        var el = this[i];
+        var v = $.fieldValue(el, successful);
+        if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length))
+            continue;
+        v.constructor == Array ? $.merge(val, v) : val.push(v);
+    }
+    return val;
+};
+
+/**
+ * Returns the value of the field element.
+ */
+$.fieldValue = function(el, successful) {
+    var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
+    if (typeof successful == 'undefined') successful = true;
+
+    if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
+        (t == 'checkbox' || t == 'radio') && !el.checked ||
+        (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
+        tag == 'select' && el.selectedIndex == -1))
+            return null;
+
+    if (tag == 'select') {
+        var index = el.selectedIndex;
+        if (index < 0) return null;
+        var a = [], ops = el.options;
+        var one = (t == 'select-one');
+        var max = (one ? index+1 : ops.length);
+        for(var i=(one ? index : 0); i < max; i++) {
+            var op = ops[i];
+            if (op.selected) {
+                               var v = op.value;
+                               if (!v) // extra pain for IE...
+                       v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
+                if (one) return v;
+                a.push(v);
+            }
+        }
+        return a;
+    }
+    return el.value;
+};
+
+/**
+ * Clears the form data.  Takes the following actions on the form's input fields:
+ *  - input text fields will have their 'value' property set to the empty string
+ *  - select elements will have their 'selectedIndex' property set to -1
+ *  - checkbox and radio inputs will have their 'checked' property set to false
+ *  - inputs of type submit, button, reset, and hidden will *not* be effected
+ *  - button elements will *not* be effected
+ */
+$.fn.clearForm = function() {
+    return this.each(function() {
+        $('input,select,textarea', this).clearFields();
+    });
+};
+
+/**
+ * Clears the selected form elements.
+ */
+$.fn.clearFields = $.fn.clearInputs = function() {
+    return this.each(function() {
+        var t = this.type, tag = this.tagName.toLowerCase();
+        if (t == 'text' || t == 'password' || tag == 'textarea')
+            this.value = '';
+        else if (t == 'checkbox' || t == 'radio')
+            this.checked = false;
+        else if (tag == 'select')
+            this.selectedIndex = -1;
+    });
+};
+
+/**
+ * Resets the form data.  Causes all form elements to be reset to their original value.
+ */
+$.fn.resetForm = function() {
+    return this.each(function() {
+        // guard against an input with the name of 'reset'
+        // note that IE reports the reset function as an 'object'
+        if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType))
+            this.reset();
+    });
+};
+
+/**
+ * Enables or disables any matching elements.
+ */
+$.fn.enable = function(b) {
+    if (b == undefined) b = true;
+    return this.each(function() {
+        this.disabled = !b;
+    });
+};
+
+/**
+ * Checks/unchecks any matching checkboxes or radio buttons and
+ * selects/deselects and matching option elements.
+ */
+$.fn.selected = function(select) {
+    if (select == undefined) select = true;
+    return this.each(function() {
+        var t = this.type;
+        if (t == 'checkbox' || t == 'radio')
+            this.checked = select;
+        else if (this.tagName.toLowerCase() == 'option') {
+            var $sel = $(this).parent('select');
+            if (select && $sel[0] && $sel[0].type == 'select-one') {
+                // deselect all other options
+                $sel.find('option').selected(false);
+            }
+            this.selected = select;
+        }
+    });
+};
+
+// helper fn for console logging
+// set $.fn.ajaxSubmit.debug to true to enable debug logging
+function log() {
+    if ($.fn.ajaxSubmit.debug && window.console && window.console.log)
+        window.console.log('[jquery.form] ' + Array.prototype.join.call(arguments,''));
+};
+
+})(jQuery);
index 86450752167c7da9d70a327f17f7850bf0635a93..348c82e8f9050e0a9fc79bf7f83b411de6c6b663 100644 (file)
@@ -1,19 +1,19 @@
-<?php\r
-\r
-       /**\r
-        * Elgg version number.\r
-        * This file defines the current version of the core Elgg code being used.\r
-        * This is compared against the values stored in the database to determine\r
-        * whether upgrades should be performed.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-        * @link http://elgg.org/\r
-        */\r
+<?php
+
+       /**
+        * Elgg version number.
+        * This file defines the current version of the core Elgg code being used.
+        * This is compared against the values stored in the database to determine
+        * whether upgrades should be performed.
+        * 
+        * @package Elgg
+        * @subpackage Core
+        * @link http://elgg.org/
+        */
 
           $version = 2009072201;  // YYYYMMDD   = Elgg Date
-                                  //         XX = Interim incrementer\r
-       \r
-          $release = '1.6';    // Human-friendly version name\r
-\r
+                                  //         XX = Interim incrementer
+       
+          $release = '1.6';    // Human-friendly version name
+
 ?>
index 11edfc25ff82e88cd611ab2fcee0082e738a87b2..52e8b8ee1ebb49b0ad711f8378719b8cf2d1de78 100644 (file)
@@ -1,37 +1,37 @@
-<?php\r
-\r
-     /**\r
-        * Elgg login form\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+     /**
+        * Elgg login form
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-        \r
-       global $CONFIG;\r
-       \r
-       $form_body = "<p class=\"loginbox\"><label>" . elgg_echo('username') . "<br />" . elgg_view('input/text', array('internalname' => 'username', 'class' => 'login-textarea')) . "</label>";\r
-       $form_body .= "<br />";\r
-       $form_body .= "<label>" . elgg_echo('password') . "<br />" . elgg_view('input/password', array('internalname' => 'password', 'class' => 'login-textarea')) . "</label><br />";\r
-       $form_body .= elgg_view('input/submit', array('value' => elgg_echo('login'))) . " <div id=\"persistent_login\"><label><input type=\"checkbox\" name=\"persistent\" value=\"true\" />".elgg_echo('user:persistent')."</label></div></p>";\r
-       $form_body .= "<p class=\"loginbox\">";\r
-       $form_body .= (!isset($CONFIG->disable_registration) || !($CONFIG->disable_registration)) ? "<a href=\"{$vars['url']}account/register.php\">" . elgg_echo('register') . "</a> | " : "";\r
-       $form_body .= "<a href=\"{$vars['url']}account/forgotten_password.php\">" . elgg_echo('user:password:lost') . "</a></p>";  \r
-       \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+        
+       global $CONFIG;
+       
+       $form_body = "<p class=\"loginbox\"><label>" . elgg_echo('username') . "<br />" . elgg_view('input/text', array('internalname' => 'username', 'class' => 'login-textarea')) . "</label>";
+       $form_body .= "<br />";
+       $form_body .= "<label>" . elgg_echo('password') . "<br />" . elgg_view('input/password', array('internalname' => 'password', 'class' => 'login-textarea')) . "</label><br />";
+       $form_body .= elgg_view('input/submit', array('value' => elgg_echo('login'))) . " <div id=\"persistent_login\"><label><input type=\"checkbox\" name=\"persistent\" value=\"true\" />".elgg_echo('user:persistent')."</label></div></p>";
+       $form_body .= "<p class=\"loginbox\">";
+       $form_body .= (!isset($CONFIG->disable_registration) || !($CONFIG->disable_registration)) ? "<a href=\"{$vars['url']}account/register.php\">" . elgg_echo('register') . "</a> | " : "";
+       $form_body .= "<a href=\"{$vars['url']}account/forgotten_password.php\">" . elgg_echo('user:password:lost') . "</a></p>";  
+       
        //<input name=\"username\" type=\"text\" class="general-textarea" /></label>
        
        $login_url = $vars['url'];
        if ((isset($CONFIG->https_login)) && ($CONFIG->https_login))
-               $login_url = str_replace("http", "https", $vars['url']);\r
-?>\r
-       \r
-       <div id="login-box">\r
-       <h2><?php echo elgg_echo('login'); ?></h2>\r
+               $login_url = str_replace("http", "https", $vars['url']);
+?>
+       
+       <div id="login-box">
+       <h2><?php echo elgg_echo('login'); ?></h2>
                <?php 
                        echo elgg_view('input/form', array('body' => $form_body, 'action' => "{$login_url}action/login"));
-               ?>\r
-               \r
+               ?>
+               
        </div>
\ No newline at end of file
index 16307fd0df19045d23434d786ae26809106de4cc..8ceeaab8fa1ef955259c29bca17e9c7bb0a91b16 100644 (file)
@@ -1,22 +1,22 @@
-<?php\r
-\r
-     /**\r
-        * Elgg register form\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+     /**
+        * Elgg register form
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
         
        $username = get_input('u');
        $email = get_input('e');
        $name = get_input('n');
-\r
-       $admin_option = false;\r
-       if (($_SESSION['user']->admin) && ($vars['show_admin'])) \r
+
+       $admin_option = false;
+       if (($_SESSION['user']->admin) && ($vars['show_admin'])) 
                $admin_option = true;
                
        $form_body = "<p><label>" . elgg_echo('name') . "<br />" . elgg_view('input/text' , array('internalname' => 'name', 'class' => "general-textarea", 'value' => $name)) . "</label><br />";
        
        if ($admin_option)
                $form_body .= elgg_view('input/checkboxes', array('internalname' => "admin", 'options' => array(elgg_echo('admin_option'))));
-       \r
-       $form_body .= elgg_view('input/hidden', array('internalname' => 'friend_guid', 'value' => $vars['friend_guid']));\r
+       
+       $form_body .= elgg_view('input/hidden', array('internalname' => 'friend_guid', 'value' => $vars['friend_guid']));
        $form_body .= elgg_view('input/hidden', array('internalname' => 'invitecode', 'value' => $vars['invitecode']));
        $form_body .= elgg_view('input/hidden', array('internalname' => 'action', 'value' => 'register'));
-       $form_body .= elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('register'))) . "</p>";\r
-?>\r
-\r
-       \r
-       <div id="register-box">\r
+       $form_body .= elgg_view('input/submit', array('internalname' => 'submit', 'value' => elgg_echo('register'))) . "</p>";
+?>
+
+       
+       <div id="register-box">
        <h2><?php echo elgg_echo('register'); ?></h2>
-       <?php echo elgg_view('input/form', array('action' => "{$vars['url']}action/register", 'body' => $form_body)) ?>\r
+       <?php echo elgg_view('input/form', array('action' => "{$vars['url']}action/register", 'body' => $form_body)) ?>
        </div>
\ No newline at end of file
index 98c9495e162094c73a07fe21a80a9bd42bc64062..7922de906703ae983d4a072b6405e0fd3972a4dc 100644 (file)
@@ -1,19 +1,19 @@
-<?php\r
-\r
-       /**\r
-        * Elgg administration main screen\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg administration main screen
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // Description of what's going on \r
-               echo "<p>" . elgg_view('output/longtext', array('value' => elgg_echo("admin:description"))) . "</p>";\r
-               \r
-       \r
-               \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       // Description of what's going on 
+               echo "<p>" . elgg_view('output/longtext', array('value' => elgg_echo("admin:description"))) . "</p>";
+               
+       
+               
 ?>
\ No newline at end of file
index 375f27a01b8ebf29c593d7bc02ef688637dab9d0..8a7850ed6ab97a9cfcd8c072ea22ca938ecc64ca 100644 (file)
                <?php } ?>
        </div>
 
-       <h3><?php echo $plugin; ?><?php if (elgg_view("settings/{$plugin}/edit")) { ?> <a class="pluginsettings_link">[<?php echo elgg_echo('settings'); ?>]</a><?php } ?></h3>\r
-       \r
-       <?php if (elgg_view("settings/{$plugin}/edit")) { ?>\r
-       <div class="pluginsettings">\r
-                       <div id="<?php echo $plugin; ?>_settings">\r
-                               <?php echo elgg_view("object/plugin", array('plugin' => $plugin, 'entity' => find_plugin_settings($plugin))) ?>\r
-                       </div>\r
-       </div>\r
-       <?php } ?>\r
-       \r
-       <?php\r
-\r
-               if ($manifest) {\r
-       \r
-       ?>\r
-               <div class="plugin_description"><?php echo elgg_view('output/longtext',array('value' => $manifest['description'])); ?></div>\r
-       <?php\r
-\r
-               }\r
-       \r
-       ?>\r
+       <h3><?php echo $plugin; ?><?php if (elgg_view("settings/{$plugin}/edit")) { ?> <a class="pluginsettings_link">[<?php echo elgg_echo('settings'); ?>]</a><?php } ?></h3>
        
-       <p><a class="manifest_details"><?php echo elgg_echo("admin:plugins:label:moreinfo"); ?></a></p>\r
+       <?php if (elgg_view("settings/{$plugin}/edit")) { ?>
+       <div class="pluginsettings">
+                       <div id="<?php echo $plugin; ?>_settings">
+                               <?php echo elgg_view("object/plugin", array('plugin' => $plugin, 'entity' => find_plugin_settings($plugin))) ?>
+                       </div>
+       </div>
+       <?php } ?>
+       
+       <?php
+
+               if ($manifest) {
+       
+       ?>
+               <div class="plugin_description"><?php echo elgg_view('output/longtext',array('value' => $manifest['description'])); ?></div>
+       <?php
+
+               }
+       
+       ?>
+       
+       <p><a class="manifest_details"><?php echo elgg_echo("admin:plugins:label:moreinfo"); ?></a></p>
 
        <div class="manifest_file">
        
-       <?php if ($manifest) { ?>\r
-               <?php if ((!$version_check_valid) || (!isset($manifest['elgg_version']))) { ?>\r
-               <div id="version_check">\r
-                       <?php \r
-                               if (!isset($manifest['elgg_version']))\r
-                                       echo elgg_echo('admin:plugins:warning:elggversionunknown');\r
-                               else\r
-                                       echo elgg_echo('admin:plugins:warning:elggtoolow');\r
-                       ?>\r
-               </div>\r
+       <?php if ($manifest) { ?>
+               <?php if ((!$version_check_valid) || (!isset($manifest['elgg_version']))) { ?>
+               <div id="version_check">
+                       <?php 
+                               if (!isset($manifest['elgg_version']))
+                                       echo elgg_echo('admin:plugins:warning:elggversionunknown');
+                               else
+                                       echo elgg_echo('admin:plugins:warning:elggtoolow');
+                       ?>
+               </div>
                <?php } ?>
                <div><?php echo elgg_echo('admin:plugins:label:version') . ": ". $manifest['version'] ?></div>
                <div><?php echo elgg_echo('admin:plugins:label:author') . ": ". $manifest['author'] ?></div>
index bf4818b643f017527bcb52335d42b33695564284..4e0f7c3b1eb9a54c43a1316a94fcad35c305355f 100644 (file)
@@ -1,15 +1,15 @@
-<?php\r
-       /**\r
-        * Elgg statistics screen\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Elgg statistics screen
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       global $CONFIG;\r
-                \r
+        * @link http://elgg.org/
+        */
+
+       global $CONFIG;
+                
 ?>
\ No newline at end of file
index d187655c3aebf87bd683592ca50cc658a9cb9d3c..b48b863193537f3ed2778a4f4ff6733de8b063ea 100644 (file)
@@ -1,55 +1,55 @@
-<?php\r
-       /**\r
-        * Elgg statistics screen\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Elgg statistics screen
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       \r
-       // Get entity statistics\r
+        * @link http://elgg.org/
+        */
+
+       
+       // Get entity statistics
        $entity_stats = get_entity_statistics();
-       $even_odd = "";\r
-?>\r
-<div class="admin_statistics">\r
-    <h3><?php echo elgg_echo('admin:statistics:label:numentities'); ?></h3>\r
-    <table>\r
-        <?php\r
-            foreach ($entity_stats as $k => $entry)\r
-            {\r
-               arsort($entry);\r
-                foreach ($entry as $a => $b)\r
-                {\r
-                    \r
-                    //This function controls the alternating class\r
-                       $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even';\r
-\r
-                    if ($a == "__base__") {\r
-                       $a = elgg_echo("item:{$k}");\r
-                       if (empty($a)) \r
-                               $a = $k;\r
-                    }\r
-                    else {\r
-                               if (empty($a))\r
-                                       $a = elgg_echo("item:{$k}");\r
-                               else\r
-                                               $a = elgg_echo("item:{$k}:{$a}");\r
-                               if (empty($a)) {\r
-                                                               $a = "$k $a";\r
-                               }\r
-                         }\r
-                    echo <<< END\r
-                        <tr class="{$even_odd}">\r
-                            <td class="column_one">{$a}:</td>\r
-                            <td>{$b}</td>\r
-                        </tr>\r
-END;\r
-                }\r
-            }\r
-        ?>\r
-    </table>\r
+       $even_odd = "";
+?>
+<div class="admin_statistics">
+    <h3><?php echo elgg_echo('admin:statistics:label:numentities'); ?></h3>
+    <table>
+        <?php
+            foreach ($entity_stats as $k => $entry)
+            {
+               arsort($entry);
+                foreach ($entry as $a => $b)
+                {
+                    
+                    //This function controls the alternating class
+                       $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even';
+
+                    if ($a == "__base__") {
+                       $a = elgg_echo("item:{$k}");
+                       if (empty($a)) 
+                               $a = $k;
+                    }
+                    else {
+                               if (empty($a))
+                                       $a = elgg_echo("item:{$k}");
+                               else
+                                               $a = elgg_echo("item:{$k}:{$a}");
+                               if (empty($a)) {
+                                                               $a = "$k $a";
+                               }
+                         }
+                    echo <<< END
+                        <tr class="{$even_odd}">
+                            <td class="column_one">{$a}:</td>
+                            <td>{$b}</td>
+                        </tr>
+END;
+                }
+            }
+        ?>
+    </table>
 </div>
\ No newline at end of file
index 403168ef0f632d0294f9a8aadfde6451305481a0..7b82ae0852a821d8272c91a6be0e05642ffe0953 100644 (file)
@@ -1,22 +1,22 @@
-<?php\r
-       /**\r
-        * Elgg statistics screen\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Elgg statistics screen
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       // users online\r
-       get_context('search');\r
-       $users_online = get_online_users();\r
-       get_context('admin');\r
-?>\r
-\r
-<div class="admin_users_online">\r
-    <h3><?php echo elgg_echo('admin:statistics:label:onlineusers'); ?></h3>\r
-    <?php echo $users_online; ?>\r
-</div>\r
+        * @link http://elgg.org/
+        */
+
+       // users online
+       get_context('search');
+       $users_online = get_online_users();
+       get_context('admin');
+?>
+
+<div class="admin_users_online">
+    <h3><?php echo elgg_echo('admin:statistics:label:onlineusers'); ?></h3>
+    <?php echo $users_online; ?>
+</div>
index 10c9b408868cee335429f95b97618cd24676466f..b7518bcd5b9aef06c1311ecb25ee0526ba6b8d81 100644 (file)
 <div id="search-box">
        <form action="<?php echo $vars['url']; ?>search/" method="get">
        <b><?php echo elgg_echo('admin:user:label:search'); ?></b>
-       <?php\r
-\r
-               echo elgg_view('input/text',array('internalname' => 'tag'));\r
-       \r
-       ?>\r
+       <?php
+
+               echo elgg_view('input/text',array('internalname' => 'tag'));
+       
+       ?>
        <input type="hidden" name="object" value="user" />
        <input type="submit" name="<?php echo elgg_echo('admin:user:label:seachbutton'); ?>" 
                value="<?php echo elgg_echo('admin:user:label:seachbutton'); ?>" />
index 5fe407fd55847d9d37d848b9594e7fa895a66439..430170aab6fb7c6b9ea30777240a8ac92476c220 100644 (file)
@@ -1,29 +1,29 @@
-<?php\r
-\r
-       /**\r
-        * Elgg AJAX loader\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg AJAX loader
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       $loader = <<< END\r
-       \r
-       <div align="center" class="ajax_loader"></div>\r
-       \r
-END;\r
-\r
-       $loader = str_replace("\n","",$loader);\r
-       $loader = str_replace("\r","",$loader);\r
-\r
-       if (isset($vars['slashes']) && $vars['slashes'] == true) {\r
-               $loader = addslashes($loader);\r
-       }\r
-       \r
-       echo $loader;\r
-               \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       $loader = <<< END
+       
+       <div align="center" class="ajax_loader"></div>
+       
+END;
+
+       $loader = str_replace("\n","",$loader);
+       $loader = str_replace("\r","",$loader);
+
+       if (isset($vars['slashes']) && $vars['slashes'] == true) {
+               $loader = addslashes($loader);
+       }
+       
+       echo $loader;
+               
 ?>
\ No newline at end of file
index cc42e103535c8857fb6559b4ad7d69f7b6bfea55..dfff81e83ca8ad4e836ad80ba3998b314004a27e 100644 (file)
@@ -1,24 +1,24 @@
-<?php\r
-\r
-       $performed_by = get_entity($vars['item']->subject_guid); // $statement->getSubject();\r
-       $object = get_entity($vars['item']->object_guid);\r
-       $url = $object->getURL();\r
-       $subtype = get_subtype_from_id($object->subtype);\r
-       $comment = $object->getAnnotations("generic_comment", 1, 0, "desc"); \r
-       foreach($comment as $c){\r
-               $contents = $c->value;\r
-       }\r
-       $contents = strip_tags($contents);//this is so we don't get large images etc in the activity river\r
-       $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";\r
-       $string = sprintf(elgg_echo("river:posted:generic"),$url) . " ";\r
-       $string .= elgg_echo("{$subtype}:river:annotate") . " | <a href=\"" . $object->getURL() . "\">" . $object->title . "</a>";\r
-       $string .= "<div class=\"river_content_display\">";\r
-       if(strlen($contents) > 200) {\r
-               $string .= substr($contents, 0, strpos($contents, ' ', 200)) . "...";\r
-    }else{\r
-           $string .= $contents;\r
-    }\r
-       $string .= "</div>";\r
-?>\r
-\r
+<?php
+
+       $performed_by = get_entity($vars['item']->subject_guid); // $statement->getSubject();
+       $object = get_entity($vars['item']->object_guid);
+       $url = $object->getURL();
+       $subtype = get_subtype_from_id($object->subtype);
+       $comment = $object->getAnnotations("generic_comment", 1, 0, "desc"); 
+       foreach($comment as $c){
+               $contents = $c->value;
+       }
+       $contents = strip_tags($contents);//this is so we don't get large images etc in the activity river
+       $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
+       $string = sprintf(elgg_echo("river:posted:generic"),$url) . " ";
+       $string .= elgg_echo("{$subtype}:river:annotate") . " | <a href=\"" . $object->getURL() . "\">" . $object->title . "</a>";
+       $string .= "<div class=\"river_content_display\">";
+       if(strlen($contents) > 200) {
+               $string .= substr($contents, 0, strpos($contents, ' ', 200)) . "...";
+    }else{
+           $string .= $contents;
+    }
+       $string .= "</div>";
+?>
+
 <?php echo $string; ?>
\ No newline at end of file
index 43254d61052af6761b8bffe17f259580cb25b99a..1ecf7ad8e46f9b565afa187052cb150b0664cd40 100644 (file)
@@ -1,61 +1,61 @@
-<?php\r
-\r
-       /**\r
-        * Elgg generic comment\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        * \r
-        */\r
-\r
-       $owner = get_user($vars['annotation']->owner_guid);\r
-\r
-?>\r
-\r
-\r
-       <div class="generic_comment"><!-- start of generic_comment div -->\r
-           \r
-               <div class="generic_comment_icon">              \r
-               <?php\r
-                       echo elgg_view("profile/icon",\r
-                                               array(\r
-                                                       'entity' => $owner, \r
-                                                       'size' => 'small'));\r
-               ?>\r
-               </div>\r
-               <div class="generic_comment_details">\r
-               \r
-                   <!-- output the actual comment -->\r
-                   <?php echo elgg_view("output/longtext",array("value" => $vars['annotation']->value)); ?>\r
-                   \r
-                   <p class="generic_comment_owner">\r
-               <a href="<?php echo $owner->getURL(); ?>"><?php echo $owner->name; ?></a> <?php echo friendly_time($vars['annotation']->time_created); ?>\r
-               </p>\r
-                   \r
-                   <?php\r
-                \r
-                       // if the user looking at the comment can edit, show the delete link\r
-                           if ($vars['annotation']->canEdit()) {\r
-                           \r
-            ?>\r
-                   <p>\r
-                       <?php\r
-\r
-                               echo elgg_view("output/confirmlink",array(\r
-                                                                                                               'href' => $vars['url'] . "action/comments/delete?annotation_id=" . $vars['annotation']->id,\r
-                                                                                                               'text' => elgg_echo('delete'),\r
-                                                                                                               'confirm' => elgg_echo('deleteconfirm'),\r
-                                                                                                       ));\r
-               \r
-                       ?>\r
-                   </p>\r
-               \r
-            <?php\r
-                           } //end of can edit if statement\r
-                   ?>\r
-               </div><!-- end of generic_comment_details -->\r
+<?php
+
+       /**
+        * Elgg generic comment
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        */
+
+       $owner = get_user($vars['annotation']->owner_guid);
+
+?>
+
+
+       <div class="generic_comment"><!-- start of generic_comment div -->
+           
+               <div class="generic_comment_icon">              
+               <?php
+                       echo elgg_view("profile/icon",
+                                               array(
+                                                       'entity' => $owner, 
+                                                       'size' => 'small'));
+               ?>
+               </div>
+               <div class="generic_comment_details">
+               
+                   <!-- output the actual comment -->
+                   <?php echo elgg_view("output/longtext",array("value" => $vars['annotation']->value)); ?>
+                   
+                   <p class="generic_comment_owner">
+               <a href="<?php echo $owner->getURL(); ?>"><?php echo $owner->name; ?></a> <?php echo friendly_time($vars['annotation']->time_created); ?>
+               </p>
+                   
+                   <?php
+                
+                       // if the user looking at the comment can edit, show the delete link
+                           if ($vars['annotation']->canEdit()) {
+                           
+            ?>
+                   <p>
+                       <?php
+
+                               echo elgg_view("output/confirmlink",array(
+                                                                                                               'href' => $vars['url'] . "action/comments/delete?annotation_id=" . $vars['annotation']->id,
+                                                                                                               'text' => elgg_echo('delete'),
+                                                                                                               'confirm' => elgg_echo('deleteconfirm'),
+                                                                                                       ));
+               
+                       ?>
+                   </p>
+               
+            <?php
+                           } //end of can edit if statement
+                   ?>
+               </div><!-- end of generic_comment_details -->
        </div><!-- end of generic_comment div -->
\ No newline at end of file
index 89b6e58d32ec441f21109c9c707e5e6629707926..1a37a464e7da077ce7d59f217fca4d0e4cd4dae9 100644 (file)
@@ -1,19 +1,19 @@
-<?php\r
-\r
-    /**\r
-        * Elgg sample welcome page\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+    /**
+        * Elgg sample welcome page
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-        \r
-        $user = $vars['name'];\r
-        \r
-?>\r
-\r
-<p><?php echo sprintf(elgg_echo('welcome:user'), $user); ?></p>\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+        
+        $user = $vars['name'];
+        
+?>
+
+<p><?php echo sprintf(elgg_echo('welcome:user'), $user); ?></p>
 <p><a href="<?php echo $vars['url']; ?>action/logout">[logout]</a></p>
\ No newline at end of file
index 34ff1984d3d7783aa85526072c4e7d33b801f034..a5c30fe52b4c1699d72027ffd40841be270724aa 100644 (file)
@@ -1,21 +1,21 @@
-<?php\r
-\r
-       /**\r
-        * Elgg default layout\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg default layout
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       for ($i = 1; $i < 8; $i++) {
+               
+               if (isset($vars["area{$i}"]))
+                       echo $vars["area{$i}"];
+               
+       }
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       for ($i = 1; $i < 8; $i++) {\r
-               \r
-               if (isset($vars["area{$i}"]))\r
-                       echo $vars["area{$i}"];\r
-               \r
-       }\r
-\r
 ?>
\ No newline at end of file
index 1537f98aeafed11b3b0d4503c756c85e35d5bb3a..b43ff4255dfcf693af827ecbcce35c0acc269998 100644 (file)
@@ -1,20 +1,20 @@
-<?php\r
-\r
-       /**\r
-        * Elgg 2 column right sidebar canvas layout\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg 2 column right sidebar canvas layout
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+?>
+
+<div id="blog_edit_page">
+
+<?php if (isset($vars['area1'])) echo $vars['area1']; ?>
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-?>\r
-\r
-<div id="blog_edit_page">\r
-\r
-<?php if (isset($vars['area1'])) echo $vars['area1']; ?>\r
-\r
 </div>
\ No newline at end of file
index 6e6f80c2180a78d3c067f864f033969de01c5faf..f6ae93a2ca184f37a9a273f91a6ebda4c952724d 100644 (file)
@@ -1,30 +1,30 @@
-<?php\r
-\r
-       /**\r
-        * Elgg 2 column left sidebar with boxes\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        */\r
-\r
-?>\r
-\r
-<!-- left sidebar -->\r
-<div id="two_column_left_sidebar_boxes">\r
-\r
-     <?php if (isset($vars['area1'])) echo $vars['area1']; ?>\r
-        <?php if (isset($vars['area3'])) echo $vars['area3']; ?>\r
-\r
-</div><!-- /two_column_left_sidebar -->\r
-\r
-<!-- main content -->\r
-<div id="two_column_left_sidebar_maincontent_boxes">\r
-\r
-<?php if (isset($vars['area2'])) echo $vars['area2']; ?>\r
-\r
-</div><!-- /two_column_left_sidebar_maincontent -->\r
-\r
+<?php
+
+       /**
+        * Elgg 2 column left sidebar with boxes
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+?>
+
+<!-- left sidebar -->
+<div id="two_column_left_sidebar_boxes">
+
+     <?php if (isset($vars['area1'])) echo $vars['area1']; ?>
+        <?php if (isset($vars['area3'])) echo $vars['area3']; ?>
+
+</div><!-- /two_column_left_sidebar -->
+
+<!-- main content -->
+<div id="two_column_left_sidebar_maincontent_boxes">
+
+<?php if (isset($vars['area2'])) echo $vars['area2']; ?>
+
+</div><!-- /two_column_left_sidebar_maincontent -->
+
index 5af0f0609c62cbd933de93246a3dd42d47f62587..a5995b24070630cc1f2d549cbf235605b342c8ab 100644 (file)
@@ -1,15 +1,15 @@
-<?php\r
-\r
-       if (isset($vars['group_name'])) {\r
-               $groupname = $vars['group_name'];\r
-       } else {\r
-               $groupname = "main";\r
-       }\r
-       if (isset($vars['submenu'])) {\r
-               \r
-               $submenu = "<ul>" . $vars['submenu'] . "</ul>";\r
-               echo "<div class=\"submenu_group\"><div class=\"submenu_group_{$groupname}\">{$submenu}</div></div>";\r
-               \r
-       }\r
-\r
+<?php
+
+       if (isset($vars['group_name'])) {
+               $groupname = $vars['group_name'];
+       } else {
+               $groupname = "main";
+       }
+       if (isset($vars['submenu'])) {
+               
+               $submenu = "<ul>" . $vars['submenu'] . "</ul>";
+               echo "<div class=\"submenu_group\"><div class=\"submenu_group_{$groupname}\">{$submenu}</div></div>";
+               
+       }
+
 ?>
\ No newline at end of file
index e73b76f0e34a0dc51953d73ba70690ee871dbda9..143b0311e3f3e56cc426fd8cd47c1d9222ae44bd 100644 (file)
@@ -1,16 +1,16 @@
-<?php\r
-\r
-       if (isset($vars['selected']) && $vars['selected'] == true) {\r
-               $selected = "class=\"selected\"";\r
-       } else {\r
-               $selected = "";\r
-       }\r
-       \r
-       if (isset($vars['onclick']) && $vars['onclick'] == true) {\r
-               $onclick = "onclick=\"javascript:return confirm('". elgg_echo('deleteconfirm') . "')\"";\r
-       } else {\r
-               $onclick = "";\r
-       }\r
-\r
-?>\r
+<?php
+
+       if (isset($vars['selected']) && $vars['selected'] == true) {
+               $selected = "class=\"selected\"";
+       } else {
+               $selected = "";
+       }
+       
+       if (isset($vars['onclick']) && $vars['onclick'] == true) {
+               $onclick = "onclick=\"javascript:return confirm('". elgg_echo('deleteconfirm') . "')\"";
+       } else {
+               $onclick = "";
+       }
+
+?>
 <li <?php echo $selected; ?>><a href="<?php echo $vars['href']; ?>" <?php echo $onclick; ?>><?php echo $vars['label']; ?></a></li>
\ No newline at end of file
index e13f139771943b3aeb979550e53ae0ae14b8b71f..b629fc3f078f7f4d9e2632f291c05b8cedbb0274 100644 (file)
@@ -1,25 +1,25 @@
-<?php\r
-\r
-    /**\r
-        * Elgg comments add form\r
-        * \r
-        * @package Elgg\r
+<?php
 
-        * @author Curverider Ltd <info@elgg.com>\r
+    /**
+        * Elgg comments add form
+        * 
+        * @package Elgg
 
-        * @link http://elgg.com/\r
-        * \r
-        * @uses $vars['entity']\r
-        */\r
-        \r
-        if (isset($vars['entity']) && isloggedin()) {\r
-        \r
-                $form_body = "<div class=\"contentWrapper\"><p class='longtext_editarea'><label>".elgg_echo("generic_comments:text")."<br />" . elgg_view('input/longtext',array('internalname' => 'generic_comment')) . "</label></p>";\r
-                $form_body .= "<p>" . elgg_view('input/hidden', array('internalname' => 'entity_guid', 'value' => $vars['entity']->getGUID()));\r
-                $form_body .= elgg_view('input/submit', array('value' => elgg_echo("save"))) . "</p></div>";\r
-                \r
-                echo elgg_view('input/form', array('body' => $form_body, 'action' => "{$vars['url']}action/comments/add"));\r
-\r
-    }\r
-    \r
+        * @author Curverider Ltd <info@elgg.com>
+
+        * @link http://elgg.com/
+        * 
+        * @uses $vars['entity']
+        */
+        
+        if (isset($vars['entity']) && isloggedin()) {
+        
+                $form_body = "<div class=\"contentWrapper\"><p class='longtext_editarea'><label>".elgg_echo("generic_comments:text")."<br />" . elgg_view('input/longtext',array('internalname' => 'generic_comment')) . "</label></p>";
+                $form_body .= "<p>" . elgg_view('input/hidden', array('internalname' => 'entity_guid', 'value' => $vars['entity']->getGUID()));
+                $form_body .= elgg_view('input/submit', array('value' => elgg_echo("save"))) . "</p></div>";
+                
+                echo elgg_view('input/form', array('body' => $form_body, 'action' => "{$vars['url']}action/comments/add"));
+
+    }
+    
 ?>
\ No newline at end of file
index 6220ba59579c71924ae1aca8324501e5ae8cd8c4..1bde247367b75935800a6d306f25fa18e0116258 100644 (file)
@@ -1,12 +1,12 @@
-<div id="dashboard_info">\r
-<p>\r
-<?php\r
-\r
-       echo elgg_echo("dashboard:nowidgets");\r
-\r
-?>\r
-</p>\r
-<p>\r
-       <a href="<?php echo $vars['url']; ?>dashboard/latest.php"><?php echo elgg_echo('content:latest:blurb'); ?></a>\r
-</p>\r
+<div id="dashboard_info">
+<p>
+<?php
+
+       echo elgg_echo("dashboard:nowidgets");
+
+?>
+</p>
+<p>
+       <a href="<?php echo $vars['url']; ?>dashboard/latest.php"><?php echo elgg_echo('content:latest:blurb'); ?></a>
+</p>
 </div>
\ No newline at end of file
index e97a518839623cd93d195e000f3ece5317c93190..481854c4d62a84386e457f65440d48039c1c83bb 100644 (file)
@@ -1,4 +1,4 @@
-\r
-       var entity;\r
-       $('textarea[name='+entityname+']').val($('textarea[name='+entityname+']').val() + ' ' + content);       \r
+
+       var entity;
+       $('textarea[name='+entityname+']').val($('textarea[name='+entityname+']').val() + ' ' + content);       
        
\ No newline at end of file
index 587acad1dd9f2f266b611e22d44c060ea8b982f8..0787a226b4854d1ac32e4a041e2354f8f8d2b9ec 100644 (file)
@@ -1,7 +1,7 @@
-\r
-       function elggUpdateContent(content, entityname) {\r
-               content = ' ' + content + ' ';\r
-               <?php\r
-                       echo elgg_view('embed/addcontentjs');\r
-               ?>\r
+
+       function elggUpdateContent(content, entityname) {
+               content = ' ' + content + ' ';
+               <?php
+                       echo elgg_view('embed/addcontentjs');
+               ?>
        }
\ No newline at end of file
index 501283fc37ec80771100bbd6513cd46066c78e04..812623cb1e34cdeaa9e3e85e7335106fc55d5aae 100644 (file)
@@ -1,60 +1,60 @@
-<?php\r
-\r
-       /**\r
-        * Elgg friends collection\r
-        * Lists one of a user's friends collections\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg friends collection
+        * Lists one of a user's friends collections
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @see collections.php
+        * 
+        * @uses $vars['collection'] The individual friends collection
+        */
+
+                       $coll = $vars['collection'];
+                       
+                       if (is_array($vars['collection']->members)) {
+                               $count = sizeof($vars['collection']->members);
+                       } else {
+                               $count = 0;
+                       }
+                       
+                       echo "<li><h2>";
+               
+                       //as collections are private, check that the logged in user is the owner
+                       if($coll->owner_guid == $_SESSION['user']->getGUID()) {
+                               echo "<div class=\"friends_collections_controls\">";
+                               echo elgg_view('output/confirmlink', array(
+                                               'href' => $vars['url'] . 'action/friends/deletecollection?collection=' . $coll->id,
+                                               'class' => 'delete_collection'
+                                               ));
+                               echo "</div>";
+                       }
+                       echo $coll->name;
+                       echo " (<span id=\"friends_membership_count{$vars['friendspicker']}\">{$count}</span>) </h2>";
+                       
+                       // individual collection panels
+                       if($friends = $vars['collection']->entities){
+                               $content = elgg_view('friends/collectiontabs', array('owner' => $_SESSION['user'], 'collection' => $vars['collection'], 'friendspicker' => $vars['friendspicker']));
+                               echo elgg_view('friends/picker',array('entities' => $friends, 'value' => $members, 'content' => $content, 'replacement' => '', 'friendspicker' => $vars['friendspicker']));
+                               ?>
+                               
+<script type="text/javascript">
+$(document).ready(function () {
+               
+               $('#friends_picker_placeholder<?php echo $vars['friendspicker']; ?>').load('<?php echo $vars['url']; ?>friends/pickercallback.php?username=<?php echo $_SESSION['user']->username; ?>&type=list&collection=<?php echo $vars['collection']->id; ?>');
+                               
+       });
+</script>
+                               <?php
+                       }
+                       
+                       // close friends_picker div and the accordian list item
+                       echo "</li>";
 
-        * @link http://elgg.org/\r
-        * \r
-        * @see collections.php\r
-        * \r
-        * @uses $vars['collection'] The individual friends collection\r
-        */\r
-\r
-                       $coll = $vars['collection'];\r
-                       \r
-                       if (is_array($vars['collection']->members)) {\r
-                               $count = sizeof($vars['collection']->members);\r
-                       } else {\r
-                               $count = 0;\r
-                       }\r
-                       \r
-                       echo "<li><h2>";\r
-               \r
-                       //as collections are private, check that the logged in user is the owner\r
-                       if($coll->owner_guid == $_SESSION['user']->getGUID()) {\r
-                               echo "<div class=\"friends_collections_controls\">";\r
-                               echo elgg_view('output/confirmlink', array(\r
-                                               'href' => $vars['url'] . 'action/friends/deletecollection?collection=' . $coll->id,\r
-                                               'class' => 'delete_collection'\r
-                                               ));\r
-                               echo "</div>";\r
-                       }\r
-                       echo $coll->name;\r
-                       echo " (<span id=\"friends_membership_count{$vars['friendspicker']}\">{$count}</span>) </h2>";\r
-                       \r
-                       // individual collection panels\r
-                       if($friends = $vars['collection']->entities){\r
-                               $content = elgg_view('friends/collectiontabs', array('owner' => $_SESSION['user'], 'collection' => $vars['collection'], 'friendspicker' => $vars['friendspicker']));\r
-                               echo elgg_view('friends/picker',array('entities' => $friends, 'value' => $members, 'content' => $content, 'replacement' => '', 'friendspicker' => $vars['friendspicker']));\r
-                               ?>\r
-                               \r
-<script type="text/javascript">\r
-$(document).ready(function () {\r
-               \r
-               $('#friends_picker_placeholder<?php echo $vars['friendspicker']; ?>').load('<?php echo $vars['url']; ?>friends/pickercallback.php?username=<?php echo $_SESSION['user']->username; ?>&type=list&collection=<?php echo $vars['collection']->id; ?>');\r
-                               \r
-       });\r
-</script>\r
-                               <?php\r
-                       }\r
-                       \r
-                       // close friends_picker div and the accordian list item\r
-                       echo "</li>";\r
-\r
 ?>
\ No newline at end of file
index 63446ec89b565808c132c9799a884ea93224f9b8..c785cd68e1fa2ec910755d6d352a941d759c3cc6 100644 (file)
@@ -1,53 +1,53 @@
-<?php\r
-\r
-       /**\r
-        * Elgg friends collections\r
-        * Lists a user's friends collections\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['collections'] The array of friends collections\r
-        */\r
-\r
-               if (!isset($friendspicker)) $friendspicker = 0;\r
-\r
-               echo "<div class=\"contentWrapper\">";\r
-\r
-               if (is_array($vars['collections']) && sizeof($vars['collections'])) {\r
-                       \r
-                       echo "<ul id=\"friends_collections_accordian\">";\r
-                       \r
-                       foreach($vars['collections'] as $collection) {\r
-                               \r
-                               $friendspicker++;\r
-                               echo elgg_view('friends/collection',array('collection' => $collection, 'friendspicker' => $friendspicker));\r
-                               \r
-                       }\r
-                       \r
-                       echo "</ul>";\r
-                       \r
-               } else {\r
-                       \r
-                       echo elgg_echo("friends:nocollections");\r
-                       \r
-               }\r
-               \r
-               echo "</div>";\r
-    \r
-?>\r
-\r
-<script>\r
-$(document).ready(function(){\r
-\r
-$('#friends_collections_accordian h2').click(function () {\r
-       $(this.parentNode).children("[class=friends_picker]").slideToggle("fast");\r
-       //return false;\r
-});\r
-\r
-});  \r
+<?php
+
+       /**
+        * Elgg friends collections
+        * Lists a user's friends collections
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['collections'] The array of friends collections
+        */
+
+               if (!isset($friendspicker)) $friendspicker = 0;
+
+               echo "<div class=\"contentWrapper\">";
+
+               if (is_array($vars['collections']) && sizeof($vars['collections'])) {
+                       
+                       echo "<ul id=\"friends_collections_accordian\">";
+                       
+                       foreach($vars['collections'] as $collection) {
+                               
+                               $friendspicker++;
+                               echo elgg_view('friends/collection',array('collection' => $collection, 'friendspicker' => $friendspicker));
+                               
+                       }
+                       
+                       echo "</ul>";
+                       
+               } else {
+                       
+                       echo elgg_echo("friends:nocollections");
+                       
+               }
+               
+               echo "</div>";
+    
+?>
+
+<script>
+$(document).ready(function(){
+
+$('#friends_collections_accordian h2').click(function () {
+       $(this.parentNode).children("[class=friends_picker]").slideToggle("fast");
+       //return false;
+});
+
+});  
 </script>
\ No newline at end of file
index 31ae0eacd254e4306df50ce3ecc3514840428ac6..a4ad5986631923f1d33d7d137ec101422cdc9eea 100644 (file)
@@ -1,48 +1,48 @@
-<?php\r
-\r
-       $friendspicker = $vars['friendspicker'];\r
-       \r
-       $collectionid = $vars['collection']->id;\r
-       $ownerid = $vars['owner']->getGUID();\r
-       \r
-?>\r
-\r
-<div id="elgg_horizontal_tabbed_nav">\r
-<ul>\r
-<li class="selected"><a href="#" class="collectionmembers<?php echo $friendspicker . "\">" . elgg_echo('friends:collections:members'); ?></a></li>\r
-\r
-<li><a href="#" class="editmembers<?php echo $friendspicker . "\">" . elgg_echo('friends:collections:edit'); ?></a></li>\r
-\r
-</ul>\r
-</div>\r
-\r
-<script type="text/javascript">\r
-$(document).ready(function () {\r
-\r
-       $('a.collectionmembers<?php echo $friendspicker; ?>').click(function () {\r
-               // load collection members pane\r
-               $('#friends_picker_placeholder<?php echo $friendspicker; ?>').load('<?php echo $vars['url']; ?>friends/pickercallback.php?username=<?php echo $_SESSION['user']->username; ?>&type=list&collection=<?php echo $collectionid; ?>&friendspicker=<?php echo $friendspicker; ?>');\r
-               \r
-               // remove selected state from previous tab\r
-               $(this).parent().parent().find("li.selected").removeClass("selected");\r
-               // add selected class to current tab\r
-               $(this).parent().addClass("selected");\r
-                               \r
-               return false;\r
-    });\r
-\r
-       $('a.editmembers<?php echo $friendspicker; ?>').click(function () {\r
-               // load friends picker pane\r
-               $('#friends_picker_placeholder<?php echo $friendspicker; ?>').load('<?php echo $vars['url']; ?>friends/pickercallback.php?username=<?php echo $_SESSION['user']->username; ?>&type=picker&collection=<?php echo $collectionid; ?>&friendspicker=<?php echo $friendspicker; ?>');\r
-\r
-               // remove selected state from previous tab\r
-               $(this).parent().parent().find("li.selected").removeClass("selected");\r
-               // add selected class to current tab\r
-               $(this).parent().addClass("selected");\r
-       \r
-               return false;\r
-    });\r
-\r
-\r
-});\r
-</script>\r
+<?php
+
+       $friendspicker = $vars['friendspicker'];
+       
+       $collectionid = $vars['collection']->id;
+       $ownerid = $vars['owner']->getGUID();
+       
+?>
+
+<div id="elgg_horizontal_tabbed_nav">
+<ul>
+<li class="selected"><a href="#" class="collectionmembers<?php echo $friendspicker . "\">" . elgg_echo('friends:collections:members'); ?></a></li>
+
+<li><a href="#" class="editmembers<?php echo $friendspicker . "\">" . elgg_echo('friends:collections:edit'); ?></a></li>
+
+</ul>
+</div>
+
+<script type="text/javascript">
+$(document).ready(function () {
+
+       $('a.collectionmembers<?php echo $friendspicker; ?>').click(function () {
+               // load collection members pane
+               $('#friends_picker_placeholder<?php echo $friendspicker; ?>').load('<?php echo $vars['url']; ?>friends/pickercallback.php?username=<?php echo $_SESSION['user']->username; ?>&type=list&collection=<?php echo $collectionid; ?>&friendspicker=<?php echo $friendspicker; ?>');
+               
+               // remove selected state from previous tab
+               $(this).parent().parent().find("li.selected").removeClass("selected");
+               // add selected class to current tab
+               $(this).parent().addClass("selected");
+                               
+               return false;
+    });
+
+       $('a.editmembers<?php echo $friendspicker; ?>').click(function () {
+               // load friends picker pane
+               $('#friends_picker_placeholder<?php echo $friendspicker; ?>').load('<?php echo $vars['url']; ?>friends/pickercallback.php?username=<?php echo $_SESSION['user']->username; ?>&type=picker&collection=<?php echo $collectionid; ?>&friendspicker=<?php echo $friendspicker; ?>');
+
+               // remove selected state from previous tab
+               $(this).parent().parent().find("li.selected").removeClass("selected");
+               // add selected class to current tab
+               $(this).parent().addClass("selected");
+       
+               return false;
+    });
+
+
+});
+</script>
index 0b387f8306069b5dfb06f29e18d4a92b3342f720..bec7212eef1db6e94b9479b784749c1d27721720 100644 (file)
@@ -1,23 +1,23 @@
-<?php\r
-\r
-       /**\r
-        * Elgg friend collections required hidden fields for js friends picker form \r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        */\r
-\r
-               if (isset($vars['collection'])) {\r
-?>\r
-\r
-               <input type="hidden" name="collection_id" value="<?php echo $vars['collection']->id; ?>" />\r
-\r
-<?php\r
-\r
-               }\r
-\r
+<?php
+
+       /**
+        * Elgg friend collections required hidden fields for js friends picker form 
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+               if (isset($vars['collection'])) {
+?>
+
+               <input type="hidden" name="collection_id" value="<?php echo $vars['collection']->id; ?>" />
+
+<?php
+
+               }
+
 ?>
\ No newline at end of file
index d9434f10b94ca6dae8d22f60ad1ceb760cfd9ead..c35bcaba3c754ae11c69e4c3465b792515d4ba89 100644 (file)
        // Set title, form destination
                if (isset($vars['collection'])) {
                        $action = "friends/editcollection";
-                       $title = $vars['collection'][0]->name;\r
+                       $title = $vars['collection'][0]->name;
                        $highlight = 'default';
                } else  {
                        $action = "friends/addcollection";
-                       $title = "";\r
+                       $title = "";
                        $highlight = 'all';
            }
 
index c6709a2c16b42acc38451629633db46596453e19..3907479bd52bb38e2ce934593804306572eb86c0 100644 (file)
@@ -1,27 +1,27 @@
-<?php\r
-\r
-       /**\r
-        * Elgg friends list\r
-        * Lists a user's friends\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg friends list
+        * Lists a user's friends
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['friends'] The array of ElggUser objects
+        */
+
+               if (is_array($vars['friends']) && sizeof($vars['friends']) > 0) {
+                       
+                       foreach($vars['friends'] as $friend) {
+                               
+                               echo elgg_view_entity($friend);
+                               
+                       }
+                       
+               }
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['friends'] The array of ElggUser objects\r
-        */\r
-\r
-               if (is_array($vars['friends']) && sizeof($vars['friends']) > 0) {\r
-                       \r
-                       foreach($vars['friends'] as $friend) {\r
-                               \r
-                               echo elgg_view_entity($friend);\r
-                               \r
-                       }\r
-                       \r
-               }\r
-\r
 ?>
\ No newline at end of file
index 0dcb208aa33ec56bf60560c60bed2bf944e649eb..319088601f2a93c3d54d29ce7841a345074f549c 100644 (file)
-<?php\r
-\r
-       /**\r
-        * Elgg friends picker\r
-        * Lists the friends picker\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['entities'] The array of ElggUser objects\r
-        */\r
-\r
-       // Let the system know that the friends picker is in use\r
-               global $pickerinuse;\r
-               $pickerinuse = true;\r
-               $chararray = elgg_echo('friendspicker:chararray');\r
-\r
-       // Initialise internalname\r
-               if (!isset($vars['internalname'])) {\r
-                       $internalname = "friend";\r
-               } else {\r
-                       $internalname = $vars['internalname'];\r
-               }\r
-               \r
-       // Are we highlighting default or all?\r
-               if (empty($vars['highlight'])) $vars['highlight'] = 'default';\r
-               if ($vars['highlight'] != 'all') $vars['highlight'] = 'default';\r
-               \r
-       // Initialise values\r
-               if (!isset($vars['value'])) {\r
-                       $vars['value'] = array();\r
-               } else {\r
-                       if (!is_array($vars['value'])) {\r
-                               $vars['value'] = (int) $vars['value'];\r
-                               $vars['value'] = array($vars['value']);\r
-                       }\r
-               }\r
-\r
-       // Initialise whether we're calling back or not\r
-               if (isset($vars['callback'])) {\r
-                       $callback = $vars['callback'];\r
-               } else {\r
-                       $callback = false;\r
-               }\r
-               \r
-       // We need to count the number of friends pickers on the page.\r
-               if (!isset($vars['friendspicker'])) {\r
-                       global $friendspicker;\r
-                       if (!isset($friendspicker)) $friendspicker = 0;\r
-                       $friendspicker++;\r
-               } else {\r
-                       $friendspicker = $vars['friendspicker'];\r
-               }\r
-\r
-               $users = array();\r
-               $activeletters = array();\r
-               \r
-       // Are we displaying form tags and submit buttons?\r
-       // (If we've been given a target, then yes! Otherwise, no.)\r
-               if (isset($vars['formtarget'])) {\r
-                       $formtarget = $vars['formtarget'];\r
-               } else {\r
-                       $formtarget = false;\r
-               }\r
-               \r
-       // Sort users by letter\r
-               if (is_array($vars['entities']) && sizeof($vars['entities']))\r
-                       foreach($vars['entities'] as $user) {\r
-                               \r
-                               if (is_callable('mb_substr'))\r
-                                       $letter = strtoupper(mb_substr($user->name,0,1));\r
-                               else\r
-                                       $letter = strtoupper(substr($user->name,0,1));\r
-                               if (!substr_count($chararray,$letter)) {\r
-                                       $letter = "*";\r
-                               }\r
-                               if (!isset($users[$letter])) {\r
-                                       $users[$letter] = array();\r
-                               }\r
-                               $users[$letter][$user->name] = $user;\r
-                               \r
-                       }\r
-               \r
-       if (!$callback) {\r
-                       \r
-?>\r
-\r
-<div class="friends_picker">\r
-\r
-<?php\r
-\r
-       if (isset($vars['content'])) echo $vars['content'];\r
-\r
-       \r
-?>\r
-\r
-       <div id="friends_picker_placeholder<?php echo $friendspicker; ?>">\r
-\r
-<?php\r
-       \r
-       }\r
-       \r
-       if (!isset($vars['replacement'])) {\r
-       \r
-               if ($formtarget) {\r
-?>\r
-\r
-       <script language="text/javascript">\r
-               $(function() { // onload...do\r
-               $('#collectionMembersForm<?php echo $friendspicker; ?>').submit(function() {\r
-                       var inputs = [];\r
-                       $(':input', this).each(function() {\r
-                               if (this.type != 'checkbox' || (this.type == 'checkbox' && this.checked != false)) {\r
-                                       inputs.push(this.name + '=' + escape(this.value));\r
-                               }\r
-                       });\r
-                       jQuery.ajax({\r
-                               type: "POST",\r
-                               data: inputs.join('&'),\r
-                               url: this.action,\r
-                               success: function(){\r
-                               $('a.collectionmembers<?php echo $friendspicker; ?>').click();\r
-                               }\r
-\r
-                       });\r
-                       return false;\r
-        })\r
-      })\r
-\r
-       </script>\r
-\r
-       <!-- Collection members form -->\r
-       <form id="collectionMembersForm<?php echo $friendspicker; ?>" action="<?php echo $formtarget; ?>" method="post"> <!-- action="" method=""> -->\r
-\r
-<?php\r
-\r
-               }\r
-\r
-?>\r
-\r
-       <div class="friendsPicker_wrapper">\r
-       <div id="friendsPicker<?php echo $friendspicker; ?>">\r
-               <div class="friendsPicker_container">\r
-<?php\r
-\r
-       // Initialise letters\r
-               $chararray .= "*";\r
-               if (is_callable('mb_substr'))\r
-                       $letter = mb_substr($chararray,0,1);\r
-               else\r
-                       $letter = substr($chararray,0,1);\r
-               $letpos = 0;\r
-               while (1 == 1) {\r
-?>\r
-                       <div class="panel" title="<?php \r
-                                       echo $letter;\r
-                       ?>">\r
-                               <div class="wrapper">\r
-                                       <h3><?php echo $letter; ?></h3>                                 \r
-                                       \r
-<?php\r
-\r
-                       if (isset($users[$letter])) {\r
-                               ksort($users[$letter]);\r
-                               \r
-                               echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";\r
-                               $col = 0;\r
-                               \r
-                               foreach($users[$letter] as $friend) {\r
-                                       if ($col == 0) echo "<tr>";\r
-                                       \r
-                                       //echo "<p>" . $user->name . "</p>";\r
-                                       $label = elgg_view("profile/icon",array('entity' => $friend, 'size' => 'tiny', 'override' => true)); \r
-                                       $options[$label] = $friend->getGUID();\r
-                                       \r
-                                       if ($vars['highlight'] == 'all'\r
-                                               && !in_array($letter,$activeletters)) {\r
-                                                       $activeletters[] = $letter;\r
-                                               }\r
-                                               \r
-                                       \r
-                                       if (in_array($friend->getGUID(),$vars['value'])) {\r
-                                               $checked = "checked = \"checked\"";\r
-                                               if (\r
-                                                               !in_array($letter,$activeletters)\r
-                                                               && $vars['highlight'] == 'default'\r
-                                                       )\r
-                                                       $activeletters[] = $letter;\r
-                                       } else {\r
-                                               $checked = "";\r
-                                       }\r
-\r
-?>\r
-\r
-                       <td>\r
-                       \r
-                               <input type="checkbox" <?php echo $checked; ?> name="<?php echo $internalname; ?>[]" value="<?php echo $options[$label]; ?>" />\r
-                       \r
-                       </td>\r
-\r
-                       <td >\r
-                       \r
-                               <div style="width: 25px; margin-bottom: 15px;">\r
-<?php\r
-\r
-                               echo $label;\r
-                       \r
-?>\r
-                               </div>\r
-                       </td>\r
-                       <td style="width: 200px; padding: 5px;">\r
-<?php\r
-\r
-                                       echo $friend->name;\r
-                               \r
-?>\r
-                       </td>\r
-<?php\r
-                                       \r
-                                       $col++;\r
-                                       if ($col == 3){\r
-                                               echo "</tr>";\r
-                                               $col = 0;\r
-                                       }\r
-                               }\r
-                               if ($col < 3) echo "</tr>";\r
-                               \r
-                               echo "</table>";\r
-                               \r
-                       }\r
-\r
-?>\r
-                       \r
-                               </div>\r
-                       </div>\r
-<?php                  \r
-                       //if ($letter == 'Z') break;\r
-                       \r
-                       if (is_callable('mb_substr'))\r
-                               $substr = mb_substr($chararray,strlen($chararray) - 1,1);\r
-                       else\r
-                               $substr = substr($chararray,strlen($chararray) - 1,1);\r
-                       if ($letter == $substr) break;\r
-                       //$letter++;\r
-                       $letpos++;\r
-                       if (is_callable('mb_substr'))\r
-                               $letter = mb_substr($chararray,$letpos,1);\r
-                       else\r
-                               $letter = substr($chararray,$letpos,1);\r
-               }\r
-               \r
-?>\r
-               </div>\r
-               \r
-<?php\r
-\r
-       if ($formtarget) {\r
-\r
-               if (isset($vars['formcontents']))\r
-                       echo $vars['formcontents'];\r
-               \r
-?>\r
-               <div class="clearfloat"></div>\r
-               <div class="friendspicker_savebuttons">\r
-                       <input type="submit" class="submit_button" value="<?php echo elgg_echo('save'); ?>" />\r
-                       <input type="button" class="cancel_button" value="<?php echo elgg_echo('cancel'); ?>" onclick="$('a.collectionmembers<?php echo $friendspicker; ?>').click();" />\r
-               <br /></div>\r
-               </form>\r
-               \r
-<?php\r
-\r
-       }\r
-\r
-?>\r
-               \r
-       </div>\r
-       </div>\r
-       \r
-<?php\r
-       } else {\r
-               echo $vars['replacement']; \r
-       }\r
-       if (!$callback) {\r
-\r
-?>\r
-                       \r
-       </div>\r
-</div>\r
-\r
-\r
-<?php\r
-\r
-       }\r
-\r
-       if (!isset($vars['replacement'])) {\r
-?>\r
-\r
-<script type="text/javascript">\r
-               // initialise picker\r
-               $("div#friendsPicker<?php echo $friendspicker; ?>").friendsPicker(<?php echo $friendspicker; ?>);\r
-</script>\r
-<script>\r
-       $(document).ready(function () {\r
-       // manually add class to corresponding tab for panels that have content\r
-<?php\r
-       if (sizeof($activeletters) > 0)\r
-               //$chararray = elgg_echo('friendspicker:chararray');\r
-               foreach($activeletters as $letter) {\r
-                       $tab = strpos($chararray, $letter) + 1;\r
-?>\r
-       $("div#friendsPickerNavigation<?php echo $friendspicker; ?> li.tab<?php echo $tab; ?> a").addClass("tabHasContent");\r
-<?php\r
-               }\r
-\r
-?>\r
-       });\r
-</script>\r
-\r
-<?php\r
-\r
-       }\r
-\r
+<?php
+
+       /**
+        * Elgg friends picker
+        * Lists the friends picker
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['entities'] The array of ElggUser objects
+        */
+
+       // Let the system know that the friends picker is in use
+               global $pickerinuse;
+               $pickerinuse = true;
+               $chararray = elgg_echo('friendspicker:chararray');
+
+       // Initialise internalname
+               if (!isset($vars['internalname'])) {
+                       $internalname = "friend";
+               } else {
+                       $internalname = $vars['internalname'];
+               }
+               
+       // Are we highlighting default or all?
+               if (empty($vars['highlight'])) $vars['highlight'] = 'default';
+               if ($vars['highlight'] != 'all') $vars['highlight'] = 'default';
+               
+       // Initialise values
+               if (!isset($vars['value'])) {
+                       $vars['value'] = array();
+               } else {
+                       if (!is_array($vars['value'])) {
+                               $vars['value'] = (int) $vars['value'];
+                               $vars['value'] = array($vars['value']);
+                       }
+               }
+
+       // Initialise whether we're calling back or not
+               if (isset($vars['callback'])) {
+                       $callback = $vars['callback'];
+               } else {
+                       $callback = false;
+               }
+               
+       // We need to count the number of friends pickers on the page.
+               if (!isset($vars['friendspicker'])) {
+                       global $friendspicker;
+                       if (!isset($friendspicker)) $friendspicker = 0;
+                       $friendspicker++;
+               } else {
+                       $friendspicker = $vars['friendspicker'];
+               }
+
+               $users = array();
+               $activeletters = array();
+               
+       // Are we displaying form tags and submit buttons?
+       // (If we've been given a target, then yes! Otherwise, no.)
+               if (isset($vars['formtarget'])) {
+                       $formtarget = $vars['formtarget'];
+               } else {
+                       $formtarget = false;
+               }
+               
+       // Sort users by letter
+               if (is_array($vars['entities']) && sizeof($vars['entities']))
+                       foreach($vars['entities'] as $user) {
+                               
+                               if (is_callable('mb_substr'))
+                                       $letter = strtoupper(mb_substr($user->name,0,1));
+                               else
+                                       $letter = strtoupper(substr($user->name,0,1));
+                               if (!substr_count($chararray,$letter)) {
+                                       $letter = "*";
+                               }
+                               if (!isset($users[$letter])) {
+                                       $users[$letter] = array();
+                               }
+                               $users[$letter][$user->name] = $user;
+                               
+                       }
+               
+       if (!$callback) {
+                       
+?>
+
+<div class="friends_picker">
+
+<?php
+
+       if (isset($vars['content'])) echo $vars['content'];
+
+       
+?>
+
+       <div id="friends_picker_placeholder<?php echo $friendspicker; ?>">
+
+<?php
+       
+       }
+       
+       if (!isset($vars['replacement'])) {
+       
+               if ($formtarget) {
+?>
+
+       <script language="text/javascript">
+               $(function() { // onload...do
+               $('#collectionMembersForm<?php echo $friendspicker; ?>').submit(function() {
+                       var inputs = [];
+                       $(':input', this).each(function() {
+                               if (this.type != 'checkbox' || (this.type == 'checkbox' && this.checked != false)) {
+                                       inputs.push(this.name + '=' + escape(this.value));
+                               }
+                       });
+                       jQuery.ajax({
+                               type: "POST",
+                               data: inputs.join('&'),
+                               url: this.action,
+                               success: function(){
+                               $('a.collectionmembers<?php echo $friendspicker; ?>').click();
+                               }
+
+                       });
+                       return false;
+        })
+      })
+
+       </script>
+
+       <!-- Collection members form -->
+       <form id="collectionMembersForm<?php echo $friendspicker; ?>" action="<?php echo $formtarget; ?>" method="post"> <!-- action="" method=""> -->
+
+<?php
+
+               }
+
+?>
+
+       <div class="friendsPicker_wrapper">
+       <div id="friendsPicker<?php echo $friendspicker; ?>">
+               <div class="friendsPicker_container">
+<?php
+
+       // Initialise letters
+               $chararray .= "*";
+               if (is_callable('mb_substr'))
+                       $letter = mb_substr($chararray,0,1);
+               else
+                       $letter = substr($chararray,0,1);
+               $letpos = 0;
+               while (1 == 1) {
+?>
+                       <div class="panel" title="<?php 
+                                       echo $letter;
+                       ?>">
+                               <div class="wrapper">
+                                       <h3><?php echo $letter; ?></h3>                                 
+                                       
+<?php
+
+                       if (isset($users[$letter])) {
+                               ksort($users[$letter]);
+                               
+                               echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
+                               $col = 0;
+                               
+                               foreach($users[$letter] as $friend) {
+                                       if ($col == 0) echo "<tr>";
+                                       
+                                       //echo "<p>" . $user->name . "</p>";
+                                       $label = elgg_view("profile/icon",array('entity' => $friend, 'size' => 'tiny', 'override' => true)); 
+                                       $options[$label] = $friend->getGUID();
+                                       
+                                       if ($vars['highlight'] == 'all'
+                                               && !in_array($letter,$activeletters)) {
+                                                       $activeletters[] = $letter;
+                                               }
+                                               
+                                       
+                                       if (in_array($friend->getGUID(),$vars['value'])) {
+                                               $checked = "checked = \"checked\"";
+                                               if (
+                                                               !in_array($letter,$activeletters)
+                                                               && $vars['highlight'] == 'default'
+                                                       )
+                                                       $activeletters[] = $letter;
+                                       } else {
+                                               $checked = "";
+                                       }
+
+?>
+
+                       <td>
+                       
+                               <input type="checkbox" <?php echo $checked; ?> name="<?php echo $internalname; ?>[]" value="<?php echo $options[$label]; ?>" />
+                       
+                       </td>
+
+                       <td >
+                       
+                               <div style="width: 25px; margin-bottom: 15px;">
+<?php
+
+                               echo $label;
+                       
+?>
+                               </div>
+                       </td>
+                       <td style="width: 200px; padding: 5px;">
+<?php
+
+                                       echo $friend->name;
+                               
+?>
+                       </td>
+<?php
+                                       
+                                       $col++;
+                                       if ($col == 3){
+                                               echo "</tr>";
+                                               $col = 0;
+                                       }
+                               }
+                               if ($col < 3) echo "</tr>";
+                               
+                               echo "</table>";
+                               
+                       }
+
+?>
+                       
+                               </div>
+                       </div>
+<?php                  
+                       //if ($letter == 'Z') break;
+                       
+                       if (is_callable('mb_substr'))
+                               $substr = mb_substr($chararray,strlen($chararray) - 1,1);
+                       else
+                               $substr = substr($chararray,strlen($chararray) - 1,1);
+                       if ($letter == $substr) break;
+                       //$letter++;
+                       $letpos++;
+                       if (is_callable('mb_substr'))
+                               $letter = mb_substr($chararray,$letpos,1);
+                       else
+                               $letter = substr($chararray,$letpos,1);
+               }
+               
+?>
+               </div>
+               
+<?php
+
+       if ($formtarget) {
+
+               if (isset($vars['formcontents']))
+                       echo $vars['formcontents'];
+               
+?>
+               <div class="clearfloat"></div>
+               <div class="friendspicker_savebuttons">
+                       <input type="submit" class="submit_button" value="<?php echo elgg_echo('save'); ?>" />
+                       <input type="button" class="cancel_button" value="<?php echo elgg_echo('cancel'); ?>" onclick="$('a.collectionmembers<?php echo $friendspicker; ?>').click();" />
+               <br /></div>
+               </form>
+               
+<?php
+
+       }
+
+?>
+               
+       </div>
+       </div>
+       
+<?php
+       } else {
+               echo $vars['replacement']; 
+       }
+       if (!$callback) {
+
+?>
+                       
+       </div>
+</div>
+
+
+<?php
+
+       }
+
+       if (!isset($vars['replacement'])) {
+?>
+
+<script type="text/javascript">
+               // initialise picker
+               $("div#friendsPicker<?php echo $friendspicker; ?>").friendsPicker(<?php echo $friendspicker; ?>);
+</script>
+<script>
+       $(document).ready(function () {
+       // manually add class to corresponding tab for panels that have content
+<?php
+       if (sizeof($activeletters) > 0)
+               //$chararray = elgg_echo('friendspicker:chararray');
+               foreach($activeletters as $letter) {
+                       $tab = strpos($chararray, $letter) + 1;
+?>
+       $("div#friendsPickerNavigation<?php echo $friendspicker; ?> li.tab<?php echo $tab; ?> a").addClass("tabHasContent");
+<?php
+               }
+
+?>
+       });
+</script>
+
+<?php
+
+       }
+
 ?>
\ No newline at end of file
index df5d2418b7101c4c6ce713ffc1e895edf55e094a..04947568b0e2a86c25db45b8454b2235384704c5 100644 (file)
@@ -1,19 +1,19 @@
-<?php\r
-\r
-       $performed_by = get_entity($vars['item']->subject_guid); // $statement->getSubject();\r
-       $performed_on = get_entity($vars['item']->object_guid);\r
-       $url = $performed_on->getURL();\r
-\r
-       $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";\r
-       $string = sprintf(elgg_echo("friends:river:add"),$url) . " ";\r
-       $string .= "<a href=\"{$performed_on->getURL()}\">{$performed_on->name}</a>";\r
-       $string .= "<div class=\"river_content_display\">";\r
-       $string .= "<table><tr><td>" . elgg_view("profile/icon",array('entity' => $performed_by, 'size' => 'small')) . "</td>";\r
-       $string .= "<td><div class=\"following_icon\"></div></td><td>" . elgg_view("profile/icon",array('entity' => $performed_on, 'size' => 'small')) . "</td></tr></table>";\r
-       $string .= "</div>";\r
-       \r
-?>\r
-\r
-<?php \r
-       echo $string; \r
+<?php
+
+       $performed_by = get_entity($vars['item']->subject_guid); // $statement->getSubject();
+       $performed_on = get_entity($vars['item']->object_guid);
+       $url = $performed_on->getURL();
+
+       $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
+       $string = sprintf(elgg_echo("friends:river:add"),$url) . " ";
+       $string .= "<a href=\"{$performed_on->getURL()}\">{$performed_on->name}</a>";
+       $string .= "<div class=\"river_content_display\">";
+       $string .= "<table><tr><td>" . elgg_view("profile/icon",array('entity' => $performed_by, 'size' => 'small')) . "</td>";
+       $string .= "<td><div class=\"following_icon\"></div></td><td>" . elgg_view("profile/icon",array('entity' => $performed_on, 'size' => 'small')) . "</td></tr></table>";
+       $string .= "</div>";
+       
+?>
+
+<?php 
+       echo $string; 
 ?>
\ No newline at end of file
index 14728d16a2bec1e29419a77f694271f815d5579e..4c4e26c8062178e36d349d975dc089d73199eea1 100644 (file)
@@ -1,22 +1,22 @@
-<?php\r
-\r
-       /**\r
-        * Elgg friends picker count updater\r
-        * Updates the friends count on a collection\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg friends picker count updater
+        * Updates the friends count on a collection
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['count'] The count\r
-        * @uses $vars['friendspicker'] The friendspicker counter number\r
-        */\r
-\r
-?>\r
-\r
-<script language="text/javascript">\r
-       $("#friends_membership_count<?php echo $vars['friendspicker']; ?>").html("<?php echo $vars['count']; ?>");\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['count'] The count
+        * @uses $vars['friendspicker'] The friendspicker counter number
+        */
+
+?>
+
+<script language="text/javascript">
+       $("#friends_membership_count<?php echo $vars['friendspicker']; ?>").html("<?php echo $vars['count']; ?>");
 </script>
\ No newline at end of file
index ccb38b54fb649a2efdf3d50e154b3efbe7884428..461fbf6259f6ad4baa01a2c2f6d06c9792bcdb76 100644 (file)
@@ -1,55 +1,55 @@
-<?php\r
-\r
-       /**\r
-        * Elgg access level input\r
-        * Displays a pulldown input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * \r
-        */\r
-\r
-       if (isset($vars['class'])) $class = $vars['class'];\r
-       if (!$class) $class = "input-access";\r
-       \r
-       if (!array_key_exists('value', $vars) || $vars['value'] == ACCESS_DEFAULT)\r
-               $vars['value'] = get_default_access();\r
-                       \r
-\r
-               if ((!isset($vars['options'])) || (!is_array($vars['options'])))\r
-               {\r
-                       $vars['options'] = array();\r
-                       $vars['options'] = get_write_access_array();\r
-               }\r
-               \r
-               if (is_array($vars['options']) && sizeof($vars['options']) > 0) {        \r
-                        \r
-?>\r
-\r
-<select <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['js'])) echo $vars['js']; ?> <?php if ((isset($vars['disabled'])) && ($vars['disabled'])) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">\r
-<?php\r
-\r
-    foreach($vars['options'] as $key => $option) {\r
-        if ($key != $vars['value']) {\r
-            echo "<option value=\"{$key}\">". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";\r
-        } else {\r
-            echo "<option value=\"{$key}\" selected=\"selected\">". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";\r
-        }\r
-    }\r
-\r
-?> \r
-</select>\r
-\r
-<?php\r
-\r
-               }               \r
-\r
+<?php
+
+       /**
+        * Elgg access level input
+        * Displays a pulldown input field
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * 
+        */
+
+       if (isset($vars['class'])) $class = $vars['class'];
+       if (!$class) $class = "input-access";
+       
+       if (!array_key_exists('value', $vars) || $vars['value'] == ACCESS_DEFAULT)
+               $vars['value'] = get_default_access();
+                       
+
+               if ((!isset($vars['options'])) || (!is_array($vars['options'])))
+               {
+                       $vars['options'] = array();
+                       $vars['options'] = get_write_access_array();
+               }
+               
+               if (is_array($vars['options']) && sizeof($vars['options']) > 0) {        
+                        
+?>
+
+<select <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['js'])) echo $vars['js']; ?> <?php if ((isset($vars['disabled'])) && ($vars['disabled'])) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">
+<?php
+
+    foreach($vars['options'] as $key => $option) {
+        if ($key != $vars['value']) {
+            echo "<option value=\"{$key}\">". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";
+        } else {
+            echo "<option value=\"{$key}\" selected=\"selected\">". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";
+        }
+    }
+
+?> 
+</select>
+
+<?php
+
+               }               
+
 ?>
\ No newline at end of file
index 69ef01ee7aa4cd8d68d3603f7b39b889022dba90..9dd5b2dc0683bcef97f4f6132ed15473282ad316 100644 (file)
@@ -1,44 +1,44 @@
-<?php \r
-\r
-       /**\r
-        * Elgg calendar input\r
-        * Displays a calendar input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php 
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg calendar input
+        * Displays a calendar input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * \r
-        */\r
-\r
-    static $calendarjs;\r
-    if (empty($calendarjs)) {\r
-        \r
-        echo <<< END\r
-        \r
-<script language="JavaScript" src="{$vars['url']}vendors/calendarpopup/CalendarPopup.js"></script>\r
-        \r
-END;\r
-        $calendarjs = 1;\r
-    }\r
-    $strippedname = sanitise_string($vars['internalname']);\r
-    $js = "cal" . $strippedname;\r
-\r
-    if ($vars['value'] > 86400) {\r
-        $val = date("F j, Y",$vars['value']);\r
-    } else {\r
-        $val = $vars['value'];\r
-    }\r
-    \r
-?>\r
-<script language="JavaScript">\r
-    var cal<?php echo $strippedname; ?> = new CalendarPopup();\r
-</script>\r
-<input type="text" <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" id="<?php echo $strippedname; ?>" value="<?php echo $val; ?>" />\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * 
+        */
+
+    static $calendarjs;
+    if (empty($calendarjs)) {
+        
+        echo <<< END
+        
+<script language="JavaScript" src="{$vars['url']}vendors/calendarpopup/CalendarPopup.js"></script>
+        
+END;
+        $calendarjs = 1;
+    }
+    $strippedname = sanitise_string($vars['internalname']);
+    $js = "cal" . $strippedname;
+
+    if ($vars['value'] > 86400) {
+        $val = date("F j, Y",$vars['value']);
+    } else {
+        $val = $vars['value'];
+    }
+    
+?>
+<script language="JavaScript">
+    var cal<?php echo $strippedname; ?> = new CalendarPopup();
+</script>
+<input type="text" <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" id="<?php echo $strippedname; ?>" value="<?php echo $val; ?>" />
 <a href="#" onclick="<?php echo $js; ?>.select(document.getElementById('<?php echo $strippedname; ?>'),'anchor<?php echo $strippedname; ?>','MMM dd, yyyy'); return false;" TITLE="<?php echo $js; ?>.select(document.forms[0].<?php echo $strippedname; ?>,'anchor<?php echo $strippedname; ?>','MMM dd, yyyy'); return false;" NAME="anchor<?php echo $strippedname; ?>" ID="anchor<?php echo $strippedname; ?>">select</a> 
\ No newline at end of file
index 7e6c70a540b9a0e3a3545ee1b763c037ec5e6c4d..4e806bbfc4223d7d6956b590701f31f5201e3350 100644 (file)
@@ -1,52 +1,52 @@
-<?php\r
-\r
-       /**\r
-        * Elgg checkbox input\r
-        * Displays a checkbox input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg checkbox input
+        * Displays a checkbox input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * @uses $vars['options'] An array of strings representing the label => options for the checkbox field\r
-        * \r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * @uses $vars['options'] An array of strings representing the label => options for the checkbox field
+        * 
+        */
 
        $class = $vars['class'];
-       if (!$class) $class = "input-checkboxes";\r
-       \r
-    foreach($vars['options'] as $label => $option) {\r
-        //if (!in_array($option,$vars['value'])) {\r
-        if (is_array($vars['value'])) {\r
-               $valarray = $vars['value'];\r
-               $valarray = array_map('strtolower', $valarray);\r
-               if (!in_array(strtolower($option),$valarray)) {\r
-                   $selected = "";\r
-               } else {\r
-                   $selected = "checked = \"checked\"";\r
-               }\r
+       if (!$class) $class = "input-checkboxes";
+       
+    foreach($vars['options'] as $label => $option) {
+        //if (!in_array($option,$vars['value'])) {
+        if (is_array($vars['value'])) {
+               $valarray = $vars['value'];
+               $valarray = array_map('strtolower', $valarray);
+               if (!in_array(strtolower($option),$valarray)) {
+                   $selected = "";
+               } else {
+                   $selected = "checked = \"checked\"";
+               }
         } else {
-               if (strtolower($option) != strtolower($vars['value'])) {\r
-                   $selected = "";\r
-               } else {\r
-                   $selected = "checked = \"checked\"";\r
-               }\r
-        }\r
-        $labelint = (int) $label;\r
-        if ("{$label}" == "{$labelint}") {\r
-               $label = $option;\r
+               if (strtolower($option) != strtolower($vars['value'])) {
+                   $selected = "";
+               } else {
+                   $selected = "checked = \"checked\"";
+               }
+        }
+        $labelint = (int) $label;
+        if ("{$label}" == "{$labelint}") {
+               $label = $option;
         }
         
         if (isset($vars['internalid'])) $id = "id=\"{$vars['internalid']}\""; 
         $disabled = "";
-        if ($vars['disabled']) $disabled = ' disabled="yes" '; \r
-        echo "<label><input type=\"checkbox\" $id $disabled {$vars['js']} name=\"{$vars['internalname']}[]\" value=\"".htmlentities($option, ENT_QUOTES, 'UTF-8')."\" {$selected} class=\"$class\" />{$label}</label><br />";\r
-    }\r
-\r
+        if ($vars['disabled']) $disabled = ' disabled="yes" '; 
+        echo "<label><input type=\"checkbox\" $id $disabled {$vars['js']} name=\"{$vars['internalname']}[]\" value=\"".htmlentities($option, ENT_QUOTES, 'UTF-8')."\" {$selected} class=\"$class\" />{$label}</label><br />";
+    }
+
 ?> 
\ No newline at end of file
index 75d7eec398b1ca46874d14a948161a9a017d0e04..e1fb61eabf6e3ba23050dbf4683207f844cafd9c 100644 (file)
@@ -1,24 +1,24 @@
-<?php\r
-\r
-       /**\r
-        * Elgg email input\r
-        * Displays an email input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg email input
+        * Displays an email input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * \r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * 
+        */
 
        $class = $vars['class'];
-       if (!$class) $class = "input-text";\r
-?>\r
-\r
+       if (!$class) $class = "input-text";
+?>
+
 <input type="text" <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?>value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class; ?>"/> 
\ No newline at end of file
index ec961b6d0cf2d356702507e70be9a1bd6f283c8d..e707e3ee06580cda4018af818bdde9f7ff60573b 100644 (file)
@@ -1,26 +1,26 @@
-<?php\r
-\r
-       /**\r
-        * Elgg file input\r
-        * Displays a file input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg file input
+        * Displays a file input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * \r
-        */\r
-\r
-    if (!empty($vars['value'])) {\r
-        echo elgg_echo('fileexists') . "<br />";\r
-    }\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * 
+        */
+
+    if (!empty($vars['value'])) {
+        echo elgg_echo('fileexists') . "<br />";
+    }
 
     $class = $vars['class'];
-       if (!$class) $class = "input-file";\r
-?>\r
+       if (!$class) $class = "input-file";
+?>
 <input type="file" size="30" <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>" />
\ No newline at end of file
index c17b770d4f0991fae477f0927d54314e8fee99c7..86b0f3fc46eb32272760178733c6de7bcd68ceac 100644 (file)
@@ -1,25 +1,25 @@
-<?php\r
-\r
-       /**\r
-        * Elgg long text input\r
-        * Displays a long text input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg long text input
+        * Displays a long text input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * \r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * 
+        */
 
        $class = $vars['class'];
        if (!$class) $class = "input-textarea";
-       \r
-?>\r
-\r
+       
+?>
+
 <textarea class="<?php echo $class; ?>" name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?>><?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?></textarea> 
\ No newline at end of file
index 9a7e678fb4bccbf992b3baf8b67a9100d9f845b4..8ab0b693522b5ebb30c16ae16ae9e64d80ec4ac8 100644 (file)
@@ -1,24 +1,24 @@
-<?php\r
-\r
-       /**\r
-        * Elgg password input\r
-        * Displays a password input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg password input
+        * Displays a password input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * \r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * 
+        */
 
        $class = $vars['class'];
-       if (!$class) $class = "input-password";\r
-?>\r
-\r
+       if (!$class) $class = "input-password";
+?>
+
 <input type="password" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class; ?>" /> 
\ No newline at end of file
index ee5854a0a983620dc99ba82da775f821e17f7724..a99084a4343568fd7ff1fd5b43f047b510d6e79f 100644 (file)
@@ -1,25 +1,25 @@
-<?php\r
-\r
-       /**\r
-        * Elgg long text input (plaintext)\r
-        * Displays a long text input field that should not be overridden by wysiwyg editors.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg long text input (plaintext)
+        * Displays a long text input field that should not be overridden by wysiwyg editors.
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * 
+        */
+
+       $class = $vars['class'];
+       if (!$class) $class = "input-textarea";
+       
+?>
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * \r
-        */\r
-\r
-       $class = $vars['class'];\r
-       if (!$class) $class = "input-textarea";\r
-       \r
-?>\r
-\r
 <textarea class="<?php echo $class; ?>" name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?>><?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?></textarea> 
\ No newline at end of file
index c73e6b6c92cbc1077a33f4ffe82ef967296ea39f..6aa69f428043c00e580d511f1b2eba8f99ab3edb 100644 (file)
@@ -1,33 +1,33 @@
-<?php\r
-\r
-       /**\r
-        * Elgg pulldown input\r
-        * Displays a pulldown input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * @uses $vars['options'] An array of strings representing the options for the pulldown field\r
+<?php
+
+       /**
+        * Elgg pulldown input
+        * Displays a pulldown input field
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * @uses $vars['options'] An array of strings representing the options for the pulldown field
         * @uses $vars['options_values'] An associative array of "value" => "option" where "value" is an internal name and "option" is 
-        *                                                               the value displayed on the button. Replaces $vars['options'] when defined. \r
-        */\r
+        *                                                               the value displayed on the button. Replaces $vars['options'] when defined. 
+        */
 
 
        $class = $vars['class'];
        if (!$class) $class = "input-pulldown";
-\r
-?>\r
-\r
-\r
-<select name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> <?php echo $vars['js']; ?> <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">\r
-<?php\r
+
+?>
+
+
+<select name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> <?php echo $vars['js']; ?> <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">
+<?php
        if ($vars['options_values'])
        {
                foreach($vars['options_values'] as $value => $option) {
            }
        }
        else
-       {\r
-           foreach($vars['options'] as $option) {\r
-               if ($option != $vars['value']) {\r
-                   echo "<option>". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";\r
-               } else {\r
-                   echo "<option selected=\"selected\">". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";\r
-               }\r
-           }\r
-       }\r
-?> \r
+       {
+           foreach($vars['options'] as $option) {
+               if ($option != $vars['value']) {
+                   echo "<option>". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";
+               } else {
+                   echo "<option selected=\"selected\">". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";
+               }
+           }
+       }
+?> 
 </select>
\ No newline at end of file
index b94ed8080405821f75d3d924de2abd81303b0c73..12e40ccdd81efbbd42b60333ddb6c58e649e28a9 100644 (file)
@@ -1,40 +1,40 @@
-<?php\r
-\r
-       /**\r
-        * Elgg radio input\r
-        * Displays a radio input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg radio input
+        * Displays a radio input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * @uses $vars['options'] An array of strings representing the options for the radio field as "label" => option\r
-        * \r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * @uses $vars['options'] An array of strings representing the options for the radio field as "label" => option
+        * 
+        */
        
        $class = $vars['class'];
        if (!$class) $class = "input-radio";
-\r
-    foreach($vars['options'] as $label => $option) {\r
-        if (strtolower($option) != strtolower($vars['value'])) {\r
-            $selected = "";\r
-        } else {\r
-            $selected = "checked = \"checked\"";\r
-        }\r
-        $labelint = (int) $label;\r
-        if ("{$label}" == "{$labelint}") {\r
-               $label = $option;\r
+
+    foreach($vars['options'] as $label => $option) {
+        if (strtolower($option) != strtolower($vars['value'])) {
+            $selected = "";
+        } else {
+            $selected = "checked = \"checked\"";
+        }
+        $labelint = (int) $label;
+        if ("{$label}" == "{$labelint}") {
+               $label = $option;
         }
         
         if (isset($vars['internalid'])) $id = "id=\"{$vars['internalid']}\""; 
-        if ($vars['disabled']) $disabled = ' disabled="yes" '; \r
-        echo "<label><input type=\"radio\" $disabled {$vars['js']} name=\"{$vars['internalname']}\" $id value=\"".htmlentities($option, ENT_QUOTES, 'UTF-8')."\" {$selected} class=\"$class\" />{$label}</label><br />";\r
-    }\r
-\r
+        if ($vars['disabled']) $disabled = ' disabled="yes" '; 
+        echo "<label><input type=\"radio\" $disabled {$vars['js']} name=\"{$vars['internalname']}\" $id value=\"".htmlentities($option, ENT_QUOTES, 'UTF-8')."\" {$selected} class=\"$class\" />{$label}</label><br />";
+    }
+
 ?> 
\ No newline at end of file
index dc38c979dfcb67cb1ed87f1b2732fcdbf1b7216f..8793756e2804268ad7d375b3db9f84a98d861775 100644 (file)
@@ -1,45 +1,45 @@
-<?php \r
-\r
-       /**\r
-        * Elgg tag input\r
-        * Displays a tag input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php 
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg tag input
+        * Displays a tag input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * @uses $vars['value'] An array of tags\r
-        * @uses $vars['class'] Class override\r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * @uses $vars['value'] An array of tags
+        * @uses $vars['class'] Class override
+        */
 
        $class = $vars['class'];
        if (!$class) $class = "input-tags";
-\r
-    $tags = "";\r
-    if (!empty($vars['value'])) {\r
-       if (is_array($vars['value'])) {\r
-               foreach($vars['value'] as $tag) {\r
-                   \r
-                   if (!empty($tags)) {\r
-                       $tags .= ", ";\r
-                   }\r
-                   if (is_string($tag)) {\r
-                       $tags .= $tag;\r
-                   } else {\r
-                       $tags .= $tag->value;\r
-                   }\r
-                   \r
-               }\r
-       } else {\r
-               $tags = $vars['value'];\r
-       }\r
-    }\r
-    \r
-?>\r
+
+    $tags = "";
+    if (!empty($vars['value'])) {
+       if (is_array($vars['value'])) {
+               foreach($vars['value'] as $tag) {
+                   
+                   if (!empty($tags)) {
+                       $tags .= ", ";
+                   }
+                   if (is_string($tag)) {
+                       $tags .= $tag;
+                   } else {
+                       $tags .= $tag->value;
+                   }
+                   
+               }
+       } else {
+               $tags = $vars['value'];
+       }
+    }
+    
+?>
 <input type="text" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?><?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> value="<?php echo htmlentities($tags, ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class; ?>"/> 
\ No newline at end of file
index 86950ff9d28da2b8b18dd56b9a321f3bd49db607..2a30ba08156852951c659f8d47af7e7728d84c9a 100644 (file)
@@ -1,27 +1,27 @@
-<?php\r
-\r
-       /**\r
-        * Elgg text input\r
-        * Displays a text input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg text input
+        * Displays a text input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
         * @uses $vars['disabled'] If true then control is read-only
-        * @uses $vars['class'] Class override\r
-        */\r
+        * @uses $vars['class'] Class override
+        */
 
        
        $class = $vars['class'];
        if (!$class) $class = "input-text";
-       \r
-?>\r
-\r
+       
+?>
+
 <input type="text" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class ?>"/> 
\ No newline at end of file
index ba77f486fc75aba7cc9e47815edd4caa1cccf58e..82fde938edcf9a0866b3706d7d1646bab69f27e3 100644 (file)
@@ -1,24 +1,24 @@
-<?php\r
-\r
-       /**\r
-        * Elgg URL input\r
-        * Displays a URL input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg URL input
+        * Displays a URL input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * @uses $vars['class'] Class override\r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * @uses $vars['class'] Class override
+        */
 
        $class = $vars['class'];
-       if (!$class) $class = "input-url";\r
-?>\r
-\r
+       if (!$class) $class = "input-url";
+?>
+
 <input type="text" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class; ?>"/> 
\ No newline at end of file
index d399b35da1c33417d3b34a25183292e0ba1d3660..32b495938e13cda7774eb023f8c691fcb5901645 100644 (file)
@@ -1,93 +1,93 @@
-/*\r
-       elgg friendsPicker plugin\r
-       adapted from Niall Doherty's excellent Coda-Slider - http://www.ndoherty.com/coda-slider\r
-*/\r
-\r
-\r
-jQuery.fn.friendsPicker = function(iterator) {\r
-\r
-       var settings; \r
-       settings = $.extend({ easeFunc: "easeOutExpo", easeTime: 1000, toolTip: false }, settings);\r
-       \r
-       return this.each(function() {\r
-       \r
-               var container = $(this);\r
-               container.addClass("friendsPicker");\r
-               // set panelwidth manually as it's hidden initially - adjust this value for different themes/pagewidths \r
-               var panelWidth = 678;\r
-\r
-               // count the panels in the container\r
-               var panelCount = container.find("div.panel").size();\r
-               // calculate the width of all the panels lined up end-to-end\r
-               var friendsPicker_containerWidth = panelWidth*panelCount;\r
-               // specify width for the friendsPicker_container\r
-               container.find("div.friendsPicker_container").css("width" , friendsPicker_containerWidth);\r
-               \r
-               // global variables for container.each function below\r
-               var friendsPickerNavigationWidth = 0;\r
-               var currentPanel = 1;\r
-               \r
-               // generate appropriate nav for each container\r
-               container.each(function(i) {\r
-                       // generate Left and Right arrows\r
-                       $(this).before("<div class='friendsPickerNavigationL' id='friendsPickerNavigationL" + iterator + "'><a href='#'>Left</a><\/div>");\r
-                       $(this).after("<div class='friendsPickerNavigationR' id='friendsPickerNavigationR" + iterator + "'><a href='#'>Right</a><\/div>");\r
-                       \r
-                       // generate a-z tabs\r
-                       $(this).before("<div class='friendsPickerNavigation' id='friendsPickerNavigation" + iterator + "'><ul><\/ul><\/div>");\r
-                       $(this).find("div.panel").each(function(individualTabItemNumber) {\r
-                               $("div#friendsPickerNavigation" + iterator + " ul").append("<li class='tab" + (individualTabItemNumber+1) + "'><a href='#" + (individualTabItemNumber+1) + "'>" + $(this).attr("title") + "<\/a><\/li>");               \r
-                       });\r
-                       \r
-                       // tabs navigation\r
-                       $("div#friendsPickerNavigation" + iterator + " a").each(function(individualTabItemNumber) {\r
-                               // calc friendsPickerNavigationWidth by summing width of each li\r
-                               friendsPickerNavigationWidth += $(this).parent().width();\r
-                               // set-up individual tab clicks\r
-                               $(this).bind("click", function() {\r
-                                       $(this).addClass("current").parent().parent().find("a").not($(this)).removeClass("current"); \r
-                                       var distanceToMoveFriendsPicker_container = - (panelWidth*individualTabItemNumber);\r
-                                       currentPanel = individualTabItemNumber + 1;\r
-                                       $(this).parent().parent().parent().next().find("div.friendsPicker_container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc);\r
-                               });\r
-                       });\r
-                       \r
-                       // Right arow click function\r
-                       $("div#friendsPickerNavigationR" + iterator + " a").click(function() {\r
-                               if (currentPanel == panelCount) {\r
-                                       var distanceToMoveFriendsPicker_container = 0;\r
-                                       currentPanel = 1; \r
-                                       $(this).parent().parent().find("div.friendsPickerNavigation a.current").removeClass("current").parent().parent().find("a:eq(0)").addClass("current");\r
-                               } else {\r
-                                       var distanceToMoveFriendsPicker_container = - (panelWidth*currentPanel);\r
-                                       currentPanel += 1;\r
-                                       $(this).parent().parent().find("div.friendsPickerNavigation a.current").removeClass("current").parent().next().find("a").addClass("current");\r
-                               };\r
-                               $(this).parent().parent().find("div.friendsPicker_container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc);\r
-                               return false;\r
-                       });\r
-                       \r
-                       // Left arrow click function\r
-                       $("div#friendsPickerNavigationL" + iterator + " a").click(function() {\r
-                               if (currentPanel == 1) {\r
-                                       var distanceToMoveFriendsPicker_container = - (panelWidth*(panelCount - 1));\r
-                                       currentPanel = panelCount;\r
-                                       $(this).parent().parent().find("div.friendsPickerNavigation a.current").removeClass("current").parent().parent().find("li:last a").addClass("current");\r
-                               } else {\r
-                                       currentPanel -= 1;\r
-                                       var distanceToMoveFriendsPicker_container = - (panelWidth*(currentPanel - 1));\r
-                                       $(this).parent().parent().find("div.friendsPickerNavigation a.current").removeClass("current").parent().prev().find("a").addClass("current");\r
-                               };\r
-                               $(this).parent().parent().find("div.friendsPicker_container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc);\r
-                               return false;\r
-                       });\r
-                                               \r
-                               // apply 'current' class to currently selected tab link\r
-                               $("div#friendsPickerNavigation" + iterator + " a:eq(0)").addClass("current");\r
-               });\r
-\r
-               $("div#friendsPickerNavigation" + iterator).append("<br />");           \r
-  });\r
-};\r
-\r
-\r
+/*
+       elgg friendsPicker plugin
+       adapted from Niall Doherty's excellent Coda-Slider - http://www.ndoherty.com/coda-slider
+*/
+
+
+jQuery.fn.friendsPicker = function(iterator) {
+
+       var settings; 
+       settings = $.extend({ easeFunc: "easeOutExpo", easeTime: 1000, toolTip: false }, settings);
+       
+       return this.each(function() {
+       
+               var container = $(this);
+               container.addClass("friendsPicker");
+               // set panelwidth manually as it's hidden initially - adjust this value for different themes/pagewidths 
+               var panelWidth = 678;
+
+               // count the panels in the container
+               var panelCount = container.find("div.panel").size();
+               // calculate the width of all the panels lined up end-to-end
+               var friendsPicker_containerWidth = panelWidth*panelCount;
+               // specify width for the friendsPicker_container
+               container.find("div.friendsPicker_container").css("width" , friendsPicker_containerWidth);
+               
+               // global variables for container.each function below
+               var friendsPickerNavigationWidth = 0;
+               var currentPanel = 1;
+               
+               // generate appropriate nav for each container
+               container.each(function(i) {
+                       // generate Left and Right arrows
+                       $(this).before("<div class='friendsPickerNavigationL' id='friendsPickerNavigationL" + iterator + "'><a href='#'>Left</a><\/div>");
+                       $(this).after("<div class='friendsPickerNavigationR' id='friendsPickerNavigationR" + iterator + "'><a href='#'>Right</a><\/div>");
+                       
+                       // generate a-z tabs
+                       $(this).before("<div class='friendsPickerNavigation' id='friendsPickerNavigation" + iterator + "'><ul><\/ul><\/div>");
+                       $(this).find("div.panel").each(function(individualTabItemNumber) {
+                               $("div#friendsPickerNavigation" + iterator + " ul").append("<li class='tab" + (individualTabItemNumber+1) + "'><a href='#" + (individualTabItemNumber+1) + "'>" + $(this).attr("title") + "<\/a><\/li>");               
+                       });
+                       
+                       // tabs navigation
+                       $("div#friendsPickerNavigation" + iterator + " a").each(function(individualTabItemNumber) {
+                               // calc friendsPickerNavigationWidth by summing width of each li
+                               friendsPickerNavigationWidth += $(this).parent().width();
+                               // set-up individual tab clicks
+                               $(this).bind("click", function() {
+                                       $(this).addClass("current").parent().parent().find("a").not($(this)).removeClass("current"); 
+                                       var distanceToMoveFriendsPicker_container = - (panelWidth*individualTabItemNumber);
+                                       currentPanel = individualTabItemNumber + 1;
+                                       $(this).parent().parent().parent().next().find("div.friendsPicker_container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc);
+                               });
+                       });
+                       
+                       // Right arow click function
+                       $("div#friendsPickerNavigationR" + iterator + " a").click(function() {
+                               if (currentPanel == panelCount) {
+                                       var distanceToMoveFriendsPicker_container = 0;
+                                       currentPanel = 1; 
+                                       $(this).parent().parent().find("div.friendsPickerNavigation a.current").removeClass("current").parent().parent().find("a:eq(0)").addClass("current");
+                               } else {
+                                       var distanceToMoveFriendsPicker_container = - (panelWidth*currentPanel);
+                                       currentPanel += 1;
+                                       $(this).parent().parent().find("div.friendsPickerNavigation a.current").removeClass("current").parent().next().find("a").addClass("current");
+                               };
+                               $(this).parent().parent().find("div.friendsPicker_container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc);
+                               return false;
+                       });
+                       
+                       // Left arrow click function
+                       $("div#friendsPickerNavigationL" + iterator + " a").click(function() {
+                               if (currentPanel == 1) {
+                                       var distanceToMoveFriendsPicker_container = - (panelWidth*(panelCount - 1));
+                                       currentPanel = panelCount;
+                                       $(this).parent().parent().find("div.friendsPickerNavigation a.current").removeClass("current").parent().parent().find("li:last a").addClass("current");
+                               } else {
+                                       currentPanel -= 1;
+                                       var distanceToMoveFriendsPicker_container = - (panelWidth*(currentPanel - 1));
+                                       $(this).parent().parent().find("div.friendsPickerNavigation a.current").removeClass("current").parent().prev().find("a").addClass("current");
+                               };
+                               $(this).parent().parent().find("div.friendsPicker_container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc);
+                               return false;
+                       });
+                                               
+                               // apply 'current' class to currently selected tab link
+                               $("div#friendsPickerNavigation" + iterator + " a:eq(0)").addClass("current");
+               });
+
+               $("div#friendsPickerNavigation" + iterator).append("<br />");           
+  });
+};
+
+
index cf6389aba5cdbc690973af90b4e49392373fa2c2..e63cd70ef0ad8340fa9df7253f6ae83aaaaac006 100644 (file)
-$(document).ready(function () {\r
-\r
-       // COLLAPSABLE WIDGETS (on Dashboard & Profile pages)\r
-       // toggle widget box contents\r
-       $('a.toggle_box_contents').bind('click', toggleContent);\r
-       \r
-       // toggle widget box edit panel\r
-       $('a.toggle_box_edit_panel').click(function () {\r
-               $(this.parentNode.parentNode).children(".collapsable_box_editpanel").slideToggle("fast");\r
-               return false;\r
-       });\r
-       \r
-       // toggle customise edit panel\r
-       $('a.toggle_customise_edit_panel').click(function () {\r
-               $('div#customise_editpanel').slideToggle("fast");\r
-               return false;\r
-       }); \r
-       \r
-       // toggle plugin's settings nad more info on admin tools admin\r
-       $('a.pluginsettings_link').click(function () {\r
-               $(this.parentNode.parentNode).children(".pluginsettings").slideToggle("fast");\r
-               return false;\r
-       });\r
-       $('a.manifest_details').click(function () {\r
-               $(this.parentNode.parentNode).children(".manifest_file").slideToggle("fast");\r
-               return false;\r
-       });\r
-       // reusable generic hidden panel\r
-       $('a.collapsibleboxlink').click(function () {\r
-               $(this.parentNode.parentNode).children(".collapsible_box").slideToggle("fast");\r
-               return false;\r
-       });\r
-       \r
-       // WIDGET GALLERY EDIT PANEL\r
-       // Sortable widgets\r
-       var els = ['#leftcolumn_widgets', '#middlecolumn_widgets', '#rightcolumn_widgets', '#widget_picker_gallery' ];\r
-       var $els = $(els.toString());\r
-       \r
-       $els.sortable({\r
-               items: '.draggable_widget',\r
-               handle: '.drag_handle',\r
-               forcePlaceholderSize: true,\r
-               placeholder: 'ui-state-highlight',\r
-               cursor: 'move',\r
-               revert: true,\r
-               opacity: 0.9,\r
-               appendTo: 'body',\r
-               connectWith: els,\r
-               start:function(e,ui) {\r
-       \r
-               },\r
-               stop: function(e,ui) {  \r
-                       // refresh list before updating hidden fields with new widget order             \r
-                       $(this).sortable( "refresh" );\r
-                       \r
-                       var widgetNamesLeft = outputWidgetList('#leftcolumn_widgets');\r
-                       var widgetNamesMiddle = outputWidgetList('#middlecolumn_widgets');\r
-                       var widgetNamesRight = outputWidgetList('#rightcolumn_widgets');\r
-                       \r
-                       document.getElementById('debugField1').value = widgetNamesLeft;\r
-                       document.getElementById('debugField2').value = widgetNamesMiddle;\r
-                       document.getElementById('debugField3').value = widgetNamesRight;\r
-               }\r
-       });\r
-       \r
-       // bind more info buttons - called when new widgets are created\r
-       widget_moreinfo();\r
-       \r
-       // set-up hover class for dragged widgets\r
-       $("#rightcolumn_widgets").droppable({\r
-               accept: ".draggable_widget",\r
-               hoverClass: 'droppable-hover'\r
-       });\r
-       $("#middlecolumn_widgets").droppable({\r
-               accept: ".draggable_widget",\r
-               hoverClass: 'droppable-hover'\r
-       });\r
-       $("#leftcolumn_widgets").droppable({\r
-               accept: ".draggable_widget",\r
-               hoverClass: 'droppable-hover'\r
-       });\r
-\r
-}); /* end document ready function */\r
-\r
-\r
-// List active widgets for each page column\r
-function outputWidgetList(forElement) {\r
-       return( $("input[name='handler'], input[name='guid']", forElement ).makeDelimitedList("value") );       \r
-}\r
-\r
-// Make delimited list\r
-jQuery.fn.makeDelimitedList = function(elementAttribute) {\r
-\r
-       var delimitedListArray = new Array();\r
-       var listDelimiter = "::";\r
-       \r
-       // Loop over each element in the stack and add the elementAttribute to the array\r
-       this.each(function(e) {\r
-                       var listElement = $(this);\r
-                       // Add the attribute value to our values array\r
-                       delimitedListArray[delimitedListArray.length] = listElement.attr(elementAttribute);\r
-               }\r
-       );\r
-       \r
-       // Return value list by joining the array\r
-       return(delimitedListArray.join(listDelimiter));\r
-}\r
-\r
-\r
-// Read each widgets collapsed/expanded state from cookie and apply\r
-function widget_state(forWidget) {\r
-\r
-       var thisWidgetState = $.cookie(forWidget);\r
-\r
-       if (thisWidgetState == 'collapsed') {\r
-               forWidget = "#" + forWidget;\r
-               $(forWidget).find("div.collapsable_box_content").hide();\r
-               $(forWidget).find("a.toggle_box_contents").html('+');\r
-               $(forWidget).find("a.toggle_box_edit_panel").fadeOut('medium');\r
-       };      \r
-}\r
-\r
-\r
-// Toggle widgets contents and save to a cookie\r
-var toggleContent = function(e) {\r
-var targetContent = $('div.collapsable_box_content', this.parentNode.parentNode);\r
-       if (targetContent.css('display') == 'none') {\r
-               targetContent.slideDown(400);\r
-               $(this).html('-');\r
-               $(this.parentNode).children(".toggle_box_edit_panel").fadeIn('medium');\r
-               \r
-               // set cookie for widget panel open-state\r
-               var thisWidgetName = $(this.parentNode.parentNode.parentNode).attr('id');\r
-               $.cookie(thisWidgetName, 'expanded', { expires: 365 });\r
-               \r
-       } else {\r
-               targetContent.slideUp(400);\r
-               $(this).html('+');\r
-               $(this.parentNode).children(".toggle_box_edit_panel").fadeOut('medium');\r
-               // make sure edit pane is closed\r
-               $(this.parentNode.parentNode).children(".collapsable_box_editpanel").hide();\r
-               \r
-               // set cookie for widget panel closed-state\r
-               var thisWidgetName = $(this.parentNode.parentNode.parentNode).attr('id');\r
-               $.cookie(thisWidgetName, 'collapsed', { expires: 365 });                        \r
-       }\r
-       return false;\r
-};\r
-\r
-// More info tooltip in widget gallery edit panel\r
-function widget_moreinfo() {\r
-\r
-       $("img.more_info").hover(function(e) {                                                                            \r
-       var widgetdescription = $("input[name='description']", this.parentNode.parentNode.parentNode ).attr('value');\r
-       $("body").append("<p id='widget_moreinfo'><b>"+ widgetdescription +" </b></p>");\r
-       \r
-               if (e.pageX < 900) {\r
-                       $("#widget_moreinfo")\r
-                               .css("top",(e.pageY + 10) + "px")\r
-                               .css("left",(e.pageX + 10) + "px")\r
-                               .fadeIn("medium");      \r
-               }       \r
-               else {\r
-                       $("#widget_moreinfo")\r
-                               .css("top",(e.pageY + 10) + "px")\r
-                               .css("left",(e.pageX - 210) + "px")\r
-                               .fadeIn("medium");              \r
-               }                       \r
-       },\r
-       function() {\r
-               $("#widget_moreinfo").remove();\r
-       });     \r
-       \r
-       $("img.more_info").mousemove(function(e) {\r
-               // action on mousemove\r
-       });     \r
-};\r
-\r
-// COOKIES\r
-jQuery.cookie = function(name, value, options) {\r
-       if (typeof value != 'undefined') { // name and value given, set cookie\r
-    options = options || {};\r
-           if (value === null) {\r
-               value = '';\r
-               options.expires = -1;\r
-           }\r
-    var expires = '';\r
-    if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {\r
-        var date;\r
-        if (typeof options.expires == 'number') {\r
-            date = new Date();\r
-            date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));\r
-        } else {\r
-            date = options.expires;\r
-        }\r
-        expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE\r
-    }\r
-    // CAUTION: Needed to parenthesize options.path and options.domain\r
-    // in the following expressions, otherwise they evaluate to undefined\r
-    // in the packed version for some reason.\r
-    var path = options.path ? '; path=' + (options.path) : '';\r
-    var domain = options.domain ? '; domain=' + (options.domain) : '';\r
-    var secure = options.secure ? '; secure' : '';\r
-    document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');\r
-    \r
-       } else { // only name given, get cookie\r
-           var cookieValue = null;\r
-           if (document.cookie && document.cookie != '') {\r
-               var cookies = document.cookie.split(';');\r
-               for (var i = 0; i < cookies.length; i++) {\r
-                   var cookie = jQuery.trim(cookies[i]);\r
-                   // Does this cookie string begin with the name we want?\r
-                   if (cookie.substring(0, name.length + 1) == (name + '=')) {\r
-                       cookieValue = decodeURIComponent(cookie.substring(name.length + 1));\r
-                       break;\r
-                   }\r
-               }\r
-           }\r
-           return cookieValue;\r
-       }\r
-};\r
-\r
-// ELGG TOOLBAR MENU\r
-$.fn.elgg_topbardropdownmenu = function(options) {\r
-    \r
-  options = $.extend({speed: 350}, options || {});\r
-  \r
-  this.each(function() {\r
-    \r
-    var root = this, zIndex = 5000;\r
-    \r
-    function getSubnav(ele) {\r
-      if (ele.nodeName.toLowerCase() == 'li') {\r
-        var subnav = $('> ul', ele);\r
-        return subnav.length ? subnav[0] : null;\r
-      } else {\r
-             \r
-        return ele;\r
-      }\r
-    }\r
-    \r
-    function getActuator(ele) {\r
-      if (ele.nodeName.toLowerCase() == 'ul') {\r
-        return $(ele).parents('li')[0];\r
-      } else {\r
-        return ele;\r
-      }\r
-    }\r
-    \r
-    function hide() {\r
-      var subnav = getSubnav(this);\r
-      if (!subnav) return;\r
-      $.data(subnav, 'cancelHide', false);\r
-      setTimeout(function() {\r
-        if (!$.data(subnav, 'cancelHide')) {\r
-          $(subnav).slideUp(100);\r
-        }\r
-      }, 250);\r
-    }\r
-  \r
-    function show() {\r
-      var subnav = getSubnav(this);\r
-      if (!subnav) return;\r
-      $.data(subnav, 'cancelHide', true);\r
-      $(subnav).css({zIndex: zIndex++}).slideDown(options.speed);\r
-      if (this.nodeName.toLowerCase() == 'ul') {\r
-        var li = getActuator(this);\r
-        $(li).addClass('hover');\r
-        $('> a', li).addClass('hover');\r
-      }\r
-    }\r
-    \r
-    $('ul, li', this).hover(show, hide);\r
-    $('li', this).hover(\r
-      function() { $(this).addClass('hover'); $('> a', this).addClass('hover'); },\r
-      function() { $(this).removeClass('hover'); $('> a', this).removeClass('hover'); }\r
-    );\r
-    \r
-  });\r
-  \r
-};\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
+$(document).ready(function () {
+
+       // COLLAPSABLE WIDGETS (on Dashboard & Profile pages)
+       // toggle widget box contents
+       $('a.toggle_box_contents').bind('click', toggleContent);
+       
+       // toggle widget box edit panel
+       $('a.toggle_box_edit_panel').click(function () {
+               $(this.parentNode.parentNode).children(".collapsable_box_editpanel").slideToggle("fast");
+               return false;
+       });
+       
+       // toggle customise edit panel
+       $('a.toggle_customise_edit_panel').click(function () {
+               $('div#customise_editpanel').slideToggle("fast");
+               return false;
+       }); 
+       
+       // toggle plugin's settings nad more info on admin tools admin
+       $('a.pluginsettings_link').click(function () {
+               $(this.parentNode.parentNode).children(".pluginsettings").slideToggle("fast");
+               return false;
+       });
+       $('a.manifest_details').click(function () {
+               $(this.parentNode.parentNode).children(".manifest_file").slideToggle("fast");
+               return false;
+       });
+       // reusable generic hidden panel
+       $('a.collapsibleboxlink').click(function () {
+               $(this.parentNode.parentNode).children(".collapsible_box").slideToggle("fast");
+               return false;
+       });
+       
+       // WIDGET GALLERY EDIT PANEL
+       // Sortable widgets
+       var els = ['#leftcolumn_widgets', '#middlecolumn_widgets', '#rightcolumn_widgets', '#widget_picker_gallery' ];
+       var $els = $(els.toString());
+       
+       $els.sortable({
+               items: '.draggable_widget',
+               handle: '.drag_handle',
+               forcePlaceholderSize: true,
+               placeholder: 'ui-state-highlight',
+               cursor: 'move',
+               revert: true,
+               opacity: 0.9,
+               appendTo: 'body',
+               connectWith: els,
+               start:function(e,ui) {
+       
+               },
+               stop: function(e,ui) {  
+                       // refresh list before updating hidden fields with new widget order             
+                       $(this).sortable( "refresh" );
+                       
+                       var widgetNamesLeft = outputWidgetList('#leftcolumn_widgets');
+                       var widgetNamesMiddle = outputWidgetList('#middlecolumn_widgets');
+                       var widgetNamesRight = outputWidgetList('#rightcolumn_widgets');
+                       
+                       document.getElementById('debugField1').value = widgetNamesLeft;
+                       document.getElementById('debugField2').value = widgetNamesMiddle;
+                       document.getElementById('debugField3').value = widgetNamesRight;
+               }
+       });
+       
+       // bind more info buttons - called when new widgets are created
+       widget_moreinfo();
+       
+       // set-up hover class for dragged widgets
+       $("#rightcolumn_widgets").droppable({
+               accept: ".draggable_widget",
+               hoverClass: 'droppable-hover'
+       });
+       $("#middlecolumn_widgets").droppable({
+               accept: ".draggable_widget",
+               hoverClass: 'droppable-hover'
+       });
+       $("#leftcolumn_widgets").droppable({
+               accept: ".draggable_widget",
+               hoverClass: 'droppable-hover'
+       });
+
+}); /* end document ready function */
+
+
+// List active widgets for each page column
+function outputWidgetList(forElement) {
+       return( $("input[name='handler'], input[name='guid']", forElement ).makeDelimitedList("value") );       
+}
+
+// Make delimited list
+jQuery.fn.makeDelimitedList = function(elementAttribute) {
+
+       var delimitedListArray = new Array();
+       var listDelimiter = "::";
+       
+       // Loop over each element in the stack and add the elementAttribute to the array
+       this.each(function(e) {
+                       var listElement = $(this);
+                       // Add the attribute value to our values array
+                       delimitedListArray[delimitedListArray.length] = listElement.attr(elementAttribute);
+               }
+       );
+       
+       // Return value list by joining the array
+       return(delimitedListArray.join(listDelimiter));
+}
+
+
+// Read each widgets collapsed/expanded state from cookie and apply
+function widget_state(forWidget) {
+
+       var thisWidgetState = $.cookie(forWidget);
+
+       if (thisWidgetState == 'collapsed') {
+               forWidget = "#" + forWidget;
+               $(forWidget).find("div.collapsable_box_content").hide();
+               $(forWidget).find("a.toggle_box_contents").html('+');
+               $(forWidget).find("a.toggle_box_edit_panel").fadeOut('medium');
+       };      
+}
+
+
+// Toggle widgets contents and save to a cookie
+var toggleContent = function(e) {
+var targetContent = $('div.collapsable_box_content', this.parentNode.parentNode);
+       if (targetContent.css('display') == 'none') {
+               targetContent.slideDown(400);
+               $(this).html('-');
+               $(this.parentNode).children(".toggle_box_edit_panel").fadeIn('medium');
+               
+               // set cookie for widget panel open-state
+               var thisWidgetName = $(this.parentNode.parentNode.parentNode).attr('id');
+               $.cookie(thisWidgetName, 'expanded', { expires: 365 });
+               
+       } else {
+               targetContent.slideUp(400);
+               $(this).html('+');
+               $(this.parentNode).children(".toggle_box_edit_panel").fadeOut('medium');
+               // make sure edit pane is closed
+               $(this.parentNode.parentNode).children(".collapsable_box_editpanel").hide();
+               
+               // set cookie for widget panel closed-state
+               var thisWidgetName = $(this.parentNode.parentNode.parentNode).attr('id');
+               $.cookie(thisWidgetName, 'collapsed', { expires: 365 });                        
+       }
+       return false;
+};
+
+// More info tooltip in widget gallery edit panel
+function widget_moreinfo() {
+
+       $("img.more_info").hover(function(e) {                                                                            
+       var widgetdescription = $("input[name='description']", this.parentNode.parentNode.parentNode ).attr('value');
+       $("body").append("<p id='widget_moreinfo'><b>"+ widgetdescription +" </b></p>");
+       
+               if (e.pageX < 900) {
+                       $("#widget_moreinfo")
+                               .css("top",(e.pageY + 10) + "px")
+                               .css("left",(e.pageX + 10) + "px")
+                               .fadeIn("medium");      
+               }       
+               else {
+                       $("#widget_moreinfo")
+                               .css("top",(e.pageY + 10) + "px")
+                               .css("left",(e.pageX - 210) + "px")
+                               .fadeIn("medium");              
+               }                       
+       },
+       function() {
+               $("#widget_moreinfo").remove();
+       });     
+       
+       $("img.more_info").mousemove(function(e) {
+               // action on mousemove
+       });     
+};
+
+// COOKIES
+jQuery.cookie = function(name, value, options) {
+       if (typeof value != 'undefined') { // name and value given, set cookie
+    options = options || {};
+           if (value === null) {
+               value = '';
+               options.expires = -1;
+           }
+    var expires = '';
+    if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
+        var date;
+        if (typeof options.expires == 'number') {
+            date = new Date();
+            date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
+        } else {
+            date = options.expires;
+        }
+        expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
+    }
+    // CAUTION: Needed to parenthesize options.path and options.domain
+    // in the following expressions, otherwise they evaluate to undefined
+    // in the packed version for some reason.
+    var path = options.path ? '; path=' + (options.path) : '';
+    var domain = options.domain ? '; domain=' + (options.domain) : '';
+    var secure = options.secure ? '; secure' : '';
+    document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
+    
+       } else { // only name given, get cookie
+           var cookieValue = null;
+           if (document.cookie && document.cookie != '') {
+               var cookies = document.cookie.split(';');
+               for (var i = 0; i < cookies.length; i++) {
+                   var cookie = jQuery.trim(cookies[i]);
+                   // Does this cookie string begin with the name we want?
+                   if (cookie.substring(0, name.length + 1) == (name + '=')) {
+                       cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
+                       break;
+                   }
+               }
+           }
+           return cookieValue;
+       }
+};
+
+// ELGG TOOLBAR MENU
+$.fn.elgg_topbardropdownmenu = function(options) {
+    
+  options = $.extend({speed: 350}, options || {});
+  
+  this.each(function() {
+    
+    var root = this, zIndex = 5000;
+    
+    function getSubnav(ele) {
+      if (ele.nodeName.toLowerCase() == 'li') {
+        var subnav = $('> ul', ele);
+        return subnav.length ? subnav[0] : null;
+      } else {
+             
+        return ele;
+      }
+    }
+    
+    function getActuator(ele) {
+      if (ele.nodeName.toLowerCase() == 'ul') {
+        return $(ele).parents('li')[0];
+      } else {
+        return ele;
+      }
+    }
+    
+    function hide() {
+      var subnav = getSubnav(this);
+      if (!subnav) return;
+      $.data(subnav, 'cancelHide', false);
+      setTimeout(function() {
+        if (!$.data(subnav, 'cancelHide')) {
+          $(subnav).slideUp(100);
+        }
+      }, 250);
+    }
+  
+    function show() {
+      var subnav = getSubnav(this);
+      if (!subnav) return;
+      $.data(subnav, 'cancelHide', true);
+      $(subnav).css({zIndex: zIndex++}).slideDown(options.speed);
+      if (this.nodeName.toLowerCase() == 'ul') {
+        var li = getActuator(this);
+        $(li).addClass('hover');
+        $('> a', li).addClass('hover');
+      }
+    }
+    
+    $('ul, li', this).hover(show, hide);
+    $('li', this).hover(
+      function() { $(this).addClass('hover'); $('> a', this).addClass('hover'); },
+      function() { $(this).removeClass('hover'); $('> a', this).removeClass('hover'); }
+    );
+    
+  });
+  
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
index ab8c0dc200a15a15e48e56e0ede4c99e4ebdd7d7..cdd011729a6bc98c05c1aae157e2d0ab70f1126e 100644 (file)
@@ -1,57 +1,57 @@
-<script>\r
-/*\r
-Part of multi file uploader\r
-*/\r
-\r
-var number_of_files = 1;\r
-\r
-// wait for the DOM to be loaded \r
-$(document).ready(function() { \r
-       // bind 'file_form' and provide a simple callback function \r
-       $('#file_form').submit(function() {\r
-               $('#form_container').hide();\r
-               $('#form_message').html('<div class="contentWrapper"><?php echo $vars['submit_message']; ?></div>');\r
-               $('#form_message').show();\r
-               $(this).ajaxSubmit(function(response_message) {\r
-                       $('#form_message').html('<div class="contentWrapper">'+response_message+'</div>');\r
-               }); \r
-               \r
-               return false;\r
-       });\r
-});\r
-\r
-function file_generate_bit(bit_label,prefix,classname,field_type,field_size) {\r
-       bit = document.createElement('p');\r
-    label = document.createElement('label');\r
-    textnode = document.createTextNode(bit_label);\r
-    label.appendChild(textnode);\r
-    el = document.createElement('br');\r
-    label.appendChild(el);\r
-    el = document.createElement('input');\r
-    el.type = field_type;\r
-    el.className = classname;\r
-    if (field_size > 0) {\r
-       el.size = field_size;\r
-    }\r
-    el.name = prefix+number_of_files;\r
-    el.value = "";\r
-    label.appendChild(el);\r
-    bit.appendChild(label);\r
-    \r
-    return bit;    \r
-}\r
-\r
-function file_addtoform() {\r
-    var o,el;\r
-    o = document.getElementById('option_container');\r
-    title_label = "<?php echo elgg_echo("title"); ?>";\r
-    bit = file_generate_bit(title_label,'title_','input-text','text',0);\r
-    o.appendChild(bit);\r
-    file_label = "<?php echo elgg_echo("file:file"); ?>";\r
-    bit = file_generate_bit(file_label,'upload_','input-file','file',30);\r
-    o.appendChild(bit);\r
-    \r
-    number_of_files++;\r
-    document.file_form.number_of_files.value = number_of_files;\r
-}\r
+<script>
+/*
+Part of multi file uploader
+*/
+
+var number_of_files = 1;
+
+// wait for the DOM to be loaded 
+$(document).ready(function() { 
+       // bind 'file_form' and provide a simple callback function 
+       $('#file_form').submit(function() {
+               $('#form_container').hide();
+               $('#form_message').html('<div class="contentWrapper"><?php echo $vars['submit_message']; ?></div>');
+               $('#form_message').show();
+               $(this).ajaxSubmit(function(response_message) {
+                       $('#form_message').html('<div class="contentWrapper">'+response_message+'</div>');
+               }); 
+               
+               return false;
+       });
+});
+
+function file_generate_bit(bit_label,prefix,classname,field_type,field_size) {
+       bit = document.createElement('p');
+    label = document.createElement('label');
+    textnode = document.createTextNode(bit_label);
+    label.appendChild(textnode);
+    el = document.createElement('br');
+    label.appendChild(el);
+    el = document.createElement('input');
+    el.type = field_type;
+    el.className = classname;
+    if (field_size > 0) {
+       el.size = field_size;
+    }
+    el.name = prefix+number_of_files;
+    el.value = "";
+    label.appendChild(el);
+    bit.appendChild(label);
+    
+    return bit;    
+}
+
+function file_addtoform() {
+    var o,el;
+    o = document.getElementById('option_container');
+    title_label = "<?php echo elgg_echo("title"); ?>";
+    bit = file_generate_bit(title_label,'title_','input-text','text',0);
+    o.appendChild(bit);
+    file_label = "<?php echo elgg_echo("file:file"); ?>";
+    bit = file_generate_bit(file_label,'upload_','input-file','file',30);
+    o.appendChild(bit);
+    
+    number_of_files++;
+    document.file_form.number_of_files.value = number_of_files;
+}
 </script>
\ No newline at end of file
index 1702142b342bcdedd609e56b37e2ff2b0ef4db13..468505c897879756e5b87832c0e377b059925af1 100644 (file)
@@ -1,20 +1,20 @@
-<?php\r
-\r
-       /**\r
-        * Elgg error message\r
-        * Displays a single error message\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg error message
+        * Displays a single error message
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['object'] An error message (string)\r
-        */\r
-?>\r
-\r
-       <p>\r
-               <?php echo elgg_view('output/longtext', array('value' => $vars['object'])); ?>\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['object'] An error message (string)
+        */
+?>
+
+       <p>
+               <?php echo elgg_view('output/longtext', array('value' => $vars['object'])); ?>
        </p>
\ No newline at end of file
index 63e0a91f38cf19c3f49b618e034f2d18ba28e19d..e9b9b2ebbbfb40f5012c5b83a025e4c371b4c4c1 100644 (file)
@@ -1,57 +1,57 @@
-<?php\r
-\r
-       /**\r
-        * Elgg list errors\r
-        * Lists error messages\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['object'] An array of error messages\r
-        */\r
-\r
-               if (!empty($vars['object']) && is_array($vars['object'])) {\r
-\r
-?>\r
-<!-- used to fade out the system messages after 3 seconds -->\r
-<script>\r
-$(document).ready(function () {\r
-       $('.messages_error').animate({opacity: 1.0}, 1000); \r
-       $('.messages_error').animate({opacity: 1.0}, 5000);\r
-       $('.messages_error').fadeOut('slow');\r
-      \r
-       $('span.closeMessages a').click(function () {\r
-               $(".messages_error").stop();\r
-               $('.messages_error').fadeOut('slow');\r
-       return false;\r
-    });\r
-    \r
-       $('div.messages_error').click(function () {\r
-               $(".messages_error").stop();\r
-               $('.messages_error').fadeOut('slow');\r
-       return false;\r
-    });\r
-\r
-});  \r
-</script>\r
-\r
-       <div class="messages_error">\r
-       <span class="closeMessages"><a href="#"><?php echo elgg_echo('systemmessages:dismiss'); ?></a></span>\r
-\r
-<?php\r
-                       foreach($vars['object'] as $error) {\r
-                               echo elgg_view('messages/errors/error',array('object' => $error));\r
-                       }\r
-?>\r
-\r
-       </div>\r
-<?php\r
-               }\r
-\r
-\r
-\r
+<?php
+
+       /**
+        * Elgg list errors
+        * Lists error messages
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['object'] An array of error messages
+        */
+
+               if (!empty($vars['object']) && is_array($vars['object'])) {
+
+?>
+<!-- used to fade out the system messages after 3 seconds -->
+<script>
+$(document).ready(function () {
+       $('.messages_error').animate({opacity: 1.0}, 1000); 
+       $('.messages_error').animate({opacity: 1.0}, 5000);
+       $('.messages_error').fadeOut('slow');
+      
+       $('span.closeMessages a').click(function () {
+               $(".messages_error").stop();
+               $('.messages_error').fadeOut('slow');
+       return false;
+    });
+    
+       $('div.messages_error').click(function () {
+               $(".messages_error").stop();
+               $('.messages_error').fadeOut('slow');
+       return false;
+    });
+
+});  
+</script>
+
+       <div class="messages_error">
+       <span class="closeMessages"><a href="#"><?php echo elgg_echo('systemmessages:dismiss'); ?></a></span>
+
+<?php
+                       foreach($vars['object'] as $error) {
+                               echo elgg_view('messages/errors/error',array('object' => $error));
+                       }
+?>
+
+       </div>
+<?php
+               }
+
+
+
 ?>
\ No newline at end of file
index 7381c969be5b3218dd224e17d3cf5379eda7821f..0b482d845c413e865c0dde408d50751c2c675592 100644 (file)
@@ -1,18 +1,18 @@
-<?php\r
-\r
-       /**\r
-        * Elgg exception\r
-        * Displays a single exception\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg exception
+        * Displays a single exception
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['object'] An exception\r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['object'] An exception
+        */
 
        global $CONFIG;
         
@@ -39,6 +39,6 @@ END;
        }
        
        $title = $class;
-       \r
-       echo elgg_view_layout("one_column", elgg_view_title($title) . $body);\r
+       
+       echo elgg_view_layout("one_column", elgg_view_title($title) . $body);
 ?>
\ No newline at end of file
index d454841d87b58228a34b9451aeac35575d0389dc..dd02fdac5c67b732010288baadb225511ec4ec53 100644 (file)
@@ -1,25 +1,25 @@
-<?php\r
-\r
-       /**\r
-        * Elgg global system message list\r
-        * Lists all system messages\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg global system message list
+        * Lists all system messages
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['object'] The array of message registers\r
-        */\r
-\r
-               if (!empty($vars['object']) && is_array($vars['object']) && sizeof($vars['object']) > 0) {\r
-                       \r
-                       foreach($vars['object'] as $register => $list ) {\r
-                               echo elgg_view("messages/{$register}/list", array('object' => $list));\r
-                       }\r
-                       \r
-               }\r
-               \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['object'] The array of message registers
+        */
+
+               if (!empty($vars['object']) && is_array($vars['object']) && sizeof($vars['object']) > 0) {
+                       
+                       foreach($vars['object'] as $register => $list ) {
+                               echo elgg_view("messages/{$register}/list", array('object' => $list));
+                       }
+                       
+               }
+               
 ?>
\ No newline at end of file
index 6a147358247a313f8419fe18d7b5a7a365866f75..41762c7f49b8bfc1ce90ca448d5660d17b5fa3b7 100644 (file)
@@ -1,58 +1,58 @@
-<?php\r
-\r
-       /**\r
-        * Elgg list system messages\r
-        * Lists system messages\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['object'] An array of system messages\r
-        */\r
-\r
-       if (!empty($vars['object']) && is_array($vars['object'])) {\r
-\r
-?>\r
-<!-- used to fade out the system messages after 3 seconds -->\r
-<script>\r
-$(document).ready(function () {\r
-       $('.messages').animate({opacity: 1.0}, 1000); \r
-       $('.messages').animate({opacity: 1.0}, 5000);\r
-       $('.messages').fadeOut('slow');\r
-      \r
-       $('span.closeMessages a').click(function () {\r
-               $(".messages").stop();\r
-               $('.messages').fadeOut('slow');\r
-       return false;\r
-    });\r
-    \r
-       $('div.messages').click(function () {\r
-               $(".messages").stop();\r
-               $('.messages').fadeOut('slow');\r
-       return false;\r
-    });\r
-});  \r
-</script>\r
-\r
-       <div class="messages">\r
-       <span class="closeMessages"><a href="#"><?php echo elgg_echo('systemmessages:dismiss'); ?></a></span>\r
-<?php\r
-\r
-               \r
-                       foreach($vars['object'] as $message) {\r
-                               echo elgg_view('messages/messages/message',array('object' => $message));\r
-                       }\r
-\r
-?>\r
-\r
-       </div>\r
-       \r
-<?php\r
-\r
-       }\r
-\r
+<?php
+
+       /**
+        * Elgg list system messages
+        * Lists system messages
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['object'] An array of system messages
+        */
+
+       if (!empty($vars['object']) && is_array($vars['object'])) {
+
+?>
+<!-- used to fade out the system messages after 3 seconds -->
+<script>
+$(document).ready(function () {
+       $('.messages').animate({opacity: 1.0}, 1000); 
+       $('.messages').animate({opacity: 1.0}, 5000);
+       $('.messages').fadeOut('slow');
+      
+       $('span.closeMessages a').click(function () {
+               $(".messages").stop();
+               $('.messages').fadeOut('slow');
+       return false;
+    });
+    
+       $('div.messages').click(function () {
+               $(".messages").stop();
+               $('.messages').fadeOut('slow');
+       return false;
+    });
+});  
+</script>
+
+       <div class="messages">
+       <span class="closeMessages"><a href="#"><?php echo elgg_echo('systemmessages:dismiss'); ?></a></span>
+<?php
+
+               
+                       foreach($vars['object'] as $message) {
+                               echo elgg_view('messages/messages/message',array('object' => $message));
+                       }
+
+?>
+
+       </div>
+       
+<?php
+
+       }
+
 ?>
\ No newline at end of file
index 1221e1001a18af7b6618ec2a00e4520b9e3bcaf0..bd3514e7abbcb0bd68afb874a39f7942baad17be 100644 (file)
@@ -1,20 +1,20 @@
-<?php\r
-\r
-       /**\r
-        * Elgg standard message\r
-        * Displays a single Elgg system message\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg standard message
+        * Displays a single Elgg system message
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['object'] A system message (string)\r
-        */\r
-?>\r
-\r
-       <p>\r
-               <?php echo elgg_view('output/longtext', array('value' => $vars['object'])); ?>\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['object'] A system message (string)
+        */
+?>
+
+       <p>
+               <?php echo elgg_view('output/longtext', array('value' => $vars['object'])); ?>
        </p>
\ No newline at end of file
index 63d79af8be072f3246b7364c0d81ab8ed4ecb57f..c5f3a80a1cc0ba4d2df496308f5207a553a44230 100644 (file)
@@ -1,34 +1,34 @@
-<?php\r
-\r
-       /**\r
-        * Elgg list view switcher\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg list view switcher
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-\r
-               $baseurl = preg_replace('/[\&\?]search\_viewtype\=[A-Za-z0-9]*/',"",$vars['baseurl']);\r
-               \r
-               if ($vars['viewtype'] == "list") {\r
-                       $viewtype = "gallery";\r
-               } else {\r
-                       $viewtype = "list";\r
-               }\r
-               \r
-               if (substr_count($baseurl,'?')) {\r
-                       $baseurl .= "&search_viewtype=" . $viewtype;\r
-               } else {\r
-                       $baseurl .= "?search_viewtype=" . $viewtype;\r
-               }\r
-\r
-?>\r
-\r
-       <div class="contentWrapper">\r
-               <?php echo elgg_echo("viewtype:change") ?>:\r
-               <a href="<?php echo $baseurl; ?>"><?php echo elgg_echo("viewtype:{$viewtype}"); ?></a>\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+
+               $baseurl = preg_replace('/[\&\?]search\_viewtype\=[A-Za-z0-9]*/',"",$vars['baseurl']);
+               
+               if ($vars['viewtype'] == "list") {
+                       $viewtype = "gallery";
+               } else {
+                       $viewtype = "list";
+               }
+               
+               if (substr_count($baseurl,'?')) {
+                       $baseurl .= "&search_viewtype=" . $viewtype;
+               } else {
+                       $baseurl .= "?search_viewtype=" . $viewtype;
+               }
+
+?>
+
+       <div class="contentWrapper">
+               <?php echo elgg_echo("viewtype:change") ?>:
+               <a href="<?php echo $baseurl; ?>"><?php echo elgg_echo("viewtype:{$viewtype}"); ?></a>
        </div>
\ No newline at end of file
index 8b34975c711ed1f3a8755b5d063265fc5dba36b7..ff894cd0ee516e378227c705059e152e62c45e8c 100644 (file)
@@ -1,46 +1,46 @@
-<?php\r
-       /**\r
-        * User settings for notifications.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * User settings for notifications.
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       global $NOTIFICATION_HANDLERS;\r
+        * @link http://elgg.org/
+        */
+
+       global $NOTIFICATION_HANDLERS;
        $notification_settings = get_user_notification_settings(page_owner());
-       \r
-?>\r
-       <h3><?php echo elgg_echo('notifications:usersettings'); ?></h3>\r
-       \r
-       <p><?php echo elgg_echo('notifications:methods'); ?>\r
-       \r
-       <table>\r
-<?php\r
-               // Loop through options\r
-               foreach ($NOTIFICATION_HANDLERS as $k => $v) \r
-               {       \r
-?>\r
-                       <tr>\r
-                               <td><?php echo elgg_echo($k); ?>: </td>\r
-\r
-                               <td>\r
-<?php\r
-\r
-       if ($notification_settings->$k) {\r
-               $val = "yes";\r
-       } else {\r
-               $val = "no";\r
-       }\r
-       echo elgg_view('input/radio',array('internalname' => "method[{$k}]", 'options' => array(elgg_echo('option:yes') => 'yes',elgg_echo('option:no') => 'no'), 'value' => $val));\r
-\r
-?>                             \r
-                               </td>\r
-                       </tr>\r
-<?php\r
-               }\r
-?>\r
+       
+?>
+       <h3><?php echo elgg_echo('notifications:usersettings'); ?></h3>
+       
+       <p><?php echo elgg_echo('notifications:methods'); ?>
+       
+       <table>
+<?php
+               // Loop through options
+               foreach ($NOTIFICATION_HANDLERS as $k => $v) 
+               {       
+?>
+                       <tr>
+                               <td><?php echo elgg_echo($k); ?>: </td>
+
+                               <td>
+<?php
+
+       if ($notification_settings->$k) {
+               $val = "yes";
+       } else {
+               $val = "no";
+       }
+       echo elgg_view('input/radio',array('internalname' => "method[{$k}]", 'options' => array(elgg_echo('option:yes') => 'yes',elgg_echo('option:no') => 'no'), 'value' => $val));
+
+?>                             
+                               </td>
+                       </tr>
+<?php
+               }
+?>
        </table>
\ No newline at end of file
index a08eaf2dcd0f4e4fc8066b804dd076409c672ccf..b49120e2e2d785249c2a8fafeab37bce5c4e7985 100644 (file)
@@ -1,16 +1,16 @@
-<?php\r
-\r
-       /**\r
-        * Elgg default widget view\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg default widget view
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+               echo elgg_view('widgets/wrapper',$vars);
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-               echo elgg_view('widgets/wrapper',$vars);\r
-\r
 ?>
\ No newline at end of file
index 353dd9b2121754eaf8c77a425cd247ddd41de14b..336129aede0e15412708ad4c340f7b7b64b3a57d 100644 (file)
@@ -1,19 +1,19 @@
 <?php
-\r
-       /**\r
-        * Elgg calendar output\r
-        * Displays a calendar output field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg calendar output
+        * Displays a calendar output field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * \r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * 
+        */
 
     if (is_int($vars['value'])) {
         echo date("F j, Y", $vars['value']);
index 462d6969ec640ad0dfa961b6ac7229b373551291..a93455e28df1ece6e7f34c56a1c0a9273fa5036d 100644 (file)
@@ -1,19 +1,19 @@
-<?php\r
-\r
-       /**\r
-        * Elgg text output\r
-        * Displays some text that was input using a standard text field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg text output
+        * Displays some text that was input using a standard text field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['text'] The text to display\r
-        * \r
-        */\r
-\r
-    echo elgg_view('output/tags',$vars);\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['text'] The text to display
+        * 
+        */
+
+    echo elgg_view('output/tags',$vars);
 ?>
\ No newline at end of file
index c5440ab885b02415b6a4e57edb3eec80bc8efa7e..bb7e866f2f0c99208f1c848080f9025c9153ff94 100644 (file)
@@ -1,24 +1,24 @@
-<?php\r
-\r
-       /**\r
-        * Elgg confirmation link\r
-        * A link that displays a confirmation dialog before it executes\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg confirmation link
+        * A link that displays a confirmation dialog before it executes
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['text'] The text of the link\r
-        * @uses $vars['href'] The address\r
-        * @uses $vars['confirm'] The dialog text\r
-        * \r
-        */\r
-\r
-       $confirm = $vars['confirm'];\r
-       if (!$confirm)\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['text'] The text of the link
+        * @uses $vars['href'] The address
+        * @uses $vars['confirm'] The dialog text
+        * 
+        */
+
+       $confirm = $vars['confirm'];
+       if (!$confirm)
                $confirm = elgg_echo('question:areyousure');
                
        $link = $vars['href'];
        $sep = "?";
                if (strpos($link, '?')>0) $sep = "&";
                $link = "$link{$sep}__elgg_token=$token&__elgg_ts=$ts";
-       }\r
-       \r
-       if ($vars['class']) {\r
-               $class = 'class="' . $vars['class'] . '"';\r
-       } else {\r
-               $class = '';\r
-       }\r
-?>\r
+       }
+       
+       if ($vars['class']) {
+               $class = 'class="' . $vars['class'] . '"';
+       } else {
+               $class = '';
+       }
+?>
 <a href="<?php echo $link; ?>" <?php echo $class; ?> onclick="return confirm('<?php echo addslashes($confirm); ?>');"><?php echo htmlentities($vars['text'], ENT_QUOTES, 'UTF-8'); ?></a>
\ No newline at end of file
index 6973a6c92f7436a4eeb22ad2bcb18bb964b8ef14..d4fba97a0ea351225d3f608a4e8e6cc045089a8f 100644 (file)
@@ -1,21 +1,21 @@
-<?php\r
-\r
-       /**\r
-        * Date\r
-        * Displays a properly formatted date\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Date
+        * Displays a properly formatted date
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] A UNIX epoch timestamp\r
-        * \r
-        */\r
-\r
-    if ($vars['value'] > 86400) {\r
-        echo date("F j, Y",$vars['value']);\r
-    }\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] A UNIX epoch timestamp
+        * 
+        */
+
+    if ($vars['value'] > 86400) {
+        echo date("F j, Y",$vars['value']);
+    }
 ?>
\ No newline at end of file
index 6c8e66901d5fa0f583532e742c10d9e2b396f741..2d454213fe692a5180a694d58ef246db03464a8c 100644 (file)
@@ -1,21 +1,21 @@
-<?php\r
-\r
-       /**\r
-        * Elgg email output\r
-        * Displays an email address that was entered using an email input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg email output
+        * Displays an email address that was entered using an email input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The email address to display\r
-        * \r
-        */\r
-\r
-    if (!empty($vars['value'])) {\r
-       echo "<a href=\"mailto:" . $vars['value'] . "\">". htmlentities($vars['value'], ENT_QUOTES, 'UTF-8') ."</a>";\r
-    }\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The email address to display
+        * 
+        */
+
+    if (!empty($vars['value'])) {
+       echo "<a href=\"mailto:" . $vars['value'] . "\">". htmlentities($vars['value'], ENT_QUOTES, 'UTF-8') ."</a>";
+    }
 ?>
\ No newline at end of file
index 101e72198a22c285f939a91a2fe00f708dd53adb..3d130359a4c2105b3de45a899f40bf886e56d4da 100644 (file)
@@ -1,21 +1,21 @@
-<?php\r
-\r
-       /**\r
-        * Elgg display long text\r
-        * Displays a large amount of text, with new lines converted to line breaks\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg display long text
+        * Displays a large amount of text, with new lines converted to line breaks
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['text'] The text to display\r
-        * \r
-        */\r
-\r
-       global $CONFIG;\r
-\r
-    echo autop(parse_urls(filter_tags($vars['value'])));\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['text'] The text to display
+        * 
+        */
+
+       global $CONFIG;
+
+    echo autop(parse_urls(filter_tags($vars['value'])));
 ?>
\ No newline at end of file
index ebda774716fd025142b5973267b5b668615c78bb..60b365b11328266434ede45cb5416492ac23e946 100644 (file)
@@ -1,19 +1,19 @@
-<?php\r
-\r
-       /**\r
-        * Elgg pulldown display\r
-        * Displays a value that was entered into the system via a pulldown\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg pulldown display
+        * Displays a value that was entered into the system via a pulldown
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['text'] The text to display\r
-        * \r
-        */\r
-\r
-    echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); //$vars['value'];\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['text'] The text to display
+        * 
+        */
+
+    echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); //$vars['value'];
 ?>
\ No newline at end of file
index 1d93dc8a049b861044d4c9b5a27689d212c26673..78723b5557e77b424bd8dd3cad493be94c3e16c8 100644 (file)
@@ -1,19 +1,19 @@
-<?php\r
-\r
-       /**\r
-        * Elgg text output\r
-        * Displays some text that was input using a standard text field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg text output
+        * Displays some text that was input using a standard text field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['text'] The text to display\r
-        * \r
-        */\r
-\r
-    echo elgg_view('output/text',$vars);\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['text'] The text to display
+        * 
+        */
+
+    echo elgg_view('output/text',$vars);
 ?>
\ No newline at end of file
index 10da20034353b89d63f7296c7dd38a71ca944f9d..27d49b089df87086b9ab6156df2f84cbcb7bb856 100644 (file)
@@ -1,52 +1,52 @@
-<?php\r
-\r
-       /**\r
-        * Elgg tagcloud\r
-        * Displays a tagcloud\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg tagcloud
+        * Displays a tagcloud
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['tagcloud'] An array of stdClass objects with two elements: 'tag' (the text of the tag) and 'total' (the number of elements with this tag) \r
-        * \r
-        */\r
-    \r
-       if (!empty($vars['subtype'])) {\r
-               $subtype = "&subtype=" . urlencode($vars['subtype']);\r
-       } else {\r
-               $subtype = "";\r
-       }\r
-       if (!empty($vars['object'])) {\r
-               $object = "&object=" . urlencode($vars['object']);\r
-       } else {\r
-               $object = "";\r
-       }\r
-       \r
-       if (empty($vars['tagcloud']) && !empty($vars['value']))\r
-               $vars['tagcloud'] = $vars['value'];\r
-\r
-    if (!empty($vars['tagcloud']) && is_array($vars['tagcloud'])) {\r
-        \r
-        $counter = 0;\r
-        $cloud = "";\r
-        $max = 0;\r
-        foreach($vars['tagcloud'] as $tag) {\r
-               if ($tag->total > $max) {\r
-                       $max = $tag->total;\r
-               }\r
-        }\r
-        foreach($vars['tagcloud'] as $tag) {\r
-            if (!empty($cloud)) $cloud .= ", ";\r
-            $size = round((log($tag->total) / log($max)) * 100) + 30;\r
-            if ($size < 60) $size = 60;\r
-            $cloud .= "<a href=\"" . $vars['url'] . "search/?tag=". urlencode($tag->tag) . $object . $subtype . "\" style=\"font-size: {$size}%\" title=\"".addslashes($tag->tag)." ({$tag->total})\" style=\"text-decoration:none;\">" . htmlentities($tag->tag, ENT_QUOTES, 'UTF-8') . "</a>";\r
-        }\r
-        echo $cloud;\r
-\r
-    }\r
-     \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['tagcloud'] An array of stdClass objects with two elements: 'tag' (the text of the tag) and 'total' (the number of elements with this tag) 
+        * 
+        */
+    
+       if (!empty($vars['subtype'])) {
+               $subtype = "&subtype=" . urlencode($vars['subtype']);
+       } else {
+               $subtype = "";
+       }
+       if (!empty($vars['object'])) {
+               $object = "&object=" . urlencode($vars['object']);
+       } else {
+               $object = "";
+       }
+       
+       if (empty($vars['tagcloud']) && !empty($vars['value']))
+               $vars['tagcloud'] = $vars['value'];
+
+    if (!empty($vars['tagcloud']) && is_array($vars['tagcloud'])) {
+        
+        $counter = 0;
+        $cloud = "";
+        $max = 0;
+        foreach($vars['tagcloud'] as $tag) {
+               if ($tag->total > $max) {
+                       $max = $tag->total;
+               }
+        }
+        foreach($vars['tagcloud'] as $tag) {
+            if (!empty($cloud)) $cloud .= ", ";
+            $size = round((log($tag->total) / log($max)) * 100) + 30;
+            if ($size < 60) $size = 60;
+            $cloud .= "<a href=\"" . $vars['url'] . "search/?tag=". urlencode($tag->tag) . $object . $subtype . "\" style=\"font-size: {$size}%\" title=\"".addslashes($tag->tag)." ({$tag->total})\" style=\"text-decoration:none;\">" . htmlentities($tag->tag, ENT_QUOTES, 'UTF-8') . "</a>";
+        }
+        echo $cloud;
+
+    }
+     
 ?>
\ No newline at end of file
index 87b23cb63953682bd026f4b46f2b015f237829fd..901fa806b19d49dcf37c97754e674143dd339633 100644 (file)
@@ -1,55 +1,55 @@
-<?php\r
-\r
-       /**\r
-        * Elgg tags\r
-        * Displays a list of tags, separated by commas\r
-        * \r
-        * Tags can be a single string (for one tag) or an array of strings\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg tags
+        * Displays a list of tags, separated by commas
+        * 
+        * Tags can be a single string (for one tag) or an array of strings
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['tags'] The tags to display\r
-        * @uses $vars['tagtype'] The tagtype, optionally\r
-        */\r
-\r
-       if (!empty($vars['subtype'])) {\r
-               $subtype = "&subtype=" . urlencode($vars['subtype']);\r
-       } else {\r
-               $subtype = "";\r
-       }\r
-       if (!empty($vars['object'])) {\r
-               $object = "&object=" . urlencode($vars['object']);\r
-       } else {\r
-               $object = "";\r
-       }\r
-\r
-       if (empty($vars['tags']) && !empty($vars['value']))\r
-               $vars['tags'] = $vars['value'];\r
-    if (!empty($vars['tags'])) {\r
-        \r
-        $tagstr = "";\r
-        if (!is_array($vars['tags']))\r
-               $vars['tags'] = array($vars['tags']);\r
-\r
-        foreach($vars['tags'] as $tag) {\r
-            if (!empty($tagstr)) {\r
-                $tagstr .= ", ";\r
-            }\r
-           if (!empty($vars['type'])) {\r
-               $type = "&type={$vars['type']}";\r
-           } else {\r
-               $type = "";\r
-           }\r
-           if (is_string($tag)) { \r
-               $tagstr .= "<a rel=\"tag\" href=\"{$vars['url']}tag/".urlencode($tag) . "{$type}{$subtype}{$object}\">" . htmlentities($tag, ENT_QUOTES, 'UTF-8') . "</a>";\r
-           }\r
-        }\r
-         echo $tagstr;\r
-        \r
-    }\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['tags'] The tags to display
+        * @uses $vars['tagtype'] The tagtype, optionally
+        */
+
+       if (!empty($vars['subtype'])) {
+               $subtype = "&subtype=" . urlencode($vars['subtype']);
+       } else {
+               $subtype = "";
+       }
+       if (!empty($vars['object'])) {
+               $object = "&object=" . urlencode($vars['object']);
+       } else {
+               $object = "";
+       }
+
+       if (empty($vars['tags']) && !empty($vars['value']))
+               $vars['tags'] = $vars['value'];
+    if (!empty($vars['tags'])) {
+        
+        $tagstr = "";
+        if (!is_array($vars['tags']))
+               $vars['tags'] = array($vars['tags']);
+
+        foreach($vars['tags'] as $tag) {
+            if (!empty($tagstr)) {
+                $tagstr .= ", ";
+            }
+           if (!empty($vars['type'])) {
+               $type = "&type={$vars['type']}";
+           } else {
+               $type = "";
+           }
+           if (is_string($tag)) { 
+               $tagstr .= "<a rel=\"tag\" href=\"{$vars['url']}tag/".urlencode($tag) . "{$type}{$subtype}{$object}\">" . htmlentities($tag, ENT_QUOTES, 'UTF-8') . "</a>";
+           }
+        }
+         echo $tagstr;
+        
+    }
 ?>
\ No newline at end of file
index ca667f98a6f389907a1029ec98b62dce02c9cbd9..080b81d6805860c646bed53b21f6adb0d1ad8a80 100644 (file)
@@ -1,19 +1,19 @@
-<?php\r
-\r
-       /**\r
-        * Elgg text output\r
-        * Displays some text that was input using a standard text field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg text output
+        * Displays some text that was input using a standard text field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['text'] The text to display\r
-        * \r
-        */\r
-\r
-    echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); // $vars['value'];\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['text'] The text to display
+        * 
+        */
+
+    echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); // $vars['value'];
 ?>
\ No newline at end of file
index 87f551ed11ff873e74c9df8c97219bd729adab1c..7f72f0dce54a816cf97ab0622f0d4be2322ef924 100644 (file)
@@ -1,24 +1,24 @@
-<?php\r
-\r
-       /**\r
-        * Elgg URL display\r
-        * Displays a URL as a link\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg URL display
+        * Displays a URL as a link
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The URL to display\r
-        * \r
-        */\r
-\r
-    $val = trim($vars['value']);\r
-    if (!empty($val)) {\r
-           if ((substr_count($val, "http://") == 0) && (substr_count($val, "https://") == 0)) {\r
-               $val = "http://" . $val;\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The URL to display
+        * 
+        */
+
+    $val = trim($vars['value']);
+    if (!empty($val)) {
+           if ((substr_count($val, "http://") == 0) && (substr_count($val, "https://") == 0)) {
+               $val = "http://" . $val;
            }
            
            if ($vars['is_action'])
@@ -30,8 +30,8 @@
                        if (strpos($val, '?')>0) $sep = "&";
                        $val = "$val{$sep}__elgg_token=$token&__elgg_ts=$ts";
                }
-           \r
-           echo "<a href=\"{$val}\" target=\"_blank\">". htmlentities($val, ENT_QUOTES, 'UTF-8'). "</a>";\r
-    }\r
-\r
+           
+           echo "<a href=\"{$val}\" target=\"_blank\">". htmlentities($val, ENT_QUOTES, 'UTF-8'). "</a>";
+    }
+
 ?>
\ No newline at end of file
index ff54a0b6e5ad41af1625718c1b53c4803a05c61f..2cb001b05da1e0a4fd7d8b09c937c94f6c10bc9a 100644 (file)
@@ -1,11 +1,11 @@
-<div class="contentWrapper<?php\r
-\r
-       if (isset($vars['subclass'])) echo ' ' . $vars['subclass'];\r
-\r
-?>">\r
-<?php\r
-\r
-       echo $vars['body'];\r
-\r
-?>\r
+<div class="contentWrapper<?php
+
+       if (isset($vars['subclass'])) echo ' ' . $vars['subclass'];
+
+?>">
+<?php
+
+       echo $vars['body'];
+
+?>
 </div>
\ No newline at end of file
index 904378ef490a8d9eb72931e8bae273dcfa932068..2786a720e460c427ff8e9a3239f1ab7ad967df18 100644 (file)
@@ -1,25 +1,25 @@
-<?php\r
-\r
-       /**\r
-        * Elgg header contents\r
-        * This file holds the header output that a user will see\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg header contents
+        * This file holds the header output that a user will see
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        **/\r
-        \r
-?>\r
-\r
-<div id="page_container">\r
-<div id="page_wrapper">\r
-\r
-<div id="layout_header">\r
-<div id="wrapper_header">\r
-       <!-- display the page title -->\r
-       <h1><a href="<?php echo $vars['url']; ?>"><?php echo $vars['config']->sitename; ?></a></h1>\r
-</div><!-- /#wrapper_header -->\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        **/
+        
+?>
+
+<div id="page_container">
+<div id="page_wrapper">
+
+<div id="layout_header">
+<div id="wrapper_header">
+       <!-- display the page title -->
+       <h1><a href="<?php echo $vars['url']; ?>"><?php echo $vars['config']->sitename; ?></a></h1>
+</div><!-- /#wrapper_header -->
 </div><!-- /#layout_header -->
\ No newline at end of file
index 8296f2e5ea12abdc732bab6118ee488f1c7ae21d..535d1b064b3a2a1feedb60471003b0f3ef7c00d7 100644 (file)
-<?php\r
-\r
-       /**\r
-        * Elgg owner block\r
-        * Displays page ownership information\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg owner block
+        * Displays page ownership information
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        */
+
+               $contents = "";
+
+       // Is there a page owner?
+               $owner = page_owner_entity();
+               // if (!$owner && isloggedin()) $owner = $_SESSION['user'];
+               if ($owner instanceof ElggEntity) {
+                       $icon = elgg_view("profile/icon",array('entity' => $owner, 'size' => 'tiny'));
+                       if ($owner instanceof ElggUser || $owner instanceof ElggGroup) {
+                               //$info = $owner->name;
+                               $info = '<a href="' . $owner->getURL() . '">' . $owner->name . '</a>';
+                       }
+                       $display = "<div id=\"owner_block_icon\">" . $icon . "</div>";
+                       $display .= "<div id=\"owner_block_content\">" . $info . "</div><div class=\"clearfloat ownerblockline\"></div>";
+                       
+                       if ($owner->briefdescription) {
+                           $desc = $owner->briefdescription;
+                           $display .= "<div id=\"owner_block_desc\">" . $desc . "</div>";
+                   }
+                   
+                   $contents .= $display;
+               }
+               
+       // Are there feeds to display?
+               global $autofeed;
+               
+               if (isset($autofeed) && $autofeed == true) {
+                       $url = $url2 = full_url();
+                       if (substr_count($url,'?')) {
+                               $url .= "&view=rss";
+                       } else {
+                               $url .= "?view=rss";
+                       }
+                       //if (substr_count($url2,'?')) {
+                       //      $url2 .= "&view=odd";
+                       //} else {
+                       //      $url2 .= "?view=opendd";
+                       //}
+                       $label = elgg_echo('feed:rss');
+                       //$label2 = elgg_echo('feed:odd');
+                       $contents .= <<<END
+
+       <div id="owner_block_rss_feed"><a href="{$url}" rel="nofollow">{$label}</a></div>
+                       
+END;
+               }
+               
+               //the follow are for logged in users only
+               if(isloggedin()){
+               
+               //is the bookmark plugin installed?
+               if(is_plugin_enabled('bookmarks')){
+    
+                       $label3 = elgg_echo('bookmarks:this');
+                       $contents .= "<div id=\"owner_block_bookmark_this\"><a href=\"javascript:location.href='". $CONFIG->wwwroot . "mod/bookmarks/add.php?address='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)\">{$label3}</a></div>";
+    
+               }
+    
+               //report this button
+               if (is_plugin_enabled('reportedcontent'))
+               {
+                       $label4 = elgg_echo('reportedcontent:report');
+                       $contents .= "<div id=\"owner_block_report_this\"><a href=\"javascript:location.href='". $CONFIG->wwwroot . "mod/reportedcontent/add.php?address='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)\">{$label4}</a></div>";
+               }
+
+           }
+
+               
+               $contents .= elgg_view('owner_block/extend');
+               
+       // Have we been asked to inject any content? If so, display it
+               if (isset($vars['content']))
+                       $contents .= $vars['content'];
+               
+       // Initialise the submenu
+               $submenu = get_submenu(); // elgg_view('canvas_header/submenu');
+               if (!empty($submenu))
+                       $contents .= "<div id=\"owner_block_submenu\">" . $submenu . "</div>"; // plugins can extend this to add menu options
+                       
+               if (!empty($contents)) {
+                       echo "<div id=\"owner_block\">";
+                       echo $contents;
+                       echo "</div><div id=\"owner_block_bottom\"></div>";
+               }
 
-        * @link http://elgg.org/\r
-        * \r
-        */\r
-\r
-               $contents = "";\r
-\r
-       // Is there a page owner?\r
-               $owner = page_owner_entity();\r
-               // if (!$owner && isloggedin()) $owner = $_SESSION['user'];\r
-               if ($owner instanceof ElggEntity) {\r
-                       $icon = elgg_view("profile/icon",array('entity' => $owner, 'size' => 'tiny'));\r
-                       if ($owner instanceof ElggUser || $owner instanceof ElggGroup) {\r
-                               //$info = $owner->name;\r
-                               $info = '<a href="' . $owner->getURL() . '">' . $owner->name . '</a>';\r
-                       }\r
-                       $display = "<div id=\"owner_block_icon\">" . $icon . "</div>";\r
-                       $display .= "<div id=\"owner_block_content\">" . $info . "</div><div class=\"clearfloat ownerblockline\"></div>";\r
-                       \r
-                       if ($owner->briefdescription) {\r
-                           $desc = $owner->briefdescription;\r
-                           $display .= "<div id=\"owner_block_desc\">" . $desc . "</div>";\r
-                   }\r
-                   \r
-                   $contents .= $display;\r
-               }\r
-               \r
-       // Are there feeds to display?\r
-               global $autofeed;\r
-               \r
-               if (isset($autofeed) && $autofeed == true) {\r
-                       $url = $url2 = full_url();\r
-                       if (substr_count($url,'?')) {\r
-                               $url .= "&view=rss";\r
-                       } else {\r
-                               $url .= "?view=rss";\r
-                       }\r
-                       //if (substr_count($url2,'?')) {\r
-                       //      $url2 .= "&view=odd";\r
-                       //} else {\r
-                       //      $url2 .= "?view=opendd";\r
-                       //}\r
-                       $label = elgg_echo('feed:rss');\r
-                       //$label2 = elgg_echo('feed:odd');\r
-                       $contents .= <<<END\r
-\r
-       <div id="owner_block_rss_feed"><a href="{$url}" rel="nofollow">{$label}</a></div>\r
-                       \r
-END;\r
-               }\r
-               \r
-               //the follow are for logged in users only\r
-               if(isloggedin()){\r
-               \r
-               //is the bookmark plugin installed?\r
-               if(is_plugin_enabled('bookmarks')){\r
-    \r
-                       $label3 = elgg_echo('bookmarks:this');\r
-                       $contents .= "<div id=\"owner_block_bookmark_this\"><a href=\"javascript:location.href='". $CONFIG->wwwroot . "mod/bookmarks/add.php?address='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)\">{$label3}</a></div>";\r
-    \r
-               }\r
-    \r
-               //report this button\r
-               if (is_plugin_enabled('reportedcontent'))\r
-               {\r
-                       $label4 = elgg_echo('reportedcontent:report');\r
-                       $contents .= "<div id=\"owner_block_report_this\"><a href=\"javascript:location.href='". $CONFIG->wwwroot . "mod/reportedcontent/add.php?address='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)\">{$label4}</a></div>";\r
-               }\r
-\r
-           }\r
-\r
-               \r
-               $contents .= elgg_view('owner_block/extend');\r
-               \r
-       // Have we been asked to inject any content? If so, display it\r
-               if (isset($vars['content']))\r
-                       $contents .= $vars['content'];\r
-               \r
-       // Initialise the submenu\r
-               $submenu = get_submenu(); // elgg_view('canvas_header/submenu');\r
-               if (!empty($submenu))\r
-                       $contents .= "<div id=\"owner_block_submenu\">" . $submenu . "</div>"; // plugins can extend this to add menu options\r
-                       \r
-               if (!empty($contents)) {\r
-                       echo "<div id=\"owner_block\">";\r
-                       echo $contents;\r
-                       echo "</div><div id=\"owner_block_bottom\"></div>";\r
-               }\r
-\r
 ?>
\ No newline at end of file
index f529aac3f19f0306d7a7619c868b2d6cf14fa9b8..7bbac004462215623f70e17381c5de772a6683af 100644 (file)
@@ -1,51 +1,51 @@
-\r
-<div class="river_item_list">\r
-<?php\r
-\r
-       if (isset($vars['items']) && is_array($vars['items'])) {\r
-               \r
-               $i = 0;\r
-               if (!empty($vars['items']))\r
-               foreach($vars['items'] as $item) {\r
-                       \r
-                       echo elgg_view_river_item($item);\r
-                       $i++;\r
-                       if ($i >= $vars['limit']) break;\r
-                       \r
-               }\r
-               \r
-       }\r
-       \r
-       if ($vars['pagination'] !== false) {\r
-       \r
-               $baseurl = $_SERVER['REQUEST_URI'];\r
-               $baseurl = $baseurl = preg_replace('/[\&\?]offset\=[0-9]*/',"",$baseurl); \r
-               \r
-               $nav = '';\r
-               \r
-               if (sizeof($vars['items']) > $vars['limit']) {\r
-                       $newoffset = $vars['offset'] + $vars['limit'];\r
-                       $urladdition = 'offset='.$newoffset;\r
-                       if (substr_count($baseurl,'?')) $nexturl=$baseurl . '&' . $urladdition; else $nexturl=$baseurl . '?' . $urladdition;\r
-                       \r
-                       $nav .= '<a class="back" href="'.$nexturl.'">&laquo; ' . elgg_echo('previous') . '</a> ';\r
-               }\r
-                       \r
-               if ($vars['offset'] > 0) {\r
-                       $newoffset = $vars['offset'] - $vars['limit'];\r
-                       if ($newoffset < 0) $newoffset = 0;\r
-                       $urladdition = 'offset='.$newoffset;\r
-                       if (substr_count($baseurl,'?')) $prevurl=$baseurl . '&' . $urladdition; else $prevurl=$baseurl . '?' . $urladdition;\r
-                       \r
-                       $nav .= '<a class="forward" href="'.$prevurl.'">' . elgg_echo('next') . ' &raquo;</a> ';\r
-               }\r
-        \r
-               \r
-               if (!empty($nav)) {\r
-                       echo '<div class="river_pagination"><p>'.$nav.'</p><div class="clearfloat"></div></div>';\r
-               }\r
-       \r
-       }\r
-\r
-?>\r
+
+<div class="river_item_list">
+<?php
+
+       if (isset($vars['items']) && is_array($vars['items'])) {
+               
+               $i = 0;
+               if (!empty($vars['items']))
+               foreach($vars['items'] as $item) {
+                       
+                       echo elgg_view_river_item($item);
+                       $i++;
+                       if ($i >= $vars['limit']) break;
+                       
+               }
+               
+       }
+       
+       if ($vars['pagination'] !== false) {
+       
+               $baseurl = $_SERVER['REQUEST_URI'];
+               $baseurl = $baseurl = preg_replace('/[\&\?]offset\=[0-9]*/',"",$baseurl); 
+               
+               $nav = '';
+               
+               if (sizeof($vars['items']) > $vars['limit']) {
+                       $newoffset = $vars['offset'] + $vars['limit'];
+                       $urladdition = 'offset='.$newoffset;
+                       if (substr_count($baseurl,'?')) $nexturl=$baseurl . '&' . $urladdition; else $nexturl=$baseurl . '?' . $urladdition;
+                       
+                       $nav .= '<a class="back" href="'.$nexturl.'">&laquo; ' . elgg_echo('previous') . '</a> ';
+               }
+                       
+               if ($vars['offset'] > 0) {
+                       $newoffset = $vars['offset'] - $vars['limit'];
+                       if ($newoffset < 0) $newoffset = 0;
+                       $urladdition = 'offset='.$newoffset;
+                       if (substr_count($baseurl,'?')) $prevurl=$baseurl . '&' . $urladdition; else $prevurl=$baseurl . '?' . $urladdition;
+                       
+                       $nav .= '<a class="forward" href="'.$prevurl.'">' . elgg_echo('next') . ' &raquo;</a> ';
+               }
+        
+               
+               if (!empty($nav)) {
+                       echo '<div class="river_pagination"><p>'.$nav.'</p><div class="clearfloat"></div></div>';
+               }
+       
+       }
+
+?>
 </div>
\ No newline at end of file
index 47c177ea42f3e58feb35123a2c11f230bfa64fa8..96958170bef3e14b6a1812acf8ec9f10fb75818c 100644 (file)
@@ -1,5 +1,5 @@
-<?php\r
-\r
-       echo elgg_echo('river:noaccess');\r
-\r
+<?php
+
+       echo elgg_echo('river:noaccess');
+
 ?>
\ No newline at end of file
index 457e25abec34f1e84db53e2239bf175ff0e5a0e0..2b146c3c5c552ecf61055fdb4e0ceabe83002681 100644 (file)
@@ -1,40 +1,40 @@
-<?php\r
-\r
-       /**\r
-        * Elgg river item wrapper.\r
-        * Wraps all river items.\r
-        * \r
-        * @package Elgg\r
+<?php
 
-        * @author Curverider\r
+       /**
+        * Elgg river item wrapper.
+        * Wraps all river items.
+        * 
+        * @package Elgg
 
-        * @link http://elgg.com/\r
-        */\r
-\r
-\r
-?>\r
-\r
-       <div class="river_item">\r
-               <div class="river_<?php echo $vars['item']->type; ?>">\r
-                       <div class="river_<?php echo $vars['item']->subtype; ?>">\r
-                               <div class="river_<?php echo $vars['item']->action_type; ?>">                           \r
-                                       <div class="river_<?php echo $vars['item']->type; ?>_<?php if($vars['item']->subtype) echo $vars['item']->subtype . "_"; ?><?php echo $vars['item']->action_type; ?>">\r
-                                       <p>\r
-                                               <?php\r
-               \r
-                                                               echo $vars['body'];\r
-                               \r
-                                               ?>\r
-                                               <span class="river_item_time">\r
-                                                       (<?php\r
-                               \r
-                                                               echo friendly_time($vars['item']->posted);\r
-                                                       \r
-                                                       ?>)\r
-                                               </span>\r
-                                       </p>\r
-                                       </div>\r
-                               </div>                          \r
-                       </div>\r
-               </div>\r
+        * @author Curverider
+
+        * @link http://elgg.com/
+        */
+
+
+?>
+
+       <div class="river_item">
+               <div class="river_<?php echo $vars['item']->type; ?>">
+                       <div class="river_<?php echo $vars['item']->subtype; ?>">
+                               <div class="river_<?php echo $vars['item']->action_type; ?>">                           
+                                       <div class="river_<?php echo $vars['item']->type; ?>_<?php if($vars['item']->subtype) echo $vars['item']->subtype . "_"; ?><?php echo $vars['item']->action_type; ?>">
+                                       <p>
+                                               <?php
+               
+                                                               echo $vars['body'];
+                               
+                                               ?>
+                                               <span class="river_item_time">
+                                                       (<?php
+                               
+                                                               echo friendly_time($vars['item']->posted);
+                                                       
+                                                       ?>)
+                                               </span>
+                                       </p>
+                                       </div>
+                               </div>                          
+                       </div>
+               </div>
        </div>
\ No newline at end of file
index 23dd508fd0d8ce210eceee6f7972f60fbea6fe7e..cba00ff5aa67acee24c905eccf243850e6b06167 100644 (file)
@@ -1,15 +1,15 @@
-<?php\r
-\r
-       /**\r
-        * Elgg river item wrapper.\r
-        * Wraps all river items.\r
-        * \r
-        * @package Elgg\r
+<?php
 
-        * @author Curverider\r
+       /**
+        * Elgg river item wrapper.
+        * Wraps all river items.
+        * 
+        * @package Elgg
 
-        * @link http://elgg.com/\r
-        */\r
+        * @author Curverider
+
+        * @link http://elgg.com/
+        */
 
        $statement = $vars['statement'];
        $time = $vars['time'];
index 6a3e075d95e98a50b228767785d2f3c20c5a85a6..2bf632c6ad32694e0281f73d0528b4da6e61a857 100644 (file)
@@ -1,19 +1,19 @@
-<?php\r
-\r
-       /**\r
-        * Elgg system settings on initial installation\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg system settings on initial installation
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        */
+
+       echo "<p>" . autop(elgg_echo("installation:settings:description")) . "</p>";
+
+       echo elgg_view("settings/system",array("action" => "action/systemsettings/install"));
 
-        * @link http://elgg.org/\r
-        * \r
-        */\r
-\r
-       echo "<p>" . autop(elgg_echo("installation:settings:description")) . "</p>";\r
-\r
-       echo elgg_view("settings/system",array("action" => "action/systemsettings/install"));\r
-\r
 ?>
\ No newline at end of file
index 91c8e11aacae9b214259b2f10d3f73e13224fc3b..521415eddee32f0401ecec3798d93e684e022795 100644 (file)
@@ -1,72 +1,72 @@
-<?php\r
-\r
-       /**\r
-        * Elgg system settings form\r
-        * The form to change system settings\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg system settings form
+        * The form to change system settings
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['action'] If set, the place to forward the form to (usually action/systemsettings/save)\r
-        */\r
-\r
-       // Set action appropriately\r
-               if (!isset($vars['action'])) {\r
-                       $action = $vars['url'] . "action/systemsettings/save";\r
-               } else {\r
-                       $action = $vars['action'];\r
-               }\r
-               \r
-               $form_body = "";\r
-               foreach(array('sitename','sitedescription', 'siteemail', 'wwwroot','path','dataroot', 'view') as $field) {\r
-                       $form_body .= "<p>";\r
-                       $form_body .= elgg_echo('installation:' . $field) . "<br />";\r
-                       $warning = elgg_echo('installation:warning:' . $field);\r
-                       if ($warning != 'installation:warning:' . $field) echo "<b>" . $warning . "</b><br />";\r
-                       $value = $vars['config']->$field;\r
-                       $form_body .= elgg_view("input/text",array('internalname' => $field, 'value' => $value));\r
-                       $form_body .= "</p>";\r
-               }\r
-               \r
-               $languages = get_installed_translations();\r
-               $form_body .= "<p>" . elgg_echo('installation:language') . elgg_view("input/pulldown", array('internalname' => 'language', 'value' => $vars['config']->language, 'options_values' => $languages)) . "</p>";\r
-               \r
-               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('admin:site:access:warning') . "<br />";\r
-               $form_body .= elgg_echo('installation:sitepermissions') . elgg_view('input/access', array('internalname' => 'default_access','value' => $vars['config']->default_access)) . "</p>";\r
-               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:allow_user_default_access:description') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:allow_user_default_access:label')), 'internalname' => 'allow_user_default_access', 'value' => ($vars['config']->allow_user_default_access ? elgg_echo('installation:allow_user_default_access:label') : "") )) . "</p>";\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['action'] If set, the place to forward the form to (usually action/systemsettings/save)
+        */
+
+       // Set action appropriately
+               if (!isset($vars['action'])) {
+                       $action = $vars['url'] . "action/systemsettings/save";
+               } else {
+                       $action = $vars['action'];
+               }
+               
+               $form_body = "";
+               foreach(array('sitename','sitedescription', 'siteemail', 'wwwroot','path','dataroot', 'view') as $field) {
+                       $form_body .= "<p>";
+                       $form_body .= elgg_echo('installation:' . $field) . "<br />";
+                       $warning = elgg_echo('installation:warning:' . $field);
+                       if ($warning != 'installation:warning:' . $field) echo "<b>" . $warning . "</b><br />";
+                       $value = $vars['config']->$field;
+                       $form_body .= elgg_view("input/text",array('internalname' => $field, 'value' => $value));
+                       $form_body .= "</p>";
+               }
+               
+               $languages = get_installed_translations();
+               $form_body .= "<p>" . elgg_echo('installation:language') . elgg_view("input/pulldown", array('internalname' => 'language', 'value' => $vars['config']->language, 'options_values' => $languages)) . "</p>";
+               
+               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('admin:site:access:warning') . "<br />";
+               $form_body .= elgg_echo('installation:sitepermissions') . elgg_view('input/access', array('internalname' => 'default_access','value' => $vars['config']->default_access)) . "</p>";
+               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:allow_user_default_access:description') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:allow_user_default_access:label')), 'internalname' => 'allow_user_default_access', 'value' => ($vars['config']->allow_user_default_access ? elgg_echo('installation:allow_user_default_access:label') : "") )) . "</p>";
                $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:simplecache:description') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:simplecache:label')), 'internalname' => 'simplecache_enabled', 'value' => ($vars['config']->simplecache_enabled ? elgg_echo('installation:simplecache:label') : "") )) . "</p>";
-               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:viewpathcache:description') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:viewpathcache:label')), 'internalname' => 'viewpath_cache_enabled', 'value' => (($vars['config']->viewpath_cache_enabled) ? elgg_echo('installation:viewpathcache:label') : "") )) . "</p>";\r
-               \r
-               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:debug') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:debug:label')), 'internalname' => 'debug', 'value' => ($vars['config']->debug ? elgg_echo('installation:debug:label') : "") )) . "</p>";\r
-               \r
-               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:httpslogin') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:httpslogin:label')), 'internalname' => 'https_login', 'value' => ($vars['config']->https_login ? elgg_echo('installation:httpslogin:label') : "") )) . "</p>";\r
-               \r
-               \r
-               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:disableapi') . "<br />";\r
-               $on = elgg_echo('installation:disableapi:label');\r
-               if ((isset($CONFIG->disable_api)) && ($CONFIG->disable_api == true))\r
-                       $on = ($vars['config']->disable_api ?  "" : elgg_echo('installation:disableapi:label'));\r
-               $form_body .= elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:disableapi:label')), 'internalname' => 'api', 'value' => $on ));\r
-               $form_body .= "</p>";\r
-               \r
-               $form_body .= "<p class=\"admin_usage\">" . elgg_echo('installation:usage') . "<br />";\r
-               $on = elgg_echo('installation:usage:label');\r
-               \r
-               if (isset($CONFIG->ping_home))\r
-                       $on = ($vars['config']->ping_home!='disabled' ? elgg_echo('installation:usage:label') : "");\r
-               $form_body .= elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:usage:label')), 'internalname' => 'usage', 'value' => $on )); \r
-               $form_body .= "</p>";\r
-               \r
-               \r
-               \r
-               $form_body .= elgg_view('input/hidden', array('internalname' => 'settings', 'value' => 'go'));\r
-               \r
-               $form_body .= elgg_view('input/submit', array('value' => elgg_echo("save")));\r
-               \r
-               echo elgg_view('input/form', array('action' => $action, 'body' => $form_body));\r
-               \r
-?>\r
+               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:viewpathcache:description') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:viewpathcache:label')), 'internalname' => 'viewpath_cache_enabled', 'value' => (($vars['config']->viewpath_cache_enabled) ? elgg_echo('installation:viewpathcache:label') : "") )) . "</p>";
+               
+               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:debug') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:debug:label')), 'internalname' => 'debug', 'value' => ($vars['config']->debug ? elgg_echo('installation:debug:label') : "") )) . "</p>";
+               
+               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:httpslogin') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:httpslogin:label')), 'internalname' => 'https_login', 'value' => ($vars['config']->https_login ? elgg_echo('installation:httpslogin:label') : "") )) . "</p>";
+               
+               
+               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:disableapi') . "<br />";
+               $on = elgg_echo('installation:disableapi:label');
+               if ((isset($CONFIG->disable_api)) && ($CONFIG->disable_api == true))
+                       $on = ($vars['config']->disable_api ?  "" : elgg_echo('installation:disableapi:label'));
+               $form_body .= elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:disableapi:label')), 'internalname' => 'api', 'value' => $on ));
+               $form_body .= "</p>";
+               
+               $form_body .= "<p class=\"admin_usage\">" . elgg_echo('installation:usage') . "<br />";
+               $on = elgg_echo('installation:usage:label');
+               
+               if (isset($CONFIG->ping_home))
+                       $on = ($vars['config']->ping_home!='disabled' ? elgg_echo('installation:usage:label') : "");
+               $form_body .= elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:usage:label')), 'internalname' => 'usage', 'value' => $on )); 
+               $form_body .= "</p>";
+               
+               
+               
+               $form_body .= elgg_view('input/hidden', array('internalname' => 'settings', 'value' => 'go'));
+               
+               $form_body .= elgg_view('input/submit', array('value' => elgg_echo("save")));
+               
+               echo elgg_view('input/form', array('action' => $action, 'body' => $form_body));
+               
+?>
index 82905af8a7d97f443c6bc0fd952547021ed792e2..e36d731a7a3e6818fa2b7dcdc0109e37f6d6969a 100644 (file)
@@ -1,19 +1,19 @@
-<?php\r
-\r
-?>\r
-\r
-<html>\r
-       <head>\r
-               <title><?php echo elgg_echo('upgrading'); ?></title>\r
-               <meta http-equiv="refresh" content="1;url=<?php echo $vars['url']; ?>upgrade.php?upgrade=upgrade"/>\r
-       </head>\r
-       <body bgcolor="white">\r
-               <table width="100%" height="100%" border="0" style="margin: 0px; padding: 0px">\r
-                       <tr>\r
-                               <td width="100%" height="100%" valign="middle" align="center">\r
-                                       <img src="<?php echo $vars['url']; ?>_graphics/ajax_loader.gif" />\r
-                               </td>\r
-                       </tr>\r
-               </table>\r
-       </body>\r
+<?php
+
+?>
+
+<html>
+       <head>
+               <title><?php echo elgg_echo('upgrading'); ?></title>
+               <meta http-equiv="refresh" content="1;url=<?php echo $vars['url']; ?>upgrade.php?upgrade=upgrade"/>
+       </head>
+       <body bgcolor="white">
+               <table width="100%" height="100%" border="0" style="margin: 0px; padding: 0px">
+                       <tr>
+                               <td width="100%" height="100%" valign="middle" align="center">
+                                       <img src="<?php echo $vars['url']; ?>_graphics/ajax_loader.gif" />
+                               </td>
+                       </tr>
+               </table>
+       </body>
 </html>
\ No newline at end of file
index d228400a4d7ae8545fa2ace65f299d70cab5b51e..6870453a4edbdf3c4264e30e6118ea59890ae22f 100644 (file)
@@ -1,39 +1,39 @@
-<?php\r
-\r
-       /**\r
-        * Elgg default spotlight\r
-        * The spotlight area that displays across the site\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg default spotlight
+        * The spotlight area that displays across the site
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        */\r
-?>\r
-\r
-<div id="spotlight_table">\r
-       <!-- spotlight RHS content -->\r
-       <div class="spotlightRHS">\r
-               <h2>Information</h2>                    \r
-               <ul>\r
-                       <li><a href="http://docs.elgg.org/wiki/Views/SystemViews">Populating this spotlight area</a></li>\r
-                       <li><a href="http://community.elgg.org">Elgg open source community</a></li>\r
-                       <li><a href="http://elgg.com">Elgg commercial services</a></li>\r
-               </ul>\r
-       </div>\r
-       <!-- spotlight LHS content -->\r
-       <div class="spotlightLHS">\r
-               <h2>Welcome to Elgg</h2>\r
-               <p>\r
-                       Elgg allows you to run your own social networking site, whether publicly (like \r
-                       Facebook) or privately within your company or organization.\r
-                       <a href="http://elgg.com/">Support and commercial services</a> are available,\r
-                       or you can find new tools for your Elgg site at the\r
-                       <a href="http://community.elgg.org/">Elgg community</a>.  \r
-               </p> \r
-       </div><!-- /spotlight LHS content -->\r
-       <div class="clearfloat"></div>\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        */
+?>
+
+<div id="spotlight_table">
+       <!-- spotlight RHS content -->
+       <div class="spotlightRHS">
+               <h2>Information</h2>                    
+               <ul>
+                       <li><a href="http://docs.elgg.org/wiki/Views/SystemViews">Populating this spotlight area</a></li>
+                       <li><a href="http://community.elgg.org">Elgg open source community</a></li>
+                       <li><a href="http://elgg.com">Elgg commercial services</a></li>
+               </ul>
+       </div>
+       <!-- spotlight LHS content -->
+       <div class="spotlightLHS">
+               <h2>Welcome to Elgg</h2>
+               <p>
+                       Elgg allows you to run your own social networking site, whether publicly (like 
+                       Facebook) or privately within your company or organization.
+                       <a href="http://elgg.com/">Support and commercial services</a> are available,
+                       or you can find new tools for your Elgg site at the
+                       <a href="http://community.elgg.org/">Elgg community</a>.  
+               </p> 
+       </div><!-- /spotlight LHS content -->
+       <div class="clearfloat"></div>
 </div>
\ No newline at end of file
index 20504e9a4a65b7d2c3b7ff6ff3fc1e56981cb3c3..24372cb0a5f8d42695d90ceb278ba749f66ae4d1 100644 (file)
@@ -1,17 +1,17 @@
-<?php\r
-\r
-       /**\r
-        * Elgg basic about page\r
-        * The standard HTML about page\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg basic about page
+        * The standard HTML about page
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        *
+        */
+?>
 
-        * @link http://elgg.org/\r
-        *\r
-        */\r
-?>\r
-\r
 <!-- still to do -->
\ No newline at end of file
index aeca248b3acb060a3e53da1426c32d69adb01512..40820b56072ca2052a5fffd34e449c425aa2e543 100644 (file)
@@ -1,15 +1,15 @@
-<?php\r
-\r
-       /**\r
-        * Elgg basic privacy page\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        *\r
-        */\r
-?>\r
-\r
+<?php
+
+       /**
+        * Elgg basic privacy page
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        *
+        */
+?>
+
index 74be5a64b4b7d0c1f45f414270b415e67b790fa6..aa1d1232203e488effc476919728e3be130ff13c 100644 (file)
@@ -1,14 +1,14 @@
-<?php\r
-\r
-       /**\r
-        * Elgg basic tos page\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg basic tos page
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        *\r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        *
+        */
 ?>
\ No newline at end of file
index c6208a8a56c79f625a7c538830180dc7f29781c9..dd0938cc230479093e05db3e18dce2a5cd45a211 100644 (file)
-<input type="hidden" name="number_of_files" value="1">\r
-<?php\r
-\r
-if (isset($vars['entity'])) {\r
-       $title = $vars['entity']->title;\r
-       $description = $vars['entity']->description;\r
-       $tags = $vars['entity']->tags;\r
-       $access_id = $vars['entity']->access_id;\r
-} else  {\r
-       $title = "";\r
-       $description = "";\r
-       $tags = "";\r
-       $access_id = get_default_access();\r
-}\r
-\r
-$plugin = $vars['plugin'];\r
-\r
-if (!$vars['entity']) {\r
-\r
-?>\r
-       <div id="option_container">\r
-               <p>\r
-                       <label><?php echo elgg_echo("title"); ?><br />\r
-                       <?php\r
-\r
-                               echo elgg_view("input/text", array(\r
-                                                                       "internalname" => "title_0"\r
-                                                                                                       ));\r
-                       \r
-                       ?>\r
-                       </label>\r
-               </p>\r
-               <p>\r
-                       <label><?php echo elgg_echo("$plugin:file"); ?><br />\r
-                       <?php\r
-\r
-                               echo elgg_view("input/file",array('internalname' => 'upload_0'));\r
-                       \r
-                       ?>\r
-                       </label>\r
-               </p>\r
-               </div>\r
-               <p><input type="button" onclick="javascript:file_addtoform()" value="<?php echo elgg_echo("$plugin:add_to_form"); ?>"></p>\r
-<?php\r
-       } else {\r
-\r
-?>\r
-               <p>\r
-                       <label><?php echo elgg_echo("title"); ?><br />\r
-                       <?php\r
-\r
-                               echo elgg_view("input/text", array(\r
-                                                                       "internalname" => "title",\r
-                                                                       "value" => $title,\r
-                                                                                                       ));\r
-                       \r
-                       ?>\r
-                       </label>\r
-               </p>\r
-<?php\r
-       }\r
-?>\r
-               <p class="longtext_editarea">\r
-                       <label><?php echo elgg_echo("description"); ?><br />\r
-                       <?php\r
-\r
-                               echo elgg_view("input/longtext",array(\r
-                                                                       "internalname" => "description",\r
-                                                                       "value" => $description,\r
-                                                                                                       ));\r
-                       ?>\r
-                       </label>\r
-               </p>\r
-               <br />\r
-               <p>\r
-                       <label><?php echo elgg_echo("tags"); ?><br />\r
-                       <?php\r
-\r
-                               echo elgg_view("input/tags", array(\r
-                                                                       "internalname" => "tags",\r
-                                                                       "value" => $tags,\r
-                                                                                                       ));\r
-                       \r
-                       ?>\r
-               </label></p>\r
-<?php\r
-\r
-               $categories = elgg_view('categories',$vars);\r
-               if (!empty($categories)) {\r
-?>\r
-\r
-               <p>\r
-                       <?php echo $categories; ?>\r
-               </p>\r
-\r
-<?php\r
-               }\r
-               //remove folders until they are ready to use\r
-               //echo elgg_view("$plugin/folders/select",$vars);\r
-?>\r
-               <p>\r
-                       <label>\r
-                               <?php echo elgg_echo('access'); ?><br />\r
-                               <?php echo elgg_view('input/access', array('internalname' => 'access_id','value' => $access_id)); ?>\r
-                       </label>\r
-               </p>\r
-       \r
-<?php\r
-\r
-       if (isset($vars['container_guid']))\r
-               echo "<input type=\"hidden\" name=\"container_guid\" value=\"{$vars['container_guid']}\" />";\r
-       if (isset($vars['entity']))\r
-               echo "<input type=\"hidden\" name=\"file_guid\" value=\"{$vars['entity']->getGUID()}\" />";\r
-\r
-?>\r
+<input type="hidden" name="number_of_files" value="1">
+<?php
+
+if (isset($vars['entity'])) {
+       $title = $vars['entity']->title;
+       $description = $vars['entity']->description;
+       $tags = $vars['entity']->tags;
+       $access_id = $vars['entity']->access_id;
+} else  {
+       $title = "";
+       $description = "";
+       $tags = "";
+       $access_id = get_default_access();
+}
+
+$plugin = $vars['plugin'];
+
+if (!$vars['entity']) {
+
+?>
+       <div id="option_container">
+               <p>
+                       <label><?php echo elgg_echo("title"); ?><br />
+                       <?php
+
+                               echo elgg_view("input/text", array(
+                                                                       "internalname" => "title_0"
+                                                                                                       ));
+                       
+                       ?>
+                       </label>
+               </p>
+               <p>
+                       <label><?php echo elgg_echo("$plugin:file"); ?><br />
+                       <?php
+
+                               echo elgg_view("input/file",array('internalname' => 'upload_0'));
+                       
+                       ?>
+                       </label>
+               </p>
+               </div>
+               <p><input type="button" onclick="javascript:file_addtoform()" value="<?php echo elgg_echo("$plugin:add_to_form"); ?>"></p>
+<?php
+       } else {
+
+?>
+               <p>
+                       <label><?php echo elgg_echo("title"); ?><br />
+                       <?php
+
+                               echo elgg_view("input/text", array(
+                                                                       "internalname" => "title",
+                                                                       "value" => $title,
+                                                                                                       ));
+                       
+                       ?>
+                       </label>
+               </p>
+<?php
+       }
+?>
+               <p class="longtext_editarea">
+                       <label><?php echo elgg_echo("description"); ?><br />
+                       <?php
+
+                               echo elgg_view("input/longtext",array(
+                                                                       "internalname" => "description",
+                                                                       "value" => $description,
+                                                                                                       ));
+                       ?>
+                       </label>
+               </p>
+               <br />
+               <p>
+                       <label><?php echo elgg_echo("tags"); ?><br />
+                       <?php
+
+                               echo elgg_view("input/tags", array(
+                                                                       "internalname" => "tags",
+                                                                       "value" => $tags,
+                                                                                                       ));
+                       
+                       ?>
+               </label></p>
+<?php
+
+               $categories = elgg_view('categories',$vars);
+               if (!empty($categories)) {
+?>
+
+               <p>
+                       <?php echo $categories; ?>
+               </p>
+
+<?php
+               }
+               //remove folders until they are ready to use
+               //echo elgg_view("$plugin/folders/select",$vars);
+?>
+               <p>
+                       <label>
+                               <?php echo elgg_echo('access'); ?><br />
+                               <?php echo elgg_view('input/access', array('internalname' => 'access_id','value' => $access_id)); ?>
+                       </label>
+               </p>
+       
+<?php
+
+       if (isset($vars['container_guid']))
+               echo "<input type=\"hidden\" name=\"container_guid\" value=\"{$vars['container_guid']}\" />";
+       if (isset($vars['entity']))
+               echo "<input type=\"hidden\" name=\"file_guid\" value=\"{$vars['entity']->getGUID()}\" />";
+
+?>
index 58b5ede8ac73e5cf0968c3092a58e6b31c58a14e..0e83b5fb0e691b34133ac522a8604074192dc4ff 100644 (file)
@@ -1,23 +1,23 @@
-<?php\r
-\r
-       /**\r
-        * Elgg user display\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
+       /**
+        * Elgg user display
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-               if ($vars['full']) {\r
-                       echo elgg_view("profile/userdetails",$vars);\r
-               } else {\r
-                       if (get_input('search_viewtype') == "gallery") {\r
-                               echo elgg_view('profile/gallery',$vars);                                \r
-                       } else {\r
-                               echo elgg_view("profile/listing",$vars);\r
-                       }\r
-               }\r
-       \r
+
+        * @link http://elgg.org/
+        */
+
+               if ($vars['full']) {
+                       echo elgg_view("profile/userdetails",$vars);
+               } else {
+                       if (get_input('search_viewtype') == "gallery") {
+                               echo elgg_view('profile/gallery',$vars);                                
+                       } else {
+                               echo elgg_view("profile/listing",$vars);
+                       }
+               }
+       
 ?>
\ No newline at end of file
index 38b194d7dc498c10c3a5b1df15bdea5aad282e4b..d5df5e426018eb7a9aae795e3c2bdcb50a77bcad 100644 (file)
@@ -1,30 +1,30 @@
-<?php\r
-       /**\r
-        * Provide a way of setting your default access\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Provide a way of setting your default access
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+       if ($vars['config']->allow_user_default_access) {
+               $user = page_owner_entity();
+               
+               if ($user) {
+                       if (false === ($default_access = $user->getPrivateSetting('elgg_default_access'))) {
+                               $default_access = $vars['config']->default_access;
+                       }
+       ?>
+               <h3><?php echo elgg_echo('default_access:settings'); ?></h3>
+               <p>
+                       <?php echo elgg_echo('default_access:label'); ?>:
+                       <?php
+       
+                               echo elgg_view('input/access',array('internalname' => 'default_access', 'value' => $default_access));
+                       
+                       ?> 
+               </p>
 
-        * @link http://elgg.org/\r
-        */\r
-       if ($vars['config']->allow_user_default_access) {\r
-               $user = page_owner_entity();\r
-               \r
-               if ($user) {\r
-                       if (false === ($default_access = $user->getPrivateSetting('elgg_default_access'))) {\r
-                               $default_access = $vars['config']->default_access;\r
-                       }\r
-       ?>\r
-               <h3><?php echo elgg_echo('default_access:settings'); ?></h3>\r
-               <p>\r
-                       <?php echo elgg_echo('default_access:label'); ?>:\r
-                       <?php\r
-       \r
-                               echo elgg_view('input/access',array('internalname' => 'default_access', 'value' => $default_access));\r
-                       \r
-                       ?> \r
-               </p>\r
-\r
 <?php }} ?>
\ No newline at end of file
index 8a9d986d984ff0a294c70682cd6aec7f7d01f049..60f2f7acd99c8f723646c58f13978d8cdd8a66e6 100644 (file)
@@ -1,27 +1,27 @@
-<?php\r
-       /**\r
-        * Provide a way of setting your email\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Provide a way of setting your email
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       $user = page_owner_entity();
+       
+       if ($user) {
+?>
+       <h3><?php echo elgg_echo('email:settings'); ?></h3>
+       <p>
+               <?php echo elgg_echo('email:address:label'); ?>:
+               <?php
+
+                       echo elgg_view('input/email',array('internalname' => 'email', 'value' => $user->email));
+               
+               ?> 
+       </p>
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       $user = page_owner_entity();\r
-       \r
-       if ($user) {\r
-?>\r
-       <h3><?php echo elgg_echo('email:settings'); ?></h3>\r
-       <p>\r
-               <?php echo elgg_echo('email:address:label'); ?>:\r
-               <?php\r
-\r
-                       echo elgg_view('input/email',array('internalname' => 'email', 'value' => $user->email));\r
-               \r
-               ?> \r
-       </p>\r
-\r
 <?php } ?>
\ No newline at end of file
index f127532d6b46d8fc3617c607c2892f0c59bdf2e4..56f6139e7b52378dd45ecb702cebb336b0bf6218 100644 (file)
@@ -1,27 +1,27 @@
-<?php\r
-       /**\r
-        * Provide a way of setting your full name.\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Provide a way of setting your full name.
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       $user = page_owner_entity();
+       
+       if ($user) {
+?>
+       <h3><?php echo elgg_echo('user:set:name'); ?></h3>
+       <p>
+               <?php echo elgg_echo('user:name:label'); ?>:
+               <?php
+
+                       echo elgg_view('input/text',array('internalname' => 'name', 'value' => $user->name));
+                       echo elgg_view('input/hidden',array('internalname' => 'guid', 'value' => $user->guid));
+               ?> 
+       </p>
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       $user = page_owner_entity();\r
-       \r
-       if ($user) {\r
-?>\r
-       <h3><?php echo elgg_echo('user:set:name'); ?></h3>\r
-       <p>\r
-               <?php echo elgg_echo('user:name:label'); ?>:\r
-               <?php\r
-\r
-                       echo elgg_view('input/text',array('internalname' => 'name', 'value' => $user->name));\r
-                       echo elgg_view('input/hidden',array('internalname' => 'guid', 'value' => $user->guid));\r
-               ?> \r
-       </p>\r
-\r
 <?php } ?>
\ No newline at end of file
index d467cd05e06a0f03bedddc5b3a8ab967161894a1..d2b794808dce4bd871d91f65ec2fda64e28be280 100644 (file)
@@ -1,28 +1,28 @@
-<?php\r
-       /**\r
-        * Provide a way of setting your password\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Provide a way of setting your password
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       $user = page_owner_entity();
+       
+       if ($user) {
+?>
+       <h3><?php echo elgg_echo('user:set:password'); ?></h3>
+       <p>
+               <?php echo elgg_echo('user:password:label'); ?>: 
+               <?php
+                       echo elgg_view('input/password',array('internalname' => 'password'));
+               ?></p><p>
+               <?php echo elgg_echo('user:password2:label'); ?>: <?php
+                       echo elgg_view('input/password',array('internalname' => 'password2'));
+               ?>
+       </p>
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       $user = page_owner_entity();\r
-       \r
-       if ($user) {\r
-?>\r
-       <h3><?php echo elgg_echo('user:set:password'); ?></h3>\r
-       <p>\r
-               <?php echo elgg_echo('user:password:label'); ?>: \r
-               <?php\r
-                       echo elgg_view('input/password',array('internalname' => 'password'));\r
-               ?></p><p>\r
-               <?php echo elgg_echo('user:password2:label'); ?>: <?php\r
-                       echo elgg_view('input/password',array('internalname' => 'password2'));\r
-               ?>\r
-       </p>\r
-\r
 <?php } ?>
\ No newline at end of file
index ce048b7bbc42d932b2fb982af0340f751c0b6f9d..ffc6b32807ad2176150bb16beb75288e0d6cae12 100644 (file)
@@ -1,53 +1,53 @@
-<?php\r
-       /**\r
-        * Elgg statistics screen\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+       /**
+        * Elgg statistics screen
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       \r
-       // Get entity statistics\r
-       $entity_stats = get_entity_statistics($_SESSION['user']->guid);\r
-       \r
-       if ($entity_stats)\r
-       {\r
-?>\r
-<div class="usersettings_statistics">\r
-    <h3><?php echo elgg_echo('usersettings:statistics:label:numentities'); ?></h3>\r
-    <table>\r
-        <?php\r
-            foreach ($entity_stats as $k => $entry)\r
-            {\r
-                foreach ($entry as $a => $b)\r
-                {\r
-                    \r
-                    //This function controls the alternating class\r
-                       $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even';\r
-\r
-                    if ($a == "__base__") {\r
-                        $a = elgg_echo("item:{$k}");\r
-                        if (empty($a))\r
-                               $a = $k;\r
-                       } else {\r
-                               $a = elgg_echo("item:{$k}:{$a}");\r
-                               if (empty($a)) {\r
-                                                               $a = "$k $a";\r
-                               }\r
-                        }\r
-                    echo <<< END\r
-                        <tr class="{$even_odd}">\r
-                            <td class="column_one"><b>{$a}:</b></td>\r
-                            <td>{$b}</td>\r
-                        </tr>\r
-END;\r
-                }\r
-            }\r
-        ?>\r
-    </table>\r
-</div>\r
+        * @link http://elgg.org/
+        */
+
+       
+       // Get entity statistics
+       $entity_stats = get_entity_statistics($_SESSION['user']->guid);
+       
+       if ($entity_stats)
+       {
+?>
+<div class="usersettings_statistics">
+    <h3><?php echo elgg_echo('usersettings:statistics:label:numentities'); ?></h3>
+    <table>
+        <?php
+            foreach ($entity_stats as $k => $entry)
+            {
+                foreach ($entry as $a => $b)
+                {
+                    
+                    //This function controls the alternating class
+                       $even_odd = ( 'odd' != $even_odd ) ? 'odd' : 'even';
+
+                    if ($a == "__base__") {
+                        $a = elgg_echo("item:{$k}");
+                        if (empty($a))
+                               $a = $k;
+                       } else {
+                               $a = elgg_echo("item:{$k}:{$a}");
+                               if (empty($a)) {
+                                                               $a = "$k $a";
+                               }
+                        }
+                    echo <<< END
+                        <tr class="{$even_odd}">
+                            <td class="column_one"><b>{$a}:</b></td>
+                            <td>{$b}</td>
+                        </tr>
+END;
+                }
+            }
+        ?>
+    </table>
+</div>
 <?php } ?>
\ No newline at end of file
index 238b485e988d902953f4539a6b056f5c79a7ecf7..1ae060d49f7a9a3ea96bc2754805b391c5ffe146 100644 (file)
@@ -1,20 +1,20 @@
-<?php\r
-\r
-    /**\r
-        * Elgg sample welcome page\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+    /**
+        * Elgg sample welcome page
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-        \r
-       if (isloggedin()) {\r
-               echo elgg_view("welcome/logged_in");            \r
-       } else {\r
-               echo elgg_view("welcome/logged_out");\r
-       }\r
-        \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+        
+       if (isloggedin()) {
+               echo elgg_view("welcome/logged_in");            
+       } else {
+               echo elgg_view("welcome/logged_out");
+       }
+        
 ?>
\ No newline at end of file
index 45e9354127573d7b86236584d676b8cb09dd46fd..75e96602824453849b852fe9ea1af05654f39605 100644 (file)
@@ -1,46 +1,46 @@
-<?php\r
-\r
-       /**\r
-        * Elgg edit widget layout\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg edit widget layout
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       $guid = $vars['entity']->getGUID();\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       $guid = $vars['entity']->getGUID();
 
        
        $form_body = $vars['body'];
        $form_body .= "<p><label>" . elgg_echo('access') . ": " . elgg_view('input/access', array('internalname' => 'params[access_id]','value' => $vars['entity']->access_id)) . "</label></p>";
-       $form_body .= "<p>" . elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $guid)) . elgg_view('input/hidden', array('internalname' => 'noforward', 'value' => 'true')) . elgg_view('input/submit', array('internalname' => "submit$guid", 'value' => elgg_echo('save'))) . "</p>";\r
+       $form_body .= "<p>" . elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $guid)) . elgg_view('input/hidden', array('internalname' => 'noforward', 'value' => 'true')) . elgg_view('input/submit', array('internalname' => "submit$guid", 'value' => elgg_echo('save'))) . "</p>";
 
        echo elgg_view('input/form', array('internalid' => "widgetform$guid", 'body' => $form_body, 'action' => "{$vars['url']}action/widgets/save"))   
-?>\r
-\r
-\r
-<script type="text/javascript">\r
-$(document).ready(function() {\r
-\r
-       $("#widgetform<?php echo $guid; ?>").submit(function () {\r
-       \r
-               $("#submit<?php echo $guid; ?>").attr("disabled","disabled");\r
-               $("#submit<?php echo $guid; ?>").attr("value","<?php echo elgg_echo("saving"); ?>");\r
-               $("#widgetcontent<?php echo $guid; ?>").html('<?php echo elgg_view('ajax/loader',array('slashes' => true)); ?>');\r
-               $("#widget<?php echo $guid; ?> .toggle_box_edit_panel").click();\r
-       \r
-               var variables = $("#widgetform<?php echo $guid; ?>").serialize();\r
-               $.post($("#widgetform<?php echo $guid; ?>").attr("action"),variables,function() {\r
-                       $("#submit<?php echo $guid; ?>").attr("disabled","");\r
-                       $("#submit<?php echo $guid; ?>").attr("value","<?php echo elgg_echo("save"); ?>");\r
-                       $("#widgetcontent<?php echo $guid; ?>").load("<?php echo $vars['url']; ?>pg/view/<?php echo $guid; ?>?shell=no&username=<?php echo page_owner_entity()->username; ?>&context=<?php echo get_context(); ?>&callback=true");\r
-               });\r
-               return false;\r
-       \r
-       });\r
-\r
-}); \r
+?>
+
+
+<script type="text/javascript">
+$(document).ready(function() {
+
+       $("#widgetform<?php echo $guid; ?>").submit(function () {
+       
+               $("#submit<?php echo $guid; ?>").attr("disabled","disabled");
+               $("#submit<?php echo $guid; ?>").attr("value","<?php echo elgg_echo("saving"); ?>");
+               $("#widgetcontent<?php echo $guid; ?>").html('<?php echo elgg_view('ajax/loader',array('slashes' => true)); ?>');
+               $("#widget<?php echo $guid; ?> .toggle_box_edit_panel").click();
+       
+               var variables = $("#widgetform<?php echo $guid; ?>").serialize();
+               $.post($("#widgetform<?php echo $guid; ?>").attr("action"),variables,function() {
+                       $("#submit<?php echo $guid; ?>").attr("disabled","");
+                       $("#submit<?php echo $guid; ?>").attr("value","<?php echo elgg_echo("save"); ?>");
+                       $("#widgetcontent<?php echo $guid; ?>").load("<?php echo $vars['url']; ?>pg/view/<?php echo $guid; ?>?shell=no&username=<?php echo page_owner_entity()->username; ?>&context=<?php echo get_context(); ?>&callback=true");
+               });
+               return false;
+       
+       });
+
+}); 
 </script>
\ No newline at end of file
index a5d36b1e3176c9f3169013e359c1c902797f3719..e7791bde98bde601ef85f588a4552dabb836da74 100644 (file)
-<?php\r
-\r
-       /**\r
-        * Elgg widget wrapper\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        */\r
-\r
-       static $widgettypes;\r
-       \r
-       $callback = get_input('callback');\r
-       \r
-       if (!isset($widgettypes)) $widgettypes = get_widget_types();\r
-       \r
-       if ($vars['entity'] instanceof ElggObject && $vars['entity']->getSubtype() == 'widget') {\r
-               $handler = $vars['entity']->handler;\r
-               $title = $widgettypes[$vars['entity']->handler]->name;\r
-               if (!$title)\r
-                       $title = $handler;\r
-       } else {\r
-               $handler = "error";\r
-               $title = elgg_echo("error"); \r
-       }\r
-       \r
-       if ($callback != "true") {\r
-       \r
-?>\r
-\r
-       <div id="widget<?php echo $vars['entity']->getGUID(); ?>">\r
-       <div class="collapsable_box">\r
-       <div class="collapsable_box_header">\r
-       <a href="javascript:void(0);" class="toggle_box_contents">-</a><?php if ($vars['entity']->canEdit()) { ?><a href="javascript:void(0);" class="toggle_box_edit_panel"><?php echo elgg_echo('edit'); ?></a><?php } ?>\r
-       <h1><?php echo $title; ?></h1>\r
-       </div>\r
-       <?php\r
-\r
-               if ($vars['entity']->canEdit()) {\r
-       \r
-       ?>\r
-       <div class="collapsable_box_editpanel"><?php \r
-               \r
-               echo elgg_view('widgets/editwrapper', \r
-                                               array(\r
-                                                               'body' => elgg_view("widgets/{$handler}/edit",$vars),\r
-                                                               'entity' => $vars['entity']\r
-                                                         )\r
-                                          ); \r
-               \r
-       ?></div><!-- /collapsable_box_editpanel -->\r
-       <?php\r
-\r
-               }\r
-       \r
-       ?>\r
-       <div class="collapsable_box_content">\r
-               <?php \r
-\r
-               echo "<div id=\"widgetcontent{$vars['entity']->getGUID()}\">";\r
-               \r
-               \r
-       } else { // end if callback != "true"\r
-\r
-               if (elgg_view_exists("widgets/{$handler}/view"))\r
-                       echo elgg_view("widgets/{$handler}/view",$vars);\r
-               else\r
-                       echo elgg_echo('widgets:handlernotfound');\r
-\r
-?>\r
-
-<script language="javascript">\r
- $(document).ready(function(){\r
-       setup_avatar_menu();\r
- });\r
-\r
-</script>\r
-\r
-\r
-<?php\r
-               \r
-       }\r
-               \r
-       if ($callback != "true") {\r
-               echo elgg_view('ajax/loader');\r
-               echo "</div>";\r
-               \r
-               ?>\r
-       </div><!-- /.collapsable_box_content -->\r
-       </div><!-- /.collapsable_box -->        \r
-       </div>\r
-       \r
-<script type="text/javascript">\r
-$(document).ready(function() {\r
-\r
-       $("#widgetcontent<?php echo $vars['entity']->getGUID(); ?>").load("<?php echo $vars['url']; ?>pg/view/<?php echo $vars['entity']->getGUID(); ?>?shell=no&username=<?php echo page_owner_entity()->username; ?>&context=widget&callback=true");\r
-\r
-       // run function to check for widgets collapsed/expanded state\r
-       var forWidget = "widget<?php echo $vars['entity']->getGUID(); ?>";\r
-       widget_state(forWidget);\r
-\r
-\r
-});\r
-</script>\r
-       \r
-<?php\r
-\r
-       }\r
-\r
+<?php
+
+       /**
+        * Elgg widget wrapper
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       static $widgettypes;
+       
+       $callback = get_input('callback');
+       
+       if (!isset($widgettypes)) $widgettypes = get_widget_types();
+       
+       if ($vars['entity'] instanceof ElggObject && $vars['entity']->getSubtype() == 'widget') {
+               $handler = $vars['entity']->handler;
+               $title = $widgettypes[$vars['entity']->handler]->name;
+               if (!$title)
+                       $title = $handler;
+       } else {
+               $handler = "error";
+               $title = elgg_echo("error"); 
+       }
+       
+       if ($callback != "true") {
+       
+?>
+
+       <div id="widget<?php echo $vars['entity']->getGUID(); ?>">
+       <div class="collapsable_box">
+       <div class="collapsable_box_header">
+       <a href="javascript:void(0);" class="toggle_box_contents">-</a><?php if ($vars['entity']->canEdit()) { ?><a href="javascript:void(0);" class="toggle_box_edit_panel"><?php echo elgg_echo('edit'); ?></a><?php } ?>
+       <h1><?php echo $title; ?></h1>
+       </div>
+       <?php
+
+               if ($vars['entity']->canEdit()) {
+       
+       ?>
+       <div class="collapsable_box_editpanel"><?php 
+               
+               echo elgg_view('widgets/editwrapper', 
+                                               array(
+                                                               'body' => elgg_view("widgets/{$handler}/edit",$vars),
+                                                               'entity' => $vars['entity']
+                                                         )
+                                          ); 
+               
+       ?></div><!-- /collapsable_box_editpanel -->
+       <?php
+
+               }
+       
+       ?>
+       <div class="collapsable_box_content">
+               <?php 
+
+               echo "<div id=\"widgetcontent{$vars['entity']->getGUID()}\">";
+               
+               
+       } else { // end if callback != "true"
+
+               if (elgg_view_exists("widgets/{$handler}/view"))
+                       echo elgg_view("widgets/{$handler}/view",$vars);
+               else
+                       echo elgg_echo('widgets:handlernotfound');
+
+?>
+
+<script language="javascript">
+ $(document).ready(function(){
+       setup_avatar_menu();
+ });
+
+</script>
+
+
+<?php
+               
+       }
+               
+       if ($callback != "true") {
+               echo elgg_view('ajax/loader');
+               echo "</div>";
+               
+               ?>
+       </div><!-- /.collapsable_box_content -->
+       </div><!-- /.collapsable_box -->        
+       </div>
+       
+<script type="text/javascript">
+$(document).ready(function() {
+
+       $("#widgetcontent<?php echo $vars['entity']->getGUID(); ?>").load("<?php echo $vars['url']; ?>pg/view/<?php echo $vars['entity']->getGUID(); ?>?shell=no&username=<?php echo page_owner_entity()->username; ?>&context=widget&callback=true");
+
+       // run function to check for widgets collapsed/expanded state
+       var forWidget = "widget<?php echo $vars['entity']->getGUID(); ?>";
+       widget_state(forWidget);
+
+
+});
+</script>
+       
+<?php
+
+       }
+
 ?>
\ No newline at end of file
index 34ff1984d3d7783aa85526072c4e7d33b801f034..a5c30fe52b4c1699d72027ffd40841be270724aa 100644 (file)
@@ -1,21 +1,21 @@
-<?php\r
-\r
-       /**\r
-        * Elgg default layout\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg default layout
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       for ($i = 1; $i < 8; $i++) {
+               
+               if (isset($vars["area{$i}"]))
+                       echo $vars["area{$i}"];
+               
+       }
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       for ($i = 1; $i < 8; $i++) {\r
-               \r
-               if (isset($vars["area{$i}"]))\r
-                       echo $vars["area{$i}"];\r
-               \r
-       }\r
-\r
 ?>
\ No newline at end of file
index d83b265ceab588887147fb2adf4e67bc2771e895..74fc56ddf4de96efb7e346c67ebd1cd78aa6d397 100644 (file)
@@ -1,51 +1,51 @@
-<?php\r
-\r
-       /**\r
-        * Elgg access level input\r
-        * Displays a pulldown input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * \r
-        */\r
-\r
-       if (isset($vars['class'])) $class = $vars['class'];\r
-       if (!$class) $class = "input-access";\r
-\r
-               if ((!isset($vars['options'])) || (!is_array($vars['options'])))\r
-               {\r
-                       $vars['options'] = array();\r
-                       $vars['options'] = get_write_access_array();\r
-               }\r
-               \r
-               if (is_array($vars['options']) && sizeof($vars['options']) > 0) {        \r
-                        \r
-?>\r
-\r
-<select name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['js'])) echo $vars['js']; ?> <?php if ((isset($vars['disabled'])) && ($vars['disabled'])) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">\r
-<?php\r
-\r
-    foreach($vars['options'] as $key => $option) {\r
-        if ($key != $vars['value']) {\r
-            echo "<option value=\"{$key}\">{$option}</option>";\r
-        } else {\r
-            echo "<option value=\"{$key}\" selected=\"selected\">{$option}</option>";\r
-        }\r
-    }\r
-\r
-?> \r
-</select>\r
-\r
-<?php\r
-\r
-               }               \r
-\r
+<?php
+
+       /**
+        * Elgg access level input
+        * Displays a pulldown input field
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * 
+        */
+
+       if (isset($vars['class'])) $class = $vars['class'];
+       if (!$class) $class = "input-access";
+
+               if ((!isset($vars['options'])) || (!is_array($vars['options'])))
+               {
+                       $vars['options'] = array();
+                       $vars['options'] = get_write_access_array();
+               }
+               
+               if (is_array($vars['options']) && sizeof($vars['options']) > 0) {        
+                        
+?>
+
+<select name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['js'])) echo $vars['js']; ?> <?php if ((isset($vars['disabled'])) && ($vars['disabled'])) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">
+<?php
+
+    foreach($vars['options'] as $key => $option) {
+        if ($key != $vars['value']) {
+            echo "<option value=\"{$key}\">{$option}</option>";
+        } else {
+            echo "<option value=\"{$key}\" selected=\"selected\">{$option}</option>";
+        }
+    }
+
+?> 
+</select>
+
+<?php
+
+               }               
+
 ?>
\ No newline at end of file
index 46894c5cbddd373a1a15e7176be668ccad9bd98f..0e394af55f3825cbda251708e0e0e8450360e459 100644 (file)
@@ -1,49 +1,49 @@
-<?php\r
-\r
-       /**\r
-        * Elgg checkbox input\r
-        * Displays a checkbox input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg checkbox input
+        * Displays a checkbox input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * @uses $vars['options'] An array of strings representing the options for the checkbox field\r
-        * \r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * @uses $vars['options'] An array of strings representing the options for the checkbox field
+        * 
+        */
 
        $class = $vars['class'];
        if (!$class) $class = "input-checkboxes";
-\r
-    foreach($vars['options'] as $label => $option) {\r
-        //if (!in_array($option,$vars['value'])) {\r
-        if (is_array($vars['value'])) {\r
-               if (!in_array($option,$vars['value'])) {\r
-                   $selected = "";\r
-               } else {\r
-                   $selected = "checked = \"checked\"";\r
-               }\r
+
+    foreach($vars['options'] as $label => $option) {
+        //if (!in_array($option,$vars['value'])) {
+        if (is_array($vars['value'])) {
+               if (!in_array($option,$vars['value'])) {
+                   $selected = "";
+               } else {
+                   $selected = "checked = \"checked\"";
+               }
         } else {
-               if ($option != $vars['value']) {\r
-                   $selected = "";\r
-               } else {\r
-                   $selected = "checked = \"checked\"";\r
-               }\r
-        }\r
-        $labelint = (int) $label;\r
-        if ("{$label}" == "{$labelint}") {\r
-               $label = $option;\r
+               if ($option != $vars['value']) {
+                   $selected = "";
+               } else {
+                   $selected = "checked = \"checked\"";
+               }
+        }
+        $labelint = (int) $label;
+        if ("{$label}" == "{$labelint}") {
+               $label = $option;
         }
         
         $disabled = "";
-        if ($vars['disabled']) $disabled = ' disabled="yes" '; \r
-        echo "<label><input type=\"checkbox\" $disabled {$vars['js']} name=\"{$vars['internalname']}[]\" {$selected} value=\"".htmlentities($option, ENT_QUOTES, 'UTF-8')."\" {$selected} class=\"$class\" />{$label}</label><br />";\r
-    }\r
-\r
+        if ($vars['disabled']) $disabled = ' disabled="yes" '; 
+        echo "<label><input type=\"checkbox\" $disabled {$vars['js']} name=\"{$vars['internalname']}[]\" {$selected} value=\"".htmlentities($option, ENT_QUOTES, 'UTF-8')."\" {$selected} class=\"$class\" />{$label}</label><br />";
+    }
+
 ?> 
\ No newline at end of file
index 41cb395c2b9f5659137aebdc2ddf07dd952bce73..c1f38fe6945580c64dab79a2a6e042f7552b8790 100644 (file)
@@ -1,25 +1,25 @@
-<?php\r
-\r
-       /**\r
-        * Elgg long text input\r
-        * Displays a long text input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg long text input
+        * Displays a long text input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * \r
-        */\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * 
+        */
 
        $class = $vars['class'];
        if (!$class) $class = "input-textarea";
-       \r
-?>\r
-\r
+       
+?>
+
 <textarea class="<?php echo $class; ?>" name="<?php echo $vars['internalname']; ?>" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?>><?php echo $vars['value']; ?></textarea> 
\ No newline at end of file
index a0e91ce25c0927d96b128f0d4516921991c2244a..1adbad099be07650105a9fe23c0570e8b9b12728 100644 (file)
@@ -1,33 +1,33 @@
-<?php\r
-\r
-       /**\r
-        * Elgg pulldown input\r
-        * Displays a pulldown input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
-        * @uses $vars['options'] An array of strings representing the options for the pulldown field\r
+<?php
+
+       /**
+        * Elgg pulldown input
+        * Displays a pulldown input field
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
+        * @uses $vars['options'] An array of strings representing the options for the pulldown field
         * @uses $vars['options_values'] An associative array of "value" => "option" where "value" is an internal name and "option" is 
-        *                                                               the value displayed on the button. Replaces $vars['options'] when defined. \r
-        */\r
+        *                                                               the value displayed on the button. Replaces $vars['options'] when defined. 
+        */
 
 
        $class = $vars['class'];
        if (!$class) $class = "input-pulldown";
-\r
-?>\r
-\r
-\r
-<select name="<?php echo $vars['internalname']; ?>" <?php echo $vars['js']; ?> <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">\r
-<?php\r
+
+?>
+
+
+<select name="<?php echo $vars['internalname']; ?>" <?php echo $vars['js']; ?> <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">
+<?php
        if ($vars['options_values'])
        {
                foreach($vars['options_values'] as $value => $option) {
            }
        }
        else
-       {\r
-           foreach($vars['options'] as $option) {\r
-               if ($option != $vars['value']) {\r
-                   echo "<option>{$option}</option>";\r
-               } else {\r
-                   echo "<option selected=\"selected\">{$option}</option>";\r
-               }\r
-           }\r
-       }\r
-?> \r
+       {
+           foreach($vars['options'] as $option) {
+               if ($option != $vars['value']) {
+                   echo "<option>{$option}</option>";
+               } else {
+                   echo "<option selected=\"selected\">{$option}</option>";
+               }
+           }
+       }
+?> 
 </select>
\ No newline at end of file
index 2195741f2d1a4bdd12f1b14cbd4677523c226c14..4c37e52196c1784b51da9e396f09f41b006c41fb 100644 (file)
@@ -1,27 +1,27 @@
-<?php\r
-\r
-       /**\r
-        * Elgg text input\r
-        * Displays a text input field\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg text input
+        * Displays a text input field
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['value'] The current value, if any\r
-        * @uses $vars['js'] Any Javascript to enter into the input tag\r
-        * @uses $vars['internalname'] The name of the input field\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['value'] The current value, if any
+        * @uses $vars['js'] Any Javascript to enter into the input tag
+        * @uses $vars['internalname'] The name of the input field
         * @uses $vars['disabled'] If true then control is read-only
-        * @uses $vars['class'] Class override\r
-        */\r
+        * @uses $vars['class'] Class override
+        */
 
        
        $class = $vars['class'];
        if (!$class) $class = "input-text";
-       \r
-?>\r
-\r
+       
+?>
+
 <input type="text" <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> <?php echo $vars['js']; ?> name="<?php echo $vars['internalname']; ?>" value="<?php echo htmlentities($vars['value'], ENT_QUOTES, 'UTF-8'); ?>" class="<?php echo $class ?>"/> 
\ No newline at end of file
index ea43f1c373c0d5ad82be82a4a7a927e1454f0501..e3eb065e7b12c4795bc3ea0674b6d13c253f6903 100644 (file)
@@ -1,20 +1,20 @@
-<?php\r
-\r
-       /**\r
-        * Elgg error message\r
-        * Displays a single error message\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg error message
+        * Displays a single error message
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['object'] An error message (string)\r
-        */\r
-?>\r
-\r
-       <p>\r
-               <?php echo $vars['object']; ?>\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['object'] An error message (string)
+        */
+?>
+
+       <p>
+               <?php echo $vars['object']; ?>
        </p>
\ No newline at end of file
index fd90a8d1fb17ab0be8f5625aef42f511103f85c4..8a4b26056e9544a28c66502dc6cbf53831a9c163 100644 (file)
@@ -1,48 +1,48 @@
-<?php\r
-\r
-       /**\r
-        * Elgg list errors\r
-        * Lists error messages\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['object'] An array of error messages\r
-        */\r
-\r
-               if (!empty($vars['object']) && is_array($vars['object'])) {\r
-\r
-?>\r
-<style type="text/css">\r
-.messages_error {\r
-    border:1px solid #D3322A;\r
-    background:#F7DAD8;\r
-    color:#000000;\r
-    padding:3px 10px 3px 10px;\r
-    margin:20px 0px 0px 0px;\r
-    z-index: 9999;\r
-    position:relative;\r
-    width:95%;\r
-}\r
-</style>\r
-       <div class="database_settings">\r
-               <div class="messages_errors">\r
-\r
-<?php\r
-                       foreach($vars['object'] as $error) {\r
-                               echo elgg_view('messages/errors/error',array('object' => $error));\r
-                               //echo "<hr />";\r
-                       }\r
-?>\r
-               </div>\r
-       </div>\r
-<?php\r
-               }\r
-\r
-\r
-\r
+<?php
+
+       /**
+        * Elgg list errors
+        * Lists error messages
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['object'] An array of error messages
+        */
+
+               if (!empty($vars['object']) && is_array($vars['object'])) {
+
+?>
+<style type="text/css">
+.messages_error {
+    border:1px solid #D3322A;
+    background:#F7DAD8;
+    color:#000000;
+    padding:3px 10px 3px 10px;
+    margin:20px 0px 0px 0px;
+    z-index: 9999;
+    position:relative;
+    width:95%;
+}
+</style>
+       <div class="database_settings">
+               <div class="messages_errors">
+
+<?php
+                       foreach($vars['object'] as $error) {
+                               echo elgg_view('messages/errors/error',array('object' => $error));
+                               //echo "<hr />";
+                       }
+?>
+               </div>
+       </div>
+<?php
+               }
+
+
+
 ?>
\ No newline at end of file
index d454841d87b58228a34b9451aeac35575d0389dc..dd02fdac5c67b732010288baadb225511ec4ec53 100644 (file)
@@ -1,25 +1,25 @@
-<?php\r
-\r
-       /**\r
-        * Elgg global system message list\r
-        * Lists all system messages\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg global system message list
+        * Lists all system messages
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['object'] The array of message registers\r
-        */\r
-\r
-               if (!empty($vars['object']) && is_array($vars['object']) && sizeof($vars['object']) > 0) {\r
-                       \r
-                       foreach($vars['object'] as $register => $list ) {\r
-                               echo elgg_view("messages/{$register}/list", array('object' => $list));\r
-                       }\r
-                       \r
-               }\r
-               \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['object'] The array of message registers
+        */
+
+               if (!empty($vars['object']) && is_array($vars['object']) && sizeof($vars['object']) > 0) {
+                       
+                       foreach($vars['object'] as $register => $list ) {
+                               echo elgg_view("messages/{$register}/list", array('object' => $list));
+                       }
+                       
+               }
+               
 ?>
\ No newline at end of file
index d103060b2d64e9d1ab7bdb8d141c84ccc1e9fc0e..2cb94b4e1da6530c9d743a34170bae7e719cb59b 100644 (file)
@@ -1,51 +1,51 @@
-<?php\r
-\r
-       /**\r
-        * Elgg list system messages\r
-        * Lists system messages\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
-
-        * @author Curverider Ltd\r
-
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['object'] An array of system messages\r
-        */\r
-\r
-       if (!empty($vars['object']) && is_array($vars['object'])) {\r
-\r
-?>\r
-\r
-<style type="text/css">\r
-.messages {\r
-    border:1px solid #00cc00;\r
-    background:#ccffcc;\r
-    color:#000000;\r
-    padding:3px 10px 3px 10px;\r
-    margin:20px 0px 0px 0px;\r
-    z-index: 9999;\r
-    position:relative;\r
-    width:95%;\r
-}\r
-</style>\r
-\r
-       <div class="messages">\r
-\r
-<?php\r
-\r
-               \r
-                       foreach($vars['object'] as $message) {\r
-                               echo elgg_view('messages/messages/message',array('object' => $message));\r
-                       }\r
-\r
-?>\r
-\r
-       </div>\r
-       \r
-<?php\r
-\r
-       }\r
-\r
+<?php
+
+       /**
+        * Elgg list system messages
+        * Lists system messages
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['object'] An array of system messages
+        */
+
+       if (!empty($vars['object']) && is_array($vars['object'])) {
+
+?>
+
+<style type="text/css">
+.messages {
+    border:1px solid #00cc00;
+    background:#ccffcc;
+    color:#000000;
+    padding:3px 10px 3px 10px;
+    margin:20px 0px 0px 0px;
+    z-index: 9999;
+    position:relative;
+    width:95%;
+}
+</style>
+
+       <div class="messages">
+
+<?php
+
+               
+                       foreach($vars['object'] as $message) {
+                               echo elgg_view('messages/messages/message',array('object' => $message));
+                       }
+
+?>
+
+       </div>
+       
+<?php
+
+       }
+
 ?>
\ No newline at end of file
index b3286e469ed8e2cf4c820f307a0ed0fcee86f422..c63c274989d5762865ccb4db4c6cd16b3eb68eee 100644 (file)
@@ -1,20 +1,20 @@
-<?php\r
-\r
-       /**\r
-        * Elgg standard message\r
-        * Displays a single Elgg system message\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg standard message
+        * Displays a single Elgg system message
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['object'] A system message (string)\r
-        */\r
-?>\r
-\r
-       <p>\r
-               <?php echo nl2br($vars['object']); ?>\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['object'] A system message (string)
+        */
+?>
+
+       <p>
+               <?php echo nl2br($vars['object']); ?>
        </p>
\ No newline at end of file
index 5bfbb38f892596916114fa9fc897ca7c1d2fc323..b8800c9be81c5237bafc01c60ff3f127068adb2a 100644 (file)
@@ -1,17 +1,17 @@
-<?php\r
-\r
-       /**\r
-        * Elgg .htaccess not found message\r
-        * Is saved to the errors register when the main .htaccess cannot be found\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg .htaccess not found message
+        * Is saved to the errors register when the main .htaccess cannot be found
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
         */
 
-       echo autop(elgg_echo('installation:error:htaccess'));\r
+       echo autop(elgg_echo('installation:error:htaccess'));
 ?>
 <textarea cols="120" rows="30"><?php echo $vars['.htaccess']; ?></textarea>
\ No newline at end of file
index 6a3e075d95e98a50b228767785d2f3c20c5a85a6..2bf632c6ad32694e0281f73d0528b4da6e61a857 100644 (file)
@@ -1,19 +1,19 @@
-<?php\r
-\r
-       /**\r
-        * Elgg system settings on initial installation\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg system settings on initial installation
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        */
+
+       echo "<p>" . autop(elgg_echo("installation:settings:description")) . "</p>";
+
+       echo elgg_view("settings/system",array("action" => "action/systemsettings/install"));
 
-        * @link http://elgg.org/\r
-        * \r
-        */\r
-\r
-       echo "<p>" . autop(elgg_echo("installation:settings:description")) . "</p>";\r
-\r
-       echo elgg_view("settings/system",array("action" => "action/systemsettings/install"));\r
-\r
 ?>
\ No newline at end of file
index 85f625336fbe59a4d9ea94184f3c75fcdb52b17c..2f7a85031124ed93a8912e981daa765cf417f471 100644 (file)
@@ -1,66 +1,66 @@
-<?php\r
-\r
-       /**\r
-        * Elgg system settings form\r
-        * The form to change system settings\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg system settings form
+        * The form to change system settings
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['action'] If set, the place to forward the form to (usually action/systemsettings/save)\r
-        */\r
-\r
-       // Set action appropriately\r
-               if (!isset($vars['action'])) {\r
-                       $action = $vars['url'] . "action/systemsettings/save";\r
-               } else {\r
-                       $action = $vars['action'];\r
-               }\r
-               \r
-               $form_body = "";\r
-               foreach(array('sitename','sitedescription', 'siteemail', 'wwwroot','path','dataroot', 'view') as $field) {\r
-                       $form_body .= "<p>";\r
-                       $form_body .= elgg_echo('installation:' . $field) . "<br />";\r
-                       $warning = elgg_echo('installation:warning:' . $field);\r
-                       if ($warning != 'installation:warning:' . $field) echo "<b>" . $warning . "</b><br />";\r
-                       $value = $vars['config']->$field;\r
-                       if ($field == 'view') $value = 'default';\r
-                       $form_body .= elgg_view("input/text",array('internalname' => $field, 'value' => $value));\r
-                       $form_body .= "</p>";\r
-               }\r
-               \r
-               $languages = get_installed_translations();\r
-               $form_body .= "<p>" . elgg_echo('installation:language') . elgg_view("input/pulldown", array('internalname' => 'language', 'value' => $vars['config']->language, 'options_values' => $languages)) . "</p>";\r
-               \r
-               $form_body .= "<p>" . elgg_echo('installation:sitepermissions') . elgg_view('input/access', array('internalname' => 'default_access','value' => ACCESS_LOGGED_IN)) . "</p>";\r
-\r
-               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:debug') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:debug:label')), 'internalname' => 'debug', 'value' => ($vars['config']->debug ? elgg_echo('installation:debug:label') : "") )) . "</p>";\r
-               \r
-               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:httpslogin') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:httpslogin:label')), 'internalname' => 'https_login', 'value' => ($vars['config']->https_login ? elgg_echo('installation:httpslogin:label') : "") )) . "</p>";\r
-               \r
-               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:disableapi') . "<br />";\r
-               $on = elgg_echo('installation:disableapi:label');\r
-               if ((isset($CONFIG->disable_api)) && ($CONFIG->disable_api == true))\r
-                       $on = ($vars['config']->disable_api ?  "" : elgg_echo('installation:disableapi:label'));\r
-               $form_body .= elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:disableapi:label')), 'internalname' => 'api', 'value' => $on ));\r
-               $form_body .= "</p>";\r
-               \r
-               $form_body .= "<p class=\"admin_usage\">" . elgg_echo('installation:usage') . "<br />";\r
-               $on = elgg_echo('installation:usage:label');\r
-\r
-               if (isset($CONFIG->ping_home))\r
-                       $on = ($vars['config']->ping_home!='disabled' ? elgg_echo('installation:usage:label') : "");\r
-               $form_body .= elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:usage:label')), 'internalname' => 'usage', 'value' => $on ));      \r
-               $form_body .= "</p>";\r
-               \r
-               $form_body .= elgg_view('input/hidden', array('internalname' => 'settings', 'value' => 'go'));\r
-               \r
-               $form_body .= elgg_view('input/submit', array('value' => elgg_echo("save")));\r
-               \r
-               echo elgg_view('input/form', array('action' => $action, 'body' => $form_body));\r
-               \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['action'] If set, the place to forward the form to (usually action/systemsettings/save)
+        */
+
+       // Set action appropriately
+               if (!isset($vars['action'])) {
+                       $action = $vars['url'] . "action/systemsettings/save";
+               } else {
+                       $action = $vars['action'];
+               }
+               
+               $form_body = "";
+               foreach(array('sitename','sitedescription', 'siteemail', 'wwwroot','path','dataroot', 'view') as $field) {
+                       $form_body .= "<p>";
+                       $form_body .= elgg_echo('installation:' . $field) . "<br />";
+                       $warning = elgg_echo('installation:warning:' . $field);
+                       if ($warning != 'installation:warning:' . $field) echo "<b>" . $warning . "</b><br />";
+                       $value = $vars['config']->$field;
+                       if ($field == 'view') $value = 'default';
+                       $form_body .= elgg_view("input/text",array('internalname' => $field, 'value' => $value));
+                       $form_body .= "</p>";
+               }
+               
+               $languages = get_installed_translations();
+               $form_body .= "<p>" . elgg_echo('installation:language') . elgg_view("input/pulldown", array('internalname' => 'language', 'value' => $vars['config']->language, 'options_values' => $languages)) . "</p>";
+               
+               $form_body .= "<p>" . elgg_echo('installation:sitepermissions') . elgg_view('input/access', array('internalname' => 'default_access','value' => ACCESS_LOGGED_IN)) . "</p>";
+
+               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:debug') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:debug:label')), 'internalname' => 'debug', 'value' => ($vars['config']->debug ? elgg_echo('installation:debug:label') : "") )) . "</p>";
+               
+               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:httpslogin') . "<br />" .elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:httpslogin:label')), 'internalname' => 'https_login', 'value' => ($vars['config']->https_login ? elgg_echo('installation:httpslogin:label') : "") )) . "</p>";
+               
+               $form_body .= "<p class=\"admin_debug\">" . elgg_echo('installation:disableapi') . "<br />";
+               $on = elgg_echo('installation:disableapi:label');
+               if ((isset($CONFIG->disable_api)) && ($CONFIG->disable_api == true))
+                       $on = ($vars['config']->disable_api ?  "" : elgg_echo('installation:disableapi:label'));
+               $form_body .= elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:disableapi:label')), 'internalname' => 'api', 'value' => $on ));
+               $form_body .= "</p>";
+               
+               $form_body .= "<p class=\"admin_usage\">" . elgg_echo('installation:usage') . "<br />";
+               $on = elgg_echo('installation:usage:label');
+
+               if (isset($CONFIG->ping_home))
+                       $on = ($vars['config']->ping_home!='disabled' ? elgg_echo('installation:usage:label') : "");
+               $form_body .= elgg_view("input/checkboxes", array('options' => array(elgg_echo('installation:usage:label')), 'internalname' => 'usage', 'value' => $on ));      
+               $form_body .= "</p>";
+               
+               $form_body .= elgg_view('input/hidden', array('internalname' => 'settings', 'value' => 'go'));
+               
+               $form_body .= elgg_view('input/submit', array('value' => elgg_echo("save")));
+               
+               echo elgg_view('input/form', array('action' => $action, 'body' => $form_body));
+               
 ?>
\ No newline at end of file
index 34ff1984d3d7783aa85526072c4e7d33b801f034..a5c30fe52b4c1699d72027ffd40841be270724aa 100644 (file)
@@ -1,21 +1,21 @@
-<?php\r
-\r
-       /**\r
-        * Elgg default layout\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg default layout
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       for ($i = 1; $i < 8; $i++) {
+               
+               if (isset($vars["area{$i}"]))
+                       echo $vars["area{$i}"];
+               
+       }
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       for ($i = 1; $i < 8; $i++) {\r
-               \r
-               if (isset($vars["area{$i}"]))\r
-                       echo $vars["area{$i}"];\r
-               \r
-       }\r
-\r
 ?>
\ No newline at end of file
index 640dd8104559d799c858384e0d89b44405672ef6..15397d55278eb4967d06da94574d4abed3f57780 100644 (file)
@@ -1,5 +1,5 @@
-<?php\r
-\r
-       echo $vars['body'];\r
-\r
+<?php
+
+       echo $vars['body'];
+
 ?>
\ No newline at end of file
index 6c0461fc2b2bf56bfbbf5d2d479aa315b05eed9d..4b67017408c71abd96a6d3d814a1e2c5959a3a84 100644 (file)
         */
 
        header("Content-Type: text/xml");
-       // echo $vars['body'];\r
-       \r
-       echo "<?xml version='1.0'?>\n";\r
-       \r
-       if (!$owner = page_owner_entity()) {\r
-               if (!isloggedin()) {\r
-                       exit;\r
-               } else {\r
-                       $owner = $vars['user'];\r
-               }\r
-       }\r
+       // echo $vars['body'];
        
-?>\r
-<rdf:RDF\r
-   xml:lang="en"\r
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\r
-   xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"\r
-   xmlns:foaf="http://xmlns.com/foaf/0.1/"\r
-   xmlns:ya="http://blogs.yandex.ru/schema/foaf/"\r
-   xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"\r
-   xmlns:dc="http://purl.org/dc/elements/1.1/">\r
-   <foaf:Person>\r
-    <foaf:nick><?php echo $owner->username; ?></foaf:nick>\r
-    <foaf:name><?php echo $owner->name; ?></foaf:name>\r
-    <foaf:homepage rdf:resource="<?php echo $owner->getURL(); ?>" />\r
-    <foaf:mbox_sha1sum><?php echo sha1("mailto:" . $owner->email); ?></foaf:mbox_sha1sum>\r
-    <foaf:img rdf:resource="<?php echo $vars['url']; ?>pg/icon/<?php echo $owner->username; ?>/large/icon.jpg" />\r
-       <?php\r
-\r
-               echo $vars['body'];\r
-       \r
-       ?>\r
-       </foaf:Person>     \r
+       echo "<?xml version='1.0'?>\n";
+       
+       if (!$owner = page_owner_entity()) {
+               if (!isloggedin()) {
+                       exit;
+               } else {
+                       $owner = $vars['user'];
+               }
+       }
+       
+?>
+<rdf:RDF
+   xml:lang="en"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+   xmlns:foaf="http://xmlns.com/foaf/0.1/"
+   xmlns:ya="http://blogs.yandex.ru/schema/foaf/"
+   xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
+   xmlns:dc="http://purl.org/dc/elements/1.1/">
+   <foaf:Person>
+    <foaf:nick><?php echo $owner->username; ?></foaf:nick>
+    <foaf:name><?php echo $owner->name; ?></foaf:name>
+    <foaf:homepage rdf:resource="<?php echo $owner->getURL(); ?>" />
+    <foaf:mbox_sha1sum><?php echo sha1("mailto:" . $owner->email); ?></foaf:mbox_sha1sum>
+    <foaf:img rdf:resource="<?php echo $vars['url']; ?>pg/icon/<?php echo $owner->username; ?>/large/icon.jpg" />
+       <?php
+
+               echo $vars['body'];
+       
+       ?>
+       </foaf:Person>     
 </rdf:RDF>
\ No newline at end of file
index 8a14e5f28eb215dec225d7ac5244127689921d04..01b9298e340a42a9059de3345629feecec3abf8d 100644 (file)
@@ -1,26 +1,26 @@
-<?php\r
-\r
-       /**\r
-        * Elgg default user view\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg default user view
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-               $friend = $vars['entity'];\r
-\r
-?>\r
-\r
-    <foaf:knows>\r
-      <foaf:Person>\r
-        <foaf:nick><?php echo $friend->username; ?></foaf:nick>\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+               $friend = $vars['entity'];
+
+?>
+
+    <foaf:knows>
+      <foaf:Person>
+        <foaf:nick><?php echo $friend->username; ?></foaf:nick>
         <foaf:member_name><?php echo $friend->name; ?></foaf:member_name>
-        <foaf:mbox_sha1sum><?php echo sha1("mailto:" . $friend->email); ?></foaf:mbox_sha1sum>\r
-        <rdfs:seeAlso rdf:resource="<?php echo $vars['url'] . "pg/friends/" . $friend->username . "/?view=foaf" ?>" />\r
-        <foaf:homepage rdf:resource="<?php echo $friend->getURL(); ?>?view=foaf"/>\r
-      </foaf:Person>\r
-    </foaf:knows>\r
+        <foaf:mbox_sha1sum><?php echo sha1("mailto:" . $friend->email); ?></foaf:mbox_sha1sum>
+        <rdfs:seeAlso rdf:resource="<?php echo $vars['url'] . "pg/friends/" . $friend->username . "/?view=foaf" ?>" />
+        <foaf:homepage rdf:resource="<?php echo $friend->getURL(); ?>?view=foaf"/>
+      </foaf:Person>
+    </foaf:knows>
index be4043ea49dfb70cd008dbbabbdde51dc512020b..1e3f65cfd73e28b715f984e264c2fedca7fb6b6b 100644 (file)
@@ -1,20 +1,20 @@
-<?php\r
-\r
-       /**\r
-        * Elgg JS default view\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg JS default view
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+               if (isset($vars['entity'])) {
+
+                       echo elgg_view_entity($vars['entity'],true,false);
+                       
+               }
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-               if (isset($vars['entity'])) {\r
-\r
-                       echo elgg_view_entity($vars['entity'],true,false);\r
-                       \r
-               }\r
-\r
 ?>
\ No newline at end of file
index 784febb1af217f942f2494a2ca866dd997df27e5..982bbcb86a8f2e3facae7345c981688af8d5c675 100644 (file)
@@ -1,27 +1,27 @@
-<?php\r
-\r
-       /**\r
-        * Elgg JS pageshell\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg JS pageshell
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       $body = $vars['body'];\r
-       \r
-       // Remove excess carriage returns\r
-               $body = str_replace("\r",'',$body);\r
-\r
-               $body = explode("\n",$body);\r
-               \r
-               foreach($body as $line) {\r
-                       \r
-                       echo "document.write('" . addslashes($line) . "');\n";\r
-                       \r
-               }\r
-               \r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       $body = $vars['body'];
+       
+       // Remove excess carriage returns
+               $body = str_replace("\r",'',$body);
+
+               $body = explode("\n",$body);
+               
+               foreach($body as $line) {
+                       
+                       echo "document.write('" . addslashes($line) . "');\n";
+                       
+               }
+               
 ?>
\ No newline at end of file
index be4043ea49dfb70cd008dbbabbdde51dc512020b..1e3f65cfd73e28b715f984e264c2fedca7fb6b6b 100644 (file)
@@ -1,20 +1,20 @@
-<?php\r
-\r
-       /**\r
-        * Elgg JS default view\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg JS default view
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+               if (isset($vars['entity'])) {
+
+                       echo elgg_view_entity($vars['entity'],true,false);
+                       
+               }
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-               if (isset($vars['entity'])) {\r
-\r
-                       echo elgg_view_entity($vars['entity'],true,false);\r
-                       \r
-               }\r
-\r
 ?>
\ No newline at end of file
index eeea0400ed95e42a15126c96d083ef7d123241c0..94aaaae608463ea092c87fe09fcd6e8439c66e99 100644 (file)
@@ -13,8 +13,8 @@
        $result = $vars['result'];
        $export = $result->export();
        
-       // echo json_encode($export);\r
-       global $jsonexport;\r
-       $jsonexport['api'][] = $export;\r
+       // echo json_encode($export);
+       global $jsonexport;
+       $jsonexport['api'][] = $export;
        
 ?>
\ No newline at end of file
index 3aab42f49b7134ea7f2cbf2ed349979fa34b8753..4978b00e75f6c9e64baf793f8c0024b006e91455 100644 (file)
@@ -8,8 +8,8 @@
         * @author Curverider Ltd
         * @link http://elgg.org/
         */
-\r
-\r
+
+
        global $jsonexport;
 
 ?>
\ No newline at end of file
index 9eeec770f2b4478ce8c290fe28893a96873aeb63..8c253d9b0db8e04c891a5d227b65f49345f696b7 100644 (file)
@@ -9,16 +9,16 @@
         * @link http://elgg.org/
         */
 
-       $entity = $vars['entity'];\r
+       $entity = $vars['entity'];
        
        $export = new stdClass;
        $exportable_values = $entity->getExportableValues();
        
        foreach ($exportable_values as $v)
-               $export->$v = $entity->$v;\r
-               \r
+               $export->$v = $entity->$v;
+               
        $export->url = $entity->getURL();
-               \r
+               
        global $jsonexport;
        $jsonexport[$entity->getType()][$entity->getSubtype()][] = $export;
 ?>
\ No newline at end of file
index 01df5567e6bf28262209951f1425b15fab657c0d..10aceb9dfac06748572f70b1e139f604a26fb01c 100644 (file)
@@ -16,8 +16,8 @@
        
        foreach ($exportable_values as $v)
                $export->$v = $m->$v;
-               \r
-       global $jsonexport;\r
+               
+       global $jsonexport;
        $jsonexport['metadata'][] = $entity;
        // echo json_encode($export);
 ?>
\ No newline at end of file
index 07b7e3b0eb7fa5dcbb8c63c3d5fa6e3e5fec493c..dd1adb4d8bbdbb403dfe21dd0c67d50049cca8a5 100644 (file)
@@ -18,7 +18,7 @@
        foreach ($exportable_values as $v)
                $export->$v = $r->$v;
                
-       global $jsonexport;\r
-       $jsonexport['relationships'][] = $export;\r
+       global $jsonexport;
+       $jsonexport['relationships'][] = $export;
        
 ?>
\ No newline at end of file
index 3a5888af40be30b0d7255b8f97ab254897ced34f..6255f08a60cf28ff9c90d005316bbc5dc8042cc7 100644 (file)
@@ -13,7 +13,7 @@
 
        $export = $vars['object'];
        
-       global $jsonexport;\r
-       $jsonexport['exceptions'][] = $export;\r
+       global $jsonexport;
+       $jsonexport['exceptions'][] = $export;
 
 ?>
\ No newline at end of file
index 640dd8104559d799c858384e0d89b44405672ef6..15397d55278eb4967d06da94574d4abed3f57780 100644 (file)
@@ -1,5 +1,5 @@
-<?php\r
-\r
-       echo $vars['body'];\r
-\r
+<?php
+
+       echo $vars['body'];
+
 ?>
\ No newline at end of file
index ca1f41a287fed9538ac070618e179616092f3506..2d2526e38e494961eb15397ba045a45137d90c6e 100644 (file)
@@ -8,14 +8,14 @@
         * @link http://elgg.org/
         * 
         */
-\r
-       if(stristr($_SERVER["HTTP_ACCEPT"],"application/json")) { \r
-               header("Content-Type: application/json");               \r
-       } else {\r
-               header("Content-Type: application/javascript");\r
+
+       if(stristr($_SERVER["HTTP_ACCEPT"],"application/json")) { 
+               header("Content-Type: application/json");               
+       } else {
+               header("Content-Type: application/javascript");
        }
-       // echo $vars['body'];\r
-       \r
-       global $jsonexport;\r
+       // echo $vars['body'];
+       
+       global $jsonexport;
        echo json_encode($jsonexport);
 ?>
\ No newline at end of file
index 8ab836f0a3350fae47233ef550b3cc3df929e573..1492121355202887e7220211a475dffe845ae7ed 100644 (file)
@@ -1,49 +1,49 @@
-<?php\r
-\r
-       global $jsonexport;\r
-       if (isset($vars['items']) && is_array($vars['items'])) {\r
-               \r
-               $i = 0;\r
-               if (!empty($vars['items']))\r
-               foreach($vars['items'] as $item) {\r
-                       \r
-                       // echo elgg_view_river_item($item);\r
-                       if (elgg_view_exists($item->view,'default')) {\r
-                               $body = elgg_view($item->view,array(\r
-                                                                       'item' => $item\r
-                                                                ),false,false,'default');\r
-                               $time = date("r",$item->posted);\r
-                               if ($entity = get_entity($item->object_guid)) {\r
-                                       $url = htmlspecialchars($entity->getURL());\r
-                               } else {\r
-                                       $url = $vars['url'];\r
-                               }\r
-                               $title = strip_tags($body);\r
-\r
-                               $jsonitem = $item;\r
-                               $jsonitem->url = $url;\r
-                               $jsonitem->description = autop($body);\r
-                               $jsonitem->title = $title;\r
-                               unset($jsonitem->view);\r
-                               \r
-                               if ($subject = get_entity($item->subject_guid)) {\r
-                                       elgg_view_entity($subject);\r
-                               }\r
-                               if ($object = get_entity($item->object_guid)) {\r
-                                       elgg_view_entity($object);\r
-                               }\r
-                               \r
-                               $jsonexport['activity'][] = $jsonitem;\r
-                               \r
-                       }\r
-                       \r
-                       $i++;\r
-                       if ($i >= $vars['limit']) break;\r
-                       \r
-               }\r
-               \r
-       }\r
-       echo "!";\r
-       \r
-\r
+<?php
+
+       global $jsonexport;
+       if (isset($vars['items']) && is_array($vars['items'])) {
+               
+               $i = 0;
+               if (!empty($vars['items']))
+               foreach($vars['items'] as $item) {
+                       
+                       // echo elgg_view_river_item($item);
+                       if (elgg_view_exists($item->view,'default')) {
+                               $body = elgg_view($item->view,array(
+                                                                       'item' => $item
+                                                                ),false,false,'default');
+                               $time = date("r",$item->posted);
+                               if ($entity = get_entity($item->object_guid)) {
+                                       $url = htmlspecialchars($entity->getURL());
+                               } else {
+                                       $url = $vars['url'];
+                               }
+                               $title = strip_tags($body);
+
+                               $jsonitem = $item;
+                               $jsonitem->url = $url;
+                               $jsonitem->description = autop($body);
+                               $jsonitem->title = $title;
+                               unset($jsonitem->view);
+                               
+                               if ($subject = get_entity($item->subject_guid)) {
+                                       elgg_view_entity($subject);
+                               }
+                               if ($object = get_entity($item->object_guid)) {
+                                       elgg_view_entity($object);
+                               }
+                               
+                               $jsonexport['activity'][] = $jsonitem;
+                               
+                       }
+                       
+                       $i++;
+                       if ($i >= $vars['limit']) break;
+                       
+               }
+               
+       }
+       echo "!";
+       
+
 ?>
\ No newline at end of file
index feeb51f18d601c3da5505c1f722cd230f8ee2041..eae45f397d5e04d9f080685cb693175b4b054b6a 100644 (file)
@@ -1,22 +1,22 @@
-<?php\r
-\r
-       /**\r
-        * Elgg exception\r
-        * Displays a single exception\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+
+       /**
+        * Elgg exception
+        * Displays a single exception
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['object'] An exception\r
-        */\r
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['object'] An exception
+        */
 
-       global $CONFIG;\r
-?>\r
-<!-- \r
+       global $CONFIG;
+?>
+<!-- 
 <?php echo get_class($vars['object']); ?>: <?php echo autop($vars['object']->getMessage()); ?>
 
 
index 9826542463c94759a8fbb178205c0abe6ffe6960..1433ba9b09747883da4c60955850cce693b79d04 100644 (file)
@@ -1,30 +1,30 @@
-<?php\r
-\r
-       /**\r
-        * Elgg generic comment\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+
+       /**
+        * Elgg generic comment
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
 
-        * @author Curverider Ltd\r
+        * @link http://elgg.org/
+        * 
+        */
+
+
+       $vars['entity'] = get_entity($vars['annotation']->entity_guid);
+       $title = substr($vars['annotation']->value,0,32);
+               if (strlen($vars['annotation']->value) > 32)
+                       $title .= " ...";
+       
+?>
 
-        * @link http://elgg.org/\r
-        * \r
-        */\r
-\r
-\r
-       $vars['entity'] = get_entity($vars['annotation']->entity_guid);\r
-       $title = substr($vars['annotation']->value,0,32);\r
-               if (strlen($vars['annotation']->value) > 32)\r
-                       $title .= " ...";\r
-       \r
-?>\r
-\r
-       <item>\r
-         <guid isPermaLink='true'><?php echo $vars['entity']->getURL(); ?>#<?php echo $vars['annotation']->id; ?></guid>\r
-         <pubDate><?php echo date("r",$vars['entity']->time_created) ?></pubDate>\r
-         <link><?php echo $vars['entity']->getURL(); ?>#<?php echo $vars['annotation']->id; ?></link>\r
-         <title><![CDATA[<?php echo $title; ?>]]></title>\r
+       <item>
+         <guid isPermaLink='true'><?php echo $vars['entity']->getURL(); ?>#<?php echo $vars['annotation']->id; ?></guid>
+         <pubDate><?php echo date("r",$vars['entity']->time_created) ?></pubDate>
+         <link><?php echo $vars['entity']->getURL(); ?>#<?php echo $vars['annotation']->id; ?></link>
+         <title><![CDATA[<?php echo $title; ?>]]></title>
          <description><![CDATA[<?php echo (autop($vars['annotation']->value)); ?>]]></description>
          <?php
                        $owner = get_entity($vars['entity']->owner);
@@ -46,5 +46,5 @@
                                <?php
                        }
          ?>
-         <?php echo elgg_view('extensions/item'); ?>\r
-       </item>\r
+         <?php echo elgg_view('extensions/item'); ?>
+       </item>
index 34ff1984d3d7783aa85526072c4e7d33b801f034..a5c30fe52b4c1699d72027ffd40841be270724aa 100644 (file)
@@ -1,21 +1,21 @@
-<?php\r
-\r
-       /**\r
-        * Elgg default layout\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg default layout
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+       for ($i = 1; $i < 8; $i++) {
+               
+               if (isset($vars["area{$i}"]))
+                       echo $vars["area{$i}"];
+               
+       }
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       for ($i = 1; $i < 8; $i++) {\r
-               \r
-               if (isset($vars["area{$i}"]))\r
-                       echo $vars["area{$i}"];\r
-               \r
-       }\r
-\r
 ?>
\ No newline at end of file
index 93dfe83e2ae51e77675eb255f9fc6f505aec6084..6ab14ecce014e28c899909ebd4fd0640b9fbdd96 100644 (file)
@@ -1,23 +1,23 @@
-<?php\r
-\r
-       /**\r
-        * Elgg default group view\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+
+       /**
+        * Elgg default group view
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
 
-        * @author Curverider Ltd\r
+        * @link http://elgg.org/
+        */
+
+?>
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-?>\r
-\r
-       <item>\r
-         <guid isPermaLink='true'><?php echo htmlspecialchars($vars['entity']->getURL()); ?></guid>\r
-         <pubDate><?php echo date("r",$vars['entity']->time_created) ?></pubDate>\r
-         <link><?php echo htmlspecialchars($vars['entity']->getURL()); ?></link>\r
-         <title><![CDATA[<?php echo (($vars['entity']->name)); ?>]]></title>\r
+       <item>
+         <guid isPermaLink='true'><?php echo htmlspecialchars($vars['entity']->getURL()); ?></guid>
+         <pubDate><?php echo date("r",$vars['entity']->time_created) ?></pubDate>
+         <link><?php echo htmlspecialchars($vars['entity']->getURL()); ?></link>
+         <title><![CDATA[<?php echo (($vars['entity']->name)); ?>]]></title>
          <description><![CDATA[<?php echo (autop($vars['entity']->description)); ?>]]></description>
          <?php
                        $owner = $vars['entity']->getOwnerEntity();
@@ -39,5 +39,5 @@
                                <?php
                        }
          ?>
-         <?php echo elgg_view('extensions/item'); ?>\r
-       </item>\r
+         <?php echo elgg_view('extensions/item'); ?>
+       </item>
index 69d16d4f689ae4e57bc26324ae4290c93097a00b..060e471c4892831003054cb05fd763a8b7f20fff 100644 (file)
@@ -1,31 +1,31 @@
-<?php\r
-\r
-       /**\r
-        * Elgg default object view\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+
+       /**
+        * Elgg default object view
+        * 
+        * @package Elgg
+        * @subpackage Core
+
+        * @author Curverider Ltd
 
-        * @author Curverider Ltd\r
+        * @link http://elgg.org/
+        */
+
+       $title = $vars['entity']->title;
+       if (empty($title)) {
+               $subtitle = strip_tags($vars['entity']->description);
+               $title = substr($subtitle,0,32);
+               if (strlen($subtitle) > 32)
+                       $title .= " ...";
+       }
+
+?>
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-       $title = $vars['entity']->title;\r
-       if (empty($title)) {\r
-               $subtitle = strip_tags($vars['entity']->description);\r
-               $title = substr($subtitle,0,32);\r
-               if (strlen($subtitle) > 32)\r
-                       $title .= " ...";\r
-       }\r
-\r
-?>\r
-\r
-       <item>\r
-         <guid isPermaLink='true'><?php echo htmlspecialchars($vars['entity']->getURL()); ?></guid>\r
-         <pubDate><?php echo date("r",$vars['entity']->time_created) ?></pubDate>\r
-         <link><?php echo htmlspecialchars($vars['entity']->getURL()); ?></link>\r
-         <title><![CDATA[<?php echo $title; ?>]]></title>\r
+       <item>
+         <guid isPermaLink='true'><?php echo htmlspecialchars($vars['entity']->getURL()); ?></guid>
+         <pubDate><?php echo date("r",$vars['entity']->time_created) ?></pubDate>
+         <link><?php echo htmlspecialchars($vars['entity']->getURL()); ?></link>
+         <title><![CDATA[<?php echo $title; ?>]]></title>
          <description><![CDATA[<?php echo (autop($vars['entity']->description)); ?>]]></description>
          <?php
                        $owner = $vars['entity']->getOwnerEntity();
@@ -47,5 +47,5 @@
                                <?php
                        }
          ?>
-         <?php echo elgg_view('extensions/item'); ?>\r
-       </item>\r
+         <?php echo elgg_view('extensions/item'); ?>
+       </item>
index 640dd8104559d799c858384e0d89b44405672ef6..15397d55278eb4967d06da94574d4abed3f57780 100644 (file)
@@ -1,5 +1,5 @@
-<?php\r
-\r
-       echo $vars['body'];\r
-\r
+<?php
+
+       echo $vars['body'];
+
 ?>
\ No newline at end of file
index 214f8c800898ef1298b405e414f645acd7f65511..c74a99f970955ec42b2cf1455b5666c9351f821d 100644 (file)
@@ -1,42 +1,42 @@
-<?php\r
-\r
-       if (isset($vars['items']) && is_array($vars['items'])) {\r
-               \r
-               $i = 0;\r
-               if (!empty($vars['items']))\r
-               foreach($vars['items'] as $item) {\r
-                       \r
-                       // echo elgg_view_river_item($item);\r
-                       if (elgg_view_exists($item->view,'default')) {\r
-                               $body = elgg_view($item->view,array(\r
-                                                                       'item' => $item\r
-                                                                ),false,false,'default');\r
-                               $time = date("r",$item->posted);\r
-                               if ($entity = get_entity($item->object_guid)) {\r
-                                       $url = htmlspecialchars($entity->getURL());\r
-                               } else {\r
-                                       $url = $vars['url'];\r
-                               }\r
-                               $title = strip_tags($body);\r
-                               \r
-?>\r
-       <item>\r
-         <guid isPermaLink='true'><?php echo $url; ?></guid>\r
-         <pubDate><?php echo $time; ?></pubDate>\r
-         <link><?php echo $url; ?></link>\r
-         <title><![CDATA[<?php echo $title; ?>]]></title>\r
-         <description><![CDATA[<?php echo (autop($body)); ?>]]></description>\r
-       </item>\r
-<?php\r
-                               \r
-                       }\r
-                       \r
-                       $i++;\r
-                       if ($i >= $vars['limit']) break;\r
-                       \r
-               }\r
-               \r
-       }\r
-       \r
-\r
+<?php
+
+       if (isset($vars['items']) && is_array($vars['items'])) {
+               
+               $i = 0;
+               if (!empty($vars['items']))
+               foreach($vars['items'] as $item) {
+                       
+                       // echo elgg_view_river_item($item);
+                       if (elgg_view_exists($item->view,'default')) {
+                               $body = elgg_view($item->view,array(
+                                                                       'item' => $item
+                                                                ),false,false,'default');
+                               $time = date("r",$item->posted);
+                               if ($entity = get_entity($item->object_guid)) {
+                                       $url = htmlspecialchars($entity->getURL());
+                               } else {
+                                       $url = $vars['url'];
+                               }
+                               $title = strip_tags($body);
+                               
+?>
+       <item>
+         <guid isPermaLink='true'><?php echo $url; ?></guid>
+         <pubDate><?php echo $time; ?></pubDate>
+         <link><?php echo $url; ?></link>
+         <title><![CDATA[<?php echo $title; ?>]]></title>
+         <description><![CDATA[<?php echo (autop($body)); ?>]]></description>
+       </item>
+<?php
+                               
+                       }
+                       
+                       $i++;
+                       if ($i >= $vars['limit']) break;
+                       
+               }
+               
+       }
+       
+
 ?>
\ No newline at end of file
index 98683d0cbe02315da2572e53763a1024a5aaa331..b3418538a1806af1e7958ced3dd680438262238d 100644 (file)
@@ -1,23 +1,23 @@
-<?php\r
-\r
-       /**\r
-        * Elgg default user view\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
 
-        * @author Curverider Ltd\r
+       /**
+        * Elgg default user view
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @link http://elgg.org/\r
-        */\r
-\r
-?>\r
-\r
-       <item>\r
-         <guid isPermaLink='true'><?php echo $vars['entity']->getURL(); ?></guid>\r
-         <pubDate><?php echo date("r",$vars['entity']->time_created) ?></pubDate>\r
-         <link><?php echo $vars['entity']->getURL(); ?></link>\r
-         <title><![CDATA[<?php echo (($vars['entity']->name)); ?>]]></title>\r
+        * @author Curverider Ltd
+
+        * @link http://elgg.org/
+        */
+
+?>
+
+       <item>
+         <guid isPermaLink='true'><?php echo $vars['entity']->getURL(); ?></guid>
+         <pubDate><?php echo date("r",$vars['entity']->time_created) ?></pubDate>
+         <link><?php echo $vars['entity']->getURL(); ?></link>
+         <title><![CDATA[<?php echo (($vars['entity']->name)); ?>]]></title>
          <description><![CDATA[<?php echo (autop($vars['entity']->description)); ?>]]></description>
          <?php
                        if (
@@ -30,5 +30,5 @@
                                <?php
                        }
          ?>
-         <?php echo elgg_view('extensions/item'); ?>\r
-       </item>\r
+         <?php echo elgg_view('extensions/item'); ?>
+       </item>
index feeb51f18d601c3da5505c1f722cd230f8ee2041..eae45f397d5e04d9f080685cb693175b4b054b6a 100644 (file)
@@ -1,22 +1,22 @@
-<?php\r
-\r
-       /**\r
-        * Elgg exception\r
-        * Displays a single exception\r
-        * \r
-        * @package Elgg\r
-        * @subpackage Core\r
+<?php
+
+       /**
+        * Elgg exception
+        * Displays a single exception
+        * 
+        * @package Elgg
+        * @subpackage Core
 
-        * @author Curverider Ltd\r
+        * @author Curverider Ltd
 
-        * @link http://elgg.org/\r
-        * \r
-        * @uses $vars['object'] An exception\r
-        */\r
+        * @link http://elgg.org/
+        * 
+        * @uses $vars['object'] An exception
+        */
 
-       global $CONFIG;\r
-?>\r
-<!-- \r
+       global $CONFIG;
+?>
+<!-- 
 <?php echo get_class($vars['object']); ?>: <?php echo autop($vars['object']->getMessage()); ?>