function message_ui_instance_message_manage in Message UI 7
The UI for creating/editing the message.
1 string reference to 'message_ui_instance_message_manage'
- message_ui_menu in ./
message_ui.module - Implements hook_menu().
File
- ./
message_ui.module, line 614 - Main file for the message UI module.
Code
function message_ui_instance_message_manage($form, &$form_state, $message) {
if (!is_object($message)) {
$message = message_create($message);
}
$form_state['#entity'] = $message;
$message_text = $message
->view();
if (variable_get('message_ui_show_preview', TRUE)) {
$form['text'] = array(
'#type' => 'item',
'#title' => t('Message text'),
'#markup' => render($message_text),
);
}
field_attach_form('message', $message, $form, $form_state);
$form['additional_settings'] = array(
'#type' => 'vertical_tabs',
'#weight' => 99,
);
$form['owner'] = array(
'#type' => 'fieldset',
'#title' => t('Authoring information'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#attributes' => array(
'class' => array(
'message-form-owner',
),
),
'#attached' => array(
'js' => array(
drupal_get_path('module', 'message_ui') . '/js/message_ui.js',
array(
'type' => 'setting',
'data' => array(
'anonymous' => variable_get('anonymous', t('Anonymous')),
),
),
),
),
'#weight' => 90,
);
$form['owner']['name'] = array(
'#type' => 'textfield',
'#title' => t('Authored by'),
'#maxlength' => 60,
'#weight' => 99,
'#autocomplete_path' => 'user/autocomplete',
'#description' => t('Leave blank for %anonymous.', array(
'%anonymous' => variable_get('anonymous', t('Anonymous')),
)),
'#default_value' => user_load($message->uid)->name,
);
$form['owner']['date'] = array(
'#type' => 'textfield',
'#title' => t('Authored on'),
'#description' => t('Please insert in the format of @date', array(
'@date' => date('Y-m-d j:i', $message->timestamp),
)),
'#default_value' => date('Y-m-d H:i', $message->timestamp),
'#maxlength' => 25,
'#weight' => 100,
);
if (!empty($message->arguments) && (user_access('update tokens') || user_access('bypass message access control'))) {
$form['tokens'] = array(
'#type' => 'fieldset',
'#title' => t('Tokens and arguments'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
'#weight' => 110,
);
// Give the user an option to update the har coded tokens.
$form['tokens']['replace_tokens'] = array(
'#type' => 'select',
'#title' => t('Update tokens value automatically'),
'#description' => t('By default, the hard coded values will be replaced automatically. If unchecked - you can update their value manually.'),
'#default_value' => 'no_update',
'#options' => array(
'no_update' => t("Don't update"),
'update' => t('Update automatically'),
'update_manually' => t('Update manually'),
),
);
$form['tokens']['values'] = array(
'#type' => 'container',
'#states' => array(
'visible' => array(
':input[name="replace_tokens"]' => array(
'value' => 'update_manually',
),
),
),
);
// Build list of fields to update the tokens manually.
foreach ($message->arguments as $name => $value) {
$form['tokens']['values'][$name] = array(
'#type' => 'textfield',
'#title' => t("@name's value", array(
'@name' => $name,
)),
'#default_value' => $value,
);
}
}
$form['actions'] = array(
'#type' => 'actions',
'submit' => array(
'#type' => 'submit',
'#value' => empty($message->is_new) ? t('Update') : t('Create'),
'#submit' => array(
'message_ui_instance_message_create_submit',
),
),
'cancel' => array(
'#type' => 'markup',
'#markup' => l(t('Cancel'), is_object($message) && !empty($message->mid) ? 'message/' . $message->mid : 'admin/structure/messages'),
),
);
return $form;
}