[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] sync/inc/class.ui_sync.inc.php, 1.20
From: |
nomail |
Subject: |
[Phpgroupware-cvs] sync/inc/class.ui_sync.inc.php, 1.20 |
Date: |
Sun, 16 May 2004 16:36:53 +0200 |
Update of /sync/inc
Modified Files:
Branch:
class.ui_sync.inc.php
date: 2004/05/16 14:36:53; author: mleonhardt; state: Exp; lines: +163 -21
Log Message:
- extending sync-ui: User can now change Device-Auth
- bugfix: save conflicthandling
=====================================================================
Index: sync/inc/class.ui_sync.inc.php
diff -u sync/inc/class.ui_sync.inc.php:1.19 sync/inc/class.ui_sync.inc.php:1.20
--- sync/inc/class.ui_sync.inc.php:1.19 Wed May 12 16:14:53 2004
+++ sync/inc/class.ui_sync.inc.php Sun May 16 14:36:53 2004
@@ -44,7 +44,9 @@
'preferences' => True,
'saveconflicthandling' => True,
'savedevicedescription' => True,
- 'resetchannel' => True
+ 'resetchannel' => True,
+ 'devicesettings' => True,
+ 'savedevicesettings' => True
);
/**
@@ -61,6 +63,12 @@
var $nextmatchs;
/**
+ * @var Object phpgw object for handling date-/timefunctions
+ * @access private
+ */
+ var $datetime;
+
+ /**
* @var boolean $debug enable debug-infos
* @access public
*/
@@ -78,6 +86,7 @@
$this->so = CreateObject('sync.so_sync');
$this->bo = CreateObject('sync.bo_sync');
$this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
+ $this->datetime = CreateObject('phpgwapi.datetime');
}
/**
@@ -174,8 +183,12 @@
if ($lastsync == 0)
$lastsync = lang('status_never');
else
-// $lastsync = $GLOBALS['phpgw']->common->show_date($lastsync);
- $lastsync = $lastsync;
+ {
+// switch this, if the routine is in api...
+// $unixtime = $this->datetime->convertIsotoUnixTime($lastsync);
+ $unixtime = $this->convertIsotoUnixTime($lastsync);
+ $lastsync = $GLOBALS['phpgw']->common->show_date($unixtime);
+ }
$this->template->set_var('lastsync_lastsync', $lastsync);
$this->template->set_var('deviceid', $deviceid);
$this->template->set_var('lastsync_source', $source);
@@ -408,7 +421,7 @@
$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_username', lang('head_auth'));
$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');
@@ -430,7 +443,9 @@
$this->template->set_var('deviceid', $deviceid);
$this->template->set_var('save', lang('save'));
$this->template->set_var('device_username', $device[4]);
- $this->template->set_var('device_edit', 'edit');
+ $this->template->set_var('device_edit', lang('head_edit'));
+ $this->template->set_var('devicesettingformaction',
+
$GLOBALS['phpgw']->link('/index.php',"menuaction=sync.ui_sync.devicesettings"));
$DeviceDeleteLink =
$GLOBALS['phpgw']->link('/index.php','menuaction=sync.ui_sync.deletedevice&del_device_id='
. $deviceid);
$this->template->set_var('DeviceDeleteLink',$DeviceDeleteLink);
$this->template->set_var('device_delete', lang('delete'));
@@ -458,22 +473,18 @@
function deletedevice()
{
$del_device_id = get_var('del_device_id');
- $validated = get_var('validated');
- if ($validated == 1)
+ if ($this->so->DeleteDevice($del_device_id) >= 0)
{
- if ($this->so->DeleteDevice($del_device_id) >= 0)
- {
- $status1 = lang('status_ok');
- $status2 = '';
- }
- else
- {
- $status1 = lang('status_error');
- $status2 = lang('status_not');
- }
- $this->last_operation_status = sprintf(lang('status_deldevice'),
- $status1, $this->bo->getDeviceName($del_device_id), $status2);
+ $status1 = lang('status_ok');
+ $status2 = '';
}
+ else
+ {
+ $status1 = lang('status_error');
+ $status2 = lang('status_not');
+ }
+ $this->last_operation_status = sprintf(lang('status_deldevice'),
+ $status1, $this->bo->getDeviceName($del_device_id), $status2);
$this->listdevices();
}
@@ -639,7 +650,7 @@
if ($handlingtype != '')
{
reset($this->bo->conflictsolutions);
- while (list($solutionkey, $solution) =
each($this->conflictsolutions)) {
+ while (list($solutionkey, $solution) =
each($this->bo->conflictsolutions)) {
if ($solution == $handlingtype)
{
if ($this->so->SetConflictHandleSetting($deviceid, $source,
$solutionkey) >= 1)
@@ -699,5 +710,136 @@
$this->listdevices();
}
+ /**
+ * show the device settings edit form
+ *
+ * this public function
+ * loads the devicesettings.tpl
+ * and saves the new settings
+ * @access public
+ */
+
+ function devicesettings()
+ {
+ // get posted variables
+ $deviceid = get_var('deviceid');
+
+ $GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
+
+ $this->template =
CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('sync'));
+ $this->template->set_file(
+ Array(
+ 'sync_template' => 'devicesettings.tpl'
+ )
+ );
+
+ // prepare blocks
+ $this->template->set_block('sync_template','page_header','page_header');
+ $this->template->set_block('sync_template','status','status');
+
$this->template->set_block('sync_template','device_settings','device_settings');
+ $this->template->set_block('sync_template','page_footer','page_footer');
+
+ // parse
+ $this->template->set_var('preferences', lang('sync_preferences'));
+ $this->template->set_var('head_device_settings',
lang('head_device_settings'));
+ $body = $this->template->fp('sync_template','page_header');
+
+ // parse status
+ $this->template->set_var('last_operation_status',
$this->last_operation_status);
+ $body .= $this->template->fp('sync_template','status');
+
+ // parse settingsform
+ $this->template->set_var('head_auth', lang('head_auth'));
+ $this->template->set_var('sync_devicelabel', lang('sync_devicelabel'));
+ $this->template->set_var('devicesettingsformaction',
+
$GLOBALS['phpgw']->link('/index.php',"menuaction=sync.ui_sync.savedevicesettings"));
+
+ // get full infos about the device:
+ $deviceinfo = $this->so->GetDeviceInfo($deviceid, true);
+ $this->template->set_var('device_description',
$this->bo->GetDeviceName($deviceid));
+ $this->template->set_var('head_username', lang('head_username'));
+ $this->template->set_var('deviceid', $deviceid);
+ $this->template->set_var('device_username', $deviceinfo["username"]);
+ $this->template->set_var('head_username', lang('head_username'));
+ $this->template->set_var('head_password', lang('head_password'));
+ $this->template->set_var('device_passwd1', $deviceinfo["password"]);
+ $this->template->set_var('head_passwordrepeat',
lang('head_passwordrepeat'));
+ $this->template->set_var('device_passwd2', $deviceinfo["password"]);
+ $this->template->set_var('error_wrongpassword',
lang('error_wrongpassword'));
+ $this->template->set_var('save', lang('save'));
+ $this->template->set_var('reset', lang('reset'));
+ $body .= $this->template->fp('sync_template','device_settings');
+
+ // footer
+ $IndexLink =
$GLOBALS['phpgw']->link('/index.php','menuaction=sync.ui_sync.listdevices');
+ $this->template->set_var('GoBackLink',$IndexLink);
+ $this->template->set_var('link_back', lang('back'));
+ $body .= $this->template->fp('sync_template','page_footer');
+
+ echo $body;
+
+ $GLOBALS['phpgw']->common->phpgw_footer();
+ }
+
+ /**
+ * save device settings
+ *
+ * this public function
+ * loads the listdevices.tpl
+ * and saves the new settings
+ * @access public
+ */
+
+ function savedevicesettings()
+ {
+ // get submitted variables
+ $deviceid = get_var('deviceid');
+ $username = get_var('username');
+ $password = get_var('passwd1');
+
+ // set the Settings
+ if ($this->so->SetDeviceSettings($deviceid, $username, $password) >= 0)
+ {
+ $status1 = lang('status_ok');
+ $status2 = '';
+ }
+ else
+ {
+ $status1 = lang('status_error');
+ $status2 = lang('status_not');
+ }
+ $this->last_operation_status = sprintf(lang('status_devicesettingssaved'),
+ $status1, $this->bo->getDeviceName($deviceid), $status2);
+ // show devicelist
+ $this->listdevices();
}
+ /**
+ * Convert a timestamp from full Iso 8601 to php-timestamp
+ *
+ * this routine will be replaced by the one in the API, if it is checked
in...
+ * ($this->datetime->convertIsotoUnixTime($lastsync);)
+ *
+ * @param string isostring date in format 20040513T142437Z
+ * @return integer timestamp unix timestamp to be used in php<br>
+ * in case of error return value is boolean
false
+ * @access private
+ */
+ function convertIsotoUnixTime($isostring)
+ {
+ // split
+ if (preg_match("/(\d{4})(\d{2})(\d+)T(\d{2})(\d{2})(\d{2})Z/",
$isostring, $matches))
+ {
+ // return the timestamp
+ return mktime(
+ $matches[4], // hour
+ $matches[5], // min
+ $matches[6], // sec
+ $matches[2], // day
+ $matches[3], // month
+ $matches[1]); // year
+ } else
+ return false;
+ }
+ }
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] sync/inc/class.ui_sync.inc.php, 1.20,
nomail <=