Skip to content
Snippets Groups Projects
Select Git revision
  • issue-444
  • master default
  • issue-752
  • develop
  • issue-677
  • issue-677-original-with-migrate
  • issue-716
  • issue-654
  • issue-732
  • issue-737
  • issue-735
  • issue-707
  • issue-706
  • issue-705
  • issue-703
  • issue-696
  • issue-690
  • issue-675
  • issue-670
  • issue-635
  • issue-404
  • 7.19
  • 2012-04-18
  • 2012-04-03
  • 2012-04-02
  • 2012-03-01
  • 2012-02-07
  • 20120207
  • 2012-01-13
  • 2012-01-12
  • 2011-12-16
  • 2011-12-05
  • 2011-11-17
  • 2011-11-14
  • 2011-11-08.2
  • 2011-11-08
  • 2011-11-01
  • 2011-10-27
  • 2011-10-06
  • 2011-10-03
  • 2011-09-19
41 results

authorize.inc

Blame
  • Forked from UNL Information Services / UNL-CMS
    Source project has a limited visibility.
    UseradminController.php 4.53 KiB
    <?php
    
    class UserAdminController extends Nmc_Controller_Action
    {
        public function indexAction()
        {
            $out = new Nmc_View();
    
            $groups = Groups::getInstance()->fetchAllWithoutPrimaries();
    
            $out->title = 'Group Administration';
            $out->page = 'user_admin';
            $out->groups = $groups;
            echo $out->render();
        }
    
        public function editUserAction()
        {
            $in = $this->_getAllParams();
            $userId = Zend_Filter::getInt($in['URI_PARAMS'][0]);
    
            if($in['Submit'] == 'Submit') {
                return $this->editUserActionPost();
            }
    
            $out = new Nmc_View();
    
            $out->title = 'Group Administration';
            $out->page = 'user_admin';
    
            if($userId < 0) {
                $out->user = People::getInstance()->fetchNew();
            } else {
                $out->user = People::getInstance()->find($userId);
            }
            $out->groups = Groups::getInstance()->fetchAllWithoutPrimaries();
    
            echo $out->render();
        }
    
        protected function editUserActionPost()
        {
            $in = $this->_getAllParams();
            $userId = Zend_Filter::getInt($in['URI_PARAMS'][0]);
            if(!$userId) {
                $user = People::getInstance()->fetchNew();
            } else {
                $user = People::getInstance()->find($userId);
            }
    
            if($in['delete'] == '1') {
                $user->delete();
            } else {
                $user->firstName = Zend_Filter::getAlnum($in['firstName']);
                $user->lastName = Zend_Filter::getAlnum($in['lastName']);
                $user->save();
            }
    
            $selectedGroups = Groups::getInstance()->findAll($in['groups']);
            $currentGroups = $user->getGroups(false);
    
            $removedGroups = $currentGroups->getRowsNotInCommonWith($selectedGroups);
            $newGroups = $selectedGroups->getRowsNotInCommonWith($currentGroups);
    
            foreach($removedGroups as $removedGroup) {
                $removedGroup->removeUser($user);
            }
    
            foreach($newGroups as $newGroup)
            {
                $newGroup->addUser($user);
            }
    
    
            $out = new Nmc_View();
            $out->refresh = '/UserAdmin/EditUser/' . $userId;
            echo $out->render();
        }
    
        public function editGroupAction()
        {
            $in = $this->_getAllParams();
            $groupId = Zend_Filter::getInt($in['URI_PARAMS'][0]);
    
            if($in['Submit'] == 'Submit') {
                return $this->editGroupActionPost();
            }
    
            $out = new Nmc_View();
    
            $out->title = 'Group Administration';
            $out->page = 'user_admin';
    
            if($groupId < 0) {
                $out->group = Groups::getInstance()->fetchNew();
            } else {
                $out->group = Groups::getInstance()->find($groupId);
            }
            $out->groups = Groups::getInstance()->fetchAllWithoutPrimaries();
            $out->users = People::getInstance()->fetchAll();
            $out->groups = Groups::getInstance()->fetchAllWithoutPrimaries();
    
            echo $out->render();
        }
    
        protected function editGroupActionPost()
        {
            $in = $this->_getAllParams();
            $groupId = Zend_Filter::getInt($in['URI_PARAMS'][0]);
            if(!$groupId) {
                $group = Groups::getInstance()->fetchNew();
                $group->type = 1;
            } else {
                $group = Groups::getInstance()->find($groupId);
            }
    
            if($in['delete'] == '1') {
                $group->delete();
            } else {
                $group->name = $in['name'];
                $group->description = $in['description'];
                $group->save();
            }
    
            $selectedGroups = Groups::getInstance()->findAll($in['groups']);
            $currentGroups = $group->getGroups(false);
    
            $removedGroups = $currentGroups->getRowsNotInCommonWith($selectedGroups);
            $newGroups = $selectedGroups->getRowsNotInCommonWith($currentGroups);
    
            foreach($removedGroups as $removedGroup) {
                $group->removeGroup($removedGroup);
            }
    
            foreach($newGroups as $newGroup)
            {
                $group->addGroup($newGroup);
            }
    
            $selectedUsers = People::getInstance()->findAll($in['users']);
            $currentUsers = $group->getUsers(false);
    
            $removedUsers = $currentUsers->getRowsNotInCommonWith($selectedUsers);
            $newUsers = $selectedUsers->getRowsNotInCommonWith($currentUsers);
    
            foreach($removedUsers as $removedUser) {
                $group->removeUser($removedUser);
            }
    
            foreach($newUsers as $newUser) {
                $group->addUser($newUser);
            }
    
            $out = new Nmc_View();
            $out->refresh = '/UserAdmin/EditGroup/' . $groupId;
            echo $out->render();
        }
    }
    
    ?>