root/trunk/RackTables/file_link_helper.php

Revision 2276, 2.2 kB (checked in by aaron, 2 months ago)

added support for file attachments (re: ticket 56)

Line 
1 <?php
2     require 'inc/init.php';
3     // This is our context.
4     $pageno = 'files';
5     $tabno = 'default';
6     fixContext();
7     if (!permitted())
8     {
9         renderAccessDenied();
10         die;
11     }
12 ?>
13 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
14 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" style="height: 100%;">
15 <head>
16  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
17 <?php
18 echo '<title>' . getTitle ($pageno, $tabno) . "</title>\n";
19 echo "<link rel=stylesheet type='text/css' href=pi.css />\n";
20 echo "<link rel=icon href='" . getFaviconURL() . "' type='image/x-icon' />";
21 ?>
22 </head>
23 <body style="height: 100%;">
24 <form action="javascript:;">
25 <div style="background-color: #f0f0f0; border: 1px solid #3c78b5; padding: 10px; height: 100%; text-align: center; margin: 5px;">
26 <h2>Choose a file:</h2><br><br>
27 <input type=hidden id='file_name'>
28 <select size=<?php echo getConfigVar ('MAXSELSIZE'); ?> id="file_id">
29 <?php
30     $entity_type = $_REQUEST['entity_type'];
31     $entity_id = $_REQUEST['entity_id'];
32
33     // Append different param to URL depending on entity_type
34     switch ($entity_type)
35     {
36         case 'ipv4net':
37             $entity_param = 'id';
38             break;
39         case 'ipv4rspool':
40             $entity_param = 'pool_id';
41             break;
42         case 'ipv4vs':
43             $entity_param = 'vs_id';
44             break;
45         case 'object':
46             $entity_param = 'object_id';
47             break;
48         case 'rack':
49             $entity_param = 'rack_id';
50             break;
51         case 'user':
52             $entity_param = 'user_id';
53             break;
54     }
55
56
57     $files = getAllUnlinkedFiles($entity_type, $entity_id);
58     foreach ($files as $file)
59     {
60         echo "<option value='${file['id']}' onclick='getElementById(\"file_name\").value=\"${file['name']}\";'>${file['name']}</option>\n";
61     }
62 ?>
63 </select><br><br>
64 <?php
65     echo "<input type='submit' value='Proceed' onclick='" .
66     "if (getElementById(\"file_id\").value != \"\") {\n" .
67     "    opener.location=\"${root}process.php?page=$entity_type&tab=files&op=linkFile&entity_type=$entity_type&entity_id=$entity_id&$entity_param=$entity_id&file_id=\"+getElementById(\"file_id\").value+\"&file_name=\"+getElementById(\"file_name\").value; \n" .
68     "    window.close();" .
69     "}" .
70     "'>";
71 ?>
72 </div>
73 </form>
74 </body>
75 </html>
76
Note: See TracBrowser for help on using the browser.