<commit_before><?php defined('SYSPATH') or die('No direct script access.');

/**
 * Letter controller.
 **/
class Controller_Letter extends Controller_Layout {
  protected $secure_actions = array(
    'index','create', 'edit', 'delete'
  );
  protected $controls = array(
    'subject' => 'input',
    'text' => 'textarea',
    'order' => 'input',
  );
  public function action_create()
  {
    $this->template = new View_Edit;
    $id = $this->request->param('id');
    if (!Model_Course::exists($id))
    {
      $this->redirect('error/500');
    }
    $this->template->model = ORM::factory('Letter');
    $this->template->model->course_id = $id;
    $this->template->title = __('New letter');
    $this->_edit($this->template->model);
  }

  public function action_edit()
  {
    $this->template = new View_Edit;
    $this->template->title = __('Letter editing');
    $id = $this->request->param('id');
    $model = ORM::factory('Letter', $id);
    if (!$model->loaded())
    {
      $this->redirect('error/404');
    }
    $this->_edit($model);
  }
  
  protected function _edit_redirect($model)
  {
    return Route::url('default', array('controller' => 'Course','action' => 'view','id' => $model->course_id));
  }

  public function action_delete()
  {
    $this->template = new View_Delete;
    $id = $this->request->param('id');
    $model = ORM::factory('Letter', $id);
    if (!$model->loaded())
    {
      $this->redirect('error/404');
    }
    $this->template->title = __('Delete letter');
    $this->template->content_title = $model->title;
    $this->template->content = $model->description;

    $confirmation = $this->request->post('confirmation');
    if ($confirmation === 'yes') {
      $post->delete();
      $this->redirect('/');
    }
  }
}<commit_msg>letter deletion<commit_after><?php defined('SYSPATH') or die('No direct script access.');

/**
 * Letter controller.
 **/
class Controller_Letter extends Controller_Layout {
  protected $secure_actions = array(
    'index','create', 'edit', 'delete'
  );
  protected $controls = array(
    'subject' => 'input',
    'text' => 'textarea',
    'order' => 'input',
  );
  public function action_create()
  {
    $this->template = new View_Edit;
    $id = $this->request->param('id');
    if (!Model_Course::exists($id))
    {
      $this->redirect('error/500');
    }
    $this->template->model = ORM::factory('Letter');
    $this->template->model->course_id = $id;
    $this->template->title = __('New letter');
    $this->_edit($this->template->model);
  }

  public function action_edit()
  {
    $this->template = new View_Edit;
    $this->template->title = __('Letter editing');
    $id = $this->request->param('id');
    $model = ORM::factory('Letter', $id);
    if (!$model->loaded())
    {
      $this->redirect('error/404');
    }
    $this->_edit($model);
  }
  
  protected function _edit_redirect($model)
  {
    return Route::url('default', array('controller' => 'Course','action' => 'view','id' => $model->course_id));
  }

  public function action_delete()
  {
    $this->template = new View_Delete;
    $id = $this->request->param('id');
    $model = ORM::factory('Letter', $id);
    if (!$model->loaded())
    {
      $this->redirect('error/404');
    }
    $this->template->title = __('Delete letter');
    $this->template->content_title = $model->title;
    $this->template->content = $model->description;

    $confirmation = $this->request->post('confirmation');
    if ($confirmation === 'yes') {
      $model->delete();
      $this->redirect('/');
    }
  }
}
{'fraction_non_alphanumeric': 0.21153305203938116, 'fraction_numerical': 0.005063291139240506, 'mean_word_length': 3.3901234567901235, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 95, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3212530', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1134, 'n_words': 205}