summaryrefslogtreecommitdiff
path: root/src/SemanticScuttle/Service/CommonDescription.php
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-24 09:12:10 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2009-10-24 09:12:10 +0000
commit9f53c3325c99c1602f570efdaf0b6e0df2944f95 (patch)
tree89aa64a2c4538ffda43d1f2c7c87f6e814b4d623 /src/SemanticScuttle/Service/CommonDescription.php
parent5d11ae2fd5a88b5605aa70167516a571822f0e06 (diff)
downloadsemanticscuttle-9f53c3325c99c1602f570efdaf0b6e0df2944f95.tar.gz
semanticscuttle-9f53c3325c99c1602f570efdaf0b6e0df2944f95.tar.bz2
convert tabs to spaces
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@407 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'src/SemanticScuttle/Service/CommonDescription.php')
-rw-r--r--src/SemanticScuttle/Service/CommonDescription.php308
1 files changed, 154 insertions, 154 deletions
diff --git a/src/SemanticScuttle/Service/CommonDescription.php b/src/SemanticScuttle/Service/CommonDescription.php
index 92327c2..d9aa814 100644
--- a/src/SemanticScuttle/Service/CommonDescription.php
+++ b/src/SemanticScuttle/Service/CommonDescription.php
@@ -8,165 +8,165 @@ class SemanticScuttle_Service_CommonDescription extends SemanticScuttle_DbServic
*
* @return SemanticScuttle_Service
*/
- public static function getInstance($db)
+ public static function getInstance($db)
{
- static $instance;
- if (!isset($instance)) {
+ static $instance;
+ if (!isset($instance)) {
$instance = new self($db);
}
- return $instance;
- }
+ return $instance;
+ }
- public function __construct($db)
+ public function __construct($db)
{
- $this->db = $db;
- $this->tablename = $GLOBALS['tableprefix'] .'commondescription';
- }
-
- function addTagDescription($tag, $desc, $uId, $time) {
- // Check if no modification
- $lastDesc = $this->getLastTagDescription($tag);
- if($lastDesc['cdDescription'] == $desc) {
- return true;
- }
-
- // If modification
- $datetime = gmdate('Y-m-d H:i:s', $time);
- $values = array('tag'=>$tag, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime);
- $sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
-
- if (!($dbresult =& $this->db->sql_query($sql))) {
- $this->db->sql_transaction('rollback');
- message_die(GENERAL_ERROR, 'Could not add tag description', '', __LINE__, __FILE__, $sql, $this->db);
- return false;
- }
-
- return true;
- }
-
- function getLastTagDescription($tag) {
- $query = "SELECT *";
- $query.= " FROM `". $this->getTableName() ."`";
- $query.= " WHERE tag='".$tag."'";
- $query.= " ORDER BY cdDatetime DESC";
-
- if (!($dbresult = & $this->db->sql_query_limit($query, 1, 0))) {
- message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db);
- return false;
- }
-
- if ($row =& $this->db->sql_fetchrow($dbresult)) {
- return $row;
- } else {
- return false;
- }
- }
-
- function getAllTagsDescription($tag) {
- $query = "SELECT *";
- $query.= " FROM `". $this->getTableName() ."`";
- $query.= " WHERE tag='".$tag."'";
- $query.= " ORDER BY cdDatetime DESC";
-
- if (!($dbresult = & $this->db->sql_query($query))) {
- message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db);
- return false;
- }
-
- return $this->db->sql_fetchrowset($dbresult);
-
- }
-
- function getDescriptionById($cdId) {
- $query = "SELECT *";
- $query.= " FROM `". $this->getTableName() ."`";
- $query.= " WHERE cdId='".$cdId."'";
-
- if (!($dbresult = & $this->db->sql_query($query))) {
- message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db);
- return false;
- }
-
- if ($row =& $this->db->sql_fetchrow($dbresult)) {
- return $row;
- } else {
- return false;
- }
-
- }
-
- function addBookmarkDescription($bHash, $title, $desc, $uId, $time) {
- // Check if no modification
- $lastDesc = $this->getLastBookmarkDescription($bHash);
- if($lastDesc['cdTitle'] == $title && $lastDesc['cdDescription'] == $desc) {
- return true;
- }
-
- // If modification
- $datetime = gmdate('Y-m-d H:i:s', $time);
- $values = array('bHash'=>$bHash, 'cdTitle'=>$title, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime);
- $sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
-
- if (!($dbresult =& $this->db->sql_query($sql))) {
- $this->db->sql_transaction('rollback');
- message_die(GENERAL_ERROR, 'Could not add bookmark description', '', __LINE__, __FILE__, $sql, $this->db);
- return false;
- }
- return true;
- }
-
- function getLastBookmarkDescription($bHash) {
- $query = "SELECT *";
- $query.= " FROM `". $this->getTableName() ."`";
- $query.= " WHERE bHash='".$bHash."'";
- $query.= " ORDER BY cdDatetime DESC";
-
- if (!($dbresult = & $this->db->sql_query_limit($query, 1, 0))) {
- message_die(GENERAL_ERROR, 'Could not get bookmark description', '', __LINE__, __FILE__, $query, $this->db);
- return false;
- }
-
- if ($row =& $this->db->sql_fetchrow($dbresult)) {
- return $row;
- } else {
- return false;
- }
- }
-
- function getAllBookmarksDescription($bHash) {
- $query = "SELECT *";
- $query.= " FROM `". $this->getTableName() ."`";
- $query.= " WHERE bHash='".$bHash."'";
- $query.= " ORDER BY cdDatetime DESC";
-
- if (!($dbresult = & $this->db->sql_query($query))) {
- message_die(GENERAL_ERROR, 'Could not get bookmark descriptions', '', __LINE__, __FILE__, $query, $this->db);
- return false;
- }
-
- return $this->db->sql_fetchrowset($dbresult);
-
- }
-
- function deleteDescriptionsForUser($uId){
- $query = 'DELETE FROM '. $this->getTableName() . ' WHERE uId = '. intval($uId);
-
- $this->db->sql_transaction('begin');
- if (!($dbresult = & $this->db->sql_query($query))) {
- $this->db->sql_transaction('rollback');
- message_die(GENERAL_ERROR, 'Could not delete user descriptions', '',
- __LINE__, __FILE__, $query, $this->db);
- return false;
- }
-
- return true;
- }
-
-
- function deleteAll() {
- $query = 'TRUNCATE TABLE `'. $this->getTableName() .'`';
- $this->db->sql_query($query);
- }
+ $this->db = $db;
+ $this->tablename = $GLOBALS['tableprefix'] .'commondescription';
+ }
+
+ function addTagDescription($tag, $desc, $uId, $time) {
+ // Check if no modification
+ $lastDesc = $this->getLastTagDescription($tag);
+ if($lastDesc['cdDescription'] == $desc) {
+ return true;
+ }
+
+ // If modification
+ $datetime = gmdate('Y-m-d H:i:s', $time);
+ $values = array('tag'=>$tag, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime);
+ $sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
+
+ if (!($dbresult =& $this->db->sql_query($sql))) {
+ $this->db->sql_transaction('rollback');
+ message_die(GENERAL_ERROR, 'Could not add tag description', '', __LINE__, __FILE__, $sql, $this->db);
+ return false;
+ }
+
+ return true;
+ }
+
+ function getLastTagDescription($tag) {
+ $query = "SELECT *";
+ $query.= " FROM `". $this->getTableName() ."`";
+ $query.= " WHERE tag='".$tag."'";
+ $query.= " ORDER BY cdDatetime DESC";
+
+ if (!($dbresult = & $this->db->sql_query_limit($query, 1, 0))) {
+ message_die(GENERAL_ERROR, 'Could not get tag description', '', __LINE__, __FILE__, $query, $this->db);
+ return false;
+ }
+
+ if ($row =& $this->db->sql_fetchrow($dbresult)) {
+ return $row;
+ } else {
+ return false;
+ }
+ }
+
+ function getAllTagsDescription($tag) {
+ $query = "SELECT *";
+ $query.= " FROM `". $this->getTableName() ."`";
+ $query.= " WHERE tag='".$tag."'";
+ $query.= " ORDER BY cdDatetime DESC";
+
+ if (!($dbresult = & $this->db->sql_query($query))) {
+ message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db);
+ return false;
+ }
+
+ return $this->db->sql_fetchrowset($dbresult);
+
+ }
+
+ function getDescriptionById($cdId) {
+ $query = "SELECT *";
+ $query.= " FROM `". $this->getTableName() ."`";
+ $query.= " WHERE cdId='".$cdId."'";
+
+ if (!($dbresult = & $this->db->sql_query($query))) {
+ message_die(GENERAL_ERROR, 'Could not get tag descriptions', '', __LINE__, __FILE__, $query, $this->db);
+ return false;
+ }
+
+ if ($row =& $this->db->sql_fetchrow($dbresult)) {
+ return $row;
+ } else {
+ return false;
+ }
+
+ }
+
+ function addBookmarkDescription($bHash, $title, $desc, $uId, $time) {
+ // Check if no modification
+ $lastDesc = $this->getLastBookmarkDescription($bHash);
+ if($lastDesc['cdTitle'] == $title && $lastDesc['cdDescription'] == $desc) {
+ return true;
+ }
+
+ // If modification
+ $datetime = gmdate('Y-m-d H:i:s', $time);
+ $values = array('bHash'=>$bHash, 'cdTitle'=>$title, 'cdDescription'=>$desc, 'uId'=>$uId, 'cdDatetime'=>$datetime);
+ $sql = 'INSERT INTO '. $this->getTableName() .' '. $this->db->sql_build_array('INSERT', $values);
+
+ if (!($dbresult =& $this->db->sql_query($sql))) {
+ $this->db->sql_transaction('rollback');
+ message_die(GENERAL_ERROR, 'Could not add bookmark description', '', __LINE__, __FILE__, $sql, $this->db);
+ return false;
+ }
+ return true;
+ }
+
+ function getLastBookmarkDescription($bHash) {
+ $query = "SELECT *";
+ $query.= " FROM `". $this->getTableName() ."`";
+ $query.= " WHERE bHash='".$bHash."'";
+ $query.= " ORDER BY cdDatetime DESC";
+
+ if (!($dbresult = & $this->db->sql_query_limit($query, 1, 0))) {
+ message_die(GENERAL_ERROR, 'Could not get bookmark description', '', __LINE__, __FILE__, $query, $this->db);
+ return false;
+ }
+
+ if ($row =& $this->db->sql_fetchrow($dbresult)) {
+ return $row;
+ } else {
+ return false;
+ }
+ }
+
+ function getAllBookmarksDescription($bHash) {
+ $query = "SELECT *";
+ $query.= " FROM `". $this->getTableName() ."`";
+ $query.= " WHERE bHash='".$bHash."'";
+ $query.= " ORDER BY cdDatetime DESC";
+
+ if (!($dbresult = & $this->db->sql_query($query))) {
+ message_die(GENERAL_ERROR, 'Could not get bookmark descriptions', '', __LINE__, __FILE__, $query, $this->db);
+ return false;
+ }
+
+ return $this->db->sql_fetchrowset($dbresult);
+
+ }
+
+ function deleteDescriptionsForUser($uId){
+ $query = 'DELETE FROM '. $this->getTableName() . ' WHERE uId = '. intval($uId);
+
+ $this->db->sql_transaction('begin');
+ if (!($dbresult = & $this->db->sql_query($query))) {
+ $this->db->sql_transaction('rollback');
+ message_die(GENERAL_ERROR, 'Could not delete user descriptions', '',
+ __LINE__, __FILE__, $query, $this->db);
+ return false;
+ }
+
+ return true;
+ }
+
+
+ function deleteAll() {
+ $query = 'TRUNCATE TABLE `'. $this->getTableName() .'`';
+ $this->db->sql_query($query);
+ }
}
?>