} if (!empty($endtime) && $endtime < $starttime) { register_error(elgg_echo('wizard:action:edit:error:endtime')); forward(REFERER); } $entity = false; if (!empty($guid)) { // edit $entity = get_entity($guid); if (empty($entity) || !elgg_instanceof($entity, 'object', Wizard::SUBTYPE)) { $entity = false; } } else { // create $entity = new Wizard(); if (!$entity->save()) { register_error(elgg_echo('wizard:action:edit:error:create')); forward(REFERER); } } if (empty($entity)) { register_error(elgg_echo('wizard:action:error:entity')); forward(REFERER); } $entity->title = $title; $entity->friendly_title = elgg_get_friendly_title($title); $entity->starttime = $starttime; $entity->endtime = $endtime; // save steps foreach ($steps as $index => $step) { if (empty($step)) {