public function clear()
 {
     parent::clear();
     $this->ori = array(-1);
 }
 public function duplicate($new_name)
 {
     $id = parent::duplicate($new_name);
     if (-1 == $id) {
         return $id;
     }
     require_once NELIOAB_MODELS_DIR . '/experiments-manager.php';
     /** @var NelioABPostAlternativeExperiment $exp */
     $exp = NelioABExperimentsManager::get_experiment_by_id($id, $this->get_type());
     $alts = 0;
     foreach ($exp->get_alternatives() as $alt) {
         /** @var NelioABAlternative $alt */
         $new_id = $exp->create_alternative_copying_content($alt->get_name(), $alt->get_value());
         if ($new_id) {
             $alt->set_value($new_id);
             $alt->mark_as_dirty();
             ++$alts;
         } else {
             $alt->mark_as_removed();
             $alt->mark_as_dirty();
         }
     }
     if (0 == $alts) {
         $exp->set_status(NelioABExperiment::STATUS_DRAFT);
     }
     $exp->save();
     return $exp->get_id();
 }
 public function add_local_alternative($alt)
 {
     $fake_post_id = -1;
     foreach ($this->get_alternatives() as $aux) {
         /** @var NelioABHeadlineAlternative $aux */
         $val = $aux->get_value();
         if (isset($val['id']) && $val['id'] <= $fake_post_id) {
             $fake_post_id = $val['id'] - 1;
         }
     }
     $val = $alt->get_value();
     $val['id'] = $fake_post_id;
     $alt->set_value($val);
     parent::add_local_alternative($alt);
 }