function after_save(&$Image) { $CarouselImage = new mCarouselImage(); $CarouselImage->order = $CarouselImage->max('order') + 1; $CarouselImage->save($Image); return; }
function update($CarouselID) { if ($_POST['field'] == 'title') { $Carousel = new mCarouselImage($CarouselID); $Model = $Carousel->image; } else { $Model = new mCarouselImage($CarouselID); } if ($_POST['field'] == 'order') { $Other = new mCarouselImage(); $Other->order = $_POST['value']; $Other->load(); $Other->order = $Model->order; } $Model->{$_POST['field']} = $_POST['value']; $Result['result'] = $Model->save(); $this->output->delete_cache('/'); if ($Result['result'] === true && isset($Other) && $Other->is_loaded()) { $Other->save(); } echo json_encode($Result); }