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 $rest = get_sub_list("(&(macAddress=*)(FAIrepository=*)(objectClass=FAIrepositoryServer))",
48 "server",get_ou("serverRDN"),$config->current['BASE'],
49 array("cn","FAIrepository","macAddress"),GL_SUBSEARCH);
51 foreach($rest as $attrs){
52 $serv = array();
53 $serv['REPOSITORIES'] = array();
54 for($i = 0 ; $i < $attrs['FAIrepository']['count'] ; $i ++){
55 list($url,$parent,$release,$sections) = explode("|",$attrs['FAIrepository'][$i]);
56 $repo['SECTIONS'] = split(",",$sections);
57 $repo['RELEASE'] = $release;
58 $repo['PARENT'] = $parent;
59 $repo['URL'] = $url;
60 $serv['REPOSITORIES'] [] = $repo;
61 }
62 $serv['MAC'] = $attrs['macAddress'][0];
63 $serv['DN'] = $attrs['dn'];
64 $serv['SERVER'] = $attrs['cn'][0];
65 $res[] = $serv;
66 }
67 return($res);
68 }
71 /*! \brief Returns all keyring entries for the specified server
72 @param String The servers mac address.
73 @return Array All keyring entries.
74 */
75 public static function list_keys($server)
76 {
77 $o_queue = new gosaSupportDaemon();
78 $data = $o_queue->DAK_keyring_entries($server);
79 if($o_queue->is_error()){
80 msg_dialog::display(_("Error"), $o_queue->get_error(), ERROR_DIALOG);
81 }
82 return($data);
83 }
86 /*! \brief Imports the given key into a keyring specified by server
87 @param String The mac address of the server that provides the keyring.
88 @param String The Key to import.
89 @return Boolean TRUE in case of success else FALSE.
90 */
91 public static function import_key($server,$key)
92 {
93 $o_queue = new gosaSupportDaemon();
94 $o_queue->DAK_import_key($server,$key);
95 if($o_queue->is_error()){
96 msg_dialog::display(_("Error"), $o_queue->get_error(), ERROR_DIALOG);
97 return(FALSE);
98 }
99 return(TRUE);
100 }
103 /*! \brief Removes the given key from a keyring.
104 @param String The servers mac address where the keyring is located.
105 @param String The Key UID to remove.
106 @return Boolean TRUE in case of success else FALSE.
107 */
108 public static function remove_key($server,$key)
109 {
110 $o_queue = new gosaSupportDaemon();
111 $o_queue->DAK_remove_key($server,$key);
112 if($o_queue->is_error()){
113 msg_dialog::display(_("Error"), $o_queue->get_error(), ERROR_DIALOG);
114 return(FALSE);
115 }
116 return(TRUE);
117 }
118 }
120 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
121 ?>