示例#1
0
文件: remote.php 项目: netixx/frankiz
 function handler_admin($page, $id = null, $action = null)
 {
     $page->assign('title', "Administration de l'authentification externe");
     $page->assign('remoterights_available', implode(',', Remote::availableRights()));
     // Find remote
     $remote = null;
     if ($id == 'new') {
         $remote = new Remote();
         $remote->insert();
     } elseif (Remote::isId($id)) {
         $remote = new Remote($id);
         // Delete a remote
         if ($action == 'delete') {
             $remote->delete();
             $remote = null;
         }
     }
     if (!empty($remote)) {
         $remote->select(RemoteSelect::groups());
         if (Env::has('change_remote')) {
             $remote->site(Env::t('site'));
             $remote->label(Env::t('label'));
             $remote->privkey(Env::t('privkey'));
             $rights = explode(',', Env::t('rights'));
             foreach ($rights as $k => $v) {
                 $rights[$k] = strtolower(trim($v));
             }
             $rights = array_intersect($rights, Remote::availableRights());
             $remote->rights(new PlFlagSet(implode(',', $rights)));
             $groups = new Collection('Group');
             $groups_fields = array('binets', 'frees');
             foreach ($groups_fields as $field) {
                 foreach (explode(';', Env::t($field)) as $gid) {
                     $gid = trim($gid);
                     if ($gid) {
                         $groups->add(new Group($gid));
                     }
                 }
             }
             $groups->select(GroupSelect::base());
             $remote->groups($groups);
         }
         $page->assign('remote', $remote);
         $page->changeTpl('remote/admin.tpl');
     } else {
         $remotes = Remote::selectAll(RemoteSelect::groups());
         $page->assign('remotes', $remotes);
         $page->changeTpl('remote/list.tpl');
     }
 }