phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] sync/inc/class.ui_sync.inc.php, 1.15


From: nomail
Subject: [Phpgroupware-cvs] sync/inc/class.ui_sync.inc.php, 1.15
Date: Sun, 23 May 2004 06:41:22 -0000

Update of /sync/inc
Modified Files:
        Branch: 
          class.ui_sync.inc.php

date: 2004/05/01 10:15:38;  author: mleonhardt;  state: Exp;  lines: +108 -54

Log Message:
- extended ui functionality
  - edit and show device description
  - show lastsync timestamps
=====================================================================
Index: sync/inc/class.ui_sync.inc.php
diff -u sync/inc/class.ui_sync.inc.php:1.14 sync/inc/class.ui_sync.inc.php:1.15
--- sync/inc/class.ui_sync.inc.php:1.14 Fri Apr 30 13:54:00 2004
+++ sync/inc/class.ui_sync.inc.php      Sat May  1 10:15:38 2004
@@ -25,6 +25,12 @@
     var $so;
 
     /**
+     * @var     object   $bo  application business object
+     * @access  private
+     */
+    var $bo;
+
+    /**
      * @var     array   holds an array of the public functions
      * @access  public
     */
@@ -36,7 +42,8 @@
                        'init'        => True,
       'deletedevice' => True,
       'preferences' => True,
-      'saveconflicthandling' => True
+      'saveconflicthandling' => True,
+      'savedevicedescription' => True
                );
 
     /**
@@ -67,6 +74,7 @@
   function ui_sync()
   {
     $this->so = CreateObject('sync.so_sync');
+    $this->bo = CreateObject('sync.bo_sync');
     $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
   }
 
@@ -131,7 +139,7 @@
     // get actual user ID
     $phpgw_userid = $GLOBALS['phpgw_info']['user']['account_id'];
     //getallsyncsources()
-    $sources = array('Addressbuch', 'Notes', 'Kalender');
+    $sources = array('appointments', 'Contacts', 'Kalender');
     
     // table header
     $this->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
@@ -149,7 +157,7 @@
       // device
       foreach($devicelist as $device) {
         $this->template->set_var('lastsync_devicelabel', 
lang('sync_devicelabel'));
-        $this->template->set_var('lastsync_devicename', $device[1]);
+        $this->template->set_var('lastsync_devicename', 
$this->bo->getDeviceName($device[0]));
         $lastsynctable .= 
$this->template->fp('sync_template','lastsync_device');
 
         // table body
@@ -157,7 +165,14 @@
           $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
           $this->template->set_var('tr_color', $tr_color);
           $this->template->set_var('lastsync_source', $source);
-          $this->template->set_var('lastsync_lastsync', 'heute');
+          $lasttimestamp = $this->so->GetTimestamp($device[0], $source);
+          $lastsync = $lasttimestamp[0];
+          if ($lastsync == 0) 
+            $lastsync = lang('status_never');
+          else
+//            $lastsync = $GLOBALS['phpgw']->common->show_date($lastsync);
+            $lastsync = $lastsync;
+          $this->template->set_var('lastsync_lastsync', $lastsync);
           $this->template->set_var('lastsync_fullsync', 'fullsync bla');
           $lastsynctable .= 
$this->template->fp('sync_template','lastsync_list');
         }
@@ -282,59 +297,12 @@
                StartTestCase();
        }
 
-  /**
-   * insert the list of all registered devices of actual user
-   *
-   * @access  private
-   */
-
-  function insert_devicelist()
-  {
-    // get actual user ID
-    $phpgw_userid = $GLOBALS['phpgw_info']['user']['account_id'];
-    //TODO: lang-support:
-
-    // table header
-    $this->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
-    // account, uri, description, username, edit, delete
-    $this->template->set_var('head_account', lang('head_account'));
-    $this->template->set_var('head_uri', lang('head_uri'));
-    $this->template->set_var('head_description', lang('head_description'));
-    $this->template->set_var('head_username', lang('head_username'));
-    $this->template->set_var('head_edit', lang('head_edit'));
-    $this->template->set_var('head_delete', lang('head_delete'));
-    $devicelisttable = $this->template->fp('sync_template','table_header');
-
-    // all devices of user $phpgw_userlid
-    $devicelist = array();
-    if ($this->so->GetDeviceList($phpgw_userid, $devicelist)) {
-      foreach($devicelist as $device) {
-        $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
-        $this->template->set_var('tr_color', $tr_color);
-        $this->template->set_var('device_account', 
$GLOBALS['phpgw']->accounts->id2name($device[0]));
-        $this->template->set_var('device_uri', $device[1]);
-        $this->template->set_var('device_description', $device[2]);
-        $this->template->set_var('device_username', $device[3]);
-        $this->template->set_var('device_edit', 'edit');
-        $DeviceDeleteLink = 
$GLOBALS['phpgw']->link('/index.php','menuaction=sync.ui_sync.deletedevice&del_device_id='
 . urlencode($device[1]));
-        $this->template->set_var('DeviceDeleteLink',$DeviceDeleteLink);
-        $this->template->set_var('device_delete', lang('delete'));
-        $devicelisttable .= $this->template->fp('sync_template','device_list');
-      }
-    } else
-      $this->template->set_var('device_name','empty');
-
-    // table footer
-    $devicelisttable .= $this->template->fp('sync_template','table_footer');
-
-    return $devicelisttable;
-  }
   
   /**
    * list registered devices
    *
    * this public function
-   * loads the sync.tpl Template and shows the default init site of the sync 
module
+   * loads the listdevices.tpl Template
    * and lists all registered devices of the actual logged in user
    * @access public
   */
@@ -384,6 +352,58 @@
   }
 
   /**
+   * insert the list of all registered devices of actual user
+   *
+   * @access  private
+   */
+
+  function insert_devicelist()
+  {
+    // get actual user ID
+    $phpgw_userid = $GLOBALS['phpgw_info']['user']['account_id'];
+    //TODO: lang-support:
+
+    // table header
+    $this->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
+    // account, uri, description, username, edit, delete
+    $this->template->set_var('head_account', lang('head_account'));
+    $this->template->set_var('head_uri', lang('head_uri'));
+    $this->template->set_var('head_description', lang('head_description'));
+    $this->template->set_var('head_username', lang('head_username'));
+    $this->template->set_var('head_edit', lang('head_edit'));
+    $this->template->set_var('head_delete', lang('head_delete'));
+    $devicelisttable = $this->template->fp('sync_template','table_header');
+
+    // all devices of user $phpgw_userlid
+    $devicelist = array();
+    if ($this->so->GetDeviceList($phpgw_userid, $devicelist)) {
+      foreach($devicelist as $device) {
+        $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
+        $this->template->set_var('tr_color', $tr_color);
+        $this->template->set_var('device_account', 
$GLOBALS['phpgw']->accounts->id2name($device[1]));
+        $this->template->set_var('device_uri', $device[2]);
+        $this->template->set_var('device_description', $device[3]);
+        $this->template->set_var('descriptionsettingformaction', 
+          
$GLOBALS['phpgw']->link('/index.php',"menuaction=sync.ui_sync.savedevicedescription"));
+        $this->template->set_var('deviceid', $device[0]);
+        $this->template->set_var('save', lang('save'));
+        $this->template->set_var('device_username', $device[4]);
+        $this->template->set_var('device_edit', 'edit');
+        $DeviceDeleteLink = 
$GLOBALS['phpgw']->link('/index.php','menuaction=sync.ui_sync.deletedevice&del_device_id='
 . urlencode($device[1]));
+        $this->template->set_var('DeviceDeleteLink',$DeviceDeleteLink);
+        $this->template->set_var('device_delete', lang('delete'));
+        $devicelisttable .= $this->template->fp('sync_template','device_list');
+      }
+    } else
+      $this->template->set_var('device_name','empty');
+
+    // table footer
+    $devicelisttable .= $this->template->fp('sync_template','table_footer');
+
+    return $devicelisttable;
+  }
+
+  /**
    * delete a device
    *
    * this function 
@@ -510,7 +530,7 @@
       // device
       foreach($devicelist as $device) {
         $this->template->set_var('conflicthandling_devicelabel', 
lang('sync_devicelabel'));
-        $this->template->set_var('conflicthandling_devicename', $device[1]);
+        $this->template->set_var('conflicthandling_devicename', 
$this->bo->getDeviceName($device[0]));
         $conflicthandlinglist .= 
$this->template->fp('sync_template','conflicthandling_device');
 
         foreach($sources as $source) {
@@ -572,6 +592,40 @@
     }   
     $this->last_operation_status = sprintf(lang('status_prefsaved'), $status1, 
$status2);
     $this->preferences();
+  }
+
+  /**
+   * save description of device specified by $deviceid (global var)
+   *
+   * this public function
+   * loads the listdevices.tpl Template and shows devicelist of the current 
user
+   * and saves the new description
+   * @access public
+  */
+
+  function savedevicedescription()
+  {
+    $success = false;
+    
+    // get posted variables
+    $deviceid = get_var('deviceid');
+    $newdescription = get_var('device_description_text');
+
+    if ($deviceid != '')
+      $success = $this->so->setDeviceDescription($deviceid, $newdescription);
+    
+    if ($success)
+    {
+      $status1 = lang('status_ok');
+      $status2 = '';
+    }
+    else
+    {
+      $status1 = lang('status_error');
+      $status2 = lang('status_not');
+    }   
+    $this->last_operation_status = sprintf(lang('status_devicedescsaved'), 
$status1, $status2);
+    $this->listdevices();
   }
 
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]