Code

Added acls to openexchange
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 Jul 2006 11:56:15 +0000 (11:56 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 Jul 2006 11:56:15 +0000 (11:56 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4316 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/personal/connectivity/class_oxchangeAccount.inc
plugins/personal/connectivity/oxchange.tpl

index 260a0184881650726ab37afce66de47533b4c40d..fc53581a74c67d3029ccfaa4d047406f75d6a64f 100644 (file)
@@ -29,11 +29,12 @@ class oxchangeAccount extends plugin
   var $OXTaskDays="5";
   var $OXTimeZone="GMT";
   var $mailEnabled="OK";
+  var $dnModeValue = "";
 
   /* attribute list for save action */
   var $attributes= array("OXAppointmentDays", "OXTaskDays", "OXTimeZone","mailEnabled");
   var $objectclasses= array("OXUserObject");
-
+  var $ReadOnly =false;
   var $oxconf = array();
   var $timezones=array(
       "Africa/Abidjan",
@@ -588,6 +589,7 @@ class oxchangeAccount extends plugin
     }
 
     $this->dnmode= $this->config->current['DNMODE'];
+    $this->dnModeValue = $this->attrs[$this->dnmode][0];
   }
 
   function execute()
@@ -595,29 +597,9 @@ class oxchangeAccount extends plugin
        /* Call parent execute */
        //plugin::execute();
   
-    print_red(_("New ACLs are not implemeneted yet."));
 
        $display="";
-    /* Show tab dialog headers  * /
-    $display="";
-    if ($this->parent != NULL){
-      if ($this->is_account){
-       $display="";
-      } else {
-        $obj= $this->parent->by_object['posixAccount'];
-       $obj2= $this->parent->by_object['mailAccount'];
-        if (! $obj->is_account){
-          $display= "<BR><BR><CENTER>".sprintf(_("This account has %s features disabled. Posix features are needed for openXchange accounts, enable them first."), "<b>"._("OpenXchange")."</b>")."</CENTER><BR><BR>";
-
-        } else {
-         if (! $obj2->is_account){
-           $display= "<BR><BR><CENTER>".sprintf(_("This account has %s features disabled. Mail features are needed for openXchange accounts, enable them first."), "<b>"._("OpenXchange")."</b>")."</CENTER><BR><BR>";
-            return ($display);
-         }
-        }
-      }
-    }
-*/
+
     /* Show main page */
     $smarty= get_smarty();
 
@@ -630,9 +612,7 @@ class oxchangeAccount extends plugin
     /* Load attributes */
     foreach($this->attributes as $val){
       $smarty->assign("$val", $this->$val);
-      $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
     }
-    $smarty->assign("oxchangeAccountACL", chkacl($this->acl, "oxchangeAccount"));
     if ($this->is_account){
       $smarty->assign("oxchangeState", "checked");
       $smarty->assign("oxState", "");
@@ -641,6 +621,18 @@ class oxchangeAccount extends plugin
       $smarty->assign("oxState", "disabled");
     }
 
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $key => $desc){
+      $smarty->assign($key."ACL",$this->getacl($key,$this->ReadOnly));
+      $smarty->assign($key."_W",$this->acl_is_writeable($key));
+    }
+
+    if((!$this->ReadOnly) && (($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable())) ){
+      $smarty->assign('oxchangeAccountACL', "");
+    }else{
+      $smarty->assign('oxchangeAccountACL', " disabled ");
+    }
+
     $smarty->assign("timezones", $this->timezones);
 
 
@@ -670,6 +662,8 @@ class oxchangeAccount extends plugin
 
   function remove_from_parent()
   {
+    if(!$this->acl_is_removeable())  return;
+    $this->attrs[$this->dnmode][0] = $this->dnModeValue;
     $sqldeluser=array(
         "delete from prg_notes where (user_right like '".$this->attrs[$this->dnmode][0]."') and (group_right like 's')",
         "delete from prg_documents_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
@@ -744,7 +738,7 @@ class oxchangeAccount extends plugin
 
     /* Finally remove data from postgresql server */
     foreach ($sqldeluser as $sqls){
-      pg_exec($pgcon,$sqls);
+       @pg_exec($pgcon,$sqls);
     }
     pg_close();
   }
@@ -755,15 +749,26 @@ class oxchangeAccount extends plugin
     /* Do we need to flip is_account state? */
     if (isset($_POST['connectivityTab'])){
       if (isset($_POST['oxchange'])){
-        if (!$this->is_account && $_POST['oxchange'] == "B"){
-          $this->is_account= TRUE;
+        if (!$this->is_account && $_POST['oxchange'] == "B") {
+          if($this->acl_is_createable()){
+            $this->is_account= TRUE;
+          }
         }
       } else {
-        $this->is_account= FALSE;
+        if($this->acl_is_removeable()){
+          $this->is_account= FALSE;
+        }
       }
     }
 
-    plugin::save_object();
+    /* Get objects */
+    foreach(array("OXTimeZone","OXTaskDays","OXAppointmentDays") as $name) {
+      if($this->acl_is_writeable($name) && isset($_POST[$name])){
+        $this->$name = $_POST[$name];
+      } 
+    }
+  
+//    plugin::save_object();
     if (isset($_POST["oxchangeStatus"])){
       $this->oxchangeStatus = "disabled";
     } else {
@@ -846,35 +851,34 @@ class oxchangeAccount extends plugin
       $os = "insert into oxfolder_standardfolders (owner,module_calendar,module_contact,module_task) VALUES ('%s',%d,%d,%d)";
       $ugr= "INSERT INTO usr_general_rights SELECT creating_date, created_from, changing_date, changed_from,text('%s'),  addr_u, addr_r, addr_d, cont_u, cont_r, cont_d, data_u, data_r, data_d, serie_u, serie_r, serie_d, task_u, task_r, task_d,  refer, proj_u, proj_r, proj_d, dfolder_u, dfolder_r, dfolder_d, doc_u, doc_r, doc_d, knowl_u, knowl_r, knowl_d, bfolder_u,  bfolder_r, bfolder_d, bookm_u, bookm_r, bookm_d, pin_u, pin_r, pin_d, forum_n, fentrie_n, setup, pin_public, internal,  int_groups, kfolder_u, kfolder_r, kfolder_d, webmail FROM sys_gen_rights_template WHERE login LIKE 'default_template'";
 
-      $res=pg_exec($pgcon,$nv); $calendarid=pg_fetch_row($res); pg_freeresult($res);
+      $res=@pg_exec($pgcon,$nv); $calendarid=pg_fetch_row($res); pg_freeresult($res);
       $q=sprintf($ot,$calendarid[0],'My Appointments','calendar',$uid,$uid);
-      pg_exec($pgcon,$q);
-      $res=pg_exec($pgcon,$nv); $nid=pg_fetch_row($res); pg_freeresult($res);
+      @pg_exec($pgcon,$q);
+      $res=@pg_exec($pgcon,$nv); $nid=pg_fetch_row($res); pg_freeresult($res);
       $q=sprintf($op,$nid[0],$calendarid[0],$uid);
-      pg_exec($pgcon,$q);
-      $res=pg_exec($pgcon,$nv); $contactsid=pg_fetch_row($res); pg_freeresult($res);
+      @pg_exec($pgcon,$q);
+      $res=@pg_exec($pgcon,$nv); $contactsid=pg_fetch_row($res); pg_freeresult($res);
       $q=sprintf($ot,$contactsid[0],'My Contacts','contact',$uid,$uid);
-      pg_exec($pgcon,$q);
-      $res=pg_exec($pgcon,$nv); $nid=pg_fetch_row($res); pg_freeresult($res);
+      @pg_exec($pgcon,$q);
+      $res=@pg_exec($pgcon,$nv); $nid=pg_fetch_row($res); pg_freeresult($res);
       $q=sprintf($op,$nid[0],$contactsid[0],$uid);
-      pg_exec($pgcon,$q);
-      $res=pg_exec($pgcon,$nv); $tasksid=pg_fetch_row($res); pg_freeresult($res);
+      @pg_exec($pgcon,$q);
+      $res=@pg_exec($pgcon,$nv); $tasksid=pg_fetch_row($res); pg_freeresult($res);
       $q=sprintf($ot,$tasksid[0],'My Tasks','task',$uid,$uid);
-      pg_exec($pgcon,$q);
-      $res=pg_exec($pgcon,$nv); $nid=pg_fetch_row($res); pg_freeresult($res);
+      @pg_exec($pgcon,$q);
+      $res=@pg_exec($pgcon,$nv); $nid=pg_fetch_row($res); pg_freeresult($res);
       $q=sprintf($op,$nid[0],$tasksid[0],$uid);
-      pg_exec($pgcon,$q);
+      @pg_exec($pgcon,$q);
       $q=sprintf($os,$uid,$calendarid[0],$contactsid[0],$tasksid[0]);
-      pg_exec($pgcon,$q);
+      @pg_exec($pgcon,$q);
       $q=sprintf($ugr,$uid);
-      pg_exec($pgcon,$q);
+      qpg_exec($pgcon,$q);
       pg_close($pgcon);
     }
   }
 
 
-  /* Return plugin informations for acl handling
-    #FIXME ACL attributes aren't translated yet.       */
+  /* Return plugin informations for acl handling */
   function plInfo()
   {
     return (array(
@@ -888,9 +892,8 @@ class oxchangeAccount extends plugin
           "plOptions"       => array(),
 
           "plProvidedAcls"  => array(
-            "OXAppointmentDays" => "!!! FIXME "._("OXAppointmentDays"),
+            "OXAppointmentDays" => _("OXAppointmentDays"),
             "OXTaskDays"           => _("OXTaskDays"),
-            "mailEnabled"        => _("mailEnabled"),
             "OXTimeZone"           => _("OXTimeZone"))
           ));
   }
index 653f0e33c672befd043a8900ed1e05ef32cc776d..0a0940c5db4addd8fcf1e5cbe8caa2131ef65069 100644 (file)
@@ -1,13 +1,21 @@
 {if !$pg}
 <h2>{t}Open-Xchange Account{/t} - {t}disabled, no Postgresql support detected. Or the specified database can't be reached{/t}</h2>
 {else}
-
+<h2>
 <input type="checkbox" name="oxchange" value="B" 
        {$oxchangeState} {$oxchangeAccountACL} 
-       onCLick="       changeState('OXAppointmentDays');
-                               changeState('OXTaskDays');
-                               changeState('OXTimeZone');" >
-<h2>{t}Open-Xchange account{/t}</h2>
+       onCLick="       
+       {if $OXAppointmentDays_W} 
+               changeState('OXAppointmentDays');
+       {/if}
+       {if $OXTaskDays_W} 
+               changeState('OXTaskDays');
+       {/if}
+       {if $OXTimeZone_W} 
+               changeState('OXTimeZone'); 
+       {/if}
+       ">
+{t}Open-Xchange account{/t}</h2>
 
 
 <table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=0 border=0>
        </tr>
        <tr>
          <td><LABEL for="OXAppointmentDays">{t}Appointment Days{/t}</LABEL></td>
-        <td><input name="OXAppointmentDays" id="OXAppointmentDays" size=7 maxlength=7 {$OXAppointmentDaysACL} value="{$OXAppointmentDays}" {$oxState}> {t}days{/t}</td>
+        <td>
+
+{render acl=$OXAppointmentDaysACL}     
+<input name="OXAppointmentDays" id="OXAppointmentDays" size=7 maxlength=7 {$OXAppointmentDaysACL} value="{$OXAppointmentDays}" {$oxState}>
+{/render}
+        {t}days{/t}</td>
        </tr>
        <tr>
          <td><LABEL for="OXTaskDays">{t}Task Days{/t}</LABEL></td>
-        <td><input name="OXTaskDays" id="OXTaskDays" size=7 maxlength=7 {$OXTaskDaysACL} value="{$OXTaskDays}" {$oxState}> {t}days{/t}</td>
+        <td>
+
+{render acl=$OXTaskDaysACL}    
+<input name="OXTaskDays" id="OXTaskDays" size=7 maxlength=7 value="{$OXTaskDays}" {$oxState}>
+{/render}
+
+        {t}days{/t}
+       </td>
        </tr>
      </table>
    </td>
        </tr>
        <tr>
          <td><LABEL for="OXTimeZone">{t}User Timezone{/t}</LABEL></td>
-        <td><select size="1" name="OXTimeZone" id="OXTimeZone" {$OXTimeZoneACL} {$oxState}> 
-        {html_options values=$timezones output=$timezones selected=$OXTimeZone}
-        </select>
+        <td>
+
+{render acl=$OXTimeZoneACL}    
+<select size="1" name="OXTimeZone" id="OXTimeZone" {$oxState}> 
+ {html_options values=$timezones output=$timezones selected=$OXTimeZone}
+ </select>
+{/render}
+
         </td>
        </tr>
        <tr>