/
myfavs-widget-users.php
73 lines (59 loc) · 1.86 KB
/
myfavs-widget-users.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
class myfavs_widget_users {
var $urltoroot;
function load_module($directory, $urltoroot)
{
$this->urltoroot = $urltoroot;
}
function allow_template($template)
{
$allow=false;
if( qa_is_logged_in() ) {
$allow=true;
}
return $allow;
}
function allow_region($region)
{
$allow=false;
switch ($region)
{
case 'side':
$allow=true;
break;
case 'full':
break;
}
return $allow;
}
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
// set up user
$userid = qa_get_logged_in_userid();
$myfavs = myfavs_get($userid, 'U');
$output = '';
$output .= '<h2 class="myfavs_title">'.qa_lang('myfavs_lang/title_widget_users').'</h2>';
$output .= '<ul class="myfavs_ul">';
if(!empty($myfavs)) {
foreach ($myfavs as $key=>$myfav) {
$url = qa_path_html('user/' . $myfav['name']);
$output .= '<form method="post" action="'.$url.'">';
$output .='<li><a href="'.$url.'" class="qa-tag-link qa-tag-favorited">'.qa_html($myfav['name']).'</a> <button class="ajax_remove_button" name="favorite_U_'.$myfav['entityid'].'_0" onclick="return qa_favorite_click(this);" type="submit" value="remove" class="qa-unfavorite-button">'.qa_lang('myfavs_lang/remove').'</button></li>';
$output .= '<input name="code" type="hidden" value="'.qa_get_form_security_code('favorite-U-'.$myfav['entityid']).'"></form>';
}
} else {
$output .= '<li>'.qa_lang('myfavs_lang/myfavs_no_records_yet').'</li>';
}
if(qa_opt('myfavs_credit')) {
$output .= ''.qa_opt('myfavs_credit_text').'</ul>';
} else {
$output .= '</ul>';
}
$themeobject->output(
$output
);
}
};
/*
Omit PHP closing tag to help avoid accidental output
*/