Commit 42dfd789 authored by m.stenta's avatar m.stenta
Browse files

Issue #2377453: New property: Log is done

parent 27976cff
......@@ -86,6 +86,14 @@ function log_type_form($form, &$form_state, $log_type, $op = 'edit') {
'#default_value' => !empty($log_type->name_edit) ? $log_type->name_edit : FALSE,
);
// Automatically mark logs of this type as done.
$form['done'] = array(
'#type' => 'checkbox',
'#title' => t('Automatically done'),
'#description' => t('Automatically mark logs of this type as "done".'),
'#default_value' => !empty($log_type->done) ? $log_type->done : FALSE,
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
......
......@@ -39,6 +39,7 @@ class LogController extends EntityAPIController {
'timestamp' => REQUEST_TIME,
'created' => REQUEST_TIME,
'changed' => REQUEST_TIME,
'done' => FALSE,
);
return parent::create($values);
}
......@@ -78,6 +79,7 @@ class LogTypeController extends EntityAPIControllerExportable {
'label' => '',
'name_pattern' => '',
'name_edit' => FALSE,
'done' => FALSE,
);
return parent::create($values);
}
......
......@@ -53,6 +53,13 @@ function log_schema() {
'not null' => TRUE,
'default' => 0,
),
'done' => array(
'description' => 'Boolean indicating whether the log is done (the event happened).',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
),
),
'primary key' => array('id'),
'indexes' => array(
......@@ -62,6 +69,7 @@ function log_schema() {
'timestamp' => array('timestamp'),
'created' => array('created'),
'modified' => array('changed'),
'done' => array('done')
),
);
$schema['log_type'] = array(
......@@ -100,6 +108,13 @@ function log_schema() {
'not null' => TRUE,
'default' => 0,
),
'done' => array(
'description' => 'Boolean: automatically mark logs of this type as done.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
// The following fields are required to make Log types exportable via
// Entity API and Ctools. See
......@@ -160,4 +175,25 @@ function log_update_7001(&$sandbox) {
);
db_add_field('log', 'timestamp', $timestamp);
db_add_index('log', 'timestamp', array('timestamp'));
}
\ No newline at end of file
}
/**
* Add 'done' fields to Logs and Log Types.
*/
function log_update_7002(&$sandbox) {
// Add done field to Logs and Log Types.
$done = array(
'description' => 'Boolean: automatically mark logs of this type as done.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
);
db_add_field('log', 'done', $done);
db_add_field('log_type', 'done', $done);
db_add_index('log', 'done', array('done'));
// Mark all existing log items with timestamps before now as "done".
db_query('UPDATE {log} SET done = 1 WHERE timestamp <= :now', array(':now' => REQUEST_TIME));
}
......@@ -295,6 +295,14 @@ function log_entity_property_info_alter(&$info) {
'required' => TRUE,
'schema field' => 'changed',
);
$properties['done'] = array(
'label' => t('Done'),
'description' => t('Whether the log is done.'),
'setter callback' => 'entity_property_verbatim_set',
'setter permission' => 'administer log module',
'schema field' => 'done',
'type' => 'boolean',
);
}
/**
......@@ -322,6 +330,15 @@ function log_field_extra_fields() {
'description' => t('The timestamp of the log entry.'),
'weight' => -5,
);
// Display the done field, if it isn't automatic.
if (empty($type->done)) {
$extra_fields['log'][$type->type]['form']['done'] = array(
'label' => t('Done'),
'description' => t('Whether or not the log is done.'),
'weight' => 100,
);
}
}
return $extra_fields;
}
......
......@@ -95,6 +95,23 @@ function log_form($form, &$form_state, $log) {
'#required' => TRUE,
);
// Only display the done field if it's not automatic.
if (empty($log_type->done)) {
$form['done'] = array(
'#type' => 'checkbox',
'#title' => t('Done'),
'#description' => t('Mark this log as done.'),
'#default_value' => $log->done,
);
}
else {
$form['done'] = array(
'#type' => 'value',
'#value' => TRUE,
);
}
// Log user id.
$form['uid'] = array(
'#type' => 'value',
'#value' => $log->uid,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment