Function to validate any add form input.
public validateAddForm ( &$info ) : mixed | ||
return | mixed | Either false if the form does not validate correctly or an array with all the form values. |
/* Set up the form variables. */ $vars = $injector->getInstance('Horde_Variables'); $perms = $injector->getInstance('Horde_Perms'); $corePerms = $injector->getInstance('Horde_Core_Perms'); $perm_id = $vars->get('perm_id'); try { $permission = $perms->getPermissionById($perm_id); } catch (Exception $e) { $notification->push(_("Invalid parent permission."), 'horde.error'); Horde::url('admin/perms/index.php', true)->redirect(); } /* Set up form. */ $ui = new Horde_Core_Perms_Ui($perms, $corePerms); $ui->setVars($vars); $ui->setupAddForm($permission); if ($ui->validateAddForm($info)) { try { if ($info['perm_id'] == Horde_Perms::ROOT) { $child = $corePerms->newPermission($info['child']); $result = $perms->addPermission($child); } else { $pOb = $perms->getPermissionById($info['perm_id']); $name = $pOb->getName() . ':' . str_replace(':', '.', $info['child']); $child = $corePerms->newPermission($name); $result = $perms->addPermission($child); } $notification->push(sprintf(_("\"%s\" was added to the permissions system."), $corePerms->getTitle($child->getName())), 'horde.success'); Horde::url('admin/perms/edit.php', true)->add('perm_id', $child->getId())->redirect(); } catch (Exception $e) { Horde::log($e, 'ERR'); $notification->push(sprintf(_("\"%s\" was not created: %s."), $corePerms->getTitle($child->getName()), $e->getMessage()), 'horde.error');