/[drupal]/contributions/modules/comment_revisions/comment_revisions.module
ViewVC logotype

Diff of /contributions/modules/comment_revisions/comment_revisions.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.1, Wed Jun 11 17:21:45 2008 UTC revision 1.1.2.2, Fri Jun 13 18:54:46 2008 UTC
# Line 1  Line 1 
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
# Line 148  function comment_revisions_comment($a1, Line 148  function comment_revisions_comment($a1,
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';
# Line 169  function comment_revisions_comment($a1, Line 192  function comment_revisions_comment($a1,
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"],
# Line 199  function comment_revisions_comment($a1, Line 222  function comment_revisions_comment($a1,
222          }          }
223    
224        break;        break;
     case 'form':  
   
       break;  
   
225    }    }
   
226  }  }
227    
228  /**  /**

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.2