Hi,
this is a plugin I wrote to force users to check a box in order to
acknowledge the terms of service of your openupload site ( something your
legal department may ask if you're in a corporate environment).
I added a global variable on config.inc.php to store the TOS page url (
this is a sitewide setting, so I prefer to put it there instead of adding
a plugin option)
1)
so for example in config.inc.php :
$CONFIG['plugins'][] = 'tos';
$CONFIG['site']['tosurl'] = 'http://tos_url';
2) the plugin ( I'm a newbie in php, it should be easy to improve it if
necessary)
openupload/plugins/tos.inc.php
<?php
class TosPlugin extends OpenUploadPlugin {
function TosPlugin() {
$this->description = tr('Add a checkbox to force user to agree to the
site terms of use');
}
function uploadOptions(&$finfo,$acl) {
if ($acl!='enable') return true;
if (isset(app()->plugins['tos']) and
isset(app()->pluginAcl['tos']) and
app()->pluginAcl['tos']['access']=='enable') {
$this->assign('tosurl',app()->config['site']['tosurl']);
}
$this->display('uploadOptions');
return true;
}
function uploadConfirm(&$finfo,$acl) {
global $_POST;
if ($acl!='enable') return true;
if (isset($_POST['tos'])) return true;
app()->error(tr('You must agree to the tos before completing upload'));
return false;
}
}
?>
3) the template adding the checkbox
openupload/templates/default/plugins/tos/uploadOptions.tpl
<tr><td><a href="{$tosurl}">{tr}I agree to the terms of
service{/tr}</a>:</td><td><input type="checkbox" name="tos"
value="no"></td></tr>
4) as usual, add translation strings if needed , activate the plugin in
the administration dashboard
The user won't be able to confirm upload unless he checked the TOS box.
I preferred to put this check on the confirmation step ( instead on a
'before uploading' step ) because as people are using the service
frequently, it is less of a hassle that way.
regards,W.
|