Fix SyncML prefs.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 1 May 2010 14:43:55 +0000 (10:43 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 1 May 2010 14:43:55 +0000 (10:43 -0400)
These types of links do not work with the new Prefs ui stuff. ui->vars will
only contain the variables from the *submitted* form, and these types of links
do not submit the form. Also, destructive actions should always be done via POST
and not GET requests.

horde/lib/Prefs/Ui.php
horde/templates/prefs/syncml.html

index 52075ad..b0d62d3 100644 (file)
@@ -362,6 +362,7 @@ class Horde_Prefs_Ui
      */
     protected function _syncmlManagement($ui)
     {
+        Horde::addScriptFile('syncmlprefs.js', 'horde');
         $devices = SyncML_Backend::factory('Horde')->getUserAnchors(Horde_Auth::getAuth());
 
         $t = $GLOBALS['injector']->createInstance('Horde_Template');
@@ -375,10 +376,8 @@ class Horde_Prefs_Ui
                 $partners[] = array(
                     'anchor' => htmlspecialchars($anchor['syncml_clientanchor']),
                     'db' => htmlspecialchars($anchor['syncml_db']),
-                    'delete' => $selfurl->copy()->add(array(
-                        'db' => $anchor['syncml_db'],
-                        'deviceid' => $device
-                    )),
+                    'deviceid' => $device,
+                    'rawdb' => $anchor ['syncml_db'],
                     'device' => htmlspecialchars($device),
                     'time' => strftime($GLOBALS['prefs']->getValue('date_format') . ' %H:%M', $anchor['syncml_serveranchor'])
                 );
@@ -550,8 +549,8 @@ class Horde_Prefs_Ui
     {
         $backend = SyncML_Backend::factory('Horde');
 
-        if ($ui->vars->deleteanchor) {
-            $res = $backend->removeAnchor(Horde_Auth::getAuth(), $ui->vars->deviceid, $ui->vars->db);
+        if ($ui->vars->removedb && $ui->vars->removedevice) {
+            $res = $backend->removeAnchor(Horde_Auth::getAuth(), $ui->vars->removedevice, $ui->vars->removedb);
             if ($res instanceof PEAR_Error) {
                 $GLOBALS['notification']->push(_("Error deleting synchronization session:") . ' ' . $res->getMessage(), 'horde.error');
             } else {
index 474d231..3a9888a 100644 (file)
@@ -3,6 +3,8 @@
 </div>
 
 <if:devices>
+<input type="hidden" id="removedb" name="removedb" />
+<input type="hidden" id="removedevice" name="removedevice" />
 <table class="striped">
  <tr>
      <th><gettext>Device</gettext></th>
@@ -18,7 +20,7 @@
   <td><tag:devices.time /></td>
   <td><tag:devices.anchor /></td>
   <td>
-   <a class="button" href="<tag:delete />"><gettext>Delete</gettext></a>
+      <input class="button" type="button" value="<gettext>Delete</gettext>" onclick="HordeSyncMLPrefs.removeAnchor('<tag:devices.deviceid />', '<tag:devices.rawdb />')" />
   </td>
  </tr>
 </loop:devices>