/**
  * Returns the authorization items of the specific type and user.
  * @param integer $type the item type (0: operation, 1: task, 2: role). Defaults to null,
  * meaning returning all items regardless of their type.
  * @param mixed $userId the user ID. Defaults to null, meaning returning all items even if
  * they are not assigned to a user.
  * @return array the authorization items of the specific type.
  */
 public function getAuthItems($type = null, $userId = null)
 {
     $authItems = parent::getAuthItems();
     if ($type === null && $userId === null) {
         return $authItems;
     }
     $items = array();
     if ($userId === null) {
         foreach ($authItems as $name => $item) {
             if ($item->getType() == $type) {
                 $items[$name] = $item;
             }
         }
     } else {
         foreach ($this->getAuthAssignments($userId) as $assignment) {
             $name = $assignment->getItemName();
             if (isset($authItems[$name]) && ($type === null || $authItems[$name]->getType() == $type)) {
                 $items[$name] = $authItems[$name];
             }
         }
     }
     return $items;
 }