[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/workflow/inc/ -> class.ui_adminsource.inc.php (source)

   1  <?php
   2  
   3      require_once(dirname(__FILE__) . SEP . 'class.workflow.inc.php');
   4  
   5      class ui_adminsource extends workflow
   6      {
   7  
   8          var $public_functions = array(
   9              'form'    => true,
  10          );
  11  
  12          var $process_manager;
  13  
  14          var $activity_manager;
  15  
  16  		function ui_adminsource()
  17          {
  18              parent::workflow();
  19              
  20                       //regis: acl check
  21              if ( !(($GLOBALS['egw']->acl->check('run',1,'admin')) || ($GLOBALS['egw']->acl->check('admin_workflow',1,'workflow'))) )
  22              {
  23                  $GLOBALS['egw']->common->egw_header();
  24                  echo parse_navbar();
  25                  echo lang('access not permitted');
  26                  $GLOBALS['egw']->log->message('F-Abort, Unauthorized access to workflow.ui_adminsources');
  27                  $GLOBALS['egw']->log->commit();
  28                  $GLOBALS['egw']->common->egw_exit();
  29              }
  30  
  31              $this->process_manager =& CreateObject('workflow.workflow_processmanager');
  32              $this->activity_manager =& CreateObject('workflow.workflow_activitymanager');
  33          }
  34  
  35  		function form()
  36          {
  37              $GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps']['workflow']['title'] . ' - ' . lang('Admin Processes Sources');
  38  
  39              // js function to introduce commands in the textarea
  40              $GLOBALS['egw_info']['flags']['java_script_thirst'] = "<script>
  41  				function setSomeElement(fooel, foo1) {\n
  42                      document.getElementById(fooel).value = document.getElementById(fooel).value + foo1;\n
  43                  }\n
  44              </script>";
  45              $GLOBALS['egw']->common->egw_header();
  46              echo parse_navbar();
  47  
  48              $this->t->set_file('admin_source', 'admin_source.tpl');
  49              $this->t->set_block('admin_source', 'block_select_activity', 'select_activity');
  50  
  51              $activity_id        = (int)get_var('activity_id', 'any', 0);
  52              $switch_to_code        = get_var('switch_to_code', 'POST', false);
  53              $switch_to_tpl        = get_var('switch_to_tpl', 'POST', false);
  54              $source_type        = get_var('source_type', 'POST', 'shared');
  55              $save                = get_var('save', 'POST', false);
  56              $source                = get_var('source', 'POST', false);
  57          
  58              if (!$this->wf_p_id) die(lang('No process indicated'));
  59              $proc_info = $this->process_manager->get_process($this->wf_p_id);
  60  
  61              // fetch activity info
  62              if ($activity_id)
  63              {
  64                  $activity_info = $this->activity_manager->get_activity($activity_id);
  65              }
  66              else
  67              {
  68                  $activity_info = array(
  69                      'wf_is_interactive'        => 'n',
  70                      'wf_normalized_name'    => 'shared',
  71                  );
  72              }
  73              
  74              //do we need to check validity, warning high load on database
  75              $checkvalidity=false;
  76  
  77              // save template and stay in same view
  78              if ($save)
  79              {
  80                  $this->save_source($proc_info['wf_normalized_name'], $activity_info['wf_normalized_name'], $source_type, $source);
  81                  if ($activity_id) 
  82                  {
  83                      $this->activity_manager->compile_activity($this->wf_p_id, $activity_id);
  84                      $errors =&  $this->activity_manager->get_error(true);
  85                      if (count(array_filter($errors))==0)
  86                      {
  87                          $this->message[] = lang('Source saved');
  88                      }
  89                      else
  90                      {
  91                          $this->message[] = lang('They were problems at the compilation of the source:');
  92                          $this->message = array_merge($this->message,$errors);
  93                      }
  94                      $checkvalidity=true;
  95                  }
  96              }
  97              elseif($switch_to_code)
  98              {
  99                  $source_type = 'code';
 100              }
 101              elseif($switch_to_tpl)
 102              {
 103                  $source_type = 'template';
 104              }
 105              elseif($activity_id)
 106              {
 107                  $source_type = 'code';
 108              }
 109              else
 110              {
 111                  $source_type = 'shared';
 112              }
 113  
 114              // fetch source
 115              $data = $this->get_source($proc_info['wf_normalized_name'], $activity_info['wf_normalized_name'], $source_type);
 116              //echo "data: <pre>";print_r($data);echo "</pre>";
 117  
 118              // check process validity and show errors if necessary
 119              if ($checkvalidity) $proc_info['isValid'] = $this->show_errors($this->activity_manager, $error_str);
 120  
 121              // fill proc_bar
 122              $this->t->set_var('proc_bar', $this->fill_proc_bar($proc_info));
 123  
 124              // fill activities select box
 125              // avoid stats queries on roles here with a false parameter
 126              $process_activities = $this->activity_manager->list_activities($this->wf_p_id, 0, -1, 'wf_name__asc', '','',false);
 127              foreach ($process_activities['data'] as $process_activity)
 128              {
 129                  $this->t->set_var(array(
 130                      'activity_id'        => $process_activity['wf_activity_id'],
 131                      'selected_activity'    => ($process_activity['wf_activity_id'] == $activity_id)? 'selected="selected"' : '',
 132                      'activity_name'        => $process_activity['wf_name'],
 133                  ));
 134                  $this->t->parse('select_activity', 'block_select_activity', true);
 135              }
 136  
 137              //collect some messages from used objects
 138              $this->message[] = $this->activity_manager->get_error(false, _DEBUG);
 139              $this->message[] = $this->process_manager->get_error(false, _DEBUG);
 140              
 141              // fill the general variables of the template
 142              $this->t->set_var(array(
 143                  'message'                => implode('<br>', array_filter($this->message)),
 144                  'errors'                => $error_str,
 145                  'form_editsource_action'    => $GLOBALS['egw']->link('/index.php', 'menuaction=workflow.ui_adminsource.form'),
 146                  'p_id'                    => $this->wf_p_id,
 147                  'selected_sharedcode'    => ($activity_id == 0)? 'selected="selected"' : '',
 148                  'source_type'            => $source_type,
 149              ));
 150  
 151              // generate 'template' or 'code' submit button
 152              if ($source_type == 'template')
 153              {
 154                  $this->t->set_var('code_or_tpl_btn', '<input type="submit" name="switch_to_code" value="'. lang('show code') .'" />');
 155              }
 156              elseif ($activity_info['wf_is_interactive'] == 'y')
 157              {
 158                  $this->t->set_var('code_or_tpl_btn', '<input type="submit" name="switch_to_tpl" value="'. lang('show template') .'" />');
 159              }
 160              else
 161              {
 162                  $this->t->set_var('code_or_tpl_btn', '');
 163              }
 164  
 165              $this->show_side_commands($source_type, $activity_info);
 166  
 167              $this->translate_template('admin_source');
 168              
 169              //only now we can insert data, to prevent templating vars used in the source
 170              $this->t->set_block('admin_source', 'block_datas', 'datas');
 171              $this->t->set_var(array('data'    => Htmlspecialchars($data),));
 172              $this->t->parse('datas', 'block_datas', true);
 173              $this->t->pparse('output', 'admin_source');
 174          }
 175  
 176  		function show_side_commands($source_type, $activity_info)
 177          {
 178              if ($source_type == 'template')
 179              {
 180                  $side_commands = lang('template');
 181              }
 182              else
 183              {
 184                  $side_commands = "
 185                      <a  href=\"javascript:setSomeElement('src','". '$instance' ."->setNextUser(\\'\\');');\">". lang('Set next user') ."</a><hr/>
 186                      <a  href=\"javascript:setSomeElement('src','". '$instance' ."->get(\\'\\');');\">". lang('Get property') ."</a><hr/>
 187                      <a  href=\"javascript:setSomeElement('src','". '$instance' ."->set(\\'\\',\\'\\');');\">". lang('Set property') ."</a><hr />";
 188                  if ($activity_info['isInteractive'] == 'y')
 189                  {
 190                      $side_commands .= "
 191                      <a href=\"javascript:setSomeElement('src','". '$instance' ."->complete();');\">". lang('Complete') ."</a><hr/>
 192                      <a href=\"javascript:setSomeElement('src','if(isset(". '$_REQUEST' ."[\\'save\\'])){\n ". ' $instance' ."->complete();\n}');\">". lang('Process form'). "</a><hr/>";
 193                  }
 194                  if ($activity_info['type'] == 'switch')
 195                  {
 196                      $side_commands .= "
 197                          <a href=\"javascript:setSomeElement('src','". '$instance' ."->setNextActivity(\\'\\');');\">". lang('Set Next act') ."</a><hr />              
 198                          <a href=\"javascript:setSomeElement('src','if() {\n  ". '$instance' ."->setNextActivity(\\'\\');\\n}');\">". lang('If:SetNextact') ."</a><hr />
 199                          <a href=\"javascript:setSomeElement('src','switch(". '$instance' ."->get(\\'\\')){\\n  case:\\'\\':\\n  ". '$instance' ."->setNextActivity(\\'\\');\\n  break;\\n}');\">". lang('Switch construct') ."</a><hr />";
 200                  }
 201  
 202              }
 203              $this->t->set_var('side_commands', $side_commands);
 204          }
 205  
 206      }
 207  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7