Database::get()->query("UPDATE course_user SET receive_mail = 0\n WHERE user_id = ?d AND course_id = " . course_code_to_id($course_code), $uid); } } $tool_content .= "<div class='alert alert-success'>{$langWikiEditionSucceed}. <br /></div>" . action_bar(array(array('title' => $langBack, 'url' => "../profile/profile.php", 'icon' => 'fa-reply', 'level' => 'primary-label'))); } } else { $tool_content .= action_bar(array(array('title' => $langBack, 'url' => 'display_profile.php', 'icon' => 'fa-reply', 'level' => 'primary-label'))); $tool_content .= "<form action='{$_SERVER['SCRIPT_NAME']}' method='post'>"; if (get_config('email_verification_required') && get_config('dont_mail_unverified_mails')) { $user_email_status = get_mail_ver_status($uid); if ($user_email_status == EMAIL_VERIFICATION_REQUIRED or $user_email_status == EMAIL_UNVERIFIED) { $link = "<a href = '../auth/mail_verify_change.php?from_profile=TRUE'>{$langHere}</a>."; $tool_content .= "<div class='alert alert-warning'>{$langMailNotVerified} {$link}</div>"; } } if (!get_user_email_notification_from_courses($uid)) { $head_content .= '<script type="text/javascript">$(control_deactivate);</script>'; $tool_content .= "<div class='alert alert-info'>{$langEmailUnsubscribeWarning}</div>\n <input type='checkbox' id='unsub' name='unsub' value='1'> {$langEmailFromCourses}"; } $tool_content .= "<div class='alert alert-info'>{$langInfoUnsubscribe}</div>\n <div id='unsubscontrols'>"; if (isset($_POST['cid'])) { // one course only $cid = intval($_POST['cid']); $course_title = course_id_to_title($cid); $selected = get_user_email_notification($uid, $cid) ? 'checked' : ''; $tool_content .= "<input type='checkbox' name='c_unsub' value='1' {$selected}> " . q($course_title) . "<br />"; $tool_content .= "<input type='hidden' name='cid' value='{$cid}'>"; } else { // displays all courses foreach ($_SESSION['courses'] as $code => $status) { $title = course_code_to_title($code);
/** * @brief send emails to course prof * @global type $themeimg * @global type $langSendingMessage * @global type $langHeaderMessage * @global type $langContactIntro * @param type $course_id * @param type $content * @param type $from_name * @param type $from_address * @return type */ function email_profs($course_id, $content, $from_name, $from_address) { global $themeimg, $langSendingMessage, $langHeaderMessage, $langContactIntro; $q = Database::get()->querySingle("SELECT public_code FROM course WHERE id = ?d", $course_id); $public_code = $q->public_code; $ret = "<p>{$langSendingMessage}</p><br />"; $profs = Database::get()->queryArray("SELECT user.id AS prof_uid, user.email AS email,\n user.surname, user.givenname\n FROM course_user JOIN user ON user.id = course_user.user_id\n WHERE course_id = ?d AND course_user.status = " . USER_TEACHER . "", $course_id); $message = sprintf($langContactIntro, $from_name, $from_address, $content); $subject = "{$langHeaderMessage} ({$public_code} - {$GLOBALS['title']})"; foreach ($profs as $prof) { if (!get_user_email_notification_from_courses($prof->prof_uid) or !get_user_email_notification($prof->prof_uid, $course_id)) { continue; } else { $to_name = $prof->givenname . ' ' . $prof->surname; $ret .= "<p><img src='{$themeimg}/teacher.png'> {$to_name}</p><br>\n"; if (!send_mail($from_name, $from_address, $to_name, $prof->email, $subject, $message, $GLOBALS['charset'])) { $ret .= "<div class='alert alert-warning'>{$GLOBALS['langErrorSendingMessage']}</div>\n"; } } } return $ret; }
$level = ($levres = Database::get()->querySingle("SELECT level FROM course_review WHERE course_id = ?d", $course_id)) ? CourseXMLElement::getLevel($levres->level) : false; if (isset($level) && !empty($level)) { $metadataUrl = $urlServer . 'modules/course_metadata/info.php?course=' . $course_code; $opencourses_level = "\r\n <div class='row'>\r\n <div class='col-md-4'>\r\n <img src='{$themeimg}/open_courses_logo_small.png' title='" . $langOpenCourses . "' alt='" . $langOpenCourses . "' />\r\n </div>\r\n <div class='col-md-8 margin-top-thin'>\r\n {$langOpenCoursesLevel}: {$level}\r\n <br />\r\n <small><a href='{$metadataUrl}'>{$langCourseMetadata} " . icon('fa-tags', $langCourseMetadata, $metadataUrl) . "</small>\r\n </div>\r\n </div>\r\n\r\n\r\n <table class='tbl_courseid' width='200' style='display: none;'>\r\n <tr class='title1'>\r\n <td class='title1'></td>\r\n <td style='text-align: right; padding-right: 1.2em'><a href='{$metadataUrl}'>" . icon('fa-tags', $langCourseMetadata, $metadataUrl) . "</td>\r\n </tr>\r\n <tr>\r\n <td colspan='2'><div class='center'>" . icon('open_courses_logo_small', $langOpenCourses) . "</div>\r\n <div class='center'><b>{$langOpenCoursesLevel}: {$level}</b></div>\r\n </td>\r\n </tr>\r\n </table>"; } $emailnotification = ''; if ($uid and $status != USER_GUEST and !get_user_email_notification($uid, $course_id)) { $emailnotification = "<div class='alert alert-warning'>{$langNoUserEmailNotification}\r\n (<a href='{$urlServer}main/profile/emailunsubscribe.php?cid={$course_id}'>{$langModify}</a>)</div>"; } // display `contact teacher via email` link if teacher actually receives email from his course $receive_mail = FALSE; $rec_mail = array(); $q = Database::get()->queryArray("SELECT user_id FROM course_user WHERE course_id = ?d\r\n AND status = ?d", $course_id, USER_TEACHER); foreach ($q as $p) { $prof_uid = $p->user_id; if (get_user_email_notification_from_courses($prof_uid) and get_user_email_notification($prof_uid, $course_id)) { $rec_mail[$prof_uid] = 1; } } if (!empty($rec_mail)) { $receive_mail = TRUE; } // Contentbox: Course main contentbox //Temp commit (waiting for Alex to fix course description issue) if ($course_info->home_layout == 3) { $left_column = ''; $main_content_cols = ''; $horizontal_info_row = "<div class='col-xs-12'>\r\n <hr class='margin-top-fat margin-bottom-fat'>\r\n </div>\r\n <div class='col-xs-8'> \r\n {$bar_content}\r\n {$bar_content_2}\r\n </div>\r\n <div class='col-xs-4 text-center'> \r\n {$license_info_box}\r\n </div>"; } else { if (!empty($license_info_box)) { $license_holder = "<hr class='col-xs-12 margin-top-slim margin-bottom-fat'>\r\n <div class ='col-xs-12 text-center margin-top-fat'>\r\n {$license_info_box}\r\n </div>\r\n <hr class='col-xs-12 margin-top-fat margin-bottom-fat visible-xs-block'>";
/** * @brief checks if user is notified via email from a given course * @param type $user_id * @param type $course_id * @return boolean */ function get_user_email_notification($user_id, $course_id = null) { // checks if a course is active or not if (isset($course_id)) { if (course_status($course_id) == COURSE_INACTIVE) { return false; } } // checks if user has verified his email address if (get_config('email_verification_required') && get_config('dont_mail_unverified_mails')) { $verified_mail = get_mail_ver_status($user_id); if ($verified_mail == EMAIL_VERIFICATION_REQUIRED or $verified_mail == EMAIL_UNVERIFIED) { return false; } } // checks if user has choosen not to be notified by email from all courses if (!get_user_email_notification_from_courses($user_id)) { return false; } if (isset($course_id)) { // finally checks if user has choosen not to be notified from a specific course $r = Database::get()->querySingle("SELECT receive_mail FROM course_user\n WHERE user_id = ?d\n AND course_id = ?d", $user_id, $course_id); if ($r) { $row = $r->receive_mail; return $row; } else { return false; } } return true; }
/** * @brief send emails to course prof * @global type $langSendingMessage * @global type $langHeaderMessage * @global type $langContactIntro * @param type $course_id * @param type $content * @param type $from_name * @param type $from_address * @return type */ function email_profs($course_id, $content, $from_name, $from_address) { global $langSendingMessage, $langHeaderMessage, $langContactIntro; $title = course_id_to_title($course_id); $ret = "<div class='alert alert-info'>$langSendingMessage $title</div>"; $public_code = course_id_to_public_code($course_id); $profs = Database::get()->queryArray("SELECT user.id AS prof_uid, user.email AS email, user.surname, user.givenname FROM course_user JOIN user ON user.id = course_user.user_id WHERE course_id = ?d AND course_user.status = " . USER_TEACHER . "", $course_id); $message = sprintf($langContactIntro, $from_name, $from_address, $content); $subject = "$langHeaderMessage ($public_code - $title)"; foreach ($profs as $prof) { if (!get_user_email_notification_from_courses($prof->prof_uid) or (!get_user_email_notification($prof->prof_uid, $course_id))) { continue; } else { $to_name = $prof->givenname . ' ' . $prof->surname; $ret .= "<div class='alert alert-success'>" . icon('fa-university') . " " . q($to_name) . "</div>"; if (!send_mail($from_name, $from_address, $to_name, $prof->email, $subject, $message, $GLOBALS['charset'])) { $ret .= "<div class='alert alert-warning'>$GLOBALS[langErrorSendingMessage]</div>"; } } } return $ret; }