$realstartdate) { if (!empty($guid)) { $entity = get_entity($guid); if (empty($entity) || !elgg_instanceof($entity, "object", SITE_ANNOUNCEMENT_SUBTYPE)) { unset($entity); register_error(elgg_echo("noaccess")); } } else { $entity = new ElggObject(); $entity->subtype = SITE_ANNOUNCEMENT_SUBTYPE; $entity->access_id = $access_id; $entity->owner_guid = elgg_get_site_entity()->getGUID(); $entity->container_guid = elgg_get_site_entity()->getGUID(); if (!$entity->save()) { unset($entity); register_error(elgg_echo("save:fail")); } } if (!empty($entity)) { $entity->description = $description; $entity->access_id = $access_id; $entity->save(); $entity->startdate = $realstartdate; $entity->enddate = $realenddate; $entity->announcement_type = $announcement_type; if ($entity->save()) { elgg_clear_sticky_form("site_announcement_edit"); $forward_url = "announcements/all"; system_message(elgg_echo("site_announcement:action:edit:success")); } else { register_error(elgg_echo("site_announcement:action:edit:error:save")); } } } else { register_error(elgg_echo("site_announcement:action:edit:error:time")); } } else { register_error(elgg_echo("site_announcement:action:edit:error:input")); } forward($forward_url);