Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
8f7b65ba
Commit
8f7b65ba
authored
Jan 05, 2009
by
Richard Mansfield
Browse files
Show number of friends in my friends block title (bug #3085)
parent
10b1c1bc
Changes
3
Hide whitespace changes
Inline
Side-by-side
htdocs/blocktype/myfriends/lang/en.utf8/blocktype.myfriends.php
View file @
8f7b65ba
...
...
@@ -29,4 +29,5 @@ defined('INTERNAL') || die();
$string
[
'title'
]
=
'My Friends'
;
$string
[
'otherusertitle'
]
=
"%s's Friends"
;
$string
[
'description'
]
=
'Display your friends'
;
$string
[
'numberoffriends'
]
=
'(%s of %s)'
;
?>
htdocs/blocktype/myfriends/lib.php
View file @
8f7b65ba
...
...
@@ -26,6 +26,8 @@
defined
(
'INTERNAL'
)
||
die
();
define
(
'MAXFRIENDDISPLAY'
,
16
);
class
PluginBlocktypeMyfriends
extends
SystemBlocktype
{
public
static
function
get_title
()
{
...
...
@@ -58,20 +60,8 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
WHERE usr1 = ? OR usr2 = ?
ORDER BY '
.
db_random
()
.
'
LIMIT ?'
,
array
(
$userid
,
$userid
,
16
)
);
$numberoffriends
=
count_records_sql
(
'SELECT COUNT(usr1) FROM {usr_friend}
JOIN {usr} u1 ON (u1.id = usr1 AND u1.deleted = 0)
JOIN {usr} u2 ON (u2.id = usr2 AND u2.deleted = 0)
WHERE usr1 = ? OR usr2 = ?'
,
array
(
$userid
,
$userid
)
array
(
$userid
,
$userid
,
MAXFRIENDDISPLAY
)
);
if
(
$numberoffriends
>
16
)
{
$friendsmessage
=
get_string
(
'numberoffriends'
,
'group'
,
$records
?
count
(
$records
)
:
0
,
$numberoffriends
);
}
else
{
$friendsmessage
=
get_string
(
'Friends'
,
'group'
);
}
// get the friends into a 4x4 array
if
(
$records
)
{
$friends
=
array
();
...
...
@@ -95,7 +85,6 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
$friends
=
false
;
}
$smarty
->
assign
(
'friends'
,
$friends
);
$smarty
->
assign
(
'friendsmessage'
,
$friendsmessage
);
// If the user has no friends, try and display something useful, such
// as a 'request friendship' button
...
...
@@ -157,10 +146,25 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
public
static
function
override_instance_title
(
BlockInstance
$instance
)
{
global
$USER
;
$ownerid
=
$instance
->
get_view
()
->
get
(
'owner'
);
if
(
$ownerid
==
$USER
->
get
(
'id'
))
{
return
get_string
(
'title'
,
'blocktype.myfriends'
);
$title
=
get_string
(
'title'
,
'blocktype.myfriends'
);
}
return
get_string
(
'otherusertitle'
,
'blocktype.myfriends'
,
display_name
(
$ownerid
,
null
,
true
));
else
{
$title
=
get_string
(
'otherusertitle'
,
'blocktype.myfriends'
,
display_name
(
$ownerid
,
null
,
true
));
}
$numberoffriends
=
count_records_sql
(
'SELECT COUNT(usr1) FROM {usr_friend}
JOIN {usr} u1 ON (u1.id = usr1 AND u1.deleted = 0)
JOIN {usr} u2 ON (u2.id = usr2 AND u2.deleted = 0)
WHERE usr1 = ? OR usr2 = ?'
,
array
(
$ownerid
,
$ownerid
)
);
if
(
$numberoffriends
>
MAXFRIENDDISPLAY
)
{
$title
.
=
' '
.
get_string
(
'numberoffriends'
,
'blocktype.myfriends'
,
MAXFRIENDDISPLAY
,
$numberoffriends
);
}
return
$title
;
}
}
...
...
htdocs/lang/en.utf8/group.php
View file @
8f7b65ba
...
...
@@ -243,7 +243,6 @@ $string['cantrequestfrienship'] = 'You cannot request frienship from this user';
$string
[
'cantmessageuser'
]
=
'You cannot send this user a message'
;
$string
[
'requestedfriendship'
]
=
'requested friendship'
;
$string
[
'notinanygroups'
]
=
'Not in any groups'
;
$string
[
'numberoffriends'
]
=
'Friends (%s of %s)'
;
$string
[
'addusertogroup'
]
=
'Add to '
;
$string
[
'inviteusertojoingroup'
]
=
'Invite to '
;
$string
[
'invitemembertogroup'
]
=
'Invite %s to join \'%s\''
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment