From 9590b4684d4ff87a5986742bf00ea0a91e061b0c Mon Sep 17 00:00:00 2001
From: Sem
Date: Mon, 9 Jul 2012 02:02:59 +0200
Subject: Fixes #4643. Locks the upgrade process while it is running.
---
upgrade.php | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/upgrade.php b/upgrade.php
index 60764ba93..38be476a4 100644
--- a/upgrade.php
+++ b/upgrade.php
@@ -13,6 +13,35 @@
* @subpackage Upgrade
*/
+function upgrade_lock() {
+ global $CONFIG, $DB_QUERY_CACHE;
+
+ $is_locked = count(get_data("show tables like '{$CONFIG->dbprefix}locked'"));
+
+ // Invalidate query cache
+ if ($DB_QUERY_CACHE) {
+ $DB_QUERY_CACHE->clear();
+ elgg_log("Query cache invalidated", 'NOTICE');
+ }
+
+ if (!$is_locked) {
+ // lock it
+ insert_data("create table {$CONFIG->dbprefix}locked (id INT)");
+ error_log('Upgrade continue running');
+ return true;
+ }
+
+ error_log('Upgrade is locked');
+ return false;
+}
+
+function upgrade_unlock() {
+ global $CONFIG;
+ delete_data("drop table {$CONFIG->dbprefix}locked");
+ error_log('Upgrade unlocks itself');
+}
+
+
// we want to know if an error occurs
ini_set('display_errors', 1);
@@ -20,6 +49,12 @@ define('UPGRADING', 'upgrading');
require_once(dirname(__FILE__) . "/engine/start.php");
if (get_input('upgrade') == 'upgrade') {
+
+ // prevent someone from running the upgrade script in parallel (see #4643)
+ if (!upgrade_lock()) {
+ forward();
+ }
+
// disable the system log for upgrades to avoid exceptions when the schema changes.
elgg_unregister_event_handler('log', 'systemlog', 'system_log_default_logger');
elgg_unregister_event_handler('all', 'all', 'system_log_listener');
@@ -33,6 +68,10 @@ if (get_input('upgrade') == 'upgrade') {
elgg_trigger_event('upgrade', 'system', null);
elgg_invalidate_simplecache();
elgg_reset_system_cache();
+
+ // critical region has past
+ upgrade_unlock();
+
} else {
// if upgrading from < 1.8.0, check for the core view 'welcome' and bail if it's found.
// see http://trac.elgg.org/ticket/3064
@@ -53,4 +92,4 @@ if (get_input('upgrade') == 'upgrade') {
exit;
}
-forward();
\ No newline at end of file
+forward();
--
cgit v1.2.3
From 1d2ce9657a44398646ed1a3980d89a1d2f50fa05 Mon Sep 17 00:00:00 2001
From: Sem
Date: Fri, 13 Jul 2012 07:42:36 +0200
Subject: Fixes #1334. Added dropdown to change the parent of a page.
---
mod/pages/actions/pages/edit.php | 3 ++
mod/pages/languages/en.php | 3 +-
mod/pages/lib/pages.php | 53 +++++++++++++++++++++-------
mod/pages/start.php | 1 +
mod/pages/views/default/forms/pages/edit.php | 10 +++---
mod/pages/views/default/input/parent.php | 37 +++++++++++++++++++
6 files changed, 87 insertions(+), 20 deletions(-)
create mode 100644 mod/pages/views/default/input/parent.php
diff --git a/mod/pages/actions/pages/edit.php b/mod/pages/actions/pages/edit.php
index a32e4a4ba..e6387c1a4 100644
--- a/mod/pages/actions/pages/edit.php
+++ b/mod/pages/actions/pages/edit.php
@@ -59,6 +59,9 @@ if (sizeof($input) > 0) {
if (($name == 'access_id' || $name == 'write_access_id') && !$can_change_access) {
continue;
}
+ if ($name == 'parent_guid') {
+ continue;
+ }
$page->$name = $value;
}
diff --git a/mod/pages/languages/en.php b/mod/pages/languages/en.php
index eb9d22708..930676b3e 100644
--- a/mod/pages/languages/en.php
+++ b/mod/pages/languages/en.php
@@ -61,6 +61,7 @@ View and comment on the new page:
'pages:title' => 'Page title',
'pages:description' => 'Page text',
'pages:tags' => 'Tags',
+ 'pages:parent_guid' => 'Parent page',
'pages:access_id' => 'Read access',
'pages:write_access_id' => 'Write access',
@@ -110,4 +111,4 @@ View and comment on the new page:
'pages:backtoparent' => "Back to '%s'",
);
-add_translation("en", $english);
\ No newline at end of file
+add_translation("en", $english);
diff --git a/mod/pages/lib/pages.php b/mod/pages/lib/pages.php
index 9a9ba12e9..afe42b68f 100644
--- a/mod/pages/lib/pages.php
+++ b/mod/pages/lib/pages.php
@@ -65,11 +65,11 @@ function pages_prepare_parent_breadcrumbs($page) {
}
/**
- * Register the navigation menu
+ * Produce the navigation tree
*
* @param ElggEntity $container Container entity for the pages
*/
-function pages_register_navigation_tree($container) {
+function pages_get_navigation_tree($container) {
if (!$container) {
return;
}
@@ -84,13 +84,18 @@ function pages_register_navigation_tree($container) {
if (!$top_pages) {
return;
}
+
+ $tree = array();
+ $depths = array();
foreach ($top_pages as $page) {
- elgg_register_menu_item('pages_nav', array(
- 'name' => $page->getGUID(),
- 'text' => $page->title,
- 'href' => $page->getURL(),
- ));
+ $tree[] = array(
+ 'guid' => $page->getGUID(),
+ 'title' => $page->title,
+ 'url' => $page->getURL(),
+ 'depth' => 0,
+ );
+ $depths[$page->guid] = 0;
$stack = array();
array_push($stack, $page);
@@ -106,15 +111,37 @@ function pages_register_navigation_tree($container) {
if ($children) {
foreach ($children as $child) {
- elgg_register_menu_item('pages_nav', array(
- 'name' => $child->getGUID(),
- 'text' => $child->title,
- 'href' => $child->getURL(),
- 'parent_name' => $parent->getGUID(),
- ));
+ $tree[] = array(
+ 'guid' => $child->getGUID(),
+ 'title' => $child->title,
+ 'url' => $child->getURL(),
+ 'parent_guid' => $parent->getGUID(),
+ 'depth' => $depths[$parent->guid] + 1,
+ );
+ $depths[$child->guid] = $depths[$parent->guid] + 1;
array_push($stack, $child);
}
}
}
}
+ return $tree;
+}
+
+/**
+ * Register the navigation menu
+ *
+ * @param ElggEntity $container Container entity for the pages
+ */
+function pages_register_navigation_tree($container) {
+ $pages = pages_get_navigation_tree($container);
+ if ($pages) {
+ foreach ($pages as $page) {
+ elgg_register_menu_item('pages_nav', array(
+ 'name' => $page['guid'],
+ 'text' => $page['title'],
+ 'href' => $page['url'],
+ 'parent_name' => $page['parent_guid'],
+ ));
+ }
+ }
}
diff --git a/mod/pages/start.php b/mod/pages/start.php
index 6b0ad38b0..6d974f122 100644
--- a/mod/pages/start.php
+++ b/mod/pages/start.php
@@ -63,6 +63,7 @@ function pages_init() {
'title' => 'text',
'description' => 'longtext',
'tags' => 'tags',
+ 'parent_guid' => 'parent',
'access_id' => 'access',
'write_access_id' => 'write_access',
));
diff --git a/mod/pages/views/default/forms/pages/edit.php b/mod/pages/views/default/forms/pages/edit.php
index 9469f5eb9..119b9ba23 100644
--- a/mod/pages/views/default/forms/pages/edit.php
+++ b/mod/pages/views/default/forms/pages/edit.php
@@ -18,6 +18,9 @@ foreach ($variables as $name => $type) {
if (($type == 'access' || $type == 'write_access') && !$can_change_access) {
continue;
}
+ if ($name == 'parent_guid' && empty($vars['parent_guid'])) {
+ continue;
+ }
?>
@@ -29,6 +32,7 @@ foreach ($variables as $name => $type) {
echo elgg_view("input/$type", array(
'name' => $name,
'value' => $vars[$name],
+ 'entity' => ($name == 'parent_guid') ? $vars['entity'] : null,
));
?>
@@ -52,12 +56,6 @@ echo elgg_view('input/hidden', array(
'name' => 'container_guid',
'value' => $vars['container_guid'],
));
-if ($vars['parent_guid']) {
- echo elgg_view('input/hidden', array(
- 'name' => 'parent_guid',
- 'value' => $vars['parent_guid'],
- ));
-}
echo elgg_view('input/submit', array('value' => elgg_echo('save')));
diff --git a/mod/pages/views/default/input/parent.php b/mod/pages/views/default/input/parent.php
new file mode 100644
index 000000000..f354129fe
--- /dev/null
+++ b/mod/pages/views/default/input/parent.php
@@ -0,0 +1,37 @@
+getContainerEntity();
+}
+
+$pages = pages_get_navigation_tree($container);
+$options = array();
+
+foreach ($pages as $page) {
+ $spacing = "";
+ for ($i = 0; $i < $page['depth']; $i++) {
+ $spacing .= "--";
+ }
+ $options[$page['guid']] = "$spacing " . $page['title'];
+}
+
+$defaults = array(
+ 'class' => 'elgg-input-parent-picker',
+ 'options_values' => $options,
+);
+
+$vars = array_merge($defaults, $vars);
+
+echo elgg_view('input/dropdown', $vars);
--
cgit v1.2.3
From 3bd71fbe0aa4a64021c4c2d59b0782faba8c22b6 Mon Sep 17 00:00:00 2001
From: Sem
Date: Sat, 14 Jul 2012 21:42:20 +0200
Subject: Refs #1334. Prevent cycles in the pages tree.
---
mod/pages/actions/pages/edit.php | 22 +++++++++++++++++++++-
mod/pages/views/default/forms/pages/edit.php | 3 ++-
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/mod/pages/actions/pages/edit.php b/mod/pages/actions/pages/edit.php
index e6387c1a4..bf54ae87d 100644
--- a/mod/pages/actions/pages/edit.php
+++ b/mod/pages/actions/pages/edit.php
@@ -70,7 +70,27 @@ if (sizeof($input) > 0) {
// need to add check to make sure user can write to container
$page->container_guid = $container_guid;
-if ($parent_guid) {
+if ($parent_guid && $parent_guid != $page_guid) {
+ // Check if parent isn't below of the page in the tree
+ if ($page_guid) {
+ $tree_page = get_entity($parent_guid);
+ while ($tree_page->parent_guid > 0 && $page_guid != $tree_page->guid) {
+ $tree_page = get_entity($tree_page->parent_guid);
+ }
+ // If is below, bring all child elements forward
+ if ($page_guid == $tree_page->guid) {
+ $previous_parent = $page->parent_guid;
+ $children = elgg_get_entities_from_metadata(array(
+ 'metadata_name' => 'parent_guid',
+ 'metadata_value' => $page->getGUID()
+ ));
+ if ($children) {
+ foreach ($children as $child) {
+ $child->parent_guid = $previous_parent;
+ }
+ }
+ }
+ }
$page->parent_guid = $parent_guid;
}
diff --git a/mod/pages/views/default/forms/pages/edit.php b/mod/pages/views/default/forms/pages/edit.php
index 119b9ba23..583dc414f 100644
--- a/mod/pages/views/default/forms/pages/edit.php
+++ b/mod/pages/views/default/forms/pages/edit.php
@@ -18,7 +18,8 @@ foreach ($variables as $name => $type) {
if (($type == 'access' || $type == 'write_access') && !$can_change_access) {
continue;
}
- if ($name == 'parent_guid' && empty($vars['parent_guid'])) {
+ // don't show parent picker input for top or new pages.
+ if ($name == 'parent_guid' && (!$vars['parent_guid'] || !$vars['guid'])) {
continue;
}
?>
--
cgit v1.2.3
From 21eb7616a11906a19260a081070a6b1c51820fa3 Mon Sep 17 00:00:00 2001
From: Sem
Date: Sat, 14 Jul 2012 22:24:09 +0200
Subject: Refs #1334. Readded hidden input in edit page form, only on page
creation.
---
mod/pages/views/default/forms/pages/edit.php | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mod/pages/views/default/forms/pages/edit.php b/mod/pages/views/default/forms/pages/edit.php
index 583dc414f..653a7ee47 100644
--- a/mod/pages/views/default/forms/pages/edit.php
+++ b/mod/pages/views/default/forms/pages/edit.php
@@ -57,6 +57,12 @@ echo elgg_view('input/hidden', array(
'name' => 'container_guid',
'value' => $vars['container_guid'],
));
+if (!$vars['guid']) {
+ echo elgg_view('input/hidden', array(
+ 'name' => 'parent_guid',
+ 'value' => $vars['parent_guid'],
+ ));
+}
echo elgg_view('input/submit', array('value' => elgg_echo('save')));
--
cgit v1.2.3
From b134c8c70cc310e8170da44d1e2291f507cb31ff Mon Sep 17 00:00:00 2001
From: Matt Beckett
Date: Sun, 15 Jul 2012 01:40:02 -0600
Subject: persist 'selected' state of site menu
---
engine/lib/navigation.php | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 4ff009bfb..8845d5164 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -308,6 +308,41 @@ function elgg_site_menu_setup($hook, $type, $return, $params) {
$return['more'] = array_splice($return['default'], $max_display_items);
}
}
+
+ // check if we have anything selected
+ $selected = false;
+ foreach ($return as $section_name => $section) {
+ foreach ($section as $key => $item) {
+ if ($item->getSelected()) {
+ $selected = true;
+ break 2;
+ }
+ }
+ }
+
+ if (!$selected) {
+ // nothing selected, match by handler
+ $handler = get_input('handler');
+
+ foreach ($return as $section_name => $section) {
+ foreach ($section as $key => $item) {
+ // determine the 'handler' of this url, if there is one
+ if (strpos($item->getHref(), elgg_get_site_url()) === 0) {
+ // this is an internal link, so it has a page handler
+ $path = array(str_replace(elgg_get_site_url(), '', $item->getHref()));
+ $separators = array('/', '?', '#');
+ foreach ($separators as $separator) {
+ $path = explode($separator, $path[0]);
+ }
+
+ if ($path[0] == $handler) {
+ $return[$section_name][$key]->setSelected(true);
+ break 2;
+ }
+ }
+ }
+ }
+ }
return $return;
}
--
cgit v1.2.3
From dce60b43126dcaa38e6845ae45e09db87aa7e229 Mon Sep 17 00:00:00 2001
From: Sem
Date: Tue, 17 Jul 2012 02:46:53 +0200
Subject: Refs #4643. Added unlock upgrade action.
---
actions/admin/site/unlock_upgrade.php | 23 ++++++++++++++++++
engine/lib/admin.php | 1 +
languages/en.php | 3 +++
upgrade.php | 2 ++
views/default/widgets/control_panel/content.php | 32 ++++++++++++++++++++-----
5 files changed, 55 insertions(+), 6 deletions(-)
create mode 100644 actions/admin/site/unlock_upgrade.php
diff --git a/actions/admin/site/unlock_upgrade.php b/actions/admin/site/unlock_upgrade.php
new file mode 100644
index 000000000..b73cf7033
--- /dev/null
+++ b/actions/admin/site/unlock_upgrade.php
@@ -0,0 +1,23 @@
+dbprefix}locked'"));
+
+// Invalidate query cache
+if ($DB_QUERY_CACHE) {
+ $DB_QUERY_CACHE->clear();
+ elgg_log("Query cache invalidated", 'NOTICE');
+}
+
+if ($is_locked) {
+ // @todo Move to ElggUpgradeManager::unlock() when #4682 fixed.
+ delete_data("drop table {$CONFIG->dbprefix}locked");
+ error_log('Upgrade unlocks itself');
+}
+system_message(elgg_echo('upgrade:unlock:success'));
+forward(REFERER);
\ No newline at end of file
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index b65d98c95..4673805f0 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -233,6 +233,7 @@ function admin_init() {
elgg_register_action('admin/site/update_basic', '', 'admin');
elgg_register_action('admin/site/update_advanced', '', 'admin');
elgg_register_action('admin/site/flush_cache', '', 'admin');
+ elgg_register_action('admin/site/unlock_upgrade', '', 'admin');
elgg_register_action('admin/menu/save', '', 'admin');
diff --git a/languages/en.php b/languages/en.php
index 18d0c88d9..159867e2f 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -1047,6 +1047,9 @@ Once you have logged in, we highly recommend that you change your password.
'upgrading' => 'Upgrading...',
'upgrade:db' => 'Your database was upgraded.',
'upgrade:core' => 'Your Elgg installation was upgraded.',
+ 'upgrade:unlock' => 'Unlock upgrade',
+ 'upgrade:unlock:confirm' => "Somebody is performing an upgrade. You should cancel and wait until upgrade is done. Are you sure you want to continue?",
+ 'upgrade:unlock:success' => "Upgrade unlocked suscessfully.",
'upgrade:unable_to_upgrade' => 'Unable to upgrade.',
'upgrade:unable_to_upgrade_info' =>
'This installation cannot be upgraded because legacy views
diff --git a/upgrade.php b/upgrade.php
index 38be476a4..e1f3c6b9e 100644
--- a/upgrade.php
+++ b/upgrade.php
@@ -13,6 +13,7 @@
* @subpackage Upgrade
*/
+// @todo Move to ElggUpgradeManager::lock() when #4628 fixed.
function upgrade_lock() {
global $CONFIG, $DB_QUERY_CACHE;
@@ -35,6 +36,7 @@ function upgrade_lock() {
return false;
}
+// @todo Move to ElggUpgradeManager::unlock() when #4682 fixed.
function upgrade_unlock() {
global $CONFIG;
delete_data("drop table {$CONFIG->dbprefix}locked");
diff --git a/views/default/widgets/control_panel/content.php b/views/default/widgets/control_panel/content.php
index d2db54bc6..e6763d851 100644
--- a/views/default/widgets/control_panel/content.php
+++ b/views/default/widgets/control_panel/content.php
@@ -11,12 +11,32 @@ elgg_register_menu_item('admin_control_panel', array(
'link_class' => 'elgg-button elgg-button-action',
));
-elgg_register_menu_item('admin_control_panel', array(
- 'name' => 'upgrade',
- 'text' => elgg_echo('upgrade'),
- 'href' => 'upgrade.php',
- 'link_class' => 'elgg-button elgg-button-action',
-));
+// @todo Move in this in ElggUpgradeManager::isLocked() when #4682 fixed
+global $CONFIG, $DB_QUERY_CACHE;
+$is_locked = count(get_data("show tables like '{$CONFIG->dbprefix}locked'"));
+// Invalidate query cache
+if ($DB_QUERY_CACHE) {
+ $DB_QUERY_CACHE->clear();
+ elgg_log("Query cache invalidated", 'NOTICE');
+}
+
+if (!$is_locked) {
+ elgg_register_menu_item('admin_control_panel', array(
+ 'name' => 'upgrade',
+ 'text' => elgg_echo('upgrade'),
+ 'href' => 'upgrade.php',
+ 'link_class' => 'elgg-button elgg-button-action',
+ ));
+} else {
+ elgg_register_menu_item('admin_control_panel', array(
+ 'name' => 'unlock_upgrade',
+ 'text' => elgg_echo('upgrade:unlock'),
+ 'href' => 'action/admin/site/unlock_upgrade',
+ 'is_action' => true,
+ 'link_class' => 'elgg-button elgg-button-delete',
+ 'confirm' => elgg_echo('upgrade:unlock:confirm'),
+ ));
+}
echo elgg_view_menu('admin_control_panel', array(
'class' => 'elgg-menu-hz',
--
cgit v1.2.3
From b336f1065259b28113be1bca11dabe3ac167bd1a Mon Sep 17 00:00:00 2001
From: Matt Beckett
Date: Tue, 17 Jul 2012 22:39:49 -0600
Subject: switched to matching by link name - same results, simpler code
---
engine/lib/navigation.php | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 8845d5164..a9d28e22e 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -321,21 +321,12 @@ function elgg_site_menu_setup($hook, $type, $return, $params) {
}
if (!$selected) {
- // nothing selected, match by handler
- $handler = get_input('handler');
-
+ // nothing selected, match name to context
foreach ($return as $section_name => $section) {
foreach ($section as $key => $item) {
- // determine the 'handler' of this url, if there is one
+ // only highlight internal links
if (strpos($item->getHref(), elgg_get_site_url()) === 0) {
- // this is an internal link, so it has a page handler
- $path = array(str_replace(elgg_get_site_url(), '', $item->getHref()));
- $separators = array('/', '?', '#');
- foreach ($separators as $separator) {
- $path = explode($separator, $path[0]);
- }
-
- if ($path[0] == $handler) {
+ if ($item->getName() == elgg_get_context()) {
$return[$section_name][$key]->setSelected(true);
break 2;
}
--
cgit v1.2.3
From ef351d0cf8a866cb40285e71fe5ed2b980bd11ed Mon Sep 17 00:00:00 2001
From: Steve Clay
Date: Sun, 5 Aug 2012 21:03:35 -0400
Subject: Fixes #4764: Twitter login supports persistent and referrer
forwarding
---
actions/login.php | 4 +-
engine/classes/ElggSession.php | 14 ++++---
mod/twitter_api/lib/twitter_api.php | 44 +++++++++++++++++++---
mod/twitter_api/start.php | 9 +++--
mod/twitter_api/views/default/twitter_api/css.php | 2 +-
mod/twitter_api/views/default/twitter_api/js.php | 16 ++++++++
.../views/default/twitter_api/login.php | 2 +-
7 files changed, 72 insertions(+), 19 deletions(-)
create mode 100644 mod/twitter_api/views/default/twitter_api/js.php
diff --git a/actions/login.php b/actions/login.php
index ea7fb3508..1e5e92ede 100644
--- a/actions/login.php
+++ b/actions/login.php
@@ -7,7 +7,7 @@
*/
// set forward url
-if (isset($_SESSION['last_forward_from']) && $_SESSION['last_forward_from']) {
+if (!empty($_SESSION['last_forward_from'])) {
$forward_url = $_SESSION['last_forward_from'];
unset($_SESSION['last_forward_from']);
} elseif (get_input('returntoreferer')) {
@@ -19,7 +19,7 @@ if (isset($_SESSION['last_forward_from']) && $_SESSION['last_forward_from']) {
$username = get_input('username');
$password = get_input('password', null, false);
-$persistent = get_input("persistent", false);
+$persistent = (bool) get_input("persistent");
$result = false;
if (empty($username) || empty($password)) {
diff --git a/engine/classes/ElggSession.php b/engine/classes/ElggSession.php
index 13a33736c..9750f063e 100644
--- a/engine/classes/ElggSession.php
+++ b/engine/classes/ElggSession.php
@@ -54,7 +54,7 @@ class ElggSession implements ArrayAccess {
*
* @param mixed $key Name
*
- * @return void
+ * @return mixed
*/
function offsetGet($key) {
if (!ElggSession::$__localcache) {
@@ -98,7 +98,7 @@ class ElggSession implements ArrayAccess {
*
* @param int $offset Offset
*
- * @return int
+ * @return bool
*/
function offsetExists($offset) {
if (isset(ElggSession::$__localcache[$offset])) {
@@ -112,6 +112,8 @@ class ElggSession implements ArrayAccess {
if ($this->offsetGet($offset)) {
return true;
}
+
+ return false;
}
@@ -132,10 +134,10 @@ class ElggSession implements ArrayAccess {
* @param string $key Name
* @param mixed $value Value
*
- * @return mixed
+ * @return void
*/
function set($key, $value) {
- return $this->offsetSet($key, $value);
+ $this->offsetSet($key, $value);
}
/**
@@ -143,9 +145,9 @@ class ElggSession implements ArrayAccess {
*
* @param string $key Name
*
- * @return bool
+ * @return void
*/
function del($key) {
- return $this->offsetUnset($key);
+ $this->offsetUnset($key);
}
}
diff --git a/mod/twitter_api/lib/twitter_api.php b/mod/twitter_api/lib/twitter_api.php
index fbce00d34..81c9c6628 100644
--- a/mod/twitter_api/lib/twitter_api.php
+++ b/mod/twitter_api/lib/twitter_api.php
@@ -29,6 +29,8 @@ function twitter_api_allow_sign_on_with_twitter() {
* This includes the login URL as the callback
*/
function twitter_api_forward() {
+ global $SESSION;
+
// sanity check
if (!twitter_api_allow_sign_on_with_twitter()) {
forward();
@@ -37,6 +39,18 @@ function twitter_api_forward() {
$callback = elgg_normalize_url("twitter_api/login");
$request_link = twitter_api_get_authorize_url($callback);
+ // capture metadata about login to persist through redirects
+ $login_metadata = array(
+ 'persistent' => (bool) get_input("persistent"),
+ );
+ // capture referrer if in site, but not the twitter_api
+ if (!empty($_SERVER['HTTP_REFERER'])
+ && 0 === strpos($_SERVER['HTTP_REFERER'], elgg_get_site_url())
+ && 0 !== strpos($_SERVER['HTTP_REFERER'], elgg_get_site_url() . 'twitter_api/')) {
+ $login_metadata['forward'] = $_SERVER['HTTP_REFERER'];
+ }
+ $SESSION['twitter_api_login_metadata'] = $login_metadata;
+
forward($request_link, 'twitter_api');
}
@@ -55,6 +69,8 @@ function twitter_api_forward() {
* the Twitter OAuth data.
*/
function twitter_api_login() {
+ /* @var ElggSession $SESSION */
+ global $SESSION;
// sanity check
if (!twitter_api_allow_sign_on_with_twitter()) {
@@ -62,6 +78,20 @@ function twitter_api_login() {
}
$token = twitter_api_get_access_token(get_input('oauth_verifier'));
+
+ $persistent = false;
+ $forward = '';
+
+ // fetch login metadata from session
+ $login_metadata = $SESSION['twitter_api_login_metadata'];
+ unset($SESSION['twitter_api_login_metadata']);
+ if (!empty($login_metadata['persistent'])) {
+ $persistent = true;
+ }
+ if (!empty($login_metadata['forward'])) {
+ $forward = $login_metadata['forward'];
+ }
+
if (!isset($token['oauth_token']) or !isset($token['oauth_token_secret'])) {
register_error(elgg_echo('twitter_api:login:error'));
forward();
@@ -81,13 +111,13 @@ function twitter_api_login() {
$users = elgg_get_entities_from_plugin_user_settings($options);
if ($users) {
- if (count($users) == 1 && login($users[0])) {
- system_message(elgg_echo('twitter_api:login:success'));
+ if (count($users) == 1 && login($users[0], $persistent)) {
+ system_message(elgg_echo('twitter_api:login:success'));
+ forward($forward);
} else {
register_error(elgg_echo('twitter_api:login:error'));
+ forward();
}
-
- forward(elgg_get_site_url());
} else {
$consumer_key = elgg_get_plugin_setting('consumer_key', 'twitter_api');
$consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitter_api');
@@ -301,9 +331,11 @@ function twitter_api_get_authorize_url($callback = NULL, $login = true) {
/**
* Returns the access token to use in twitter calls.
*
- * @param unknown_type $oauth_verifier
+ * @param bool $oauth_verifier
+ * @return array
*/
function twitter_api_get_access_token($oauth_verifier = FALSE) {
+ /* @var ElggSession $SESSION */
global $SESSION;
$consumer_key = elgg_get_plugin_setting('consumer_key', 'twitter_api');
@@ -312,7 +344,7 @@ function twitter_api_get_access_token($oauth_verifier = FALSE) {
// retrieve stored tokens
$oauth_token = $SESSION['twitter_api']['oauth_token'];
$oauth_token_secret = $SESSION['twitter_api']['oauth_token_secret'];
- $SESSION->offsetUnset('twitter_api');
+ unset($SESSION['twitter_api']);
// fetch an access token
$api = new TwitterOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
diff --git a/mod/twitter_api/start.php b/mod/twitter_api/start.php
index 08bce5479..e6221de6b 100644
--- a/mod/twitter_api/start.php
+++ b/mod/twitter_api/start.php
@@ -20,6 +20,7 @@ function twitter_api_init() {
//elgg_extend_view('metatags', 'twitter_api/metatags');
elgg_extend_view('css/elgg', 'twitter_api/css');
elgg_extend_view('css/admin', 'twitter_api/css');
+ elgg_extend_view('js/elgg', 'twitter_api/js');
// sign on with twitter
if (twitter_api_allow_sign_on_with_twitter()) {
@@ -60,7 +61,7 @@ function twitter_api_pagehandler_deprecated($page) {
* Serves pages for twitter.
*
* @param array $page
- * @return void
+ * @return bool
*/
function twitter_api_pagehandler($page) {
if (!isset($page[0])) {
@@ -131,14 +132,15 @@ function twitter_api_tweet($hook, $type, $returnvalue, $params) {
// send tweet
$api = new TwitterOAuth($consumer_key, $consumer_secret, $access_key, $access_secret);
- $response = $api->post('statuses/update', array('status' => $params['message']));
+ $api->post('statuses/update', array('status' => $params['message']));
}
/**
* Get tweets for a user.
*
- * @param int $user_id The Elgg user GUID
+ * @param int $user_guid The Elgg user GUID
* @param array $options
+ * @return array
*/
function twitter_api_fetch_tweets($user_guid, $options = array()) {
// check admin settings
@@ -167,6 +169,7 @@ function twitter_api_fetch_tweets($user_guid, $options = array()) {
* @param string $type
* @param array $return_value
* @param array $params
+ * @return array
*/
function twitter_api_public_pages($hook, $type, $return_value, $params) {
$return_value[] = 'twitter_api/forward';
diff --git a/mod/twitter_api/views/default/twitter_api/css.php b/mod/twitter_api/views/default/twitter_api/css.php
index 04bbed668..2d081d361 100644
--- a/mod/twitter_api/views/default/twitter_api/css.php
+++ b/mod/twitter_api/views/default/twitter_api/css.php
@@ -4,7 +4,7 @@
*/
?>
-#login_with_twitter {
+.login_with_twitter {
padding: 10px 0 0 0;
}
diff --git a/mod/twitter_api/views/default/twitter_api/js.php b/mod/twitter_api/views/default/twitter_api/js.php
new file mode 100644
index 000000000..60839709d
--- /dev/null
+++ b/mod/twitter_api/views/default/twitter_api/js.php
@@ -0,0 +1,16 @@
+
\ No newline at end of file
--
cgit v1.2.3
From 22e8d9be4582b78a500382e14046a653a14e3f43 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Sun, 16 Dec 2012 17:26:03 -0500
Subject: Refs #4643. Cleanup for the upgrade lock.
---
engine/lib/upgrade.php | 20 ++++++++++++--------
languages/en.php | 3 ++-
upgrade.php | 5 +++--
views/default/widgets/control_panel/content.php | 10 ++--------
4 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/engine/lib/upgrade.php b/engine/lib/upgrade.php
index 7f55c4cba..f4f4b16f5 100644
--- a/engine/lib/upgrade.php
+++ b/engine/lib/upgrade.php
@@ -313,7 +313,9 @@ function elgg_upgrade_bootstrap_17_to_18() {
}
/**
- * Locks a mutual execution of upgrade
+ * Creates a table {prefix}upgrade_lock that is used as a mutex for upgrades.
+ *
+ * @see _elgg_upgrade_lock()
*
* @return bool
* @access private
@@ -323,24 +325,26 @@ function _elgg_upgrade_lock() {
if (!_elgg_upgrade_is_locked()) {
// lock it
- insert_data("create table {$CONFIG->dbprefix}locked (id INT)");
- error_log('Upgrade continue running');
+ insert_data("create table {$CONFIG->dbprefix}upgrade_lock (id INT)");
+ elgg_log('Locked for upgrade.', 'NOTICE');
return true;
}
- error_log('Upgrade is locked');
+ elgg_log('Cannot lock for upgrade: already locked.', 'WARNING');
return false;
}
/**
- * Unlocks upgrade for new upgrade executions
+ * Unlocks upgrade.
+ *
+ * @see _elgg_upgrade_lock()
*
* @access private
*/
function _elgg_upgrade_unlock() {
global $CONFIG;
- delete_data("drop table {$CONFIG->dbprefix}locked");
- error_log('Upgrade unlocks itself');
+ delete_data("drop table {$CONFIG->dbprefix}upgrade_lock");
+ elgg_log('Upgrade unlocked.', 'NOTICE');
}
/**
@@ -352,7 +356,7 @@ function _elgg_upgrade_unlock() {
function _elgg_upgrade_is_locked() {
global $CONFIG, $DB_QUERY_CACHE;
- $is_locked = count(get_data("show tables like '{$CONFIG->dbprefix}locked'"));
+ $is_locked = count(get_data("show tables like '{$CONFIG->dbprefix}upgrade_lock'"));
// Invalidate query cache
if ($DB_QUERY_CACHE) {
diff --git a/languages/en.php b/languages/en.php
index 159867e2f..f1a1d650b 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -1048,7 +1048,8 @@ Once you have logged in, we highly recommend that you change your password.
'upgrade:db' => 'Your database was upgraded.',
'upgrade:core' => 'Your Elgg installation was upgraded.',
'upgrade:unlock' => 'Unlock upgrade',
- 'upgrade:unlock:confirm' => "Somebody is performing an upgrade. You should cancel and wait until upgrade is done. Are you sure you want to continue?",
+ 'upgrade:unlock:confirm' => "The database is locked for another upgrade. Running concurrent upgrades is dangerous. You should only continue if you know there is not another upgrade running. Unlock?",
+ 'upgrade:locked' => "Cannot upgrade. Another upgrade is running. To clear the upgrade lock, visit the Admin section.",
'upgrade:unlock:success' => "Upgrade unlocked suscessfully.",
'upgrade:unable_to_upgrade' => 'Unable to upgrade.',
'upgrade:unable_to_upgrade_info' =>
diff --git a/upgrade.php b/upgrade.php
index a58fcdc96..c5f158c61 100644
--- a/upgrade.php
+++ b/upgrade.php
@@ -9,6 +9,8 @@
* new version of the script. Deleting the script is not a requirement and
* leaving it behind does not affect the security of the site.
*
+ * Upgrades use a table {db_prefix}upgrade_lock as a mutex to prevent concurrent upgrades.
+ *
* @package Elgg.Core
* @subpackage Upgrade
*/
@@ -20,9 +22,9 @@ define('UPGRADING', 'upgrading');
require_once(dirname(__FILE__) . "/engine/start.php");
if (get_input('upgrade') == 'upgrade') {
-
// prevent someone from running the upgrade script in parallel (see #4643)
if (!_elgg_upgrade_lock()) {
+ register_error(elgg_echo('upgrade:locked'));
forward();
}
@@ -40,7 +42,6 @@ if (get_input('upgrade') == 'upgrade') {
elgg_invalidate_simplecache();
elgg_reset_system_cache();
- // critical region has past
_elgg_upgrade_unlock();
} else {
diff --git a/views/default/widgets/control_panel/content.php b/views/default/widgets/control_panel/content.php
index e6763d851..a348d612f 100644
--- a/views/default/widgets/control_panel/content.php
+++ b/views/default/widgets/control_panel/content.php
@@ -12,13 +12,7 @@ elgg_register_menu_item('admin_control_panel', array(
));
// @todo Move in this in ElggUpgradeManager::isLocked() when #4682 fixed
-global $CONFIG, $DB_QUERY_CACHE;
-$is_locked = count(get_data("show tables like '{$CONFIG->dbprefix}locked'"));
-// Invalidate query cache
-if ($DB_QUERY_CACHE) {
- $DB_QUERY_CACHE->clear();
- elgg_log("Query cache invalidated", 'NOTICE');
-}
+$is_locked = _elgg_upgrade_is_locked();
if (!$is_locked) {
elgg_register_menu_item('admin_control_panel', array(
@@ -33,7 +27,7 @@ if (!$is_locked) {
'text' => elgg_echo('upgrade:unlock'),
'href' => 'action/admin/site/unlock_upgrade',
'is_action' => true,
- 'link_class' => 'elgg-button elgg-button-delete',
+ 'link_class' => 'elgg-button elgg-button-action',
'confirm' => elgg_echo('upgrade:unlock:confirm'),
));
}
--
cgit v1.2.3
From 4aae9078525de7c6e56091d6864e7397b58280cb Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Sun, 16 Dec 2012 21:04:43 -0500
Subject: Fixes #4962. Using get/setData() methods to store menu item
original_order.
---
engine/classes/ElggMenuBuilder.php | 8 ++++----
engine/classes/ElggMenuItem.php | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/engine/classes/ElggMenuBuilder.php b/engine/classes/ElggMenuBuilder.php
index df0f9147f..d7f85685c 100644
--- a/engine/classes/ElggMenuBuilder.php
+++ b/engine/classes/ElggMenuBuilder.php
@@ -205,7 +205,7 @@ class ElggMenuBuilder {
// sort each section
foreach ($this->menu as $index => $section) {
foreach ($section as $key => $node) {
- $section[$key]->original_order = $key;
+ $section[$key]->setData('original_order', $key);
}
usort($section, $sort_callback);
$this->menu[$index] = $section;
@@ -240,7 +240,7 @@ class ElggMenuBuilder {
$result = strnatcmp($at, $bt);
if ($result === 0) {
- return $a->original_order - $b->original_order;
+ return $a->getData('original_order') - $b->getData('original_order');
}
return $result;
}
@@ -258,7 +258,7 @@ class ElggMenuBuilder {
$result = strcmp($an, $bn);
if ($result === 0) {
- return $a->original_order - $b->original_order;
+ return $a->getData('original_order') - $b->getData('original_order');
}
return $result;
}
@@ -275,7 +275,7 @@ class ElggMenuBuilder {
$bw = $b->getWeight();
if ($aw == $bw) {
- return $a->original_order - $b->original_order;
+ return $a->getData('original_order') - $b->getData('original_order');
}
return $aw - $bw;
}
diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php
index fe25f3ddd..81ce6c099 100644
--- a/engine/classes/ElggMenuItem.php
+++ b/engine/classes/ElggMenuItem.php
@@ -543,7 +543,7 @@ class ElggMenuItem {
*/
public function sortChildren($sortFunction) {
foreach ($this->data['children'] as $key => $node) {
- $this->data['children'][$key]->original_order = $key;
+ $this->data['children'][$key]->data['original_order'] = $key;
}
usort($this->data['children'], $sortFunction);
}
--
cgit v1.2.3
From d809ded90fb5213f1a7ec59c776f92ea654454d6 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Mon, 17 Dec 2012 11:58:26 -0500
Subject: Refs #4764. Also checking $_SESSION['last_forward_from'] for twitter
forwarding.
---
mod/twitter_api/lib/twitter_api.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mod/twitter_api/lib/twitter_api.php b/mod/twitter_api/lib/twitter_api.php
index 81c9c6628..e163d2b3e 100644
--- a/mod/twitter_api/lib/twitter_api.php
+++ b/mod/twitter_api/lib/twitter_api.php
@@ -44,7 +44,9 @@ function twitter_api_forward() {
'persistent' => (bool) get_input("persistent"),
);
// capture referrer if in site, but not the twitter_api
- if (!empty($_SERVER['HTTP_REFERER'])
+ if (!empty($SESSION['last_forward_from'])) {
+ $login_metadata['forward'] = $SESSION['last_forward_from'];
+ } elseif (!empty($_SERVER['HTTP_REFERER'])
&& 0 === strpos($_SERVER['HTTP_REFERER'], elgg_get_site_url())
&& 0 !== strpos($_SERVER['HTTP_REFERER'], elgg_get_site_url() . 'twitter_api/')) {
$login_metadata['forward'] = $_SERVER['HTTP_REFERER'];
--
cgit v1.2.3
From b46d3d3699529b49e147843437148baac6657f39 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Mon, 17 Dec 2012 12:20:57 -0500
Subject: Fixes #4720. Disabling access while finding / fetching page owners so
group gatekeepers work.
---
engine/lib/pageowner.php | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/engine/lib/pageowner.php b/engine/lib/pageowner.php
index 0cf0e0625..94765feee 100644
--- a/engine/lib/pageowner.php
+++ b/engine/lib/pageowner.php
@@ -37,6 +37,8 @@ function elgg_get_page_owner_guid($guid = 0) {
/**
* Gets the owner entity for the current page.
*
+ * @note Access is disabled when getting the page owner entity.
+ *
* @return ElggEntity|false The current page owner or false if none.
*
* @since 1.8.0
@@ -44,10 +46,14 @@ function elgg_get_page_owner_guid($guid = 0) {
function elgg_get_page_owner_entity() {
$guid = elgg_get_page_owner_guid();
if ($guid > 0) {
- return get_entity($guid);
+ $ia = elgg_set_ignore_access(true);
+ $owner = get_entity($guid);
+ elgg_set_ignore_access($ia);
+
+ return $owner;
}
- return FALSE;
+ return false;
}
/**
@@ -75,6 +81,8 @@ function elgg_set_page_owner_guid($guid) {
* /edit/
* /group/
*
+ * @note Access is disabled while finding the page owner for the group gatekeeper functions.
+ *
*
* @param string $hook 'page_owner'
* @param string $entity_type 'system'
@@ -90,6 +98,8 @@ function default_page_owner_handler($hook, $entity_type, $returnvalue, $params)
return $returnvalue;
}
+ $ia = elgg_set_ignore_access(true);
+
$username = get_input("username");
if ($username) {
// @todo using a username of group: is deprecated
@@ -97,6 +107,7 @@ function default_page_owner_handler($hook, $entity_type, $returnvalue, $params)
preg_match('/group\:([0-9]+)/i', $username, $matches);
$guid = $matches[1];
if ($entity = get_entity($guid)) {
+ elgg_set_ignore_access($ia);
return $entity->getGUID();
}
}
@@ -109,6 +120,7 @@ function default_page_owner_handler($hook, $entity_type, $returnvalue, $params)
$owner = get_input("owner_guid");
if ($owner) {
if ($user = get_entity($owner)) {
+ elgg_set_ignore_access($ia);
return $user->getGUID();
}
}
@@ -130,6 +142,7 @@ function default_page_owner_handler($hook, $entity_type, $returnvalue, $params)
case 'friends':
$user = get_user_by_username($segments[2]);
if ($user) {
+ elgg_set_ignore_access($ia);
return $user->getGUID();
}
break;
@@ -137,6 +150,7 @@ function default_page_owner_handler($hook, $entity_type, $returnvalue, $params)
case 'edit':
$entity = get_entity($segments[2]);
if ($entity) {
+ elgg_set_ignore_access($ia);
return $entity->getContainerGUID();
}
break;
@@ -144,6 +158,7 @@ function default_page_owner_handler($hook, $entity_type, $returnvalue, $params)
case 'group':
$entity = get_entity($segments[2]);
if ($entity) {
+ elgg_set_ignore_access($ia);
return $entity->getGUID();
}
break;
@@ -151,7 +166,7 @@ function default_page_owner_handler($hook, $entity_type, $returnvalue, $params)
}
}
- return $returnvalue;
+ elgg_set_ignore_access($ia);
}
/**
--
cgit v1.2.3
From 93170dd8fb02fd2adb691c34742ca1e47d21c14d Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Mon, 17 Dec 2012 14:36:08 -0500
Subject: Fixes #4709. Removed documentation for unused annotation_id(s) in
egef_annotations().
---
engine/lib/annotations.php | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php
index 2036ccd61..3b9f84703 100644
--- a/engine/lib/annotations.php
+++ b/engine/lib/annotations.php
@@ -316,8 +316,6 @@ function elgg_list_annotations($options) {
*
* annotation_owner_guids => NULL|ARR guids for annotaiton owners
*
- * annotation_ids => NULL|ARR Annotation IDs
- *
* @return mixed If count, int. If not count, array. false on errors.
* @since 1.7.0
*/
@@ -336,8 +334,6 @@ function elgg_get_entities_from_annotations(array $options = array()) {
'annotation_owner_guids' => ELGG_ENTITIES_ANY_VALUE,
- 'annotation_ids' => ELGG_ENTITIES_ANY_VALUE,
-
'order_by' => 'maxtime desc',
'group_by' => 'a.entity_guid'
);
@@ -345,12 +341,13 @@ function elgg_get_entities_from_annotations(array $options = array()) {
$options = array_merge($defaults, $options);
$singulars = array('annotation_name', 'annotation_value',
- 'annotation_name_value_pair', 'annotation_owner_guid', 'annotation_id');
+ 'annotation_name_value_pair', 'annotation_owner_guid');
$options = elgg_normalise_plural_options_array($options, $singulars);
+ $options = elgg_entities_get_metastrings_options('annotation', $options);
- if (!$options = elgg_entities_get_metastrings_options('annotation', $options)) {
- return FALSE;
+ if (!$options) {
+ return false;
}
// special sorting for annotations
--
cgit v1.2.3
From b691e4e2c002ef83c0c2e2bbd74885d4828b5c67 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Mon, 17 Dec 2012 15:56:06 -0500
Subject: Fixes #4963, refs #4847. Error messages don't automatically fade.
---
js/lib/elgglib.js | 8 ++++++--
js/lib/ui.js | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/js/lib/elgglib.js b/js/lib/elgglib.js
index dc7c07165..af2c94000 100644
--- a/js/lib/elgglib.js
+++ b/js/lib/elgglib.js
@@ -347,8 +347,12 @@ elgg.system_messages = function(msgs, delay, type) {
msgs.forEach(appendMessage);
- $(messages_html.join('')).appendTo(systemMessages)
- .animate({opacity: '1.0'}, delay).fadeOut('slow');
+ if (type != 'error') {
+ $(messages_html.join('')).appendTo(systemMessages)
+ .animate({opacity: '1.0'}, delay).fadeOut('slow');
+ } else {
+ $(messages_html.join('')).appendTo(systemMessages);
+ }
};
/**
diff --git a/js/lib/ui.js b/js/lib/ui.js
index 2a4d269d6..413078b4f 100644
--- a/js/lib/ui.js
+++ b/js/lib/ui.js
@@ -10,7 +10,7 @@ elgg.ui.init = function () {
});
$('.elgg-system-messages li').animate({opacity: 0.9}, 6000);
- $('.elgg-system-messages li').fadeOut('slow');
+ $('.elgg-system-messages li.elgg-state-success').fadeOut('slow');
$('[rel=toggle]').live('click', elgg.ui.toggles);
--
cgit v1.2.3
From 2b08c9d03b803c8227a99a4c3fce3ecb84ed6fc4 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Tue, 18 Dec 2012 15:55:42 -0500
Subject: Fixes #3940. Cleaned up caching for access functions. Access caches
are now cleared on ignore access change.
---
engine/classes/ElggStaticVariableCache.php | 4 +-
engine/lib/access.php | 153 ++++++++++++++++++-----------
engine/tests/api/access_collections.php | 22 +++++
3 files changed, 120 insertions(+), 59 deletions(-)
diff --git a/engine/classes/ElggStaticVariableCache.php b/engine/classes/ElggStaticVariableCache.php
index 787d35a32..17d849400 100644
--- a/engine/classes/ElggStaticVariableCache.php
+++ b/engine/classes/ElggStaticVariableCache.php
@@ -21,8 +21,8 @@ class ElggStaticVariableCache extends ElggSharedMemoryCache {
* This function creates a variable cache in a static variable in
* memory, optionally with a given namespace (to avoid overlap).
*
- * @param string $namespace The namespace for this cache to write to
- * note, namespaces of the same name are shared!
+ * @param string $namespace The namespace for this cache to write to.
+ * @note namespaces of the same name are shared!
*/
function __construct($namespace = 'default') {
$this->setNamespace($namespace);
diff --git a/engine/lib/access.php b/engine/lib/access.php
index 3b2b7aeaa..f7d3bf7ea 100644
--- a/engine/lib/access.php
+++ b/engine/lib/access.php
@@ -11,6 +11,26 @@
* @link http://docs.elgg.org/Access
*/
+/**
+ * Return an ElggCache static variable cache for the access caches
+ *
+ * @staticvar ElggStaticVariableCache $access_cache
+ * @return \ElggStaticVariableCache
+ * @access private
+ */
+function _elgg_get_access_cache() {
+ /**
+ * A default filestore cache using the dataroot.
+ */
+ static $access_cache;
+
+ if (!$access_cache) {
+ $access_cache = new ElggStaticVariableCache('access');
+ }
+
+ return $access_cache;
+}
+
/**
* Return a string of access_ids for $user_id appropriate for inserting into an SQL IN clause.
*
@@ -29,10 +49,10 @@
*/
function get_access_list($user_id = 0, $site_id = 0, $flush = false) {
global $CONFIG, $init_finished;
- static $access_list;
-
- if (!isset($access_list)) {
- $access_list = array();
+ $cache = _elgg_get_access_cache();
+
+ if ($flush) {
+ $cache->clear();
}
if ($user_id == 0) {
@@ -45,20 +65,20 @@ function get_access_list($user_id = 0, $site_id = 0, $flush = false) {
$user_id = (int) $user_id;
$site_id = (int) $site_id;
- if (isset($access_list[$user_id]) && $flush == false) {
- return $access_list[$user_id];
- }
+ $hash = $user_id . $site_id . 'get_access_list';
- $access = "(" . implode(",", get_access_array($user_id, $site_id, $flush)) . ")";
+ if ($cache[$hash]) {
+ return $cache[$hash];
+ }
+
+ $access_array = get_access_array($user_id, $site_id, $flush);
+ $access = "(" . implode(",", $access_array) . ")";
- // only cache if done with init and access is enabled (unless admin user)
- // session is loaded before init is finished, so don't need to check for user session
- if ($init_finished && (elgg_is_admin_logged_in() || !elgg_get_ignore_access())) {
- $access_list[$user_id] = $access;
- return $access_list[$user_id];
- } else {
- return $access;
+ if ($init_finished) {
+ $cache[$hash] = $access;
}
+
+ return $access;
}
/**
@@ -86,9 +106,11 @@ function get_access_list($user_id = 0, $site_id = 0, $flush = false) {
function get_access_array($user_id = 0, $site_id = 0, $flush = false) {
global $CONFIG, $init_finished;
- // @todo everything from the db is cached.
- // this cache might be redundant. But db cache is flushed on every db write.
- static $access_array = array();
+ $cache = _elgg_get_access_cache();
+
+ if ($flush) {
+ $cache->clear();
+ }
if ($user_id == 0) {
$user_id = elgg_get_logged_in_user_guid();
@@ -101,35 +123,41 @@ function get_access_array($user_id = 0, $site_id = 0, $flush = false) {
$user_id = (int) $user_id;
$site_id = (int) $site_id;
- if (empty($access_array[$user_id]) || $flush == true) {
- $tmp_access_array = array(ACCESS_PUBLIC);
+ $hash = $user_id . $site_id . 'get_access_array';
+
+ if ($cache[$hash]) {
+ $access_array = $cache[$hash];
+ } else {
+ $access_array = array(ACCESS_PUBLIC);
// The following can only return sensible data if the user is logged in.
if (elgg_is_logged_in()) {
- $tmp_access_array[] = ACCESS_LOGGED_IN;
+ $access_array[] = ACCESS_LOGGED_IN;
// Get ACL memberships
$query = "SELECT am.access_collection_id"
. " FROM {$CONFIG->dbprefix}access_collection_membership am"
. " LEFT JOIN {$CONFIG->dbprefix}access_collections ag ON ag.id = am.access_collection_id"
- . " WHERE am.user_guid = {$user_id} AND (ag.site_guid = {$site_id} OR ag.site_guid = 0)";
+ . " WHERE am.user_guid = $user_id AND (ag.site_guid = $site_id OR ag.site_guid = 0)";
- if ($collections = get_data($query)) {
+ $collections = get_data($query);
+ if ($collections) {
foreach ($collections as $collection) {
if (!empty($collection->access_collection_id)) {
- $tmp_access_array[] = (int)$collection->access_collection_id;
+ $access_array[] = (int)$collection->access_collection_id;
}
}
}
// Get ACLs owned.
$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)";
+ $query .= "WHERE ag.owner_guid = $user_id AND (ag.site_guid = $site_id OR ag.site_guid = 0)";
- if ($collections = get_data($query)) {
+ $collections = get_data($query);
+ if ($collections) {
foreach ($collections as $collection) {
if (!empty($collection->id)) {
- $tmp_access_array[] = (int)$collection->id;
+ $access_array[] = (int)$collection->id;
}
}
}
@@ -137,21 +165,21 @@ function get_access_array($user_id = 0, $site_id = 0, $flush = false) {
$ignore_access = elgg_check_access_overrides($user_id);
if ($ignore_access == true) {
- $tmp_access_array[] = ACCESS_PRIVATE;
+ $access_array[] = ACCESS_PRIVATE;
}
+ }
- // only cache if done with init and access is enabled (unless admin user)
- // session is loaded before init is finished, so don't need to check for user session
- if ($init_finished && (elgg_is_admin_logged_in() || !elgg_get_ignore_access())) {
- $access_array[$user_id] = $tmp_access_array;
- }
+ if ($init_finished) {
+ $cache[$hash] = $access_array;
}
- } else {
- $tmp_access_array = $access_array[$user_id];
}
- $options = array('user_id' => $user_id, 'site_id' => $site_id);
- return elgg_trigger_plugin_hook('access:collections:read', 'user', $options, $tmp_access_array);
+ $options = array(
+ 'user_id' => $user_id,
+ 'site_id' => $site_id
+ );
+
+ return elgg_trigger_plugin_hook('access:collections:read', 'user', $options, $access_array);
}
/**
@@ -397,9 +425,12 @@ function has_access_to_entity($entity, $user = null) {
* @link http://docs.elgg.org/Access
*/
function get_write_access_array($user_id = 0, $site_id = 0, $flush = false) {
- global $CONFIG;
- //@todo this is probably not needed since caching happens at the DB level.
- static $access_array;
+ global $CONFIG, $init_finished;
+ $cache = _elgg_get_access_cache();
+
+ if ($flush) {
+ $cache->clear();
+ }
if ($user_id == 0) {
$user_id = elgg_get_logged_in_user_guid();
@@ -412,37 +443,41 @@ function get_write_access_array($user_id = 0, $site_id = 0, $flush = false) {
$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})";
- // ACCESS_PRIVATE through ACCESS_PUBLIC take 0 through 2
- // @todo this AND clause is unnecessary because of id starts at 3 for table
- $query .= " AND ag.id >= 3";
+ $hash = $user_id . $site_id . 'get_write_access_array';
- $tmp_access_array = array(
+ if ($cache[$hash]) {
+ $access_array = $cache[$hash];
+ } else {
+ // @todo is there such a thing as public write access?
+ $access_array = array(
ACCESS_PRIVATE => elgg_echo("PRIVATE"),
ACCESS_FRIENDS => elgg_echo("access:friends:label"),
ACCESS_LOGGED_IN => elgg_echo("LOGGED_IN"),
ACCESS_PUBLIC => elgg_echo("PUBLIC")
);
+
+ $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)";
+
$collections = get_data($query);
if ($collections) {
foreach ($collections as $collection) {
- $tmp_access_array[$collection->id] = $collection->name;
+ $access_array[$collection->id] = $collection->name;
}
}
- $access_array[$user_id] = $tmp_access_array;
- } else {
- $tmp_access_array = $access_array[$user_id];
+ if ($init_finished) {
+ $cache[$hash] = $access_array;
+ }
}
- $options = array('user_id' => $user_id, 'site_id' => $site_id);
- $tmp_access_array = elgg_trigger_plugin_hook('access:collections:write', 'user',
- $options, $tmp_access_array);
-
- return $tmp_access_array;
+ $options = array(
+ 'user_id' => $user_id,
+ 'site_id' => $site_id
+ );
+ return elgg_trigger_plugin_hook('access:collections:write', 'user',
+ $options, $access_array);
}
/**
@@ -871,6 +906,8 @@ function get_readable_access_level($entity_access_id) {
* @tip Use this to access entities in automated scripts
* when no user is logged in.
*
+ * @note This clears the access cache.
+ *
* @warning This will not show disabled entities.
* Use {@link access_show_hidden_entities()} to access disabled entities.
*
@@ -882,6 +919,8 @@ function get_readable_access_level($entity_access_id) {
* @see elgg_get_ignore_access()
*/
function elgg_set_ignore_access($ignore = true) {
+ $cache = _elgg_get_access_cache();
+ $cache->clear();
$elgg_access = elgg_get_access_object();
return $elgg_access->setIgnoreAccess($ignore);
}
diff --git a/engine/tests/api/access_collections.php b/engine/tests/api/access_collections.php
index bea995a6e..ebcd7d318 100644
--- a/engine/tests/api/access_collections.php
+++ b/engine/tests/api/access_collections.php
@@ -268,4 +268,26 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest {
$group->delete();
}
+
+ public function testAccessCaching() {
+ // create a new user to check against
+ $user = new ElggUser();
+ $user->username = 'access_test_user';
+ $user->save();
+
+ foreach (array('get_access_list', 'get_access_array') as $func) {
+ $cache = _elgg_get_access_cache();
+ $cache->clear();
+
+ // admin users run tests, so disable access
+ elgg_set_ignore_access(true);
+ $access = $func($user->getGUID());
+
+ elgg_set_ignore_access(false);
+ $access2 = $func($user->getGUID());
+ $this->assertNotEqual($access, $access2, "Access test for $func");
+ }
+
+ $user->delete();
+ }
}
--
cgit v1.2.3
From 68441b33797e681a03fc61d217e1d110baa9e482 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Wed, 19 Dec 2012 14:11:37 -0500
Subject: Refs #4789. Removing the container check for river items.
---
engine/lib/views.php | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/engine/lib/views.php b/engine/lib/views.php
index c1b616cf1..8618c2997 100644
--- a/engine/lib/views.php
+++ b/engine/lib/views.php
@@ -1235,13 +1235,16 @@ function elgg_view_river_item($item, array $vars = array()) {
if (!$subject || !$object) {
// subject is disabled or subject/object deleted
return '';
- } else {
- // hide based on object's container
- $visibility = ElggGroupItemVisibility::factory($object->container_guid);
- if ($visibility->shouldHideItems) {
- return '';
- }
}
+ // Don't hide objects in closed groups that a user can see.
+ // see http://trac.elgg.org/ticket/4789
+// else {
+// // hide based on object's container
+// $visibility = ElggGroupItemVisibility::factory($object->container_guid);
+// if ($visibility->shouldHideItems) {
+// return '';
+// }
+// }
$vars['item'] = $item;
--
cgit v1.2.3
From 9e5941882ea30511b9be7887da2b555399395f14 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Wed, 19 Dec 2012 15:39:04 -0500
Subject: Fixes #4633. Added the invitation count for group invitations page
menu item.
---
mod/groups/languages/en.php | 3 ++-
mod/groups/start.php | 12 +++++++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php
index 0d57f1680..a9743f9d4 100644
--- a/mod/groups/languages/en.php
+++ b/mod/groups/languages/en.php
@@ -21,6 +21,7 @@ $english = array(
'groups:delete' => 'Delete group',
'groups:membershiprequests' => 'Manage join requests',
'groups:invitations' => 'Group invitations',
+ 'groups:invitations:pending' => 'Group invitations (%s)',
'groups:icon' => 'Group icon (leave blank to leave unchanged)',
'groups:name' => 'Group name',
@@ -211,7 +212,7 @@ View and reply to the discussion:
'groups:updated' => "Last reply by %s %s",
'groups:started' => "Started by %s",
'groups:joinrequest:remove:check' => 'Are you sure you want to remove this join request?',
- 'groups:invite:remove:check' => 'Are you sure you want to remove this invite?',
+ 'groups:invite:remove:check' => 'Are you sure you want to remove this invitation?',
'groups:invite:body' => "Hi %s,
%s invited you to join the '%s' group. Click below to view your invitations:
diff --git a/mod/groups/start.php b/mod/groups/start.php
index 9dca7dc16..25ce56350 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -163,11 +163,21 @@ function groups_setup_sidebar_menus() {
$url = "groups/owner/$user->username";
$item = new ElggMenuItem('groups:owned', elgg_echo('groups:owned'), $url);
elgg_register_menu_item('page', $item);
+
$url = "groups/member/$user->username";
$item = new ElggMenuItem('groups:member', elgg_echo('groups:yours'), $url);
elgg_register_menu_item('page', $item);
+
$url = "groups/invitations/$user->username";
- $item = new ElggMenuItem('groups:user:invites', elgg_echo('groups:invitations'), $url);
+ $invitations = groups_get_invited_groups($user->getGUID());
+ if (is_array($invitations) && !empty($invitations)) {
+ $invitation_count = count($invitations);
+ $text = elgg_echo('groups:invitations:pending', array($invitation_count));
+ } else {
+ $text = elgg_echo('groups:invitations');
+ }
+
+ $item = new ElggMenuItem('groups:user:invites', $text, $url);
elgg_register_menu_item('page', $item);
}
}
--
cgit v1.2.3
From bccc976f079590f0c989484a0a6237dc4a1b8615 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Wed, 19 Dec 2012 15:56:57 -0500
Subject: Refs #4633. Added join request count to page menu item.
---
mod/groups/languages/en.php | 1 +
mod/groups/start.php | 17 ++++++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php
index a9743f9d4..a817210c6 100644
--- a/mod/groups/languages/en.php
+++ b/mod/groups/languages/en.php
@@ -20,6 +20,7 @@ $english = array(
'groups:edit' => "Edit group",
'groups:delete' => 'Delete group',
'groups:membershiprequests' => 'Manage join requests',
+ 'groups:membershiprequests:pending' => 'Manage join requests (%s)',
'groups:invitations' => 'Group invitations',
'groups:invitations:pending' => 'Group invitations (%s)',
diff --git a/mod/groups/start.php b/mod/groups/start.php
index 25ce56350..4e49d9e55 100644
--- a/mod/groups/start.php
+++ b/mod/groups/start.php
@@ -144,9 +144,24 @@ function groups_setup_sidebar_menus() {
if (elgg_in_context('group_profile')) {
if (elgg_is_logged_in() && $page_owner->canEdit() && !$page_owner->isPublicMembership()) {
$url = elgg_get_site_url() . "groups/requests/{$page_owner->getGUID()}";
+
+ $count = elgg_get_entities_from_relationship(array(
+ 'type' => 'user',
+ 'relationship' => 'membership_request',
+ 'relationship_guid' => $guid,
+ 'inverse_relationship' => true,
+ 'count' => true,
+ ));
+
+ if ($count) {
+ $text = elgg_echo('groups:membershiprequests:pending', array($count));
+ } else {
+ $text = elgg_echo('groups:membershiprequests');
+ }
+
elgg_register_menu_item('page', array(
'name' => 'membership_requests',
- 'text' => elgg_echo('groups:membershiprequests'),
+ 'text' => $text,
'href' => $url,
));
}
--
cgit v1.2.3
From 29606e1ecc874452f4d047a25e07755fcb7d7ac4 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Wed, 19 Dec 2012 16:14:31 -0500
Subject: Refs #3907. Changed river icons to tiny size if used within a widget.
---
views/default/river/elements/image.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/views/default/river/elements/image.php b/views/default/river/elements/image.php
index 9caa44b36..6f6aeae65 100644
--- a/views/default/river/elements/image.php
+++ b/views/default/river/elements/image.php
@@ -9,4 +9,8 @@
$subject = $vars['item']->getSubjectEntity();
-echo elgg_view_entity_icon($subject, 'small');
+if (elgg_in_context('widgets')) {
+ echo elgg_view_entity_icon($subject, 'tiny');
+} else {
+ echo elgg_view_entity_icon($subject, 'small');
+}
--
cgit v1.2.3
From 9272e4210274d49ec77b7bcfc07ff0e14e222721 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Thu, 20 Dec 2012 15:47:34 -0500
Subject: Not using short open tag.
---
mod/twitter_api/views/default/twitter_api/js.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mod/twitter_api/views/default/twitter_api/js.php b/mod/twitter_api/views/default/twitter_api/js.php
index 60839709d..3d2905a44 100644
--- a/mod/twitter_api/views/default/twitter_api/js.php
+++ b/mod/twitter_api/views/default/twitter_api/js.php
@@ -1,4 +1,4 @@
-
+
+
\ No newline at end of file
diff --git a/mod/developers/views/default/theme_preview/miscellaneous/toggle.php b/mod/developers/views/default/theme_preview/miscellaneous/toggle.php
new file mode 100644
index 000000000..abe39ddd8
--- /dev/null
+++ b/mod/developers/views/default/theme_preview/miscellaneous/toggle.php
@@ -0,0 +1,15 @@
+ 'Toggle content',
+ 'href' => "#elgg-toggle-test",
+ 'rel' => 'toggle'
+));
+
+echo $link;
+echo elgg_view_module('featured', 'Toggle Test', $ipsum, array(
+ 'id' => 'elgg-toggle-test',
+ 'class' => 'hidden clearfix developers-content-thin',
+));
\ No newline at end of file
diff --git a/mod/developers/views/default/theme_preview/miscellaneous/user_hover_menu.php b/mod/developers/views/default/theme_preview/miscellaneous/user_hover_menu.php
new file mode 100644
index 000000000..45331b6e0
--- /dev/null
+++ b/mod/developers/views/default/theme_preview/miscellaneous/user_hover_menu.php
@@ -0,0 +1,16 @@
+ 'user',
+ 'wheres' => array("guid != {$me->getGUID()}"),
+ 'limit' => 1
+));
+
+if (is_array($users) && count($users) > 0) {
+ echo elgg_view_entity_icon($users[0]);
+}
+
diff --git a/mod/developers/views/default/theme_preview/modules.php b/mod/developers/views/default/theme_preview/modules.php
index 3e0acb3a5..c46c94296 100644
--- a/mod/developers/views/default/theme_preview/modules.php
+++ b/mod/developers/views/default/theme_preview/modules.php
@@ -2,5 +2,5 @@
echo elgg_view_module('info', 'Modules (.elgg-module)', elgg_view('theme_preview/modules/modules'));
-echo elgg_view_module('info', 'Widgets (.elgg-widget)', elgg_view('theme_preview/modules/widgets'));
+echo elgg_view_module('info', 'Widgets (.elgg-module-widget)', elgg_view('theme_preview/modules/widgets'));
--
cgit v1.2.3
From 693928cf9f758da348ed7f11cf43442f1efcf435 Mon Sep 17 00:00:00 2001
From: Brett Profitt
Date: Fri, 4 Jan 2013 16:29:43 -0500
Subject: Version bump. Updated changes.
---
CHANGES.txt | 36 ++++++++++++++++++++++++++++++++++++
version.php | 2 +-
2 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index ca1bdc675..acfb7055e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,39 @@
+Version 1.8.12
+(January 4th, 2013 from https://github.com/Elgg/Elgg/tree/1.8)
+ Contributing Developers:
+ * Brett Profitt
+ * Cash Costello
+ * Jerome Bakker
+ * Matt Beckett
+ * Paweł Sroka
+ * Sem
+ * Srokap
+ * Steve Clay
+
+ Bugfixes:
+ * Added an AJAX workaround for the rewrite test.
+ * Code cleanup to prevent some notices and warnings.
+ * Removed "original_order" in menu item anchor tags.
+ * Site menu's selected item correctly persists through content pages.
+ * Static caches rewritten and improved to prevent stale data being returned.
+ * Installation: Invalid characters in admin username are handled correctly.
+ * Messages: Fixed inbox link in email notifications.
+ * The Wire: Fixed objects not displaying correctly when upgrading from 1.7.
+
+ Enhancements:
+ * Performance improvements and improved caching in entity loading.
+ * Added upgrade locking to prevent concurrent upgrade attempts.
+ * Replaced xml_to_object() and autop() with GPL / MIT-compatible code.
+ * Error messages (register_error()) only fade after being clicked.
+ * Groups: Added a sidebar entry to display membership status and a link to
+ group notification settings.
+ * Groups: Added pending membership and invitation requests to the sidebar.
+ * Groups: Better redirection for invisible and closed groups.
+ * Search: User profile fields are searched.
+ * Pages: Subpages can be reassigned to new parent pages.
+ * Twitter: Login with twitter supports persistent login and correctly forwards
+ after login.
+
Version 1.8.11
(December 5th, 2012 from https://github.com/Elgg/Elgg/tree/1.8)
diff --git a/version.php b/version.php
index 77d151bb6..858877cfd 100644
--- a/version.php
+++ b/version.php
@@ -14,4 +14,4 @@
$version = 2012120500;
// Human-friendly version name
-$release = '1.8.11';
+$release = '1.8.12';
--
cgit v1.2.3
From b800d4721c8dccb5bd0ad6a0d793219d27cf25bd Mon Sep 17 00:00:00 2001
From: Per Jensen
Date: Sat, 22 Dec 2012 09:35:47 +0100
Subject: Prevent distortion of group icon
---
mod/groups/views/default/groups/css.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/mod/groups/views/default/groups/css.php b/mod/groups/views/default/groups/css.php
index 20cd947f8..f475f7d9e 100644
--- a/mod/groups/views/default/groups/css.php
+++ b/mod/groups/views/default/groups/css.php
@@ -9,7 +9,10 @@
.groups-profile > .elgg-image {
margin-right: 10px;
}
-
+.groups-profile img {
+ width: 100%;
+ height: auto;
+}
.groups-stats {
background: #eeeeee;
padding: 5px;
@@ -74,4 +77,4 @@
.elgg-menu-groups-my-status li.elgg-state-selected > a {
background-color: #4690D6;
color: white;
-}
\ No newline at end of file
+}
--
cgit v1.2.3
From 41dd5f6e18213e6041900b058817a1951caca177 Mon Sep 17 00:00:00 2001
From: Per Jensen
Date: Sat, 22 Dec 2012 09:16:42 +0100
Subject: Prevent distortion of image
---
views/default/css/elements/typography.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/views/default/css/elements/typography.php b/views/default/css/elements/typography.php
index d93b28d2c..4c2c3c774 100644
--- a/views/default/css/elements/typography.php
+++ b/views/default/css/elements/typography.php
@@ -157,5 +157,6 @@ h6 { font-size: 0.8em; }
padding: 3px 5px;
}
.elgg-output img {
- max-width: 100%;
+ max-width: 100%;
+ height: auto;
}
\ No newline at end of file
--
cgit v1.2.3
From b339fd125870bb0b084cf54b03cdacd257cc560b Mon Sep 17 00:00:00 2001
From: Steve Clay
Date: Thu, 17 Jan 2013 10:24:54 -0500
Subject: Corrects encoding and other small tweaks in Twitter widget
---
mod/twitter/languages/en.php | 9 ++---
.../views/default/widgets/twitter/content.php | 41 ++++++++++++++--------
mod/twitter/views/default/widgets/twitter/edit.php | 34 +++++++++++-------
3 files changed, 54 insertions(+), 30 deletions(-)
diff --git a/mod/twitter/languages/en.php b/mod/twitter/languages/en.php
index 29700744a..11e745ba1 100644
--- a/mod/twitter/languages/en.php
+++ b/mod/twitter/languages/en.php
@@ -4,13 +4,14 @@
*/
$english = array(
-
'twitter:title' => 'Twitter',
'twitter:info' => 'Display your latest tweets',
- 'twitter:username' => 'Enter your twitter username.',
- 'twitter:num' => 'The number of tweets to show.',
+ 'twitter:username' => 'Your twitter username',
+ 'twitter:num' => 'Number of tweets to show*',
'twitter:visit' => 'visit my twitter',
- 'twitter:notset' => 'This Twitter widget is not yet set to go. To display your latest tweets, click on - edit - and fill in your details',
+ 'twitter:notset' => 'This widget needs to be configured. To display your latest tweets, click the customize icon and fill in your Twitter username.',
+ 'twitter:invalid' => 'This widget is configured with an invalid Twitter username. Click the customize icon to correct it.',
+ 'twitter:apibug' => "*Due to a bug in the Twitter 1.0 API, you may see fewer tweets than you ask for.",
);
add_translation("en", $english);
diff --git a/mod/twitter/views/default/widgets/twitter/content.php b/mod/twitter/views/default/widgets/twitter/content.php
index c616d944c..dd741745e 100644
--- a/mod/twitter/views/default/widgets/twitter/content.php
+++ b/mod/twitter/views/default/widgets/twitter/content.php
@@ -6,26 +6,39 @@
* @package ElggTwitter
*/
-//some required params
-
$username = $vars['entity']->twitter_username;
+
+if (empty($username)) {
+ echo "" . elgg_echo("twitter:notset") . "
";
+ return;
+}
+
+$username_is_valid = preg_match('~^[a-zA-Z0-9_]{1,20}$~', $username);
+
+if (!$username_is_valid) {
+ echo "" . elgg_echo("twitter:invalid") . "
";
+ return;
+}
+
+
+
$num = $vars['entity']->twitter_num;
+if (empty($num)) {
+ $num = 5;
+}
-// if the twitter username is empty, then do not show
-if ($username) {
+// @todo upgrade to 1.1 API https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline
+$script_url = "https://api.twitter.com/1/statuses/user_timeline/" . urlencode($username) . ".json"
+ . "?callback=twitterCallback2&count=" . (int) $num;
?>
-
-
-" . elgg_echo("twitter:notset") . ".
";
-
-}
diff --git a/mod/twitter/views/default/widgets/twitter/edit.php b/mod/twitter/views/default/widgets/twitter/edit.php
index 5da3a7e55..5dd291257 100644
--- a/mod/twitter/views/default/widgets/twitter/edit.php
+++ b/mod/twitter/views/default/widgets/twitter/edit.php
@@ -1,16 +1,26 @@
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
\ No newline at end of file
--
cgit v1.2.3
From 60dde10b389667af0b4e1b703f8962e9e54f4a28 Mon Sep 17 00:00:00 2001
From: Steve Clay
Date: Fri, 18 Jan 2013 16:51:20 -0500
Subject: Style fixes to match 1.8 widgets
---
mod/twitter/views/default/widgets/twitter/content.php | 2 --
mod/twitter/views/default/widgets/twitter/edit.php | 16 +++++++---------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/mod/twitter/views/default/widgets/twitter/content.php b/mod/twitter/views/default/widgets/twitter/content.php
index dd741745e..caefd369a 100644
--- a/mod/twitter/views/default/widgets/twitter/content.php
+++ b/mod/twitter/views/default/widgets/twitter/content.php
@@ -14,14 +14,12 @@ if (empty($username)) {
}
$username_is_valid = preg_match('~^[a-zA-Z0-9_]{1,20}$~', $username);
-
if (!$username_is_valid) {
echo "" . elgg_echo("twitter:invalid") . "
";
return;
}
-
$num = $vars['entity']->twitter_num;
if (empty($num)) {
$num = 5;
diff --git a/mod/twitter/views/default/widgets/twitter/edit.php b/mod/twitter/views/default/widgets/twitter/edit.php
index 5dd291257..c3fc6f0d5 100644
--- a/mod/twitter/views/default/widgets/twitter/edit.php
+++ b/mod/twitter/views/default/widgets/twitter/edit.php
@@ -7,20 +7,18 @@
*/
?>
-
-