From f496261aadce495d841a3f31f932ecf50591fd4a Mon Sep 17 00:00:00 2001 From: Stanislav Atanasov Date: Sat, 19 Jul 2014 22:20:23 +0300 Subject: [PATCH] Move Zebra to new repo --- README.md | 31 +- composer.json | 24 ++ config/routing.yml | 5 + config/services.yml | 82 ++++ controller/ajaxify.php | 161 ++++++++ controller/notifyhelper.php | 85 ++++ event/zebra_listener.php | 369 ++++++++++++++++++ ext.php | 124 ++++++ images/cancel.gif | Bin 0 -> 634 bytes images/confirm_16.png | Bin 0 -> 966 bytes images/favorite_add.png | Bin 0 -> 2135 bytes images/favorite_remove.png | Bin 0 -> 2205 bytes language/bg/zebra_enchance.php | 50 +++ language/en/zebra_enchance.php | 51 +++ migrations/v10x/release_1_0_0.php | 78 ++++ notification/zebraadd.php | 204 ++++++++++ notification/zebraconfirm.php | 204 ++++++++++ styles/composer.json | 24 ++ styles/config/routing.yml | 5 + styles/config/services.yml | 82 ++++ styles/controller/ajaxify.php | 161 ++++++++ styles/controller/notifyhelper.php | 85 ++++ styles/event/zebra_listener.php | 369 ++++++++++++++++++ styles/ext.php | 124 ++++++ styles/images/cancel.gif | Bin 0 -> 634 bytes styles/images/confirm_16.png | Bin 0 -> 966 bytes styles/images/favorite_add.png | Bin 0 -> 2135 bytes styles/images/favorite_remove.png | Bin 0 -> 2205 bytes styles/language/bg/zebra_enchance.php | 50 +++ styles/language/en/zebra_enchance.php | 51 +++ styles/migrations/v10x/release_1_0_0.php | 78 ++++ styles/notification/zebraadd.php | 204 ++++++++++ styles/notification/zebraconfirm.php | 204 ++++++++++ ...memberlist_view_user_statistics_after.html | 20 + .../template/event/overall_footer_after.html | 32 ++ .../event/ucp_friend_list_before.html | 40 ++ 36 files changed, 2995 insertions(+), 2 deletions(-) create mode 100644 composer.json create mode 100644 config/routing.yml create mode 100644 config/services.yml create mode 100644 controller/ajaxify.php create mode 100644 controller/notifyhelper.php create mode 100644 event/zebra_listener.php create mode 100644 ext.php create mode 100644 images/cancel.gif create mode 100644 images/confirm_16.png create mode 100644 images/favorite_add.png create mode 100644 images/favorite_remove.png create mode 100644 language/bg/zebra_enchance.php create mode 100644 language/en/zebra_enchance.php create mode 100644 migrations/v10x/release_1_0_0.php create mode 100644 notification/zebraadd.php create mode 100644 notification/zebraconfirm.php create mode 100644 styles/composer.json create mode 100644 styles/config/routing.yml create mode 100644 styles/config/services.yml create mode 100644 styles/controller/ajaxify.php create mode 100644 styles/controller/notifyhelper.php create mode 100644 styles/event/zebra_listener.php create mode 100644 styles/ext.php create mode 100644 styles/images/cancel.gif create mode 100644 styles/images/confirm_16.png create mode 100644 styles/images/favorite_add.png create mode 100644 styles/images/favorite_remove.png create mode 100644 styles/language/bg/zebra_enchance.php create mode 100644 styles/language/en/zebra_enchance.php create mode 100644 styles/migrations/v10x/release_1_0_0.php create mode 100644 styles/notification/zebraadd.php create mode 100644 styles/notification/zebraconfirm.php create mode 100644 styles/prosilver/template/event/memberlist_view_user_statistics_after.html create mode 100644 styles/prosilver/template/event/overall_footer_after.html create mode 100644 styles/prosilver/template/event/ucp_friend_list_before.html diff --git a/README.md b/README.md index 55f21be..ceb3645 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,31 @@ -zebraenhance +Friend list enchance ============ -Event Medals is a extension for PhpBB3 that adds support for event awards. +Zebra enhance + + Description: + + Enhances PhpBB Zebra module adding additional ACL level. + Adds support for friend request need to be approved. + Adds addition level of friends - hidden mark for special friends. + Adds beautiful friend control. + + Features: + + System: + - Make sure AJAX Callback function is loaded only in UCP -> Zebra + - Add notifications for new requests. + + UCP: + - Show pending and awaiting confirmation requests + - Show beautiful friend control (using AJAX) + - Add option for selecting "Close Friends" with additional access* + - Dynamically locate which is the zebra module + - Cancel request use AJAXed "confirm_box" + - See if when user is deleted zebra cleans the remains (if not - make the extension do it) + - Add ACL who can view friendlist + + Profile: + - Add friend list in profile + Global TO DO: + Optimize and Clean code. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..a5c4a26 --- /dev/null +++ b/composer.json @@ -0,0 +1,24 @@ +{ + "name": "anavaro/zebraenhance", + "type": "phpbb-extension", + "description": "Enchance ZEBRA function adding confimation and special friends", + "homepage": "", + "version": "1.0.0", + "time": "2014-05-23", + "license": "GPL-2.0", + "authors": [ + { + "name": "Stanislav Atanasov", + "email": "lucifer@anavaro.com", + "homepage": "http://anavaro.com", + "role": "Lead Developer" + } + ], + "require": { + "php": ">=5.3", + "phpbb/phpbb": "3.1.*@dev" + }, + "extra": { + "display-name": "phpBB 3.1 Zebra Enchance" + } +} diff --git a/config/routing.yml b/config/routing.yml new file mode 100644 index 0000000..6ba1e8d --- /dev/null +++ b/config/routing.yml @@ -0,0 +1,5 @@ +zebra_enchacnce_ajax: + path: /zebraenhance/{action}/{userid} + defaults: { _controller: anavaro.zebraenhance.ajaxyfy:base } + requirements: + userid: \d+ \ No newline at end of file diff --git a/config/services.yml b/config/services.yml new file mode 100644 index 0000000..61f5f98 --- /dev/null +++ b/config/services.yml @@ -0,0 +1,82 @@ +services: + anavaro.zebraenhance.listener: + class: anavaro\zebraenhance\event\zebra_listener + arguments: + - @user_loader + - @auth + - @cache + - @config + - @dbal.conn + - @request + - @template + - @user + - @controller.helper + - @anavaro.zebraenhance.notifyhelper + - %core.root_path% + - %core.php_ext% + - %core.table_prefix% + tags: + - { name: event.listener } + anavaro.zebraenhance.ajaxyfy: + class: anavaro\zebraenhance\controller\ajaxify + arguments: + - @auth + - @cache + - @config + - @dbal.conn + - @request + - @template + - @user + - @controller.helper + - %core.root_path% + - %core.php_ext% + - %core.table_prefix% + anavaro.zebraenhance.notifyhelper: + class: anavaro\zebraenhance\controller\notifyhelper + arguments: + - @config + - @dbal.conn + - @request + - @template + - @user + - @service_container + - %core.root_path% + - %core.php_ext% + - %core.table_prefix% + notification.type.zebraadd: + class: anavaro\zebraenhance\notification\zebraadd + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - @controller.helper + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.zebraconfirm: + class: anavaro\zebraenhance\notification\zebraconfirm + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - @controller.helper + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } \ No newline at end of file diff --git a/controller/ajaxify.php b/controller/ajaxify.php new file mode 100644 index 0000000..248208f --- /dev/null +++ b/controller/ajaxify.php @@ -0,0 +1,161 @@ +auth = $auth; + $this->cache = $cache; + $this->config = $config; + $this->db = $db; + $this->request = $request; + $this->template = $template; + $this->user = $user; + $this->helper = $helper; + $this->root_path = $root_path; + $this->php_ext = $php_ext; + $this->table_prefix = $table_prefix; + } + + + public function base ($action, $userid) + { + + //load language file + + $this->user->add_lang_ext('anavaro/zebraenhance', 'zebra_enchance'); + $confirm = $this->request->variable('confirm', ''); + $u_action = $this->root_path . 'ucp.php?i=168'; + switch ($action) + { + + case 'cancel_fr': + // check mode + if ($confirm) + { + //$this->var_display($userid); + //let me delete all requests between you and user id. + + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . $userid . ' AND zebra_id = ' . $this->user->data['user_id']; + $this->db->sql_query($sql); + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . $this->user->data['user_id'] . ' AND zebra_id = ' . $userid; + $this->db->sql_query($sql); + $message = ''; + if ($this->request->is_ajax()) + { + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'success' => $updated, + 'MESSAGE_TITLE' => $this->user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $this->user->lang['UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL_ASK'], + 'REFRESH_DATA' => array( + 'time' => 3, + 'url' => $u_action + ) + )); + } + else + { + meta_refresh(3, $u_action); + trigger_error($this->user->lang['UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL']); + } + } + else + { + confirm_box(false, $this->user->lang['UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL_ASK']); + } + break; + case 'togle_bff': + $sql='SELECT bff FROM ' . ZEBRA_TABLE . ' WHERE zebra_id = ' .$userid. ' AND user_id = ' .$this->user->data['user_id']; + $result = $this->db->sql_fetchrow($this->db->sql_query($sql)); + if ($result) + { + if($result['bff'] == '0') + { + $sql = 'UPDATE ' . ZEBRA_TABLE . ' SET bff = 1 WHERE zebra_id = ' . $userid. ' AND user_id = ' .$this->user->data['user_id']; + $this->db->sql_query($sql); + $exit = 'add'; + } + if($result['bff'] == '1') + { + $sql = 'UPDATE ' . ZEBRA_TABLE . ' SET bff = 0 WHERE zebra_id = ' .$userid. ' AND user_id = ' .$this->user->data['user_id']; + $this->db->sql_query($sql); + $exit = 'rem'; + } + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'status' => '0', + 'exit' => $exit, + 'user_id' => $userid, + )); + } + else + { + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'status' => '1', + 'user_id' => $userid, + )); + } + + break; + case 'change_acl': + if ($userid > 4) + { + $userid = 0; + } + $sql = 'UPDATE ' . $this->table_prefix . 'users_custom SET profile_friend_show = ' . $userid . ' WHERE user_id = '.$this->user->data['user_id']; + $this->db->sql_query($sql); + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'status' => 0, + 'exit' => 'acl_set' + )); + break; + } + } + protected function var_display($i) + { + echo '
';
+		print_r($i);
+		echo '
'; + return true; + } + + +} \ No newline at end of file diff --git a/controller/notifyhelper.php b/controller/notifyhelper.php new file mode 100644 index 0000000..77dc613 --- /dev/null +++ b/controller/notifyhelper.php @@ -0,0 +1,85 @@ +config = $config; + $this->db = $db; + $this->request = $request; + $this->template = $template; + $this->user = $user; + $this->phpbb_container = $phpbb_container; + $this->root_path = $root_path; + $this->php_ext = $php_ext; + } + + public function test() + { + + } + + /** + * Main notification function + * @param type Type of notification (add/confirm) + * @param notify_user User to notify + * @param action_user User that trigered the action + */ + public function notify($type, $notify_user, $action_user) + { + $notification_data = array( + 'user_id' => (int) $notify_user, + 'requester_id' => (int) $action_user, + ); + + + $phpbb_notifications = $this->phpbb_container->get('notification_manager'); + + switch ($type) + { + case 'add': + $phpbb_notifications->add_notifications('zebraadd', $notification_data); + break; + case 'confirm': + $phpbb_notifications->add_notifications('zebraconfirm', $notification_data); + break; + } + + } + public function clean($user1, $user2) + { + $phpbb_notifications = $this->phpbb_container->get('notification_manager'); + $phpbb_notifications->delete_notifications('zebraadd', $user1, $user2); + $phpbb_notifications->delete_notifications('zebraadd', $user2, $user1); + $phpbb_notifications->delete_notifications('zebraconfirm', $user2, $user1); + $phpbb_notifications->delete_notifications('zebraconfirm', $user1, $user2); + } +} \ No newline at end of file diff --git a/event/zebra_listener.php b/event/zebra_listener.php new file mode 100644 index 0000000..190b9a4 --- /dev/null +++ b/event/zebra_listener.php @@ -0,0 +1,369 @@ + 'prepare_medals', + //'core.user_setup' => 'load_language_on_setup', + //'core.memberlist_view_profile' => 'fuunct_one', + //'core.viewtopic_modify_post_row' => 'modify_post_row', + + 'core.user_setup' => 'load_language_on_setup', + 'core.ucp_add_zebra' => 'zebra_confirm_add', + 'core.ucp_remove_zebra' => 'zebra_confirm_remove', + 'core.ucp_display_module_before' => 'module_display', + 'core.delete_user_before' => 'delete_users', + 'core.memberlist_prepare_profile_data' => 'prepare_friends', + ); + } + + + /** + * Constructor + * NOTE: The parameters of this method must match in order and type with + * the dependencies defined in the services.yml file for this service. + * + * @param \phpbb\auth $auth Auth object + * @param \phpbb\cache\service $cache Cache object + * @param \phpbb\config $config Config object + * @param \phpbb\db\driver $db Database object + * @param \phpbb\request $request Request object + * @param \phpbb\template $template Template object + * @param \phpbb\user $user User object + * @param \phpbb\content_visibility $content_visibility Content visibility object + * @param \phpbb\controller\helper $helper Controller helper object + * @param string $root_path phpBB root path + * @param string $php_ext phpEx + */ + public function __construct(\phpbb\user_loader $user_loader, \phpbb\auth\auth $auth, \phpbb\cache\service $cache, \phpbb\config\config $config, \phpbb\db\driver\driver $db, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, \anavaro\zebraenhance\controller\notifyhelper $notifyhelper, $root_path, $php_ext, $table_prefix) + { + $this->user_loader = $user_loader; + $this->auth = $auth; + $this->cache = $cache; + $this->config = $config; + $this->db = $db; + $this->request = $request; + $this->template = $template; + $this->user = $user; + $this->helper = $helper; + $this->notifyhelper = $notifyhelper; + $this->root_path = $root_path; + $this->php_ext = $php_ext; + $this->table_prefix = $table_prefix; + } + public function load_language_on_setup($event){ + $lang_set_ext = $event['lang_set_ext']; + $lang_set_ext[] = array( + 'ext_name' => 'anavaro/zebraenhance', + 'lang_set' => 'zebra_enchance', + ); + $event['lang_set_ext'] = $lang_set_ext; + $this->notifyhelper->test(); + if ($this->config['zebra_module_id'] == 'none') + { + $sql = 'SELECT parent_id FROM ' . MODULES_TABLE . ' WHERE module_basename = \'ucp_zebra\' LIMIT 1'; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->config->set('zebra_module_id', $row['parent_id']); + } + + } + + + protected $image_dir = 'ext/anavaro/zebraenhance/images'; + + public function zebra_confirm_add($event) + { + if ($event['mode'] == 'friends') + { + foreach($event['sql_ary'] as $VAR) + { + //let's test if we have sent request + $sql = 'SELECT * FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . (int) $VAR['user_id'] . ' AND zebra_id = ' . (int) $VAR['zebra_id']; + $result = $this->db->sql_fetchrow($this->db->sql_query($sql)); + if (!$result) + { + //Let's test if request is pending from the other user + $sql = 'SELECT * FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . (int) $VAR['zebra_id'] . ' AND zebra_id = ' . (int) $VAR['user_id']; + $result = $this->db->sql_fetchrow($this->db->sql_query($sql)); + //$this->var_display($result); + if ($result) + { + //so we have incoming request -> we add friends! + $sql = 'INSERT INTO '. ZEBRA_TABLE .' SET user_id = ' . (int) $VAR['user_id'] . ', zebra_id = ' . (int) $VAR['zebra_id'] . ', friend = 1, foe = 0'; + $this->db->sql_query($sql); + $sql = 'INSERT INTO '. ZEBRA_TABLE .' SET user_id = ' . (int) $VAR['zebra_id'] . ', zebra_id = ' . (int) $VAR['user_id'] . ', friend = 1, foe = 0'; + $this->db->sql_query($sql); + + //let's clean the request table + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . (int) $VAR['zebra_id'] . ' AND zebra_id = ' . (int) $VAR['user_id']; + $this->db->sql_query($sql); + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . (int) $VAR['user_id'] . ' AND zebra_id = ' . (int) $VAR['zebra_id']; + $this->db->sql_query($sql); + $this->notifyhelper->notify('confirm', $VAR['zebra_id'], $VAR['user_id']); + } + else + { + //lets see if user is hostile towerds us (if yes - silently drop request) + $sql = 'SELECT * FROM '. ZEBRA_TABLE .' WHERE user_id = ' . (int) $VAR['zebra_id'] . ' AND zebra_id = ' . (int) $VAR['user_id']. ' AND foe = 1'; + $result = $this->db->sql_fetchrow($this->db->sql_query($sql)); + if (!$result) { + $sql = 'INSERT INTO ' . $this->table_prefix . 'zebra_confirm SET user_id = ' . (int) $VAR['user_id'] . ', zebra_id = ' . (int) $VAR['zebra_id'] . ', friend = 1, foe = 0'; + $this->db->sql_query($sql); + $this->notifyhelper->notify('add', $VAR['zebra_id'], $VAR['user_id']); + } + } + } + } + $event['sql_ary'] = array(); + } + if ($event['mode'] == 'foes') + { + foreach($event['sql_ary'] as $VAR) + { + //if we add user as foe we have to remove pending requests. + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . (int) $VAR['zebra_id']. ' AND zebra_id = ' . (int) $VAR['user_id']; + $this->db->sql_query($sql); + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . (int) $VAR['user_id'] . ' AND zebra_id = ' . (int) $VAR['zebra_id']; + $this->db->sql_query($sql); + } + } + } + + public function zebra_confirm_remove($event) + { + if($event['mode'] == 'friends') + { + //let's go for syncronieus remove + foreach($event['user_ids'] AS $VAR) + { + $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' + WHERE user_id = ' . $this->user->data['user_id'] . ' + AND zebra_id = '. $VAR; + $this->db->sql_query($sql); + + $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' + WHERE user_id = ' . $VAR . ' + AND zebra_id = '. $this->user->data['user_id']; + $this->db->sql_query($sql); + + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm + WHERE user_id = ' . $this->user->data['user_id'] . ' + AND zebra_id = '. $VAR; + $this->db->sql_query($sql); + + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm + WHERE user_id = ' . $VAR . ' + AND zebra_id = '. $this->user->data['user_id']; + $this->db->sql_query($sql); + + $this->notifyhelper->clean($VAR, $this->user->data['user_id']); + } + + $event['user_ids'] = array('0'); + } + } + + + public function module_display($event) + { + $ispending = $iswaiting = ''; + if ($event['id'] == 'ucp_zebra' OR $event['id'] == $this->config['zebra_module_id']) + { + $this->template->assign_var('IS_ZEBRA', '1'); + $sql = 'SELECT profile_friend_show FROM ' . $this->table_prefix . 'users_custom WHERE user_id = '. $this->user->data['user_id']; + $result = $this->db->sql_fetchrow($this->db->sql_query($sql)); + $this->template->assign_var('ZEBRA_ACL', $result['profile_friend_show']); + //let's get incoming pendings + $sql_array = array( + 'SELECT' => 'zc.*, u.username, u.user_colour', + 'FROM' => array( + $this->table_prefix . 'zebra_confirm' => 'zc', + USERS_TABLE => 'u', + ), + 'WHERE' => 'zc.user_id = u.user_id AND zc.zebra_id = '.$this->user->data['user_id'] + ); + $sql = $this->db->sql_build_query('SELECT', $sql_array); + $result = $this->db->sql_query($sql); + + while($row = $this->db->sql_fetchrow($result)) + { + $ispending = 1; + $this->template->assign_block_vars('pending_requests', array( + 'USERNAME' => ''.$row['username'].'', + 'CONFIRM' => '', + 'CANCEL' => '', + )); + } + if($ispending) + { + $this->template->assign_var('HAS_PENDING', 'yes'); + + } + //now, let's get our own requests that are waiting. + $sql_array = array( + 'SELECT' => 'zc.*, u.username, u.user_colour', + 'FROM' => array( + $this->table_prefix . 'zebra_confirm' => 'zc', + USERS_TABLE => 'u', + ), + 'WHERE' => 'zc.zebra_id = u.user_id AND zc.user_id = '.$this->user->data['user_id'] + ); + $sql = $this->db->sql_build_query('SELECT', $sql_array); + $result = $this->db->sql_query($sql); + + while($row = $this->db->sql_fetchrow($result)) + { + $iswaiting = 1; + $this->template->assign_block_vars('pending_awaits', array( + 'USERNAME' => ''.$row['username'].'', + 'CANCEL' => '', + )); + } + if($iswaiting) + { + $this->template->assign_var('HAS_WAITING', 'yes'); + } + + + //let's populate the prity zebra list (bff and all) + $sql_array = array( + 'SELECT' => 'zc.*, u.username, u.user_colour', + 'FROM' => array( + ZEBRA_TABLE => 'zc', + USERS_TABLE => 'u', + ), + 'WHERE' => 'zc.zebra_id = u.user_id AND zc.user_id = '.$this->user->data['user_id'], + 'ORDER_BY' => 'u.username ASC' + ); + $sql = $this->db->sql_build_query('SELECT', $sql_array); + $result = $this->db->sql_query($sql); + while($row = $this->db->sql_fetchrow($result)) + { + $this->template->assign_block_vars('prity_zebra', array( + 'USERNAME' => ''.$row['username'].'', + 'CANCEL' => '', + 'BFF' => $row['bff'] ? '' : '' + )); + } + $this->template->assign_var('IMGDIR', $this->image_dir); + } + } + + + public function delete_users($event) + { + foreach ($event['user_ids'] AS $VAR) + { + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = '.$VAR.' OR zebra_id = '.$VAR; + $this->db->sql_query($sql); + $sql = 'DELETE FROM '. ZEBRA_TABLE .' WHERE user_id = '.$VAR.' OR zebra_id = '.$VAR; + $this->db->sql_query($sql); + } + } + + public function prepare_friends($event) + { + $sql = 'SELECT profile_friend_show FROM ' . $this->table_prefix . 'users_custom WHERE user_id = '.$this->db->sql_escape($event['data']['user_id']); + $result = $this->db->sql_query($sql); + $optResult = $this->db->sql_fetchrow($result); + $sql = 'SELECT * FROM ' . ZEBRA_TABLE . ' WHERE user_id = '.$this->db->sql_escape($event['data']['user_id']).' AND zebra_id = '.$this->user->data['user_id']; + $result = $this->db->sql_fetchrow($this->db->sql_query($sql)); + $zebra_state = 0; + if ($result) + { + if ($result['foe'] == 1) + { + $zebra_state = 1; + } + else + { + if ($result['bff'] == '0') { + $zebra_state = 3; + } + else { + $zebra_state = 4; + } + } + } + else + { + $zebra_state = 2; + } + //print_r($zebra_state); + $users; + $show = ($optResult['profile_friend_show'] > 0 ? (($optResult['profile_friend_show'] == 1 AND $zebra_state != 1) ? (($optResult['profile_friend_show'] <= $zebra_state) ? true : false) : false) : false); + if ($event['data']['user_id'] == $this->user->data['user_id'] || $this->auth->acl_get('a_user') || $show) + { + $sql = 'SELECT zebra_id FROM ' . ZEBRA_TABLE . ' WHERE user_id = ' . $this->db->sql_escape($event['data']['user_id']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $user_id[] = (int) $row['zebra_id']; + } + if (!empty($user_id)) + { + $this->user_loader->load_users($user_id); + $selector = 0; + foreach ($user_id as $VAR) { + $this->template->assign_block_vars('zebra_friendslist', array( + 'USER_LINK' => $this->user_loader->get_username($VAR, 'profile'), + 'USER_AVATAR' => $this->user_loader->get_avatar($VAR), + 'USERNAME' => $this->user_loader->get_username($VAR, 'full'), + 'SELECTOR' => $selector, + )); + if ($selector == 3) + { + $selector = 0; + } + else + { + $selector ++; + } + } + } + } + else + { + $this->template->assign_var('FRIENDLIST_ERROR_ACCESS', 'yes'); + } + $this->template->assign_var('FRIENDLIST', 'yes'); + } + + protected function var_display($i) + { + echo '
';
+		print_r($i);
+		echo '
'; + return true; + } + +} diff --git a/ext.php b/ext.php new file mode 100644 index 0000000..e60add0 --- /dev/null +++ b/ext.php @@ -0,0 +1,124 @@ +container->get('notification_manager'); + $phpbb_notifications->enable_notifications('zebraadd'); + $phpbb_notifications->enable_notifications('zebraconfirm'); + return 'notifications'; + + break; + + default: + + // Run parent enable step method + return parent::enable_step($old_state); + + break; + } + } + + /** + * Single disable step that does nothing + * + * @param mixed $old_state State returned by previous call of this method + * @return mixed Returns false after last step, otherwise temporary state + */ + function disable_step($old_state) + { + switch ($old_state) + { + case '': // Empty means nothing has run yet + + // Disable board rules notifications + $phpbb_notifications = $this->container->get('notification_manager'); + $phpbb_notifications->disable_notifications('zebraadd'); + $phpbb_notifications->disable_notifications('zebraconfirm'); + return 'notifications'; + + break; + + default: + + // Run parent disable step method + return parent::disable_step($old_state); + + break; + } + } + + /** + * Single purge step that reverts any included and installed migrations + * + * @param mixed $old_state State returned by previous call of this method + * @return mixed Returns false after last step, otherwise temporary state + */ + function purge_step($old_state) + { + switch ($old_state) + { + case '': // Empty means nothing has run yet + + /** + * @todo Remove this try/catch condition once purge_notifications is fixed + * in the core to work with disabled extensions without fatal errors. + * https://tracker.phpbb.com/browse/PHPBB3-12435 + */ + try + { + // Purge board rules notifications + $phpbb_notifications = $this->container->get('notification_manager'); + $phpbb_notifications->purge_notifications('zebraadd'); + $phpbb_notifications->purge_notifications('zebraconfirm'); + } + catch (\phpbb\notification\exception $e) + { + // continue + } + + return 'notifications'; + + break; + + default: + + // Run parent purge step method + return parent::purge_step($old_state); + + break; + } + } +} diff --git a/images/cancel.gif b/images/cancel.gif new file mode 100644 index 0000000000000000000000000000000000000000..f2e8e38f4dcbccc481ddbd722ae8be09f7df04c8 GIT binary patch literal 634 zcmZ?wbhEHb6krfwIOfCf$c*8MIm1(PhF2C0Z!H+!TQYpGWcXys@Y#yts};j{D~2C7 z48Lp`e%mnowPE;Y%kbZh;lDlGe<$w$F8u%8ME<#p|MQai=Og>iSK*((^1mR>|53*O zRru+X~pZ|G&|BHhEmxTSVjQ(F0`>!$WUvt*K)|`JG1^;_W z{!gg-Ke_h*^rrtan*Yyi{Xe_?|D4YM^Sb^o?EAlH!v7_c{x6&I|IoJoC-(h6x&Qyg zlm9QD{&)N8zq{A|-M#Ve;oX0a@BMrF;Q#Z-|KGg)|L)cQ5AXhe`tbk9_y50s{Qvv+ z{~!j6{{)?jQWHy3QxwWGOEMJPJ$(Zh6o0ZXaxv61=r8~QD54nH4>i;`HMg|32z7LJ z3bx8x+S*KLUS4UgZ#mmcGN>EsYr-@lhL(|dK&DqsO zUQB|ci9t<8+1g1-#NJNsncxQTM~7Ki6vSK(1UNFW@vyS69+=SR*u=`G5-=m-pc5No lGe^b`0jDDzLaIU2DgrnTG%|A}C^;-pXjnMAjfs)L8UO_UZR`L5 literal 0 HcmV?d00001 diff --git a/images/confirm_16.png b/images/confirm_16.png new file mode 100644 index 0000000000000000000000000000000000000000..83330e48b6966eb585527e1528850c5347e039c8 GIT binary patch literal 966 zcmV;%13CPOP)+KxDZ(oAb=QQ44t_;@<5FnOeBmAqO_tIoaCHP zbnkn#k73!hWejItoV@@vDBw!+m4_g4fB*s;pgB_$r1?UTd4Yh3iX+4J=L;Dwe>}qQ z{qGmBW=>`v23>v|22aU&hMjkS4*Adcq3>j$!S(d(4*>!QY=GJ{wetlQIR-Y0CJfVV zR{%ABWxxi6*(Dgd3^oAmVq`e=?BoSY8EZp;0Af*|tQ@Z^rfp!SWX3SzdMQxzH>{eu zfUd|@?P2)){}02@zuy^DMC1*ge7jQ*5I`({|NKn|(C}i|`gl3R=bzYZ=3?PtDAS(8 zAj%=h@a4}3h95vn9({Vqkh#9l0U&^wfCf02$mug&e0zrB_g@BvAh|RKHbx#W8-!Vb z>{6Y61`&2KhR;CFpZ~mPxc%u013wox!`m zIE#TDsF974o1s*7^)0<8Gioz4%95d@cH)#Ap0A`!_RjaW?!8O^uiCY9$`*F27my9yI{-1bqu#Y zTx0n5_cPcgVNPKNAr2uh`wI}?`FNdS`sJxWm;PX2VPpsEdH((-13&;Vv)i&e$Owxo zFtGk-SaEA9gQl=10~-qq!?!=5fidzKXy6xyd!K+dUz*GC?e|ZHfBzX6)P>X;-o5|G zaP-#M0{{U8a>0U4XZJ9eO6oKG`16aQ?pQU$_4k*-HiPh;54RX*UYG}rp&tyt|NLiQ zVqgWU1?d6l1qdMKpGSUP{Gk0gfRB?)!cpCv;nK@n49A|HWKa;4W_a`cHN)Hs%i%V& zGP5#-Xt^_-ync~k@1+wLzI1)b1PCB-O5`l$lm`ahg>ZX!0W&Rah7*skGCckG7U<94 zU{|pNH7W~BGFZrJGn~41m0{(klqNh5hOs04sl>p3f4nll<4DUXD og5}!-Kytyq>Hko&GeCd=03gYB0F-l~FaQ7m07*qoM6N<$f|RPVCIA2c literal 0 HcmV?d00001 diff --git a/images/favorite_add.png b/images/favorite_add.png new file mode 100644 index 0000000000000000000000000000000000000000..ce7ee4adf00b7794fd979ec760078664ddb0ea29 GIT binary patch literal 2135 zcmV-d2&ngoP)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ@-AP12RCwBymurk&RTam7YwvUJdpdWfGwsYUwJmLd0+yDFKub$OKt(VnH3dvS zBLQNR;0Gi4fkcgwM1mob82MmC4FrK05)CO0j|erO2#Tc-Vd`}Hn6dNdyzZTQ?zw00 z<%fCn&fICCJ6Xwj?414I|NmP5b+)J~0MTE*3f6-6oN*XK<%8ax$yn)YV(kOKan3pf z)Zxn|B+OwlIV7D%jL`D!zXA}?1Cz8=}rx^S6#{w`0 zH&H^91WBD?%It+NN0i<^1TI0cDI^sj=>?Ipn}Uv(HVFbGmHwQ`W;tWz@}S`37(~v9 zagG787GJ7Rez%9F>pngGMi){b+k>{I&^8xTu-6g<7HFVLj6rKPd?iB8uF+`*03@{3 zj*k%SKZaydV9oq6vfbv>gv*LCVfsRo&#g209P^@(N754O__Jry_h*1@rNXFAe}8uq6HCRC|Un*$@c~V$F8! z^hZrTw6;0tC7a%23fY_~WU<9O>KtyO{E2pcb^rj@5WRnbWT=d!12D2(tbhm-NMMVZ z*kn@Owkdm=E#@H%NQTEb*KrzvD)^aDofgx1D(@agqof%t8|PJcA#^66L5=M2agAEv zAjHWz?S6h4W>VLhe0nFw77!T}VCQX^?>>S7gcfbX7H~PNST-l!U!;m z>LlKmP(O+>V?b%fSq=jy8UUEUK8}^;So4rrgIJlaeF3~$ja{8g9=rx7t5&QDOeVPA z7cywoqSX`{WpL#zZmfixu=pra1d$+kNsK(OxDQM(^aIp&s@JdM1jI9EWeQrCC+Zb- zDmZV&RS_5C)q=@FDh;tiBtb|Bj1Ed@e90TeU z5|1P?E{^eLEwo?3RM^3|8bD}LM}DLi*YoCo2DNaj1mQ>dcz`fIMNpe)1fX*nMhx6R zqOXXN&B*DVp#C%fsa1&MW>~t5_kEG)d-w9r$(I?bi~>qqwuOz$FJkA`dsnVct$M8Q zc;7=KT020sj3iTBJxl!T!pV{Q<}=~=6soTvtecf!mU^j0#IBRdvio?n=XHMl@8>aM zXv!AwC?a4nl&cl0NtHV;zLAGFd}Czr*#CB&DviG;V%c`hmIVw{l7(U%1?~Y}1I)BP z04^p@3PfG^@tuD?!yiA~!$r%^$68@!({gTEwGDtj_3q_JsUNGB-yYh-;fdo*f4BYN z7orcNt(7=B*kD8&C5uI~R-MtRLt}?l6I@iqwCv*NeS3NC@NO>eUPo)rPz)nBwzhHi z`dhhs{jIE9(m`twQOqbCI#;sy8;$R2xREg_Q&*K-JTg@1C2xsr^!_wIzfm zq^1c6M|)XY7-o2CAJtGdHv)*0h5TQINV@(&fl9)J4< zUz&IS)PWZm9RC|e$B2pB8UVObw4hJQ4l!oNh!j6MHe4PHev*8q<(s)cHz*L~MH`TTgm+xS7?Bw&CTdqw4y8@@4w9S#SIZ`%H zVA69tNZAxAo1b}?LlF{f<*Ma3Gd?l)OalOu&P+!tjmhO-lXT|$s2%`CO~7RP<#?A+ znwmUdOR1-BUi)22NfxiQIhBprI?cnmCZZ&i63g|g@28E9KbI<#Z=AUs)^|QY)Z@}c z;^wtj90UQ!2l^h|c;R(h%WEE7zxT*v1Tuk@fZ?gbywvjuieTJ37!#8C2&Y-D{?xbF z(Xp$)_rHhlPm&sE2e8;7bH))x1m}}ey}ciOdE1&hUhK@Rxa5tazhb1kkCWvd`X_%j zBS9LGCR(x=vSr0RY-qjt=<%aRcShCdh%x3|0kGhlCe)Hz&yl{K9V?b?{^?y8KY7=Y z$#>GnCjZHJbpXZDoa*4brpq|L`6?g8P0tPVpLnnmO&zUY{2T!+^eI7AhmZC5-P=@X z{>94T)~~GVxNfW0=sd&_n(Sb;T77$RXzazQ=-5AuF&Ja;3y%N)9{^bQrqJd3Q7ixe N002ovPDHLkV1k;-2JZj> literal 0 HcmV?d00001 diff --git a/images/favorite_remove.png b/images/favorite_remove.png new file mode 100644 index 0000000000000000000000000000000000000000..a94ad30a4f0988a1f9a2f822f5e62c4a7c46fb82 GIT binary patch literal 2205 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 literal 0 HcmV?d00001 diff --git a/language/bg/zebra_enchance.php b/language/bg/zebra_enchance.php new file mode 100644 index 0000000..7c784e7 --- /dev/null +++ b/language/bg/zebra_enchance.php @@ -0,0 +1,50 @@ + 'Очакващи потвърждение', + 'UCP_ZEBRA_PENDING_IN_EXP' => 'Списък на очакващите потвърждение заявки за приятелство.', + + 'UCP_ZEBRA_PENDING_OUT' => 'Изчакващи потвърждение', + 'UCP_ZEBRA_PENDING_OUT_EXP' => 'Списък на изчкаващите вашето потвърждение заявки за приятелство.', + + 'UCP_ZEBRA_PENDING_NONE' => 'Нямате изчакващи заявки', + + + 'UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL_ASK' => 'Сигурни ли сте, че искате да отхвърлите предложението за приятелство?', + 'UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL' => 'Предложението за приятелство е отхвърлено!', + + 'NOTIFICATION_TYPE_ZEBRA_ADD' => 'Сигнал за получаване на заявка за приятелство', + 'NOTIFICATION_ZEBRA_ADD' => '%1$s Ви изпрати покана за приятелство!', + + 'NOTIFICATION_TYPE_ZEBRA_CONFIRM' => 'Сигнал за потвърждаване на приятелство', + 'NOTIFICATION_ZEBRA_CONFIRM' => '%1$s потвърди приятелството!', + + 'FRINEDLIST_TITLE' => 'Приятели', + + 'NOT_ENEMY' => 'Всички без врагове', + 'SPECIAL_FRIENDS' => 'Специални приятели', + + 'ZE_FRIENDLIST' => 'Листа с приятели', + 'ZE_FRIENDLIST_EXPLAIN' => 'Кой може да вижда приятелите ви в профила ви?', + + 'FRIENDLIST_ERROR_ACCESS' => 'Нямате права да виждате приятелите на този потребител', +)); \ No newline at end of file diff --git a/language/en/zebra_enchance.php b/language/en/zebra_enchance.php new file mode 100644 index 0000000..8ca7bf1 --- /dev/null +++ b/language/en/zebra_enchance.php @@ -0,0 +1,51 @@ + 'Awaiting confirmation', + 'UCP_ZEBRA_PENDING_IN_EXP' => 'List with requests waiting for your approval.', + + 'UCP_ZEBRA_PENDING_OUT' => 'Pending confirmation', + 'UCP_ZEBRA_PENDING_OUT_EXP' => 'List with your requests pending approval.', + + 'UCP_ZEBRA_PENDING_NONE' => 'No pending requests', + + + 'UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL_ASK' => 'Are you sure you want to cancel the friend request?', + 'UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL' => 'Friend request was cancelled!', + + 'NOTIFICATION_TYPE_ZEBRA_ADD' => 'New friend request notification', + 'NOTIFICATION_ZEBRA_ADD' => '%1$s sent you friend request!', + + 'NOTIFICATION_TYPE_ZEBRA_CONFIRM' => 'Confirmation for friend request', + 'NOTIFICATION_ZEBRA_CONFIRM' => '%1$s confirmed your friend request!', + + 'FRINEDLIST_TITLE' => 'Friendlist', + + 'NOT_ENEMY' => 'All except foes', + 'SPECIAL_FRIENDS' => 'Special friends', + + 'ZE_FRIENDLIST' => 'Friendlist', + 'ZE_FRIENDLIST_EXPLAIN' => 'Who can see your frindlist?', + + 'FRIENDLIST_ERROR_ACCESS' => 'You do not have access to see user\'s friendlist.', + +)); \ No newline at end of file diff --git a/migrations/v10x/release_1_0_0.php b/migrations/v10x/release_1_0_0.php new file mode 100644 index 0000000..fa8708d --- /dev/null +++ b/migrations/v10x/release_1_0_0.php @@ -0,0 +1,78 @@ +config['zebra_enhance_version']) && version_compare($this->config['zebra_enhance_version'], '1.0.0', '>='); + } + static public function depends_on() + { + return array('\phpbb\db\migration\data\v310\dev'); + } + + public function update_data() + { + return array( + array('config.add', array('zebra_enhance_version', '1.0.0')), + array('config.add', array('zebra_module_id', 'none')), + ); + } + //lets create the needed table + public function update_schema() + { + return array( + 'add_tables' => array( + $this->table_prefix . 'zebra_confirm' => array( + 'COLUMNS' => array( + 'user_id' => array('UINT:8'), + 'zebra_id' => array('UINT:8'), + 'friend' => array('UINT:1'), + 'foe' => array('UINT:1') + ), + 'PRIMARY_KEY' => 'user_id, zebra_id', + ), + $this->table_prefix . 'users_custom' => array( + 'COLUMNS' => array( + 'user_id' => array('UINT'), + ), + 'PRIMARY_KEY' => 'user_id' + ), + ), + 'add_columns' => array( + ZEBRA_TABLE => array( + 'bff' => array('UINT', 0), + ), + $this->table_prefix . 'users_custom' => array( + 'profile_friend_show' => array('UINT', 0), + ) + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'zebra_confirm' + ), + 'drop_columns' => array( + ZEBRA_TABLE => array( + 'bff', + ), + $this->table_prefix . 'users_custom' => array( + 'profile_friend_show', + ) + ), + ); + } +} \ No newline at end of file diff --git a/notification/zebraadd.php b/notification/zebraadd.php new file mode 100644 index 0000000..97fee9f --- /dev/null +++ b/notification/zebraadd.php @@ -0,0 +1,204 @@ +user_loader = $user_loader; + $this->db = $db; + $this->cache = $cache; + $this->user = $user; + $this->auth = $auth; + $this->config = $config; + $this->helper = $helper; + + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + + $this->notification_types_table = $notification_types_table; + $this->notifications_table = $notifications_table; + $this->user_notifications_table = $user_notifications_table; + } + + /** + * Get notification type name + * + * @return string + */ + public function get_type() + { + return 'zebraadd'; + } + + /** + * Notification option data (for outputting to the user) + * + * @var bool|array False if the service should use it's default data + * Array of data (including keys 'id', 'lang', and 'group') + */ + public static $notification_option = array( + 'lang' => 'NOTIFICATION_TYPE_ZEBRA_ADD', + ); + + /** + * Is this type available to the current user (defines whether or not it will be shown in the UCP Edit notification options) + * + * @return bool True/False whether or not this is available to the user + */ + public function is_available() + { + return true; + } + + /** + * Get the id of the rule + * + * @param array $data The data for the updated rules + */ + public static function get_item_id($data) + { + return $data['requester_id']; + } + + /** + * Get the id of the parent + * + * @param array $data The data for the updated rules + */ + public static function get_item_parent_id($data) + { + // No parent + return $data['user_id']; + } + + /** + * Find the users who will receive notifications + * + * @param array $data The data for the updated rules + * + * @return array + */ + public function find_users_for_notification($data, $options = array()) + { + + $users = array(); + $users[$data['user_id']] = array(''); + + $this->user_loader->load_users(array_keys($users)); + return $this->check_user_notification_options(array_keys($users), $options); + } + + /** + * Users needed to query before this notification can be displayed + * + * @return array Array of user_ids + */ + public function users_to_query() + { + return array(); + } + + /** + * Get the user's avatar + */ + public function get_avatar() + { + $users = array($this->get_data('requester_id')); + $this->user_loader->load_users($users); + return $this->user_loader->get_avatar($this->get_data('requester_id')); + } + + /** + * Get the HTML formatted title of this notification + * + * @return string + */ + public function get_title() + { + $users = array($this->get_data('requester_id')); + $this->user_loader->load_users($users); + $username = $this->user_loader->get_username($this->get_data('requester_id'), 'no_profile'); + return $this->user->lang('NOTIFICATION_ZEBRA_ADD', $username); + } + + /** + * Get the url to this item + * + * @return string URL + */ + public function get_url() + { + return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=". $this->config['zebra_module_id']); + } + + /** + * Get email template + * + * @return string|bool + */ + public function get_email_template() + { + return false; + } + + /** + * Get email template variables + * + * @return array + */ + public function get_email_template_variables() + { + return array(); + } + + /** + * Function for preparing the data for insertion in an SQL query + * (The service handles insertion) + * + * @param array $data The data for the updated rules + * @param array $pre_create_data Data from pre_create_insert_array() + * + * @return array Array of data ready to be inserted into the database + */ + public function create_insert_array($data, $pre_create_data = array()) + { + $this->set_data('requester_id', $data['requester_id']); + + return parent::create_insert_array($data, $pre_create_data); + } +} \ No newline at end of file diff --git a/notification/zebraconfirm.php b/notification/zebraconfirm.php new file mode 100644 index 0000000..cce4982 --- /dev/null +++ b/notification/zebraconfirm.php @@ -0,0 +1,204 @@ +user_loader = $user_loader; + $this->db = $db; + $this->cache = $cache; + $this->user = $user; + $this->auth = $auth; + $this->config = $config; + $this->helper = $helper; + + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + + $this->notification_types_table = $notification_types_table; + $this->notifications_table = $notifications_table; + $this->user_notifications_table = $user_notifications_table; + } + + /** + * Get notification type name + * + * @return string + */ + public function get_type() + { + return 'zebraconfirm'; + } + + /** + * Notification option data (for outputting to the user) + * + * @var bool|array False if the service should use it's default data + * Array of data (including keys 'id', 'lang', and 'group') + */ + public static $notification_option = array( + 'lang' => 'NOTIFICATION_TYPE_ZEBRA_CONFIRM', + ); + + /** + * Is this type available to the current user (defines whether or not it will be shown in the UCP Edit notification options) + * + * @return bool True/False whether or not this is available to the user + */ + public function is_available() + { + return true; + } + + /** + * Get the id of the rule + * + * @param array $data The data for the updated rules + */ + public static function get_item_id($data) + { + return $data['requester_id']; + } + + /** + * Get the id of the parent + * + * @param array $data The data for the updated rules + */ + public static function get_item_parent_id($data) + { + // No parent + return $data['user_id']; + } + + /** + * Find the users who will receive notifications + * + * @param array $data The data for the updated rules + * + * @return array + */ + public function find_users_for_notification($data, $options = array()) + { + + $users = array(); + $users[$data['user_id']] = array(''); + + $this->user_loader->load_users(array_keys($users)); + return $this->check_user_notification_options(array_keys($users), $options); + } + + /** + * Users needed to query before this notification can be displayed + * + * @return array Array of user_ids + */ + public function users_to_query() + { + return array(); + } + + /** + * Get the user's avatar + */ + public function get_avatar() + { + $users = array($this->get_data('requester_id')); + $this->user_loader->load_users($users); + return $this->user_loader->get_avatar($this->get_data('requester_id')); + } + + /** + * Get the HTML formatted title of this notification + * + * @return string + */ + public function get_title() + { + $users = array($this->get_data('requester_id')); + $this->user_loader->load_users($users); + $username = $this->user_loader->get_username($this->get_data('requester_id'), 'no_profile'); + return $this->user->lang('NOTIFICATION_ZEBRA_ADD', $username); + } + + /** + * Get the url to this item + * + * @return string URL + */ + public function get_url() + { + return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=". $this->config['zebra_module_id']); + } + + /** + * Get email template + * + * @return string|bool + */ + public function get_email_template() + { + return false; + } + + /** + * Get email template variables + * + * @return array + */ + public function get_email_template_variables() + { + return array(); + } + + /** + * Function for preparing the data for insertion in an SQL query + * (The service handles insertion) + * + * @param array $data The data for the updated rules + * @param array $pre_create_data Data from pre_create_insert_array() + * + * @return array Array of data ready to be inserted into the database + */ + public function create_insert_array($data, $pre_create_data = array()) + { + $this->set_data('requester_id', $data['requester_id']); + + return parent::create_insert_array($data, $pre_create_data); + } +} \ No newline at end of file diff --git a/styles/composer.json b/styles/composer.json new file mode 100644 index 0000000..a5c4a26 --- /dev/null +++ b/styles/composer.json @@ -0,0 +1,24 @@ +{ + "name": "anavaro/zebraenhance", + "type": "phpbb-extension", + "description": "Enchance ZEBRA function adding confimation and special friends", + "homepage": "", + "version": "1.0.0", + "time": "2014-05-23", + "license": "GPL-2.0", + "authors": [ + { + "name": "Stanislav Atanasov", + "email": "lucifer@anavaro.com", + "homepage": "http://anavaro.com", + "role": "Lead Developer" + } + ], + "require": { + "php": ">=5.3", + "phpbb/phpbb": "3.1.*@dev" + }, + "extra": { + "display-name": "phpBB 3.1 Zebra Enchance" + } +} diff --git a/styles/config/routing.yml b/styles/config/routing.yml new file mode 100644 index 0000000..6ba1e8d --- /dev/null +++ b/styles/config/routing.yml @@ -0,0 +1,5 @@ +zebra_enchacnce_ajax: + path: /zebraenhance/{action}/{userid} + defaults: { _controller: anavaro.zebraenhance.ajaxyfy:base } + requirements: + userid: \d+ \ No newline at end of file diff --git a/styles/config/services.yml b/styles/config/services.yml new file mode 100644 index 0000000..61f5f98 --- /dev/null +++ b/styles/config/services.yml @@ -0,0 +1,82 @@ +services: + anavaro.zebraenhance.listener: + class: anavaro\zebraenhance\event\zebra_listener + arguments: + - @user_loader + - @auth + - @cache + - @config + - @dbal.conn + - @request + - @template + - @user + - @controller.helper + - @anavaro.zebraenhance.notifyhelper + - %core.root_path% + - %core.php_ext% + - %core.table_prefix% + tags: + - { name: event.listener } + anavaro.zebraenhance.ajaxyfy: + class: anavaro\zebraenhance\controller\ajaxify + arguments: + - @auth + - @cache + - @config + - @dbal.conn + - @request + - @template + - @user + - @controller.helper + - %core.root_path% + - %core.php_ext% + - %core.table_prefix% + anavaro.zebraenhance.notifyhelper: + class: anavaro\zebraenhance\controller\notifyhelper + arguments: + - @config + - @dbal.conn + - @request + - @template + - @user + - @service_container + - %core.root_path% + - %core.php_ext% + - %core.table_prefix% + notification.type.zebraadd: + class: anavaro\zebraenhance\notification\zebraadd + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - @controller.helper + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } + + notification.type.zebraconfirm: + class: anavaro\zebraenhance\notification\zebraconfirm + scope: prototype # scope MUST be prototype for this to work! + arguments: + - @user_loader + - @dbal.conn + - @cache.driver + - @user + - @auth + - @config + - @controller.helper + - %core.root_path% + - %core.php_ext% + - %tables.notification_types% + - %tables.notifications% + - %tables.user_notifications% + tags: + - { name: notification.type } \ No newline at end of file diff --git a/styles/controller/ajaxify.php b/styles/controller/ajaxify.php new file mode 100644 index 0000000..248208f --- /dev/null +++ b/styles/controller/ajaxify.php @@ -0,0 +1,161 @@ +auth = $auth; + $this->cache = $cache; + $this->config = $config; + $this->db = $db; + $this->request = $request; + $this->template = $template; + $this->user = $user; + $this->helper = $helper; + $this->root_path = $root_path; + $this->php_ext = $php_ext; + $this->table_prefix = $table_prefix; + } + + + public function base ($action, $userid) + { + + //load language file + + $this->user->add_lang_ext('anavaro/zebraenhance', 'zebra_enchance'); + $confirm = $this->request->variable('confirm', ''); + $u_action = $this->root_path . 'ucp.php?i=168'; + switch ($action) + { + + case 'cancel_fr': + // check mode + if ($confirm) + { + //$this->var_display($userid); + //let me delete all requests between you and user id. + + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . $userid . ' AND zebra_id = ' . $this->user->data['user_id']; + $this->db->sql_query($sql); + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . $this->user->data['user_id'] . ' AND zebra_id = ' . $userid; + $this->db->sql_query($sql); + $message = ''; + if ($this->request->is_ajax()) + { + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'success' => $updated, + 'MESSAGE_TITLE' => $this->user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $this->user->lang['UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL_ASK'], + 'REFRESH_DATA' => array( + 'time' => 3, + 'url' => $u_action + ) + )); + } + else + { + meta_refresh(3, $u_action); + trigger_error($this->user->lang['UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL']); + } + } + else + { + confirm_box(false, $this->user->lang['UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL_ASK']); + } + break; + case 'togle_bff': + $sql='SELECT bff FROM ' . ZEBRA_TABLE . ' WHERE zebra_id = ' .$userid. ' AND user_id = ' .$this->user->data['user_id']; + $result = $this->db->sql_fetchrow($this->db->sql_query($sql)); + if ($result) + { + if($result['bff'] == '0') + { + $sql = 'UPDATE ' . ZEBRA_TABLE . ' SET bff = 1 WHERE zebra_id = ' . $userid. ' AND user_id = ' .$this->user->data['user_id']; + $this->db->sql_query($sql); + $exit = 'add'; + } + if($result['bff'] == '1') + { + $sql = 'UPDATE ' . ZEBRA_TABLE . ' SET bff = 0 WHERE zebra_id = ' .$userid. ' AND user_id = ' .$this->user->data['user_id']; + $this->db->sql_query($sql); + $exit = 'rem'; + } + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'status' => '0', + 'exit' => $exit, + 'user_id' => $userid, + )); + } + else + { + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'status' => '1', + 'user_id' => $userid, + )); + } + + break; + case 'change_acl': + if ($userid > 4) + { + $userid = 0; + } + $sql = 'UPDATE ' . $this->table_prefix . 'users_custom SET profile_friend_show = ' . $userid . ' WHERE user_id = '.$this->user->data['user_id']; + $this->db->sql_query($sql); + $json_response = new \phpbb\json_response; + $json_response->send(array( + 'status' => 0, + 'exit' => 'acl_set' + )); + break; + } + } + protected function var_display($i) + { + echo '
';
+		print_r($i);
+		echo '
'; + return true; + } + + +} \ No newline at end of file diff --git a/styles/controller/notifyhelper.php b/styles/controller/notifyhelper.php new file mode 100644 index 0000000..77dc613 --- /dev/null +++ b/styles/controller/notifyhelper.php @@ -0,0 +1,85 @@ +config = $config; + $this->db = $db; + $this->request = $request; + $this->template = $template; + $this->user = $user; + $this->phpbb_container = $phpbb_container; + $this->root_path = $root_path; + $this->php_ext = $php_ext; + } + + public function test() + { + + } + + /** + * Main notification function + * @param type Type of notification (add/confirm) + * @param notify_user User to notify + * @param action_user User that trigered the action + */ + public function notify($type, $notify_user, $action_user) + { + $notification_data = array( + 'user_id' => (int) $notify_user, + 'requester_id' => (int) $action_user, + ); + + + $phpbb_notifications = $this->phpbb_container->get('notification_manager'); + + switch ($type) + { + case 'add': + $phpbb_notifications->add_notifications('zebraadd', $notification_data); + break; + case 'confirm': + $phpbb_notifications->add_notifications('zebraconfirm', $notification_data); + break; + } + + } + public function clean($user1, $user2) + { + $phpbb_notifications = $this->phpbb_container->get('notification_manager'); + $phpbb_notifications->delete_notifications('zebraadd', $user1, $user2); + $phpbb_notifications->delete_notifications('zebraadd', $user2, $user1); + $phpbb_notifications->delete_notifications('zebraconfirm', $user2, $user1); + $phpbb_notifications->delete_notifications('zebraconfirm', $user1, $user2); + } +} \ No newline at end of file diff --git a/styles/event/zebra_listener.php b/styles/event/zebra_listener.php new file mode 100644 index 0000000..190b9a4 --- /dev/null +++ b/styles/event/zebra_listener.php @@ -0,0 +1,369 @@ + 'prepare_medals', + //'core.user_setup' => 'load_language_on_setup', + //'core.memberlist_view_profile' => 'fuunct_one', + //'core.viewtopic_modify_post_row' => 'modify_post_row', + + 'core.user_setup' => 'load_language_on_setup', + 'core.ucp_add_zebra' => 'zebra_confirm_add', + 'core.ucp_remove_zebra' => 'zebra_confirm_remove', + 'core.ucp_display_module_before' => 'module_display', + 'core.delete_user_before' => 'delete_users', + 'core.memberlist_prepare_profile_data' => 'prepare_friends', + ); + } + + + /** + * Constructor + * NOTE: The parameters of this method must match in order and type with + * the dependencies defined in the services.yml file for this service. + * + * @param \phpbb\auth $auth Auth object + * @param \phpbb\cache\service $cache Cache object + * @param \phpbb\config $config Config object + * @param \phpbb\db\driver $db Database object + * @param \phpbb\request $request Request object + * @param \phpbb\template $template Template object + * @param \phpbb\user $user User object + * @param \phpbb\content_visibility $content_visibility Content visibility object + * @param \phpbb\controller\helper $helper Controller helper object + * @param string $root_path phpBB root path + * @param string $php_ext phpEx + */ + public function __construct(\phpbb\user_loader $user_loader, \phpbb\auth\auth $auth, \phpbb\cache\service $cache, \phpbb\config\config $config, \phpbb\db\driver\driver $db, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, \anavaro\zebraenhance\controller\notifyhelper $notifyhelper, $root_path, $php_ext, $table_prefix) + { + $this->user_loader = $user_loader; + $this->auth = $auth; + $this->cache = $cache; + $this->config = $config; + $this->db = $db; + $this->request = $request; + $this->template = $template; + $this->user = $user; + $this->helper = $helper; + $this->notifyhelper = $notifyhelper; + $this->root_path = $root_path; + $this->php_ext = $php_ext; + $this->table_prefix = $table_prefix; + } + public function load_language_on_setup($event){ + $lang_set_ext = $event['lang_set_ext']; + $lang_set_ext[] = array( + 'ext_name' => 'anavaro/zebraenhance', + 'lang_set' => 'zebra_enchance', + ); + $event['lang_set_ext'] = $lang_set_ext; + $this->notifyhelper->test(); + if ($this->config['zebra_module_id'] == 'none') + { + $sql = 'SELECT parent_id FROM ' . MODULES_TABLE . ' WHERE module_basename = \'ucp_zebra\' LIMIT 1'; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->config->set('zebra_module_id', $row['parent_id']); + } + + } + + + protected $image_dir = 'ext/anavaro/zebraenhance/images'; + + public function zebra_confirm_add($event) + { + if ($event['mode'] == 'friends') + { + foreach($event['sql_ary'] as $VAR) + { + //let's test if we have sent request + $sql = 'SELECT * FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . (int) $VAR['user_id'] . ' AND zebra_id = ' . (int) $VAR['zebra_id']; + $result = $this->db->sql_fetchrow($this->db->sql_query($sql)); + if (!$result) + { + //Let's test if request is pending from the other user + $sql = 'SELECT * FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . (int) $VAR['zebra_id'] . ' AND zebra_id = ' . (int) $VAR['user_id']; + $result = $this->db->sql_fetchrow($this->db->sql_query($sql)); + //$this->var_display($result); + if ($result) + { + //so we have incoming request -> we add friends! + $sql = 'INSERT INTO '. ZEBRA_TABLE .' SET user_id = ' . (int) $VAR['user_id'] . ', zebra_id = ' . (int) $VAR['zebra_id'] . ', friend = 1, foe = 0'; + $this->db->sql_query($sql); + $sql = 'INSERT INTO '. ZEBRA_TABLE .' SET user_id = ' . (int) $VAR['zebra_id'] . ', zebra_id = ' . (int) $VAR['user_id'] . ', friend = 1, foe = 0'; + $this->db->sql_query($sql); + + //let's clean the request table + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . (int) $VAR['zebra_id'] . ' AND zebra_id = ' . (int) $VAR['user_id']; + $this->db->sql_query($sql); + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . (int) $VAR['user_id'] . ' AND zebra_id = ' . (int) $VAR['zebra_id']; + $this->db->sql_query($sql); + $this->notifyhelper->notify('confirm', $VAR['zebra_id'], $VAR['user_id']); + } + else + { + //lets see if user is hostile towerds us (if yes - silently drop request) + $sql = 'SELECT * FROM '. ZEBRA_TABLE .' WHERE user_id = ' . (int) $VAR['zebra_id'] . ' AND zebra_id = ' . (int) $VAR['user_id']. ' AND foe = 1'; + $result = $this->db->sql_fetchrow($this->db->sql_query($sql)); + if (!$result) { + $sql = 'INSERT INTO ' . $this->table_prefix . 'zebra_confirm SET user_id = ' . (int) $VAR['user_id'] . ', zebra_id = ' . (int) $VAR['zebra_id'] . ', friend = 1, foe = 0'; + $this->db->sql_query($sql); + $this->notifyhelper->notify('add', $VAR['zebra_id'], $VAR['user_id']); + } + } + } + } + $event['sql_ary'] = array(); + } + if ($event['mode'] == 'foes') + { + foreach($event['sql_ary'] as $VAR) + { + //if we add user as foe we have to remove pending requests. + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . (int) $VAR['zebra_id']. ' AND zebra_id = ' . (int) $VAR['user_id']; + $this->db->sql_query($sql); + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = ' . (int) $VAR['user_id'] . ' AND zebra_id = ' . (int) $VAR['zebra_id']; + $this->db->sql_query($sql); + } + } + } + + public function zebra_confirm_remove($event) + { + if($event['mode'] == 'friends') + { + //let's go for syncronieus remove + foreach($event['user_ids'] AS $VAR) + { + $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' + WHERE user_id = ' . $this->user->data['user_id'] . ' + AND zebra_id = '. $VAR; + $this->db->sql_query($sql); + + $sql = 'DELETE FROM ' . ZEBRA_TABLE . ' + WHERE user_id = ' . $VAR . ' + AND zebra_id = '. $this->user->data['user_id']; + $this->db->sql_query($sql); + + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm + WHERE user_id = ' . $this->user->data['user_id'] . ' + AND zebra_id = '. $VAR; + $this->db->sql_query($sql); + + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm + WHERE user_id = ' . $VAR . ' + AND zebra_id = '. $this->user->data['user_id']; + $this->db->sql_query($sql); + + $this->notifyhelper->clean($VAR, $this->user->data['user_id']); + } + + $event['user_ids'] = array('0'); + } + } + + + public function module_display($event) + { + $ispending = $iswaiting = ''; + if ($event['id'] == 'ucp_zebra' OR $event['id'] == $this->config['zebra_module_id']) + { + $this->template->assign_var('IS_ZEBRA', '1'); + $sql = 'SELECT profile_friend_show FROM ' . $this->table_prefix . 'users_custom WHERE user_id = '. $this->user->data['user_id']; + $result = $this->db->sql_fetchrow($this->db->sql_query($sql)); + $this->template->assign_var('ZEBRA_ACL', $result['profile_friend_show']); + //let's get incoming pendings + $sql_array = array( + 'SELECT' => 'zc.*, u.username, u.user_colour', + 'FROM' => array( + $this->table_prefix . 'zebra_confirm' => 'zc', + USERS_TABLE => 'u', + ), + 'WHERE' => 'zc.user_id = u.user_id AND zc.zebra_id = '.$this->user->data['user_id'] + ); + $sql = $this->db->sql_build_query('SELECT', $sql_array); + $result = $this->db->sql_query($sql); + + while($row = $this->db->sql_fetchrow($result)) + { + $ispending = 1; + $this->template->assign_block_vars('pending_requests', array( + 'USERNAME' => ''.$row['username'].'', + 'CONFIRM' => '', + 'CANCEL' => '', + )); + } + if($ispending) + { + $this->template->assign_var('HAS_PENDING', 'yes'); + + } + //now, let's get our own requests that are waiting. + $sql_array = array( + 'SELECT' => 'zc.*, u.username, u.user_colour', + 'FROM' => array( + $this->table_prefix . 'zebra_confirm' => 'zc', + USERS_TABLE => 'u', + ), + 'WHERE' => 'zc.zebra_id = u.user_id AND zc.user_id = '.$this->user->data['user_id'] + ); + $sql = $this->db->sql_build_query('SELECT', $sql_array); + $result = $this->db->sql_query($sql); + + while($row = $this->db->sql_fetchrow($result)) + { + $iswaiting = 1; + $this->template->assign_block_vars('pending_awaits', array( + 'USERNAME' => ''.$row['username'].'', + 'CANCEL' => '', + )); + } + if($iswaiting) + { + $this->template->assign_var('HAS_WAITING', 'yes'); + } + + + //let's populate the prity zebra list (bff and all) + $sql_array = array( + 'SELECT' => 'zc.*, u.username, u.user_colour', + 'FROM' => array( + ZEBRA_TABLE => 'zc', + USERS_TABLE => 'u', + ), + 'WHERE' => 'zc.zebra_id = u.user_id AND zc.user_id = '.$this->user->data['user_id'], + 'ORDER_BY' => 'u.username ASC' + ); + $sql = $this->db->sql_build_query('SELECT', $sql_array); + $result = $this->db->sql_query($sql); + while($row = $this->db->sql_fetchrow($result)) + { + $this->template->assign_block_vars('prity_zebra', array( + 'USERNAME' => ''.$row['username'].'', + 'CANCEL' => '', + 'BFF' => $row['bff'] ? '' : '' + )); + } + $this->template->assign_var('IMGDIR', $this->image_dir); + } + } + + + public function delete_users($event) + { + foreach ($event['user_ids'] AS $VAR) + { + $sql = 'DELETE FROM ' . $this->table_prefix . 'zebra_confirm WHERE user_id = '.$VAR.' OR zebra_id = '.$VAR; + $this->db->sql_query($sql); + $sql = 'DELETE FROM '. ZEBRA_TABLE .' WHERE user_id = '.$VAR.' OR zebra_id = '.$VAR; + $this->db->sql_query($sql); + } + } + + public function prepare_friends($event) + { + $sql = 'SELECT profile_friend_show FROM ' . $this->table_prefix . 'users_custom WHERE user_id = '.$this->db->sql_escape($event['data']['user_id']); + $result = $this->db->sql_query($sql); + $optResult = $this->db->sql_fetchrow($result); + $sql = 'SELECT * FROM ' . ZEBRA_TABLE . ' WHERE user_id = '.$this->db->sql_escape($event['data']['user_id']).' AND zebra_id = '.$this->user->data['user_id']; + $result = $this->db->sql_fetchrow($this->db->sql_query($sql)); + $zebra_state = 0; + if ($result) + { + if ($result['foe'] == 1) + { + $zebra_state = 1; + } + else + { + if ($result['bff'] == '0') { + $zebra_state = 3; + } + else { + $zebra_state = 4; + } + } + } + else + { + $zebra_state = 2; + } + //print_r($zebra_state); + $users; + $show = ($optResult['profile_friend_show'] > 0 ? (($optResult['profile_friend_show'] == 1 AND $zebra_state != 1) ? (($optResult['profile_friend_show'] <= $zebra_state) ? true : false) : false) : false); + if ($event['data']['user_id'] == $this->user->data['user_id'] || $this->auth->acl_get('a_user') || $show) + { + $sql = 'SELECT zebra_id FROM ' . ZEBRA_TABLE . ' WHERE user_id = ' . $this->db->sql_escape($event['data']['user_id']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $user_id[] = (int) $row['zebra_id']; + } + if (!empty($user_id)) + { + $this->user_loader->load_users($user_id); + $selector = 0; + foreach ($user_id as $VAR) { + $this->template->assign_block_vars('zebra_friendslist', array( + 'USER_LINK' => $this->user_loader->get_username($VAR, 'profile'), + 'USER_AVATAR' => $this->user_loader->get_avatar($VAR), + 'USERNAME' => $this->user_loader->get_username($VAR, 'full'), + 'SELECTOR' => $selector, + )); + if ($selector == 3) + { + $selector = 0; + } + else + { + $selector ++; + } + } + } + } + else + { + $this->template->assign_var('FRIENDLIST_ERROR_ACCESS', 'yes'); + } + $this->template->assign_var('FRIENDLIST', 'yes'); + } + + protected function var_display($i) + { + echo '
';
+		print_r($i);
+		echo '
'; + return true; + } + +} diff --git a/styles/ext.php b/styles/ext.php new file mode 100644 index 0000000..e60add0 --- /dev/null +++ b/styles/ext.php @@ -0,0 +1,124 @@ +container->get('notification_manager'); + $phpbb_notifications->enable_notifications('zebraadd'); + $phpbb_notifications->enable_notifications('zebraconfirm'); + return 'notifications'; + + break; + + default: + + // Run parent enable step method + return parent::enable_step($old_state); + + break; + } + } + + /** + * Single disable step that does nothing + * + * @param mixed $old_state State returned by previous call of this method + * @return mixed Returns false after last step, otherwise temporary state + */ + function disable_step($old_state) + { + switch ($old_state) + { + case '': // Empty means nothing has run yet + + // Disable board rules notifications + $phpbb_notifications = $this->container->get('notification_manager'); + $phpbb_notifications->disable_notifications('zebraadd'); + $phpbb_notifications->disable_notifications('zebraconfirm'); + return 'notifications'; + + break; + + default: + + // Run parent disable step method + return parent::disable_step($old_state); + + break; + } + } + + /** + * Single purge step that reverts any included and installed migrations + * + * @param mixed $old_state State returned by previous call of this method + * @return mixed Returns false after last step, otherwise temporary state + */ + function purge_step($old_state) + { + switch ($old_state) + { + case '': // Empty means nothing has run yet + + /** + * @todo Remove this try/catch condition once purge_notifications is fixed + * in the core to work with disabled extensions without fatal errors. + * https://tracker.phpbb.com/browse/PHPBB3-12435 + */ + try + { + // Purge board rules notifications + $phpbb_notifications = $this->container->get('notification_manager'); + $phpbb_notifications->purge_notifications('zebraadd'); + $phpbb_notifications->purge_notifications('zebraconfirm'); + } + catch (\phpbb\notification\exception $e) + { + // continue + } + + return 'notifications'; + + break; + + default: + + // Run parent purge step method + return parent::purge_step($old_state); + + break; + } + } +} diff --git a/styles/images/cancel.gif b/styles/images/cancel.gif new file mode 100644 index 0000000000000000000000000000000000000000..f2e8e38f4dcbccc481ddbd722ae8be09f7df04c8 GIT binary patch literal 634 zcmZ?wbhEHb6krfwIOfCf$c*8MIm1(PhF2C0Z!H+!TQYpGWcXys@Y#yts};j{D~2C7 z48Lp`e%mnowPE;Y%kbZh;lDlGe<$w$F8u%8ME<#p|MQai=Og>iSK*((^1mR>|53*O zRru+X~pZ|G&|BHhEmxTSVjQ(F0`>!$WUvt*K)|`JG1^;_W z{!gg-Ke_h*^rrtan*Yyi{Xe_?|D4YM^Sb^o?EAlH!v7_c{x6&I|IoJoC-(h6x&Qyg zlm9QD{&)N8zq{A|-M#Ve;oX0a@BMrF;Q#Z-|KGg)|L)cQ5AXhe`tbk9_y50s{Qvv+ z{~!j6{{)?jQWHy3QxwWGOEMJPJ$(Zh6o0ZXaxv61=r8~QD54nH4>i;`HMg|32z7LJ z3bx8x+S*KLUS4UgZ#mmcGN>EsYr-@lhL(|dK&DqsO zUQB|ci9t<8+1g1-#NJNsncxQTM~7Ki6vSK(1UNFW@vyS69+=SR*u=`G5-=m-pc5No lGe^b`0jDDzLaIU2DgrnTG%|A}C^;-pXjnMAjfs)L8UO_UZR`L5 literal 0 HcmV?d00001 diff --git a/styles/images/confirm_16.png b/styles/images/confirm_16.png new file mode 100644 index 0000000000000000000000000000000000000000..83330e48b6966eb585527e1528850c5347e039c8 GIT binary patch literal 966 zcmV;%13CPOP)+KxDZ(oAb=QQ44t_;@<5FnOeBmAqO_tIoaCHP zbnkn#k73!hWejItoV@@vDBw!+m4_g4fB*s;pgB_$r1?UTd4Yh3iX+4J=L;Dwe>}qQ z{qGmBW=>`v23>v|22aU&hMjkS4*Adcq3>j$!S(d(4*>!QY=GJ{wetlQIR-Y0CJfVV zR{%ABWxxi6*(Dgd3^oAmVq`e=?BoSY8EZp;0Af*|tQ@Z^rfp!SWX3SzdMQxzH>{eu zfUd|@?P2)){}02@zuy^DMC1*ge7jQ*5I`({|NKn|(C}i|`gl3R=bzYZ=3?PtDAS(8 zAj%=h@a4}3h95vn9({Vqkh#9l0U&^wfCf02$mug&e0zrB_g@BvAh|RKHbx#W8-!Vb z>{6Y61`&2KhR;CFpZ~mPxc%u013wox!`m zIE#TDsF974o1s*7^)0<8Gioz4%95d@cH)#Ap0A`!_RjaW?!8O^uiCY9$`*F27my9yI{-1bqu#Y zTx0n5_cPcgVNPKNAr2uh`wI}?`FNdS`sJxWm;PX2VPpsEdH((-13&;Vv)i&e$Owxo zFtGk-SaEA9gQl=10~-qq!?!=5fidzKXy6xyd!K+dUz*GC?e|ZHfBzX6)P>X;-o5|G zaP-#M0{{U8a>0U4XZJ9eO6oKG`16aQ?pQU$_4k*-HiPh;54RX*UYG}rp&tyt|NLiQ zVqgWU1?d6l1qdMKpGSUP{Gk0gfRB?)!cpCv;nK@n49A|HWKa;4W_a`cHN)Hs%i%V& zGP5#-Xt^_-ync~k@1+wLzI1)b1PCB-O5`l$lm`ahg>ZX!0W&Rah7*skGCckG7U<94 zU{|pNH7W~BGFZrJGn~41m0{(klqNh5hOs04sl>p3f4nll<4DUXD og5}!-Kytyq>Hko&GeCd=03gYB0F-l~FaQ7m07*qoM6N<$f|RPVCIA2c literal 0 HcmV?d00001 diff --git a/styles/images/favorite_add.png b/styles/images/favorite_add.png new file mode 100644 index 0000000000000000000000000000000000000000..ce7ee4adf00b7794fd979ec760078664ddb0ea29 GIT binary patch literal 2135 zcmV-d2&ngoP)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ@-AP12RCwBymurk&RTam7YwvUJdpdWfGwsYUwJmLd0+yDFKub$OKt(VnH3dvS zBLQNR;0Gi4fkcgwM1mob82MmC4FrK05)CO0j|erO2#Tc-Vd`}Hn6dNdyzZTQ?zw00 z<%fCn&fICCJ6Xwj?414I|NmP5b+)J~0MTE*3f6-6oN*XK<%8ax$yn)YV(kOKan3pf z)Zxn|B+OwlIV7D%jL`D!zXA}?1Cz8=}rx^S6#{w`0 zH&H^91WBD?%It+NN0i<^1TI0cDI^sj=>?Ipn}Uv(HVFbGmHwQ`W;tWz@}S`37(~v9 zagG787GJ7Rez%9F>pngGMi){b+k>{I&^8xTu-6g<7HFVLj6rKPd?iB8uF+`*03@{3 zj*k%SKZaydV9oq6vfbv>gv*LCVfsRo&#g209P^@(N754O__Jry_h*1@rNXFAe}8uq6HCRC|Un*$@c~V$F8! z^hZrTw6;0tC7a%23fY_~WU<9O>KtyO{E2pcb^rj@5WRnbWT=d!12D2(tbhm-NMMVZ z*kn@Owkdm=E#@H%NQTEb*KrzvD)^aDofgx1D(@agqof%t8|PJcA#^66L5=M2agAEv zAjHWz?S6h4W>VLhe0nFw77!T}VCQX^?>>S7gcfbX7H~PNST-l!U!;m z>LlKmP(O+>V?b%fSq=jy8UUEUK8}^;So4rrgIJlaeF3~$ja{8g9=rx7t5&QDOeVPA z7cywoqSX`{WpL#zZmfixu=pra1d$+kNsK(OxDQM(^aIp&s@JdM1jI9EWeQrCC+Zb- zDmZV&RS_5C)q=@FDh;tiBtb|Bj1Ed@e90TeU z5|1P?E{^eLEwo?3RM^3|8bD}LM}DLi*YoCo2DNaj1mQ>dcz`fIMNpe)1fX*nMhx6R zqOXXN&B*DVp#C%fsa1&MW>~t5_kEG)d-w9r$(I?bi~>qqwuOz$FJkA`dsnVct$M8Q zc;7=KT020sj3iTBJxl!T!pV{Q<}=~=6soTvtecf!mU^j0#IBRdvio?n=XHMl@8>aM zXv!AwC?a4nl&cl0NtHV;zLAGFd}Czr*#CB&DviG;V%c`hmIVw{l7(U%1?~Y}1I)BP z04^p@3PfG^@tuD?!yiA~!$r%^$68@!({gTEwGDtj_3q_JsUNGB-yYh-;fdo*f4BYN z7orcNt(7=B*kD8&C5uI~R-MtRLt}?l6I@iqwCv*NeS3NC@NO>eUPo)rPz)nBwzhHi z`dhhs{jIE9(m`twQOqbCI#;sy8;$R2xREg_Q&*K-JTg@1C2xsr^!_wIzfm zq^1c6M|)XY7-o2CAJtGdHv)*0h5TQINV@(&fl9)J4< zUz&IS)PWZm9RC|e$B2pB8UVObw4hJQ4l!oNh!j6MHe4PHev*8q<(s)cHz*L~MH`TTgm+xS7?Bw&CTdqw4y8@@4w9S#SIZ`%H zVA69tNZAxAo1b}?LlF{f<*Ma3Gd?l)OalOu&P+!tjmhO-lXT|$s2%`CO~7RP<#?A+ znwmUdOR1-BUi)22NfxiQIhBprI?cnmCZZ&i63g|g@28E9KbI<#Z=AUs)^|QY)Z@}c z;^wtj90UQ!2l^h|c;R(h%WEE7zxT*v1Tuk@fZ?gbywvjuieTJ37!#8C2&Y-D{?xbF z(Xp$)_rHhlPm&sE2e8;7bH))x1m}}ey}ciOdE1&hUhK@Rxa5tazhb1kkCWvd`X_%j zBS9LGCR(x=vSr0RY-qjt=<%aRcShCdh%x3|0kGhlCe)Hz&yl{K9V?b?{^?y8KY7=Y z$#>GnCjZHJbpXZDoa*4brpq|L`6?g8P0tPVpLnnmO&zUY{2T!+^eI7AhmZC5-P=@X z{>94T)~~GVxNfW0=sd&_n(Sb;T77$RXzazQ=-5AuF&Ja;3y%N)9{^bQrqJd3Q7ixe N002ovPDHLkV1k;-2JZj> literal 0 HcmV?d00001 diff --git a/styles/images/favorite_remove.png b/styles/images/favorite_remove.png new file mode 100644 index 0000000000000000000000000000000000000000..a94ad30a4f0988a1f9a2f822f5e62c4a7c46fb82 GIT binary patch literal 2205 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 literal 0 HcmV?d00001 diff --git a/styles/language/bg/zebra_enchance.php b/styles/language/bg/zebra_enchance.php new file mode 100644 index 0000000..7c784e7 --- /dev/null +++ b/styles/language/bg/zebra_enchance.php @@ -0,0 +1,50 @@ + 'Очакващи потвърждение', + 'UCP_ZEBRA_PENDING_IN_EXP' => 'Списък на очакващите потвърждение заявки за приятелство.', + + 'UCP_ZEBRA_PENDING_OUT' => 'Изчакващи потвърждение', + 'UCP_ZEBRA_PENDING_OUT_EXP' => 'Списък на изчкаващите вашето потвърждение заявки за приятелство.', + + 'UCP_ZEBRA_PENDING_NONE' => 'Нямате изчакващи заявки', + + + 'UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL_ASK' => 'Сигурни ли сте, че искате да отхвърлите предложението за приятелство?', + 'UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL' => 'Предложението за приятелство е отхвърлено!', + + 'NOTIFICATION_TYPE_ZEBRA_ADD' => 'Сигнал за получаване на заявка за приятелство', + 'NOTIFICATION_ZEBRA_ADD' => '%1$s Ви изпрати покана за приятелство!', + + 'NOTIFICATION_TYPE_ZEBRA_CONFIRM' => 'Сигнал за потвърждаване на приятелство', + 'NOTIFICATION_ZEBRA_CONFIRM' => '%1$s потвърди приятелството!', + + 'FRINEDLIST_TITLE' => 'Приятели', + + 'NOT_ENEMY' => 'Всички без врагове', + 'SPECIAL_FRIENDS' => 'Специални приятели', + + 'ZE_FRIENDLIST' => 'Листа с приятели', + 'ZE_FRIENDLIST_EXPLAIN' => 'Кой може да вижда приятелите ви в профила ви?', + + 'FRIENDLIST_ERROR_ACCESS' => 'Нямате права да виждате приятелите на този потребител', +)); \ No newline at end of file diff --git a/styles/language/en/zebra_enchance.php b/styles/language/en/zebra_enchance.php new file mode 100644 index 0000000..8ca7bf1 --- /dev/null +++ b/styles/language/en/zebra_enchance.php @@ -0,0 +1,51 @@ + 'Awaiting confirmation', + 'UCP_ZEBRA_PENDING_IN_EXP' => 'List with requests waiting for your approval.', + + 'UCP_ZEBRA_PENDING_OUT' => 'Pending confirmation', + 'UCP_ZEBRA_PENDING_OUT_EXP' => 'List with your requests pending approval.', + + 'UCP_ZEBRA_PENDING_NONE' => 'No pending requests', + + + 'UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL_ASK' => 'Are you sure you want to cancel the friend request?', + 'UCP_ZEBRA_ENCHANCE_CONFIRM_CANCEL' => 'Friend request was cancelled!', + + 'NOTIFICATION_TYPE_ZEBRA_ADD' => 'New friend request notification', + 'NOTIFICATION_ZEBRA_ADD' => '%1$s sent you friend request!', + + 'NOTIFICATION_TYPE_ZEBRA_CONFIRM' => 'Confirmation for friend request', + 'NOTIFICATION_ZEBRA_CONFIRM' => '%1$s confirmed your friend request!', + + 'FRINEDLIST_TITLE' => 'Friendlist', + + 'NOT_ENEMY' => 'All except foes', + 'SPECIAL_FRIENDS' => 'Special friends', + + 'ZE_FRIENDLIST' => 'Friendlist', + 'ZE_FRIENDLIST_EXPLAIN' => 'Who can see your frindlist?', + + 'FRIENDLIST_ERROR_ACCESS' => 'You do not have access to see user\'s friendlist.', + +)); \ No newline at end of file diff --git a/styles/migrations/v10x/release_1_0_0.php b/styles/migrations/v10x/release_1_0_0.php new file mode 100644 index 0000000..fa8708d --- /dev/null +++ b/styles/migrations/v10x/release_1_0_0.php @@ -0,0 +1,78 @@ +config['zebra_enhance_version']) && version_compare($this->config['zebra_enhance_version'], '1.0.0', '>='); + } + static public function depends_on() + { + return array('\phpbb\db\migration\data\v310\dev'); + } + + public function update_data() + { + return array( + array('config.add', array('zebra_enhance_version', '1.0.0')), + array('config.add', array('zebra_module_id', 'none')), + ); + } + //lets create the needed table + public function update_schema() + { + return array( + 'add_tables' => array( + $this->table_prefix . 'zebra_confirm' => array( + 'COLUMNS' => array( + 'user_id' => array('UINT:8'), + 'zebra_id' => array('UINT:8'), + 'friend' => array('UINT:1'), + 'foe' => array('UINT:1') + ), + 'PRIMARY_KEY' => 'user_id, zebra_id', + ), + $this->table_prefix . 'users_custom' => array( + 'COLUMNS' => array( + 'user_id' => array('UINT'), + ), + 'PRIMARY_KEY' => 'user_id' + ), + ), + 'add_columns' => array( + ZEBRA_TABLE => array( + 'bff' => array('UINT', 0), + ), + $this->table_prefix . 'users_custom' => array( + 'profile_friend_show' => array('UINT', 0), + ) + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'zebra_confirm' + ), + 'drop_columns' => array( + ZEBRA_TABLE => array( + 'bff', + ), + $this->table_prefix . 'users_custom' => array( + 'profile_friend_show', + ) + ), + ); + } +} \ No newline at end of file diff --git a/styles/notification/zebraadd.php b/styles/notification/zebraadd.php new file mode 100644 index 0000000..97fee9f --- /dev/null +++ b/styles/notification/zebraadd.php @@ -0,0 +1,204 @@ +user_loader = $user_loader; + $this->db = $db; + $this->cache = $cache; + $this->user = $user; + $this->auth = $auth; + $this->config = $config; + $this->helper = $helper; + + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + + $this->notification_types_table = $notification_types_table; + $this->notifications_table = $notifications_table; + $this->user_notifications_table = $user_notifications_table; + } + + /** + * Get notification type name + * + * @return string + */ + public function get_type() + { + return 'zebraadd'; + } + + /** + * Notification option data (for outputting to the user) + * + * @var bool|array False if the service should use it's default data + * Array of data (including keys 'id', 'lang', and 'group') + */ + public static $notification_option = array( + 'lang' => 'NOTIFICATION_TYPE_ZEBRA_ADD', + ); + + /** + * Is this type available to the current user (defines whether or not it will be shown in the UCP Edit notification options) + * + * @return bool True/False whether or not this is available to the user + */ + public function is_available() + { + return true; + } + + /** + * Get the id of the rule + * + * @param array $data The data for the updated rules + */ + public static function get_item_id($data) + { + return $data['requester_id']; + } + + /** + * Get the id of the parent + * + * @param array $data The data for the updated rules + */ + public static function get_item_parent_id($data) + { + // No parent + return $data['user_id']; + } + + /** + * Find the users who will receive notifications + * + * @param array $data The data for the updated rules + * + * @return array + */ + public function find_users_for_notification($data, $options = array()) + { + + $users = array(); + $users[$data['user_id']] = array(''); + + $this->user_loader->load_users(array_keys($users)); + return $this->check_user_notification_options(array_keys($users), $options); + } + + /** + * Users needed to query before this notification can be displayed + * + * @return array Array of user_ids + */ + public function users_to_query() + { + return array(); + } + + /** + * Get the user's avatar + */ + public function get_avatar() + { + $users = array($this->get_data('requester_id')); + $this->user_loader->load_users($users); + return $this->user_loader->get_avatar($this->get_data('requester_id')); + } + + /** + * Get the HTML formatted title of this notification + * + * @return string + */ + public function get_title() + { + $users = array($this->get_data('requester_id')); + $this->user_loader->load_users($users); + $username = $this->user_loader->get_username($this->get_data('requester_id'), 'no_profile'); + return $this->user->lang('NOTIFICATION_ZEBRA_ADD', $username); + } + + /** + * Get the url to this item + * + * @return string URL + */ + public function get_url() + { + return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=". $this->config['zebra_module_id']); + } + + /** + * Get email template + * + * @return string|bool + */ + public function get_email_template() + { + return false; + } + + /** + * Get email template variables + * + * @return array + */ + public function get_email_template_variables() + { + return array(); + } + + /** + * Function for preparing the data for insertion in an SQL query + * (The service handles insertion) + * + * @param array $data The data for the updated rules + * @param array $pre_create_data Data from pre_create_insert_array() + * + * @return array Array of data ready to be inserted into the database + */ + public function create_insert_array($data, $pre_create_data = array()) + { + $this->set_data('requester_id', $data['requester_id']); + + return parent::create_insert_array($data, $pre_create_data); + } +} \ No newline at end of file diff --git a/styles/notification/zebraconfirm.php b/styles/notification/zebraconfirm.php new file mode 100644 index 0000000..cce4982 --- /dev/null +++ b/styles/notification/zebraconfirm.php @@ -0,0 +1,204 @@ +user_loader = $user_loader; + $this->db = $db; + $this->cache = $cache; + $this->user = $user; + $this->auth = $auth; + $this->config = $config; + $this->helper = $helper; + + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + + $this->notification_types_table = $notification_types_table; + $this->notifications_table = $notifications_table; + $this->user_notifications_table = $user_notifications_table; + } + + /** + * Get notification type name + * + * @return string + */ + public function get_type() + { + return 'zebraconfirm'; + } + + /** + * Notification option data (for outputting to the user) + * + * @var bool|array False if the service should use it's default data + * Array of data (including keys 'id', 'lang', and 'group') + */ + public static $notification_option = array( + 'lang' => 'NOTIFICATION_TYPE_ZEBRA_CONFIRM', + ); + + /** + * Is this type available to the current user (defines whether or not it will be shown in the UCP Edit notification options) + * + * @return bool True/False whether or not this is available to the user + */ + public function is_available() + { + return true; + } + + /** + * Get the id of the rule + * + * @param array $data The data for the updated rules + */ + public static function get_item_id($data) + { + return $data['requester_id']; + } + + /** + * Get the id of the parent + * + * @param array $data The data for the updated rules + */ + public static function get_item_parent_id($data) + { + // No parent + return $data['user_id']; + } + + /** + * Find the users who will receive notifications + * + * @param array $data The data for the updated rules + * + * @return array + */ + public function find_users_for_notification($data, $options = array()) + { + + $users = array(); + $users[$data['user_id']] = array(''); + + $this->user_loader->load_users(array_keys($users)); + return $this->check_user_notification_options(array_keys($users), $options); + } + + /** + * Users needed to query before this notification can be displayed + * + * @return array Array of user_ids + */ + public function users_to_query() + { + return array(); + } + + /** + * Get the user's avatar + */ + public function get_avatar() + { + $users = array($this->get_data('requester_id')); + $this->user_loader->load_users($users); + return $this->user_loader->get_avatar($this->get_data('requester_id')); + } + + /** + * Get the HTML formatted title of this notification + * + * @return string + */ + public function get_title() + { + $users = array($this->get_data('requester_id')); + $this->user_loader->load_users($users); + $username = $this->user_loader->get_username($this->get_data('requester_id'), 'no_profile'); + return $this->user->lang('NOTIFICATION_ZEBRA_ADD', $username); + } + + /** + * Get the url to this item + * + * @return string URL + */ + public function get_url() + { + return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=". $this->config['zebra_module_id']); + } + + /** + * Get email template + * + * @return string|bool + */ + public function get_email_template() + { + return false; + } + + /** + * Get email template variables + * + * @return array + */ + public function get_email_template_variables() + { + return array(); + } + + /** + * Function for preparing the data for insertion in an SQL query + * (The service handles insertion) + * + * @param array $data The data for the updated rules + * @param array $pre_create_data Data from pre_create_insert_array() + * + * @return array Array of data ready to be inserted into the database + */ + public function create_insert_array($data, $pre_create_data = array()) + { + $this->set_data('requester_id', $data['requester_id']); + + return parent::create_insert_array($data, $pre_create_data); + } +} \ No newline at end of file diff --git a/styles/prosilver/template/event/memberlist_view_user_statistics_after.html b/styles/prosilver/template/event/memberlist_view_user_statistics_after.html new file mode 100644 index 0000000..d396832 --- /dev/null +++ b/styles/prosilver/template/event/memberlist_view_user_statistics_after.html @@ -0,0 +1,20 @@ + + + + + + +
+
+

{L_FRINEDLIST_TITLE}

+
+
+
+ +
{L_FRIENDLIST_ERROR_ACCESS}
+ + + {zebra_friendslist.USER_AVATAR} {zebra_friendslist.USERNAME} + + + diff --git a/styles/prosilver/template/event/overall_footer_after.html b/styles/prosilver/template/event/overall_footer_after.html new file mode 100644 index 0000000..fb0691d --- /dev/null +++ b/styles/prosilver/template/event/overall_footer_after.html @@ -0,0 +1,32 @@ + + + \ No newline at end of file diff --git a/styles/prosilver/template/event/ucp_friend_list_before.html b/styles/prosilver/template/event/ucp_friend_list_before.html new file mode 100644 index 0000000..01045b3 --- /dev/null +++ b/styles/prosilver/template/event/ucp_friend_list_before.html @@ -0,0 +1,40 @@ + +
+

{L_UCP_ZEBRA_PENDING_IN_EXP}
+
+ + {pending_requests.CONFIRM} {pending_requests.CANCEL} {pending_requests.USERNAME} + +
+
+ + +
+

{L_UCP_ZEBRA_PENDING_OUT_EXP}
+
+ + {pending_awaits.CANCEL} {pending_awaits.USERNAME} + +
+
+ +
+

{L_YOUR_FRIENDS_EXPLAIN}
+
+ +
{prity_zebra.BFF} {prity_zebra.USERNAME}
{prity_zebra.CANCEL}
+ +
+
+
+

{L_ZE_FRIENDLIST_EXPLAIN}
+
+ +
+
\ No newline at end of file