Exemple #1
0
 public function save_action()
 {
     $this->tabs = $_POST;
     $tab_count = intval($this->tabs['tab_num']);
     $order = explode(',', $this->tabs['new_order']);
     $position = 1;
     foreach ($order as $o) {
         $this->tabs['tab_position_' . $o] = $position;
         $position++;
     }
     for ($i = 0; $i < $tab_count; $i++) {
         $block = new SeminarTab();
         //falls noch kein Eintrag existiert: anlegen
         if (!SeminarTab::findOneBySQL('seminar_id = ? AND tab IN (?) ORDER BY position ASC', array($this->course_id, $this->tabs['tab_title_' . $i]))) {
             $block->setData(array('seminar_id' => $this->course_id, 'tab' => $this->tabs['tab_title_' . $i], 'title' => $this->tabs['new_tab_title_' . $i], 'position' => $this->tabs['tab_position_' . $i], 'tn_visible' => $this->tabs['visible_' . $i] == 'on' ? true : false));
             $block->store();
         } else {
             $block = SeminarTab::findOneBySQL('seminar_id = ? AND tab IN (?) ORDER BY position ASC', array($this->course_id, $this->tabs['tab_title_' . $i]));
             $block->setValue('title', $this->tabs['new_tab_title_' . $i]);
             $block->setValue('position', $this->tabs['tab_position_' . $i]);
             $block->setValue('tn_visible', $this->tabs['visible_' . $i] == 'on' ? true : false);
             $block->store();
         }
     }
 }