Skip to content

Commit

Permalink
Move Zebra to new repo
Browse files Browse the repository at this point in the history
  • Loading branch information
satanasov committed Jul 19, 2014
1 parent 5440aaf commit f496261
Show file tree
Hide file tree
Showing 36 changed files with 2,995 additions and 2 deletions.
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
24 changes: 24 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"homepage": "http://anavaro.com",
"role": "Lead Developer"
}
],
"require": {
"php": ">=5.3",
"phpbb/phpbb": "3.1.*@dev"
},
"extra": {
"display-name": "phpBB 3.1 Zebra Enchance"
}
}
5 changes: 5 additions & 0 deletions config/routing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
zebra_enchacnce_ajax:
path: /zebraenhance/{action}/{userid}
defaults: { _controller: anavaro.zebraenhance.ajaxyfy:base }
requirements:
userid: \d+
82 changes: 82 additions & 0 deletions config/services.yml
Original file line number Diff line number Diff line change
@@ -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 }
161 changes: 161 additions & 0 deletions controller/ajaxify.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?php
/**
*
* @package Anavaro.com Zebra Enchance
* @copyright (c) 2013 Lucifer
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

namespace anavaro\zebraenhance\controller;

/**
* @ignore
*/

if (!defined('IN_PHPBB'))
{
exit;
}

class ajaxify
{
/**
* 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\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, $root_path, $php_ext, $table_prefix)
{
$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->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 '<pre>';
print_r($i);
echo '</pre>';
return true;
}


}
85 changes: 85 additions & 0 deletions controller/notifyhelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/**
*
* @package Zebra Enhance Extension
* @copyright (c) 2014 Lucifer
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

namespace anavaro\zebraenhance\controller;

use Symfony\Component\DependencyInjection\Container;

/**
* Admin controller
*/
class notifyhelper
{
/**
* Constructor
*
* @param \phpbb\config\config $config Config object
* @param \phpbb\db\driver\driver $db Database object
* @param \phpbb\request\request $request Request object
* @param \phpbb\template\template $template Template object
* @param \phpbb\user $user User object
* @param Container $phpbb_container
* @param string $root_path phpBB root path
* @param string $php_ext phpEx
* @return \phpbb\boardrules\controller\admin_controller
* @access public
*/
public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver $db, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, Container $phpbb_container, $root_path, $php_ext)
{
$this->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);
}
}
Loading

0 comments on commit f496261

Please sign in to comment.