Пример #1
0
 /**
  * Update any section associated with the unit
  *
  * @param   object  $model  \Components\Courses\Models\Unit
  * @return  mixed
  */
 public function onUnitSave($unit)
 {
     if (!$unit->exists()) {
         return;
     }
     $db = App::get('db');
     $section = new \Components\Forum\Tables\Section($db);
     $section->loadByObject($unit->get('id'), $unit->get('offering_id'), 'course');
     if ($section->id && $section->state != 2) {
         $section->state = $unit->get('state');
         $section->title = $unit->get('title');
         $section->alias = $unit->get('alias');
         $section->ordering = $unit->get('ordering');
         if ($section->check()) {
             $section->store();
         }
     }
     return $section->id;
 }