public function getPermissions() { if ($this->erased) { throw new Exception("Cannot access permissions of deleted key {$this->id}"); } if (($this->id || $this->key) && !$this->loaded) { $this->load(); } $permissions = new Zotero_Permissions($this->userID); foreach ($this->permissions as $libraryID => $p) { foreach ($p as $key => $val) { $permissions->setPermission($libraryID, $key, $val); } } return $permissions; }