Beispiel #1
0
 public function updateTorrentAgent(PwTorrentAgentDm $dm, $fetchmode = self::FETCH_MAIN)
 {
     if (($result = $dm->beforeUpdate()) !== true) {
         return $result;
     }
     return $this->_getDao($fetchmode)->updateTorrentAgent($dm->id, $dm->getData(), $dm->getIncreaseData());
 }
Beispiel #2
0
 public function doagentAction()
 {
     $PwTorrentAgentDs = Wekit::load('EXT:torrent.service.PwTorrentAgent');
     if ($this->getInput('act', 'post') == 'delete') {
         $PwTorrentAgentDs->deleteTorrentAgent($this->getInput('id', 'post'));
     } else {
         Wind::import('EXT:torrent.service.dm.PwTorrentAgentDm');
         list($allowedClients, $newAllowedClients) = $this->getInput(array('allowedClients', 'newAllowedClients'), 'post');
         foreach ($allowedClients as $key => $allowedClient) {
             if (empty($allowedClient['family']) || empty($allowedClient['agent_pattern'])) {
                 continue;
             }
             $dm = new PwTorrentAgentDm($key);
             $dm->setFamily($allowedClient['family'])->setPeeridPattern($allowedClient['peer_id_pattern'])->setAgentPattern($allowedClient['agent_pattern'])->setAllowHttps($allowedClient['allowhttps']);
             $PwTorrentAgentDs->updateTorrentAgent($dm);
         }
         foreach ($newAllowedClients as $key => $allowedClient) {
             if (empty($allowedClient['family']) || empty($allowedClient['agent_pattern'])) {
                 continue;
             }
             $dm = new PwTorrentAgentDm();
             $dm->setFamily($allowedClient['family'])->setPeeridPattern($allowedClient['peer_id_pattern'])->setAgentPattern($allowedClient['agent_pattern'])->setAllowHttps($allowedClient['allowhttps']);
             $PwTorrentAgentDs->addTorrentAgent($dm);
         }
     }
     $this->showMessage('ADMIN:success');
 }