Skip to content

Commit

Permalink
chore(style): reduces nesting of code
Browse files Browse the repository at this point in the history
  • Loading branch information
Juho Jaakkola committed Jan 28, 2016
1 parent 75012a3 commit 05afad6
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions start.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,23 @@ function community_spam_is_new_user() {
* Remove some add links for new users
*/
function community_spam_remove_add_links() {
if (elgg_is_logged_in() && community_spam_is_new_user()) {
if (!elgg_is_logged_in()) {
return;
}

if (!community_spam_is_new_user()) {
return;
}

elgg_unregister_menu_item('extras', 'bookmark');
elgg_unregister_menu_item('extras', 'bookmark');

if (elgg_in_context('bookmarks') || elgg_in_context('pages')) {
// remove bookmarklet menu item
elgg_unregister_plugin_hook_handler('register', 'menu:page', 'bookmarks_page_menu');
if (elgg_in_context('bookmarks') || elgg_in_context('pages')) {
// remove bookmarklet menu item
elgg_unregister_plugin_hook_handler('register', 'menu:page', 'bookmarks_page_menu');

// remove add buttons
$callback = function() { return array(); };
elgg_register_plugin_hook_handler('register','menu:title', $callback);
}
// remove add buttons
$callback = function() { return array(); };
elgg_register_plugin_hook_handler('register','menu:title', $callback);
}
}

Expand All @@ -183,16 +188,18 @@ function community_spam_messages_filter($event, $type, $object) {
return;
}

if (community_spam_is_new_user()) {
$terms = array('yahoo', 'hotmail', 'miss', 'love', 'email address', 'dear', 'picture', 'profile', 'interest');
$count = 0;
foreach ($terms as $term) {
if (stripos($object->description, $term) !== false) {
$count++;
}
}
if ($count > 3) {
return false;
if (!community_spam_is_new_user()) {
return;
}

$terms = array('yahoo', 'hotmail', 'miss', 'love', 'email address', 'dear', 'picture', 'profile', 'interest');
$count = 0;
foreach ($terms as $term) {
if (stripos($object->description, $term) !== false) {
$count++;
}
}
if ($count > 3) {
return false;
}
}

0 comments on commit 05afad6

Please sign in to comment.