BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

editgroup.php 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <?php
  2. declare(strict_types = 1);
  3. /**
  4. * Edit torrent group wiki page
  5. *
  6. * The page inserts a new revision into the wiki_torrents table,
  7. * and clears the cache for the torrent group page.
  8. */
  9. $GroupID = (int) $_GET['groupid'];
  10. Security::checkInt($GroupID);
  11. // Get the torrent group name and the body of the last revision
  12. $DB->prepare_query("
  13. SELECT
  14. tg.`title`,
  15. tg.`subject`,
  16. tg.`object`,
  17. wt.`Image`,
  18. wt.`Body`,
  19. tg.`picture`,
  20. tg.`description`,
  21. tg.`published`,
  22. tg.`workgroup`,
  23. tg.`location`,
  24. tg.`identifier`,
  25. tg.`category_id`
  26. FROM
  27. `torrents_group` AS tg
  28. LEFT JOIN `wiki_torrents` AS wt
  29. ON
  30. wt.`RevisionID` = tg.`revision_id`
  31. WHERE
  32. tg.`id` = '$GroupID'
  33. ");
  34. $DB->exec_prepared_query();
  35. if (!$DB->has_results()) {
  36. error(404);
  37. }
  38. list($title, $subject, $object, $Image, $Body, $picture, $description, $published, $workgroup, $location, $identifier, $category_id) = $DB->next_record();
  39. $DB->prepare_query("
  40. SELECT
  41. `ID`,
  42. `UserID`,
  43. `Time`,
  44. `URI`
  45. FROM
  46. `torrents_doi`
  47. WHERE
  48. `TorrentID` = '$GroupID'
  49. ");
  50. $DB->exec_prepared_query();
  51. if ($DB->has_results()) {
  52. $Screenshots = [];
  53. while ($S = $DB->next_record(MYSQLI_ASSOC, true)) {
  54. $Screenshots[] = $S;
  55. }
  56. }
  57. $Artists = Artists::get_artists(array($GroupID))[$GroupID];
  58. if (!$Body) {
  59. $Body = $description;
  60. $Image = $picture;
  61. }
  62. View::show_header(
  63. 'Edit torrent group',
  64. 'upload,bbcode,vendor/easymde.min',
  65. 'vendor/easymde.min'
  66. ); ?>
  67. <h2 class="header">
  68. Edit
  69. <a href="torrents.php?id=<?=$GroupID?>"><?=($title ? $title : ($subject ? $subject : $object))?></a>
  70. </h2>
  71. <div class="box pad">
  72. <form class="edit_form" name="torrent_group" action="torrents.php" method="post">
  73. <input type="hidden" name="action" value="takegroupedit" />
  74. <input type="hidden" name="auth"
  75. value="<?=$LoggedUser['AuthKey']?>" />
  76. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  77. <h3>
  78. Picture
  79. </h3>
  80. <input type="text" name="image" size="80" value="<?=$Image?>" />
  81. <br /><br />
  82. <h3>
  83. Torrent Group Description
  84. </h3>
  85. <?php
  86. new TEXTAREA_PREVIEW(
  87. 'body', # $title breaks "Rename (will not merge)"
  88. $ID = 'body',
  89. $Value = display_str($Body) ?? '',
  90. );
  91. $DB->query("
  92. SELECT
  93. `UserID`
  94. FROM
  95. `torrents`
  96. WHERE
  97. `GroupID` = '$GroupID'
  98. ");
  99. $Contributed = in_array($LoggedUser['ID'], $DB->collect('UserID'));
  100. ?>
  101. <h3>
  102. Edit Summary
  103. </h3>
  104. <input type="text" name="summary" size="80" />
  105. <br />
  106. <div class="center pad">
  107. <input type="submit" value="Submit" />
  108. </div>
  109. </form>
  110. </div>
  111. <?php
  112. if ($Contributed
  113. || check_perms('torrents_edit')
  114. || check_perms('screenshots_delete')
  115. || check_perms('screenshots_add')) { ?>
  116. <h2 id="screenshots_section">
  117. Publications
  118. </h2>
  119. <div class="box pad">
  120. <form class="edit_form" name="screenshots_form" action="torrents.php" method="post">
  121. <input type="hidden" name="action" value="screenshotedit" />
  122. <input type="hidden" name="auth"
  123. value="<?=$LoggedUser['AuthKey']?>" />
  124. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  125. <table cellpadding="3" cellspacing="1" border="0" class="layout" width="100%">
  126. <tr>
  127. <td class="label">
  128. Publications
  129. </td>
  130. <td id="screenshots">
  131. <?php
  132. if ($Contributed || check_perms('screenshots_add') || check_perms('torrents_edit')) { ?>
  133. <a class="float_right brackets" onclick="AddScreenshotField()">+</a>
  134. <?php } ?>
  135. </td>
  136. </tr>
  137. </table>
  138. <div class="center pad">
  139. <input type="submit" value="Submit" />
  140. </div>
  141. </form>
  142. </div>
  143. <?php
  144. }
  145. // Users can edit the group info if they've uploaded a torrent to the group or have torrents_edit
  146. if ($Contributed || check_perms('torrents_edit')) { ?>
  147. <h2>
  148. Non-wiki torrent group editing
  149. </h2>
  150. <div class="box pad">
  151. <form class="edit_form" name="torrent_group" action="torrents.php" method="post">
  152. <input type="hidden" name="action" value="nonwikiedit" />
  153. <input type="hidden" name="auth"
  154. value="<?=$LoggedUser['AuthKey']?>" />
  155. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  156. <table cellpadding="3" cellspacing="1" border="0" class="layout" width="100%">
  157. <tr>
  158. <td class="label">
  159. Author(s)
  160. </td>
  161. <td id="idolfields">
  162. <input type="text" id="idols_0" name="idols[]" size="45"
  163. value="<?=$Artists[0]['name']?>"
  164. <?php Users::has_autocomplete_enabled('other'); ?>/>
  165. <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
  166. <?php
  167. for ($i = 1; $i < count($Artists); $i++) {
  168. echo '<br /><input type="text" id="idol_'.$i.'" name="idols[]" size="45" value="'.$Artists[$i]['name'].'"/>';
  169. } ?>
  170. </td>
  171. </tr>
  172. <tr>
  173. <td class="label">
  174. Department/Lab
  175. </td>
  176. <td>
  177. <input type="text" id="studio" name="studio" size="60"
  178. value="<?=$Studio?>" />
  179. </td>
  180. </tr>
  181. <tr>
  182. <td class="label">
  183. Location
  184. </td>
  185. <td>
  186. <input type="text" id="series" name="series" size="60"
  187. value="<?=$Series?>" />
  188. </td>
  189. </tr>
  190. <tr>
  191. <td class="label">
  192. Year
  193. </td>
  194. <td>
  195. <input type="text" name="year" size="10"
  196. value="<?=$Year?>" />
  197. </td>
  198. </tr>
  199. <tr>
  200. <td class="label">
  201. Accession Number
  202. </td>
  203. <td>
  204. <input type="text" name="catalogue" size="40"
  205. value="<?=$CatalogueNumber?>" />
  206. </td>
  207. </tr>
  208. <?php if (check_perms('torrents_freeleech')) { ?>
  209. <tr>
  210. <td class="label">
  211. Torrent <strong>group</strong> leech status
  212. </td>
  213. <td>
  214. <input type="checkbox" id="unfreeleech" name="unfreeleech" />
  215. <label for="unfreeleech"> Reset</label>
  216. <input type="checkbox" id="freeleech" name="freeleech" />
  217. <label for="freeleech"> Freeleech</label>
  218. <input type="checkbox" id="neutralleech" name="neutralleech" />
  219. <label for="neutralleech"> Neutral Leech</label>
  220. because
  221. <select name="freeleechtype">
  222. <?php $FL = array('N/A', 'Staff Pick', 'Perma-FL', 'Freeleechizer', 'Site-Wide FL');
  223. foreach ($FL as $Key => $FLType) { ?>
  224. <option value="<?=$Key?>" <?=($Key == $Torrent['FreeLeechType'] ? ' selected="selected"' : '')?>><?=$FLType?>
  225. </option>
  226. <?php } ?>
  227. </select>
  228. </td>
  229. </tr>
  230. <?php } ?>
  231. </table>
  232. <div class="center pad">
  233. <input type="submit" value="Edit" />
  234. </div>
  235. </form>
  236. </div>
  237. <?php
  238. }
  239. if ($Contributed || check_perms('torrents_edit')) { ?>
  240. <h2>
  241. Rename (will not merge)
  242. </h2>
  243. <div class="box pad">
  244. <form class="rename_form" name="torrent_group" action="torrents.php" method="post">
  245. <table cellpadding="3" cellspacing="1" border="0" class="layout" width="100%">
  246. <input type="hidden" name="action" value="rename" />
  247. <input type="hidden" name="auth"
  248. value="<?=$LoggedUser['AuthKey']?>" />
  249. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  250. <tr>
  251. <td class="label">
  252. Torrent Title
  253. </td>
  254. <td>
  255. <input type="text" name="name" size="70"
  256. value="<?=$title?>" />
  257. </td>
  258. </tr>
  259. <tr>
  260. <td class="label">
  261. Organism
  262. </td>
  263. <td>
  264. <input type="text" name="subject" size="70"
  265. value="<?=$subject?>" />
  266. </td>
  267. </tr>
  268. <tr>
  269. <td class="label">
  270. Strain/Variety
  271. </td>
  272. <td>
  273. <input type="text" name="namejp" size="70"
  274. value="<?=$NameJP?>" />
  275. </td>
  276. </tr>
  277. </table>
  278. <div class="center pad">
  279. <input type="submit" value="Rename" />
  280. </div>
  281. </form>
  282. </div>
  283. <?php
  284. }
  285. if (check_perms('torrents_edit')) { ?>
  286. <h2>
  287. Merge with another group
  288. </h2>
  289. <div class="box pad">
  290. <form class="merge_form" name="torrent_group" action="torrents.php" method="post">
  291. <input type="hidden" name="action" value="merge" />
  292. <input type="hidden" name="auth"
  293. value="<?=$LoggedUser['AuthKey']?>" />
  294. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  295. <h3>
  296. Target torrent group ID
  297. <input type="text" name="targetgroupid" size="10" />
  298. </h3>
  299. <div class="center pad">
  300. <input type="submit" value="Merge" />
  301. </div>
  302. </form>
  303. </div>
  304. <?php
  305. }
  306. View::show_footer();