1 <?php
4 class DAK
5 {
6 public static function get_repositories($config)
7 {
8 if(!$config instanceOf config){
9 trigger_error("Invalid config object given, aborting.");
10 return;
11 }
12 $res = array();
13 $ldap = $config->get_ldap_link();
14 $ldap->cd($config->current['BASE']);
15 $ldap->search("(&(macAddress=*)(FAIrepository=*)(objectClass=FAIrepositoryServer))",array("cn","FAIrepository","macAddress"));
16 while($attrs = $ldap->fetch()){
17 for($i = 0 ; $i < $attrs['FAIrepository']['count'] ; $i ++){
18 list($url,$parent,$release,$sections) = explode("|",$attrs['FAIrepository'][$i]);
19 $repo['SECTIONS'] = split(",",$sections);
20 $repo['SERVER'] = $attrs['cn'][0];
21 $repo['RELEASE'] = $release;
22 $repo['MAC'] = $attrs['macAddress'][0];
23 $repo['PARENT'] = $parent;
24 $repo['URL'] = $url;
25 $repo['DN'] = $attrs['dn'];
26 $res[] = $repo;
27 }
28 }
29 return($res);
30 }
33 public static function get_repositories_by_server($config)
34 {
35 if(!$config instanceOf config){
36 trigger_error("Invalid config object given, aborting.");
37 return;
38 }
39 $res = array();
40 $ldap = $config->get_ldap_link();
41 $ldap->cd($config->current['BASE']);
42 $ldap->search("(&(macAddress=*)(FAIrepository=*)(objectClass=FAIrepositoryServer))",array("cn","FAIrepository","macAddress"));
43 while($attrs = $ldap->fetch()){
44 $serv = array();
45 $serv['REPOSITORIES'] = array();
46 for($i = 0 ; $i < $attrs['FAIrepository']['count'] ; $i ++){
47 list($url,$parent,$release,$sections) = explode("|",$attrs['FAIrepository'][$i]);
48 $repo['SECTIONS'] = split(",",$sections);
49 $repo['RELEASE'] = $release;
50 $repo['PARENT'] = $parent;
51 $repo['URL'] = $url;
52 $serv['REPOSITORIES'] [] = $repo;
53 }
54 $serv['MAC'] = $attrs['macAddress'][0];
55 $serv['DN'] = $attrs['dn'];
56 $serv['SERVER'] = $attrs['cn'][0];
57 $res[] = $serv;
58 }
59 return($res);
60 }
63 /*! \brief Returns all */
64 public static function list_keys($server)
65 {
66 $o_queue = new gosaSupportDaemon();
67 $data = $o_queue->DAK_get_queue_entries($server);
68 if($o_queue->is_error()){
69 msg_dialog::display(_("Error"), $o_queue->get_error(), ERROR_DIALOG);
70 }
71 return($data);
72 }
75 /*! \brief Imports the given key into a keyring specified by server
76 @param String The mac address of the server that provides the keyring.
77 @param String The Key to import.
78 @return Boolean TRUE in case of success else FALSE.
79 */
80 public static function import_key($server,$key)
81 {
82 $o_queue = new gosaSupportDaemon();
83 $o_queue->DAK_import_key($server,$key);
84 if($o_queue->is_error()){
85 msg_dialog::display(_("Error"), $o_queue->get_error(), ERROR_DIALOG);
86 return(FALSE);
87 }
88 return(TRUE);
89 }
92 /*! \brief Removes the given key from a keyring.
93 @param String The servers mac address where the keyring is located.
94 @param String The Key UID to remove.
95 @return Boolean TRUE in case of success else FALSE.
96 */
97 public static function remove_key($server,$key)
98 {
99 $o_queue = new gosaSupportDaemon();
100 $o_queue->DAK_remove_key($server,$key);
101 if($o_queue->is_error()){
102 msg_dialog::display(_("Error"), $o_queue->get_error(), ERROR_DIALOG);
103 return(FALSE);
104 }
105 return(TRUE);
106 }
107 }
109 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
110 ?>