34 include_once(dirname(__DIR__) .
"/agent/version.php");
49 public function __construct()
51 $this->Name =
"agent_reuser";
52 $this->Title = _(
"Reuse of License Clearing");
53 $this->AgentName =
"reuser";
55 parent::__construct();
57 $this->uploadDao = $GLOBALS[
'container']->get(
'dao.upload');
68 return $reuserPlugin->renderContent($vars);
79 return $reuserPlugin->renderFoot($vars);
88 menu_insert(
"ParmAgents::" . $this->Title, 0, $this->Name);
101 $reuseUploadPair = explode(
',',
102 $request->get(self::UPLOAD_TO_REUSE_SELECTOR_NAME), 2);
103 if (count($reuseUploadPair) == 2) {
104 list($reuseUploadId, $reuseGroupId) = $reuseUploadPair;
106 $errorMsg .=
'no reuse upload id given';
111 $getReuseValue = $request->get(
'reuseMode') ?: array();
112 $reuserDependencies = array(
"agent_adj2nest");
114 $reuseMode = UploadDao::REUSE_NONE;
115 foreach ($getReuseValue as $currentReuseValue) {
116 switch ($currentReuseValue) {
118 $reuseMode |= UploadDao::REUSE_MAIN;
120 case 'reuseEnhanced':
121 $reuseMode |= UploadDao::REUSE_ENHANCED;
124 $reuseMode |= UploadDao::REUSE_CONF;
129 $reuserDependencies = array_merge($reuserDependencies,
135 return $this->
doAgentAdd($jobId, $uploadId, $errorMsg,
136 array_unique($reuserDependencies), $uploadId);
147 protected function createPackageLink($uploadId, $reuseUploadId, $groupId, $reuseGroupId, $reuseMode=0)
150 $packageDao = $GLOBALS[
'container']->get(
'dao.package');
151 $newUpload = $this->uploadDao->getUpload($uploadId);
152 $uploadForReuse = $this->uploadDao->getUpload($reuseUploadId);
154 $package = $packageDao->findPackageForUpload($reuseUploadId);
156 if ($package === null) {
158 $package = $packageDao->createPackage($packageName ?: $uploadForReuse->getFilename());
159 $packageDao->addUploadToPackage($reuseUploadId, $package);
162 $packageDao->addUploadToPackage($uploadId, $package);
164 $this->uploadDao->addReusedUpload($uploadId, $reuseUploadId, $groupId, $reuseGroupId, $reuseMode);
174 $dependencies = array();
175 if ($request->get(
"Check_agent_nomos",
false)) {
176 $dependencies[] =
"agent_nomos";
178 if ($request->get(
"Check_agent_monk",
false)) {
179 $dependencies[] =
"agent_monk";
181 if ($request->get(
"Check_agent_ojo",
false)) {
182 $dependencies[] =
"agent_ojo";
184 if ($request->get(
"Check_agent_ninka",
false)) {
185 $dependencies[] =
"agent_ninka";
187 return $dependencies;
static getCommonHead($a, $b)
UI element for reuser during Uploading new package.
renderFoot(&$vars)
Render footer twig templates for plugin_reuser.
createPackageLink($uploadId, $reuseUploadId, $groupId, $reuseGroupId, $reuseMode=0)
Create links between old and new upload.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.
getReuserDependencies($request)
const UPLOAD_TO_REUSE_SELECTOR_NAME
Form element name for main license to reuse.
static getGroupId()
Get the current user's group id.
renderContent(&$vars)
Render twig templates for plugin_reuser.
scheduleAgent($jobId, $uploadId, &$errorMsg, $request)
Get parameters from request and add to job queue.
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)