public static function print_note($note_id, $note_item, $display_summary = false, $can_edit = true, $can_delete = true, $options = array()) { if (!$note_item) { $note_item = self::get_note($note_id); } static $x = 0; global $plugins; $can_view = $can_edit = $can_create = $can_delete = false; // re-check permissions... if (isset($options) && isset($options['owner_table']) && $options['owner_table'] && isset($options['title']) && $options['title']) { $can_view = $plugins[$options['owner_table']]->can_i('view', $options['title']); $can_edit = $plugins[$options['owner_table']]->can_i('edit', $options['title']); $can_create = $plugins[$options['owner_table']]->can_i('create', $options['title']); $can_delete = $plugins[$options['owner_table']]->can_i('delete', $options['title']); } else { } if (!module_security::is_page_editable()) { //$can_edit=$can_create=$can_delete=false; } if (isset($options['summary_owners'])) { unset($options['summary_owners']); } if (isset($options['display_summary'])) { unset($options['display_summary']); } // if (!trim($note_item['note'])) { $note_item['note'] = 'none'; } ob_start(); /** START TABLE LAYOUT **/ $table_manager = module_theme::new_table_manager(); $columns = array(); $columns['date'] = array('title' => 'Date', 'width' => 60, 'callback' => function ($note_item) { if ($note_item['reminder']) { echo '<strong>'; } echo print_date($note_item['note_time']); if ($note_item['reminder']) { echo '</strong>'; } }); $columns['description'] = array('title' => 'Description', 'callback' => function ($note_item) { if (isset($note_item['public']) && $note_item['public']) { echo '* '; } if ($note_item['can_edit']) { $note_text = nl2br(htmlspecialchars(substr($note_item['note'], 0, module_config::c('note_trim_length', 35)))); $note_text .= strlen($note_item['note']) > module_config::c('note_trim_length', 35) ? '...' : ''; ?> <a href="<?php echo module_note::link_open($note_item['note_id'], false, $note_item['options']); ?> " data-options="<?php echo htmlspecialchars(base64_encode(serialize($note_item['options']))); ?> " class="note_edit note_options_link" rel="<?php echo $note_item['note_id']; ?> "> <?php echo $note_text; ?> </a> <?php } else { echo forum_text($note_item['note']); } }); $columns['info'] = array('title' => 'Info', 'width' => 40, 'callback' => function ($note_item) { if ($note_item['display_summary']) { if ($note_item['rel_data']) { global $plugins; echo $plugins[$note_item['owner_table']]->link_open($note_item['owner_id'], true); } } else { // find the user name who made thsi note. $user_data = module_user::get_user($note_item['create_user_id']); echo $user_data['name']; } }); if ($can_delete) { $columns['del'] = array('title' => ' ', 'callback' => function ($note_item) { if ($note_item['can_delete']) { ?> <a href="<?php echo module_note::link_open($note_item['note_id'], false, array_merge($note_item['options'], array('do_delete' => 'yes', 'note_id' => $note_item['note_id']))); ?> " data-options="<?php echo htmlspecialchars(base64_encode(serialize(array_merge($note_item['options'], array('do_delete' => 'yes', 'note_id' => $note_item['note_id']))))); ?> " rel="<?php echo $note_item['note_id']; ?> " onclick="if(confirm('<?php _e('Really Delete Note?'); ?> '))return true; else return false;" class="note_delete note_options_link delete ui-state-default ui-corner-all ui-icon ui-icon-trash">[x]</a> <?php } }); } $table_manager->set_columns($columns); $table_manager->inline_table = true; $table_manager->row_callback = function ($row_data, &$row_object) use($display_summary, $can_edit, $can_delete, &$options) { $row_data['display_summary'] = $display_summary; $row_data['can_edit'] = $can_edit; $row_data['can_delete'] = $can_delete; $row_data['options'] = $options; $row_object->row_id = 'note_' . $row_data['note_id']; return $row_data; }; $table_manager->print_row($note_item); /*?> <tr id="note_<?php echo $note_item['note_id'];?>" class="<?php echo ($x++%2)?'odd':'even';?>"> <td> <?php if($note_item['reminder'])echo '<strong>'; echo print_date($note_item['note_time']); if($note_item['reminder'])echo '</strong>'; ?> </td> <td> <?php if(isset($note_item['public']) && $note_item['public'])echo '* '; if($can_edit){ $note_text = nl2br(htmlspecialchars(substr($note_item['note'],0,module_config::c('note_trim_length',35)))); $note_text .= strlen($note_item['note']) > module_config::c('note_trim_length',35) ? '...' : ''; ?> <a href="<?php echo self::link_open($note_item['note_id'],false,$options);?>" data-options="<?php echo htmlspecialchars(base64_encode(serialize($options)));?>" class="note_edit note_options_link" rel="<?php echo $note_item['note_id'];?>"> <?php echo $note_text; ?> </a> <?php }else{ echo forum_text($note_item['note']); } ?> </td> <td nowrap="nowrap"> <?php if($display_summary){ if($note_item['rel_data']){ echo $plugins[$note_item['owner_table']]->link_open($note_item['owner_id'],true); } }else{ // find the user name who made thsi note. $user_data = module_user::get_user($note_item['create_user_id']); echo $user_data['name']; } ?> </td> <?php if($can_delete){ ?> <td><a href="<?php echo self::link_open($note_item['note_id'],false,array_merge($options,array('do_delete'=>'yes','note_id'=>$note_item['note_id'])));?>" data-options="<?php echo htmlspecialchars(base64_encode(serialize(array_merge($options,array('do_delete'=>'yes','note_id'=>$note_item['note_id'])))));?>" rel="<?php echo $note_item['note_id'];?>" onclick="if(confirm('<?php _e('Really Delete Note?');?>'))return true; else return false;" class="note_delete note_options_link delete ui-state-default ui-corner-all ui-icon ui-icon-trash">[x]</a></td> <?php } ?> </tr> <?php */ return ob_get_clean(); }
echo $user_data['name']; } if ($note_item['display_summary'] && $note_item['rel_data'] && $note_item['owner_id']) { global $plugins; if (module_config::c('note_show_creator', 1)) { echo ' / '; } echo $plugins[$note_item['owner_table']]->link_open($note_item['owner_id'], true); } }); if ($can_delete) { $columns['del'] = array('title' => ' ', 'callback' => function ($note_item) { if ($note_item['can_delete']) { ?> <a href="<?php echo module_note::link_open($note_item['note_id'], false, array_merge($note_item['options'], array('do_delete' => 'yes', 'note_id' => $note_item['note_id']))); ?> " data-options="<?php echo htmlspecialchars(base64_encode(serialize(array_merge($note_item['options'], array('do_delete' => 'yes', 'note_id' => $note_item['note_id']))))); ?> " rel="<?php echo $note_item['note_id']; ?> " onclick="if(confirm('<?php _e('Really Delete Note?'); ?> '))return true; else return false;" class="note_delete note_options_link delete ui-state-default ui-corner-all ui-icon ui-icon-trash">[x]</a> <?php } }); } $table_manager->set_columns($columns);