ocPortal Developer's Guide: OCF posts
» Return to Contents
sources/ocf_posts.php
Global_functions_ocf_posts.php
void init__ocf_posts()
Standard code module initialisation function.
Parameters…
(No return value)
function init__ocf_posts()
{
global $SIGNATURES_CACHE;
$SIGNATURES_CACHE=array();
}
boolean ocf_may_post_in_topic(AUTO_LINK forum_id, AUTO_LINK topic_id, ?MEMBER last_member_id, ?MEMBER member_id)
Find whether a member may post in a certain topic.
Parameters…
| Name |
forum_id |
| Description |
The forum ID of the forum the topic is in. |
| Type |
AUTO_LINK |
| Name |
topic_id |
| Description |
The topic ID is in. |
| Type |
AUTO_LINK |
| Name |
last_member_id |
| Description |
The last poster in the topic (NULL: do not check for double posting). |
| Default value |
|
| Type |
?MEMBER |
| Name |
member_id |
| Description |
The member (NULL: current member). |
| Default value |
|
| Type |
?MEMBER |
Returns…
| Description |
The answer. |
| Type |
boolean |
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;
}
boolean ocf_may_edit_post_by(MEMBER resource_owner, ?AUTO_LINK forum_id, ?MEMBER member_id)
Find whether a member may edit the detailed post.
Parameters…
| Name |
resource_owner |
| Description |
The owner of the post. |
| Type |
MEMBER |
| Name |
forum_id |
| Description |
The forum the post is in (NULL: is a Private Topic). |
| Type |
?AUTO_LINK |
| Name |
member_id |
| Description |
The member (NULL: current member). |
| Default value |
|
| Type |
?MEMBER |
Returns…
| Description |
The answer. |
| Type |
boolean |
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));
}
boolean ocf_may_delete_post_by(MEMBER resource_owner, ?AUTO_LINK forum_id, ?MEMBER member_id)
Find whether a member may delete the detailed post.
Parameters…
| Name |
resource_owner |
| Description |
The owner of the post. |
| Type |
MEMBER |
| Name |
forum_id |
| Description |
The forum the post is in (NULL: is a Private Topic). |
| Type |
?AUTO_LINK |
| Name |
member_id |
| Description |
The member (NULL: current member). |
| Default value |
|
| Type |
?MEMBER |
Returns…
| Description |
The answer. |
| Type |
boolean |
function ocf_may_delete_post_by($resource_owner,$forum_id,$member_id=NULL)
{
if (is_null($member_id)) $member_id=get_member();
if (!has_category_access($member_id,'forums',strval($forum_id))) return false;
if (is_null($forum_id))
{
if (($resource_owner!=$member_id) || (!has_specific_permission($member_id,'delete_personal_topic_posts'))) return false;
}
return has_delete_permission('low',$member_id,$resource_owner,'topics',array('forums',$forum_id));
}
array ocf_display_spacer_post(ID_TEXT linked_type, ID_TEXT linked_id)
Try and make a spacer post look nicer on OCF than it automatically would.
Parameters…
| Name |
linked_type |
| Description |
Content type. |
| Type |
ID_TEXT |
| Name |
linked_id |
| Description |
Content ID. |
| Type |
ID_TEXT |
Returns…
| Description |
A pair: better description (may be NULL), better post (may be NULL). |
| Type |
array |
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);
}
sources/ocf_posts_action.php
Global_functions_ocf_posts_action.php
Function summary
|
void
|
init__ocf_posts_action ()
|
|
?array
|
ocf_check_post (LONG_TEXT post, ?AUTO_LINK topic_id, ?MEMBER poster)
|
|
AUTO_LINK
|
ocf_make_post (AUTO_LINK topic_id, SHORT_TEXT title, LONG_TEXT post, BINARY skip_sig, boolean is_starter, ?BINARY validated, BINARY is_emphasised, ?string poster_name_if_guest, ?IP ip_address, ?TIME time, ?MEMBER poster, ?MEMBER intended_solely_for, ?TIME last_edit_time, ?MEMBER last_edit_by, boolean check_permissions, boolean update_cacheing, ?AUTO_LINK forum_id, boolean support_attachments, ?string topic_title, BINARY sunk, ?AUTO_LINK id, boolean anonymous, boolean skip_post_checks, boolean is_pt, boolean insert_comcode_as_admin, ?AUTO_LINK parent_id)
|
|
void
|
ocf_force_update_member_post_count (MEMBER member_id, ?integer member_post_count_dif)
|
|
void
|
ocf_decache_ocp_blocks (AUTO_LINK updated_forum_id, ?string forum_name, ?MEMBER member)
|
void init__ocf_posts_action()
Standard code module initialisation function.
Parameters…
(No return value)
function init__ocf_posts_action()
{
global $ALL_FORUM_POST_COUNT_INFO;
$ALL_FORUM_POST_COUNT_INFO=NULL;
}
?array ocf_check_post(LONG_TEXT post, ?AUTO_LINK topic_id, ?MEMBER poster)
Check a post would be valid.
Parameters…
| Name |
post |
| Description |
The post. |
| Type |
LONG_TEXT |
| Name |
topic_id |
| Description |
The ID of the topic the post would be in (NULL: don't check with regard to any particular topic). |
| Default value |
|
| Type |
?AUTO_LINK |
| Name |
poster |
| Description |
The poster (NULL: current member). |
| Default value |
|
| Type |
?MEMBER |
Returns…
| Description |
Row of the existing post if a double post (single row map-element in a list of rows) (NULL: not a double post). |
| Type |
?array |
function ocf_check_post($post,$topic_id=NULL,$poster=NULL)
{
if (is_null($poster)) $poster=get_member();
require_code('comcode_check');
check_comcode($post,NULL,false,NULL,true);
if (strlen($post)==0)
{
warn_exit(do_lang_tempcode('POST_TOO_SHORT'));
}
require_code('ocf_groups');
if (strlen($post)>ocf_get_member_best_group_property($poster,'max_post_length_comcode'))
{
warn_exit(make_string_tempcode(escape_html(do_lang('_POST_TOO_LONG'))));
}
if (!is_null($topic_id))
{
if (running_script('stress_test_loader')) return NULL;
// Check this isn't the same as the last post here
$last_posts=$GLOBALS['FORUM_DB']->query_select('f_posts',array('p_post','p_poster','p_ip_address'),array('p_topic_id'=>$topic_id),'ORDER BY p_time DESC,id DESC',1);
if (array_key_exists(0,$last_posts))
{
if (($last_posts[0]['p_poster']==$GLOBALS['OCF_DRIVER']->get_guest_id()) && (get_ip_address()!=$last_posts[0]['p_ip_address']))
$last_posts[0]['p_poster']=-1;
if (($last_posts[0]['p_poster']==$poster) && (get_translated_text($last_posts[0]['p_post'],$GLOBALS['FORUM_DB'])==$post) && (get_param_integer('keep_debug_notifications',0)!=1))
warn_exit(do_lang_tempcode('DOUBLE_POST_PREVENTED'));
}
return $last_posts;
}
}
AUTO_LINK ocf_make_post(AUTO_LINK topic_id, SHORT_TEXT title, LONG_TEXT post, BINARY skip_sig, boolean is_starter, ?BINARY validated, BINARY is_emphasised, ?string poster_name_if_guest, ?IP ip_address, ?TIME time, ?MEMBER poster, ?MEMBER intended_solely_for, ?TIME last_edit_time, ?MEMBER last_edit_by, boolean check_permissions, boolean update_cacheing, ?AUTO_LINK forum_id, boolean support_attachments, ?string topic_title, BINARY sunk, ?AUTO_LINK id, boolean anonymous, boolean skip_post_checks, boolean is_pt, boolean insert_comcode_as_admin, ?AUTO_LINK parent_id)
Add a post.
Parameters…
| Name |
topic_id |
| Description |
The ID of the topic to add the post to. |
| Type |
AUTO_LINK |
| Name |
title |
| Description |
The title of the post (may be blank). |
| Type |
SHORT_TEXT |
| Name |
post |
| Description |
The post. |
| Type |
LONG_TEXT |
| Name |
skip_sig |
| Description |
Whether to skip showing the posters signature in the post. |
| Default value |
0 |
| Type |
BINARY |
| Name |
is_starter |
| Description |
Whether the post is the first in the topic. |
| Default value |
boolean-false |
| Type |
boolean |
| Name |
validated |
| Description |
Whether the post is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). |
| Default value |
|
| Type |
?BINARY |
| Name |
is_emphasised |
| Description |
Whether the post is marked emphasised. |
| Default value |
0 |
| Type |
BINARY |
| Name |
poster_name_if_guest |
| Description |
The name of the person making the post (NULL: username of current member). |
| Default value |
|
| Type |
?string |
| Name |
ip_address |
| Description |
The IP address the post is to be made under (NULL: IP of current user). |
| Default value |
|
| Type |
?IP |
| Name |
time |
| Description |
The time of the post (NULL: now). |
| Default value |
|
| Type |
?TIME |
| Name |
poster |
| Description |
The poster (NULL: current member). |
| Default value |
|
| Type |
?MEMBER |
| Name |
intended_solely_for |
| Description |
The member that this post is intended solely for (NULL: public). |
| Default value |
|
| Type |
?MEMBER |
| Name |
last_edit_time |
| Description |
The last edit time of the post (NULL: never edited). |
| Default value |
|
| Type |
?TIME |
| Name |
last_edit_by |
| Description |
The member that was last to edit the post (NULL: never edited). |
| Default value |
|
| Type |
?MEMBER |
| Name |
check_permissions |
| Description |
Whether to check permissions for whether the post may be made as it is given. |
| Default value |
boolean-true |
| Type |
boolean |
| Name |
update_cacheing |
| Description |
Whether to update the caches after making the post. |
| Default value |
boolean-true |
| Type |
boolean |
| Name |
forum_id |
| Description |
The forum the post will be in (NULL: find out from the DB). |
| Default value |
|
| Type |
?AUTO_LINK |
| Name |
support_attachments |
| Description |
Whether to allow attachments in this post. |
| Default value |
boolean-true |
| Type |
boolean |
| Name |
topic_title |
| Description |
The title of the topic (NULL: find from the DB). |
| Default value |
|
| Type |
?string |
| Name |
sunk |
| Description |
Whether the topic is a sunk topic. |
| Default value |
0 |
| Type |
BINARY |
| Name |
id |
| Description |
Force an ID (NULL: don't force an ID) |
| Default value |
|
| Type |
?AUTO_LINK |
| Name |
anonymous |
| Description |
Whether to make the post anonymous |
| Default value |
boolean-false |
| Type |
boolean |
| Name |
skip_post_checks |
| Description |
Whether to skip post checks |
| Default value |
boolean-false |
| Type |
boolean |
| Name |
is_pt |
| Description |
Whether this is for a new Private Topic |
| Default value |
boolean-false |
| Type |
boolean |
| Name |
insert_comcode_as_admin |
| Description |
Whether to explicitly insert the Comcode with admin privileges |
| Default value |
boolean-false |
| Type |
boolean |
| Name |
parent_id |
| Description |
Parent post ID (NULL: none-threaded/root-of-thread) |
| Default value |
|
| Type |
?AUTO_LINK |
Returns…
| Description |
The ID of the new post. |
| Type |
AUTO_LINK |
function ocf_make_post($topic_id,$title,$post,$skip_sig=0,$is_starter=false,$validated=NULL,$is_emphasised=0,$poster_name_if_guest=NULL,$ip_address=NULL,$time=NULL,$poster=NULL,$intended_solely_for=NULL,$last_edit_time=NULL,$last_edit_by=NULL,$check_permissions=true,$update_cacheing=true,$forum_id=NULL,$support_attachments=true,$topic_title='',$sunk=0,$id=NULL,$anonymous=false,$skip_post_checks=false,$is_pt=false,$insert_comcode_as_admin=false,$parent_id=NULL)
{
if (is_null($poster)) $poster=get_member();
if ($check_permissions)
{
if (strlen($title)>120)
{
warn_exit(do_lang_tempcode('TITLE_TOO_LONG'));
}
if (get_option('prevent_shouting')=='1')
{
if (strtoupper($title)==$title) $title=ucwords($title);
}
if ((is_null($intended_solely_for)) && (!$skip_post_checks))
{
ocf_check_post($post,$topic_id,$poster);
}
}
if (is_null($ip_address)) $ip_address=get_ip_address();
if (is_null($time))
{
$time=time();
$send_notification=true;
} else
{
$send_notification=false;
}
if (is_null($poster_name_if_guest))
{
if (($poster==$GLOBALS['OCF_DRIVER']->get_guest_id()) || ($anonymous))
{
$poster_name_if_guest=do_lang('GUEST');
}
else
{
$poster_name_if_guest=$GLOBALS['OCF_DRIVER']->get_username($poster);
if (is_null($poster_name_if_guest)) $poster_name_if_guest=do_lang('UNKNOWN');
}
}
if ((is_null($forum_id)) || (($topic_title=='') && (!$is_starter)))
{
$info=$GLOBALS['FORUM_DB']->query_select('f_topics',array('t_is_open','t_pt_from','t_pt_to','t_forum_id','t_cache_last_member_id','t_cache_first_title'),array('id'=>$topic_id),'',1);
if (!array_key_exists(0,$info))
{
warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
}
$forum_id=$info[0]['t_forum_id'];
$topic_title=$info[0]['t_cache_first_title'];
if ($topic_title=='') $topic_title=$title;
if ($check_permissions)
{
if (((($info[0]['t_pt_from']!=$poster) && ($info[0]['t_pt_to']!=$poster) && (!ocf_has_special_pt_access($topic_id))) && (!has_specific_permission($poster,'view_other_pt')) && (is_null($forum_id))))
access_denied('I_ERROR');
}
}
if (is_null($forum_id))
{
if (($check_permissions) && ($poster==$GLOBALS['OCF_DRIVER']->get_guest_id()))
access_denied('I_ERROR');
$validated=1; // Personal posts always validated
} else
{
if ($check_permissions)
{
if (($info[0]['t_is_open']==0) && (!ocf_may_moderate_forum($forum_id))) access_denied('I_ERROR');
$last_member_id=$info[0]['t_cache_last_member_id'];
if (!ocf_may_post_in_topic($forum_id,$topic_id,$last_member_id))
access_denied('I_ERROR');
}
}
if ((is_null($validated)) || (($validated==1) && ($check_permissions)))
{
if ((!is_null($forum_id)) && (!has_specific_permission($poster,'bypass_validation_lowrange_content','topics',array('forums',$forum_id)))) $validated=0; else $validated=1;
}
if (!$support_attachments)
{
$lang_id=insert_lang_comcode($post,4,$GLOBALS['FORUM_DB'],$insert_comcode_as_admin);
} else
{
$lang_id=0;
}
if (!addon_installed('unvalidated')) $validated=1;
$map=array(
'p_title'=>$title,
'p_post'=>$lang_id,
'p_ip_address'=>$ip_address,
'p_time'=>$time,
'p_poster'=>$anonymous?db_get_first_id():$poster,
'p_poster_name_if_guest'=>$poster_name_if_guest,
'p_validated'=>$validated,
'p_topic_id'=>$topic_id,
'p_is_emphasised'=>$is_emphasised,
'p_cache_forum_id'=>$forum_id,
'p_last_edit_time'=>$last_edit_time,
'p_last_edit_by'=>$last_edit_by,
'p_intended_solely_for'=>$intended_solely_for,
'p_skip_sig'=>$skip_sig,
'p_parent_id'=>$parent_id
);
if (!is_null($id)) $map['id']=$id;
$post_id=$GLOBALS['FORUM_DB']->query_insert('f_posts',$map,true);
if ($support_attachments)
{
require_code('attachments2');
$lang_id=insert_lang_comcode_attachments(4,$post,'ocf_post',strval($post_id),$GLOBALS['FORUM_DB']);
$GLOBALS['FORUM_DB']->query_update('f_posts',array('p_post'=>$lang_id),array('id'=>$post_id),'',1);
}
if (($validated==0) || ($check_permissions))
{
$_url=build_url(array('page'=>'topicview','type'=>'findpost','id'=>$post_id),'forum',NULL,false,false,true,'post_'.strval($post_id));
$url=$_url->evaluate();
}
if ($validated==0)
{
if ($check_permissions)
{
// send_validation_mail is used for other content - but forum is special
$subject=do_lang('POST_REQUIRING_VALIDATION_MAIL_SUBJECT',$topic_title,NULL,NULL,get_site_default_lang());
$post_text=get_translated_text($lang_id,$GLOBALS['FORUM_DB'],get_site_default_lang());
$mail=do_lang('POST_REQUIRING_VALIDATION_MAIL',comcode_escape($url),comcode_escape($poster_name_if_guest),$post_text);
require_code('notifications');
dispatch_notification('needs_validation',NULL/*'ocf_forum:'.strval($forum_id)*/,$subject,$mail);
}
} else
{
if ($check_permissions) // Not automated, so we'll have to be doing run-time progressing too
{
if ($send_notification)
{
$post_comcode=get_translated_text($lang_id,$GLOBALS['FORUM_DB']);
require_code('ocf_posts_action2');
ocf_send_topic_notification($url,$topic_id,$forum_id,$anonymous?db_get_first_id():$poster,$is_starter,$post_comcode,$topic_title,$intended_solely_for,$is_pt);
// Send a notification for the inline PP
if (!is_null($intended_solely_for))
{
require_code('notifications');
$msubject=do_lang('NEW_PERSONAL_POST_SUBJECT',$topic_title,NULL,NULL,get_lang($intended_solely_for));
$mmessage=do_lang('NEW_PERSONAL_POST_MESSAGE',comcode_escape($GLOBALS['FORUM_DRIVER']->get_username($anonymous?db_get_first_id():$poster)),comcode_escape($topic_title),array(comcode_escape($url),$post_comcode),get_lang($intended_solely_for));
dispatch_notification('ocf_new_pt',NULL,$msubject,$mmessage,array($intended_solely_for),$anonymous?db_get_first_id():$poster);
}
}
}
}
if ($check_permissions) // Not automated, so we'll have to be doing run-time progressing too
{
// Is the user gonna automatically enable notifications for this?
$auto_monitor_contrib_content=$GLOBALS['OCF_DRIVER']->get_member_row_field($poster,'m_auto_monitor_contrib_content');
if ($auto_monitor_contrib_content==1)
{
require_code('notifications');
enable_notifications('ocf_topic',strval($topic_id),$poster);
}
}
if ($update_cacheing)
{
if (function_exists('get_member'))
{
if (function_exists('ocf_ping_topic_read'))
ocf_ping_topic_read($topic_id);
if (is_null($forum_id))
{
$with=$info[0]['t_pt_from'];
if ($with==$poster) $with=$info[0]['t_pt_to'];
decache('side_ocf_personal_topics',array($with));
decache('_new_pp',array($with));
}
if (get_option('show_post_validation')=='1') decache('main_staff_checklist');
}
if (is_null($intended_solely_for))
{
if (($validated==1)/* || ($is_starter)*/)
{
require_code('ocf_posts_action2');
ocf_force_update_topic_cacheing($topic_id,1,true,$is_starter,$post_id,$time,$title,$lang_id,$poster_name_if_guest,$poster);
}
if ($validated==1)
{
if (!is_null($forum_id))
{
/*if ($sunk==1) Don't like this
{
$GLOBALS['FORUM_DB']->query('UPDATE '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_forums SET f_cache_num_topics=(f_cache_num_topics+'.(($is_starter)?'1':'0').'),f_cache_num_posts=(f_cache_num_posts+1) WHERE id='.strval((integer)$topic_id));
} else*/
{
require_code('ocf_posts_action2');
// Find if the topic is validated. This can be approximate, if we don't get 1 then ocf_force_update_forum_cacheing will do a search, making the code very slightly slower
if ((!$check_permissions) || (is_null($forum_id)))
{
$topic_validated=1;
} else
{
if ($is_starter)
{
$topic_validated=has_specific_permission($poster,'bypass_validation_midrange_content','topics',array('forums',$forum_id))?1:0;
} else
{
$topic_validated=$GLOBALS['FORUM_DB']->query_value('f_topics','t_validated',array('id'=>$topic_id));
}
}
ocf_force_update_forum_cacheing($forum_id,($is_starter)?1:0,1,($topic_validated==0)?NULL:$topic_id,($topic_validated==0)?NULL:$topic_title,($topic_validated==0)?NULL:$time,($topic_validated==0)?NULL:$poster_name_if_guest,($topic_validated==0)?NULL:$poster,($topic_validated==0)?NULL:$forum_id);
}
}
}
}
// Update post count
if (!is_null($forum_id))
{
$post_counts=is_null($forum_id)?1:$GLOBALS['FORUM_DB']->query_value_null_ok('f_forums','f_post_count_increment',array('id'=>$forum_id));
if (($post_counts===1) && (!$anonymous)) ocf_force_update_member_post_count($poster,1);
if ($check_permissions) ocf_decache_ocp_blocks($forum_id,NULL,$intended_solely_for); // i.e. we don't run this if in installer
}
if ($poster!=$GLOBALS['OCF_DRIVER']->get_guest_id())
{
require_code('ocf_posts_action2');
ocf_member_handle_promotion($poster);
}
}
return $post_id;
}
void ocf_force_update_member_post_count(MEMBER member_id, ?integer member_post_count_dif)
Force a members post count to be recalculated.
Parameters…
| Name |
member_id |
| Description |
The member. |
| Type |
MEMBER |
| Name |
member_post_count_dif |
| Description |
The amount to add to the post count (NULL: fully recalculate the post count). |
| Default value |
|
| Type |
?integer |
(No return value)
function ocf_force_update_member_post_count($member_id,$member_post_count_dif=NULL)
{
if ($GLOBALS['OCF_DRIVER']->get_guest_id()==$member_id) return;
if (get_db_type()=='xml') return;
if (is_null($member_post_count_dif))
{
// This is gonna take a while!!
global $ALL_FORUM_POST_COUNT_INFO;
if (is_null($ALL_FORUM_POST_COUNT_INFO))
{
$ALL_FORUM_POST_COUNT_INFO=collapse_2d_complexity('id','f_post_count_increment',$GLOBALS['FORUM_DB']->query('SELECT id,f_post_count_increment FROM '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_forums WHERE f_cache_num_posts>0'));
}
$member_post_count=0;
foreach ($ALL_FORUM_POST_COUNT_INFO as $forum_id=>$post_count_increment)
{
if ($post_count_increment==1)
{
$member_post_count+=$GLOBALS['FORUM_DB']->query_value('f_posts','COUNT(*)',array('p_poster'=>$member_id,'p_cache_forum_id'=>$forum_id));
}
}
$member_post_count+=$GLOBALS['FORUM_DB']->query_value('f_posts','COUNT(*)',array('p_poster'=>$member_id,'p_cache_forum_id'=>NULL));
$GLOBALS['FORUM_DB']->query('UPDATE '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_members SET m_cache_num_posts='.strval((integer)$member_post_count).' WHERE id='.strval((integer)$member_id));
}
else
{
$GLOBALS['FORUM_DB']->query('UPDATE '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_members SET m_cache_num_posts=(m_cache_num_posts+'.strval((integer)$member_post_count_dif).') WHERE id='.strval((integer)$member_id));
}
}
void ocf_decache_ocp_blocks(AUTO_LINK updated_forum_id, ?string forum_name, ?MEMBER member)
Decache cached OCF elements depending on a certain forum, and optionally a certain member.
Parameters…
| Name |
updated_forum_id |
| Description |
The ID of the forum. |
| Type |
AUTO_LINK |
| Name |
forum_name |
| Description |
The name of the forum (NULL: find it from the DB). |
| Default value |
|
| Type |
?string |
| Name |
member |
| Description |
The member (NULL: do no member decacheing). |
| Default value |
|
| Type |
?MEMBER |
(No return value)
function ocf_decache_ocp_blocks($updated_forum_id,$forum_name=NULL,$member=NULL)
{
if (is_null($forum_name)) $forum_name=$GLOBALS['FORUM_DB']->query_value('f_forums','f_name',array('id'=>$updated_forum_id));
decache('main_forum_news');
decache('main_forum_topics');
decache('side_forum_news');
decache('bottom_news',array($forum_name));
if (!is_null($member))
{
decache('side_ocf_personal_topics',array($member));
decache('_new_pp',array($member));
}
}
0 reviews: Unrated (average)
There have been no comments yet