示例#1
0
}

// adding a new role
if (Request::option('cmd') == 'addRole' && !Request::submitted('choosePreset')) {
    // to prevent url-hacking for changing the data of an existing role
    $role_id = md5(uniqid(rand()));
    if (!Statusgruppe::roleExists($role_id)) {
        $new_role = new Statusgruppe();

        // this is necessary, because it could be the second try to add after the user has corrected errors
        $new_role->setStatusgruppe_Id($role_id);
        $new_role->setRange_Id($range_id);

        if ($new_role->checkData()) {
            // show a hint if a role with the same name already exists
            if (Statusgruppe::countByName($new_role->getName(), $new_role->getRange_Id()) > 0) {
                $message = sprintf(_('Die Gruppe %s wurde hinzugefügt, es gibt jedoch bereits eine Gruppe mit demselben Namen!'),
                                   '<b>'. htmlReady($new_role->getName()) .'</b>');
                PageLayout::postMessage(MessageBox::info($message));
            } else {
                $message = sprintf(_('Die Gruppe %s wurde hinzugefügt!'),
                                   '<b>'. htmlReady($new_role->getName()) .'</b>');
                PageLayout::postMessage(MessageBox::success($message));
            }

            $new_role->store();
        }

        $msgs = $new_role->getMessages($msgs);
    }
}