root/devel/mod/file/lib/edit_file.php

Revision 1539, 4.2 kB (checked in by renato, 1 year ago)

Setting prop svn:eol-style in LOTS of files.

  • Property svn:eol-style set to native
Line 
1 <?php
2 global $CFG;
3 global $folder;
4 global $page_owner;
5
6 $file_id = optional_param('edit_file_id',0,PARAM_INT);
7 if (!empty($file_id)) {
8     $file = get_record_sql('SELECT f.*,u.username FROM '.$CFG->prefix.'files f
9                                     JOIN '.$CFG->prefix.'users u ON u.ident = f.owner
10                                     WHERE f.ident = ?',array($file_id));
11     if (!empty($file)  && (permissions_check("files:edit",$file->owner) || permissions_check("files:edit",$file->files_owner))) {
12         $page_owner = $file->files_owner;
13         
14         $description = stripslashes($file->description);
15         $title = htmlspecialchars(stripslashes($file->title), ENT_COMPAT, 'utf-8');
16         
17         $fileLabel = __gettext("File title:"); // gettext variable
18         $body = <<< END
19             <form action="{$CFG->wwwroot}mod/file/action_redirection.php" method="post">
20             <div id="edit_files">
21             <table width="80%">
22                 <tr>
23                     <td width="30%">   
24                         <h4><label for="edit_file_title">$fileLabel</label></h4>
25                     </td>
26                     <td width="70%">
27 END;
28         $body .= display_input_field(array("edit_file_title",$title,"text"));
29         $fileDesc = __gettext("File description:"); // gettext variable
30         $body .= <<< END
31                     </td>
32                 </tr>
33                 <tr>
34                     <td width="30%">
35                         <h4><label for="edit_file_description">$fileDesc</label></h4>
36                     </td>
37                     <td width="70%">
38 END;
39         $body .= display_input_field(array("edit_file_description",$description,"longtext"));
40         $fileAccess = __gettext("Access restrictions:"); // gettext variable
41         $body .= <<< END
42                     </td>
43                 </tr>
44                 <tr>
45                     <td width="30%">
46                         <h4><label for="edit_file_access">$fileAccess</label></h4>
47                     </td>
48                     <td width="70%">
49 END;
50         $body .= run("display:access_level_select",array("edit_file_access",$file->access));
51         $fileFolder = __gettext("File folder:"); // gettext variable
52         $body .= <<< END
53                     </td>
54                 </tr>
55                 <tr>
56                     <td width="30%">
57                         <h4><label for="edit_file_folder">$fileFolder</label></h4>
58                     </td>
59                     <td width="70%">
60 END;
61         $body .= run("folder:select", array("edit_file_folder",$file->files_owner,$file->folder));
62         $keywords = __gettext("Keywords (comma separated):"); // gettext variable
63         $body .= <<< END
64                     </td>
65                 </tr>
66                 <tr>
67                     <td width="30%">
68                         <h4><label for="edit_file_keywords">$keywords</label></h4>
69                     </td>
70                     <td width="70%">
71 END;
72         $body .= display_input_field(array("edit_file_keywords","","keywords","file",$file_id));
73         $body .= <<< END
74                     </td>
75                 </tr>
76 END;
77     
78         $body .= run("metadata:edit",$file_id);
79         
80         $saveChanges = __gettext("Save changes"); // gettext variable
81         $body .= <<< END
82                 
83                 <tr>
84                     <td colspan="2" align="center"><br />
85                         <input type="hidden" name="folder" value="{$folder}" />
86                         <input type="hidden" name="file_id" value="{$file_id}" />
87                         <input type="hidden" name="action" value="files:editfile" />
88                         <input type="submit" value=$saveChanges />
89                     </td>
90                 </tr>
91     
92             </table>
93                 </div>
94 END;
95     
96         $run_result .= templates_draw(array(
97                                             'context' => 'databoxvertical',
98                                             'name' => __gettext("Edit ") . $title,
99                                             'contents' => $body
100                                             )
101                                       );
102         
103         $run_result .= <<< END
104         </form>
105 END;
106     } else {
107         echo "?";
108     }
109 }
110
111 ?>
Note: See TracBrowser for help on using the browser.