$name = api_get_person_name($last_post_row['firstname'], $last_post_row['lastname']); $last_post_info_username = sprintf(get_lang('LoginX'), $last_post_row['username']); $last_post = api_convert_and_format_date($last_post_row['post_date']).' '.get_lang('By').' '.display_user_link($last_post_row['poster_id'], $name, '', $last_post_info_username); } else { $last_post_sql = "SELECT post.*, user.firstname, user.lastname, user.username FROM $table_posts post, $table_users user WHERE post.poster_id=user.user_id AND visible='1' AND thread_id='".$row['thread_id']."' AND post.c_id=".api_get_course_int_id()." ORDER BY post_id DESC"; $last_post_result = Database::query($last_post_sql); $last_post_row = Database::fetch_array($last_post_result); $last_post_info_username = sprintf(get_lang('LoginX'), $last_post_row['username']); $name = api_get_person_name($last_post_row['firstname'], $last_post_row['lastname']); $last_post = api_convert_and_format_date($last_post_row['post_date']).' '.get_lang('By').' '.Display::tag('span', $name, array("title"=>api_htmlentities($last_post_info_username, ENT_QUOTES))); }*/ echo '<td>' . $last_post . '</td>'; echo '<td class="td_actions">'; // Get attachment id. if (isset($row['post_id'])) { $attachment_list = get_attachment($row['post_id']); } $id_attach = !empty($attachment_list) ? $attachment_list['id'] : ''; $sql_post_id = "SELECT post_id FROM {$table_posts} WHERE c_id = {$course_id} AND post_title='" . Database::escape_string($row['thread_title']) . "'"; $result_post_id = Database::query($sql_post_id); $row_post_id = Database::fetch_array($result_post_id); if ($origin != 'learnpath') { if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) { echo '<a href="' . $forumUrl . 'editpost.php?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&thread=' . Security::remove_XSS($row['thread_id']) . '&post=' . $row_post_id['post_id'] . '&id_attach=' . $id_attach . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>'; if (api_resource_is_locked_by_gradebook($row['thread_id'], LINK_FORUM_THREAD)) { echo Display::return_icon('delete_na.png', get_lang('ResourceLockedByGradebook'), array(), ICON_SIZE_SMALL); } else { echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&action=delete&content=thread&id=' . $row['thread_id'] . $origin_string . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeleteCompleteThread'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; } display_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => $groupId)); display_lock_unlock_icon('thread', $row['thread_id'], $row['locked'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => api_get_group_id()));
/** * 附件信息 * * @param string $key * @return array */ function dr_file_info($key) { if (!$key) { return NULL; } if (is_numeric($key)) { $info = get_attachment($key); if (!$info) { return NULL; } if (in_array($info['fileext'], array('jpg', 'gif', 'png'))) { $info['icon'] = SITE_URL . 'dayrui/statics/images/ext/jpg.gif'; } else { $info['icon'] = is_file(FCPATH . 'dayrui/statics/images/ext/' . $info['fileext'] . '.gif') ? SITE_URL . 'dayrui/statics/images/ext/' . $info['fileext'] . '.gif' : SITE_URL . 'dayrui/statics/images/ext/blank.gif'; } $info['size'] = dr_format_file_size($info['filesize']); return $info; } else { return array('icon' => SITE_URL . 'dayrui/statics/images/ext/url.gif', 'size' => ''); } }
/** * 文件真实地址 * * @param string $id * @return array */ function dr_get_file($id) { if (!$id) { return ''; } if (is_numeric($id)) { // 表示附件id $info = get_attachment($id); $id = $info['attachment'] ? $info['attachment'] : ''; } $file = dr_file($id); return $file ? $file : ''; }
/** * @param int $start * @param int $end * @param array $course_info * @param int $group_id * @param int $session_id * @param int $user_id * @return array */ public function get_course_events($start, $end, $course_info, $group_id = 0, $session_id = 0, $user_id = 0) { $course_id = $course_info['real_id']; $user_id = intval($user_id); $group_list = GroupManager::get_group_list(null, $course_info['code']); $group_name_list = array(); if (!empty($group_list)) { foreach ($group_list as $group) { $group_name_list[$group['id']] = $group['name']; } } if (!api_is_allowed_to_edit()) { $group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id()); $user_id = api_get_user_id(); } else { $group_memberships = array_keys($group_name_list); } $tlb_course_agenda = Database::get_course_table(TABLE_AGENDA); $tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY); if (!empty($group_id)) { $group_memberships = array($group_id); } $session_id = intval($session_id); if (is_array($group_memberships) && count($group_memberships) > 0) { if (api_is_allowed_to_edit()) { if (!empty($user_id)) { $where_condition = "( ip.to_user_id = {$user_id} AND ip.to_group_id is null OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ") ) "; } else { $where_condition = "( ip.to_group_id is null OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ") ) "; } } else { $where_condition = "( ip.to_user_id = {$user_id} OR ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ") ) "; } $sql = "SELECT DISTINCT\n agenda.*,\n ip.visibility,\n ip.to_group_id,\n ip.insert_user_id,\n ip.ref,\n to_user_id\n FROM " . $tlb_course_agenda . " agenda, " . $tbl_property . " ip\n WHERE agenda.id = ip.ref AND\n ip.tool ='" . TOOL_CALENDAR_EVENT . "' AND\n {$where_condition} AND\n ip.visibility = '1' AND\n agenda.c_id = {$course_id} AND\n ip.c_id = {$course_id}\n GROUP BY id"; } else { if (api_is_allowed_to_edit()) { $where_condition = ""; } else { $where_condition = "( ip.to_user_id={$user_id} OR ip.to_group_id='0') AND "; } $sql = "SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref, to_user_id\n FROM " . $tlb_course_agenda . " agenda, " . $tbl_property . " ip\n WHERE agenda.id = ip.ref AND\n ip.tool='" . TOOL_CALENDAR_EVENT . "' AND\n {$where_condition}\n ip.visibility='1' AND\n agenda.c_id = {$course_id} AND\n ip.c_id = {$course_id} AND\n agenda.session_id = {$session_id} AND\n ip.id_session = {$session_id}\n "; } $result = Database::query($sql); $events = array(); if (Database::num_rows($result)) { $events_added = array(); while ($row = Database::fetch_array($result, 'ASSOC')) { //to gather sent_tos $sql = "SELECT to_user_id, to_group_id\n FROM " . $tbl_property . " ip\n WHERE ip.tool = '" . TOOL_CALENDAR_EVENT . "' AND\n ref = {$row['ref']} AND\n ip.visibility = '1' AND\n ip.c_id = {$course_id}"; $sent_to_result = Database::query($sql); $user_to_array = array(); $group_to_array = array(); while ($row_send_to = Database::fetch_array($sent_to_result, 'ASSOC')) { if (!empty($row_send_to['to_group_id'])) { $group_to_array[] = $row_send_to['to_group_id']; } if (!empty($row_send_to['to_user_id'])) { $user_to_array[] = $row_send_to['to_user_id']; } } //Only show events from the session /*if (api_get_course_int_id()) { if ($row['session_id'] != api_get_session_id()) { continue; } }*/ $event = array(); $event['id'] = 'course_' . $row['id']; //To avoid doubles if (in_array($row['id'], $events_added)) { continue; } $events_added[] = $row['id']; $attachment = get_attachment($row['id'], $course_id); $has_attachment = ''; if (!empty($attachment)) { $has_attachment = Display::return_icon('attachment.gif', get_lang('Attachment')); $user_filename = $attachment['filename']; $full_file_name = 'download.php?file=' . $attachment['path'] . '&course_id=' . $course_id; $event['attachment'] = $has_attachment . Display::url($user_filename, $full_file_name); } else { $event['attachment'] = ''; } $event['title'] = $row['title']; $event['className'] = 'course'; $event['allDay'] = 'false'; $event['course_id'] = $course_id; $event['borderColor'] = $event['backgroundColor'] = $this->event_course_color; if (isset($row['session_id']) && !empty($row['session_id'])) { $event['borderColor'] = $event['backgroundColor'] = $this->event_session_color; } if (isset($row['to_group_id']) && !empty($row['to_group_id'])) { $event['borderColor'] = $event['backgroundColor'] = $this->event_group_color; } $event['editable'] = false; if (api_is_allowed_to_edit() && $this->type == 'course') { $event['editable'] = true; } if (!empty($row['start_date']) && $row['start_date'] != '0000-00-00 00:00:00') { $event['start'] = $this->format_event_date($row['start_date']); } if (!empty($row['end_date']) && $row['end_date'] != '0000-00-00 00:00:00') { $event['end'] = $this->format_event_date($row['end_date']); } $event['sent_to'] = ''; //$event['type'] = $this->type; $event['type'] = 'course'; if ($row['session_id'] != 0) { $event['type'] = 'session'; } //Event Sent to a group? if (isset($row['to_group_id']) && !empty($row['to_group_id'])) { $sent_to = array(); if (!empty($group_to_array)) { foreach ($group_to_array as $group_item) { $sent_to[] = $group_name_list[$group_item]; } } $sent_to = implode('@@', $sent_to); $sent_to = str_replace('@@', '</div><div class="label_tag notice">', $sent_to); $event['sent_to'] = '<div class="label_tag notice">' . $sent_to . '</div>'; $event['type'] = 'group'; } //Event sent to a user? if (isset($row['to_user_id'])) { $sent_to = array(); if (!empty($user_to_array)) { foreach ($user_to_array as $item) { $user_info = api_get_user_info($item); // add username as tooltip for $event['sent_to'] - ref #4226 $username = api_htmlentities(sprintf(get_lang('LoginX'), $user_info['username']), ENT_QUOTES); $sent_to[] = "<span title='" . $username . "'>" . $user_info['complete_name'] . "</span>"; } } $sent_to = implode('@@', $sent_to); $sent_to = str_replace('@@', '</div><div class="label_tag notice">', $sent_to); $event['sent_to'] = '<div class="label_tag notice">' . $sent_to . '</div>'; } //Event sent to everyone! if (empty($event['sent_to'])) { $event['sent_to'] = '<div class="label_tag notice">' . get_lang('Everyone') . '</div>'; } $event['description'] = $row['content']; $event['allDay'] = isset($row['all_day']) && $row['all_day'] == 1 ? $row['all_day'] : 0; $this->events[] = $event; } } return $this->events; }
$rm_folder = WW_ROOT . '/ww_files/attachments/' . $_GET['ext'] . '/'; rmdir($rm_folder); header('Location: ' . WW_WEB_ROOT . '/ww_edit/index.php?page_name=attachments'); } } // process our params and get main content $attachment_id = isset($_GET['attachment_id']) ? (int) $_GET['attachment_id'] : 0; if (isset($_GET['filename'])) { $filepath = WW_ROOT . '/ww_files/attachments/' . $_GET['filename'] . '/' . $_GET['filename']; if (file_exists($filepath)) { $filename = $_GET['filename']; } } // a single attachment if (!empty($attachment_id)) { $attachment = get_attachment($attachment_id); // file usage $usage = attachment_usage($attachment_id); // default to list if requested attachment not found if (empty($attachment)) { $attachments = get_attachments(); } } elseif (isset($_GET['filename'])) { // this is a rogue file $rogue_path = WW_ROOT . '/ww_files/attachments/' . $_GET['ext'] . '/' . $_GET['filename']; $attachment = get_file_details($rogue_path); $attachment['src'] = WW_WEB_ROOT . '/ww_files/attachments/' . $_GET['ext'] . '/' . $_GET['filename']; // file usage $usage = attachment_usage($attachment_id); } else { // if no single attachment is found/requested we return a list
/** * 下载文件 */ public function file() { $id = (int) $this->input->get('id'); $info = get_attachment($id); $this->template->admin(); if (!$info) { $this->admin_msg(lang('m-326')); } // 是否允许下载附件 if (!$this->member['adminid'] && !$this->member_rule['is_download']) { $this->admin_msg(lang('m-322')); } // 虚拟币与经验值检查 $mark = 'attachment-' . $id; $table = $this->db->dbprefix('member_scorelog_' . (int) substr((string) $this->uid, -1, 1)); if ($this->member_rule['download_score'] && !$this->db->where('type', 1)->where('mark', $mark)->count_all_results($table)) { // 虚拟币不足时,提示错误 if ($this->member_rule['download_score'] + $this->member['score'] < 0) { $this->admin_msg(dr_lang('m-324', SITE_SCORE, abs($this->member_rule['download_score']))); } // 虚拟币扣减 $this->member_model->update_score(1, $this->uid, (int) $this->member_rule['download_score'], $mark, "lang,m-325"); } if ($this->member_rule['download_experience'] && !$this->db->where('type', 0)->where('mark', $mark)->count_all_results($table)) { // 经验值扣减 $this->member_model->update_score(0, $this->uid, (int) $this->member_rule['download_experience'], $mark, "lang,m-325"); } $file = $info['attachment']; $this->db->where('id', $id)->set('download', 'download+1', FALSE)->update('attachment'); if (strpos($file, ':/')) { //远程文件 header("Location: {$file}"); } else { //本地文件 $file = FCPATH . str_replace('..', '', $file); $name = urlencode($info['filename'] . '.' . $info['fileext']); $this->load->helper('download'); force_download($name, file_get_contents($file)); } }
/** * 字段入库值 */ public function insert_value($field) { $data = $this->ci->post[$field['fieldname']]; // 第一张作为缩略图 if (isset($_POST['data']['thumb']) && !$_POST['data']['thumb'] && isset($data['file'][0]) && $data['file'][0]) { $info = get_attachment($data['file'][0]); if (in_array($info['fileext'], array('jpg', 'png', 'gif'))) { $this->ci->data[1]['thumb'] = $data['file'][0]; } unset($info); } $this->ci->data[$field['ismain']][$field['fieldname']] = dr_array2string($data); }
$post_image = Display::return_icon('forumpostnew.gif'); } else { $post_image = Display::return_icon('forumpost.gif'); } if ($post['post_notification'] == '1' and $post['poster_id'] == $_user['user_id']) { $post_image .= Display::return_icon('forumnotification.gif', get_lang('YouWillBeNotified')); } // The post title echo "<td class=\"{$titleclass}\">" . prepare4display($post['post_title']) . "</td>"; echo "</tr>"; // The post message echo "<tr>"; echo "<td class=\"{$messageclass}\">" . prepare4display($post['post_text']) . "</td>"; echo "</tr>"; // The check if there is an attachment $attachment_list = get_attachment($post['post_id']); if (!empty($attachment_list)) { echo '<tr><td height="50%">'; $realname = $attachment_list['path']; $user_filename = $attachment_list['filename']; echo Display::return_icon('attachment.gif', get_lang('Attachment')); echo '<a href="download.php?file='; echo $realname; echo ' "> ' . $user_filename . ' </a>'; echo '<span class="forum_attach_comment" >' . $attachment_list['comment'] . '</span>'; if ($current_forum['allow_edit'] == 1 and $post['user_id'] == $_user['user_id'] or api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) { echo ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&origin=' . Security::remove_XSS($_GET['origin']) . '&action=delete_attach&id_attach=' . $attachment_list['id'] . '&forum=' . $clean_forum_id . '&thread=' . $clean_thread_id . '" onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . '\')) return false;">' . Display::return_icon('delete.gif', get_lang('Delete')) . '</a><br />'; } echo '</td></tr>'; } // The post has been displayed => it can be removed from the what's new array
/** * serve attachment() * * serves an attachment and updates counter * * @param int/string $url2 if only url2 is provided this should be the database id of the file * @param string $url3 if provided this should be the filename * */ function serve_attachment($id) { // database connection $conn = author_connect(); // validate id $id = (int) $id; if (empty($id)) { return; } // get attachment details $file = get_attachment($id); // update counter $query = "UPDATE attachments \n\t\t\t\t\t\tSET downloads = downloads+1 \n\t\t\t\t\t\tWHERE id = " . $id; $conn->query($query); // serve attachment $file_to_download = WW_ROOT . "/ww_files/attachments/" . $file['ext'] . "/" . $file['filename']; header('Content-Type: ' . $file['mime'] . ''); header('Content-Disposition: attachment; filename=' . $file['filename'] . ''); // update download counter readfile($file_to_download); $result->close(); return; }
$count = 1; $class = ''; foreach ($entries as $entry) { $class = $count % 2 == 0 ? ' class="alternate"' : ''; ?> <tr <?php echo $class; ?> > <td><?php echo esc_html($entry->name); ?> </td> <td><?php echo get_attachment($entry->id); ?> </td> <td><?php echo $entry->send_count; ?> </td> <td><?php echo get_remaining_count($entry->list_id, $entry->last_send_mapping_id, $entry->join_after_campaign_started, $entry->start_time); ?> </td> <td><?php $starttime = $entry->start_time; if ($starttime != "Never") { echo xyz_local_date_time("F j, Y, g:i a", $starttime); } else {
echo "<table width=\"100%\" class=\"forum_table\" cellspacing=\"5\" border=\"0\">"; echo "<tr>"; echo "<td rowspan=\"3\" class=\"{$leftclass}\">"; $username = sprintf(get_lang('LoginX'), $rows[$display_post_id]['username']); if ($rows[$display_post_id]['user_id'] == '0') { $name = prepare4display($rows[$display_post_id]['poster_name']); } else { $name = api_get_person_name($rows[$display_post_id]['firstname'], $rows[$display_post_id]['lastname']); } if (api_get_course_setting('allow_user_image_forum')) { echo '<br />' . display_user_image($rows[$display_post_id]['user_id'], $name, $origin) . '<br />'; } echo display_user_link($rows[$display_post_id]['user_id'], $name, $origin, $username) . "<br />"; echo api_convert_and_format_date($rows[$display_post_id]['post_date']) . '<br /><br />'; // Get attach id $attachment_list = get_attachment($display_post_id); $id_attach = !empty($attachment_list) ? $attachment_list['id'] : ''; // The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum // The course admin him/herself can do this off course always if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) or $current_forum['allow_edit'] == 1 and $row['user_id'] == $_user['user_id'] or api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) { if ($locked == false) { echo "<a href=\"editpost.php?" . api_get_cidreq() . "&forum=" . $forumId . "&thread=" . $threadId . "&post=" . $rows[$display_post_id]['post_id'] . "&id_attach=" . $id_attach . "\">" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>'; } } if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) or api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) { if ($locked == false) { echo "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&forum=" . $forumId . "&thread=" . $threadId . "&action=delete&content=post&id=" . $rows[$display_post_id]['post_id'] . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . "</a>"; } display_visible_invisible_icon('post', $rows[$display_post_id]['post_id'], $rows[$display_post_id]['visible'], array('forum' => $forumId, 'thread' => $threadId, 'post' => Security::remove_XSS($_GET['post']))); // Verified the post minor $my_post = get_posts($_GET['thread']);
{ $sql = get_sql_for_attached_documents($type); $cols = array(_("#") => array('fun' => 'trans_view', 'ord' => ''), _("Description") => array('name' => 'description'), _("Filename") => array('name' => 'filename'), _("Size") => array('name' => 'filesize'), _("Filetype") => array('name' => 'filetype'), _("Date Uploaded") => array('name' => 'tran_date', 'type' => 'date'), array('insert' => true, 'fun' => 'edit_link'), array('insert' => true, 'fun' => 'view_link'), array('insert' => true, 'fun' => 'download_link'), array('insert' => true, 'fun' => 'delete_link')); $table =& new_db_pager('trans_tbl', $sql, $cols); $table->width = "60%"; display_db_pager($table); } //---------------------------------------------------------------------------------------- start_form(true); viewing_controls(); display_rows($_POST['filterType']); br(2); start_table(TABLESTYLE2); if ($selected_id != -1) { if ($Mode == 'Edit') { $row = get_attachment($selected_id); $_POST['trans_no'] = $row["trans_no"]; $_POST['description'] = $row["description"]; hidden('trans_no', $row['trans_no']); hidden('unique_name', $row['unique_name']); label_row(_("Transaction #"), $row['trans_no']); } hidden('selected_id', $selected_id); } else { text_row_ex(_("Transaction #") . ':', 'trans_no', 10); } text_row_ex(_("Description") . ':', 'description', 40); file_row(_("Attached File") . ":", 'filename', 'filename'); end_table(1); submit_add_or_update_center($selected_id == -1, '', 'process'); end_form();
/** * This function displays the form that is used to edit a post. This can be a new thread or a reply. * @param array contains all the information about the current post * @param array contains all the information about the current thread * @param array contains all info about the current forum (to check if attachments are allowed) * @param array contains the default values to fill the form * @return void * * @author Patrick Cool <*****@*****.**>, Ghent University * @version february 2006, dokeos 1.8 */ function show_edit_post_form($current_post, $current_thread, $current_forum, $form_values = '', $id_attach = 0) { global $forum_setting; global $origin; $gradebook = Security::remove_XSS($_GET['gradebook']); // Initialize the object. $form = new FormValidator('edit_post', 'post', api_get_self() . '?forum=' . Security::remove_XSS($_GET['forum']) . '&gradebook=' . $gradebook . '&origin=' . $origin . '&thread=' . Security::remove_XSS($_GET['thread']) . '&post=' . Security::remove_XSS($_GET['post'])); $form->addElement('header', get_lang('EditPost')); // Settting the form elements. $form->addElement('hidden', 'post_id', $current_post['post_id']); $form->addElement('hidden', 'thread_id', $current_thread['thread_id']); $form->addElement('hidden', 'id_attach', $id_attach); if ($current_post['post_parent_id'] == 0) { $form->addElement('hidden', 'is_first_post_of_thread', '1'); } $form->addElement('text', 'post_title', get_lang('Title'), 'class="input_titles"'); $form->applyFilter('post_title', 'html_filter'); $form->addElement('html_editor', 'post_text', get_lang('Text'), null, api_is_allowed_to_edit(null, true) ? array('ToolbarSet' => 'Forum', 'Width' => '100%', 'Height' => '400') : array('ToolbarSet' => 'ForumStudent', 'Width' => '100%', 'Height' => '400', 'UserStatus' => 'student')); $form->addRule('post_text', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('advanced_settings', '<a href="javascript://" onclick="return advanced_parameters()"><span id="img_plus_and_minus">' . Display::return_icon('div_show.gif', get_lang('Show'), array('style' => 'vertical-align:middle')) . '' . get_lang('AdvancedParameters') . '</span></a>'); $form->addElement('html', '<div id="id_qualify" style="display:none">'); if (!isset($_GET['edit'])) { if (Gradebook::is_active()) { $form->addElement('label', '<strong>' . get_lang('AlterQualifyThread') . '</strong>'); $form->addElement('checkbox', 'thread_qualify_gradebook', '', get_lang('QualifyThreadGradebook'), 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"'); $link_info = is_resource_in_course_gradebook(api_get_course_id(), 5, $_GET['thread'], api_get_session_id()); if (!empty($link_info)) { $defaults['thread_qualify_gradebook'] = true; $defaults['category_id'] = $link_info['category_id']; } else { $defaults['thread_qualify_gradebook'] = false; $defaults['category_id'] = ''; } } else { $form->addElement('hidden', 'thread_qualify_gradebook', false); $defaults['thread_qualify_gradebook'] = false; } if (!empty($defaults['thread_qualify_gradebook'])) { $form->addElement('html', '<div id="options_field" style="display:block">'); } else { $form->addElement('html', '<div id="options_field" style="display:none">'); } //Loading gradebook select load_gradebook_select_in_tool($form); $form->addElement('text', 'numeric_calification', get_lang('QualificationNumeric'), 'value="' . $current_thread['thread_qualify_max'] . '" style="width:40px"'); $form->applyFilter('numeric_calification', 'html_filter'); $form->addElement('text', 'calification_notebook_title', get_lang('TitleColumnGradebook'), 'value="' . $current_thread['thread_title_qualify'] . '"'); $form->applyFilter('calification_notebook_title', 'html_filter'); $form->addElement('text', 'weight_calification', array(get_lang('QualifyWeight'), null, ''), 'value="' . $current_thread['thread_weight'] . '" style="width:40px"'); $form->applyFilter('weight_calification', 'html_filter'); $form->addElement('html', '</div>'); } if ($forum_setting['allow_post_notification']) { $form->addElement('checkbox', 'post_notification', '', get_lang('NotifyByEmail') . ' (' . $current_post['email'] . ')'); } if ($forum_setting['allow_sticky'] && api_is_allowed_to_edit(null, true) && $current_post['post_parent_id'] == 0) { // The sticky checkbox only appears when it is the first post of a thread. $form->addElement('checkbox', 'thread_sticky', '', get_lang('StickyPost')); if ($current_thread['thread_sticky'] == 1) { $defaults['thread_sticky'] = true; } } $attachment_list = get_attachment($current_post['post_id']); $message = get_lang('AddAnAttachment'); if (!empty($attachment_list)) { //$message = ; $form->addElement('label', get_lang('EditAnAttachment'), Display::return_icon('attachment.gif', get_lang('Attachment')) . ' ' . $attachment_list['filename'] . (!empty($attachment_list['comment']) ? '(' . $attachment_list['comment'] . ')' : '')); $form->addElement('checkbox', 'remove_attach', null, get_lang('DeleteAttachmentFile')); } else { // User upload $form->addElement('label', $message); $form->addElement('file', 'user_upload', get_lang('FileName'), ''); $form->addElement('textarea', 'file_comment', get_lang('FileComment'), array('rows' => 4, 'cols' => 34)); $form->applyFilter('file_comment', 'html_filter'); } if ($current_forum['allow_attachments'] == '1' || api_is_allowed_to_edit(null, true)) { if (empty($form_values) && !isset($_POST['SubmitPost'])) { //edit_added_resources('forum_post', $current_post['post_id']); } } $form->addElement('html', '</div>'); $form->addElement('style_submit_button', 'SubmitPost', get_lang('ModifyThread'), 'class="save"'); // Setting the default values for the form elements. $defaults['post_title'] = $current_post['post_title']; $defaults['post_text'] = $current_post['post_text']; if ($current_post['post_notification'] == 1) { $defaults['post_notification'] = true; } if (!empty($form_values)) { $defaults['post_notification'] = Security::remove_XSS($form_values['post_notification']); $defaults['thread_sticky'] = Security::remove_XSS($form_values['thread_sticky']); } $form->setDefaults($defaults); // The course admin can make a thread sticky (=appears with special icon and always on top). $form->addRule('post_title', get_lang('ThisFieldIsRequired'), 'required'); // Validation or display if ($form->validate()) { $values = $form->exportValues(); if ($values['thread_qualify_gradebook'] == '1' && empty($values['weight_calification'])) { Display::display_error_message(get_lang('YouMustAssignWeightOfQualification') . ' <a href="javascript:window.back()">' . get_lang('Back') . '</a>', false); return false; } return $values; } else { $form->display(); } }
/** * Displays all the agenda items * @author Patrick Cool <*****@*****.**>, Ghent University * @author Yannick Warnier <*****@*****.**> - cleanup * @author Julio Montoya <*****@*****.**> - Refactoring */ function display_agenda_items($agenda_items, $day = false) { global $charset; if (isset($day) && $day) { $new_items = array(); foreach ($agenda_items as $item) { if (substr($item['start_date'], 8, 2) == $day) { $new_items[] = $item; } } $agenda_items = $new_items; } if (isset($_GET['sort']) && $_GET['sort'] == 'asc') { $sort_inverse = 'desc'; $sort = 'asc'; } else { $sort_inverse = 'asc'; $sort = 'desc'; } if (isset($_GET['col']) && $_GET['col'] == 'end') { $sort_item = 'end_date_tms'; $col = 'end'; } else { $sort_item = 'start_date_tms'; $col = 'start'; } $agenda_items = msort($agenda_items, $sort_item, $sort); //DISPLAY: NO ITEMS if (empty($agenda_items)) { echo Display::display_warning_message(get_lang('NoAgendaItems')); } else { echo '<table class="data_table">'; $th = Display::tag('th', get_lang('Title')); $month = isset($_GET['month']) ? intval($_GET['month']) : null; $year = isset($_GET['year']) ? intval($_GET['year']) : null; $day = isset($_GET['day']) ? intval($_GET['day']) : null; $url = api_get_self() . '?' . api_get_cidreq() . '&month=' . $month . '&year=' . $year . '&day=' . $day; $th .= Display::tag('th', Display::url(get_lang('StartTimeWindow'), $url . '&sort=' . $sort_inverse . '&col=start')); $th .= Display::tag('th', Display::url(get_lang('EndTimeWindow'), $url . '&sort=' . $sort_inverse . '&col=end')); if (api_is_allowed_to_edit(false, true) or api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) { $th .= Display::tag('th', get_lang('Modify')); } echo Display::tag('tr', $th); $counter = 0; foreach ($agenda_items as $myrow) { $is_repeated = !empty($myrow['parent_event_id']); $class = 'row_even'; if ($counter % 2) { $class = 'row_odd'; } /* display: the icon, title, destinees of the item */ echo '<tr class="' . $class . '">'; //Title echo "<td>"; $attach_icon = ''; // attachment list $attachment_list = get_attachment($myrow['id']); if (!empty($attachment_list)) { $attach_icon = ' ' . Display::return_icon('attachment.gif', get_lang('Attachment')); } $title_class = ''; if (isset($myrow['visibility']) && $myrow['visibility'] == 0) { $title_class = 'invisible'; } switch ($myrow['calendar_type']) { case 'global': $icon_type = Display::return_icon('view_remove.png', get_lang('GlobalEvent'), array(), 22); echo $icon_type . ' ' . $myrow['title'] . $attach_icon; break; case 'personal': $icon_type = Display::return_icon('user.png', get_lang(' '), array(), 22); echo $icon_type . ' ' . $myrow['title'] . $attach_icon; break; case 'course': $icon_type = Display::return_icon('course.png', get_lang('Course'), array(), 22); $agenda_url = api_get_path(WEB_CODE_PATH) . 'calendar/agenda.php?agenda_id=' . $myrow['id'] . '&action=view'; echo Display::url($icon_type . ' ' . $myrow['title'] . $attach_icon, $agenda_url, array('class' => $title_class)); break; } echo '</td>'; //Start date echo '<td>'; if (!empty($myrow['start_date']) && $myrow['start_date'] != '0000-00-00 00:00:00') { echo api_format_date($myrow['start_date']); } echo '</td>'; //End date echo '<td>'; if (!empty($myrow['end_date']) && $myrow['end_date'] != '0000-00-00 00:00:00') { echo api_format_date($myrow['end_date']); } echo '</td>'; /* Display: edit delete button (course admin only) */ if (!$is_repeated && (api_is_allowed_to_edit(false, true) or api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) && $myrow['calendar_type'] == 'course') { echo '<td align="center">'; if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id']))) { // a coach can only delete an element belonging to his session $mylink = api_get_self() . '?' . api_get_cidreq() . '&origin=' . Security::remove_XSS($_GET['origin']) . '&id=' . $myrow['id'] . '&sort=' . $sort . '&col=' . $col . '&'; // edit echo '<a href="' . $mylink . api_get_cidreq() . "&toolgroup=" . Security::remove_XSS($_GET['toolgroup']) . '&action=edit&id_attach=' . $attachment_list['id'] . '" title="' . get_lang("ModifyCalendarItem") . '">'; echo Display::return_icon('edit.png', get_lang('ModifyCalendarItem'), '', ICON_SIZE_SMALL) . "</a>"; echo '<a href="' . $mylink . api_get_cidreq() . "&toolgroup=" . Security::remove_XSS($_GET['toolgroup']) . '&action=announce" title="' . get_lang("AddAnnouncement") . '">'; echo Display::return_icon('new_announce.png', get_lang('AddAnnouncement'), array(), ICON_SIZE_SMALL) . "</a> "; if ($myrow['visibility'] == 1) { $image_visibility = "visible"; $text_visibility = get_lang("Hide"); $next_action = 0; } else { $image_visibility = "invisible"; $text_visibility = get_lang("Show"); $next_action = 1; } echo '<a href="' . $mylink . api_get_cidreq() . '&toolgroup=' . Security::remove_XSS($_GET['toolgroup']) . '&action=showhide&next_action=' . $next_action . '" title="' . $text_visibility . '">' . Display::return_icon($image_visibility . '.png', $text_visibility, '', ICON_SIZE_SMALL) . '</a> '; echo "<a href=\"" . $mylink . api_get_cidreq() . "&toolgroup=" . Security::remove_XSS($_GET['toolgroup']) . "&action=delete\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . "')) return false;\" title=\"" . get_lang("Delete") . "\"> "; echo Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . " </a>"; } $mylink = 'ical_export.php?' . api_get_cidreq() . '&type=course&id=' . $myrow['id']; //echo '<a class="ical_export" href="'.$mylink.'&class=confidential" title="'.get_lang('ExportiCalConfidential').'">'.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).'</a> '; //echo '<a class="ical_export" href="'.$mylink.'&class=private" title="'.get_lang('ExportiCalPrivate').'">'.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).'</a> '; //echo '<a class="ical_export" href="'.$mylink.'&class=public" title="'.get_lang('ExportiCalPublic').'">'.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).'</a> '; echo '<a href="#" onclick="javascript:win_print=window.open(\'print.php?id=' . $myrow['id'] . '\',\'popup\',\'left=100,top=100,width=700,height=500,scrollbars=1,resizable=0\'); win_print.focus(); return false;">' . Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_SMALL) . '</a> '; echo '</td>'; } else { if ($is_repeated && (api_is_allowed_to_edit(false, true) || api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) { echo '<td align="center">'; echo get_lang('RepeatedEvent'), ' <a href="', api_get_self(), '?', api_get_cidreq(), '&agenda_id=', $myrow['parent_event_id'], '" alt="', get_lang('RepeatedEventViewOriginalEvent'), '">', get_lang('RepeatedEventViewOriginalEvent'), '</a>'; echo '</td>'; } if ((api_is_allowed_to_edit(false, true) || api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) && ($myrow['calendar_type'] == 'personal' or $myrow['calendar_type'] == 'global')) { echo '<td align="center">'; echo '</td>'; } } $counter++; echo "</tr>"; } // end while ($myrow=Database::fetch_array($result)) echo "</table><br /><br />"; } if (!empty($event_list)) { $event_list = api_substr($event_list, 0, -1); } else { $event_list = '0'; } echo "<form name=\"event_list_form\"><input type=\"hidden\" name=\"event_list\" value=\"{$event_list}\" /></form>"; // closing the layout table echo "</td>", "</tr>", "</table>"; }
/** * Displays only 1 agenda item. This is used when an agenda item is added to the learning path. * @author Patrick Cool <*****@*****.**>, Ghent University */ function display_one_agenda_item($agenda_id) { global $TABLEAGENDA; global $TABLE_ITEM_PROPERTY; global $select_month, $select_year; global $DaysShort, $DaysLong, $MonthsLong; global $dateFormatLong, $timeNoSecFormat, $charset; // getting the name of the groups $group_names = get_course_groups(); $agenda_id = intval($agenda_id); if (!(api_is_allowed_to_edit(false, true) || api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) { $visibility_condition = " AND ip.visibility='1' "; } $sql = "SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref\n\t\t\tFROM " . $TABLEAGENDA . " agenda, " . $TABLE_ITEM_PROPERTY . " ip\n\t\t\tWHERE agenda.id = ip.ref\n\t\t\tAND ip.tool='" . TOOL_CALENDAR_EVENT . "'\n\t\t\t{$visibility_condition}\n\t\t\tAND agenda.id='{$agenda_id}'"; $result = Database::query($sql); $number_items = Database::num_rows($result); $myrow = Database::fetch_array($result, 'ASSOC'); // there should be only one item so no need for a while loop $sql_rep = "SELECT * FROM {$TABLEAGENDA} WHERE id = {$agenda_id} AND parent_event_id IS NOT NULL AND parent_event_id !=0"; $res_rep = Database::query($sql_rep); $repeat = false; $repeat_id = 0; if (Database::num_rows($res_rep) > 0) { $repeat = true; $row_rep = Database::fetch_array($res_rep); $repeat_id = $row_rep['parent_event_id']; } // DISPLAY: NO ITEMS if ($number_items == 0) { Display::display_warning_message(get_lang("NoAgendaItems")); return false; } // DISPLAY: THE ITEMS echo "<table id=\"data_table\" class=\"data_table\">"; // DISPLAY : the icon, title, destinees of the item $myrow["start_date"] = api_get_local_time($myrow["start_date"]); // highlight: if a date in the small calendar is clicked we highlight the relevant items $db_date = (int) api_format_date($myrow["start_date"], "%d") . intval(api_format_date($myrow["start_date"], "%m")) . api_format_date($myrow["start_date"], "%Y"); if ($_GET["day"] . $_GET["month"] . $_GET["year"] != $db_date) { if ($myrow['visibility'] == '0') { $style = "data_hidden"; $stylenotbold = "datanotbold_hidden"; $text_style = "text_hidden"; } else { $style = "data"; $stylenotbold = "datanotbold"; $text_style = "text"; } } else { $style = "datanow"; $stylenotbold = "datanotboldnow"; $text_style = "textnow"; } echo Display::tag('h2', $myrow['title']); echo "<tr>"; if (api_is_allowed_to_edit(false, true)) { if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id']))) { // a coach can only delete an element belonging to his session // DISPLAY: edit delete button (course admin only) $export_icon = '../img/export.png'; $export_icon_low = '../img/export_low_fade.png'; $export_icon_high = '../img/export_high_fade.png'; echo '<th style="text-align:right">'; if (!$repeat && api_is_allowed_to_edit(false, true)) { // edit $mylink = api_get_self() . "?" . api_get_cidreq() . "&origin=" . Security::remove_XSS($_GET['origin']) . "&id=" . $myrow['id']; if (!empty($_GET['agenda_id'])) { // rather ugly hack because the id parameter is already set above but below we set it again $mylink .= '&agenda_id=' . Security::remove_XSS($_GET['agenda_id']) . '&id=' . Security::remove_XSS($_GET['agenda_id']); } if ($myrow['visibility'] == 1) { $image_visibility = "visible"; $next_action = 0; } else { $image_visibility = "invisible"; $next_action = 1; } echo '<a href="' . $mylink . '&action=showhide&next_action=' . $next_action . '">' . Display::return_icon($image_visibility . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . '</a>'; echo "<a href=\"" . $mylink . "&action=edit\">", Display::return_icon('edit.png', get_lang('ModifyCalendarItem'), '', ICON_SIZE_SMALL), "</a>", "<a href=\"" . $mylink . "&action=delete\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . "')) return false;\">", Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL), "</a>"; } $mylink = 'ical_export.php?' . api_get_cidreq() . '&type=course&id=' . $myrow['id']; //echo '<a class="ical_export" href="'.$mylink.'&class=confidential" title="'.get_lang('ExportiCalConfidential').'">'.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).'</a> '; //echo '<a class="ical_export" href="'.$mylink.'&class=private" title="'.get_lang('ExportiCalPrivate').'">'.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).'</a> '; //echo '<a class="ical_export" href="'.$mylink.'&class=public" title="'.get_lang('ExportiCalPublic').'">'.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).'</a> '; echo '<a href="javascript: void(0);" onclick="javascript:win_print=window.open(\'print.php?id=' . $myrow['id'] . '\',\'popup\',\'left=100,top=100,width=700,height=500,scrollbars=1,resizable=0\'); win_print.focus(); return false;">' . Display::return_icon('printer.png', get_lang('Print'), '', ICON_SIZE_SMALL) . '</a> '; echo "</th>"; } } // title echo "<tr class='row_odd'>"; echo '<td colspan="2">' . get_lang("StartTime") . ": "; echo api_format_date($myrow['start_date']); echo "</td>"; echo "</td>"; echo "<tr class='row_odd'>"; echo '<td colspan="2">' . get_lang("EndTime") . ": "; echo api_convert_and_format_date($myrow['end_date']); echo "</td>"; // Content $content = $myrow['content']; $content = Text::make_clickable($content); echo '<tr class="row_even">'; echo '<td ' . (api_is_allowed_to_edit() ? 'colspan="3"' : 'colspan="2"') . '>'; echo $content; echo '</td></tr>'; //Attachments $attachment_list = get_attachment($agenda_id); if (!empty($attachment_list)) { echo '<tr class="row_even"><td colspan="2">'; $realname = $attachment_list['path']; $user_filename = $attachment_list['filename']; $full_file_name = 'download.php?file=' . $realname; echo Display::return_icon('attachment.gif', get_lang('Attachment')); echo '<a href="' . $full_file_name . '"> ' . $user_filename . '</a>'; if (api_is_allowed_to_edit()) { echo ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&origin=' . Security::remove_XSS($_GET['origin']) . '&action=delete_attach&id_attach=' . $attachment_list['id'] . '" onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . '\')) return false;">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a><br />'; } echo '<br /><span class="forum_attach_comment" >' . $attachment_list['comment'] . '</span>'; echo '</td></tr>'; } // the message has been sent to echo '<tr>'; echo "<td class='announcements_datum'>" . get_lang("SentTo") . ": "; $sent_to = sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]); $sent_to_form = sent_to_form($sent_to); echo $sent_to_form; echo "</td></tr>"; if ($repeat) { echo '<tr>'; echo '<td colspan="2">'; echo get_lang('RepeatedEvent') . ' <a href="', api_get_self(), '?', api_get_cidreq(), '&agenda_id=', $repeat_id, '" alt="', get_lang('RepeatedEventViewOriginalEvent'), '">', get_lang('RepeatedEventViewOriginalEvent'), '</a>'; echo '</td>'; echo '</tr>'; } /* Added resources */ if (check_added_resources("Agenda", $myrow["id"])) { echo "<tr><td colspan='3'>"; echo "<i>" . get_lang("AddedResources") . "</i><br/>"; if ($myrow['visibility'] == 0) { $addedresource_style = "invisible"; } display_added_resources("Agenda", $myrow["id"], $addedresource_style); echo "</td></tr>"; } // closing the layout table echo "</td>", "</tr>", "</table>"; }