summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBogomil Shopov <shopov@kolabsys.com>2011-04-19 12:08:25 (GMT)
committerBogomil Shopov <shopov@kolabsys.com>2011-04-19 12:08:25 (GMT)
commit7bd1a1f7559608040b9022147ff5ac2835141699 (patch)
treef46d9bb9431daa26066dfd03a6d11a296565237e /lib
parent6af61f8c3c46aa032a1f0bb7ff70e939ca4f0454 (diff)
downloadkolab-webadmin-7bd1a1f7559608040b9022147ff5ac2835141699.tar.gz
ActiveSync management screen
Diffstat (limited to 'lib')
-rw-r--r--lib/KolabAdmin/include/function.kolabsync.php146
-rwxr-xr-x[-rw-r--r--]lib/KolabAdmin/include/menu.php5
2 files changed, 150 insertions, 1 deletions
diff --git a/lib/KolabAdmin/include/function.kolabsync.php b/lib/KolabAdmin/include/function.kolabsync.php
new file mode 100644
index 0000000..f254868
--- /dev/null
+++ b/lib/KolabAdmin/include/function.kolabsync.php
@@ -0,0 +1,146 @@
+<?php
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: function.kolabsync.php
+ * Type: function
+ * Name: Kolabsync
+ * Purpose: Check folder settings
+ * -------------------------------------------------------------
+ */
+global $tmbox;
+@include_once 'Horde/Kolab/Kolab_Zpush/lib/kolabActivesyncData.php';
+
+function smarty_function_kolabsync($params, &$smarty)
+{
+
+ $result = checkFolder($params['folder'],$params['serial']);
+ if ($result=="") $result="0";
+ $folder_type=getFolderType($params['folder']);
+
+ //array
+ if ($result==1)
+ {
+ $checked="checked=checked";
+
+
+ }elseif($result==2)
+ {
+
+ $checked2="checked=checked";
+ $checked="checked=checked";
+ }
+
+ else
+ {
+ $cheked="";
+ $checked2="";
+ }
+ $rnd=rand(5, 121);
+
+ //stupid smarty hack
+ $params['folder']=preg_replace('/( )/','@',$params['folder']);
+ $params['folder']=preg_replace('/\./','*',$params['folder']);
+
+ $ch = "<td><input type=checkbox name='".$params['folder']."' value='1' $checked></td><td width='20'></td>";
+
+
+ if(preg_match("/(event)/",$folder_type) OR preg_match("/(task)/",$folder_type))
+ {
+ $ch = "<td><input type='checkbox' id='".$rnd."-1' name='".$params['folder']."' value='1' $checked onclick='synced(this)'></td>
+ <td><input type='checkbox' id='".$rnd."-2' name='".$params['folder']."' value='2' $checked2 onclick='synced(this)'></td>";
+ }
+
+
+
+
+ return $ch;
+}
+
+
+function connect()
+{
+global $tmbox;
+
+ $connectstring= $_server = "{localhost:143/imap/notls/norsh}";
+ $tmbox = imap_open($_server , $_SESSION['auth_user'], $_SESSION['auth_pw'], OP_HALFOPEN);
+ if ($tmbox) {
+ return $tmbox;
+ }else
+ {
+ return false;
+ }
+
+}
+
+function checkFolder($folder,$serial)
+{
+ $gp=new FolderParam();
+ $result = imap_getannotation(connect(), $folder, "/vendor/kolab/activesync", "value.priv");
+
+
+ if (isset($result["value.priv"]))
+ {
+ $res= json_decode(base64_decode($result["value.priv"]),true);
+
+
+ }
+
+ //is default folder for syncing
+
+ $def=is_default($folder);
+
+
+ if($def==true)
+ {
+ //all default folders
+ $r=1;
+ }
+
+ if((isset($res['FOLDER'][$serial]['S'])) and $res['FOLDER'][$serial]['S'] ==0)
+ {
+
+ $r=0;
+ }else if((isset($res['FOLDER'][$serial]['S'])) and $res['FOLDER'][$serial]['S'] !=0)
+ {
+ return $r=$res['FOLDER'][$serial]['S'];
+
+ }
+
+
+ return $r;
+
+}
+
+ function is_default($folder)
+ {
+
+ if(preg_match("/(^INBOX)/", $folder))
+ {
+
+ return true;
+ }else
+ {
+ return false;
+ }
+ }
+
+ //get folder type
+
+function getFolderType($folder)
+ {
+ global $tmbox;
+
+ $result = imap_getannotation($tmbox, $folder, "/vendor/kolab/folder-type", "value.shared");
+
+ if (isset($result["value.shared"]))
+ {
+ return $result["value.shared"];
+ }
+
+ }
+
+
+/* vim: set expandtab: */
+
+?>
diff --git a/lib/KolabAdmin/include/menu.php b/lib/KolabAdmin/include/menu.php
index 6954c5b..aa0ef6c 100644..100755
--- a/lib/KolabAdmin/include/menu.php
+++ b/lib/KolabAdmin/include/menu.php
@@ -39,7 +39,10 @@ if( $auth->group() == "admin" || $auth->group() == "maintainer" || $auth->group(
array( 'name' => _('Forward Email'),
'url' => 'forward.php' ),
array( 'name' => _('Vacation'),
- 'url' => 'vacation.php' )));
+ 'url' => 'vacation.php' ),
+ array( 'name' => _('ActiveSync'),
+ 'url' => 'activesync.php' ),
+ ));
}
if( $auth->group() == "admin" || $auth->group() == "maintainer") {
$menuitems['addressbook'] = array( 'name' => _('Addressbook'),