summaryrefslogtreecommitdiffstatshomepage
path: root/src/SemanticScuttle/Service/User.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/SemanticScuttle/Service/User.php')
-rw-r--r--src/SemanticScuttle/Service/User.php72
1 files changed, 41 insertions, 31 deletions
diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php
index 68e8c11..dbbb202 100644
--- a/src/SemanticScuttle/Service/User.php
+++ b/src/SemanticScuttle/Service/User.php
@@ -103,15 +103,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
GENERAL_ERROR, 'Could not get user',
'', __LINE__, __FILE__, $query, $this->db
);
- return [ 'uId' => 0,
- 'username' => '',
- 'name' => '',
- 'email' => '',
- 'homepage' => '',
- 'content' => '',
- 'datetime' => NULL,
- 'isAdmin' => false,
- 'privateKeey' => '' ];
+ return false;
}
$row = $this->db->sql_fetchrow($dbresult);
@@ -119,15 +111,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
if ($row) {
return $row;
} else {
- return [ 'uId' => 0,
- 'username' => '',
- 'name' => '',
- 'email' => '',
- 'homepage' => '',
- 'content' => '',
- 'datetime' => NULL,
- 'isAdmin' => false,
- 'privateKeey' => '' ];
+ return false;
}
}
@@ -218,7 +202,15 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
);
return false;
}
- $this->db->sql_transaction('commit');
+
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not commit user update', '',
+ __LINE__, __FILE__, $sql, $this->db
+ );
+ return false;
+ }
// Everything worked out, so return true.
return true;
@@ -411,7 +403,12 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
{
if (is_numeric($user)) {
$user = $this->getUser($user);
- $user = $user['username'];
+ if ($user) {
+ $user = $user['username'];
+ }
+ else {
+ $user = 'unknown';
+ }
} else if (is_array($user)) {
$user = $user['username'];
}
@@ -620,10 +617,6 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
}
$arrWatch = array();
- if ($this->db->sql_numrows($dbresult) == 0) {
- $this->db->sql_freeresult($dbresult);
- return $arrWatch;
- }
while ($row = $this->db->sql_fetchrow($dbresult)) {
$arrWatch[] = $row['watched'];
}
@@ -670,10 +663,6 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
}
$arrWatch = array();
- if ($this->db->sql_numrows($dbresult) == 0) {
- $this->db->sql_freeresult($dbresult);
- return $arrWatch;
- }
while ($row = $this->db->sql_fetchrow($dbresult)) {
$arrWatch[] = $row[$this->getFieldName('username')];
}
@@ -726,7 +715,12 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
}
}
- $this->db->sql_transaction('commit');
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(GENERAL_ERROR, 'Could not commit adding user to watch list', '', __LINE__, __FILE__, $sql, $this->db);
+ return false;
+ }
+
return true;
}
@@ -770,7 +764,15 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
return false;
}
$uId = $this->db->sql_nextid($dbresult);
- $this->db->sql_transaction('commit');
+
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not commit user',
+ '', __LINE__, __FILE__, $sql, $this->db
+ );
+ return false;
+ }
return $uId;
}
@@ -852,7 +854,15 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
);
return false;
}
- $this->db->sql_transaction('commit');
+
+ if (!$this->db->sql_transaction('commit')) {
+ $this->db->sql_transaction('rollback');
+ message_die(
+ GENERAL_ERROR, 'Could not commit user update', '',
+ __LINE__, __FILE__, $sql, $this->db
+ );
+ return false;
+ }
// Everything worked out, so return true.
return true;