Skip to content
GitLab
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
7bc5b382
Commit
7bc5b382
authored
Dec 06, 2007
by
Richard Mansfield
Browse files
Institution activity type added; send email notification on membership request
parent
115763e5
Changes
6
Hide whitespace changes
Inline
Side-by-side
htdocs/lang/en.utf8/activity.php
View file @
7bc5b382
...
...
@@ -37,6 +37,7 @@ $string['typeobjectionable'] = 'Objectionable content';
$string
[
'typevirusrepeat'
]
=
'Repeat virus upload'
;
$string
[
'typevirusrelease'
]
=
'Virus flag release'
;
$string
[
'typeadminmessages'
]
=
'Administration messages'
;
$string
[
'typeinstitutionmessage'
]
=
'Institution message'
;
$string
[
'type'
]
=
'Activity type'
;
$string
[
'attime'
]
=
'at'
;
...
...
@@ -93,4 +94,7 @@ $string['removedgroupmembersubj'] = '%s is no longer a group member';
$string
[
'addtowatchlist'
]
=
'Add to watchlist'
;
$string
[
'removefromwatchlist'
]
=
'Remove from watchlist'
;
$string
[
'institutionrequestsubject'
]
=
'%s has asked to be added as a member of %s.'
;
$string
[
'institutionrequestmessage'
]
=
'You can add users to institutions by visiting the Institution Members page:'
;
?>
htdocs/lib/activity.php
View file @
7bc5b382
...
...
@@ -156,6 +156,23 @@ function handle_activity($activitytype, $data, $cron=false) {
}
$users
=
activity_get_users
(
$activitytype
->
name
,
$data
->
users
);
break
;
case
'institutionmessage'
:
if
(
$data
->
messagetype
==
'request'
)
{
$userstring
=
$data
->
username
.
' ('
.
$data
->
fullname
.
')'
;
$data
->
subject
=
get_string
(
'institutionrequestsubject'
,
'activity'
,
$userstring
,
$data
->
institution
->
displayname
);
$data
->
message
=
get_string
(
'institutionrequestmessage'
,
'activity'
);
$data
->
url
=
get_config
(
'wwwroot'
)
.
'admin/users/institutionusers.php'
;
$admins
=
get_column_sql
(
'
SELECT u.id
FROM {usr} u
LEFT OUTER JOIN {usr_institution} i ON (u.id = i.usr AND i.institution = ?)
WHERE u.admin = 1 OR i.admin = 1'
,
array
(
$data
->
institution
->
name
));
$users
=
activity_get_users
(
$activitytype
->
name
,
$admins
);
}
else
if
(
$data
->
messagetype
==
'invite'
)
{
}
break
;
case
'usermessage'
:
if
(
!
is_numeric
(
$data
->
userto
)
||
!
is_numeric
(
$data
->
userfrom
))
{
throw
new
InvalidArgumentException
(
"User message requires userto and userfrom to be set"
);
...
...
@@ -394,11 +411,18 @@ function activity_get_users($activitytype, $userids=null, $userobjs=null, $admin
*/
function
activity_set_defaults
(
$user_id
)
{
$activitytypes
=
get_records_array
(
'activity_type'
,
'admin'
,
0
);
$haveemail
=
in_array
(
'email'
,
array_map
(
create_function
(
'$a'
,
'return $a->name;'
),
plugins_installed
(
'notification'
)));
foreach
(
$activitytypes
as
$type
)
{
if
(
$type
->
name
==
'institutionmessage'
&&
$haveemail
)
{
$method
=
'email'
;
}
else
{
$method
=
'internal'
;
}
insert_record
(
'usr_activity_preference'
,
(
object
)
array
(
'usr'
=>
$user_id
,
'activity'
=>
$type
->
name
,
'method'
=>
'internal'
,
'method'
=>
$method
,
));
}
...
...
htdocs/lib/db/upgrade.php
View file @
7bc5b382
...
...
@@ -514,6 +514,27 @@ function xmldb_core_upgrade($oldversion=0) {
execute_sql
(
'ALTER TABLE {institution} ADD COLUMN defaultmembershipperiod bigint'
);
}
if
(
$oldversion
<
2007120500
)
{
insert_record
(
'activity_type'
,
(
object
)
array
(
'name'
=>
'institutionmessage'
,
'admin'
=>
0
,
'delay'
=>
0
));
if
(
in_array
(
'email'
,
array_map
(
create_function
(
'$a'
,
'return $a->name;'
),
plugins_installed
(
'notification'
))))
{
$method
=
'email'
;
}
else
{
$method
=
'internal'
;
}
foreach
(
get_column
(
'usr'
,
'id'
)
as
$userid
)
{
insert_record
(
'usr_activity_preference'
,
(
object
)
array
(
'usr'
=>
$userid
,
'activity'
=>
'institutionmessage'
,
'method'
=>
$method
));
}
}
return
$status
;
}
...
...
htdocs/lib/institution.php
View file @
7bc5b382
...
...
@@ -248,6 +248,13 @@ class Institution {
);
insert_record
(
'usr_institution_request'
,
$request
);
// Send request notification
$data
=
new
StdClass
;
$data
->
messagetype
=
'request'
;
$data
->
username
=
$user
->
username
;
$data
->
fullname
=
$user
->
firstname
.
' '
.
$user
->
lastname
;
$data
->
institution
=
(
object
)
array
(
'name'
=>
$this
->
name
,
'displayname'
=>
$this
->
displayname
);
$data
->
url
=
get_config
(
'wwwroot'
)
.
'foo'
;
activity_occurred
(
'institutionmessage'
,
$data
);
}
else
if
(
$request
->
confirmedinstitution
)
{
$this
->
addUserAsMember
(
$user
);
}
...
...
htdocs/lib/upgrade.php
View file @
7bc5b382
...
...
@@ -639,6 +639,7 @@ function core_install_firstcoredata_defaults() {
array
(
'objectionable'
,
1
,
1
),
array
(
'virusrepeat'
,
1
,
1
),
array
(
'virusrelease'
,
1
,
1
),
array
(
'institutionmessage'
,
0
,
0
),
);
foreach
(
$activitytypes
as
$at
)
{
...
...
htdocs/lib/version.php
View file @
7bc5b382
...
...
@@ -27,7 +27,7 @@
defined
(
'INTERNAL'
)
||
die
();
$config
=
new
StdClass
;
$config
->
version
=
20071
126
00
;
$config
->
version
=
20071
205
00
;
$config
->
release
=
'0.9.0alpha3dev'
;
$config
->
minupgradefrom
=
2007080700
;
$config
->
minupgraderelease
=
'0.8.0 (release tag 0.8.0_RELEASE)'
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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