/**
  * Stores selected permissions in database.
  *
  * @param type $request
  *
  * TODO secure against missing parameters
  */
 private function storeModules($request)
 {
     $id = $request->getParam('roleid');
     $role = new Opus_UserRole($id);
     $roleModules = $role->listAccessModules();
     foreach ($roleModules as $module) {
         if ($request->getParam('set_' . $module, 'NULL') === 'NULL') {
             $role->removeAccessModule($module);
         }
     }
     $params = $request->getParams();
     foreach ($params as $name => $value) {
         if ($this->string_begins_with($name, 'set_')) {
             $module = explode("_", $name, 2);
             $module = $module[1];
             $role->appendAccessModule($module);
         }
     }
     $role->store();
 }