Send email when user has been subscribed - refs BT#9896 #TMI

1.10.x
Angel Fernando Quiroz Campos 9 years ago
parent 726638cb2f
commit 2bedf1af14
  1. 89
      main/inc/lib/sessionmanager.lib.php
  2. 5
      main/session/session_user_import.php
  3. 1
      main/webservices/registration.soap.php
  4. 22
      src/Chamilo/CoreBundle/Entity/Session.php

@ -1517,15 +1517,13 @@ class SessionManager
* @param array $user_list
* @param int $session_visibility
* @param bool $empty_users
* @param bool $send_email
* @return bool
*/
public static function suscribe_users_to_session(
$id_session,
$user_list,
$session_visibility = SESSION_VISIBLE_READ_ONLY,
$empty_users = true,
$send_email = false
$empty_users = true
) {
if ($id_session != strval(intval($id_session))) {
return false;
@ -1573,51 +1571,52 @@ class SessionManager
$course_list[] = $row['c_id'];
}
if ($send_email) {
if (
$session->getSendSubscriptionNotification() &&
is_array($user_list)
) {
// Sending emails only
if (is_array($user_list) && count($user_list) > 0) {
foreach ($user_list as $user_id) {
if (in_array($user_id, $existingUsers)) {
continue;
}
foreach ($user_list as $user_id) {
if (in_array($user_id, $existingUsers)) {
continue;
}
$tplSubject = new Template(null, false, false, false, false, false);
$layoutSubject = $tplSubject->get_template(
'mail/subject_subscription_to_session_confirmation.tpl'
);
$subject = $tplSubject->fetch($layoutSubject);
$tplSubject = new Template(null, false, false, false, false, false);
$layoutSubject = $tplSubject->get_template(
'mail/subject_subscription_to_session_confirmation.tpl'
);
$subject = $tplSubject->fetch($layoutSubject);
$user_info = api_get_user_info($user_id);
$user_info = api_get_user_info($user_id);
$tplContent = new Template(null, false, false, false, false, false);
// Variables for default template
$tplContent->assign(
'complete_name',
stripslashes($user_info['complete_name'])
);
$tplContent->assign('session_name', $session->getName());
$tplContent->assign(
'session_coach',
$session->getGeneralCoach()->getCompleteName()
);
$layoutContent = $tplContent->get_template(
'mail/content_subscription_to_session_confirmation.tpl'
);
$content = $tplContent->fetch($layoutContent);
MessageManager::send_message(
$user_id,
$subject,
$content,
array(),
array(),
null,
null,
null,
null,
null
);
}
$tplContent = new Template(null, false, false, false, false, false);
// Variables for default template
$tplContent->assign(
'complete_name',
stripslashes($user_info['complete_name'])
);
$tplContent->assign('session_name', $session->getName());
$tplContent->assign(
'session_coach',
$session->getGeneralCoach()->getCompleteName()
);
$layoutContent = $tplContent->get_template(
'mail/content_subscription_to_session_confirmation.tpl'
);
$content = $tplContent->fetch($layoutContent);
MessageManager::send_message(
$user_id,
$subject,
$content,
array(),
array(),
null,
null,
null,
null,
null
);
}
}
@ -3689,7 +3688,7 @@ class SessionManager
}
$users = null;
//Subscribing in read only mode
self::suscribe_users_to_session($sid, $short_users, SESSION_VISIBLE_READ_ONLY, true, false);
self::suscribe_users_to_session($sid, $short_users, SESSION_VISIBLE_READ_ONLY, true);
$short_users = null;
}
return $sid;

@ -31,7 +31,6 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
!empty($_FILES['import_file']['tmp_name'])
) {
$form_sent = $_POST['formSent'];
$send_mail = $_POST['sendMail'] ? 1 : 0;
// CSV
$users = Import::csvToArray($_FILES['import_file']['tmp_name']);
@ -49,8 +48,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
$session_id,
$user_list,
null,
false,
$send_mail
false
);
foreach ($user_list as & $user_id) {
$user_info = api_get_user_info($user_id);
@ -85,7 +83,6 @@ $form = new FormValidator(
);
$form->addElement('hidden', 'formSent', 1);
$form->addElement('file', 'import_file', get_lang('ImportCSVFileLocation'));
$form->addElement('checkbox', 'sendMail', null, get_lang('SendMailToUsers'));
$form->addButtonImport(get_lang('Import'));
$form->display();

@ -4915,7 +4915,6 @@ function WSSubscribeUserToSessionSimple($params) {
$session_id,
array($user_id),
SESSION_VISIBLE_READ_ONLY,
false,
false
);
if ($debug) error_log('User registered to the course: '.$session_id);

@ -965,4 +965,26 @@ class Session
}
return $this;
}
/**
* Set $sendSubscriptionNotification
* @param boolean $sendNotification
* @return \Chamilo\CoreBundle\Entity\Session
*/
public function setSendSubscriptionNotification($sendNotification)
{
$this->sendSubscriptionNotification = $sendNotification;
return $this;
}
/**
* Get $sendSubscriptionNotification
* @return boolean
*/
public function getSendSubscriptionNotification()
{
return $this->sendSubscriptionNotification;
}
}

Loading…
Cancel
Save