/
qa-admin-check.php
70 lines (64 loc) · 1.82 KB
/
qa-admin-check.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
<?php
class qa_admin_plus_check {
function process_event($event, $userid, $handle, $cookieid, $params) {
switch ($event) {
case 'a_post':
if(qa_opt('notify_admin_a_post')) {
$this->sendEmail($event,$userid,$handle,$params);
}
break;
case 'c_post':
if(qa_opt('notify_admin_c_post'))
$this->sendEmail($event,$userid,$handle,$params);
break;
default:
break;
}
}
function sendEmail($event,$userid,$handle,$params){
$email = $this->getEmail($userid);
if($email == qa_opt('feedback_email'))
return;
$parent = qa_db_read_one_assoc(
qa_db_query_sub(
'SELECT * FROM ^posts WHERE postid=#',
$params['parentid']
),
true
);
if($parent['type'] == 'A') {
$parent = qa_db_read_one_assoc(
qa_db_query_sub(
'SELECT * FROM ^posts WHERE postid=#',
$parent['parentid']
),
true
);
}
$url = qa_q_path($parent['postid'], $parent['title'], true,$event=='a_post'?'A':'C',$params['postid']);
$title=$parent['title'];
$type = ($event == 'a_post'?'answer':'comment');
$subs = array(
);
qa_send_notification(null, qa_opt('feedback_email'), null, qa_lang('admin_plus/posted_subject'), qa_lang('admin_plus/posted_body'), array(
'^post_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'),
'^post_type'=> $type,
'^post_title'=> $title,
'^post_content'=> $params['content'],
'^site_url'=> qa_opt('site_url'),
'^url'=> $url,
));
}
function getEmail($userid) {
require_once QA_INCLUDE_DIR.'qa-db-selects.php';
if (QA_FINAL_EXTERNAL_USERS) {
$email=qa_get_user_email($userid);
} else {
$useraccount=qa_db_select_with_pending(
qa_db_user_account_selectspec($userid, true)
);
$email=@$useraccount['email'];
}
return $email;
}
}