12 use Symfony\Component\HttpFoundation\Request;
13 use Symfony\Component\HttpFoundation\Response;
26 const NAME =
"upload_agent_options";
28 public function __construct()
30 parent::__construct(self::NAME, array(
31 self::TITLE => _(
"List Agents for an Upload as Options"),
45 $sql =
"select count(*) from job inner join jobqueue on job_pk=jq_job_fk "
46 .
"where job_upload_fk=$1 and jq_endtext is null and jq_type=$2";
47 $queued = $GLOBALS[
'container']->get(
'db.manager')->getSingleRow($sql,array($uploadId,$agentName));
48 return $queued[
'count']==0;
51 protected function handle(Request $request)
53 $uploadId = intval($request->get(
"upload"));
54 if (empty($uploadId)) {
55 throw new Exception(
'missing upload id');
58 $parmAgentList = MenuHook::getAgentPluginNames(
"ParmAgents");
59 $plainAgentList = MenuHook::getAgentPluginNames(
"Agents");
60 $agentList = array_merge($plainAgentList, $parmAgentList);
61 $skipAgents = array(
"agent_unpack",
"wget_agent");
63 $relevantAgents = array();
64 foreach ($agentList as $agent) {
65 if (array_search($agent, $skipAgents) !==
false) {
69 if (($plugin->AgentHasResults($uploadId) != 1) &&
70 $this->jobNotYetScheduled($plugin->AgentName, $uploadId)) {
71 $out .=
"<option value='" . $agent .
"'>";
72 $position = strpos($plugin->Title,
'<');
73 if ($position !==
false) {
74 $out .= htmlentities(substr($plugin->Title, 0, $position));
76 $out .= htmlentities($plugin->Title);
78 $out .=
"</option>\n";
79 $relevantAgents[$agent] = $plugin->Title;
83 $out =
'<select multiple size="10" id="agents" name="agents[]">' .$out.
'</select>';
84 return new Response($out, Response::HTTP_OK, array(
'Content-Type'=>
'text/plain'));
jobNotYetScheduled($agentName, $uploadId)
This function checks if the current job was not already scheduled, or did already fail (You can resch...
Contains the constants and helpers for authentication of user.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
#define PERM_READ
Read-only permission.