ocPortal Developer's Guide: Images Of The Day
» Return to Contents
sources/iotds.php
Global_functions_iotds.php
Function summary
|
AUTO_LINK
|
add_iotd (URLPATH url, SHORT_TEXT title, LONG_TEXT caption, URLPATH thumb_url, BINARY current, BINARY allow_rating, SHORT_INTEGER allow_comments, BINARY allow_trackbacks, LONG_TEXT notes, ?TIME time, ?MEMBER submitter, BINARY used, ?TIME use_time, integer views, ?TIME edit_date)
|
|
void
|
edit_iotd (AUTO_LINK id, SHORT_TEXT title, LONG_TEXT caption, URLPATH thumb_url, URLPATH url, BINARY allow_rating, SHORT_INTEGER allow_comments, BINARY allow_trackbacks, LONG_TEXT notes)
|
|
void
|
delete_iotd (AUTO_LINK id)
|
|
void
|
set_iotd (AUTO_LINK id)
|
AUTO_LINK add_iotd(URLPATH url, SHORT_TEXT title, LONG_TEXT caption, URLPATH thumb_url, BINARY current, BINARY allow_rating, SHORT_INTEGER allow_comments, BINARY allow_trackbacks, LONG_TEXT notes, ?TIME time, ?MEMBER submitter, BINARY used, ?TIME use_time, integer views, ?TIME edit_date)
Add an IOTD to the database and return the ID of the new entry.
Parameters…
| Name |
url |
| Description |
The URL to the IOTD image |
| Type |
URLPATH |
| Name |
title |
| Description |
The IOTD title |
| Type |
SHORT_TEXT |
| Name |
caption |
| Description |
The IOTD caption |
| Type |
LONG_TEXT |
| Name |
thumb_url |
| Description |
The URL to the IOTD thumbnail image |
| Type |
URLPATH |
| Name |
current |
| Description |
Whether the IOTD is currently in use (note: setting this to 1 will not actually set the IOTD, and if it is 1, then the IOTD must be explicitly set only to this) |
| Type |
BINARY |
| Name |
allow_rating |
| Description |
Whether the IOTD may be rated |
| Type |
BINARY |
| Name |
allow_comments |
| Description |
Whether comments are allowed (0=no, 1=yes, 2=review style) |
| Type |
SHORT_INTEGER |
| Name |
allow_trackbacks |
| Description |
Whether the IOTD may be trackbacked |
| Type |
BINARY |
| Name |
notes |
| Description |
Notes for the IOTD |
| Type |
LONG_TEXT |
| Name |
time |
| Description |
The time of submission (NULL: now) |
| Default value |
|
| Type |
?TIME |
| Name |
submitter |
| Description |
The IOTD submitter (NULL: current member) |
| Default value |
|
| Type |
?MEMBER |
| Name |
used |
| Description |
Whether the IOTD has been used before |
| Default value |
0 |
| Type |
BINARY |
| Name |
use_time |
| Description |
The time the IOTD was used (NULL: never) |
| Default value |
|
| Type |
?TIME |
| Name |
views |
| Description |
The number of views had |
| Default value |
0 |
| Type |
integer |
| Name |
edit_date |
| Description |
The edit date (NULL: never) |
| Default value |
|
| Type |
?TIME |
Returns…
| Description |
The ID of the IOTD just added |
| Type |
AUTO_LINK |
function add_iotd($url,$title,$caption,$thumb_url,$current,$allow_rating,$allow_comments,$allow_trackbacks,$notes,$time=NULL,$submitter=NULL,$used=0,$use_time=NULL,$views=0,$edit_date=NULL)
{
if (is_null($time)) $time=time();
if (is_null($submitter)) $submitter=get_member();
$id=$GLOBALS['SITE_DB']->query_insert('iotd',array('i_title'=>insert_lang_comcode($title,2),'add_date'=>time(),'edit_date'=>$edit_date,'iotd_views'=>$views,'allow_rating'=>$allow_rating,'allow_comments'=>$allow_comments,'allow_trackbacks'=>$allow_trackbacks,'notes'=>$notes,'date_and_time'=>$use_time,'used'=>$used,'url'=>$url,'caption'=>insert_lang_comcode($caption,2),'thumb_url'=>$thumb_url,'submitter'=>$submitter,'is_current'=>$current),true);
log_it('ADD_IOTD',strval($id),$caption);
return $id;
}
void edit_iotd(AUTO_LINK id, SHORT_TEXT title, LONG_TEXT caption, URLPATH thumb_url, URLPATH url, BINARY allow_rating, SHORT_INTEGER allow_comments, BINARY allow_trackbacks, LONG_TEXT notes)
Edit an IOTD.
Parameters…
| Name |
id |
| Description |
The ID of the IOTD to edit |
| Type |
AUTO_LINK |
| Name |
title |
| Description |
The IOTD title |
| Type |
SHORT_TEXT |
| Name |
caption |
| Description |
The IOTD caption |
| Type |
LONG_TEXT |
| Name |
thumb_url |
| Description |
The URL to the IOTD image |
| Type |
URLPATH |
| Name |
url |
| Description |
The URL to the IOTD thumbnail image |
| Type |
URLPATH |
| Name |
allow_rating |
| Description |
Whether the IOTD may be rated |
| Type |
BINARY |
| Name |
allow_comments |
| Description |
Whether comments are allowed (0=no, 1=yes, 2=review style) |
| Type |
SHORT_INTEGER |
| Name |
allow_trackbacks |
| Description |
Whether the IOTD may be trackbacked |
| Type |
BINARY |
| Name |
notes |
| Description |
Notes for the IOTD |
| Type |
LONG_TEXT |
(No return value)
function edit_iotd($id,$title,$caption,$thumb_url,$url,$allow_rating,$allow_comments,$allow_trackbacks,$notes)
{
$_caption=$GLOBALS['SITE_DB']->query_value('iotd','caption',array('id'=>$id));
$_title=$GLOBALS['SITE_DB']->query_value('iotd','i_title',array('id'=>$id));
require_code('files2');
delete_upload('uploads/iotds','iotd','url','id',$id,$url);
delete_upload('uploads/iotds_thumbs','iotd','thumb_url','id',$id,$thumb_url);
$GLOBALS['SITE_DB']->query_update('iotd',array('i_title'=>lang_remap_comcode($_title,$title),'edit_date'=>time(),'allow_rating'=>$allow_rating,'allow_comments'=>$allow_comments,'allow_trackbacks'=>$allow_trackbacks,'notes'=>$notes,'caption'=>lang_remap_comcode($_caption,$caption),'thumb_url'=>$thumb_url,'url'=>$url),array('id'=>$id),'',1);
require_code('urls2');
suggest_new_idmoniker_for('iotds','view',strval($id),$title);
log_it('EDIT_IOTD',strval($id),get_translated_text($_caption));
decache('main_iotd');
require_code('feedback');
update_spacer_post($allow_comments!=0,'videos',strval($id),build_url(array('page'=>'iotds','type'=>'view','id'=>$id),get_module_zone('iotds'),NULL,false,false,true),$title,get_value('comment_forum__iotds'));
}
void delete_iotd(AUTO_LINK id)
Delete an IOTD.
Parameters…
| Name |
id |
| Description |
The ID of the IOTD to delete |
| Type |
AUTO_LINK |
(No return value)
function delete_iotd($id)
{
$caption=$GLOBALS['SITE_DB']->query_value('iotd','caption',array('id'=>$id));
$title=$GLOBALS['SITE_DB']->query_value('iotd','i_title',array('id'=>$id));
log_it('DELETE_IOTD',strval($id),get_translated_text($caption));
delete_lang($caption);
delete_lang($title);
require_code('files2');
delete_upload('uploads/iotds','iotd','url','id',$id);
delete_upload('uploads/iotds_thumbs','iotd','thumb_url','id',$id);
// Delete from the database
$GLOBALS['SITE_DB']->query_delete('iotd',array('id'=>$id),'',1);
$GLOBALS['SITE_DB']->query_delete('rating',array('rating_for_type'=>'iotds','rating_for_id'=>$id));
$GLOBALS['SITE_DB']->query_delete('trackbacks',array('trackback_for_type'=>'iotds','trackback_for_id'=>$id));
decache('main_iotd');
}
void set_iotd(AUTO_LINK id)
Set the IOTD.
Parameters…
| Name |
id |
| Description |
The IOTD ID to set |
| Type |
AUTO_LINK |
(No return value)
function set_iotd($id)
{
$rows=$GLOBALS['SITE_DB']->query_select('iotd',array('*'),array('id'=>$id),'',1);
$title=get_translated_text($rows[0]['i_title']);
$submitter=$rows[0]['submitter'];
log_it('CHOOSE_IOTD',strval($id),$title);
if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(),'iotds'))
syndicate_described_activity('iotds:ACTIVITY_CHOOSE_IOTD',$title,'','','_SEARCH:iotds:view:'.strval($id),'','','iotds');
if ((!is_guest($submitter)) && (addon_installed('points')))
{
require_code('points2');
$_points_chosen=get_option('points_CHOOSE_IOTD');
if (is_null($_points_chosen)) $points_chosen=35; else $points_chosen=intval($_points_chosen);
if ($points_chosen!=0)
system_gift_transfer(do_lang('IOTD'),$points_chosen,$submitter);
}
// Turn all others off
$GLOBALS['SITE_DB']->query_update('iotd',array('is_current'=>0),array('is_current'=>1));
// Turn ours on
$GLOBALS['SITE_DB']->query_update('iotd',array('is_current'=>1,'used'=>1,'date_and_time'=>time()),array('id'=>$id),'',1);
require_lang('iotds');
require_code('notifications');
$view_url=build_url(array('page'=>'iotds','type'=>'view','id'=>$id),get_module_zone('iotds'),NULL,false,false,true);
$thumb_url=$rows[0]['thumb_url'];
if (url_is_local($thumb_url)) $thumb_url=get_custom_base_url().'/'.$thumb_url;
$subject=do_lang('IOTD_CHOSEN_NOTIFICATION_MAIL_SUBJECT',get_site_name(),$title);
$mail=do_lang('IOTD_CHOSEN_NOTIFICATION_MAIL',comcode_escape(get_site_name()),$title,array($view_url->evaluate(),$thumb_url));
dispatch_notification('iotd_chosen',NULL,$subject,$mail);
decache('main_iotd');
}
0 reviews: Unrated (average)
There have been no comments yet