svn: /web/doc-editor/trunk/ install/doc-editor.sql php/LogManager.php

[email protected] (Yannick Torres)
Newsgroups php.doc.web
Message-ID <[email protected]>
yannick                                  Wed, 26 May 2010 16:21:55 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=299798

Log:
Get only LogMessage for current user and current project

Changed paths:
    U   web/doc-editor/trunk/install/doc-editor.sql
    U   web/doc-editor/trunk/php/LogManager.php

Modified: web/doc-editor/trunk/install/doc-editor.sql
===================================================================
--- web/doc-editor/trunk/install/doc-editor.sql	2010-05-26 16:17:15 UTC (rev 299797)
+++ web/doc-editor/trunk/install/doc-editor.sql	2010-05-26 16:21:55 UTC (rev 299798)
@@ -46,7 +46,7 @@
   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `project` varchar(255) NOT NULL,
   `text` text NOT NULL,
-  `userID` int(10) unsigned NOT NULL,
+  `user` varchar(255) NOT NULL,
   KEY `id` (`id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


Modified: web/doc-editor/trunk/php/LogManager.php
===================================================================
--- web/doc-editor/trunk/php/LogManager.php	2010-05-26 16:17:15 UTC (rev 299797)
+++ web/doc-editor/trunk/php/LogManager.php	2010-05-26 16:21:55 UTC (rev 299798)
@@ -28,11 +28,15 @@
      */
     public function getCommitLog()
     {
+        $am = AccountManager::getInstance();
+        $project = $am->project;
+        $vcsLogin = $am->vcsLogin;
+
         $result = array();

         $s = sprintf(
-            'SELECT `id`, `text` FROM `commitMessage` WHERE userID="%s"',
-            AccountManager::getInstance()->userID
+            'SELECT `id`, `text` FROM `commitMessage` WHERE `project`="%s" AND `user`="%s"',
+            $project, $vcsLogin
         );
         $r = DBConnection::getInstance()->query($s);
         while ($a = $r->fetch_assoc()) {
@@ -50,20 +54,22 @@
      */
     public function addCommitLog($log)
     {
-        $db     = DBConnection::getInstance();
-        $log    = $db->real_escape_string($log);
-        $userID = AccountManager::getInstance()->userID;
+        $am       = AccountManager::getInstance();
+        $db       = DBConnection::getInstance();
+        $log      = $db->real_escape_string($log);
+        $project  = $am->project;
+        $vcsLogin = $am->vcsLogin;

         $s = sprintf(
-            'SELECT id FROM `commitMessage` WHERE `text`="%s" AND `userID`="%s"',
-            $log, $userID
+            'SELECT id FROM `commitMessage` WHERE `project`="%s" AND `text`="%s" AND `user`="%s"',
+            $project, $log, $vcsLogin
         );
         $r = $db->query($s);

         if ($r->num_rows == 0 ) {
             $s = sprintf(
-                'INSERT INTO `commitMessage` (`text`,`userID`) VALUES ("%s", "%s")',
-                $log, $userID
+                'INSERT INTO `commitMessage` (`project`, `text`,`user`) VALUES ("%s", "%s", "%s")',
+                $project, $log, $vcsLogin
             );
             $db->query($s);
         }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.