49 if (!empty($AgentList)) {
51 $userName = $_SESSION[
'User'];
52 if (!empty($specified_username)) {
53 $userName = $specified_username;
55 $sql =
"SELECT user_name, user_agent_list, default_bucketpool_fk FROM users WHERE
56 user_name='$userName';";
59 $uList = pg_fetch_all($result);
60 pg_free_result($result);
64 $text = _(
"Fatal! Query Failed getting user_agent_list for user");
65 return(
"<h3 style='color:red'>$text $userName</h3>");
67 $list = explode(
',',$uList[0][
'user_agent_list']);
68 $default_bucketpool_fk = $uList[0][
'default_bucketpool_fk'];
69 if (empty($default_bucketpool_fk)) {
70 $SkipAgents[] =
"agent_bucket";
73 foreach ($AgentList as $AgentItem) {
74 $Agent = &$Plugins[plugin_find_id($AgentItem->URI)];
81 foreach ($SkipAgents as $SkipAgent) {
82 if ($Agent->Name == $SkipAgent) {
91 if ($upload_pk != -1) {
92 $rc = $Agent->AgentHasResults($upload_pk);
97 $Name = htmlentities($Agent->Name);
98 $Desc = $AgentItem->Name;
102 if (in_array($Name, $list)) {
103 $Selected =
" checked ";
107 $V .=
"<input type='checkbox' class='browse-upload-checkbox view-license-rc-size' name='Check_$Name' value='1' $Selected /> $Desc<br />\n";
140 foreach ($agents as &$agent) {
141 $rv = $agent->AgentAdd($jobId, $uploadId, $errorMsg, array());
177 $sql =
"SELECT job_upload_fk, job_pk, job_name FROM job WHERE " .
178 "job_upload_fk = $UploadPk order by job_pk desc;";
181 $Jobs = pg_fetch_all($result);
182 pg_free_result($result);
185 foreach ($Jobs as $Row) {
186 if ($Row[
'job_name'] ==
'Copyright Analysis') {
187 $jobList[] = $Row[
'job_pk'];
188 } elseif ($Row[
'job_name'] ==
'Bucket Analysis') {
189 $jobList[] = $Row[
'job_pk'];
190 } elseif ($Row[
'job_name'] ==
'Package Agents') {
191 $jobList[] = $Row[
'job_pk'];
192 } elseif ($Row[
'job_name'] ==
'Nomos License Analysis') {
193 $jobList[] = $Row[
'job_pk'];
198 foreach ($jobList as $job) {
199 $sql =
"SELECT jq_pk, jq_job_fk FROM jobqueue WHERE jq_job_fk = $job " .
200 " order by jq_pk desc;";
203 $Q = pg_fetch_all($result);
204 pg_free_result($result);
205 $Depends[] = $Q[0][
'jq_pk'];
228 $sqlselect =
"SELECT agent_pk FROM agent WHERE agent_name ='$agentName' "
229 .
"and agent_enabled='true' order by agent_ts desc limit 1";
230 $result = pg_query(
$PG_CONN, $sqlselect);
233 if (pg_num_rows($result) == 0) {
235 $sql =
"INSERT INTO agent (agent_name,agent_desc,agent_enabled) VALUES ('$agentName',E'$agentDesc',1)";
236 $result = pg_query(
$PG_CONN, $sqlselect);
240 $result = pg_query(
$PG_CONN, $sqlselect);
244 $row = pg_fetch_assoc($result);
245 pg_free_result($result);
246 return $row[
"agent_pk"];
272 function AgentARSList($TableName, $upload_pk, $limit=1, $agent_fk=0, $ExtraWhere=
"")
277 $agentDao = $container->get(
'dao.agent');
278 return $agentDao->agentARSList($TableName, $upload_pk, $limit, $agent_fk, $ExtraWhere);
293 $AgentRec = AgentARSList($arsTableName, $upload_pk, 1, 0, $arsSuccess);
295 if (empty($AgentRec)) {
298 $Agent_pk = intval($AgentRec[0][
'agent_fk']);
320 function AgentSelect($TableName, $upload_pk, $SLName, &$agent_pk, $extra =
"")
324 $TableName .=
'_ars';
325 $sql =
"select agent_pk, agent_name, agent_rev from agent, $TableName where "
326 .
"agent.agent_pk = $TableName.agent_fk and upload_fk = $upload_pk order by agent_rev DESC";
330 $NumRows = pg_num_rows($result);
332 pg_free_result($result);
336 $select =
"<select name='$SLName' id='$SLName' $extra>";
337 while ($row = pg_fetch_assoc($result)) {
338 $select .=
"<option value='$row[agent_pk]'";
340 if (empty($agent_pk)) {
341 $select .=
" SELECTED ";
342 $agent_pk = $row[
"agent_pk"];
343 }
else if (in_array($row[
'agent_pk'], $agent_pk)) {
344 $select .=
" SELECTED ";
347 $select .=
">$row[agent_name], v $row[agent_rev]\n";
349 $select .=
"</select>";
350 pg_free_result($result);
374 $agentsChecked = array();
376 foreach ($agentList as $agentName => &$agentPlugin) {
377 if (is_null($agents)) {
379 $agentsChecked[$agentName] = &$agentPlugin;
382 if ($agents[
"Check_" . $agentName] == 1) {
383 $agentsChecked[$agentName] = &$agentPlugin;
389 return $agentsChecked;
402 if (!empty($agentList)) {
403 foreach ($agentList as $agentItem) {
410 if (empty($agentPlugin)) {
413 $name = htmlentities($agentPlugin->Name);
414 $agents[$name] = $agentPlugin;
432 function CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
435 $Latest_agent_pk =
GetAgentKey($AgentName, $AgentDesc);
438 $Last_successful_agent_pk =
LatestAgentpk($upload_pk, $AgentARSTableName,
true);
440 if (! empty($Latest_agent_pk) && ! empty($Last_successful_agent_pk)) {
441 if ($Latest_agent_pk == $Last_successful_agent_pk) {
AgentSchedule($jobId, $uploadId, $agents)
Schedule all given agents.
AgentCheckBoxDo($job_pk, $upload_pk)
Assume someone called AgentCheckBoxMake() and submitted the HTML form. Run AgentAdd() for each of the...
checkedAgents($agents=null)
read the UI form and return array of user selected agents Because input comes from the user,...
GetAgentKey($agentName, $agentDesc)
Get the latest enabled agent_pk for a given agent.
userAgents($agents=null)
Read the UI form and format the user selected agents into a comma separated list.
AgentCheckBoxMake($upload_pk, $SkipAgents=array(), $specified_username="")
Generate a checkbox list of available agents.
listAgents()
Search in available plugins and return all agents.
AgentSelect($TableName, $upload_pk, $SLName, &$agent_pk, $extra="")
LatestAgentpk($upload_pk, $arsTableName, $arsSuccess=false)
Given an upload_pk, find the latest enabled agent_pk with results.
FindDependent($UploadPk, $list=NULL)
Find the jobs in the job and jobqueue table to be dependent on.
CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
Check the ARS table to see if an agent has successfully scanned an upload.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN