<commit_before><?php
class Vps_Controller_Action_User_UsersController extends Vps_Controller_Action_Auto_Grid
{
    protected $_buttons = array('add', 'delete');
    protected $_sortable = true;
    protected $_defaultOrder = 'id';
    protected $_paging = 20;
    protected $_editDialog = array('controllerUrl'=>'/vps/user/user',
                                   'width'=>400,
                                   'height'=>410);
    protected $_filters = array('text' => true);

    protected function _getWhere()
    {
        $where = parent::_getWhere();
        $acl = Zend_Registry::get('acl');
        $roles = array();
        foreach ($acl->getAllResources() as $res) {
            if ($res instanceof Vps_Acl_Resource_EditRole
                && $acl->isAllowed($this->_getUserRole(), $res, 'view')
            ) {
                $roles[] = $res->getRoleId();
            }
        }

        if ($roles) {
            $where[] = "role IN ('".implode("','", $roles)."')";
        } else {
            $where[] = "0 = 1";
        }

        return $where;
    }

    public function preDispatch()
    {
        $this->_table = Zend_Registry::get('userModel');
        parent::preDispatch();
    }

    protected function _initColumns()
    {
        parent::_initColumns();
        $this->_columns->add(new Vps_Grid_Column_Button('edit', trlVps('Edit')));
        $this->_columns->add(new Vps_Grid_Column('id', 'ID', 50));
        $this->_columns->add(new Vps_Grid_Column('email', trlVps('Email'), 140));
        $this->_columns->add(new Vps_Grid_Column('role', trlVps('Rights')))
            ->setData(new Vps_Controller_Action_User_Users_RoleData());

        $this->_columns->add(new Vps_Grid_Column('gender', trlVps('Gender'), 70))
            ->setRenderer('genderIcon');
        $this->_columns->add(new Vps_Grid_Column('title', trlVps('Title'), 100));

        $this->_columns->add(new Vps_Grid_Column('firstname', trlVps('First name'), 150));
        $this->_columns->add(new Vps_Grid_Column('lastname', trlVps('Last name'), 150));

        //TODO: sowas nicht mit try-catch lösen
        try {
            new Vpc_Forum_User_Model();
            $this->_columns->add(new Vps_Grid_Column('nickname', trlVps('Forum name'), 150))
                ->setData(new Vps_Controller_Action_User_Users_ForumNameData());
        } catch(Zend_Db_Statement_Exception $e) {
            // Forum user table existiert nicht -> daten nicht anzeigen
        }

        if (isset($this->_getAuthData()->language)){
             $this->_columns->add(new Vps_Grid_Column('language', trlVps('lang'), 30));
        }

        $this->_columns->add(new Vps_Grid_Column('password', trlVps('Activated'), 60))
            ->setRenderer('boolean');

        $authedRole = Zend_Registry::get('userModel')->getAuthedUserRole();
        $acl = Zend_Registry::get('acl');
        if ($acl->getRole($authedRole) instanceof Vps_Acl_Role_Admin) {
            $this->_columns->add(new Vps_Grid_Column('webcode', trlVps('Webcode'), 60))
                 ->setData(new Vps_Controller_Action_User_Users_WebcodeData())
                 ->setRenderer('boolean');
        }
    }<commit_msg>spalte gibts ned immer, nicht mit try-catch probieren<commit_after><?php
class Vps_Controller_Action_User_UsersController extends Vps_Controller_Action_Auto_Grid
{
    protected $_buttons = array('add', 'delete');
    protected $_sortable = true;
    protected $_defaultOrder = 'id';
    protected $_paging = 20;
    protected $_editDialog = array('controllerUrl'=>'/vps/user/user',
                                   'width'=>400,
                                   'height'=>410);
    protected $_filters = array('text' => true);

    protected function _getWhere()
    {
        $where = parent::_getWhere();
        $acl = Zend_Registry::get('acl');
        $roles = array();
        foreach ($acl->getAllResources() as $res) {
            if ($res instanceof Vps_Acl_Resource_EditRole
                && $acl->isAllowed($this->_getUserRole(), $res, 'view')
            ) {
                $roles[] = $res->getRoleId();
            }
        }

        if ($roles) {
            $where[] = "role IN ('".implode("','", $roles)."')";
        } else {
            $where[] = "0 = 1";
        }

        return $where;
    }

    public function preDispatch()
    {
        $this->_table = Zend_Registry::get('userModel');
        parent::preDispatch();
    }

    protected function _initColumns()
    {
        parent::_initColumns();
        $this->_columns->add(new Vps_Grid_Column_Button('edit', trlVps('Edit')));
        $this->_columns->add(new Vps_Grid_Column('id', 'ID', 50));
        $this->_columns->add(new Vps_Grid_Column('email', trlVps('Email'), 140));
        $this->_columns->add(new Vps_Grid_Column('role', trlVps('Rights')))
            ->setData(new Vps_Controller_Action_User_Users_RoleData());

        $this->_columns->add(new Vps_Grid_Column('gender', trlVps('Gender'), 70))
            ->setRenderer('genderIcon');
        $this->_columns->add(new Vps_Grid_Column('title', trlVps('Title'), 100));

        $this->_columns->add(new Vps_Grid_Column('firstname', trlVps('First name'), 150));
        $this->_columns->add(new Vps_Grid_Column('lastname', trlVps('Last name'), 150));

        if (isset($this->_getAuthData()->language)){
             $this->_columns->add(new Vps_Grid_Column('language', trlVps('lang'), 30));
        }

        $this->_columns->add(new Vps_Grid_Column('password', trlVps('Activated'), 60))
            ->setRenderer('boolean');

        $authedRole = Zend_Registry::get('userModel')->getAuthedUserRole();
        $acl = Zend_Registry::get('acl');
        if ($acl->getRole($authedRole) instanceof Vps_Acl_Role_Admin) {
            $this->_columns->add(new Vps_Grid_Column('webcode', trlVps('Webcode'), 60))
                 ->setData(new Vps_Controller_Action_User_Users_WebcodeData())
                 ->setRenderer('boolean');
        }
    }
{'fraction_non_alphanumeric': 0.16367600201240987, 'fraction_numerical': 0.011235955056179775, 'mean_word_length': 2.63436928702011, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5992264', 'n_tokens_mistral': 1879, 'n_tokens_neox': 1780, 'n_words': 299}