<?php
/**
 * Open Source Social Network
 *
 * @package   (softlab24.com).ossn
 * @author    OSSN Core Team <info@softlab24.com>
 * @copyright 2014-2019 SOFTLAB24 LIMITED
 * @license   SOFTLAB24 LIMITED, COMMERCIAL LICENSE  https://www.softlab24.com/license/commercial-license-v1
 * @link      https://www.softlab24.com/
 */
$title = input('title');
$desc  = input('description');
$guid  = input('guid');
$cover = input('cover');

if (empty($title) || empty($desc)) {
    ossn_trigger_message(ossn_print("wpages:fillfields"), 'error');
    redirect(REF);
}

$page = get_worlds_page($guid); // Corrected function name
if (!$page) {
    ossn_trigger_message(ossn_print("wpages:invalid:page"), 'error');
    redirect(REF);
}

$page->title = $title;
$page->description = $desc;
$page->cover = $cover; // Assign cover directly to $page

if ($page->save()) {
    ossn_trigger_message(ossn_print("wpages:page:saved"));
    redirect("administrator/settings/wpages?mpage=list");
} else {
    ossn_trigger_message(ossn_print("wpages:page:save:failed"), 'error');
    redirect(REF);
}
?>
