Exemplo n.º 1
0
 /**
  * Method used to prompt the current user to select a project.
  *
  * @access  public
  * @param   resource $rpc_conn The connection resource
  * @param   array $auth Array of authentication information (email, password)
  * @param   boolean $only_customer_projects Whether to only include projects with customer integration or not
  * @return  integer The project ID
  */
 function promptProjectSelection($rpc_conn, $auth, $only_customer_projects = FALSE)
 {
     // list the projects that this user is assigned to
     $projects = Command_Line::getUserAssignedProjects(&$rpc_conn, $auth, $only_customer_projects);
     if (count($projects) > 1) {
         // need to ask which project this person is asking about
         $prompt = "For which project do you want this action to apply to?\n";
         for ($i = 0; $i < count($projects); $i++) {
             $prompt .= sprintf(" [%s] => %s\n", $projects[$i]['id'], $projects[$i]['title']);
         }
         $prompt .= "Please enter the number of the project";
         $project_id = Misc::prompt($prompt, false);
         $found = 0;
         for ($i = 0; $i < count($projects); $i++) {
             if ($project_id == $projects[$i]['id']) {
                 $found = 1;
                 break;
             }
         }
         if (!$found) {
             Command_Line::quit("Entered project number doesn't match any in the list of projects assigned to you");
         }
     } else {
         $project_id = $projects[0]['id'];
     }
     return $project_id;
 }