-
Notifications
You must be signed in to change notification settings - Fork 16
/
ocf_general_action2.php
executable file
·186 lines (161 loc) · 6.07 KB
/
ocf_general_action2.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php /*
ocPortal
Copyright (c) ocProducts, 2004-2012
See text/EN/licence.txt for full licencing information.
NOTE TO PROGRAMMERS:
Do not edit this file. If you need to make changes, save your changed file to the appropriate *_custom folder
**** If you ignore this advice, then your website upgrades (e.g. for bug fixes) will likely kill your changes ****
*/
/**
* @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
* @copyright ocProducts Ltd
* @package core_ocf
*/
/**
* Edit a post template.
*
* @param AUTO_LINK The ID of the post template to edit.
* @param SHORT_TEXT The title for the template.
* @param LONG_TEXT The text of the template.
* @param SHORT_TEXT The multi code specifying which forums this is applicable in.
* @param BINARY Whether to use this as the default post in applicable forum.
*/
function ocf_edit_post_template($id,$title,$text,$forum_multi_code,$use_default_forums)
{
$GLOBALS['FORUM_DB']->query_update('f_post_templates',array(
't_title'=>$title,
't_text'=>$text,
't_forum_multi_code'=>$forum_multi_code,
't_use_default_forums'=>$use_default_forums
),array('id'=>$id),'',1);
log_it('EDIT_POST_TEMPLATE',strval($id),$title);
}
/**
* Delete a post template.
*
* @param AUTO_LINK The ID of the post template to delete.
*/
function ocf_delete_post_template($id)
{
$GLOBALS['FORUM_DB']->query_delete('f_post_templates',array('id'=>$id),'',1);
log_it('DELETE_POST_TEMPLATE',strval($id));
}
/**
* Edit an emoticon.
*
* @param SHORT_TEXT The textual code entered to make the emoticon appear.
* @param SHORT_TEXT The old textual code.
* @param ID_TEXT The image code used for the emoticon.
* @param integer The relevance level.
* @range 0 4
* @param BINARY Whether this may be used as a topic emoticon.
* @param BINARY Whether this may only be used by privileged members
*/
function ocf_edit_emoticon($old_code,$code,$theme_img_code,$relevance_level,$use_topics,$is_special=0)
{
if ($code!=$old_code)
{
$test=$GLOBALS['FORUM_DB']->query_value_null_ok('f_emoticons','e_code',array('e_code'=>$code));
if (!is_null($test)) warn_exit(do_lang_tempcode('CONFLICTING_EMOTICON_CODE',escape_html($code)));
}
$old_theme_img_code=$GLOBALS['FORUM_DB']->query_value('f_emoticons','e_theme_img_code',array('e_code'=>$old_code));
$GLOBALS['FORUM_DB']->query_update('f_emoticons',array(
'e_code'=>$code,
'e_theme_img_code'=>$theme_img_code,
'e_relevance_level'=>$relevance_level,
'e_use_topics'=>$use_topics,
'e_is_special'=>$is_special
),array('e_code'=>$old_code),'',1);
require_code('themes2');
tidy_theme_img_code($theme_img_code,$old_theme_img_code,'f_emoticons','e_theme_img_code');
log_it('EDIT_EMOTICON',$code,$theme_img_code);
}
/**
* Delete an emoticon.
*
* @param SHORT_TEXT The ID of the emoticon to delete.
*/
function ocf_delete_emoticon($code)
{
$old_theme_img_code=$GLOBALS['FORUM_DB']->query_value('f_emoticons','e_theme_img_code',array('e_code'=>$code));
$GLOBALS['FORUM_DB']->query_delete('f_emoticons',array('e_code'=>$code),'',1);
require_code('themes2');
tidy_theme_img_code(NULL,$old_theme_img_code,'f_emoticons','e_theme_img_code');
log_it('DELETE_EMOTICON',$code);
}
/**
* Edit a Welcome E-mail.
*
* @param AUTO_LINK The ID
* @param SHORT_TEXT A name for the Welcome E-mail
* @param SHORT_TEXT The subject of the Welcome E-mail
* @param LONG_TEXT The message body of the Welcome E-mail
* @param integer The number of hours before sending the e-mail
* @param ?AUTO_LINK What newsletter to send out to instead of members (NULL: none)
*/
function ocf_edit_welcome_email($id,$name,$subject,$text,$send_time,$newsletter)
{
$_subject=$GLOBALS['SITE_DB']->query_value('f_welcome_emails','w_subject',array('id'=>$id));
$_text=$GLOBALS['SITE_DB']->query_value('f_welcome_emails','w_text',array('id'=>$id));
$GLOBALS['SITE_DB']->query_update('f_welcome_emails',array('w_name'=>$name,'w_newsletter'=>$newsletter,'w_subject'=>lang_remap($_subject,$subject),'w_text'=>lang_remap($_text,$text),'w_send_time'=>$send_time),array('id'=>$id),'',1);
log_it('EDIT_WELCOME_EMAIL',strval($id),get_translated_text($_subject));
}
/**
* Delete a Welcome E-mail.
*
* @param AUTO_LINK The ID
*/
function ocf_delete_welcome_email($id)
{
$_subject=$GLOBALS['SITE_DB']->query_value('f_welcome_emails','w_subject',array('id'=>$id));
$_text=$GLOBALS['SITE_DB']->query_value('f_welcome_emails','w_text',array('id'=>$id));
log_it('DELETE_WELCOME_EMAIL',strval($id),get_translated_text($_subject));
$GLOBALS['SITE_DB']->query_delete('f_welcome_emails',array('id'=>$id),'',1);
delete_lang($_subject);
delete_lang($_text);
}
/**
* Get a form field for editing a forum multi code, set up with a default of the given forum multi code.
*
* @param SHORT_TEXT The multi code.
* @return tempcode The form field.
*/
function ocf_get_forum_multi_code_field($forum_multi_code)
{
require_code('form_templates');
if ($forum_multi_code!='')
{
$selected=array_map('intval',explode(',',substr($forum_multi_code,1)));
$type=$forum_multi_code[0];
} else
{
$selected=NULL;
$type='+';
}
require_code('ocf_forums2');
$list=ocf_get_forum_tree_secure(NULL,NULL,true,$selected);
return form_input_all_and_not(do_lang_tempcode('SECTION_FORUMS'),do_lang_tempcode('USE_IN_ALL_FORUMS'),'forum_multi_code',$list,$type);
}
/**
* Log a moderation action.
*
* @param ID_TEXT The type of moderation.
* @param SHORT_TEXT First detailing parameter.
* @param SHORT_TEXT Second detailing parameter.
* @param LONG_TEXT The reason for the moderation (may be blank).
* @param ?MEMBER The member performing the moderation (NULL: current member).
* @param ?TIME The time of the moderation (NULL: just now).
*/
function ocf_mod_log_it($the_type,$param_a='',$param_b='',$reason='',$by=NULL,$date_and_time=NULL)
{
if (is_null($date_and_time)) $date_and_time=time();
if (is_null($by)) $by=get_member();
$GLOBALS['FORUM_DB']->query_insert('f_moderator_logs',array(
'l_the_type'=>$the_type,
'l_param_a'=>$param_a,
'l_param_b'=>$param_b,
'l_date_and_time'=>$date_and_time,
'l_reason'=>$reason,
'l_by'=>$by
));
}