コード例 #1
0
ファイル: Admin.php プロジェクト: projectesIF/Sirius
    /**
     * Edit / Create permissions in the mainview.
     *
     * @return boolean
     */
    public function listedit()
    {
        // Security check
        if (!SecurityUtil::checkPermission('Permissions::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        // Get parameters from whatever input we need.
        $chgpid = FormUtil::getPassedValue('chgpid', null, 'GET');
        $action = FormUtil::getPassedValue('action', null, 'GET');
        $insseq = FormUtil::getPassedValue('insseq', null, 'GET');
        $permgrp = FormUtil::getPassedValue('permgrp', null, 'REQUEST');

        // decide default view
        $rowview = is_null($this->getVar('rowview')) ? '25' : $this->getVar('rowview');

        // Assign the permission levels
        $this->view->assign('permissionlevels', SecurityUtil::accesslevelnames());

        // Work out which tables to operate against, and
        // various other bits and pieces
        $dbtable = DBUtil::getTables();
        $permcolumn = $dbtable['group_perms_column'];
        $mlpermtype = $this->__('Group');
        $viewperms = ($action == 'modify') ? $this->__('Modify permission rule') : $this->__('Create new permission rule');
        $ids = $this->getGroupsInfo();

        $orderBy = "ORDER BY $permcolumn[sequence]";
        $objArray = DBUtil::selectObjectArray('group_perms', '', $orderBy);
        if (!$objArray && $action != 'add') {
            LogUtil::registerError($this->__('Error! No permission rules of this kind were found. Please add some first.'));
            $this->redirect(ModUtil::url('modules', 'admin', 'view'));
        }

        $this->view->assign('title', $viewperms)
                ->assign('mlpermtype', $mlpermtype);

        $accesslevels = SecurityUtil::accesslevelnames();
        $numrows = count($objArray);

        $this->view->assign('idvalues', $ids);

        if ($action == 'modify') {
            // Form-start
            $this->view->assign('formurl', ModUtil::url('Permissions', 'admin', 'update'))
                    ->assign('permgrp', $permgrp)
                    ->assign('chgpid', $chgpid);

            // Realms hard-code4d - jgm
            $this->view->assign('realm', 0)
                    ->assign('insseq', $chgpid)
                    ->assign('submit', $this->__('Edit permission rule'));
        } elseif ($action == 'insert') {
            $this->view->assign('formurl', ModUtil::url('Permissions', 'admin', 'create'))
                    ->assign('permgrp', $permgrp)
                    ->assign('insseq', $insseq);

            // Realms hard-coded - jgm
            $this->view->assign('realm', 0)
                    ->assign('submit', $this->__('Create new permission rule'));
        } elseif ($action == 'add') {
            // Form-start
            $this->view->assign('formurl', ModUtil::url('Permissions', 'admin', 'create'))
                    ->assign('permgrp', $permgrp)
                    ->assign('insseq', -1);

            // Realms hard-coded - jgm
            $this->view->assign('realm', 0)
                    ->assign('submit', $this->__('Create new permission rule'));
        }

        $this->view->assign('action', $action);

        $permissions = array();
        $ak = array_keys($objArray);
        foreach ($ak as $v) {
            $obj = & $objArray[$v];
            $id = $obj['gid']; //get's uid or gid accordingly
            $permissions[] = array(// Realms not currently functional so hide the output - jgm
                    //'realms' => $realms[$realm],
                    'pid' => $obj['pid'],
                    'group' => $ids[$id],
                    'component' => $obj['component'],
                    'instance' => $obj['instance'],
                    'accesslevel' => $accesslevels[$obj['level']],
                    'level' => $obj['level'],
                    'sequence' => $obj['sequence']);
            if ($action == 'modify' && $obj['pid'] == $chgpid) {
                $this->view->assign('selectedid', $id);
            }
        }
        $this->view->assign('permissions', $permissions);

        return $this->view->fetch('permissions_admin_listedit.tpl');
    }
コード例 #2
0
 /**
  * Create a blank permission and return it
  *
  * @return mixed array with new permission or Ajax error
  */
 public function createpermission()
 {
     $this->checkAjaxToken();
     $this->throwForbiddenUnless(SecurityUtil::checkPermission('Permissions::', '::', ACCESS_ADMIN));
     // add a blank permission
     $dummyperm = array('realm' => 0, 'id' => 0, 'component' => '.*', 'instance' => '.*', 'level' => ACCESS_NONE, 'insseq' => -1);
     $newperm = ModUtil::apiFunc('Permissions', 'admin', 'create', $dummyperm);
     if ($newperm == false) {
         AjaxUtil::error($this->__('Error! Could not create new permission rule.'));
     }
     $accesslevels = SecurityUtil::accesslevelnames();
     $newperm['instance'] = DataUtil::formatForDisplay($newperm['instance']);
     $newperm['component'] = DataUtil::formatForDisplay($newperm['component']);
     $newperm['levelname'] = $accesslevels[$newperm['level']];
     $newperm['groupname'] = $this->__('Unregistered');
     return new Zikula_Response_Ajax($newperm);
 }
コード例 #3
0
/**
 * get access level names
 *
 * @deprecated
 * @see SecurityUtil::accesslevelnames()
 * @return array of access names
 */
function accesslevelnames()
{
    LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(
        'accesslevelnames()',
        'SecurityUtil::accesslevelnames()')), E_USER_DEPRECATED);
    return SecurityUtil::accesslevelnames();
}