summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/controllers/file.php2
-rw-r--r--application/controllers/user.php13
-rw-r--r--application/migrations/001_add_files.php7
-rw-r--r--application/migrations/003_add_referrers.php3
-rw-r--r--application/migrations/007_repurpose_invitations.php3
-rw-r--r--application/models/mfile.php16
6 files changed, 21 insertions, 23 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index b81900af2..62cf342b1 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -1009,7 +1009,7 @@ class File extends MY_Controller {
->from('files')
->where('date <', $oldest_time)
->or_where('('.$this->db->_protect_identifiers('user').' = 0 AND '
- .$this->db->_protect_identifiers('date')." < $oldest_session_time)")
+ .$this->db->_protect_identifiers('date')." < $oldest_session_time)")
->get()->result_array();
foreach($query as $row) {
diff --git a/application/controllers/user.php b/application/controllers/user.php
index 57c6498b1..b542f2b4c 100644
--- a/application/controllers/user.php
+++ b/application/controllers/user.php
@@ -148,10 +148,9 @@ class User extends MY_Controller {
->get()->result_array();
// Convert timestamp to unix timestamp
- foreach ($query as & $record)
- {
- if ( ! empty($record['created']))
- {
+ // TODO: migrate database to integer timestamp and get rid of this
+ foreach ($query as &$record) {
+ if (!empty($record['created'])) {
$record['created'] = strtotime($record['created']);
}
}
@@ -389,11 +388,11 @@ class User extends MY_Controller {
if (empty($error)) {
$this->db->where('id', $userid)
- ->update('users', [
+ ->update('users', array(
'password' => $this->muser->hash_password($password)
- ]);
+ ));
- $this->db->where($key, $key)
+ $this->db->where('key', $key)
->delete('actions');
$this->load->view('header', $this->data);
diff --git a/application/migrations/001_add_files.php b/application/migrations/001_add_files.php
index 70efbb520..30f567325 100644
--- a/application/migrations/001_add_files.php
+++ b/application/migrations/001_add_files.php
@@ -5,8 +5,7 @@ class Migration_Add_files extends CI_Migration {
public function up()
{
- if ($this->db->dbdriver == 'postgre')
- {
+ if ($this->db->dbdriver == 'postgre') {
$this->db->query('
CREATE TABLE IF NOT EXISTS "files" (
"hash" varchar(32) NOT NULL,
@@ -20,9 +19,7 @@ class Migration_Add_files extends CI_Migration {
CREATE INDEX "files_date_idx" ON files ("date");
CREATE INDEX "files_hash_id_idx" ON files ("hash", "id");
');
- }
- else
- {
+ } else {
$this->db->query("
CREATE TABLE IF NOT EXISTS `files` (
`hash` varchar(32) CHARACTER SET ascii NOT NULL,
diff --git a/application/migrations/003_add_referrers.php b/application/migrations/003_add_referrers.php
index 9ca167eab..e30f1faef 100644
--- a/application/migrations/003_add_referrers.php
+++ b/application/migrations/003_add_referrers.php
@@ -42,8 +42,7 @@ class Migration_Add_referrers extends CI_Migration {
public function down()
{
- if ($this->db->dbdriver == 'postgre')
- {
+ if ($this->db->dbdriver == 'postgre') {
$this->db->query('
ALTER TABLE "users" DROP "referrer"
');
diff --git a/application/migrations/007_repurpose_invitations.php b/application/migrations/007_repurpose_invitations.php
index 024b62984..fb40e8179 100644
--- a/application/migrations/007_repurpose_invitations.php
+++ b/application/migrations/007_repurpose_invitations.php
@@ -42,8 +42,7 @@ class Migration_Repurpose_invitations extends CI_Migration {
public function down()
{
- if ($this->db->dbdriver == 'postgre')
- {
+ if ($this->db->dbdriver == 'postgre') {
$this->db->query('ALTER TABLE "actions" RENAME TO "invitations"');
$this->db->query('
ALTER TABLE "invitations"
diff --git a/application/models/mfile.php b/application/models/mfile.php
index be315b9e6..539092887 100644
--- a/application/models/mfile.php
+++ b/application/models/mfile.php
@@ -219,15 +219,17 @@ class Mfile extends CI_Model {
// which is actually done by a SQL contraint.
// TODO: make it work properly without the constraint
$map = $this->db->select('multipaste_id')
+ ->distinct()
->from('multipaste_file_map')
->where('file_url_id', $id)
- ->get()->row_array();
+ ->get()->result_array();
$this->db->where('id', $id)
->delete('files');
- if ( ! empty($map['multipaste_id'])) {
- $this->db->where('multipaste_id', $map['multipaste_id'])
+ foreach ($map as $entry) {
+ assert(!empty($entry['multipaste_id']));
+ $this->db->where('multipaste_id', $entry['multipaste_id'])
->delete('multipaste');
}
@@ -264,15 +266,17 @@ class Mfile extends CI_Model {
}
$map = $this->db->select('multipaste_id')
+ ->distinct()
->from('multipaste_file_map')
->where('file_url_id', $file['id'])
- ->get()->row_array();
+ ->get()->result_array();
$this->db->where('hash', $hash)
->delete('files');
- if ( ! empty($map['multipaste_id'])) {
- $this->db->where('multipaste_id', $map['multipaste_id'])
+ foreach ($map as $entry) {
+ assert(!empty($entry['multipaste_id']));
+ $this->db->where('multipaste_id', $entry['multipaste_id'])
->delete('multipaste');
}