Add "help desk" notifications see BT#15586

pull/2913/head
Julio Montoya 6 years ago
parent ce303b0737
commit 4f0b6b4723
  1. 34
      main/cron/import_csv.php
  2. 3
      main/install/configuration.dist.php

@ -5,9 +5,7 @@ use Chamilo\CourseBundle\Entity\CCalendarEvent;
use Chamilo\CourseBundle\Entity\CItemProperty;
use Chamilo\PluginBundle\Entity\StudentFollowUp\CarePost;
use Fhaculty\Graph\Graph;
use Graphp\GraphViz\GraphViz;
use Monolog\Handler\BufferHandler;
use Monolog\Handler\NativeMailerHandler;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
@ -826,6 +824,35 @@ class ImportCsv
$userInfoByOfficialCode = api_get_user_info_from_official_code($row['official_code']);
}
$userInfoFromUsername = api_get_user_info_from_official_code($row['username']);
if (!empty($userInfoFromUsername)) {
$extraFieldValue = new ExtraFieldValue('user');
$extraFieldValues = $extraFieldValue->get_values_by_handler_and_field_variable(
$userInfoFromUsername['user_id'],
$this->extraFieldIdNameList['user']
);
if (!empty($extraFieldValues)) {
$value = 0;
foreach ($extraFieldValues as $extraFieldValue) {
$value = $extraFieldValue['value'];
}
if (!empty($user_id) && $value != $user_id) {
$emails = api_get_configuration_value('cron_notification_help_desk');
if (!empty($emails)) {
$subject = 'User not added due to same username';
$body = 'Cannot add username: "'.$row['username'].'"
with external_user_id: '.$row['extra_'.$this->extraFieldIdNameList['user']].'
because '.$userInfoFromUsername['username'].' with external_user_id '.$value.' exists on the portal
';
foreach ($emails as $email) {
api_mail_html('', $email, $subject, $body);
}
}
}
}
}
if (empty($userInfo) && empty($userInfoByOfficialCode)) {
// Create user
$result = UserManager::create_user(
@ -840,7 +867,7 @@ class ImportCsv
$row['phone'],
null, //$row['picture'], //picture
$row['auth_source'], // ?
$expirationDateOnCreate, //'0000-00-00 00:00:00', //$row['expiration_date'], //$expiration_date = '0000-00-00 00:00:00',
$expirationDateOnCreate,
1, //active
0,
null, // extra
@ -973,7 +1000,6 @@ class ImportCsv
);
}
}
$this->logger->addInfo("Students - User updated: ".$row['username']);
} else {
$this->logger->addError("Students - User NOT updated: ".$row['username']." ".$row['firstname']." ".$row['lastname']);

@ -227,6 +227,9 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
// E-mail accounts to send notifications to when executing cronjobs - works for main/cron/import_csv.php
//$_configuration['cron_notification_mails'] = array('email@example.com', 'email2@example.com');
// Help desk emails that will recieve email notifications in import_csv.php
//$_configuration['cron_notification_help_desk'] = array('email@example.com', 'email2@example.com');
// Only shows the fields in this list
/*$_configuration['allow_fields_inscription'] = [
'fields' => [

Loading…
Cancel
Save