/** * Legg til forumtråd * @param \Kofradia\Forum\Category $forum * @param array $data (ft_id, ft_title, ft_type) */ public static function add_topic_added(Category $forum, $data) { // finn ut hvor loggen skal plasseres $location = "INFO"; // crewforum, crewforum arkiv eller idémyldringsforumet if ($forum->id >= 5 && $forum->id <= 7) { $location = "CREWCHAN"; // legg til hendelse i spilleloggen $type = $forum->id == 5 ? 'crewforum_emne' : ($forum->id == 6 ? 'crewforuma_emne' : 'crewforumi_emne'); $access_levels = implode(",", \ess::$g['access']['crewet']); \Kofradia\DB::get()->exec("INSERT INTO users_log SET time = " . time() . ", ul_up_id = 0, type = " . intval(\gamelog::$items[$type]) . ", note = " . \Kofradia\DB::quote(\login::$user->player->id . ":" . $data['ft_title']) . ", num = {$data['ft_id']}"); \Kofradia\DB::get()->exec("UPDATE users SET u_log_crew_new = u_log_crew_new + 1 WHERE u_access_level IN ({$access_levels}) AND (u_id != " . \login::$user->id . " OR u_log_crew_new > 0)"); // send e-post til crewet $email = new email(); $email->text = "*{$data['ft_title']}* ble opprettet av " . \login::$user->player->data['up_name'] . "\r\n" . \ess::$s['path'] . "/forum/topic?id={$data['ft_id']}\r\n\r\nForum: " . $forum->get_name() . "\r\nAutomatisk melding for Kofradia Crewet"; $result = \Kofradia\DB::get()->query("SELECT u_email FROM users WHERE u_access_level IN ({$access_levels}) AND u_id != " . \login::$user->id); while ($row = $result->fetch()) { $email->send($row['u_email'], \login::$user->player->data['up_name'] . " opprettet {$data['ft_title']} -- " . $forum->get_name() . ""); } } elseif ($forum->id == 4) { $location = ""; // legg til hendelse i spilleloggen $type = $forum->id == 4 ? 'crewforume_emne' : 'crewforum_emne'; $access_levels = implode(",", \ess::$g['access']['seniormod']); \Kofradia\DB::get()->exec("INSERT INTO users_log SET time = " . time() . ", ul_up_id = 0, type = " . intval(\gamelog::$items[$type]) . ", note = " . \Kofradia\DB::quote(\login::$user->player->id . ":" . $data['ft_title']) . ", num = {$data['ft_id']}"); \Kofradia\DB::get()->exec("UPDATE users SET u_log_crew_new = u_log_crew_new + 1 WHERE u_access_level IN ({$access_levels}) AND (u_id != " . \login::$user->id . " OR u_log_crew_new > 0)"); // send e-post til crewet $email = new email(); $email->text = "*{$data['ft_title']}* ble opprettet av " . \login::$user->player->data['up_name'] . "\r\n" . \ess::$s['path'] . "/forum/topic?id={$data['ft_id']}\r\n\r\nForum: " . $forum->get_name() . "\r\nAutomatisk melding for Kofradia Crewet"; $result = \Kofradia\DB::get()->query("SELECT u_email FROM users WHERE u_access_level IN ({$access_levels}) AND u_id != " . \login::$user->id); while ($row = $result->fetch()) { $email->send($row['u_email'], \login::$user->player->data['up_name'] . " opprettet {$data['ft_title']} -- " . $forum->get_name() . ""); } } elseif (!$forum->ff) { // live-feed \livefeed::add_row('<user id="' . \login::$user->player->id . '" /> opprettet <a href="' . \ess::$s['relative_path'] . '/forum/topic?id=' . $data['ft_id'] . '">' . htmlspecialchars($data['ft_title']) . '</a> i ' . htmlspecialchars($forum->get_name()) . '.'); } // legg til som logg self::putlog($forum, $location, "FORUMTRÅD: (" . $forum->get_name() . ") '" . \login::$user->player->data['up_name'] . "' opprettet '{$data['ft_title']}' " . \ess::$s['path'] . "/forum/topic?id={$data['ft_id']}"); }
/** * @param Category $catobj * @param $showtree * @param $selectcat * @param $is_course_admin * @param $is_platform_admin * @param $simple_search_form * @param bool $show_add_qualification * @param bool $show_add_link */ public function display_header_gradebook_per_gradebook($catobj, $showtree, $selectcat, $is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true) { // Student $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); $objcat = new Category(); $course_id = Database::get_course_by_category($selectcat); $message_resource = $objcat->show_message_resource_delete($course_id); if (!$is_course_admin && $status != 1 && $selectcat != 0) { $user_id = api_get_user_id(); $user = get_user_info_from_id($user_id); $catcourse = Category::load($catobj->get_id()); $scoredisplay = ScoreDisplay::instance(); $scorecourse = $catcourse[0]->calc_score($user_id); // generating the total score for a course $allevals = $catcourse[0]->get_evaluations($user_id, true); $alllinks = $catcourse[0]->get_links($user_id, true); $evals_links = array_merge($allevals, $alllinks); $item_value = 0; $item_total = 0; for ($count = 0; $count < count($evals_links); $count++) { $item = $evals_links[$count]; $score = $item->calc_score($user_id); $my_score_denom = $score[1] == 0 ? 1 : $score[1]; $item_value += $score[0] / $my_score_denom * $item->get_weight(); $item_total += $item->get_weight(); } $item_value = number_format($item_value, 2, '.', ' '); $total_score = array($item_value, $item_total); $scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT); $cattotal = Category::load(0); $scoretotal = $cattotal[0]->calc_score(api_get_user_id()); $scoretotal_display = isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable'); $scoreinfo = get_lang('StatsStudent') . ' :<b> ' . api_get_person_name($user['firstname'], $user['lastname']) . '</b><br />'; if (!$catobj->get_id() == '0' && !isset($_GET['studentoverview']) && !isset($_GET['search'])) { $scoreinfo .= '<h2>' . get_lang('Total') . ' : ' . $scorecourse_display . '</h2>'; } Display::display_normal_message($scoreinfo, false); } // show navigation tree and buttons? $header = '<div class="actions"><table border=0>'; if ($showtree == '1' || isset($_GET['studentoverview'])) { $header .= '<tr>'; if (!$selectcat == '0') { $header .= '<td style=" "><a href="' . api_get_self() . '?selectcat=' . $catobj->get_parent_id() . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('RootCat'), '', ICON_SIZE_MEDIUM) . '</a></td>'; } $header .= '<td style=" ">' . get_lang('CurrentCategory') . '</td>' . '<td style=" "><form name="selector"><select name="selectcat" onchange="document.selector.submit()">'; $cats = Category::load(); $tree = $cats[0]->get_tree(); unset($cats); foreach ($tree as $cat) { for ($i = 0; $i < $cat[2]; $i++) { $line .= '—'; } $line = isset($line) ? $line : ''; if (isset($_GET['selectcat']) && $_GET['selectcat'] == $cat[0]) { $header .= '<option selected value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>'; } else { $header .= '<option value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>'; } $line = ''; } $header .= '</select></form></td>'; if (!empty($simple_search_form) && $message_resource === false) { $header .= '<td style="vertical-align: top;">' . $simple_search_form->toHtml() . '</td>'; } else { $header .= '<td></td>'; } if ($is_course_admin && $message_resource === false && $_GET['selectcat'] != 0) { /* $header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '"><img src="../img/view_list.gif" alt="' . get_lang('FlatView') . '" /> ' . get_lang('FlatView') . '</a>'; if ($is_course_admin && $message_resource===false) { $header .= '<td style="vertical-align: top;"><a href="gradebook_scoring_system.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() .'"><img src="../img/acces_tool.gif" alt="' . get_lang('ScoreEdit') . '" /> ' . get_lang('ScoreEdit') . '</a>'; } */ } elseif (!isset($_GET['studentoverview'])) { if ($message_resource === false) { //$header .= '<td style="vertical-align: top;"><a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&selectcat=' . $catobj->get_id() . '"><img src="../img/view_list.gif" alt="' . get_lang('FlatView') . '" /> ' . get_lang('FlatView') . '</a>'; } } else { $header .= '<td style="vertical-align: top;"><a href="' . api_get_self() . '?' . api_get_cidreq() . '&studentoverview=&exportpdf=&selectcat=' . $catobj->get_id() . '" target="_blank"><img src="../img/icons/32/pdf.png" alt="' . get_lang('ExportPDF') . '" /> ' . get_lang('ExportPDF') . '</a>'; } $header .= '</td></tr>'; } $header .= '</table></div>'; // for course admin & platform admin add item buttons are added to the header $header .= '<div class="actions">'; $my_category = $catobj->shows_all_information_an_category($catobj->get_id()); $user_id = api_get_user_id(); $course_code = $my_category['course_code']; $status_user = api_get_status_of_user_in_course($user_id, $course_code); //$header .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat=0"><img src="../img/folder_new.gif" alt="' . get_lang('AddGradebook') . '" /></a></td>'; if (api_is_allowed_to_edit(null, true)) { if ($selectcat == '0') { if ($show_add_qualification === true) { } if ($show_add_link) { //$header .= '<td><a href="gradebook_add_eval.php?'.api_get_cidreq().'"><img src="../img/filenew.gif" alt="' . get_lang('NewEvaluation') . '" /> ' . get_lang('NewEvaluation') . '</a>'; } } else { if ($show_add_qualification === true && $message_resource === false) { //$header .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '" ><img src="../img/folder_new.gif" alt="' . get_lang('NewSubCategory') . '" align="absmiddle" /> ' . get_lang('NewSubCategory') . '</a></td>'; } $my_category = $catobj->shows_all_information_an_category($catobj->get_id()); $my_api_cidreq = api_get_cidreq(); if ($my_api_cidreq == '') { $my_api_cidreq = 'cidReq=' . $my_category['course_code']; } if ($show_add_link && !$message_resource) { //$header .= '<td><a href="gradebook_add_eval.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '" >'.Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'),'',ICON_SIZE_MEDIUM).'</a>'; $cats = Category::load($selectcat); if ($cats[0]->get_course_code() != null && !$message_resource) { //$header .= '<td><a href="gradebook_add_link.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '"><img src="../img/link.gif" alt="' . get_lang('MakeLink') . '" align="absmiddle" /> ' . get_lang('MakeLink') . '</a>'; //$header .= '<td><a href="gradebook_add_link.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'),'',ICON_SIZE_MEDIUM).'</a>'; } else { // $header .= '<td><a href="gradebook_add_link_select_course.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'),'',ICON_SIZE_MEDIUM).'</a>'; } } if (!$message_resource) { $myname = $catobj->shows_all_information_an_category($catobj->get_id()); $my_course_id = api_get_course_id(); $my_file = substr($_SESSION['gradebook_dest'], 0, 5); $header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>'; $header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?' . $my_api_cidreq . '&cat_id=' . (int) $_GET['selectcat'] . '">' . Display::return_icon('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'), '', ICON_SIZE_MEDIUM) . '</a>'; $visibility_icon = $catobj->is_visible() == 0 ? 'invisible' : 'visible'; $visibility_command = $catobj->is_visible() == 0 ? 'set_visible' : 'set_invisible'; //Right icons $modify_icons = '<a href="gradebook_edit_cat.php?editcat=' . $catobj->get_id() . '&cidReq=' . $catobj->get_course_code() . '&id_session=' . $catobj->get_session_id() . '">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM) . '</a>'; //$modify_icons .= '<a href="../document/document.php?curdirpath=/certificates&'.$my_api_cidreq.'&origin=gradebook&selectcat=' . $catobj->get_id() . '">'. //Display::return_icon('certificate.png', get_lang('AttachCertificate'),'',ICON_SIZE_MEDIUM).'</a>'; //hide or delete are not options available //$modify_icons .= ' <a href="' . api_get_self() . '?visiblecat=' . $catobj->get_id() . '&' . $visibility_command . '=&selectcat=0 ">'.Display::return_icon($visibility_icon.'.png', get_lang('Visible'),'',ICON_SIZE_MEDIUM).'</a>'; if ($catobj->get_name() != api_get_course_id()) { $modify_icons .= ' <a href="' . api_get_self() . '?deletecat=' . $catobj->get_id() . '&selectcat=0&cidReq=' . $catobj->get_course_code() . '" onclick="return confirmation();">' . Display::return_icon('delete.png', get_lang('DeleteAll'), '', ICON_SIZE_MEDIUM) . '</a>'; } $header .= Display::div($modify_icons, array('class' => 'right')); } } } elseif (isset($_GET['search'])) { $header .= '<b>' . get_lang('SearchResults') . ' :</b>'; } $header .= '</div>'; echo $header; }