Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More notifications and buddy systems code

  • Loading branch information...
commit 925d03a6fafe3753c8986bb8c6dcdce37e3abf9c 1 parent 68ccd3a
@MissAllSunday authored
View
24 Breeze/Breeze.php
@@ -151,6 +151,30 @@ public static function ProfileInfo(&$profile_areas)
),
);
+ /* Buddies page */
+ /* if $some_check here */
+ $profile_areas['breeze_profile']['areas']['breezebuddies'] = array(
+ 'label' => $s->GetText('user_buddysettings_name'),
+ 'file' => Breeze::$BreezeFolder .'Breeze_User.php',
+ 'function' => 'Breeze_Wrapper_BuddyRequest',
+ 'permission' => array(
+ 'own' => 'profile_view_own',
+ 'any' => 'profile_view_any',
+ ),
+ );
+
+ /* Notifications admin page */
+ /* if $some_check here */
+ $profile_areas['breeze_profile']['areas']['breezenoti'] = array(
+ 'label' => $s->GetText('user_notisettings_name'),
+ 'file' => Breeze::$BreezeFolder .'Breeze_User.php',
+ 'function' => 'Breeze_Wrapper_Notifications',
+ 'permission' => array(
+ 'own' => 'profile_view_own',
+ 'any' => 'profile_view_any',
+ ),
+ );
+
/* Done with the hacking... */
}
View
43 Breeze/Breeze_Buddy.php
@@ -44,7 +44,7 @@ public function __construct(){}
public static function Buddy()
{
- global $user_info;
+ global $user_info, $scripturl;
checkSession('get');
@@ -54,10 +54,18 @@ public static function Buddy()
Breeze::Load(array(
'Settings',
'Globals',
+ 'Notifications',
+ 'UserInfo',
+ 'Query'
));
+ /* We need all this stuff */
$sa = new Breeze_Globals('get');
+ $notification = new Breeze_Notification();
+ $setings = Breeze_Settings::getInstance();
+
+ /* There's gotta be an user... */
if ($sa->Validate('u') == false)
fatal_lang_error('no_access', false);
@@ -73,13 +81,44 @@ public static function Buddy()
/* Before anything else, let's ask the user shall we? */
elseif ($user_info['id'] != $sa->Raw('u'))
{
+ /* Load the users link */
+ $user_asking = Breeze_UserInfo::Profile($user_info['id']);
+ $user_receiving = Breeze_UserInfo::Profile($sa->Raw('u'));
+
+ $params = array(
+ 'user' => $sa->Raw('u'),
+ 'time' => time(),
+ 'read' => 0,
+ 'content' => array(
+ 'title' => $settings->GetText('noti_buddy_title'),
+ 'message' => sprintf($settings->GetText('noti_buddy_message'), $context['Breeze']['user_info']['link'][$user_info['id']]),
+ 'url' => $scripturl .'?action=profile;area=breezebuddies;u='. $sa->Raw('u')
+ )
+ );
+
/* Notification here */
+ $notification->Create('buddy', $params);
$user_info['buddies'][] = (int) $sa->Raw('u');
/* Show a nice message saying the user must approve the friendship request */
- redirectexit('action=profile;sa=buddymessage;u=' . $sa->Raw('u'));
+ redirectexit('action=profile;area=breezebuddies;u=' . $sa->Raw('u'));
}
}
+
+ public function ShowBuddyRequests($user)
+ {
+ $query = Breeze_Query::getInstance();
+
+ /* Load all buddy request for this user */
+ $query->GetNotificationByType($user);
+
+ /* We only want the notification for this user... */
+
+
+ /* Return the notifications */
+
+
+ }
}
View
69 Breeze/Breeze_Notifications.php
@@ -40,11 +40,12 @@
class Breeze_Notifications
{
- $types = array();
- $params = array();
- $user = 0;
- $settings = '';
- $query = '';
+ protected $types = array();
+ protected $params = array();
+ private $user = 0;
+ private $settings = '';
+ private $query = '';
+ private $ReturnArray = array();
function __construct()
{
@@ -52,7 +53,8 @@ function __construct()
'comment',
'status',
'like',
- 'buddy'
+ 'buddy',
+ 'mention'
);
Breeze::Load(array(
@@ -70,62 +72,39 @@ public function Create($type, $params)
if (in_array($type, $this->types) && !empty($params))
{
$this->params = $params;
+ $this->type = $type;
+ $this->params['type'] = $this->type;
- switch ($type)
- {
- case 'comment':
- $this->NewComment();
- break;
- case 'status':
- $this->NewStatus();
- break;
- case 'like':
- $this->NewLike();
- case 'buddy':
- $this->NewBuddy();
- break;
- }
+ $this->query->InsertNotification($this->params);
}
- }
-
- protected function NewComment()
- {
-
- }
-
- protected function NewStatus()
- {
+ else
+ return false;
}
- protected function NewLike()
- {
-
- }
-
- protected function NewBuddy()
- {
-
- }
-
- public function GetByUser($user)
+ protected function GetByUser($user)
{
/* Dont even bother... */
if (empty($user))
return;
- $this->user = $user;
+ $user = (int) $user;
+ return $this->query->GetNotificationByUser($user);
}
- public function Stream()
+ public function Stream($user)
{
-
+ return $this->GetByUser($user);
}
- protected function Delete()
+ protected function Delete($id)
{
+ $this->query->DeleteNotification($id);
+ }
-
+ protected function MarkAsRead($id)
+ {
+ $this->query->MarkAsReadNotification($id);
}
}
View
20 Breeze/Breeze_Parser.php
@@ -41,11 +41,16 @@
class Breeze_Parser
{
+ private $notification;
+
function __construct()
{
Breeze::Load(array(
- 'Subs'
+ 'Subs',
+ 'Notifications'
));
+
+ $this->notification = new Breeze_Notifications();
}
function Display($string)
@@ -90,6 +95,19 @@ private function Mention($s)
{
$context['Breeze']['user_info'][$user[0]] = Breeze_UserInfo::Profile($user[0], true);
$s = str_replace($matches[0], '@'.$context['Breeze']['user_info']['link'][$user[0]], $s);
+
+ /* Does this user wants to be notificated? */
+ /* Some if check here */
+ {
+ /* Build the params */
+ $params = array(
+ /* Params here */
+ );
+
+ /* Create the notification */
+ $this->notification->Create('mention', $params);
+ }
+
}
else
$s = str_replace($matches[0], '@'.$m, $s);
View
27 Breeze/Breeze_Query.php
@@ -55,7 +55,7 @@ class Breeze_Query
private $valid = false;
private $global_settings;
- private function __construct()
+ protected function __construct()
{
Breeze::Load(array(
'DB',
@@ -402,10 +402,9 @@ public function GetStatusByID($id)
*/
public function GetStatusByUser($id)
{
- return $this->GetReturn('status', 'status_id', $id);
+ return $this->GetReturn('status', 'status_user', $id);
}
-
/* Methods for comments */
/*
@@ -962,6 +961,23 @@ public function InsertNotification($array)
$this->Query('notifications')->InsertData($data, $array, $indexes);
}
+ public function MarkAsReadNotification($id)
+ {
+ /* Delete! */
+ $params = array(
+ 'set' => 'read = {int:read}',
+ 'where' => 'id = {int:id}'
+ );
+
+ $data = array(
+ 'read' => 1,
+ 'id' => $id
+ );
+
+ $this->Query('notifications')->Params($params, $data);
+ $this->Query('notifications')->UpdateData();
+ }
+
public function DeleteNotification($id)
{
/* Delete! */
@@ -981,6 +997,11 @@ public function GetNotificationByUser($user)
{
return $this->GetReturn('notifications', 'user', $user);
}
+
+ public function GetNotificationByType($user)
+ {
+ return $this->GetReturn('notifications', 'type', $user);
+ }
}
/*
View
2  Breeze/Breeze_User.php
@@ -42,7 +42,7 @@
function Breeze_Wrapper_Wall(){Breeze_User::Wall();}
function Breeze_Wrapper_Settings(){Breeze_User::Settings();}
function Breeze_Wrapper_BuddyRequest(){Breeze_User::BuddyRequest();}
- function Breeze_Wrapper_BuddyMessage(){Breeze_User::BuddyMessage();}
+ function Breeze_Wrapper_Notifications(){Breeze_User::Notifications();}
class Breeze_User
{
View
7 languages/Breeze.english.php
@@ -58,6 +58,8 @@
/* User Individual Settings */
$txt['BreezeMod_profile'] = 'Wall Settings';
$txt['BreezeMod_user_settings_name'] = 'Wall Settings';
+$txt['BreezeMod_user_buddysettings_name'] = 'Buddy Requests';
+$txt['BreezeMod_user_notisettings_name'] = 'Notifications';
$txt['BreezeMod_user_settings_wall_limit'] = 'How many status per page to show?';
$txt['BreezeMod_user_settings_wall_limit_sub'] = 'This will be the number of status to show by default, max value is 30, if set it will create a pagination with the rest of your status.';
$txt['BreezeMod_user_settings_kick_ignored'] = 'Do not show my wall to users in my ignore list';
@@ -172,6 +174,7 @@
$txt['BreezeMod_pag_first'] = 'First';
$txt['BreezeMod_pag_last'] = 'Last';
-
/* Notifications */
-$txt['BreezeMod_noti_title'] = 'Notifications';
+$txt['BreezeMod_noti_title'] = 'Notifications';
+$txt['BreezeMod_noti_buddy_title'] = 'Buddy notification';
+$txt['BreezeMod_noti_buddy_message'] = 'The user %1$s has added you as his/her buddy, please confirm this request.';
Please sign in to comment.
Something went wrong with that request. Please try again.