-
Notifications
You must be signed in to change notification settings - Fork 16
/
ocf_posts.php
132 lines (108 loc) · 4.29 KB
/
ocf_posts.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
<?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
*/
/**
* Standard code module initialisation function.
*/
function init__ocf_posts()
{
global $SIGNATURES_CACHE;
$SIGNATURES_CACHE=array();
}
/**
* Find whether a member may post in a certain topic.
*
* @param AUTO_LINK The forum ID of the forum the topic is in.
* @param AUTO_LINK The topic ID is in.
* @param ?MEMBER The last poster in the topic (NULL: do not check for double posting).
* @param ?MEMBER The member (NULL: current member).
* @return boolean The answer.
*/
function ocf_may_post_in_topic($forum_id,$topic_id,$last_member_id=NULL,$member_id=NULL)
{
if (is_null($member_id)) $member_id=get_member();
if (!has_specific_permission($member_id,'submit_lowrange_content','topics',array('forums',$forum_id,'topics',$topic_id))) return false;
if (is_null($last_member_id)) return true;
if (($last_member_id==$member_id) && (!is_null($forum_id)))
{
if (!has_specific_permission($member_id,'double_post')) return false;
}
/*$test=$GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT id FROM '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_warnings WHERE (p_silence_from_topic='.strval($topic_id).' OR p_silence_from_forum='.strval($forum_id).') AND w_member_id='.strval($member_id));
if (!is_null($test)) return false;*/
return true;
}
/**
* Find whether a member may edit the detailed post.
*
* @param MEMBER The owner of the post.
* @param ?AUTO_LINK The forum the post is in (NULL: is a Private Topic).
* @param ?MEMBER The member (NULL: current member).
* @return boolean The answer.
*/
function ocf_may_edit_post_by($resource_owner,$forum_id,$member_id=NULL)
{
if (is_null($member_id)) $member_id=get_member();
if (is_null($forum_id))
{
if (($resource_owner==$member_id) && (has_specific_permission($member_id,'edit_personal_topic_posts'))) return true;
}
if (!has_category_access($member_id,'forums',strval($forum_id))) return false;
return has_edit_permission('low',$member_id,$resource_owner,'topics',array('forums',$forum_id));
}
/**
* Find whether a member may delete the detailed post.
*
* @param MEMBER The owner of the post.
* @param ?AUTO_LINK The forum the post is in (NULL: is a Private Topic).
* @param ?MEMBER The member (NULL: current member).
* @return boolean The answer.
*/
function ocf_may_delete_post_by($resource_owner,$forum_id,$member_id=NULL)
{
if (is_null($member_id)) $member_id=get_member();
if (is_null($forum_id))
{
if (($resource_owner!=$member_id) || (!has_specific_permission($member_id,'delete_personal_topic_posts'))) return false;
}
if (is_null($forum_id)) return false;
if (!has_category_access($member_id,'forums',strval($forum_id))) return false;
return has_delete_permission('low',$member_id,$resource_owner,'topics',array('forums',$forum_id));
}
/**
* Try and make a spacer post look nicer on OCF than it automatically would.
*
* @param ID_TEXT Content type.
* @param ID_TEXT Content ID.
* @return array A pair: better description (may be NULL), better post (may be NULL).
*/
function ocf_display_spacer_post($linked_type,$linked_id)
{
$new_description=mixed();
$new_post=mixed();
if (addon_installed('awards'))
{
require_code('content');
$linked_type=convert_ocportal_type_codes('feedback_type_code',$linked_type,'award_hook');
if ($linked_type!='')
{
require_code('hooks/systems/awards/'.$linked_type);
$award_ob=object_factory('Hook_awards_'.$linked_type);
$award_info=$award_ob->info();
$linked_rows=$GLOBALS['SITE_DB']->query_select($award_info['table'],array('*'),array($award_info['id_field']=>$award_info['id_is_string']?$linked_id:intval($linked_id)),'',1);
if (array_key_exists(0,$linked_rows))
$new_post=$award_ob->run($linked_rows[0],'_SEARCH');
$new_description=do_lang('THIS_IS_COMMENT_TOPIC',get_site_name());
}
}
return array($new_description,$new_post);
}