Minor: Plugin: SendMailWhenLpIsPublish: Flinci Fix - refs BT#18214

pull/3743/head
Carlos Alvarado 5 years ago
parent 04116b13ed
commit 62b9f17bf0
No known key found for this signature in database
GPG Key ID: B612DB1EE6658FBB
  1. 51
      main/cron/learning_path_reminder.php

@ -31,14 +31,13 @@ if (!isset($activeMessageNewlp['default_value'])) {
/**
* Send the message to the intended user, manage the corresponding template and send through
* MessageManager::send_message_simple, using this for the option of human resources managers
*
* @param Array $toUser
* @param Int $fromUser
* @param String $courseName
* @param String $lpName
* @param String $link
* MessageManager::send_message_simple, using this for the option of human resources managers.
*
* @param array $toUser
* @param int $fromUser
* @param string $courseName
* @param string $lpName
* @param string $link
*/
function SendMessage($toUser, $fromUser, $courseName, $lpName, $link)
{
@ -83,14 +82,15 @@ function SendMessage($toUser, $fromUser, $courseName, $lpName, $link)
}
/**
* Obtains the data of the learning path and course searched by the id of the LP
* Obtains the data of the learning path and course searched by the id of the LP.
*
* @param array $lpid
*
*/
function getLpDataByArrayId($lpid = [])
{
if (count($lpid) == 0) return [];
if (count($lpid) == 0) {
return [];
}
$tblCourse = Database::get_main_table(TABLE_MAIN_COURSE);
$lpTable = Database::get_course_table(TABLE_LP_MAIN);
$sql = "
@ -115,14 +115,12 @@ function getLpDataByArrayId($lpid = [])
$return[$element['lp_id']] = $element;
}
return $return;
}
/**
* Returns the id of the LPs that have the notification option active through the extra
* field 'notify_student_and_hrm_when_available'
*
* field 'notify_student_and_hrm_when_available'.
*/
function getLpIdWithNotify()
{
@ -170,7 +168,7 @@ function LearningPaths()
$tblCourseRelUser = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tblSessionCourseUser = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tblItempProperty = Database::get_course_table(TABLE_ITEM_PROPERTY);
/*** Gets subscribed users individually in lp's by LearnpathSubscription **/
/* Gets subscribed users individually in lp's by LearnpathSubscription */
$sql = "
SELECT DISTINCT
tblItemProperty.session_id as session_id,
@ -198,12 +196,13 @@ function LearningPaths()
foreach ($data as $row) {
$lpId = (int) $row['lp_id'];
$lpData = [];
if (isset($lpsData[$lpId])) $lpData = $lpsData[$lpId];
if (isset($lpsData[$lpId])) {
$lpData = $lpsData[$lpId];
}
$courseName = isset($lpData['course_name']) ? $lpData['course_name'] : null;
$courseCode = isset($lpData['code']) ? $lpData['code'] : null;
$lpName = isset($lpData['name']) ? $lpData['name'] : null;
$sessionId = (int) $row['session_id'];
$toUser = (int) $row['user_id'];
$fromUser = (int) $row['from_user_id'];
@ -221,7 +220,7 @@ function LearningPaths()
];
$itemProcessed[$lpId][$sessionId]['LearnpathSubscription'][$toUser] = $groupUsers[$lpId][$sessionId][$toUser];
}
/*** Gets subscribed users by classes in lp's by LearnpathSubscription **/
/* Gets subscribed users by classes in lp's by LearnpathSubscription */
$sql = "
SELECT DISTINCT
tblItemProperty.session_id as session_id,
@ -254,7 +253,9 @@ function LearningPaths()
foreach ($data as $row) {
$lpId = (int) $row['lp_id'];
$lpData = [];
if (isset($lpsData[$lpId])) $lpData = $lpsData[$lpId];
if (isset($lpsData[$lpId])) {
$lpData = $lpsData[$lpId];
}
$courseName = isset($lpData['course_name']) ? $lpData['course_name'] : null;
$courseCode = isset($lpData['code']) ? $lpData['code'] : null;
$lpName = isset($lpData['name']) ? $lpData['name'] : null;
@ -276,7 +277,7 @@ function LearningPaths()
];
$itemProcessed[$lpId][$sessionId]['LearnpathSubscription'][$toUser] = $groupUsers[$lpId][$sessionId][$toUser];
}
/*** Get users who are enrolled in the course **/
/* Get users who are enrolled in the course */
$sql = "
SELECT DISTINCT
@ -300,7 +301,9 @@ function LearningPaths()
foreach ($data as $row) {
$lpId = (int) $row['lp_id'];
$sessionId = 0;
if (isset($lpsData[$lpId])) $lpData = $lpsData[$lpId];
if (isset($lpsData[$lpId])) {
$lpData = $lpsData[$lpId];
}
$courseName = isset($lpData['course_name']) ? $lpData['course_name'] : null;
$courseCode = isset($lpData['code']) ? $lpData['code'] : null;
$lpName = isset($lpData['name']) ? $lpData['name'] : null;
@ -322,7 +325,7 @@ function LearningPaths()
$itemProcessed[$lpId][$sessionId]['Normal'][$toUser] = $groupUsers[$lpId][$sessionId][$toUser];
}
}
/** Get the users who are registered in the sessions **/
/** Get the users who are registered in the sessions */
$sql = "
SELECT DISTINCT
tblSessionRelCourseRelUser.user_id AS user_id,
@ -348,7 +351,9 @@ function LearningPaths()
foreach ($data as $row) {
$lpId = (int) $row['lp_id'];
$sessionId = 0;
if (isset($lpsData[$lpId])) $lpData = $lpsData[$lpId];
if (isset($lpsData[$lpId])) {
$lpData = $lpsData[$lpId];
}
$courseName = isset($lpData['course_name']) ? $lpData['course_name'] : null;
$courseCode = isset($lpData['code']) ? $lpData['code'] : null;
$lpName = isset($lpData['name']) ? $lpData['name'] : null;
@ -374,7 +379,7 @@ function LearningPaths()
/**
* Send the emails to the corresponding students and their DRHs, Bearing in mind that if they exist through
* LearnpathSubscription, it will not send anything in the other elements
* LearnpathSubscription, it will not send anything in the other elements.
*/
foreach ($itemProcessed as $lpId => $sessions) {
foreach ($sessions as $sessionId => $types) {

Loading…
Cancel
Save