Пример #1
0
 public function migrateJsonSteps()
 {
     $fh = new \ElggFile();
     $fh->owner_guid = $this->getGUID();
     $fh->setFilename('steps.json');
     if (!$fh->exists()) {
         return false;
     }
     $steps = $fh->grabFile();
     $steps = @json_decode($steps, true);
     foreach ($steps as $step) {
         $new_step = new WizardStep();
         $new_step->container_guid = $this->getGUID();
         $new_step->description = $step;
         $new_step->save();
     }
     $fh->delete();
     return true;
 }
Пример #2
0
    register_error(elgg_echo('error:missing_data'));
    forward(REFERER);
}
$entity = false;
if (!empty($guid)) {
    $entity = get_entity($guid);
    if (!$entity instanceof WizardStep) {
        register_error(elgg_echo('wizard:action:error:entity:wizard_step'));
        forward(REFERER);
    }
} else {
    $container = get_entity($container_guid);
    if (!$container instanceof Wizard) {
        register_error(elgg_echo('wizard:action:error:entity'));
        forward(REFERER);
    }
    $entity = new WizardStep();
    $entity->container_guid = $container->getGUID();
    if (!$entity->save()) {
        register_error(elgg_echo('wizard:action:wizard_step:edit:error:create'));
        forward(REFERER);
    }
}
$entity->title = $title;
$entity->description = $description;
if ($entity->save()) {
    system_message(elgg_echo('wizard:action:wizard_step:edit:success'));
} else {
    register_error(elgg_echo('save:fail'));
}
forward(REFERER);