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
ef56fe08
Commit
ef56fe08
authored
Jul 07, 2007
by
Penny Leach
Browse files
added messaging between users
parent
9358b41a
Changes
4
Hide whitespace changes
Inline
Side-by-side
htdocs/lang/en.utf8/mahara.php
View file @
ef56fe08
...
...
@@ -538,6 +538,14 @@ $string['pendingfriends'] = 'Pending friends';
$string
[
'friendlistfailure'
]
=
'Failed to modify your friends list'
;
$string
[
'userdoesntwantfriends'
]
=
'This user doesn\'t want any new friends'
;
//messaging between users
$string
[
'messagebody'
]
=
'Send message'
;
$string
[
'sendmessage'
]
=
'Send'
;
$string
[
'messagesent'
]
=
'Message sent!'
;
$string
[
'messagenotsent'
]
=
'Failed to send message'
;
$string
[
'newusermessage'
]
=
'New message from %s'
;
$string
[
'friend'
]
=
'Friend'
;
$string
[
'profileicon'
]
=
'Profile Icon'
;
...
...
htdocs/lib/activity.php
View file @
ef56fe08
...
...
@@ -160,7 +160,7 @@ function handle_activity($activitytype, $data, $cron=false) {
throw
new
InvalidArgumentException
(
"User message requires userto and userfrom to be set"
);
}
if
(
empty
(
$data
->
subject
))
{
throw
new
InvalidArgumentException
(
"U
ser
message
activity type expects a subject"
);
$data
->
subject
=
get_string
(
'newu
sermessage
'
,
'mahara'
,
display_name
(
$data
->
userfrom
)
);
}
if
(
empty
(
$data
->
message
))
{
throw
new
InvalidArgumentException
(
"User message activity type expects a message"
);
...
...
htdocs/theme/default/templates/user/view.tpl
View file @
ef56fe08
...
...
@@ -42,6 +42,7 @@
{
$INVITEFORM
}
{
$ADDFORM
}
{
$FRIENDFORM
}
{
$MESSAGEFORM
}
</div>
{
include
file
=
"columnleftend.tpl"
}
...
...
htdocs/user/view.php
View file @
ef56fe08
...
...
@@ -32,6 +32,13 @@ $userid = param_integer('id','');
$loggedinid
=
$USER
->
get
(
'id'
);
$prefix
=
get_config
(
'dbprefix'
);
$inlinejs
=
<<<EOF
function messageform_success(formname, data) {
swapDOM(formname, P(null, data.message));
return true;
}
function usercontrol_success(formname, data) {
if (formname != 'friend') {
...
...
@@ -66,6 +73,7 @@ $userfields = array();
if
(
!
$user
=
get_record
(
'usr'
,
'id'
,
$userid
))
{
throw
new
UserNotFoundException
(
"User with id
$userid
not found"
);
}
$is_friend
=
is_friend
(
$userid
,
$loggedinid
);
$name
=
display_name
(
$user
);
define
(
'TITLE'
,
$name
);
...
...
@@ -216,7 +224,7 @@ EOF;
$friendtype
=
''
;
$friendformmessage
=
''
;
// already a friend ... we can remove.
if
(
is_friend
(
$userid
,
$loggedinid
)
)
{
if
(
$
is_friend
)
{
$friendtype
=
'remove'
;
$friendsubmit
=
get_string
(
'removefromfriendslist'
);
}
...
...
@@ -265,6 +273,30 @@ EOF;
$friendtype
=
'add'
;
}
}
$messagepref
=
get_account_preference
(
$userid
,
'messages'
);
if
((
$is_friend
&&
$messagepref
==
'friends'
)
||
$messagepref
==
'allow'
)
{
$messageform
=
array
(
'name'
=>
'messageform'
,
'jsform'
=>
true
,
'jssuccesscallback'
=>
'messageform_success'
,
'elements'
=>
array
(
'body'
=>
array
(
'type'
=>
'textarea'
,
'title'
=>
get_string
(
'messagebody'
),
'cols'
=>
50
,
'rows'
=>
4
,
'rules'
=>
array
(
'required'
=>
true
,
),
),
'submit'
=>
array
(
'type'
=>
'submit'
,
'value'
=>
get_string
(
'sendmessage'
),
),
),
);
}
}
// if we have a form to display, do it
if
(
!
empty
(
$friendtype
))
{
...
...
@@ -290,7 +322,15 @@ else {
}
}
if
(
!
empty
(
$messageform
))
{
$messageform
=
pieform
(
$messageform
);
}
else
{
$messageform
=
''
;
}
$smarty
->
assign
(
'FRIENDFORM'
,
$friendform
);
$smarty
->
assign
(
'MESSAGEFORM'
,
$messageform
);
$smarty
->
assign
(
'INLINEJAVASCRIPT'
,
$inlinejs
);
$smarty
->
assign
(
'NAME'
,
$name
);
$smarty
->
assign
(
'USERID'
,
$userid
);
...
...
@@ -357,5 +397,24 @@ function addmember_submit(Pieform $form, $values) {
$form
->
json_reply
(
PIEFORM_OK
,
get_string
(
'useradded'
));
}
function
messageform_submit
(
Pieform
$form
,
$values
)
{
global
$USER
,
$user
;
try
{
activity_occurred
(
'usermessage'
,
array
(
'userto'
=>
$user
->
id
,
'userfrom'
=>
$USER
->
id
,
'message'
=>
$values
[
'body'
],
)
);
$form
->
json_reply
(
PIEFORM_OK
,
get_string
(
'messagesent'
));
}
catch
(
InvalidException
$_e
)
{
$form
->
json_reply
(
PIEFORM_ERR
,
get_string
(
'messagenotsent'
));
}
}
// friend submit function lives in lib/user.php
?>
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