From 17c28c8161e8c551ce4e4a1345e525cbb785fb59 Mon Sep 17 00:00:00 2001 From: Sem Date: Sun, 8 Jul 2012 09:48:50 +0200 Subject: Fixes #3646. Added suport for Repository, Bugtracker and Donations in manifest. --- engine/classes/ElggPluginManifest.php | 26 ++++++++++++++++++++++++++ engine/classes/ElggPluginManifestParser18.php | 11 +++++++---- engine/tests/api/plugins.php | 18 ++++++++++++++++++ engine/tests/test_files/plugin_18/manifest.xml | 3 +++ 4 files changed, 54 insertions(+), 4 deletions(-) (limited to 'engine') diff --git a/engine/classes/ElggPluginManifest.php b/engine/classes/ElggPluginManifest.php index 7e79c15c8..5eb248c2c 100644 --- a/engine/classes/ElggPluginManifest.php +++ b/engine/classes/ElggPluginManifest.php @@ -276,6 +276,32 @@ class ElggPluginManifest { } } + /** + * Returns the repository url + * + * @return sting + */ + public function getRepository() { + return $this->parser->getAttribute('repository'); + } + + /** + * Returns the bug tracker page + * + * @return sting + */ + public function getBugTracker() { + return $this->parser->getAttribute('bugtracker'); + } + + /** + * Returns the donations page + * + * @return sting + */ + public function getDonationsPage() { + return $this->parser->getAttribute('donations'); + } /** * Returns the version of the plugin. diff --git a/engine/classes/ElggPluginManifestParser18.php b/engine/classes/ElggPluginManifestParser18.php index 554e28c02..3b753f17b 100644 --- a/engine/classes/ElggPluginManifestParser18.php +++ b/engine/classes/ElggPluginManifestParser18.php @@ -13,10 +13,10 @@ class ElggPluginManifestParser18 extends ElggPluginManifestParser { * @var array */ protected $validAttributes = array( - 'name', 'author', 'version', 'blurb', 'description', - 'website', 'copyright', 'license', 'requires', 'suggests', - 'screenshot', 'category', 'conflicts', 'provides', - 'activate_on_install' + 'name', 'author', 'version', 'blurb', 'description','website', + 'repository', 'bugtracker', 'donations', 'copyright', 'license', + 'requires', 'suggests', 'conflicts', 'provides', + 'screenshot', 'category', 'activate_on_install' ); /** @@ -46,6 +46,9 @@ class ElggPluginManifestParser18 extends ElggPluginManifestParser { case 'website': case 'copyright': case 'license': + case 'repository': + case 'bugtracker': + case 'donations': case 'activate_on_install': $parsed[$element->name] = $element->content; break; diff --git a/engine/tests/api/plugins.php b/engine/tests/api/plugins.php index 8ecb0a46c..66297266c 100644 --- a/engine/tests/api/plugins.php +++ b/engine/tests/api/plugins.php @@ -68,6 +68,9 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { 'blurb' => 'A concise description.', 'description' => 'A longer, more interesting description.', 'website' => 'http://www.elgg.org/', + 'repository' => 'https://github.com/Elgg/Elgg', + 'bugtracker' => 'http://trac.elgg.org', + 'donations' => 'http://elgg.org/supporter.php', 'copyright' => '(C) Elgg Foundation 2011', 'license' => 'GNU General Public License version 2', @@ -164,6 +167,21 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { $this->assertEqual($this->manifest18->getWebsite(), 'http://www.elgg.org/'); $this->assertEqual($this->manifest17->getWebsite(), 'http://www.elgg.org/'); } + + public function testElggPluginManifestGetRepository() { + $this->assertEqual($this->manifest18->getRepository(), 'https://github.com/Elgg/Elgg'); + $this->assertEqual($this->manifest17->getRepository(), ''); + } + + public function testElggPluginManifestGetBugtracker() { + $this->assertEqual($this->manifest18->getBugTracker(), 'http://trac.elgg.org'); + $this->assertEqual($this->manifest17->getBugTracker(), ''); + } + + public function testElggPluginManifestGetDonationsPage() { + $this->assertEqual($this->manifest18->getDonationsPage(), 'http://elgg.org/supporter.php'); + $this->assertEqual($this->manifest17->getDonationsPage(), ''); + } public function testElggPluginManifestGetCopyright() { $this->assertEqual($this->manifest18->getCopyright(), '(C) Elgg Foundation 2011'); diff --git a/engine/tests/test_files/plugin_18/manifest.xml b/engine/tests/test_files/plugin_18/manifest.xml index 9654b6422..5d788616a 100644 --- a/engine/tests/test_files/plugin_18/manifest.xml +++ b/engine/tests/test_files/plugin_18/manifest.xml @@ -6,6 +6,9 @@ A concise description. A longer, more interesting description. http://www.elgg.org/ + https://github.com/Elgg/Elgg + http://trac.elgg.org + http://elgg.org/supporter.php (C) Elgg Foundation 2011 GNU General Public License version 2 -- cgit v1.2.3 From 538a4c24bd9c942d8e0e9a58a650a29188fbd2ce Mon Sep 17 00:00:00 2001 From: Sem Date: Sun, 8 Jul 2012 10:42:17 +0200 Subject: Fixes #4004. elgg_logging when a language key is missing. --- engine/lib/languages.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engine') diff --git a/engine/lib/languages.php b/engine/lib/languages.php index 15c48f902..e8e3d31af 100644 --- a/engine/lib/languages.php +++ b/engine/lib/languages.php @@ -50,8 +50,10 @@ function elgg_echo($message_key, $args = array(), $language = "") { $string = $CONFIG->translations[$language][$message_key]; } else if (isset($CONFIG->translations["en"][$message_key])) { $string = $CONFIG->translations["en"][$message_key]; + elgg_log(sprintf('Missing %s translation for "%s" language key', $language, $message_key), WARNING); } else { $string = $message_key; + elgg_log(sprintf('Missing %s translation for "%s" language key', $language, $message_key), ERROR); } // only pass through if we have arguments to allow backward compatibility -- cgit v1.2.3 From 0b00af1e77d7ffc5c739f7fa21f61886b5480e62 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Thu, 12 Jul 2012 07:51:54 -0400 Subject: Fixes #4702 better actions logic --- engine/lib/actions.php | 44 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 30 deletions(-) (limited to 'engine') diff --git a/engine/lib/actions.php b/engine/lib/actions.php index 3a7c02488..53b185dea 100644 --- a/engine/lib/actions.php +++ b/engine/lib/actions.php @@ -82,44 +82,28 @@ function action($action, $forwarder = "") { $forwarder = str_replace(elgg_get_site_url(), "", $forwarder); $forwarder = str_replace("http://", "", $forwarder); $forwarder = str_replace("@", "", $forwarder); - if (substr($forwarder, 0, 1) == "/") { $forwarder = substr($forwarder, 1); } - if (isset($CONFIG->actions[$action])) { - if (elgg_is_admin_logged_in() || ($CONFIG->actions[$action]['access'] !== 'admin')) { - if (elgg_is_logged_in() || ($CONFIG->actions[$action]['access'] === 'public')) { - - // Trigger action event - // @todo This is only called before the primary action is called. - $event_result = true; - $event_result = elgg_trigger_plugin_hook('action', $action, null, $event_result); - - // Include action - // Event_result being false doesn't produce an error - // since i assume this will be handled in the hook itself. - // @todo make this better! - if ($event_result) { - if (!include($CONFIG->actions[$action]['file'])) { - register_error(elgg_echo('actionnotfound', array($action))); - } - } - } else { - register_error(elgg_echo('actionloggedout')); + if (!isset($CONFIG->actions[$action])) { + register_error(elgg_echo('actionundefined', array($action))); + } elseif (!elgg_is_admin_logged_in() && ($CONFIG->actions[$action]['access'] === 'admin')) { + register_error(elgg_echo('actionunauthorized')); + } elseif (!elgg_is_logged_in() && ($CONFIG->actions[$action]['access'] !== 'public')) { + register_error(elgg_echo('actionloggedout')); + } else { + // Returning falsy doesn't produce an error + // We assume this will be handled in the hook itself. + if (elgg_trigger_plugin_hook('action', $action, null, true)) { + if (!include($CONFIG->actions[$action]['file'])) { + register_error(elgg_echo('actionnotfound', array($action))); } - } else { - register_error(elgg_echo('actionunauthorized')); } - } else { - register_error(elgg_echo('actionundefined', array($action))); } - if (!empty($forwarder)) { - forward($forwarder); - } else { - forward(REFERER); - } + $forwarder = empty($forwarder) ? REFERER : $forwarder; + forward($forwarder); } /** -- cgit v1.2.3 From b7edff977107e928660256f37bbf4bc35fdea0a9 Mon Sep 17 00:00:00 2001 From: Sem Date: Fri, 13 Jul 2012 00:58:12 +0200 Subject: Refs #3646. "getRepositoryURL" is more descriptive than "getRepository". --- engine/classes/ElggPluginManifest.php | 10 +++++----- engine/tests/api/plugins.php | 4 ++-- views/default/object/plugin/full.php | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'engine') diff --git a/engine/classes/ElggPluginManifest.php b/engine/classes/ElggPluginManifest.php index 5eb248c2c..5706d1e42 100644 --- a/engine/classes/ElggPluginManifest.php +++ b/engine/classes/ElggPluginManifest.php @@ -264,7 +264,7 @@ class ElggPluginManifest { /** * Returns the license * - * @return sting + * @return string */ public function getLicense() { // license vs licence. Use license. @@ -279,16 +279,16 @@ class ElggPluginManifest { /** * Returns the repository url * - * @return sting + * @return string */ - public function getRepository() { + public function getRepositoryURL() { return $this->parser->getAttribute('repository'); } /** * Returns the bug tracker page * - * @return sting + * @return string */ public function getBugTracker() { return $this->parser->getAttribute('bugtracker'); @@ -297,7 +297,7 @@ class ElggPluginManifest { /** * Returns the donations page * - * @return sting + * @return string */ public function getDonationsPage() { return $this->parser->getAttribute('donations'); diff --git a/engine/tests/api/plugins.php b/engine/tests/api/plugins.php index 66297266c..3b650f1b0 100644 --- a/engine/tests/api/plugins.php +++ b/engine/tests/api/plugins.php @@ -169,8 +169,8 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { } public function testElggPluginManifestGetRepository() { - $this->assertEqual($this->manifest18->getRepository(), 'https://github.com/Elgg/Elgg'); - $this->assertEqual($this->manifest17->getRepository(), ''); + $this->assertEqual($this->manifest18->getRepositoryURL(), 'https://github.com/Elgg/Elgg'); + $this->assertEqual($this->manifest17->getRepositoryURL(), ''); } public function testElggPluginManifestGetBugtracker() { diff --git a/views/default/object/plugin/full.php b/views/default/object/plugin/full.php index a96acd4ec..76e1136f2 100644 --- a/views/default/object/plugin/full.php +++ b/views/default/object/plugin/full.php @@ -173,7 +173,7 @@ $website = elgg_view('output/url', array( )); $resources = array( - 'repository' => $plugin->getManifest()->getRepository(), + 'repository' => $plugin->getManifest()->getRepositoryURL(), 'bugtracker' => $plugin->getManifest()->getBugTracker(), 'donate' => $plugin->getManifest()->getDonationsPage(), ); -- cgit v1.2.3 From 25c324f5bf0f8737268c34626455a302b819651e Mon Sep 17 00:00:00 2001 From: Sem Date: Fri, 13 Jul 2012 01:32:44 +0200 Subject: Refs #4004. Downgraded to notice and warning. It also returns the complete language name. --- engine/lib/languages.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engine') diff --git a/engine/lib/languages.php b/engine/lib/languages.php index e8e3d31af..77128202f 100644 --- a/engine/lib/languages.php +++ b/engine/lib/languages.php @@ -50,10 +50,11 @@ function elgg_echo($message_key, $args = array(), $language = "") { $string = $CONFIG->translations[$language][$message_key]; } else if (isset($CONFIG->translations["en"][$message_key])) { $string = $CONFIG->translations["en"][$message_key]; - elgg_log(sprintf('Missing %s translation for "%s" language key', $language, $message_key), WARNING); + $lang = elgg_echo($language, array(), 'en'); + elgg_log(sprintf('Missing %s translation for "%s" language key', $lang, $message_key), 'NOTICE'); } else { $string = $message_key; - elgg_log(sprintf('Missing %s translation for "%s" language key', $language, $message_key), ERROR); + elgg_log(sprintf('Missing English translation for "%s" language key', $message_key), 'WARNING'); } // only pass through if we have arguments to allow backward compatibility -- cgit v1.2.3 From 185b73174fbd39e4b47c27f19839329438b8f3c2 Mon Sep 17 00:00:00 2001 From: Sem Date: Fri, 13 Jul 2012 14:39:32 +0300 Subject: Refs #4004. Used $CONFIG->translations instead of elgg_echo() --- engine/lib/languages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine') diff --git a/engine/lib/languages.php b/engine/lib/languages.php index 77128202f..219917b29 100644 --- a/engine/lib/languages.php +++ b/engine/lib/languages.php @@ -50,7 +50,7 @@ function elgg_echo($message_key, $args = array(), $language = "") { $string = $CONFIG->translations[$language][$message_key]; } else if (isset($CONFIG->translations["en"][$message_key])) { $string = $CONFIG->translations["en"][$message_key]; - $lang = elgg_echo($language, array(), 'en'); + $lang = $CONFIG->translations["en"][$language]; elgg_log(sprintf('Missing %s translation for "%s" language key', $lang, $message_key), 'NOTICE'); } else { $string = $message_key; -- cgit v1.2.3 From 0a54cabfe75fb0261fff12ee48cd868bfa8f06fb Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 14 Jul 2012 20:42:31 -0400 Subject: Refs #4004 decided to downgrage missing language keys to NOTICE for all languages. The plugin categories were causing problems at the WARNING level. This will be more useful when we move db queries off NOTICE --- engine/lib/languages.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engine') diff --git a/engine/lib/languages.php b/engine/lib/languages.php index 219917b29..98006f7cd 100644 --- a/engine/lib/languages.php +++ b/engine/lib/languages.php @@ -50,11 +50,11 @@ function elgg_echo($message_key, $args = array(), $language = "") { $string = $CONFIG->translations[$language][$message_key]; } else if (isset($CONFIG->translations["en"][$message_key])) { $string = $CONFIG->translations["en"][$message_key]; - $lang = $CONFIG->translations["en"][$language]; + $lang = $CONFIG->translations["en"][$language]; elgg_log(sprintf('Missing %s translation for "%s" language key', $lang, $message_key), 'NOTICE'); } else { $string = $message_key; - elgg_log(sprintf('Missing English translation for "%s" language key', $message_key), 'WARNING'); + elgg_log(sprintf('Missing English translation for "%s" language key', $message_key), 'NOTICE'); } // only pass through if we have arguments to allow backward compatibility -- cgit v1.2.3 From 8163cd38fe4d963bfc9087f7fedc2461e655f43e Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 14 Jul 2012 21:00:53 -0400 Subject: Fixes #4705 validate view type --- engine/start.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'engine') diff --git a/engine/start.php b/engine/start.php index 5f4bded45..55b8ffa5b 100644 --- a/engine/start.php +++ b/engine/start.php @@ -100,6 +100,15 @@ elgg_trigger_event('boot', 'system'); // Load the plugins that are active elgg_load_plugins(); + +// @todo move loading plugins into a single boot function that replaces 'boot', 'system' event +// and then move this code in there. +// This validates the view type - first opportunity to do it is after plugins load. +$view_type = elgg_get_viewtype(); +if (!elgg_is_valid_view_type($view_type)) { + elgg_set_viewtype('default'); +} + // @todo deprecate as plugins can use 'init', 'system' event elgg_trigger_event('plugins_boot', 'system'); -- cgit v1.2.3 From 1080fecabc592c9c319c1aa816f61eb922cf3285 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Mon, 16 Jul 2012 20:05:39 -0400 Subject: added URL to the other new method names --- engine/classes/ElggPluginManifest.php | 4 ++-- engine/tests/api/plugins.php | 8 ++++---- views/default/object/plugin/full.php | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'engine') diff --git a/engine/classes/ElggPluginManifest.php b/engine/classes/ElggPluginManifest.php index 5706d1e42..a1fe66856 100644 --- a/engine/classes/ElggPluginManifest.php +++ b/engine/classes/ElggPluginManifest.php @@ -290,7 +290,7 @@ class ElggPluginManifest { * * @return string */ - public function getBugTracker() { + public function getBugTrackerURL() { return $this->parser->getAttribute('bugtracker'); } @@ -299,7 +299,7 @@ class ElggPluginManifest { * * @return string */ - public function getDonationsPage() { + public function getDonationsPageURL() { return $this->parser->getAttribute('donations'); } diff --git a/engine/tests/api/plugins.php b/engine/tests/api/plugins.php index 3b650f1b0..114f3991b 100644 --- a/engine/tests/api/plugins.php +++ b/engine/tests/api/plugins.php @@ -174,13 +174,13 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { } public function testElggPluginManifestGetBugtracker() { - $this->assertEqual($this->manifest18->getBugTracker(), 'http://trac.elgg.org'); - $this->assertEqual($this->manifest17->getBugTracker(), ''); + $this->assertEqual($this->manifest18->getBugTrackerURL(), 'http://trac.elgg.org'); + $this->assertEqual($this->manifest17->getBugTrackerURL(), ''); } public function testElggPluginManifestGetDonationsPage() { - $this->assertEqual($this->manifest18->getDonationsPage(), 'http://elgg.org/supporter.php'); - $this->assertEqual($this->manifest17->getDonationsPage(), ''); + $this->assertEqual($this->manifest18->getDonationsPageURL(), 'http://elgg.org/supporter.php'); + $this->assertEqual($this->manifest17->getDonationsPageURL(), ''); } public function testElggPluginManifestGetCopyright() { diff --git a/views/default/object/plugin/full.php b/views/default/object/plugin/full.php index 76e1136f2..2de65b555 100644 --- a/views/default/object/plugin/full.php +++ b/views/default/object/plugin/full.php @@ -174,8 +174,8 @@ $website = elgg_view('output/url', array( $resources = array( 'repository' => $plugin->getManifest()->getRepositoryURL(), - 'bugtracker' => $plugin->getManifest()->getBugTracker(), - 'donate' => $plugin->getManifest()->getDonationsPage(), + 'bugtracker' => $plugin->getManifest()->getBugTrackerURL(), + 'donate' => $plugin->getManifest()->getDonationsPageURL(), ); $resources_html = "
    "; -- cgit v1.2.3 From b164c39ac5c82b311e9ef07fa01fcc464bab86b1 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Mon, 16 Jul 2012 22:30:20 -0400 Subject: Fixes #4621 adds warning to remove_subtype() --- engine/lib/entities.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engine') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index abfe07276..66c1475b7 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -313,6 +313,10 @@ function add_subtype($type, $subtype, $class = "") { /** * Removes a registered ElggEntity type, subtype, and classname. * + * @warning You do not want to use this function. If you want to unregister + * a class for a subtype, use update_subtype(). Using this function will + * permanently orphan all the objects created with the specified subtype. + * * @param string $type Type * @param string $subtype Subtype * -- cgit v1.2.3