1<?php
2/******************************************************************************/
3/*
4 * Load all assignees from files into an array
5 *
6 */
7  function __get_assignees_from_files($fileextension) {
8  	// loop through plugin conf path and load all '.mail.list.assignees'
9    $BASE = DOKU_PLUGIN."issuetracker/conf/";
10    $assignees_lists = __find_assignees($BASE, $fileextension);
11  	$assignees_list_files = explode(',',$assignees_lists);
12
13  	foreach ($assignees_list_files as $assignees_list)
14    {   $assignees_list = trim($assignees_list);
15        if(is_file($BASE.$assignees_list)) {
16            $assigneesList_handle = fopen($BASE.$assignees_list, "rb");
17            while (!feof($assigneesList_handle) ) {
18        	     $line_of_text = fgets($assigneesList_handle);
19               $parts = explode('=', $line_of_text);
20               if(strlen($parts[0])==0) continue;
21               elseif(strlen($parts[1])==0) {
22                  $parts[1] = trim($parts[0]);
23                  msg($parts[1],0);
24                }
25                 //      NAME      = E-MAIL ADDRESS
26                // delete doubles
27                if(!stristr($x_umail_select,trim($parts[0]))) $x_umail_select = $x_umail_select . "['".trim($parts[0])."','".trim($parts[1])."'],";
28        	  }
29        	  fclose($assigneesList_handle);
30  	    }
31    }
32    return $x_umail_select;
33  }
34/*----------------------------------------------------------------------------*/
35  function __find_assignees($path, $fileextension) {
36    if ($handle=opendir($path)) {
37      while (false!==($file=readdir($handle))) {
38        if ($file<>"." AND $file<>"..") {
39          if (is_file($path.'/'.$file)) {
40            $ext = explode('.',$file);
41            $last = count($ext) - 1;
42	          if (stristr($file, $fileextension)!==false) {
43              $assignees_lists .= ','.$file;
44            }
45          }
46        }
47      }
48    }
49    return $assignees_lists ;
50  }
51/******************************************************************************/