Beispiel #1
0
 public function link($arguments)
 {
     if (!Session::isLoggedIn()) {
         return Error::set('Please login.');
     }
     $irc = new irc(ConnectionFactory::get('redis'));
     $username = Session::getVar('username');
     $this->view['valid'] = true;
     $this->view['pending'] = $nicks = $irc->getPending($username);
     $this->view['nicks'] = $goodNicks = $irc->getNicks($username);
     if (!empty($arguments[0]) && $arguments[0] == 'add') {
         if (!isset($nicks[$arguments[1]])) {
             return Error::set('Invalid nick id.');
         }
         $irc->addNick($username, $nicks[$arguments[1]]);
         $this->view['pending'] = $irc->getPending($username);
         $this->view['nicks'] = $irc->getNicks($username);
     } else {
         if (!empty($arguments[0]) && $arguments[0] == 'delP') {
             if (!isset($nicks[$arguments[1]])) {
                 return Error::set('Invalid nick id.');
             }
             $irc->delNick($username, $nicks[$arguments[1]]);
             $this->view['pending'] = $irc->getPending($username);
         } else {
             if (!empty($arguments[0]) && $arguments[0] == 'delA') {
                 if (!isset($goodNicks[$arguments[1]])) {
                     return Error::set('Invalid nick id.');
                 }
                 $irc->delAcceptedNick($username, $goodNicks[$arguments[1]]);
                 $this->view['nicks'] = $irc->getPending($username);
             }
         }
     }
 }