Index: decisions_node.inc
===================================================================
--- decisions_node.inc	(révision 1164)
+++ decisions_node.inc	(copie de travail)
@@ -25,6 +25,28 @@ function decisions_load($node) {
   $criteria['content_id'] = $node->nid;
   $decision->voted = count(votingapi_select_votes($criteria)) > 0;
 
+// Respect TREE form
+  $decision->settings['algorithm'] = $decision->algorithm;
+  $decision->settings['userlist'] = $decision->userlist;
+  $decision->settings['active'] = $decision->active;
+  $decision->settings['showvotes'] = $decision->showvotes;
+  $decision->settings['maxchoices'] = $decision->maxchoices;
+  $decision->settings['quorum']['quorum_abs'] = $decision->quorum_abs;
+  $decision->settings['quorum']['quorum_percent'] = $decision->quorum_percent;
+
+  $decision->settings['date']['startdate']['date'] = $decision->startdate;
+ 
+  $startdate = $decision->startdate;
+  $runtime = !is_null($decision->runtime) ? $decision->runtime : variable_get('decisions_default_runtime', 24 * 60 * 60);
+  if ($runtime == DECISIONS_RUNTIME_INFINITY) {
+    $enddate = $startdate; // by default
+    $decision->settings['date']['noenddate'] = 1;
+  }
+  else {
+    $enddate = ($startdate + $runtime);
+  }
+  $decision->settings['date']['enddate']['date'] = $enddate;
+
   return $decision;
 }
 
@@ -65,7 +87,7 @@ function decisions_insert($node) {
   $mode = _decisions_get_mode($node);
 
   $algs = decisions_algorithms($mode);
-  db_query("INSERT INTO {decisions} (nid, mode, quorum_abs, quorum_percent, uselist, active, runtime, maxchoices, algorithm, startdate) VALUES (%d, '%s', %d, %f, %d, %d, %d, %d, '%s', %d)", $node->nid, $mode, $node->settings['quorum_abs'], $node->settings['quorum_percent'], $node->settings['uselist'], $node->settings['active'], $node->settings['runtime'], $node->settings['maxchoices'], $algs[0], $startdate);
+  db_query("INSERT INTO {decisions} (nid, mode, quorum_abs, quorum_percent, uselist, active, runtime, maxchoices, algorithm, startdate) VALUES (%d, '%s', %d, %f, %d, %d, %d, %d, '%s', %d)", $node->nid, $mode, $node->settings['quorum']['quorum_abs'], $node->settings['quorum']['quorum_percent'], $node->settings['uselist'], $node->settings['active'], $runtime, $node->settings['maxchoices'], $algs[0], $startdate);
 
   // create the electoral list if desired
 
@@ -117,11 +139,20 @@ function decisions_validate(&$node) {
  */
 function decisions_update($node) {
   // Compute startdate and runtime.
+	
+	// Format dates if hook_update processed without form
+	if (!is_array($node->settings['date']['startdate']['date']))
+		$node->settings['date']['startdate']['date'] = _decisions_form_prepare_datetime($node->settings['date']['startdate']['date']);
+
   $startdate = _decisions_translate_form_date($node->settings['date']['startdate']['date']);
   if ($node->settings['date']['noenddate']) {
     $runtime = DECISIONS_RUNTIME_INFINITY;
   }
   else {
+		// Format dates if hook_update processed without form
+		if (!is_array($node->settings['date']['enddate']['date']))
+			$node->settings['date']['enddate']['date'] = _decisions_form_prepare_datetime($node->settings['date']['enddate']['date']);
+
     $enddate =  _decisions_translate_form_date($node->settings['date']['enddate']['date']);
     if ($enddate < $startdate) {
       form_set_error('enddate', t('The specified close date is less than the opening date, setting it to the same for now.'));
@@ -130,7 +161,7 @@ function decisions_update($node) {
     $runtime = $enddate - $startdate;
   }
     
-  db_query("UPDATE {decisions} SET quorum_abs=%d, quorum_percent=%f, active=%d, runtime=%d, maxchoices=%d, algorithm='%s', uselist=%d, showvotes=%d, startdate=%d WHERE nid = %d", $node->settings['quorum_abs'], $node->settings['quorum_percent'], $node->settings['active'], $runtime, $node->settings['maxchoices'], $node->settings['algorithm'], $node->settings['uselist'], $node->settings['showvotes'], $startdate, $node->nid);
+  db_query("UPDATE {decisions} SET quorum_abs=%d, quorum_percent=%f, active=%d, runtime=%d, maxchoices=%d, algorithm='%s', uselist=%d, showvotes=%d, startdate=%d WHERE nid = %d", $node->settings['quorum']['quorum_abs'], $node->settings['quorum']['quorum_percent'], $node->settings['active'], $runtime, $node->settings['maxchoices'], $node->settings['algorithm'], $node->settings['uselist'], $node->settings['showvotes'], $startdate, $node->nid);
   // XXX: should update decisions here, when it has some parameters
   // XXX: ... but before doing so, the code below must be factored out in a seperate function for usage in decisions_insert()
   db_query('DELETE FROM {decisions_choices} WHERE nid = %d', $node->nid);
@@ -361,7 +392,8 @@ function decisions_form(&$node, &$form_state) {
     '#type' => 'fieldset',
     '#collapsed' => FALSE,
     '#description' => t('Opening date')
-  );  
+  ); 
+
   $form['settings']['date']['startdate']['date'] = _decisions_form_date($startdate);
   
   $form['settings']['date']['noenddate'] = array(
Index: decisions.inc
===================================================================
--- decisions.inc	(révision 1164)
+++ decisions.inc	(copie de travail)
@@ -202,7 +202,7 @@ function _decisions_form_date($timestamp) {
     '#required' => TRUE);
   $form['month'] = array(
     '#type' => 'select',
-    '#default_value' => _decisions_date('m', $timestamp),
+    '#default_value' => _decisions_date('n', $timestamp),
     '#options' => $months,
     '#required' => TRUE);
   $form['year'] = array(
