aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/ucp/ucp_zebra.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/ucp/ucp_zebra.php')
-rw-r--r--phpBB/includes/ucp/ucp_zebra.php55
1 files changed, 47 insertions, 8 deletions
diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php
index 5ed4db7520..6bb3cdc145 100644
--- a/phpBB/includes/ucp/ucp_zebra.php
+++ b/phpBB/includes/ucp/ucp_zebra.php
@@ -2,9 +2,8 @@
/**
*
* @package ucp
-* @version $Id$
* @copyright (c) 2005 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
@@ -26,7 +25,7 @@ class ucp_zebra
function main($id, $mode)
{
- global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
+ global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx, $request, $phpbb_dispatcher;
$submit = (isset($_POST['submit']) || isset($_GET['add']) || isset($_GET['remove'])) ? true : false;
$s_hidden_fields = '';
@@ -55,9 +54,22 @@ class ucp_zebra
// Remove users
if (!empty($data['usernames']))
{
+ $user_ids = $data['usernames'];
+
+ /**
+ * Remove users from friends/foes
+ *
+ * @event core.ucp_remove_zebra
+ * @var string mode Zebra type: friends|foes
+ * @var array user_ids User ids we remove
+ * @since 3.1-A1
+ */
+ $vars = array('user_ids');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_remove_zebra', compact($vars)));
+
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE user_id = ' . $user->data['user_id'] . '
- AND ' . $db->sql_in_set('zebra_id', $data['usernames']);
+ AND ' . $db->sql_in_set('zebra_id', $user_ids);
$db->sql_query($sql);
$updated = true;
@@ -187,6 +199,19 @@ class ucp_zebra
);
}
+ /**
+ * Add users to friends/foes
+ *
+ * @event core.ucp_add_zebra
+ * @var string mode Zebra type:
+ * friends|foes
+ * @var array sql_ary Array of
+ * entries we add
+ * @since 3.1-A1
+ */
+ $vars = array('mode', 'sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_add_zebra', compact($vars)));
+
$db->sql_multi_insert(ZEBRA_TABLE, $sql_ary);
$updated = true;
@@ -199,8 +224,24 @@ class ucp_zebra
}
}
}
-
- if ($updated)
+
+ if ($request->is_ajax())
+ {
+ $message = ($updated) ? $user->lang[$l_mode . '_UPDATED'] : implode('<br />', $error);
+
+ $json_response = new \phpbb\json_response;
+ $json_response->send(array(
+ 'success' => $updated,
+
+ 'MESSAGE_TITLE' => $user->lang['INFORMATION'],
+ 'MESSAGE_TEXT' => $message,
+ 'REFRESH_DATA' => array(
+ 'time' => 3,
+ 'url' => $this->u_action
+ )
+ ));
+ }
+ else if ($updated)
{
meta_refresh(3, $this->u_action);
$message = $user->lang[$l_mode . '_UPDATED'] . '<br />' . implode('<br />', $error) . ((sizeof($error)) ? '<br />' : '') . '<br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
@@ -253,5 +294,3 @@ class ucp_zebra
$this->page_title = 'UCP_ZEBRA_' . $l_mode;
}
}
-
-?> \ No newline at end of file