This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".
The branch, master has been updated
via 2016446c07df5c5fc532f7029c59350c09b19f5b (commit)
from 2cd5cda8b10e1fb1c3937742ab92676441760e46 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=2016446c07df5c5fc532f7029c59350c09b19f5b
commit 2016446c07df5c5fc532f7029c59350c09b19f5b
Author: Franck Villaume <[email protected]>
Date: Mon Dec 26 17:46:15 2016 +0100
artifact display widget: support clone template
diff --git a/src/common/include/Group.class.php
b/src/common/include/Group.class.php
index 7815444..157f6b9 100644
--- a/src/common/include/Group.class.php
+++ b/src/common/include/Group.class.php
@@ -2672,6 +2672,9 @@ class Group extends FFError {
}
}
+ $lm = new WidgetLayoutManager();
+ $lm->createDefaultLayoutForProject($this->getID(),
$template->getID());
+
// second computation to clone fields and workflow
if (forge_get_config('use_tracker')) {
if ($template->usesTracker()) {
@@ -2679,14 +2682,14 @@ class Group extends FFError {
foreach ($oldatf->getArtifactTypes() as
$o) {
$t =
artifactType_get_object($id_mappings['tracker'][$o->getID()]);
$id_mappings['tracker'][$o->getID()] = $t->getID();
-
$t->cloneFieldsFrom($o->getID(), $o->Group->getID(), $id_mappings);
+ $newEFIds =
$t->cloneFieldsFrom($o->getID(), $o->Group->getID(), $id_mappings);
+ if
(forge_get_config('use_tracker_widget_display')) {
+
$lm->createDefaultLayoutForTracker($t->getID(), $o->getID(), $newEFIds);
+ }
}
}
}
- $lm = new WidgetLayoutManager();
- $lm->createDefaultLayoutForProject ($this->getID(),
$template->getID());
-
$params = array();
$params['template'] = $template;
$params['project'] = $this;
diff --git a/src/common/tracker/ArtifactType.class.php
b/src/common/tracker/ArtifactType.class.php
index 107c974..da8156f 100644
--- a/src/common/tracker/ArtifactType.class.php
+++ b/src/common/tracker/ArtifactType.class.php
@@ -952,7 +952,7 @@ class ArtifactType extends FFError {
}
db_commit();
- return true;
+ return $newEFIds;
}
/**
diff --git a/src/common/widget/WidgetLayoutManager.class.php
b/src/common/widget/WidgetLayoutManager.class.php
index 89b2804..30fc41a 100644
--- a/src/common/widget/WidgetLayoutManager.class.php
+++ b/src/common/widget/WidgetLayoutManager.class.php
@@ -222,48 +222,90 @@ class WidgetLayoutManager {
db_commit();
}
- function createDefaultLayoutForTracker($owner_id) {
+ function createDefaultLayoutForTracker($owner_id, $template_id = 0,
$newEFIds = array()) {
db_begin();
$success = true;
- $sql = "INSERT INTO owner_layouts (owner_id, owner_type,
layout_id, is_default) values ($1, $2, $3, $4)";
- if (db_query_params($sql, array($owner_id,
self::OWNER_TYPE_TRACKER, 1, 1))) {
-
- $sql = "INSERT INTO layouts_contents (owner_id,
owner_type, layout_id, column_id, name, rank) VALUES ";
-
- $args[] = "($1, $2, 1, 1, 'trackersummary', 1)";
- $args[] = "($1, $2, 1, 1, 'trackermain', 2)";
- $args[] = "($1, $2, 1, 1, 'trackerdefaultactions', 3)";
- $args[] = "($1, $2, 1, 2, 'trackergeneral', 1)";
- $args[] = "($1, $2, 1, 2, 'trackercomment', 2)";
-
- // owner_id is an atid
- $at = artifactType_get_object($owner_id);
- $extrafields = $at->getExtraFields(array());
- if (count($extrafields) > 0) {
-
+ $notemplate = true;
+ if ($template_id) {
+ $res = db_query_params('SELECT layout_id FROM
owner_layouts WHERE owner_type = $1 AND owner_id = $2',
array(self::OWNER_TYPE_TRACKER, $template_id));
+ if ($res && db_numrows($res) == 1) {
+ $res = db_query_params('INSERT INTO
owner_layouts(layout_id, is_default, owner_id, owner_type)
+ SELECT layout_id, is_default,
$1, owner_type
+ FROM owner_layouts
+ WHERE owner_type = $2
+ AND owner_id = $3',
array($owner_id, self::OWNER_TYPE_TRACKER, $template_id));
+ $notemplate = false;
}
-
- foreach($args as $a) {
- if (!db_query_params($sql.$a,array($owner_id,
self::OWNER_TYPE_TRACKER))) {
- $success = false;
- break;
+ }
+ if ($notemplate) {
+ $res = db_query_params('INSERT INTO owner_layouts
(owner_id, owner_type, layout_id, is_default) values ($1, $2, $3, $4)',
array($owner_id, self::OWNER_TYPE_TRACKER, 1, 1));
+ }
+ if ($res) {
+ if ($notemplate) {
+ $sql = "INSERT INTO layouts_contents (owner_id,
owner_type, layout_id, column_id, name, rank) VALUES ";
+
+ $args[] = "($1, $2, 1, 1, 'trackersummary', 1)";
+ $args[] = "($1, $2, 1, 1, 'trackermain', 2)";
+ $args[] = "($1, $2, 1, 1,
'trackerdefaultactions', 3)";
+ $args[] = "($1, $2, 1, 2, 'trackergeneral', 1)";
+ $args[] = "($1, $2, 1, 2, 'trackercomment', 2)";
+
+ foreach($args as $a) {
+ if
(!db_query_params($sql.$a,array($owner_id, self::OWNER_TYPE_TRACKER))) {
+ $success = false;
+ break;
+ }
}
- }
- if (count($extrafields) > 0) {
- $res = db_query_params('INSERT INTO
artifact_display_widget (owner_id, title, cols) VALUES ($1, $2, $3)',
array($owner_id, _('Default ExtraField 2-columns Widget'), 2));
- $content_id = db_insertid($res,
'artifact_display_widget', 'id');
- $row_id = 1;
- $column_id = 1;
- foreach ($extrafields as $key => $extrafield) {
- $column_id = ($key % 2) + 1; // 1 or 2
- if ($column_id == 2) {
- $row_id++;
+ // owner_id is an atid
+ $at = artifactType_get_object($owner_id);
+ $extrafields = $at->getExtraFields(array());
+ if (count($extrafields) > 0) {
+ $res = db_query_params('INSERT INTO
artifact_display_widget (owner_id, title, cols) VALUES ($1, $2, $3)',
array($owner_id, _('Default ExtraField 2-columns Widget'), 2));
+ $content_id = db_insertid($res,
'artifact_display_widget', 'id');
+ $row_id = 1;
+ $column_id = 1;
+ foreach ($extrafields as $key =>
$extrafield) {
+ $column_id = ($key % 2) + 1; //
1 or 2
+ if ($column_id == 2) {
+ $row_id++;
+ }
+ db_query_params('INSERT INTO
artifact_display_widget_field (id, field_id, column_id, row_id) VALUES ($1, $2,
$3, $4)', array($content_id, $extrafield['extra_field_id'], $column_id,
$row_id));
+ }
+ db_query_params('INSERT INTO
layouts_contents (owner_id, owner_type, layout_id, column_id, name, rank,
content_id) VALUES ($1, $2, 1, 2, $3, 3, $4)',
+ array($owner_id,
self::OWNER_TYPE_TRACKER, 'trackercontent', $content_id));
+ }
+ } else {
+ $sql = "SELECT layout_id, column_id, name,
rank, is_minimized, is_removed, display_preferences, content_id
+ FROM layouts_contents
+ WHERE owner_type = $1
+ AND owner_id = $2
+ ";
+ if ($req = db_query_params($sql,array(
self::OWNER_TYPE_TRACKER,$template_id))) {
+ while ($data = db_fetch_array($req)) {
+ $content_id = 0;
+ if ($data['name'] ==
'trackercontent') {
+ $res =
db_query_params('SELECT title, cols FROM artifact_display_widget WHERE owner_id
= $1 AND id = $2', array($template_id, $data['content_id']));
+ if ($res &&
db_numrows($res) > 0) {
+ $arr =
db_fetch_array($res);
+
db_query_params('INSERT INTO artifact_display_widget (owner_id, title, cols)
VALUES ($1, $2, $3)', array($owner_id, $arr['title'], $arr['cols']));
+ $content_id =
db_insertid($res, 'artifact_display_widget', 'id');
+ $res2 =
db_query_params('SELECT field_id, column_id, row_id FROM
artifact_display_widget_field WHERE id = $1', array($data['content_id']));
+ if ($res2 &&
db_numrows($res2) > 0) {
+ while
($arr2 = db_fetch_array($res2)) {
+
db_query_params('INSERT INTO artifact_display_widget_field (id, field_id,
column_id, row_id) VALUES ($1, $2, $3, $4)',
+
array($content_id, $newEFIds[$arr2['field_id']],
$arr2['column_id'], $arr2['row_id']));
+
echo db_error();
+ }
+ }
+ }
+ }
+ $sql = 'INSERT INTO
layouts_contents (owner_id, owner_type, content_id, layout_id, column_id, name,
rank, is_minimized, is_removed, display_preferences)
+ VALUES ($1, $2, $3, $4,
$5, $6, $7, $8, $9, $10)';
+ db_query_params($sql,
array($owner_id, self::OWNER_TYPE_TRACKER, $content_id, $data['layout_id'],
$data['column_id'], $data['name'], $data['rank'], $data['is_minimized'],
$data['is_removed'], $data['display_preferences']));
+ echo db_error();
}
- db_query_params('INSERT INTO
artifact_display_widget_field (id, field_id, column_id, row_id) VALUES ($1, $2,
$3, $4)', array($content_id, $extrafield['extra_field_id'], $column_id,
$row_id));
}
- db_query_params('INSERT INTO layouts_contents
(owner_id, owner_type, layout_id, column_id, name, rank, content_id) VALUES
($1, $2, 1, 2, $3, 3, $4)',
- array($owner_id,
self::OWNER_TYPE_TRACKER, 'trackercontent', $content_id));
}
} else {
$success = false;
-----------------------------------------------------------------------
Summary of changes:
src/common/include/Group.class.php | 11 ++-
src/common/tracker/ArtifactType.class.php | 2 +-
src/common/widget/WidgetLayoutManager.class.php | 112 ++++++++++++++++--------
3 files changed, 85 insertions(+), 40 deletions(-)
hooks/post-receive
--
FusionForge
_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits