<commit_before><?php

class AdminController extends BaseController
{

    public function __construct()
    {
        $this->beforeFilter('auth');
        $this->beforeFilter('admin');
        $this->beforeFilter('csrf', array('only' => array('getDeleteProject')));
    }

    public function getCreateProject()
    {
        return View::make('admin.create-project');
    }

    public function postCreateProject()
    {
        if (!is_null(Input::get('update')))
        {
            $project = Project::find(Input::get('project_id'));
            $message = trans('messages.create_project');
        }
        else
        {
            $project = new Project;
            $message = trans('messages.update_project');
        }

        if (!$project)
        {
            return Redirect::action('HomeController@getIndex')->with('message', trans('messages.form_error'));
        }

        $v = Validator::make(Input::all(), Project::getRules(Input::get('update'), $project->project_id));
        if ($v->fails())
        {
            return Redirect::back()->withErrors($v)->withInput()->with('message', trans('messages.form_error'));
        }

        $admins = is_array(Input::get('admins')) ? Input::get('admins') : array();
        $writers = is_array(Input::get('writers')) ? Input::get('writers') : array();
        $readers = is_array(Input::get('readers')) ? Input::get('readers') : array();

        $writers = Project::removeElementFromArray($admins, $writers);
        $readers = Project::removeElementFromArray(array_merge($admins, $writers), $readers);


        $project->name = Input::get('name');
        $project->url = Str::slug(Input::get('name'));
        $project->repository = Input::get('repository');
        $project->description = Input::get('description');

        $project->admins = implode(',', $admins);
        $project->writers = implode(',', $writers);
        $project->readers = implode(',', $readers);

        $project->save();

        return Redirect::action('HomeController@getIndex')->with('message', trans('messages.create_project'));
    }

    public function getUpdateProject($id = null)
    {
        $project = Project::find($id);

        if ($project)
        {
            $admins = User::getGroupIdName($project->admins);<commit_msg>Fix bug in create project<commit_after><?php

class AdminController extends BaseController
{

    public function __construct()
    {
        $this->beforeFilter('auth');
        $this->beforeFilter('admin');
        $this->beforeFilter('csrf', array('only' => array('getDeleteProject')));
    }

    public function getCreateProject()
    {
        return View::make('admin.create-project');
    }

    public function postCreateProject()
    {
        if (!is_null(Input::get('update')))
        {
            $project = Project::find(Input::get('project_id'));
            $message = trans('messages.create_project');
        }
        else
        {
            $project = new Project;
            $message = trans('messages.update_project');
        }

        if (!$project)
        {
            return Redirect::action('HomeController@getIndex')->with('message', trans('messages.form_error'));
        }

        $v = Validator::make(Input::all(), Project::getRules(Input::get('update'), $project->project_id));
        if ($v->fails())
        {
            return Redirect::back()->withErrors($v)->withInput()->with('message', trans('messages.form_error'));
        }

        $admins = is_array(Input::get('admins')) ? Input::get('admins') : array();
        $writers = is_array(Input::get('writers')) ? Input::get('writers') : array();
        $readers = is_array(Input::get('readers')) ? Input::get('readers') : array();

        $writers = Project::removeElementFromArray($admins, $writers);
        $readers = Project::removeElementFromArray(array_merge($admins, $writers), $readers);

        if (count($admins) == 0)
        {
            $errors = array('admins' => 'At least one admin must be determined.');
            $errors = new Illuminate\Support\MessageBag($errors);
            return Redirect::back()->withInput()->with('errors', $errors);
        }

        $project->name = Input::get('name');
        $project->url = Str::slug(Input::get('name'));
        $project->repository = Input::get('repository');
        $project->description = Input::get('description');

        $project->admins = implode(',', $admins);
        $project->writers = implode(',', $writers);
        $project->readers = implode(',', $readers);

        $project->save();

        return Redirect::action('HomeController@getIndex')->with('message', trans('messages.create_project'));
    }

    public function getUpdateProject($id = null)
    {
        $project = Project::find($id);

        if ($project)
        {
            $admins = User::getGroupIdName($project->admins);
{'fraction_non_alphanumeric': 0.18159458905513426, 'fraction_numerical': 0.00020496003279360525, 'mean_word_length': 2.8853503184713376, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 46, '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': '7131281', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1338, 'n_words': 215}