getSubtype() == "infopage" && $page->canEdit()) { // Cache to the session $_SESSION['pagetitle'] = $title; $_SESSION['pagebody'] = $body; $_SESSION['pagetags'] = $tags; $_SESSION['pagesubjects'] = $subjects; $_SESSION['pagetargetgroup'] = $targetgroup; $_SESSION['pagecategories'] = $categories; // 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)) { /*translation:Please fill all required fields.*/ register_error(elgg_echo("koolielu:error_blank")); forward("mod/info/edit_page.php?page=" . $guid); // Otherwise, save the page } else { // Get owning user $owner = get_entity($page->getOwner()); // For now, set its access to public (we'll add an access dropdown shortly) $page->access_id = 2;// public // Set its title and description appropriately $page->title = $title; $page->description = $body; // Before we can set metadata, we need to save the page if (!$page->save()) { /*translation:Error occured, object could not be saved.*/ register_error(elgg_echo("koolielu:error_not_saved")); forward("mod/info/edit_page.php?page=" . $guid); } // Now let's add tags. We can pass an array directly to the object property! Easy. $page->clearMetadata('tags'); if (is_array($tagarray)) { $page->tags = $tagarray; } // Custom metadata $page->clearMetadata('categories'); $page->categories = $categories; $page->clearMetadata('subjects'); $page->subjects = $subjects; $page->clearMetadata('targetgroup'); $page->targetgroup = $targetgroup; unassociate_prioval($prioval); $page->prioval = $prioval; // Success message /*translation:Page modified.*/ system_message(elgg_echo("koolielu:message_page_modified")); // Remove the page cache unset($_SESSION['pagetitle']); unset($_SESSION['pagebody']); unset($_SESSION['pagetags']); unset($_SESSION['pagecategories']); unset($_SESSION['pagesubjects']); unset($_SESSION['pagetargetgroup']); // Forward to the main page forward($page->getURL()); } } ?>