Пример #1
0
 /**
  * Saves the user-course legal agreement
  * @param   int user id
  * @param   string course code
  * @param   int session id
  * @return mixed
  */
 public static function save_user_legal($user_id, $course_code, $session_id = null)
 {
     // Course plugin legal
     $enabled = api_get_plugin_setting('courselegal', 'tool_enable');
     if ($enabled == 'true') {
         require_once api_get_path(SYS_PLUGIN_PATH) . 'courselegal/config.php';
         $plugin = CourseLegalPlugin::create();
         return $plugin->saveUserLegal($user_id, $course_code, $session_id);
     }
     $user_id = intval($user_id);
     $course_code = Database::escape_string($course_code);
     $session_id = intval($session_id);
     $courseInfo = api_get_course_info($course_code);
     $courseId = $courseInfo['real_id'];
     if (empty($session_id)) {
         $table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
         $sql = "UPDATE {$table} SET legal_agreement = '1'\n                    WHERE user_id = {$user_id} AND c_id  = {$courseId} ";
         Database::query($sql);
     } else {
         $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
         $sql = "UPDATE  {$table} SET legal_agreement = '1'\n                    WHERE user_id = {$user_id} AND c_id = {$courseId} AND session_id = {$session_id}";
         Database::query($sql);
     }
 }
Пример #2
0
$this_section = SECTION_COURSES;
$course_code = isset($_REQUEST['course_code']) ? $_REQUEST['course_code'] : null;
$session_id = isset($_REQUEST['session_id']) ? intval($_REQUEST['session_id']) : null;
$user_id = api_get_user_id();
if (empty($course_code)) {
    api_not_allowed();
}
$course_info = CourseManager::get_course_information($course_code);
$course_legal = $course_info['legal'];
$enabled = api_get_plugin_setting('courselegal', 'tool_enable');
$pluginExtra = null;
$pluginLegal = false;
if ($enabled == 'true') {
    $pluginLegal = true;
    require_once api_get_path(SYS_PLUGIN_PATH) . 'courselegal/config.php';
    $plugin = CourseLegalPlugin::create();
    $data = $plugin->getData($course_info['real_id'], $session_id);
    if (!empty($data)) {
        $course_legal = $data['content'];
    }
    $userData = $plugin->getUserAcceptedLegal($user_id, $course_info['real_id'], $session_id);
    if (isset($_GET['web_agreement_link'])) {
        $plugin->saveUserMailLegal($_GET['web_agreement_link'], $user_id, $course_info['real_id'], $session_id);
    }
}
// Build the form
$form = new FormValidator('legal', 'GET', api_get_self() . '?course_code=' . $course_code . '&session_id=' . $session_id);
$pluginMessage = null;
$hideForm = false;
if ($pluginLegal && isset($userData) && !empty($userData)) {
    if ($userData['web_agreement'] == 1) {
Пример #3
0
$language_file = array('document', 'gradebook');

require_once dirname(__FILE__) . '/config.php';

// Course legal
$enabled = api_get_plugin_setting('courselegal', 'tool_enable');

if ($enabled != 'true') {
    api_not_allowed(true);
}

if (!api_is_allowed_to_edit()) {
    api_not_allowed(true);
}

$legal = CourseLegalPlugin::create();
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
$url = api_get_self().'?'.api_get_cidreq();

$action = isset($_GET['action']) ? $_GET['action'] : null;
switch($action) {
    case 'resend':
        if (isset($_GET['user_id'])) {
            $legal->updateMailAgreementLink($_GET['user_id'], $courseId, $sessionId);
            header('Location: '.$url);
            exit;
        }
        break;
    case 'delete':
        if (isset($_GET['user_id'])) {
Пример #4
0
<?php

require_once dirname(__FILE__) . '/config.php';
$plugin_info = CourseLegalPlugin::create()->get_info();
             $result['pass'] = false;
         }
     } catch (\Exception $e) {
         $result['errorMessage'] = $e->getMessage();
     }
     break;
 case 'subscribe':
     // Subscription
     // Start subscription to queue
     $res = AdvancedSubscriptionPlugin::create()->startSubscription($data['studentUserId'], $data['sessionId'], $data);
     // Check if queue subscription was successful
     if ($res === true) {
         $legalEnabled = api_get_plugin_setting('courselegal', 'tool_enable');
         if ($legalEnabled) {
             // Save terms confirmation
             CourseLegalPlugin::create()->saveUserLegal($data['studentUserId'], $data['courseId'], $data['sessionId'], false);
         }
         // Prepare data
         // Get session data
         // Assign variables
         $fieldsArray = array('description', 'target', 'mode', 'publication_end_date', 'recommended_number_of_participants');
         $sessionArray = api_get_session_info($data['sessionId']);
         $extraSession = new ExtraFieldValue('session');
         $extraField = new ExtraField('session');
         // Get session fields
         $fieldList = $extraField->get_all(array('variable IN ( ?, ?, ?, ?, ?)' => $fieldsArray));
         // Index session fields
         foreach ($fieldList as $field) {
             $fields[$field['id']] = $field['variable'];
         }
         $mergedArray = array_merge(array($data['sessionId']), array_keys($fields));
Пример #6
0
<?php

/* For license terms, see /license.txt */
require_once dirname(__FILE__) . '/config.php';
if (!api_is_platform_admin()) {
    die('You must have admin permissions to install plugins');
}
CourseLegalPlugin::create()->install();
 /**
  * Render and send mail by defined advanced subscription action
  * @param $data
  * @param $actionType
  * @return array
  */
 public function sendMail($data, $actionType)
 {
     $template = new Template($this->get_lang('plugin_title'));
     $template->assign('data', $data);
     $templateParams = array('user', 'student', 'students', 'superior', 'admins', 'session', 'signature', 'admin_view_url', 'acceptUrl', 'rejectUrl');
     foreach ($templateParams as $templateParam) {
         $template->assign($templateParam, $data[$templateParam]);
     }
     $mailIds = array();
     switch ($actionType) {
         case ADVANCED_SUBSCRIPTION_ACTION_STUDENT_REQUEST:
             // Mail to student
             $mailIds['render'] = $this->sendMailMessage($data['studentUserId'], $data['student']['user_id'], $this->get_lang('MailStudentRequest'), $template->fetch('/advanced_subscription/views/student_notice_student.tpl'), $data['sessionId'], true);
             // Mail to superior
             $mailIds[] = $this->sendMailMessage($data['studentUserId'], $data['superior']['user_id'], $this->get_lang('MailStudentRequest'), $template->fetch('/advanced_subscription/views/student_notice_superior.tpl'), $data['sessionId']);
             break;
         case ADVANCED_SUBSCRIPTION_ACTION_SUPERIOR_APPROVE:
             // Mail to student
             $mailIds[] = $this->sendMailMessage($data['studentUserId'], $data['student']['user_id'], $this->get_lang('MailBossAccept'), $template->fetch('/advanced_subscription/views/superior_accepted_notice_student.tpl'), $data['sessionId'], true);
             // Mail to superior
             $mailIds['render'] = $this->sendMailMessage($data['studentUserId'], $data['superior']['user_id'], $this->get_lang('MailBossAccept'), $template->fetch('/advanced_subscription/views/superior_accepted_notice_superior.tpl'), $data['sessionId']);
             // Mail to admin
             foreach ($data['admins'] as $adminId => $admin) {
                 $template->assign('admin', $admin);
                 $mailIds[] = $this->sendMailMessage($data['studentUserId'], $adminId, $this->get_lang('MailBossAccept'), $template->fetch('/advanced_subscription/views/superior_accepted_notice_admin.tpl'), $data['sessionId']);
             }
             break;
         case ADVANCED_SUBSCRIPTION_ACTION_SUPERIOR_DISAPPROVE:
             // Mail to student
             $mailIds[] = $this->sendMailMessage($data['studentUserId'], $data['student']['user_id'], $this->get_lang('MailBossReject'), $template->fetch('/advanced_subscription/views/superior_rejected_notice_student.tpl'), $data['sessionId'], true);
             // Mail to superior
             $mailIds['render'] = $this->sendMailMessage($data['studentUserId'], $data['superior']['user_id'], $this->get_lang('MailBossReject'), $template->fetch('/advanced_subscription/views/superior_rejected_notice_superior.tpl'), $data['sessionId']);
             break;
         case ADVANCED_SUBSCRIPTION_ACTION_SUPERIOR_SELECT:
             // Mail to student
             $mailIds[] = $this->sendMailMessage($data['studentUserId'], $data['student']['user_id'], $this->get_lang('MailStudentRequestSelect'), $template->fetch('/advanced_subscription/views/student_notice_student.tpl'), $data['sessionId'], true);
             // Mail to superior
             $mailIds['render'] = $this->sendMailMessage($data['studentUserId'], $data['superior']['user_id'], $this->get_lang('MailStudentRequestSelect'), $template->fetch('/advanced_subscription/views/student_notice_superior.tpl'), $data['sessionId']);
             break;
         case ADVANCED_SUBSCRIPTION_ACTION_ADMIN_APPROVE:
             $fileAttachments = array();
             if (api_get_plugin_setting('courselegal', 'tool_enable')) {
                 $courseLegal = CourseLegalPlugin::create();
                 $courses = SessionManager::get_course_list_by_session_id($data['sessionId']);
                 $course = current($courses);
                 $data['courseId'] = $course['id'];
                 $data['course'] = api_get_course_info_by_id($data['courseId']);
                 $termsAndConditions = $courseLegal->getData($data['courseId'], $data['sessionId']);
                 $termsAndConditions = $termsAndConditions['content'];
                 $termsAndConditions = $this->renderTemplateString($termsAndConditions, $data);
                 $tpl = new Template(get_lang('TermsAndConditions'));
                 $tpl->assign('session', $data['session']);
                 $tpl->assign('student', $data['student']);
                 $tpl->assign('sessionId', $data['sessionId']);
                 $tpl->assign('termsContent', $termsAndConditions);
                 $termsAndConditions = $tpl->fetch('/advanced_subscription/views/terms_and_conditions_to_pdf.tpl');
                 $pdf = new PDF();
                 $filename = 'terms' . sha1(rand(0, 99999));
                 $pdf->content_to_pdf($termsAndConditions, null, $filename, null, 'F');
                 $fileAttachments['file'][] = array('name' => $filename . '.pdf', 'application/pdf' => $filename . '.pdf', 'tmp_name' => api_get_path(SYS_ARCHIVE_PATH) . $filename . '.pdf', 'error' => UPLOAD_ERR_OK, 'size' => filesize(api_get_path(SYS_ARCHIVE_PATH) . $filename . '.pdf'));
                 $fileAttachments['comments'][] = get_lang('TermsAndConditions');
             }
             // Mail to student
             $mailIds[] = $this->sendMailMessage($data['studentUserId'], $data['student']['user_id'], $this->get_lang('MailAdminAccept'), $template->fetch('/advanced_subscription/views/admin_accepted_notice_student.tpl'), $data['sessionId'], true, $fileAttachments);
             // Mail to superior
             $mailIds[] = $this->sendMailMessage($data['studentUserId'], $data['superior']['user_id'], $this->get_lang('MailAdminAccept'), $template->fetch('/advanced_subscription/views/admin_accepted_notice_superior.tpl'), $data['sessionId']);
             // Mail to admin
             $adminId = $data['currentUserId'];
             $template->assign('admin', $data['admins'][$adminId]);
             $mailIds['render'] = $this->sendMailMessage($data['studentUserId'], $adminId, $this->get_lang('MailAdminAccept'), $template->fetch('/advanced_subscription/views/admin_accepted_notice_admin.tpl'), $data['sessionId']);
             break;
         case ADVANCED_SUBSCRIPTION_ACTION_ADMIN_DISAPPROVE:
             // Mail to student
             $mailIds[] = $this->sendMailMessage($data['studentUserId'], $data['student']['user_id'], $this->get_lang('MailAdminReject'), $template->fetch('/advanced_subscription/views/admin_rejected_notice_student.tpl'), $data['sessionId'], true);
             // Mail to superior
             $mailIds[] = $this->sendMailMessage($data['studentUserId'], $data['superior']['user_id'], $this->get_lang('MailAdminReject'), $template->fetch('/advanced_subscription/views/admin_rejected_notice_superior.tpl'), $data['sessionId']);
             // Mail to admin
             $adminId = $data['currentUserId'];
             $template->assign('admin', $data['admins'][$adminId]);
             $mailIds['render'] = $this->sendMailMessage($data['studentUserId'], $adminId, $this->get_lang('MailAdminReject'), $template->fetch('/advanced_subscription/views/admin_rejected_notice_admin.tpl'), $data['sessionId']);
             break;
         case ADVANCED_SUBSCRIPTION_ACTION_STUDENT_REQUEST_NO_BOSS:
             // Mail to student
             $mailIds['render'] = $this->sendMailMessage($data['studentUserId'], $data['student']['user_id'], $this->get_lang('MailStudentRequestNoBoss'), $template->fetch('/advanced_subscription/views/student_no_superior_notice_student.tpl'), $data['sessionId'], true);
             // Mail to admin
             foreach ($data['admins'] as $adminId => $admin) {
                 $template->assign('admin', $admin);
                 $mailIds[] = $this->sendMailMessage($data['studentUserId'], $adminId, $this->get_lang('MailStudentRequestNoBoss'), $template->fetch('/advanced_subscription/views/student_no_superior_notice_admin.tpl'), $data['sessionId']);
             }
             break;
         case ADVANCED_SUBSCRIPTION_ACTION_REMINDER_STUDENT:
             $mailIds['render'] = $this->sendMailMessage($data['student']['user_id'], $data['student']['user_id'], $this->get_lang('MailRemindStudent'), $template->fetch('/advanced_subscription/views/reminder_notice_student.tpl'), $data['sessionId'], true);
             break;
         case ADVANCED_SUBSCRIPTION_ACTION_REMINDER_SUPERIOR:
             $mailIds['render'] = $this->sendMailMessage($data['students'], $data['superior']['user_id'], $this->get_lang('MailRemindSuperior'), $template->fetch('/advanced_subscription/views/reminder_notice_superior.tpl'), $data['sessionId']);
             break;
         case ADVANCED_SUBSCRIPTION_ACTION_REMINDER_SUPERIOR_MAX:
             $mailIds['render'] = $this->sendMailMessage($data['students'], $data['superior']['user_id'], $this->get_lang('MailRemindSuperior'), $template->fetch('/advanced_subscription/views/reminder_notice_superior_max.tpl'), $data['sessionId']);
             break;
         case ADVANCED_SUBSCRIPTION_ACTION_REMINDER_ADMIN:
             // Mail to admin
             foreach ($data['admins'] as $adminId => $admin) {
                 $template->assign('admin', $admin);
                 $mailIds[] = $this->sendMailMessage($data['students'], $adminId, $this->get_lang('MailRemindAdmin'), $template->fetch('/advanced_subscription/views/reminder_notice_admin.tpl'), $data['sessionId']);
             }
             break;
         default:
             break;
     }
     return $mailIds;
 }