ocPortal Developer's Guide: User submission
» Return to Contents
sources/submit.php
Global_functions_submit.php
boolean content_validated(ID_TEXT content_type, ID_TEXT content_id)
Find whether some content is validated.
Parameters…
| Name |
content_type |
| Description |
Content type |
| Type |
ID_TEXT |
| Name |
content_id |
| Description |
Content ID |
| Type |
ID_TEXT |
Returns…
| Description |
Whether it is validated |
| Type |
boolean |
function content_validated($content_type,$content_id)
{
require_code('content');
list(,,$cma_info,$content_row,)=content_get_details($content_type,$content_id);
return ($content_row[$cma_info['validated_field']]==1);
}
void send_content_validated_notification(ID_TEXT content_type, ID_TEXT content_id)
Send a "your content has been validated" notification out to the submitter of some content. Only call if this is true
.
Parameters…
| Name |
content_type |
| Description |
Content type |
| Type |
ID_TEXT |
| Name |
content_id |
| Description |
Content ID |
| Type |
ID_TEXT |
(No return value)
function send_content_validated_notification($content_type,$content_id)
{
require_code('content');
list($content_title,$submitter_id,,,$content_url)=content_get_details($content_type,$content_id);
require_code('notifications');
require_lang('unvalidated');
$subject=do_lang('CONTENT_VALIDATED_NOTIFICATION_MAIL_SUBJECT',get_site_name(),$content_title);
$mail=do_lang('CONTENT_VALIDATED_NOTIFICATION_MAIL',comcode_escape(get_site_name()),comcode_escape($content_title),array($content_url->evaluate()));
dispatch_notification('content_validated',NULL,$subject,$mail,array($submitter_id));
}
void send_validation_request(ID_TEXT type, ?ID_TEXT table, boolean non_integer_id, ID_TEXT id, tempcode url, ?MEMBER member_id)
Send (by e-mail) a validation request for a submitted item to the admin.
Parameters…
| Name |
type |
| Description |
The validation request will say one of this type has been submitted. By convention it is the language code of what was done, e.g. ADD_DOWNLOAD |
| Type |
ID_TEXT |
| Name |
table |
| Description |
The table saved into (NULL: unknown) |
| Type |
?ID_TEXT |
| Name |
non_integer_id |
| Description |
Whether the ID field is not an integer |
| Type |
boolean |
| Name |
id |
| Description |
The validation request will say this ID has been submitted |
| Type |
ID_TEXT |
| Name |
url |
| Description |
The validation request will link to this URL |
| Type |
tempcode |
| Name |
member_id |
| Description |
Member doing the submitting (NULL: current member) |
| Default value |
|
| Type |
?MEMBER |
(No return value)
function send_validation_request($type,$table,$non_integer_id,$id,$url,$member_id=NULL)
{
$good=NULL;
if (!is_null($table))
{
$_hooks=find_all_hooks('modules','admin_unvalidated');
foreach (array_keys($_hooks) as $hook)
{
require_code('hooks/modules/admin_unvalidated/'.filter_naughty_harsh($hook));
$object=object_factory('Hook_unvalidated_'.filter_naughty_harsh($hook),true);
if (is_null($object)) continue;
$info=$object->info();
if (is_null($info)) continue;
if ($info['db_table']==$table)
{
$good=$info;
break;
}
}
}
$title=mixed();
$title='';
if ((!is_null($good)) && (!is_array($good['db_identifier'])))
{
$db=array_key_exists('db',$good)?$good['db']:$GLOBALS['SITE_DB'];
$where=$good['db_identifier'].'='.$id;
if ($non_integer_id)
$where=db_string_equal_to($good['db_identifier'],$id);
$rows=$db->query('SELECT '.$good['db_identifier'].(array_key_exists('db_title',$good)?(','.$good['db_title']):'').' FROM '.$db->get_table_prefix().$good['db_table'].' WHERE '.$where,100);
if (array_key_exists('db_title',$good))
{
$title=$rows[0][$good['db_title']];
if ($good['db_title_dereference']) $title=get_translated_text($title,$db); // May actually be comcode (can't be certain), but in which case it will be shown as source
} else $title='#'.(is_integer($id)?strval($id):$id);
}
if ($title=='') $title='#'.strval($id);
if (is_null($member_id)) $member_id=get_member();
require_lang('unvalidated');
$_type=do_lang($type,NULL,NULL,NULL,NULL,false);
if (!is_null($_type)) $type=$_type;
$comcode=do_template('VALIDATION_REQUEST',array('_GUID'=>'1885be371b2ff7810287715ef2f7b948','USERNAME'=>$GLOBALS['FORUM_DRIVER']->get_username($member_id),'TYPE'=>$type,'ID'=>$id,'URL'=>$url),get_site_default_lang());
require_code('notifications');
$subject=do_lang('UNVALIDATED_TITLE',$title,'','',get_site_default_lang());
$message=$comcode->evaluate(get_site_default_lang(),false);
dispatch_notification('needs_validation',NULL,$subject,$message);
}
?string give_submit_points(ID_TEXT type, ?MEMBER member)
Give points to a member for submitting something, then returns the XHTML page to say so.
Parameters…
| Name |
type |
| Description |
One of this type has been submitted. By convention it is the language code of what was done, e.g. ADD_DOWNLOAD |
| Type |
ID_TEXT |
| Name |
member |
| Description |
The member to give the points to (NULL: give to current member) |
| Default value |
|
| Type |
?MEMBER |
Returns…
| Description |
A message about the member being given these submit points (NULL: no message) |
| Type |
?string |
function give_submit_points($type,$member=NULL)
{
if (is_null($member)) $member=get_member();
if ((!is_guest($member)) && (addon_installed('points')))
{
$points=get_option('points_'.$type,true);
if (is_null($points)) return '';
require_code('points2');
system_gift_transfer(do_lang($type),intval($points),get_member());
return do_lang('SUBMIT_AWARD',integer_format(intval($points)));
}
return NULL;
}
array wrap_probe_ip(IP ip)
Find a member from their IP address. Unlike plain $GLOBALS['FORUM_DRIVER']->probe_ip, it has the benefit of looking in the adminlogs table also.
Parameters…
| Name |
ip |
| Description |
The IP address to probe |
| Type |
IP |
Returns…
| Description |
The members found |
| Type |
array |
function wrap_probe_ip($ip)
{
if (strpos($ip,'*')!==false)
{
$a=$GLOBALS['SITE_DB']->query('SELECT DISTINCT the_user AS id FROM '.get_table_prefix().'adminlogs WHERE ip LIKE \''.db_encode_like(str_replace('*','%',$ip)).'\'');
} else
{
$a=$GLOBALS['SITE_DB']->query_select('adminlogs',array('DISTINCT the_user AS id'),array('ip'=>$ip));
}
$b=$GLOBALS['FORUM_DRIVER']->probe_ip($ip);
$r=array();
$guest_id=$GLOBALS['FORUM_DRIVER']->get_guest_id();
foreach ($a as $x)
{
if ((!in_array($x,$r)) && ($x['id']!=$guest_id)) $r[]=$x;
}
foreach ($b as $x)
{
if ((!in_array($x,$r)) && ($x['id']!=$guest_id)) $r[]=$x;
}
return $r;
}
void ban_ip(IP ip, LONG_TEXT descrip)
Ban the specified IP address.
Parameters…
| Name |
ip |
| Description |
The IP address to ban |
| Type |
IP |
| Name |
descrip |
| Description |
Explanation for ban |
| Default value |
|
| Type |
LONG_TEXT |
(No return value)
function ban_ip($ip,$descrip='')
{
$ban=trim($ip);
if (($ban!='') && (!compare_ip_address($ban,get_ip_address())))
{
require_code('failure');
add_ip_ban($ban,$descrip);
}
elseif (compare_ip_address($ban,get_ip_address()))
{
attach_message(do_lang_tempcode('AVOIDING_BANNING_SELF'),'warn');
}
}
void unban_ip(IP ip)
Unban the specified IP address.
Parameters…
| Name |
ip |
| Description |
The IP address to unban |
| Type |
IP |
(No return value)
function unban_ip($ip)
{
require_code('failure');
$unban=trim($ip);
remove_ip_ban($unban);
}
0 reviews: Unrated (average)
There have been no comments yet