| 1 |
<?php |
<?php |
| 2 |
// $Id: comment_revisions.module,v 1.1.1.1 2007/12/09 01:51:56 Raiden-San Exp $ |
// $Id: comment_revisions.module,v 1.24 2008/06/13 18:47:21 Raiden Exp $ |
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 5 |
* Complete module for comment_revisions |
* Complete module for comment_revisions |
| 148 |
global $user; |
global $user; |
| 149 |
|
|
| 150 |
switch($op) { |
switch($op) { |
| 151 |
|
case "delete": |
| 152 |
|
db_query("DELETE FROM {comment_revisions} WHERE cid=%d", $a1->cid); |
| 153 |
|
db_query("DELETE FROM {comment_revisions_actual} WHERE cid=%d", $a1->cid); |
| 154 |
|
break; |
| 155 |
|
case "validate": |
| 156 |
|
/* Comment is edited and revision should be created */ |
| 157 |
|
if($a1["cid"] != NULL && $a1["create_revision"] == 1 && $a1["op"] != "Preview comment") { |
| 158 |
|
/* No revision before, that means, the original has to be saved */ |
| 159 |
|
if(!_comment_revision_cmt_has_revisions($a1["cid"])) { |
| 160 |
|
$result = db_fetch_array(db_query("SELECT * FROM {comments} WHERE cid=%d", $a1['cid'])); |
| 161 |
|
db_query("INSERT INTO {comment_revisions} (vid, cid, comment, subject, logMessage, createdOn, createdBy, isUsrRev) |
| 162 |
|
VALUES(%d, %d, '%s', '%s', '%s', %d, %d, '%s')", |
| 163 |
|
db_next_id("{comment_revisions}_vid"), |
| 164 |
|
$result["cid"], |
| 165 |
|
$result["comment"], |
| 166 |
|
$result["subject"], |
| 167 |
|
t("Original comment"), |
| 168 |
|
$result["timestamp"], |
| 169 |
|
$result["uid"], |
| 170 |
|
'0'); |
| 171 |
|
} |
| 172 |
|
} |
| 173 |
|
break; |
| 174 |
case 'update': |
case 'update': |
|
|
|
| 175 |
if($user->uid == $a1['uid'] and !user_access('willful create own')) { |
if($user->uid == $a1['uid'] and !user_access('willful create own')) { |
| 176 |
$isUserRevision = TRUE; |
$isUserRevision = TRUE; |
| 177 |
} else { |
} else { |
| 178 |
$isUserRevision = FALSE; |
$isUserRevision = FALSE; |
| 179 |
} |
} |
| 180 |
|
/* Prepare query to insert revision */ |
| 181 |
if($a1['create_revision']) { |
if($a1['create_revision']) { |
| 182 |
|
|
| 183 |
$queryInfo = array(); |
$queryInfo = array(); |
| 184 |
$queryInfo['cid'] = $a1['cid']; |
$queryInfo['cid'] = $a1['cid']; |
| 185 |
$queryInfo['comment'] = $a1['comment']; |
$queryInfo['comment'] = $a1['comment']; |
| 186 |
$queryInfo['subject'] = $a1['subject']; |
$queryInfo['subject'] = $a1['subject']; |
| 187 |
$queryInfo['log_message'] = $a1['log_message']; |
$queryInfo['log_message'] = $a1['log_message']; |
| 188 |
$queryInfo['createdOn'] = time(); |
$queryInfo['createdOn'] = time(); |
| 189 |
$queryInfo['createdBy'] = $user->uid; |
$queryInfo['createdBy'] = $user->uid; |
| 190 |
$queryInfo['isUsrRev'] = $isUserRevision ? '1' : '0'; |
$queryInfo['isUsrRev'] = $isUserRevision ? '1' : '0'; |
| 192 |
|
|
| 193 |
db_query("INSERT INTO {comment_revisions} |
db_query("INSERT INTO {comment_revisions} |
| 194 |
(vid, cid, comment, subject, logMessage, createdOn, createdBy, isUsrRev) |
(vid, cid, comment, subject, logMessage, createdOn, createdBy, isUsrRev) |
| 195 |
VALUES (%d, %d,'%s','%s','%s', %d, %d, %s)", |
VALUES (%d, %d,'%s','%s','%s', %d, %d, '%s')", |
| 196 |
$queryInfo['vid'], |
$queryInfo['vid'], |
| 197 |
$queryInfo["cid"], |
$queryInfo["cid"], |
| 198 |
$queryInfo["comment"], |
$queryInfo["comment"], |
| 222 |
} |
} |
| 223 |
|
|
| 224 |
break; |
break; |
|
case 'form': |
|
|
|
|
|
break; |
|
|
|
|
| 225 |
} |
} |
|
|
|
| 226 |
} |
} |
| 227 |
|
|
| 228 |
/** |
/** |