13 define(
"TITLE_admin_bucket_pool", _(
"Duplicate Bucketpool"));
23 $this->Name =
"admin_bucket_pool";
24 $this->Title = TITLE_admin_bucket_pool;
25 $this->MenuList =
"Admin::Buckets::Duplicate Bucketpool";
27 parent::__construct();
46 $sql =
"select * from bucketpool where bucketpool_pk='$bucketpool_pk' ";
49 $row = pg_fetch_assoc($result);
50 pg_free_result($result);
60 $sql =
"select max(version) as version from bucketpool where bucketpool_name='$row[bucketpool_name]'";
63 $vrow = pg_fetch_assoc($result);
64 pg_free_result($result);
65 $newversion = $vrow[
'version'] + 1;
68 $sql =
"insert into bucketpool (bucketpool_name, version, active, description) select bucketpool_name, '$newversion', active, description from bucketpool where bucketpool_pk=$bucketpool_pk";
71 pg_free_result($result);
74 $sql =
"select bucketpool_pk from bucketpool where bucketpool_name='$row[bucketpool_name]' and version='$newversion'";
77 $row = pg_fetch_assoc($result);
78 pg_free_result($result);
79 $newbucketpool_pk = $row[
'bucketpool_pk'];
82 $sql =
"insert into bucket_def (bucket_name, bucket_color, bucket_reportorder, bucket_evalorder, bucketpool_fk, bucket_type, bucket_regex, bucket_filename, stopon, applies_to)
83 select bucket_name, bucket_color, bucket_reportorder, bucket_evalorder, $newbucketpool_pk, bucket_type, bucket_regex, bucket_filename, stopon, applies_to from bucket_def where bucketpool_fk=$bucketpool_pk";
84 $insertresult = pg_query(
$PG_CONN, $sql);
86 pg_free_result($insertresult);
89 if ($UpdateDefault ==
'on')
91 $sql =
"update users set default_bucketpool_fk='$newbucketpool_pk' where user_pk='$_SESSION[UserId]'";
94 pg_free_result($result);
97 return $newbucketpool_pk;
116 global $PROJECTSTATEDIR;
122 if (!empty($bucketpool_pk))
125 $newbucketpool_pk = $this->
CloneBucketpool($bucketpool_pk, $UpdateDefault, $msg);
126 $text = _(
"Your new bucketpool_pk is");
127 $this->vars[
'message'] =
"$text $newbucketpool_pk";
131 $V .= _(
"The purpose of this is to facilitate editing an existing bucketpool. Make sure you understand");
132 $V .=
" <a href='https://github.com/fossology/fossology/wiki/Buckets'>";
133 $V .= _(
"Creating Bucket Pools");
135 $V .= _(
"before continuing.");
136 $V .= _(
" It will explain why you should create a new bucketpool rather than edit an old one that has already recorded results.");
138 $V .= _(
"Steps to modify a bucketpool:");
141 $V .= _(
"Create a baseline with your current bucketpool. In other words, run a bucket scan on something. If you do this before creating a new modified bucketpool, you can compare the old results with the new to verify it is working as you expect.");
143 $V .= _(
"Duplicate the bucketpool (this will increment the bucketpool version and its bucketdef records). You should also check 'Update my default bucketpool' since new bucket jobs only use your default bucketpool.");
145 $V .= _(
"Duplicate any bucket scripts that you defined in $PROJECTSTATEDIR.");
147 $V .= _(
"Manually edit the new bucketpool record, if desired.");
149 $V .= _(
"Manually insert/update/delete the new bucketdef records.");
151 $V .= _(
"Manually insert a new buckets record in the agent table.");
153 $V .= _(
"Queue up the new bucket job in Jobs > Schedule Agents.");
155 $V .= _(
"Use Buckets > Compare to compare the new and old runs. Verify the results.");
157 $V .= _(
"If you still need to edit the buckets, use Buckets > Remove Bucket Results to remove the previous runs results and repeat starting with editing the bucketpool or def records.");
159 $V .= _(
"When the bucket results are what you want, then you can reset all the users of the old bucketpool to the new one (manual sql step).");
163 $V .=
"<form method='POST'>";
164 $text = _(
"Choose the bucketpool to duplicate");
170 $text = _(
"Update my default bucketpool");
171 $V .=
"<input type='checkbox' name='updatedefault' checked> $text.";
174 $V .=
"<input type='submit' value='$text'>";
181 $NewPlugin->Initialize();
This is the Plugin class. All plugins should:
CloneBucketpool($bucketpool_pk, $UpdateDefault, &$msg)
Clone a bucketpool and its bucketdef records. Increment the bucketpool version.
__construct()
base constructor. Most plugins will just use this
Output()
User chooses a bucketpool to duplicate from a select list.
SelectBucketPool($selected, $active='Y')
Return a select list containing all the active bucketpool's.
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.
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN