Fossil SCM

/info/TICKET_UUID now only shows the ticket title if the ticket db has a title field.

stephan 2013-02-18 21:45 UTC timeline-rss-ticket
Commit 1c46835e4c92d817379890c87eba14d400668be2
2 files changed +21 +8 -2
+21
--- src/db.c
+++ src/db.c
@@ -1872,10 +1872,31 @@
18721872
return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName);
18731873
}
18741874
void db_lset_int(const char *zName, int value){
18751875
db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
18761876
}
1877
+
1878
+/*
1879
+** Returns non-0 if the database (which must be open) table identified
1880
+** by zTableName has a column named zColName (case-sensitive), else
1881
+** returns 0.
1882
+*/
1883
+int db_table_has_column( char const *zTableName, char const *zColName ){
1884
+ Stmt q = empty_Stmt;
1885
+ int rc = 0;
1886
+ db_prepare( &q, "PRAGMA table_info(%Q)", zTableName );
1887
+ while(SQLITE_ROW == db_step(&q)){
1888
+ /* Columns: (cid, name, type, notnull, dflt_value, pk) */
1889
+ char const * zCol = db_column_text(&q, 1);
1890
+ if(0==fossil_strcmp(zColName, zCol)){
1891
+ rc = 1;
1892
+ break;
1893
+ }
1894
+ }
1895
+ db_finalize(&q);
1896
+ return rc;
1897
+}
18771898
18781899
/*
18791900
** Record the name of a local repository in the global_config() database.
18801901
** The repository filename %s is recorded as an entry with a "name" field
18811902
** of the following form:
18821903
--- src/db.c
+++ src/db.c
@@ -1872,10 +1872,31 @@
1872 return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName);
1873 }
1874 void db_lset_int(const char *zName, int value){
1875 db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
1876 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1877
1878 /*
1879 ** Record the name of a local repository in the global_config() database.
1880 ** The repository filename %s is recorded as an entry with a "name" field
1881 ** of the following form:
1882
--- src/db.c
+++ src/db.c
@@ -1872,10 +1872,31 @@
1872 return db_int(dflt, "SELECT value FROM vvar WHERE name=%Q", zName);
1873 }
1874 void db_lset_int(const char *zName, int value){
1875 db_multi_exec("REPLACE INTO vvar(name,value) VALUES(%Q,%d)", zName, value);
1876 }
1877
1878 /*
1879 ** Returns non-0 if the database (which must be open) table identified
1880 ** by zTableName has a column named zColName (case-sensitive), else
1881 ** returns 0.
1882 */
1883 int db_table_has_column( char const *zTableName, char const *zColName ){
1884 Stmt q = empty_Stmt;
1885 int rc = 0;
1886 db_prepare( &q, "PRAGMA table_info(%Q)", zTableName );
1887 while(SQLITE_ROW == db_step(&q)){
1888 /* Columns: (cid, name, type, notnull, dflt_value, pk) */
1889 char const * zCol = db_column_text(&q, 1);
1890 if(0==fossil_strcmp(zColName, zCol)){
1891 rc = 1;
1892 break;
1893 }
1894 }
1895 db_finalize(&q);
1896 return rc;
1897 }
1898
1899 /*
1900 ** Record the name of a local repository in the global_config() database.
1901 ** The repository filename %s is recorded as an entry with a "name" field
1902 ** of the following form:
1903
+8 -2
--- src/info.c
+++ src/info.c
@@ -1752,11 +1752,13 @@
17521752
}
17531753
if( strcmp(zModAction,"approve")==0 ){
17541754
moderation_approve(rid);
17551755
}
17561756
}
1757
- zTktTitle = db_text("???", "SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName);
1757
+ zTktTitle = db_table_has_column( "ticket", "title" )
1758
+ ? db_text("(No title)", "SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName)
1759
+ : 0;
17581760
style_header("Ticket Change Details");
17591761
style_submenu_element("Raw", "Raw", "%R/artifact/%S", zUuid);
17601762
style_submenu_element("History", "History", "%R/tkthistory/%s", zTktName);
17611763
style_submenu_element("Page", "Page", "%R/tktview/%t", zTktName);
17621764
style_submenu_element("Timeline", "Timeline", "%R/tkttimeline/%t", zTktName);
@@ -1777,11 +1779,15 @@
17771779
modPending = moderation_pending(rid);
17781780
if( modPending ){
17791781
@ <span class="modpending">*** Awaiting Moderator Approval ***</span>
17801782
}
17811783
@ <tr><th>Ticket:</th>
1782
- @ <td>%z(href("%R/tktview/%s",zTktName))%s(zTktName)</a><br>%h(zTktTitle)</td></tr>
1784
+ @ <td>%z(href("%R/tktview/%s",zTktName))%s(zTktName)</a>
1785
+ if(zTktTitle){
1786
+ @<br>%h(zTktTitle)
1787
+ }
1788
+ @</td></tr>
17831789
@ <tr><th>Date:</th><td>
17841790
hyperlink_to_date(zDate, "</td></tr>");
17851791
@ <tr><th>User:</th><td>
17861792
hyperlink_to_user(pTktChng->zUser, zDate, "</td></tr>");
17871793
@ </table>
17881794
--- src/info.c
+++ src/info.c
@@ -1752,11 +1752,13 @@
1752 }
1753 if( strcmp(zModAction,"approve")==0 ){
1754 moderation_approve(rid);
1755 }
1756 }
1757 zTktTitle = db_text("???", "SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName);
 
 
1758 style_header("Ticket Change Details");
1759 style_submenu_element("Raw", "Raw", "%R/artifact/%S", zUuid);
1760 style_submenu_element("History", "History", "%R/tkthistory/%s", zTktName);
1761 style_submenu_element("Page", "Page", "%R/tktview/%t", zTktName);
1762 style_submenu_element("Timeline", "Timeline", "%R/tkttimeline/%t", zTktName);
@@ -1777,11 +1779,15 @@
1777 modPending = moderation_pending(rid);
1778 if( modPending ){
1779 @ <span class="modpending">*** Awaiting Moderator Approval ***</span>
1780 }
1781 @ <tr><th>Ticket:</th>
1782 @ <td>%z(href("%R/tktview/%s",zTktName))%s(zTktName)</a><br>%h(zTktTitle)</td></tr>
 
 
 
 
1783 @ <tr><th>Date:</th><td>
1784 hyperlink_to_date(zDate, "</td></tr>");
1785 @ <tr><th>User:</th><td>
1786 hyperlink_to_user(pTktChng->zUser, zDate, "</td></tr>");
1787 @ </table>
1788
--- src/info.c
+++ src/info.c
@@ -1752,11 +1752,13 @@
1752 }
1753 if( strcmp(zModAction,"approve")==0 ){
1754 moderation_approve(rid);
1755 }
1756 }
1757 zTktTitle = db_table_has_column( "ticket", "title" )
1758 ? db_text("(No title)", "SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName)
1759 : 0;
1760 style_header("Ticket Change Details");
1761 style_submenu_element("Raw", "Raw", "%R/artifact/%S", zUuid);
1762 style_submenu_element("History", "History", "%R/tkthistory/%s", zTktName);
1763 style_submenu_element("Page", "Page", "%R/tktview/%t", zTktName);
1764 style_submenu_element("Timeline", "Timeline", "%R/tkttimeline/%t", zTktName);
@@ -1777,11 +1779,15 @@
1779 modPending = moderation_pending(rid);
1780 if( modPending ){
1781 @ <span class="modpending">*** Awaiting Moderator Approval ***</span>
1782 }
1783 @ <tr><th>Ticket:</th>
1784 @ <td>%z(href("%R/tktview/%s",zTktName))%s(zTktName)</a>
1785 if(zTktTitle){
1786 @<br>%h(zTktTitle)
1787 }
1788 @</td></tr>
1789 @ <tr><th>Date:</th><td>
1790 hyperlink_to_date(zDate, "</td></tr>");
1791 @ <tr><th>User:</th><td>
1792 hyperlink_to_user(pTktChng->zUser, zDate, "</td></tr>");
1793 @ </table>
1794

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button