getSubtype() == "externalgroup" && $externalgroup->canEdit()) { // Cache to the session $_SESSION['externalgrouptitle'] = $title; $_SESSION['externalgroupbody'] = $body; $_SESSION['externalgroupurl'] = $url; $_SESSION['externalgrouprss'] = $rss; $_SESSION['externalgrouptags'] = $tags; // Convert string of tags into a preformatted array $tagarray = string_to_tag_array($tags); // Make sure the title / description aren't blank if (empty($title) || empty($body) || empty($url) || empty($rss)) { /*translation:Please fill all required fields.*/ register_error(elgg_echo("koolielu:error_blank")); forward("pg/groups/editexternal/" . $guid); // Otherwise, save the externalgroup } else { // Get owning user $owner = get_entity($externalgroup->getOwner()); // For now, set its access to public (we'll add an access dropdown shortly) $externalgroup->access_id = 2;// public // Set its title and description appropriately $externalgroup->title = $title; $externalgroup->description = $body; // Before we can set metadata, we need to save the externalgroup if (!$externalgroup->save()) { /*translation:Error occured, object could not be saved.*/ register_error(elgg_echo("koolielu:error_not_saved")); forward("pg/groups/editexternal/" . $guid); } // Now let's add tags. We can pass an array directly to the object property! Easy. $externalgroup->clearMetadata('tags'); if (is_array($tagarray)) { $externalgroup->tags = $tagarray; } $externalgroup->clearMetadata('url'); $externalgroup->url = $url; $externalgroup->clearMetadata('rss'); $externalgroup->rss = $rss; // Deal with image if ((isset($_FILES['externalgroupimage'])) && (substr_count($_FILES['externalgroupimage']['type'],'image/'))) { $supported_formats = getSupportedImageFormats(); $image = get_uploaded_file('externalgroupimage'); // See if we even support the format first if (in_array(exif_imagetype($_FILES['externalgroupimage']['tmp_name']),$supported_formats)) { // Save it $original = saveImageFile($externalgroup->getGUID() . '.original', $image, $externalgroup->getOwner()); // Write original file name into objects metadata $externalgroup->original_file_name = $_FILES['externalgroupimage']['name']; if (!original) { /*translation:Original image could not be saved.*/ register_error(elgg_echo('koolielu:error_original_image_not_saved')); } $resized_image = get_resized_image_from_uploaded_file('externalgroupimage', 150, 150, false); // Save it $resized = saveImageFile("small_" . $externalgroup->getGUID() . ".jpg", $resized_image, $externalgroup->getOwner()); if (!$resized) { /*translation:Resized image could not be saved.*/ register_error(elgg_echo('koolielu:error_resized_image_not_saved')); } $resized_listing_image = get_resized_image_from_uploaded_file('externalgroupimage', 40, 40, false); // Save it $resized_listing = saveImageFile("listing_" . $externalgroup->getGUID() . ".jpg", $resized_listing_image, $externalgroup->getOwner()); if (!$resized_listing) { /*translation:Resized image could not be saved.*/ register_error(elgg_echo('koolielu:error_resized_image_not_saved')); } } else { /*translation:Image format not supported. Supported formats are: .jpg, .png, .jpeg and .gif.*/ register_error(elgg_echo('koolielu:error_supported_image_formats')); } } // Success message /*translation:External group modified.*/ system_message(elgg_echo("koolielu:message_externalgroup_modified")); // Remove the externalgroup cache unset($_SESSION['externalgrouptitle']); unset($_SESSION['externalgroupbody']); unset($_SESSION['externalgroupurl']); unset($_SESSION['externalgrouprss']); unset($_SESSION['externalgrouptags']); // Forward to the main page forward($externalgroup->getURL()); } } ?>