PHP Class ImportModel, vanilla

Inheritance: extends Gdn_Model
Mostra file Open project: vanilla/vanilla Class Usage Examples

Public Properties

Property Type Description
$CurrentStep Track what step of this process we're on.
$Data array
$ErrorType Error to return.
$ImportPath File location.
$MaxStepTime Max seconds to run a single step.
$Timer Used for timing various long running methods to break them up into pieces.

Protected Properties

Property Type Description
$_MergeSteps Method names in order they are called during a merge.
$_OverwriteSteps Method names in order they are called during a clean slate import from file.
$_OverwriteStepsDb Steps for importing from database.

Public Methods

Method Description
__construct ( $ImportPath = '' ) Set the import path.
addActivity ( ) : boolean
assignOtherIDs ( ) : boolean
assignUserIDs ( ) : boolean
authenticateAdminUser ( ) : boolean
customFinalization ( ) : boolean
data ( $Key, null $Value = null ) : mixed
defineIndexes ( ) : boolean
defineTables ( ) : boolean
deleteFiles ( )
deleteOverwriteTables ( ) Remove the data from the appropriate tables when we are overwriting the forum.
deleteState ( )
fGetCSV2 ( $fp, string $Delim = ',', string $Quote = '"', string $Escape = "\" ) : array
fromPost ( $Post )
generateSQL ( null $Value = null ) : mixed
getCountSQL ( string $Aggregate, string $ParentTable, string $ChildTable, string $ParentColumnName = '', string $ChildColumnName = '', string $ParentJoinColumn = '', string $ChildJoinColumn = '' ) : Gdn_DataSet Return SQL for updating a count.
getCustomImportModel ( ) Get a custom import model based on the import's source.
getImportHeader ( null $fpin = null ) : array | mixed | string
getPasswordHashMethod ( ) : mixed | string
importExists ( string $Table, string $Column = '' ) : boolean Checks to see of a table and/or column exists in the import data.
initialize ( ) : boolean
insertPermissionTable ( ) : boolean
insertTables ( ) : boolean
insertUserTable ( ) : boolean
isDbSource ( ) : boolean | string
loadState ( )
loadTable ( $Tablename, $Path ) : boolean
loadTableInsert ( string $Tablename, string $Path, boolean $skipHeader = true, integer $chunk = 100 ) : boolean Import a table from a CSV using SQL insert statements.
loadTableType ( boolean $Save = true ) : boolean | mixed | string
loadTables ( ) : boolean
loadUserTable ( ) : boolean
localInfileSupported ( ) : boolean
overwrite ( string $Overwrite = '', string $Email = '', string $Password = '' ) : mixed
parseInfoLine ( $Line ) : array
processImportDb ( ) Process the import tables from the database.
processImportFile ( ) : boolean
query ( string $Sql, array $Parameters = null ) : Gdn_DataSet Run a query, replacing database prefixes.
runStep ( integer $Step = 1 ) : mixed Run the step in the import.
saveSQL ( $CurrentStep )
saveState ( )
setCategoryPermissionIDs ( ) Set the category permissions based on the permission table.
setRoleDefaults ( )
stat ( $Key, null $Value = null, string $Op = 'set' ) : mixed
steps ( ) : array
tables ( string $TableName = '' ) : mixed
toPost ( &$Post )
updateCounts ( ) : boolean
verifyImport ( ) Verify imported data.

Protected Methods

Method Description
_InsertTable ( $TableName, array $Sets = [] ) : boolean | integer | void
_LoadTableLocalInfile ( $Tablename, $Path )
_LoadTableOnSameServer ( $Tablename, $Path )
_LoadTableWithInsert ( $Tablename, $Path ) : boolean
_assignIDs ( $TableName, null $PrimaryKey = null, null $SecondaryKey = null ) : boolean | void
_setCategoryPermissionIDs ( $Category, $PermissionID, $IDs )
backTick ( $Str ) : string

Method Details

_InsertTable() protected method

protected _InsertTable ( $TableName, array $Sets = [] ) : boolean | integer | void
$TableName
$Sets array
return boolean | integer | void

_LoadTableLocalInfile() protected method

protected _LoadTableLocalInfile ( $Tablename, $Path )
$Tablename
$Path

_LoadTableOnSameServer() protected method

protected _LoadTableOnSameServer ( $Tablename, $Path )
$Tablename
$Path

_LoadTableWithInsert() protected method

protected _LoadTableWithInsert ( $Tablename, $Path ) : boolean
$Tablename
$Path
return boolean

__construct() public method

Set the import path.
public __construct ( $ImportPath = '' )

_assignIDs() protected method

protected _assignIDs ( $TableName, null $PrimaryKey = null, null $SecondaryKey = null ) : boolean | void
$TableName
$PrimaryKey null
$SecondaryKey null
return boolean | void

_setCategoryPermissionIDs() protected method

protected _setCategoryPermissionIDs ( $Category, $PermissionID, $IDs )
$Category
$PermissionID
$IDs

addActivity() public method

public addActivity ( ) : boolean
return boolean

assignOtherIDs() public method

public assignOtherIDs ( ) : boolean
return boolean

assignUserIDs() public method

public assignUserIDs ( ) : boolean
return boolean

authenticateAdminUser() public method

public authenticateAdminUser ( ) : boolean
return boolean

backTick() protected static method

protected static backTick ( $Str ) : string
$Str
return string

customFinalization() public method

public customFinalization ( ) : boolean
return boolean

data() public method

public data ( $Key, null $Value = null ) : mixed
$Key
$Value null
return mixed

defineIndexes() public method

public defineIndexes ( ) : boolean
return boolean

defineTables() public method

public defineTables ( ) : boolean
return boolean

deleteFiles() public method

public deleteFiles ( )

deleteOverwriteTables() public method

Remove the data from the appropriate tables when we are overwriting the forum.

deleteState() public method

public deleteState ( )

fGetCSV2() public static method

public static fGetCSV2 ( $fp, string $Delim = ',', string $Quote = '"', string $Escape = "\" ) : array
$fp
$Delim string
$Quote string
$Escape string
return array

fromPost() public method

public fromPost ( $Post )
$Post

generateSQL() public method

public generateSQL ( null $Value = null ) : mixed
$Value null
return mixed

getCountSQL() public method

Return SQL for updating a count.
public getCountSQL ( string $Aggregate, string $ParentTable, string $ChildTable, string $ParentColumnName = '', string $ChildColumnName = '', string $ParentJoinColumn = '', string $ChildJoinColumn = '' ) : Gdn_DataSet
$Aggregate string count, max, min, etc.
$ParentTable string The name of the parent table.
$ChildTable string The name of the child table
$ParentColumnName string
$ChildColumnName string
$ParentJoinColumn string
$ChildJoinColumn string
return Gdn_DataSet

getCustomImportModel() public method

Get a custom import model based on the import's source.

getImportHeader() public method

public getImportHeader ( null $fpin = null ) : array | mixed | string
$fpin null
return array | mixed | string

getPasswordHashMethod() public method

public getPasswordHashMethod ( ) : mixed | string
return mixed | string

importExists() public method

Checks to see of a table and/or column exists in the import data.
public importExists ( string $Table, string $Column = '' ) : boolean
$Table string The name of the table to check for.
$Column string
return boolean

initialize() public method

public initialize ( ) : boolean
return boolean

insertPermissionTable() public method

public insertPermissionTable ( ) : boolean
return boolean

insertTables() public method

public insertTables ( ) : boolean
return boolean

insertUserTable() public method

public insertUserTable ( ) : boolean
return boolean

isDbSource() public method

public isDbSource ( ) : boolean | string
return boolean | string

loadState() public method

public loadState ( )

loadTable() public method

public loadTable ( $Tablename, $Path ) : boolean
$Tablename
$Path
return boolean

loadTableInsert() public method

Import a table from a CSV using SQL insert statements.
public loadTableInsert ( string $Tablename, string $Path, boolean $skipHeader = true, integer $chunk = 100 ) : boolean
$Tablename string The name of the table to import to.
$Path string The path to the CSV.
$skipHeader boolean Whether the CSV contains a header row.
$chunk integer The number of records to chunk the imports to.
return boolean Whether any records were found.

loadTableType() public method

public loadTableType ( boolean $Save = true ) : boolean | mixed | string
$Save boolean
return boolean | mixed | string

loadTables() public method

public loadTables ( ) : boolean
return boolean

loadUserTable() public method

public loadUserTable ( ) : boolean
return boolean

localInfileSupported() public method

public localInfileSupported ( ) : boolean
return boolean

overwrite() public method

public overwrite ( string $Overwrite = '', string $Email = '', string $Password = '' ) : mixed
$Overwrite string
$Email string
$Password string
return mixed

parseInfoLine() public method

public parseInfoLine ( $Line ) : array
$Line
return array

processImportDb() public method

Process the import tables from the database.
public processImportDb ( )

processImportFile() public method

public processImportFile ( ) : boolean
return boolean

query() public method

Run a query, replacing database prefixes.
public query ( string $Sql, array $Parameters = null ) : Gdn_DataSet
$Sql string The sql to execute. - :_z will be replaced by the import prefix. - :_ will be replaced by the database prefix.
$Parameters array PDO parameters to pass to the query.
return Gdn_DataSet

runStep() public method

Run the step in the import.
public runStep ( integer $Step = 1 ) : mixed
$Step integer the step to run.
return mixed Whether the step succeeded or an array of information.

saveSQL() public method

public saveSQL ( $CurrentStep )
$CurrentStep

saveState() public method

public saveState ( )

setCategoryPermissionIDs() public method

Set the category permissions based on the permission table.

setRoleDefaults() public method

public setRoleDefaults ( )

stat() public method

public stat ( $Key, null $Value = null, string $Op = 'set' ) : mixed
$Key
$Value null
$Op string
return mixed

steps() public method

public steps ( ) : array
return array

tables() public method

public tables ( string $TableName = '' ) : mixed
$TableName string
return mixed

toPost() public method

public toPost ( &$Post )
$Post

updateCounts() public method

public updateCounts ( ) : boolean
return boolean

verifyImport() public method

Verify imported data.
public verifyImport ( )

Property Details

$CurrentStep public_oe property

Track what step of this process we're on.
public $CurrentStep

$Data public_oe property

public array $Data
return array

$ErrorType public_oe property

Error to return.
public $ErrorType

$ImportPath public_oe property

File location.
public $ImportPath

$MaxStepTime public_oe property

Max seconds to run a single step.
public $MaxStepTime

$Timer public_oe property

Used for timing various long running methods to break them up into pieces.
public $Timer

$_MergeSteps protected_oe property

Method names in order they are called during a merge.
protected $_MergeSteps

$_OverwriteSteps protected_oe property

Method names in order they are called during a clean slate import from file.
protected $_OverwriteSteps

$_OverwriteStepsDb protected_oe property

Steps for importing from database.
protected $_OverwriteStepsDb