60 if (!empty($AgentList)) {
62 $userName = $_SESSION[
'User'];
63 if (!empty($specified_username)) {
64 $userName = $specified_username;
66 $sql =
"SELECT user_name, user_agent_list, default_bucketpool_fk FROM users WHERE 67 user_name='$userName';";
68 $result = pg_query($PG_CONN, $sql);
70 $uList = pg_fetch_all($result);
71 pg_free_result($result);
75 $text = _(
"Fatal! Query Failed getting user_agent_list for user");
76 return(
"<h3 style='color:red'>$text $userName</h3>");
78 $list = explode(
',',$uList[0][
'user_agent_list']);
79 $default_bucketpool_fk = $uList[0][
'default_bucketpool_fk'];
80 if (empty($default_bucketpool_fk)) {
81 $SkipAgents[] =
"agent_bucket";
84 foreach ($AgentList as $AgentItem) {
85 $Agent = &$Plugins[plugin_find_id($AgentItem->URI)];
92 foreach ($SkipAgents as $SkipAgent) {
93 if ($Agent->Name == $SkipAgent) {
102 if ($upload_pk != -1) {
103 $rc = $Agent->AgentHasResults($upload_pk);
108 $Name = htmlentities($Agent->Name);
109 $Desc = htmlentities($AgentItem->Name);
113 if (in_array($Name, $list)) {
114 $Selected =
" checked ";
118 $V .=
"<input type='checkbox' name='Check_$Name' value='1' $Selected />$Desc<br />\n";
151 foreach ($agents as &$agent) {
152 $rv = $agent->AgentAdd($jobId, $uploadId, $errorMsg, array());
188 $sql =
"SELECT job_upload_fk, job_pk, job_name FROM job WHERE " .
189 "job_upload_fk = $UploadPk order by job_pk desc;";
190 $result = pg_query($PG_CONN, $sql);
192 $Jobs = pg_fetch_all($result);
193 pg_free_result($result);
196 foreach ($Jobs as $Row) {
197 if ($Row[
'job_name'] ==
'Copyright Analysis') {
198 $jobList[] = $Row[
'job_pk'];
199 } elseif ($Row[
'job_name'] ==
'Bucket Analysis') {
200 $jobList[] = $Row[
'job_pk'];
201 } elseif ($Row[
'job_name'] ==
'Package Agents') {
202 $jobList[] = $Row[
'job_pk'];
203 } elseif ($Row[
'job_name'] ==
'Nomos License Analysis') {
204 $jobList[] = $Row[
'job_pk'];
209 foreach ($jobList as $job) {
210 $sql =
"SELECT jq_pk, jq_job_fk FROM jobqueue WHERE jq_job_fk = $job " .
211 " order by jq_pk desc;";
212 $result = pg_query($PG_CONN, $sql);
214 $Q = pg_fetch_all($result);
215 pg_free_result($result);
216 $Depends[] = $Q[0][
'jq_pk'];
239 $sqlselect =
"SELECT agent_pk FROM agent WHERE agent_name ='$agentName' " 240 .
"and agent_enabled='true' order by agent_ts desc limit 1";
241 $result = pg_query($PG_CONN, $sqlselect);
244 if (pg_num_rows($result) == 0) {
246 $sql =
"INSERT INTO agent (agent_name,agent_desc,agent_enabled) VALUES ('$agentName',E'$agentDesc',1)";
247 $result = pg_query($PG_CONN, $sqlselect);
251 $result = pg_query($PG_CONN, $sqlselect);
255 $row = pg_fetch_assoc($result);
256 pg_free_result($result);
257 return $row[
"agent_pk"];
283 function AgentARSList($TableName, $upload_pk, $limit=1, $agent_fk=0, $ExtraWhere=
"")
288 $agentDao = $container->get(
'dao.agent');
289 return $agentDao->agentARSList($TableName, $upload_pk, $limit, $agent_fk, $ExtraWhere);
304 $AgentRec = AgentARSList($arsTableName, $upload_pk, 1, 0, $arsSuccess);
306 if (empty($AgentRec)) {
309 $Agent_pk = intval($AgentRec[0][
'agent_fk']);
331 function AgentSelect($TableName, $upload_pk, $SLName, &$agent_pk, $extra =
"")
335 $TableName .=
'_ars';
336 $sql =
"select agent_pk, agent_name, agent_rev from agent, $TableName where " 337 .
"agent.agent_pk = $TableName.agent_fk and upload_fk = $upload_pk order by agent_rev DESC";
338 $result = pg_query($PG_CONN, $sql);
341 $NumRows = pg_num_rows($result);
343 pg_free_result($result);
347 $select =
"<select name='$SLName' id='$SLName' $extra>";
348 while ($row = pg_fetch_assoc($result)) {
349 $select .=
"<option value='$row[agent_pk]'";
351 if (empty($agent_pk)) {
352 $select .=
" SELECTED ";
353 $agent_pk = $row[
"agent_pk"];
354 }
else if ($agent_pk == $row[
'agent_pk']) {
355 $select .=
" SELECTED ";
358 $select .=
">$row[agent_name], v $row[agent_rev]\n";
360 $select .=
"</select>";
361 pg_free_result($result);
385 $agentsChecked = array();
387 foreach ($agentList as $agentName => &$agentPlugin) {
389 $agentsChecked[$agentName] = &$agentPlugin;
394 return $agentsChecked;
407 if (!empty($agentList)) {
408 foreach ($agentList as $agentItem) {
415 if (empty($agentPlugin)) {
418 $name = htmlentities($agentPlugin->Name);
419 $agents[$name] = $agentPlugin;
437 function CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
440 $Latest_agent_pk =
GetAgentKey($AgentName, $AgentDesc);
443 $Last_successful_agent_pk =
LatestAgentpk($upload_pk, $AgentARSTableName,
true);
445 if (! empty($Latest_agent_pk) && ! empty($Last_successful_agent_pk)) {
446 if ($Latest_agent_pk == $Last_successful_agent_pk) {
AgentSchedule($jobId, $uploadId, $agents)
Schedule all given agents.
checkedAgents()
read the UI form and return array of user selected agents Because input comes from the user...
userAgents()
Read the UI form and format the user selected agents into a comma separated list. ...
AgentCheckBoxDo($job_pk, $upload_pk)
Assume someone called AgentCheckBoxMake() and submitted the HTML form. Run AgentAdd() for each of the...
listAgents()
Search in available plugins and return all agents.
AgentCheckBoxMake($upload_pk, $SkipAgents=array(), $specified_username="")
Generate a checkbox list of available agents.
FindDependent($UploadPk, $list=NULL)
Find the jobs in the job and jobqueue table to be dependent on.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
LatestAgentpk($upload_pk, $arsTableName, $arsSuccess=false)
Given an upload_pk, find the latest enabled agent_pk with results.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
Check the ARS table to see if an agent has successfully scanned an upload.
AgentSelect($TableName, $upload_pk, $SLName, &$agent_pk, $extra="")
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
GetAgentKey($agentName, $agentDesc)
Get the latest enabled agent_pk for a given agent.