Difference between revisions of "Configuring file registration"
| Line 1: | Line 1: | ||
| + | If you are looking for a how-to for using the file registration system then this page will be more help: [[How-to: Register and Upload Files]] | ||
| + | |||
In order to utilise the new dataclass of 'file' there are a few changes that need to be made to your currently existing database and also the config files. | In order to utilise the new dataclass of 'file' there are a few changes that need to be made to your currently existing database and also the config files. | ||
Revision as of 13:20, 26 June 2008
If you are looking for a how-to for using the file registration system then this page will be more help: How-to: Register and Upload Files
In order to utilise the new dataclass of 'file' there are a few changes that need to be made to your currently existing database and also the config files.
Run the following SQL in phpMyAdmin to create the tables:
CREATE TABLE `cor_lut_file` ( `id` int( 11 ) NOT NULL AUTO_INCREMENT , `filename` varchar( 255 ) COLLATE utf8_unicode_ci NOT NULL , `module` varchar( 255 ) COLLATE utf8_unicode_ci NOT NULL , `batch` varchar( 255 ) COLLATE utf8_unicode_ci NOT NULL default '0', `cre_by` int( 11 ) NOT NULL default '0', `cre_on` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY ( `id` ) ) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;
CREATE TABLE `cor_tbl_file2` ( `id` int( 11 ) NOT NULL AUTO_INCREMENT , `itemkey` varchar( 50 ) COLLATE utf8_unicode_ci NOT NULL default , `itemvalue` varchar( 30 ) COLLATE utf8_unicode_ci NOT NULL default , `file` varchar( 255 ) COLLATE utf8_unicode_ci NOT NULL default , `cre_by` int( 11 ) NOT NULL default '0', `cre_on` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY ( `id` ) , FULLTEXT KEY `txt` ( `file` ) ) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;
First set the registered files directory in the settings.php. This directory needs to exist and be writeable by the www user.
// FILES $registered_files_dir = $ark_server_path . '/data/files/';
Now add a field to handle the files in field_settings.php
//FILE FIELDS
$conf_field_file =
array(
'dataclass' => 'file',
'classtype' => 'file',
'alias_tbl' => 'cor_lut_file',
'alias_col' => 'id',
'alias_src_key' => '1',
'alias_type' => '1',
'editable' => TRUE,
'hidden' => FALSE,
'add_validation' => $file_add_validation,
'edt_validation' => $file_edt_validation
);
As you have stated in the above field settings that you will be usinf the file_add and edt validation - you need to set those up in your vd_settings.php
// file - request and chkSet
$file_vd_file =
array(
'rq_func' => 'reqMulti',
'vd_func' => 'chkSkipBlank',
'var_name' => 'file',
'lv_name' => 'dyn_field',
'var_locn' => 'request'
);
// file - request and chkSet
$file_vd_requiredfile =
array(
'rq_func' => 'reqMulti',
'vd_func' => 'chkSet',
'var_name' => 'file',
'lv_name' => 'dyn_field',
'var_locn' => 'request'
);
// 4 - Compound items
// itemkey - request and chkSet
$file_vd_key =
array(
'rq_func' => 'reqMulti',
'vd_func' => 'chkSet',
'var_name' => 'itemkey',
'lv_name' => 'item_key',
'var_locn' => 'live'
);
// file - request and chkSet
$file_vd_val =
array(
'rq_func' => 'reqItemVal',
'vd_func' => 'chkSet',
'var_name' => 'itemval',
'lv_name' => 'itemval',
'var_locn' => 'request',
'req_keytype' => 'auto',
'ret_keytype' => 'cd'
);
// add file default validation group
$file_add_validation =
array(
$vd_cre_on,
$vd_log,
$vd_ste_cd,
$vd_cre_by,
$file_vd_file,
$file_vd_key,
$file_vd_val,
$vd_lang
);
// edt file default validation group
$file_edt_validation =
array(
$vd_cre_on,
$vd_log,
$vd_ste_cd,
$vd_cre_by,
$file_vd_file,
$file_vd_key,
$file_vd_val,
$vd_frag_id,
$vd_lang
);
Finally add the field to the conf_register array in the mod_settings file, for example:
$conf_register =
array(
'view_state' => 'max',
'edit_state' => 'edit',
'sf_title' => 'register', //appears in the titlebar of the subform (mk nname)
'sf_html_id' => 'sph_cd_register', //the form id tag (must be unique)
'script' => 'php/data_entry/register.php',
'op_label' => 'save',
'op_input' => 'save',
'op_reg_mode' => 'sgl',
'op_no_rows' => 15,
'fields' =>
array(
$conf_field_itemkey,
$conf_field_short_desc,
$conf_field_cxtxmi,
$conf_field_takenby,
$conf_field_takenon,
$conf_field_file,
$conf_reg_op
)
);
In order to make it easier for your users to get to the upload page - you may want to add a link onto the data_entry page (add this in settings.php)
$data_entry_left_panel[] = array('href' => "{$_SERVER['PHP_SELF']}?view=files", 'text' => 'Upload Files');