18 require_once SQ_INCLUDE_PATH.
'/asset_management.inc';
40 Asset_Management::__construct($pm);
47 'description' =>
'Name of the workflow stream',
73 }
catch (Exception $e) {
74 pre_echo($e->getMessage());
79 $failed_schema_name = NULL;
80 $failed_schemaid = NULL;
84 if ($GLOBALS[
'SQ_SYSTEM']->am->installed(
'workflow_schema') === TRUE) {
85 $GLOBALS[
'SQ_SYSTEM']->changeDatabaseConnection(
'db2');
86 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'BEGIN');
88 $schemaids = $GLOBALS[
'SQ_SYSTEM']->am->getTypeAssetids(
'workflow_schema');
90 if (count($schemaids) > 0) {
91 pre_echo(
'Upgrading '.count($schemaids).
' Workflow Schema asset(s) to use Workflow Stream...');
93 foreach ($schemaids as $schemaid) {
94 $schema = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($schemaid);
96 $new_stream->setAttrValue(
'name',
'Default Stream');
97 echo str_pad(
'Creating new workflow stream for schema #'.$schemaid, 60);
100 'link_type' => SQ_LINK_TYPE_2,
101 'value' =>
'default_stream',
102 'is_exclusive' => TRUE,
103 'is_dependant' => FALSE,
106 if (!$new_stream->create($link_info)) {
107 echo
'[ FAIL ]'.
"\n";
109 $failed_schema_name = $schema->name;
110 $failed_schemaid = $schema->id;
113 echo
'[ OK ] Id: #'.$new_stream->id.
"\n";
117 $step_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($schemaid, SQ_LINK_TYPE_2,
'workflow_step');
118 foreach ($step_links as $step_link) {
119 echo str_pad(
'Re-linking step #'.$step_link[
'minorid'].
' to stream', 60);
120 if ($GLOBALS[
'SQ_SYSTEM']->am->moveLink($step_link[
'linkid'], $new_stream->id, SQ_LINK_TYPE_2, $step_link[
'sort_order']) === 0) {
121 echo
'[ FAIL ]'.
"\n";
123 $failed_schema_name = $schema->name;
124 $failed_schemaid = $schema->id;
131 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($schema);
138 pre_echo(
'Finished upgrading '.count($schemaids).
' Workflow Schema asset(s)');
139 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'COMMIT');
141 pre_echo(
'FAILED upgrading '.count($schemaids).
' Workflow Schema asset(s) - failure at schema "'.$failed_schemaid.
'" (Id: #'.$failed_schemaid.
')');
142 $GLOBALS[
'SQ_SYSTEM']->doTransaction(
'ROLLBACK');
144 $GLOBALS[
'SQ_SYSTEM']->restoreDatabaseConnection();
161 'css/workflow_stream_edit_fns.css',
162 'js/workflow_stream_edit_fns.js',
163 'files/wf_drag_handle.png',