예제 #1
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function CompletelyRemoveAll()
 {
     \OCP\JSON::setContentTypeHeader('application/json');
     try {
         if (isset($_POST['GIDS']) && count($_POST['GIDS']) > 0) {
             $GIDS = array();
             foreach ($_POST['GIDS'] as $GID) {
                 $Status = $this->WhichDownloader == 0 ? Aria2::TellStatus($GID) : CURL::TellStatus($GID);
                 if (!isset($Status['error']) && strcmp($Status['result']['status'], 'removed') == 0) {
                     $Remove = $this->WhichDownloader == 0 ? Aria2::RemoveDownloadResult($GID) : CURL::RemoveDownloadResult($GID);
                 }
                 $SQL = 'DELETE FROM `*PREFIX*ocdownloader_queue` WHERE `UID` = ? AND `GID` = ?';
                 if ($this->DbType == 1) {
                     $SQL = 'DELETE FROM *PREFIX*ocdownloader_queue WHERE "UID" = ? AND "GID" = ?';
                 }
                 $Query = \OCP\DB::prepare($SQL);
                 $Result = $Query->execute(array($this->CurrentUID, $GID));
                 $GIDS[] = $GID;
             }
             return new JSONResponse(array('ERROR' => false, 'MESSAGE' => (string) $this->L10N->t('The download has been totally removed'), 'GIDS' => $GIDS));
         } else {
             return new JSONResponse(array('ERROR' => true, 'MESSAGE' => (string) $this->L10N->t('Bad GID')));
         }
     } catch (Exception $E) {
         return new JSONResponse(array('ERROR' => true, 'MESSAGE' => $E->getMessage()));
     }
 }