aboutsummaryrefslogtreecommitdiff
path: root/reminder.module
diff options
context:
space:
mode:
Diffstat (limited to 'reminder.module')
-rw-r--r--reminder.module48
1 files changed, 40 insertions, 8 deletions
diff --git a/reminder.module b/reminder.module
index a1c7b68..e241222 100644
--- a/reminder.module
+++ b/reminder.module
@@ -134,6 +134,7 @@ function reminder_form(&$node) {
$type = node_type_get_type($node);
$format_until = 'Y-m-d H:i';
+ $reminder = isset($node->nid) ? reminder_get_reminder($node->nid) : array();
if ($type->has_title) {
$form['title'] = array(
@@ -166,6 +167,7 @@ function reminder_form(&$node) {
'#title' => t('Your name'),
'#maxlength' => 100,
'#description' => t('This is optional.'),
+ '#default_value' => isset($reminder['anonym_name']) ? $reminder['anonym_name'] : 0,
);
$form['anonym']['user_email'] = array(
@@ -173,6 +175,7 @@ function reminder_form(&$node) {
'#title' => t('Your e-mail'),
'#description' => t(''),
'#maxlength' => 100,
+ '#default_value' => isset($reminder['anonym_email']) ? $reminder['anonym_email'] : 0,
);
}
@@ -180,7 +183,7 @@ function reminder_form(&$node) {
'#type' => 'date_popup',
'#title' => 'Remind until',
'#default_value' => date($format_until),
- '#date_format' => isset($node->until) ? $node->until : $format_until,
+ '#date_format' => isset($reminder['until']) ? $reminder['until'] : $format_until,
'#date_label_position' => 'within',
'#date_increment' => 60,
'#date_year_range' => '0:+3',
@@ -197,7 +200,7 @@ function reminder_form(&$node) {
'yearly' => t('Yearly'),
'decreasing' => t('Increasing (you get more reminders over time)'),
),
- '#default_value' => isset($node->frequency) ? $node->frequency : 'hourly',
+ '#default_value' => isset($reminder['frequency']) ? $reminder['frequency'] : 'hourly',
'#description' => t('Choose the frequency a reminder should be sent to you and all subscribers.'),
);
@@ -212,7 +215,7 @@ function reminder_form(&$node) {
'#title' => t('Show subscribed emails'),
'#description' => t("Deny subscribers to see each other."),
'#options' => array('0' => t('No'), '1' => t('Yes')),
- '#default_value' => isset($node->secure) ? $node->secure : 0,
+ '#default_value' => isset($reminder['secure']) ? $reminder['secure'] : 0,
);
$form['reminder_options']['now'] = array(
@@ -223,6 +226,7 @@ function reminder_form(&$node) {
'#default_value' => 0,
);
+ // TODO
$form['reminder_subscriptions'] = array(
'#type' => 'textarea',
'#title' => t('Subscribers'),
@@ -297,11 +301,6 @@ function reminder_node_submit($node, $form, &$form_state) {
);
$query = db_insert('reminder')->fields($values);
-
- //if ($anonym_name != NULL) {
- // $query->fields(array('anonym_name' => $anonym_name, 'anonym_email' => $anonym_email));
- //}
-
$query->execute();
// Save subscribers.
@@ -471,3 +470,36 @@ function _reminder_access_userreminders($account) {
global $user;
return user_access('access all reminders') || ($user->uid == $account->uid && user_access('access own reminders'));
}
+
+/**
+ * Get reminder data.
+ *
+ * @param $nid
+ * Reminder nid.
+ *
+ * @return
+ * Reminder result set.
+ *
+ * @todo
+ * Fetch subscriptions.
+ */
+function reminder_get_reminder($nid) {
+ // Schema
+ include_once 'reminder.install';
+ $schema = reminder_schema();
+ $fields = array_keys($schema['reminder']['fields']);
+
+ // Fetch existing options.
+ $query = db_select('reminder', 'r');
+ $query
+ ->condition('r.nid', $nid)
+ ->fields('r', $fields);
+
+ $results = $query->execute()->fetchAll();
+
+ // Sanitize the data before handing it off to the theme layer.
+ foreach ($results as $entry) {
+ // Return the first result as we just have one entry.
+ return array_map('check_plain', (array) $entry);
+ }
+}