예제 #1
0
 public function action_delete()
 {
     $role = ORM::factory('Role', arr::get($_POST, 'id'));
     if (!$role->loaded()) {
         ajax::error(__('Role not found. Has it been deleted already?'));
     }
     try {
         $role->delete();
         ajax::info(__('Deleted'));
     } catch (exception $e) {
         ajax::error(__('An uncaught error occurred: :error', array(':error' => $e->getMessage())));
     }
 }
예제 #2
0
 public function action_autosave()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in');
     }
     $user = user::get();
     $autosave = ORM::factory('Page')->where('user_id', '=', $user->id)->where('type', '=', 'autosave')->find();
     if (!$autosave->loaded()) {
         $autosave->user_id = $user->id;
         $autosave->type = 'autosave';
     }
     $content = arr::get($_POST, 'content', '');
     $autosave->content = $content;
     try {
         $autosave->save();
         ajax::success('Page saved!');
     } catch (ORM_Validation_Exception $e) {
         ajax::error('Validation error');
         $errors = $e->errors('models');
     }
     ajax::info('Nothing to do');
 }
예제 #3
0
 public function action_delete()
 {
     $user = $this->post();
     if (arr::get($_POST, 'action') == 'transfer') {
         $newowner = arr::get($_POST, 'newowner', 3);
         $content = $user->contents->find_all();
         if ((bool) $content->count()) {
             foreach ($content as $cont) {
                 $cont->user_id = $newowner;
                 $cont->save();
             }
         }
     }
     try {
         $user->delete();
         ajax::info(__('User deleted'));
     } catch (exception $e) {
         ajax::error(__('An uncaught error occurred: :error', array(':error' => $e->getMessage())));
     }
 }
예제 #4
0
 public function action_deletepost()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in to do that.');
     }
     $id = arr::get($_POST, 'id', false);
     $object = ORM::factory('Talkreply', $id);
     if (!$object->loaded()) {
         ajax::error('I couldn\'t find that post. Has it already been deleted? Please contact us if you think this is a mistake');
     }
     if (!user::can_edit($object)) {
         ajax::error('That doesn\'t seem to be your post to delete. Please contact us if you think this is a mistake');
     }
     $object->deleted = time();
     $object->deleted_by = user::get()->id;
     try {
         $object->talk->deleted = 0;
         $object->talk->save();
         $object->save();
         if ($object->op == 1) {
             $talk = $object->talk;
             $talk->deleted = 1;
             $talk->save();
         }
         ajax::info('Your post has been deleted.');
     } catch (exception $e) {
         Kohana::$log->add(Log::CRITICAL, 'Couldn\'t delete Model_Talkreply: :message. User_id: :userid, postreply_id: :replyid', array(':message' => $e->getMessage(), ':userid' => user::get()->id, ':replyid' => $object->id));
         ajax::error('Something went wrong and your post couln\'t be deleted. Please try again or contact us if you think this is a mistake.');
     }
 }
예제 #5
0
 public function action_delete()
 {
     $dashboard = ORM::factory('Dashboard', arr::get($_POST, 'id'));
     if (!$dashboard->loaded()) {
         ajax::error('The dashboard wasn\'t found. Has it been deleted in the meantime?');
     }
     try {
         $user = $dashboard->user;
         $dashboard->delete();
         $dashboards = $user->dashboards->count_all();
         if ((bool) $dashboards) {
             $current = $user->dashboards->find();
             $current->current = 1;
             $current->save();
         }
         ajax::info('Dashboard deleted', array('dashboard' => dashboards::get_current()->info()));
     } catch (exception $e) {
         ajax::error('An error occurred and the panel could not be deleted: ' . $e->getMessage());
     }
 }