This file is indexed.

/usr/share/gosa/plugins/personal/mail/class_mail-methods.inc is in gosa-plugin-mail 2.7.4+reloaded2-9ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
<?php


class mailMethod{

  /* Allow modification of account_ids for existing mail accounts */
  protected $modifyableMail   = TRUE;

  /* Allow modification of the mail server attribute existing mail accounts */
  protected $modifyableServer = TRUE;

  /* Enforces same value for 'mail' as used for 'cn' */
  protected $mailEqualsCN   = FALSE; 

  /* the attribute used to create accounts */ 
  protected $uattrib        = "mail";  // Naming attribute for accounts, e.g. imap.

  /* The account prefixes, keep the '.' here! See FAQ cyrusUseSlashes */
  protected $user_prefix    = "user.";  
  protected $share_prefix   = "share.";

  /* Account ID creation 

      !!Depends on the attributes 'user_prefix'/'share_prefix' and the option 'cyrusUseSlashes'

      Examples - based on defaults : 
        %PREFIX%    => "user." or "user/" (Depending on cyrusUseSlashes=FALSE/TRUE) 
        %CN%        => "technik"          (The groups cn)
        %UID%       => "herbert"          (The users uid)
        %MAIL%      => "herbert@domain.de"(The mail address)
        %DOMAIN%    => "domain.de"        (The domain part of the specified mail)
        %MAILPART%  => "herbert"          (The mail address without domain)
        %UATTRIB%   => "herbert"/"herbert@domains.de"
                                            (Configured in gosa.conf mailAttribute="mail"/"uid")
   */
  protected $user_id    = "%PREFIX%%UATTRIB%";  
  protected $share_id   = "%PREFIX%%UATTRIB%";

  /* Create accounts in cyrus style with '/' instead of '.' */
  protected $cyrusUseSlashes= FALSE;

  /* gosaSharedFolderTarget settings, 
   *  E.g. 
   *    For an accountID like: 'share/herberts.folder@gonicus.de' the value 'dummy+' 
   *    will result in gosaSharedFolderTarget: dummy+share/herberts.folder@gonicus.de
   */
  protected $gosaSharedPrefix = '';  

  /* The atribute mapping for this class  Source --> Destination */
  protected $attributes     = array();
  protected $userObjectClasses = array();
  protected $shareObjectClasses = array();

  /* Enabled mail domain selection. If enabled getMailDomains() have to return an array 
   *  with the domain parts.
   */ 
  protected $enableDomainSelection= FALSE;
  protected $enableQuota          = TRUE;
  protected $enableSieveManager   = FALSE;
  protected $enableVacationRange  = TRUE;
  protected $enableFolderTypes    = FALSE;

  /* Default values */
  protected $quotaValue   = 0;  
  protected $quotaUsage   = 0;  

  /* Method internal */
  protected $type               = "user"; 
  protected $account_id         = "";
  protected $initial_account_id = "";
  protected $connected          = FALSE;
  protected $error              = "";
  protected $parent             = NULL;   
  protected $MailServer         = "";

  protected $default_acls = array("__anyone__" => "p", "__member__" => "lrswp");

  protected $acl_map = array(
      "lrsw"     => "read",
      "lrswp"    => "post",
      "p"        => "external post",
      "lrswip"   => "append",
      "lrswipd"  => "delete",
      "lrswipcd" => "write",
      "lrswipcda"=> "admin",
      " "         => "none");

  protected $acl_mapping = array();


  /*! \brief  Constructs the mail class 
      @param  Object  Config  The GOsa configuration object
      @param  Object  Plugin  The initator
      @param  String          Open "user" or "group" account.
   */
  function __construct(&$config, &$parent, $type = "user")
  {
    $this->parent = $parent;
    $this->config = $config;

    /* Create a refernce to the mail selected server 
     */
    if(isset($this->parent->gosaMailServer)){
      $this->MailServer = &$this->parent->gosaMailServer;
    }else{
      trigger_error("mailMethod with invalid parent object initialized.");
    }

    if(!in_array_strict($this->type,array("user","group"))){
      trigger_error("Unknown mail class type used '".$type."'.");
    }else{
      $this->type = $type;
    }

  }

  
  /*! \brief  Intialize attributes and config settings.
   */
  protected function init()
  {
    /* Get config value for cyrusUseSlashes
     */
    if ($this->config->get_cfg_value("core","cyrusUseSlashes") == "true"){
      $this->cyrusUseSlashes = TRUE;
      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "","<b>MAIL:</b> cyrusUseSlashes: <b>Enabled</b>");
    }else{
      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "","<b>MAIL:</b> cyrusUseSlashes: <b>Disabled</b>");
    }

    /* Check if the mail account identification attribute
       is overridden in the configuration file
     */
    if($this->config->get_cfg_value("core","mailAttribute") != ""){
      $new_uattrib= strtolower($this->config->get_cfg_value("core","mailAttribute"));
      if(in_array_strict($new_uattrib,array("mail","uid"))){
        $this->uattrib = $new_uattrib;
      }else{
        @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>".$new_uattrib."</b>",
          "<b>MAIL:</b> Unsupported 'mailAttribute' in gosa configuration specified");
        msg_dialog::display(_("Configuration error"), 
            sprintf(_("The configured mail attribute '%s' is unsupported!"), $new_uattrib), ERROR_DIALOG);
      }
    }

    /* Create ACL map */
    foreach($this->acl_map as $acl => $name){
      $this->acl_mapping[$acl] = _($name);
    }

    /* Check if we have an individual user/folder creation syntax 
     */
    $tmp = $this->config->get_cfg_value("core","mailUserCreation");
    if(!empty($tmp)){
      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<i>".$tmp."</i>",
          "<b>MAIL:</b> User creation set to");
      $this->user_id  = $tmp;
    }
    $tmp = $this->config->get_cfg_value("core","mailFolderCreation");
    if(!empty($tmp)){
      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<i>".$tmp."</i>",
          "<b>MAIL:</b> Shared folder creation set to");
      $this->share_id = $tmp;
    }
    $tmp = $this->config->get_cfg_value("core","gosaSharedPrefix");
    if(!empty($tmp)){
      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<i>".$tmp."</i>",
          "<b>MAIL:</b> Shared folder prefix set to");
      $this->gosaSharedPrefix = $tmp;
    }

    $this->build_account_id();
    $this->initial_account_id = $this->account_id;
  }

  
  public function fixAttributesOnLoad()
  {
    foreach($this->attributes as $source => $dest){
      if(isset($this->parent->attrs[$source])){
        $this->parent->attrs[$dest] = $this->parent->attrs[$source];
      }
      if(isset($this->parent->$source)){
        $this->parent->$dest = $this->parent->$source;
      }
      if(isset($this->parent->attrs[$source][0])){
        $this->parent->saved_attributes[$source] = $this->parent->attrs[$source][0];
      }
    }
  }


  public function mailEqualsCN()
  {
    return($this->mailEqualsCN);
  }
  

  public function fixAttributesOnRemove()
  {
    /* Remove objectClasses  
     */ 
    if($this->type == "user"){
      $this->parent->attrs['objectClass'] = 
        array_remove_entries_ics($this->userObjectClasses, $this->parent->attrs['objectClass']);
    }else{
      $this->parent->attrs['objectClass'] = 
        array_remove_entries_ics($this->shareObjectClasses, $this->parent->attrs['objectClass']);
      $this->parent->attrs['gosaSharedFolderTarget'] =array();
    }
    foreach($this->attributes as $source => $dest){
      $this->attrs[$dest]   = array();
      $this->attrs[$source] = array();
    }
  }

  public function fixAttributesOnStore()
  {
    foreach($this->attributes as $source => $dest){
      if(isset($this->parent->attrs[$dest])){
        $this->parent->attrs[$source] = $this->parent->attrs[$dest ];
      }
      if(isset($this->parent->$dest)){
        $this->parent->$source = $this->parent->$dest;
      }
    }

    if($this->type == "user"){
      $ocs = $this->userObjectClasses;
    }else{
      $ocs = $this->shareObjectClasses;
    }
    foreach($ocs as $oc){
      if(!in_array_strict($oc, $this->parent->attrs['objectClass'])){
        $this->parent->attrs['objectClass'][] = $oc;
      }
    }
  
    // Add gosaSharedFolderTarget for groups.
    $this->build_account_id();
    if($this->type == "group"){ 
      $this->parent->attrs['gosaSharedFolderTarget'] = 
        $this->gosaSharedPrefix.$this->account_id;
    }
  }


  /*! \brief  Connect services like imap.
              Not necessary for the base class.
      @return Boolean True if this method is connected else false.
   */
  public function connect()
  {
    $this->reset_error();
    @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"","<b>MAIL: Connect method</b>: ".get_class($this));
    @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"","<b>MAIL: Current server</b>: ".$this->MailServer);
 
    $this->connected = TRUE;
    return(TRUE);
  }


  /*! \brief  Returns the connection status of this method.
      @return Boolean True if this method is connected else false.
   */
  public function is_connected()
  {
    return($this->connected);
  }


  /*! \brief  Disconnect this method. Close services like imap connection.
              Not necessary for the base class.
   */
  public function disconnect()
  {
    $this->reset_error();
    if($this->is_connected()){
      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"","<b>MAIL: Disconnect method</b>: ".get_class($this));
      $this->connected =FALSE; 
    }
  }

  
  /*! \brief  Returns true the current object represents a valid account
              (Some methods may check imap accounts here.)
      @return Boolean TRUE if this is a valid account else FALSE
  */
  public function account_exists()
  {
    $this->reset_error();
    return(TRUE);
  }
  

  /*! \brief  Returns the last error occurred 
      @return String  The last error message.
   */
  public function get_error(){
    return($this->error);
  }


  public function isModifyableMail()
  {
    return($this->modifyableMail);
  }


  public function isModifyableServer()
  {
    return($this->modifyableServer);
  }


  /*! \brief  Returns TRUE if the action caused an error.
      @return Boolean TRUE on error else FALSE
   */
  public function is_error(){
    return($this->error != "");
  }


  /*! \brief  Resets the error message.
   */
  public function reset_error(){
    $this->error = "";
  }


  public function get_account_id()
  {
    $this->build_account_id();
    return($this->account_id);
  }

  /*! \brief  Create a new account id, like 'user/name@domain.com'.
   */
  protected function build_account_id()
  {
    /* Build account identicator */
    if($this->type == "user"){
      $prefix = $this->user_prefix;
      $acc_string = $this->user_id;
    }else{
      $prefix = $this->share_prefix;
      $acc_string = $this->share_id;
    }

    /* Create account prefix and respect "cyrusUseSlashes" 
       Do not replace escaped dots for cyrusUseSlashes.
     */
    $uattrib = $this->uattrib;
    if($this->cyrusUseSlashes){
      $prefix     = preg_replace('/([^\\\\])\./',"\\1/",$prefix);
      $acc_string = preg_replace('/([^\\\\])\./',"\\1/",$acc_string); 
    }
    $prefix = preg_replace("/\\\\([\.\/])/","\\1",$prefix);
    $acc_string = preg_replace("/\\\\([\.\/])/","\\1",$acc_string); 
  
    $domain = $mailpart = "";
    $mail = $this->parent->mail;
    if(preg_match("/\@/",$mail)){
      list($mailpart,$domain) = explode("@",$mail);
    }

    /* Create account_id 
     */ 
    $from = array("/%cn%/i","/%uid%/i","/%prefix%/i","/%uattrib%/i","/%domain%/i","/%mailpart%/i","/%mail%/i");
    $to   = array($this->parent->cn,$this->parent->uid,$prefix,$this->parent->$uattrib, $domain, $mailpart,$mail);
    $acc_id = trim(strtolower(preg_replace($from,$to,$acc_string)));

    /* Check for not replaced pattern.
     */
    if(preg_match("/%/",$acc_id)){
      $notr = preg_replace("/^[^%]*/","",$acc_id);
      if(!empty($notr)){
        @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"<b>Warning</b>", 
            sprintf("<b>MAIL: WARNING unknown pattern in account creation string '%s' near '%s'</b>", $acc_id, $notr));

        /* Remove incomprehensible patterns */
        $acc_id = preg_replace("/%[^%]+%/","",$acc_id);
      }
    }


    if($this->account_id != $acc_id){
      $this->account_id = $acc_id;
      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"", "<b>MAIL:</b> AccountID generated: <b>".$acc_id."</b>");
    }
  }


  /*! \brief  Creates a valid folder id for a given folder name.
               e.g. $folder_id = "INBOX/test"  &&  $this->account_id = "share/mailbox@domain.de"
               will result in "share/mailbox/test@domain.de"
              This function is mainly used to read and write folder permissions.
      @return String A valid folder id
   */
  public function create_folder_id($folder, $type = "")
  {

    if(!empty($folder)){
      $folder = trim(preg_replace("/^INBOX[\.\/]*/i","",$folder));
    }
    if(!empty($folder)){
      $folder = "/".$folder;
    }

    /* Build account identicator */
    if($this->type == "user"){
      $prefix = $this->user_prefix;
      $acc_string = $this->user_id;
    }else{
      $prefix = $this->share_prefix;
      $acc_string = $this->share_id;
    }

    /* Create account prefix and respect "cyrusUseSlashes" 
       Do not replace escaped dots for cyrusUseSlashes.
     */
    $uattrib = $this->uattrib;
    if($this->cyrusUseSlashes){
      $prefix     = preg_replace('/([^\\\\])\./',"\\1/",$prefix);
      $acc_string = preg_replace('/([^\\\\])\./',"\\1/",$acc_string); 
    }
    $prefix = preg_replace("/\\\\([\.\/])/","\\1",$prefix);
    $acc_string = preg_replace("/\\\\([\.\/])/","\\1",$acc_string); 
  
    $domain = $mailpart = "";
    $mail = $this->parent->mail;
    if(preg_match("/\@/",$mail)){
      list($mailpart,$domain) = explode("@",$mail);
    }

    /* Create account_id
     */
    $from = array("/%cn%/i","/%uid%/i","/%prefix%/i","/%uattrib%/i","/%domain%/i","/%mailpart%/i","/%mail%/i");
    $to   = array($this->parent->cn,$this->parent->uid,$prefix,$this->parent->$uattrib, $domain, $mailpart,$mail);
    $acc_id = trim(strtolower(preg_replace($from,$to,$acc_string)));

    /* Check for not replaced pattern.
     */
    if(preg_match("/%/",$acc_id)){
      $notr = preg_replace("/^[^%]*/","",$acc_id);
      if(!empty($notr)){
        @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"<b>Warning</b>", 
            sprintf("<b>MAIL: WARNING unknown pattern in account creation string '%s' near '%s'</b>", $acc_id, $notr));

        /* Remove incomprehensible patterns */
        $acc_id = preg_replace("/%[^%]+%/","",$acc_id);
      }
    }

    if(preg_match("/\@/",$acc_id)){
      list($mail,$domain) = explode("@",$acc_id);
      $str = trim($mail . $folder . "@" . $domain);
    }else{
      $str = trim($acc_id . $folder);
    }
    return($str) ;
  }


  /*! \brief  Returns the configured mail method for the given parent object, 
                initialized and read for use.
      @return mailMethod  The configured mailMethod.
   */
  public function get_method()
  {
    $methods = mailMethod::get_methods();
    if ($this->config->get_cfg_value("core","mailMethod") != ""){
      $method= $this->config->get_cfg_value("core","mailMethod");
      $cls = get_correct_class_name("mailMethod$method");
      if(isset($methods[$cls])){
        @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"", "<b>MAIL:</b> Selected mailMethod: <b>".$cls."</b>");
        $tmp = new $cls($this->config,$this->parent,$this->type);
        $tmp->init();
        return($tmp);
      }else{
        @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "","<b>MAIL: Invalid mailMethod defined: ".$cls.
            " falling back to ".get_class($this)."</b>");

        /* Print out configuration errors directly, we can't catch them everywhere. 
         */
        msg_dialog::display(_("Configuration error"), 
            sprintf(_("Mail method '%s' is unknown!"), $method), ERROR_DIALOG);
      }
    }

    /* If no valued mailMethod could be detected, return the base class.
     */
    $this->init();
    return($this);
  }


  /*! \brief Saves sieve settings 
   */
  public function saveSieveSettings()
  {
    $this->reset_error();
    return(TRUE);
  }

  
  /*! \brief  Creates or Updates the mailAccount represented by this class. 
   */
  public function updateMailbox()
  {
    $this->reset_error();
    return(TRUE);
  }


  /*! \brief  Update shared folder dependencies 
   */
  public function updateSharedFolder()
  {
    $this->reset_error();
    return(TRUE);
  }


  /*! \brief  Removes the mailbox represented by this class,
               and update shared folder ACLs .
   */
  public function deleteMailbox()
  {
    $this->reset_error();

    @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>".$this->account_id."</b>" ,
        "<b>MAIL: Remove account</b> from server :".$this->MailServer);

    return(TRUE);
  }

  
  /*! \brief  Returns the used mail attribute (mail,uid)
      @param  String  One out of 'mail','uid'
   */
  public function getUAttrib()
  {
    return($this->uattrib);
  }


  /*! \brief  Returns the used mail attribute (mail,uid)
      @param  String  One out of 'mail','uid'
   */
  public function getUAttribValue()
  {
    $uattrib = $this->getUAttrib();
    return($this->parent->$uattrib);
  }

  
  /*! \brief  Returns whether the quota settings are enabled or not 
      @return Boolean TRUE if enabled else FALSE
   */
  public function quotaEnabled()
  {
    return($this->enableQuota);
  }

  
  /*! \brief  Returns the used quota 
      @return Integer Quota used.
   */
  public function getQuotaUsage()
  {
    return(-1);
  }


  /*! \brief  Returns the quota restrictions.
      @return Integer Quota restrictions.
   */
  public function getQuota($quotaValue)
  {
    return($quotaValue);
  }

  
  /*! \brief  Sets the mail quota
   */
  public function setQuota($number)
  {
    if(!is_numeric($number)){
      $number = (int) $number;
      if(!$number){
        $number = 0;
      }
    }
    $this->quotaValue = $number; 
    return(TRUE);
  }


  /*! \brief  Returns true whether the domain is selectable or not 
   */
  public function domainSelectionEnabled()
  {
    return($this->enableDomainSelection);
  } 


  /*! \brief Returns a list of configured mail domains 
      @return Array A list of mail domains
   */
  public function getMailDomains()
  {
    return(array("Unconfigured"));
  } 

  
  /*! \brief  Returns the used Spamlevels for this mailmethod 
   */
  public function getSpamLevels()
  {
    $spamlevel= array();
    for ($i= 0; $i<21; $i++){
      $spamlevel[]= $i;
    }
    return($spamlevel);
  }

  
  /*! \brief  Returns the list of configured mailbox folders
      @return Array The mailbox folders.
   */
  public function getMailboxList()
  {
    return(array("INBOX"));
  }


  /*! \brief  Returns whether the vacation range is selectable or not
      @return Boolean TRUE, FALSE
   */
  public function vacationRangeEnabled()
  {
    return($this->enableVacationRange);
  }

  
  /*! \brief  Returns true if the sieveManagement is allowed
      @return Boolean TRUE, FALSE
   */
  public function allowSieveManagement()
  {
    return($this->enableSieveManager);
  } 


  /*! \brief  Checks dependencies to other GOsa plugins.
   */
  public function accountCreateable(&$reason = ""){
    return(TRUE);
  }


  /*! \brief  Checks whether this account is removeable or not.
              There may be some dependencies left, eg. kolab.
   */
  public function accountRemoveable(&$reason = ""){
    return(TRUE);
  }

  
  /*! \brief  Returns all mail servers configured in GOsa 
               that are useable with this mailMethod.
      @return Array  All useable mail servers.
  */
  public function getMailServers()
  {
    $mailserver = array();
    $ui = get_userinfo();
    foreach ($this->config->data['SERVERS']['IMAP'] as $key => $val){
      if( $this->MailServer == $key ||
          preg_match("/r/",$ui->get_permissions($val['server_dn'],"server/goImapServer",""))){
        $mailserver[]= $key;
      }
    }
    return($mailserver);
  }

  
  /*! \brief  Returns the available mailMethods
      @return Array   A list of all avaialable mailMethods_
   */ 
  static function get_methods()
  {
    global $class_mapping;
    $available = array();
    foreach($class_mapping as $class => $path){
      if($class == "mailMethod") continue;
      if(preg_match("/^mailMethod/",$class)){
        $available[$class] = $class;
      }
    }
    return($available);
  }

  
  /* \brief   Some method require special folder types, "kolab" for example.
      !! Those values are dummy values, the base class doesn't use folder types;
     @return  Array Return folder types.
   */
  public function getAvailableFolderTypes()
  {
    $ret = array();
    $ret['CAT'][''] = _("None"); 
    $ret['SUB_CAT'][''][''] = _("None");
    return($ret);
  }


  /* \brief  Returns the selected folder type. 
      !! Those values are dummy values, the base class doesn't use folder types;
     @return  Array  The folde type.
   */
  public function getFolderType($default)
  {
    return($default);
  }

 
  /* \brief  Returns the selected folder type. 
      !! Those values are dummy values, the base class doesn't use folder types;
     @return  Array  The folde type.
   */
  public function setFolderType($type)
  {
    return(TRUE) ;   
  }


  /*! \brief  Returns configured acls 
   */
  public function  getFolderACLs($folder_acls)
  {
    /* Merge given ACL with acl mapping 
       This ensures that no ACL will accidentally overwritten by gosa.
     */
    foreach($folder_acls as $user => $acl){
      if(!isset($this->acl_mapping[$acl])){
        $this->acl_mapping[$acl] = $acl;
      }
    }

    return($folder_acls);
  }


  /*! \brief  Write ACLs back to imap or what ever 
   */
  public function  setFolderACLs($array)
  {
    return(TRUE);
  }


  /*! \brief  Returns a list of all possible acls.
      @return Array   ACLs.
  */
  public function getAclTypes()
  {
    return( $this->acl_mapping);
  }

  public function folderTypesEnabled()
  {
    return($this->enableFolderTypes);
  }

  public function allow_remove(&$reason)
  {
    return(TRUE);
  }


  /*! \brief  Returns the configured mailMethod
      @return String  the configured mail method or ""
   */
  static public function get_current_method($config)
  {
    global $class_mapping;
    $method= $config->get_cfg_value("core","mailMethod");
    $cls = get_correct_class_name("mailMethod$method");
    foreach($class_mapping as $class => $path){
      if($class == $cls){
        return($class);
      }
    }
    return("");
  }


  static function quota_to_image($use,$quota)
  {
    if($use == -1){
      return("&nbsp;&nbsp;"._("Unknown"));
    }elseif(empty($quota)){
      return("&nbsp;&nbsp;"._("Unlimited"));
    }else{
      $usage =round(($use/$quota) * 100);
      return(progressbar($usage,100,15,true));
    }
  }

 
  /*! \brief  Returns the default sharedFolder ACLs for this method.
      @return Array Returns an array containg acls for __member__ and __anyone__
   */ 
  public function getDefaultACLs()
  {
    $tmp = $this->default_acls;
    if(!isset($tmp['__member__'])) $tmp['__member__'] = " ";
    if(!isset($tmp['__anyone__'])) $tmp['__anyone__'] = " ";
    return($tmp);
  }
}


// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>