|
|
|
@ -562,7 +562,7 @@ function exercise_attempt_hotspot($exe_id, $question_id, $answer_id, $correct, $ |
|
|
|
|
* @param integer User ID (defaults to null) |
|
|
|
|
* @param string Course code (defaults to null) |
|
|
|
|
*/ |
|
|
|
|
function event_system($event_type, $event_value_type, $event_value, $datetime = null, $user_id=null, $course_code=null) { |
|
|
|
|
function event_system($event_type, $event_value_type, $event_value, $datetime = null, $user_id = null, $course_code = null) { |
|
|
|
|
global $_user; |
|
|
|
|
global $TABLETRACK_DEFAULT; |
|
|
|
|
|
|
|
|
@ -579,18 +579,25 @@ function event_system($event_type, $event_value_type, $event_value, $datetime = |
|
|
|
|
unset($event_value['avatar']); |
|
|
|
|
unset($event_value['password']); |
|
|
|
|
unset($event_value['lastLogin']); |
|
|
|
|
unset($event_value['picture_uri']); |
|
|
|
|
|
|
|
|
|
unset($event_value['picture_uri']); |
|
|
|
|
$event_value = serialize($event_value); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$event_value = Database::escape_string($event_value); |
|
|
|
|
$user_id = Database::escape_string($user_id); |
|
|
|
|
$course_code = Database::escape_string($course_code); |
|
|
|
|
$course_info = api_get_course_info($course_code); |
|
|
|
|
|
|
|
|
|
$course_id = null; |
|
|
|
|
if (!empty($course_info)) { |
|
|
|
|
$course_id = $course_info['real_id']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!isset($datetime)) { |
|
|
|
|
$datetime = api_get_utc_datetime(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$datetime = Database::escape_string($datetime); |
|
|
|
|
|
|
|
|
|
if(!isset($user_id)) { |
|
|
|
@ -599,17 +606,19 @@ function event_system($event_type, $event_value_type, $event_value, $datetime = |
|
|
|
|
if(!isset($course_code)) { |
|
|
|
|
$course_code = ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sql = "INSERT INTO $TABLETRACK_DEFAULT |
|
|
|
|
(default_user_id, |
|
|
|
|
default_cours_code, |
|
|
|
|
c_id, |
|
|
|
|
default_date, |
|
|
|
|
default_event_type, |
|
|
|
|
default_value_type, |
|
|
|
|
default_value |
|
|
|
|
) |
|
|
|
|
VALUES |
|
|
|
|
('$user_id.', |
|
|
|
|
VALUES('$user_id.', |
|
|
|
|
'$course_code', |
|
|
|
|
'$course_id', |
|
|
|
|
'$datetime', |
|
|
|
|
'$event_type', |
|
|
|
|
'$event_value_type', |
|
|
|
@ -617,37 +626,37 @@ function event_system($event_type, $event_value_type, $event_value, $datetime = |
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
|
|
|
|
|
//Sending notifications to users |
|
|
|
|
$send_event_setting = api_get_setting('activate_send_event_by_mail'); |
|
|
|
|
if (!empty($send_event_setting) && $send_event_setting == 'true') { |
|
|
|
|
global $language_file; |
|
|
|
|
|
|
|
|
|
//prepare message |
|
|
|
|
list($message, $subject) = get_event_message_and_subject($event_type); |
|
|
|
|
$mail_body=$message; |
|
|
|
|
if ( is_array($notification_infos) ){ |
|
|
|
|
foreach ($notification_infos as $variable => $value) { |
|
|
|
|
$mail_body = str_replace('%'.$variable.'%',$value,$mail_body); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$send_event_setting = api_get_setting('activate_send_event_by_mail'); |
|
|
|
|
if (!empty($send_event_setting) && $send_event_setting == 'true') { |
|
|
|
|
global $language_file; |
|
|
|
|
|
|
|
|
|
//prepare message |
|
|
|
|
list($message, $subject) = get_event_message_and_subject($event_type); |
|
|
|
|
$mail_body=$message; |
|
|
|
|
if (is_array($notification_infos)) { |
|
|
|
|
foreach ($notification_infos as $variable => $value) { |
|
|
|
|
$mail_body = str_replace('%'.$variable.'%',$value,$mail_body); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//prepare mail common variables |
|
|
|
|
if(empty($subject)) { |
|
|
|
|
$subject = $event_type; |
|
|
|
|
} |
|
|
|
|
$mail_subject = '['.api_get_setting('siteName').'] '.$subject; |
|
|
|
|
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); |
|
|
|
|
$email_admin = api_get_setting('emailAdministrator'); |
|
|
|
|
$emailfromaddr = api_get_setting('emailAdministrator'); |
|
|
|
|
$emailfromname = api_get_setting('siteName'); |
|
|
|
|
|
|
|
|
|
//Send mail to all subscribed users |
|
|
|
|
$users_arr = get_users_subscribed_to_event($event_type); |
|
|
|
|
foreach ($users_arr as $user) { |
|
|
|
|
$recipient_name = api_get_person_name($user['firstname'], $user['lastname']); |
|
|
|
|
$email = $user['email']; |
|
|
|
|
@api_mail($recipient_name, $email, $mail_subject, $mail_body, $sender_name, $email_admin); |
|
|
|
|
//prepare mail common variables |
|
|
|
|
if(empty($subject)) { |
|
|
|
|
$subject = $event_type; |
|
|
|
|
} |
|
|
|
|
$mail_subject = '['.api_get_setting('siteName').'] '.$subject; |
|
|
|
|
$sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); |
|
|
|
|
$email_admin = api_get_setting('emailAdministrator'); |
|
|
|
|
$emailfromaddr = api_get_setting('emailAdministrator'); |
|
|
|
|
$emailfromname = api_get_setting('siteName'); |
|
|
|
|
|
|
|
|
|
//Send mail to all subscribed users |
|
|
|
|
$users_arr = get_users_subscribed_to_event($event_type); |
|
|
|
|
foreach ($users_arr as $user) { |
|
|
|
|
$recipient_name = api_get_person_name($user['firstname'], $user['lastname']); |
|
|
|
|
$email = $user['email']; |
|
|
|
|
@api_mail($recipient_name, $email, $mail_subject, $mail_body, $sender_name, $email_admin); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|