ocPortal Developer's Guide: OCF
» Return to Contents
sources/ocf_general.php
Global_functions_ocf_general.php
array ocf_get_forums_stats()
Get some forum stats.
Parameters…
Returns…
| Description |
A map of forum stats. |
| Type |
array |
function ocf_get_forums_stats()
{
$out=array();
$out['num_topics']=$GLOBALS['OCF_DRIVER']->get_topics();
$out['num_posts']=$GLOBALS['OCF_DRIVER']->get_num_forum_posts();
$out['num_members']=$GLOBALS['OCF_DRIVER']->get_members();
$temp=get_value_newer_than('ocf_newest_member_id',time()-60*60*1);
$out['newest_member_id']=is_null($temp)?NULL:intval($temp);
if (!is_null($out['newest_member_id']))
{
$out['newest_member_username']=get_value_newer_than('ocf_newest_member_username',time()-60*60*1);
} else
{
$out['newest_member_username']=NULL;
}
$out['newest_member_username']=NULL;
if (is_null($out['newest_member_username']))
{
$newest_member=$GLOBALS['FORUM_DB']->query('SELECT m_username,id FROM '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_members WHERE m_validated=1 AND id<>'.strval($GLOBALS['FORUM_DRIVER']->get_guest_id()).' ORDER BY m_join_time DESC',1); // Only ordered by m_join_time and not double ordered with ID to make much faster in MySQL
$out['newest_member_id']=$newest_member[0]['id'];
$out['newest_member_username']=$newest_member[0]['m_username'];
if (get_db_type()!='xml')
{
set_value('ocf_newest_member_id',strval($out['newest_member_id']));
set_value('ocf_newest_member_username',$out['newest_member_username']);
}
}
return $out;
}
array ocf_read_in_member_profile(MEMBER member_id, boolean lite)
Get details on a member profile.
Parameters…
| Name |
member_id |
| Description |
The member to get details of. |
| Type |
MEMBER |
| Name |
lite |
| Description |
Whether to get a 'lite' version (contains less detail, therefore less costly). |
| Default value |
boolean-true |
| Type |
boolean |
Returns…
| Description |
A map of details. |
| Type |
array |
function ocf_read_in_member_profile($member_id,$lite=true)
{
$row=$GLOBALS['OCF_DRIVER']->get_member_row($member_id);
if (is_null($row)) return array();
$last_visit_time=(($member_id==get_member()) && (array_key_exists('last_visit',$_COOKIE)))?intval($_COOKIE['last_visit']):$row['m_last_visit_time'];
$join_time=$row['m_join_time'];
$out=array(
'username'=>$row['m_username'],
'last_visit_time'=>$last_visit_time,
'last_visit_time_string'=>get_timezoned_date($last_visit_time),
'signature'=>$row['m_signature'],
'posts'=>$row['m_cache_num_posts'],
'join_time'=>$join_time,
'join_time_string'=>get_timezoned_date($join_time),
);
if (addon_installed('points'))
{
require_code('points');
$num_points=total_points($member_id);
$out['points']=$num_points;
}
if (!$lite)
{
$out['groups']=ocf_get_members_groups($member_id);
// Custom fields
$out['custom_fields']=ocf_get_all_custom_fields_match_member($member_id,((get_member()!=$member_id) && (!has_specific_permission(get_member(),'view_any_profile_field')))?1:NULL,((get_member()!=$member_id) && (!has_specific_permission(get_member(),'view_any_profile_field')))?1:NULL);
// Birthdate
if ($row['m_reveal_age']==1)
{
$out['birthdate']=$row['m_dob_year'].'/'.$row['m_dob_month'].'/'.$row['m_dob_day'];
}
// Find title
if (addon_installed('ocf_member_titles'))
{
$title=$GLOBALS['OCF_DRIVER']->get_member_row_field($member_id,'m_title');
if ($title=='')
{
$primary_group=ocf_get_member_primary_group($member_id);
$title=ocf_get_group_property($primary_group,$GLOBALS['OCF_DRIVER']->get_member_row_field($member_id,'title'));
}
if ($title!='') $out['title']=$title;
}
// Find photo
$photo=$GLOBALS['OCF_DRIVER']->get_member_row_field($member_id,'m_photo_thumb_url');
if (($photo!='') && (addon_installed('ocf_member_photos')))
{
if (url_is_local($photo)) $photo=get_complex_base_url($photo).'/'.$photo;
$out['photo']=$photo;
}
// Any warnings?
if ((has_specific_permission(get_member(),'see_warnings')) && (addon_installed('ocf_warnings')))
{
$out['warnings']=ocf_get_warnings($member_id);
}
}
// Find avatar
$avatar=$GLOBALS['OCF_DRIVER']->get_member_avatar_url($member_id);
if ($avatar!='')
{
$out['avatar']=$avatar;
}
// Primary usergroup
$primary_group=ocf_get_member_primary_group($member_id);
$out['primary_group']=$primary_group;
$out['primary_group_name']=ocf_get_group_name($primary_group);
// Find how many points we need to advance
if (addon_installed('points'))
{
$promotion_threshold=ocf_get_group_property($primary_group,'promotion_threshold');
if (!is_null($promotion_threshold))
{
$num_points_advance=$promotion_threshold-$num_points;
$out['num_points_advance']=$num_points_advance;
}
}
return $out;
}
string get_group_colour(GROUP gid)
Get a usergroup colour based on it's ID number.
Parameters…
| Name |
gid |
| Description |
ID number. |
| Type |
GROUP |
Returns…
| Description |
Colour. |
| Type |
string |
function get_group_colour($gid)
{
$all_colours=array('ocf_gcol_1','ocf_gcol_2','ocf_gcol_3','ocf_gcol_4','ocf_gcol_5','ocf_gcol_6','ocf_gcol_7','ocf_gcol_8','ocf_gcol_9','ocf_gcol_10','ocf_gcol_11','ocf_gcol_12','ocf_gcol_13','ocf_gcol_14','ocf_gcol_15');
return $all_colours[$gid%count($all_colours)];
}
tempcode ocf_wrapper(tempcode title, tempcode content, boolean show_personal_bar, boolean show_stats, ?AUTO_LINK forum_id)
Do the wrapper that fits around OCF module output.
Parameters…
| Name |
title |
| Description |
The title for the module output that we are wrapping. |
| Type |
tempcode |
| Name |
content |
| Description |
The module output that we are wrapping. |
| Type |
tempcode |
| Name |
show_personal_bar |
| Description |
Whether to include the personal bar in the wrap. |
| Default value |
boolean-true |
| Type |
boolean |
| Name |
show_stats |
| Description |
Whether to include statistics in the wrap. |
| Default value |
boolean-true |
| Type |
boolean |
| Name |
forum_id |
| Description |
The forum to make the search link search under (NULL: Users own PT forum/unknown). |
| Default value |
|
| Type |
?AUTO_LINK |
Returns…
| Description |
The wrapped output. |
| Type |
tempcode |
function ocf_wrapper($title,$content,$show_personal_bar=true,$show_stats=true,$forum_id=NULL)
{
global $ZONE;
$wide=is_wide();
if (($wide==0) && (get_value('force_forum_bar')!=='1'))
{
$show_personal_bar=false;
$show_stats=false;
}
// Notifications
if ((!is_guest()) && ((get_page_name()=='forumview') || (get_page_name()=='topicview') || (get_page_name()=='vforums')))
{
$cache_identifier=serialize(array(get_member()));
$_notifications=NULL;
if (((get_option('is_on_block_cache')=='1') || (get_param_integer('keep_cache',0)==1) || (get_param_integer('cache',0)==1)) && ((get_param_integer('keep_cache',NULL)!==0) && (get_param_integer('cache',NULL)!==0)))
{
$_notifications=get_cache_entry('_new_pp',$cache_identifier,10000);
}
if (is_null($_notifications))
{
require_code('ocf_notifications');
list($notifications,$num_unread_pps)=generate_notifications($cache_identifier);
} else
{
list($__notifications,$num_unread_pps)=$_notifications;
$notifications=new ocp_tempcode();
if (!$notifications->from_assembly($__notifications,true))
{
require_code('ocf_notifications');
list($notifications,$num_unread_pps)=generate_notifications($cache_identifier);
}
if (!$notifications->is_empty())
{
require_javascript('javascript_ajax');
}
}
} else
{
$notifications=new ocp_tempcode();
$num_unread_pps=0;
}
if ($show_personal_bar)
{
if (get_member()!=$GLOBALS['OCF_DRIVER']->get_guest_id()) // Logged in user
{
$member_info=ocf_read_in_member_profile(get_member(),true);
$profile_url=$GLOBALS['OCF_DRIVER']->member_profile_url(get_member(),true,true);
$_new_topics=$GLOBALS['FORUM_DB']->query('SELECT COUNT(*) AS mycnt FROM '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_topics WHERE NOT t_forum_id IS NULL AND t_cache_first_time>'.strval((integer)$member_info['last_visit_time']));
$new_topics=$_new_topics[0]['mycnt'];
$_new_posts=$GLOBALS['FORUM_DB']->query('SELECT COUNT(*) AS mycnt FROM '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_posts WHERE NOT p_cache_forum_id IS NULL AND p_time>'.strval((integer)$member_info['last_visit_time']));
$new_posts=$_new_posts[0]['mycnt'];
$max_avatar_height=ocf_get_member_best_group_property(get_member(),'max_avatar_height');
// Any unread PT-PPs?
$pt_extra=($num_unread_pps==0)?new ocp_tempcode():do_lang_tempcode('NUM_UNREAD',integer_format($num_unread_pps));
$personal_topic_url=build_url(array('page'=>'members','type'=>'view','id'=>get_member()),get_module_zone('members'),NULL,true,false,false,'tab__pts');
$head=do_template('OCF_MEMBER_BAR',array(
'_GUID'=>'s3kdsadf0p3wsjlcfksdj',
'AVATAR'=>array_key_exists('avatar',$member_info)?$member_info['avatar']:'',
'PROFILE_URL'=>$profile_url,
'USERNAME'=>$member_info['username'],
'LOGOUT_URL'=>build_url(array('page'=>'login','type'=>'logout'),get_module_zone('login')),
'NUM_POINTS_ADVANCE'=>array_key_exists('num_points_advance',$member_info)?make_string_tempcode(integer_format($member_info['num_points_advance'])):do_lang('NA'),
'NUM_POINTS'=>array_key_exists('points',$member_info)?integer_format($member_info['points']):'',
'NUM_POSTS'=>integer_format($member_info['posts']),
'PRIMARY_GROUP'=>$member_info['primary_group_name'],
'LAST_VISIT_DATE_RAW'=>strval($member_info['last_visit_time']),
'LAST_VISIT_DATE'=>$member_info['last_visit_time_string'],
'PERSONAL_TOPIC_URL'=>$personal_topic_url,
'NEW_POSTS_URL'=>build_url(array('page'=>'vforums','type'=>'misc'),get_module_zone('vforums')),
'UNREAD_TOPICS_URL'=>build_url(array('page'=>'vforums','type'=>'unread'),get_module_zone('vforums')),
'RECENTLY_READ_URL'=>build_url(array('page'=>'vforums','type'=>'recently_read'),get_module_zone('vforums')),
'INLINE_PERSONAL_POSTS_URL'=>build_url(array('page'=>'topicview'),get_module_zone('topicview')),
'PT_EXTRA'=>$pt_extra,
'NEW_TOPICS'=>integer_format($new_topics),
'NEW_POSTS'=>integer_format($new_posts),
'MAX_AVATAR_HEIGHT'=>strval($max_avatar_height),
));
} else // Guest
{
if (count($_POST)>0)
{
$_this_url=build_url(array('page'=>'forumview'),'forum',array('keep_session'=>1));
} else
{
$_this_url=build_url(array('page'=>'_SELF'),'_SELF',array('keep_session'=>1),true);
}
$this_url=$_this_url->evaluate();
$login_url=build_url(array('page'=>'login','type'=>'login','redirect'=>$this_url),get_module_zone('login'));
$full_link=build_url(array('page'=>'login','type'=>'misc','redirect'=>$this_url),get_module_zone('login'));
$join_url=build_url(array('page'=>'join','redirect'=>$this_url),get_module_zone('join'));
$head=do_template('OCF_GUEST_BAR',array('NAVIGATION'=>''/*deprecated*/,'LOGIN_URL'=>$login_url,'JOIN_LINK'=>$join_url,'FULL_LINK'=>$full_link));
}
} else $head=new ocp_tempcode();
if ($show_stats)
{
$stats=ocf_get_forums_stats();
// Users online
$users_online=new ocp_tempcode();
$count=0;
$members=get_online_members(false,NULL,$count);
$groups_seen=array();
if (!is_null($members))
{
//$members=collapse_2d_complexity('the_user','cache_username',$members);
$guests=0;
foreach ($members as $bits)
{
$member=$bits['the_user'];
$username=$bits['cache_username'];
if ($member==$GLOBALS['OCF_DRIVER']->get_guest_id())
{
$guests++;
continue;
}
if (is_null($username)) continue;
$url=$GLOBALS['OCF_DRIVER']->member_profile_url($member,false,true);
if (!array_key_exists('m_primary_group',$bits))
$bits['m_primary_group']=$GLOBALS['FORUM_DRIVER']->get_member_row_field($member,'m_primary_group');
$pgid=$bits['m_primary_group'];//$GLOBALS['FORUM_DRIVER']->get_member_row_field($member,'m_primary_group');
if (is_null($pgid)) continue; // Deleted member
$groups_seen[$pgid]=1;
$col=get_group_colour($pgid);
$usergroup=ocf_get_group_name($pgid);
if (get_value('disable_user_online_groups')==='1')
{
$usergroup=NULL;
$col=NULL;
$groups_seen=array();
}
$users_online->attach(do_template('OCF_USER_MEMBER',array('_GUID'=>'a9cb1af2a04b14edd70749c944495bff','COLOUR'=>$col,'PROFILE_URL'=>$url,'USERNAME'=>$username,'USERGROUP'=>$usergroup)));
}
if ($guests!=0)
{
if (!$users_online->is_empty()) $users_online->attach(do_lang_tempcode('LIST_SEP'));
$users_online->attach(do_lang_tempcode('NUM_GUESTS',integer_format($guests)));
}
}
// Birthdays
$_birthdays=ocf_find_birthdays();
$birthdays=new ocp_tempcode();
foreach ($_birthdays as $_birthday)
{
$birthday_link=build_url(array('page'=>'topics','type'=>'birthday','id'=>$_birthday['username']),get_module_zone('topics'));
$birthday=do_template('OCF_BIRTHDAY_LINK',array('_GUID'=>'a98959187d37d80e134d47db7e3a52fa','AGE'=>array_key_exists('age',$_birthday)?integer_format($_birthday['age']):NULL,'PROFILE_URL'=>$GLOBALS['OCF_DRIVER']->member_profile_url($_birthday['id'],false,true),'USERNAME'=>$_birthday['username'],'BIRTHDAY_LINK'=>$birthday_link));
$birthdays->attach($birthday);
}
if (!$birthdays->is_empty()) $birthdays=do_template('OCF_BIRTHDAYS',array('_GUID'=>'03da2c0d46e76407d63bff22aac354bd','BIRTHDAYS'=>$birthdays));
// Usergroup keys
$groups=array();
$all_groups=$GLOBALS['FORUM_DRIVER']->get_usergroup_list(true,false,false,NULL,NULL,true);
foreach ($all_groups as $gid=>$gtitle)
{
if ($gid==db_get_first_id()) continue; // Throw out the first, guest
if (array_key_exists($gid,$groups_seen))
$groups[]=array('GCOLOUR'=>get_group_colour($gid),'GID'=>strval($gid),'GTITLE'=>$gtitle);
}
$foot=do_template('OCF_STATS',array(
'_GUID'=>'sdflkdlfd303frksdf',
'NEWEST_MEMBER_PROFILE_URL'=>$GLOBALS['OCF_DRIVER']->member_profile_url($stats['newest_member_id'],false,true),
'NEWEST_MEMBER_USERNAME'=>$stats['newest_member_username'],
'NUM_MEMBERS'=>integer_format($stats['num_members']),
'NUM_TOPICS'=>integer_format($stats['num_topics']),
'NUM_POSTS'=>integer_format($stats['num_posts']),
'BIRTHDAYS'=>$birthdays,
'USERS_ONLINE'=>$users_online,
'USERS_ONLINE_URL'=>has_actual_page_access(get_member(),'onlinemembers')?build_url(array('page'=>'onlinemembers'),get_module_zone('onlinemembers')):new ocp_tempcode(),
'GROUPS'=>$groups
));
} else $foot=new ocp_tempcode();
$wrap=do_template('OCF_WRAPPER',array('_GUID'=>'456c21db6c09ae260accfa4c2a59fce7','TITLE'=>$title,'NOTIFICATIONS'=>$notifications,'HEAD'=>$head,'FOOT'=>$foot,'CONTENT'=>$content));
return $wrap;
}
array ocf_find_birthdays(?TIME time)
Find all the birthdays in a certain day.
Parameters…
| Name |
time |
| Description |
A timestamps that exists in the certain day (NULL: now). |
| Default value |
|
| Type |
?TIME |
Returns…
| Description |
List of maps describing the members whose birthday it is on the certain day. |
| Type |
array |
function ocf_find_birthdays($time=NULL)
{
if (is_null($time)) $time=time();
$num_members=$GLOBALS['FORUM_DB']->query_value('f_members','COUNT(*)');
if ($num_members>365*20) return array(); // 20 birthdays on average per day is more than worth reporting! And would kill performance
list($day,$month,$year)=explode(' ',date('j m Y',utctime_to_usertime($time)));
$rows=$GLOBALS['FORUM_DB']->query_select('f_members',array('id','m_username','m_reveal_age','m_dob_year'),array('m_dob_day'=>intval($day),'m_dob_month'=>intval($month)));
$birthdays=array();
foreach ($rows as $row)
{
$birthday=array('id'=>$row['id'],'username'=>$row['m_username']);
if ($row['m_reveal_age']==1) $birthday['age']=intval($year)-$row['m_dob_year'];
$birthdays[]=$birthday;
}
return $birthdays;
}
tempcode ocf_screen_button_wrap(array buttons)
Turn a list of maps describing buttons, into a tempcode button panel.
Parameters…
| Name |
buttons |
| Description |
List of maps (each map contains: url, img, title). |
| Type |
array |
Returns…
| Description |
The button panel. |
| Type |
tempcode |
function ocf_screen_button_wrap($buttons)
{
if (count($buttons)==0) return new ocp_tempcode();
$b=new ocp_tempcode();
foreach ($buttons as $button)
{
$b->attach(do_template('SCREEN_BUTTON',array('_GUID'=>'bdd441c40c5b03134ce6541335fece2c','REL'=>array_key_exists('rel',$button)?$button['rel']:NULL,'IMMEDIATE'=>$button['immediate'],'URL'=>$button['url'],'IMG'=>$button['img'],'TITLE'=>$button['title'])));
}
return $b;
}
sources/ocf_general_action.php
Global_functions_ocf_general_action.php
Function summary
|
AUTO_LINK
|
ocf_make_post_template (SHORT_TEXT title, LONG_TEXT text, SHORT_TEXT forum_multi_code, BINARY use_default_forums)
|
|
void
|
ocf_make_emoticon (SHORT_TEXT code, ID_TEXT theme_img_code, integer relevance_level, BINARY use_topics, BINARY is_special)
|
|
AUTO_LINK
|
ocf_make_welcome_email (SHORT_TEXT name, SHORT_TEXT subject, LONG_TEXT text, integer send_time, ?AUTO_LINK newsletter)
|
AUTO_LINK ocf_make_post_template(SHORT_TEXT title, LONG_TEXT text, SHORT_TEXT forum_multi_code, BINARY use_default_forums)
Make a post template.
Parameters…
| Name |
title |
| Description |
The title for the template. |
| Type |
SHORT_TEXT |
| Name |
text |
| Description |
The text of the template. |
| Type |
LONG_TEXT |
| Name |
forum_multi_code |
| Description |
The multi code specifying which forums this is applicable in. |
| Type |
SHORT_TEXT |
| Name |
use_default_forums |
| Description |
Whether to use this as the default post in applicable forum. |
| Type |
BINARY |
Returns…
| Description |
The added ID |
| Type |
AUTO_LINK |
function ocf_make_post_template($title,$text,$forum_multi_code,$use_default_forums)
{
$id=$GLOBALS['FORUM_DB']->query_insert('f_post_templates',array(
't_title'=>$title,
't_text'=>$text,
't_forum_multi_code'=>$forum_multi_code,
't_use_default_forums'=>$use_default_forums
),true);
log_it('ADD_POST_TEMPLATE',strval($id),$title);
return $id;
}
void ocf_make_emoticon(SHORT_TEXT code, ID_TEXT theme_img_code, integer relevance_level, BINARY use_topics, BINARY is_special)
Make an emoticon.
Parameters…
| Name |
code |
| Description |
The textual code entered to make the emoticon appear. |
| Type |
SHORT_TEXT |
| Name |
theme_img_code |
| Description |
The image code used for the emoticon. |
| Type |
ID_TEXT |
| Name |
relevance_level |
| Description |
The relevance level. |
| Default value |
1 |
| Type |
integer |
| Value range |
0 4 |
| Name |
use_topics |
| Description |
Whether this may be used as a topic emoticon. |
| Default value |
1 |
| Type |
BINARY |
| Name |
is_special |
| Description |
Whether this may only be used by privileged members |
| Default value |
0 |
| Type |
BINARY |
(No return value)
function ocf_make_emoticon($code,$theme_img_code,$relevance_level=1,$use_topics=1,$is_special=0)
{
$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($test)));
$GLOBALS['FORUM_DB']->query_insert('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
));
log_it('ADD_EMOTICON',$code,$theme_img_code);
}
AUTO_LINK ocf_make_welcome_email(SHORT_TEXT name, SHORT_TEXT subject, LONG_TEXT text, integer send_time, ?AUTO_LINK newsletter)
Make a Welcome E-mail.
Parameters…
| Name |
name |
| Description |
A name for the Welcome E-mail |
| Type |
SHORT_TEXT |
| Name |
subject |
| Description |
The subject of the Welcome E-mail |
| Type |
SHORT_TEXT |
| Name |
text |
| Description |
The message body of the Welcome E-mail |
| Type |
LONG_TEXT |
| Name |
send_time |
| Description |
The number of hours before sending the e-mail |
| Type |
integer |
| Name |
newsletter |
| Description |
What newsletter to send out to instead of members (NULL: none) |
| Default value |
0 |
| Type |
?AUTO_LINK |
Returns…
| Description |
The ID |
| Type |
AUTO_LINK |
function ocf_make_welcome_email($name,$subject,$text,$send_time,$newsletter=0)
{
$id=$GLOBALS['SITE_DB']->query_insert('f_welcome_emails',array('w_name'=>$name,'w_newsletter'=>$newsletter,'w_subject'=>insert_lang($subject,2),'w_text'=>insert_lang($text,2),'w_send_time'=>$send_time),true);
log_it('ADD_WELCOME_EMAIL',strval($id),$subject);
return $id;
}
sources/ocf_moderation.php
Global_functions_ocf_moderation.php
array ocf_list_multi_moderations(AUTO_LINK forum_id)
List all the multi moderations that may be used in a certain forum.
Parameters…
| Name |
forum_id |
| Description |
The forum we are listing for. |
| Type |
AUTO_LINK |
Returns…
| Description |
List of multi moderations. |
| Type |
array |
function ocf_list_multi_moderations($forum_id)
{
if (!addon_installed('ocf_multi_moderations')) return array();
$rows=$GLOBALS['FORUM_DB']->query_select('f_multi_moderations m LEFT JOIN '.$GLOBALS['FORUM_DB']->get_table_prefix().'translate t ON '.db_string_equal_to('language',user_lang()).' AND m.mm_name=t.id',array('mm_forum_multi_code','m.id','m.mm_name','text_original AS _mm_name'),NULL,'ORDER BY text_original');
$out=array();
if (count($rows)==0) return $out;
$lots_of_forums=$GLOBALS['FORUM_DB']->query_value('f_forums','COUNT(*)')>200;
if (!$lots_of_forums)
{
$all_forums=collapse_2d_complexity('id','f_parent_forum',$GLOBALS['FORUM_DB']->query_select('f_forums',array('id','f_parent_forum')));
}
foreach ($rows as $row)
{
if ($GLOBALS['RECORD_LANG_STRINGS_CONTENT'] || is_null($row['_mm_name'])) $row['_mm_name']=get_translated_text($row['mm_name'],$GLOBALS['FORUM_DB']);
require_code('ocfiltering');
if ($lots_of_forums)
{
$sql=ocfilter_to_sqlfragment($row['mm_forum_multi_code'],'id','f_forums','f_parent_forum','f_parent_forum','id',true,true,$GLOBALS['FORUM_DB']);
if (!is_null($GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT id FROM '.$GLOBALS['FORUM_DB']->get_table_prefix().'f_forums WHERE id='.strval($forum_id).' AND ('.$sql.')')))
$out[$row['id']]=$row['_mm_name'];
} else
{
$idlist=ocfilter_to_idlist_using_memory($row['mm_forum_multi_code'],$all_forums,'f_forums','f_parent_forum','f_parent_forum','id',true,true,$GLOBALS['FORUM_DB']);
if (in_array($forum_id,$idlist))
$out[$row['id']]=$row['_mm_name'];
}
}
return $out;
}
boolean ocf_may_perform_multi_moderation(AUTO_LINK forum_id, ?MEMBER member_id)
Whether a certain member may perform multi moderations in a certain forum.
Parameters…
| Name |
forum_id |
| Description |
The forum. |
| Type |
AUTO_LINK |
| Name |
member_id |
| Description |
The member (NULL: current member). |
| Default value |
|
| Type |
?MEMBER |
Returns…
| Description |
Answer. |
| Type |
boolean |
function ocf_may_perform_multi_moderation($forum_id,$member_id=NULL)
{
if (is_null($member_id)) $member_id=get_member();
if (!ocf_may_moderate_forum($forum_id,$member_id)) return false;
return has_specific_permission($member_id,'run_multi_moderations');
}
boolean ocf_may_warn_members(?MEMBER member_id)
Whether a certain member may give formal warnings to other members.
Parameters…
| Name |
member_id |
| Description |
The member (NULL: current member). |
| Default value |
|
| Type |
?MEMBER |
Returns…
| Description |
Answer. |
| Type |
boolean |
function ocf_may_warn_members($member_id=NULL)
{
if (is_null($member_id)) $member_id=get_member();
return has_specific_permission($member_id,'warn_members');
}
array ocf_get_warnings(MEMBER member_id)
Get all the warning rows for a certain member.
Parameters…
| Name |
member_id |
| Description |
The member. |
| Type |
MEMBER |
Returns…
| Description |
The warning rows. |
| Type |
array |
function ocf_get_warnings($member_id)
{
if (!addon_installed('ocf_warnings')) return array();
return $GLOBALS['FORUM_DB']->query_select('f_warnings',array('*'),array('w_member_id'=>$member_id,'w_is_warning'=>1));
}
sources/ocf_moderation_action.php
Global_functions_ocf_moderation_action.php
Function summary
|
AUTO_LINK
|
ocf_make_multi_moderation (SHORT_TEXT name, LONG_TEXT post_text, ?AUTO_LINK move_to, BINARY pin_state, BINARY sink_state, BINARY open_state, SHORT_TEXT forum_multi_code, SHORT_TEXT title_suffix)
|
AUTO_LINK ocf_make_multi_moderation(SHORT_TEXT name, LONG_TEXT post_text, ?AUTO_LINK move_to, BINARY pin_state, BINARY sink_state, BINARY open_state, SHORT_TEXT forum_multi_code, SHORT_TEXT title_suffix)
Add a multi moderation to the system.
Parameters…
| Name |
name |
| Description |
The name of the multi moderation. |
| Type |
SHORT_TEXT |
| Name |
post_text |
| Description |
The post text to add when applying (blank: don't add a post). |
| Type |
LONG_TEXT |
| Name |
move_to |
| Description |
The forum to move the topic when applying (NULL: do not move). |
| Type |
?AUTO_LINK |
| Name |
pin_state |
| Description |
The pin state after applying. |
| Type |
BINARY |
| Name |
sink_state |
| Description |
The sink state after applying. |
| Type |
BINARY |
| Name |
open_state |
| Description |
The open state after applying. |
| Type |
BINARY |
| Name |
forum_multi_code |
| Description |
The forum multi code for where this multi moderation may be applied. |
| Default value |
* |
| Type |
SHORT_TEXT |
| Name |
title_suffix |
| Description |
The title suffix. |
| Default value |
|
| Type |
SHORT_TEXT |
Returns…
| Description |
The ID of the multi moderation just added. |
| Type |
AUTO_LINK |
function ocf_make_multi_moderation($name,$post_text,$move_to,$pin_state,$sink_state,$open_state,$forum_multi_code='*',$title_suffix='')
{
if ($move_to==-1) $move_to=NULL;
if ($pin_state==-1) $pin_state=NULL;
if ($open_state==-1) $open_state=NULL;
if ($sink_state==-1) $sink_state=NULL;
$id=$GLOBALS['FORUM_DB']->query_insert('f_multi_moderations',array(
'mm_name'=>insert_lang($name,3,$GLOBALS['FORUM_DB']),
'mm_post_text'=>$post_text,
'mm_move_to'=>$move_to,
'mm_pin_state'=>$pin_state,
'mm_sink_state'=>$sink_state,
'mm_open_state'=>$open_state,
'mm_forum_multi_code'=>$forum_multi_code,
'mm_title_suffix'=>$title_suffix,
),true);
log_it('ADD_MULTI_MODERATION',strval($id),$name);
return $id;
}
0 reviews: Unrated (average)
There have been no comments yet