| 110 | | $result = add_album(mysql_real_escape_string($_REQUEST["new_album_name"]), NULL, $_REQUEST["collections_menu"]); |
| 111 | | $album_id = $result["id"]; |
| | 110 | $result = add_album(mysql_real_escape_string($_REQUEST['new_album_name']), NULL, $_REQUEST['collections_menu']); |
| | 111 | if (!$result['errors']) { |
| | 112 | // no errors, add uploaded image to new album |
| | 113 | $album_id = $result['id']; |
| | 114 | } else { |
| | 115 | // errors exist, let's find out what they are |
| | 116 | if (isset($result['output']) && $result['output'] == "existing" && isset($result['id'])) { |
| | 117 | // album already exists so try insert images into the existing album |
| | 118 | // and alert the user that their "new" album is already existing |
| | 119 | $album_id = $result['id']; |
| | 120 | // get the collection name for display |
| | 121 | $sql = "SELECT `name` FROM ".TABLE_PREFIX."collections WHERE id = ".intval($_REQUEST['collections_menu']); |
| | 122 | $result = run_query($sql); |
| | 123 | $row = mysql_fetch_assoc($result); |
| | 124 | $output .= "\n\t" . '<p class="actions">'.sprintf(plog_tr('Album already exists. Uploading file to existing album `%s` in collection `%s`'), $_REQUEST['new_album_name'], $row['name']).'</p>' . "\n"; |
| | 125 | } else { |
| | 126 | // error has nothing to do with an existing album, show the returned error |
| | 127 | $album_id = ''; |
| | 128 | $output .= "\n\t" . '<p class="errors">' . $result['errors'] . '</p>' . "\n"; |
| | 129 | } |
| | 130 | } |
| 116 | | $result = add_picture($album_id,$_FILES["userfile"]["tmp_name"],$_FILES["userfile"]["name"],$_REQUEST["caption"], $_REQUEST["description"]); |
| 117 | | $output .= "\n\t" . '<p class="actions">'.$result["output"].'</p>' . "\n"; |
| | 136 | if ($album_id){ |
| | 137 | $result = add_picture($album_id,$_FILES["userfile"]["tmp_name"],$_FILES["userfile"]["name"],$_REQUEST["caption"], $_REQUEST["description"]); |
| | 138 | if (!$result['errors']) { |
| | 139 | // added uploaded image successfully |
| | 140 | $output .= "\n\t" . '<p class="actions">'.$result['output'].'</p>' . "\n"; |
| | 141 | } else { |
| | 142 | // errors adding the image, show the returned error |
| | 143 | $output .= "\n\t" . '<p class="errors">' . $result['errors'] . '</p>' . "\n"; |
| | 144 | } |
| | 145 | } |