aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/elgglib.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/elgglib.php')
-rw-r--r--engine/lib/elgglib.php81
1 files changed, 58 insertions, 23 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 198ffe60c..08b346960 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -18,6 +18,7 @@ elgg_register_classes(dirname(dirname(__FILE__)) . '/classes');
*
* @return void
* @throws Exception
+ * @access private
*/
function _elgg_autoload($class) {
global $CONFIG;
@@ -143,9 +144,9 @@ function forward($location = "", $reason = 'system') {
} else if ($location === '') {
exit;
}
+ } else {
+ throw new SecurityException(elgg_echo('SecurityException:ForwardFailedToRedirect'));
}
-
- return false;
}
/**
@@ -278,7 +279,7 @@ function elgg_get_loaded_css() {
* @return bool
* @since 1.8.0
*/
-function elgg_register_external_file($type, $name, $url, $location, $priority = null) {
+function elgg_register_external_file($type, $name, $url, $location, $priority = 500) {
global $CONFIG;
if (empty($name) || empty($url)) {
@@ -291,7 +292,15 @@ function elgg_register_external_file($type, $name, $url, $location, $priority =
elgg_bootstrap_externals_data_structure($type);
$name = trim(strtolower($name));
+
+ // normalize bogus priorities, but allow empty, null, and false to be defaults.
+ if (!is_numeric($priority)) {
+ $priority = 500;
+ }
+
+ // no negative priorities right now.
$priority = max((int)$priority, 0);
+
$item = elgg_extract($name, $CONFIG->externals_map[$type]);
if ($item) {
@@ -406,6 +415,7 @@ function elgg_get_loaded_external_files($type, $location) {
* Bootstraps the externals data structure in $CONFIG.
*
* @param string $type The type of external, js or css.
+ * @access private
*/
function elgg_bootstrap_externals_data_structure($type) {
global $CONFIG;
@@ -414,7 +424,7 @@ function elgg_bootstrap_externals_data_structure($type) {
$CONFIG->externals = array();
}
- if (!$CONFIG->externals[$type] instanceof ElggPriorityList) {
+ if (!isset($CONFIG->externals[$type]) || !$CONFIG->externals[$type] instanceof ElggPriorityList) {
$CONFIG->externals[$type] = new ElggPriorityList();
}
@@ -979,6 +989,7 @@ function elgg_trigger_plugin_hook($hook, $type, $params = null, $returnvalue = n
* @param Exception $exception The exception being handled
*
* @return void
+ * @access private
*/
function _elgg_php_exception_handler($exception) {
error_log("*** FATAL EXCEPTION *** : " . $exception);
@@ -1027,6 +1038,7 @@ function _elgg_php_exception_handler($exception) {
* @param array $vars An array that points to the active symbol table where error occurred
*
* @return true
+ * @access private
*/
function _elgg_php_error_handler($errno, $errmsg, $filename, $linenum, $vars) {
$error = date("Y-m-d H:i:s (T)") . ": \"$errmsg\" in file $filename (line $linenum)";
@@ -1463,8 +1475,12 @@ function elgg_http_url_is_identical($url1, $url2, $ignore_params = array('offset
$url1_info = parse_url($url1);
$url2_info = parse_url($url2);
- $url1_info['path'] = trim($url1_info['path'], '/');
- $url2_info['path'] = trim($url2_info['path'], '/');
+ if (isset($url1_info['path'])) {
+ $url1_info['path'] = trim($url1_info['path'], '/');
+ }
+ if (isset($url2_info['path'])) {
+ $url2_info['path'] = trim($url2_info['path'], '/');
+ }
// compare basic bits
$parts = array('scheme', 'host', 'path');
@@ -1661,9 +1677,9 @@ function is_not_null($string) {
* @param array $options The options array. $options['keys'] = 'values';
* @param array $singulars A list of singular words to pluralize by adding 's'.
*
- * @access private
* @return array
* @since 1.7.0
+ * @access private
*/
function elgg_normalise_plural_options_array($options, $singulars) {
foreach ($singulars as $singular) {
@@ -1701,6 +1717,7 @@ function elgg_normalise_plural_options_array($options, $singulars) {
*
* @return void
* @see register_shutdown_hook()
+ * @access private
*/
function _elgg_shutdown_hook() {
global $START_MICROTIME;
@@ -1727,8 +1744,9 @@ function _elgg_shutdown_hook() {
*
* @param array $page The page array
*
- * @return void
+ * @return bool
* @elgg_pagehandler js
+ * @access private
*/
function elgg_js_page_handler($page) {
return elgg_cacheable_view_page_handler($page, 'js');
@@ -1741,8 +1759,9 @@ function elgg_js_page_handler($page) {
*
* @param array $page The page array
*
- * @return void
+ * @return bool
* @elgg_pagehandler ajax
+ * @access private
*/
function elgg_ajax_page_handler($page) {
if (is_array($page) && sizeof($page)) {
@@ -1761,9 +1780,9 @@ function elgg_ajax_page_handler($page) {
}
echo elgg_view($view, $vars);
+ return true;
}
-
- return true;
+ return false;
}
/**
@@ -1775,6 +1794,7 @@ function elgg_ajax_page_handler($page) {
*
* @return void
* @elgg_pagehandler css
+ * @access private
*/
function elgg_css_page_handler($page) {
if (!isset($page[0])) {
@@ -1793,7 +1813,8 @@ function elgg_css_page_handler($page) {
* @param array $page The page array
* @param string $type The type: js or css
*
- * @return mixed
+ * @return bool
+ * @access private
*/
function elgg_cacheable_view_page_handler($page, $type) {
@@ -1833,9 +1854,8 @@ function elgg_cacheable_view_page_handler($page, $type) {
//header("Content-Length: " . strlen($return));
echo $return;
+ return true;
}
-
- return true;
}
/**
@@ -1847,6 +1867,7 @@ function elgg_cacheable_view_page_handler($page, $type) {
* @param string $order_by An order by clause
* @access private
* @return string
+ * @access private
*/
function elgg_sql_reverse_order_by_clause($order_by) {
$order_by = strtolower($order_by);
@@ -1868,9 +1889,11 @@ function elgg_sql_reverse_order_by_clause($order_by) {
*
* Used as a callback for ElggBatch.
*
+ * @todo why aren't these static methods on ElggBatch?
+ *
* @param object $object The object to enable
- * @access private
* @return bool
+ * @access private
*/
function elgg_batch_enable_callback($object) {
// our db functions return the number of rows affected...
@@ -1883,8 +1906,8 @@ function elgg_batch_enable_callback($object) {
* Used as a callback for ElggBatch.
*
* @param object $object The object to disable
- * @access private
* @return bool
+ * @access private
*/
function elgg_batch_disable_callback($object) {
// our db functions return the number of rows affected...
@@ -1897,8 +1920,8 @@ function elgg_batch_disable_callback($object) {
* Used as a callback for ElggBatch.
*
* @param object $object The object to disable
- * @access private
* @return bool
+ * @access private
*/
function elgg_batch_delete_callback($object) {
// our db functions return the number of rows affected...
@@ -1912,6 +1935,7 @@ function elgg_batch_delete_callback($object) {
* @param array $options Options array
* @param string $type Options type: metadata or annotations
* @return bool
+ * @access private
*/
function elgg_is_valid_options_for_batch_operation($options, $type) {
if (!$options || !is_array($options)) {
@@ -1965,15 +1989,18 @@ function elgg_is_valid_options_for_batch_operation($options, $type) {
*
* @link http://docs.elgg.org/Tutorials/WalledGarden
* @elgg_plugin_hook index system
- * @return boolean
+ * @return bool
+ * @access private
*/
function elgg_walled_garden_index() {
elgg_register_css('elgg.walled_garden', '/css/walled_garden.css');
elgg_load_css('elgg.walled_garden');
+ elgg_register_js('elgg.walled_garden', '/js/walled_garden.js');
+ elgg_load_js('elgg.walled_garden');
- $login = elgg_view('core/account/login_walled_garden');
+ $body = elgg_view('core/walled_garden/body');
- echo elgg_view_page('', $login, 'walled_garden');
+ echo elgg_view_page('', $body, 'walled_garden');
// return true to prevent other plugins from adding a front page
return true;
@@ -1991,6 +2018,7 @@ function elgg_walled_garden_index() {
* @elgg_event_handler init system
* @link http://docs.elgg.org/Tutorials/WalledGarden
* @return void
+ * @access private
*/
function elgg_walled_garden() {
global $CONFIG;
@@ -2008,6 +2036,7 @@ function elgg_walled_garden() {
*
* @elgg_event_handler init system
* @return void
+ * @access private
*/
function elgg_init() {
global $CONFIG;
@@ -2019,11 +2048,16 @@ function elgg_init() {
elgg_register_page_handler('css', 'elgg_css_page_handler');
elgg_register_page_handler('ajax', 'elgg_ajax_page_handler');
- elgg_register_js('elgg.autocomplete', 'js/lib/autocomplete.js');
- elgg_register_js('elgg.userpicker', 'js/lib/userpicker.js');
- elgg_register_js('elgg.friendspicker', 'js/lib/friends_picker.js');
+ elgg_register_js('elgg.autocomplete', 'js/lib/ui.autocomplete.js');
+ elgg_register_js('jquery.ui.autocomplete.html', 'vendors/jquery/jquery.ui.autocomplete.html.js');
+ elgg_register_js('elgg.userpicker', 'js/lib/ui.userpicker.js');
+ elgg_register_js('elgg.friendspicker', 'js/lib/ui.friends_picker.js');
elgg_register_js('jquery.easing', 'vendors/jquery/jquery.easing.1.3.packed.js');
+ elgg_register_js('elgg.avatar_cropper', 'js/lib/ui.avatar_cropper.js');
+ elgg_register_js('jquery.imgareaselect', 'vendors/jquery/jquery.imgareaselect-0.9.8/scripts/jquery.imgareaselect.min.js');
+ elgg_register_css('jquery.imgareaselect', 'vendors/jquery/jquery.imgareaselect-0.9.8/css/imgareaselect-deprecated.css');
+
// Trigger the shutdown:system event upon PHP shutdown.
register_shutdown_function('_elgg_shutdown_hook');
@@ -2058,6 +2092,7 @@ function elgg_init() {
*
* @elgg_plugin_hook unit_tests system
* @return void
+ * @access private
*/
function elgg_api_test($hook, $type, $value, $params) {
global $CONFIG;