24 define(
"TITLE_admin_bucket_pool", _(
"Duplicate Bucketpool"));
32 function __construct()
34 $this->Name =
"admin_bucket_pool";
35 $this->Title = TITLE_admin_bucket_pool;
36 $this->MenuList =
"Admin::Buckets::Duplicate Bucketpool";
38 parent::__construct();
57 $sql =
"select * from bucketpool where bucketpool_pk='$bucketpool_pk' ";
58 $result = pg_query($PG_CONN, $sql);
60 $row = pg_fetch_assoc($result);
61 pg_free_result($result);
71 $sql =
"select max(version) as version from bucketpool where bucketpool_name='$row[bucketpool_name]'";
72 $result = pg_query($PG_CONN, $sql);
74 $vrow = pg_fetch_assoc($result);
75 pg_free_result($result);
76 $newversion = $vrow[
'version'] + 1;
79 $sql =
"insert into bucketpool (bucketpool_name, version, active, description) select bucketpool_name, '$newversion', active, description from bucketpool where bucketpool_pk=$bucketpool_pk";
80 $result = pg_query($PG_CONN, $sql);
82 pg_free_result($result);
85 $sql =
"select bucketpool_pk from bucketpool where bucketpool_name='$row[bucketpool_name]' and version='$newversion'";
86 $result = pg_query($PG_CONN, $sql);
88 $row = pg_fetch_assoc($result);
89 pg_free_result($result);
90 $newbucketpool_pk = $row[
'bucketpool_pk'];
93 $sql =
"insert into bucket_def (bucket_name, bucket_color, bucket_reportorder, bucket_evalorder, bucketpool_fk, bucket_type, bucket_regex, bucket_filename, stopon, applies_to) 94 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";
95 $insertresult = pg_query($PG_CONN, $sql);
97 pg_free_result($insertresult);
100 if ($UpdateDefault ==
'on')
102 $sql =
"update users set default_bucketpool_fk='$newbucketpool_pk' where user_pk='$_SESSION[UserId]'";
103 $result = pg_query($PG_CONN, $sql);
105 pg_free_result($result);
108 return $newbucketpool_pk;
127 global $PROJECTSTATEDIR;
133 if (!empty($bucketpool_pk))
136 $newbucketpool_pk = $this->
CloneBucketpool($bucketpool_pk, $UpdateDefault, $msg);
137 $text = _(
"Your new bucketpool_pk is");
138 $this->vars[
'message'] =
"$text $newbucketpool_pk";
142 $V .= _(
"The purpose of this is to facilitate editing an existing bucketpool. Make sure you understand");
143 $V .=
" <a href='http://www.fossology.org/projects/fossology/wiki/Buckets'>";
144 $V .= _(
"Creating Bucket Pools");
146 $V .= _(
"before continuing.");
147 $V .= _(
" It will explain why you should create a new bucketpool rather than edit an old one that has already recorded results.");
149 $V .= _(
"Steps to modify a bucketpool:");
152 $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.");
154 $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.");
156 $V .= _(
"Duplicate any bucket scripts that you defined in $PROJECTSTATEDIR.");
158 $V .= _(
"Manually edit the new bucketpool record, if desired.");
160 $V .= _(
"Manually insert/update/delete the new bucketdef records.");
162 $V .= _(
"Manually insert a new buckets record in the agent table.");
164 $V .= _(
"Queue up the new bucket job in Jobs > Schedule Agents.");
166 $V .= _(
"Use Buckets > Compare to compare the new and old runs. Verify the results.");
168 $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.");
170 $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).");
174 $V .=
"<form method='POST'>";
175 $text = _(
"Choose the bucketpool to duplicate");
181 $text = _(
"Update my default bucketpool");
182 $V .=
"<input type='checkbox' name='updatedefault' checked> $text.";
185 $V .=
"<input type='submit' value='$text'>";
192 $NewPlugin->Initialize();
SelectBucketPool($selected, $active='Y')
Return a select list containing all the active bucketpool's.
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
Output()
User chooses a bucketpool to duplicate from a select list.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
This is the Plugin class. All plugins should:
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.
CloneBucketpool($bucketpool_pk, $UpdateDefault, &$msg)
Clone a bucketpool and its bucketdef records. Increment the bucketpool version.