Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
report_edit_fns.inc
1 <?php
17 require_once SQ_CORE_PACKAGE_PATH.'/page/page_edit_fns.inc';
18 
31 {
32 
33 
38  function __construct()
39  {
40  parent::__construct();
41  $this->static_screens['details']['lock_type'] = 'content';
42 
43  }//end constructor
44 
45 
56  public function paintRegenerate(Report $asset, Backend_Outputter $o, $prefix)
57  {
58  $report_path = $asset->data_path.'/report.xml';
59  if (!is_file($report_path)) {
60  $o->note(translate('report_not_generated'));
61  } else {
62  $o->note(translate('core_report_last_generated', $asset->attr('generated_date'), $asset->attr('generated_user')));
63  }
64 
65  if ($asset->writeAccess('attributes')) {
66  check_box($prefix.'_regenerate');
67  label(translate('core_generate_report'), $prefix.'_regenerate');
68  return TRUE;
69  }
70  return FALSE;
71 
72  }//end paintRegenerate()
73 
74 
85  public function processRegenerate(Report $asset, Backend_Outputter $o, $prefix)
86  {
87  if (!isset($_POST[$prefix.'_regenerate']) || !$_POST[$prefix.'_regenerate']) {
88  return FALSE;
89  }
90 
91  $user = $GLOBALS['SQ_SYSTEM']->user;
92  $hh = $GLOBALS['SQ_SYSTEM']->getHipoHerder();
93  $vars = Array(
94  'assetid' => $asset->id,
95  'userid' => $user->id,
96  'generated_date' => date('F j, Y, g:i a'),
97  );
98  $hh->queueHipo('hipo_job_generate_report', $vars);
99 
100  if (!$asset->writeAccess('links')) return FALSE;
101 
102  $asset->setAttrValue('generated_date', date('F j, Y, g:i a'));
103  $asset->setAttrValue('generated_user', $user->name.' (#'.$user->id.')');
104 
105  return TRUE;
106 
107  }//end processRegenerate()
108 
109 
120  public function paintRootNode(Report $asset, Backend_Outputter $o, $prefix)
121  {
122  $root_link = $GLOBALS['SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE, '', FALSE, 'root');
123  $write_access = $asset->writeAccess('links');
124 
125  if (!$write_access) {
126  if (!empty($root_link)) {
127  echo get_asset_tag_line($root_link['minorid']);
128  } else {
129  echo translate('core_no_selected_root_node');
130  }
131  } else {
132  asset_finder($prefix.'_rootid', (!empty($root_link)) ? $root_link['minorid'] : '');
133  }
134 
135  return $write_access;
136 
137  }//end paintRootNode()
138 
139 
150  public function processRootNode(Report $asset, Backend_Outputter $o, $prefix)
151  {
152  if (!isset($_POST[$prefix.'_rootid']['assetid']) || (isset($asset->_tmp['reverting_to_system_version']) && $asset->_tmp['reverting_to_system_version']) ) {
153  return FALSE;
154  }
155  if (!$asset->writeAccess('links')) return FALSE;
156 
157  $new_root = $_POST[$prefix.'_rootid']['assetid'];
158 
159  // getting existing root link
160  $root_link = $GLOBALS['SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE, '', FALSE, 'root');
161 
162  // dont process anything if the root node has not changed
163  if (!empty($root_link) && $root_link['minorid'] == $new_root) {
164  return FALSE;
165  }
166 
167  $ok = TRUE;
168 
169  $GLOBALS['SQ_SYSTEM']->changeDatabaseConnection('db2');
170  $GLOBALS['SQ_SYSTEM']->doTransaction('BEGIN');
171 
172  // deleting old root link if any found...
173  if (!empty($root_link) && !$GLOBALS['SQ_SYSTEM']->am->deleteAssetLink($root_link['linkid'])) {
174  $ok = FALSE;
175  } else if ($new_root) {
176  $root = $GLOBALS['SQ_SYSTEM']->am->getAsset($new_root);
177  if (!is_null($root)) {
178  if (!$asset->createLink($root, SQ_LINK_NOTICE, 'root')) {
179  $ok = FALSE;
180  trigger_localised_error('CORE0029', E_USER_WARNING, $root->name);
181  }
182  }
183  }
184 
185  if ($ok) {
186  $GLOBALS['SQ_SYSTEM']->doTransaction('COMMIT');
187  } else {
188  $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
189  }
190 
191  $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
192  return $ok;
193 
194  }//end processRootNode()
195 
196 
205  public function getRootAssetid(Report $asset)
206  {
207  $root_link = $GLOBALS['SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE, '', FALSE, 'root');
208  if (!empty($root_link)) return $root_link['minorid'];
209 
210  // the whole system
211  return '1';
212 
213  }//end getRootAssetid()
214 
215 
226  public function paintReport(Report $asset, Backend_Outputter $o, $prefix)
227  {
228  echo translate('core_no_visual_report');
229  return FALSE;
230 
231  }//end paintReport()
232 
233 
244  public function processReport(Report $asset, Backend_Outputter $o, $prefix)
245  {
246  return FALSE;
247 
248  }//end processReport()
249 
250 
262  public function generateReport(HIPO_Job $job, Array &$step_data, $prefix)
263  {
264  trigger_localised_error('CORE0079', E_USER_WARNING);
265  $step_data['percent_done'] = 100;
266  $step_data['complete'] = TRUE;
267  return TRUE;
268 
269  }//end generateReport()
270 
271 
272 }//end class
273 
274 ?>