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.

new_edit.php 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <?php
  2. /*
  3. * Yeah, that's right, edit and new are the same place again.
  4. * It makes the page uglier to read but ultimately better as the alternative means
  5. * maintaining 2 copies of almost identical files.
  6. */
  7. $NewRequest = $_GET['action'] === 'new';
  8. if (!$NewRequest) {
  9. $RequestID = $_GET['id'];
  10. if (!is_number($RequestID)) {
  11. error(404);
  12. }
  13. }
  14. $Disabled = "";
  15. if ($NewRequest && ($LoggedUser['BytesUploaded'] < 250 * 1024 * 1024 || !check_perms('site_submit_requests'))) {
  16. error('You do not have enough uploaded to make a request.');
  17. }
  18. if (!$NewRequest) {
  19. if (empty($ReturnEdit)) {
  20. $Request = Requests::get_request($RequestID);
  21. if ($Request === false) {
  22. error(404);
  23. }
  24. // Define these variables to simplify _GET['groupid'] requests later on
  25. $CategoryID = $Request['CategoryID'];
  26. $Title = $Request['Title'];
  27. $TitleRJ = $Request['TitleRJ'];
  28. $TitleJP = $Request['TitleJP'];
  29. $CatalogueNumber = $Request['CatalogueNumber'];
  30. $DLsiteID = $Request['DLsiteID'];
  31. $Image = $Request['Image'];
  32. $GroupID = $Request['GroupID'];
  33. $VoteArray = Requests::get_votes_array($RequestID);
  34. $VoteCount = count($VoteArray['Voters']);
  35. $IsFilled = !empty($Request['TorrentID']);
  36. $CategoryName = $Categories[$CategoryID - 1];
  37. $ProjectCanEdit = (check_perms('project_team') && !$IsFilled && $CategoryID === '0');
  38. $CanEdit = ((!$IsFilled && $LoggedUser['ID'] === $Request['UserID'] && $VoteCount < 2) || $ProjectCanEdit || check_perms('site_moderate_requests'));
  39. if (!$CanEdit) {
  40. error(403);
  41. }
  42. $ArtistForm = Requests::get_artists($RequestID);
  43. $Tags = implode(', ', $Request['Tags']);
  44. }
  45. }
  46. if ($NewRequest && !empty($_GET['artistid']) && is_number($_GET['artistid'])) {
  47. $DB->query("
  48. SELECT Name
  49. FROM artists_group
  50. WHERE artistid = ".$_GET['artistid']."
  51. LIMIT 1");
  52. list($ArtistName) = $DB->next_record();
  53. $ArtistForm = array(
  54. 1 => array(array('name' => trim($ArtistName))),
  55. );
  56. } elseif ($NewRequest && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
  57. $ArtistForm = Artists::get_artist($_GET['groupid']);
  58. $DB->query("
  59. SELECT
  60. tg.Name,
  61. tg.NameRJ,
  62. tg.NameJP,
  63. tg.Year,
  64. tg.Studio,
  65. tg.Series,
  66. tg.CatalogueNumber,
  67. tg.DLsiteID,
  68. tg.WikiImage,
  69. GROUP_CONCAT(t.Name SEPARATOR ', '),
  70. tg.CategoryID
  71. FROM torrents_group AS tg
  72. JOIN torrents_tags AS tt ON tt.GroupID = tg.ID
  73. JOIN tags AS t ON t.ID = tt.TagID
  74. WHERE tg.ID = ".$_GET['groupid']);
  75. if (list($Title, $TitleRJ, $TitleJP, $Year, $Studio, $Series, $CatalogueNumber, $DLsiteID, $Image, $Tags, $CategoryID) = $DB->next_record()) {
  76. $GroupID = trim($_REQUEST['groupid']);
  77. $CategoryName = $Categories[$CategoryID - 1];
  78. $Disabled = 'readonly="readonly"';
  79. }
  80. }
  81. View::show_header(($NewRequest ? 'Create a request' : 'Edit a request'), 'bbcode,requests,form_validate');
  82. ?>
  83. <div class="thin">
  84. <div class="header">
  85. <h2><?=($NewRequest ? 'Create a request' : 'Edit a request')?>
  86. </h2>
  87. </div>
  88. <div class="box pad">
  89. <form action="" method="post" id="request_form" onsubmit="Calculate();">
  90. <div>
  91. <?php if (!$NewRequest) { ?>
  92. <input type="hidden" name="requestid"
  93. value="<?=$RequestID?>" />
  94. <?php } ?>
  95. <input type="hidden" name="auth"
  96. value="<?=$LoggedUser['AuthKey']?>" />
  97. <input type="hidden" name="action"
  98. value="<?=($NewRequest ? 'takenew' : 'takeedit')?>" />
  99. </div>
  100. <table class="layout">
  101. <tr>
  102. <td colspan="2" class="center">Please make sure your request follows <a href="rules.php?p=requests">the
  103. request rules</a>!</td>
  104. </tr>
  105. <?php if ($NewRequest || $CanEdit) { ?>
  106. <tr>
  107. <td class="label tooltip" title="What alphabet the sequence uses, n.b., plasmids fit in the Other category">
  108. Type</td>
  109. <td>
  110. <?php if (!empty($Disabled)) { ?>
  111. <input type="hidden" name="type"
  112. value="<?=$CategoryName?>" />
  113. <select id="categories" name="type" onchange="Categories();" disabled="disabled">
  114. <?php } else { ?>
  115. <select id="categories" name="type" onchange="Categories();">
  116. <?php } ?>
  117. <?php foreach (Misc::display_array($Categories) as $Cat) { ?>
  118. <option value="<?=$Cat?>" <?=(!empty($CategoryName) && ($CategoryName === $Cat) ? ' selected="selected"' : '')?>><?=$Cat?>
  119. </option>
  120. <?php } ?>
  121. </select>
  122. </td>
  123. </tr>
  124. <tr id="cataloguenumber_tr">
  125. <td class="label">Accession Number</td>
  126. <td>
  127. <input type="text" id="catalogue" name="cataloguenumber" size="15"
  128. value="<?=(isset($CatalogueNumber)?$CatalogueNumber:'') ?>"
  129. <?=$Disabled?>/>
  130. <?php if (empty($Disabled)) { ?>
  131. <input type="button" autofill="jav" value="Autofill"></input>
  132. <?php } ?>
  133. </td>
  134. </tr>
  135. <tr id="artist_tr">
  136. <td class="label">Collaborator(s)</td>
  137. <td id="artistfields">
  138. <p id="vawarning" class="hidden">Please use the multiple artists feature rather than adding "Various
  139. Artists" as an artist; read <a href="wiki.php?action=article&amp;id=369">this</a> for more information.
  140. </p>
  141. <?php
  142. if (!empty($ArtistForm)) {
  143. $First = true;
  144. foreach ($ArtistForm as $Artist) {
  145. ?>
  146. <input type="text" id="artist_0" name="artists[]" <?php Users::has_autocomplete_enabled('other'); ?>
  147. size="45" value="<?=display_str($Artist['name']) ?>" <?=$Disabled?>/>
  148. <?php if (empty($Disabled)) {
  149. if ($First) { ?><a class="add_artist_button brackets">+</a> <a
  150. class="remove_artist_button brackets">&minus;</a><?php }
  151. $First = false;
  152. } ?>
  153. <br />
  154. <?php
  155. }
  156. } else {
  157. ?> <input type="text" id="artist_0" name="artists[]" <?php Users::has_autocomplete_enabled('other'); ?>
  158. size="45" <?=$Disabled?>/>
  159. <?php if (empty($Disabled)) { ?>
  160. <a class="add_artist_button brackets">+</a> <a class="remove_artist_button brackets">&minus;</a>
  161. <?php } ?>
  162. <?php
  163. }
  164. ?>
  165. </td>
  166. </tr>
  167. <tr>
  168. <td class="label tooltip" title="FASTA definition line, e.g., Alcohol dehydrogenase ADH1">Sequence Name</td>
  169. <td>
  170. <input type="text" id="title" name="title" size="45"
  171. value="<?=(!empty($Title) ? $Title : '')?>"
  172. <?=$Disabled?>/>
  173. </td>
  174. </tr>
  175. <tr>
  176. <td class="label tooltip" title="FASTA organism line binomial nomenclature, e.g., Saccharomyces cerevisiae">
  177. Organism</td>
  178. <td>
  179. <input type="text" id="title_rj" name="title_rj" size="45"
  180. value="<?=(!empty($TitleRJ) ? $TitleRJ : '')?>"
  181. <?=$Disabled?>/>
  182. </td>
  183. </tr>
  184. <tr>
  185. <td class="label tooltip" title="FASTA organism line if applicable, e.g., S288C">Strain/Variety</td>
  186. <td>
  187. <input type="text" id="title_jp" name="title_jp" size="45"
  188. value="<?=!empty($TitleJP)?$TitleJP:''?>"
  189. <?=$Disabled?>/>
  190. </td>
  191. </tr>
  192. <?php } ?>
  193. <?php if ($NewRequest || $CanEdit) { ?>
  194. <tr id="image_tr">
  195. <td class="label tooltip" title="A meaningful picture, e.g., of the specimen">Picture</td>
  196. <td>
  197. <input type="text" id="image" name="image" size="45"
  198. value="<?=(!empty($Image) ? $Image : '')?>"
  199. <?=$Disabled?>/>
  200. </td>
  201. </tr>
  202. <?php } ?>
  203. <tr>
  204. <td class="label tooltip" title="Comma-seperated list of tags, n.b., use vanity.house for data you produced">
  205. Tags</td>
  206. <td>
  207. <?php
  208. $GenreTags = $Cache->get_value('genre_tags');
  209. if (!$GenreTags) {
  210. $DB->query('
  211. SELECT Name
  212. FROM tags
  213. WHERE TagType = \'genre\'
  214. ORDER BY Name');
  215. $GenreTags = $DB->collect('Name');
  216. $Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
  217. }
  218. if (!empty($Disabled)) {
  219. ?>
  220. <select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;" disabled="disabled">
  221. <?php
  222. } else { ?>
  223. <select id="genre_tags" name="genre_tags" onchange="add_tag(); return false;">
  224. <?php } ?>
  225. <option>---</option>
  226. <?php foreach (Misc::display_array($GenreTags) as $Genre) { ?>
  227. <option value="<?=$Genre?>"><?=$Genre?>
  228. </option>
  229. <?php } ?>
  230. </select>
  231. <input type="text" id="tags" name="tags" size="45"
  232. value="<?=(!empty($Tags) ? display_str($Tags) : '')?>"
  233. <?php Users::has_autocomplete_enabled('other'); ?>
  234. <?=$Disabled?>/>
  235. </td>
  236. </tr>
  237. <?php if ($NewRequest || $CanEdit) { ?>
  238. <?php } ?>
  239. <tr>
  240. <td class="label">Description</td>
  241. <td>
  242. <?php new TEXTAREA_PREVIEW('description', 'req_desc', $Request['Description']??''); ?>
  243. </td>
  244. </tr>
  245. <?php if (check_perms('site_moderate_requests')) { ?>
  246. <tr>
  247. <td class="label">Torrent Group</td>
  248. <td>
  249. <?=site_url()?>torrents.php?id=<input type="text"
  250. name="groupid"
  251. value="<?=isset($GroupID)?$GroupID:''?>"
  252. size="15" /><br />
  253. If this request matches a torrent group <strong>already existing</strong> on the site, please indicate that
  254. here.
  255. </td>
  256. </tr>
  257. <?php } elseif (!empty($GroupID) && ($CategoryID !== 5) && ($CategoryID !== 0)) { ?>
  258. <tr>
  259. <td class="label">Torrent Group</td>
  260. <td>
  261. <a href="torrents.php?id=<?=$GroupID?>"><?=site_url()?>torrents.php?id=<?=$GroupID?></a><br />
  262. This request <?=($NewRequest ? 'will be' : 'is')?>
  263. associated with the above torrent group.
  264. <?php if (!$NewRequest) { ?>
  265. If this is incorrect, please <a
  266. href="reports.php?action=report&amp;type=request&amp;id=<?=$RequestID?>">report
  267. this request</a> so that staff can fix it.
  268. <?php } ?>
  269. <input type="hidden" name="groupid"
  270. value="<?=$GroupID?>" />
  271. </td>
  272. </tr>
  273. <?php }
  274. if ($NewRequest) { ?>
  275. <tr id="voting">
  276. <td class="label tooltip" title="How much upload credit the fulfiller wins">Bounty</td>
  277. <td>
  278. <input type="text" id="amount_box" size="8"
  279. value="<?=(!empty($Bounty) ? $Bounty : '100')?>"
  280. onchange="Calculate();" />
  281. <select id="unit" name="unit" onchange="Calculate();">
  282. <option value="mb" <?=(!empty($_POST['unit']) && $_POST['unit'] === 'mb' ? ' selected="selected"' : '') ?>>MB
  283. </option>
  284. <option value="gb" <?=(!empty($_POST['unit']) && $_POST['unit'] === 'gb' ? ' selected="selected"' : '') ?>>GB
  285. </option>
  286. </select>
  287. <input type="button" value="Preview" onclick="Calculate();" />
  288. <strong><?=($RequestTax * 100)?>% of this is deducted as
  289. tax by the system.</strong>
  290. </td>
  291. </tr>
  292. <tr>
  293. <td class="label">Post-Request Information</td>
  294. <td>
  295. <input type="hidden" id="amount" name="amount"
  296. value="<?=(!empty($Bounty) ? $Bounty : '100')?>" />
  297. <input type="hidden" id="current_uploaded"
  298. value="<?=$LoggedUser['BytesUploaded']?>" />
  299. <input type="hidden" id="current_downloaded"
  300. value="<?=$LoggedUser['BytesDownloaded']?>" />
  301. Bounty after tax: <strong><span id="bounty_after_tax">90.00 MB</span></strong><br />
  302. If you add the entered <strong><span id="new_bounty">100.00 MB</span></strong> of bounty, your new stats
  303. will be: <br />
  304. Uploaded: <span id="new_uploaded"><?=Format::get_size($LoggedUser['BytesUploaded'])?></span><br />
  305. Ratio: <span id="new_ratio"><?=Format::get_ratio_html($LoggedUser['BytesUploaded'], $LoggedUser['BytesDownloaded'])?></span>
  306. </td>
  307. </tr>
  308. <tr>
  309. <td colspan="2" class="center">
  310. <input type="submit" id="button" value="Create request" disabled="disabled" />
  311. </td>
  312. </tr>
  313. <?php } else { ?>
  314. <tr>
  315. <td colspan="2" class="center">
  316. <input type="submit" id="button" value="Edit request" />
  317. </td>
  318. </tr>
  319. <?php } ?>
  320. </table>
  321. </form>
  322. </div>
  323. </div>
  324. <?php
  325. View::show_footer();