示例#1
0
 /**
  * Prompts the user for a resolution option, and returns the ID of the
  * selected one.
  *
  * @param   RemoteApi $client The connection resource
  * @return  integer The selected resolution id
  */
 public function promptResolutionSelection($client)
 {
     $list = $client->getResolutionAssocList();
     if (count($list) > 1) {
         // need to ask which status this person wants to use
         $prompt = "Which resolution do you want to use in this action?\n";
         foreach ($list as $key => $value) {
             $prompt .= sprintf(" [%s] => %s\n", $key, $value);
         }
         $prompt .= 'Please enter the resolution';
         $resolution_id = CLI_Misc::prompt($prompt, false);
         $available_ids = array_keys($list);
         if (!in_array($resolution_id, $available_ids)) {
             self::quit("Entered resolution doesn't match any in the list available to you");
         }
     } else {
         if (count($list) == 0) {
             $resolution_id = 0;
         } else {
             $t = array_keys($list);
             $resolution_id = $t[0];
         }
     }
     return $resolution_id;
 }