Add Horde_Core_Ajax_Application::setPrefValue()
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 27 Sep 2010 17:51:09 +0000 (11:51 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 27 Sep 2010 18:03:00 +0000 (12:03 -0600)
14 files changed:
framework/Core/lib/Horde.php
framework/Core/lib/Horde/Core/Ajax/Application.php
gollem/js/manager.js
gollem/lib/Ajax/Application.php [new file with mode: 0644]
gollem/templates/javascript_defs.php
imp/js/dimpbase.js
imp/templates/dimp/javascript_defs_dimp.php
kronolith/js/calendar-panel.js
kronolith/templates/javascript_defs.php
nag/lib/Ajax/Application.php [new file with mode: 0644]
nag/templates/panel.inc
skoli/lib/Ajax/Application.php [new file with mode: 0644]
skoli/templates/panel.inc
skoli/templates/search/headers.inc

index 38923fc..b9032f0 100644 (file)
@@ -453,7 +453,6 @@ HTML;
      * 'login'
      * 'logintasks'
      * 'logout'
-     * 'prefsapi
      * 'problem'
      * 'sidebar'
      * 'prefs'
@@ -506,15 +505,11 @@ HTML;
             return $GLOBALS['registry']->getLogoutUrl(array('reason' => Horde_Auth::REASON_LOGOUT));
 
         case 'prefs':
-        case 'prefsapi':
             if (!in_array($GLOBALS['conf']['prefs']['driver'], array('', 'none'))) {
-                $url = self::url(($type == 'prefs') ? 'services/prefs.php' : 'services/prefs/', false, $opts);
+                $url = self::url('services/prefs.php', false, $opts);
                 if (!is_null($app)) {
                     $url->add('app', $app);
                 }
-                if ($type == 'prefsapi') {
-                    $url->remove('ajaxui');
-                }
                 return $url;
             }
             break;
index f91f556..64dcb40 100644 (file)
@@ -211,4 +211,20 @@ abstract class Horde_Core_Ajax_Application
         return $result;
     }
 
+    /**
+     * Sets a preference value.
+     *
+     * Variables used:
+     * <pre>
+     * 'pref' - (string) The preference name.
+     * 'value' - (mixed) The preference value.
+     * </pre>
+     *
+     * @return boolean  True on success.
+     */
+    public function setPrefValue()
+    {
+        return $GLOBALS['prefs']->setValue($this->_vars->pref, $this->_vars->value);
+    }
+
 }
index 62ecc7d..2394353 100644 (file)
@@ -362,8 +362,8 @@ var Gollem = {
     doPrefsUpdate: function(column, sortDown)
     {
         try {
-            new Ajax.Request(GollemVar.prefs_api, { parameters: { pref: 'sortby', value: column.substring(1) } });
-            new Ajax.Request(GollemVar.prefs_api, { parameters: { pref: 'sortdir', value: sortDown } });
+            new Ajax.Request(GollemVar.URI_AJAX + 'setPrefValue', { parameters: { pref: 'sortby', value: column.substring(1) } });
+            new Ajax.Request(GollemVar.URI_AJAX + 'setPrefValue', { parameters: { pref: 'sortdir', value: sortDown } });
         } catch (e) {}
     }
 };
diff --git a/gollem/lib/Ajax/Application.php b/gollem/lib/Ajax/Application.php
new file mode 100644 (file)
index 0000000..ef15d2b
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Defines the AJAX interface for Gollem.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @package  Gollem
+ */
+class Gollem_Ajax_Application extends Horde_Core_Ajax_Application {}
index d5059f1..fa1f02d 100644 (file)
@@ -4,8 +4,8 @@ $charset = $GLOBALS['registry']->getCharset();
 
 /* Variables used in core javascript files. */
 $var = array(
-    'empty_input' => intval($GLOBALS['browser']->hasQuirk('empty_file_input_value')),
-    'prefs_api' => Horde::getServiceLink('prefsapi', 'gollem')
+    'URI_AJAX' => Horde::getServiceLink('ajax', 'gollem')->url,
+    'empty_input' => intval($GLOBALS['browser']->hasQuirk('empty_file_input_value'))
 );
 
 /* Gettext strings used in core javascript files. */
index 07336d1..3016e4f 100644 (file)
@@ -3001,7 +3001,7 @@ var DimpBase = {
     /* Pref updating function. */
     _updatePrefs: function(pref, value)
     {
-        new Ajax.Request(DimpCore.addURLParam(DIMP.conf.URI_PREFS), { parameters: { pref: pref, value: value } });
+        DimpCore.doAction('setPrefValue', { pref: pref, value: value });
     },
 
     /* Onload function. */
index 2022a36..f1f2b07 100644 (file)
@@ -55,7 +55,6 @@ $code['conf'] = array_filter(array(
     'URI_COMPOSE' => strval(Horde::url('compose-dimp.php')->setRaw(true)->add('ajaxui', 1)),
     'URI_DIMP' => strval(Horde::url('index-dimp.php')),
     'URI_MESSAGE' => strval(Horde::url('message-dimp.php')->setRaw(true)->add('ajaxui', 1)),
-    'URI_PREFS' => strval(Horde::getServiceLink('prefsapi', 'imp')),
     'URI_PREFS_IMP' => strval(Horde::getServiceLink('prefs', 'imp')->setRaw(true)->add('ajaxui', 1)),
     'URI_SEARCH' => strval(Horde::url('search.php')),
     'URI_VIEW' => strval(Horde::url('view.php')),
index 5ff6fb3..c66981b 100644 (file)
@@ -10,7 +10,7 @@ function sbarToggle()
         body.addClassName('rightPanel');
     }
 
-    new Ajax.Request(KronolithVar.pref_api_url, { parameters: { pref: 'show_panel', value: pref_value } });
+    new Ajax.Request(KronolithVar.URI_AJAX + 'setPrefValue', { parameters: { pref: 'show_panel', value: pref_value } });
 }
 
 document.observe('dom:loaded', function() {
index 307eba1..50e40ca 100644 (file)
@@ -8,9 +8,9 @@ $currentDate = Kronolith::currentDate();
 
 /* Variables used in core javascript files. */
 $var = array(
+    'URI_AJAX' => Horde::getServiceLink('ajax', 'kronolith')->url,
     'calendar_info_url' => (string)Horde::url('calendars/info.php', true),
     'page_title' => $GLOBALS['registry']->get('name') . ' :: ',
-    'pref_api_url' => (string)Horde::getServiceLink('prefsapi', 'kronolith'),
     'twentyFour' => intval($GLOBALS['prefs']->getValue('twentyFour')),
     'view_url' => (string)Horde::url('view.php'),
 );
diff --git a/nag/lib/Ajax/Application.php b/nag/lib/Ajax/Application.php
new file mode 100644 (file)
index 0000000..06ffc8f
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Defines the AJAX interface for Nag.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @package  Nag
+ */
+class Nag_Ajax_Application extends Horde_Core_Ajax_Application {}
index c95534f..ba96037 100644 (file)
@@ -34,7 +34,7 @@ function sbarToggle()
         Element.addClassName(document.body, 'rightPanel');
     }
 
-    new Ajax.Request('<?php echo Horde::getServiceLink('prefsapi', 'nag') ?>', { parameters: { pref: 'show_panel', value: pref_value } });
+    new Ajax.Request('<?php echo Horde::getServiceLink('ajax', 'nag')->url ?>setPrefValue', { parameters: { pref: 'show_panel', value: pref_value } });
 }
 
 document.observe('dom:loaded', function() {
diff --git a/skoli/lib/Ajax/Application.php b/skoli/lib/Ajax/Application.php
new file mode 100644 (file)
index 0000000..6d30960
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Defines the AJAX interface for Skoli.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/gpl.html GPL
+ * @package  Skoli
+ */
+class Skoli_Ajax_Application extends Horde_Core_Ajax_Application {}
index 5d250c3..7801452 100644 (file)
@@ -26,7 +26,7 @@ function sbarToggle()
         Element.addClassName(document.body, 'rightPanel');
     }
 
-    new Ajax.Request('<?php echo Horde::getServiceLink('prefsapi', 'skoli') ?>', { parameters: { pref: 'show_panel', value: pref_value } });
+    new Ajax.Request('<?php echo Horde::getServiceLink('ajax', 'skoli')->url ?>setPrefValue', { parameters: { pref: 'show_panel', value: pref_value } });
 }
 </script>
 <a id="sbarShow" href="#" onclick="sbarToggle(); return false;"><?php echo _("Classes") ?></a>
index 8a1eb1a..5d762e3 100644 (file)
@@ -15,10 +15,9 @@ function table_sortCallback(tableId, column, sortDown)
 
 function doPrefsUpdate(column, sortDown)
 {
-    baseurl = '<?php echo Horde::getServiceLink('prefsapi', 'skoli') ?>';
     try {
         column = column.substring(1);
-        new Ajax.Request(baseurl, { parameters: { pref: 'sortby', value: encodeURIComponent(column) } });
+        new Ajax.Request('<?php echo Horde::getServiceLink('ajax', 'skoli')->url ?>setPrefValue', { parameters: { pref: 'sortby', value: column } });
     } catch (e) {}
 }