diff options
author | Brett Profitt <brett.profitt@gmail.com> | 2011-04-16 11:52:37 -0400 |
---|---|---|
committer | Brett Profitt <brett.profitt@gmail.com> | 2011-04-16 11:52:37 -0400 |
commit | 309dff2bf948ab191ccb1e8d4a777e49ad498820 (patch) | |
tree | 813350181be64e239287c0bb587a3a49320a49b7 /engine/lib | |
parent | 119ec1f1425ab77ed29c696d99c0c80df3886791 (diff) | |
parent | 2b2afd98c05139c1a5c25f1752e2bb412e26e335 (diff) | |
download | elgg-309dff2bf948ab191ccb1e8d4a777e49ad498820.tar.gz elgg-309dff2bf948ab191ccb1e8d4a777e49ad498820.tar.bz2 |
Merge branch 'master' of github.com:Elgg/Elgg
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/actions.php | 6 | ||||
-rw-r--r-- | engine/lib/cache.php | 2 | ||||
-rw-r--r-- | engine/lib/deprecated-1.8.php | 28 | ||||
-rw-r--r-- | engine/lib/elgglib.php | 76 | ||||
-rw-r--r-- | engine/lib/entities.php | 2 | ||||
-rw-r--r-- | engine/lib/metastrings.php | 2 | ||||
-rw-r--r-- | engine/lib/output.php | 2 | ||||
-rw-r--r-- | engine/lib/sessions.php | 4 | ||||
-rw-r--r-- | engine/lib/upgrade.php | 2 | ||||
-rw-r--r-- | engine/lib/upgrades/2011010101.php | 18 | ||||
-rw-r--r-- | engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php | 60 | ||||
-rw-r--r-- | engine/lib/widgets.php | 1 |
12 files changed, 104 insertions, 99 deletions
diff --git a/engine/lib/actions.php b/engine/lib/actions.php index 407b99f87..47e4dd4a4 100644 --- a/engine/lib/actions.php +++ b/engine/lib/actions.php @@ -113,7 +113,11 @@ function action($action, $forwarder = "") { register_error(elgg_echo('actionundefined', array($action))); } - forward($forwarder); + if (!empty($forwarder)) { + forward($forwarder); + } else { + forward(REFERER); + } } /** diff --git a/engine/lib/cache.php b/engine/lib/cache.php index d4888f9d9..8529ae7fa 100644 --- a/engine/lib/cache.php +++ b/engine/lib/cache.php @@ -166,7 +166,7 @@ function elgg_get_simplecache_url($type, $view) { if (elgg_is_simplecache_enabled()) { $viewtype = elgg_get_viewtype(); - $url = elgg_get_site_url() . "cache/$type/$view/$viewtype/$view.$lastcache.$type"; + $url = elgg_get_site_url() . "cache/$type/$viewtype/$view.$lastcache.$type"; } else { $url = elgg_get_site_url() . "$type/$view.$lastcache.$type"; } diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php index 165546d31..bb52881cd 100644 --- a/engine/lib/deprecated-1.8.php +++ b/engine/lib/deprecated-1.8.php @@ -115,7 +115,7 @@ function get_entities_from_annotations_calculate_x($sum = "sum", $entity_type = $options['limit'] = $limit; $options['offset'] = $offset; - $options['order_by'] = "calculated $orderdir"; + $options['order_by'] = "calculation $orderdir"; $options['count'] = $count; @@ -179,7 +179,7 @@ function get_entities_from_annotation_count($entity_type = "", $entity_subtype = $options['limit'] = $limit; $options['offset'] = $offset; - $options['order_by'] = "calculated $orderdir"; + $options['order_by'] = "calculation $orderdir"; $options['count'] = $count; @@ -241,7 +241,7 @@ function list_entities_from_annotation_count($entity_type = "", $entity_subtype $options['limit'] = $limit; - $options['order_by'] = "calculated $orderdir"; + $options['order_by'] = "calculation $orderdir"; return elgg_get_entities_from_annotation_calculation($options); } @@ -1152,10 +1152,22 @@ function list_entities_from_metadata($meta_name, $meta_value = "", $entity_type $offset = (int)get_input('offset'); $limit = (int)$limit; - $options = array('metadata_name' => $meta_name, 'metadata_value' => $meta_value, - 'types' => $entity_type, 'subtypes' => $entity_subtype, 'owner_guid' => $owner_guid, - 'limit' => $limit, 'offset' => $offset, 'count' => TRUE, - 'metadata_case_sensitive' => $case_sensitive); + $options = array( + 'metadata_name' => $meta_name, + 'metadata_value' => $meta_value, + 'types' => $entity_type, + 'subtypes' => $entity_subtype, + 'limit' => $limit, + 'offset' => $offset, + 'count' => TRUE, + 'metadata_case_sensitive' => $case_sensitive + ); + + // previous function allowed falsy $owner_guid for anything + if ($owner_guid) { + $options['owner_guid'] = $owner_guid; + } + $count = elgg_get_entities_from_metadata($options); $options['count'] = FALSE; @@ -3492,7 +3504,7 @@ $asc = false, $fullview = true, $listtypetoggle = false, $pagination = true, $or $options['limit'] = $limit; - $options['order_by'] = "calculated $orderdir"; + $options['order_by'] = "calculation $orderdir"; return elgg_get_entities_from_annotation_calculation($options); } diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 1aef48ef4..6c94133df 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -400,7 +400,7 @@ function elgg_get_loaded_external_files($type, $location) { if (isset($CONFIG->externals) && isset($CONFIG->externals[$type])) { $items = array_values($CONFIG->externals[$type]); - $callback = "return \$v->loaded == true && \$v->location == $location;"; + $callback = "return \$v->loaded == true && \$v->location == '$location';"; $items = array_filter($items, create_function('$v', $callback)); if ($items) { usort($items, create_function('$a,$b','return $a->priority >= $b->priority;')); @@ -1685,21 +1685,7 @@ function _elgg_shutdown_hook() { * @elgg_pagehandler js */ function elgg_js_page_handler($page) { - if (is_array($page) && sizeof($page)) { - $js = implode('/', $page); - $js = substr($js, 0, strpos($js, '.')); - $return = elgg_view('js/' . $js); - - header('Content-type: text/javascript'); - - // @todo should js be cached when simple cache turned off - //header('Expires: ' . date('r', time() + 864000)); - //header("Pragma: public"); - //header("Cache-Control: public"); - //header("Content-Length: " . strlen($return)); - - echo $return; - } + return elgg_cacheable_view_page_handler($page, 'js'); } /** @@ -1749,18 +1735,60 @@ function elgg_css_page_handler($page) { // default css $page[0] = 'elgg'; } + + return elgg_cacheable_view_page_handler($page, 'css'); +} + +/** + * Serves a JS or CSS view with headers for caching. + * + * /<css||js>/name/of/view.<last_cache>.<css||js> + * + * @param array $page The page array + * @param string $type The type: js or css + * + * @return mixed + */ +function elgg_cacheable_view_page_handler($page, $type) { + + switch ($type) { + case 'js': + $content_type = 'text/javascript'; + break; + + case 'css': + $content_type = 'text/css'; + break; + + default: + return false; + break; + } - $css = substr($page[0], 0, strpos($page[0], '.')); - $return = elgg_view("css/$css"); + if ($page) { + // the view file names can have multiple dots + // eg: views/default/js/calendars/jquery.fullcalendar.min.php + // translates to the url /js/calendars/jquery.fullcalendar.min.<ts>.js + // and the view js/calendars/jquery.fullcalendar.min + // we ignore the last two dots for the ts and the ext. + $page = implode('/', $page); + $regex = '|(.+)\.([^\.]+)\.([^.]+)$|'; + preg_match($regex, $page, $matches); + $view = $matches[1]; + $return = elgg_view("$type/$view"); - header("Content-type: text/css", true); + header("Content-type: $content_type"); - // @todo should css be cached when simple cache is turned off - //header('Expires: ' . date('r', time() + 86400000), true); - //header("Pragma: public", true); - //header("Cache-Control: public", true); + // @todo should js be cached when simple cache turned off + //header('Expires: ' . date('r', time() + 864000)); + //header("Pragma: public"); + //header("Cache-Control: public"); + //header("Content-Length: " . strlen($return)); - echo $return; + echo $return; + } + + return true; } /** diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 742630cc7..685c68a5b 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -740,7 +740,7 @@ function elgg_entity_exists($guid) { * type_subtype_pairs => NULL|ARR (array('type' => 'subtype')) * (type = '$type' AND subtype = '$subtype') pairs * - * entity_guids => NULL|ARR Array of entity guids + * guids => NULL|ARR Array of entity guids * * owner_guids => NULL|ARR Array of owner guids * diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index 6db4e6d7c..604c7f765 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -75,7 +75,7 @@ function get_metastring_id($string, $case_sensitive = TRUE) { $ids[] = $metaString->id; } return $ids; - } else if ($metaStrings) { + } else if (isset($metaStrings[0])) { $row = $metaStrings[0]; } } diff --git a/engine/lib/output.php b/engine/lib/output.php index 8c2a3d50d..3f35a1576 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -170,7 +170,7 @@ function elgg_format_attributes(array $attrs) { } // ignore $vars['entity'] => ElggEntity stuff - if (is_not_null($val) && (is_array($val) || !is_object($var))) { + if (is_not_null($val) && (is_array($val) || !is_object($val))) { // allow $vars['class'] => array('one', 'two'); // @todo what about $vars['style']? Needs to be semi-colon separated... diff --git a/engine/lib/sessions.php b/engine/lib/sessions.php index 5d45cc73d..ae42956a9 100644 --- a/engine/lib/sessions.php +++ b/engine/lib/sessions.php @@ -155,9 +155,9 @@ function elgg_authenticate($username, $password) { * @return bool * @throws LoginException */ -function pam_auth_userpass($credentials = NULL) { +function pam_auth_userpass(array $credentials = array()) { - if (!is_array($credentials) || !isset($credentials['username']) || !isset($credentials['password'])) { + if (!isset($credentials['username']) || !isset($credentials['password'])) { return false; } diff --git a/engine/lib/upgrade.php b/engine/lib/upgrade.php index 755c100dd..85810956b 100644 --- a/engine/lib/upgrade.php +++ b/engine/lib/upgrade.php @@ -147,6 +147,8 @@ function elgg_get_upgrade_files($upgrade_path = null) { $upgrade_files[] = $upgrade_file; } + sort($upgrade_files); + return $upgrade_files; } diff --git a/engine/lib/upgrades/2011010101.php b/engine/lib/upgrades/2011010101.php index be1adac1a..9dbaff1e4 100644 --- a/engine/lib/upgrades/2011010101.php +++ b/engine/lib/upgrades/2011010101.php @@ -73,3 +73,21 @@ remove_metadata($site->guid, 'pluginorder'); remove_metadata($site->guid, 'enabled_plugins'); elgg_set_ignore_access($old_id); + +/** + * @hack + * + * We stop the upgrade at this point because plugins weren't given the chance to + * load due to the new plugin code introduced with Elgg 1.8. Instead, we manually + * set the version and start the upgrade process again. + * + * The variables from upgrade_code() are available because this script was included + */ +if ($upgrade_version > $version) { + datalist_set('version', $upgrade_version); +} + +$processed_upgrades = array_unique($processed_upgrades); +datalist_set('processed_upgrades', serialize($processed_upgrades)); + +forward('upgrade.php'); diff --git a/engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php b/engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php deleted file mode 100644 index 6a5f2fa02..000000000 --- a/engine/lib/upgrades/2011032300-1.8_svn-update_default_widgets-7daf5a459720d06d.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php -/** - * Elgg 1.8-svn upgrade 2011032300 - * update_default_widgets - * - * Pre-1.8, default widgets were stored as metadata on a defaultwidgets object. - * Now they are stored as widget objects owned by the site. - */ - -$object = elgg_get_entities(array( - 'type' => 'object', - 'subtype' => 'moddefaultwidgets', - 'limit' => 1, -)); - -if (!$object) { - // nothing to upgrade - return true; -} - -$object = $object[0]; - -$site = elgg_get_site_entity(); - -$ia = elgg_set_ignore_access(true); -foreach (array('profile', 'dashboard') as $context) { - if (isset($object->$context)) { - elgg_push_context($context); - elgg_push_context('default_widgets'); - elgg_push_context('widgets'); - - // deserialize the widget information - list($left, $middle, $right) = split('%%', $object->$context); - $left_widgets = split('::', $left); - $middle_widgets = split('::', $middle); - $right_widgets = split('::', $right); - - // 1st column is right column in default theme - $widgets = array( - 1 => array_reverse($right_widgets), - 2 => array_reverse($middle_widgets), - 3 => array_reverse($left_widgets), - ); - - foreach ($widgets as $column => $column_widgets) { - foreach ($column_widgets as $handler) { - $guid = elgg_create_widget($site->getGUID(), $handler, $context); - if ($guid) { - $widget = get_entity($guid); - $widget->move($column, 0); - } - } - } - - elgg_pop_context(); - elgg_pop_context(); - elgg_pop_context(); - } -} -elgg_set_ignore_access($ia); diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php index b20f92f74..cc3cf20e4 100644 --- a/engine/lib/widgets.php +++ b/engine/lib/widgets.php @@ -272,6 +272,7 @@ function elgg_widgets_init() { elgg_register_action('widgets/add'); elgg_register_action('widgets/move'); elgg_register_action('widgets/delete'); + elgg_register_action('widgets/upgrade', '', 'admin'); run_function_once("elgg_widget_run_once"); } |