예제 #1
0
 $forum_user_stats = Database::get()->querySingle("SELECT COUNT(*) as c FROM forum_post \n                        INNER JOIN forum_topic ON forum_post.topic_id = forum_topic.id\n                        INNER JOIN forum ON forum.id = forum_topic.forum_id\n                        WHERE forum_post.poster_id = ?d AND forum.course_id = ?d", $uid, $course_id);
 Database::get()->query("DELETE FROM forum_user_stats WHERE user_id = ?d AND course_id = ?d", $uid, $course_id);
 Database::get()->query("INSERT INTO forum_user_stats (user_id, num_posts, course_id) VALUES (?d,?d,?d)", $uid, $forum_user_stats->c, $course_id);
 Database::get()->query("UPDATE forum_topic\n                    SET last_post_id = ?d\n                WHERE id = ?d\n                AND forum_id = ?d", $post_id, $topic_id, $forum_id);
 Database::get()->query("UPDATE forum\n                    SET num_topics = num_topics+1,\n                    num_posts = num_posts+1,\n                    last_post_id = ?d\n\t\tWHERE id = ?d", $post_id, $forum_id);
 $topic = $topic_id;
 $total_forum = get_total_topics($forum_id);
 $total_topic = get_total_posts($topic) - 1;
 // subtract 1 because we want the number of replies, not the number of posts.
 // --------------------------------
 // notify users
 // --------------------------------
 $subject_notify = "{$logo} - {$langNewForumNotify}";
 $category_id = forum_category($forum_id);
 $cat_name = category_name($category_id);
 $c = course_code_to_title($course_code);
 $name = uid_to_name($uid);
 $title = course_id_to_title($course_id);
 $forum_message = "-------- {$langBodyMessage} ({$langSender}: {$name})\n{$message}--------";
 $plain_forum_message = q(html2text($forum_message));
 $body_topic_notify = "{$langBodyForumNotify} {$langInForums} '" . q($forum_name) . "' \n                               {$langInCat} '" . q($cat_name) . "' {$langTo} {$langCourseS} '{$c}' <br /><br />" . q($forum_message) . "<br />\n                               <br />{$gunet}<br /><a href='{$urlServer}courses/{$course_code}'>{$urlServer}courses/{$course_code}</a>";
 $plain_body_topic_notify = "{$langBodyForumNotify} {$langInForums} '" . q($forum_name) . "' {$langInCat} '" . q($cat_name) . "' {$langTo} {$langCourseS} '{$c}' \n\n{$plain_forum_message} \n\n{$gunet}\n<a href='{$urlServer}courses/{$course_code}'>{$urlServer}courses/{$course_code}</a>";
 $linkhere = "&nbsp;<a href='{$urlServer}main/profile/emailunsubscribe.php?cid={$course_id}'>{$langHere}</a>.";
 $unsubscribe = "<br /><br />{$langNote}: " . sprintf($langLinkUnsubscribe, $title);
 $plain_body_topic_notify .= $unsubscribe . $linkhere;
 $body_topic_notify .= $unsubscribe . $linkhere;
 $sql = Database::get()->queryArray("SELECT DISTINCT user_id FROM forum_notify\n\t\t\tWHERE (forum_id = ?d OR cat_id = ?d)\n\t\t\tAND notify_sent = 1 AND course_id = ?d AND user_id != ?d", $forum_id, $category_id, $course_id, $uid);
 foreach ($sql as $r) {
     if (get_user_email_notification($r->user_id, $course_id)) {
         $emailaddr = uid_to_email($r->user_id);
         send_mail_multipart('', '', '', $emailaddr, $subject_notify, $plain_body_topic_notify, $body_topic_notify, $charset);
예제 #2
0
        $duration[$code] = $result->duration;
        $totalDuration += $duration[$code];
    }
    $chart = new Plotter(600, 300);
    $chart->setTitle($langCourseVisits);
    foreach ($hits as $code => $count) {
        if ($count > 0) {
            $chart->addPoint($course_names[$code], $count);
            $chart->modDimension(7, 0);
        }
    }
    $tool_content .= $chart->plot();
    $totalDuration = format_time_duration(0 + $totalDuration);
    $tool_content .= "<fieldset>\n                <legend>{$langPlatformGenStats}</legend>\n                <table class='table-default'>\n                <tr>\n                <th>{$langTotalVisitsCourses}:</th>\n                <td>{$totalHits}</td>\n                </tr>\n                <tr>\n                <th>{$langDurationVisits}:</th>\n                <td>{$totalDuration}</td>\n                </tr>\n                <tr>\n                <th valign='top'>{$langDurationVisitsPerCourse}:</th>\n                <td>\n                <table class='table-default' width='550'>\n                <tr>\n                <th>{$langCourseTitle}</th>                   \n                <th width='160'>{$langDuration}</th>\n                </tr>";
    foreach ($duration as $code => $time) {
        $tool_content .= "                \n                <td>" . q(course_code_to_title($code)) . "</td>\n                <td width='140'>" . format_time_duration(0 + $time) . "</td>\n                </tr>";
    }
    $tool_content .= "</table></td></tr>";
}
// End of chart display; chart unlinked at end of script.
$tool_content .= "<tr><th>{$langLastVisits}:</th><td>";
$tool_content .= "<table class='table-default' width='550'>\n            <tr>\n              <th>{$langDate}</th>\n              <th width='140'>{$langAction}</th>\n            </tr>";
$act["LOGIN"] = "******";
$act["LOGOUT"] = "<font color='#FF0000'>{$langLogout}</font>";
$q = Database::get()->queryArray("SELECT * FROM loginout\n                        WHERE id_user = ?d ORDER by idLog DESC LIMIT 10", $uid);
foreach ($q as $result) {
    $when = $result->when;
    $action = $result->action;
    $tool_content .= "        \n        <td>" . strftime("%d/%m/%Y (%H:%M:%S) ", strtotime($when)) . "</td>\n        <td>" . $act[$action] . "</td>\n        </tr>";
}
$tool_content .= "</table>";
예제 #3
0
function notify_users($forum_id, $forum_name, $topic_id, $subject, $message, $topic_date) {
    global $logo, $langNewForumNotify, $course_code, $course_code, $course_id, $langForumFrom,
        $uid, $langBodyForumNotify, $langInForums, $urlServer, $langdate, $langSender,
        $langCourse, $langCategory, $langForum, $langSubject, $langNote,
        $langLinkUnsubscribe, $langHere, $charset, $langMailBody;

    $subject_notify = "$logo - $langNewForumNotify";
    $category_id = forum_category($forum_id);
    $cat_name = category_name($category_id);
    $c = course_code_to_title($course_code);
    $name = uid_to_name($uid);
    $title = course_id_to_title($course_id);

    $header_html_topic_notify = "<!-- Header Section -->
    <div id='mail-header'>
        <br>
        <div>
            <div id='header-title'>$langBodyForumNotify <a href='{$urlServer}courses/$course_code'>".q($title)."</a>.</div>
            <ul id='forum-category'>
                <li><span><b>$langCategory:</b></span> <span>" . q($cat_name) . "</span></li>
                <li><span><b>$langForum:</b></span> <span><a href='{$urlServer}modules/forum/viewforum.php?course=$course_code&amp;forum=$forum_id'>" . q($forum_name) . "</a></span></li>
                <li><span><b>$langForumFrom :</b></span> <span>$name</span></li>
                <li><span><b>$langdate:</b></span> <span> $topic_date </span></li>
            </ul>
        </div>
    </div>";
    
    $body_html_topic_notify = "<!-- Body Section -->
    <div id='mail-body'>
        <br>
        <div><b>$langSubject:</b> <span class='left-space'><a href='{$urlServer}modules/forum/viewforum.php?course=$course_code&amp;forum=$forum_id&amp;topic=$topic_id'>" . q($subject) . "</a></span></div><br>
        <div><b>$langMailBody:</b></div>
        <div id='mail-body-inner'>
            $message
        </div>
    </div>";

    $footer_html_topic_notify = "<!-- Footer Section -->
    <div id='mail-footer'>
        <br>
        <div>
            <small>" . sprintf($langLinkUnsubscribe, q($title)) ." <a href='${urlServer}main/profile/emailunsubscribe.php?cid=$course_id'>$langHere</a></small>
        </div>
    </div>";

    $html_topic_notify = $header_html_topic_notify.$body_html_topic_notify.$footer_html_topic_notify;

    $plain_message = html2text($message);
    $plain_topic_notify = "$langBodyForumNotify $langInForums\n" .
       "$langSender: $name\n" .
       "$langCourse: $title\n    {$urlServer}courses/$course_code/\n" .
       "$langCategory: $cat_name\n" .
       "$langForum: $forum_name\n    {$urlServer}modules/forum/viewforum.php?course=$course_code&forum=$forum_id\n" . 
       "$langSubject: $subject\n    {$urlServer}modules/forum/viewforum.php?course=$course_code&forum=$forum_id&topic=$topic_id\n" . 
       "--------------------------------------------\n$plain_message\n" .
       "--------------------------------------------\n" .
       "$langNote: " . canonicalize_whitespace(str_replace('<br />', "\n", sprintf($langLinkUnsubscribe, q($title)))) .
       " $langHere:\n${urlServer}main/profile/emailunsubscribe.php?cid=$course_id\n";

    $users = Database::get()->queryArray("SELECT DISTINCT user_id FROM forum_notify
			WHERE (forum_id = ?d OR cat_id = ?d)
			AND notify_sent = 1 AND course_id = ?d AND user_id != ?d", $forum_id, $category_id, $course_id, $uid);
    $email = array();
    foreach ($users as $user) {
        if (get_user_email_notification($user->user_id, $course_id)) {
            $email[] = uid_to_email($user->user_id);
        }
    }
    send_mail_multipart('', '', '', $email, $subject_notify, $plain_topic_notify, $html_topic_notify, $charset);
}
예제 #4
0
                        </ul>
                    </div>
                </div>
                <div class='row margin-bottom-fat margin-top-fat'>
                  <div class='col-xs-12'>
                    <ul class='list-group'>
                      <li class='list-group-item disabled'>
                        <div class='row'>
                          <div class='col-sm-12'><b>$langDurationVisitsPerCourse</b></div>
                        </div>
                      </li>";
    foreach ($duration as $code => $time) {
        $tool_content .= "
                      <li class='list-group-item'>
                        <div class='row'>
                          <div class='col-sm-8'><b>" . q(course_code_to_title($code)) . "</b></div>
                          <div class='col-sm-4 text-muted'>" . format_time_duration(0 + $time, 240) . "</div>
                        </div>
                      </li>";
    }
    $tool_content .= "
                    </ul>
                  </div>
                </div>";
}

$tool_content .= "
                <div class='row margin-bottom-fat margin-top-fat'>
                  <div class='col-xs-12'>
                    <ul class='list-group'>
                      <li class='list-group-item disabled'>