Skip to content

Commit

Permalink
Some small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
spotweb committed Jul 3, 2012
1 parent 869d4a9 commit 956461f
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Auto detect text files and perform LF normalization
* text=auto
* text=LF

# Custom for Visual Studio
*.cs diff=csharp
Expand Down
168 changes: 84 additions & 84 deletions lib/dbstruct/SpotStruct_pgsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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']);
Expand All @@ -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);
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion lib/notifications/Notifications_Boxcar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/notifications/Notifications_Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ function sendMessage($type, $title, $body, $sourceUrl) {
mail($this->_dataArray['receiver'], $title, $body, $header);
} # sendMessage

} # Notifications_Email
} # Notifications_Email
2 changes: 1 addition & 1 deletion lib/notifications/Notifications_Growl.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ function sendMessage($type, $title, $body, $sourceUrl) {
$this->growlObj->notify($this->_connection, $type, $title, $body);
} # sendMessage

} # Notifications_Growl
} # Notifications_Growl
2 changes: 1 addition & 1 deletion lib/notifications/Notifications_Notifo.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ function sendMessage($type, $title, $body, $sourceUrl) {
$response = $this->notifoObj->send_notification($params);
} # sendMessage

} # Notifications_Notifo
} # Notifications_Notifo
4 changes: 2 additions & 2 deletions lib/notifications/Notifications_Prowl.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
class Notifications_Prowl extends Notifications_abs {
class Notifications_Prowl extends Notifications_abs {
private $_apikey;
private $_appName;
var $prowlObj;
Expand Down Expand Up @@ -45,4 +45,4 @@ function sendMessage($type, $title, $body, $sourceUrl) {
} # if
} # sendMessage

} # Notifications_Prowl
} # Notifications_Prowl
2 changes: 1 addition & 1 deletion lib/notifications/Notifications_Twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ function sendMessage($type, $title, $body, $sourceUrl) {
} # if
} # sendMessage

} # Notifications_Twitter
} # Notifications_Twitter
2 changes: 1 addition & 1 deletion templates/mobile/permdenied.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<?php
/* Als de user nog niet ingelogged is, geven we hem - mits hij dat recht heeft - de mogelijkheid in te loggen */
if ($tplHelper->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' => '');
Expand Down

0 comments on commit 956461f

Please sign in to comment.