/** * CRUD controller: UPDATE */ public function action_update() { $this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id'); $form = new FormOrm($this->_orm_model, $this->request->param('id')); if ($this->request->post()) { if ($success = $form->submit()) { if (Valid::email($form->object->email, TRUE)) { //check we have this email in the DB $user = new Model_User(); $user = $user->where('email', '=', Kohana::$_POST_ORIG['formorm']['email'])->where('id_user', '!=', $this->request->param('id'))->limit(1)->find(); if ($user->loaded()) { Alert::set(Alert::ERROR, __('A user with the email you specified already exists')); } else { $form->save_object(); Alert::set(Alert::SUCCESS, __('Item updated') . '. ' . __('Please to see the changes delete the cache') . '<br><a class="btn btn-primary btn-mini ajax-load" href="' . Route::url('oc-panel', array('controller' => 'tools', 'action' => 'cache')) . '?force=1" title="' . __('Delete cache') . '">' . __('Delete cache') . '</a>'); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller()))); } } else { Alert::set(Alert::ERROR, __('Invalid Email')); } } else { Alert::set(Alert::ERROR, __('Check form for errors')); } } return $this->render('oc-panel/pages/user/update', array('form' => $form)); }
/** * CRUD controller: UPDATE */ public function action_update() { $this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id'); $this->template->styles = array('css/sortable.css' => 'screen'); $this->template->scripts['footer'][] = 'js/oc-panel/category_edit.js'; $form = new FormOrm($this->_orm_model, $this->request->param('id')); $category = new Model_Category($this->request->param('id')); $fields = Model_Field::get_all(); $category_fields = array(); $selectable_fields = array(); // get selectable fields foreach ($fields as $field => $values) { if (!(is_array($values['categories']) and in_array($category->id_category, $values['categories']))) { $selectable_fields[$field] = $values; } else { $category_fields[$field] = $values; } } if ($this->request->post()) { if ($success = $form->submit()) { //category is different than himself, cant be his own father!!! if ($form->object->id_category == $form->object->id_category_parent) { Alert::set(Alert::INFO, __('You can not set as parent the same category')); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'update', 'id' => $form->object->id_category))); } //check if the parent is loaded/exists avoiding errors $parent_cat = new Model_Category($form->object->id_category_parent); if (!$parent_cat->loaded()) { Alert::set(Alert::INFO, __('You are assigning a parent category that does not exist')); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'update', 'id' => $form->object->id_category))); } $form->object->description = Kohana::$_POST_ORIG['formorm']['description']; try { $form->object->save(); } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } $form->object->parent_deep = $form->object->get_deep(); try { $form->object->save(); } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } $this->action_deep(); //rename icon name if ($category->has_image and $category->seoname != $form->object->seoname) { $category->rename_icon($form->object->seoname); } Core::delete_cache(); Alert::set(Alert::SUCCESS, __('Item updated')); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller()))); } else { Alert::set(Alert::ERROR, __('Check form for errors')); } } return $this->render('oc-panel/pages/categories/update', compact('form', 'category', 'category_fields', 'selectable_fields')); }
/** * CRUD controller: UPDATE */ public function action_update() { $this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id'); $form = new FormOrm($this->_orm_model, $this->request->param('id')); // fields array foreach ($form->fields as $field_key => $field) { $fields[$field_key] = array('name' => $field['field_name'], 'value' => $field['value'], 'id' => $field['field_id'], 'label' => $field['label']); } if ($this->request->post()) { if ($success = $form->submit()) { $form->object->description = Kohana::$_POST_ORIG['formorm']['description']; $form->save_object(); Alert::set(Alert::SUCCESS, __('Blog post updated') . '. ' . __('Please to see the changes delete the cache') . '<br><a class="btn btn-primary btn-mini ajax-load" href="' . Route::url('oc-panel', array('controller' => 'tools', 'action' => 'cache')) . '?force=1" title="' . __('Delete cache') . '">' . __('Delete cache') . '</a>'); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller()))); } else { Alert::set(Alert::ERROR, __('Check form for errors')); } } return $this->render('oc-panel/pages/blog/update', array('form' => $fields)); }
/** * CRUD controller: UPDATE */ public function action_update() { $this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id'); $form = new FormOrm($this->_orm_model, $this->request->param('id')); $category = new Model_Category($this->request->param('id')); if ($this->request->post()) { if ($success = $form->submit()) { //category is different than himself, cant be his ow father!!! if ($form->object->id_category == $form->object->id_category_parent) { Alert::set(Alert::INFO, __('You can not set as parent the same category')); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'update', 'id' => $form->object->id_category))); } //check if the parent is loaded/exists avoiding errors $parent_cat = new Model_Category($form->object->id_category_parent); if (!$parent_cat->loaded()) { Alert::set(Alert::INFO, __('You are assigning a parent category that does not exist')); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'update', 'id' => $form->object->id_category))); } $form->object->description = Kohana::$_POST_ORIG['formorm']['description']; try { $form->object->save(); } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } $form->object->parent_deep = $form->object->get_deep(); try { $form->object->save(); } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } $this->action_deep(); Core::delete_cache(); Alert::set(Alert::SUCCESS, __('Item updated')); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller()))); } else { Alert::set(Alert::ERROR, __('Check form for errors')); } } return $this->render('oc-panel/pages/categories/update', array('form' => $form, 'category' => $category)); }
/** * CRUD controller: UPDATE */ public function action_update() { $this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id'); $this->template->scripts['footer'][] = 'js/oc-panel/locations-gmap.js'; $form = new FormOrm($this->_orm_model, $this->request->param('id')); $location = new Model_Location($this->request->param('id')); if ($this->request->post()) { if ($success = $form->submit()) { if ($form->object->id_location == $form->object->id_location_parent) { Alert::set(Alert::INFO, __('You can not set as parent the same location')); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'update', 'id' => $form->object->id_location))); } //check if the parent is loaded/exists avoiding errors $parent_loc = new Model_Location($form->object->id_location_parent); if (!$parent_loc->loaded()) { Alert::set(Alert::INFO, __('You are assigning a parent location that does not exist')); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller(), 'action' => 'create'))); } $form->object->description = Kohana::$_POST_ORIG['formorm']['description']; try { $form->object->save(); } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } $form->object->parent_deep = $form->object->get_deep(); try { $form->object->save(); } catch (Exception $e) { throw HTTP_Exception::factory(500, $e->getMessage()); } $this->action_deep(); //rename icon name if ($location->has_image and $location->seoname != $form->object->seoname) { $location->rename_icon($form->object->seoname); } Core::delete_cache(); Alert::set(Alert::SUCCESS, __('Item updated')); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller()))); } else { Alert::set(Alert::ERROR, __('Check form for errors')); } } return $this->render('oc-panel/pages/locations/update', array('form' => $form, 'location' => $location)); }
/** * CRUD controller: UPDATE */ public function action_update() { $this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id'); $form = new FormOrm($this->_orm_model, $this->request->param('id')); if ($this->request->post()) { if ($success = $form->submit()) { $form->save_object(); Alert::set(Alert::SUCCESS, __('Item updated') . '. ' . __('Please to see the changes delete the cache') . '<br><a class="btn btn-primary btn-mini" href="' . Route::url('oc-panel', array('controller' => 'tools', 'action' => 'cache')) . '?force=1">' . __('Delete All') . '</a>'); $this->request->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller()))); } else { Alert::set(Alert::ERROR, __('Check form for errors')); } } return $this->render('oc-panel/crud/update', array('form' => $form)); }
/** * CRUD controller: UPDATE */ public function action_update() { $this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id'); $form = new FormOrm($this->_orm_model, $this->request->param('id')); if ($this->request->post()) { if ($success = $form->submit()) { $form->save_object(); //if fraud or refunded....disable licenses!! AND commissions if ($form->object->status == Model_Order::STATUS_FRAUD or $form->object->status == Model_Order::STATUS_REFUND) { foreach ($form->object->licenses->find_all() as $l) { $l->status = Model_License::STATUS_NOACTIVE; $l->save(); } //change affiliate commision if ($form->object->affiliate->loaded()) { $form->object->affiliate->status = $form->object->status; $form->object->affiliate->save(); } } Alert::set(Alert::SUCCESS, __('Item updated') . '. ' . __('Please to see the changes delete the cache') . '<br><a class="btn btn-primary btn-mini" href="' . Route::url('oc-panel', array('controller' => 'tools', 'action' => 'cache')) . '?force=1">' . __('Delete All') . '</a>'); $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller()))); } else { Alert::set(Alert::ERROR, __('Check form for errors')); } } $licenses = new Model_License(); $licenses = $licenses->where('id_order', '=', $this->request->param('id'))->find_all(); return $this->render('oc-panel/pages/order/update', array('form' => $form, 'licenses' => $licenses)); }