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