ImportModel::deleteFiles PHP Method

deleteFiles() public method

public deleteFiles ( )
    public function deleteFiles()
    {
        if (stringBeginsWith($this->ImportPath, 'Db:', true)) {
            return;
        }
        $St = Gdn::structure();
        foreach (val('Tables', $this->Data, array()) as $Table => $TableInfo) {
            $Path = val('Path', $TableInfo, '');
            if (file_exists($Path)) {
                unlink($Path);
            }
            // Drop the import table.
            $St->table("z{$Table}")->drop();
        }
        // Delete the uploaded files.
        $UploadedFiles = val('UploadedFiles', $this->Data, array());
        foreach ($UploadedFiles as $Path => $Name) {
            safeUnlink($Path);
        }
    }

Usage Example

示例#1
0
 /**
  * Restart the import process. Undo any work we've done so far and erase state.
  *
  * @since 2.0.0
  * @access public
  */
 public function restart($transientKey = '')
 {
     $this->permission('Garden.Import');
     // This permission doesn't exist, so only users with Admin == '1' will succeed.
     if (!Gdn::session()->validateTransientKey($transientKey) && !Gdn::request()->isAuthenticatedPostBack()) {
         throw new Gdn_UserException('The CSRF token is invalid.', 403);
     }
     // Delete the individual table files.
     $Imp = new ImportModel();
     try {
         $Imp->loadState();
         $Imp->deleteFiles();
     } catch (Exception $Ex) {
     }
     $Imp->deleteState();
     redirect(strtolower($this->Application) . '/import');
 }
All Usage Examples Of ImportModel::deleteFiles