コード例 #1
0
ファイル: legal.php プロジェクト: annickvdp/Chamilo1.9.10
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
// Language files that need to be included
$language_file = array('create_course', 'course_info', 'admin');
$cidReset = true;
require_once '../inc/global.inc.php';
$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);
    }
}
コード例 #2
0
ファイル: course.lib.php プロジェクト: feroli1000/chamilo-lms
 /**
  * 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);
     }
 }
コード例 #3
0
ファイル: index.php プロジェクト: omaoibrahim/chamilo-lms
 if (api_get_path(REL_PATH) !== $currentPage) {
     return null;
 }
 // Hide only if the before_login_accepted session was set to ON.
 if ($loginAccepted) {
     return null;
 }
 // Only available for the selected language.
 $languageToActivate = api_get_plugin_setting('before_login', 'language');
 if (api_get_interface_language() != $languageToActivate) {
     return null;
 }
 $option1 = api_get_plugin_setting('before_login', 'option1');
 $urlOption1 = api_get_plugin_setting('before_login', 'option1_url');
 $option2 = api_get_plugin_setting('before_login', 'option2');
 $urlOption2 = api_get_plugin_setting('before_login', 'option2_url');
 $form = new FormValidator('form');
 $renderer =& $form->defaultRenderer();
 $renderer->setFormTemplate('<form{attributes}><table border="0" cellpadding="5" cellspacing="0" width="100%">{content}</table></form>');
 $renderersetCustomElementTemplate->setCustomElementTemplate('<tr><td>{element}</td></tr>');
 $form->addElement('html', $option1);
 $form->addElement('checkbox', 'left', null, get_lang('Yes'));
 $form->addElement('button', 'submit', get_lang('Confirm'), array('class' => 'btn btn-primary'));
 $formHtml = $form->return_form();
 if ($form->validate()) {
     $result = $form->getSubmitValues();
     if (isset($result['left']) && $result['left']) {
         $_SESSION['before_login_accepted'] = 1;
         header('Location: ' . $urlOption1);
         exit;
     }
コード例 #4
0
ファイル: plugin.php プロジェクト: ragebat/chamilo-lms
$plugin_info['title'] = 'Show HTML before login';
// The comments that go with the plugin.
$plugin_info['comment'] = "Show a content before loading the login page.";
// The plugin version.
$plugin_info['version'] = '1.0';
// The plugin author.
$plugin_info['author'] = 'Julio Montoya';
// The plugin configuration.
$form = new FormValidator('form');
$form->addElement('select', 'language', get_lang('Language'), api_get_languages_to_array());
$form->addElement('header', 'Option 1');
$form->addElement('textarea', 'option1', get_lang('Description'), array('rows' => 10, 'class' => 'span6'));
$form->addElement('text', 'option1_url', get_lang('RedirectTo'));
$form->addElement('header', 'Option 2');
$form->addElement('textarea', 'option2', get_lang('Description'), array('rows' => 10, 'class' => 'span6'));
$form->addElement('text', 'option2_url', get_lang('RedirectTo'));
$form->addElement('button', 'submit_button', get_lang('Save'));
// Get default value for form
$defaults = array();
$defaults['language'] = api_get_plugin_setting('before_login', 'language');
$defaults['option1'] = api_get_plugin_setting('before_login', 'option1');
$defaults['option2'] = api_get_plugin_setting('before_login', 'option2');
$defaults['option1_url'] = api_get_plugin_setting('before_login', 'option1_url');
$defaults['option2_url'] = api_get_plugin_setting('before_login', 'option2_url');
$plugin_info['templates'] = array('template.tpl');
if (file_exists(__DIR__ . '/custom.template.tpl')) {
    $plugin_info['templates'] = array('custom.template.tpl');
}
$form->setDefaults($defaults);
// Display form
$plugin_info['settings_form'] = $form;
コード例 #5
0
 /**
  * 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;
 }