예제 #1
0
파일: issue.php 프로젝트: svenbw/phproject
 /**
  * Create and save a new comment
  * @param  array $data
  * @param  bool  $notify
  * @return Comment
  */
 public static function create(array $data, $notify = true)
 {
     // Normalize data
     if (isset($data["hours"])) {
         $data["hours_total"] = $data["hours"];
         $data["hours_remaining"] = $data["hours"];
         unset($data["hours"]);
     }
     if (!empty($data["due_date"])) {
         if (!preg_match("/[0-9]{4}(-[0-9]{2}){2}/", $data["due_date"])) {
             $data["due_date"] = date("Y-m-d", strtotime($data["due_date"]));
         }
         if (empty($data["sprint_id"])) {
             $sprint = new Sprint();
             $sprint->load(array("DATE(?) BETWEEN start_date AND end_date", $issue->due_date));
             $data["sprint_id"] = $sprint->id;
         }
     }
     if (empty($data["author_id"]) && ($user_id = \Base::instance()->get("user.id"))) {
         $data["author_id"] = $user_id;
     }
     // Create issue
     $item = parent::create($data);
     // Send creation notifications
     if ($notify) {
         $notification = \Helper\Notification::instance();
         $notification->issue_create($item->id);
     }
     // Return instance
     return $item;
 }
예제 #2
0
 public function delete(Sprint $sprint)
 {
     if ($sprint->delete()) {
         Flash::success('The sprint was deleted.');
         return Redirect::route('project_path', ['project' => $sprint->project->slug]);
     } else {
         Flash::error('The sprint could not be deleted. Please try again.');
         return Redirect::back();
     }
 }
 public function store(Sprint $sprint)
 {
     $snapshot = $sprint->createSnapshot();
     if ($snapshot->exists) {
         Flash::success("Successfully created a snapshot for \"{$sprint->title}\"");
         return Redirect::route('snapshot_path', $snapshot->id);
     } else {
         Flash::error("The snapshot could not be created. Please try again");
         return Redirect::route('sprint_live_path', $sprint->phabricator_id);
     }
 }
예제 #4
0
/**
 * Receive post data from ExampleData edit form.
 * 
 * Url:
 * 
 * /example/edit/{id}
 * 
 * @param Web $w
 */
function edit_POST(Web $w)
{
    $p = $w->pathMatch("id");
    if (isset($p['id'])) {
        $data = $w->Sprint->getDataForId($p['id']);
    } else {
        $data = new Sprint($w);
    }
    $data->fill($_POST);
    // fill in validation step!
    $data->insertOrUpdate();
    // go back to the list view
    $w->msg("Sprint updated", "sprints/index");
}
예제 #5
0
 function beforeFilter()
 {
     $hasAdmin = $this->User->hasAdminUser();
     $this->set('has_admin', $hasAdmin);
     // RSS Authentication by user model
     if ($this->RequestHandler->isRss()) {
         $this->Auth->allow('index');
         $this->Security->loginOptions = array('type' => 'basic', 'login' => 'authenticate', 'realm' => 'My_RSS_Feeds');
         $this->Security->loginUsers = array();
         $this->Security->requireLogin('*');
     }
     // UsersControllerの認証除外設定
     if (get_class($this) == "UsersController") {
         if (!$hasAdmin) {
             $this->Auth->allow(array('add'));
         }
         $this->Auth->allow(array('reset_password', 'reset_password_mail'));
     }
     if (isset($this->Auth)) {
         //コントローラー側でさらに詳細を判別
         $this->Auth->authorize = 'controller';
         //ログインできるユーザの条件をデータベースのフィールドの値で指定
         $this->Auth->userScope = array("User.disabled" => 0);
         //ログイン処理を行うactionを指定(/users/loginがデフォルト)。
         $this->Auth->loginAction = "/users/login";
         //ログインが失敗した際のエラーメッセージ
         $this->Auth->loginError = __("Invalid username or password", true);
         //権限が無いactionを実行した際のエラーメッセージ
         $this->Auth->authError = __('You have no privileges', true);
         //ログイン後にリダイレクトするURL
         $this->Auth->loginRedirect = "/users/index";
         //ユーザIDとパスワードがあるmodelを指定(’User’がデフォルト)
         $this->Auth->userModel = "User";
         //ユーザIDとパスワードのフィールドを指定(username、password がデフォルト)
         $this->Auth->fields = array("username" => "loginname", "password" => "password");
         //自動リダイレクトしない
         $this->Auth->autoRedirect = false;
         // ログインユーザ情報をviewに受け渡し
         $login_user = $this->Auth->User();
         $this->set('login_user', $login_user['User']);
     }
     $project = $this->Project->getProjectInfo();
     $this->set('project_info', $project["Project"]);
     $sprint = $this->Sprint->getActiveSprintList();
     $this->set('sprint_info', $sprint);
 }
예제 #6
0
 public function getGraphDataForSprint($sprintID = null)
 {
     $memberID = $this->owner->ID;
     $sprintID = $sprintID ? $sprintID : $this->owner->Team()->getCurrentSprint()->ID;
     $sprint = Sprint::get_by_id('Sprint', $sprintID);
     if (!$sprint) {
         return false;
     }
     $vertices = array();
     $numDaysInSprint = $sprint->getNumDays();
     for ($day = 0; $day < $numDaysInSprint; $day++) {
         $dayVertices = DataObject::get('VertexMemberRelation', '"MemberID" = ' . $memberID . ' AND ' . '"SprintID" = ' . $sprintID . ' AND ' . '"Day" = ' . $day, 'X ASC');
         $XOffset = 1 / $numDaysInSprint * $day;
         foreach ($dayVertices as $vertex) {
             $vertices[] = new ArrayData(array('X' => $XOffset + $vertex->X / $numDaysInSprint, 'Y' => 1 - $vertex->Y));
         }
     }
     return new ArrayList($vertices);
 }
예제 #7
0
 /**
  * @Given :sprint contains a task
  */
 public function containsATask($sprintTitle)
 {
     $phid = Sprint::where('title', $sprintTitle)->first()->phid;
     $this->selectedTask = $this->getOrCreateTaskForSprint($phid);
 }
예제 #8
0
파일: routes.php 프로젝트: r8j3/phragile
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::bind('project', function ($slug) {
    return Project::where('slug', $slug)->first();
});
Route::bind('sprint', function ($phabricatorID) {
    return Sprint::where('phabricator_id', $phabricatorID)->first() ?: new Sprint(['phabricator_id' => $phabricatorID]);
});
Route::bind('snapshot', function ($snapshotID) {
    return SprintSnapshot::where('id', $snapshotID)->first();
});
Route::get('/', ['as' => 'home_path', 'uses' => 'ProjectsController@index']);
Route::get('/login', ['as' => 'login_path', 'uses' => 'SessionsController@login']);
Route::get('/logout', ['as' => 'logout_path', 'uses' => 'SessionsController@logout']);
Route::put('/conduit_certificate', ['middleware' => 'auth', 'as' => 'conduit_certificate_path', 'uses' => 'UsersController@updateCertificate']);
Route::get('/projects/{project}', ['as' => 'project_path', 'uses' => 'ProjectsController@show']);
Route::post('projects/store', ['middleware' => 'admin', 'as' => 'create_project_path', 'uses' => 'ProjectsController@store']);
Route::get('/projects/{project}/sprints/create', ['as' => 'create_sprint_path', 'uses' => 'SprintsController@create']);
Route::post('projects/{project}/sprints/store', ['middleware' => 'auth', 'as' => 'store_sprint_path', 'uses' => 'SprintsController@store']);
Route::get('/sprints/{sprint}', ['as' => 'sprint_path', 'uses' => 'SprintsController@show']);
Route::get('/sprints/{sprint}/export.json', ['as' => 'sprint_export_json_path', 'uses' => 'SprintsController@exportJSON']);
Route::get('/sprints/{sprint}/snapshot', ['as' => 'create_snapshot_path', 'middleware' => 'auth', 'uses' => 'SprintSnapshotsController@store']);
예제 #9
0
	/**
	 * Returns the data model based on the primary key given in the GET variable.
	 * If the data model is not found, an HTTP exception will be raised.
	 * @param integer the ID of the model to be loaded
	 */
	public function loadModel($id)
	{
		$model=Sprint::model()->findByPk((int)$id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}
예제 #10
0
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::bind('project', function ($slug) {
    return Project::where('slug', $slug)->first();
});
Route::bind('sprint', function ($phabricatorID) {
    return Sprint::where('phabricator_id', $phabricatorID)->first();
});
Route::bind('snapshot', function ($snapshotID) {
    return SprintSnapshot::where('id', $snapshotID)->first();
});
Route::get('/', ['as' => 'home_path', 'uses' => 'ProjectsController@index']);
Route::get('/login', ['as' => 'login_path', 'uses' => 'SessionsController@login']);
Route::get('/logout', ['as' => 'logout_path', 'uses' => 'SessionsController@logout']);
Route::put('/conduit_certificate', ['middleware' => 'auth', 'as' => 'conduit_certificate_path', 'uses' => 'UsersController@updateCertificate']);
Route::get('/projects/{project}', ['as' => 'project_path', 'uses' => 'ProjectsController@show']);
Route::post('projects/store', ['middleware' => 'auth', 'as' => 'create_project_path', 'uses' => 'ProjectsController@store']);
Route::get('/projects/{project}/sprints/create', ['as' => 'create_sprint_path', 'uses' => 'SprintsController@create']);
Route::post('projects/{project}/sprints/store', ['middleware' => 'auth', 'as' => 'store_sprint_path', 'uses' => 'SprintsController@store']);
Route::get('/sprints/{sprint}', ['as' => 'sprint_path', 'uses' => 'SprintsController@show']);
Route::get('/sprints/{sprint}/export.json', ['as' => 'sprint_export_json_path', 'uses' => 'SprintsController@exportJSON']);
Route::get('/sprints/{sprint}/snapshot', ['as' => 'create_snapshot_path', 'middleware' => 'auth', 'uses' => 'SprintSnapshotsController@store']);
예제 #11
0
 public function updateSettings(Sprint $sprint)
 {
     $sprint->update(Input::only('ignore_estimates'));
     Flash::success('The sprint settings have been updated');
     return Redirect::back();
 }
예제 #12
0
파일: Project.php 프로젝트: r8j3/phragile
 private function closestFutureSprint()
 {
     return Sprint::where('sprint_start', '>', date('Y-m-d'))->where('project_id', $this->id)->orderBy('sprint_start', 'asc')->first();
 }
         } else {
             $cards = DB::table('cards')->where('sprint', $sprint_id)->get();
         }
         $setting = array('response_time' => $progress[sizeof($progress) - 1]->response, 'loops' => $progress[sizeof($progress) - 1]->loops, 'maintenance_loops' => $progress[sizeof($progress) - 1]->maintenance, 'active' => $progress[sizeof($progress) - 1]->active);
     } else {
         $cards = DB::table('cards')->where('sprint', $sprint_id)->get();
         $setting = Config::get('general.sprint');
     }
     $subcards = array();
     foreach ($cards as $card) {
         $temp = DB::table('sub_cards')->where('cards', $card->id)->get();
         for ($i = 0; $i < sizeof($temp); $i++) {
             array_push($subcards, $temp[$i]);
         }
     }
     $sprint = Sprint::find($sprint_id);
     $data['school'] = $school_id;
     $data['user'] = $user->id;
     $data['sprint'] = $sprint_id;
     App::make('SprintController')->newProgress($data, $setting);
     $progress = DB::table('studentprogress')->where('user', $user->id)->where('school', $school_id)->where('sprint', $sprint_id)->orderBy('id', 'desc')->get();
     $progress_id = $progress[0]->id;
     return View::make("student.flashcards")->with("title", $sprint->first()->name)->with("sprint_id", $sprint_id)->with("school_id", $school_id)->with("rate", $sprint->fluency_rate)->with("cards", $cards)->with("subcards", $subcards)->with("setting", $setting)->with("total_count", $total_count)->with("mastered_count", $mastered_count)->with("progress_id", $progress_id)->with("studyroom", true)->with("user", $user);
 }));
 Route::post("student_quizcomplete", array("as" => "student/quizcomplete", function () {
     $user = Auth::user();
     $post = Input::all();
     $school = $post['school'];
     $sprint_id = $post['id'];
     $correct = $post['correct_cards'];
     $incorrect = $post['incorrect_cards'];
 public function deleteAction()
 {
     $input = Input::all();
     $id = $input["id"];
     $sprint = Sprint::find($id);
     $sprint->deleted_at = new DateTime(date('Y-m-d H:i:s'));
     $sprint->save();
     //$result = $sprint->delete();
     $message = "";
     /*$cards = Card::where('sprint', $id);
     
     		foreach ($cards->get() as $card) {
     			SubCard::where('cards', $card->id)->delete();
     		}
     
     		$cards->delete();
     		if ($result == 1) {
     			$status = true;
     		}*/
     $responses = array('idx' => $id, 'message' => $message, 'status' => true);
     return Response::json($responses);
 }
예제 #15
0
 /**
  * @dataProvider dateSequenceProvider
  */
 public function testGetDaysIncrementsCorrectly($start, $end, $all)
 {
     $sprint = new Sprint(['sprint_start' => $start, 'sprint_end' => $end]);
     $this->assertSame($sprint->getFormattedDays('Y-m-d'), $all);
 }
예제 #16
0
 /**
  * @When I go to the :sprint export page
  */
 public function iGoToTheExportPage($sprint)
 {
     $this->visit('/sprints/' . Sprint::where('title', $sprint)->first()->phabricator_id . '/export.json');
 }
예제 #17
0
 public function getNumber()
 {
     $sprints = Sprint::get('Sprint', "TeamID = {$this->TeamID} AND StartDate <= '{$this->StartDate}'", array('StartDate', 'ASC'));
     return $sprints->count();
 }