Example #1
0
 /**
  * @param $argv
  * @return int
  * @throws InvalidArgumentException
  */
 public function execute($argv)
 {
     try {
         $crewUrl = $this->git->getConfig('pflow.crew.url');
         $crewProjectId = $this->git->getConfig('pflow.crew.project-id');
     } catch (InvalidArgumentException $e) {
         throw new InvalidArgumentException("Crew is not configured. Use pflow init.");
     }
     $branch = $this->git->getCurrentBranch();
     $crew = new Crew($crewUrl);
     $infos = $crew->reviewStatus($crewProjectId, $branch);
     foreach ($infos as $field => $value) {
         $this->output(sprintf('%s : %s', $field, $value));
     }
     return 1;
 }
 function testCrewModule()
 {
     $acrew = new Crew("13-10-12", "foodbank", 3, null, "", "");
     $this->assertEqual($acrew->get_group(), "foodbank");
     $this->assertTrue($acrew->get_id() == "13-10-12-foodbank");
     $this->assertTrue($acrew->num_vacancies() == 3);
     $this->assertFalse($acrew->has_sub_call_list());
     $persons = array();
     $persons[] = "alex1234567890+alex+jones";
     $persons[] = "malcom1234567890+malcom+jones";
     $persons[] = "nat1234567890+nat+jones";
     $acrew->assign_persons($persons);
     $this->assertTrue($acrew->num_vacancies() == 0);
     $acrew->set_notes("Hello 3-5 crew!");
     $this->assertTrue($acrew->get_notes() == "Hello 3-5 crew!");
     echo "testCrew complete";
 }
Example #3
0
 /**
  * 
  */
 private function configureCrew()
 {
     $this->output('-!- PMSIpilot flow can work with Crew');
     $use_crew = $this->input('handle Crew stuff', 'no', array('yes', 'no')) == 'yes' ? 1 : 0;
     if ($use_crew) {
         do {
             $crew_url = $this->input('Crew URL');
             $crew = new Crew($crew_url);
             $crewProjects = $crew->getProjects();
             $isCrewUrlValid = is_array($crewProjects);
         } while (!$isCrewUrlValid && $this->output("Crew URL is invalid"));
         $validCrewProjectIds = array();
         foreach ($crewProjects as $crewProject) {
             $crewProject = (array) $crewProject;
             $validCrewProjectIds[] = $crewProject['id'];
             $this->output(sprintf('%d: %s (repository: %s)', $crewProject['id'], $crewProject['name'], $crewProject['remote']));
         }
         $this->git->setConfig('pflow.crew.project-id', (int) $this->input('project selection', null, $validCrewProjectIds));
         $this->git->setConfig('pflow.crew.url', $crew_url);
     }
 }
Example #4
0
 /**
  * @param $argv
  * @return int
  * @throws InvalidArgumentException
  */
 public function execute($argv)
 {
     try {
         $crewUrl = $this->git->getConfig('pflow.crew.url');
         $crewProjectId = $this->git->getConfig('pflow.crew.project-id');
     } catch (InvalidArgumentException $e) {
         throw new InvalidArgumentException("Crew is not configured. Use pflow init.");
     }
     $branch = $this->git->getCurrentBranch();
     try {
         $baseBranch = $this->getConfig(sprintf('branch.%s.base', $branch));
     } catch (InvalidArgumentException $e) {
         $this->output(sprintf('Unable to find base branch configuration for branch %s.', $branch));
         return 0;
     }
     $lastCommit = $this->git->getLastCommit($branch);
     $crew = new Crew($crewUrl);
     $message = $crew->reviewRequest($crewProjectId, $branch, $baseBranch, $lastCommit);
     $this->output($message);
     return 1;
 }
function newMonth($id)
{
    $days = array(1 => "Mon", 2 => "Tue", 3 => "Wed", 4 => "Thu", 5 => "Fri", 6 => "Sat");
    $fpdays = array(1 => "Mon", 2 => "Wed930", 3 => "Wed1100", 4 => "Thu", 5 => "Fri", 6 => "Sat");
    if (substr($id, 6) == "foodpantry") {
        $thisdays = $fpdays;
    } else {
        $thisdays = $days;
    }
    // We switched new months to default to published, because otherwise they won't be available for viewing.
    // We're unsure if this was the right move to make.
    $new_month = new Month($id, "unpublished");
    $new_crews = $new_month->get_crews();
    $dom = 1;
    // day of the month, 1, 2, ..., 31
    $week_no = 1;
    // master schedule week number
    $firstdow = $dow = date("N", mktime(0, 0, 0, substr($id, 3, 2), "01", substr($id, 0, 2)));
    // day of week, 1 = Monday
    if (substr($id, 6) == "foodpantry" && $firstdow == 3) {
        $firstdow = $dow = 2;
    }
    $newbies = array();
    foreach ($new_crews as $new_crew) {
        if ($dom == sizeof($new_crews) && substr($id, 6) == "foodpantry" && $dow == 2) {
            break;
        }
        $id1 = substr($id, 6) . $thisdays[$dow] . $week_no;
        $schedule_entry = retrieve_dbMasterSchedule($id1);
        if ($schedule_entry && $schedule_entry->get_slots() > 0) {
            if ($dom < 10) {
                $dd = "-0" . $dom;
            } else {
                $dd = "-" . $dom;
            }
            $person_ids = $schedule_entry->get_persons();
            $crew_names = array();
            foreach ($person_ids as $person_id) {
                if ($person_id == "") {
                    continue;
                }
                $p = retrieve_person($person_id);
                if ($p) {
                    $crew_names[] = $person_id . "+" . $p->get_first_name() . "+" . $p->get_last_name() . "+(" . implode(' ', $p->get_role()) . ")";
                } else {
                    $crew_names[] = $person_id . "+++";
                }
            }
            $newbie = new Crew(substr($id, 0, 5) . $dd, substr($id, 6), $schedule_entry->get_slots(), $crew_names, "", "");
            $new_month->set_crew($dom, $newbie->get_id());
            $newbies[] = $newbie;
        }
        if ($dow == 7) {
            $dow = 1;
        } else {
            $dow++;
        }
        if ($dow == $firstdow) {
            $week_no++;
        }
        $dom++;
    }
    update_dbMonths($new_month);
    foreach ($newbies as $newbie) {
        update_dbCrews($newbie);
    }
    return $new_month;
}
Example #6
0
 /**
  * @param Crew $crew
  * @return float
  */
 public function getAverageScoreFromCrew(Crew $crew)
 {
     $totalCommentsForCrew = 0;
     $totalScoreForCrew = 0;
     foreach ($this->getComments() as $comment) {
         if ($comment->getCrewID() == $crew->getCrewID()) {
             $totalCommentsForCrew++;
             $totalScoreForCrew += $comment->getApproval();
         }
     }
     if ($totalCommentsForCrew < 1 || $totalScoreForCrew < 1) {
         return 0;
     }
     return floor($totalScoreForCrew / $totalCommentsForCrew);
 }