From 956461f69604a271d3f675609f227cfd59d585f9 Mon Sep 17 00:00:00 2001 From: spotweb Date: Wed, 4 Jul 2012 00:53:21 +0200 Subject: [PATCH] Some small changes --- .gitattributes | 2 +- lib/dbstruct/SpotStruct_pgsql.php | 168 ++++++++++---------- lib/notifications/Notifications_Boxcar.php | 2 +- lib/notifications/Notifications_Email.php | 2 +- lib/notifications/Notifications_Growl.php | 2 +- lib/notifications/Notifications_Notifo.php | 2 +- lib/notifications/Notifications_Prowl.php | 4 +- lib/notifications/Notifications_Twitter.php | 2 +- templates/mobile/permdenied.inc.php | 2 +- 9 files changed, 93 insertions(+), 93 deletions(-) diff --git a/.gitattributes b/.gitattributes index 412eeda78..a582a1793 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,5 @@ # Auto detect text files and perform LF normalization -* text=auto +* text=LF # Custom for Visual Studio *.cs diff=csharp diff --git a/lib/dbstruct/SpotStruct_pgsql.php b/lib/dbstruct/SpotStruct_pgsql.php index 823b79541..1842c5ebc 100755 --- a/lib/dbstruct/SpotStruct_pgsql.php +++ b/lib/dbstruct/SpotStruct_pgsql.php @@ -15,8 +15,8 @@ function analyze() { $this->_dbcon->rawExec("VACUUM ANALYZE filters"); $this->_dbcon->rawExec("VACUUM ANALYZE spotteridblacklist"); $this->_dbcon->rawExec("VACUUM ANALYZE filtercounts"); - $this->_dbcon->rawExec("VACUUM ANALYZE spotstatelist"); - $this->_dbcon->rawExec("VACUUM ANALYZE users"); + $this->_dbcon->rawExec("VACUUM ANALYZE spotstatelist"); + $this->_dbcon->rawExec("VACUUM ANALYZE users"); $this->_dbcon->rawExec("VACUUM ANALYZE cache"); } # analyze @@ -54,16 +54,16 @@ function nativeDtToSw($colInfo) { /* checks if an index exists */ function indexExists($idxname, $tablename) { - $q = $this->_dbcon->arrayQuery("SELECT indexname FROM pg_indexes WHERE schemaname = CURRENT_SCHEMA() AND tablename = '%s' AND indexname = '%s'", - Array($tablename, $idxname)); + $q = $this->_dbcon->arrayQuery("SELECT indexname FROM pg_indexes WHERE schemaname = CURRENT_SCHEMA() AND tablename = '%s' AND indexname = '%s'", + Array($tablename, $idxname)); return !empty($q); } # indexExists /* checks if a column exists */ function columnExists($tablename, $colname) { - $q = $this->_dbcon->arrayQuery("SELECT column_name FROM information_schema.columns - WHERE table_schema = CURRENT_SCHEMA() AND table_name = '%s' AND column_name = '%s'", - Array($tablename, $colname)); + $q = $this->_dbcon->arrayQuery("SELECT column_name FROM information_schema.columns + WHERE table_schema = CURRENT_SCHEMA() AND table_name = '%s' AND column_name = '%s'", + Array($tablename, $colname)); return !empty($q); } # columnExists @@ -121,21 +121,21 @@ function getFtsInfo($ftsname, $tablename, $colList) { * $idxType can be either 'UNIQUE', '' or 'FULLTEXT' */ function addIndex($idxname, $idxType, $tablename, $colList) { - if (!$this->indexExists($idxname, $tablename)) { - switch($idxType) { - case 'UNIQUE': { - $this->_dbcon->rawExec("CREATE UNIQUE INDEX " . $idxname . " ON " . $tablename . "(" . implode(",", $colList) . ")"); - break; - } # case - - case 'FULLTEXT' : { - $this->_dbcon->rawExec("CREATE INDEX " . $idxname . " ON " . $tablename . " USING gin(to_tsvector('dutch', " . implode(",", $colList) . "))"); - break; - } # case - - default : { - $this->_dbcon->rawExec("CREATE INDEX " . $idxname . " ON " . $tablename . "(" . implode(",", $colList) . ")"); - } # default + if (!$this->indexExists($idxname, $tablename)) { + switch($idxType) { + case 'UNIQUE': { + $this->_dbcon->rawExec("CREATE UNIQUE INDEX " . $idxname . " ON " . $tablename . "(" . implode(",", $colList) . ")"); + break; + } # case + + case 'FULLTEXT' : { + $this->_dbcon->rawExec("CREATE INDEX " . $idxname . " ON " . $tablename . " USING gin(to_tsvector('dutch', " . implode(",", $colList) . "))"); + break; + } # case + + default : { + $this->_dbcon->rawExec("CREATE INDEX " . $idxname . " ON " . $tablename . "(" . implode(",", $colList) . ")"); + } # default } # switch } # if } # addIndex @@ -203,36 +203,36 @@ function modifyColumn($colName, $tablename, $colType, $colDefault, $notNull, $co * Only pgsql 9.1 (only just released) supports per-column collation, so for now * we ignore this */ - switch(strtolower($collation)) { + switch(strtolower($collation)) { case 'utf8' : case 'ascii' : case 'ascii_bin' : - case '' : $colSetting = ''; break; - default : throw new Exception("Invalid collation setting"); - } # switch + case '' : $colSetting = ''; break; + default : throw new Exception("Invalid collation setting"); + } # switch # and define the 'NOT NULL' part switch($notNull) { case true : $nullStr = 'NOT NULL'; break; default : $nullStr = ''; } # switch - + # Alter the column type - $this->_dbcon->rawExec("ALTER TABLE " . $tablename . " ALTER COLUMN " . $colName . " TYPE " . $colType); - - # Change the default value (if one set, else drop it) - if (strlen($colDefault) > 0) { - $this->_dbcon->rawExec("ALTER TABLE " . $tablename . " ALTER COLUMN " . $colName . " SET " . $colDefault); - } else { - $this->_dbcon->rawExec("ALTER TABLE " . $tablename . " ALTER COLUMN " . $colName . " DROP DEFAULT"); - } # if - - # and changes the null/not-null constraint - if (strlen($notNull) > 0) { - $this->_dbcon->rawExec("ALTER TABLE " . $tablename . " ALTER COLUMN " . $colName . " SET NOT NULL"); - } else { - $this->_dbcon->rawExec("ALTER TABLE " . $tablename . " ALTER COLUMN " . $colName . " DROP NOT NULL"); - } # if + $this->_dbcon->rawExec("ALTER TABLE " . $tablename . " ALTER COLUMN " . $colName . " TYPE " . $colType); + + # Change the default value (if one set, else drop it) + if (strlen($colDefault) > 0) { + $this->_dbcon->rawExec("ALTER TABLE " . $tablename . " ALTER COLUMN " . $colName . " SET " . $colDefault); + } else { + $this->_dbcon->rawExec("ALTER TABLE " . $tablename . " ALTER COLUMN " . $colName . " DROP DEFAULT"); + } # if + + # and changes the null/not-null constraint + if (strlen($notNull) > 0) { + $this->_dbcon->rawExec("ALTER TABLE " . $tablename . " ALTER COLUMN " . $colName . " SET NOT NULL"); + } else { + $this->_dbcon->rawExec("ALTER TABLE " . $tablename . " ALTER COLUMN " . $colName . " DROP NOT NULL"); + } # if } # modifyColumn /* drops a column */ @@ -244,7 +244,7 @@ function dropColumn($colName, $tablename) { /* checks if a table exists */ function tableExists($tablename) { - $q = $this->_dbcon->arrayQuery("SELECT tablename FROM pg_tables WHERE schemaname = CURRENT_SCHEMA() AND (tablename = '%s')", array($tablename)); + $q = $this->_dbcon->arrayQuery("SELECT tablename FROM pg_tables WHERE schemaname = CURRENT_SCHEMA() AND (tablename = '%s')", array($tablename)); return !empty($q); } # tableExists @@ -255,12 +255,12 @@ function createTable($tablename, $collation) { * Only pgsql 9.1 (only just released) supports per-column collation, so for now * we ignore this */ - switch(strtolower($collation)) { - case 'utf8' : - case 'ascii' : - case '' : $colSetting = ''; break; - default : throw new Exception("Invalid collation setting"); - } # switch + switch(strtolower($collation)) { + case 'utf8' : + case 'ascii' : + case '' : $colSetting = ''; break; + default : throw new Exception("Invalid collation setting"); + } # switch $this->_dbcon->rawExec("CREATE TABLE " . $tablename . " (id SERIAL PRIMARY KEY) " . $colSetting); } # if @@ -274,7 +274,7 @@ function dropTable($tablename) { } # dropTable /* dummy - postgresql doesn't know storage engines of course */ - function alterStorageEngine($tablename, $engine) { + function alterStorageEngine($tablename, $engine) { return false; } # alterStorageEngine @@ -284,26 +284,26 @@ function renameTable($tablename, $newTableName) { } # renameTable /* drop a foreign key constraint */ - function dropForeignKey($tablename, $colname, $reftable, $refcolumn, $action) { + function dropForeignKey($tablename, $colname, $reftable, $refcolumn, $action) { /* SQL from http://stackoverflow.com/questions/1152260/postgres-sql-to-list-table-foreign-keys */ - $q = $this->_dbcon->arrayQuery("SELECT - tc.constraint_name AS CONSTRAINT_NAME, - tc.table_name AS TABLE_NAME, - tc.constraint_schema AS TABLE_SCHEMA, - kcu.column_name AS COLUMN_NAME, - ccu.table_name AS REFERENCED_TABLE_NAME, - ccu.column_name AS REFERENCED_COLUMN_NAME - FROM - information_schema.table_constraints AS tc - JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name - JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name - WHERE constraint_type = 'FOREIGN KEY' - AND tc.TABLE_SCHEMA = CURRENT_SCHEMA() - AND tc.TABLE_NAME = '%s' - AND kcu.COLUMN_NAME = '%s' - AND ccu.table_name = '%s' - AND ccu.column_name = '%s'", - Array($tablename, $colname, $reftable, $refcolumn)); + $q = $this->_dbcon->arrayQuery("SELECT + tc.constraint_name AS CONSTRAINT_NAME, + tc.table_name AS TABLE_NAME, + tc.constraint_schema AS TABLE_SCHEMA, + kcu.column_name AS COLUMN_NAME, + ccu.table_name AS REFERENCED_TABLE_NAME, + ccu.column_name AS REFERENCED_COLUMN_NAME + FROM + information_schema.table_constraints AS tc + JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name + JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name + WHERE constraint_type = 'FOREIGN KEY' + AND tc.TABLE_SCHEMA = CURRENT_SCHEMA() + AND tc.TABLE_NAME = '%s' + AND kcu.COLUMN_NAME = '%s' + AND ccu.table_name = '%s' + AND ccu.column_name = '%s'", + Array($tablename, $colname, $reftable, $refcolumn)); if (!empty($q)) { foreach($q as $res) { $this->_dbcon->rawExec("ALTER TABLE " . $tablename . " DROP CONSTRAINT " . $res['constraint_name']); @@ -313,25 +313,25 @@ function dropForeignKey($tablename, $colname, $reftable, $refcolumn, $action) { /* create a foreign key constraint */ function addForeignKey($tablename, $colname, $reftable, $refcolumn, $action) { - /* SQL from http://stackoverflow.com/questions/1152260/postgres-sql-to-list-table-foreign-keys */ - $q = $this->_dbcon->arrayQuery("SELECT - tc.constraint_name AS CONSTRAINT_NAME, - tc.table_name AS TABLE_NAME, - tc.constraint_schema AS TABLE_SCHEMA, - kcu.column_name AS COLUMN_NAME, - ccu.table_name AS REFERENCED_TABLE_NAME, - ccu.column_name AS REFERENCED_COLUMN_NAME - FROM - information_schema.table_constraints AS tc - JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name - JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name - WHERE constraint_type = 'FOREIGN KEY' + /* SQL from http://stackoverflow.com/questions/1152260/postgres-sql-to-list-table-foreign-keys */ + $q = $this->_dbcon->arrayQuery("SELECT + tc.constraint_name AS CONSTRAINT_NAME, + tc.table_name AS TABLE_NAME, + tc.constraint_schema AS TABLE_SCHEMA, + kcu.column_name AS COLUMN_NAME, + ccu.table_name AS REFERENCED_TABLE_NAME, + ccu.column_name AS REFERENCED_COLUMN_NAME + FROM + information_schema.table_constraints AS tc + JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name + JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name + WHERE constraint_type = 'FOREIGN KEY' AND tc.TABLE_SCHEMA = CURRENT_SCHEMA() AND tc.TABLE_NAME = '%s' AND kcu.COLUMN_NAME = '%s' AND ccu.table_name = '%s' AND ccu.column_name = '%s'", - Array($tablename, $colname, $reftable, $refcolumn)); + Array($tablename, $colname, $reftable, $refcolumn)); if (empty($q)) { $this->_dbcon->rawExec("ALTER TABLE " . $tablename . " ADD FOREIGN KEY (" . $colname . ") REFERENCES " . $reftable . " (" . $refcolumn . ") " . $action); @@ -385,7 +385,7 @@ function getColumnInfo($tablename, $colname) { } # getColumnInfo /* Returns in a fixed format, index information */ - function getIndexInfo($idxname, $tablename) { + function getIndexInfo($idxname, $tablename) { $q = $this->_dbcon->arrayQuery("SELECT * FROM pg_indexes WHERE schemaname = CURRENT_SCHEMA() diff --git a/lib/notifications/Notifications_Boxcar.php b/lib/notifications/Notifications_Boxcar.php index 163c4bada..ed052efe1 100755 --- a/lib/notifications/Notifications_Boxcar.php +++ b/lib/notifications/Notifications_Boxcar.php @@ -20,4 +20,4 @@ function sendMessage($type, $title, $body, $sourceUrl) { $this->boxcarObj->notify($this->_dataArray['email'], $this->_appName, $body, null, null, $sourceUrl); } # sendMessage -} # Notifications_Boxcar +} # Notifications_Boxcar diff --git a/lib/notifications/Notifications_Email.php b/lib/notifications/Notifications_Email.php index d2a95f906..d12656fa1 100755 --- a/lib/notifications/Notifications_Email.php +++ b/lib/notifications/Notifications_Email.php @@ -18,4 +18,4 @@ function sendMessage($type, $title, $body, $sourceUrl) { mail($this->_dataArray['receiver'], $title, $body, $header); } # sendMessage -} # Notifications_Email +} # Notifications_Email diff --git a/lib/notifications/Notifications_Growl.php b/lib/notifications/Notifications_Growl.php index 2b949e5fb..226f71adf 100755 --- a/lib/notifications/Notifications_Growl.php +++ b/lib/notifications/Notifications_Growl.php @@ -21,4 +21,4 @@ function sendMessage($type, $title, $body, $sourceUrl) { $this->growlObj->notify($this->_connection, $type, $title, $body); } # sendMessage -} # Notifications_Growl +} # Notifications_Growl diff --git a/lib/notifications/Notifications_Notifo.php b/lib/notifications/Notifications_Notifo.php index 7588a839c..062566c1b 100755 --- a/lib/notifications/Notifications_Notifo.php +++ b/lib/notifications/Notifications_Notifo.php @@ -22,4 +22,4 @@ function sendMessage($type, $title, $body, $sourceUrl) { $response = $this->notifoObj->send_notification($params); } # sendMessage -} # Notifications_Notifo +} # Notifications_Notifo diff --git a/lib/notifications/Notifications_Prowl.php b/lib/notifications/Notifications_Prowl.php index 4552b468e..7fcd84035 100755 --- a/lib/notifications/Notifications_Prowl.php +++ b/lib/notifications/Notifications_Prowl.php @@ -1,5 +1,5 @@ allowed(SpotSecurity::spotsec_perform_login, '') && ($currentSession['user']['userid'] == $settings->get('nonauthenticated_userid'))) { + if ($tplHelper->allowed(SpotSecurity::spotsec_perform_login, '') && ($currentSession['user']['userid'] == $settings->get('nonauthenticated_userid'))) { # loginform verwacht deze twee variables door de renderer, dus die faken we $data['performredirect'] = true; $loginform = array('username' => '', 'password' => '');