subtype = "externalgroup"; // Set its owner to the current user $externalgroup->owner_guid = $_SESSION['user']->getGUID(); // 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/newexternal/"); } // Now let's add tags. We can pass an array directly to the object property! Easy. if (is_array($tagarray)) { $externalgroup->tags = $tagarray; } $externalgroup->url = $url; $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 added.*/ system_message(elgg_echo("koolielu:message_externalgroup_added")); // river add_to_river('river/object/externalgroup/create','create',$_SESSION['user']->guid,$externalgroup->guid); // Remove the externalgroup cache unset($_SESSION['externalgrouptitle']); unset($_SESSION['externalgroupbody']); unset($_SESSION['externalgroupurl']); unset($_SESSION['externalgrouprss']); unset($_SESSION['externalgrouptags']); // Forward to the main info page forward($externalgroup->getURL()); } ?>