10 use Symfony\Component\HttpFoundation\Request;
12 include_once(__DIR__ .
"/../agent/version.php");
20 const RULES_FLAG =
"-r";
21 const LICENSE_FLAG =
"-t";
23 function __construct()
25 $this->Name =
"agent_decider";
26 $this->Title = _(
"Automatic Concluded License Decider, based on scanners Matches");
27 $this->AgentName = AGENT_DECIDER_NAME;
29 parent::__construct();
41 $renderer = $GLOBALS[
'container']->get(
'twig.environment');
42 $vars[
'isNinkaInstalled'] =
false;
44 $vars[
'isNinkaInstalled'] = $ninkaUi->isNinkaInstalled();
47 $licenseTypes = array_map(
'trim', explode(
',',
48 $SysConf[
'SYSCONFIG'][
'LicenseTypes']));
49 $vars[
'licenseTypes'] = array_combine($licenseTypes, $licenseTypes);
50 return $renderer->load(
'agent_decider.html.twig')->render($vars);
63 public function getScriptIncludes(&$vars)
78 $dependencies = array();
80 $rules = $request->get(
'deciderRules', []);
81 if (!is_array($rules)) {
84 $agents = $request->get(
'agents', []);
85 if (!is_array($agents)) {
88 if (in_array(
'agent_nomos', $agents)) {
89 $checkAgentNomos =
true;
91 $checkAgentNomos = $request->get(
'Check_agent_nomos',
false);
94 if (in_array(
'agent_copyright', $agents)) {
95 $checkAgentCopyright =
true;
97 $checkAgentCopyright = $request->get(
'Check_agent_copyright') ?:
false;
101 foreach ($rules as $rule) {
104 $dependencies[] =
'agent_nomos';
105 $dependencies[] =
'agent_monk';
108 case 'nomosMonkNinka':
109 $dependencies[] =
'agent_nomos';
110 $dependencies[] =
'agent_monk';
111 $dependencies[] =
'agent_ninka';
115 $dependencies[] =
'agent_nomos';
116 $dependencies[] =
'agent_monk';
117 $dependencies[] =
'agent_reuser';
120 case 'wipScannerUpdates':
124 case 'ojoNoContradiction':
125 if ($checkAgentNomos) {
126 $dependencies[] =
'agent_nomos';
128 $dependencies[] =
'agent_ojo';
131 case 'copyrightDeactivation':
132 if ($checkAgentCopyright) {
133 $dependencies[] =
'agent_copyright';
137 case 'copyrightDeactivationClutterRemoval':
138 if ($checkAgentCopyright) {
139 $dependencies[] =
'agent_copyright';
143 case 'licenseTypeConc':
144 $dependencies[] =
'agent_compatibility';
153 if (empty($rulebits)) {
158 if ($rulebits == 0x100) {
160 if ($kotobaPlugin !==
null) {
161 return $kotobaPlugin->AgentAdd($jobId, $uploadId, $errorMsg, array(),
null, $request);
167 if ($rulebits & 0x100) {
168 $dependencies[] =
'agent_kotoba';
171 $args = self::RULES_FLAG . $rulebits;
173 if ($rulebits & 0x80) {
175 if ($licenseType !=
"") {
176 $args .=
" " . self::LICENSE_FLAG . escapeshellarg($licenseType);
180 return parent::AgentAdd($jobId, $uploadId, $errorMsg,
181 array_unique($dependencies), $args, $request);
191 $agentList = $request->get(
'agents') ?: array();
192 if (!is_array($agentList)) {
193 $agentList = array();
195 foreach (array(
'agent_nomos',
'agent_monk',
'agent_ninka') as $agentName) {
196 if (in_array($agentName, $dependencies)) {
199 if ($request->get(
'Check_'.$agentName)) {
200 $dependencies[] = $agentName;
203 if (in_array($agentName, $agentList)) {
204 $dependencies[] = $agentName;
215 menu_insert(
"ParmAgents::" . $this->Title, 0, $this->Name);
226 $licenseTypes = array_map(
'trim', explode(
',',
227 $SysConf[
'SYSCONFIG'][
'LicenseTypes']));
228 $licenseType = $request->get(
"licenseTypeConc",
"");
229 if (!is_string($licenseType)) {
232 $licenseType =
trim($licenseType);
233 if (in_array($licenseType, $licenseTypes)) {
246 return file_exists(
"/home/" .
247 $SysConf[
'DIRECTORIES'][
'PROJECTUSER'] .
"/pythondeps/bin/spacy");
UI plugin for DeciderAgent.
renderFoot(&$vars)
Render footer HTML.
addScannerDependencies(&$dependencies, Request $request)
Add dependencies on DeciderAgent.
getLicenseTypeConf(Request $request)
scheduleAgent($jobId, $uploadId, &$errorMsg, $request)
Schedule decider agent.
renderContent(&$vars)
Render HTML from template.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
char * trim(char *ptext)
Trimming whitespace.