Öffentliche Methoden | |
| __construct ($role, Zend_Acl $acl) | |
| Konstruktor. | |
| filter ($array) | |
| Filter das übergebene Array. | |
Geschützte Attribute | |
| $_acl = null | |
| Zend_Acl, ACL-Objekt. | |
| $_role = null | |
| string, Rollenname | |
Filtert für bestimmte Benutzergruppen nicht zugängliche Links heraus.
Definiert in Zeile 11 der Datei Acl.php.
| Dsao_Filter_Acl::__construct | ( | $ | role, | |
| Zend_Acl $ | acl | |||
| ) |
| Dsao_Filter_Acl::filter | ( | $ | array | ) |
Filter das übergebene Array.
| $menu | array, Array aus URIs im Format /module/controller/action bzw. Objekten der Klasse Dsao_Uri_Http |
Definiert in Zeile 43 der Datei Acl.php.
00044 { 00045 foreach ($array as $key => $value) 00046 { 00047 // Falls Menügruppe übergeben wurde 00048 if ($value instanceof Dsao_Module_Menu_Group) 00049 { 00050 // Damit Objekte erhalten bleiben, müssen die Inhalte speziell 00051 // gefiltert werden 00052 $value->setFromArray($this->filter($value->toArray())); 00053 00054 // Falls das Objekt nun leer ist, Element löschen 00055 if (!$value->toArray()) 00056 { 00057 unset($array[$key]); 00058 } 00059 00060 continue; 00061 } 00062 00063 // Rekursion 00064 if (is_array($value)) 00065 { 00066 $array[$key] = $this->filter($value); 00067 00068 if (empty($array[$key])) 00069 { 00070 unset($array[$key]); 00071 } 00072 00073 continue; 00074 } 00075 00076 $uri = (string) $value; 00077 00078 // In Modul, Controller und Aktion aufspalten 00079 $parts = explode('/', $uri, 4); 00080 00081 // Falls URI zu kurz 00082 if (count($parts) < 4) 00083 { 00084 throw new Dsao_Exception('dsao_filter_acl_invalid_uri'); 00085 } 00086 00087 // module (Modul) 00088 $resourceCurrentModule = $parts[1]; 00089 00090 // module_controller (Controller) 00091 $resourceCurrentController = $resourceCurrentModule.'_'.$parts[2]; 00092 00093 // module_controller_action (Aktion) 00094 $resourceCurrentAction = $resourceCurrentController.'_'.$parts[3]; 00095 00096 // Falls Aktion vorhanden 00097 if ($this->_acl->has($resourceCurrentAction)) 00098 { 00099 // Falls Benutzer Erlaubnis hat, auf die Aktion zuzugreifen 00100 if ($this->_acl->isAllowed($this->_role, $resourceCurrentAction)) 00101 { 00102 continue; 00103 } 00104 } 00105 // Falls Controller vorhanden 00106 else if ($this->_acl->has($resourceCurrentController)) 00107 { 00108 // Falls Benutzer Erlaubnis hat, auf den Controller zuzugreifen 00109 if ($this->_acl->isAllowed($this->_role, $resourceCurrentController)) 00110 { 00111 continue; 00112 } 00113 } 00114 // Falls Modul vorhanden 00115 else if ($this->_acl->has($resourceCurrentModule)) 00116 { 00117 // Falls Benutzer Erlaubnis hat, auf das Modul zuzugreifen 00118 if ($this->_acl->isAllowed($this->_role, $resourceCurrentModule)) 00119 { 00120 continue; 00121 } 00122 } 00123 00124 // Die Ressource existiert nicht oder der Benutzer hat keine Berechtigung 00125 // darauf zuzugreifen, also löschen 00126 unset($array[$key]); 00127 } 00128 00129 return $array; 00130 }
1.5.7.1