[AppDB] restore the ability to add a url to an app family

Tony Lambregts tony_lambregts at telusplanet.net
Sun Feb 6 12:51:23 CST 2005


You will need to insert appid into the table appdata again for this to work.

Change Log: Restore the ability to add a url to an app family

Files changed: appview.php admin/editAppFamily.php tables/appdb_tables.sql
-------------- next part --------------
Index: appview.php
===================================================================
RCS file: /home/wine/appdb/appview.php,v
retrieving revision 1.52
diff -u -r1.52 appview.php
--- appview.php	6 Feb 2005 17:49:48 -0000	1.52
+++ appview.php	6 Feb 2005 18:44:03 -0000
@@ -220,6 +220,18 @@
     // main URL
     echo "        <tr class=\"color1\"><td><b>URL</b></td><td>".$appLinkURL."</td></tr>\n";
 
+    // optional links
+    $result = query_appdb("SELECT * FROM appData WHERE appId = ".$_REQUEST['appId']." AND versionID = 0 AND type = 'url'");
+    if($result && mysql_num_rows($result) > 0)
+    {
+        echo "        <tr class=\"color1\"><td> <b>Links</b></td><td>\n";
+        while($ob = mysql_fetch_object($result))
+        {
+            echo "        <a href='$ob->url'>".substr(stripslashes($ob->description),0,30)."</a> <br />\n";
+        }
+            echo "        </td></tr>\n";
+        }
+  
     // image
     $img = get_screenshot_img($oApp->iAppId);
     echo "<tr><td align=center colspan=2>$img</td></tr>\n";
Index: admin/editAppFamily.php
===================================================================
RCS file: /home/wine/appdb/admin/editAppFamily.php,v
retrieving revision 1.27
diff -u -r1.27 editAppFamily.php
--- admin/editAppFamily.php	4 Feb 2005 02:59:05 -0000	1.27
+++ admin/editAppFamily.php	6 Feb 2005 18:44:03 -0000
@@ -125,6 +125,93 @@
             }   
         }
     }
+    else if($_REQUEST['submit'] == "Update URL")
+    {
+
+        $sWhatChanged = "";
+        $bAppChanged = false;
+
+        if (!empty($_REQUEST['url_desc']) && !empty($_REQUEST['url']) )
+        {
+            // process added URL
+            if($_SESSION['current']->showDebuggingInfos()) { echo "<p align=center><b>{$_REQUEST['url']}:</b> {$_REQUEST['url_desc']} </p>"; }
+        
+            $aInsert = compile_insert_string( array( 'appId' => $_REQUEST['appId'],
+                                             'type' => 'url',
+                                             'description' => $_REQUEST['url_desc'],
+                                             'url' => $_REQUEST['url']));
+            
+            $sQuery = "INSERT INTO appData ({$aInsert['FIELDS']}) VALUES ({$aInsert['VALUES']})";
+	    
+            if($_SESSION['current']->showDebuggingInfos()) { echo "<p align=center><b>query:</b> $sQuery </p>"; }
+	    
+            if (query_appdb($sQuery))
+            {
+                addmsg("The URL was successfully added into the database", "green");
+                $sWhatChanged .= "  Added Url:     Description: ".stripslashes($_REQUEST['url_desc'])."\n";
+                $sWhatChanged .= "                         Url: ".stripslashes($_REQUEST['url'])."\n";
+                $bAppChanged = true;
+            }
+        }
+        
+        // Process changed URLs
+        
+        for($i = 0; $i < $_REQUEST['rows']; $i++)
+        {
+            if($_SESSION['current']->showDebuggingInfos()) { echo "<p align=center><b>{$_REQUEST['adescription'][$i]}:</b> {$_REQUEST['aURL'][$i]}: {$_REQUEST['adelete'][$i]} : {$_REQUEST['aId'][$i]} : .{$_REQUEST['aOldDesc'][$i]}. : {$_REQUEST['aOldURL'][$i]}</p>"; }
+            
+            if ($_REQUEST['adelete'][$i] == "on")
+            {
+	            $hResult = query_appdb("DELETE FROM appData WHERE id = '{$_REQUEST['aId'][$i]}'");
+
+                if($hResult)
+                {
+                    addmsg("<p><b>Successfully deleted URL ".$_REQUEST['aOldDesc'][$i]." (".$_REQUEST['aOldURL'][$i].")</b></p>\n",'green');
+                    $sWhatChanged .= "Deleted Url:     Description: ".stripslashes($_REQUEST['aOldDesc'][$i])."\n";
+                    $sWhatChanged .= "                         url: ".stripslashes($_REQUEST['aOldURL'][$i])."\n";
+                    $bAppChanged = true;
+                }
+
+
+            }
+            else if( $_REQUEST['aURL'][$i] != $_REQUEST['aOldURL'][$i] || $_REQUEST['adescription'][$i] != $_REQUEST['aOldDesc'][$i])
+            {
+                if(empty($_REQUEST['aURL'][$i]) || empty($_REQUEST['adescription'][$i]))
+                    addmsg("The URL or description was blank. URL not changed in the database", "red");
+                else
+                {
+                    $sUpdate = compile_update_string( array( 'description' => $_REQUEST['adescription'][$i],
+                                                     'url' => $_REQUEST['aURL'][$i]));
+                    if (query_appdb("UPDATE appData SET $sUpdate WHERE id = '{$_REQUEST['aId'][$i]}'"))
+                    {
+                         addmsg("<p><b>Successfully updated ".$_REQUEST['aOldDesc'][$i]." (".$_REQUEST['aOldURL'][$i].")</b></p>\n",'green');
+                         $sWhatChanged .= "Changed Url: Old Description: ".stripslashes($_REQUEST['aOldDesc'][$i])."\n";
+                         $sWhatChanged .= "                     Old Url: ".stripslashes($_REQUEST['aOldURL'][$i])."\n";
+                         $sWhatChanged .= "             New Description: ".stripslashes($_REQUEST['adescription'][$i])."\n";
+                         $sWhatChanged .= "                     New url: ".stripslashes($_REQUEST['aURL'][$i])."\n";
+                         $bAppChanged = true;
+                    }
+                }
+            }
+        }
+        if ($bAppChanged) 
+        {
+            $sEmail = get_notify_email_address_list($_REQUEST['appId']);
+            if($sEmail)
+            {
+                $sFullAppName = "Links for ".lookup_app_name($_REQUEST['appId'])." have been updated";
+                $sMsg  = APPDB_ROOT."appview.php?appId=".$_REQUEST['appId']."\r\n";
+                $sMsg .= "\n";
+                $sMsg .= $_SESSION['current']->sRealname." updated links for ".$sFullAppName." \r\n";
+                $sMsg .= "\n";
+                $sMsg .= $sWhatChanged."\n";
+                mail_appdb($sEmail, $sFullAppName ,$sMsg);
+            }
+        }
+
+        redirect(apidb_fullurl("appview.php?appId={$_REQUEST['appId']}"));
+        exit;
+    }
 }
 else
 // Show the form for editing the Application Family 
@@ -175,6 +262,50 @@
     echo html_frame_end();
     echo "</form>";
 
+    // url edit form
+    echo '<form enctype="multipart/form-data" action="editAppFamily.php" method="post">',"\n";
+    echo '<input type=hidden name="appId" value='.$ob->appId.'>';
+    echo html_frame_start("Edit URL","90%","",0);
+    echo '<table border=0 cellpadding=6 cellspacing=0 width="100%">',"\n";
+            
+    $i = 0;
+    $result = query_appdb("SELECT * FROM appData WHERE appId = $ob->appId AND type = 'url' AND versionId = 0");
+    if($result && mysql_num_rows($result) > 0)
+    {
+        echo '<tr><td class=color1><b>Delete</b></td><td class=color1>',"\n";
+        echo '<b>Description</b></td><td class=color1><b>URL</b></td></tr>',"\n";
+        while($ob = mysql_fetch_object($result))
+        {
+            $temp0 = "adelete[".$i."]";
+            $temp1 = "adescription[".$i."]";
+            $temp2 = "aURL[".$i."]";
+            $temp3 = "aId[".$i."]";
+            $temp4 = "aOldDesc[".$i."]";
+            $temp5 = "aOldURL[".$i."]";
+            echo '<tr><td class=color3><input type="checkbox" name="'.$temp0.'"></td>',"\n";
+            echo '<td class=color3><input size=45% type="text" name="'.$temp1.'" value ="'.stripslashes($ob->description).'"</td>',"\n";
+            echo '<td class=color3><input size=45% type="text" name="'.$temp2.'" value="'.$ob->url.'"></td></tr>',"\n";
+            echo '<input type=hidden name="'.$temp3.'" value='.$ob->id.'>';
+            echo '<input type=hidden name="'.$temp4.'" value="'.stripslashes($ob->description).'">';
+            echo '<input type=hidden name="'.$temp5.'" value="'.$ob->url.'">',"\n";
+            $i++;
+        }
+    } else
+    {
+        echo '<tr><td class=color1></td><td class=color1><b>Description</b></td>',"\n";
+        echo '<td class=color1><b>URL</b></td></tr>',"\n";
+    }
+    echo "</td></tr>\n";
+    echo "<input type=hidden name='rows' value='$i'>";
+
+    echo '<tr><td class=color1>New</td><td class=color1><input size=45% type="text" name="url_desc"></td>',"\n";
+    echo '<td class=color1><input size=45% name="url" type="text"></td></tr>',"\n";
+     
+    echo '<tr><td colspan=3 align=center class=color3><input type="submit" name=submit value="Update URL"></td></tr>',"\n";
+         
+    echo '</table>',"\n";
+    echo html_frame_end();
+    echo "</form>";
     echo html_back_link(1,BASE."appview.php?appId=$ob->appId");
 
 }
Index: tables/appdb_tables.sql
===================================================================
RCS file: /home/wine/appdb/tables/appdb_tables.sql,v
retrieving revision 1.19
diff -u -r1.19 appdb_tables.sql
--- tables/appdb_tables.sql	4 Feb 2005 02:55:50 -0000	1.19
+++ tables/appdb_tables.sql	6 Feb 2005 18:44:04 -0000
@@ -154,6 +154,7 @@
  */
 create table appData (
 	id		int not null auto_increment,
+	appId		int not null,
 	versionId	int default 0,
 	type		enum('image', 'url', 'bug'),
 	description	text,


More information about the wine-patches mailing list