MOD Versie: 0.1 (experiment)
Author: (eigenlijk bestaande code uit phpBB 3.0.8)
MOD Descriptie: Gebruikers de mogelijkheid bieden om bij het bekijken van hun eigen profiel hun logs te zien.
phpBB Versie: 3.0.8 (hoogstwaarschijnlijk werkt het ook in voorgaande versies)
De bestanden die ik hiervoor bewerk zijn:
memberlist.php
/styles/prosilver/template/memberlist_view.html
/language/nl/memberlist.php
Wat ik eigenlijk wil bewerkstelligen, is dat reguliere gebruikers via memberlist.php hun eigen logs kunnen zien. Het komt erop neer dat ik in de memberlist.php wat code wil zetten die normaal gesproken alleen in /includes/mcp/mcp_notes.php te vinden is.
Nu ben ik zelf niet echt een held met databases en php en probeer ik vooral heel logisch na te denken om dingen voor elkaar te krijgen, maar dat lukt niet altijd.
![Haha :P](./images/smilies/icon_razz.gif)
Ik heb het volgende php-bestandje gemaakt. (Het is eigenlijk voornamelijk een kopie van /includes/mcp/mcp_notes.php) maar dan zonder de code die het voor admins mogelijk maakt om notities te verwijderen en zonder de code om ip-adressen te zien of om daarop te sorteren. (Ik heb er voorlopig een heel php-bestand van gemaakt, i.v.m. syntax check.)
Code: Selecteer alles
<?php
/**
*
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
{
global $phpEx, $phpbb_root_path, $config;
global $template, $db, $user;
$user_id = request_var('u', 0);
$username = request_var('username', '', true);
$start = request_var('start', 0);
$st = request_var('st', 0);
$sk = request_var('sk', 'b');
$sd = request_var('sd', 'd');
$sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
$sql = 'SELECT *
FROM ' . USERS_TABLE . "
WHERE $sql_where";
$result = $db->sql_query($sql);
$userrow = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$userrow)
{
trigger_error('NO_USER');
}
$user_id = $userrow['user_id'];
// Populate user id to the currently active module (this module)
// The following method is another way of adjusting module urls. It is the easy variant if we want
// to directly adjust the current module url based on data retrieved within the same module.
if (strpos($this->u_action, "&u=$user_id") === false)
{
$this->p_master->adjust_url('&u=' . $user_id);
$this->u_action .= "&u=$user_id";
}
$usernote = utf8_normalize_nfc(request_var('usernote', '', true));
// Generate the appropriate user information for ownnotes section
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
$sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_ACTION']);
$sort_by_sql = array('a' => 'u.username_clean', 'b' => 'l.log_time', 'c' => 'l.log_operation');
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
// Define where and sort sql for use in displaying logs
$sql_where = ($st) ? (time() - ($st * 86400)) : 0;
$sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC');
$keywords = utf8_normalize_nfc(request_var('keywords', '', true));
$keywords_param = !empty($keywords) ? '&keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
$log_data = array();
$log_count = 0;
view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort, $keywords);
if ($log_count)
{
$template->assign_var('S_USER_NOTES', true);
foreach ($log_data as $row)
{
$template->assign_block_vars('usernotes', array(
'REPORT_BY' => $row['username_full'],
'REPORT_AT' => $user->format_date($row['time']),
'ACTION' => $row['action'])
);
}
}
$template->assign_vars(array(
'S_SELECT_SORT_DIR' => $s_sort_dir,
'S_SELECT_SORT_KEY' => $s_sort_key,
'S_SELECT_SORT_DAYS' => $s_limit_days,
'OWNNOTES' => ($user_row['user_id'] == $user->data['user_id']),
'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start),
'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start),
'TOTAL_REPORTS' => ($log_count == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $log_count),
)
);
}
?>
Code: Selecteer alles
'OWNNOTES' => ($user_row['user_id'] == $user->data['user_id']),
En wel op deze wijze:
Code: Selecteer alles
<!-- IF OWNNOTES -->
<h3>{L_OWNNOTES}</h3>
<div class="panel bg1">
<div class="inner"><span class="corners-top"><span></span></span>
<ul class="linklist">
<li class="rightside pagination">
<!-- IF TOTAL_REPORTS -->{TOTAL_REPORTS} <!-- ENDIF -->
<!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> • <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> • <span>{PAGINATION}</span><!-- ELSE --> • {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
</li>
</ul>
<table cellspacing="1" class="table1">
<thead>
<tr>
<th>{L_REPORT_BY}</th>
<th style="text-align: center">{L_TIME}</th>
<th>{L_ACTION_NOTE}</th>
</tr>
</thead>
<tbody>
<!-- BEGIN usernotes -->
<!-- IF usernotes.S_ROW_COUNT is even --><tr class="bg1"><!-- ELSE --><tr class="bg2"><!-- ENDIF -->
<td>{usernotes.REPORT_BY}</td>
<td style="text-align: center">{usernotes.REPORT_AT}</td>
<td>{usernotes.ACTION}</td>
</tr>
<!-- BEGINELSE -->
<tr>
<td class="bg1" colspan="4" align="center"><span class="gen">{L_NO_ENTRIES}</span></td>
</tr>
<!-- END usernames -->
</tbody>
</table>
<hr />
<fieldset class="display-options">
<!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box {S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
<!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box {S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
<label>{L_DISPLAY_LOG}: {S_SELECT_SORT_DAYS}</label>
<label>{L_SORT_BY} {S_SELECT_SORT_KEY}</label><label>{S_SELECT_SORT_DIR}</label>
<input type="submit" name="sort" value="{L_GO}" class="button2" />
</fieldset>
<hr />
<ul class="linklist">
<li class="rightside pagination">
<!-- IF TOTAL_REPORTS -->{TOTAL_REPORTS}<!-- ENDIF -->
<!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> • <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> • <span>{PAGINATION}</span><!-- ELSE --> • {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
</li>
</ul>
<span class="corners-bottom"><span></span></span></div>
</div>
<!-- ENDIF -->
</form>
![Smile :)](./images/smilies/icon_e_smile.gif)
Wie kan me tips geven hoe ik ervoor kan zorgen dat ik deze extra code werkend krijg in 'memberlist.php'.
Alvast bedankt!