Changeset 3167


Ignore:
Timestamp:
08/17/10 16:17:12 (14 years ago)
Author:
viani
Message:

Ticket #1135 - Merged r1990:3166 from /trunk/workflow into /branches/2.2/workflow

Location:
branches/2.2/workflow
Files:
5 deleted
154 edited
11 copied

Legend:

Unmodified
Added
Removed
  • branches/2.2/workflow/controller.php

    r1484 r3167  
    1616        { 
    1717                require_once dirname(__FILE__) . '/inc/common.inc.php'; 
    18                 $GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareEnvironment(); 
     18                Factory::getInstance('WorkflowMacro')->prepareEnvironment(); 
    1919        } 
    2020 
  • branches/2.2/workflow/doc/change_log.txt

    r1712 r3167  
    1515arifragoso is Ari Fragoso de Medeiros Junior 
    1616hermespinheiro is Hermes Pinheiro Neto 
    17  
    18 Os registros estão listados em ordem decrescente de data de realização. 
     17pedroerp is Pedro Eugênio Rocha Pedreira 
     18fabianok is Fabiano Sardenberg Kuss 
     19pereira.jair is Jair Gonçalves Pereira Junior 
     20adeildosantos is Adeildo Fernandes dos Santos 
     21 
     22[2.2.000] 
     23 
     24        #1164 - Substituição de require por require_once na classe run_activity (viani) 
     25        #1162 - Otimização da query do método getChildren da classe wf_instance (fabianok/gbisotto) 
     26        #1146 - Inclusão de parâmetro no método getOrganizationAreas da classe wf_orgchart para selecionar áreas ativas/inativas (adeildosantos) 
     27        #1143 - Refinição da função apache_request_headers, caso não exista no ambiente apache-php (viani) 
     28        #1139 - Modificação na função wf_upload_file para possibilitar a remoção de arquivos (fabianok) 
     29        #1131 - Modificação na exportação de processos para permitir templates com nomes aleatórios (viani) 
     30        #1120 - Moficado plugin wf_select_ldap_users para retornar atributos adicionais (adeildosantos) 
     31        #1119 - Implementado método getSupervisorAreas em class.wf_orgchart.php (pereira.jair) 
     32        #1089 - Melhoria em query sql na inserção de instancias. (fabianok) 
     33        #1082 - Removida coluna wf_parent_activity_id da tabela egw_wf_interinstance_relations (asaikawa) 
     34        #1080 - Modificada string (excluído) para (inativo) quando um registro de usuário no cache não existe mais no ldap. (viani) 
     35        #1069 - Inclusão de log de tempo de execução de atividades. (gbisotto/rufino) 
     36        #1004 - Melhorado o método getEmployeeCostCenterID para que retorne o id da área caso não exista o id do centro de custo do funcionário. (gbisotto) 
     37        #946 - Possibilitar que o plugin smarty wf_autocomplete_input atualize a lista de seleção a cada tecla pressionada. (asaikawa) 
     38        #944 - Alteração na função javascript get_form_fields para retornar em array os elementos identificados com '[]'. (asaikawa) 
     39        #943 - Criar na classe wf_location, uma consulta de cidades pelo início do nome. (asaikawa) 
     40        #942 - Ajustar a classe wf_location para considerar a nova coluna que identifica se o registro é distrito. (asaikawa) 
     41        #935 - Incluída opção para listar funcionários em ordem alfabética geral na impressão do organograma. (pedroerp) 
     42        #928 - Incluída busca por telefone no organograma. (pedroerp) 
     43        #916 - Criada nova variável wf_webserver_url no contexto de execução dos processos. (pedroerp) 
     44        #873 - Incluída verificação de existência do diretório de arquivos do processo, antes de renderizar a aba processos (asaikawa) 
     45        #871 - Incluída opção para listar usuários ocultos na janela de seleção de usuários (asaikawa) 
     46        #870 - Correção de bug no parâmetro print_mode da classe run_activity. (pedroerp) 
     47        #869 - Indentificação do titular e substituro de áreas do organograma. (pedroerp) 
     48        #868 - Correção da altura das janelas de edição do organograma. (pedroerp) 
     49        #865 - Incluído o uid do usuário na lista de mapeamentos de perfis (asaikawa) 
     50        #863 - Remoção do operador & nas instanciações de objeto new classe (asaikawa) 
     51        #609 - Reconstrução da classe factory (pedroerp/rufino) 
     52        #446 - Depreciação de métodos (asaikawa) 
     53        #441 - Inclusão do período de substituição de chefia no organograma. (pedroerp) 
    1954 
    2055[2.1.000] 
    2156 
     57        #989 - Compatibilização do workflow com os novos temas do Expresso. (rodsouza) 
     58        #951 - Correção de bug na verificação de sessão das chamadas ajax do workflow. (viani) 
    2259        #794 - Correção de bug de sintaxe na classe Workflow_WfSecurity. (hermespinheiro). 
    2360        #792 - Modificado o atribuito de usuário padrão de uma atividade para aceitar também um perfil padrão. (rufino) 
     
    2764        #658 - Correção no alinhamento dos ícones de aplicações externas. Ao redimensionar a janela, o ícones são reorganizados. (gbisotto) 
    2865        #657 - Correção no alinhamento do menu de atividades dos processos. Ao redimensionar a janela, os menus são reorganizados. (gbisotto). 
     66        #643 - Criação do método createNewInstance na classe JobBase, que possibilita iniciar uma instância do processo a partir de um job. (rufino) 
    2967        #639 - Inclusão de cor em destaque ao passar o mouse sobre uma linha nas visualizações do organograma. (rodsouza) 
    3068        #638 - Mudança na query de busca do organograma para pesquisar também por áreas. (rodsouza) 
    31         #643 - Criação do método createNewInstance na classe JobBase, que possibilita iniciar uma instância do processo a partir de um job. (rufino) 
     69        #637 - Inclusão de click-to-call no organograma e outras melhorias na interface. (rodsouza) 
     70        #603 - Remoção do design pattern observer da engine do workflow, por inutilidade. (gbisotto) 
    3271        #442 - Criação do plugin wf_autocomplete_input, para listar com autocomplete o resultado de uma busca ajax. (rufino) 
    33         #637 - Inclusão de click-to-call no organograma e outras melhorias na interface. (rodsouza) 
     72 
     73[2.0.004] 
     74 
     75        #1045 - Corrigido bug de sessão nas chamadas ajax de processos. (viani) 
     76        #951 - Corrigido bug na verificação de sessão ativa nas chamadas ajax de processos. (viani) 
     77 
     78[2.0.003] 
     79 
     80        #899 - Inclusão de inserts faltantes no arquivo default_records, além de atualização de estrutura de tabelas do organograma. (pedroerp) 
     81 
     82[2.0.001] 
     83 
     84        #671 - Inclusão do arquivo header.session.inc.php para a verificação de segurança de sessão. (asaikawa) 
    3485 
    3586[2.0.000] 
    3687 
    37         * Correção de bug no método getByUser da classe wf_instance. (hermespinheiro) 
    38         * Melhorias no organograma, com novas visualizações nas interfaces. (rodsouza) 
     88        #641 - Correção de bug no método getByUser da classe wf_instance. (hermespinheiro) 
     89        #589 - Melhorias no organograma, com novas visualizações nas interfaces. (rodsouza) 
     90        #439 - Redução do tempo de carga dos funcionários de uma área no organograma (rodsouza) 
    3991 
    4092[1.8.05.000] 
  • branches/2.2/workflow/inc/class.CachedLDAP.inc.php

    r1310 r3167  
    9797 
    9898                /* load the information and establish a connection */ 
    99                 $tmpLDAP = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     99                $tmpLDAP =& Factory::getInstance('WorkflowLDAP'); 
    100100                $this->userContext  = $tmpLDAP->getUserContext(); 
    101101                $this->groupContext = $tmpLDAP->getGroupContext(); 
    102                 $this->dataSource = &$GLOBALS['workflow']['workflowObjects']->getLDAP(); 
     102                $this->dataSource =& Factory::getInstance('WorkflowObjects')->getLDAP(); 
    103103        } 
    104104 
     
    115115 
    116116                /* establish a connection */ 
    117                 $this->DBLink = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID; 
     117                $this->DBLink =& Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 
    118118        } 
    119119 
  • branches/2.2/workflow/inc/class.JobRunner.inc.php

    r795 r3167  
    4343                $this->parameters = unserialize(base64_decode($parameters)); 
    4444                $this->parameters['currentDate'] = new DateTime($this->parameters['currentDate']); 
    45                 $this->jobManager = &$GLOBALS['workflow']['factory']->getInstance('WorkflowJobManager'); 
     45                $this->jobManager =& Factory::getInstance('WorkflowJobManager'); 
    4646        } 
    4747 
     
    6666        { 
    6767                /* activate the security policy */ 
    68                 $GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->enableSecurityPolicy(); 
     68                Factory::getInstance('WorkflowSecurity')->enableSecurityPolicy(); 
     69 
     70                /** 
     71                 * Since all jobs must run in process mode, e. g. it's user code, 
     72                 * we must enable the security. 
     73                 */ 
     74                Security::enable(); 
    6975 
    7076                if (!file_exists($this->parameters['file'])) 
     
    94100 
    95101require_once 'common.inc.php'; 
    96 $GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareEnvironment(); 
     102Factory::getInstance('WorkflowMacro')->prepareEnvironment(); 
    97103 
    98 $jobRunner = new JobRunner($argv[1]); 
     104$jobRunner = &Factory::newInstance('JobRunner', $argv[1]); 
    99105$jobRunner->run(); 
    100106?> 
  • branches/2.2/workflow/inc/class.JobScheduler.inc.php

    r795 r3167  
    1111 
    1212require_once 'jobs/class.JobEnum.inc.php'; 
    13 require_once 'jobs/class.AbsoluteDate.inc.php'; 
    14 require_once 'jobs/class.WeekDate.inc.php'; 
    15 require_once 'jobs/class.RelativeDate.inc.php'; 
    1613 
    1714/** 
     
    5754        { 
    5855                $this->currentDate = new DateTime(date('Y-n-j G:i:00')); 
    59                 $this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID; 
    60                 $this->jobManager = &$GLOBALS['workflow']['factory']->getInstance('WorkflowJobManager'); 
     56                $this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 
     57                $this->jobManager = &Factory::getInstance('WorkflowJobManager'); 
    6158        } 
    6259 
     
    7673                { 
    7774                        case DateType::ABSOLUTE_DATE: 
    78                                 $object = new AbsoluteDate($startDate, $interval); 
     75                                $object = &Factory::getInstance('AbsoluteDate', $startDate, $interval); 
    7976                                break; 
    8077 
    8178                        case DateType::WEEK_DATE: 
    82                                 $object = new WeekDate($startDate, $interval); 
     79                                $object = &Factory::getInstance('WeekDate', $startDate, $interval); 
    8380                                $object->setWeekDays($record['week_days']); 
    8481                                break; 
    8582 
    8683                        case DateType::RELATIVE_DATE: 
    87                                 $object = new RelativeDate($startDate, $interval); 
     84                                $object = &Factory::getInstance('RelativeDate', $startDate, $interval); 
    8885                                $object->setOffset($record['month_offset']); 
    8986                                break; 
     
    171168                $previousDir = getcwd(); 
    172169                chdir(GALAXIA_LIBRARY . '/../'); 
    173                 $output = $GLOBALS['workflow']['factory']->newInstance('Thread', 'class.JobRunner.inc.php "' . $parameters . '"'); 
     170                $output = Factory::newInstance('Thread', 'class.JobRunner.inc.php "' . $parameters . '"'); 
    174171                chdir($previousDir); 
    175172                return $output; 
     
    192189{ 
    193190        require_once 'common.inc.php'; 
    194         $GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareEnvironment(); 
     191        Factory::getInstance('WorkflowMacro')->prepareEnvironment(); 
    195192 
    196         $job = new JobScheduler(); 
     193        $job = Factory::newInstance('JobScheduler'); 
    197194        $job->run(); 
    198195} 
  • branches/2.2/workflow/inc/class.Logger.inc.php

    r900 r3167  
    8080        { 
    8181 
    82                 $this->db =& $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID; 
     82                $this->db =& Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID; 
    8383 
    8484                if(!empty($curProcessName)){ 
  • branches/2.2/workflow/inc/class.ResourcesRedirector.inc.php

    r795 r3167  
    5454                if (!isset($_SESSION['workflow']['ResourcesRedirector'][$this->pid])) 
    5555                { 
    56                         $result = $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID->query('SELECT wf_normalized_name FROM egw_wf_processes WHERE wf_p_id = ?', array($this->pid)); 
     56                        $result = Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID->query('SELECT wf_normalized_name FROM egw_wf_processes WHERE wf_p_id = ?', array($this->pid)); 
    5757                        if ($result->numRows() != 1) 
    5858                                return; 
     
    9494                                { 
    9595                                        /* em último caso, tenta buscar a informação em banco de dados */ 
    96                                         $result = $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir')); 
     96                                        $result = Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir')); 
    9797                                        if (empty($result)) 
    9898                                                return; 
  • branches/2.2/workflow/inc/class.TemplateServer.inc.php

    r795 r3167  
    9999                                else 
    100100                                { 
    101                                         $GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareEnvironment(); 
     101                                        Factory::getInstance('WorkflowMacro')->prepareEnvironment(); 
    102102                                        if (!isset($GLOBALS['phpgw_info']['login_template_set'])) 
    103103                                                return false; 
     
    131131                                { 
    132132                                        /* se não for encontrado em nenhuma variável de ambiente, tenta carregar do banco de dados */ 
    133                                         $webServerURL = (string) $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID->GetOne('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'webserver_url')); 
     133                                        $webServerURL = (string) Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID->GetOne('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'webserver_url')); 
    134134                                        $this->WEB_WORKFLOW_BASE = str_replace('//', '/', "{$webServerURL}/workflow"); 
    135135                                } 
  • branches/2.2/workflow/inc/class.UserPictureProvider.inc.php

    r795 r3167  
    114114                                        /* em último caso, tenta buscar a informação em banco de dados */ 
    115115                                        /* prepara o ambiente para a carga de informações sobre o banco de dados */ 
    116                                         $result = $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir')); 
     116                                        $result = Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir')); 
    117117                                        if (empty($result)) 
    118118                                                return; 
     
    141141                                mkdir($baseDirectory, 0770, true); 
    142142 
    143                         $contents = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getUserPicture($this->userID); 
     143                        $contents = Factory::getInstance('WorkflowLDAP')->getUserPicture($this->userID); 
    144144                        $success = true; 
    145145                        if ($contents !== false) 
     
    165165                } 
    166166 
    167                 $GLOBALS['workflow']['factory']->getInstance('ResourcesRedirector')->show($filename); 
     167                Factory::getInstance('ResourcesRedirector')->show($filename); 
    168168        } 
    169169} 
  • branches/2.2/workflow/inc/class.WorkflowJobManager.inc.php

    r795 r3167  
    1616        public function WorkflowJobManager() 
    1717        { 
    18                 parent::JobManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     18                parent::JobManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    1919        } 
    2020} 
  • branches/2.2/workflow/inc/class.WorkflowLDAP.inc.php

    r795 r3167  
    5050        function WorkflowLDAP() 
    5151        { 
    52                 $this->dataSource = &$GLOBALS['workflow']['workflowObjects']->getLDAP(); 
     52                $this->dataSource =& Factory::getInstance('WorkflowObjects')->getLDAP(); 
    5353 
    5454                /* get the required parameters */ 
     
    377377         * @access public 
    378378         */ 
    379         function getUsers($context) 
    380         { 
    381                 $filter = '(&(phpgwaccounttype=u)(!(phpgwAccountVisible=-1)))'; 
     379        function getUsers($context, $onlyVisibleAccounts = true) 
     380        { 
     381                $filter = '(phpgwaccounttype=u)'; 
     382                if($onlyVisibleAccounts) 
     383                        $filter = '(&' . $filter . '(!(phpgwAccountVisible=-1)))'; 
     384 
    382385                $elements = array('uidnumber', 'cn', 'mail'); 
    383386                return $this->getEntities($context, $filter, $elements, 'u', false); 
     
    561564         * @access public 
    562565         */ 
    563         function search($searchTerm, $includeUsers = true, $includeGroups = false, $includeLists = false, $context = null) 
     566        function search($searchTerm, $includeUsers = true, $includeGroups = false, $includeLists = false, $context = null, $onlyVisibleAccounts = true) 
    564567        { 
    565568                if (!($includeUsers || $includeGroups || $includeLists)) 
     
    586589                        $entityFilter = $entityFilter[0]; 
    587590 
    588                 $filter = "(&{$entityFilter}(cn={$searchTerm})(!(phpgwAccountVisible=-1)))"; 
     591                if($onlyVisibleAccounts) 
     592                        $filter = "(&{$entityFilter}(cn={$searchTerm})(!(phpgwAccountVisible=-1)))"; 
     593                else 
     594                        $filter = "(&{$entityFilter}(cn={$searchTerm}))"; 
     595 
    589596                $resourceIdentifier = ldap_search($this->dataSource, $context, $filter, array('cn', 'uidnumber', 'gidnumber', 'phpgwaccounttype', 'mail')); 
    590597                ldap_sort($this->dataSource, $resourceIdentifier, 'cn'); 
  • branches/2.2/workflow/inc/class.WorkflowMacro.inc.php

    r795 r3167  
    4040                require dirname(__FILE__) . '/../setup/setup.inc.php'; /* DO NOT USE require_once */ 
    4141                $GLOBALS['phpgw_info']['apps']['workflow'] = $setup_info['workflow']; 
    42                 $row = $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir'))->fetchRow(); 
     42                $row = Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID->query('SELECT config_value FROM phpgw_config WHERE config_app = ? AND config_name = ?', array('phpgwapi', 'files_dir'))->fetchRow(); 
    4343                $_SESSION['phpgw_info']['workflow']['vfs_basedir'] = ($row !== false) ? $row['config_value'] : '/home/expressolivre'; 
    4444                $_SESSION['phpgw_info']['workflow']['phpgw_api_inc'] = PHPGW_API_INC; 
     
    4848                require_once PHPGW_API_INC . '/functions.inc.php'; 
    4949                require_once 'engine/class.ajax_config.inc.php'; 
    50                 require_once 'engine/class.ajax_ldap.inc.php'; 
    5150                require_once 'engine/config.ajax.inc.php'; 
    52                 $GLOBALS['ajax']->ldap = new ajax_ldap(); 
     51                $GLOBALS['ajax']->ldap = &Factory::getInstance('ajax_ldap'); 
    5352 
    5453                /* definição de algumas constantes */ 
     
    6463        public function prepareProcessEnvironment($processID) 
    6564        { 
    66                 require_once GALAXIA_LIBRARY . '/src/common/WfRuntime.php'; 
    6765                require_once PHPGW_SERVER_ROOT . '/workflow/inc/local/functions/local.functions.php'; 
    6866 
    69                 $runtime = new WfRuntime($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     67                $runtime = &Factory::getInstance('WfRuntime'); 
    7068                $runtime->loadProcess($processID); 
    7169 
  • branches/2.2/workflow/inc/class.WorkflowObjects.inc.php

    r795 r3167  
    8787                        { 
    8888                                /* connect to the database */ 
    89                                 $this->cache['DBGalaxia'] = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $GLOBALS['workflow']['factory']->newForeignInstance('phpgwapi', 'db')); 
     89                                $this->cache['DBGalaxia'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); 
    9090                                $this->cache['DBGalaxia']->disconnect(); /* for some reason it won't connect to the desired database unless we disconnect it first */ 
    9191                                $this->cache['DBGalaxia']->Halt_On_Error = 'no'; 
     
    9898                                        $dbConfigValues['workflow_database_type'] 
    9999                                ); 
    100                                 $GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBGalaxia']); 
    101                                 $this->cache['DBGalaxia']->Link_ID = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $this->cache['DBGalaxia']->Link_ID); 
     100                                Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBGalaxia']); 
     101                                $this->cache['DBGalaxia']->Link_ID = Factory::newInstance('WorkflowWatcher', $this->cache['DBGalaxia']->Link_ID); 
    102102                        } 
    103103                        else 
     
    128128                        if (!isset($connectionInfo['db_name'])) 
    129129                        { 
    130                                 $GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareEnvironment(); 
     130                                Factory::getInstance('WorkflowMacro')->prepareEnvironment(); 
    131131                                if (isset($GLOBALS['phpgw_info']['server'])) 
    132132                                        $connectionInfo = $GLOBALS['phpgw_info']['server']; 
     
    136136 
    137137                        /* connect to the database */ 
    138                         $this->cache['DBExpresso'] = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $GLOBALS['workflow']['factory']->newForeignInstance('phpgwapi', 'db')); 
     138                        $this->cache['DBExpresso'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); 
    139139                        $this->cache['DBExpresso']->disconnect(); /* for some reason it won't connect to the desired database unless we disconnect it first */ 
    140140                        $this->cache['DBExpresso']->Halt_On_Error = 'no'; 
     
    147147                                $connectionInfo['db_type'] 
    148148                        ); 
    149                         $GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBExpresso']); 
    150                         $this->cache['DBExpresso']->Link_ID = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $this->cache['DBExpresso']->Link_ID); 
     149                        Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBExpresso']); 
     150                        $this->cache['DBExpresso']->Link_ID = Factory::newInstance('WorkflowWatcher', $this->cache['DBExpresso']->Link_ID); 
    151151                } 
    152152 
     
    177177 
    178178                        /* connect to the database */ 
    179                         $this->cache['DBWorkflow'] = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $GLOBALS['workflow']['factory']->newForeignInstance('phpgwapi', 'db')); 
     179                        $this->cache['DBWorkflow'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); 
    180180                        $this->cache['DBWorkflow']->disconnect(); /* for some reason it won't connect to the desired database unless we disconnect it first */ 
    181181                        $this->cache['DBWorkflow']->Halt_On_Error = 'no'; 
     
    188188                                $dbConfigValues['database_type'] 
    189189                        ); 
    190                         $GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBWorkflow']); 
    191                         $this->cache['DBWorkflow']->Link_ID = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $this->cache['DBWorkflow']->Link_ID); 
     190                        Factory::getInstance('WorkflowSecurity')->removeSensitiveInformationFromDatabaseObject($this->cache['DBWorkflow']); 
     191                        $this->cache['DBWorkflow']->Link_ID = Factory::newInstance('WorkflowWatcher', $this->cache['DBWorkflow']->Link_ID); 
    192192                } 
    193193 
  • branches/2.2/workflow/inc/class.WorkflowSecurity.inc.php

    r795 r3167  
    5151        { 
    5252                /* garante que o objeto de DataBase do Expresso estará disponível */ 
    53                 $GLOBALS['workflow']['workflowObjects']->getDBExpresso(); 
     53                Factory::getInstance('WorkflowObjects')->getDBExpresso(); 
    5454        } 
    5555 
     
    7777                                continue; 
    7878                        $this->removeSensitiveInformationFromDatabaseObject($variable); 
    79                         $variable = $GLOBALS['workflow']['factory']->newInstance('WorkflowWatcher', $variable); 
     79                        $variable = Factory::newInstance('WorkflowWatcher', $variable); 
    8080                } 
    8181        } 
  • branches/2.2/workflow/inc/class.WorkflowUtils.inc.php

    r795 r3167  
    11<?php 
     2        require_once 'common.inc.php'; 
     3 
    24        //set here the global DEBUG level which is actually 0 (nothing) or 1 (all) 
    35        if (!defined('_DEBUG')) define('_DEBUG', 0); 
     
    102104                        $this->start            = (int)get_var('start', 'any', 0); 
    103105                        $this->search_str       = get_var('find', 'any', ''); 
    104                         $this->nextmatchs       = CreateObject('phpgwapi.nextmatchs'); 
     106                        $this->nextmatchs       = Factory::getInstance('nextmatchs'); 
    105107                } 
    106108 
    107109                /** 
    108110                 * Fill the process bar 
    109                  *  
     111                 * 
    110112                 * @param array $proc_info 
    111113                 * @access public 
     
    116118                        //echo "proc_info: <pre>";print_r($proc_info);echo "</pre>"; 
    117119                        $this->t->set_file('proc_bar_tpl', 'proc_bar.tpl'); 
    118                         $templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer'); 
     120                        $templateServer = &Factory::getInstance('TemplateServer'); 
    119121 
    120122                        if ($proc_info['wf_is_valid'] == 'y') 
     
    170172                /** 
    171173                 * Select activity representation icon 
    172                  *   
     174                 * 
    173175                 * @var string $type type of activity 
    174176                 * @var bool   $interactive interactive? 
     
    207209                                        $ic="no-activity.gif"; 
    208210                        } 
    209                         return '<img src="'. $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink($ic) .'" alt="'. lang($type) .'" title="'. lang($type) .'" />'; 
    210                 } 
    211          
     211                        return '<img src="'. Factory::getInstance('TemplateServer')->generateImageLink($ic) .'" alt="'. lang($type) .'" title="'. lang($type) .'" />'; 
     212                } 
     213 
    212214                /** 
    213215                 * Translate template file 
    214                  * @param string $template_name template name  
     216                 * @param string $template_name template name 
    215217                 * @return void 
    216218                 * @access public 
     
    359361                function export() 
    360362                { 
    361                         $this->process_manager  = CreateObject('workflow.workflow_processmanager'); 
     363                        $this->process_manager  = Factory::getInstance('workflow_processmanager'); 
    362364 
    363365                        // retrieve process info 
     
    387389                { 
    388390                        $file = "css/$css_name" . (($print_mode !== false) ? '_print' : '') . '.css'; 
    389                         return $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->getWebFile($file); 
    390                 } 
    391                  
     391                        return Factory::getInstance('TemplateServer')->getWebFile($file); 
     392                } 
     393 
    392394                /** 
    393395                 * Return a given duration in human readable form, usefull for workitems duration 
    394396                 * @param int $to given duration 
    395397                 * @return string given duration in human readable form 
    396                  * @access public  
     398                 * @access public 
    397399                 */ 
    398400                function time_diff($to) { 
  • branches/2.2/workflow/inc/class.basemodel.inc.php

    r795 r3167  
    167167    * @param string $obj Class name 
    168168    * @return mixed 
    169     * @deprecated 
     169    * @deprecated 2.2.00.000 
    170170    * @access public 
    171171    */ 
    172172        function &getInstance($obj) 
    173     { 
     173        { 
     174                wf_warn_deprecated_method('Factory', 'getInstance'); 
    174175                return(wf_create_object(strtolower($obj))); 
    175176        } 
  • branches/2.2/workflow/inc/class.bo_adminaccess.inc.php

    r795 r3167  
    1111 
    1212require_once('class.bo_ajaxinterface.inc.php'); 
    13 require_once('class.so_adminaccess.inc.php'); 
    14 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php'); 
    1513require_once(PHPGW_API_INC . SEP . 'common_functions.inc.php'); 
    16 require_once(PHPGW_API_INC . SEP . 'class.acl.inc.php'); 
    1714 
    1815/** 
     
    4340                parent::bo_ajaxinterface(); 
    4441 
    45                 if (!$GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($_SESSION['phpgw_info']['workflow']['account_id'])) 
     42                if (!Factory::getInstance('workflow_acl')->checkWorkflowAdmin($_SESSION['phpgw_info']['workflow']['account_id'])) 
    4643                        exit(serialize(array('error' => 'Você não tem permissão para executar esta operação.'))); 
    4744 
    48                 $this->so = new so_adminaccess($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     45                $this->so = &Factory::getInstance('so_adminaccess', Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    4946        } 
    5047 
     
    5754        function get_all_processes() 
    5855        { 
    59                 $proc_mng = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     56                $proc_mng = &Factory::newInstance('ProcessManager'); 
    6057                $proc_list = $proc_mng->list_processes(0,-1,'wf_name__ASC'); 
    6158 
     
    315312        { 
    316313                $GLOBALS['phpgw']->db = $GLOBALS['ajax']->db; 
    317                 $acl = new ACL(); 
     314                $acl = &Factory::getInstance('acl'); 
    318315                $output = $this->so->getUserNames($acl->get_ids_for_location('admin_workflow', 1, 'workflow')); 
    319316                unset($GLOBALS['phpgw']->db); 
     
    332329                $ids = explode('.', str_replace('g', '', str_replace('u', '', $params['user_ids']))); 
    333330                $GLOBALS['phpgw']->db = $GLOBALS['ajax']->db; 
    334                 $acl = new ACL(); 
     331                $acl = &Factory::getInstance('acl'); 
    335332                foreach ($ids as $id) 
    336333                        $acl->add_repository('workflow', 'admin_workflow', $id, 1); 
     
    350347        { 
    351348                $GLOBALS['phpgw']->db = $GLOBALS['ajax']->db; 
    352                 $acl = new ACL(); 
     349                $acl = &Factory::getInstance('acl'); 
    353350                $acl->delete_repository('workflow', 'admin_workflow', (int) $params['admin_id']); 
    354351                unset($GLOBALS['phpgw']->db); 
  • branches/2.2/workflow/inc/class.bo_adminjobs.inc.php

    r795 r3167  
    1111 
    1212require_once 'class.bo_ajaxinterface.inc.php'; 
    13 require_once 'class.so_adminjobs.inc.php'; 
    14 require_once 'nano/JSON.php'; 
    1513 
    1614/** 
     
    3634        { 
    3735                parent::bo_ajaxinterface(); 
    38                 $this->so = new so_adminjobs(); 
     36                $this->so = &Factory::getInstance('so_adminjobs'); 
    3937        } 
    4038 
     
    10098                /* paginate the result */ 
    10199                $logEntriesPerPage = 30; 
    102                 $paging = &$GLOBALS['workflow']['factory']->newInstance('Paging', $logEntriesPerPage, $params); 
     100                $paging =& Factory::newInstance('Paging', $logEntriesPerPage, $params); 
    103101                $logs = $paging->restrictItems($logs); 
    104102 
  • branches/2.2/workflow/inc/class.bo_adminsource.inc.php

    r795 r3167  
    1111 
    1212require_once('class.bo_ajaxinterface.inc.php'); 
    13  
    14 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php'); 
    15 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'RoleManager.php'); 
    16 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php'); 
    17 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'API' . SEP . 'Process.php'); 
    1813 
    1914/** 
     
    8075                $fileSizeUnit[] = 'Mb'; 
    8176                $fileSizeUnit[] = 'Gb'; 
    82                  
     77 
    8378                $unitSelect = 0; 
    8479                while ($value > 1024.0) 
     
    8782                        $unitSelect++; 
    8883                } 
    89          
     84 
    9085                $output = round($value, 1); 
    9186                $output .= " " . $fileSizeUnit[$unitSelect]; 
    92          
     87 
    9388                return $output; 
    9489        } 
    95          
     90 
    9691        /** 
    9792        * Get process toolbar data 
    98         * @param  array $p process process data  
    99         * @return array 
    100         * @access public  
    101         */       
    102         function get_toolbar_data($p)  
    103         { 
    104                  
    105                 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
    106                 $proc_info       = $process_manager->get_process($p['proc_id']);  
    107                  
     93        * @param  array $p process process data 
     94        * @return array 
     95        * @access public 
     96        */ 
     97        function get_toolbar_data($p) 
     98        { 
     99 
     100                $process_manager = &Factory::newInstance('ProcessManager'); 
     101                $proc_info       = $process_manager->get_process($p['proc_id']); 
     102 
    108103                $web_server_url  = $_SESSION['phpgw_info']['workflow']['server']['webserver_url']; 
    109                 $img_default_dir = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink(''); 
    110                  
     104                $img_default_dir = Factory::getInstance('TemplateServer')->generateImageLink(''); 
     105 
    111106                if ($proc_info['wf_is_valid'] == 'y') 
    112107                { 
     
    119114                        $alt_validity = tra('invalid'); 
    120115                } 
    121          
     116 
    122117                // if process is active show stop button. Else show start button, but only if it is valid. If it's not valid, don't show any activation or stop button. 
    123118                if ($proc_info['wf_is_active'] == 'y') 
     
    138133                        $start_stop_img  = ''; 
    139134                } 
    140          
     135 
    141136                /* load other processes link */ 
    142137                $proc_ids = $GLOBALS['ajax']->acl->get_granted_processes($_SESSION['phpgw_info']['workflow']['account_id']); 
     
    145140                else 
    146141                        $where = ' wf_p_id = -1 '; 
    147          
     142 
    148143                $processesInfo = &$process_manager->list_processes(0, -1, 'wf_name__asc', '', $where); 
    149144                $otherProcesses = array(); 
    150145                foreach ($processesInfo['data'] as $pi) 
    151146                        $otherProcesses[] = array("name" => $pi['wf_name'] . " (v" . $pi['wf_version'] . ")", "link" => $web_server_url . "/index.php?menuaction=workflow.ui_adminsource.form&p_id=" . $pi['wf_p_id'], "pid" => $pi['wf_p_id']); 
    152          
     147 
    153148                $toolbar_data = array ( 
    154149                        'proc_name'                                     => $proc_info['wf_name'], 
     
    177172                        'other_processes'                       => $otherProcesses 
    178173                ); 
    179                          
     174 
    180175                return $toolbar_data; 
    181176                } 
    182                  
    183                  
     177 
     178 
    184179        /** 
    185180        * Get process model files 
    186         * @param  array $p process process data  
    187         * @return array 
    188         * @access public  
     181        * @param  array $p process process data 
     182        * @return array 
     183        * @access public 
    189184        */ 
    190185        function get_model_files($p) 
    191186        { 
    192                 switch($p['type'])  
     187                switch($p['type']) 
    193188                { 
    194189                        case 'include'  : $path = PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'js' . SEP . 'adminsource' . SEP . 'inc'; 
     
    203198                $files          = array(); 
    204199 
    205                 if ($handle = opendir($path))  
    206                 { 
    207                         while (false !== ($file_name = readdir($handle)))  
    208                         {        
    209                                 if (!is_dir($path.SEP.$file_name))  
     200                if ($handle = opendir($path)) 
     201                { 
     202                        while (false !== ($file_name = readdir($handle))) 
     203                        { 
     204                                if (!is_dir($path.SEP.$file_name)) 
    210205                                { 
    211206                                        $files[] = array('file_name'     => $file_name); 
     
    217212                array_multisort($col_file_name,SORT_ASC,$files); 
    218213 
    219                 return $files;  
     214                return $files; 
    220215        } 
    221216 
    222217        /** 
    223218        * Get process php files 
    224         * @param array $p process data  
    225         * @return array 
    226         * @access public  
     219        * @param array $p process data 
     220        * @return array 
     221        * @access public 
    227222        */ 
    228223        function get_php_files($p) 
    229224        { 
    230                 $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     225                $process_manager    = &Factory::newInstance('ProcessManager'); 
    231226                $proc_info          = $process_manager->get_process($p['proc_id']); 
    232                 $activity_manager   = new ActivityManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     227                $activity_manager   = &Factory::newInstance('ActivityManager'); 
    233228                $process_activities = $activity_manager->list_activities($p['proc_id'], 0, -1, 'wf_name__asc', '','',false); 
    234229                $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'activities' . SEP; 
    235                  
     230 
    236231                $files = array(); 
    237232 
     
    242237                foreach ($process_activities['data'] as $process_activity) 
    243238                { 
    244                          
     239 
    245240                        $file_name   = $process_activity['wf_normalized_name'].'.php'; 
    246241                        $activity_id = $process_activity['wf_activity_id']; 
    247242                        $tamanho     = filesize($path.$file_name); 
    248243                        $modificado  = date('d/m/Y H:i:s', filemtime($path.$file_name) ); 
    249                          
     244 
    250245                        $files[] = array('file_name'     => $file_name, 
    251246                                                         'activity_id'   => $activity_id, 
     
    258253                                                         'tipo_codigo'   => 'atividade' 
    259254                        ); 
    260                          
     255 
    261256                        $col_file_name[]  = $file_name; 
    262257                        $col_tamanho[]    = $tamanho; 
    263258                        $col_modificado[] = $modificado; 
    264259                } 
    265                  
    266                 if (isset($p['sort']))  
     260 
     261                if (isset($p['sort'])) 
    267262                { 
    268263                        $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC; 
     
    279274                        } 
    280275                } 
    281                  
    282                 return $files;  
    283         } 
    284          
    285         /** 
    286         * Delete process file  
     276 
     277                return $files; 
     278        } 
     279 
     280        /** 
     281        * Delete process file 
    287282        * @param array $p process data 
    288283        * @return array 
    289         * @access public  
     284        * @access public 
    290285        */ 
    291286        function delete_file($p) 
     
    293288                if ((strpos($p['file_name'],'/') !== false) || (strpos($p['file_name'],'/') !== false)) 
    294289                        return 'Não foi possível executar a operação solicitada'; 
    295                 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
    296                 $proc_info = $process_manager->get_process($p['proc_id']);  
     290                $process_manager = &Factory::newInstance('ProcessManager'); 
     291                $proc_info = $process_manager->get_process($p['proc_id']); 
    297292                $file_name = $p['file_name']; 
    298                 $proc_name = $proc_info['wf_normalized_name'];  
     293                $proc_name = $proc_info['wf_normalized_name']; 
    299294                $type      = $p['type']; 
    300295                if (strpos($file_name,'/')) return 'Nome de arquivo inválido.'; 
    301296                if (!strlen($proc_name)) return 'ID de Processo inválido.'; 
    302                  
     297 
    303298    switch($type) 
    304299    { 
     
    315310                                $path = GALAXIA_PROCESSES . '/' . $proc_info['wf_normalized_name'] . '/resources/' . $file_name; 
    316311            break; 
    317                          
     312 
    318313    } 
    319     
    320                 if ($type == 'resource')  
     314 
     315                if ($type == 'resource') 
    321316                { 
    322317                        $complete_path = $path; 
    323                 }  
    324                 else  
     318                } 
     319                else 
    325320                { 
    326321                        $complete_path = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path; 
    327322                } 
    328          
    329                 if (file_exists($complete_path))  
     323 
     324                if (file_exists($complete_path)) 
    330325                { 
    331326                        if (unlink($complete_path)) 
     
    342337                        return 'O arquivo '.$file_name.' não existe.'; 
    343338                } 
    344         }        
    345         /** 
    346         * Create process new file  
     339        } 
     340        /** 
     341        * Create process new file 
    347342        * @param array $p process 
    348343        * @return array 
    349         * @access public  
     344        * @access public 
    350345        */ 
    351346        function create_file($p) 
    352347        { 
    353                 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
    354                 $proc_info = $process_manager->get_process($p['proc_id']);  
     348                $process_manager = &Factory::newInstance('ProcessManager'); 
     349                $proc_info = $process_manager->get_process($p['proc_id']); 
    355350                $file_name = $p['file_name']; 
    356                 $proc_name = $proc_info['wf_normalized_name'];  
     351                $proc_name = $proc_info['wf_normalized_name']; 
    357352                $type      = $p['type']; 
    358353 
     
    386381                } 
    387382 
    388                 if (file_exists($complete_path))  
    389                 { 
    390                         if (!$p['rewrite'])  
     383                if (file_exists($complete_path)) 
     384                { 
     385                        if (!$p['rewrite']) 
    391386                        { 
    392387                                return FILE_ALREADY_EXISTS; 
     
    396391                } 
    397392 
    398                 if ($fp = fopen($complete_path, 'w'))  
     393                if ($fp = fopen($complete_path, 'w')) 
    399394                { 
    400395                        $basepath = PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'js'.SEP.'adminsource'; 
     
    409404                        if ($type == 'template' || $type == 'include') 
    410405                        { 
    411                                 if (file_exists($basepath.SEP.$p['modelo']))  
     406                                if (file_exists($basepath.SEP.$p['modelo'])) 
    412407                                { 
    413408                                        fwrite($fp,file_get_contents($basepath.SEP.$p['modelo'])); 
     
    423418                } 
    424419        } 
    425          
     420 
    426421        /** 
    427422        * Get process include files 
    428423        * @param  array $p process 
    429424        * @return array 
    430         * @access public  
     425        * @access public 
    431426        */ 
    432427        function get_include_files($p) 
    433428        { 
    434                 $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
    435                 $proc_info          = $process_manager->get_process($p['proc_id']);  
     429                $process_manager    = &Factory::newInstance('ProcessManager'); 
     430                $proc_info          = $process_manager->get_process($p['proc_id']); 
    436431                $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code'; 
    437432 
     
    442437                $files          = array(); 
    443438 
    444                 if ($handle = opendir($path))  
    445                 { 
    446                         while (false !== ($file_name = readdir($handle)))  
    447                         {        
    448                                 if (!is_dir($path.SEP.$file_name))  
     439                if ($handle = opendir($path)) 
     440                { 
     441                        while (false !== ($file_name = readdir($handle))) 
     442                        { 
     443                                if (!is_dir($path.SEP.$file_name)) 
    449444                                { 
    450445                                        $tamanho     = filesize($path.SEP.$file_name); 
     
    467462 
    468463 
    469                 if (isset($p['sort']))  
     464                if (isset($p['sort'])) 
    470465                { 
    471466                        $order_by = ($p['order_by'] == 1) ? SORT_ASC : SORT_DESC; 
     
    483478                } 
    484479 
    485                 return $files;  
    486         } 
    487  
    488         /** 
    489         * Get process template files  
    490         * @param array $p process data  
    491         * @return array 
    492         * @access public  
     480                return $files; 
     481        } 
     482 
     483        /** 
     484        * Get process template files 
     485        * @param array $p process data 
     486        * @return array 
     487        * @access public 
    493488        */ 
    494489        function get_template_files($p) 
    495490        { 
    496                 $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
    497                 $proc_info          = $process_manager->get_process($p['proc_id']);  
     491                $process_manager    = &Factory::newInstance('ProcessManager'); 
     492                $proc_info          = $process_manager->get_process($p['proc_id']); 
    498493                $path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'templates'; 
    499494 
     
    502497                $col_modificado = array(); 
    503498 
    504                 if ($handle = opendir($path))  
    505                 { 
    506                         while (false !== ($file_name = readdir($handle)))  
    507                         {        
    508                                 if (!is_dir($path.SEP.$file_name))  
     499                if ($handle = opendir($path)) 
     500                { 
     501                        while (false !== ($file_name = readdir($handle))) 
     502                        { 
     503                                if (!is_dir($path.SEP.$file_name)) 
    509504                                { 
    510505                                        $tamanho     = filesize($path.SEP.$file_name); 
     
    541536 
    542537        } 
    543     }    
    544  
    545                 return $files;  
    546         } 
    547  
    548         /** 
    549         * Upload process resource   
    550         *  
     538    } 
     539 
     540                return $files; 
     541        } 
     542 
     543        /** 
     544        * Upload process resource 
     545        * 
    551546        * @param array $p process 
    552547        * @return array 
    553         * @access public  
     548        * @access public 
    554549        */ 
    555550        function upload_resource($p) 
    556551        { 
    557                 $process_manager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     552                $process_manager = &Factory::newInstance('ProcessManager'); 
    558553                $proc_info = $process_manager->get_process($p['proc_id']); 
    559554                $file_name = basename($_FILES['resource_file']['name']); 
     
    587582                if (strpos($_REQUEST['file_name'],'/') !== false) 
    588583                        return 'Não foi possível executar a operação solicitada'; 
    589                 $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     584                $process_manager    = &Factory::newInstance('ProcessManager'); 
    590585                $proc_info          = $process_manager->get_process($_REQUEST['proc_id']); 
    591586 
     
    617612                        $completePath = GALAXIA_PROCESSES . SEP . $proc_name . SEP . 'code' . SEP . $path; 
    618613 
    619                 $GLOBALS['workflow']['factory']->getInstance('ResourcesRedirector')->show($completePath, 'application/force-download'); 
     614                Factory::getInstance('ResourcesRedirector')->show($completePath, 'application/force-download'); 
    620615                exit; 
    621616        } 
     
    630625        function get_resource_files($p) 
    631626        { 
    632                 $process_manager    = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     627                $process_manager    = &Factory::newInstance('ProcessManager'); 
    633628                $proc_info          = $process_manager->get_process($p['proc_id']); 
    634629 
  • branches/2.2/workflow/inc/class.bo_agent.inc.php

    r795 r3167  
    278278                        if (!(isset($this->process))) 
    279279                        { 
    280                                 $this->process = CreateObject('workflow.workflow_process'); 
     280                                $this->process = Factory::getInstance('workflow_process'); 
    281281                                $this->process->getProcess($wf_p_id); 
    282282                        } 
  • branches/2.2/workflow/inc/class.bo_agent_mail_smtp.inc.php

    r795 r3167  
    109109        { 
    110110                parent::bo_agent(); 
    111                 $this->so_agent = CreateObject('workflow.so_agent_mail_smtp'); 
    112                 $this->bo_emailadmin = CreateObject('emailadmin.bo'); 
     111                $this->so_agent = Factory::getInstance('so_agent_mail_smtp'); 
     112                $this->bo_emailadmin = Factory::getInstance('bo'); 
    113113                //the showProcessConfigurationFields is not done here, quite harder to build 
    114114                $this->ProcessConfigurationFieldsdefault = array( 
     
    312312        function init() 
    313313        { 
    314                 $this->mail = CreateObject('phpgwapi.phpmailer'); 
     314                $this->mail = Factory::getInstance('phpmailer'); 
    315315                //set the $this->conf 
    316316                $this->getProcessConfigurationFields($this->activity->getProcessId()); 
     
    466466                } 
    467467 
    468                 $process = CreateObject('workflow.workflow_process'); 
     468                $process = Factory::getInstance('workflow_process'); 
    469469                $process->getProcess($this->process_id); 
    470470                $this->process_name = $process->getName(); 
     
    637637                                        if ($this->process_name=='') 
    638638                                        { 
    639                                                 $process = CreateObject('workflow.workflow_process'); 
     639                                                $process = Factory::getInstance('workflow_process'); 
    640640                                                $process->getProcess($this->process_id); 
    641641                                                $this->process_name = $process->getName(); 
     
    648648                                        if ($this->process_version=='') 
    649649                                        { 
    650                                                 $process = CreateObject('workflow.workflow_process'); 
     650                                                $process = Factory::getInstance('workflow_process'); 
    651651                                                $process->getProcess($this->process_id); 
    652652                                                $this->process_name = $process->getName(); 
     
    674674                                        if (!is_object($this->account)) 
    675675                                        { 
    676                                                 $this->account = CreateObject('phpgwapi.accounts'); 
     676                                                $this->account = Factory::getInstance('accounts'); 
    677677                                        } 
    678678                                        $ask_user = $this->instance->getOwner(); 
     
    683683                                        if (!is_object($this->role_manager)) 
    684684                                        { 
    685                                                 $this->role_manager = CreateObject('workflow.workflow_rolemanager'); 
     685                                                $this->role_manager = Factory::getInstance('workflow_rolemanager'); 
    686686                                        } 
    687687                                        if (!is_object($this->account)) 
    688688                                        { 
    689                                                 $this->account = CreateObject('phpgwapi.accounts'); 
     689                                                $this->account = Factory::getInstance('accounts'); 
    690690                                        } 
    691691                                        $my_subset = array('wf_activity_name' => $this->activity->getName()); 
     
    718718                                                        if (!is_object($this->account)) 
    719719                                                        { 
    720                                                                 $this->account = CreateObject('phpgwapi.accounts'); 
     720                                                                $this->account = Factory::getInstance('accounts'); 
    721721                                                        } 
    722722                                                        $ask_user = $this->account->name2id($second_part); 
     
    731731                                                        if (!is_object($this->role_manager)) 
    732732                                                        { 
    733                                                                 $this->role_manager = CreateObject('workflow.workflow_rolemanager'); 
     733                                                                $this->role_manager = Factory::getInstance('workflow_rolemanager'); 
    734734                                                        } 
    735735                                                        if (!is_object($this->account)) 
    736736                                                        { 
    737                                                                 $this->account = CreateObject('phpgwapi.accounts'); 
     737                                                                $this->account = Factory::getInstance('accounts'); 
    738738                                                        } 
    739739                                                        $my_subset = array('wf_role_name' => $second_part); 
  • branches/2.2/workflow/inc/class.bo_ajaxinterface.inc.php

    r795 r3167  
    3636 
    3737require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'common.inc.php'); 
    38 require_once(PHPGW_API_INC . SEP . 'class.db.inc.php'); 
    39 require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'engine' . SEP . 'class.ajax_ldap.inc.php'); 
    4038require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'engine' . SEP . 'class.ajax_config.inc.php'); 
    4139require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'engine' . SEP . 'config.ajax.inc.php'); 
    42 require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'class.so_adminaccess.inc.php'); 
    4340 
    4441/** 
     
    6663                if (isset($_SESSION['phpgw_info']['workflow']['account_id'])) 
    6764                { 
    68                         $GLOBALS['ajax']->ldap = new ajax_ldap(); 
    69                         $GLOBALS['ajax']->db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso(); 
     65                        $GLOBALS['ajax']->ldap = &Factory::getInstance('ajax_ldap'); 
     66                        $GLOBALS['ajax']->db =& Factory::getInstance('WorkflowObjects')->getDBExpresso(); 
    7067                        $GLOBALS['ajax']->db->Halt_On_Error = 'no'; 
    7168 
    72                         $GLOBALS['ajax']->db_workflow = &$GLOBALS['workflow']['workflowObjects']->getDBWorkflow(); 
     69                        $GLOBALS['ajax']->db_workflow =& Factory::getInstance('WorkflowObjects')->getDBWorkflow(); 
    7370                        $GLOBALS['ajax']->db_workflow->Halt_On_Error = 'no'; 
    7471 
    7572                        $GLOBALS['phpgw']->ADOdb = &$GLOBALS['ajax']->db->Link_ID; 
    76                         $GLOBALS['ajax']->acl = new so_adminaccess($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     73                        $GLOBALS['ajax']->acl = &Factory::getInstance('so_adminaccess', Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    7774                } 
    7875                else 
  • branches/2.2/workflow/inc/class.bo_editor.inc.php

    r795 r3167  
    1111 
    1212require_once('class.bo_ajaxinterface.inc.php'); 
    13 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php'); 
    14 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php'); 
    1513/** 
    1614 * @package Workflow 
     
    234232                if ($p['tipo_codigo'] != 'include') 
    235233                { 
    236                         $activity_manager   = new ActivityManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     234                        $activity_manager   = &Factory::newInstance('ActivityManager'); 
    237235 
    238236                        if ($this->check_process($p['proc_id'], &$activity_manager, &$error_str) == 'n') 
  • branches/2.2/workflow/inc/class.bo_external_applications.inc.php

    r795 r3167  
    1111\**************************************************************************/ 
    1212 
    13 require_once('class.so_external_applications.inc.php'); 
    1413require_once('class.bo_ajaxinterface.inc.php'); 
    1514/** 
     
    3433        { 
    3534                parent::bo_ajaxinterface(); 
    36                 $this->so = new so_external_applications(); 
     35                $this->so = &Factory::getInstance('so_external_applications'); 
    3736        } 
    3837 
  • branches/2.2/workflow/inc/class.bo_monitors.inc.php

    r795 r3167  
    1212require_once('class.bo_ajaxinterface.inc.php'); 
    1313 
    14 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'GUI' . SEP . 'GUI.php'); 
    15 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php'); 
    16 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php'); 
    17 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'InstanceManager.php'); 
    18 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'RoleManager.php'); 
    19 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessMonitor' . SEP . 'ProcessMonitor.php'); 
    20 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'API' . SEP . 'Instance.php'); 
    21 require_once('class.workflow_acl.inc.php'); 
    22 require_once('class.bo_adminaccess.inc.php'); 
    23 require_once('class.powergraphic.inc.php'); 
     14 
     15/** 
     16 * DO NOT remove this line. Ever. Somehow, monitors interface will stop working.. 
     17 */ 
     18require_once(PHPGW_API_INC . SEP . 'common_functions.inc.php'); 
     19 
    2420 
    2521/** 
     
    134130        { 
    135131                parent::bo_ajaxinterface(); 
    136                 $GLOBALS['ajax']->gui   = new GUI($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     132                $GLOBALS['ajax']->gui   = &Factory::newInstance('GUI'); 
    137133                $this->userID                   = $_SESSION['phpgw_info']['workflow']['account_id']; 
    138134                $this->isWorkflowAdmin  = $GLOBALS['ajax']->acl->checkWorkflowAdmin($this->userID); 
    139                 $this->processManager   = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
    140                 $this->activityManager  = new ActivityManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
    141                 $this->instanceManager  = new InstanceManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
    142                 $this->roleManager              = new RoleManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
    143                 $this->processMonitor   = new ProcessMonitor($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     135                $this->processManager   = &Factory::newInstance('ProcessManager'); 
     136                $this->activityManager  = &Factory::newInstance('ActivityManager'); 
     137                $this->instanceManager  = &Factory::newInstance('InstanceManager'); 
     138                $this->roleManager              = &Factory::newInstance('RoleManager'); 
     139                $this->processMonitor   = &Factory::newInstance('ProcessMonitor'); 
    144140        } 
    145141 
     
    169165        private function convertFiltersToSQL($filters) 
    170166        { 
    171                 require_once 'nano/JSON.php'; 
    172167 
    173168                /* desserializa os dados */ 
    174                 $JSON = new Services_JSON(); 
     169                $JSON = &Factory::newInstance('Services_JSON'); 
    175170                /* desserializa a array principal, depois desserializa cada elemento desta array e, por fim, converte os elementos (que estão em forma de objeto) para array associativa */ 
    176171                $filters = array_map('get_object_vars', array_map(array($JSON, 'decode'), $JSON->decode($filters))); 
     
    335330                $filters[] = '(gia.wf_user IS NOT NULL)'; 
    336331 
    337                 $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     332                $ldap = &Factory::getInstance('WorkflowLDAP'); 
    338333                if (!$completeData) 
    339334                { 
    340                         $paging = $GLOBALS['workflow']['factory']->newInstance('Paging', 500, $_POST); 
     335                        $paging = Factory::newInstance('Paging', 500, $_POST); 
    341336                        $tmp = $this->processMonitor->monitor_list_instances($paging->nextItem, $paging->itemsPerPage, $order, '', implode(' AND ', $filters)); 
    342337                        $output['data'] = $paging->restrictItems(array_values($tmp['data']), $tmp['cant']); 
     
    353348                $activityMapping = array(); 
    354349                $instanceCount = count($output['data']); 
    355                 $cachedLDAP = &$GLOBALS['workflow']['factory']->getInstance('CachedLDAP'); 
     350                $cachedLDAP = &Factory::getInstance('CachedLDAP'); 
    356351                for ($i = 0; $i < $instanceCount; $i++) 
    357352                { 
     
    476471                /* load the data */ 
    477472                $filters[] = '(gp.wf_p_id = ' . $params['pid'] . ')'; 
    478                 $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     473                $ldap = &Factory::getInstance('WorkflowLDAP'); 
    479474                if (!$completeData) 
    480475                { 
    481                         $paging = $GLOBALS['workflow']['factory']->newInstance('Paging', 500, $_POST); 
     476                        $paging = Factory::newInstance('Paging', 500, $_POST); 
    482477                        $tmp = $this->processMonitor->monitor_list_completed_instances($paging->nextItem, $paging->itemsPerPage, $order, '', implode(' AND ', $filters)); 
    483478                        $output['data'] = $paging->restrictItems(array_values($tmp['data']), $tmp['cant']); 
     
    491486                } 
    492487 
    493                 $cachedLDAP = &$GLOBALS['workflow']['factory']->getInstance('CachedLDAP'); 
     488                $cachedLDAP = &Factory::getInstance('CachedLDAP'); 
    494489                $userMapping = array(); 
    495490                $instanceCount = count($output['data']); 
     
    627622                        } 
    628623                        else 
    629                                 $output['fullname'] = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($user); 
     624                                $output['fullname'] = Factory::getInstance('WorkflowLDAP')->getName($user); 
    630625 
    631626                $this->instanceManager->set_instance_user($params['iid'], $params['aid'], $user); 
     
    648643                if ($params['ns'] == 'aborted') 
    649644                { 
    650                         $realInstance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     645                        $realInstance = &Factory::newInstance('Instance'); 
    651646                        $realInstance->getInstance($params['iid']); 
    652647                        if (!empty($realInstance->instanceId)) 
     
    684679 
    685680                /* use next user or * for the new instance */ 
    686                 $realInstance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     681                $realInstance = &Factory::newInstance('Instance'); 
    687682                $realInstance->getInstance($params['iid'], false, false); 
    688683                $user = $realInstance->getNextUser($params['aid']); 
     
    751746 
    752747                $maximumDisplaySize = 100; 
    753                 $instance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     748                $instance = &Factory::newInstance('Instance'); 
    754749                $instance->getInstance($params['iid']); 
    755750 
     
    783778                        return "Você não tem permissão para executar este procedimento!"; 
    784779 
    785                 $instance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     780                $instance = &Factory::newInstance('Instance'); 
    786781                $instance->getInstance($params['iid']); 
    787782                $output = $params; 
     
    804799                $maximumDisplaySize = 100; 
    805800 
    806                 $instance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     801                $instance = &Factory::newInstance('Instance'); 
    807802                $instance->getInstance($params['iid']); 
    808803                $instance->set($params['name'], $params['value']); 
     
    835830                        return "Você não tem permissão para executar este procedimento!"; 
    836831 
    837                 $instance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     832                $instance = &Factory::newInstance('Instance'); 
    838833                $instance->getInstance($params['iid']); 
    839834                $instance->clear($params['name']); 
     
    858853                $output = array(); 
    859854                $urlPrefix = 'workflow/inc/class.powergraphic.inc.php?'; 
    860                 $powergraphic = new powergraphic; 
     855                $powergraphic = &Factory::getInstance('powergraphic'); 
    861856                $powergraphic->graphic_1 = $params['pid']; 
    862857                $powergraphic->skin = 1; 
     
    904899                /* prepare the data */ 
    905900                $aux2 = array(); 
    906                 $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     901                $ldap = &Factory::getInstance('WorkflowLDAP'); 
    907902                foreach ($aux as $user => $count) 
    908903                        $aux2[] = array( 
     
    984979 
    985980                /* load LDAP info and sort the result */ 
    986                 $foundUsers = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getNames($users); 
     981                $foundUsers = Factory::getInstance('WorkflowLDAP')->getNames($users); 
    987982                usort($foundUsers, create_function('$a,$b', 'return strcasecmp($a[\'name\'],$b[\'name\']);')); 
    988983 
     
    991986                if (count($users) > count($foundUsers)) 
    992987                { 
    993                         $cachedLDAP = &$GLOBALS['workflow']['factory']->getInstance('CachedLDAP'); 
     988                        $cachedLDAP = &Factory::getInstance('CachedLDAP'); 
    994989                        $foundUsersID = array_map(create_function('$a', 'return $a[\'id\'];'), $foundUsers); 
    995990                        $missingUsers = array_diff($users, $foundUsersID); 
     
    12421237                        return $output; 
    12431238 
    1244                 $BOUserInterface = &$GLOBALS['workflow']['factory']->getInstance('bo_userinterface'); 
     1239                $BOUserInterface = &Factory::getInstance('bo_userinterface'); 
    12451240 
    12461241                /* initialize some variables */ 
     
    13441339 
    13451340                /* load the recipient e-mail */ 
    1346                 $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     1341                $ldap = &Factory::getInstance('WorkflowLDAP'); 
    13471342                foreach ($output as $key => $value) 
    13481343                { 
     
    13961391 
    13971392                /* prepare the environment to load some configuration values from other module */ 
    1398                 $GLOBALS['phpgw']->db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso(); 
    1399                 $GLOBALS['phpgw']->common = CreateObject('phpgwapi.common'); 
    1400                 $GLOBALS['phpgw']->session = CreateObject('phpgwapi.sessions'); 
     1393                $GLOBALS['phpgw']->db =& Factory::getInstance('WorkflowObjects')->getDBExpresso(); 
     1394                $GLOBALS['phpgw']->common = Factory::getInstance('common'); 
     1395                $GLOBALS['phpgw']->session = Factory::getInstance('sessions'); 
    14011396                function lang($a){return $a;}; 
    14021397 
    14031398                /* get the required configuration */ 
    1404                 $BOEmailAdmin = $GLOBALS['workflow']['factory']->newForeignInstance('emailadmin', 'bo'); 
     1399                $BOEmailAdmin = Factory::getInstance('bo'); 
    14051400                $profileList = $BOEmailAdmin->getProfileList(); 
    14061401                $profile = $BOEmailAdmin->getProfile($profileList[0]['profileID']); 
     1402 
     1403                /** 
     1404                 * XXX - XXX 
     1405                 * It's weird.. There are two almost identical PHPMailer classes. 
     1406                 * The class registered in our factory is under 'EGW_INC_ROOT'. 
     1407                 * The class used here has the same name and it's under another 
     1408                 * directory. For now, let's just include it in the old-fashion 
     1409                 * way, but if someone, someday try to use both classes in the 
     1410                 * same access, it could cause us troubles. 
     1411                 */ 
    14071412 
    14081413                /* configure the PHPMailer class to send the e-mails */ 
     
    14941499        { 
    14951500                $output = array(); 
    1496                 $cachedLDAP = &$GLOBALS['workflow']['factory']->getInstance('CachedLDAP'); 
    1497                 $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     1501                $cachedLDAP = &Factory::getInstance('CachedLDAP'); 
     1502                $ldap = &Factory::getInstance('WorkflowLDAP'); 
    14981503                foreach ($userIDs as $userID) 
    14991504                { 
     
    15421547                $filters[] = '(gia.wf_user IS NOT NULL)'; 
    15431548 
    1544                 $cachedLDAP = &$GLOBALS['workflow']['factory']->newInstance('CachedLDAP'); 
     1549                $cachedLDAP = &Factory::newInstance('CachedLDAP'); 
    15451550                $cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP); 
    15461551                $output = array(); 
     
    15591564                } 
    15601565 
    1561                 $validUsers = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getNames(array_keys($userIDs)); 
     1566                $validUsers = Factory::getInstance('WorkflowLDAP')->getNames(array_keys($userIDs)); 
    15621567                array_walk($validUsers, create_function('&$a', '$a = $a[\'id\'];')); 
    15631568 
  • branches/2.2/workflow/inc/class.bo_move_instances.inc.php

    r795 r3167  
    1212 
    1313require_once('class.bo_ajaxinterface.inc.php'); 
    14 require_once('class.so_move_instances.inc.php'); 
    15 require_once('nano/JSON.php'); 
    1614 
    1715 
     
    3937        { 
    4038                parent::bo_ajaxinterface(); 
    41                 $this->so = new so_move_instances(); 
     39                $this->so = &Factory::getInstance('so_move_instances'); 
    4240        } 
    4341 
     
    7977        function moveInstances($params) 
    8078        { 
    81                 $JSON = new Services_JSON(); 
     79                $JSON = &Factory::newInstance('Services_JSON'); 
    8280 
    8381                /* convert the mappgin element to array */ 
  • branches/2.2/workflow/inc/class.bo_orgchart.inc.php

    r1245 r3167  
    1010\**************************************************************************/ 
    1111 
    12 require_once('class.so_orgchart.inc.php'); 
    1312require_once('class.bo_ajaxinterface.inc.php'); 
    1413/** 
     
    4746        { 
    4847                parent::bo_ajaxinterface(); 
    49                 $this->so = new so_orgchart(); 
     48                $this->so = &Factory::getInstance('so_orgchart'); 
    5049        } 
    5150 
     
    524523        function listArea($params) 
    525524        { 
    526                 $result = $this->so->getArea($params['organizacao_id']); 
     525                $result = $this->so->getArea($params['organizacao_id'], $params['area_id']); 
    527526                $this->disconnect_all(); 
    528527 
     
    552551        function addArea($params) 
    553552        { 
    554                 $result = $this->so->addArea($params['centro_custo_id'], $params['organizacao_id'], $params['area_status_id'], $this->_nullReplace($params['substituto_funcionario_id']), $this->_nullReplace($params['titular_funcionario_id']), $this->_nullReplace($params['superior_area_id']), $params['sigla'], $params['descricao'], $params['ativa'], $this->_nullReplace($params['auxiliar_funcionario_id'])); 
     553                $result = $this->so->addArea($params['centro_custo_id'], $params['organizacao_id'], $params['area_status_id'], $this->_nullReplace($params['titular_funcionario_id']), $this->_nullReplace($params['superior_area_id']), $params['sigla'], $params['descricao'], $params['ativa'], $this->_nullReplace($params['auxiliar_funcionario_id'])); 
    555554                $this->disconnect_all(); 
    556555 
     
    566565        function updateArea($params) 
    567566        { 
    568                 $result = $this->so->updateArea($params['centro_custo_id'], $params['organizacao_id'], $params['area_status_id'], $this->_nullReplace($params['substituto_funcionario_id']), $this->_nullReplace($params['titular_funcionario_id']), $this->_nullReplace($params['superior_area_id']), $params['sigla'], $params['descricao'], $params['ativa'], $this->_nullReplace($params['auxiliar_funcionario_id']), $params['area_id']); 
     567                $result = $this->so->updateArea($params['centro_custo_id'], $params['organizacao_id'], $params['area_status_id'], $this->_nullReplace($params['titular_funcionario_id']), $this->_nullReplace($params['superior_area_id']), $params['sigla'], $params['descricao'], $params['ativa'], $this->_nullReplace($params['auxiliar_funcionario_id']), $params['area_id']); 
    569568                $this->disconnect_all(); 
    570569 
     
    669668                return $result; 
    670669        } 
     670 
     671        /** 
     672         * Add a substitution to an specific area 
     673         * @param array $params An array filled by the substitution parameters 
     674         * @return bool TRUE if we are successfull, FALSE otherwise 
     675         * @access public 
     676         */ 
     677        function addSubstitution( $params ) 
     678        { 
     679                $result = $this -> so -> addSubstitution( $params[ 'organizacao_id' ], $params[ 'area_id' ], $params[ 'substituto_funcionario_id' ], $params[ 'data_inicio' ], $params[ 'data_fim' ] ); 
     680                $this->disconnect_all( ); 
     681 
     682                return $result; 
     683        } 
     684 
     685        /** 
     686         * Update a substitution 
     687         * @param array $params An array filled by the substitution parameters 
     688         * @return bool TRUE if we are successfull, FALSE otherwise 
     689         * @access public 
     690         */ 
     691        function updateSubstitution( $params ) 
     692        { 
     693                $result = $this -> so -> updateSubstitution( $params[ 'organizacao_id' ], $params[ 'area_id' ], $params[ 'substituto_funcionario_id' ], $params[ 'data_inicio' ], $params[ 'data_fim' ], $params['substituicao_id'] ); 
     694                $this->disconnect_all( ); 
     695 
     696                return $result; 
     697        } 
     698 
     699        /** 
     700         * List the substitutions for a given area. 
     701         * @param array $params An array containing the areaID 
     702         * @return array Substitution's list 
     703         * @access public 
     704         */ 
     705        function listSubstitution( $params ) 
     706        { 
     707                $result = $this -> so -> getSubstitutions( $params['organizacao_id'], $params[ 'area_id' ] ); 
     708                $this -> disconnect_all( ); 
     709 
     710                return $result; 
     711        } 
     712 
     713        /** 
     714         * Remove a substitution 
     715         * @param array $params An array containing a substitutionID 
     716         * @return bool 
     717         * @access public 
     718         */ 
     719        function removeSubstitution( $params ) 
     720        { 
     721                $result = $this -> so -> removeSubstitution( $params['organizacao_id'], $params[ 'substituicao_id' ] ); 
     722                $this -> disconnect_all( ); 
     723 
     724                return $result; 
     725        } 
    671726} 
    672727?> 
  • branches/2.2/workflow/inc/class.bo_participants.inc.php

    r795 r3167  
    3434        function bo_participants() 
    3535        { 
    36                 $this->ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     36                $this->ldap = &Factory::getInstance('WorkflowLDAP'); 
    3737        } 
    3838 
     
    7474                { 
    7575                        $preffix = ($usePreffix) ? 'u' : ''; 
    76                         $ents = $this->ldap->getUsers($params['context']); 
     76                        $ents = $this->ldap->getUsers($params['context'], $params['onlyVisibleAccounts']); 
    7777                        foreach ($ents as $ent) 
    7878                                $output[$preffix . $ent[$id]] = $ent['name']; 
     
    162162                $searchLists = (strpos($entities, 'l') !== false); 
    163163 
     164                $onlyVisibleAccounts = $params['onlyVisibleAccounts']; 
     165 
    164166                /* faz a busca */ 
    165167                $output = array(); 
    166                 $output['participants'] = $this->ldap->search($searchTerm, $searchUsers, $searchGroups, $searchLists); 
     168                $output['participants'] = $this->ldap->search($searchTerm, $searchUsers, $searchGroups, $searchLists, null, $onlyVisibleAccounts); 
    167169 
    168170                /* limita os resultados e define uma mensagem que será exibida */ 
  • branches/2.2/workflow/inc/class.bo_userinterface.inc.php

    r1470 r3167  
    1010\**************************************************************************/ 
    1111 
    12 require_once('class.so_userinterface.inc.php'); 
    1312require_once('class.bo_ajaxinterface.inc.php'); 
    14 require_once('class.Paging.inc.php'); 
    15  
    16 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'GUI' . SEP . 'GUI.php'); 
    17 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php'); 
     13 
    1814/** 
    1915 * @package Workflow 
     
    4339        function bo_userinterface() 
    4440        { 
    45                 parent::bo_ajaxinterface();      
    46                 $this->so = new so_userinterface(); 
    47                 $GLOBALS['ajax']->gui = new GUI($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     41                parent::bo_ajaxinterface(); 
     42                $this->so = &Factory::getInstance('so_userinterface'); 
     43                $GLOBALS['ajax']->gui = &Factory::newInstance('GUI'); 
    4844        } 
    4945 
     
    6864                $webserver_url = $_SESSION['phpgw_info']['workflow']['server']['webserver_url']; 
    6965 
    70                 $templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer'); 
     66                $templateServer =& Factory::getInstance('TemplateServer'); 
    7167                foreach ($result['data'] as $line) 
    7268                { 
     
    9591                                        $recset[$procname_ver]['useHTTPS'] = 0; 
    9692                        } 
    97                         $recset[$procname_ver][] = array('wf_activity_id'       => $line['wf_activity_id'], 
    98                                                                                 'wf_name'                       => $line['wf_name'], 
    99                                                                                 'wf_menu_path'          => $line['wf_menu_path'], 
    100                                                                                 'wf_type'                       => $line['wf_type'], 
    101                                                                                 'wf_is_autorouted'      => $line['wf_is_autorouted'], 
    102                                                                                 'wf_is_interactive' => $line['wf_is_interactive']); 
     93                        if (!is_dir(GALAXIA_PROCESSES . '/' . $line['wf_normalized_name'])) 
     94                        { 
     95                                $recset[$procname_ver]['wf_iconfile'] = $templateServer->generateImageLink('navbar_nocode.png'); 
     96                        } 
     97                        else 
     98                        { 
     99                                $recset[$procname_ver][] = array('wf_activity_id'       => $line['wf_activity_id'], 
     100                                                                                                'wf_name'                       => $line['wf_name'], 
     101                                                                                                'wf_menu_path'          => $line['wf_menu_path'], 
     102                                                                                                'wf_type'                       => $line['wf_type'], 
     103                                                                                                'wf_is_autorouted'      => $line['wf_is_autorouted'], 
     104                                                                                                'wf_is_interactive' => $line['wf_is_interactive']); 
     105                        } 
    103106                } 
    104107 
     
    120123                $pid = $params['pid']; 
    121124                $result = array(); 
    122                  
    123                 $process = new Process($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     125 
     126                $process = &Factory::newInstance('Process'); 
    124127                $process->getProcess($pid); 
    125128                $result['wf_procname'] = $process->name; 
    126129                $result['wf_version'] = $process->version; 
    127130                $result['wf_description'] = $process->description; 
    128                  
    129                 $activ_manager = new ActivityManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     131 
     132                $activ_manager = &Factory::newInstance('ActivityManager'); 
    130133                $result['wf_activities'] = $activ_manager->get_process_activities($pid); 
    131                  
    132                 $this->disconnect_all(); 
    133                  
    134                 return $result;  
     134 
     135                $this->disconnect_all(); 
     136 
     137                return $result; 
    135138        } 
    136139 
     
    148151                $itemsPerPage = isset($preferences['ui_items_per_page']) ? $preferences['ui_items_per_page'] : 15; 
    149152                $lightVersion = ((isset($preferences['use_light_interface']) ? $preferences['use_light_interface'] : 0) == 1); 
    150                 $paging = new Paging($itemsPerPage, $_POST); 
     153                $paging = Factory::newInstance('Paging', $itemsPerPage, $_POST); 
    151154 
    152155                /* define the sorting */ 
     
    263266                                else 
    264267                                        if ($row['wf_user'] != '') 
    265                                                 $row['wf_user_fullname'] = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($row['wf_user']); 
     268                                                $row['wf_user_fullname'] = Factory::getInstance('WorkflowLDAP')->getName($row['wf_user']); 
    266269 
    267270                                /* unset unneeded information */ 
     
    495498                } 
    496499 
    497                 $instance = new Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     500                $instance = &Factory::newInstance('Instance'); 
    498501                $instance->getInstance($instanceID); 
    499502 
    500                 $process = new Process($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     503                $process = &Factory::newInstance('Process'); 
    501504                $process->getProcess($instance->pId); 
    502505 
     
    508511                        'wf_instance_id' => $instance->instanceId, 
    509512                        'wf_priority' => $instance->priority, 
    510                         'wf_owner' => $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($instance->owner), 
     513                        'wf_owner' => Factory::getInstance('WorkflowLDAP')->getName($instance->owner), 
    511514                        'wf_next_activity' => $instance->nextActivity, 
    512                         'wf_next_user' => $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($instance->nextUser), 
     515                        'wf_next_user' => Factory::getInstance('WorkflowLDAP')->getName($instance->nextUser), 
    513516                        'wf_name' => $instance->name, 
    514517                        'wf_category' => $instance->category, 
     
    526529                $result['wf_ended'] = ""; 
    527530 
    528                 $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     531                $ldap = &Factory::getInstance('WorkflowLDAP'); 
    529532                foreach ($instance->workitems as $line) 
    530533                { 
     
    657660                $cod_process = array(); 
    658661 
    659                 $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     662                $ldap = &Factory::getInstance('WorkflowLDAP'); 
    660663                $viewActivitiesID = array(); 
    661664                foreach ($result['data'] as $row) 
     
    726729                        /* paginate the result */ 
    727730                        $itemsPerPage = isset($_SESSION['phpgw_info']['workflow']['user']['preferences']['ui_items_per_page']) ? $_SESSION['phpgw_info']['workflow']['user']['preferences']['ui_items_per_page'] : 15; 
    728                         $paging = new Paging($itemsPerPage, $_POST); 
     731                        $paging = Factory::newInstance('Paging', $itemsPerPage, $_POST); 
    729732                        $output['instances'] = $paging->restrictItems($output['instances']); 
    730733                        $output['paging_links'] = $paging->commonLinks(); 
     
    740743        /** 
    741744         * Aplicacoes externas do usuario 
    742          * @return array  
     745         * @return array 
    743746         * @access public 
    744747         */ 
     
    746749        { 
    747750                $webserver_url = $_SESSION['phpgw_info']['workflow']['server']['webserver_url']; 
    748                 $templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer'); 
     751                $templateServer = &Factory::getInstance('TemplateServer'); 
    749752 
    750753                /* load the sites that the user can access */ 
     
    927930                        return $checkWarnings; 
    928931 
    929                 $result = $this->so->searchEmployee($params['searchTerm'], $this->organizationInfo['organizacao_id']); 
    930                 $this->disconnect_all(); 
    931  
    932                 if ($result === false) 
     932                $result = array(); 
     933 
     934                /* do the search */ 
     935                $result['bytelephone'] = $this->so->searchEmployeeByTelephone($params['searchTerm'], $this->organizationInfo['organizacao_id']); 
     936                $result['employees'] = $this->so->searchEmployeeByName($params['searchTerm'], $this->organizationInfo['organizacao_id']); 
     937                $result['bygroup'] = $this->so->searchEmployeeByArea($params['searchTerm'], $this->organizationInfo['organizacao_id']); 
     938 
     939                $this->disconnect_all(); 
     940 
     941                /* if all searches returned false */ 
     942                if (!is_array($result['employees']) and 
     943                        !is_array($result['bygroup']) and 
     944                        !is_array($result['bytelephone'])) 
    933945                        return array('error' => 'O sistema de busca não pode ser utilizado para sua organização'); 
    934  
    935                 $sort_function = create_function('$a,$b', 'return strcasecmp($a[\'cn\'],$b[\'cn\']);'); 
    936  
    937                 usort($result['employees'], $sort_function ); 
    938                 usort($result['bygroup'], $sort_function ); 
    939946 
    940947                return $result; 
     
    10661073        function callVoipConnect($params) 
    10671074        { 
    1068                 $cachedLDAP = $GLOBALS['workflow']['factory']->newInstance('CachedLDAP'); 
     1075                $cachedLDAP = Factory::newInstance('CachedLDAP'); 
    10691076                $cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP); 
    10701077 
  • branches/2.2/workflow/inc/class.bo_utils.inc.php

    r795 r3167  
    1111 
    1212require_once 'class.bo_ajaxinterface.inc.php'; 
    13 require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'GUI' . SEP . 'GUI.php'; 
    14 require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php'; 
    1513 
    1614/** 
     
    3432        { 
    3533                parent::bo_ajaxinterface(); 
    36                 $this->db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso(); 
     34                $this->db =& Factory::getInstance('WorkflowObjects')->getDBExpresso(); 
    3735        } 
    3836 
     
    6664         */ 
    6765        function search_ldap_users_by_cn($params) 
    68         { 
     66        {  
    6967                // parâmetro a ser procurado no ldap 
    7068                $cn = trim(ereg_replace(' +', ' ', $params['cn'])); 
     
    8886                        $ret_name = empty($params['name']) ? 'cn' : $params['name']; 
    8987 
    90                         $ajaxConfig = new ajax_config('contactcenter'); 
     88                        $ret_complement = empty($params['complement']) ? '' : $params['complement']; 
     89 
     90                        $ajaxConfig = &Factory::newInstance('ajax_config', 'contactcenter'); 
    9191                        $config = $ajaxConfig->read_repository(); 
    9292 
     
    105105 
    106106                                $filter     = '(&(uid=*)(phpgwAccountType=u)(!(phpgwAccountVisible=-1))(cn=*' . $cn . '*))'; 
    107                                 $attrib_ret = array('cn', $ret_id, $ret_name); 
     107 
     108                                if($ret_complement != '') 
     109                                        $attrib_ret = array('cn', $ret_id, $ret_name, $ret_complement); 
     110                                else 
     111                                        $attrib_ret = array('cn', $ret_id, $ret_name); 
    108112 
    109113                                $r = ldap_search($ds, $ldapconfig['basedn'], $filter, $attrib_ret, 0, 0, 5); 
     
    114118                                        } 
    115119                                        elseif(ldap_count_entries($ds, $r) < 200){ 
     120 
    116121                                                $result = ldap_get_entries($ds, $r); 
    117                                                 foreach($result as $value){ 
    118                                                         $output['values'][] = array( 
    119                                                                 'id'   => $value[$ret_id], 
    120                                                                 'name' => trim(ucwords(strtolower($value[$ret_name][0])))); 
     122 
     123                                                foreach($result as $value){  
     124                                                        if( ($value[$ret_name][0] != '') && ($value[$ret_complement][0] != '') ){ 
     125                                                                        $complement = " >> " . $value[$ret_complement][0]; 
     126                                                                        $output['values'][] = array( 
     127                                                                                                                                 'id'   => $value[$ret_id], 
     128                                                                                                                                 'name' => trim(ucwords(strtolower($value[$ret_name][0]))) . $complement 
     129                                                                                                                           );  
     130 
     131                                                        } 
     132                                                elseif($value[$ret_name][0] != ''){ 
     133                                                                $output['values'][] = array( 
     134                                                                                                                         'id'   => $value[$ret_id], 
     135                                                                                                                         'name' => trim(ucwords(strtolower($value[$ret_name][0]))) 
     136                                                                                                                   );  
     137                                                        } 
     138                                                else{ 
     139                                                                $output['values'][] = array( 
     140                                                                                                                         'id'   => '', 
     141                                                                                                                         'name' => "-- Selecione uma Opção --" 
     142                                                                                                                   );  
     143                                                        } 
     144 
    121145                                                } 
    122  
    123146 
    124147                                                foreach ($output['values'] as $key => $value){ 
     
    142165                else{ 
    143166                        $output['msg'] = 'Não digite caracteres especiais nem números. Apenas letras e espaços são permitidos.'; 
    144                 } 
     167                }  
    145168                return $output; 
    146169        } 
  • branches/2.2/workflow/inc/class.bo_workflow_forms.inc.php

    r795 r3167  
    9090                        $this->sort_mode        = $this->order . '__' . $this->sort; 
    9191                        $this->search_str       = get_var('find', 'any', ''); 
    92                         $this->nextmatchs       = CreateObject('phpgwapi.nextmatchs'); 
     92                        $this->nextmatchs       = Factory::getInstance('nextmatchs'); 
    9393                         
    9494                        // number of rows allowed 
  • branches/2.2/workflow/inc/class.external_bridge.inc.php

    r795 r3167  
    1313require_once 'common.inc.php'; 
    1414require_once 'engine/config.egw.inc.php'; 
    15 require_once 'class.so_adminaccess.inc.php'; 
    1615 
    1716/** 
     
    5251        function external_bridge() 
    5352        { 
    54                 $this->db = $GLOBALS['workflow']['workflowObjects']->getDBGalaxia(); 
    55                 $this->acl = new so_adminaccess($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     53                $this->db = Factory::getInstance('WorkflowObjects')->getDBGalaxia(); 
     54                $this->acl = &Factory::getInstance('so_adminaccess', Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    5655        } 
    5756        /** 
     
    156155 
    157156                /* assign variables to the template */ 
    158                 $smarty = $GLOBALS['workflow']['factory']->getInstance('workflow_smarty', false); 
     157                $smarty = Factory::getInstance('workflow_smarty', false); 
    159158                $smarty->assign('encodedForm', $encodedForm); 
    160159                $smarty->assign('siteAddress', $this->siteAddress); 
  • branches/2.2/workflow/inc/class.powergraphic.inc.php

    r795 r3167  
    139139 
    140140 
    141  
    142  
    143 $PowerGraphic = new powergraphic; 
     141require_once 'common.inc.php'; 
     142 
     143$PowerGraphic = &Factory::newInstance('powergraphic'); 
    144144 
    145145$PowerGraphic->start(); 
  • branches/2.2/workflow/inc/class.run_activity.inc.php

    r795 r3167  
    1010        \**************************************************************************/ 
    1111 
     12        require_once(dirname(__FILE__) . SEP . 'common.inc.php');                                /* including common deifinitions */ 
    1213        require_once(dirname(__FILE__) . SEP . 'class.WorkflowUtils.inc.php'  ); /* superclass source code       */ 
    1314        require_once(dirname(__FILE__) . SEP . 'class.basecontroller.inc.php' ); /* module controller            */ 
    1415        require_once(dirname(__FILE__) . SEP . 'class.basemodel.inc.php'      ); /* module logic                 */ 
    15         require_once(dirname(__FILE__) . SEP . 'class.process_factory.inc.php'); /* module process factory class */ 
    16         require_once(dirname(__FILE__) . SEP . 'class.utils.security.php'     ); /* sanitizes input data         */ 
    1716 
    1817        /** 
     
    169168                var $agents = Array(); 
    170169 
    171                 /* CELEPAR */ 
    172170                /** 
    173171                 * @var object $smarty holds a Smarty instance 
     
    195193         */ 
    196194                var $isChildInstance = false; 
    197  
     195                /** 
     196                 * @var object Stores a 'workflow_smarty' object 
     197         * @access private 
     198         */ 
    198199                private $workflowSmarty = null; 
    199                 /* CELEPAR */ 
     200                /** 
     201                 * @var object Log Object 
     202         * @access private 
     203         */ 
     204                private $logger = null; 
     205 
    200206                /** 
    201207                 * Constructor 
     
    206212                { 
    207213                        parent::WorkflowUtils(); 
    208                         $this->runtime          = CreateObject('workflow.workflow_wfruntime'); 
     214 
     215                        /** 
     216                         * We should always use newInstance to instantiate 
     217                         * 'workflow_wfruntime' 
     218                         */ 
     219                        $this->runtime                  = &Factory::newInstance('workflow_wfruntime'); 
    209220                        $this->runtime->setDebug(_DEBUG); 
    210                         //$this->base_activity  = CreateObject('workflow.workflow_baseactivity'); 
    211                         //$this->process                = CreateObject('workflow.workflow_process'); 
    212                         $this->GUI              = CreateObject('workflow.workflow_gui'); 
    213                         $this->categories       = CreateObject('phpgwapi.categories'); 
    214  
    215                         $this->workflowSmarty = CreateObject('workflow.workflow_smarty', false); 
     221                        $this->GUI                              = &Factory::getInstance('workflow_gui'); 
     222                        $this->categories               = &Factory::getInstance('categories'); 
     223 
     224                        $this->workflowSmarty   = &Factory::getInstance('workflow_smarty', false); 
     225 
     226                        // never configure a log of type "firebug" here. This will make goAjax stop running well =( 
     227                        $this->logger                   = &Factory::getInstance('Logger', array('file')); 
     228 
    216229                        // TODO: open a new connection to the database under a different username to allow privilege handling on tables 
    217                         /* CELEPAR */ 
    218230                        unset($this->db); 
    219231                } 
     
    232244                function go($activity_id=0, $iid=0, $auto=0) 
    233245                { 
     246                        $totalTime = microtime(true); 
     247 
    234248                        $result=Array(); 
    235249 
     
    301315                        $this->process_version  = $this->process->getVersion(); 
    302316                        $this->activity_name    = $activity->getName(); 
    303                         $this->user_name        = $GLOBALS['phpgw']->accounts->id2name($GLOBALS['user']); 
     317                        $this->user_name                = $GLOBALS['phpgw']->accounts->id2name($GLOBALS['user']); 
    304318                        $this->view_activity    = $this->GUI->gui_get_process_view_activity($this->process_id); 
    305319 
     
    315329                        $GLOBALS['workflow']['wf_user_id']                                      =& $GLOBALS['user']; 
    316330                        $GLOBALS['workflow']['wf_view_activity']                        =& $this->view_activity; 
     331                        $GLOBALS['workflow']['wf_webserver_url']                        = $GLOBALS['phpgw_info']['server']['webserver_url']; 
    317332                        $GLOBALS['workflow']['wf_workflow_path']                        = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'; 
    318333                        $GLOBALS['workflow']['wf_resources_path']                       = $GLOBALS['phpgw_info']['server']['webserver_url'] . SEP . 'workflow/redirect.php?pid=' . $this->process_id . '&file='; 
    319                         $GLOBALS['workflow']['wf_default_resources_path']       = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateLink('processes'); 
    320                         $GLOBALS['workflow']['wf_workflow_resources_path']      = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateLink(''); 
     334                        $GLOBALS['workflow']['wf_default_resources_path']       = Factory::getInstance('TemplateServer')->generateLink('processes'); 
     335                        $GLOBALS['workflow']['wf_workflow_resources_path']      = Factory::getInstance('TemplateServer')->generateLink(''); 
    321336                        $GLOBALS['workflow']['wf_activity_url']                         = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'index.php?menuaction=workflow.'.get_class($this).'.go&activity_id='.$activity_id; 
    322                         $GLOBALS['workflow']['wf_user_cnname']                          = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($GLOBALS['user']); 
     337                        $GLOBALS['workflow']['wf_user_cnname']                          = Factory::getInstance('WorkflowLDAP')->getName($GLOBALS['user']); 
    323338                        $GLOBALS['workflow']['wf_back_link']                            = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'.SEP.'index.php?start_tab=1'; 
    324339                        $GLOBALS['workflow']['wf_js_path']                                      = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'.SEP.'js'.SEP.'jscode'; 
     
    330345                        $wf =& $GLOBALS['workflow']; 
    331346 
    332                         /* CELEPAR */ 
    333347                        /* path to the local functions developed by Celepar */ 
    334348                        $functions = PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'local' . SEP . 'functions' . SEP . 'local.functions.php'; 
     
    336350                        /* activate local functions */ 
    337351                        require_once($functions); 
    338                         /* CELEPAR */ 
    339352 
    340353                        //get configuration options with default values if no init was done before 
     
    375388 
    376389                                /* check some permissions */ 
    377                                 if (($newUser == '*') || (!$this->runtime->checkUserRun($newUser)) || ($GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($newUser) === false)) 
     390                                if (($newUser == '*') || (!$this->runtime->checkUserRun($newUser)) || (Factory::getInstance('WorkflowLDAP')->getName($newUser) === false)) 
    378391                                { 
    379392                                        $_SESSION['phpgw_info']['workflow']['user_groups'] = $actualUserGroups; 
     
    385398                                        return false; 
    386399                                } 
    387                                 $smarty = CreateObject('workflow.process_smarty'); 
     400                                $smarty = Factory::getInstance('process_smarty'); 
    388401                        } 
    389402 
     
    396409                                $this->download_mode = get_var('download_mode', array('POST','GET'), false); 
    397410 
    398                                 /* #celepar# smarty code*/ 
    399  
    400                                 $smarty = CreateObject('workflow.process_smarty'); 
     411                                $smarty = Factory::getInstance('process_smarty'); 
    401412 
    402413                                $smarty->template_dir  = GALAXIA_PROCESSES.SEP.$this->process->getNormalizedName().SEP.'code'.SEP.'templates'; 
     
    418429                                $smarty->assign('wf_back_link',$GLOBALS['workflow']['wf_back_link']); 
    419430                                $smarty->assign('wf_activity_url',$GLOBALS['workflow']['wf_activity_url']); 
    420                                  
     431 
    421432                                /* register the prefilter smarty plugin wf_default_template */ 
    422433                                $smarty->load_filter('pre', 'wf_default_template'); 
     
    430441 
    431442                        /* BEGIN WORKFLOW MVC SETTINGS */ 
    432                         $env = array( );                                           //create settings vector 
     443                        $env = array();                                            //create settings vector 
    433444                        $env['view']          =& $smarty;                          //view layer instance 
    434445                        $env['template_file'] =& $_template_name;                  //template file to be shown 
    435                         $env['dao']           =& wf_create_object('wf_db');        //data access object instance 
     446                        $env['dao']                       =& Factory::newInstance('wf_db');    //data access object instance 
    436447                        $env['workflow']      =& $GLOBALS['workflow'];             //workflow environment information 
    437448                        $env['instance']      =& $instance;                        //process manager instance 
    438449                        $env['activity']      =& $activity;                        //activity manager instance 
    439                         $security             =& new SecurityUtils();              //input sanitizer class 
     450                        $security             =& Factory::newInstance('SecurityUtils');              //input sanitizer class 
    440451                        $env['request']       =& $security->process($_REQUEST);    //sanitizes input data from client 
    441                         $env['factory']       =& new ProcessFactory();             //instantiation controller class 
    442                         $env['natural']           =& wf_create_object('wf_natural');   //data access object instance for mainframe 
     452                        $env['factory']       =& Factory::getInstance('ProcessWrapperFactory');  //instantiation controller class 
     453                        $env['natural']           =& Factory::newInstance('wf_natural');   //data access object instance for mainframe 
    443454                        /* END WORKFLOW MVC SETTINGS */ 
    444455 
    445456                        $GLOBALS['workflow_env'] = &$env; 
    446                         //echo "<br><br><br><br><br>Including $source <br>In request: <pre>";print_r($_REQUEST);echo "</pre>"; 
    447                         //[__leave_activity] is setted if needed in the xxx_pre code or by the user in his code 
    448                         // HERE the user code is 'executed'. Note that we do not use include_once or require_once because 
    449                         //it could the same code several times with automatic activities looping in the graph and it still 
    450                         //need to be executed 
     457 
     458                        /** 
     459                         * [__leave_activity] is setted if needed in the xxx_pre code or by the user in his code 
     460                         * HERE the user code is 'executed'. Note that we do not use include_once or require_once because 
     461                         * it could the same code several times with automatic activities looping in the graph and it still 
     462                         * need to be executed 
     463                         */ 
    451464                        $_engineProcessCodeDirectory = GALAXIA_PROCESSES . SEP . $this->process->getNormalizedName(). SEP . 'code'; 
    452465                        $_engineCompilerDirectory = GALAXIA_LIBRARY . SEP . 'compiler'; 
     
    471484 
    472485                        /* activate the security policy */ 
    473                         $GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->enableSecurityPolicy(); 
     486                        Factory::getInstance('WorkflowSecurity')->enableSecurityPolicy(); 
     487 
     488                        /** 
     489                         * Here we are going to use our new Security static class. 
     490                         * From now, the factory frontend (static) will forward 
     491                         * the messages for the process factory instead of Workflow 
     492                         * factory. 
     493                        */ 
     494                        Security::enable(); 
    474495 
    475496                        /* include the files */ 
     497                        $processTime = microtime(true); 
     498 
    476499                        foreach ($_engineFiles as $_engineFile) 
    477                                 require $_engineFile; 
     500                                require_once $_engineFile; 
     501 
     502                        $processTime = (microtime(true) - $processTime); 
    478503 
    479504                        unset($GLOBALS['workflow_env']); 
     
    517542                        } 
    518543 
     544                        $totalTime = (microtime(true) - $totalTime); 
     545 
     546                        $logTime = sprintf("GO [pid=%s,iid=%s,uid=%s,aid=%s] [eng=%ss,proc=%ss]", 
     547                                                                $this->process_id, 
     548                                                                $this->instance_id, 
     549                                                                $GLOBALS['user'], 
     550                                                                $this->activity_id, 
     551                                                                number_format(($totalTime - $processTime),3), 
     552                                                                number_format($processTime,3) ); 
     553 
     554                        $this->logger->debug($logTime); 
     555 
    519556                        // TODO: process instance comments 
    520  
    521557                        $instructions = $this->runtime->handle_postUserCode(_DEBUG); 
    522558                        switch($instructions['action']) 
     
    582618                function goAjax($activity_id=0, $iid=0, $auto=0) 
    583619                { 
     620                        $totalTime = microtime(true); 
     621 
    584622                        $result=Array(); 
    585623 
     
    660698                        $GLOBALS['workflow']['wf_workflow_path']                        = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'; 
    661699                        $GLOBALS['workflow']['wf_resources_path']                       = $GLOBALS['phpgw_info']['server']['webserver_url'] . SEP . 'workflow/redirect.php?pid=' . $this->process_id . '&file='; 
    662                         $GLOBALS['workflow']['wf_default_resources_path']       = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateLink('processes'); 
    663                         $GLOBALS['workflow']['wf_workflow_resources_path']      = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateLink(''); 
     700                        $GLOBALS['workflow']['wf_default_resources_path']       = Factory::getInstance('TemplateServer')->generateLink('processes'); 
     701                        $GLOBALS['workflow']['wf_workflow_resources_path']      = Factory::getInstance('TemplateServer')->generateLink(''); 
    664702                        $GLOBALS['workflow']['wf_activity_url']                         = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'index.php?menuaction=workflow.'.get_class($this).'.go&activity_id='.$activity_id; 
    665                         $GLOBALS['workflow']['wf_user_cnname']                          = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($GLOBALS['user']); 
     703                        $GLOBALS['workflow']['wf_user_cnname']                          = Factory::getInstance('WorkflowLDAP')->getName($GLOBALS['user']); 
    666704                        $GLOBALS['workflow']['wf_back_link']                            = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'.SEP.'index.php?start_tab=1'; 
    667705                        $GLOBALS['workflow']['wf_js_path']                                      = $GLOBALS['phpgw_info']['server']['webserver_url'].SEP.'workflow'.SEP.'js'.SEP.'jscode'; 
     
    672710                                unset($GLOBALS['workflow']['wf_instance_url']); 
    673711 
    674                         /* CELEPAR */ 
    675712                        /* activate local functions */ 
    676713                        require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'local' . SEP . 'functions' . SEP . 'local.functions.php'); 
    677                         /* CELEPAR */ 
    678714 
    679715                        //get configuration options with default values if no init was done before 
     
    693729 
    694730                        /* BEGIN WORKFLOW MVC SETTINGS */ 
    695                         $env = array( );                                           //create settings vector 
    696                         $env['dao']           =& wf_create_object('wf_db');        //data access object instance 
     731                        $env = array();                                            //create settings vector 
     732                        $env['dao']                       =& Factory::newInstance('wf_db');    //data access object instance 
    697733                        $env['workflow']      =& $GLOBALS['workflow'];             //workflow environment information 
    698734                        $env['instance']      =& $instance;                        //process manager instance 
    699735                        $env['activity']      =& $activity;                        //activity manager instance 
    700                         $security             =& new SecurityUtils();              //input sanitizer class 
     736                        $security             =& Factory::newInstance('SecurityUtils'); //input sanitizer class 
    701737                        $env['request']       =& $security->process($_REQUEST); //sanitizes input data from client 
    702                         $env['factory']       =& new ProcessFactory();                     //instantiation controller class 
    703                         $env['natural']           =& wf_create_object('wf_natural');   //data access object instance for mainframe 
     738                        $env['factory']       =& Factory::newInstance('ProcessWrapperFactory');  //instantiation controller class 
     739                        $env['natural']           =& Factory::newInstance('wf_natural');   //data access object instance for mainframe 
    704740                        /* END WORKFLOW MVC SETTINGS */ 
    705741 
     
    711747 
    712748                        /* activate the security policy */ 
    713                         $GLOBALS['workflow']['factory']->getInstance('WorkflowSecurity')->enableSecurityPolicy(); 
     749                        Factory::getInstance('WorkflowSecurity')->enableSecurityPolicy(); 
     750 
     751                        /** 
     752                         * here we are going to use our new Security static class. 
     753                         * From now, the factory frontend (static) will forward 
     754                         * the messages for the process factory instead of Workflow 
     755                         * factory. Note that this is the same comment as the previous 
     756                         * function... boooring.. 
     757                         */ 
     758                        Security::enable(); 
    714759 
    715760                        $GLOBALS['workflow_env'] = &$env; 
    716                         $nc = new NanoController(); 
     761                        $nc = &Factory::newInstance('NanoController'); 
    717762                        $nc->setClassPath(GALAXIA_PROCESSES . SEP . $this->process->getNormalizedName(). SEP . 'code'); 
     763 
     764                        $processTime = microtime(true); 
    718765                        $nc->iterateOverVirtualRequests(); 
     766                        $processTime = microtime(true) - $processTime; 
     767 
    719768                        $nc->outputResultData(); 
    720769                        unset($GLOBALS['workflow_env']); 
     
    722771                        if (!is_null($iid)) 
    723772                                $instance->instance->sync(); 
     773 
     774                        $totalTime = microtime(true) - $totalTime; 
     775 
     776                        $logTime = sprintf("GOAJAX [pid=%s,iid=%s,uid=%s,aid=%s] [eng=%ss,proc=%ss]", 
     777                                                                $this->process_id, 
     778                                                                $this->instance_id, 
     779                                                                $GLOBALS['user'], 
     780                                                                $this->activity_id, 
     781                                                                number_format(($totalTime - $processTime),3), 
     782                                                                number_format($processTime,3) ); 
     783 
     784                        $this->logger->debug($logTime); 
    724785                } 
    725786 
     
    850911                { 
    851912                        $headerConfig = 0; 
    852                         if (!$this->download_mode) 
     913                        if (!$this->download_mode and !$this->print_mode) 
    853914                        { 
    854915                                $headerConfig |= workflow_smarty::SHOW_HEADER | workflow_smarty::SHOW_FOOTER; 
  • branches/2.2/workflow/inc/class.so_adminaccess.inc.php

    r795 r3167  
    7777        { 
    7878                $output = array(); 
    79                 $names = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getNames($userIDs); 
     79                $names = Factory::getInstance('WorkflowLDAP')->getNames($userIDs); 
    8080                foreach ($names as $name) 
    8181                        $output[] = array( 
     
    201201                if (!is_object($GLOBALS['phpgw']->acl)) 
    202202                { 
    203                         $GLOBALS['phpgw']->db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso(); 
    204                         $GLOBALS['phpgw']->acl = &$GLOBALS['workflow']['factory']->getForeignInstance('phpgwapi', 'acl', $userID); 
     203                        $GLOBALS['phpgw']->db =& Factory::getInstance('WorkflowObjects')->getDBExpresso(); 
     204                        $GLOBALS['phpgw']->acl =& Factory::getInstance('acl', $userID); 
    205205                } 
    206206 
  • branches/2.2/workflow/inc/class.so_adminjobs.inc.php

    r795 r3167  
    1010\**************************************************************************/ 
    1111 
    12 require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php'; 
    13 require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'JobManager.php'; 
    14 require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php'; 
    1512 
    1613/** 
     
    9693                $this->isAdmin = $_SESSION['phpgw_info']['workflow']['user_is_admin']; 
    9794                $this->acl = &$GLOBALS['ajax']->acl; 
    98                 $this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID; 
    99                 $this->jobManager = new JobManager(&$this->db); 
     95                $this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 
     96                $this->jobManager = &Factory::newInstance('JobManager'); 
    10097        } 
    10198 
     
    229226                $output = array(); 
    230227                $job = $this->jobManager->getJob($jobID); 
    231                 $jobScheduler = &$GLOBALS['workflow']['factory']->getInstance('JobScheduler'); 
     228                $jobScheduler =& Factory::getInstance('JobScheduler'); 
    232229                $totalTime = microtime(true); 
    233230                $thread = $jobScheduler->execute($job, true); 
  • branches/2.2/workflow/inc/class.so_agent.inc.php

    r795 r3167  
    2626{ 
    2727        //public functions 
    28          
     28 
    2929        /** 
    3030         * @var array $public_functions Array of public functions 
    31          * @access public  
     31         * @access public 
    3232         */ 
    3333        var $public_functions = array( 
     
    3636        ); 
    3737        /** 
    38          * @var array $wf_table  
     38         * @var array $wf_table 
    3939         * @access public 
    4040         */ 
    4141        var $wf_table = 'egw_wf_agent_'; 
    4242        /** 
    43          * @var string $agent_table  
     43         * @var string $agent_table 
    4444         * @access public 
    4545         */ 
    4646        var $agent_table = ''; 
    47          
     47 
    4848        // link to the global db-object 
    49          
     49 
    5050        /** 
    51          * @var object $db objeto para conexao do banco de dados  
     51         * @var object $db objeto para conexao do banco de dados 
    5252         * @access public 
    5353         */ 
    5454        var $db; 
    55          
     55 
    5656        /** 
    5757         * Constructor of the so_agent class 
    5858         * do not forget to call it (parent::so_agent();) in child classes 
    5959         * @access public 
    60          * @return object  
     60         * @return object 
    6161         */ 
    62          
     62 
    6363        function so_agent() 
    6464        { 
    65                 $this->db =& $GLOBALS['workflow']['workflowObjects']->getDBGalaxia(); 
     65                $this->db =& Factory::getInstance('WorkflowObjects')->getDBGalaxia(); 
    6666        } 
    67          
     67 
    6868        /** 
    6969         * @abstract read all agent datas from the database 
  • branches/2.2/workflow/inc/class.so_external_applications.inc.php

    r795 r3167  
    130130                $this->isAdmin = $_SESSION['phpgw_info']['workflow']['user_is_admin']; 
    131131                $this->acl = &$GLOBALS['ajax']->acl; 
    132                 $this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID; 
     132                $this->db =& Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 
    133133                $this->EXTERNAL_APPLICATION_PATH = $_SESSION['phpgw_info']['workflow']['server']['files_dir'] . '/workflow//workflow/external_applications'; 
    134134        } 
  • branches/2.2/workflow/inc/class.so_move_instances.inc.php

    r795 r3167  
    1111\**************************************************************************/ 
    1212 
    13 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php'); 
    14 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php'); 
    1513 
    1614/** 
     
    9189                $this->userID = $_SESSION['phpgw_info']['workflow']['account_id']; 
    9290                $this->isAdmin = $_SESSION['phpgw_info']['workflow']['user_is_admin']; 
    93                 $this->acl = &$GLOBALS['ajax']->acl; 
    94                 $this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID; 
     91                $this->acl =& $GLOBALS['ajax']->acl; 
     92                $this->db =& Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 
    9593        } 
    9694 
     
    113111                                $where[] = 'wf_p_id IS NULL'; 
    114112                } 
    115                 $processManager = new ProcessManager($this->db); 
     113                $processManager = &Factory::getInstance('ProcessManager'); 
    116114 
    117115                /* workaround to sort the result using two columns */ 
     
    137135                $this->_checkAccess($processID); 
    138136 
    139                 $activityManager = new ActivityManager($this->db); 
     137                $activityManager = &Factory::newInstance('ActivityManager'); 
    140138                $activities = $activityManager->list_activities($processID, 0, -1, 'wf_name__ASC', '', 'wf_type <> \'standalone\' AND wf_type <> \'view\''); 
    141139                $output = array(); 
     
    320318                } 
    321319 
    322                 /* format the array elements for use in a SELECT SQL statement, e.g. [iid => 12, aid = 27] would produce (12, 27) */ 
    323                 $instanceActivityList = array_map(create_function('$e', 'return \'(\' . $e[\'iid\'] . \', \' . $e[\'aid\'] . \')\';'), $instanceActivityList); 
    324  
    325                 /* update the interinstance relations of the modified rows of the instance_activities table */ 
    326                 $resultSet = $this->db->query("SELECT wf_parent_instance_id, wf_parent_activity_id FROM egw_wf_interinstance_relations WHERE ((wf_parent_instance_id, wf_parent_activity_id) IN (" . implode(', ', $instanceActivityList) . "))"); 
    327                 $rows = $resultSet->GetArray(-1); 
    328                 if (is_array($rows)) 
    329                 { 
    330                         foreach ($rows as $row) 
    331                         { 
    332                                 /* update the activity ID */ 
    333                                 if (!$this->db->query("UPDATE egw_wf_interinstance_relations SET wf_parent_activity_id = ? WHERE (wf_parent_instance_id = ?) AND (wf_parent_activity_id = ?)", array($activitiesConvert[$row['wf_parent_activity_id']], $row['wf_parent_instance_id'], $row['wf_parent_activity_id']))) 
    334                                 { 
    335                                         $this->db->FailTrans(); 
    336                                         return array('error' => 'Erro atualizando a tabela de relacionamento inter-instância. Nenhuma modificação foi salva'); 
    337                                 } 
    338                         } 
    339                 } 
    340  
    341320                /* in case of success, commit the modifications */ 
    342321                $this->db->CompleteTrans(); 
  • branches/2.2/workflow/inc/class.so_orgchart.inc.php

    r1446 r3167  
    127127                $this->isAdmin = $_SESSION['phpgw_info']['workflow']['user_is_admin']; 
    128128                $this->acl = &$GLOBALS['ajax']->acl; 
    129                 $this->db = &$GLOBALS['workflow']['workflowObjects']->getDBWorkflow()->Link_ID; 
    130                 $this->db = &$GLOBALS['workflow']['workflowObjects']->getDBWorkflow()->Link_ID; 
     129                $this->db = &Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Link_ID; 
     130                $this->db = &Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Link_ID; 
    131131                $this->db->SetFetchMode(ADODB_FETCH_ASSOC); 
    132132        } 
     
    699699                $this->_checkAccess($organizationID); 
    700700 
    701                 $supervisors = '{' . implode(', ', $this->db->GetRow('SELECT COALESCE(titular_funcionario_id, -1) AS titular_funcionario_id, COALESCE(substituto_funcionario_id, -1) AS substituto_funcionario_id FROM area WHERE (area_id = ?) AND (organizacao_id = ?)', array($areaID, $organizationID))) . '}'; 
     701                /* gather some info from the area */ 
     702                $areaInfo = $this->db->query('SELECT COALESCE(a.titular_funcionario_id, -1) AS titular_funcionario_id, COALESCE(s.funcionario_id, -1) AS substituto_funcionario_id FROM area a LEFT OUTER JOIN substituicao s ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) WHERE (a.organizacao_id = ?) AND (a.area_id = ?)', array($organizationID, $areaID))->GetArray(-1); 
     703                if (empty($areaInfo)) 
     704                        return false; 
     705                $areaInfo = $areaInfo[0]; 
     706                $supervisors = '{' . implode(', ', $areaInfo) . '}'; 
     707 
    702708                $query = "SELECT funcionario_id, funcionario_status_id, centro_custo_id, localidade_id, organizacao_id, area_id, cargo_id, nivel, funcionario_categoria_id, titulo FROM funcionario WHERE ((area_id = ?) AND (organizacao_id = ?)) OR (funcionario_id = ANY (?))"; 
    703709                $result = $this->db->query($query, array($areaID, $organizationID, $supervisors)); 
     
    705711 
    706712                $output = $result->GetArray(-1); 
    707                 $cachedLDAP = $GLOBALS['workflow']['factory']->newInstance('CachedLDAP'); 
     713                $cachedLDAP = Factory::newInstance('CachedLDAP'); 
    708714                $cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP_DATABASE); 
    709715                for ($i = 0; $i < count($output); $i++) 
     
    711717                        $output[$i]['funcionario_id_desc'] = ''; 
    712718                        $output[$i]['uid'] = ''; 
     719 
     720                        if (in_array($output[$i]['funcionario_id'], $areaInfo)) 
     721                                $output[$i]['chief'] = ($output[$i]['funcionario_id'] == $areaInfo['titular_funcionario_id']) ? 1 : 2; 
     722 
    713723                        if (($entry = $cachedLDAP->getEntryByID($output[$i]['funcionario_id']))) 
    714724                        { 
     
    739749                $unifiedResult = array(); 
    740750 
     751                /* FIXME - this piece of code should use the new CacheLdap class */ 
    741752                if (is_numeric($searchTerm)) 
    742753                { 
     
    754765 
    755766                /* search for the $searchTerm in the LDAP */ 
    756                 $ldap = &$GLOBALS['workflow']['workflowObjects']->getLDAP(); 
    757                 $list = @ldap_search($ldap, $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getLDAPContext(), $ldapSearch, array('uidnumber', 'cn', 'uid')); 
     767                $ldap = &Factory::getInstance('WorkflowObjects')->getLDAP(); 
     768                $list = @ldap_search($ldap, Factory::getInstance('WorkflowLDAP')->getLDAPContext(), $ldapSearch, array('uidnumber', 'cn', 'uid')); 
    758769                if ($list === false) 
    759770                        die(serialize("O sistema de busca não pode ser utilizado nesta organização.")); 
     
    763774 
    764775                /* search for the $searchTerm in the DB */ 
    765                 $resultSet = $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID->query($DBSearch, $DBValues)->GetArray(-1); 
     776                $resultSet = Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID->query($DBSearch, $DBValues)->GetArray(-1); 
    766777                foreach ($resultSet as $row) 
    767778                        if (!isset($unifiedResult[$row['uidnumber']])) 
     
    812823                { 
    813824                        $errors = array( 
    814                                 "O funcionário \"" . $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($employeeID) . "\" já pertença à área \"{$row['sigla']}\".", 
     825                                "O funcionário \"" . Factory::getInstance('WorkflowLDAP')->getName($employeeID) . "\" já pertença à área \"{$row['sigla']}\".", 
    815826                                '-----------------', 
    816827                                'Caso você queira colocá-lo na área selecionada, siga o procedimento: faça uma busca por seu nome, clique para editá-lo e, troque pela área desejada.' 
     
    862873                $this->_checkAccess($organizationID); 
    863874 
    864                 $query = 'SELECT sigla FROM area WHERE (? IN (titular_funcionario_id, substituto_funcionario_id, auxiliar_funcionario_id))'; 
     875                $query = 'SELECT DISTINCT(a.sigla) FROM area a LEFT OUTER JOIN substituicao s USING (area_id) WHERE (? IN (a.titular_funcionario_id, s.funcionario_id, a.auxiliar_funcionario_id))'; 
    865876                $areas = array(); 
    866877                $resultSet = $this->db->query($query, $employeeID); 
     
    870881                { 
    871882                        $errors = array( 
    872                                 "O funcionário \"" . $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($employeeID) . "\" é titular, substituto ou auxiliar administrativo das seguintes áreas: " . implode(", ", $areas), 
     883                                "O funcionário \"" . Factory::getInstance('WorkflowLDAP')->getName($employeeID) . "\" é titular, substituto, já participou de substituição ou é auxiliar administrativo das seguintes áreas: " . implode(", ", $areas), 
    873884                                '-----------------', 
    874885                                'Se você quiser excluir este funcionário, precisa removê-lo dos "cargos" que ele possui nas áreas citadas.' 
     
    890901         * @access public 
    891902         */ 
    892         function getArea($organizationID) 
     903        function getArea($organizationID, $areaID = -1) 
    893904        { 
    894905                $this->_checkAccess($organizationID); 
    895906 
    896907                $output = array(); 
    897  
    898                 $query = "SELECT area_id, centro_custo_id, organizacao_id, area_status_id, substituto_funcionario_id, titular_funcionario_id, superior_area_id, sigla, descricao, ativa, auxiliar_funcionario_id FROM area WHERE organizacao_id = ? ORDER BY sigla"; 
    899                 $result = $this->db->query($query, array($organizationID)); 
    900                 $this->_checkError($result); 
    901  
    902                 $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     908                $values = array($organizationID); 
     909 
     910                // if we are looking for a specific area 
     911                $area_condition = ""; 
     912                if (($areaID != -1) && !empty($areaID)) { 
     913                        $area_condition = " AND a.area_id = ? "; 
     914                        $values[]= $areaID; 
     915                } 
     916 
     917                $query = "SELECT a.area_id, a.centro_custo_id, a.organizacao_id, a.area_status_id, a.titular_funcionario_id, a.superior_area_id, a.sigla, a.descricao, a.ativa, a.auxiliar_funcionario_id, s.funcionario_id as substituto_funcionario_id FROM area a LEFT OUTER JOIN substituicao s ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) WHERE organizacao_id = ? " . $area_condition . " ORDER BY sigla"; 
     918                $result = $this->db->query($query, $values); 
     919                $this->_checkError($result); 
     920 
     921                $ldap = &Factory::getInstance('WorkflowLDAP'); 
    903922                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) 
    904923                { 
     
    958977         * @param int $organizationID O ID da organização. 
    959978         * @param int $areaStatusID O ID do status da área. 
    960          * @param int $backupEmployeeID O ID do funcionário que está substituindo o superior da área. 
    961979         * @param int $supervisorID O ID do funcionário que é superior da área. 
    962980         * @param int $superiorAreaID O ID da área que é superior a que está sendo adicionada (NULL caso não possua área superior). 
     
    968986         * @access public 
    969987         */ 
    970         function addArea($costCenterID, $organizationID, $areaStatusID, $backupEmployeeID, $supervisorID, $superiorAreaID, $acronym, $description, $active, $assistantID) 
    971         { 
    972                 $this->_checkAccess($organizationID); 
    973  
    974                 $checkEmployees = array($backupEmployeeID, $supervisorID, $assistantID); 
     988        function addArea($costCenterID, $organizationID, $areaStatusID, $supervisorID, $superiorAreaID, $acronym, $description, $active, $assistantID) 
     989        { 
     990                $this->_checkAccess($organizationID); 
     991 
     992                $checkEmployees = array($supervisorID, $assistantID); 
    975993                $errors = array(); 
    976994                foreach ($checkEmployees as $checkEmployee) 
     
    981999                        $query = 'SELECT 1 FROM funcionario WHERE (funcionario_id = ?)'; 
    9821000                        if (!$this->db->query($query, $checkEmployee)->fetchRow()) 
    983                                 $errors[] = "O funcionário \"" . $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($checkEmployee) . "\" não está vinculado a uma área."; 
     1001                                $errors[] = "O funcionário \"" . Factory::getInstance('WorkflowLDAP')->getName($checkEmployee) . "\" não está vinculado a uma área."; 
    9841002                } 
    9851003 
     
    9911009                } 
    9921010 
    993                 $query = "INSERT INTO area(centro_custo_id, organizacao_id, area_status_id, substituto_funcionario_id, titular_funcionario_id, superior_area_id, sigla, descricao, ativa, auxiliar_funcionario_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; 
    994                 $result = $this->db->query($query, array($costCenterID, $organizationID, $areaStatusID, $backupEmployeeID, $supervisorID, $superiorAreaID, $acronym, $description, $active, $assistantID)); 
     1011                $query = "INSERT INTO area(centro_custo_id, organizacao_id, area_status_id, titular_funcionario_id, superior_area_id, sigla, descricao, ativa, auxiliar_funcionario_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; 
     1012                $result = $this->db->query($query, array($costCenterID, $organizationID, $areaStatusID, $supervisorID, $superiorAreaID, $acronym, $description, $active, $assistantID)); 
    9951013                $this->_checkError($result); 
    9961014 
     
    10031021         * @param int $organizationID O ID da organização. 
    10041022         * @param int $areaStatusID O ID do status da área. 
    1005          * @param int $backupEmployeeID O ID do funcionário que está substituindo o superior da área. 
    10061023         * @param int $supervisorID O ID do funcionário que é superior da área. 
    10071024         * @param int $superiorAreaID O ID da área que é superior a que está sendo atualizada (NULL caso não possua área superior). 
     
    10141031         * @access public 
    10151032         */ 
    1016         function updateArea($costCenterID, $organizationID, $areaStatusID, $backupEmployeeID, $supervisorID, $superiorAreaID, $acronym, $description, $active, $assistantID, $areaID) 
    1017         { 
    1018                 $this->_checkAccess($organizationID); 
    1019  
    1020                 $checkEmployees = array($backupEmployeeID, $supervisorID, $assistantID); 
     1033        function updateArea($costCenterID, $organizationID, $areaStatusID, $supervisorID, $superiorAreaID, $acronym, $description, $active, $assistantID, $areaID) 
     1034        { 
     1035                $this->_checkAccess($organizationID); 
     1036 
     1037                $checkEmployees = array($supervisorID, $assistantID); 
    10211038                $errors = array(); 
    10221039                foreach ($checkEmployees as $checkEmployee) 
     
    10271044                        $query = 'SELECT 1 FROM funcionario WHERE (funcionario_id = ?)'; 
    10281045                        if (!$this->db->query($query, $checkEmployee)->fetchRow()) 
    1029                                 $errors[] = "O funcionário \"" . $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($checkEmployee) . "\" não está vinculado a uma área."; 
     1046                                $errors[] = "O funcionário \"" . Factory::getInstance('WorkflowLDAP')->getName($checkEmployee) . "\" não está vinculado a uma área."; 
    10301047                } 
    10311048 
     
    10331050                { 
    10341051                        $errors[] = '-----------------'; 
    1035                         $errors[] = 'Somente funcionários que estão vinculados a alguma área podem ser colocados na posição de titular, substituto ou auxiliar administrativo.'; 
     1052                        $errors[] = 'Somente funcionários que estão vinculados a alguma área podem ser colocados na posição de titular ou auxiliar administrativo.'; 
    10361053                        $this->endExecution($errors); 
    10371054                } 
    10381055 
    1039                 $query = "UPDATE area SET centro_custo_id = ?, organizacao_id = ?, area_status_id = ?, substituto_funcionario_id = ?, titular_funcionario_id = ?, superior_area_id = ?, sigla = ?, descricao = ?, ativa = ?, auxiliar_funcionario_id = ? WHERE (area_id = ?)"; 
    1040                 $result = $this->db->query($query, array($costCenterID, $organizationID, $areaStatusID, $backupEmployeeID, $supervisorID, $superiorAreaID, $acronym, $description, $active, $assistantID, $areaID)); 
     1056                $query = "UPDATE area SET centro_custo_id = ?, organizacao_id = ?, area_status_id = ?, titular_funcionario_id = ?, superior_area_id = ?, sigla = ?, descricao = ?, ativa = ?, auxiliar_funcionario_id = ? WHERE (area_id = ?)"; 
     1057                $result = $this->db->query($query, array($costCenterID, $organizationID, $areaStatusID, $supervisorID, $superiorAreaID, $acronym, $description, $active, $assistantID, $areaID)); 
    10411058                $this->_checkError($result); 
    10421059 
     
    10741091                $this->_checkAccess($organizationID, false, true); 
    10751092 
     1093                /** 
     1094                 * This is so wrong.. We should always use the factory to 
     1095                 * instantiate stuff. Besides, module class should not 
     1096                 * use process classes; the correct is to do the inverse. 
     1097                 */ 
    10761098                require_once dirname(__FILE__) . '/local/classes/class.wf_orgchart.php'; 
    10771099                $orgchart = new wf_orgchart(); 
     
    10791101                $outputInfo = array(); 
    10801102 
    1081                 $cachedLDAP = $GLOBALS['workflow']['factory']->newInstance('CachedLDAP'); 
     1103                $cachedLDAP = Factory::newInstance('CachedLDAP'); 
     1104 
     1105                /* here we need fresh information. Let's access ldap first */ 
    10821106                $cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP_DATABASE); 
    10831107                $employeeEntry = $cachedLDAP->getEntryByID($employeeID); 
     
    12431267                ); 
    12441268 
    1245                 $cachedLDAP = $GLOBALS['workflow']['factory']->newInstance('CachedLDAP'); 
     1269                $cachedLDAP = Factory::newInstance('CachedLDAP'); 
    12461270                $cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_LDAP_DATABASE); 
    12471271                if (!empty($areaInfo['titular_funcionario_id'])) 
     
    13571381                return ( ( $result === false ) ? false : true ); 
    13581382        } 
     1383 
     1384        /** 
     1385         * Validate start and end dates for a substitution 
     1386         * @param int $areaID Area's ID. 
     1387         * @param string $date_start Substitution's start date. 
     1388         * @param string $date_start Substitution's end date. 
     1389         * @return bool 
     1390         * @access private 
     1391         */ 
     1392        function validateSubstitutionDates($areaID, $date_start, $date_end, $substitutionID = -1) 
     1393        { 
     1394                /* TODO 
     1395                * I'm not supose to be here.. (date validations speaking) 
     1396                * move me to some validation class! 
     1397                */  
     1398 
     1399                /* validating dates */ 
     1400                $date_pattern = '/^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/[12][0-9]{3}$/'; 
     1401 
     1402                if (!preg_match($date_pattern, $date_start)) 
     1403                        $this->endExecution("Formato inválido para data de início."); 
     1404                if (!preg_match($date_pattern, $date_end)) 
     1405                        $this->endExecution("Formato inválido para data de término. "); 
     1406 
     1407                $date_start_arr = explode('/', $date_start); 
     1408                $date_end_arr = explode('/', $date_end); 
     1409 
     1410                /* is it a gregorian date? */ 
     1411                if (!checkdate($date_start_arr[1], $date_start_arr[0], $date_start_arr[2])) 
     1412                        $this->endExecution("Data de início inválida."); 
     1413                if (!checkdate($date_end_arr[1], $date_end_arr[0], $date_end_arr[2])) 
     1414                        $this->endExecution("Data de término inválida. "); 
     1415 
     1416                /* is date_end greater then date_start? */ 
     1417                if (mktime(0,0,0, $date_start_arr[1], $date_start_arr[0], $date_start_arr[2]) >= mktime(0,0,0, $date_end_arr[1], $date_end_arr[0], $date_end_arr[2])) 
     1418                        $this->endExecution("A data de término deve ser maior que a data de início."); 
     1419 
     1420                /* preparing dates to database */ 
     1421                $date_start = implode('-', array_reverse($date_start_arr)); 
     1422                $date_end = implode('-', array_reverse($date_end_arr)); 
     1423 
     1424                /* checking if there is a substitution in conflict with these dates */ 
     1425                $query  = "SELECT * FROM substituicao WHERE "; 
     1426                $query .= "     area_id = ? "; 
     1427                $query .= " AND "; 
     1428                $query .= "     substituicao_id != ? "; 
     1429                $query .= " AND "; 
     1430                $query .= "     ("; 
     1431                $query .= "             (? BETWEEN data_inicio AND data_fim) "; 
     1432                $query .= "     OR "; 
     1433                $query .= "             (? BETWEEN data_inicio AND data_fim)"; 
     1434                $query .= "     OR "; 
     1435                $query .= "             (data_inicio BETWEEN ? AND ?)"; 
     1436                $query .= "     ) "; 
     1437 
     1438                // raise an error if there is any record 
     1439                if ($row = $this->db->query($query, array( $areaID, $substitutionID, $date_start, $date_end, $date_start, $date_end ))->fetchRow()) 
     1440                { 
     1441                        $row['data_inicio'] = implode('/', array_reverse(explode('-', $row['data_inicio']))); 
     1442                        $row['data_fim'] = implode('/', array_reverse(explode('-', $row['data_fim']))); 
     1443                        $this->endExecution('Já existe uma substituição no período de '. $row['data_inicio'] . ' a ' . $row['data_fim']); 
     1444                } 
     1445                return true; 
     1446        } 
     1447 
     1448        /** 
     1449         * Add a substitution. 
     1450         * @param int $organizationID Organization's ID. 
     1451         * @param int $areaID Area's ID. 
     1452         * @param int $substituteID Substitute's employee ID. 
     1453         * @param string $date_start Substitution's start date. 
     1454         * @param string $date_start Substitution's end date. 
     1455         * @return bool 
     1456         * @access public 
     1457         */ 
     1458        function addSubstitution( $organizationID, $areaID, $substituteID, $date_start, $date_end ) 
     1459        { 
     1460                $this->_checkAccess( $organizationID ); 
     1461 
     1462                if (!$this->validateSubstitutionDates($areaID, $date_start, $date_end)) 
     1463                        return false; 
     1464 
     1465                /* formating dates */ 
     1466                $date_start = implode('-', array_reverse(explode('/', $date_start))); 
     1467                $date_end = implode('-', array_reverse(explode('/', $date_end))); 
     1468 
     1469                $query = "INSERT INTO substituicao (area_id, funcionario_id, data_inicio, data_fim) VALUES (?, ?, ?, ?)"; 
     1470                $result = $this -> db -> query( $query, array( $areaID, $substituteID, $date_start, $date_end ) ); 
     1471                $this->_checkError( $result ); 
     1472                 
     1473                return ( ( $result === false ) ? false : true ); 
     1474        } 
     1475 
     1476        /** 
     1477         * Update a substitution. 
     1478         * @param int $organizationID Organization's ID. 
     1479         * @param int $areaID Area's ID. 
     1480         * @param int $substituteID Substitute's employee ID. 
     1481         * @param string $date_start Substitution's start date. 
     1482         * @param string $date_start Substitution's end date. 
     1483         * @return bool 
     1484         * @access public 
     1485         */ 
     1486        function updateSubstitution( $organizationID, $areaID, $substituteID, $date_start, $date_end, $substitutionID ) 
     1487        { 
     1488                $this->_checkAccess( $organizationID ); 
     1489 
     1490                if (!$this->validateSubstitutionDates($areaID, $date_start, $date_end, $substitutionID)) 
     1491                        return false; 
     1492 
     1493                /* formating dates */ 
     1494                $date_start = implode('-', array_reverse(explode('/', $date_start))); 
     1495                $date_end = implode('-', array_reverse(explode('/', $date_end))); 
     1496 
     1497                $query = "UPDATE substituicao SET funcionario_id = ?, data_inicio = ?, data_fim = ? WHERE substituicao_id = ?"; 
     1498                $result = $this -> db -> query( $query, array( $substituteID, $date_start, $date_end, $substitutionID ) ); 
     1499                $this->_checkError( $result ); 
     1500                 
     1501                return ( ( $result === false ) ? false : true ); 
     1502        } 
     1503 
     1504        /** 
     1505         * List all the substituions for a given area 
     1506         * @return array List of the substitutions 
     1507         * @access public 
     1508         */ 
     1509        function getSubstitutions( $organizationID, $areaID ) 
     1510        { 
     1511                $this -> _checkAccess( $organizationID ); 
     1512 
     1513                /* we must join area table to get organizacao_id */ 
     1514                $query = "SELECT s.*, a.organizacao_id FROM substituicao s INNER JOIN area a USING(area_id) WHERE area_id = ? ORDER BY data_inicio DESC"; 
     1515                $result = $this -> db -> query( $query, array( $areaID ) ); 
     1516                $this -> _checkError( $result ); 
     1517 
     1518                /* we must query ldap to get full user names. In workflow db we just store uids */ 
     1519                $cachedLDAP = Factory::getInstance('CachedLDAP'); 
     1520 
     1521                $output = $result->GetArray(-1); 
     1522                for ($i = 0; $i < count($output); $i++) { 
     1523                        for ($j = 0; $j < $result->_numOfFields; $j++) 
     1524                                unset($output[$i][$j]); 
     1525 
     1526                        /* including substitute full name */ 
     1527                        $ldap_result = $cachedLDAP->getEntryByID($output[$i]['funcionario_id']); 
     1528                        $output[$i]['substituto_funcionario_id'] = $output[$i]['funcionario_id']; 
     1529                        $output[$i]['substituto_funcionario_id_desc'] = $ldap_result['cn']; 
     1530 
     1531                        /* formating dates */ 
     1532                        $output[$i]['data_inicio'] = implode('/', array_reverse(explode('-', $output[$i]['data_inicio']))); 
     1533                        $output[$i]['data_fim'] = implode('/', array_reverse(explode('-', $output[$i]['data_fim']))); 
     1534                } 
     1535                return $output; 
     1536        } 
     1537 
     1538        /** 
     1539         * Remove a substitution 
     1540         * @param int $organizationID Organization's ID 
     1541         * @param int $telephoneID Substitution's ID 
     1542         * @return bool  
     1543         * @access public 
     1544         */ 
     1545        function removeSubstitution( $organizationID, $substitutionID ) 
     1546        { 
     1547                $this->_checkAccess( $organizationID ); 
     1548 
     1549                $query = "DELETE FROM substituicao WHERE substituicao_id = ?"; 
     1550                $result = $this -> db -> query( $query, array( $substitutionID ) ); 
     1551                $this -> _checkError( $result ); 
     1552 
     1553                return ( ( $result === false ) ? false : true ); 
     1554        } 
    13591555} 
    13601556?> 
  • branches/2.2/workflow/inc/class.so_userinterface.inc.php

    r1470 r3167  
    11<?php 
    2 require_once($_SESSION['phpgw_info']['workflow']['phpgw_api_inc'] . '/class.config.inc.php'); 
    32 
    43/** 
     
    2221        function so_userinterface() 
    2322        { 
    24                 $this->db = &$GLOBALS['workflow']['workflowObjects']->getDBWorkflow()->Link_ID; 
     23                $this->db =& Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Link_ID; 
    2524                $this->db->SetFetchMode(ADODB_FETCH_ASSOC); 
    2625        } 
     
    6160                $oldDB = $GLOBALS['phpgw']->db; 
    6261                $GLOBALS['phpgw']->db = $GLOBALS['ajax']->db; 
    63                 $config = new config('workflow'); 
     62                $config = &Factory::getInstance('config', 'workflow'); 
    6463                $configValues = $config->read_repository(); 
    6564                $submasksString = $configValues['intranet_subnetworks']; 
     
    9392                if (!empty($externalApplicationsID)) 
    9493                { 
    95                         $result = $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID->query("SELECT DISTINCT external_application_id, name, address, image, authentication, intranet_only FROM egw_wf_external_application WHERE (external_application_id IN (" . implode(', ', $externalApplicationsID)  . ")) ORDER BY name"); 
     94                        $result = Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID->query("SELECT DISTINCT external_application_id, name, address, image, authentication, intranet_only FROM egw_wf_external_application WHERE (external_application_id IN (" . implode(', ', $externalApplicationsID)  . ")) ORDER BY name"); 
    9695                        $preOutput = $result->GetArray(-1); 
    9796 
     
    234233 
    235234                /* gather some info from the area */ 
    236                 $areaInfo = $this->db->query('SELECT COALESCE(titular_funcionario_id, -1) AS titular_funcionario_id, COALESCE(substituto_funcionario_id, -1) AS substituto_funcionario_id FROM area WHERE (organizacao_id = ?) AND (area_id = ?)', array($organizationID, $areaID))->GetArray(-1); 
     235                $areaInfo = $this->db->query('SELECT COALESCE(a.titular_funcionario_id, -1) AS titular_funcionario_id, COALESCE(s.funcionario_id, -1) AS substituto_funcionario_id FROM area a LEFT OUTER JOIN substituicao s ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) WHERE (a.organizacao_id = ?) AND (a.area_id = ?)', array($organizationID, $areaID))->GetArray(-1); 
    237236                if (empty($areaInfo)) 
    238237                        return false; 
     
    245244 
    246245                $employees = $result->GetArray(-1); 
    247                 $cachedLDAP = $GLOBALS['workflow']['factory']->newInstance('CachedLDAP'); 
     246                $cachedLDAP = Factory::newInstance('CachedLDAP'); 
    248247                $cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_NORMAL); 
    249248                $categoriesCount = array(); 
     
    318317 
    319318                $employees = $result->GetArray(-1); 
    320                 $cachedLDAP = $GLOBALS['workflow']['factory']->newInstance('CachedLDAP'); 
     319                $cachedLDAP = Factory::newInstance('CachedLDAP'); 
    321320                $cachedLDAP->setOperationMode($cachedLDAP->OPERATION_MODE_NORMAL); 
    322321                for ($i = 0; $i < count($employees); $i++) 
     
    334333                        { 
    335334                                $employees[$i]['telephoneNumber'] = is_null($entry['telephonenumber']) ? '' : $entry['telephonenumber']; 
    336                                 $employees[$i]['cn'] = is_null($entry['cn']) ? '' : $entry['cn'] . (is_null($entry['last_update']) ? ' <font color="red">(excluído)</font>' : ''); 
     335                                $employees[$i]['cn'] = is_null($entry['cn']) ? '' : $entry['cn'] . (is_null($entry['last_update']) ? ' <font color="red">(inativo)</font>' : ''); 
    337336                        } 
    338337                } 
     
    343342 
    344343        /** 
    345          * Search Employee 
     344         * Search Employee by Name 
    346345         * @param int $searchTerm term to search 
    347346         * @param int $organizationID  Id of organization 
     
    349348         * @access public 
    350349         */ 
    351         function searchEmployee($searchTerm, $organizationID) 
    352         { 
    353                 /* initialize some variables */ 
    354                 $output = array('employees' => array(), 'bygroup' => array( ) ); 
    355                 $ldapResult = array(); 
    356  
    357                 /* search for the $searchTerm in the LDAP */ 
    358                 $ldap = &$GLOBALS['workflow']['workflowObjects']->getLDAP(); 
     350        function searchEmployeeByName($searchTerm, $organizationID) 
     351        { 
     352                /* get ldap connection */ 
     353                $ldap = &Factory::getInstance('WorkflowObjects')->getLDAP(); 
    359354 
    360355                $searchTermExploded = explode(" ", $searchTerm); 
    361356                $fullSearch = false; 
    362357 
    363                 if(count($searchTermExploded) > 0){ 
    364                         for($i=1; $i<count($searchTermExploded); $i++){ 
    365                                 if(strlen($searchTermExploded[$i]) > 2){ 
     358                if (count($searchTermExploded) > 0){ 
     359                        for ($i=1; $i<count($searchTermExploded); $i++) { 
     360                                if (strlen($searchTermExploded[$i]) > 2) { 
    366361                                        $fullSearch = true; 
    367362                                } 
    368363                        } 
    369364 
    370                         if($fullSearch){ 
     365                        if ($fullSearch){ 
    371366                                $searchTerm = implode("*", $searchTermExploded); 
    372367                        } 
    373368                } 
    374369 
    375                 $list = @ldap_search($ldap, $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getLDAPContext(), ('(&(cn=*' . $searchTerm . '*)(phpgwaccounttype=u))'), array('uidNumber', 'cn', 'telephoneNumber')); 
     370                /* searching employees by name in the ldap server */ 
     371                $list = @ldap_search($ldap, Factory::getInstance('WorkflowLDAP')->getLDAPContext(), ('(&(cn=*' . $searchTerm . '*)(phpgwaccounttype=u))'), array('uidNumber', 'cn', 'telephoneNumber')); 
    376372                if ($list === false) 
    377373                        return false; 
    378374 
     375                /* parsing ldap result */ 
    379376                $entries = ldap_get_entries($ldap, $list); 
    380                 $employeesID = array(); 
     377                $ldapResult = array(); 
     378 
    381379                for ($i = 0; $i < $entries['count']; $i++) 
    382380                        $ldapResult[$entries[$i]['uidnumber'][0]] = array('cn' => $entries[$i]['cn'][0], 'telephoneNumber' => $entries[$i]['telephonenumber'][0]); 
    383381 
     382                /* no records found. bye. */ 
     383                if (count($ldapResult) == 0) 
     384                        return array(); 
     385 
    384386                $uids = implode( ',', array_keys( $ldapResult ) ); 
    385387 
    386                 /* load employee information */ 
    387                 $query = 'SELECT f.funcionario_id AS funcionario_id, f.area_id AS area_id, a.sigla AS area'; 
    388                 $query .= ' FROM funcionario f, area a, funcionario_status s'; 
    389                 $query .= " WHERE (f.area_id = a.area_id) AND (f.organizacao_id = {$organizationID})"; 
    390                 $query .= " AND (" . ( ( ! empty( $uids ) ) ? "f.funcionario_id IN ({$uids}) OR " : '' ); 
    391                 $query .= " a.sigla LIKE UPPER(?))"; 
    392                 $query .= " AND (f.funcionario_status_id = s.funcionario_status_id) AND (s.exibir = 'S')"; 
    393                 $query .= " ORDER BY a.sigla asc"; 
    394  
    395                 $result = $this->db->query($query, array( "%{$searchTerm}%" ) ); 
    396  
    397                 if ( ! $result ) 
    398                         return array( ); 
    399  
    400                 $uids = array( ); 
    401  
    402                 $employees = $result->GetArray(-1); 
    403                 for ($i = 0; $i < count($employees); $i++) 
    404                 { 
    405                         for ($j = 0; $j < $result->_numOfFields; $j++) 
    406                                 unset($employees[$i][$j]); 
    407  
    408                         if ( array_key_exists( $employees[$i]['funcionario_id'], $ldapResult ) ) 
    409                         { 
    410                                 $employees[$i]['cn'] = is_null($ldapResult[$employees[$i]['funcionario_id']]['cn']) ? '' : $ldapResult[$employees[$i]['funcionario_id']]['cn']; 
    411                                 $employees[$i]['telephoneNumber'] = is_null($ldapResult[$employees[$i]['funcionario_id']]['telephoneNumber']) ? '' : $ldapResult[$employees[$i]['funcionario_id']]['telephoneNumber']; 
     388                /* searching for aditional employee information */ 
     389                $query  = "SELECT "; 
     390                $query .= "             f.funcionario_id AS funcionario_id, f.area_id AS area_id, a.sigla AS area "; 
     391                $query .= " FROM "; 
     392                $query .= "                     funcionario f "; 
     393                $query .= "             INNER JOIN "; 
     394                $query .= "                     area a USING (area_id) "; 
     395                $query .= "             INNER JOIN "; 
     396                $query .= "                     funcionario_status s ON ((f.funcionario_status_id = s.funcionario_status_id) AND (s.exibir = 'S')) "; 
     397                $query .= " WHERE "; 
     398                $query .= "             (f.organizacao_id = ?) "; 
     399                $query .= "     AND "; 
     400                $query .= "             (f.funcionario_id IN ({$uids})) "; 
     401 
     402                $result = $this->db->query($query, array($organizationID))->GetArray(-1); 
     403                $employees = array(); 
     404 
     405                /* filling return array with employee's information */ 
     406                for ($i = 0; $i < count($result); $i++) { 
     407                        $employees []= array( 
     408                                        'area'                          => $result[$i]['area'], 
     409                                        'area_id'                       => $result[$i]['area_id'], 
     410                                        'funcionario_id'        => $result[$i]['funcionario_id'], 
     411                                        'cn'                            => $ldapResult[$result[$i]['funcionario_id']]['cn'], 
     412                                        'telephoneNumber'       => empty($ldapResult[$result[$i]['funcionario_id']]['telephoneNumber']) ? '': $ldapResult[$result[$i]['funcionario_id']]['telephoneNumber'] 
     413                        ); 
     414                } 
     415 
     416                /* sorting by name (cn) */ 
     417        $sort_function = create_function('$a, $b', 'return strcasecmp($a[\'cn\'],$b[\'cn\']);'); 
     418        usort($employees, $sort_function ); 
     419 
     420                return $employees; 
     421        } 
     422 
     423        /** 
     424         * Search Employee by Area 
     425         * @param int $searchTerm term to search 
     426         * @param int $organizationID  Id of organization 
     427         * @return array employee data information 
     428         * @access public 
     429         */ 
     430        function searchEmployeeByArea($searchTerm, $organizationID) 
     431        { 
     432                /* get ldap connection */ 
     433                $ldap = &Factory::getInstance('WorkflowObjects')->getLDAP(); 
     434 
     435                /* makes no sense search for an area if the string has more than one word */ 
     436                if (count(explode(" ", $searchTerm)) > 1) 
     437                        return array(); 
     438 
     439                /* searching for employees in areas that match 'searchTerm' */ 
     440                $query  = "SELECT "; 
     441                $query .= "             f.funcionario_id AS funcionario_id, f.area_id AS area_id, a.sigla AS area "; 
     442                $query .= " FROM "; 
     443                $query .= "                     funcionario f "; 
     444                $query .= "             INNER JOIN "; 
     445                $query .= "                     area a USING (area_id) "; 
     446                $query .= "             INNER JOIN "; 
     447                $query .= "                     funcionario_status s ON ((f.funcionario_status_id = s.funcionario_status_id) AND (s.exibir = 'S')) "; 
     448                $query .= " WHERE "; 
     449                $query .= "             (f.organizacao_id = ?) "; 
     450                $query .= "     AND "; 
     451                $query .= "             (UPPER(a.sigla) LIKE UPPER(?)) "; 
     452 
     453                $result = $this->db->query($query, array($organizationID, '%'.$searchTerm.'%'))->GetArray(-1); 
     454         
     455                /* no records found. bye */ 
     456                if (count($result) == 0) 
     457                        return array(); 
     458 
     459                /* creating the ldap query */ 
     460                $ldap_query = '(&(|'; 
     461                for ($i = 0; $i < count($result); $i++) { 
     462                        $ldap_query .= '(uidNumber=' . $result[$i]['funcionario_id'] . ')'; 
     463                } 
     464                $ldap_query .= ')(phpgwAccountType=u))'; 
     465 
     466                /* executing it */ 
     467                $list = @ldap_search($ldap, Factory::getInstance('WorkflowLDAP')->getLDAPContext(), $ldap_query, array('uidNumber', 'cn', 'telephoneNumber')); 
     468                $entries = ldap_get_entries($ldap, $list); 
     469 
     470                /* parsing result */ 
     471                $ldapResult = array(); 
     472                for ($i = 0; $i < $entries['count']; $i++) 
     473                        $ldapResult[$entries[$i]['uidnumber'][0]] = array('cn' => $entries[$i]['cn'][0], 'telephoneNumber' => $entries[$i]['telephonenumber'][0]); 
     474 
     475                /* we will need to search into database 'cache' for users deleted in ldap */ 
     476                $cachedLDAP = Factory::newInstance( 'CachedLDAP' ); 
     477                $cachedLDAP -> setOperationMode( $cachedLDAP -> OPERATION_MODE_DATABASE ); 
     478 
     479                /* filling return array with employee's information */ 
     480                $employees = array(); 
     481                for ($i = 0; $i < count($result); $i++) { 
     482 
     483                        $employee = array(); 
     484 
     485                        /* user deleted in ldap. Let's try to find him into database 'cache' */ 
     486                        if (empty($ldapResult[$result[$i]['funcionario_id']]['cn'])) { 
     487                                $entry = $cachedLDAP->getEntryByID($result[$i]['funcionario_id']); 
     488 
     489                                $employee['removed'] = is_null($entry['last_update']); 
     490 
     491                                if ($entry && !empty($entry['cn'])) 
     492                                        $employee['cn'] = $entry['cn']; 
     493                                /* we cant find it anywhere */ 
     494                                else 
     495                                        $employee['cn'] = $result[$i]['funcionario_id']; 
    412496                        } 
    413497                        else 
    414                         { 
    415                                 $employees[$i]['cn'] = $employees[$i]['funcionario_id']; 
    416                                 $employees[$i]['telephoneNumber'] = ''; 
    417  
    418                                 $output['bygroup'][ $employees[$i]['funcionario_id'] ] = $employees[ $i ]; 
    419                                 array_splice( $employees, $i--, 1 ); 
    420                         } 
    421                 } 
    422  
    423                 if ( count( $output['bygroup'] ) ) 
    424                 { 
    425                         $list = ldap_search($ldap, $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getLDAPContext(), ('(&(|(uidNumber=' . implode( ')(uidNumber=', array_keys( $output['bygroup'] ) ) . '))(phpgwaccounttype=u))'), array('uidNumber', 'cn', 'telephoneNumber')); 
    426  
    427                         if ( $list !== false ) 
    428                         { 
    429                                 $entries = ldap_get_entries($ldap, $list); 
    430  
    431                                 for ( $i = 0; $i < $entries[ 'count' ]; $i++ ) 
    432                                 { 
    433                                         $output[ 'bygroup' ][ $entries[$i]['uidnumber'][0] ][ 'cn' ] = $entries[$i]['cn'][0]; 
    434                                         $output[ 'bygroup' ][ $entries[$i]['uidnumber'][0] ][ 'telephoneNumber' ] = $entries[$i]['telephonenumber'][0]; 
    435                                 } 
    436                         } 
    437                 } 
    438  
    439                 $output[ 'bygroup' ] = array_values( $output[ 'bygroup' ] ); 
    440                 $output[ 'employees' ] = $employees; 
    441  
    442                 return $output; 
    443         } 
     498                                $employee['cn'] = $ldapResult[$result[$i]['funcionario_id']]['cn']; 
     499 
     500                        $employee['area']                               = $result[$i]['area']; 
     501                        $employee['area_id']                    = $result[$i]['area_id']; 
     502                        $employee['funcionario_id']     = $result[$i]['funcionario_id']; 
     503                        $employee['telephoneNumber']    = empty($ldapResult[$result[$i]['funcionario_id']]['telephoneNumber']) ? '': $ldapResult[$result[$i]['funcionario_id']]['telephoneNumber']; 
     504 
     505                        $employees []= $employee; 
     506                } 
     507 
     508                /* sorting by name (cn) */ 
     509        $sort_function = create_function('$a, $b', 'return strcasecmp($a[\'cn\'],$b[\'cn\']);'); 
     510        usort($employees, $sort_function ); 
     511 
     512                return $employees; 
     513        } 
     514 
     515        /** 
     516         * Search Employee by Telephone 
     517         * @param int $searchTerm term to search 
     518         * @param int $organizationID  Id of organization 
     519         * @return array employee data information 
     520         * @access public 
     521         */ 
     522        function searchEmployeeByTelephone($searchTerm, $organizationID) 
     523        { 
     524                /* we will just excute it if we just get numbers and '-' */ 
     525                if (!preg_match('/^[0-9-]+$/', $searchTerm)) 
     526                        return array(); 
     527 
     528                /* get ldap connection */ 
     529                $ldap = &Factory::getInstance('WorkflowObjects')->getLDAP(); 
     530 
     531                /* searching employees by telephoneNumber in the ldap server */ 
     532                $list = @ldap_search($ldap, Factory::getInstance('WorkflowLDAP')->getLDAPContext(), ('(&(telephoneNumber=*' . $searchTerm . '*)(phpgwaccounttype=u))'), array('uidNumber', 'cn', 'telephoneNumber')); 
     533 
     534                if (!$list) return false; 
     535 
     536                /* parsing ldap result */ 
     537                $entries = ldap_get_entries($ldap, $list); 
     538                $ldapResult = array(); 
     539 
     540                for ($i = 0; $i < $entries['count']; $i++) 
     541                        $ldapResult[$entries[$i]['uidnumber'][0]] = array('cn' => $entries[$i]['cn'][0], 'telephoneNumber' => $entries[$i]['telephonenumber'][0]); 
     542 
     543                /* no records found. bye. */ 
     544                if (count($ldapResult) == 0) 
     545                        return array(); 
     546 
     547                $uids = implode( ',', array_keys( $ldapResult ) ); 
     548 
     549                /* searching for aditional employee information */ 
     550                $query  = "SELECT "; 
     551                $query .= "             f.funcionario_id AS funcionario_id, f.area_id AS area_id, a.sigla AS area "; 
     552                $query .= " FROM "; 
     553                $query .= "                     funcionario f "; 
     554                $query .= "             INNER JOIN "; 
     555                $query .= "                     area a USING (area_id) "; 
     556                $query .= "             INNER JOIN "; 
     557                $query .= "                     funcionario_status s ON ((f.funcionario_status_id = s.funcionario_status_id) AND (s.exibir = 'S')) "; 
     558                $query .= " WHERE "; 
     559                $query .= "             (f.organizacao_id = ?) "; 
     560                $query .= "     AND "; 
     561                $query .= "             (f.funcionario_id IN ({$uids})) "; 
     562 
     563                $result = $this->db->query($query, array($organizationID))->GetArray(-1); 
     564                $employees = array(); 
     565 
     566                /* filling return array with employee's information */ 
     567                for ($i = 0; $i < count($result); $i++) { 
     568                        $employees []= array( 
     569                                        'area'                          => $result[$i]['area'], 
     570                                        'area_id'                       => $result[$i]['area_id'], 
     571                                        'funcionario_id'        => $result[$i]['funcionario_id'], 
     572                                        'cn'                            => $ldapResult[$result[$i]['funcionario_id']]['cn'], 
     573                                        'telephoneNumber'       => empty($ldapResult[$result[$i]['funcionario_id']]['telephoneNumber']) ? '': $ldapResult[$result[$i]['funcionario_id']]['telephoneNumber'] 
     574                        ); 
     575                } 
     576 
     577                /* sorting by name (cn) */ 
     578        $sort_function = create_function('$a, $b', 'return strcasecmp($a[\'cn\'],$b[\'cn\']);'); 
     579        usort($employees, $sort_function ); 
     580 
     581                return $employees; 
     582        } 
     583 
    444584 
    445585        /** 
     
    453593        function getEmployeeInfo($employeeID, $organizationID) 
    454594        { 
    455                 require_once dirname(__FILE__) . '/class.so_orgchart.inc.php'; 
    456  
    457                 $SOOrgchart = new so_orgchart(); 
     595                $SOOrgchart = &Factory::getInstance('so_orgchart'); 
    458596                $SOOrgchart->setExternalCalls(true); 
    459597                $output = $SOOrgchart->getEmployeeInfo($employeeID, $organizationID); 
     
    473611        function getAreaInfo($areaID, $organizationID) 
    474612        { 
    475                 require_once dirname(__FILE__) . '/class.so_orgchart.inc.php'; 
    476  
    477                 $SOOrgchart = new so_orgchart(); 
     613                $SOOrgchart = &Factory::getInstance('so_orgchart'); 
    478614                $SOOrgchart->setExternalCalls(true); 
    479615                $output = $SOOrgchart->getAreaInfo($areaID, $organizationID); 
     
    509645        function getAreaWithSubtituteBoss( $organizationID ) 
    510646        { 
    511                 $result = $this -> db -> query( "SELECT sigla as area, titular_funcionario_id as titular, substituto_funcionario_id as substituto FROM area WHERE (organizacao_id = ?) and substituto_funcionario_id is not null ORDER BY area", array( $organizationID ) ); 
    512  
    513                 $cachedLDAP = $GLOBALS[ 'workflow' ][ 'factory' ] -> newInstance( 'CachedLDAP' ); 
     647                $result = $this -> db -> query( "SELECT a.sigla as area, a.titular_funcionario_id as titular, s.funcionario_id as substituto, s.data_inicio, s.data_fim FROM area a INNER JOIN substituicao s ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) WHERE (organizacao_id = ?) ORDER BY area", array( $organizationID ) ); 
     648 
     649                $cachedLDAP = Factory::newInstance( 'CachedLDAP' ); 
    514650                $cachedLDAP -> setOperationMode( $cachedLDAP -> OPERATION_MODE_LDAP_DATABASE ); 
    515651 
     
    527663                        if ( $entry && ( ! is_null( $entry[ 'cn' ] ) ) ) 
    528664                                $output[ $i ][ 'substituto' ] = $entry[ 'cn' ]; 
     665 
     666                        $output[$i]['data_inicio'] = implode('/', array_reverse(explode('-', $output[$i]['data_inicio']))); 
     667                        $output[$i]['data_fim'] = implode('/', array_reverse(explode('-', $output[$i]['data_fim']))); 
    529668                } 
    530669 
     
    575714 
    576715                $employees = $result -> GetArray( -1 ); 
    577                 $cachedLDAP = $GLOBALS[ 'workflow' ][ 'factory' ] -> newInstance( 'CachedLDAP' ); 
     716                $cachedLDAP = Factory::newInstance( 'CachedLDAP' ); 
    578717                $cachedLDAP -> setOperationMode( $cachedLDAP -> OPERATION_MODE_NORMAL ); 
    579718 
     
    647786                $employees = $result -> GetArray( -1 ); 
    648787 
    649                 $cachedLDAP = $GLOBALS[ 'workflow' ][ 'factory' ] -> newInstance( 'CachedLDAP' ); 
     788                $cachedLDAP = Factory::newInstance( 'CachedLDAP' ); 
    650789                $cachedLDAP -> setOperationMode( $cachedLDAP -> OPERATION_MODE_NORMAL ); 
    651790 
     
    673812                usort( $employees, create_function( '$a,$b', 'return strcasecmp($a[\'cn\'],$b[\'cn\']);' ) ); 
    674813 
    675                 $paging = $GLOBALS['workflow']['factory']->newInstance('Paging', 50, $_POST); 
     814                $paging = Factory::newInstance('Paging', 50, $_POST); 
    676815                $employees = $paging->restrictItems( $employees ); 
    677816 
  • branches/2.2/workflow/inc/class.ui_adminaccess.inc.php

    r795 r3167  
    4141        function ui_adminaccess() 
    4242        { 
    43                 if (!$GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id'])) 
     43                if (!Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id'])) 
    4444                { 
    4545                        $GLOBALS['phpgw']->common->phpgw_header(); 
     
    6363                $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['workflow']['title'] . ' - ' . lang('Access Control List'); 
    6464                $GLOBALS['phpgw_info']['flags'] = array('noheader' => false, 'nonavbar' => false, 'currentapp' => 'workflow'); 
    65                 $smarty = CreateObject('workflow.workflow_smarty'); 
     65                $smarty = Factory::getInstance('workflow_smarty'); 
    6666 
    6767                $javaScripts = $this->get_common_js(); 
  • branches/2.2/workflow/inc/class.ui_adminactivities.inc.php

    r1710 r3167  
    22 
    33require_once dirname(__FILE__) . SEP . 'class.WorkflowUtils.inc.php'; 
    4 require_once dirname(__FILE__) . SEP . 'class.fsutils.inc.php'; /* toolkit for filesystem handling */ 
    54require_once 'engine' . SEP . 'config.egw.inc.php'; 
    65/** 
     
    7372                parent::WorkflowUtils(); 
    7473 
    75                 $this->workflow_acl = CreateObject('workflow.workflow_acl'); 
     74                $this->workflow_acl = Factory::getInstance('workflow_acl'); 
    7675                $denyAccess = true; 
    7776                if ($this->workflow_acl->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id'])) 
     
    106105                } 
    107106 
    108                 $this->process_manager  = CreateObject('workflow.workflow_processmanager'); 
    109                 $this->activity_manager = CreateObject('workflow.workflow_activitymanager'); 
    110                 $this->role_manager     = CreateObject('workflow.workflow_rolemanager'); 
    111                 $this->fs = new FsUtils(); /* gets instance */ 
     107                $this->process_manager  = Factory::getInstance('workflow_processmanager'); 
     108                $this->activity_manager = Factory::getInstance('workflow_activitymanager'); 
     109                $this->role_manager     = Factory::getInstance('workflow_rolemanager'); 
     110                $this->fs = &Factory::newInstance('FsUtils'); /* gets instance */ 
    112111 
    113112        } 
     
    374373                // fill proc_bar 
    375374                $this->t->set_var('proc_bar', $this->fill_proc_bar($proc_info)); 
    376                  
     375 
    377376                //collect some messages from used objects 
    378377                $this->message[] = $this->activity_manager->get_error(false, _DEBUG); 
     
    380379                $this->message[] = $this->role_manager->get_error(false, _DEBUG); 
    381380 
    382                 $templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer'); 
     381                $templateServer = &Factory::getInstance('TemplateServer'); 
    383382 
    384383                // fill the general variables of the template 
     
    732731                        $this->translate_template('block_process_activities_header'); 
    733732                        $this->t->parse('process_activities_header', 'block_process_activities_header', True); 
    734                         $templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer'); 
     733                        $templateServer = &Factory::getInstance('TemplateServer'); 
    735734                        foreach ($process_activities_data as $activity) 
    736735                        { 
     
    792791                                'trans_href_from'       => $GLOBALS['phpgw']->link('/index.php', 'menuaction=workflow.ui_adminactivities.form&where2='. $where2 .'&sort_mode2='. $sort_mode2 .'&p_id='. $this->wf_p_id .'&find='. $find .'&where='. $where .'&sort_mode='. $this->sort_mode .'&activity_id='. $transition['wf_act_from_id']), 
    793792                                'trans_actFromName'     => $transition['wf_act_from_name'], 
    794                                 'trans_arrow'           => $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink('next.gif'), 
     793                                'trans_arrow'           => Factory::getInstance('TemplateServer')->generateImageLink('next.gif'), 
    795794                                'trans_href_to'         => $GLOBALS['phpgw']->link('/index.php', 'menuaction=workflow.ui_adminactivities.form&where2='. $where2 .'&sort_mode2='. $sort_mode2 .'&p_id='. $this->wf_p_id .'&find='. $find .'&where='. $where .'&sort_mode='. $this->sort_mode .'&activity_id='. $transition['wf_act_to_id']), 
    796795                                'trans_actToName'       => $transition['wf_act_to_name'], 
     
    10361035                $image_name = $proc_info['wf_normalized_name'] . SEP . 'graph' . SEP . $proc_info['wf_normalized_name'] . '.png'; 
    10371036                $image = GALAXIA_PROCESSES . SEP . $image_name; 
    1038                 if ($GLOBALS['workflow']['factory']->getInstance('BrowserInfo')->isOpera()) 
    1039                         $maximumDimension = 1000000; 
     1037                if (file_exists($image)) 
     1038                { 
     1039                        if (Factory::getInstance('BrowserInfo')->isOpera()) 
     1040                                $maximumDimension = 1000000; 
     1041                        else 
     1042                                $maximumDimension = 2500; 
     1043 
     1044                        $dims = getimagesize($image); 
     1045                        list($originalWidth, $originalHeight) = $dims; 
     1046 
     1047                        /* the image must be resized */ 
     1048                        if (max($originalWidth, $originalHeight) > $maximumDimension) 
     1049                        { 
     1050                                /* define the new width and height */ 
     1051                                $newWidth = $newHeight = $maximumDimension; 
     1052                                if ($originalWidth > $originalHeight) 
     1053                                        $newHeight = $maximumDimension * ($originalHeight / $originalWidth); 
     1054                                else 
     1055                                        $newWidth = $maximumDimension * ($originalWidth / $originalHeight); 
     1056 
     1057                                /* create the new image and send to the browser */ 
     1058                                $smallerImage = imagecreatetruecolor($newWidth, $newHeight); 
     1059                                imagecopyresampled($smallerImage, imagecreatefrompng($image), 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight); 
     1060                                header('content-disposition: inline; filename=' . $image_name); 
     1061                                header('content-type: ' . $dims['mime']); 
     1062                                imagepng($smallerImage); 
     1063                        } 
     1064                        else 
     1065                        { 
     1066                                header('content-disposition: inline; filename=' . $image_name); 
     1067                                header('content-type: ' . $dims['mime']); 
     1068                                header('content-length: ' . filesize($image)); 
     1069                                readfile($image); 
     1070                        } 
     1071                } 
     1072                // if there is no graph, show "graph not found" message 
    10401073                else 
    1041                         $maximumDimension = 2500; 
    1042  
    1043                 $dims = getimagesize($image); 
    1044                 list($originalWidth, $originalHeight) = $dims; 
    1045  
    1046                 /* the image must be resized */ 
    1047                 if (max($originalWidth, $originalHeight) > $maximumDimension) 
    1048                 { 
    1049                         /* define the new width and height */ 
    1050                         $newWidth = $newHeight = $maximumDimension; 
    1051                         if ($originalWidth > $originalHeight) 
    1052                                 $newHeight = $maximumDimension * ($originalHeight / $originalWidth); 
    1053                         else 
    1054                                 $newWidth = $maximumDimension * ($originalWidth / $originalHeight); 
    1055  
    1056                         /* create the new image and send to the browser */ 
    1057                         $smallerImage = imagecreatetruecolor($newWidth, $newHeight); 
    1058                         imagecopyresampled($smallerImage, imagecreatefrompng($image), 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight); 
    1059                         header('content-disposition: inline; filename=' . $image_name); 
    1060                         header('content-type: ' . $dims['mime']); 
    1061                         imagepng($smallerImage); 
    1062                 } 
    1063                 else 
    1064                 { 
    1065                         header('content-disposition: inline; filename=' . $image_name); 
    1066                         header('content-type: ' . $dims['mime']); 
    1067                         header('content-length: ' . filesize($image)); 
    1068                         readfile($image); 
    1069                 } 
    1070         } 
    1071          
     1074                { 
     1075                        header ('Content-type: image/png'); 
     1076                        $text = 'GRAFICO NAO ENCONTRADO'; 
     1077                        $font_size = 5; 
     1078                        $width = imagefontwidth($font_size) * strlen($text); 
     1079                        $height = imagefontheight($font_size); 
     1080                        $im = imagecreate($width, $height); 
     1081                        $text_color = imagecolorallocate($im, 0, 0, 0);         // black 
     1082                        $bg_color = imagecolorallocate($im, 255, 255, 255);     // white 
     1083                        imagefill($im, 0, 0, $bg_color); 
     1084                        imagestring($im, $font_size, 0, 0, $text, $text_color); 
     1085                        imagepng($im); 
     1086                        imagedestroy($im); 
     1087                } 
     1088        } 
     1089 
    10721090        /** 
    10731091         * Dislays the activity agents config rows 
     
    10901108                        } 
    10911109                        $this->translate_template('admin_agents'); 
    1092                                                                                                 $this->t->parse('agents_config_rows', 'admin_agents'); 
     1110                        $this->t->parse('agents_config_rows', 'admin_agents'); 
    10931111                } 
    10941112        } 
  • branches/2.2/workflow/inc/class.ui_adminjobs.inc.php

    r795 r3167  
    4141                        'app_header' => $GLOBALS['phpgw_info']['apps']['workflow']['title'] . ' - ' . lang('Jobs') 
    4242                ); 
    43                 $smarty = &$GLOBALS['workflow']['factory']->getInstance('workflow_smarty'); 
     43                $smarty = &Factory::getInstance('workflow_smarty'); 
    4444 
    4545                $javaScripts = $this->get_common_js(); 
     
    5454                $css .= $this->get_css_link('adminjobs'); 
    5555 
    56                 $processInfo = $GLOBALS['workflow']['factory']->getInstance('workflow_processmanager')->get_process((int) $_REQUEST['p_id']); 
     56                $processInfo = Factory::getInstance('workflow_processmanager')->get_process((int) $_REQUEST['p_id']); 
    5757                $smarty->assign('processNameVersion', "{$processInfo['wf_name']} v{$processInfo['wf_version']}"); 
    5858                $smarty->assign('processID', (int) $processInfo['wf_p_id']); 
  • branches/2.2/workflow/inc/class.ui_adminprocesses.inc.php

    r989 r3167  
    5454                parent::bo_workflow_forms('admin_processes'); 
    5555 
    56                 $this->workflow_acl = CreateObject('workflow.workflow_acl'); 
     56                $this->workflow_acl = Factory::getInstance('workflow_acl'); 
    5757                $denyAccess = true; 
    5858                if ($this->workflow_acl->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id'])) 
     
    8383                } 
    8484 
    85                 $this->process_manager  = CreateObject('workflow.workflow_processmanager'); 
    86                 $this->activity_manager = CreateObject('workflow.workflow_activitymanager'); 
     85                $this->process_manager  = Factory::getInstance('workflow_processmanager'); 
     86                $this->activity_manager = Factory::getInstance('workflow_activitymanager'); 
    8787 
    8888                $this->form_action = $GLOBALS['phpgw']->link('/index.php', 'menuaction=workflow.ui_adminprocesses.form'); 
     
    127127                } 
    128128 
    129                 if (!$GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id'])) 
     129                if (!Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id'])) 
    130130                { 
    131131                        $proc_ids = $this->workflow_acl->get_granted_processes($GLOBALS['phpgw_info']['user']['account_id']); 
     
    190190                $known_config_items = array_merge($known_config_items, array('Log Options' => 'title', 'log_level' => $log_levels)); 
    191191 
    192                 $bo_agent = CreateObject('workflow.bo_agent_mail_smtp'); 
     192                $bo_agent = Factory::getInstance('bo_agent_mail_smtp'); 
    193193                $known_config_items = array_merge($known_config_items, $bo_agent->listProcessConfigurationFields()); 
    194194 
     
    589589 
    590590                        $myp_id = $item['wf_p_id']; 
    591                         $templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer'); 
     591                        $templateServer = &Factory::getInstance('TemplateServer'); 
    592592                        $this->t->set_var(array( 
    593593                                'item_wf_p_id'          => $myp_id, 
  • branches/2.2/workflow/inc/class.ui_adminroles.inc.php

    r795 r3167  
    4242                parent::WorkflowUtils(); 
    4343 
    44                 $this->workflow_acl = CreateObject('workflow.workflow_acl'); 
     44                $this->workflow_acl = Factory::getInstance('workflow_acl'); 
    4545                $denyAccess = true; 
    4646                if ($this->workflow_acl->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id'])) 
     
    7171                } 
    7272 
    73                 $this->process_manager  = CreateObject('workflow.workflow_processmanager'); 
    74                 $this->activity_manager = CreateObject('workflow.workflow_activitymanager'); 
    75                 $this->role_manager     = CreateObject('workflow.workflow_rolemanager'); 
     73                $this->process_manager  = Factory::getInstance('workflow_processmanager'); 
     74                $this->activity_manager = Factory::getInstance('workflow_activitymanager'); 
     75                $this->role_manager     = Factory::getInstance('workflow_rolemanager'); 
    7676                $this->form_action = $GLOBALS['phpgw']->link('/index.php', 'menuaction=workflow.ui_adminroles.form'); 
    7777                 
     
    254254                        $this->t->set_var('list_mappings', '<tr><td colspan="3" align="center">'. lang('There are no mappings defined for this process')  .'</td></tr>'); 
    255255                } 
    256                 else {   
     256                else { 
    257257                        /* load the LDAP information */ 
    258                         $cachedLDAP = $GLOBALS['workflow']['factory']->getInstance('CachedLDAP'); 
    259                         $tmpLDAP = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     258                        $cachedLDAP = Factory::getInstance('CachedLDAP'); 
     259                        $tmpLDAP = &Factory::getInstance('WorkflowLDAP'); 
    260260                        $userContext  = $tmpLDAP->getUserContext(); 
    261261                        $groupContext = $tmpLDAP->getGroupContext(); 
     
    264264                        { 
    265265                                if ($mapping['wf_account_type'] == 'g') { 
    266                                         $sri = ldap_search($GLOBALS['workflow']['workflowObjects']->getLDAP(),  
    267                                                                         $groupContext,  
     266                                        $sri = ldap_search(Factory::getInstance('WorkflowObjects')->getLDAP(), 
     267                                                                        $groupContext, 
    268268                                                                        '(&(gidnumber=' . (int)$mapping['wf_user'] . ')(phpgwAccountType=g))'); 
    269                                                                          
    270                                         $allValues = ldap_get_entries($GLOBALS['workflow']['workflowObjects']->getLDAP(), $sri); 
    271                                          
     269 
     270                                        $allValues = ldap_get_entries(Factory::getInstance('WorkflowObjects')->getLDAP(), $sri); 
     271 
    272272                                        $cname = $GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8'); 
    273273                                        $glabel = '[' . lang('Group') . ']'; 
     
    276276                                        $entry = $cachedLDAP->getEntryByID($mapping['wf_user']); 
    277277                                        $cname = $GLOBALS['phpgw']->translation->convert($entry['cn'],'utf-8'); 
    278                                         $glabel = ""; 
     278                                        $glabel = (!empty($entry['uid'])) ? '[' . $entry['uid'] . ']' : ''; 
    279279                                        if (is_null($entry['last_update'])) 
    280                                                 $glabel = '<font color="red">(excluído)</font>'; 
     280                                                $glabel = '<font color="red">(inativo)</font>'; 
    281281                                } 
    282                                  
     282 
    283283                                $this->t->set_var(array( 
    284284                                        'map_user_id'   => $mapping['wf_user'], 
     
    313313         * Show users roles selects 
    314314         * @param string $all_roles_data 
    315          * @return  
     315         * @return 
    316316         */ 
    317317        function show_users_roles_selects($all_roles_data) 
    318318        { 
    319                 $templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer'); 
     319                $templateServer = &Factory::getInstance('TemplateServer'); 
    320320                $imgaddusers = $templateServer->generateImageLink('add_group.png'); 
    321321                $imgdelusers = $templateServer->generateImageLink('delete_group.png'); 
     
    325325                        'src_img_del_users' => $imgdelusers 
    326326                )); 
    327                  
     327 
    328328                $this->t->set_block('admin_roles', 'block_select_roles', 'select_roles'); 
    329329                foreach ($all_roles_data as $role) 
  • branches/2.2/workflow/inc/class.ui_adminsource.inc.php

    r795 r3167  
    1717 */ 
    1818require_once dirname(__FILE__) . SEP . 'class.ui_ajaxinterface.inc.php'; 
    19 require_once dirname(__FILE__) . SEP . 'class.workflow_acl.inc.php'; 
    2019require_once 'engine' . SEP . 'config.ajax.inc.php'; 
    2120 
     
    4342        function ui_adminsource() 
    4443        { 
    45                 $this->workflow_acl = new workflow_acl(); 
     44                $this->workflow_acl = Factory::getInstance('workflow_acl'); 
    4645                $denyAccess = true; 
    4746                if ($this->workflow_acl->checkWorkflowAdmin($_SESSION['phpgw_info']['workflow']['account_id'])) 
     
    7877        function form() 
    7978        { 
    80                 $smarty = $GLOBALS['workflow']['factory']->getInstance('workflow_smarty', false); 
     79                $smarty = Factory::getInstance('workflow_smarty', false); 
    8180                $smarty->setHeader(workflow_smarty::SHOW_HEADER | workflow_smarty::SHOW_NAVIGATION_BAR | workflow_smarty::SHOW_FOOTER, $GLOBALS['phpgw_info']['apps']['workflow']['title'] . ' - ' . lang('Admin Processes Sources')); 
    8281 
  • branches/2.2/workflow/inc/class.ui_agent_mail_smtp.inc.php

    r795 r3167  
    2929                parent::ui_agent(); 
    3030                $this->agent_type = 'mail_smtp'; 
    31                 $this->bo_agent = CreateObject('workflow.bo_agent_mail_smtp'); 
     31                $this->bo_agent = Factory::getInstance('bo_agent_mail_smtp'); 
    3232        } 
    3333 
  • branches/2.2/workflow/inc/class.ui_ajaxinterface.inc.php

    r1452 r3167  
    1111\**************************************************************************/ 
    1212 
    13 require_once 'class.workflow_acl.inc.php'; 
    1413require_once 'common.inc.php'; 
    1514require_once 'engine/class.ajax_config.inc.php'; 
     
    5049        function set_wf_session() 
    5150        { 
    52                 $acl = new workflow_acl(); 
     51                $acl = Factory::getInstance('workflow_acl'); 
    5352                $_SESSION['phpgw_info']['workflow']['server_root'] = PHPGW_SERVER_ROOT; 
    5453                $_SESSION['phpgw_info']['workflow']['phpgw_api_inc'] = PHPGW_API_INC; 
     
    5655                $vfs = createobject('phpgwapi.vfs'); 
    5756                $_SESSION['phpgw_info']['workflow']['vfs_basedir'] = $vfs->basedir; 
    58                 $_SESSION['phpgw_info']['workflow']['server'] = $GLOBALS['phpgw_info']['server'];                        
     57                $_SESSION['phpgw_info']['workflow']['server'] = $GLOBALS['phpgw_info']['server']; 
    5958                $_SESSION['phpgw_info']['workflow']['lang'] = $GLOBALS['lang']; 
    6059                $_SESSION['phpgw_info']['workflow']['account_id'] = $GLOBALS['phpgw_info']['user']['account_id']; 
    61                 $_SESSION['phpgw_info']['workflow']['user_groups'] = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getUserGroups($GLOBALS['phpgw_info']['user']['account_id']); 
     60                $_SESSION['phpgw_info']['workflow']['user_groups'] = Factory::getInstance('WorkflowLDAP')->getUserGroups($GLOBALS['phpgw_info']['user']['account_id']); 
    6261                $user_is_admin = $acl->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']); 
    63                 $_SESSION['phpgw_info']['workflow']['user_is_admin'] = $user_is_admin;  
     62                $_SESSION['phpgw_info']['workflow']['user_is_admin'] = $user_is_admin; 
    6463                $_SESSION['phpgw_info']['workflow']['user_can_admin_process'] = ($user_is_admin || ($GLOBALS['phpgw']->acl->check('admin_workflow',1,'workflow'))); 
    65                 $_SESSION['phpgw_info']['workflow']['user_can_admin_instance'] = ($user_is_admin || ($GLOBALS['phpgw']->acl->check('admin_instance_workflow',1,'workflow')));  
     64                $_SESSION['phpgw_info']['workflow']['user_can_admin_instance'] = ($user_is_admin || ($GLOBALS['phpgw']->acl->check('admin_instance_workflow',1,'workflow'))); 
    6665 
    6766                $can_monitor = $acl->checkUserGroupAccessToType('MON', $GLOBALS['phpgw_info']['user']['account_id']); 
     
    118117        { 
    119118                $CSSName = "css/{$CSSName}.css"; 
    120                 $templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer'); 
     119                $templateServer = &Factory::getInstance('TemplateServer'); 
    121120                $CSSLink = $templateServer->getWebFile($CSSName); 
    122121                $CSSFile = $templateServer->getSystemFile($CSSName); 
  • branches/2.2/workflow/inc/class.ui_external_applications.inc.php

    r795 r3167  
    4949        function draw() 
    5050        { 
    51                 if (!$GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id'])) 
     51                if (!Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id'])) 
    5252                { 
    5353                        $GLOBALS['phpgw']->common->phpgw_header(); 
     
    6161                $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['workflow']['title']; 
    6262                $GLOBALS['phpgw_info']['flags'] = array('noheader' => false, 'nonavbar' => false, 'currentapp' => 'workflow'); 
    63                 $smarty = CreateObject('workflow.workflow_smarty'); 
     63                $smarty = Factory::getInstance('workflow_smarty'); 
    6464 
    6565                $this->set_wf_session(); 
  • branches/2.2/workflow/inc/class.ui_generic_select.inc.php

    r795 r3167  
    7979        function form() 
    8080        { 
    81                 $smarty = $GLOBALS['workflow']['factory']->getInstance('workflow_smarty', false); 
     81                $smarty = Factory::getInstance('workflow_smarty', false); 
    8282                $smarty->setHeader(workflow_smarty::SHOW_HEADER | workflow_smarty::SHOW_FOOTER); 
    8383 
  • branches/2.2/workflow/inc/class.ui_monitors.inc.php

    r795 r3167  
    1212 
    1313require_once(dirname(__FILE__) . SEP . 'class.ui_ajaxinterface.inc.php'); 
    14 require_once(dirname(__FILE__) . SEP . 'class.workflow_acl.inc.php'); 
    1514/** 
    1615 * @package Workflow 
     
    3736        { 
    3837                $this->set_wf_session(); 
    39                 $this->workflow_acl = new workflow_acl(); 
     38                $this->workflow_acl = Factory::getInstance('workflow_acl'); 
    4039 
    4140                if (!($this->workflow_acl->checkUserGroupAccessToType('MON', $_SESSION['phpgw_info']['workflow']['account_id']) || ($this->workflow_acl->checkWorkflowAdmin($_SESSION['phpgw_info']['workflow']['account_id'])))) 
     
    5857                $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['workflow']['title'] . ' - ' . lang('%1 monitoring'); 
    5958                $GLOBALS['phpgw_info']['flags'] = array('noheader' => false, 'nonavbar' => false, 'currentapp' => 'workflow'); 
    60                 $smarty = CreateObject('workflow.workflow_smarty'); 
     59                $smarty = Factory::getInstance('workflow_smarty'); 
    6160 
    6261                $javaScripts = $this->get_common_js(); 
  • branches/2.2/workflow/inc/class.ui_move_instances.inc.php

    r795 r3167  
    3636        { 
    3737                $GLOBALS['phpgw_info']['flags'] = array('noheader' => false, 'nonavbar' => false, 'currentapp' => 'workflow'); 
    38                 $smarty = CreateObject('workflow.workflow_smarty'); 
     38                $smarty = Factory::getInstance('workflow_smarty'); 
    3939 
    4040                $javaScripts = $this->get_common_js(); 
  • branches/2.2/workflow/inc/class.ui_orgchart.inc.php

    r795 r3167  
    11<?php 
    22 
    3         /**************************************************************************\ 
     3/**************************************************************************\ 
    44* eGroupWare                                                 * 
    55* http://www.egroupware.org                                                * 
     
    1212 
    1313require_once(dirname(__FILE__) . SEP . 'class.ui_ajaxinterface.inc.php'); 
    14 require_once(dirname(__FILE__) . SEP . 'class.workflow_acl.inc.php'); 
     14 
    1515/** 
    1616 * @package Workflow 
     
    4747        function draw($tab_index = "") 
    4848        { 
    49                 $this->workflow_acl = CreateObject('workflow.workflow_acl'); 
     49                $this->workflow_acl = Factory::getInstance('workflow_acl'); 
    5050 
    5151                $isAdmin = $this->workflow_acl->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']); 
     
    6363 
    6464                $GLOBALS['phpgw_info']['flags'] = array('noheader' => false, 'nonavbar' => false, 'currentapp' => 'workflow'); 
    65                 $smarty = CreateObject('workflow.workflow_smarty'); 
     65                $smarty = Factory::getInstance('workflow_smarty'); 
    6666 
    6767                $this->set_wf_session(); 
     
    104104                        die(); 
    105105 
    106                 require_once(dirname(__FILE__) . SEP . 'engine' . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'GraphViz.php'); 
    107  
    108                 $config_values = CreateObject('phpgwapi.config','workflow'); 
     106                $config_values = Factory::getInstance('config', 'workflow'); 
    109107                $config_values->read_repository(); 
    110                 $conf_db = $config_values->config_data;  
    111                 $db = CreateObject('phpgwapi.db'); 
     108                $conf_db = $config_values->config_data; 
     109                $db = Factory::getInstance('db'); 
    112110                $db->connect( 
    113111                        $conf_db['database_name'], 
     
    122120                $attributes['ranksep'] = '1.5 equally'; 
    123121                $attributes['rankdir'] = 'LR'; 
    124                 $graph = new Process_GraphViz(true, $attributes); 
     122                $graph = &Factory::getInstance('Process_GraphViz', true, $attributes); 
    125123 
    126124 
     
    153151                                return false; 
    154152 
    155                         $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     153                        $ldap = &Factory::getInstance('WorkflowLDAP'); 
    156154                        for ($i = 0; $i < count($output); $i++) 
    157155                        { 
  • branches/2.2/workflow/inc/class.ui_participants.inc.php

    r795 r3167  
    4141        function ui_participants() 
    4242        { 
    43                 $this->bo = $GLOBALS['workflow']['factory']->getInstance('bo_participants'); 
     43                $this->bo = Factory::getInstance('bo_participants'); 
    4444        } 
    4545 
     
    5151        function form() 
    5252        { 
    53                 $smarty = $GLOBALS['workflow']['factory']->getInstance('workflow_smarty', false); 
     53                $smarty = Factory::getInstance('workflow_smarty', false); 
    5454                $smarty->setHeader(workflow_smarty::SHOW_HEADER | workflow_smarty::SHOW_FOOTER); 
    55                 $ldap = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     55                $ldap = Factory::getInstance('WorkflowLDAP'); 
    5656                $userDN = $GLOBALS['phpgw_info']['user']['account_dn']; 
    57                 $account = $GLOBALS['workflow']['factory']->getForeignInstance('phpgwapi', 'accounts', $userDN); 
     57                $account = Factory::getInstance('accounts', $userDN); 
    5858                $organizationList = $this->bo->getOrganizations(); 
    5959 
     
    9292                $hideSectors = ($_REQUEST['hideSectors'] == '1') ? true : false; 
    9393 
     94                // the default value of $onlyVisibleAccounts is true 
     95                if((isset($_REQUEST['onlyVisibleAccounts'])) && (empty($_REQUEST['onlyVisibleAccounts']) || $_REQUEST['onlyVisibleAccounts'] === 'false')) 
     96                        $onlyVisibleAccounts = false; 
     97                else 
     98                        $onlyVisibleAccounts = true; 
     99 
    94100                /* define the initial organization */ 
    95101                $selectedOrganization = $ldap->getOrganizationFromDN($userDN); 
     
    117123                $smarty->assign('organizations', $organizationList); 
    118124                $smarty->assign('selectedOrganization', $selectedOrganization); 
    119                 $smarty->assign('sectors', $this->bo->getSectors(array('organization' => $selectedOrganization), true)); 
     125                $smarty->assign('sectors', $this->bo->getSectors(array('organization' => $selectedOrganization, 'onlyVisibleAccounts' => $onlyVisibleAccounts), true)); 
    120126                $smarty->assign('selectedSector', $selectedSector); 
    121                 $smarty->assign('participants', $this->bo->getEntities(array('entities' => $entities, 'id' => $id, 'context' => $selectedSector, 'usePreffix' => $usePreffix), true)); 
     127                $smarty->assign('participants', $this->bo->getEntities(array('entities' => $entities, 'id' => $id, 'context' => $selectedSector, 'onlyVisibleAccounts' => $onlyVisibleAccounts, 'usePreffix' => $usePreffix), true)); 
    122128                $smarty->assign('entities', $entities); 
    123129                $smarty->assign('id', $id); 
     
    126132                $smarty->assign('hideOrganizations', $hideOrganizations); 
    127133                $smarty->assign('hideSectors', $hideSectors); 
     134                $smarty->assign('onlyVisibleAccounts', $onlyVisibleAccounts); 
    128135                $smarty->assign('header', $smarty->expressoHeader); 
    129136                $smarty->assign('txt_loading', lang("loading")); 
  • branches/2.2/workflow/inc/class.ui_phpeditor.inc.php

    r795 r3167  
    1111 
    1212require_once dirname(__FILE__) . SEP . 'engine' . SEP . 'config.ajax.inc.php'; 
    13 require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php'; 
    1413require_once dirname(__FILE__) . SEP . 'class.ui_ajaxinterface.inc.php'; 
    1514/** 
     
    4544        function ui_phpeditor() 
    4645        { 
    47                 $this->bo = CreateObject('workflow.bo_editor'); 
     46                $this->bo = Factory::getInstance('bo_editor'); 
    4847                $this->loadVariables(); 
    4948        } 
     
    6261        function form() 
    6362        { 
    64                 $smarty = $GLOBALS['workflow']['factory']->getInstance('workflow_smarty', false); 
    65                 $processManager = new ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     63                $smarty = Factory::getInstance('workflow_smarty', false); 
     64                $processManager = &Factory::newInstance('ProcessManager'); 
    6665                $proccessInfo = $processManager->get_process($_GET['proc_id']); 
    6766 
  • branches/2.2/workflow/inc/class.ui_userinterface.inc.php

    r1227 r3167  
    4545                $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['workflow']['title']; 
    4646                $GLOBALS['phpgw_info']['flags'] = array('noheader' => false, 'nonavbar' => false, 'currentapp' => 'workflow'); 
    47                 $smarty = CreateObject('workflow.workflow_smarty'); 
     47                $smarty = Factory::getInstance('workflow_smarty'); 
    4848 
    4949                // Check if workflow config is ok 
     
    114114 
    115115                // Get a connection to db workflow and galaxia (module) 
    116                 if ($GLOBALS['workflow']['workflowObjects']->getDBWorkflow()->Error) 
     116                if (Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Error) 
    117117                        $errors[] = 'Unable to connect to database Workflow'; 
    118118 
    119                 if ($errormsg = $GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Error) 
     119                if ($errormsg = Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Error) 
    120120                        $errors[] = 'Unable to connect to database Galaxia'; 
    121121 
     
    129129 
    130130                /* create some objects */ 
    131                 require_once 'class.so_userinterface.inc.php'; 
    132                 $so = new so_userinterface(); 
    133                 $smarty = CreateObject('workflow.workflow_smarty'); 
     131                $so = &Factory::getInstance('so_userinterface'); 
     132                $smarty = &Factory::getInstance('workflow_smarty'); 
    134133 
    135134                /* get the user's organization */ 
     
    202201 
    203202                /* pass variables to smarty */ 
    204                 $smarty->assign('areasInfo', $flatAreas); 
     203                $smarty->assign('areasJson', json_encode($flatAreas)); 
    205204                $smarty->assign('javaScripts', $javaScripts); 
    206205                $smarty->assign('css', $css); 
  • branches/2.2/workflow/inc/class.workflow_acl.inc.php

    r795 r3167  
    3030        function workflow_acl() 
    3131        { 
    32                 parent::so_adminaccess($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     32                parent::so_adminaccess(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    3333        } 
    3434 
  • branches/2.2/workflow/inc/class.workflow_activitymanager.inc.php

    r795 r3167  
    55 
    66        require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php'); 
    7         require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'GraphViz.php'); 
    8         require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php'); 
    9         require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'common' . SEP . 'WfSecurity.php'); 
    107        /** 
    118         * @package Workflow 
     
    2017                function workflow_activitymanager() 
    2118                { 
    22                         parent::ActivityManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     19                        parent::ActivityManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    2320                } 
    2421        } 
  • branches/2.2/workflow/inc/class.workflow_baseactivity.inc.php

    r795 r3167  
    1717                function workflow_baseactivity() 
    1818                { 
    19                         parent::BaseActivity($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     19                        parent::BaseActivity(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    2020                } 
    2121        } 
  • branches/2.2/workflow/inc/class.workflow_gui.inc.php

    r795 r3167  
    55 
    66        require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'GUI' . SEP . 'GUI.php'); 
    7         require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'API' . SEP . 'Process.php'); 
    8         require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'API' . SEP . 'Instance.php'); 
    9         require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'common' . SEP . 'WfSecurity.php'); 
     7 
    108        /** 
    119         * @package Workflow 
     
    2018                function workflow_gui() 
    2119                { 
    22                         parent::GUI($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     20                        parent::GUI(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    2321                } 
    2422        } 
  • branches/2.2/workflow/inc/class.workflow_instance.inc.php

    r795 r3167  
    66 
    77        require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'API' . SEP . 'Instance.php'); 
    8         require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'common' . SEP . 'WfSecurity.php'); 
    9         require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php'); 
    108        /** 
    119         * @package Workflow 
     
    2018                function workflow_Instance() 
    2119                { 
    22                         parent::Instance($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     20                        parent::Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    2321                } 
    2422        } 
  • branches/2.2/workflow/inc/class.workflow_instancemanager.inc.php

    r795 r3167  
    1717                function workflow_instancemanager() 
    1818                { 
    19                         parent::InstanceManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     19                        parent::InstanceManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    2020                } 
    2121        } 
  • branches/2.2/workflow/inc/class.workflow_process.inc.php

    r795 r3167  
    1616                function workflow_process() 
    1717                { 
    18                         parent::Process($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     18                        parent::Process(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    1919                } 
    2020        } 
  • branches/2.2/workflow/inc/class.workflow_processmanager.inc.php

    r795 r3167  
    55 
    66        require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php'); 
    7         require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'RoleManager.php'); 
    8         require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php'); 
    9         require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'API' . SEP . 'Process.php'); 
     7 
    108        /** 
    119         * @package Workflow 
     
    2624                        'database_user', 
    2725                        'database_password' 
    28                 );  
     26                ); 
    2927           /** 
    3028                 * Constructor 
     
    3432                function workflow_processmanager() 
    3533                { 
    36                         parent::ProcessManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
    37                         $this->workflow_acl = CreateObject('workflow.workflow_acl'); 
    38                          
     34                        parent::ProcessManager(); 
     35                        $this->workflow_acl = Factory::getInstance('workflow_acl'); 
     36 
    3937                        /* allow regular users to see the process graph */ 
    4038                        if ($_GET['menuaction'] == "workflow.ui_adminactivities.show_graph") 
     
    6260                function import_process(&$data) 
    6361                { 
    64                         if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db); 
     62                        if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager'); 
    6563 
    6664                        if (parent::import_process($data)) 
     
    121119                function serialize_process($pId) 
    122120                { 
    123                         if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db); 
     121                        if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager'); 
    124122                        if (!isset($this->jobManager)) 
    125                                 $this->jobManager = new JobManager($this->db); 
     123                                $this->jobManager = &Factory::newInstance('JobManager'); 
    126124                 
    127125                        //if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db); 
     
    228226                          fclose($fp); 
    229227                          $out.='      ]]></code>'; 
    230                           if($res['wf_is_interactive']=='y') { 
    231                                 $out.='      <template><![CDATA['; 
    232                                 $fp=fopen(GALAXIA_PROCESSES.SEP."$wf_procname".SEP."code".SEP."templates".SEP."$name.tpl","r"); 
    233                                 //while(!feof($fp)) { 
    234                                 //      $line=fread($fp,8192); 
    235                                         $out.=''; //all templatess will be exported in another section 
    236                                 //} 
    237                                 fclose($fp); 
    238                                 $out.='      ]]></template>'; 
    239                           } 
    240228                          $out.='    </activity>'."\n";     
    241229                        } 
  • branches/2.2/workflow/inc/class.workflow_processmonitor.inc.php

    r795 r3167  
    1717                function workflow_processmonitor() 
    1818                { 
    19                         parent::ProcessMonitor($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     19                        parent::ProcessMonitor(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    2020                } 
    2121        } 
  • branches/2.2/workflow/inc/class.workflow_rolemanager.inc.php

    r795 r3167  
    1717                function workflow_rolemanager() 
    1818                { 
    19                         parent::RoleManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     19                        parent::RoleManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    2020                } 
    2121        } 
  • branches/2.2/workflow/inc/class.workflow_smarty.inc.php

    r1227 r3167  
    1111 
    1212require_once 'smarty/Smarty.class.php'; 
    13 //require_once 'class.ui_ajaxinterface.inc.php'; 
    1413 
    1514/** 
  • branches/2.2/workflow/inc/class.workflow_wfruntime.inc.php

    r795 r3167  
    1818                function workflow_wfruntime() 
    1919                { 
    20                         parent::WfRuntime($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     20                        parent::WfRuntime(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    2121                } 
    2222        } 
  • branches/2.2/workflow/inc/class.workflow_wfsecurity.inc.php

    r1712 r3167  
    1818                function workflow_wfsecurity() 
    1919                { 
    20                         parent::WfSecurity($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     20                        parent::WfSecurity(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID); 
    2121                } 
    2222        } 
  • branches/2.2/workflow/inc/common.inc.php

    r1484 r3167  
    11<?php 
    2 if (file_exists(dirname(__FILE__) . '/../../header.session.inc.php')) { 
    3         require_once dirname(__FILE__) . '/../../header.session.inc.php'; 
     2/**************************************************************************\ 
     3* eGroupWare                                                               * 
     4* http://www.egroupware.org                                                * 
     5* --------------------------------------------                             * 
     6*  This program is free software; you can redistribute it and/or modify it * 
     7*  under the terms of the GNU General Public License as published by the   * 
     8*  Free Software Foundation; either version 2 of the License, or (at your  * 
     9*  option) any later version.                                              * 
     10\**************************************************************************/ 
     11 
     12/** 
     13 * Server base path. This constant is somewhat simililar to 
     14 * 'PHPGW_SERVER_ROOT'. Nevertheless, there are cases that we 
     15 * access Workflow directly and it must be defined somewhere. 
     16 * Recently discovered, when we are runnnig jobs HTTP_SERVER_VARS 
     17 * exported by apache are not available. 
     18 * Therefore, we are using this workaround here, setting 
     19 * EGW_SERVER_ROOT based on the location of this file. This constant 
     20 * should be updated properly every time we move this file. 
     21 * @name EGW_SERVER_ROOT 
     22 */ 
     23define('EGW_SERVER_ROOT', dirname(dirname(dirname(__FILE__)))); 
     24//define('EGW_SERVER_ROOT', $GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT']); 
     25 
     26/** 
     27 * Server include base path. We must define our own constants 
     28 * because there are several cases in which workflow is called 
     29 * directly, thus PHPGW constants are not defined. 
     30 * @name EGW_INC_ROOT 
     31 */ 
     32define('EGW_INC_ROOT', EGW_SERVER_ROOT . '/phpgwapi/inc/'); 
     33 
     34/** 
     35 * Workflow base path. 
     36 * @name WF_SERVER_ROOT 
     37 */ 
     38define('WF_SERVER_ROOT', EGW_SERVER_ROOT.'/workflow/'); 
     39 
     40/** 
     41 * Workflow include path. 
     42 * @name WF_INC_ROOT 
     43 */ 
     44define('WF_INC_ROOT', WF_SERVER_ROOT.'/inc/'); 
     45 
     46/** 
     47 * Workflow lib base dir. 
     48 * @name WF_LIB_ROOT 
     49 */ 
     50define('WF_LIB_ROOT', WF_SERVER_ROOT.'/lib/'); 
     51 
     52 
     53if (file_exists(EGW_SERVER_ROOT . '/header.session.inc.php')) { 
     54        require_once EGW_SERVER_ROOT . '/header.session.inc.php'; 
    455} 
    556 
    6 /* garante que durante a execução de funções que modificam strings, os 
    7  * caracteres acentuados sejam tratados corretamente (e.g. strtoupper) 
    8  */ 
     57 
     58/* assure that the correct encondig will be used (e.g string functions) */ 
    959setlocale(LC_CTYPE, 'pt_BR', 'pt_BR.iso-8859-1', 'pt_BR.utf-8'); 
     60 
    1061 
    1162/* define o umask para a criação de arquivos por parte do Workflow */ 
    1263umask(007); 
    1364 
    14 require_once dirname(__FILE__) . '/class.factory.inc.php'; 
    1565 
    16 /** 
    17  * Objeto que implementa uma Factory 
    18  * @global object $GLOBALS['workflow']['factory'] 
    19  * @name $factory 
    20  */ 
    21 $GLOBALS['workflow']['factory'] = new Factory(); 
    22  
    23 /** 
    24  * Objeto que cria objetos voltados exclusivamente para o módulo Workflow 
    25  * @global object $GLOBALS['workflow']['workflowObjects'] 
    26  * @name $workflowObjects 
    27  */ 
    28 $GLOBALS['workflow']['workflowObjects'] = $GLOBALS['workflow']['factory']->newInstance('WorkflowObjects'); 
     66/* including common classes */ 
     67require_once WF_LIB_ROOT . 'security/Security.php'; 
     68require_once WF_LIB_ROOT . 'factory/Factory.php'; 
     69require_once WF_LIB_ROOT . 'factory/BaseFactory.php'; 
     70require_once WF_LIB_ROOT . 'factory/WorkflowFactory.php'; 
     71require_once WF_LIB_ROOT . 'factory/ProcessFactory.php'; 
     72require_once WF_INC_ROOT . 'common_functions.inc.php'; 
    2973?> 
  • branches/2.2/workflow/inc/engine/class.ajax_config.inc.php

    r795 r3167  
    4545                } 
    4646 
    47                 $this->db      = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso(); 
     47                $this->db      =& Factory::getInstance('WorkflowObjects')->getDBExpresso(); 
    4848                $this->appname = $appname; 
    4949        } 
     
    5151        /** 
    5252        * Reads the whole repository for $this->appname, appname has to be set via the constructor 
    53         *  
     53        * 
    5454        * @return array the whole config-array for that app 
    5555        * @access public 
  • branches/2.2/workflow/inc/engine/class.ajax_ldap.inc.php

    r795 r3167  
    2929        function ajax_ldap() 
    3030        { 
    31                 $tmpLDAP = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     31                $tmpLDAP = &Factory::getInstance('WorkflowLDAP'); 
    3232                $this->user_context  = $tmpLDAP->getUserContext(); 
    3333                $this->group_context = $tmpLDAP->getGroupContext(); 
    3434 
    35                 $this->ds = &$GLOBALS['workflow']['workflowObjects']->getLDAP(); 
     35                $this->ds =& Factory::getInstance('WorkflowObjects')->getLDAP(); 
    3636        } 
    3737 
     
    8383        function id2fullname($account_id) 
    8484    { 
    85                 return $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getName($account_id); 
     85                return Factory::getInstance('WorkflowLDAP')->getName($account_id); 
    8686    } 
    8787 
     
    107107                        $accountID = $_SESSION['phpgw_info']['workflow']['account_id']; 
    108108 
    109                 $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     109                $ldap =& Factory::getInstance('WorkflowLDAP'); 
    110110                if (count($output = $ldap->getUserGroups($accountID)) == 0) 
    111111                        return false; 
  • branches/2.2/workflow/inc/engine/config.ajax.inc.php

    r795 r3167  
    170170                if ($loadGroups) 
    171171                { 
    172                         $memberships = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getUserGroups($user); 
     172                        $memberships = Factory::getInstance('WorkflowLDAP')->getUserGroups($user); 
    173173                        if ($user == $_SESSION['phpgw_info']['workflow']['account_id']) 
    174174                                $_SESSION['phpgw_info']['workflow']['user_groups'] = $memberships; 
     
    196196                { 
    197197                        /* get information regarding the members of the group */ 
    198                         $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     198                        $ldap = &Factory::getInstance('WorkflowLDAP'); 
    199199                        $members = $ldap->getGroupUsers($group); 
    200200 
     
    256256        function galaxia_get_config_values($parameters=array()) 
    257257        { 
    258                         $config = new ajax_config(); 
     258                        $config = &Factory::getInstance('ajax_config'); 
    259259                        $config->read_repository(); 
    260260 
  • branches/2.2/workflow/inc/engine/config.egw.inc.php

    r795 r3167  
    151151        function galaxia_user_can_admin_process() 
    152152        { 
    153                 return ($GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('admin_workflow', 1, 'workflow')); 
     153                return (Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('admin_workflow', 1, 'workflow')); 
    154154        } 
    155155} 
     
    165165        function galaxia_user_can_admin_instance() 
    166166        { 
    167                 return ($GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('admin_instance_workflow', 1, 'workflow')); 
     167                return (Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('admin_instance_workflow', 1, 'workflow')); 
    168168        } 
    169169} 
     
    179179        function galaxia_user_can_clean_instances() 
    180180        { 
    181                 return ($GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('cleanup_workflow', 1, 'workflow')); 
     181                return (Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('cleanup_workflow', 1, 'workflow')); 
    182182        } 
    183183} 
     
    191191        function galaxia_user_can_clean_aborted_instances() 
    192192        { 
    193                 return ($GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('cleanup_aborted_workflow', 1, 'workflow')); 
     193                return (Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('cleanup_aborted_workflow', 1, 'workflow')); 
    194194        } 
    195195} 
     
    203203        function galaxia_user_can_monitor() 
    204204        { 
    205                 return ($GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('monitor_workflow', 1, 'workflow')); 
     205                return (Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']) || $GLOBALS['phpgw']->acl->check('monitor_workflow', 1, 'workflow')); 
    206206        } 
    207207} 
     
    221221                                $user = $GLOBALS['phpgw_info']['user']['account_id']; 
    222222 
    223                         $memberships = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getUserGroups($user); 
     223                        $memberships = Factory::getInstance('WorkflowLDAP')->getUserGroups($user); 
    224224 
    225225                        if ($memberships === false) 
     
    245245                { 
    246246                        /* get information regarding the members of the group */ 
    247                         $members = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getGroupUsers($group); 
     247                        $members = &Factory::getInstance('WorkflowLDAP')->getGroupUsers($group); 
    248248 
    249249                        /* checl for error in the LDAP query */ 
     
    305305                { 
    306306                        // This way we create a new run_activity instance for the next activity 
    307                         $run_activity = CreateObject('workflow.run_activity.go'); 
     307                        $run_activity = Factory::getInstance('run_activity'); 
    308308                        $data = $run_activity->go($activityId, $iid, $auto); 
    309309                        return $data; 
     
    325325        function galaxia_get_config_values($parameters=array()) 
    326326        { 
    327                         $config = CreateObject('phpgwapi.config'); 
     327                        $config = Factory::getInstance('config'); 
    328328                        $config->read_repository(); 
    329329 
  • branches/2.2/workflow/inc/engine/src/API/BaseActivity.php

    r795 r3167  
    8484   * Seems to be the rest of a bad object architecture 
    8585   *  
    86    * @deprecated 
     86   * @deprecated 2.2.00.000 
    8787   */ 
    8888  function setDb(&$db) 
    8989  { 
     90        wf_warn_deprecated_method(); 
    9091    $this->db =& $db; 
    9192  } 
     
    9798   * @access public 
    9899   */ 
    99   function BaseActivity(&$db) 
     100  function BaseActivity() 
    100101  { 
    101102    $this->type='base'; 
    102103    $this->child_name = 'BaseActivity'; 
    103     parent::Base($db); 
     104    parent::Base(); 
    104105  } 
    105106 
     
    122123    if(!$result || !$result->numRows() ) return false; 
    123124    $res = $result->fetchRow(); 
     125 
    124126    switch($res['wf_type']) { 
    125127      case 'start': 
    126         require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Start.php'); 
    127         $act = new Start($this->db);   
    128         break; 
     128        $act = &Factory::newInstance('Start'); 
     129        break; 
     130 
    129131      case 'end': 
    130         require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'End.php'); 
    131         $act = new End($this->db); 
    132         break; 
     132        $act = &Factory::newInstance('End'); 
     133        break; 
     134 
    133135      case 'join': 
    134         require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Join.php'); 
    135         $act = new Join($this->db); 
    136         break; 
     136        $act = &Factory::newInstance('Join'); 
     137        break; 
     138 
    137139      case 'split': 
    138         require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Split.php'); 
    139         $act = new Split($this->db); 
    140         break; 
     140        $act = &Factory::newInstance('Split'); 
     141        break; 
     142 
    141143      case 'standalone': 
    142         require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Standalone.php'); 
    143         $act = new Standalone($this->db); 
    144         break; 
     144        $act = &Factory::newInstance('Standalone'); 
     145        break; 
     146 
    145147      case 'view': 
    146         require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'View.php'); 
    147         $act = new View($this->db); 
    148         break; 
     148        $act = &Factory::newInstance('View'); 
     149        break; 
     150 
    149151      case 'switch': 
    150         require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'SwitchActivity.php'); 
    151         $act = new SwitchActivity($this->db); 
    152         break; 
     152        $act = &Factory::newInstance('SwitchActivity'); 
     153        break; 
     154 
    153155      case 'activity': 
    154         require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Activity.php'); 
    155         $act = new Activity($this->db); 
    156         break; 
     156        $act = &Factory::newInstance('Activity'); 
     157        break; 
     158 
    157159      default: 
    158160        trigger_error('Unknown activity type:'.$res['wf_type'],E_USER_WARNING); 
    159161    } 
    160      
     162 
    161163    $act->setName($res['wf_name']); 
    162164    $act->setProcessId($res['wf_p_id']); 
     
    549551   * e.g. $isadmin = $activity->checkUserRole($user,'admin') 
    550552   *  
    551    * @deprecated Unused function. Old API, do not use it. Return always false 
     553   * @deprecated 2.2.00.000 - Unused function. Old API, do not use it. Return always false 
    552554   */ 
    553555  function checkUserRole($user,$rolename)  
    554556  { 
     557        wf_warn_deprecated_method(); 
    555558    $this->error[] = 'use of an old deprecated function checkUserRole, return always false'; 
    556559    return false; 
  • branches/2.2/workflow/inc/engine/src/API/Instance.php

    r795 r3167  
    11<?php 
    22require_once (GALAXIA_LIBRARY.SEP.'src'.SEP.'common'.SEP.'Base.php'); 
    3 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'common' . SEP . 'WfSecurity.php'); 
    43require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php'); 
    54 
     
    8685  var $parentLock = false; 
    8786  /** 
    88    * @var int $parentActivityId The activity ID of the parent instance 
    89    * @access public 
    90    */ 
    91   var $parentActivityId; 
    92   /** 
    9387   * @var int $parentInstanceId The instance ID of the parent instance 
    9488   * @access public 
     
    141135 
    142136  var $activityID = null; 
    143   function Instance($db)  
     137  function Instance()  
    144138  { 
    145139    $this->child_name = 'Instance'; 
    146     parent::Base($db); 
     140    parent::Base(); 
    147141  } 
    148142 
     
    491485    return ''; 
    492486  } 
    493   
     487 
    494488  /** 
    495489   * Creates a new instance. 
     
    504498  function _createNewInstance($activityId,$user) { 
    505499    // Creates a new instance setting up started, ended, user, status and owner 
    506     $pid = $this->getOne('select wf_p_id from '.GALAXIA_TABLE_PREFIX.'activities where wf_activity_id=?',array((int)$activityId)); 
     500    $pid = $this->getOne('SELECT wf_p_id FROM '.GALAXIA_TABLE_PREFIX.'activities WHERE wf_activity_id=?',array((int)$activityId)); 
    507501    $this->pId = $pid; 
    508502    $this->setStatus('active'); 
     
    511505    $this->setStarted($now); 
    512506    $this->setOwner($user); 
    513      
    514     $query = 'insert into '.GALAXIA_TABLE_PREFIX.'instances 
    515       (wf_started,wf_ended,wf_status,wf_p_id,wf_owner,wf_properties)  
    516       values(?,?,?,?,?,?)'; 
    517     $this->query($query,array($now,0,'active',$pid,$user,$this->security_cleanup(Array(),false))); 
    518     $this->instanceId = $this->getOne('select max(wf_instance_id) from '.GALAXIA_TABLE_PREFIX.'instances  
    519                       where wf_started=? and wf_owner=?',array((int)$now,$user)); 
     507 
     508    //Get the id of new instance, before insert values in table and use this value from main table and relationship tables. 
     509    $this->instanceId = $this->getOne("SELECT nextval('seq_egw_wf_instances')"); 
    520510    $iid=$this->instanceId; 
    521      
     511 
     512    $query = 'INSERT INTO '.GALAXIA_TABLE_PREFIX.'instances 
     513                (wf_instance_id, wf_started,wf_ended,wf_status,wf_p_id,wf_owner,wf_properties) 
     514              VALUES 
     515                (?,?,?,?,?,?,?)'; 
     516 
     517    $this->query($query,array((int)$iid, $now,0,'active',$pid,$user,$this->security_cleanup(Array(),false))); 
     518 
    522519    // Then add in ".GALAXIA_TABLE_PREFIX."instance_activities an entry for the 
    523520    // activity the user and status running and started now 
    524     $query = 'insert into '.GALAXIA_TABLE_PREFIX.'instance_activities (wf_instance_id,wf_activity_id,wf_user, 
    525             wf_started,wf_status) values(?,?,?,?,?)'; 
     521    $query = 'INSERT INTO '.GALAXIA_TABLE_PREFIX.'instance_activities 
     522                (wf_instance_id,wf_activity_id,wf_user,wf_started,wf_status) 
     523              VALUES 
     524                (?,?,?,?,?)'; 
    526525    $this->query($query,array((int)$iid,(int)$activityId,$user,(int)$now,'running')); 
    527526 
    528527    if (($this->isChildInstance) && (!is_null($this->parentInstanceId))) 
    529528    { 
    530       $query = 'INSERT INTO '.GALAXIA_TABLE_PREFIX.'interinstance_relations(wf_parent_instance_id, wf_parent_activity_id, wf_child_instance_id, wf_parent_lock) VALUES(?,?,?,?)'; 
    531       $this->query($query,array((int) $this->parentInstanceId, (int) $this->parentActivityId, (int) $iid, (int) (($this->parentLock) ? 1 : 0))); 
    532     } 
    533      
     529      $query = 'INSERT INTO '.GALAXIA_TABLE_PREFIX.'interinstance_relations 
     530                  (wf_parent_instance_id, wf_child_instance_id, wf_parent_lock) 
     531                VALUES 
     532                  (?,?,?)'; 
     533      $this->query($query,array((int) $this->parentInstanceId, (int) $iid, (int) (($this->parentLock) ? 1 : 0))); 
     534    } 
     535 
    534536    //update database with other datas stored in the object 
    535537    return $this->sync(); 
    536538  } 
    537    
     539 
    538540  /** 
    539541   * Sets the name of this instance 
     
    11411143    return $this->__activity_completed; 
    11421144  } 
    1143   
     1145 
    11441146  /** 
    11451147   * This function can be called by the instance object himself (for automatic activities) 
    1146    * or by the WfRuntime object. In interactive activities code users use complete() --without args--  
    1147    * which refer to the WfRuntime->complete() function which call this one.  
     1148   * or by the WfRuntime object. In interactive activities code users use complete() --without args-- 
     1149   * which refer to the WfRuntime->complete() function which call this one. 
    11481150   * In non-interactive activities a call to a complete() will generate errors because the engine 
    11491151   * does it his own way as I said first. 
     
    11611163  { 
    11621164    //$this->db-> 
    1163     $result = $this->query("SELECT 1 FROM " . GALAXIA_TABLE_PREFIX . "instances i, " . GALAXIA_TABLE_PREFIX . "interinstance_relations ir WHERE (ir.wf_child_instance_id = i.wf_instance_id) AND (i.wf_status IN ('active', 'exception')) AND (ir.wf_parent_lock = 1) AND (ir.wf_parent_instance_id = ?) AND (ir.wf_parent_activity_id = ?)", array($this->instanceId, $activityId)); 
     1165    $result = $this->query("SELECT 1 FROM " . GALAXIA_TABLE_PREFIX . "instances i, " . GALAXIA_TABLE_PREFIX . "interinstance_relations ir WHERE (ir.wf_child_instance_id = i.wf_instance_id) AND (i.wf_status IN ('active', 'exception')) AND (ir.wf_parent_lock = 1) AND (ir.wf_parent_instance_id = ?)", array($this->instanceId)); 
    11641166    if ($result->numRows() > 0) 
    11651167      die("Esta instância está aguardando que outras instâncias, das quais depende, sejam finalizadas."); 
     
    11691171    //The complete() is in a transaction, it will be completly done or not at all 
    11701172    $this->db->StartTrans(); 
    1171      
     1173 
    11721174    //lock rows and ensure access is granted 
    1173     if (!(isset($this->security))) $this->security =& new WfSecurity($this->db);  
     1175    if (!(isset($this->security))) $this->security = &Factory::getInstance('WfSecurity'); 
    11741176    if (!($this->security->checkUserAction($activityId,$this->instanceId,'complete'))) 
    11751177    { 
     
    15511553    { 
    15521554      //we check rights for this user on the next activity 
    1553       if (!(isset($this->security))) $this->security =& new WfSecurity($this->db);  
     1555      if (!(isset($this->security))) $this->security = &Factory::getInstance('WfSecurity'); 
    15541556      if ($this->security->checkUserAccess($the_next_user,$activityId)) 
    15551557      { 
     
    15601562    { 
    15611563      // then check to see if there is a default user 
    1562       $activity_manager =& new ActivityManager($this->db); 
     1564      $activity_manager = &Factory::newInstance('ActivityManager'); 
    15631565      //get_default_user will give us '*' if there is no default_user or if the default user has no role 
    15641566      //mapped anymore 
  • branches/2.2/workflow/inc/engine/src/API/Process.php

    r795 r3167  
    4848         * @access public 
    4949         */ 
    50         function Process(&$db)  
     50        function Process()  
    5151        { 
    5252                $this->child_name = 'Process'; 
    53                 parent::Base($db); 
     53                parent::Base(); 
    5454        } 
    5555 
  • branches/2.2/workflow/inc/engine/src/API/activities/Activity.php

    r795 r3167  
    1616         * @access public 
    1717         */ 
    18         function Activity(&$db) 
     18        function Activity() 
    1919        { 
    20                 parent::Base($db); 
     20                parent::Base(); 
    2121                $this->child_name = 'Activity'; 
    2222        } 
  • branches/2.2/workflow/inc/engine/src/API/activities/End.php

    r795 r3167  
    1515         * @access public 
    1616         */ 
    17         function End(&$db) 
     17        function End() 
    1818        { 
    19                 parent::Base($db); 
     19                parent::Base(); 
    2020                $this->child_name = 'End'; 
    2121        } 
  • branches/2.2/workflow/inc/engine/src/API/activities/Join.php

    r795 r3167  
    1515         * @access public 
    1616         */ 
    17         function Join(&$db) 
     17        function Join() 
    1818        { 
    19                 parent::Base($db); 
     19                parent::Base(); 
    2020                $this->child_name = 'Join'; 
    2121        } 
  • branches/2.2/workflow/inc/engine/src/API/activities/Split.php

    r795 r3167  
    1515         * @access public 
    1616         */ 
    17         function Split(&$db) 
     17        function Split() 
    1818        { 
    19                 parent::Base($db); 
     19                parent::Base(); 
    2020                $this->child_name = 'Split'; 
    2121        } 
  • branches/2.2/workflow/inc/engine/src/API/activities/Standalone.php

    r795 r3167  
    1515         * @access public 
    1616         */ 
    17         function Standalone(&$db) 
     17        function Standalone() 
    1818        { 
    19                 parent::Base($db); 
     19                parent::Base(); 
    2020                $this->child_name = 'Standalone'; 
    2121        } 
  • branches/2.2/workflow/inc/engine/src/API/activities/Start.php

    r795 r3167  
    1515         * @access public 
    1616         */ 
    17         function Start(&$db) 
     17        function Start() 
    1818        { 
    19                 parent::Base($db); 
     19                parent::Base(); 
    2020                $this->child_name = 'Start'; 
    2121        } 
  • branches/2.2/workflow/inc/engine/src/API/activities/SwitchActivity.php

    r795 r3167  
    1616         * @access public 
    1717         */ 
    18         function SwitchActivity(&$db) 
     18        function SwitchActivity() 
    1919        { 
    20            parent::Base($db); 
     20           parent::Base(); 
    2121           $this->child_name = 'Switch'; 
    2222        } 
  • branches/2.2/workflow/inc/engine/src/API/activities/View.php

    r795 r3167  
    1616         * @access public 
    1717         */      
    18         function View(&$db) 
     18        function View() 
    1919        { 
    20                 parent::Base($db); 
     20                parent::Base(); 
    2121                $this->child_name = 'View'; 
    2222        } 
  • branches/2.2/workflow/inc/engine/src/GUI/GUI.php

    r795 r3167  
    3232   * @access public 
    3333   */ 
    34   function GUI(&$db)  
     34  function GUI() 
    3535  { 
    3636    $this->child_name = 'GUI'; 
    37     parent::Base($db); 
    38     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'common'.SEP.'WfSecurity.php'); 
    39     $this->wf_security =& new WfSecurity($this->db);  
     37    parent::Base(); 
     38    $this->wf_security = &Factory::getInstance('WfSecurity'); 
    4039  } 
    4140 
     
    703702      if (!(isset($this->pm))) 
    704703      { 
    705         require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'ProcessManager'.SEP.'ProcessManager.php'); 
    706         $this->pm =& new ProcessManager($this->db); 
     704        $this->pm = &Factory::newInstance('ProcessManager'); 
    707705      } 
    708706      $this->process_cache[$pId]['view'] = $this->pm->get_process_view_activity($pId); 
     
    871869    { 
    872870      //the security object said everything was fine 
    873       $instance = new Instance($this->db); 
     871      $instance = &Factory::newInstance('Instance'); 
    874872      $instance->getInstance($instanceId); 
    875873      if (!empty($instance->instanceId))  
     
    975973    { 
    976974      //the security object said everything was fine 
    977       $instance =& new Instance($this->db); 
     975      $instance = &Factory::newInstance('Instance'); 
    978976      $instance->getInstance($instanceId); 
    979977      // we force the execution of the activity 
     
    10121010    { 
    10131011      //the security object said everything was fine 
    1014       $instance =& new Instance($this->db); 
     1012      $instance = &Factory::newInstance('Instance'); 
    10151013      $instance->getInstance($instanceId); 
    10161014      // we force the continuation of the flow 
  • branches/2.2/workflow/inc/engine/src/ProcessManager/ActivityManager.php

    r795 r3167  
    2626   * @access public 
    2727   */ 
    28   function ActivityManager(&$db) 
    29   { 
    30     parent::BaseManager($db); 
     28  function ActivityManager() 
     29  { 
     30    parent::BaseManager(); 
    3131    $this->child_name = 'ActivityManager'; 
    3232    require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'ProcessManager' .SEP . 'ProcessManager.php'); 
     
    370370  function build_process_graph($pId) 
    371371  { 
    372     if (!(isset($this->process_manager))) $this->process_manager = new ProcessManager($this->db); 
     372    if (!(isset($this->process_manager))) $this->process_manager = &Factory::newInstance('ProcessManager'); 
    373373    $attributes = Array( 
    374374     
    375375    ); 
    376     $graph = new Process_GraphViz(true,$attributes); 
     376    $graph = &Factory::newInstance('Process_GraphViz', true, $attributes); 
    377377    $name = $this->process_manager->_get_normalized_name($pId); 
    378378    $graph->set_pid($name); 
     
    747747  { 
    748748    require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP . 'BaseActivity.php'); 
    749     $act = new BaseActivity($this->db); 
     749    $act = &Factory::newInstance('BaseActivity'); 
    750750    //Warning, we now use the BaseActivity object for it, interactivity and autorouting is now true/fales, not y/n 
    751751    return ($act->getActivity($activityId,false,true, true)); 
     
    825825  function remove_activity($pId, $activityId, $transaction = true) 
    826826  { 
    827     if (!(isset($this->process_manager))) $this->process_manager = new ProcessManager($this->db); 
     827    if (!(isset($this->process_manager))) $this->process_manager = &Factory::newInstance('ProcessManager'); 
    828828    $proc_info = $this->process_manager->get_process($pId); 
    829829    $actname = $this->_get_normalized_name($activityId); 
     
    888888  function replace_activity($pId, $activityId, $vars, $create_files=true) 
    889889  { 
    890     if (!(isset($this->process_manager))) $this->process_manager = new ProcessManager($this->db); 
     890    if (!(isset($this->process_manager))) $this->process_manager = &Factory::newInstance('ProcessManager'); 
    891891    $TABLE_NAME = GALAXIA_TABLE_PREFIX.'activities'; 
    892892    $now = date("U"); 
     
    11951195    elseif ( (!($result=='*')) && $performAccessCheck) 
    11961196    { 
    1197       $wf_security = new WfSecurity($this->db); 
     1197      $wf_security = &Factory::getInstance('WfSecurity'); 
    11981198      // perform the check 
    11991199      if (!($wf_security->checkUserAccess($result,$activityId))) 
  • branches/2.2/workflow/inc/engine/src/ProcessManager/BaseManager.php

    r795 r3167  
    44/** 
    55 * This class is derived by all the API classes so they get the 
    6  * database connection, database methods and the Observable interface 
     6 * database connection and the database methods. 
    77 * 
    88 * @package Galaxia 
     
    1818   * @access public 
    1919   */ 
    20   function BaseManager(&$db) 
     20  function BaseManager() 
    2121  { 
    2222    $this->child_name = 'BaseManager'; 
    23     parent::Base($db); 
     23    parent::Base(); 
    2424  } 
    2525 
  • branches/2.2/workflow/inc/engine/src/ProcessManager/InstanceManager.php

    r795 r3167  
    1616   * @access public 
    1717   */ 
    18   function InstanceManager(&$db)  
    19   { 
    20     parent::BaseManager($db); 
     18  function InstanceManager()  
     19  { 
     20    parent::BaseManager(); 
    2121    $this->child_name = 'InstanceManager'; 
    2222  } 
  • branches/2.2/workflow/inc/engine/src/ProcessManager/JobManager.php

    r795 r3167  
    7676         * @access public 
    7777         */ 
    78         public function JobManager(&$db) 
    79         { 
    80                 parent::BaseManager($db); 
     78        public function JobManager() 
     79        { 
     80                parent::BaseManager(); 
    8181                $this->child_name = 'JobManager'; 
    8282 
    8383                $this->jobTable = GALAXIA_TABLE_PREFIX . 'jobs'; 
    8484                $this->logTable = GALAXIA_TABLE_PREFIX . 'job_logs'; 
    85                 $this->processManager = new ProcessManager($this->db); 
     85                $this->processManager = &Factory::newInstance('ProcessManager'); 
    8686        } 
    8787 
  • branches/2.2/workflow/inc/engine/src/ProcessManager/ProcessManager.php

    r795 r3167  
    44 * Adds, removes, modifies and lists processes. 
    55 * Most of the methods acts directly in database level, bypassing Project object methods 
    6  *  
     6 * 
    77 * @todo Fix multiple non checked fopen ==> infinite loops in case of problems with filesystem 
    88 * @package Galaxia 
    9  * @license http://www.gnu.org/copyleft/gpl.html GPL  
     9 * @license http://www.gnu.org/copyleft/gpl.html GPL 
    1010 */ 
    1111class ProcessManager extends BaseManager { 
    12    
    13   /** 
    14    * @var resource $parser xml parser 
    15    * @access public 
    16    */ 
    17   var $parser; 
    18    
    19   /** 
    20    * @var array $tree data struture 
    21    * @access public 
    22    */ 
    23   var $tree; 
    24    
    25   /** 
    26    * @var $current current element 
    27    * @access public 
    28    */ 
    29   var $current; 
    30    
    31   /** 
    32    * @var $buffer buffer for data 
    33    * @access public 
    34    */ 
    35   var $buffer; 
    36    
    37   /** 
    38    * @var object $Process Process 
    39    * @access public 
    40    */ 
    41   var $Process; 
    42    
    43   /** 
    44    * @var object $activity_manager Activity Manager 
    45    * @access public 
    46    */ 
    47   var $activity_manager; 
    48  
    49   /** 
    50    * @var object $jobManager Job Manager object 
    51    * @access public 
    52    */ 
    53   var $jobManager; 
    54     
    55   /** 
    56    * @var object $role_manager Role Manager 
    57    * @access public 
    58    */ 
    59   var $role_manager; 
    60    
    61   /** 
    62    * Constructor 
    63    *  
    64    * @param object &$db ADOdb  
    65    * @return object ProcessManager 
    66    * @access public 
    67    */ 
    68   function ProcessManager(&$db)  
    69   { 
    70     parent::BaseManager($db); 
    71     $this->child_name = 'ProcessManager'; 
    72     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'ProcessManager'.SEP.'ActivityManager.php'); 
    73     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'ProcessManager'.SEP.'JobManager.php'); 
    74     // $this->activity_manager is not set here to avoid objects loading object A loading object B loading object A, etc 
    75     //$this->role_manager will only be loaded when needed as well 
    76   } 
    77  
    78   /** 
    79   * Collect errors from all linked objects which could have been used by this object. 
    80   * Each child class should instantiate this function with her linked objetcs, calling get_error(true) 
    81   * 
    82   * @param bool $debug False by default, if true debug messages can be added to 'normal' messages 
    83   * @param string $prefix Appended to the debug message 
    84   * @return void  
    85   * @access public 
    86   */ 
    87   function collect_errors($debug=false, $prefix = '') 
    88   { 
    89     parent::collect_errors($debug, $prefix); 
    90     if (isset($this->activity_manager)) $this->error[] = $this->activity_manager->get_error(false, $debug, $prefix); 
    91     if (isset($this->role_manager)) $this->error[] = $this->role_manager->get_error(false, $debug, $prefix); 
    92   } 
    93  
    94   /** 
    95    * Activates a process 
    96    *  
    97    * @param int $pId Process id 
    98    * @return void  
    99    * @access public 
    100    */ 
    101   function activate_process($pId) 
    102   { 
    103     $query = 'update '.GALAXIA_TABLE_PREFIX.'processes set wf_is_active=? where wf_p_id=?'; 
    104     $this->query($query, array('y',$pId));   
    105     $msg = sprintf(tra('Process %d has been activated'),$pId); 
    106     $this->notify_all(3,$msg); 
    107     $this->error[] = $msg; 
    108   } 
    109    
    110   /** 
    111    * Deactivates a process 
    112    *  
    113    * @param int $pId Process id 
    114    * @return void  
    115    * @access public 
    116    */ 
    117   function deactivate_process($pId) 
    118   { 
    119     $query = 'update '.GALAXIA_TABLE_PREFIX.'processes set wf_is_active=? where wf_p_id=?'; 
    120     $this->query($query, array('n',$pId));   
    121     $msg = sprintf(tra('Process %d has been deactivated'),$pId); 
    122     $this->notify_all(3,$msg); 
    123     $this->error[] = $msg; 
    124   } 
    125    
    126   /** 
    127    * Creates an XML representation of a process 
    128    *  
    129    * @param int $pId Process id 
    130    * @return string  
    131    * @access public 
    132    */   
    133   function serialize_process($pId) 
    134   { 
    135     if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db); 
    136     // <process> 
    137     $out = '<process>'."\n"; 
    138     //we retrieve config values with the others process data 
    139     $proc_info =& $this->get_process($pId, true); 
    140     $wf_procname = $proc_info['wf_normalized_name']; 
    141     $out.= '  <name>'.htmlspecialchars($proc_info['wf_name']).'</name>'."\n"; 
    142     $out.= '  <isValid>'.htmlspecialchars($proc_info['wf_is_valid']).'</isValid>'."\n"; 
    143     $out.= '  <version>'.htmlspecialchars($proc_info['wf_version']).'</version>'."\n"; 
    144     $out.= '  <isActive>'.htmlspecialchars($proc_info['wf_is_active']).'</isActive>'."\n"; 
    145     $out.='   <description>'.htmlspecialchars($proc_info['wf_description']).'</description>'."\n"; 
    146     $out.= '  <lastModif>'.date("d/m/Y [h:i:s]",$proc_info['wf_last_modif']).'</lastModif>'."\n"; 
    147  
    148     //Shared code 
    149     $out.= '  <sharedCode><![CDATA['; 
    150     $fp=fopen(GALAXIA_PROCESSES.SEP."$wf_procname".SEP."code".SEP."shared.php","r"); 
    151     while(!feof($fp)) { 
    152       $line=fread($fp,8192); 
    153       $out.=$line; 
    154     } 
    155     fclose($fp); 
    156     $out.= '  ]]></sharedCode>'."\n"; 
    157  
    158     //Loop on config values 
    159     $out.='  <configs>'."\n"; 
    160     foreach($proc_info['config'] as $res) {       
    161       $name = $res['wf_config_name']; 
    162       $value_int = $res['wf_config_value_int']; 
    163       $value = $res['wf_config_value']; 
    164       $out.='    <config>'."\n"; 
    165       $out.='      <wf_config_name>'.htmlspecialchars($name).'</wf_config_name>'."\n"; 
    166       $out.='      <wf_config_value>'.htmlspecialchars($value).'</wf_config_value>'."\n"; 
    167       $out.='      <wf_config_value_int>'.htmlspecialchars($value_int).'</wf_config_value_int>'."\n"; 
    168       $out.='    </config>'."\n"; 
    169     } 
    170     $out.='  </configs>'."\n"; 
    171  
    172     // Now loop over activities 
    173     $query = "select * from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId"; 
    174     $result = $this->query($query); 
    175     $out.='  <activities>'."\n"; 
    176     while($res = $result->fetchRow()) {       
    177       $name = $res['wf_normalized_name']; 
    178       $out.='    <activity>'."\n"; 
    179       $out.='      <name>'.htmlspecialchars($res['wf_name']).'</name>'."\n"; 
    180       $out.='      <type>'.htmlspecialchars($res['wf_type']).'</type>'."\n"; 
    181       $out.='      <description>'.htmlspecialchars($res['wf_description']).'</description>'."\n"; 
    182       $out.='      <lastModif>'.date("d/m/Y [h:i:s]",$res['wf_last_modif']).'</lastModif>'."\n"; 
    183       $out.='      <isInteractive>'.$res['wf_is_interactive'].'</isInteractive>'."\n"; 
    184       $out.='      <isAutoRouted>'.$res['wf_is_autorouted'].'</isAutoRouted>'."\n"; 
    185       $out.='      <roles>'."\n"; 
    186       //loop on activity roles 
    187       $actid = $res['wf_activity_id']; 
    188       $roles =& $this->activity_manager->get_activity_roles($actid); 
    189       foreach($roles as $role) { 
    190         if ($role['wf_readonly']) 
    191         { 
    192           $out.='        <role readonly="true">'.htmlspecialchars($role['wf_name']).'</role>'."\n"; 
    193         } 
    194         else 
    195         { 
    196           $out.='        <role>'.htmlspecialchars($role['wf_name']).'</role>'."\n"; 
    197         } 
    198       }   
    199       $out.='      </roles>'."\n"; 
    200       $out.='      <agents>'."\n"; 
    201       //loop on activity agents 
    202       $agents =& $this->activity_manager->get_activity_agents($actid); 
    203       foreach($agents as $agent) { 
    204         $out.='        <agent>'."\n"; 
    205         $out.='           <agent_type>'.htmlspecialchars($agent['wf_agent_type']).'</agent_type>'."\n"; 
    206         //loop on agent datas 
    207         $agent_data =& $this->activity_manager->get_activity_agent_data($actid,$agent['wf_agent_type']); 
    208         $out.='           <agent_datas>'."\n"; 
    209         foreach($agent_data as $key => $value) 
    210         { 
    211           if (!($key=='wf_agent_id')) 
    212           { 
    213             $out.='               <agent_data>'."\n"; 
    214             $out.='                   <name>'.htmlspecialchars($key).'</name>'."\n"; 
    215             $out.='                   <value>'.htmlspecialchars($value).'</value>'."\n"; 
    216             $out.='               </agent_data>'."\n"; 
    217           } 
    218         } 
    219         $out.='           </agent_datas>'."\n"; 
    220         $out.='        </agent>'."\n"; 
    221       }   
    222       $out.='      </agents>'."\n"; 
    223  
    224       //the code 
    225       $out.='      <code><![CDATA['; 
    226       $fp=fopen(GALAXIA_PROCESSES.SEP."$wf_procname".SEP."code".SEP."activities".SEP."$name.php","r"); 
    227       while(!feof($fp)) { 
    228         $line=fread($fp,8192); 
    229         $out.=$line; 
    230       } 
    231       fclose($fp); 
    232       $out.='      ]]></code>'; 
    233       if($res['wf_is_interactive']=='y') { 
    234         $out.='      <template><![CDATA['; 
    235         $fp=fopen(GALAXIA_PROCESSES.SEP."$wf_procname".SEP."code".SEP."templates".SEP."$name.tpl","r"); 
    236         while(!feof($fp)) { 
    237           $line=fread($fp,8192); 
    238           $out.=$line; 
    239         } 
    240         fclose($fp); 
    241         $out.='      ]]></template>'; 
    242       } 
    243       $out.='    </activity>'."\n";     
    244     } 
    245     $out.='  </activities>'."\n"; 
    246     $out.='  <transitions>'."\n"; 
    247     //loop on transitions 
    248     $transitions = $this->activity_manager->get_process_transitions($pId); 
    249     foreach($transitions as $tran) { 
    250       $out.='     <transition>'."\n"; 
    251       $out.='       <from>'.htmlspecialchars($tran['wf_act_from_name']).'</from>'."\n"; 
    252       $out.='       <to>'.htmlspecialchars($tran['wf_act_to_name']).'</to>'."\n"; 
    253       $out.='     </transition>'."\n"; 
    254     }      
    255     $out.='  </transitions>'."\n"; 
    256     $out.= '</process>'."\n"; 
    257     //$fp = fopen(GALAXIA_PROCESSES."/$wf_procname/$wf_procname.xml","w"); 
    258     //fwrite($fp,$out); 
    259     //fclose($fp); 
    260     return $out; 
    261   } 
    262    
    263   /** 
    264    * Creates  a process PHP data structure from its XML representation 
    265    *  
    266    * @param string &$xml XML document 
    267    * @return array Process data structure 
    268    * @access public 
    269    */ 
    270   function unserialize_process(&$xml)  
    271   { 
    272     // Create SAX parser assign this object as base for handlers 
    273     // handlers are private methods defined below. 
    274     // keep contexts and parse 
    275     $this->parser = xml_parser_create();  
    276     xml_parser_set_option($this->parser,XML_OPTION_CASE_FOLDING,0); 
    277     //xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE, 1); 
    278     xml_set_object($this->parser, $this); 
    279     xml_set_element_handler($this->parser, '_start_element_handler', '_end_element_handler'); 
    280     xml_set_character_data_handler($this->parser, '_data_handler');  
    281     $aux=Array( 
    282       'name'=>'root', 
    283       'children'=>Array(), 
    284       'parent' => 0, 
    285       'data'=>'',  
    286       'attribs' => Array(), 
    287     ); 
    288     $this->tree[0]=$aux; 
    289     $this->current=0; 
    290          
    291          
    292     if (!xml_parse($this->parser, $xml, true)) { 
    293        $error = sprintf("XML error: %s at line %d", 
    294                     xml_error_string(xml_get_error_code($this->parser)), 
    295                     xml_get_current_line_number($this->parser)); 
    296        trigger_error($error,E_USER_WARNING); 
    297        $this->error[] = $error; 
    298     } 
    299     xml_parser_free($this->parser);    
    300     // Now that we have the tree we can do interesting things 
    301      
    302     $process=Array(); 
    303     $activities=Array(); 
    304     $transitions=Array(); 
    305     for($i=0;$i<count($this->tree[1]['children']);$i++) { 
    306       // Process attributes 
    307       $z=$this->tree[1]['children'][$i]; 
    308       $name = trim($this->tree[$z]['name']); 
    309        
    310       //config values 
    311       if ($name=='configs') { 
    312         for($j=0;$j<count($this->tree[$z]['children']);$j++) { 
    313           $z2 = $this->tree[$z]['children'][$j]; 
    314           // this is a config $name = $this->tree[$z2]['name']; 
    315           $aux = Array(); 
    316           if($this->tree[$z2]['name']=='config') { 
    317             for($k=0;$k<count($this->tree[$z2]['children']);$k++) { 
    318               $z3 = $this->tree[$z2]['children'][$k]; 
    319               $name = trim($this->tree[$z3]['name']); 
    320               $value= trim($this->tree[$z3]['data']); 
    321               $aux[$name]=$value; 
    322             } 
    323             $configs[]=$aux; 
    324           } 
    325         }       
    326       } 
    327       //activities 
    328       elseif($name=='activities') { 
    329         for($j=0;$j<count($this->tree[$z]['children']);$j++) { 
    330           $z2 = $this->tree[$z]['children'][$j]; 
    331           // this is an activity $name = $this->tree[$z2]['name']; 
    332           $aux = Array(); 
    333           if($this->tree[$z2]['name']=='activity') { 
    334             for($k=0;$k<count($this->tree[$z2]['children']);$k++) { 
    335               $z3 = $this->curre[$z2]['children'][$k]; 
    336               $name = trim($this->tree[$z3]['name']); 
    337               $value= trim($this->tree[$z3]['data']); 
    338               if($name=='roles') { 
    339                 $roles=Array(); 
    340                 for($l=0;$l<count($this->tree[$z3]['children']);$l++) { 
    341                   $z4 = $this->tree[$z3]['children'][$l]; 
    342                   $name = trim($this->tree[$z4]['name']); 
    343                   $data = trim($this->tree[$z4]['data']); 
    344                   $attribs = $this->tree[$z4]['attribs']; 
    345                   $readonly = false; 
    346                   if ( (isset($attribs['readonly'])) && ($attribs['readonly'])) 
    347                   { 
    348                     //role in read-only 
    349                     $readonly = true; 
    350                   } 
    351                   $roles[]=array( 
    352                     'name'      => $data, 
    353                     'readonly'  => $readonly, 
    354                   ); 
    355                 } 
    356               }  
    357               elseif ($name=='agents')  
    358               { 
    359                 $agents=Array(); 
    360                 for($l=0;$l<count($this->tree[$z3]['children']);$l++)  
    361                 { 
    362                   $z4 = $this->tree[$z3]['children'][$l]; 
    363                   //$name is agent 
    364                   $name = trim($this->tree[$z4]['name']); 
    365                   if ($name = 'agent') 
    366                   { 
    367                     $agent = array(); 
    368                     for($m=0;$m<count($this->tree[$z4]['children']);$m++) 
    369                     { 
    370                       $z5 = $this->tree[$z4]['children'][$m]; 
    371                       //$name is agent_type or agent_datas 
    372                       $name = trim($this->tree[$z5]['name']); 
    373                       // data will be the agent_type or an array for agent_datas 
    374                       $data = trim($this->tree[$z5]['data']); 
    375                       if ($name=='agent_type')  
    376                       { 
    377                         $agent['wf_agent_type']=$data; 
    378                       }  
    379                       elseif ($name=='agent_datas')  
    380                       { 
    381                         for($n=0;$n<count($this->tree[$z5]['children']);$n++) 
    382                         { 
    383                           $z6 = $this->tree[$z5]['children'][$n]; 
    384                           //$name is agent_data $val is an array 
    385                           $name = trim($this->tree[$z6]['name']); 
    386                           $val = trim($this->tree[$z6]['data']); 
    387                           if ($name=='agent_data') 
    388                           { 
    389                             for($o=0;$o<count($this->tree[$z6]['children']);$o++) 
    390                             { 
    391                               $z7 = $this->tree[$z6]['children'][$o]; 
    392                               //$name is agent_data $val is 'name' or 'value' 
    393                               $name = trim($this->tree[$z7]['name']); 
    394                               $content = trim($this->tree[$z7]['data']); 
    395                               //echo "<br>z7 name $name content: $content"; 
    396                               if ($name=='name') 
    397                               { 
    398                                 $agent_data_name = $content; 
    399                               } 
    400                               elseif ($name=='value') 
    401                               { 
    402                                 $agent_data_value =& $content; 
    403                               } 
    404                             } 
    405                             //echo "<br>associate $agent_data_name to $agent_data_value <hr>"; 
    406                             $agent[$agent_data_name] = $agent_data_value; 
    407                           } 
    408                         } 
    409                       } 
    410                     } 
    411                     $agents[]=$agent; 
    412                   } 
    413                 } 
    414               } else { 
    415                 $aux[$name]=$value; 
    416                 //print("$name:$value<br/>"); 
    417               } 
    418             } 
    419             $aux['agents']=$agents; 
    420             $aux['roles']=$roles; 
    421             $activities[]=$aux; 
    422           } 
    423         } 
    424       } elseif($name=='transitions') { 
    425         for($j=0;$j<count($this->tree[$z]['children']);$j++) { 
    426           $z2 = $this->tree[$z]['children'][$j]; 
    427           // this is an activity $name = $this->tree[$z2]['name']; 
    428           $aux=Array(); 
    429           if($this->tree[$z2]['name']=='transition') { 
    430             for($k=0;$k<count($this->tree[$z2]['children']);$k++) { 
    431               $z3 = $this->tree[$z2]['children'][$k]; 
    432               $name = trim($this->tree[$z3]['name']); 
    433               $value= trim($this->tree[$z3]['data']); 
    434               if($name == 'from' || $name == 'to') { 
    435                 $aux[$name]=$value; 
    436               } 
    437             } 
    438           } 
    439           $transitions[] = $aux; 
    440         } 
    441       } else { 
    442         $value = trim($this->tree[$z]['data']); 
    443         //print("$name is $value<br/>"); 
    444         $process[$name]=$value; 
    445       } 
    446     } 
    447     $process['configs']=$configs; 
    448     $process['activities']=$activities; 
    449     $process['transitions']=$transitions; 
    450     return $process; 
    451   } 
    452  
    453   /** 
    454    * Creates a process from the process data structure, if you want to convert an XML to a process then use first unserialize_process and then this method. 
    455    *  
    456    * @access public 
    457    * @param string &$data 
    458    * @return bool 
    459    */ 
    460   function import_process(&$data) 
    461   { 
    462     //Now the show begins 
    463     if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db); 
    464     if (!(isset($this->role_manager))) $this->role_manager = new RoleManager($this->db); 
    465     if (!isset($this->jobManager)) 
    466       $this->jobManager = new JobManager($this->db); 
    467  
    468     // First create the process. Always inactive and inactive first. 
    469     $vars = Array( 
    470       'wf_name' => trim($data['name']), 
    471       'wf_version' => $data['version'], 
    472       'wf_description' => $data['description'], 
    473       'wf_last_modif' => $data['lastModif'], 
    474       'wf_is_active' => false, 
    475       'wf_is_valid' => false, 
    476       'config' => $data['configs'], 
    477     ); 
    478  
    479     if (empty($vars['wf_name'])) 
    480     { 
    481       $msg = tra('invalid name specified'); 
    482       $this->notify_all(2,$msg); 
    483       $this->error[] = $msg; 
    484       return false; 
    485     } 
    486  
    487     if (ereg('^[0-9]{1,2}\.[0-9]{1,2}$', $vars['wf_version']) === false) 
    488     { 
    489       $msg = tra('invalid version specified'); 
    490       $this->notify_all(2,$msg); 
    491       $this->error[] = $msg; 
    492       return false; 
    493     } 
    494  
    495     if ($this->process_name_exists($vars['wf_name'], $vars['wf_version'])) 
    496     { 
    497       $msg = sprintf(tra('Process %s %s already exists, the import process was aborted'),$vars['wf_name'],$vars['wf_version']); 
    498       $this->notify_all(2,$msg); 
    499       $this->error[] = $msg; 
    500       return false; 
    501     } 
    502     $pid = $this->replace_process(0,$vars,false); 
    503     //Put the shared code  
    504     $proc_info = $this->get_process($pid); 
    505     $wf_procname = $proc_info['wf_normalized_name']; 
    506     $fp = fopen(GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code'.SEP.'shared.php',"w"); 
    507     fwrite($fp, $data['sharedCode']); 
    508     fclose($fp); 
    509     $actids = Array(); 
    510      
    511     // Foreach activity create activities 
    512     foreach($data['activities'] as $activity) { 
    513                  
    514       $vars = Array( 
    515         'wf_name' => $activity['name'], 
    516         'wf_description' => $activity['description'], 
    517         'wf_type' => $activity['type'], 
    518         'wf_menu_path' => $activity['menuPath'], 
    519         'wf_last_modif' => $activity['lastModif'], 
    520         'wf_is_interactive' => $activity['isInteractive'], 
    521         'wf_is_autorouted' => $activity['isAutoRouted'] 
    522       );     
    523       $actname=$this->activity_manager->_normalize_name($activity['name']); 
    524       $actid = $this->activity_manager->replace_activity($pid,0,$vars); 
    525            
    526       $fp = fopen(GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code'.SEP.'activities'.SEP.$actname.'.php',"w"); 
    527       fwrite($fp, $activity['code']); 
    528       fclose($fp); 
    529       if($activity['isInteractive']=='y') { 
    530         $fp = fopen(GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code'.SEP.'templates'.SEP.$actname.'.tpl',"w"); 
    531         fwrite($fp,$activity['template']); 
    532         fclose($fp); 
    533       } 
    534       $actids[$activity['name']] = $this->activity_manager->_get_activity_id_by_name($pid, $activity['name']); 
    535       $actname = $this->activity_manager->_normalize_name($activity['name']); 
    536       $now = date("U"); 
    537       //roles 
    538           if( is_array($activity['roles']) && count($activity['roles']) > 0 ) 
    539           { 
    540               foreach($activity['roles'] as $role)  
    541               { 
    542                 $rolename = $role['name']; 
    543                 $vars = Array( 
    544                   'wf_name' => $rolename, 
    545                   'wf_description' => $rolename, 
    546                   'wf_last_modif' => $now, 
    547                 ); 
    548                 if(!$this->role_manager->role_name_exists($pid,$rolename)) { 
    549                   $rid=$this->role_manager->replace_role($pid,0,$vars); 
    550                 } else { 
    551                   $rid = $this->role_manager->get_role_id($pid,$rolename); 
    552                 } 
    553                 if($actid && $rid) { 
    554                   $this->activity_manager->add_activity_role($actid,$rid,$role['readonly']); 
    555                 } 
    556               } 
    557           } 
    558       //agents 
    559       if( is_array($activity['agents']) && count($activity['agents']) > 0 ) 
    560       { 
    561         foreach($activity['agents'] as $agent) 
    562         { 
    563             if (empty($agent['wf_agent_type'])) 
    564             { 
    565               $this->error[] = lang('empty agent type'); 
    566             } 
    567             else 
    568             { 
    569               //create a new agent of the same type for the new activity 
    570               $agentid = $this->activity_manager->add_activity_agent($actid,$agent['wf_agent_type']); 
    571               //save values of this new agent 
    572               $bindvars = Array(); 
    573               $query = 'update '.GALAXIA_TABLE_PREFIX.'agent_'.$agent['wf_agent_type'].' 
    574                         set '; 
    575               //we wont need the old type anymore 
    576               unset($agent['wf_agent_type']); 
    577               $countfields = 0; 
    578               foreach ($agent as $key => $value) 
    579               { 
    580                 if ($key) 
    581                 { 
    582                   $countfields++; 
    583                   $query .= "$key = ? ,"; 
    584                   $bindvars[] = $value; 
    585                 } 
    586               } 
    587               $query = substr($query,'0',-1); 
    588               $query .= ' where wf_agent_id = ?'; 
    589               $bindvars[] = $agentid; 
    590               if ($countfields) $this->query($query, $bindvars); 
    591             } 
    592         } 
    593       } 
    594     } 
    595     //transitions 
    596     foreach($data['transitions'] as $tran)  
    597     { 
    598       $this->activity_manager->add_transition($pid,$actids[$tran['from']],$actids[$tran['to']]);   
    599     } 
    600  
    601     foreach ($data['jobs'] as $job) 
    602     { 
    603       $this->jobManager->replaceJob($pid, 0, $job); 
    604     } 
    605  
    606     // create a graph for the new process 
    607     $this->activity_manager->build_process_graph($pid); 
    608     //Test the final process 
    609     $this->activity_manager->validate_process_activities($pid); 
    610  
    611     $msg = sprintf(tra('Process %s %s imported'),$proc_info['wf_name'],$proc_info['wf_version']); 
    612     $this->notify_all(2,$msg); 
    613     $this->error[] = $msg; 
    614     return true; 
    615   } 
    616  
    617   /** 
    618    * Creates a new process based on an existing process changing the process version.  
    619    * By default the process is created as an unactive process and the version is by default a minor version of the process 
    620    *  
    621    * @param int $pId Process id 
    622    * @param bool $minor Process previous version 
    623    * @return int Process id 
    624    * @access public 
    625    */ 
    626   function new_process_version($pId, $minor=true) 
    627   { 
    628     if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db); 
    629     $oldpid = $pId; 
    630     //retrieve process info with config rows 
    631     $proc_info = $this->get_process($pId, true); 
    632     if(!($proc_info) || (count($proc_info)==0)) return false; 
    633     $name = $proc_info['wf_name']; 
    634  
    635     // Now update the version 
    636     $version = $this->_new_version($proc_info['wf_version'],$minor); 
    637     while($this->getOne('select count(*) from '.GALAXIA_TABLE_PREFIX.'processes where wf_name=? and wf_version=?',array($name,$version)))  
    638     { 
    639       $version = $this->_new_version($version,$minor); 
    640     } 
    641     $oldname = $proc_info['wf_normalized_name']; 
    642  
    643     // Make new versions unactive 
    644     $proc_info['wf_version'] = $version; 
    645     $proc_info['wf_is_active'] = 'n'; 
    646     // create a new process, but don't create start/end activities 
    647     $pid = $this->replace_process(0, $proc_info, false); 
    648     if (!pid) return false; 
    649  
    650     //Since we are copying a process we should copy 
    651     //the old directory structure to the new directory 
    652     //oldname was saved a few lines before 
    653     $newname = $this->_get_normalized_name($pid); 
    654     $this->_rec_copy(GALAXIA_PROCESSES.SEP.$oldname.SEP.'code',GALAXIA_PROCESSES.SEP.$newname.SEP.'code'); 
    655     // And here copy all the activities & so 
    656     $query = 'select * from '.GALAXIA_TABLE_PREFIX.'activities where wf_p_id=?'; 
    657     $result = $this->query($query, array($oldpid)); 
    658     $newaid = array(); 
    659     while($res = $result->fetchRow()) {     
    660       $oldaid = $res['wf_activity_id']; 
    661       // the false tell the am not to create activities source files 
    662       $newaid[$oldaid] = $this->activity_manager->replace_activity($pid,0,$res, false); 
    663     } 
    664     // create transitions 
    665     $query = 'select * from '.GALAXIA_TABLE_PREFIX.'transitions where wf_p_id=?'; 
    666     $result = $this->query($query, array($oldpid)); 
    667  
    668     /* create the jobs */ 
    669     $query = "INSERT INTO " . GALAXIA_TABLE_PREFIX . "jobs (wf_process_id, name, description, time_start, interval_value, interval_unity, date_type, week_days, month_offset, active) (SELECT {$pid}, name, description, time_start, interval_value, interval_unity, date_type, week_days, month_offset, FALSE FROM " . GALAXIA_TABLE_PREFIX . "jobs WHERE wf_process_id = ?)"; 
    670     $this->query($query, array($oldpid)); 
    671  
    672     while($res = $result->fetchRow()) {  
    673       if (empty($newaid[$res['wf_act_from_id']]) || empty($newaid[$res['wf_act_to_id']])) { 
    674         continue; 
    675       } 
    676       $this->activity_manager->add_transition($pid,$newaid[$res['wf_act_from_id']],$newaid[$res['wf_act_to_id']]); 
    677     } 
    678     // create roles 
    679     if (!(isset($this->role_manager))) $this->role_manager = new RoleManager($this->db); 
    680     $query = 'select * from '.GALAXIA_TABLE_PREFIX.'roles where wf_p_id=?'; 
    681     $result = $this->query($query, array($oldpid)); 
    682     $newrid = array(); 
    683     while($res = $result->fetchRow()) { 
    684       if(!$this->role_manager->role_name_exists($pid,$res['wf_name'])) { 
    685         $rid=$this->role_manager->replace_role($pid,0,$res); 
    686       } else { 
    687         $rid = $this->role_manager->get_role_id($pid,$res['wf_name']); 
    688       } 
    689       $newrid[$res['wf_role_id']] = $rid; 
    690     } 
    691     // map users to roles 
    692     if (count($newrid) > 0) { 
    693       $query = 'select * from '.GALAXIA_TABLE_PREFIX.'user_roles where wf_p_id=?'; 
    694       $result = $this->query($query, array($oldpid)); 
    695       while($res = $result->fetchRow()) { 
    696         if (empty($newrid[$res['wf_role_id']])) { 
    697           continue; 
    698         } 
    699         $this->role_manager->map_user_to_role($pid,$res['wf_user'],$newrid[$res['wf_role_id']], $res['wf_account_type']); 
    700       } 
    701     } 
    702     // add roles to activities 
    703     if (count($newaid) > 0 && count($newrid ) > 0) { 
    704       $query = 'select * from '.GALAXIA_TABLE_PREFIX.'activity_roles where wf_activity_id in (' . join(', ',array_keys($newaid)) . ')'; 
    705       $result = $this->query($query); 
    706       while($res = $result->fetchRow()) { 
    707         if (empty($newaid[$res['wf_activity_id']]) || empty($newrid[$res['wf_role_id']])) { 
    708           continue; 
    709         } 
    710         $this->activity_manager->add_activity_role($newaid[$res['wf_activity_id']],$newrid[$res['wf_role_id']], $res['wf_readonly']); 
    711       } 
    712     } 
    713  
    714     //create agents 
    715     //get the list of agents used by the old process 
    716     $query = 'select gaa.* from '.GALAXIA_TABLE_PREFIX.'activity_agents gaa 
    717                 INNER JOIN '.GALAXIA_TABLE_PREFIX.'activities gac ON gaa.wf_activity_id = gac.wf_activity_id 
    718                 where gac.wf_p_id=?'; 
    719     $result = $this->query($query, array($oldpid)); 
    720     if (!(empty($result))) 
    721     { 
    722       while ($res = $result->fetchRow())  
    723       { 
    724           //create a new agent of the same type for the new activity 
    725           $agentid = $this->activity_manager->add_activity_agent($newaid[$res['wf_activity_id']],$res['wf_agent_type']); 
    726           //save values of this new agents, taking the old ones, we make a simple copy 
    727           $old_activity_agent_data =& $this->activity_manager->get_activity_agent_data($res['wf_activity_id'],$res['wf_agent_type']); 
    728           //we wont need the old id and type 
    729           unset($old_activity_agent_data['wf_agent_id']); 
    730           unset($old_activity_agent_data['wf_agent_type']); 
    731           $bindvars = Array(); 
    732           $query = 'update '.GALAXIA_TABLE_PREFIX.'agent_'.$res['wf_agent_type'].' 
    733                       set '; 
    734           $countfields = 0; 
    735           foreach ($old_activity_agent_data as $key => $value) 
    736           { 
    737             if ($key) 
    738             { 
    739               $countfields++; 
    740               $query .= "$key = ? ,"; 
    741               $bindvars[] = $value; 
    742             } 
    743           } 
    744           $query = substr($query,'0',-1); 
    745           $query .= ' where wf_agent_id = ?'; 
    746           $bindvars[] = $agentid; 
    747           if ($countfields) $this->query($query, $bindvars); 
    748       } 
    749     } 
    750  
    751     // create a graph for the new process 
    752     $this->activity_manager->build_process_graph($pid); 
    753      
    754     return $pid; 
    755   } 
    756    
    757   /** 
    758    * This function can be used to check if a process name exists, note that this is NOT used by replace_process since that function can be used to 
    759    * create new versions of an existing process. The application must use this method to ensure that processes have unique names. 
    760    *  
    761    * @param string $name Process name 
    762    * @param string $version Process version 
    763    * @return bool  
    764    * @access public 
    765   */ 
    766   function process_name_exists($name,$version) 
    767   { 
    768     $name = addslashes($this->_normalize_name($name,$version)); 
    769     return $this->getOne('select count(*) from '.GALAXIA_TABLE_PREFIX.'processes where wf_normalized_name=?',array($name)); 
    770   } 
    771    
    772    
    773   /** 
    774    * Gets a process by pId. Fields are returned as an associative array.  
    775    * If withConfig is set (false by default), the configuration options are returned as well the ['config'] key is then an array containing the config data with type distinction 
    776    *  
    777    * @param int $pId Process id 
    778    * @param bool $withConfig Configuration options 
    779    * @return bool 
    780    * @access public 
    781    */ 
    782   function get_process($pId, $withConfig=false) 
    783   { 
    784     $query = 'select * from '.GALAXIA_TABLE_PREFIX.'processes where wf_p_id=?'; 
    785     $result = $this->query($query, array($pId)); 
    786     if((empty($result)) || (!$result->numRows())) return false; 
    787     $res = $result->fetchRow(); 
    788     if ($withConfig) 
    789     { 
    790       // by setting true we force this function to keep type distinction on config values 
    791       $res['config'] = $this->getConfigValues($res['wf_p_id'], true); 
    792     } 
    793     return $res; 
    794   } 
    795    
    796   /** 
    797    * Lists all processes 
    798    *  
    799    * @param int $offset Resultset starting row 
    800    * @param int $maxRecords Max number of resulting rows 
    801    * @param string $sort_mode Sorting mode 
    802    * @param string $find Search query string 
    803    * @param string $where Condition query string 
    804    * @return bool  
    805    * @access public 
    806    */ 
    807   function list_processes($offset,$maxRecords,$sort_mode,$find='',$where='') 
    808   { 
    809     $sort_mode = $this->convert_sortmode($sort_mode); 
    810     if($find) { 
    811       $findesc = '%'.$find.'%'; 
    812       $mid=' where ((wf_name like ?) or (wf_description like ?))'; 
    813       $bindvars = array($findesc,$findesc); 
    814     } else { 
    815       $mid=''; 
    816       $bindvars = array(); 
    817     } 
    818     if($where) { 
    819       if($mid) { 
    820         $mid.= " and ($where) "; 
    821       } else { 
    822         $mid.= " where ($where) "; 
    823       } 
    824     } 
    825     $query = 'select * from '.GALAXIA_TABLE_PREFIX."processes $mid"; 
    826     $query_cant = 'select count(*) from '.GALAXIA_TABLE_PREFIX."processes $mid"; 
    827     $result = $this->query($query,$bindvars,$maxRecords,$offset, true, $sort_mode); 
    828     $cant = $this->getOne($query_cant,$bindvars); 
    829     $ret = Array(); 
    830     if (isset($result)) 
    831     { 
    832       while($res = $result->fetchRow())  
    833       { 
    834         $ret[] = $res; 
    835       } 
    836     } 
    837     $retval = Array(); 
    838     $retval['data'] = $ret; 
    839     $retval['cant'] = $cant; 
    840     return $retval; 
    841   } 
    842    
     12 
     13        /** 
     14         * @var resource $parser xml parser 
     15         * @access public 
     16         */ 
     17        var $parser; 
     18 
     19        /** 
     20         * @var array $tree data struture 
     21         * @access public 
     22         */ 
     23        var $tree; 
     24 
     25        /** 
     26         * @var $current current element 
     27         * @access public 
     28         */ 
     29        var $current; 
     30 
     31        /** 
     32         * @var $buffer buffer for data 
     33         * @access public 
     34         */ 
     35        var $buffer; 
     36 
     37        /** 
     38         * @var object $Process Process 
     39         * @access public 
     40         */ 
     41        var $Process; 
     42 
     43        /** 
     44         * @var object $activity_manager Activity Manager 
     45         * @access public 
     46         */ 
     47        var $activity_manager; 
     48 
     49        /** 
     50         * @var object $jobManager Job Manager object 
     51         * @access public 
     52         */ 
     53        var $jobManager; 
     54 
     55        /** 
     56         * @var object $role_manager Role Manager 
     57         * @access public 
     58         */ 
     59        var $role_manager; 
     60 
     61        /** 
     62         * Constructor 
     63         * 
     64         * @param object &$db ADOdb 
     65         * @return object ProcessManager 
     66         * @access public 
     67         */ 
     68        function ProcessManager() 
     69        { 
     70                parent::BaseManager(); 
     71                $this->child_name = 'ProcessManager'; 
     72                // $this->activity_manager is not set here to avoid objects loading object A loading object B loading object A, etc 
     73                //$this->role_manager will only be loaded when needed as well 
     74        } 
     75 
     76        /** 
     77         * Collect errors from all linked objects which could have been used by this object. 
     78         * Each child class should instantiate this function with her linked objetcs, calling get_error(true) 
     79         * 
     80         * @param bool $debug False by default, if true debug messages can be added to 'normal' messages 
     81         * @param string $prefix Appended to the debug message 
     82         * @return void 
     83         * @access public 
     84         */ 
     85        function collect_errors($debug=false, $prefix = '') 
     86        { 
     87                parent::collect_errors($debug, $prefix); 
     88                if (isset($this->activity_manager)) $this->error[] = $this->activity_manager->get_error(false, $debug, $prefix); 
     89                if (isset($this->role_manager)) $this->error[] = $this->role_manager->get_error(false, $debug, $prefix); 
     90        } 
     91 
     92        /** 
     93         * Activates a process 
     94         * 
     95         * @param int $pId Process id 
     96         * @return void 
     97         * @access public 
     98         */ 
     99        function activate_process($pId) 
     100        { 
     101                $query = 'update '.GALAXIA_TABLE_PREFIX.'processes set wf_is_active=? where wf_p_id=?'; 
     102                $this->query($query, array('y',$pId)); 
     103                $msg = sprintf(tra('Process %d has been activated'),$pId); 
     104                $this->error[] = $msg; 
     105        } 
     106 
     107        /** 
     108         * Deactivates a process 
     109         * 
     110         * @param int $pId Process id 
     111         * @return void 
     112         * @access public 
     113         */ 
     114        function deactivate_process($pId) 
     115        { 
     116                $query = 'update '.GALAXIA_TABLE_PREFIX.'processes set wf_is_active=? where wf_p_id=?'; 
     117                $this->query($query, array('n',$pId)); 
     118                $msg = sprintf(tra('Process %d has been deactivated'),$pId); 
     119                $this->error[] = $msg; 
     120        } 
     121 
     122        /** 
     123         * Creates an XML representation of a process 
     124         * 
     125         * @param int $pId Process id 
     126         * @return string 
     127         * @access public 
     128         */ 
     129        function serialize_process($pId) 
     130        { 
     131                if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager'); 
     132                // <process> 
     133                $out = '<process>'."\n"; 
     134                //we retrieve config values with the others process data 
     135                $proc_info =& $this->get_process($pId, true); 
     136                $wf_procname = $proc_info['wf_normalized_name']; 
     137                $out.= '  <name>'.htmlspecialchars($proc_info['wf_name']).'</name>'."\n"; 
     138                $out.= '  <isValid>'.htmlspecialchars($proc_info['wf_is_valid']).'</isValid>'."\n"; 
     139                $out.= '  <version>'.htmlspecialchars($proc_info['wf_version']).'</version>'."\n"; 
     140                $out.= '  <isActive>'.htmlspecialchars($proc_info['wf_is_active']).'</isActive>'."\n"; 
     141                $out.='   <description>'.htmlspecialchars($proc_info['wf_description']).'</description>'."\n"; 
     142                $out.= '  <lastModif>'.date("d/m/Y [h:i:s]",$proc_info['wf_last_modif']).'</lastModif>'."\n"; 
     143 
     144                //Shared code 
     145                $out.= '  <sharedCode><![CDATA['; 
     146                $fp=fopen(GALAXIA_PROCESSES.SEP."$wf_procname".SEP."code".SEP."shared.php","r"); 
     147                while(!feof($fp)) { 
     148                        $line=fread($fp,8192); 
     149                        $out.=$line; 
     150                } 
     151                fclose($fp); 
     152                $out.= '  ]]></sharedCode>'."\n"; 
     153 
     154                //Loop on config values 
     155                $out.='  <configs>'."\n"; 
     156                foreach($proc_info['config'] as $res) { 
     157                        $name = $res['wf_config_name']; 
     158                        $value_int = $res['wf_config_value_int']; 
     159                        $value = $res['wf_config_value']; 
     160                        $out.='    <config>'."\n"; 
     161                        $out.='      <wf_config_name>'.htmlspecialchars($name).'</wf_config_name>'."\n"; 
     162                        $out.='      <wf_config_value>'.htmlspecialchars($value).'</wf_config_value>'."\n"; 
     163                        $out.='      <wf_config_value_int>'.htmlspecialchars($value_int).'</wf_config_value_int>'."\n"; 
     164                        $out.='    </config>'."\n"; 
     165                } 
     166                $out.='  </configs>'."\n"; 
     167 
     168                // Now loop over activities 
     169                $query = "select * from ".GALAXIA_TABLE_PREFIX."activities where wf_p_id=$pId"; 
     170                $result = $this->query($query); 
     171                $out.='  <activities>'."\n"; 
     172                while($res = $result->fetchRow()) { 
     173                        $name = $res['wf_normalized_name']; 
     174                        $out.='    <activity>'."\n"; 
     175                        $out.='      <name>'.htmlspecialchars($res['wf_name']).'</name>'."\n"; 
     176                        $out.='      <type>'.htmlspecialchars($res['wf_type']).'</type>'."\n"; 
     177                        $out.='      <description>'.htmlspecialchars($res['wf_description']).'</description>'."\n"; 
     178                        $out.='      <lastModif>'.date("d/m/Y [h:i:s]",$res['wf_last_modif']).'</lastModif>'."\n"; 
     179                        $out.='      <isInteractive>'.$res['wf_is_interactive'].'</isInteractive>'."\n"; 
     180                        $out.='      <isAutoRouted>'.$res['wf_is_autorouted'].'</isAutoRouted>'."\n"; 
     181                        $out.='      <roles>'."\n"; 
     182                        //loop on activity roles 
     183                        $actid = $res['wf_activity_id']; 
     184                        $roles =& $this->activity_manager->get_activity_roles($actid); 
     185                        foreach($roles as $role) { 
     186                                if ($role['wf_readonly']) 
     187                                { 
     188                                        $out.='        <role readonly="true">'.htmlspecialchars($role['wf_name']).'</role>'."\n"; 
     189                                } 
     190                                else 
     191                                { 
     192                                        $out.='        <role>'.htmlspecialchars($role['wf_name']).'</role>'."\n"; 
     193                                } 
     194                        } 
     195                        $out.='      </roles>'."\n"; 
     196                        $out.='      <agents>'."\n"; 
     197                        //loop on activity agents 
     198                        $agents =& $this->activity_manager->get_activity_agents($actid); 
     199                        foreach($agents as $agent) { 
     200                                $out.='        <agent>'."\n"; 
     201                                $out.='           <agent_type>'.htmlspecialchars($agent['wf_agent_type']).'</agent_type>'."\n"; 
     202                                //loop on agent datas 
     203                                $agent_data =& $this->activity_manager->get_activity_agent_data($actid,$agent['wf_agent_type']); 
     204                                $out.='           <agent_datas>'."\n"; 
     205                                foreach($agent_data as $key => $value) 
     206                                { 
     207                                        if (!($key=='wf_agent_id')) 
     208                                        { 
     209                                                $out.='               <agent_data>'."\n"; 
     210                                                $out.='                   <name>'.htmlspecialchars($key).'</name>'."\n"; 
     211                                                $out.='                   <value>'.htmlspecialchars($value).'</value>'."\n"; 
     212                                                $out.='               </agent_data>'."\n"; 
     213                                        } 
     214                                } 
     215                                $out.='           </agent_datas>'."\n"; 
     216                                $out.='        </agent>'."\n"; 
     217                        } 
     218                        $out.='      </agents>'."\n"; 
     219 
     220                        //the code 
     221                        $out.='      <code><![CDATA['; 
     222                        $fp=fopen(GALAXIA_PROCESSES.SEP."$wf_procname".SEP."code".SEP."activities".SEP."$name.php","r"); 
     223                        while(!feof($fp)) { 
     224                                $line=fread($fp,8192); 
     225                                $out.=$line; 
     226                        } 
     227                        fclose($fp); 
     228                        $out.='      ]]></code>'; 
     229                        if($res['wf_is_interactive']=='y') { 
     230                                $out.='      <template><![CDATA['; 
     231                                $fp=fopen(GALAXIA_PROCESSES.SEP."$wf_procname".SEP."code".SEP."templates".SEP."$name.tpl","r"); 
     232                                while(!feof($fp)) { 
     233                                        $line=fread($fp,8192); 
     234                                        $out.=$line; 
     235                                } 
     236                                fclose($fp); 
     237                                $out.='      ]]></template>'; 
     238                        } 
     239                        $out.='    </activity>'."\n"; 
     240                } 
     241                $out.='  </activities>'."\n"; 
     242                $out.='  <transitions>'."\n"; 
     243                //loop on transitions 
     244                $transitions = $this->activity_manager->get_process_transitions($pId); 
     245                foreach($transitions as $tran) { 
     246                        $out.='     <transition>'."\n"; 
     247                        $out.='       <from>'.htmlspecialchars($tran['wf_act_from_name']).'</from>'."\n"; 
     248                        $out.='       <to>'.htmlspecialchars($tran['wf_act_to_name']).'</to>'."\n"; 
     249                        $out.='     </transition>'."\n"; 
     250                } 
     251                $out.='  </transitions>'."\n"; 
     252                $out.= '</process>'."\n"; 
     253                //$fp = fopen(GALAXIA_PROCESSES."/$wf_procname/$wf_procname.xml","w"); 
     254                //fwrite($fp,$out); 
     255                //fclose($fp); 
     256                return $out; 
     257        } 
     258 
     259        /** 
     260         * Creates  a process PHP data structure from its XML representation 
     261         * 
     262         * @param string &$xml XML document 
     263         * @return array Process data structure 
     264         * @access public 
     265         */ 
     266        function unserialize_process(&$xml) 
     267        { 
     268                // Create SAX parser assign this object as base for handlers 
     269                // handlers are private methods defined below. 
     270                // keep contexts and parse 
     271                $this->parser = xml_parser_create(); 
     272                xml_parser_set_option($this->parser,XML_OPTION_CASE_FOLDING,0); 
     273                //xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE, 1); 
     274                xml_set_object($this->parser, $this); 
     275                xml_set_element_handler($this->parser, '_start_element_handler', '_end_element_handler'); 
     276                xml_set_character_data_handler($this->parser, '_data_handler'); 
     277                $aux=Array( 
     278                        'name'=>'root', 
     279                        'children'=>Array(), 
     280                        'parent' => 0, 
     281                        'data'=>'', 
     282                        'attribs'       => Array(), 
     283                ); 
     284                $this->tree[0]=$aux; 
     285                $this->current=0; 
     286 
     287 
     288                if (!xml_parse($this->parser, $xml, true)) { 
     289                        $error = sprintf("XML error: %s at line %d", 
     290                                xml_error_string(xml_get_error_code($this->parser)), 
     291                                xml_get_current_line_number($this->parser)); 
     292                        trigger_error($error,E_USER_WARNING); 
     293                        $this->error[] = $error; 
     294                } 
     295                xml_parser_free($this->parser); 
     296                // Now that we have the tree we can do interesting things 
     297 
     298                $process=Array(); 
     299                $activities=Array(); 
     300                $transitions=Array(); 
     301                for($i=0;$i<count($this->tree[1]['children']);$i++) { 
     302                        // Process attributes 
     303                        $z=$this->tree[1]['children'][$i]; 
     304                        $name = trim($this->tree[$z]['name']); 
     305 
     306                        //config values 
     307                        if ($name=='configs') { 
     308                                for($j=0;$j<count($this->tree[$z]['children']);$j++) { 
     309                                        $z2 = $this->tree[$z]['children'][$j]; 
     310                                        // this is a config $name = $this->tree[$z2]['name']; 
     311                                        $aux = Array(); 
     312                                        if($this->tree[$z2]['name']=='config') { 
     313                                                for($k=0;$k<count($this->tree[$z2]['children']);$k++) { 
     314                                                        $z3 = $this->tree[$z2]['children'][$k]; 
     315                                                        $name = trim($this->tree[$z3]['name']); 
     316                                                        $value= trim($this->tree[$z3]['data']); 
     317                                                        $aux[$name]=$value; 
     318                                                } 
     319                                                $configs[]=$aux; 
     320                                        } 
     321                                } 
     322                        } 
     323                        //activities 
     324                        elseif($name=='activities') { 
     325                                for($j=0;$j<count($this->tree[$z]['children']);$j++) { 
     326                                        $z2 = $this->tree[$z]['children'][$j]; 
     327                                        // this is an activity $name = $this->tree[$z2]['name']; 
     328                                        $aux = Array(); 
     329                                        if($this->tree[$z2]['name']=='activity') { 
     330                                                for($k=0;$k<count($this->tree[$z2]['children']);$k++) { 
     331                                                        $z3 = $this->curre[$z2]['children'][$k]; 
     332                                                        $name = trim($this->tree[$z3]['name']); 
     333                                                        $value= trim($this->tree[$z3]['data']); 
     334                                                        if($name=='roles') { 
     335                                                                $roles=Array(); 
     336                                                                for($l=0;$l<count($this->tree[$z3]['children']);$l++) { 
     337                                                                        $z4 = $this->tree[$z3]['children'][$l]; 
     338                                                                        $name = trim($this->tree[$z4]['name']); 
     339                                                                        $data = trim($this->tree[$z4]['data']); 
     340                                                                        $attribs = $this->tree[$z4]['attribs']; 
     341                                                                        $readonly = false; 
     342                                                                        if ( (isset($attribs['readonly'])) && ($attribs['readonly'])) 
     343                                                                        { 
     344                                                                                //role in read-only 
     345                                                                                $readonly = true; 
     346                                                                        } 
     347                                                                        $roles[]=array( 
     348                                                                                'name'  => $data, 
     349                                                                                'readonly'      => $readonly, 
     350                                                                        ); 
     351                                                                } 
     352                                                        } 
     353                                                        elseif ($name=='agents') 
     354                                                        { 
     355                                                                $agents=Array(); 
     356                                                                for($l=0;$l<count($this->tree[$z3]['children']);$l++) 
     357                                                                { 
     358                                                                        $z4 = $this->tree[$z3]['children'][$l]; 
     359                                                                        //$name is agent 
     360                                                                        $name = trim($this->tree[$z4]['name']); 
     361                                                                        if ($name = 'agent') 
     362                                                                        { 
     363                                                                                $agent = array(); 
     364                                                                                for($m=0;$m<count($this->tree[$z4]['children']);$m++) 
     365                                                                                { 
     366                                                                                        $z5 = $this->tree[$z4]['children'][$m]; 
     367                                                                                        //$name is agent_type or agent_datas 
     368                                                                                        $name = trim($this->tree[$z5]['name']); 
     369                                                                                        // data will be the agent_type or an array for agent_datas 
     370                                                                                        $data = trim($this->tree[$z5]['data']); 
     371                                                                                        if ($name=='agent_type') 
     372                                                                                        { 
     373                                                                                                $agent['wf_agent_type']=$data; 
     374                                                                                        } 
     375                                                                                        elseif ($name=='agent_datas') 
     376                                                                                        { 
     377                                                                                                for($n=0;$n<count($this->tree[$z5]['children']);$n++) 
     378                                                                                                { 
     379                                                                                                        $z6 = $this->tree[$z5]['children'][$n]; 
     380                                                                                                        //$name is agent_data $val is an array 
     381                                                                                                        $name = trim($this->tree[$z6]['name']); 
     382                                                                                                        $val = trim($this->tree[$z6]['data']); 
     383                                                                                                        if ($name=='agent_data') 
     384                                                                                                        { 
     385                                                                                                                for($o=0;$o<count($this->tree[$z6]['children']);$o++) 
     386                                                                                                                { 
     387                                                                                                                        $z7 = $this->tree[$z6]['children'][$o]; 
     388                                                                                                                        //$name is agent_data $val is 'name' or 'value' 
     389                                                                                                                        $name = trim($this->tree[$z7]['name']); 
     390                                                                                                                        $content = trim($this->tree[$z7]['data']); 
     391                                                                                                                        //echo "<br>z7 name $name content: $content"; 
     392                                                                                                                        if ($name=='name') 
     393                                                                                                                        { 
     394                                                                                                                                $agent_data_name = $content; 
     395                                                                                                                        } 
     396                                                                                                                        elseif ($name=='value') 
     397                                                                                                                        { 
     398                                                                                                                                $agent_data_value =& $content; 
     399                                                                                                                        } 
     400                                                                                                                } 
     401                                                                                                                //echo "<br>associate $agent_data_name to $agent_data_value <hr>"; 
     402                                                                                                                $agent[$agent_data_name] = $agent_data_value; 
     403                                                                                                        } 
     404                                                                                                } 
     405                                                                                        } 
     406                                                                                } 
     407                                                                                $agents[]=$agent; 
     408                                                                        } 
     409                                                                } 
     410                                                        } else { 
     411                                                                $aux[$name]=$value; 
     412                                                                //print("$name:$value<br/>"); 
     413                                                        } 
     414                                                } 
     415                                                $aux['agents']=$agents; 
     416                                                $aux['roles']=$roles; 
     417                                                $activities[]=$aux; 
     418                                        } 
     419                                } 
     420                        } elseif($name=='transitions') { 
     421                                for($j=0;$j<count($this->tree[$z]['children']);$j++) { 
     422                                        $z2 = $this->tree[$z]['children'][$j]; 
     423                                        // this is an activity $name = $this->tree[$z2]['name']; 
     424                                        $aux=Array(); 
     425                                        if($this->tree[$z2]['name']=='transition') { 
     426                                                for($k=0;$k<count($this->tree[$z2]['children']);$k++) { 
     427                                                        $z3 = $this->tree[$z2]['children'][$k]; 
     428                                                        $name = trim($this->tree[$z3]['name']); 
     429                                                        $value= trim($this->tree[$z3]['data']); 
     430                                                        if($name == 'from' || $name == 'to') { 
     431                                                                $aux[$name]=$value; 
     432                                                        } 
     433                                                } 
     434                                        } 
     435                                        $transitions[] = $aux; 
     436                                } 
     437                        } else { 
     438                                $value = trim($this->tree[$z]['data']); 
     439                                //print("$name is $value<br/>"); 
     440                                $process[$name]=$value; 
     441                        } 
     442                } 
     443                $process['configs']=$configs; 
     444                $process['activities']=$activities; 
     445                $process['transitions']=$transitions; 
     446                return $process; 
     447        } 
     448 
     449        /** 
     450         * Creates a process from the process data structure, if you want to convert an XML to a process then use first unserialize_process and then this method. 
     451         * 
     452         * @access public 
     453         * @param string &$data 
     454         * @return bool 
     455         */ 
     456        function import_process(&$data) 
     457        { 
     458                //Now the show begins 
     459                if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager'); 
     460                if (!(isset($this->role_manager))) $this->role_manager = &Factory::newInstance('RoleManager'); 
     461                if (!isset($this->jobManager)) 
     462                        $this->jobManager = &Factory::newInstance('JobManager'); 
     463 
     464                // First create the process. Always inactive and inactive first. 
     465                $vars = Array( 
     466                        'wf_name' => trim($data['name']), 
     467                        'wf_version' => $data['version'], 
     468                        'wf_description' => $data['description'], 
     469                        'wf_last_modif' => $data['lastModif'], 
     470                        'wf_is_active' => false, 
     471                        'wf_is_valid' => false, 
     472                        'config' => $data['configs'], 
     473                ); 
     474 
     475                if (empty($vars['wf_name'])) 
     476                { 
     477                        $msg = tra('invalid name specified'); 
     478                        $this->error[] = $msg; 
     479                        return false; 
     480                } 
     481 
     482                if (ereg('^[0-9]{1,2}\.[0-9]{1,2}$', $vars['wf_version']) === false) 
     483                { 
     484                        $msg = tra('invalid version specified'); 
     485                        $this->error[] = $msg; 
     486                        return false; 
     487                } 
     488 
     489                if ($this->process_name_exists($vars['wf_name'], $vars['wf_version'])) 
     490                { 
     491                        $msg = sprintf(tra('Process %s %s already exists, the import process was aborted'),$vars['wf_name'],$vars['wf_version']); 
     492                        $this->error[] = $msg; 
     493                        return false; 
     494                } 
     495                $pid = $this->replace_process(0,$vars,false); 
     496                //Put the shared code 
     497                $proc_info = $this->get_process($pid); 
     498                $wf_procname = $proc_info['wf_normalized_name']; 
     499                $fp = fopen(GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code'.SEP.'shared.php',"w"); 
     500                fwrite($fp, $data['sharedCode']); 
     501                fclose($fp); 
     502                $actids = Array(); 
     503 
     504                // Foreach activity create activities 
     505                foreach($data['activities'] as $activity) { 
     506 
     507                        $vars = Array( 
     508                                'wf_name' => $activity['name'], 
     509                                'wf_description' => $activity['description'], 
     510                                'wf_type' => $activity['type'], 
     511                                'wf_menu_path' => $activity['menuPath'], 
     512                                'wf_last_modif' => $activity['lastModif'], 
     513                                'wf_is_interactive' => $activity['isInteractive'], 
     514                                'wf_is_autorouted' => $activity['isAutoRouted'] 
     515                        ); 
     516                        $actname=$this->activity_manager->_normalize_name($activity['name']); 
     517                        $actid = $this->activity_manager->replace_activity($pid,0,$vars); 
     518 
     519                        $fp = fopen(GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code'.SEP.'activities'.SEP.$actname.'.php',"w"); 
     520                        fwrite($fp, $activity['code']); 
     521                        fclose($fp); 
     522                        if($activity['isInteractive']=='y') { 
     523                                $fp = fopen(GALAXIA_PROCESSES.SEP.$wf_procname.SEP.'code'.SEP.'templates'.SEP.$actname.'.tpl',"w"); 
     524                                fwrite($fp,$activity['template']); 
     525                                fclose($fp); 
     526                        } 
     527                        $actids[$activity['name']] = $this->activity_manager->_get_activity_id_by_name($pid, $activity['name']); 
     528                        $actname = $this->activity_manager->_normalize_name($activity['name']); 
     529                        $now = date("U"); 
     530                        //roles 
     531                        if( is_array($activity['roles']) && count($activity['roles']) > 0 ) 
     532                        { 
     533                                foreach($activity['roles'] as $role) 
     534                                { 
     535                                        $rolename = $role['name']; 
     536                                        $vars = Array( 
     537                                                'wf_name' => $rolename, 
     538                                                'wf_description' => $rolename, 
     539                                                'wf_last_modif' => $now, 
     540                                        ); 
     541                                        if(!$this->role_manager->role_name_exists($pid,$rolename)) { 
     542                                                $rid=$this->role_manager->replace_role($pid,0,$vars); 
     543                                        } else { 
     544                                                $rid = $this->role_manager->get_role_id($pid,$rolename); 
     545                                        } 
     546                                        if($actid && $rid) { 
     547                                                $this->activity_manager->add_activity_role($actid,$rid,$role['readonly']); 
     548                                        } 
     549                                } 
     550                        } 
     551                        //agents 
     552                        if( is_array($activity['agents']) && count($activity['agents']) > 0 ) 
     553                        { 
     554                                foreach($activity['agents'] as $agent) 
     555                                { 
     556                                        if (empty($agent['wf_agent_type'])) 
     557                                        { 
     558                                                $this->error[] = lang('empty agent type'); 
     559                                        } 
     560                                        else 
     561                                        { 
     562                                                //create a new agent of the same type for the new activity 
     563                                                $agentid = $this->activity_manager->add_activity_agent($actid,$agent['wf_agent_type']); 
     564                                                //save values of this new agent 
     565                                                $bindvars = Array(); 
     566                                                $query = 'update '.GALAXIA_TABLE_PREFIX.'agent_'.$agent['wf_agent_type'].' 
     567                                                        set '; 
     568                                                //we wont need the old type anymore 
     569                                                unset($agent['wf_agent_type']); 
     570                                                $countfields = 0; 
     571                                                foreach ($agent as $key => $value) 
     572                                                { 
     573                                                        if ($key) 
     574                                                        { 
     575                                                                $countfields++; 
     576                                                                $query .= "$key = ? ,"; 
     577                                                                $bindvars[] = $value; 
     578                                                        } 
     579                                                } 
     580                                                $query = substr($query,'0',-1); 
     581                                                $query .= ' where wf_agent_id = ?'; 
     582                                                $bindvars[] = $agentid; 
     583                                                if ($countfields) $this->query($query, $bindvars); 
     584                                        } 
     585                                } 
     586                        } 
     587                } 
     588                //transitions 
     589                foreach($data['transitions'] as $tran) 
     590                { 
     591                        $this->activity_manager->add_transition($pid,$actids[$tran['from']],$actids[$tran['to']]); 
     592                } 
     593 
     594                foreach ($data['jobs'] as $job) 
     595                { 
     596                        $this->jobManager->replaceJob($pid, 0, $job); 
     597                } 
     598 
     599                // create a graph for the new process 
     600                $this->activity_manager->build_process_graph($pid); 
     601                //Test the final process 
     602                $this->activity_manager->validate_process_activities($pid); 
     603 
     604                $msg = sprintf(tra('Process %s %s imported'),$proc_info['wf_name'],$proc_info['wf_version']); 
     605                $this->error[] = $msg; 
     606                return true; 
     607        } 
     608 
     609        /** 
     610         * Creates a new process based on an existing process changing the process version. 
     611         * By default the process is created as an unactive process and the version is by default a minor version of the process 
     612         * 
     613         * @param int $pId Process id 
     614         * @param bool $minor Process previous version 
     615         * @return int Process id 
     616         * @access public 
     617         */ 
     618        function new_process_version($pId, $minor=true) 
     619        { 
     620                if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager'); 
     621                $oldpid = $pId; 
     622                //retrieve process info with config rows 
     623                $proc_info = $this->get_process($pId, true); 
     624                if(!($proc_info) || (count($proc_info)==0)) return false; 
     625                $name = $proc_info['wf_name']; 
     626 
     627                // Now update the version 
     628                $version = $this->_new_version($proc_info['wf_version'],$minor); 
     629                while($this->getOne('select count(*) from '.GALAXIA_TABLE_PREFIX.'processes where wf_name=? and wf_version=?',array($name,$version))) 
     630                { 
     631                        $version = $this->_new_version($version,$minor); 
     632                } 
     633                $oldname = $proc_info['wf_normalized_name']; 
     634 
     635                // Make new versions unactive 
     636                $proc_info['wf_version'] = $version; 
     637                $proc_info['wf_is_active'] = 'n'; 
     638                // create a new process, but don't create start/end activities 
     639                $pid = $this->replace_process(0, $proc_info, false); 
     640                if (!pid) return false; 
     641 
     642                //Since we are copying a process we should copy 
     643                //the old directory structure to the new directory 
     644                //oldname was saved a few lines before 
     645                $newname = $this->_get_normalized_name($pid); 
     646                $this->_rec_copy(GALAXIA_PROCESSES.SEP.$oldname.SEP.'code',GALAXIA_PROCESSES.SEP.$newname.SEP.'code'); 
     647                // And here copy all the activities & so 
     648                $query = 'select * from '.GALAXIA_TABLE_PREFIX.'activities where wf_p_id=?'; 
     649                $result = $this->query($query, array($oldpid)); 
     650                $newaid = array(); 
     651                while($res = $result->fetchRow()) { 
     652                        $oldaid = $res['wf_activity_id']; 
     653                        // the false tell the am not to create activities source files 
     654                        $newaid[$oldaid] = $this->activity_manager->replace_activity($pid,0,$res, false); 
     655                } 
     656                // create transitions 
     657                $query = 'select * from '.GALAXIA_TABLE_PREFIX.'transitions where wf_p_id=?'; 
     658                $result = $this->query($query, array($oldpid)); 
     659 
     660                /* create the jobs */ 
     661                $query = "INSERT INTO " . GALAXIA_TABLE_PREFIX . "jobs (wf_process_id, name, description, time_start, interval_value, interval_unity, date_type, week_days, month_offset, active) (SELECT {$pid}, name, description, time_start, interval_value, interval_unity, date_type, week_days, month_offset, FALSE FROM " . GALAXIA_TABLE_PREFIX . "jobs WHERE wf_process_id = ?)"; 
     662                $this->query($query, array($oldpid)); 
     663 
     664                while($res = $result->fetchRow()) { 
     665                        if (empty($newaid[$res['wf_act_from_id']]) || empty($newaid[$res['wf_act_to_id']])) { 
     666                                continue; 
     667                        } 
     668                        $this->activity_manager->add_transition($pid,$newaid[$res['wf_act_from_id']],$newaid[$res['wf_act_to_id']]); 
     669                } 
     670                // create roles 
     671                if (!(isset($this->role_manager))) $this->role_manager = &Factory::newInstance('RoleManager'); 
     672                $query = 'select * from '.GALAXIA_TABLE_PREFIX.'roles where wf_p_id=?'; 
     673                $result = $this->query($query, array($oldpid)); 
     674                $newrid = array(); 
     675                while($res = $result->fetchRow()) { 
     676                        if(!$this->role_manager->role_name_exists($pid,$res['wf_name'])) { 
     677                                $rid=$this->role_manager->replace_role($pid,0,$res); 
     678                        } else { 
     679                                $rid = $this->role_manager->get_role_id($pid,$res['wf_name']); 
     680                        } 
     681                        $newrid[$res['wf_role_id']] = $rid; 
     682                } 
     683                // map users to roles 
     684                if (count($newrid) > 0) { 
     685                        $query = 'select * from '.GALAXIA_TABLE_PREFIX.'user_roles where wf_p_id=?'; 
     686                        $result = $this->query($query, array($oldpid)); 
     687                        while($res = $result->fetchRow()) { 
     688                                if (empty($newrid[$res['wf_role_id']])) { 
     689                                        continue; 
     690                                } 
     691                                $this->role_manager->map_user_to_role($pid,$res['wf_user'],$newrid[$res['wf_role_id']], $res['wf_account_type']); 
     692                        } 
     693                } 
     694                // add roles to activities 
     695                if (count($newaid) > 0 && count($newrid ) > 0) { 
     696                        $query = 'select * from '.GALAXIA_TABLE_PREFIX.'activity_roles where wf_activity_id in (' . join(', ',array_keys($newaid)) . ')'; 
     697                        $result = $this->query($query); 
     698                        while($res = $result->fetchRow()) { 
     699                                if (empty($newaid[$res['wf_activity_id']]) || empty($newrid[$res['wf_role_id']])) { 
     700                                        continue; 
     701                                } 
     702                                $this->activity_manager->add_activity_role($newaid[$res['wf_activity_id']],$newrid[$res['wf_role_id']], $res['wf_readonly']); 
     703                        } 
     704                } 
     705 
     706                //create agents 
     707                //get the list of agents used by the old process 
     708                $query = 'select gaa.* from '.GALAXIA_TABLE_PREFIX.'activity_agents gaa 
     709                        INNER JOIN '.GALAXIA_TABLE_PREFIX.'activities gac ON gaa.wf_activity_id = gac.wf_activity_id 
     710                        where gac.wf_p_id=?'; 
     711                $result = $this->query($query, array($oldpid)); 
     712                if (!(empty($result))) 
     713                { 
     714                        while ($res = $result->fetchRow()) 
     715                        { 
     716                                //create a new agent of the same type for the new activity 
     717                                $agentid = $this->activity_manager->add_activity_agent($newaid[$res['wf_activity_id']],$res['wf_agent_type']); 
     718                                //save values of this new agents, taking the old ones, we make a simple copy 
     719                                $old_activity_agent_data =& $this->activity_manager->get_activity_agent_data($res['wf_activity_id'],$res['wf_agent_type']); 
     720                                //we wont need the old id and type 
     721                                unset($old_activity_agent_data['wf_agent_id']); 
     722                                unset($old_activity_agent_data['wf_agent_type']); 
     723                                $bindvars = Array(); 
     724                                $query = 'update '.GALAXIA_TABLE_PREFIX.'agent_'.$res['wf_agent_type'].' 
     725                                        set '; 
     726                                $countfields = 0; 
     727                                foreach ($old_activity_agent_data as $key => $value) 
     728                                { 
     729                                        if ($key) 
     730                                        { 
     731                                                $countfields++; 
     732                                                $query .= "$key = ? ,"; 
     733                                                $bindvars[] = $value; 
     734                                        } 
     735                                } 
     736                                $query = substr($query,'0',-1); 
     737                                $query .= ' where wf_agent_id = ?'; 
     738                                $bindvars[] = $agentid; 
     739                                if ($countfields) $this->query($query, $bindvars); 
     740                        } 
     741                } 
     742 
     743                // create a graph for the new process 
     744                $this->activity_manager->build_process_graph($pid); 
     745 
     746                return $pid; 
     747        } 
     748 
     749        /** 
     750         * This function can be used to check if a process name exists, note that this is NOT used by replace_process since that function can be used to 
     751         * create new versions of an existing process. The application must use this method to ensure that processes have unique names. 
     752         * 
     753         * @param string $name Process name 
     754         * @param string $version Process version 
     755         * @return bool 
     756         * @access public 
     757         */ 
     758        function process_name_exists($name,$version) 
     759        { 
     760                $name = addslashes($this->_normalize_name($name,$version)); 
     761                return $this->getOne('select count(*) from '.GALAXIA_TABLE_PREFIX.'processes where wf_normalized_name=?',array($name)); 
     762        } 
     763 
     764 
     765        /** 
     766         * Gets a process by pId. Fields are returned as an associative array. 
     767         * If withConfig is set (false by default), the configuration options are returned as well the ['config'] key is then an array containing the config data with type distinction 
     768         * 
     769         * @param int $pId Process id 
     770         * @param bool $withConfig Configuration options 
     771         * @return bool 
     772         * @access public 
     773         */ 
     774        function get_process($pId, $withConfig=false) 
     775        { 
     776                $query = 'select * from '.GALAXIA_TABLE_PREFIX.'processes where wf_p_id=?'; 
     777                $result = $this->query($query, array($pId)); 
     778                if((empty($result)) || (!$result->numRows())) return false; 
     779                $res = $result->fetchRow(); 
     780                if ($withConfig) 
     781                { 
     782                        // by setting true we force this function to keep type distinction on config values 
     783                        $res['config'] = $this->getConfigValues($res['wf_p_id'], true); 
     784                } 
     785                return $res; 
     786        } 
     787 
     788        /** 
     789         * Lists all processes 
     790         * 
     791         * @param int $offset Resultset starting row 
     792         * @param int   $maxRecords Max number of resulting rows 
     793         * @param string $sort_mode Sorting mode 
     794         * @param string $find Search query string 
     795         * @param string $where Condition query string 
     796         * @return bool 
     797         * @access public 
     798         */ 
     799        function list_processes($offset,$maxRecords,$sort_mode,$find='',$where='') 
     800        { 
     801                $sort_mode = $this->convert_sortmode($sort_mode); 
     802                if($find) { 
     803                        $findesc = '%'.$find.'%'; 
     804                        $mid=' where ((wf_name like ?) or (wf_description like ?))'; 
     805                        $bindvars = array($findesc,$findesc); 
     806                } else { 
     807                        $mid=''; 
     808                        $bindvars = array(); 
     809                } 
     810                if($where) { 
     811                        if($mid) { 
     812                                $mid.= " and ($where) "; 
     813                        } else { 
     814                                $mid.= " where ($where) "; 
     815                        } 
     816                } 
     817                $query = 'select * from '.GALAXIA_TABLE_PREFIX."processes $mid"; 
     818                $query_cant = 'select count(*) from '.GALAXIA_TABLE_PREFIX."processes $mid"; 
     819                $result = $this->query($query,$bindvars,$maxRecords,$offset, true, $sort_mode); 
     820                $cant = $this->getOne($query_cant,$bindvars); 
     821                $ret = Array(); 
     822                if (isset($result)) 
     823                { 
     824                        while($res = $result->fetchRow()) 
     825                        { 
     826                                $ret[] = $res; 
     827                        } 
     828                } 
     829                $retval = Array(); 
     830                $retval['data'] = $ret; 
     831                $retval['cant'] = $cant; 
     832                return $retval; 
     833        } 
     834 
    843835  /*! 
    844836   Marks a process as an invalid process 
    845   */ 
    846   function invalidate_process($pid) 
    847   { 
    848     $query = 'update '.GALAXIA_TABLE_PREFIX.'processes set wf_is_valid=? where wf_p_id=?'; 
    849     $this->query($query, array('n',$pid)); 
    850   } 
    851    
    852   /**  
    853    * Removes a process by pId 
    854    *  
    855    * @param int $pId Process id 
    856    * @return bool  
    857    * @access public 
    858837   */ 
    859   function remove_process($pId) 
    860   { 
    861     if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db); 
    862     if (!isset($this->jobManager)) 
    863       $this->jobManager = new JobManager($this->db); 
    864     $this->deactivate_process($pId); 
    865     $name = $this->_get_normalized_name($pId); 
    866      
    867     // start a transaction 
    868     $this->db->StartTrans(); 
    869         $this->jobManager->removeJobsByProcessID($pId); 
    870      
    871     // Remove process activities 
    872     $query = 'select wf_activity_id from '.GALAXIA_TABLE_PREFIX.'activities where wf_p_id=?'; 
    873     $result = $this->query($query, array($pId)); 
    874     while($res = $result->fetchRow()) { 
    875       //we add a false parameter to prevent the ActivityManager from opening a new transaction 
    876       $this->activity_manager->remove_activity($pId,$res['wf_activity_id'], false); 
    877     } 
    878  
    879     // Remove process roles 
    880     $query = 'delete from '.GALAXIA_TABLE_PREFIX.'roles where wf_p_id=?'; 
    881     $this->query($query, array($pId)); 
    882     $query = 'delete from '.GALAXIA_TABLE_PREFIX.'user_roles where wf_p_id=?'; 
    883     $this->query($query, array($pId)); 
    884  
    885         // Remove process instances 
    886         $query = 'delete from '.GALAXIA_TABLE_PREFIX.'instances where wf_p_id=?'; 
    887     $this->query($query, array($pId)); 
    888      
    889     // Remove the directory structure 
    890     if (!empty($name) && is_dir(GALAXIA_PROCESSES.SEP.$name)) { 
    891       $this->_remove_directory(GALAXIA_PROCESSES.SEP.$name,true); 
    892     } 
    893     if (GALAXIA_TEMPLATES && !empty($name) && is_dir(GALAXIA_TEMPLATES.SEP.$name)) { 
    894       $this->_remove_directory(GALAXIA_TEMPLATES.SEP.$name,true); 
    895     } 
    896      
    897     // Remove configuration data 
    898     $query = 'delete from '.GALAXIA_TABLE_PREFIX.'process_config where wf_p_id=?'; 
    899     $this->query($query, array($pId)); 
    900      
    901     // And finally remove the proc 
    902     $query = 'delete from '.GALAXIA_TABLE_PREFIX.'processes where wf_p_id=?'; 
    903     $this->query($query, array($pId)); 
    904     $msg = sprintf(tra('Process %s removed'),$name); 
    905     $this->notify_all(5,$msg); 
    906     $this->error[] = $msg; 
    907      
    908     // perform commit (return true) or Rollback (return false) 
    909     return $this->db->CompleteTrans(); 
    910      
    911   } 
    912    
    913   /** 
    914    * Updates or inserts a new process in the database, $vars is an associative array containing the fields to update or to insert as needed. 
    915    * Configuration options should be in an array associated with the 'config' key 
    916    * this config array should contain 'wf_config_name', 'wf_config_value' and 'wf_config_value_int' keys. 
    917    * $pId is the processI. If $pId is 0 then we create a new process, else we are in edit mode. 
    918    * if $create is true start and end activities will be created (when importing use $create=false) 
    919    *  
    920    * @param int $pId Process id, if 0 then we create a new process, else we are in edit mode 
    921    * @param array &$vars Associative containing the fields to update or to insert as needed 
    922    * @param bool $create If true, start and end activities will be created (when importing use $create=false). 
    923    * @return int Process id 
    924    * @access public 
    925    */ 
    926   function replace_process($pId, &$vars, $create = true) 
    927   { 
    928     if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db); 
    929     $TABLE_NAME = GALAXIA_TABLE_PREFIX.'processes'; 
    930     $now = date("U"); 
    931     $vars['wf_last_modif']=$now; 
    932     $vars['wf_normalized_name'] = $this->_normalize_name($vars['wf_name'],$vars['wf_version']); 
    933     $config_array = array(); 
    934          
    935     foreach($vars as $key=>$value) 
    936     { 
    937       if ($key=='config') 
    938       { 
    939         $config_array_init =& $value;  
    940         // rebuild a nice config_array with type of config and value 
    941         if( is_array($config_array_init) && count($config_array_init) > 0 ) 
    942         { 
    943                 foreach($config_array_init as $config) 
    944                 { 
    945                   if (isset($config['wf_config_value_int']) && (!($config['wf_config_value_int']==''))) 
    946                   { 
    947                     $config_array[$config['wf_config_name']] = array('int' => $config['wf_config_value_int']); 
    948                   } 
    949                   else 
    950                   { 
    951                     if (isset($config['wf_config_value']))  
    952                     { 
    953                       $config_array[$config['wf_config_name']] = array('text' => $config['wf_config_value']); 
    954                     } 
    955                   } 
    956                 } 
    957         } 
    958         //no need to keep it in the vars array, this array is used in queries 
    959         unset($vars['config']); 
    960       } 
    961       else // not config, it's just process's fields values 
    962       { 
    963         $vars[$key]=addslashes($value); 
    964       } 
    965     } 
    966    
    967     if($pId) { 
    968       // update mode 
    969       $old_proc = $this->get_process($pId); 
    970       $first = true; 
    971       $query ="update $TABLE_NAME set"; 
    972       foreach($vars as $key=>$value) { 
    973         if(!$first) $query.= ','; 
    974         if(!is_numeric($value)||strstr($value,'.')) $value="'".$value."'"; 
    975         $query.= " $key=$value "; 
    976         $first = false; 
    977       } 
    978       $query .= " where wf_p_id=$pId "; 
    979       $this->query($query); 
    980        
    981       //set config values 
    982       $this->setConfigValues($pId,$config_array); 
    983        
    984       // Note that if the name is being changed then 
    985       // the directory has to be renamed! 
    986       $oldname = $old_proc['wf_normalized_name']; 
    987       $newname = $vars['wf_normalized_name']; 
    988       if ($newname != $oldname) { 
    989           rename(GALAXIA_PROCESSES.SEP."$oldname",GALAXIA_PROCESSES.SEP."$newname"); 
    990       } 
    991       $msg = sprintf(tra('Process %s has been updated'),$vars['wf_name']);      
    992       $this->notify_all(3,$msg); 
    993       $this->error[] = $msg; 
    994     } else { 
    995       unset($vars['wf_p_id']); 
    996       // insert mode 
    997       $name = $this->_normalize_name($vars['wf_name'],$vars['wf_version']); 
    998       $this->_create_directory_structure($name); 
    999       $first = true; 
    1000       $query = "insert into $TABLE_NAME("; 
    1001       foreach(array_keys($vars) as $key) { 
    1002         if(!$first) $query.= ',';  
    1003         $query.= "$key"; 
    1004         $first = false; 
    1005       }  
    1006       $query .=") values("; 
    1007       $first = true; 
    1008       foreach(array_values($vars) as $value) { 
    1009         if(!$first) $query.= ',';  
    1010         if(!is_numeric($value)||strstr($value,'.')) $value="'".$value."'"; 
    1011         $query.= "$value"; 
    1012         $first = false; 
    1013       }  
    1014       $query .=")"; 
    1015       $this->query($query); 
    1016       //FIXME: this query seems to be quite sure to get a result, I would prefer something 
    1017       // more sure to get the right result everytime 
    1018       $pId = $this->getOne("select max(wf_p_id) from $TABLE_NAME where wf_last_modif=$now");  
    1019        
    1020       //set config values 
    1021       $this->setConfigValues($pId,$config_array); 
    1022        
    1023       // Now automatically add a start and end activity  
    1024       // unless importing ($create = false) 
    1025       if($create) { 
    1026         $vars1 = Array( 
    1027           'wf_name' => 'start', 
    1028           'wf_description' => 'default start activity', 
    1029           'wf_type' => 'start', 
    1030           'wf_is_interactive' => 'y', 
    1031           'wf_is_autorouted' => 'y' 
    1032         ); 
    1033         $vars2 = Array( 
    1034           'wf_name' => 'end', 
    1035           'wf_description' => 'default end activity', 
    1036           'wf_type' => 'end', 
    1037           'wf_is_interactive' => 'n', 
    1038           'wf_is_autorouted' => 'y' 
    1039         ); 
    1040    
    1041         $this->activity_manager->replace_activity($pId,0,$vars1); 
    1042         $this->activity_manager->replace_activity($pId,0,$vars2); 
    1043       } 
    1044     $msg = sprintf(tra('Process %s has been created'),$vars['wf_name']);      
    1045     $this->notify_all(4,$msg); 
    1046     $this->error[] = $msg; 
    1047     } 
    1048     // Get the id 
    1049     return $pId; 
    1050   } 
    1051     
    1052   /** 
    1053    * Gets the normalized name of a process by pid 
    1054    *  
    1055    * @param int $pId Process id 
    1056    * @access private 
    1057    * @return string  
    1058    */ 
    1059   function _get_normalized_name($pId) 
    1060   { 
    1061     $info = $this->get_process($pId); 
    1062     return $info['wf_normalized_name']; 
    1063   } 
    1064     
    1065   /** 
    1066    * Normalizes a process name 
    1067    *  
    1068    * @param string $name Process name to be normalized 
    1069    * @param string $version Process version 
    1070    * @access private 
    1071    * @return string Process normalized name 
    1072    */ 
    1073   function _normalize_name($name, $version) 
    1074   { 
    1075     $name = $name.'_'.$version; 
    1076     $name = str_replace(" ","_",$name); 
    1077     $name = preg_replace("/[^0-9A-Za-z\_]/",'',$name); 
    1078     return $name; 
    1079   } 
    1080     
    1081   /** 
    1082    * Generates a new minor version number 
    1083    *  
    1084    * @param string $version Current process version 
    1085    * @param bool $minor Generate minor version 
    1086    * @access private 
    1087    * @return string  
    1088    */ 
    1089   function _new_version($version,$minor=true) 
    1090   { 
    1091     $parts = explode('.',$version); 
    1092     if($minor) { 
    1093       $parts[count($parts)-1]++; 
    1094     } else { 
    1095       $parts[0]++; 
    1096       for ($i = 1; $i < count($parts); $i++) { 
    1097         $parts[$i] = 0; 
    1098       } 
    1099     } 
    1100     return implode('.',$parts); 
    1101   } 
    1102     
    1103   /** 
    1104    * Creates directory structure for process 
    1105    *  
    1106    * @param string $name Dir name in process repository 
    1107    * @access private 
    1108    * @return bool  
    1109    */ 
    1110   function _create_directory_structure($name) 
    1111   { 
    1112     $path = GALAXIA_PROCESSES.SEP.$name; 
    1113     if (!file_exists($path)) mkdir($path,0770); 
    1114     $path = GALAXIA_PROCESSES.SEP.$name.SEP."resources"; 
    1115     if (!file_exists($path)) mkdir($path,0770); 
    1116     $path = GALAXIA_PROCESSES.SEP.$name.SEP."graph"; 
    1117     if (!file_exists($path)) mkdir($path,0770); 
    1118     $path = GALAXIA_PROCESSES.SEP.$name.SEP."code"; 
    1119     if (!file_exists($path)) mkdir($path,0770); 
    1120     $path = GALAXIA_PROCESSES.SEP.$name.SEP."code".SEP."activities"; 
    1121     if (!file_exists($path)) mkdir($path,0770); 
    1122     $path = GALAXIA_PROCESSES.SEP.$name.SEP."code".SEP."templates"; 
    1123     if (!file_exists($path)) mkdir($path,0770); 
    1124     $path = GALAXIA_PROCESSES.SEP.$name.SEP."code".SEP."jobs"; 
    1125     if (!file_exists($path)) mkdir($path,0770); 
    1126     $path = GALAXIA_PROCESSES.SEP.$name.SEP."smarty"; 
    1127     if (!file_exists($path)) mkdir($path,0770); 
    1128     $path = GALAXIA_PROCESSES.SEP.$name.SEP."smarty".SEP."cache"; 
    1129     if (!file_exists($path)) mkdir($path,0770); 
    1130     $path = GALAXIA_PROCESSES.SEP.$name.SEP."smarty".SEP."compiled"; 
    1131     if (!file_exists($path)) mkdir($path,0770); 
    1132     if (GALAXIA_TEMPLATES) { 
    1133       $path = GALAXIA_TEMPLATES.SEP.$name; 
    1134       if (!file_exists($path)) mkdir($path,0770); 
    1135     } 
    1136     // Create shared file 
    1137     $file = GALAXIA_PROCESSES.SEP.$name.SEP."code".SEP."shared.php"; 
    1138     if (!file_exists($file)) 
    1139     { 
    1140       $fp = fopen(GALAXIA_PROCESSES.SEP.$name.SEP."code".SEP."shared.php","w"); 
    1141       if (!fp) return false; 
    1142       fwrite($fp,'<'.'?'.'php'."\n".'?'.'>'); 
    1143       fclose($fp); 
    1144     } 
    1145   } 
    1146     
    1147   /** 
    1148    * Removes a directory recursively  
    1149    * 
    1150    * @param string $dir Dir name to be erased 
    1151    * @param bool $rec Recursive mode 
    1152    * @access private 
    1153    * @return void  
    1154    */ 
    1155   function _remove_directory($dir,$rec=false) 
    1156   { 
    1157     // Prevent a disaster 
    1158     if(trim($dir) == SEP || trim($dir)=='.' || trim($dir)=='templates' || trim($dir)=='templates'.SEP) return false; 
    1159     $h = opendir($dir); 
    1160     while(($file = readdir($h)) != false) { 
    1161       if(is_file($dir.SEP.$file)) { 
    1162         @unlink($dir.SEP.$file); 
    1163       } else { 
    1164         if($rec && $file != '.' && $file != '..') { 
    1165           $this->_remove_directory($dir.SEP.$file, true); 
    1166         } 
    1167       } 
    1168     } 
    1169     closedir($h);    
    1170     @rmdir($dir); 
    1171     @unlink($dir); 
    1172   } 
    1173    
    1174   /** 
    1175    * Copies a directory recursively  
    1176    * 
    1177    * @param string $dir1 Dir name to be copied 
    1178    * @param string $dir2 Generated destination dir 
    1179    * @access private 
    1180    * @return void  
    1181    */ 
    1182   function _rec_copy($dir1,$dir2) 
    1183   { 
    1184     @mkdir($dir2,0777); 
    1185     $h = opendir($dir1); 
    1186     while(($file = readdir($h)) !== false) { 
    1187       if(is_file($dir1.SEP.$file)) { 
    1188         copy($dir1.SEP.$file,$dir2.SEP.$file); 
    1189       } else { 
    1190         if($file != '.' && $file != '..') { 
    1191           $this->_rec_copy($dir1.SEP.$file, $dir2.SEP.$file); 
    1192         } 
    1193       } 
    1194     } 
    1195     closedir($h);    
    1196   } 
    1197  
    1198   /** 
    1199    * XML parser start element handler 
    1200    *  
    1201    * @param resource $parser Parser handle 
    1202    * @param string $element XML tag 
    1203    * @param array $attribs XML tag attributes 
    1204    * @access private 
    1205    * @return void  
    1206    */ 
    1207   function _start_element_handler($parser, $element, $attribs) 
    1208   { 
    1209     $aux=Array('name'=>$element, 
    1210                'data'=>'', 
    1211                'parent' => $this->current, 
    1212                'children'=>Array(), 
    1213                'attribs' => $attribs); 
    1214                             
    1215     $i = count($this->tree);            
    1216     $this->tree[$i] = $aux; 
    1217  
    1218     $this->tree[$this->current]['children'][]=$i; 
    1219     $this->current=$i; 
    1220   } 
    1221  
    1222   /** 
    1223    * XML parser end element handler 
    1224    *  
    1225    * @param resource $parser Parser handle 
    1226    * @param string $element XML tag 
    1227    * @param array $attribs XML tag attributes 
    1228    * @access private 
    1229    * @return void  
    1230    */ 
    1231   function _end_element_handler($parser, $element) 
    1232   { 
    1233     //when a tag ends put text 
    1234     $this->tree[$this->current]['data']=$this->buffer;            
    1235     $this->buffer=''; 
    1236     $this->current=$this->tree[$this->current]['parent']; 
    1237   } 
    1238  
    1239   /** 
    1240    * XML parser element data handler 
    1241    *  
    1242    * @param resource $parser Parser handle 
    1243    * @param string $element XML tag 
    1244    * @param string $data XML tag content 
    1245    * @access private 
    1246    * @return void  
    1247    */ 
    1248   function _data_handler($parser, $data) 
    1249   { 
    1250           $this->buffer .= $data; 
    1251   } 
    1252  
    1253   /** 
    1254    * This getConfigValues differs from the Process::getConfigValues because requires only process id. 
    1255    * This method gets the items defined in process_config table for this process, in fact this admin function bypass 
    1256    * the process behaviour and is just showing you the basic content of the table.  
    1257    * All config items are returned as a function result.         
    1258    *  
    1259    * @param int $pId Process id 
    1260    * @param bool $distinct_types If the distinct_type is set the returned array will follow the format: 
    1261    * * 0        =>('wf_config_name'=> 'foo') 
    1262    *            =>('wf_config_value'=>'bar') 
    1263    *            =>('wf_config_vale_int'=>null) 
    1264    * * 1        =>('wf_config_name' => 'toto') 
    1265    *            =>('wf_config_value'=>'') 
    1266    *            =>('wf_config_vale_int'=>15) 
    1267    * if set to false (default) the result array will be (note that this is the default result if having just the $pId): 
    1268    * * 'foo'=>'bar' 
    1269    * * 'toto'=>15 
    1270    * @param bool $askProcessObject If the askProcessObject is set to true (false by default) then the ProcessManager will load a process 
    1271    * object to run directly Process->getConfigValues($config_ask_array) this let you use this ProcessManager 
    1272    * getConfigValues the same way you would use $process->getConfigValues, with initialisation of default values. 
    1273    * you should then call this function this way: $conf_result=$pm->getConfigValues($pId,true,true,$my_conf_array) 
    1274    * @param array $config_array 
    1275    * @access public 
    1276    * @return array  
    1277    */ 
    1278   function getConfigValues($pId, $distinct_types=false, $askProcessObject=false, $config_array=array()) 
    1279   { 
    1280     if (!$askProcessObject) 
    1281     { 
    1282       $query = 'select * from '.GALAXIA_TABLE_PREFIX.'process_config where wf_p_id=?'; 
    1283       $result = $this->query($query, array($pId)); 
    1284       $result_array=array(); 
    1285       while($res = $result->fetchRow()) 
    1286       { 
    1287         if ( (!$distinct_types) ) 
    1288         {// we want a simple array 
    1289           if ($res['wf_config_value_int']==null) 
    1290           { 
    1291             $result_array[$res['wf_config_name']] = $res['wf_config_value']; 
    1292             } 
    1293           else 
    1294           { 
    1295             $result_array[$res['wf_config_name']] = $res['wf_config_value_int']; 
    1296           } 
    1297         } 
    1298         else 
    1299         {// build a more complex result array, which is just the table rows 
    1300           $result_array[] = $res; 
    1301         } 
    1302       } 
    1303     } 
    1304     else //we'll load a Process object and let him work for us 
    1305     { 
    1306       //Warning: this means you have to include the Process.php from the API 
    1307       $this->Process = new Process($this->db); 
    1308       $this->Process->getProcess($pId); 
    1309       $result_array = $this->Process->getConfigValues($config_array); 
    1310       unset ($this->Process); 
    1311     } 
    1312     return $result_array; 
    1313   } 
    1314    
    1315   /** 
    1316    * Calls a process object to save his new config values by taking a process Id as first argument and simply call  
    1317    * this process's setConfigValues method. We let the process define the better way to store the data given as second arg. 
    1318    *  
    1319    * @param int $pId Process id 
    1320    * @param array &$config_array 
    1321    * @return void  
    1322    * @access public 
    1323    */ 
    1324   function setConfigValues($pId, &$config_array) 
    1325   { 
    1326     //Warning: this means you have to include the Process.php from the API 
    1327     $this->Process = new Process($this->db); 
    1328     $this->Process->getProcess($pId); 
    1329     $this->Process->setConfigValues($config_array); 
    1330     unset ($this->Process); 
    1331   } 
    1332    
    1333   /** 
    1334    * Gets available agents list 
    1335    *  
    1336    * @return array 
    1337    * @access public 
    1338    */ 
    1339   function get_agents() 
    1340   { 
    1341     return galaxia_get_agents_list(); 
    1342   } 
    1343  
    1344   /** 
    1345    * Gets the view activity id avaible for a given process 
    1346    *  
    1347    * @param int $pId Process Id 
    1348    * @return bool False if no view activity is avaible for the process, return the activity id if there is one 
    1349    * @access public 
    1350    */ 
    1351   function get_process_view_activity($pId) 
    1352   { 
    1353     $mid = 'where gp.wf_p_id=? and ga.wf_type=?'; 
    1354     $bindvars = array($pId,'view'); 
    1355     $query = 'select ga.wf_activity_id 
    1356         from '.GALAXIA_TABLE_PREFIX.'processes gp 
    1357         INNER JOIN '.GALAXIA_TABLE_PREFIX."activities ga ON gp.wf_p_id=ga.wf_p_id 
    1358         $mid"; 
    1359     $result = $this->query($query,$bindvars); 
    1360     $ret = Array(); 
    1361     $retval = false; 
    1362     if (!(empty($result))) 
    1363     { 
    1364       while($res = $result->fetchRow())  
    1365       { 
    1366         $retval = $res['wf_activity_id']; 
    1367       } 
    1368     } 
    1369     return $retval; 
    1370   } 
     838        function invalidate_process($pid) 
     839        { 
     840                $query = 'update '.GALAXIA_TABLE_PREFIX.'processes set wf_is_valid=? where wf_p_id=?'; 
     841                $this->query($query, array('n',$pid)); 
     842        } 
     843 
     844        /** 
     845         * Removes a process by pId 
     846         * 
     847         * @param int $pId Process id 
     848         * @return bool 
     849         * @access public 
     850         */ 
     851        function remove_process($pId) 
     852        { 
     853                if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager'); 
     854                if (!isset($this->jobManager)) 
     855                        $this->jobManager = &Factory::newInstance('JobManager'); 
     856                $this->deactivate_process($pId); 
     857                $name = $this->_get_normalized_name($pId); 
     858 
     859                // start a transaction 
     860                $this->db->StartTrans(); 
     861                $this->jobManager->removeJobsByProcessID($pId); 
     862 
     863                // Remove process activities 
     864                $query = 'select wf_activity_id from '.GALAXIA_TABLE_PREFIX.'activities where wf_p_id=?'; 
     865                $result = $this->query($query, array($pId)); 
     866                while($res = $result->fetchRow()) { 
     867                        //we add a false parameter to prevent the ActivityManager from opening a new transaction 
     868                        $this->activity_manager->remove_activity($pId,$res['wf_activity_id'], false); 
     869                } 
     870 
     871                // Remove process roles 
     872                $query = 'delete from '.GALAXIA_TABLE_PREFIX.'roles where wf_p_id=?'; 
     873                $this->query($query, array($pId)); 
     874                $query = 'delete from '.GALAXIA_TABLE_PREFIX.'user_roles where wf_p_id=?'; 
     875                $this->query($query, array($pId)); 
     876 
     877                // Remove process instances 
     878                $query = 'delete from '.GALAXIA_TABLE_PREFIX.'instances where wf_p_id=?'; 
     879                $this->query($query, array($pId)); 
     880 
     881                // Remove the directory structure 
     882                if (!empty($name) && is_dir(GALAXIA_PROCESSES.SEP.$name)) { 
     883                        $this->_remove_directory(GALAXIA_PROCESSES.SEP.$name,true); 
     884                } 
     885                if (GALAXIA_TEMPLATES && !empty($name) && is_dir(GALAXIA_TEMPLATES.SEP.$name)) { 
     886                        $this->_remove_directory(GALAXIA_TEMPLATES.SEP.$name,true); 
     887                } 
     888 
     889                // Remove configuration data 
     890                $query = 'delete from '.GALAXIA_TABLE_PREFIX.'process_config where wf_p_id=?'; 
     891                $this->query($query, array($pId)); 
     892 
     893                // And finally remove the proc 
     894                $query = 'delete from '.GALAXIA_TABLE_PREFIX.'processes where wf_p_id=?'; 
     895                $this->query($query, array($pId)); 
     896                $msg = sprintf(tra('Process %s removed'),$name); 
     897                $this->error[] = $msg; 
     898 
     899                // perform commit (return true) or Rollback (return false) 
     900                return $this->db->CompleteTrans(); 
     901 
     902        } 
     903 
     904        /** 
     905         * Updates or inserts a new process in the database, $vars is an associative array containing the fields to update or to insert as needed. 
     906         * Configuration options should be in an array associated with the 'config' key 
     907         * this config array should contain 'wf_config_name', 'wf_config_value' and 'wf_config_value_int' keys. 
     908         * $pId is the processI. If $pId is 0 then we create a new process, else we are in edit mode. 
     909         * if $create is true start and end activities will be created (when importing use $create=false) 
     910         * 
     911         * @param int $pId Process id, if 0 then we create a new process, else we are in edit mode 
     912         * @param array &$vars Associative containing the fields to update or to insert as needed 
     913         * @param bool $create If true, start and end activities will be created (when importing use $create=false). 
     914         * @return int Process id 
     915         * @access public 
     916         */ 
     917        function replace_process($pId, &$vars, $create = true) 
     918        { 
     919                if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager'); 
     920                $TABLE_NAME = GALAXIA_TABLE_PREFIX.'processes'; 
     921                $now = date("U"); 
     922                $vars['wf_last_modif']=$now; 
     923                $vars['wf_normalized_name'] = $this->_normalize_name($vars['wf_name'],$vars['wf_version']); 
     924                $config_array = array(); 
     925 
     926                foreach($vars as $key=>$value) 
     927                { 
     928                        if ($key=='config') 
     929                        { 
     930                                $config_array_init =& $value; 
     931                                // rebuild a nice config_array with type of config and value 
     932                                if( is_array($config_array_init) && count($config_array_init) > 0 ) 
     933                                { 
     934                                        foreach($config_array_init as $config) 
     935                                        { 
     936                                                if (isset($config['wf_config_value_int']) && (!($config['wf_config_value_int']==''))) 
     937                                                { 
     938                                                        $config_array[$config['wf_config_name']] = array('int' => $config['wf_config_value_int']); 
     939                                                } 
     940                                                else 
     941                                                { 
     942                                                        if (isset($config['wf_config_value'])) 
     943                                                        { 
     944                                                                $config_array[$config['wf_config_name']] = array('text' => $config['wf_config_value']); 
     945                                                        } 
     946                                                } 
     947                                        } 
     948                                } 
     949                                //no need to keep it in the vars array, this array is used in queries 
     950                                unset($vars['config']); 
     951                        } 
     952                        else // not config, it's just process's fields values 
     953                        { 
     954                                $vars[$key]=addslashes($value); 
     955                        } 
     956                } 
     957 
     958                if($pId) { 
     959                        // update mode 
     960                        $old_proc = $this->get_process($pId); 
     961                        $first = true; 
     962                        $query ="update $TABLE_NAME set"; 
     963                        foreach($vars as $key=>$value) { 
     964                                if(!$first) $query.= ','; 
     965                                if(!is_numeric($value)||strstr($value,'.')) $value="'".$value."'"; 
     966                                $query.= " $key=$value "; 
     967                                $first = false; 
     968                        } 
     969                        $query .= " where wf_p_id=$pId "; 
     970                        $this->query($query); 
     971 
     972                        //set config values 
     973                        $this->setConfigValues($pId,$config_array); 
     974 
     975                        // Note that if the name is being changed then 
     976                        // the directory has to be renamed! 
     977                        $oldname = $old_proc['wf_normalized_name']; 
     978                        $newname = $vars['wf_normalized_name']; 
     979                        if ($newname != $oldname) { 
     980                                rename(GALAXIA_PROCESSES.SEP."$oldname",GALAXIA_PROCESSES.SEP."$newname"); 
     981                        } 
     982                        $msg = sprintf(tra('Process %s has been updated'),$vars['wf_name']); 
     983                        $this->error[] = $msg; 
     984                } else { 
     985                        unset($vars['wf_p_id']); 
     986                        // insert mode 
     987                        $name = $this->_normalize_name($vars['wf_name'],$vars['wf_version']); 
     988                        $this->_create_directory_structure($name); 
     989                        $first = true; 
     990                        $query = "insert into $TABLE_NAME("; 
     991                        foreach(array_keys($vars) as $key) { 
     992                                if(!$first) $query.= ','; 
     993                                $query.= "$key"; 
     994                                $first = false; 
     995                        } 
     996                        $query .=") values("; 
     997                        $first = true; 
     998                        foreach(array_values($vars) as $value) { 
     999                                if(!$first) $query.= ','; 
     1000                                if(!is_numeric($value)||strstr($value,'.')) $value="'".$value."'"; 
     1001                                $query.= "$value"; 
     1002                                $first = false; 
     1003                        } 
     1004                        $query .=")"; 
     1005                        $this->query($query); 
     1006                        //FIXME: this query seems to be quite sure to get a result, I would prefer something 
     1007                        // more sure to get the right result everytime 
     1008                        $pId = $this->getOne("select max(wf_p_id) from $TABLE_NAME where wf_last_modif=$now"); 
     1009 
     1010                        //set config values 
     1011                        $this->setConfigValues($pId,$config_array); 
     1012 
     1013                        // Now automatically add a start and end activity 
     1014                        // unless importing ($create = false) 
     1015                        if($create) { 
     1016                                $vars1 = Array( 
     1017                                        'wf_name' => 'start', 
     1018                                        'wf_description' => 'default start activity', 
     1019                                        'wf_type' => 'start', 
     1020                                        'wf_is_interactive' => 'y', 
     1021                                        'wf_is_autorouted' => 'y' 
     1022                                ); 
     1023                                $vars2 = Array( 
     1024                                        'wf_name' => 'end', 
     1025                                        'wf_description' => 'default end activity', 
     1026                                        'wf_type' => 'end', 
     1027                                        'wf_is_interactive' => 'n', 
     1028                                        'wf_is_autorouted' => 'y' 
     1029                                ); 
     1030 
     1031                                $this->activity_manager->replace_activity($pId,0,$vars1); 
     1032                                $this->activity_manager->replace_activity($pId,0,$vars2); 
     1033                        } 
     1034                        $msg = sprintf(tra('Process %s has been created'),$vars['wf_name']); 
     1035                        $this->error[] = $msg; 
     1036                } 
     1037                // Get the id 
     1038                return $pId; 
     1039        } 
     1040 
     1041        /** 
     1042         * Gets the normalized name of a process by pid 
     1043         * 
     1044         * @param int $pId Process id 
     1045         * @access private 
     1046         * @return string 
     1047         */ 
     1048        function _get_normalized_name($pId) 
     1049        { 
     1050                $info = $this->get_process($pId); 
     1051                return $info['wf_normalized_name']; 
     1052        } 
     1053 
     1054        /** 
     1055         * Normalizes a process name 
     1056         * 
     1057         * @param string $name Process name to be normalized 
     1058         * @param string $version Process version 
     1059         * @access private 
     1060         * @return string Process normalized name 
     1061         */ 
     1062        function _normalize_name($name, $version) 
     1063        { 
     1064                $name = $name.'_'.$version; 
     1065                $name = str_replace(" ","_",$name); 
     1066                $name = preg_replace("/[^0-9A-Za-z\_]/",'',$name); 
     1067                return $name; 
     1068        } 
     1069 
     1070        /** 
     1071         * Generates a new minor version number 
     1072         * 
     1073         * @param string $version Current process version 
     1074         * @param bool $minor Generate minor version 
     1075         * @access private 
     1076         * @return string 
     1077         */ 
     1078        function _new_version($version,$minor=true) 
     1079        { 
     1080                $parts = explode('.',$version); 
     1081                if($minor) { 
     1082                        $parts[count($parts)-1]++; 
     1083                } else { 
     1084                        $parts[0]++; 
     1085                        for ($i = 1; $i < count($parts); $i++) { 
     1086                                $parts[$i] = 0; 
     1087                        } 
     1088                } 
     1089                return implode('.',$parts); 
     1090        } 
     1091 
     1092        /** 
     1093         * Creates directory structure for process 
     1094         * 
     1095         * @param string $name Dir name in process repository 
     1096         * @access private 
     1097         * @return bool 
     1098         */ 
     1099        function _create_directory_structure($name) 
     1100        { 
     1101                $path = GALAXIA_PROCESSES.SEP.$name; 
     1102                if (!file_exists($path)) mkdir($path,0770); 
     1103                $path = GALAXIA_PROCESSES.SEP.$name.SEP."resources"; 
     1104                if (!file_exists($path)) mkdir($path,0770); 
     1105                $path = GALAXIA_PROCESSES.SEP.$name.SEP."graph"; 
     1106                if (!file_exists($path)) mkdir($path,0770); 
     1107                $path = GALAXIA_PROCESSES.SEP.$name.SEP."code"; 
     1108                if (!file_exists($path)) mkdir($path,0770); 
     1109                $path = GALAXIA_PROCESSES.SEP.$name.SEP."code".SEP."activities"; 
     1110                if (!file_exists($path)) mkdir($path,0770); 
     1111                $path = GALAXIA_PROCESSES.SEP.$name.SEP."code".SEP."templates"; 
     1112                if (!file_exists($path)) mkdir($path,0770); 
     1113                $path = GALAXIA_PROCESSES.SEP.$name.SEP."code".SEP."jobs"; 
     1114                if (!file_exists($path)) mkdir($path,0770); 
     1115                $path = GALAXIA_PROCESSES.SEP.$name.SEP."smarty"; 
     1116                if (!file_exists($path)) mkdir($path,0770); 
     1117                $path = GALAXIA_PROCESSES.SEP.$name.SEP."smarty".SEP."cache"; 
     1118                if (!file_exists($path)) mkdir($path,0770); 
     1119                $path = GALAXIA_PROCESSES.SEP.$name.SEP."smarty".SEP."compiled"; 
     1120                if (!file_exists($path)) mkdir($path,0770); 
     1121                if (GALAXIA_TEMPLATES) { 
     1122                        $path = GALAXIA_TEMPLATES.SEP.$name; 
     1123                        if (!file_exists($path)) mkdir($path,0770); 
     1124                } 
     1125                // Create shared file 
     1126                $file = GALAXIA_PROCESSES.SEP.$name.SEP."code".SEP."shared.php"; 
     1127                if (!file_exists($file)) 
     1128                { 
     1129                        $fp = fopen(GALAXIA_PROCESSES.SEP.$name.SEP."code".SEP."shared.php","w"); 
     1130                        if (!fp) return false; 
     1131                        fwrite($fp,'<'.'?'.'php'."\n".'?'.'>'); 
     1132                        fclose($fp); 
     1133                } 
     1134        } 
     1135 
     1136        /** 
     1137         * Removes a directory recursively 
     1138         * 
     1139         * @param string $dir Dir name to be erased 
     1140         * @param bool $rec Recursive mode 
     1141         * @access private 
     1142         * @return void 
     1143         */ 
     1144        function _remove_directory($dir,$rec=false) 
     1145        { 
     1146                // Prevent a disaster 
     1147                if(trim($dir) == SEP || trim($dir)=='.' || trim($dir)=='templates' || trim($dir)=='templates'.SEP) return false; 
     1148                $h = opendir($dir); 
     1149                while(($file = readdir($h)) != false) { 
     1150                        if(is_file($dir.SEP.$file)) { 
     1151                                @unlink($dir.SEP.$file); 
     1152                        } else { 
     1153                                if($rec && $file != '.' && $file != '..') { 
     1154                                        $this->_remove_directory($dir.SEP.$file, true); 
     1155                                } 
     1156                        } 
     1157                } 
     1158                closedir($h); 
     1159                @rmdir($dir); 
     1160                @unlink($dir); 
     1161        } 
     1162 
     1163        /** 
     1164         * Copies a directory recursively 
     1165         * 
     1166         * @param string $dir1 Dir name to be copied 
     1167         * @param string $dir2 Generated destination dir 
     1168         * @access private 
     1169         * @return void 
     1170         */ 
     1171        function _rec_copy($dir1,$dir2) 
     1172        { 
     1173                @mkdir($dir2,0777); 
     1174                $h = opendir($dir1); 
     1175                while(($file = readdir($h)) !== false) { 
     1176                        if(is_file($dir1.SEP.$file)) { 
     1177                                copy($dir1.SEP.$file,$dir2.SEP.$file); 
     1178                        } else { 
     1179                                if($file != '.' && $file != '..') { 
     1180                                        $this->_rec_copy($dir1.SEP.$file, $dir2.SEP.$file); 
     1181                                } 
     1182                        } 
     1183                } 
     1184                closedir($h); 
     1185        } 
     1186 
     1187        /** 
     1188         * XML parser start element handler 
     1189         * 
     1190         * @param resource $parser Parser handle 
     1191         * @param string $element XML tag 
     1192         * @param array $attribs XML tag attributes 
     1193         * @access private 
     1194         * @return void 
     1195         */ 
     1196        function _start_element_handler($parser, $element, $attribs) 
     1197        { 
     1198                $aux=Array('name'=>$element, 
     1199                        'data'=>'', 
     1200                        'parent' => $this->current, 
     1201                        'children'=>Array(), 
     1202                        'attribs' => $attribs); 
     1203 
     1204                $i = count($this->tree); 
     1205                $this->tree[$i] = $aux; 
     1206 
     1207                $this->tree[$this->current]['children'][]=$i; 
     1208                $this->current=$i; 
     1209        } 
     1210 
     1211        /** 
     1212         * XML parser end element handler 
     1213         * 
     1214         * @param resource $parser Parser handle 
     1215         * @param string $element XML tag 
     1216         * @param array $attribs XML tag attributes 
     1217         * @access private 
     1218         * @return void 
     1219         */ 
     1220        function _end_element_handler($parser, $element) 
     1221        { 
     1222                //when a tag ends put text 
     1223                $this->tree[$this->current]['data']=$this->buffer; 
     1224                $this->buffer=''; 
     1225                $this->current=$this->tree[$this->current]['parent']; 
     1226        } 
     1227 
     1228        /** 
     1229         * XML parser element data handler 
     1230         * 
     1231         * @param resource $parser Parser handle 
     1232         * @param string $element XML tag 
     1233         * @param string $data XML tag content 
     1234         * @access private 
     1235         * @return void 
     1236         */ 
     1237        function _data_handler($parser, $data) 
     1238        { 
     1239                $this->buffer .= $data; 
     1240        } 
     1241 
     1242        /** 
     1243         * This getConfigValues differs from the Process::getConfigValues because requires only process id. 
     1244         * This method gets the items defined in process_config table for this process, in fact this admin function bypass 
     1245         * the process behaviour and is just showing you the basic content of the table. 
     1246         * All config items are returned as a function result. 
     1247         * 
     1248         * @param int $pId Process id 
     1249         * @param bool $distinct_types If the distinct_type is set the returned array will follow the format: 
     1250         * * 0  =>('wf_config_name'=> 'foo') 
     1251         *              =>('wf_config_value'=>'bar') 
     1252         *              =>('wf_config_vale_int'=>null) 
     1253         * * 1  =>('wf_config_name' => 'toto') 
     1254         *              =>('wf_config_value'=>'') 
     1255         *              =>('wf_config_vale_int'=>15) 
     1256         * if set to false (default) the result array will be (note that this is the default result if having just the $pId): 
     1257         * * 'foo'=>'bar' 
     1258         * * 'toto'=>15 
     1259         * @param bool $askProcessObject If the askProcessObject is set to true (false by default) then the ProcessManager will load a process 
     1260         * object to run directly Process->getConfigValues($config_ask_array) this let you use this ProcessManager 
     1261         * getConfigValues the same way you would use $process->getConfigValues, with initialisation of default values. 
     1262         * you should then call this function this way: $conf_result=$pm->getConfigValues($pId,true,true,$my_conf_array) 
     1263         * @param array $config_array 
     1264         * @access public 
     1265         * @return array 
     1266         */ 
     1267        function getConfigValues($pId, $distinct_types=false, $askProcessObject=false, $config_array=array()) 
     1268        { 
     1269                if (!$askProcessObject) 
     1270                { 
     1271                        $query = 'select * from '.GALAXIA_TABLE_PREFIX.'process_config where wf_p_id=?'; 
     1272                        $result = $this->query($query, array($pId)); 
     1273                        $result_array=array(); 
     1274                        while($res = $result->fetchRow()) 
     1275                        { 
     1276                                if ( (!$distinct_types) ) 
     1277                                {// we want a simple array 
     1278                                        if ($res['wf_config_value_int']==null) 
     1279                                        { 
     1280                                                $result_array[$res['wf_config_name']] = $res['wf_config_value']; 
     1281                                        } 
     1282                                        else 
     1283                                        { 
     1284                                                $result_array[$res['wf_config_name']] = $res['wf_config_value_int']; 
     1285                                        } 
     1286                                } 
     1287                                else 
     1288                                {// build a more complex result array, which is just the table rows 
     1289                                        $result_array[] = $res; 
     1290                                } 
     1291                        } 
     1292                } 
     1293                else //we'll load a Process object and let him work for us 
     1294                { 
     1295                        //Warning: this means you have to include the Process.php from the API 
     1296                        $this->Process = &Factory::newInstance('Process'); 
     1297                        $this->Process->getProcess($pId); 
     1298                        $result_array = $this->Process->getConfigValues($config_array); 
     1299                        unset ($this->Process); 
     1300                } 
     1301                return $result_array; 
     1302        } 
     1303 
     1304        /** 
     1305         * Calls a process object to save his new config values by taking a process Id as first argument and simply call 
     1306         * this process's setConfigValues method. We let the process define the better way to store the data given as second arg. 
     1307         * 
     1308         * @param int $pId Process id 
     1309         * @param array &$config_array 
     1310         * @return void 
     1311         * @access public 
     1312         */ 
     1313        function setConfigValues($pId, &$config_array) 
     1314        { 
     1315                //Warning: this means you have to include the Process.php from the API 
     1316                $this->Process = &Factory::newInstance('Process'); 
     1317                $this->Process->getProcess($pId); 
     1318                $this->Process->setConfigValues($config_array); 
     1319                unset ($this->Process); 
     1320        } 
     1321 
     1322        /** 
     1323         * Gets available agents list 
     1324         * 
     1325         * @return array 
     1326         * @access public 
     1327         */ 
     1328        function get_agents() 
     1329        { 
     1330                return galaxia_get_agents_list(); 
     1331        } 
     1332 
     1333        /** 
     1334         * Gets the view activity id avaible for a given process 
     1335         * 
     1336         * @param int $pId Process Id 
     1337         * @return bool False if no view activity is avaible for the process, return the activity id if there is one 
     1338         * @access public 
     1339         */ 
     1340        function get_process_view_activity($pId) 
     1341        { 
     1342                $mid = 'where gp.wf_p_id=? and ga.wf_type=?'; 
     1343                $bindvars = array($pId,'view'); 
     1344                $query = 'select ga.wf_activity_id 
     1345                        from '.GALAXIA_TABLE_PREFIX.'processes gp 
     1346                        INNER JOIN '.GALAXIA_TABLE_PREFIX."activities ga ON gp.wf_p_id=ga.wf_p_id 
     1347                        $mid"; 
     1348                $result = $this->query($query,$bindvars); 
     1349                $ret = Array(); 
     1350                $retval = false; 
     1351                if (!(empty($result))) 
     1352                { 
     1353                        while($res = $result->fetchRow()) 
     1354                        { 
     1355                                $retval = $res['wf_activity_id']; 
     1356                        } 
     1357                } 
     1358                return $retval; 
     1359        } 
    13711360 
    13721361} 
  • branches/2.2/workflow/inc/engine/src/ProcessManager/RoleManager.php

    r795 r3167  
    1919   * @access public 
    2020   */ 
    21   function RoleManager(&$db)  
    22   { 
    23     parent::Base($db); 
     21  function RoleManager()  
     22  { 
     23    parent::Base(); 
    2424    $this->child_name = 'RoleManager'; 
    2525  } 
     
    247247    $result = $this->query($query,$bindvars); 
    248248    $ret = Array(); 
    249     $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     249    $ldap = &Factory::getInstance('WorkflowLDAP'); 
    250250    if (!(empty($result))) 
    251251    { 
     
    256256          //we have a group instead of a simple user and we want real users 
    257257          $real_users = galaxia_retrieve_group_users($res['wf_user'], true); 
    258           foreach ($real_users as $key => $value) 
    259           { 
    260             $ret[$key]=$value; 
    261           } 
     258                  if (!empty($real_users)) { 
     259            foreach ($real_users as $key => $value) 
     260            { 
     261              $ret[$key]=$value; 
     262            } 
     263                  } 
    262264        } 
    263265        else 
  • branches/2.2/workflow/inc/engine/src/ProcessMonitor/ProcessMonitor.php

    r795 r3167  
    1818   * @access public 
    1919   */ 
    20   function ProcessMonitor(&$db) 
     20  function ProcessMonitor() 
    2121  { 
    2222    $this->child_name = 'ProcessMonitor'; 
    23     parent::Base($db); 
     23    parent::Base(); 
    2424    // check the the actual user can really do this 
    2525    if ( !(galaxia_user_can_monitor())) 
     
    5959 
    6060  /** 
    61    * @deprecated 
     61   * @deprecated 2.2.00.000 
    6262   */ 
    6363  function update_instance_status($iid,$status) { 
     64        wf_warn_deprecated_method(); 
    6465    return; 
    6566    $query = "update `".GALAXIA_TABLE_PREFIX."instances` set `wf_status`=? where `wf_instance_id`=?"; 
     
    6970   
    7071  /** 
    71    * @deprecated 
     72   * @deprecated 2.2.00.000 
    7273   */ 
    7374  function update_instance_activity_status($iid,$activityId,$status) { 
     75        wf_warn_deprecated_method(); 
    7476    return; 
    7577    $query = "update `".GALAXIA_TABLE_PREFIX."instance_activities` set `wf_status`=? where `wf_instance_id`=? and `wf_activity_id`=?"; 
  • branches/2.2/workflow/inc/engine/src/common/Base.php

    r795 r3167  
    11<?php 
    2 require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'common'.SEP.'Observable.php'); 
    32/** 
    43 * This class is derived by all the API classes so they get the 
    5  * database connection, database methods and the Observable interface 
    6  *  
     4 * database connection and the database methods. 
     5 * 
    76 * @package Galaxia 
    8  * @license http://www.gnu.org/copyleft/gpl.html GPL  
     7 * @license http://www.gnu.org/copyleft/gpl.html GPL 
    98 */ 
    10 class Base extends Observable { 
     9class Base { 
    1110        /** 
    1211         * @var object $db Database abstraction object used to access the database 
     
    1716         * @var int     $num_queries Debugging var 
    1817         * @access private 
    19          */      
     18         */ 
    2019        var $num_queries = 0; 
    2120        /** 
    2221         * @var int     $num_queries_total Debugging var 
    2322         * @access private 
    24          */      
     23         */ 
    2524        var $num_queries_total = 0; 
    2625        /** 
    2726         * @var array  $error Error messages 
    2827         * @access public 
    29          */      
     28         */ 
    3029        var $error= Array(); 
    3130        /** 
     
    3938         */ 
    4039        var $child_name = 'Base'; 
    41    
     40 
     41        /** 
     42         * @var object $db_shared_obj The database abstraction object shared between 
     43         *                                                    all instances of this class. 
     44         * @acess private 
     45         * @static 
     46         */ 
     47        private static $db_shared_obj = null; 
     48 
    4249  /** 
    4350   * Constructor receiving a database abstraction object 
     
    4754   * @access public 
    4855   */ 
    49   function Base(&$db) 
     56  function Base() 
    5057  { 
    51     if(!$db) { 
     58        /** 
     59         * New Stuff! 
     60         * We decided to get here the database object. In a recent past, 
     61         * all the classes that specialize this one passed a db object. 
     62         * Now, to simplify and save memory, we store the database object 
     63         * into a single and static atribute shared among each instance 
     64         * of this class. 
     65         * 
     66         * To prevent to modify all sub-classes to use "self::$db" instead 
     67         * of "this->db", we made a very tiny workaround here. In the first 
     68         * instantiation of this class, we instantiate the database object 
     69         * and store it into 'self::$db_shared_obj'. Any subsequent 
     70         * instantiations will just point to the static one. 
     71         */ 
     72        if (!self::$db_shared_obj) 
     73                self::$db_shared_obj = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 
     74 
     75        $this->db = &self::$db_shared_obj; 
     76 
     77 
     78    if(!$this->db) { 
    5279      die('Invalid db object passed to '.$this->child_name.' constructor'); 
    5380    } 
    5481    //Force transactionnal mysql (Innodb) -> mysqlt 
    55     if ($db->databaseType=='mysql') 
     82    if ($this->db->databaseType=='mysql') 
    5683    { 
    5784        $GLOBALS['phpgw']->db->disconnect(); 
    58         $db = $GLOBALS['phpgw']->db->connect( 
     85        $this->db = $GLOBALS['phpgw']->db->connect( 
    5986                        $GLOBALS['phpgw_info']['server']['db_name'], 
    6087                        $GLOBALS['phpgw_info']['server']['db_host'], 
     
    6592                ); 
    6693    } 
    67     $this->db = &$db; 
    6894  } 
    6995 
     
    7298   * Always call this function after failed operations on a workflow object to obtain messages 
    7399   * 
    74    * @param bool $as_array if true the result will be send as an array of errors or an empty array. Else, if you do not give any parameter  
     100   * @param bool $as_array if true the result will be send as an array of errors or an empty array. Else, if you do not give any parameter 
    75101   * or give a false parameter you will obtain a single string which can be empty or will contain error messages with <br /> html tags 
    76102   * @param bool $debug is false by default, if true you wil obtain more messages 
    77103   * @param string $prefix string appended to the debug message 
    78104   * @return mixed Error and debug messages or an array of theses messages and empty the error messages 
    79    * @access public   
     105   * @access public 
    80106   */ 
    81   function get_error($as_array=false, $debug=false, $prefix='')  
     107  function get_error($as_array=false, $debug=false, $prefix='') 
    82108  { 
    83109    //collect errors from used objects 
     
    96122  /** 
    97123   * Gets warnings recorded by this object 
    98    *  
    99    * @param bool $as_array if true the result will be send as an array of warnings or an empty array. Else, if you do not give any parameter  
     124   * 
     125   * @param bool $as_array if true the result will be send as an array of warnings or an empty array. Else, if you do not give any parameter 
    100126   * or give a false parameter you will obtain a single string which can be empty or will contain warning messages with <br /> html tags 
    101127   * @return mixed Warning messages or an array of theses messages and empty the warning messages 
    102    * @access public   
     128   * @access public 
    103129   */ 
    104   function get_warning($as_array=false)  
     130  function get_warning($as_array=false) 
    105131  { 
    106132    if ($as_array) 
     
    118144   * Collect errors from all linked objects which could have been used by this object 
    119145   * Each child class should instantiate this function with her linked objetcs, calling get_error(true) 
    120    *  
     146   * 
    121147   * @param bool $debug is false by default, if true debug messages can be added to 'normal' messages 
    122148   * @param string $prefix is a string appended to the debug message 
    123149   * @abstract 
    124150   * @access public 
    125    * @return void  
     151   * @return void 
    126152   */ 
    127153  function collect_errors($debug=false, $prefix = '') 
     
    134160        } 
    135161  } 
    136          
     162 
    137163        /** 
    138164         * Performs a query on the AdoDB database object 
    139          *  
     165         * 
    140166         * @param string $query sql query, parameters should be replaced with ? 
    141167         * @param array $values array containing the parameters (going in the ?), use it to avoid security problems. If 
     
    196222 
    197223        /** 
    198          * @see Base::query  
     224         * @see Base::query 
    199225         * @param string $query sql query, parameters should be replaced with ? 
    200226     * @param array $values array containing the parameters (going in the ?), use it to avoid security problems 
     
    224250                if (!$result && $reporterrors ) 
    225251                        $this->sql_error($query, $clean_values, $result); 
    226                 if (!!$result)  
     252                if (!!$result) 
    227253                { 
    228254                        $res = $result->fetchRow(); 
     
    241267        /** 
    242268         * Throws error warnings 
    243          *  
     269         * 
    244270         * @param string $query 
    245271         * @param array $values 
    246272         * @param mixed $result 
    247273         * @access public 
    248          * @return void  
     274         * @return void 
    249275         */ 
    250276        function sql_error($query, $values, $result) { 
     
    252278                // DO NOT DIE, if transactions are there, they will do things in a better way 
    253279        } 
    254          
     280 
    255281        /** 
    256282         * Clean the data before it is recorded on the database 
    257          *  
     283         * 
    258284         * @param $value is a data we want to be stored in the database. 
    259          * If it is an array we'll make a serialize and then an base64_encode  
     285         * If it is an array we'll make a serialize and then an base64_encode 
    260286         * (you'll have to make an unserialize(base64_decode()) 
    261287         * If it is not an array we make an htmlspecialchars() on it 
     
    292318        /** 
    293319         * Supports DB abstraction 
    294          *  
     320         * 
    295321         * @param string &$query 
    296          * @return void  
     322         * @return void 
    297323         * @access public 
    298324         */ 
     
    302328                case "oci8": 
    303329                        $query = preg_replace("/`/", "\"", $query); 
    304                         // convert bind variables - adodb does not do that  
     330                        // convert bind variables - adodb does not do that 
    305331                        $qe = explode("?", $query); 
    306332                        $query = ''; 
     
    318344        /** 
    319345         * Supports DB abstraction 
    320          *  
     346         * 
    321347         * @param string $sort_mode 
    322          * @return string  
     348         * @return string 
    323349         * @access public 
    324350         */ 
     
    330356        /** 
    331357         * Supports DB abstraction 
    332          *  
    333          * @return mixed  
     358         * 
     359         * @return mixed 
    334360         * @access public 
    335361         */ 
  • branches/2.2/workflow/inc/engine/src/common/WfRuntime.php

    r795 r3167  
    8686   * @access public 
    8787   */ 
    88   function WfRuntime(&$db)  
     88  function WfRuntime()  
    8989  { 
    9090    $this->child_name = 'WfRuntime'; 
    91     parent::Base($db); 
    92     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'BaseActivity.php'); 
    93     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Process.php'); 
    94     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Instance.php'); 
    95     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'common'.SEP.'WfSecurity.php'); 
    96      
     91    parent::Base(); 
     92 
    9793    //first the activity is not set 
    9894    $this->activity = null; 
    99     $this->instance = new Instance($this->db); 
    100     $this->process = new Process($this->db); 
    101     $this->security = new WfSecurity($this->db);  
     95    $this->instance = &Factory::newInstance('Instance'); 
     96    $this->process = &Factory::newInstance('Process'); 
     97    $this->security = &Factory::getInstance('WfSecurity'); 
    10298  } 
    10399 
     
    276272      return false; 
    277273    } 
    278     $base_activity = new BaseActivity($this->db); 
     274    $base_activity = &Factory::newInstance('BaseActivity'); 
    279275    $this->activity =& $base_activity->getActivity($activity_id, $with_roles, $with_agents); 
    280276    if (!$this->activity) 
     
    10911087    $workflow = $GLOBALS['workflow']; 
    10921088    unset($_REQUEST['iid']); 
    1093     $run_activity = CreateObject('workflow.run_activity'); 
     1089    $run_activity = Factory::newInstance('run_activity'); 
    10941090    $run_activity->runtime->instance->parentInstanceId = $this->instance_id; 
    1095     $run_activity->runtime->instance->parentActivityId = $this->activity_id; 
    10961091    $output = $run_activity->goChildInstance($activityID, $properties, $user, $parentLock); 
    10971092    $_REQUEST['iid'] = $iid; 
     
    11321127  function getParent() 
    11331128  { 
    1134     $resultSet = $this->query("SELECT wf_parent_instance_id, wf_parent_activity_id, wf_parent_lock FROM egw_wf_interinstance_relations WHERE (wf_child_instance_id = ?)", array($this->getInstanceId())); 
     1129    $resultSet = $this->query("SELECT wf_parent_instance_id, wf_parent_lock FROM egw_wf_interinstance_relations WHERE (wf_child_instance_id = ?)", array($this->getInstanceId())); 
    11351130    if (($row = $resultSet->fetchRow())) 
    1136       return array('instance_id' => $row['wf_parent_instance_id'], 'activity_id' => $row['wf_parent_activity_id'], 'lock' => ($row['wf_parent_lock'] == 1)); 
     1131      return array('instance_id' => $row['wf_parent_instance_id'], 'lock' => ($row['wf_parent_lock'] == 1)); 
    11371132    else 
    11381133      return false; 
  • branches/2.2/workflow/inc/engine/src/common/WfSecurity.php

    r795 r3167  
    2323   * @access public 
    2424   */ 
    25   function WfSecurity(&$db)  
     25  function WfSecurity()  
    2626  { 
    2727    $this->child_name = 'WfSecurity'; 
    28     parent::Base($db); 
    29     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Instance.php'); 
    30     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Process.php'); 
    31     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'BaseActivity.php'); 
     28    parent::Base(); 
    3229  } 
    3330 
     
    5855      ); 
    5956      //check theses values for this process and store the result for this object life duration 
    60       $myProcess = new Process($this->db); 
     57      $myProcess = &Factory::newInstance('Process'); 
    6158      $myProcess->getProcess($pId); 
    6259      $this->processesConfig[$pId] = $myProcess->getConfigValues($arrayConf); 
     
    7875  function checkUserAccess($user, $activity_id, $readonly=false)  
    7976  { 
     77        /* if activity is non-interactive is not necessary checking user access */ 
     78        $activity = &Factory::getInstance('BaseActivity')->getActivity($activity_id); 
     79        if (!$activity->isInteractive()) 
     80                return true; 
     81 
    8082    //group mapping, warning groups and user can have the same id 
    8183    if ($user[0] != 'p') 
     
    577579      if (!(isset($this->pm))) 
    578580      { 
    579         require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'ProcessManager'.SEP.'ProcessManager.php'); 
    580         $this->pm = new ProcessManager($this->db); 
     581        $this->pm = &Factory::newInstance('ProcessManager'); 
    581582      } 
    582583      //$this->error[] = 'DEBUG: checking to see if there is no view activities on process :'.$pId.':'.$this->pm->get_process_view_activity($pId); 
  • branches/2.2/workflow/inc/hook_home.inc.php

    r795 r3167  
    11<?php 
     2require_once 'common.inc.php'; 
     3 
    24$GLOBALS['phpgw_info']['flags']['currentapp'] = "workflow"; 
    35if (!isset($_SESSION['phpgw_info']['workflow']['server'])) 
     
    2224 
    2325$title = lang("External Applications"); 
    24 $bo     = CreateObject('workflow.bo_userinterface'); 
     26$bo     = Factory::getInstance('bo_userinterface'); 
    2527$externals      = $bo -> externals(); 
    2628$extra_data = ''; 
     
    4244} 
    4345$extra_data .= "</table></div>"; 
    44 $portalbox = CreateObject('phpgwapi.listbox', 
     46$portalbox = Factory::getInstance('listbox', 
    4547        Array( 
    4648                'title'     => $title, 
  • branches/2.2/workflow/inc/hook_sidebox_menu.inc.php

    r795 r3167  
    1414 */ 
    1515 
     16require_once 'common.inc.php'; 
    1617require_once 'engine/config.egw.inc.php'; 
    1718 
    1819{ 
    19         $workflowACL = CreateObject('workflow.workflow_acl'); 
     20        $workflowACL = Factory::getInstance('workflow_acl'); 
    2021        $userID = $GLOBALS['phpgw_info']['user']['account_id']; 
    2122        $apptitle = $GLOBALS['phpgw_info']['apps'][$appname]['title']; 
  • branches/2.2/workflow/inc/local/classes/class.JobBase.php

    r1437 r3167  
    8989        { 
    9090                require_once 'common.inc.php'; 
    91                 $GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareEnvironment(); 
     91                Factory::getInstance('WorkflowMacro')->prepareEnvironment(); 
    9292                $this->jobID = $jobID; 
    9393                $this->processID = $processID; 
    9494                $this->currentDate = $currentDate; 
    95                 $this->jobManager = &$GLOBALS['workflow']['factory']->getInstance('WorkflowJobManager'); 
     95                $this->jobManager = Factory::getInstance('WorkflowJobManager'); 
    9696                $this->testMode = $testMode; 
    9797                $this->maximumExecutionTime = $maximumExecutionTime; 
     
    148148        final private function prepareEnvironment() 
    149149        { 
    150                 $GLOBALS['workflow']['factory']->getInstance('WorkflowMacro')->prepareProcessEnvironment($this->processID); 
    151  
    152                 require_once PHPGW_SERVER_ROOT . '/workflow/inc/class.process_factory.inc.php'; 
     150                Factory::getInstance('WorkflowMacro')->prepareProcessEnvironment($this->processID); 
    153151 
    154152                $this->environment = array(); 
    155                 $this->environment['factory']  = &new ProcessFactory(); 
     153                $this->environment['factory']  = &Factory::newInstance('ProcessWrapperFactory'); 
    156154        } 
    157155 
     
    202200        final public function createNewInstance($startActivityId, $instanceName=false, $properties=false, $user=false) 
    203201        { 
    204                 $activityManager = CreateObject('workflow.workflow_activitymanager'); 
     202                $activityManager = Factory::getInstance('workflow_activitymanager'); 
    205203                $activity = $activityManager->get_activity($startActivityId); 
    206204 
  • branches/2.2/workflow/inc/local/classes/class.wf_engine.php

    r795 r3167  
    6868                $flagObject[0] = is_null($this->processManager); 
    6969                if ($flagObject[0]) 
    70                         $this->processManager = CreateObject('workflow.workflow_processmanager'); 
     70                        $this->processManager = Factory::getInstance('workflow_processmanager'); 
    7171 
    7272                $output = array(); 
     
    8686        * @return bool true caso a instância tenha sido continuada e false caso contrário. 
    8787        * @access public 
    88         * @deprecated 1.7.00.000 
     88        * @deprecated 2.2.00.000 
    8989        */ 
    9090        function continueInstance($activityID, $instanceID) 
    9191        { 
    92                 require_once 'class.wf_instance.php'; 
    93                 $WFInstance = new wf_instance(); 
     92                wf_warn_deprecated_method('wf_instance', 'continueInstance'); 
     93                $WFInstance = &Factory::getInstance('wf_instance'); 
    9494                return $WFInstance->continueInstance($activityID, $instanceID); 
    9595        } 
     
    100100        * @return boolean true se foi possível abortar a instância e false caso contrário. 
    101101        * @access public 
    102         * @deprecated 1.7.00.000 
     102        * @deprecated 2.2.00.000 
    103103        */ 
    104104        function abortInstance($instanceID) 
    105105        { 
    106                 require_once 'class.wf_instance.php'; 
    107                 $WFInstance = new wf_instance(); 
     106                wf_warn_deprecated_method('wf_instance', 'abort'); 
     107                $WFInstance = &Factory::getInstance('wf_instance'); 
    108108                return $WFInstance->abort($instanceID); 
    109109        } 
     
    115115        * @return boolean true se foi possível mudar o nome da instância e false caso contrário. 
    116116        * @access public 
    117         * @deprecated 1.7.00.000 
     117        * @deprecated 2.2.00.000 
    118118        */ 
    119119        function setInstanceName($instanceID, $name) 
    120120        { 
    121                 require_once 'class.wf_instance.php'; 
    122                 $WFInstance = new wf_instance(); 
     121                wf_warn_deprecated_method('wf_instance', 'setName'); 
     122                $WFInstance = &Factory::getInstance('wf_instance'); 
    123123                return $WFInstance->setName($instanceID, $name); 
    124124        } 
     
    130130        * @return boolean true se foi possível mudar a prioridade da instância e false caso contrário. 
    131131        * @access public 
    132         * @deprecated 1.7.00.000 
     132        * @deprecated 2.2.00.000 
    133133        */ 
    134134        function setInstancePriority($instanceID, $priority) 
    135135        { 
    136                 require_once 'class.wf_instance.php'; 
    137                 $WFInstance = new wf_instance(); 
     136                wf_warn_deprecated_method('wf_instance', 'setPriority'); 
     137                $WFInstance = &Factory::getInstance('wf_instance'); 
    138138                return $WFInstance->setPriority($instanceID, $priority); 
    139139        } 
     
    145145        * @return array As instâncias que satisfazem o critério de seleção. 
    146146        * @access public 
    147         * @deprecated 1.7.00.000 
     147        * @deprecated 2.2.00.000 
    148148        */ 
    149149        function getIdleInstances($numberOfDays, $activities = null) 
    150150        { 
    151                 require_once 'class.wf_instance.php'; 
    152                 $WFInstance = new wf_instance(); 
     151                wf_warn_deprecated_method('wf_instance', 'getIdle'); 
     152                $WFInstance = &Factory::getInstance('wf_instance'); 
    153153                return $WFInstance->getIdle($numberOfDays, $activities); 
    154154        } 
     
    159159        * @return array As instâncias que satisfazem o critério de seleção. 
    160160        * @access public 
    161         * @deprecated 1.7.00.000 
     161        * @deprecated 2.2.00.000 
    162162        */ 
    163163        function getInstances($activities = null) 
    164164        { 
     165                wf_warn_deprecated_method('wf_instance', 'getIdle'); 
    165166                return $this->getIdleInstances(0, $activities); 
    166167        } 
     
    171172        * @return array As instâncias que satisfazem o critério de seleção. 
    172173        * @access public 
    173         * @deprecated 1.7.00.000 
     174        * @deprecated 2.2.00.000 
    174175        */ 
    175176        function getInstancesByName($name) 
    176177        { 
    177                 require_once 'class.wf_instance.php'; 
    178                 $WFInstance = new wf_instance(); 
     178                wf_warn_deprecated_method('wf_instance', 'getByName'); 
     179                $WFInstance = &Factory::getInstance('wf_instance'); 
    179180                $preOutput = $WFInstance->getByName($name); 
    180181                $output = array(); 
     
    193194        * @return array As instâncias filhas do par instância/atividade atual 
    194195        * @access public 
    195         * @deprecated 1.7.00.000 
     196        * @deprecated 2.2.00.000 
    196197        */ 
    197198        function getChildInstances($instanceID = null, $activityID = null) 
    198199        { 
    199                 require_once 'class.wf_instance.php'; 
    200                 $WFInstance = new wf_instance(); 
    201                 $preOutput = $WFInstance->getChildren($instanceID, $activityID); 
     200                wf_warn_deprecated_method('wf_instance', 'getChildren'); 
     201                $WFInstance = &Factory::getInstance('wf_instance'); 
     202                $preOutput = $WFInstance->getChildren($instanceID); 
    202203                $output = array(); 
    203204                foreach ($preOutput as $childInstance) 
     
    213214        * @return mixed Uma array contento as propriedades da instância (no formato "nome_da_propriedade" => "valor"). Ou false em caso de erro. 
    214215        * @access public 
    215         * @deprecated 1.7.00.000 
     216        * @deprecated 2.2.00.000 
    216217        */ 
    217218        function getInstanceProperties($instanceID) 
    218219        { 
    219                 require_once 'class.wf_instance.php'; 
    220                 $WFInstance = new wf_instance(); 
     220                wf_warn_deprecated_method('wf_instance', 'getProperties'); 
     221                $WFInstance = &Factory::getInstance('wf_instance'); 
    221222                return $WFInstance->getProperties($instanceID); 
    222223        } 
     
    227228        * @return array Propriedades da instância filha. Array no formato "nome_da_propriedade" => "valor". 
    228229        * @access public 
    229         * @deprecated 1.7.00.000 
     230        * @deprecated 2.2.00.000 
    230231        */ 
    231232        function getChildInstanceProperties($instanceID) 
    232233        { 
    233                 require_once 'class.wf_instance.php'; 
    234                 $WFInstance = new wf_instance(); 
     234                wf_warn_deprecated_method('wf_instance', 'getProperties'); 
     235                $WFInstance = &Factory::getInstance('wf_instance'); 
    235236                return $WFInstance->getProperties($instanceID); 
    236237        } 
     
    247248                $flagObject[0] = is_null($this->acl); 
    248249                if ($flagObject[0]) 
    249                         $this->acl = CreateObject('workflow.workflow_acl'); 
     250                        $this->acl = Factory::getInstance('workflow_acl'); 
    250251 
    251252                $output = $this->acl->getUserPermissions($type, $uid); 
     
    268269                $flagObject[0] = is_null($this->acl); 
    269270                if ($flagObject[0]) 
    270                         $this->acl = CreateObject('workflow.workflow_acl'); 
     271                        $this->acl = Factory::getInstance('workflow_acl'); 
    271272 
    272273                $output = $this->acl->getUserGroupPermissions($type, $uid); 
     
    291292                /* build the SQL query */ 
    292293                $query = "SELECT wf_activity_id, wf_name, wf_normalized_name, wf_type, wf_description FROM egw_wf_activities WHERE (wf_activity_id = ?) AND (wf_p_id = ?)"; 
    293                 $db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID; 
     294                $db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 
    294295                $resultSet = $db->query($query, array($activityID, $processID)); 
    295296 
     
    319320                /* build the SQL query */ 
    320321                $query = "SELECT wf_activity_id, wf_name, wf_normalized_name, wf_type, wf_description FROM egw_wf_activities WHERE (wf_name = ?) AND (wf_p_id = ?)"; 
    321                 $db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID; 
     322                $db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 
    322323                $resultSet = $db->query($query, array($activityName, $processID)); 
    323324 
     
    342343        * @return array As instâncias que satisfazem o critério de seleção. 
    343344        * @access public 
    344         * @deprecated 1.7.00.000 
     345        * @deprecated 2.2.00.000 
    345346        */ 
    346347        function getUserInstances($users, $activities = null, $status = null) 
    347348        { 
    348                 require_once 'class.wf_instance.php'; 
    349                 $WFInstance = new wf_instance(); 
     349                wf_warn_deprecated_method('wf_instance', 'getByUser'); 
     350                $WFInstance = &Factory::getInstance('wf_instance'); 
    350351                return $WFInstance->getByUser($users, $activities, $status); 
    351352        } 
     
    356357        * @return bool true caso a propriedade tenha sido alterada com sucesso 
    357358        * @access public 
    358         * @deprecated 1.7.00.000 
     359        * @deprecated 2.2.00.000 
    359360        */ 
    360361        function setInstanceProperty($instanceID, $nameProperty, $value) 
    361362        { 
    362                 require_once 'class.wf_instance.php'; 
    363                 $WFInstance = new wf_instance(); 
     363                wf_warn_deprecated_method('wf_instance', 'setProperty'); 
     364                $WFInstance = &Factory::getInstance('wf_instance'); 
    364365                return $WFInstance->setProperty($instanceID, $nameProperty, $value); 
    365366        } 
     
    373374        * @return bool true se o usuário tiver acesso à instância (levando em consideração $writeAccess) ou false caso contrário 
    374375        * @access public 
    375         * @deprecated 1.7.00.000 
     376        * @deprecated 2.2.00.000 
    376377        */ 
    377378        function checkUserAccessToInstance($userID, $instanceID, $activityID, $writeAccess = true) 
    378379        { 
    379                 require_once 'class.wf_instance.php'; 
    380                 $WFInstance = new wf_instance(); 
     380                wf_warn_deprecated_method('wf_instance', 'checkUserAccess'); 
     381                $WFInstance = &Factory::getInstance('wf_instance'); 
    381382                return $WFInstance->checkUserAccess($userID, $instanceID, $activityID, $writeAccess); 
    382383        } 
  • branches/2.2/workflow/inc/local/classes/class.wf_instance.php

    r1385 r3167  
    7777        { 
    7878                $instanceID = (int) $instanceID; 
    79                 $instance = CreateObject('workflow.workflow_instance'); 
     79                $instance = Factory::getInstance('workflow_instance'); 
    8080                if (!$instance->getInstance($instanceID)) 
    8181                        return false; 
     
    9292        { 
    9393                /* load the DB */ 
    94                 $this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID; 
     94                $this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 
    9595 
    9696                /* load the process ID from the runtime */ 
     
    118118                $instance = $this->getInstanceObject($instanceID); 
    119119 
    120                 $runActivity = CreateObject('workflow.run_activity'); 
     120                $runActivity = Factory::getInstance('run_activity'); 
    121121 
    122122                ob_start(); 
     
    250250 
    251251        /** 
    252         * Busca as instâncias filhas de uma instância 
    253         * Se os parâmetros não forem informados, retorna instâncias filhas das instância atual. 
    254         * @param int $instanceID O ID da instância pai (não obrigatório). 
    255         * @param int $activityID O ID da atividade corrente da instância pai 
    256         * @return array As instâncias filhas do par instância/atividade atual 
    257         * @access public 
    258         */ 
    259         public function getChildren($instanceID = null, $activityID = null) 
     252        * This method gets all children instances of the given instance. 
     253        * If there is no parameter, it gets the children instances of the current instance 
     254        * @param int $instanceID Dad instance's identification. 
     255        * @return array Array with the children instances, or false 
     256        * @access public 
     257        */ 
     258        public function getChildren($instanceID = null) 
    260259        { 
    261260                $output = array(); 
    262261                if (is_null($instanceID)) 
    263262                        $instanceID = $GLOBALS['workflow']['wf_runtime']->instance_id; 
    264                 if (is_null($activityID)) 
    265                         $activityID = $GLOBALS['workflow']['wf_runtime']->activity_id; 
    266  
    267                 /* check instanceID */ 
    268                 if (!$this->checkInstanceAccess($instanceID, $activityID)) 
     263 
     264                /* check instanceID */ 
     265                if (!$this->checkInstanceAccess($instanceID)) 
    269266                        return $output; 
    270267 
    271268                /* build the SQL query */ 
    272                 $query = 'SELECT i.wf_instance_id AS wf_instance_id, ia.wf_activity_id AS wf_activity_id, ia.wf_started AS wf_started, i.wf_name AS wf_name, i.wf_status AS wf_status, ia.wf_user AS wf_user, ir.wf_parent_lock AS wf_parent_lock '; 
    273                 $query .= 'FROM egw_wf_interinstance_relations ir, egw_wf_instances i LEFT JOIN egw_wf_instance_activities ia ON (ia.wf_instance_id = i.wf_instance_id)'; 
    274                 $query .= 'WHERE (ir.wf_child_instance_id = i.wf_instance_id) AND (ir.wf_parent_instance_id = ?) AND (ir.wf_parent_activity_id = ?)'; 
    275  
    276                 $result = $this->db->query($query, array($instanceID, $activityID)); 
     269                $query = " 
     270                        SELECT 
     271                                i.wf_instance_id AS wf_instance_id, 
     272                                ia.wf_activity_id AS wf_activity_id, 
     273                                i.wf_started AS wf_started, 
     274                                i.wf_name AS wf_name, 
     275                                i.wf_status AS wf_status, 
     276                                ia.wf_user AS wf_user, 
     277                                ir.wf_parent_lock AS wf_parent_lock 
     278                        FROM 
     279                            egw_wf_interinstance_relations as ir 
     280                        LEFT JOIN 
     281                            egw_wf_instances as i 
     282                        ON 
     283                            i.wf_instance_id = ir.wf_child_instance_id 
     284                        LEFT JOIN 
     285                            egw_wf_instance_activities as ia 
     286                        ON 
     287                            i.wf_instance_id = ia.wf_instance_id 
     288                        WHERE 
     289                            ir.wf_parent_instance_id = ?"; 
     290 
     291                $result = $this->db->query($query, array($instanceID)); 
    277292                $output = $result->GetArray(-1); 
    278293 
     
    423438 
    424439                /* load the required instance (for the required user) */ 
    425                 require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'GUI' . SEP . 'GUI.php'; 
    426                 $GUI = new GUI($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID); 
     440                $GUI = &Factory::newInstance('GUI'); 
    427441                $userInstance = $GUI->gui_list_user_instances($userID, 0, -1, '', '', "(ga.wf_is_interactive = 'y') AND (gia.wf_activity_id = {$activityID}) AND (gia.wf_instance_id = {$instanceID})", false, $this->processID, true, false, true, false, false, false); 
    428442                $userInstance = $userInstance['data']; 
     
    456470                if ($userID !== '*') 
    457471                { 
    458                         require_once dirname(__FILE__) . '/class.wf_role.php'; 
    459                         require_once dirname(__FILE__) . '/class.wf_engine.php'; 
    460  
    461                         $wfRole = new wf_role(); 
    462                         $engine = new wf_engine(); 
     472                        $wfRole = Factory::getInstance('wf_role'); 
     473                        $engine = Factory::getInstance('wf_engine'); 
    463474                        /* get information about the activity */ 
    464475                        if (($activityInfo = $engine->getActivityInformationByID($activityID)) === false) 
     
    529540 
    530541                /* try to get the role id */ 
    531                 require_once dirname(__FILE__) . '/class.wf_role.php'; 
    532                 $wfRole = new wf_role(); 
     542                $wfRole = Factory::getInstance('wf_role'); 
    533543                if (($roleID = $wfRole->getRoleIdByName($roleName)) === false) 
    534544                        return false; 
  • branches/2.2/workflow/inc/local/classes/class.wf_ldap.php

    r1067 r3167  
    11<?php 
    2 require_once PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'local' . SEP . 'classes' . SEP . 'class.wf_cached_ldap.php'; 
    32 
    43/** 
     
    4140        function wf_ldap() 
    4241        { 
    43                 $tmpLDAP = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     42                $tmpLDAP = Factory::getInstance('WorkflowLDAP'); 
    4443                $this->user_context  = $tmpLDAP->getUserContext(); 
    4544                $this->group_context = $tmpLDAP->getGroupContext(); 
    4645 
    47                 $this->ds = &$GLOBALS['workflow']['workflowObjects']->getLDAP(); 
     46                $this->ds = &Factory::getInstance('WorkflowObjects')->getLDAP(); 
    4847 
    49                 $this->cachedLDAP = new wf_cached_ldap(); 
     48                $this->cachedLDAP = &Factory::getInstance('wf_cached_ldap'); 
    5049                $this->cachedLDAP->setOperationMode($this->cachedLDAP->OPERATION_MODE_LDAP); 
    5150        } 
  • branches/2.2/workflow/inc/local/classes/class.wf_location.php

    r795 r3167  
    3636        function initialize() 
    3737        { 
    38                 $this->db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID; 
     38                $this->db = &Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID; 
    3939                $this->db->setFetchMode(ADODB_FETCH_ASSOC); 
    4040                $this->cityInfo = array(); 
     
    6767                if (isset($this->cityInfo[$city_id])) 
    6868                        return $this->cityInfo[$city_id]; 
     69 
     70                $sql = 
     71                "SELECT 
     72                        c.id_city AS id_city, 
     73                        c.city_name AS city_name, 
     74                        c.is_district, 
     75                        s.id_state AS id_state, 
     76                        s.state_name AS state_name, 
     77                        s.state_symbol AS state_symbol 
     78                FROM 
     79                        phpgw_cc_state s, 
     80                        phpgw_cc_city c 
     81                WHERE 
     82                        c.id_state = s.id_state AND 
     83                        s.id_country = 'BR' AND 
     84                        c.id_city = ?"; 
     85 
     86                $result = $this->db->query($sql, array($city_id)); 
     87                $output = $result->fetchRow(); 
     88 
     89                $this->cityInfo[$city_id] = $output; 
     90                return $output; 
     91        } 
     92 
     93   /** 
     94        * Busca as informações do estado pelo id passado 
     95        * @param int $state_id Numero ID do estado 
     96        * @return mixed (array ou boolean) 
     97        * @access public 
     98        */ 
     99        function getStateById($state_id) 
     100        { 
     101                if (!is_numeric($state_id)) 
     102                        return false; 
     103 
     104                $state_id = (int) $state_id; 
     105                if (isset($this->stateInfo[$state_id])) 
     106                        return $this->stateInfo[$state_id]; 
     107 
     108                $sql = 
     109                "SELECT 
     110                        id_state, 
     111                        state_name, 
     112                        state_symbol 
     113                FROM 
     114                        phpgw_cc_state 
     115                WHERE 
     116                        id_country = 'BR' AND 
     117                        id_state = ?"; 
     118 
     119                $result = $this->db->query($sql, array($state_id)); 
     120                $output = $result->fetchRow(); 
     121 
     122                $this->stateInfo[$city_id] = $output; 
     123                return $output; 
     124        } 
     125    /** 
     126         * Busca as cidades de um estado 
     127         * @param int $state_id Numero ID do estado 
     128         * @param bool $include_districts True, busca cidades e distritos. False, busca apenas cidades. 
     129         * @return mixed (array ou boolean) 
     130         * @access public 
     131         */ 
     132        function getCitiesFromState($state_id, $include_districts = true) 
     133        { 
     134                if (!is_numeric($state_id) || !is_bool($include_districts)) 
     135                        return false; 
     136 
     137                $state_id = (int) $state_id; 
     138                if (isset($this->citiesFromState[$state_id])) 
     139                        return $this->citiesFromState[$state_id]; 
     140 
     141                $where = ""; 
     142                if(!$include_districts){ 
     143                        $where = " AND c.is_district = 'F' "; 
     144                } 
     145 
     146                $sql = 
     147                "SELECT 
     148                        c.id_city AS id_city, 
     149                        c.city_name AS city_name, 
     150                        c.is_district 
     151                FROM 
     152                        phpgw_cc_state s, 
     153                        phpgw_cc_city c 
     154                WHERE 
     155                        c.id_state = s.id_state AND 
     156                        s.id_country = 'BR' AND 
     157                        c.id_state = ? " . $where . " 
     158                ORDER BY 
     159                        city_name"; 
     160 
     161                $result = $this->db->query($sql, array($state_id)); 
     162                $output = array(); 
     163                while ($row = $result->fetchRow()) 
     164                        $output[] = $row; 
     165 
     166                $this->citiesFromState[$state_id] = $output; 
     167                return $output; 
     168        } 
     169    /** 
     170         * Busca as cidades por parte do nome, sem considerar maiúsculas e/ou minúsculas e nem acentuação (retorna 10 resultados) 
     171         * @param string Parte do nome da cidade 
     172         * @param int $state_id Numero ID do estado 
     173         * @param bool $include_districts True, busca cidades e distritos. False, busca apenas cidades. 
     174         * @return mixed (array ou boolean) 
     175         * @access public 
     176         */ 
     177        function getCitiesByKey($key, $state_id = 0, $include_districts = true) 
     178        { 
     179                if (!is_string($key) || !is_numeric($state_id) || !is_bool($include_districts)) 
     180                        return false; 
     181 
     182                $where = ""; 
     183                if($state_id > 0){ 
     184                        $where = " AND c.id_state = " . $state_id; 
     185                } 
     186 
     187                if(!$include_districts){ 
     188                        $where = " AND c.is_district = 'F' "; 
     189                } 
    69190 
    70191                $sql = 
     
    81202                        c.id_state = s.id_state AND 
    82203                        s.id_country = 'BR' AND 
    83                         c.id_city = ?"; 
    84  
    85                 $result = $this->db->query($sql, array($city_id)); 
    86                 $output = $result->fetchRow(); 
    87  
    88                 $this->cityInfo[$city_id] = $output; 
    89                 return $output; 
    90         } 
    91  
    92    /** 
    93         * Busca as informações do estado pelo id passado 
    94         * @param int $state_id Numero ID do estado 
    95         * @return mixed (array ou boolean) 
    96         * @access public 
    97         */ 
    98         function getStateById($state_id) 
    99         { 
    100                 if (!is_numeric($state_id)) 
    101                         return false; 
    102  
    103                 $state_id = (int) $state_id; 
    104                 if (isset($this->stateInfo[$state_id])) 
    105                         return $this->stateInfo[$state_id]; 
    106  
    107                 $sql = 
    108                 "SELECT 
    109                         id_state, 
    110                         state_name, 
    111                         state_symbol 
    112                 FROM 
    113                         phpgw_cc_state 
    114                 WHERE 
    115                         id_country = 'BR' AND 
    116                         id_state = ?"; 
    117  
    118                 $result = $this->db->query($sql, array($state_id)); 
    119                 $output = $result->fetchRow(); 
    120  
    121                 $this->stateInfo[$city_id] = $output; 
    122                 return $output; 
    123         } 
    124     /** 
    125          * Busca as cidades de um estado 
    126          * @param int $state_id Numero ID do estado 
    127          * @return mixed (array ou boolean) 
    128          * @access public 
    129          */ 
    130         function getCitiesFromState($state_id) 
    131         { 
    132                 if (!is_numeric($state_id)) 
    133                         return false; 
    134  
    135                 $state_id = (int) $state_id; 
    136                 if (isset($this->citiesFromState[$state_id])) 
    137                         return $this->citiesFromState[$state_id]; 
    138  
    139                 $sql = 
    140                 "SELECT 
    141                         c.id_city AS id_city, 
    142                         c.city_name AS city_name 
    143                 FROM 
    144                         phpgw_cc_state s, 
    145                         phpgw_cc_city c 
    146                 WHERE 
    147                         c.id_state = s.id_state AND 
    148                         s.id_country = 'BR' AND 
    149                         c.id_state = ? 
     204                        TO_ASCII(c.city_name) ILIKE TO_ASCII('" . $key . "%') 
     205                        " . $where . " 
    150206                ORDER BY 
    151                         city_name"; 
    152  
    153                 $result = $this->db->query($sql, array($state_id)); 
    154                 $output = array(); 
    155                 while ($row = $result->fetchRow()) 
    156                         $output[] = $row; 
    157  
    158                 $this->citiesFromState[$state_id] = $output; 
    159                 return $output; 
    160         } 
    161     /** 
    162          * Busca os estados brasileiros 
    163          * @return mixed (array ou boolean) 
    164          * @access public 
    165          */ 
    166         function getStates() 
    167         { 
    168                 $sql = 
    169                 "SELECT 
    170                         id_state, 
    171                         state_name 
    172                 FROM 
    173                         phpgw_cc_state 
    174                 WHERE 
    175                         id_country = 'BR' 
    176                 ORDER BY 
    177                         state_name"; 
     207                        city_name 
     208                LIMIT 10"; 
    178209 
    179210                $result = $this->db->query($sql); 
     
    184215                return $output; 
    185216        } 
     217        /** 
     218         * Busca os estados brasileiros 
     219         * @return mixed (array ou boolean) 
     220         * @access public 
     221         */ 
     222        function getStates() 
     223        { 
     224                $sql = 
     225                "SELECT 
     226                        id_state, 
     227                        state_name 
     228                FROM 
     229                        phpgw_cc_state 
     230                WHERE 
     231                        id_country = 'BR' 
     232                ORDER BY 
     233                        state_name"; 
     234 
     235                $result = $this->db->query($sql); 
     236                $output = array(); 
     237                while ($row = $result->fetchRow()) 
     238                        $output[] = $row; 
     239 
     240                return $output; 
     241        } 
    186242} 
    187243?> 
  • branches/2.2/workflow/inc/local/classes/class.wf_mail.php

    r795 r3167  
    3939                $requiredConfiguration = array('mail_smtp_profile' => false); 
    4040                $configuration = $GLOBALS['workflow']['wf_runtime']->process->getConfigValues($requiredConfiguration); 
    41                 $bo_emailadmin = CreateObject('emailadmin.bo'); 
     41                $bo_emailadmin = Factory::getInstance('bo'); 
    4242                $profileData = $bo_emailadmin->getProfile($configuration['mail_smtp_profile']); 
    4343 
  • branches/2.2/workflow/inc/local/classes/class.wf_natural.php

    r795 r3167  
    11<?php 
    2         require_once(PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'inc'.SEP.'natural'.SEP.'class.natural.php'); 
     2/**************************************************************************\ 
     3* eGroupWare                                                               * 
     4* http://www.egroupware.org                                                * 
     5* --------------------------------------------                             * 
     6*  This program is free software; you can redistribute it and/or modify it * 
     7*  under the terms of the GNU General Public License as published by the   * 
     8*  Free Software Foundation; either version 2 of the License, or (at your  * 
     9*  option) any later version.                                              * 
     10\**************************************************************************/ 
     11 
     12require_once(PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'inc'.SEP.'natural'.SEP.'class.natural.php'); 
     13 
     14/** 
     15 * Mainframe connection to workflow 
     16 * 
     17 * TODO - This class should be removed from here. Its based on a not 
     18 * public protocol, thus cannot be used for everybody. 
     19 * 
     20 * @package Workflow 
     21 * @subpackage local 
     22 * @license http://www.gnu.org/copyleft/gpl.html GPL 
     23 * @author Everton Flávio Rufino Seára 
     24 */ 
     25class wf_natural extends Natural 
     26{ 
    327 
    428        /** 
    5         * Mainframe connection to workflow 
    6         * @author Everton Flávio Rufino Seára 
    7         * @package Workflow 
    8         * @subpackage local 
    9         * @license http://www.gnu.org/copyleft/gpl.html GPL 
    10         **/ 
     29         * @var object Log Object 
     30         * @access private 
     31         */ 
     32        private $logger = null; 
    1133 
    12         class wf_natural extends Natural 
     34        function __construct() 
    1335        { 
     36                parent::Natural(); 
    1437 
    15                 function __construct() 
    16                 { 
    17                         parent::Natural(); 
     38                $natconf = array( 
     39                                        'mainframe_ip'                  => '', 
     40                                        'mainframe_port'                => '', 
     41                                        'mainframe_key'                 => '', 
     42                                        'mainframe_password'    => '', 
     43                                        'mainframe_environment' => '' 
     44                ); 
    1845 
    19                         $natconf = array( 
    20                                                 'mainframe_ip'                  => '', 
    21                                                 'mainframe_port'                => '', 
    22                                                 'mainframe_key'                 => '', 
    23                                                 'mainframe_password'    => '', 
    24                                                 'mainframe_environment' => '' 
    25                         ); 
     46                $nat_conf_values = &Factory::getInstance('workflow_wfruntime')->getConfigValues($natconf); 
    2647 
    27                         $nat_conf_values = $GLOBALS['workflow']['wf_runtime']->getConfigValues($natconf); 
     48                $this->setIPAddress($nat_conf_values['mainframe_ip']); 
     49                $this->setServerPort($nat_conf_values['mainframe_port']); 
     50                $this->setKey($nat_conf_values['mainframe_key']); 
     51                $this->setPassword($nat_conf_values['mainframe_password']); 
     52                $this->setApplication($nat_conf_values['mainframe_environment']); 
    2853 
    29                         $this->setIPAddress($nat_conf_values['mainframe_ip']); 
    30                         $this->setServerPort($nat_conf_values['mainframe_port']); 
    31                         $this->setKey($nat_conf_values['mainframe_key']); 
    32                         $this->setPassword($nat_conf_values['mainframe_password']); 
    33                         $this->setApplication($nat_conf_values['mainframe_environment']); 
     54                $this->logger = &Factory::getInstance('Logger', array('file')); 
     55        } 
     56 
     57        /** 
     58         * This method MUST be called before using execute method 
     59         * It specifies the natural sub-program to be accessed. 
     60         * 
     61         * @param Object $obj Object that specifies natural sub-program properties 
     62         * @return void 
     63         */ 
     64        public function configure($obj) 
     65        { 
     66                $this->obj = $obj; 
     67 
     68                $this->initialize($obj->name); 
     69 
     70                if ($obj->server != NULL){ 
     71                        $this->setIPAddress($obj->server); 
    3472                } 
    35  
    36                 /** 
    37                  * Method to configure the access to mainframe 
    38                  * This method MUST be called before using execute method, else 'false' will be returned 
    39                  * 
    40                  * Only the first and second param are mandatory. 
    41                  * 
    42                  * @param String $subProgram - Name of sub-program 
    43                  * @param String $inputParameter - Input parameters to sub-program 
    44                  * 
    45                  * @param String $ip - IP Address of Mainfram 
    46                  * @param int $port - ServerPort to access the mainframe 
    47                  * @param String $key - Access key (user) 
    48                  * @param String $password - Key (user) password 
    49                  * @param char $environment - Application environment access 'D' (development) or 'P' (production) 
    50  
    51                  */ 
    52  
    53                 public function configure($obj) 
    54                 { 
    55                         $this->obj = $obj; 
    56  
    57                         $this->initialize($obj->name); 
    58  
    59                         if ($obj->server != NULL){ 
    60                                 $this->setIPAddress($obj->server); 
    61                         } 
    62                         if ($obj->port != NULL){ 
    63                                 $this->setServerPort($obj->port); 
    64                         } 
    65                         if ($obj->key != NULL){ 
    66                                 $this->setKey($obj->key); 
    67                         } 
    68                         if ($obj->password != NULL){ 
    69                                 $this->setPassword($obj->password); 
    70                         } 
    71                         if ($obj->environment != NULL){ 
    72                                 $this->setApplication($obj->environment); 
    73                         } 
    74                         if ($obj->logon != NULL){ 
    75                                 $this->setLogon($obj->logon); 
    76                         } 
    77                         if ($obj->system != NULL){ 
    78                                 $this->setSystem($obj->system); 
    79                         } 
    80                         if ($obj->rc != NULL){ 
    81                                 $this->setRC($obj->rc); 
    82                         } 
     73                if ($obj->port != NULL){ 
     74                        $this->setServerPort($obj->port); 
    8375                } 
    84  
    85                 /* 
    86  
    87                 public function configure($subProgram, $inputParameter, $ip = NULL, $port = NULL, 
    88                                                                                 $key = NULL, $password = NULL, $environment = NULL, $logon = NULL, $system = NULL, $rc = NULL) 
    89                 { 
    90                         $this->initialize($subProgram, $inputParameter); 
    91  
    92                         if ($ip != NULL){ 
    93                                 $this->setIPAddress($ip); 
    94                         } 
    95                         if ($port != NULL){ 
    96                                 $this->setServerPort($port); 
    97                         } 
    98                         if ($key != NULL){ 
    99                                 $this->setKey($key); 
    100                         } 
    101                         if ($password != NULL){ 
    102                                 $this->setPassword($password); 
    103                         } 
    104                         if ($environment != NULL){ 
    105                                 $this->setApplication($environment); 
    106                         } 
    107                         if ($logon != NULL){ 
    108                                 $this->setLogon($logon); 
    109                         } 
    110                         if ($system != NULL){ 
    111                                 $this->setSystem($system); 
    112                         } 
    113                         if ($rc != NULL){ 
    114                                 $this->setRC($rc); 
    115                         } 
    116  
     76                if ($obj->key != NULL){ 
     77                        $this->setKey($obj->key); 
    11778                } 
    118  
    119                  */ 
    120  
    121                 /** 
    122                  * Access and retrieve data from mainframe 
    123                  * @return bool 
    124                  */ 
    125                 public function execute($inputParams = "") 
    126                 { 
    127                         return parent::execute($inputParams); 
     79                if ($obj->password != NULL){ 
     80                        $this->setPassword($obj->password); 
     81                } 
     82                if ($obj->environment != NULL){ 
     83                        $this->setApplication($obj->environment); 
     84                } 
     85                if ($obj->logon != NULL){ 
     86                        $this->setLogon($obj->logon); 
     87                } 
     88                if ($obj->system != NULL){ 
     89                        $this->setSystem($obj->system); 
     90                } 
     91                if ($obj->rc != NULL){ 
     92                        $this->setRC($obj->rc); 
    12893                } 
    12994        } 
     95 
     96        /** 
     97         * Method for accessing and retrieving data from mainframe 
     98         * @return bool 
     99         */ 
     100        public function execute($inputParams = "") 
     101        { 
     102                // execute action and log wasted time 
     103                $totalTime = microtime(true); 
     104                $result = parent::execute($inputParams); 
     105                $totalTime = microtime(time) - $totalTime; 
     106                $log = sprintf("WF_NATURAL [subprogram=%s] [time=%ss]", 
     107                                        $this->obj->name, 
     108                                        number_format($totalTime,3) 
     109                                        ); 
     110                $this->logger->debug($log); 
     111                return $result; 
     112        } 
     113} 
    130114?> 
  • branches/2.2/workflow/inc/local/classes/class.wf_orgchart.php

    r1320 r3167  
    2424        function wf_orgchart() 
    2525        { 
    26                 $this->db = &$GLOBALS['workflow']['workflowObjects']->getDBWorkflow()->Link_ID; 
     26                $this->db = &Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Link_ID; 
    2727                $this->db->setFetchMode(ADODB_FETCH_ASSOC); 
    2828        } 
     
    117117         * Este método irá buscar na tabela de áreas, todas as áreas que pertencem à organização solicitada. 
    118118         * @param int $organizationID O ID da organização. 
     119         * @param int $onlyActiveAreas false= recupera todas as áreas; true= recupera somente as áreas ativas. 
    119120         * @return array Uma array seqüencial contendo as áreas de uma organização. Cada linha do array conterá: 
    120121         * - organizacao_id 
     
    131132         * @access public 
    132133         */ 
    133         function getOrganizationAreas($organizationID) 
    134         { 
    135                 $query = "SELECT organizacao_id, area_id, area_status_id, " . 
    136                                  "       superior_area_id, centro_custo_id, titular_funcionario_id," . 
    137                                  "       substituto_funcionario_id, sigla, descricao, ativa, auxiliar_funcionario_id" . 
    138                                  "  FROM area" . 
    139                                  " WHERE (organizacao_id = ?)" . 
    140                                  " ORDER BY sigla, descricao"; 
     134        function getOrganizationAreas($organizationID, $onlyActiveAreas = false) 
     135        { 
     136                $query = "SELECT a.organizacao_id, a.area_id, a.area_status_id, " . 
     137                                 "       a.superior_area_id, a.centro_custo_id, a.titular_funcionario_id, " . 
     138                                 "       a.sigla, a.descricao, a.ativa, a.auxiliar_funcionario_id, " . 
     139                                 "               s.funcionario_id as substituto_funcionario_id " . 
     140                                 " FROM area a " . 
     141                                 "  LEFT OUTER JOIN substituicao s " . 
     142                                 "  ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) " . 
     143                                 " WHERE " . 
     144                                 "      (a.organizacao_id = ?) "; 
     145                // Se desejar somente retornar as áreas que estão ativas 
     146                if($onlyActiveAreas) 
     147                        $query .=" AND a.ativa = 'S' "; 
     148 
     149                $query .= " ORDER BY a.sigla, a.descricao"; 
    141150 
    142151                $result = $this->db->query($query, array($organizationID)); 
     
    320329        function getArea($areaID) 
    321330        { 
    322                 $query = "SELECT organizacao_id, area_id, area_status_id, " . 
    323                                  "       superior_area_id, centro_custo_id, titular_funcionario_id," . 
    324                                  "       substituto_funcionario_id, sigla, descricao, ativa, auxiliar_funcionario_id" . 
    325                                  "  FROM area" . 
    326                                  " WHERE (area_id = ?)"; 
     331                $query = "SELECT a.organizacao_id, a.area_id, a.area_status_id, " . 
     332                                 "       a.superior_area_id, a.centro_custo_id, a.titular_funcionario_id, " . 
     333                                 "       a.sigla, a.descricao, a.ativa, a.auxiliar_funcionario_id, " . 
     334                                 "               s.funcionario_id as substituto_funcionario_id " . 
     335                                 " FROM area a " . 
     336                                 "  LEFT OUTER JOIN substituicao s " . 
     337                                 "  ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) " . 
     338                                 " WHERE " . 
     339                                 "      (a.area_id = ?) " . 
     340                                 " ORDER BY a.sigla, a.descricao"; 
     341 
    327342 
    328343                $result = $this->db->query($query, array($areaID)); 
     
    357372        function getAreaByName($acronym, $organizationID = 1) 
    358373        { 
    359                 $query = "SELECT organizacao_id, area_id, area_status_id, " . 
    360                                  "       superior_area_id, centro_custo_id, titular_funcionario_id," . 
    361                                  "       substituto_funcionario_id, sigla, descricao, ativa, auxiliar_funcionario_id" . 
    362                                  "  FROM area" . 
    363                                  " WHERE (UPPER(sigla) = UPPER(?) and (organizacao_id = ?))"; 
     374                $query = "SELECT a.organizacao_id, a.area_id, a.area_status_id, " . 
     375                                 "       a.superior_area_id, a.centro_custo_id, a.titular_funcionario_id, " . 
     376                                 "       a.sigla, a.descricao, a.ativa, a.auxiliar_funcionario_id, " . 
     377                                 "               s.funcionario_id as substituto_funcionario_id " . 
     378                                 " FROM area a " . 
     379                                 "  LEFT OUTER JOIN substituicao s " . 
     380                                 "  ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) " . 
     381                                 " WHERE " . 
     382                                 "      (UPPER(a.sigla) = UPPER(?)) " . 
     383                                 " AND " . 
     384                                 "      (a.organizacao_id = ?) " . 
     385                                 " ORDER BY a.sigla, a.descricao"; 
     386 
    364387 
    365388                $result = $this->db->query($query, array($acronym, (int) $organizationID)); 
     
    395418                $result = array(); 
    396419 
    397                 $query = "SELECT organizacao_id, area_id, area_status_id, " . 
    398                                  "       superior_area_id, centro_custo_id, titular_funcionario_id," . 
    399                                  "       substituto_funcionario_id, sigla, descricao, ativa, auxiliar_funcionario_id" . 
    400                                  "  FROM area" . 
    401                                  " WHERE (area_status_id = ?)"; 
     420                $query = "SELECT a.organizacao_id, a.area_id, a.area_status_id, " . 
     421                                 "       a.superior_area_id, a.centro_custo_id, a.titular_funcionario_id, " . 
     422                                 "       a.sigla, a.descricao, a.ativa, a.auxiliar_funcionario_id, " . 
     423                                 "               s.funcionario_id as substituto_funcionario_id " . 
     424                                 " FROM area a " . 
     425                                 "  LEFT OUTER JOIN substituicao s " . 
     426                                 "  ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) " . 
     427                                 " WHERE " . 
     428                                 "      (a.area_status_id = ?) " . 
     429                                 " ORDER BY a.sigla, a.descricao"; 
     430 
     431 
    402432 
    403433                $result = $this->db->query($query, array($areaStatusID)); 
     
    436466                $areas = implode(', ', $areaIDs); 
    437467 
    438                 $query = "SELECT organizacao_id, area_id, area_status_id, " . 
    439                                  "       superior_area_id, centro_custo_id, titular_funcionario_id," . 
    440                                  "       substituto_funcionario_id, sigla, descricao, ativa, auxiliar_funcionario_id" . 
    441                                  "  FROM area" . 
    442                                  " WHERE area_id IN ($areas)" . 
    443                                  " ORDER BY sigla, descricao"; 
     468                $query = "SELECT a.organizacao_id, a.area_id, a.area_status_id, " . 
     469                                 "       a.superior_area_id, a.centro_custo_id, a.titular_funcionario_id, " . 
     470                                 "       a.sigla, a.descricao, a.ativa, a.auxiliar_funcionario_id, " . 
     471                                 "               s.funcionario_id as substituto_funcionario_id " . 
     472                                 " FROM area a " . 
     473                                 "  LEFT OUTER JOIN substituicao s " . 
     474                                 "  ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) " . 
     475                                 " WHERE " . 
     476                                 "      (a.area_id IN ($areas)) " . 
     477                                 " ORDER BY a.sigla, a.descricao"; 
    444478 
    445479                // A execução é realizada sem o segundo parâmetro pois este não pode estar entre aspas 
     
    448482                        return false; 
    449483 
     484                $output = $result->GetArray(-1); 
     485                return $output; 
     486        } 
     487         
     488        /** 
     489         * Return all areas that the employee is a supervisor. 
     490         *  
     491         * Search in the organization for all areas that the employee is a supervisor. 
     492         * @param int $employeeID The ID of employee 
     493         * @return array Array containing all the areas that the employeee is a supervisor. 
     494         * @access public 
     495         */ 
     496        function getSupervisorAreas($employeeID) { 
     497 
     498                if (!$employeeID) { 
     499                        return false; 
     500                } 
     501 
     502                $query = "SELECT  
     503                                                a.area_id 
     504                                        FROM  
     505                                                area a  
     506                                                LEFT OUTER JOIN substituicao s ON ((a.area_id = s.area_id)  
     507                                                AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim))  
     508                                        WHERE  
     509                                                a.titular_funcionario_id = ? OR  
     510                                                s.funcionario_id = ? 
     511                                        GROUP BY 
     512                                                a.area_id"; 
     513                 
     514                $result = $this->db->query($query, array($employeeID,$employeeID)); 
     515                if (!$result) 
     516                        return false; 
     517                 
    450518                $output = $result->GetArray(-1); 
    451519                return $output; 
     
    506574        function getSubAreasByParentAreaID($parentAreaID, $onlyActiveAreas = false) 
    507575        { 
    508                 $query = "SELECT organizacao_id, area_id, area_status_id, " . 
    509                                  "       superior_area_id, centro_custo_id, titular_funcionario_id," . 
    510                                  "       substituto_funcionario_id, sigla, descricao, ativa, auxiliar_funcionario_id" . 
    511                                  "  FROM area" . 
    512                                  " WHERE superior_area_id = ?"; 
     576                $query = "SELECT a.organizacao_id, a.area_id, a.area_status_id, " . 
     577                                 "       a.superior_area_id, a.centro_custo_id, a.titular_funcionario_id, " . 
     578                                 "       a.sigla, a.descricao, a.ativa, a.auxiliar_funcionario_id, " . 
     579                                 "               s.funcionario_id as substituto_funcionario_id " . 
     580                                 " FROM area a " . 
     581                                 "  LEFT OUTER JOIN substituicao s " . 
     582                                 "  ON ((a.area_id = s.area_id) AND (CURRENT_DATE BETWEEN s.data_inicio AND s.data_fim)) " . 
     583                                 " WHERE " . 
     584                                 "      (a.superior_area_id = ?) "; 
     585 
    513586 
    514587                if ($onlyActiveAreas){ 
    515588                        $query .= " AND ativa = 'S'"; 
    516589                } 
    517                 $query .= " ORDER BY sigla, descricao"; 
     590                $query .= " ORDER BY a.sigla, a.descricao"; 
    518591 
    519592                $result = $this->db->query($query, array($parentAreaID)); 
     
    11681241                        return false; 
    11691242 
    1170                 return $employee['centro_custo_id']; 
     1243                $costCenterID = $employee['centro_custo_id']; 
     1244                if(!empty($costCenterID)){ 
     1245                        return $costCenterID; 
     1246                } else { 
     1247                        $employeeArea = $this->getArea($employee['area_id']); 
     1248                        return $employeeArea['centro_custo_id']; 
     1249                } 
    11711250        } 
    11721251 
  • branches/2.2/workflow/inc/local/classes/class.wf_role.php

    r1048 r3167  
    5757                        $this->processID = (int) $GLOBALS['workflow']['job']['processID']; 
    5858 
    59                 $this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID; 
    60                 $this->roleManager = CreateObject('workflow.workflow_rolemanager'); 
    61                 $this->activityManager = CreateObject('workflow.workflow_activitymanager'); 
     59                $this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 
     60                $this->roleManager = Factory::getInstance('workflow_rolemanager'); 
     61                $this->activityManager = Factory::getInstance('workflow_activitymanager'); 
    6262        } 
    6363 
     
    186186                        $users = array((int) $users); 
    187187                $roleID = $this->roleManager->get_role_id($this->processID, $roleName); 
    188                 $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     188                $ldap = Factory::getInstance('WorkflowLDAP'); 
    189189                foreach ($users as $user) 
    190190                { 
     
    212212                $users = $this->roleManager->list_mapped_users($this->processID, false, array('wf_role_name' => $roleName)); 
    213213 
    214                 $ldap = &$GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP'); 
     214                $ldap = Factory::getInstance('WorkflowLDAP'); 
    215215                $output = array(); 
    216216                foreach ($users as $id => $login) 
     
    367367 
    368368                /* get the roles */ 
    369                 $userGroups = $GLOBALS['workflow']['factory']->getInstance('WorkflowLDAP')->getUserGroups($userID); 
     369                $userGroups = Factory::getInstance('WorkflowLDAP')->getUserGroups($userID); 
    370370                $query = 'SELECT DISTINCT role.wf_role_id, role.wf_name, role.wf_description FROM egw_wf_roles role, egw_wf_user_roles user_role WHERE (user_role.wf_role_id = role.wf_role_id) AND (role.wf_p_id = ?) AND (role.wf_role_id = ANY (?))'; 
    371371                $query .= ' AND (((user_role.wf_user = ?) AND (user_role.wf_account_type = ?))'; 
  • branches/2.2/workflow/inc/local/classes/class.wf_workitem.php

    r795 r3167  
    2929        public function wf_workitem() 
    3030        { 
    31                 $this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID; 
     31                $this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID; 
    3232                $this->processID = (int) $GLOBALS['workflow']['wf_runtime']->activity->getProcessId(); 
    3333        } 
  • branches/2.2/workflow/inc/local/functions/function.wf_create_object.php

    r795 r3167  
    55 * @return mixed 
    66 * @license http://www.gnu.org/copyleft/gpl.html GPL 
    7  * @deprecated 1.4.00.000 - 08/03/2007 
     7 * @deprecated 2.2.00.000 
    88 * @package Workflow  
    99 * @subpackage local  
     
    1212function wf_create_object($class_name) 
    1313{ 
     14        wf_warn_deprecated_method('Factory', 'getInstance'); 
    1415        $obj = null; 
    1516        $file_name = PHPGW_SERVER_ROOT.SEP.'workflow'.SEP.'inc'.SEP.'local'.SEP.'classes'.SEP.'class.'.$class_name.'.php'; 
  • branches/2.2/workflow/inc/log/Log.php

    r795 r3167  
    167167        /* If the class exists, return a new instance of it. */ 
    168168        if (Log::_classExists($class)) { 
    169             $obj = &new $class($name, $ident, $conf, $level); 
     169            $obj = new $class($name, $ident, $conf, $level); 
    170170            return $obj; 
    171171        } 
  • branches/2.2/workflow/inc/log/Log/observer.php

    r795 r3167  
    7979         */ 
    8080        if (class_exists($class)) { 
    81             $object = &new $class($priority, $conf); 
     81            $object = new $class($priority, $conf); 
    8282            return $object; 
    8383        } 
     
    103103            /* Support both new-style and old-style construction. */ 
    104104            if ($newstyle) { 
    105                 $object = &new $class($priority, $conf); 
     105                $object = new $class($priority, $conf); 
    106106            } else { 
    107                 $object = &new $class($priority); 
     107                $object = new $class($priority); 
    108108            } 
    109109            return $object; 
  • branches/2.2/workflow/inc/natural/class.natural.php

    r795 r3167  
    196196                        try 
    197197                        { 
    198                                 $str = new PosString(new NatType); 
     198                                $str = Factory::newInstance('PosString', Factory::newInstance('NatType')); 
    199199                                $this->strInputParameter = $str->mountString(array_merge($this->obj->input, $this->obj->output), $inputParams); 
    200200 
     
    409409                if (!empty($this->resultSet)) 
    410410                        unset($this->resultSet); 
    411                 $this->resultSet = new NaturalResultSet($result); 
     411                $this->resultSet = &Factory::newInstance('NaturalResultSet', $result); 
    412412         } 
    413413} 
  • branches/2.2/workflow/inc/smarty/plugins/function.html_options.php

    r795 r3167  
    9696} 
    9797 
     98function smarty_function_html_boxoptions($params, &$smarty) 
     99{ 
     100    require_once $smarty->_get_plugin_filepath('shared','escape_special_chars'); 
     101     
     102    $name = null; 
     103    $values = null; 
     104    $options = null; 
     105    $selected = array(); 
     106    $output = null; 
     107     
     108    $extra = ''; 
     109     
     110    foreach($params as $_key => $_val) { 
     111        switch($_key) { 
     112            case 'name': 
     113                $$_key = (string)$_val; 
     114                break; 
     115             
     116            case 'options': 
     117                $$_key = (array)$_val; 
     118                break; 
     119                 
     120            case 'values': 
     121            case 'output': 
     122                $$_key = array_values((array)$_val); 
     123                break; 
     124 
     125            case 'selected': 
     126                $$_key = array_map('strval', array_values((array)$_val)); 
     127                break; 
     128 
     129            default: 
     130                if(!is_array($_val)) { 
     131                    $extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; 
     132                } else { 
     133                    $smarty->trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE); 
     134                } 
     135                break; 
     136        } 
     137    } 
     138 
     139    if (!isset($options) && !isset($values)) 
     140        return ''; /* raise error here? */ 
     141 
     142    $_html_result = ''; 
     143 
     144    if (isset($options)) { 
     145 
     146        foreach ($options as $_key=>$_val) 
     147            $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected); 
     148 
     149    } else { 
     150 
     151        foreach ($values as $_i=>$_key) { 
     152            $_val = isset($output[$_i]) ? $output[$_i] : ''; 
     153            $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected); 
     154        } 
     155 
     156    } 
     157 
     158    if(!empty($name)) { 
     159        $_html_result = '<select name="' . $name . '"' . $extra . ' style="height: 100px;" size="5">' . "\n" . $_html_result . '</select>' . "\n"; 
     160    } 
     161 
     162    return $_html_result; 
     163 
     164} 
    98165function smarty_function_html_options_optoutput($key, $value, $selected) { 
    99166    if(!is_array($value)) { 
  • branches/2.2/workflow/inc/smarty/wf_plugins/function.wf_autocomplete_input.php

    r1935 r3167  
    2828        $defaultValues = array( 
    2929                'minLength'     => 1, 
    30                 'style'         => "width: 200px" 
     30                'style'         => "width: 200px", 
     31                'mode'          => "POPULATE_ON_LOAD" 
    3132        ); 
    3233        $extractParams = array( 
     
    3839                'idValue', 
    3940                'textValue', 
    40                 'style' 
     41                'style', 
     42                'mode' 
    4143        ); 
    4244 
     
    7981        $extraParams = json_encode($extraParams); 
    8082 
     83        /* se o componente for do tipo padrão (POPULATE_ON_LOAD), não necessita de função para onkeyup */ 
     84        if ($mode == 'POPULATE_ON_LOAD'){ 
     85                $inputElement = <<<EOF 
     86                <input id="$name_input" name="$name_input" type="text" value="$textValue" style="$style" onfocus="checkDataLoaded('$name');" onblur="setTimeout('selectAutocompleteElement(\'$name\')', 500);"/> 
     87EOF; 
     88        } 
     89        elseif ($mode == 'REPOPULATE_ON_CHANGE'){ 
     90                $inputElement = <<<EOF 
     91                <input id="$name_input" name="$name_input" type="text" value="$textValue" style="$style" onblur="setTimeout('selectAutocompleteElement(\'$name\')', 500);" onkeyup="updateCacheRequestsTimeout('$name', '$ajaxClass', '$ajaxMethod', this.value, '$mode')"/> 
     92EOF; 
     93        } 
     94 
     95        /* Cria todos os elementos HTML necessários para o componente */ 
    8196        $output = <<<EOF 
    8297        <input id="$name" name="$name" type="hidden"/> 
    83         <input id="$name_input" name="$name_input" type="text" value="$textValue" style="$style" onfocus="checkDataLoaded('$name');" onblur="setTimeout('selectAutocompleteElement(\'$name\')', 500);"/> 
     98        $inputElement 
    8499        <span id="$name_response"></span> 
    85100        <div id="$name_list" class="autocomplete" style="display: none;"></div> 
    86         <script>autocompleteSelect('$name', '$ajaxClass', '$ajaxMethod', $sep$methodParam$sep, $extraParams);</script> 
     101        <script>autocompleteSelect('$name', '$ajaxClass', '$ajaxMethod', $sep$methodParam$sep, '$mode', $extraParams);</script> 
    87102EOF; 
    88103        return $output; 
  • branches/2.2/workflow/inc/smarty/wf_plugins/function.wf_generic_select.php

    r795 r3167  
    5353EOF; 
    5454 
    55         $templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer'); 
     55        $templateServer = &Factory::getInstance('TemplateServer'); 
    5656        $imageAdd = $templateServer->generateImageLink('add.png'); 
    5757        $imageRemove = $templateServer->generateImageLink('close.png'); 
  • branches/2.2/workflow/inc/smarty/wf_plugins/function.wf_redir_menu.php

    r795 r3167  
    5353        $select_tag .= "<option value=\"og\">Organograma</option>"; 
    5454 
    55         $user_is_admin = $GLOBALS['workflow']['factory']->getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']); 
     55        $user_is_admin = Factory::getInstance('workflow_acl')->checkWorkflowAdmin($GLOBALS['phpgw_info']['user']['account_id']); 
    5656        if ($user_is_admin || ($GLOBALS['phpgw']->acl->check('admin_workflow',1,'workflow'))) { 
    5757                $select_tag .= "<option value=\"ad\">Administração</option>"; 
  • branches/2.2/workflow/inc/smarty/wf_plugins/function.wf_select_city.php

    r795 r3167  
    3737                if (!array_key_exists($required, $params) || (empty($params[$required]))) 
    3838                        $smarty->trigger_error("[wf_select_city] missing required parameter(s): $required", E_USER_ERROR); 
    39          
     39 
    4040        /* atribui valores default para os parâmetros não passados */ 
    4141        foreach ($defaultValues as $key => $value) 
    4242                if (!isset($params[$key])) 
    4343                        $params[$key] = $value; 
    44          
     44 
    4545        /* extrai alguns parâmetros da matriz de parâmetros */ 
    4646        foreach ($extractParams as $extract) 
    4747                $$extract = $params[$extract]; 
    48          
     48 
    4949        /* parâmetros extras são "acumulados" em uma única variável */ 
    5050        $extraParams = array(); 
     
    5353                        $extraParams[$key] = $value_params; 
    5454 
    55         $db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID; 
     55        $db = &Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID; 
    5656        if (isset($params['value'])) 
    5757        { 
  • branches/2.2/workflow/inc/smarty/wf_plugins/function.wf_select_ldap_users.php

    r795 r3167  
    2323 */ 
    2424function smarty_function_wf_select_ldap_users($params, &$smarty) 
    25 { 
     25{  
    2626    require_once $smarty->_get_plugin_filepath('function','html_options'); 
    27         $imagesPath = substr($GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink(''), 0, -1); 
     27        $imagesPath = substr(Factory::getInstance('TemplateServer')->generateImageLink(''), 0, -1); 
    2828 
    2929        $requiredParams = array( 
     
    3434                'size_input'            => '20', 
    3535                'opt_id'                => 'dn', 
    36                 'opt_name'              => 'cn'); 
     36                'opt_name'              => 'cn', 
     37                'opt_complement'        => ''); 
    3738        $extractParams = array( 
    3839                'name', 
     
    4243                'class_btn', 
    4344                'opt_id', 
    44                 'opt_name'); 
     45                'opt_name', 
     46                'opt_complement'); 
    4547 
    4648        /* verifica se todos os parâmetros obrigatórios foram passados */ 
     
    7880        $output = <<<EOF 
    7981                <input type="text" id="$name_input" name="$name_input" size="$size_input" /> 
    80                 <input type="button" class="$class_btn" value="$value_btn" onclick="search_ldap_users_by_cn(document.getElementById('$name_input').value, '$name', '$opt_id', '$opt_name', $handleExpiredSessions)" /> 
     82                <input type="button" class="$class_btn" value="$value_btn" onclick="search_ldap_users_by_cn(document.getElementById('$name_input').value, '$name', '$opt_id', '$opt_name', $handleExpiredSessions, '$opt_complement')" /> 
    8183                &nbsp;<img id="$name_img" border="0" src="$imagesPath/loading.gif" style="display:none"> 
    82                 <span id="$name_span" style="display:none">&nbsp;&nbsp;&nbsp;&nbsp;<b>Selecione o nome: </b> 
     84                <span id="$name_span" style="display:none"><br><br><b>Selecione um nome abaixo: </b><br><br> 
    8385EOF; 
    8486 
    85         $output .= smarty_function_html_options(array_merge(array( 
     87        $output .= smarty_function_html_boxoptions(array_merge(array( 
    8688                                                                                        'name'    => $name, 
    8789                                                                                        'id'      => $name, 
  • branches/2.2/workflow/inc/smarty/wf_plugins/function.wf_select_state.php

    r795 r3167  
    4646        $sql = "SELECT id_state, state_name FROM phpgw_cc_state WHERE id_country = 'BR' ORDER BY state_name"; 
    4747 
    48         $result = $GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID->query($sql); 
     48        $result = Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID->query($sql); 
    4949        $estados = array(); 
    5050        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) 
  • branches/2.2/workflow/inc/smarty/wf_plugins/function.wf_select_user.php

    r795 r3167  
    1212 * - email_as_textarea : indica se o campo que receberá os emails deve ser um textarea (valor true) ou input type text (valor false). Este parâmetro só tem validade se get_email for true. 
    1313 * - hide_groups : indica se deve-se omitir os grupos na tela de seleção. 
     14 * - onlyVisibleAccounts : indica se devem ser recuperadas apenas as contas visíveis, ou se as ocultas também devem ser listadas. 
    1415 * - organization : nome da organização que estará previamente selecionada. 
    1516 * - title : texto da tooltip que aparecerá quando o usuário colocar o mouse sobre o ícone para adicionar usuário. 
     
    3536                'hide_organizations' => false, 
    3637                'hide_sectors' => false, 
     38                'onlyVisibleAccounts' => true, 
    3739                'rows'=> 2); 
    3840        $extractParams = array( 
     
    4244                'title', 
    4345                'cols', 
    44                 'rows'); 
     46                'rows', 
     47                'onlyVisibleAccounts'); 
    4548 
    4649        /* verifica se todos os parâmetros obrigatórios foram passados */ 
     
    9396        if ($params['hide_sectors'] == true) 
    9497                $extraParams .= "&hideSectors=1"; 
     98        if (empty($onlyVisibleAccounts) || $onlyVisibleAccounts === 'false') 
     99                $extraParams .= "&onlyVisibleAccounts=false"; 
     100        else 
     101                $extraParams .= "&onlyVisibleAccounts=true"; 
    95102 
    96         $image = $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink('add_user.png'); 
     103        $image = Factory::getInstance('TemplateServer')->generateImageLink('add_user.png'); 
    97104 
    98 $output .= <<<EOF 
    99         <a alt="$title" title="$title" href="javascript:void(0)" onclick="openParticipants('$name', '$extraParams');"><img border="0" alt="" src="$image" /></a> 
     105        $output .= <<<EOF 
     106                <a alt="$title" title="$title" href="javascript:void(0)" onclick="openParticipants('$name', '$extraParams');"><img border="0" alt="" src="$image" /></a> 
    100107EOF; 
    101108        return $output; 
  • branches/2.2/workflow/inc/smarty/wf_plugins/function.wf_select_users.php

    r795 r3167  
    88 * - value : usuários e grupos previamente selecionados. Deve estar no formato de matriz, seguindo o seguinte padrão: ::$matriz["u123"]="Nome do usuário 123" ; $matriz["g321"]="Nome do grupo 321" e, assim por diante. 
    99 * - hide_groups : indica se deve-se omitir os grupos na tela de seleção. 
     10 * - onlyVisibleAccounts : indica se devem ser recuperadas apenas as contas visíveis, ou se as ocultas também devem ser listadas. 
    1011 * - organization : nome da organização que estará previamente selecionada. 
    1112 * @param object &$smarty Instância do objeto smarty em uso 
     
    1617{ 
    1718    require_once $smarty->_get_plugin_filepath('function','html_options'); 
    18         $imagesPath = substr($GLOBALS['workflow']['factory']->getInstance('TemplateServer')->generateImageLink(''), 0, -1); 
     19        $imagesPath = substr(Factory::getInstance('TemplateServer')->generateImageLink(''), 0, -1); 
    1920        $requiredParams = array( 
    2021                'name'); 
     
    2425                'hide_organizations' => false, 
    2526                'hide_sectors' => false, 
     27                'onlyVisibleAccounts' => true, 
    2628                'value' => array()); 
    2729        $extractParams = array( 
    2830                'name', 
    29                 'value'); 
     31                'value', 
     32                'onlyVisibleAccounts'); 
    3033 
    3134        /* verifica se todos os parâmetros obrigatórios foram passados */ 
     
    5457        if ($params['hide_sectors'] == true) 
    5558                $extraParams .= "&hideSectors=1"; 
     59        if (empty($onlyVisibleAccounts) || $onlyVisibleAccounts === 'false') 
     60                $extraParams .= "&onlyVisibleAccounts=false"; 
     61        else 
     62                $extraParams .= "&onlyVisibleAccounts=true"; 
    5663 
    5764        $output = '<table border="0"><tr><td>'; 
     
    6673        $output .= "</td><td>"; 
    6774        $output .= <<<EOF 
    68                 <a href='javascript:void(0)' onclick="openParticipants(500, 270, '$name', '$extraParams');"><img border="0" src="$imagesPath/add_group.png"></a> 
     75                <a href='javascript:void(0)' onclick="openParticipants(500, 315, '$name', '$extraParams');"><img border="0" src="$imagesPath/add_group.png"></a> 
    6976                <br /> 
    70                 <a href='javascript:void(0)' onclick="openParticipants(500, 270, '$name', '$extraParams');">Adicionar</a> 
     77                <a href='javascript:void(0)' onclick="openParticipants(500, 315, '$name', '$extraParams');">Adicionar</a> 
    7178                <br /><br /> 
    7279                <a href='javascript:void(0)' onclick="delUsers('$name');"><img border="0" src="$imagesPath/delete_group.png"></a> 
  • branches/2.2/workflow/inc/smarty/wf_plugins/prefilter.wf_default_template.php

    r795 r3167  
    3131        { 
    3232                /* get the header and footer location */ 
    33                 $templateServer = &$GLOBALS['workflow']['factory']->getInstance('TemplateServer'); 
     33                $templateServer = &Factory::getInstance('TemplateServer'); 
    3434                $header = $templateServer->getSystemFile('processes/header.tpl'); 
    3535                $footer = $templateServer->getSystemFile('processes/footer.tpl'); 
  • branches/2.2/workflow/index.php

    r795 r3167  
    1010\**************************************************************************/ 
    1111 
     12/* Including common stuff to prepare workflow to run. A session start is needed */ 
     13require_once 'inc/common.inc.php'; 
     14 
    1215/* if the menuaction variable is set, then let the expresso index deal with it */ 
    1316if (isset($_GET['menuaction'])) 
    1417{ 
    1518        /* in case it's an Ajax call from the processes, then check for expired session */ 
    16         if (($_GET['menuaction'] == 'workflow.run_activity.goAjax') && ($_SERVER['HTTP_CONNECTION'] == 'close')) 
     19        if (($_GET['menuaction'] == 'workflow.run_activity.goAjax')) 
    1720        { 
    18                 if (empty($_SESSION)) 
     21                if (empty($_SESSION['phpgw_session']['session_id'])) 
    1922                { 
    2023                        /* the session is expired, return a NanoAjax exception */ 
    2124                        require_once dirname(__FILE__) . '/inc/nano/JSON.php'; 
    2225                        require_once dirname(__FILE__) . '/inc/nano/NanoJsonConverter.class.php'; 
    23                         require_once dirname(__FILE__) . '/inc/nano/NanoController.class.php'; 
    24                         $nanoController = new NanoController(); 
     26                        $nanoController = &Factory::newInstance('NanoController'); 
    2527                        $nanoController->throwErrorOnAllVirtualRequests('__NANOAJAX_SESSION_EXPIRED__'); 
    2628                        exit; 
     
    3941        ); 
    4042        require_once '../header.inc.php'; 
    41         require_once 'inc/common.inc.php'; 
    4243 
    4344        if (isset($_GET['start_tab'])) 
  • branches/2.2/workflow/js/htmlarea/plugins/UploadImage/popups/ImageEditor/Transform.php

    r795 r3167  
    130130 
    131131        $classname = "Image_Transform_Driver_{$driver}"; 
    132         $obj =& new $classname; 
     132        $obj = new $classname; 
    133133        return $obj; 
    134134    } 
  • branches/2.2/workflow/js/jscode/abas.js

    r795 r3167  
    2424        { 
    2525                m = document.getElementById(BordersArray[i].border_id); 
    26                 m.className = 'abas_menu'; 
     26                m.className = 'menu'; 
    2727                c = document.getElementById("content_id_"+BordersArray[i].sequence); 
    2828                if (is_ie) { 
     
    3333         
    3434        m = document.getElementById("border_id_"+ID); 
    35         m.className = 'abas_menu_sel'; 
     35        m.className = 'menu-sel'; 
    3636        c = document.getElementById("content_id_"+ID); 
    3737        c.style.display = ''; 
     
    4747        td.id="border_id_" + ID; 
    4848        td.setAttribute("width", "auto"); 
    49         td.className = "abas_menu"; 
     49        td.className = "menu"; 
    5050        td.setAttribute("align", "right"); 
    5151        td.onclick = function(){alternate_border(ID);}; 
     
    7272                div.className = "conteudo_div_ie"; 
    7373        } else { 
    74                 div.className = "conteudo_div"; 
     74                div.className = "conteudo"; 
    7575        } 
    7676        div.style.display=''; 
     
    8787        { 
    8888                m = document.getElementById(BordersArray[i].border_id); 
    89                 if (m.className == 'abas_menu_sel') 
     89                if (m.className == 'menu-sel') 
    9090                        border_selected = BordersArray[i].border_id; 
    9191        } 
  • branches/2.2/workflow/js/jscode/common_functions.js

    r795 r3167  
    9090        return false; 
    9191} 
     92 
     93function formatDateField(e, obj) 
     94{ 
     95        // assuring it works on IE 
     96        var e = window.event || e; 
     97        var code = e.charCode || e.keyCode; 
     98         
     99        switch (code) { 
     100                case (8): // backspace 
     101                case (9): // tab 
     102                case (35): // end 
     103                case (36): // home 
     104                case (37): // left arrow 
     105                case (39): // right arrow 
     106                case (46): // delete 
     107                        return true; 
     108        } 
     109 
     110        if (obj.value.length == 2) 
     111                obj.value += '/'; 
     112        else if (obj.value.length == 5) 
     113                obj.value += '/'; 
     114        else if (obj.value.length >= 10) 
     115                return false; 
     116 
     117        // just numbers! 
     118        return ((code >= 48) && (code <= 57))? true : false; 
     119} 
  • branches/2.2/workflow/js/jscode/get_form_fields.js

    r795 r3167  
    66function get_form_fields(form_id){ 
    77        var elems = document.forms[form_id].elements; 
    8         var arr = new Object(); 
    9         var j = 0; 
     8        var arr   = new Object(); 
     9        var j     = 0; 
    1010        for(var i = 0; i < elems.length; i++){ 
    1111                if(elems[i].id.substr(0,1) == "_"){ 
     
    3333                                continue; 
    3434                        } 
     35 
     36                        // if the element has [] in the end of its name, return its values (or checked elements) like an array 
     37                        if(elems[i].name.substr(-2,2) == "[]"){ 
     38                                elem_name = elems[i].name.substr(0, elems[i].name.length - 2); 
     39                                if(arr[elem_name] == undefined){ 
     40                                        arr[elem_name] = new Array(); 
     41                                } 
     42 
     43                                if(elems[i].type != "checkbox") 
     44                                        arr[elem_name].push(elems[i].value); 
     45                                else if(elems[i].checked) 
     46                                        arr[elem_name].push(elems[i].value); 
     47                        } 
     48 
    3549                        arr[elems[i].id] = elems[i].value; 
    3650                        j++; 
  • branches/2.2/workflow/js/jscode/participants.js

    r795 r3167  
    11var participantsClone = null; 
     2var chkOnlyVisibleAccountsClone = null; 
    23var searchTimer = null; 
    34var globalSearchEnter = true; 
     
    2324        var params = { 
    2425                organization: $F('organization'), 
     26                onlyVisibleAccounts: $F('onlyVisibleAccounts'), 
    2527                entities: $F('entities'), 
    2628                id: $F('id'), 
     
    3436        var params = { 
    3537                context: $F('sector'), 
     38                onlyVisibleAccounts: $F('onlyVisibleAccounts'), 
    3639                entities: $F('entities'), 
    3740                id: $F('id'), 
     
    4649        setSelectValue($('participants'), data); 
    4750        participantsClone = data; 
     51        if($('onlyVisibleAccounts')) 
     52                chkOnlyVisibleAccountsClone = $('onlyVisibleAccounts').checked; 
    4853} 
    4954 
     
    6368        var reg = new RegExp("<option[^>]*>[^<]*" + searchString + "[^<]*<\/option>", "gi"); 
    6469        setSelectValue($('participants'), participantsClone.match(reg)); 
     70        if($('onlyVisibleAccounts')) 
     71                $('onlyVisibleAccounts').checked = chkOnlyVisibleAccountsClone; 
    6572 
    6673        var participants = $('participants'); 
     
    126133 
    127134                obj = $('participants'); 
    128                 if (obj) 
     135                if (obj){ 
    129136                        participantsClone = obj.innerHTML; 
     137                        if($('onlyVisibleAccounts')) 
     138                                chkOnlyVisibleAccountsClone = $('onlyVisibleAccounts').checked; 
     139                } 
    130140 
    131141                obj = $('exitLink'); 
     
    140150                if (obj) 
    141151                        obj.focus(); 
     152 
     153                obj = $('onlyVisibleAccounts'); 
     154                if (obj) 
     155                        obj.onclick = checkOnlyVisibleAccounts; 
    142156 
    143157                obj = $('useGlobalSearch'); 
     
    149163        }); 
    150164}; 
     165 
     166function checkOnlyVisibleAccounts() 
     167{ 
     168        if(!$('useGlobalSearch').checked) 
     169                getParticipants(); 
     170        else 
     171                toggleFullSearch(); 
     172} 
    151173 
    152174function participantsFilterName(name) 
     
    330352        $('globalSearchWarnings').innerHTML = ''; 
    331353        var params = { 
     354                onlyVisibleAccounts: $F('onlyVisibleAccounts'), 
    332355                searchTerm: $F('search'), 
    333356                entities: $F('entities'), 
     
    341364{ 
    342365        newWidth   = 500; 
    343         newHeight  = 290; 
     366        newHeight  = 315; 
    344367        newScreenX = screen.width - newWidth; 
    345368        newScreenY = 0; 
  • branches/2.2/workflow/js/jscode/wf_autocomplete_input.js

    r1935 r3167  
    11var _cache = new Array(); 
    2  
     2var autocompleterObjs = new Array(); 
     3var myTimer; 
     4 
     5/* Verifica se o componente já foi populado (usado quando o tipo do componente é POPULATE_ON_LOAD) */ 
    36function checkDataLoaded(elementId) 
    47{ 
     
    1821} 
    1922 
     23/* Faz a verificação se o conteúdo digitado tem um correspondente na lista */ 
    2024function selectAutocompleteElement(elementId) 
    2125{ 
    2226        if ($('input' + elementId) == null) return -1; 
    2327        var value = $('input' + elementId).value; 
    24         var items = _cache['requests'][_cache['elements'][elementId]['hash']]['data']; 
     28        var items = new Object(); 
     29        if(_cache['requests'][_cache['elements'][elementId]['hash']] != undefined) 
     30                items = _cache['requests'][_cache['elements'][elementId]['hash']]['data']; 
    2531        var index = autocompleteIndexOf(items, value); 
    2632        $(elementId).value = index; 
     
    3036} 
    3137 
    32 function autocompleteIndexOf(array, value) 
    33 { 
    34         for (key in array){ 
    35                 if (array[key].toLowerCase() == value.toLowerCase()){ 
    36                         return key; 
     38/* Percorre o objeto comparando cada item com o valor digitado no componente, e retorna o índice, se encontrar */ 
     39function autocompleteIndexOf(items, value) 
     40{ 
     41        for (key in items){ 
     42                if(items.hasOwnProperty(key)){ 
     43                        if (items[key].toLowerCase() == value.toLowerCase()){ 
     44                                return key; 
     45                        } 
    3746                } 
    3847        } 
     
    4049} 
    4150 
    42 function arrayValues(array) 
     51function arrayValues(items) 
    4352{ 
    4453        var i = 0; 
    4554        var arr = Array(); 
    46         for (key in array){ 
    47                 arr[i++] = array[key]; 
     55        for (key in items){ 
     56                arr[i++] = items[key]; 
    4857        } 
    4958        return arr; 
    5059} 
    5160 
     61function removeAccents(text) { 
     62        var accents = 'áàãâäéèêëíìîïóòõôöúùûüçÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÕÖÔÚÙÛÜÇ'; 
     63        var normalLetters = 'aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC'; 
     64        var newText = ''; 
     65 
     66        for (i = 0; i < text.length; i++) { 
     67                if (accents.search(text.substr(i, 1)) >= 0) { 
     68                        newText += normalLetters.substr(accents.search(text.substr(i, 1)), 1); 
     69                } 
     70                else { 
     71                        newText += text.substr(i, 1); 
     72                } 
     73        } 
     74 
     75        return newText; 
     76} 
     77 
     78/* Cria, ou recria, o objeto autocompleter do componente, carregando a lista com os valores que já devem estar no cache */ 
    5279function autocompletePopulate(elementId) 
    5380{ 
     
    5582                var items = _cache['requests'][_cache['elements'][elementId]['hash']]['data']; 
    5683                var values = arrayValues(items); 
    57                 new Autocompleter.Local('input' + elementId, 'list' + elementId, values, { 
     84                autocompleterObjs[elementId] = new Autocompleter.Local('input' + elementId, 'list' + elementId, values, { 
    5885                        'choices':9, 
    5986                        'partialChars': _cache['elements'][elementId]['minLength'] 
    6087                }); 
    61         } 
    62         _cache['elements'][elementId]['populated'] = true; 
    63 } 
    64  
    65 function catchJsonError(dados){ return false; } 
    66  
    67 function autocompleteSelect(elementId, ajaxClass, ajaxMethod, methodParam, extraParams) 
    68 { 
    69         // se o parâmetro for um objeto, transforma em uma string para gerar o hash 
     88                _cache['elements'][elementId]['populated'] = true; 
     89        } 
     90} 
     91 
     92/* Cria array para armazenar os elementos */ 
     93function createCacheElementsArray(){ 
     94        if(_cache['elements'] == null) 
     95                _cache['elements'] = new Array(); 
     96} 
     97 
     98/* Cria array para armazenar os valores das requisições ajax */ 
     99function createCacheRequestsArray(){ 
     100        if(_cache['requests'] == null) 
     101                _cache['requests'] = new Array(); 
     102} 
     103 
     104/* Seta os valores do componente no _cache */ 
     105function createCacheElement(elementId, ajaxClass, ajaxMethod, methodParam, componentMode, extraParams){ 
     106        // se o parâmetro for um objeto, transforma em uma string para gerar o hash 
    70107        var _param = (typeof(methodParam) == 'object')? JSON.stringify(methodParam) : methodParam; 
    71         var str = ajaxClass + ajaxMethod + _param; 
    72         // Cria hash que identifica classe, método e parâmetro. 
    73         // Componente verifica se hash já existe para não fazer requisições ajax desnecessárias 
    74         var hash = new SHA1(str).hexdigest(); 
     108 
     109        // se o componente tiver que ser populado em sua criação, calcula o hash 
     110        if (componentMode == 'POPULATE_ON_LOAD'){ 
     111                var str = ajaxClass + ajaxMethod + _param; 
     112                // Cria hash que identifica classe, método e parâmetro. 
     113                // Componente verifica se hash já existe para não fazer requisições ajax desnecessárias 
     114                var hash = new SHA1(str).hexdigest(); 
     115        } 
     116        // senão, não há a necessidade de calcular o hash, pois a lista será carregada posteriormente 
     117        else 
     118                var hash = ""; 
    75119 
    76120        if(extraParams['minLength'] == null){ 
     
    89133        } 
    90134 
    91         func = function (dados) 
    92         { 
    93                 var result = dados[ajaxMethod]['data']; 
    94                 if (result !== false){ 
    95                         // guarda valores localmente 
    96                         _cache['requests'][hash]['data'] = result; 
    97                         _cache['requests'][hash]['populated'] = true; 
    98                         // Envia dados para o componente 
    99                         autocompletePopulate(elementId); 
    100                 } 
    101         }; 
    102  
    103         // Relaciona chamada ajax ao objeto 
    104         if(_cache['elements'] == null){ 
    105                 _cache['elements'] = new Array(); 
    106         } 
     135        createCacheElementsArray(); 
    107136 
    108137        if(_cache['elements'][elementId] == null){ 
     
    111140                _cache['elements'][elementId]['minLength'] = extraParams['minLength']; 
    112141        } else { 
    113                 // por algum motivo componente já existe. 
    114                 // Se o _cache na posição hash não for null, requisição ajax já foi feita. 
    115                 // Se o objeto já foi populado e está sendo escrito novamente, manda popular denovo  
    116                 //   (isso pode acontecer quando o componente é escrito através de javascript) 
     142                // por algum motivo componente já existe. 
     143                // Se o _cache na posição hash não for null, requisição ajax já foi feita. 
     144                // Se o objeto já foi populado e está sendo escrito novamente, manda popular denovo 
     145                //   (isso pode acontecer quando o componente é escrito através de javascript) 
    117146                if(_cache['requests'][hash] != null) 
    118147                        if (_cache['requests'][hash]['populated'] == true){ 
     
    121150                        } 
    122151        } 
    123  
    124         // Cria array para armazenar localmente os valores da requisição ajax 
    125         if(_cache['requests'] == null) 
    126                 _cache['requests'] = new Array(); 
     152} 
     153 
     154function catchJsonError(dados){ return false; } 
     155 
     156/* Controle de timeout para chamar a função updateCacheRequests quando o usuário ficar 0.3 segundos sem digitar. (chamada no onkeyup do componente do tipo REPOPULATE_ON_CHANGE) */ 
     157function updateCacheRequestsTimeout(elementId, ajaxClass, ajaxMethod, methodParam, componentMode){ 
     158        clearTimeout(myTimer); 
     159        myTimer = setTimeout("updateCacheRequests('" + elementId + "', '" + ajaxClass + "', '" + ajaxMethod + "', '" + methodParam + "', '" + componentMode + "')", 300); 
     160} 
     161 
     162/* Função que faz o gerenciamento das chamadas ajax e atualiza a lista de opções para seleção. */ 
     163var updateCacheRequests = function(elementId, ajaxClass, ajaxMethod, methodParam, componentMode){ 
     164        // se o parâmetro for um objeto, transforma em uma string para gerar o hash 
     165        var _param = (typeof(methodParam) == 'object')? JSON.stringify(methodParam) : methodParam; 
     166        var str = ajaxClass + ajaxMethod + _param; 
     167        // Cria hash que identifica classe, método e parâmetro. 
     168        // Componente verifica se hash já existe para não fazer requisições ajax desnecessárias 
     169        var hash = new SHA1(str).hexdigest(); 
    127170 
    128171        if(_cache['requests'][hash] == null){ 
     
    131174                _cache['requests'][hash]['data'] = new Array(); 
    132175 
    133                 // Faz a requisição ajax/Json 
    134                 var nc = new NanoController(); 
    135                 nc.setWfUrl(); 
    136                 nc.setSuccessHandler(func); 
    137                 nc.setExceptionHandler(catchJsonError); 
    138                 nc.setErrorHandler(catchJsonError); 
    139                 nc.addVirtualRequest(ajaxMethod, 
    140                 { 
    141                         action: ajaxClass, 
    142                         mode:   ajaxMethod 
    143                 }, methodParam); 
    144                 nc.sendRequest(); 
    145         } 
    146 } 
     176                if (componentMode == 'POPULATE_ON_LOAD'){ 
     177                        func = function (dados) 
     178                        { 
     179                                var result = dados[ajaxMethod]['data']; 
     180                                if (result !== false){ 
     181                                        // guarda valores localmente 
     182                                        _cache['requests'][hash]['data'] = result; 
     183                                        _cache['requests'][hash]['populated'] = true; 
     184                                        // Envia dados para o componente 
     185                                        autocompletePopulate(elementId); 
     186                                } 
     187                        }; 
     188 
     189                        // Faz a requisição ajax/Json 
     190                        var nc = new NanoController(); 
     191                        nc.setWfUrl(); 
     192                        nc.setSuccessHandler(func); 
     193                        nc.setExceptionHandler(catchJsonError); 
     194                        nc.setErrorHandler(catchJsonError); 
     195                        nc.addVirtualRequest(ajaxMethod, 
     196                                { 
     197                                        action: ajaxClass, 
     198                                        mode:   ajaxMethod 
     199                                }, methodParam); 
     200                        nc.sendRequest(); 
     201                } 
     202                else{ 
     203                        if(_param.length >= 3){ 
     204                                func = function (dados) 
     205                                { 
     206                                        var result = dados[ajaxMethod]['data']; 
     207                                        if(typeof(result) == "object" && result.length != 0){ 
     208                                                // guarda valores localmente 
     209                                                _cache['requests'][hash]['data'] = result; 
     210                                                _cache['requests'][hash]['populated'] = true; 
     211                                                _cache['elements'][elementId]['hash'] = hash; 
     212                                                var values = arrayValues(result); 
     213                                                autocompleterObjs[elementId].options.array = values; 
     214                                                autocompleterObjs[elementId].getUpdatedChoices(); 
     215                                        } 
     216                                }; 
     217 
     218                                // Faz a requisição ajax/Json 
     219                                var nc = new NanoController(); 
     220                                nc.setWfUrl(); 
     221                                nc.setSuccessHandler(func); 
     222                                nc.setExceptionHandler(catchJsonError); 
     223                                nc.setErrorHandler(catchJsonError); 
     224                                nc.addVirtualRequest(ajaxMethod, 
     225                                        { 
     226                                                action: ajaxClass, 
     227                                                mode:   ajaxMethod 
     228                                        }, removeAccents(methodParam)); 
     229                                nc.sendRequest(); 
     230                        } 
     231                } 
     232        } 
     233        else{ 
     234                // Se for do modo que deve repopular a lista a cada tecla pressionada e o _cache referente à entrada digitada já estiver populada 
     235                if (componentMode == 'REPOPULATE_ON_CHANGE' && _cache['requests'][hash]['populated']){ 
     236                        _cache['elements'][elementId]['hash'] = hash; 
     237                        var values = arrayValues(_cache['requests'][hash]['data']); 
     238                        autocompleterObjs[elementId].options.array = values; 
     239                } 
     240        } 
     241} 
     242 
     243/* Função que prepara o _cache, criando e setando os valores para cada componente */ 
     244function autocompleteSelect(elementId, ajaxClass, ajaxMethod, methodParam, componentMode, extraParams) 
     245{ 
     246        createCacheElement(elementId, ajaxClass, ajaxMethod, methodParam, componentMode, extraParams); 
     247        createCacheRequestsArray(); 
     248 
     249        // Se o componente é do tipo que deve repopular a lista a cada tecla, cria um objeto autocompleter com a lista vazia 
     250        if(componentMode == 'REPOPULATE_ON_CHANGE') 
     251                autocompleterObjs[elementId] = new Autocompleter.Local('input' + elementId, 'list' + elementId, new Array(), { 
     252                        'choices':9, 
     253                        'partialChars': _cache['elements'][elementId]['minLength'] 
     254                }); 
     255 
     256        updateCacheRequests(elementId, ajaxClass, ajaxMethod, methodParam, componentMode); 
     257} 
  • branches/2.2/workflow/js/jscode/wf_file_upload.js

    r795 r3167  
    149149                }; 
    150150 
     151 
     152 
    151153                // Set row value 
    152154                new_row.innerHTML = element.value + '&nbsp;&nbsp;'; 
     
    160162        }; 
    161163 
     164        this.removeFile = function (me, nome){ 
     165                me.parentNode.parentNode.removeChild(me.parentNode); 
     166                hd = document.getElementById("hd_remover_anexos"); 
     167                hd.value += nome+"; "; 
     168        } 
     169 
    162170}; 
  • branches/2.2/workflow/js/jscode/wf_select_ldap_users.js

    r795 r3167  
    99 * @param String opt_name Atributo que será atribuído ao name (innerHTML) das options da combo, por padrão é o 'cn' 
    1010 */ 
    11 function search_ldap_users_by_cn(cn, target, opt_id, opt_name, handleExpiredSessions) 
    12 { 
     11function search_ldap_users_by_cn(cn, target, opt_id, opt_name, handleExpiredSessions, opt_complement) 
     12 
     13        // o parâmetro opt_complement foi acrescentado posteriormente a esta função, devido alguns métodos não utilizá-lo é 
     14        // necessário fazer o tratamento do mesmo caso não seja passado. 
     15        if(opt_complement == undefined) 
     16                opt_complement = ''; 
     17 
    1318/* Método que trata o retorno da chamada Ajax. Atribui os valores retornados à combobox */ 
    1419        function result_search_ldap_users_by_cn(data) 
     
    3540                        var container = document.getElementById(data["target"]); 
    3641                        container.innerHTML = ""; 
    37                         if(data['values'].length > 1){ 
     42                        if(data['values'].length >= 1){ 
    3843                                container.disabled = true; 
    3944                                fill_combo_employee(data["target"], data["values"]); 
     
    4449                        } 
    4550                } 
     51 
     52                return false; 
    4653        } 
    4754 
    4855        var url = '$this.bo_utils.search_ldap_users_by_cn'; 
    49         var param = "cn=" + cn + "&target=" + target + "&id=" + opt_id + "&name=" + opt_name; 
     56        var param = "cn=" + cn + "&target=" + target + "&id=" + opt_id + "&name=" + opt_name + "&complement=" + opt_complement; 
    5057 
    5158        document.getElementById(target + "_img").show(); 
  • branches/2.2/workflow/js/orgchart/organization.js

    r1279 r3167  
    169169                        if (data.length == 0) 
    170170                        { 
    171                                 displayArea.innerHTML += '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>'; 
     171                                //displayArea.innerHTML += '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>'; 
     172                                elem = document.createElement('div'); 
     173                                elem.id = this.name.capitalize() + 'List'; 
     174                                elem.innerHTML = '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>'; 
     175                                displayArea.appendChild(elem); 
    172176                                return true; 
    173177                        } 
     
    369373Object.extend(objTelephones, CadastroTelefone); 
    370374 
     375var CadastroSubstituto = 
     376{ 
     377        name: 'substitution', 
     378        required: new Array('organizacao_id', 'area_id', 'descricao', 'titular_funcionario_id', 'substituto_funcionario_id', 'data_inicio', 'data_fim'), 
     379        tableHeader: {'substituto_funcionario_id_desc': 'Nome', 'data_inicio': 'Data de início', 'data_fim': 'Data de término'}, 
     380        combo: {} 
     381}; 
     382var objSubstitution = new CadastroAjax(); 
     383Object.extend(objSubstitution, CadastroSubstituto); 
     384 
     385 
    371386function createOrganizationLayout(organizationID, organizationDiv) 
    372387{ 
     
    397412        content += '<option onclick="loadAddEmployeeUI(' + organizationID  + ');" class="lbOn">Funcionários</option>' 
    398413        content += '<option onclick="loadAddTelephoneUI(' + organizationID  + ');" class="lbOn">Telefones</option>' 
     414        content += '<option onclick="loadAddSubstitutionUI(' + organizationID  + ');" class="lbOn">Substituições</option>' 
    399415        content += '</select></li>'; 
    400416        content += '<li><a><input type="text" name="search_term" id="search_term" onkeypress="if (((window.Event) ? event.which : event.keyCode) == 13) $(\'search_span_' + organizationID  + '\').onclick(); return true;" /> <span id="search_span_' + organizationID + '" onclick="tmp = $$(\'div#orgchartAreas_' + organizationID + ' a.destaque\'); if (tmp[0]) tmp[0].removeClassName(\'destaque\'); searchEmployee(' + organizationID + ', $(\'orgchartEmployees_' + organizationID + '\')); return false;">busca</span></a></li>'; 
     
    467483                        data[i]['tr_attributes']['class'] = "linha" + i%2; 
    468484                        data[i]['tr_attributes']['className'] = "linha" + i%2; 
    469                         data[i]['funcionario_id_desc'] = '<a href="javascript:void(0)" class="lbOn" onmouseover="getEmployeeInfoTimer(event, ' + data[i]['funcionario_id'] + ', ' + organizationID + '); return false;" onmouseout="hideEmployeeInfo(); return false;" onclick="loadAddEmployeeUI(' + organizationID + ', function(){objEmployee.fillForm(' + dataHash.customInspect() + ')}); $(\'addEmployeeLink\').parentNode.removeChild($(\'addEmployeeLink\')); return false;">' + data[i]['funcionario_id_desc'] + '</a>' + (data[i]['removed'] ? ' <font color="red">(excluído)</font>' : ''); 
     485                        data[i]['funcionario_id_desc'] = '<a href="javascript:void(0)" class="lbOn" onmouseover="getEmployeeInfoTimer(event, ' + data[i]['funcionario_id'] + ', ' + organizationID + '); return false;" onmouseout="hideEmployeeInfo(); return false;" onclick="loadAddEmployeeUI(' + organizationID + ', function(){objEmployee.fillForm(' + dataHash.customInspect() + ')}); $(\'addEmployeeLink\').parentNode.removeChild($(\'addEmployeeLink\')); return false;">' + data[i]['funcionario_id_desc'] + '</a>' + (data[i]['removed'] ? ' <font color="red">(inativo)</font>' : ''); 
    470486                        data[i]['actions'] = '<a href="#" onclick="objEmployee.remove({\'funcionario_id\': ' + data[i]['funcionario_id'] + ', \'organizacao_id\': ' + organizationID + '} , this.parentNode.parentNode); return false;"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/button_cancel.png" /></a>'; 
    471487                } 
     
    504520                tableHeader['uid'] = 'UID'; 
    505521                tableHeader['actions'] = 'Ações'; 
     522 
     523                var complement; 
    506524                for (var i = 0; i < data.length; i++) 
    507525                { 
     
    511529                                        dataHash[j] = data[i][j]; 
    512530 
     531                        // are you a chief ('titular' or 'substituto')? 
     532                        complement = ''; 
     533                        if (data[i]['chief']) 
     534                                complement = ' <strong>(' + ((data[i]['chief'] == 1) ? 'Titular' : 'Substituto') + ')</strong>'; 
     535 
    513536                        data[i]['tr_attributes'] = new Array(); 
    514537                        data[i]['tr_attributes']['class'] = "linha" + i%2; 
    515538                        data[i]['tr_attributes']['className'] = "linha" + i%2; 
    516                         data[i]['funcionario_id_desc'] = '<a href="javascript:void(0)" class="lbOn" onmouseover="getEmployeeInfoTimer(event, ' + data[i]['funcionario_id'] + ', ' + organizationID + '); return false;" onmouseout="hideEmployeeInfo(); return false;" onclick="loadAddEmployeeUI(' + organizationID + ', function(){objEmployee.fillForm(' + dataHash.customInspect() + ')}); $(\'addEmployeeLink\').parentNode.removeChild($(\'addEmployeeLink\')); return false;">' + data[i]['funcionario_id_desc'] + '</a>' + (data[i]['removed'] ? ' <font color="red">(excluído)</font>' : ''); 
     539                        data[i]['funcionario_id_desc'] = '<a href="javascript:void(0)" class="lbOn" onmouseover="getEmployeeInfoTimer(event, ' + data[i]['funcionario_id'] + ', ' + organizationID + '); return false;" onmouseout="hideEmployeeInfo(); return false;" onclick="loadAddEmployeeUI(' + organizationID + ', function(){objEmployee.fillForm(' + dataHash.customInspect() + ')}); $(\'addEmployeeLink\').parentNode.removeChild($(\'addEmployeeLink\')); return false;">' + data[i]['funcionario_id_desc'] + ' ' + complement + '</a>' + (data[i]['removed'] ? ' <font color="red">(inativo)</font>' : ''); 
    517540                        data[i]['actions'] = '<a href="#" onclick="objEmployee.remove({\'funcionario_id\': ' + data[i]['funcionario_id'] + ', \'organizacao_id\': ' + organizationID + '} , this.parentNode.parentNode); return false;"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/button_cancel.png" /></a>'; 
    518541                        window.scrollTo(0,0); 
     
    745768        content += ' <a href="javascript:void(0)" onclick="$(\'titular_funcionario_id\').value=\'\'; $(\'titular_funcionario_id_desc\').value=\'\'; return false;"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/delete_user.png" /></a>'; 
    746769        content += '</td></tr>'; 
    747         content += '<tr><td><label for="substituto_funcionario_id">Substituto</label></td><td>'; 
    748         content += '<input type="hidden" name="substituto_funcionario_id" id="substituto_funcionario_id" value="" />'; 
    749         content += '<input type="input" name="substituto_funcionario_id_desc" id="substituto_funcionario_id_desc" value="" readonly="true" size="40" />'; 
    750         content += '<a href="javascript:void(0)" onclick="openParticipants(\'substituto_funcionario_id\', \'uid=1&hidegroups=1\');"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/add_user.png" /></a>'; 
    751         content += ' <a href="javascript:void(0)" onclick="$(\'substituto_funcionario_id\').value=\'\'; $(\'substituto_funcionario_id_desc\').value=\'\'; return false;"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/delete_user.png" /></a>'; 
    752         content += '</td></tr>'; 
    753770        content += '<tr><td><label for="auxiliar_funcionario_id">Auxiliar Administrativo</label></td><td>'; 
    754771        content += '<input type="hidden" name="auxiliar_funcionario_id" id="auxiliar_funcionario_id" value="" />'; 
     
    808825} 
    809826 
     827 
     828function loadAddSubstitutionUI(organizationID) 
     829{ 
     830        var area_id = 'combo_area'; 
     831        var content; 
     832 
     833        content  = '<h2 id="modalTitle">Adicionar Substituição</h2>'; 
     834        content += '<form name="orgchartForm" id="orgchartForm">'; 
     835        content += '<input type="hidden" name="organizacao_id" id="organizacao_id" value="' + organizationID + '" />'; 
     836        content += "<table>"; 
     837        content += '<tr><td><label for="area_id">Sigla</label>'; 
     838        content += '<input type="hidden" name="area_id" id="area_id" value="" />'; 
     839        content += '</td><td id="comboArea"><i>carregando</i></td></tr>'; 
     840        content += '<tr><td><label for="descricao">Nome</label></td><td><input type="text" name="descricao" id="descricao" readonly="true" size="40" /></td></tr>'; 
     841        content += '<tr><td><label for="titular_funcionario_id">Titular</label></td><td>'; 
     842        content += '<input type="hidden" name="titular_funcionario_id" id="titular_funcionario_id" value="" readonly="true" />'; 
     843        content += '<input type="input" name="titular_funcionario_id_desc" id="titular_funcionario_id_desc" value="" readonly="true" size="40" />'; 
     844        content += '</td></tr>'; 
     845        content += '<tr><td><label for="substituto_funcionario_id">Substituto</label></td><td>'; 
     846        content += '<input type="hidden" name="substituto_funcionario_id" id="substituto_funcionario_id" value="" />'; 
     847        content += '<input type="input" name="substituto_funcionario_id_desc" id="substituto_funcionario_id_desc" value="" readonly="true" size="40" />'; 
     848        content += '<a href="javascript:void(0)" onclick="openParticipants(\'substituto_funcionario_id\', \'uid=1&hidegroups=1\');"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/add_user.png" /></a>'; 
     849        content += ' <a href="javascript:void(0)" onclick="$(\'substituto_funcionario_id\').value=\'\'; $(\'substituto_funcionario_id_desc\').value=\'\'; return false;"><img border="0" width="16" height="16" src="workflow/templateFile.php?file=images/delete_user.png" /></a>'; 
     850        content += '</td></tr>'; 
     851        content += '<tr><td><label for="data_inicio">Data de início</label></td><td><input type="text" name="data_inicio" id="data_inicio" size="15" onkeypress="return formatDateField(event, this);" /></td></tr>'; 
     852        content += '<tr><td><label for="data_fim">Data de término</label></td><td><input type="text" name="data_fim" id="data_fim" size="15" onkeypress="return formatDateField(event, this);"/></td></tr>'; 
     853        content += "</table>"; 
     854        content += '</form>'; 
     855        content += '<button id="inserir" onclick="objSubstitution.add(); return false;">Inserir</button>'; 
     856        content += '<button onclick="valid.deactivate(); return false;">Cancelar</button>'; 
     857 
     858        var divLB = $('lbContent'); 
     859        divLB.innerHTML = content; 
     860 
     861        // function that must be called after loading areas on the combobox 
     862        var areas_callback = function () { 
     863 
     864                // every change on the combo box must query for area information 
     865                $(area_id).onchange = function () { 
     866                        if ($('SubstitutionList')) 
     867                                $('SubstitutionList').remove(); 
     868                         
     869                        var info_callback = function (data) { 
     870 
     871                                // just to be sure 
     872                                if (!data[0]) { 
     873                                        alert("Não foi possível encontrar os dados."); 
     874                                } 
     875 
     876                                // we received an empty response. Let's reset the form. 
     877                                if ((data[0]['area_id'] == '') || (data[0]['area_id'] == null)) { 
     878                                        alert('RESET'); 
     879                                        $('area_id').value = ''; 
     880                                        $('descricao').value = ''; 
     881                                        $('titular_funcionario_id').value = ''; 
     882                                        $('titular_funcionario_id_desc').value = ''; 
     883                                } 
     884                                // fill the form 
     885                                else { 
     886                                        $('area_id').value = data[0]['area_id']; 
     887                                        $('descricao').value = data[0]['descricao']; 
     888                                        $('titular_funcionario_id').value = data[0]['titular_funcionario_id']; 
     889                                        $('titular_funcionario_id_desc').value = data[0]['titular_funcionario_id_desc']; 
     890                                } 
     891 
     892                                // get the list of substitutions 
     893                                objSubstitution.generateUpdateTable({'organizacao_id': organizationID, 'area_id': $(area_id).value}, divLB); 
     894                        } 
     895                        objArea.list(info_callback, {'organizacao_id': organizationID, 'area_id': $(area_id).value}); 
     896 
     897                } 
     898        } 
     899        objArea.generateComboBox({'organizacao_id': organizationID}, $('comboArea'), true, area_id, areas_callback); 
     900} 
     901 
    810902function getEmployeeInfoTimer(e, employeeID, organizationID) 
    811903{ 
  • branches/2.2/workflow/js/orgchart/utils.js

    r795 r3167  
    33        /*** constrói a tabela ***/ 
    44        var table = document.createElement("TABLE"); 
     5 
     6        table.style.marginTop = "10px"; 
    57 
    68        /* configura a tabela */ 
     
    1618        /* cabeçalho */ 
    1719        tr = document.createElement("TR"); 
     20        tr.className = 'message_header'; 
    1821        for (i in header) 
    1922        { 
     
    2225                        td = document.createElement("TH"); 
    2326                        td.innerHTML = header[i]; 
     27                        td.className = 'message_header'; 
    2428                        tr.appendChild(td); 
    2529                } 
  • branches/2.2/workflow/js/userinterface/orgchart.js

    r1452 r3167  
    4545        content += '</select></a></li>'; 
    4646        content += '<li><a href="#" onclick="window.open(\'' + enderecoImagem + '\', \'extwindow\'); return false;"><img src="templateFile.php?file=images/Process.gif">&nbsp;&nbsp;Gráfico</a></li>'; 
    47         content += '<li><a><input type="text" name="search_term" id="search_term" onkeypress="if (((event.which) ? event.which : event.keyCode) == 13) $(\'search_span\').onclick(); return true;" /><span id="search_span" style="cursor: pointer;" onclick="tmp = $$(\'div#orgchartAreas a.destaque\'); if (tmp[0]) tmp[0].removeClassName(\'destaque\'); orgchartSearchEmployee($F(\'search_term\')); return false;">&nbsp;busca</span></a></li>'; 
     47        content += '<li><a><input type="text" name="search_term" id="search_term" onkeypress="if (((event.which) ? event.which : event.keyCode) == 13) $(\'search_span\').onclick(); return true;" /><span id="search_span" style="cursor: pointer;" onclick="tmp = $$(\'div#orgchartAreas a.destaque\'); if (tmp[0]) tmp[0].removeClassName(\'destaque\'); orgchartSearchEmployee($F(\'search_term\')); return false;">&nbsp;busca&nbsp;</span><img src="templateFile.php?file=images/help.png" title="Informe o nome, área ou telefone a ser pesquisado." style="cursor: help" /></a></li>'; 
    4848        content += '<li><a href="#" onclick="printArea(); return false;"><img src="templateFile.php?file=images/imprimir.png" width="16">&nbsp;&nbsp;Imprimir</a></li>'; 
    4949        content += '</ul>'; 
     
    171171        var content = '<center><h2>Substituição de Chefia</h2></center>'; 
    172172        content += '<table class="employeeList">'; 
    173         content += '<tr><th>Área</th><th>Titular</th><th>Substituto</th></tr>'; 
     173        content += '<tr><th>Área</th><th>Titular</th><th>Substituto</th><th>Data de início</th><th>Data de término</th></tr>'; 
    174174        var current; 
    175175        for (var i = 0; i < data.length; i++) 
     
    180180                content += '<td>' + current['titular'] + '</td>'; 
    181181                content += '<td>' + current['substituto'] + '</td>'; 
     182                content += '<td>' + current['data_inicio'] + '</td>'; 
     183                content += '<td>' + current['data_fim'] + '</td>'; 
    182184                content += '</tr>'; 
    183185        } 
     
    294296 
    295297        /* no employee to list */ 
    296         if ( ( ! data['employees'] || data['employees'].length == 0 ) && ( ! data['bygroup'] || data['bygroup'].length == 0 ) ) 
     298        if ( ( ! data['employees'] || data['employees'].length == 0 ) &&  
     299                 ( ! data['bygroup'] || data['bygroup'].length == 0 ) && 
     300                 ( ! data['bytelephone'] || data['bytelephone'].length == 0 ) ) 
    297301        { 
    298302                div.innerHTML = '<br/><br/><center><strong>Nenhum registro encontrado</strong></center>'; 
     
    317321                /* build the display table (headers)*/ 
    318322                content += '<table id="employeeList" class="employeeList" style="clear: both">'; 
    319                 content += '<tr>'; 
     323                content += '<tr class="message_header">'; 
    320324                content += '<th>Nome</th>'; 
    321325                if (useArea) 
     
    344348                                complement = ''; 
    345349                        if (employees[i]['removed']) 
    346                                 complement += ' <font color="red">(excluído)</font>'; 
     350                                complement += ' <font color="red">(inativo)</font>'; 
    347351                        content += '<tr class="linha'+ i%2 + (useCategories ? ' categoria_' + employees[i]['funcionario_categoria_id'] : '') + '" onmouseover="this.className=\'highlight0\'" onmouseout="this.className=\'linha'+ i%2 + (useCategories ? ' categoria_' + employees[i]['funcionario_categoria_id'] : '') + '\'">'; 
    348352                        content += '<td><a href="javascript:void(0);" onmouseover="getEmployeeInfoTimer(event, ' + employees[i]['funcionario_id'] + '); return false;" onmouseout="hideEmployeeInfo(); return false;">' + employees[i]['cn'] + complement + '</a></td>'; 
     
    477481                        div.innerHTML += '</center><span style="color:red">Busca pelo nome: ' + searchTerm.toUpperCase( ) + '</span>' + content; 
    478482 
     483                // printing records found by group 
    479484                if ( data['bygroup'] && data['bygroup'].length ) 
    480485                { 
     
    484489                        if ( content ) 
    485490                                div.innerHTML += '<br/><br/><span style="color:red">Busca pelo setor: ' + searchTerm.toUpperCase( ) + '</span><br/>' + content; 
     491                } 
     492 
     493                // printing records found by telephoneNumber 
     494                if ( data['bytelephone'] && data['bytelephone'].length ) 
     495                { 
     496                        employees = [ ]; 
     497                        employees[ 'employees' ] = data['bytelephone']; 
     498                        content = printEmployeesHandler( employees, 'returnResult' ); 
     499                        if ( content ) 
     500                                div.innerHTML += '<br/><br/><span style="color:red">Busca pelo telefone: ' + searchTerm.toUpperCase( ) + '</span><br/>' + content; 
    486501                } 
    487502 
  • branches/2.2/workflow/js/userinterface/orgchartPrint.js

    r795 r3167  
     1/** 
     2* Show / Hide all employees 
     3*/ 
    14function toggleEmployeesVisibility() 
    25{ 
    36        if ($('#employeesVisibility').attr('checked')) 
    4                 $('div.employees').show(); 
     7                $('tr.employees').show(); 
    58        else 
    6                 $('div.employees').hide(); 
    7 } 
    8  
     9                $('tr.employees').hide(); 
     10} 
     11 
     12/** 
     13* Highlight supervisor names? 
     14*/ 
    915function toggleHighlightSupervisor() 
    1016{ 
     
    1521} 
    1622 
     23/** 
     24* Show / Hide orgchart area path visibility 
     25*/ 
    1726function toggleOrgchartPathVisibility() 
    1827{ 
    1928        if ($('#orgchartPathVisibility').attr('checked')) 
    20         { 
    2129                $('span.orgchartPath').css('visibility', 'visible').show(); 
    22         } 
    23         else 
    24         { 
     30        else { 
    2531                if ($('#orgchartPathIndentation').attr('checked')) 
    2632                        $('span.orgchartPath').show().css('visibility', 'hidden'); 
     
    3036} 
    3137 
     38/** 
     39* Group by area or show a single list alphabetically ordered 
     40* For large sets of data this function may be potencially slow 
     41*/ 
     42function toggleGroupByArea() 
     43{ 
     44        /* remove the table and compute it again */ 
     45        $('#employee_table').remove(); 
     46 
     47        if ($('#groupByArea').attr('checked')) 
     48                showGroupedByArea(); 
     49        else 
     50                showUngrouped(); 
     51 
     52        /* updating supervisor highlight and orgchart path visibility */ 
     53        toggleHighlightSupervisor(); 
     54        toggleOrgchartPathVisibility(); 
     55} 
     56 
     57/** 
     58* Centralize the creation of table rows for employees. 
     59* 'showAreaColumn' specifies whether the second column will be shown 
     60*/ 
     61function createEmployeeRow(area_id, user_id, showAreaColumn) 
     62{ 
     63        /* set a special 'class' if the employee is a supervisor one */ 
     64        class_name = 'employee'; 
     65        if (areas[area_id].titular_funcionario_id == areas[area_id].employees[user_id].funcionario_id) 
     66                class_name += 'supervisor'; 
     67 
     68        /* creating the row. */ 
     69        element = $('<tr></tr>') 
     70                                /* name: first column */ 
     71                                .append( 
     72                                                $('<td></td>') 
     73                                                        .append( 
     74                                                                $('<span></span>') 
     75                                                                        .addClass(class_name) 
     76                                                                        .append(areas[area_id].employees[user_id].cn) 
     77                                                        ) 
     78                                                        .css('width', '70%') 
     79                                                ); 
     80 
     81        /* area: second (optional) column */ 
     82        if (showAreaColumn) 
     83                element.append( 
     84                                                $('<td>' + areas[area_id].sigla + '</td>') 
     85                                                        .css('width', '15%') 
     86                                        ); 
     87 
     88        /* telephone: last column */ 
     89        element.append( 
     90                                        $('<td>' + areas[area_id].employees[user_id].telephoneNumber + '</td>') 
     91                                                .css('width', '20%') 
     92                                        ) 
     93                                .addClass('employees'); 
     94 
     95        return element; 
     96} 
     97 
     98/** 
     99* Creating a employee table grouped by area 
     100*/ 
     101function showGroupedByArea() 
     102{ 
     103        var table = $('<table></table>').css('width', '90%').attr('id', 'employee_table'); 
     104        var i, j; 
     105 
     106        /* iterating over areas */ 
     107        for (i=0; i < areas.length; i++) { 
     108 
     109                /* inserting area header */ 
     110                table.append( 
     111                                $('<tr></tr>') 
     112                                .append( 
     113                                        $('<th></th>') 
     114                                                .css('text-align', 'left') 
     115                                                .css('height', '30') 
     116                                                .append( 
     117                                                        $('<span></span>') 
     118                                                                .addClass('orgchartPath') 
     119                                                                .append(areas[i].orgchartPath) 
     120                                                                ) 
     121                                                .append(areas[i].sigla) 
     122                                        ) 
     123                ); 
     124 
     125                /* creating employee rows */ 
     126                for (j=0; j < areas[i].employees.length; j++) 
     127                        table.append(createEmployeeRow(i, j)); 
     128        } 
     129        $('#areas_content').append(table); 
     130} 
     131 
     132/** 
     133* Creating employess ordered alphabetically and ungrouped. In this 
     134* function we implemented a 'merge' of all area's employee arrays. 
     135* 
     136* Be careful if you are going to update this code... =) 
     137*/ 
     138function showUngrouped() 
     139{ 
     140        var table = $('<table></table>').css('width', '90%').attr('id', 'employee_table'); 
     141        var i, less, end; 
     142 
     143        /* creating and reseting indexes */ 
     144        for (i=0; i < areas.length; i++) 
     145                areas[i].index = 0; 
     146 
     147        /* */ 
     148        while (true) { 
     149                less = -1; 
     150                end = true; 
     151 
     152                /* searching the area with smallest employee name */ 
     153                for (i=0; i < areas.length; i++) { 
     154 
     155                        /* if this area have employees left */ 
     156                        if (areas[i].employees.length > areas[i].index) { 
     157 
     158                                /* if it's the first area reached in this iteration */ 
     159                                if (less == -1) 
     160                                        less = i; 
     161 
     162                                /* updating less */ 
     163                                if (areas[i].employees[areas[i].index].cn < areas[less].employees[areas[less].index].cn) 
     164                                        less = i; 
     165 
     166                                /* so, we are not done */ 
     167                                end = false; 
     168                        } 
     169                } 
     170                /* if we are done */ 
     171                if (end) break; 
     172 
     173                /* inserting the row */ 
     174                table.append(createEmployeeRow(less, areas[less].index, true)); 
     175                areas[less].index++; 
     176        } 
     177        $('#areas_content').append(table); 
     178} 
     179 
     180/** 
     181* Print me! 
     182*/ 
    32183function printAction() 
    33184{ 
     
    35186} 
    36187 
     188/** 
     189* Binding events to HTML elements 
     190*/ 
    37191function bindEvents() 
    38192{ 
    39193        $('#employeesVisibility').click(toggleEmployeesVisibility); 
     194        $('#groupByArea').click(toggleGroupByArea); 
    40195        $('#highlightSupervisor').click(toggleHighlightSupervisor); 
    41196        $('#orgchartPathVisibility').click(toggleOrgchartPathVisibility); 
     
    45200function initialSetup() 
    46201{ 
     202        toggleGroupByArea(); 
    47203        toggleEmployeesVisibility(); 
    48204        toggleHighlightSupervisor(); 
     
    50206} 
    51207 
     208/** 
     209* Call setup functions on body onload. 
     210*/ 
    52211function pageLoad() 
    53212{ 
  • branches/2.2/workflow/redirect.php

    r1468 r3167  
    1212if (empty($_SESSION)) 
    1313        exit(0); 
    14 $GLOBALS['workflow']['factory']->getInstance('ResourcesRedirector')->redirect(); 
     14Factory::getInstance('ResourcesRedirector')->redirect(); 
    1515?> 
  • branches/2.2/workflow/setup/default_records.inc.php

    r1980 r3167  
    5959$GLOBALS['phpgw']->ADOdb->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES(?, ?, ?)", array('workflow', 'log_type_file', 'True')); 
    6060$GLOBALS['phpgw']->ADOdb->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES(?, ?, ?)", array('workflow', 'log_type_firebug', 'True')); 
    61 $GLOBALS['phpgw']->ADOdb->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES(?, ?, ?)", array('workflow', 'log_level', '7')); 
     61$GLOBALS['phpgw']->ADOdb->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES(?, ?, ?)", array('workflow', 'log_level', '0')); 
    6262 
    6363/* connect to the new database */ 
     
    8686        $workflowDB->query('CREATE TABLE localidade (organizacao_id integer NOT NULL, localidade_id serial NOT NULL, centro_custo_id integer, descricao character varying(50) NOT NULL, empresa CHARACTER VARYING(100), endereco CHARACTER VARYING(100), complemento CHARACTER VARYING(50), cep CHARACTER VARYING(9), bairro CHARACTER VARYING(30), cidade CHARACTER VARYING(50), uf CHARACTER(2))'); 
    8787        $workflowDB->query('CREATE TABLE funcionario (funcionario_id int4 NOT NULL, area_id integer NOT NULL, localidade_id integer NOT NULL, centro_custo_id integer, organizacao_id integer NOT NULL, funcionario_status_id integer NOT NULL, cargo_id int4, nivel int2, funcionario_categoria_id int4, titulo CHARACTER VARYING(30))'); 
    88         $workflowDB->query('CREATE TABLE area (organizacao_id integer NOT NULL, area_id serial NOT NULL, area_status_id integer NOT NULL, areasup_organizacao_id integer, superior_area_id integer, centro_custo_id integer, titular_funcionario_id int4, substituto_funcionario_id int4, sigla character varying(20) NOT NULL, descricao character varying(100) NOT NULL, ativa character varying(1) NOT NULL, auxiliar_funcionario_id int4)'); 
     88        $workflowDB->query('CREATE TABLE area (organizacao_id integer NOT NULL, area_id serial NOT NULL, area_status_id integer NOT NULL, areasup_organizacao_id integer, superior_area_id integer, centro_custo_id integer, titular_funcionario_id int4, sigla character varying(20) NOT NULL, descricao character varying(100) NOT NULL, ativa character varying(1) NOT NULL, auxiliar_funcionario_id int4)'); 
    8989        $workflowDB->query('CREATE TABLE funcionario_status (funcionario_status_id serial NOT NULL, descricao character varying(50) NOT NULL, exibir character varying(1) NOT NULL, organizacao_id integer NOT NULL)'); 
    9090        $workflowDB->query('CREATE TABLE cargo (cargo_id serial NOT NULL, descricao character varying(150), organizacao_id int4)'); 
    9191        $workflowDB->query('CREATE TABLE funcionario_categoria (funcionario_categoria_id serial NOT NULL, descricao character varying(150), organizacao_id int4)'); 
    9292        $workflowDB->query('CREATE TABLE telefone (telefone_id serial NOT NULL, descricao character varying(50) NOT NULL, numero character varying(50) NOT NULL, organizacao_id integer NOT NULL)'); 
     93        $workflowDB->query('CREATE TABLE substituicao (substituicao_id serial NOT NULL, area_id integer NOT NULL, funcionario_id integer NOT NULL, data_inicio date NOT NULL, data_fim date NOT NULL)'); 
     94 
    9395 
    9496        /* add the constraints */ 
     
    100102        $workflowDB->query('ALTER TABLE ONLY localidade ADD CONSTRAINT localidade_pkey PRIMARY KEY (organizacao_id, localidade_id)'); 
    101103        $workflowDB->query('ALTER TABLE ONLY funcionario ADD CONSTRAINT funcionario_pkey PRIMARY KEY (funcionario_id)'); 
    102         $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT area_pkey PRIMARY KEY (organizacao_id, area_id)'); 
     104        $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT area_pkey PRIMARY KEY (area_id)'); 
    103105        $workflowDB->query('ALTER TABLE ONLY funcionario_status ADD CONSTRAINT funcionario_status_pkey PRIMARY KEY (funcionario_status_id)'); 
    104106        $workflowDB->query('ALTER TABLE ONLY telefone ADD CONSTRAINT telefone_pkey PRIMARY KEY (telefone_id)'); 
     107        $workflowDB->query('ALTER TABLE ONLY substituicao ADD CONSTRAINT substituicao_pkey PRIMARY KEY (substituicao_id)'); 
     108 
    105109 
    106110        /* foreign keys */ 
     
    119123        $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$2" FOREIGN KEY (centro_custo_id, organizacao_id) REFERENCES centro_custo(centro_custo_id, organizacao_id)'); 
    120124        $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$3" FOREIGN KEY (titular_funcionario_id) REFERENCES funcionario(funcionario_id)'); 
    121         $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$4" FOREIGN KEY (substituto_funcionario_id) REFERENCES funcionario(funcionario_id)'); 
    122         $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$5" FOREIGN KEY (organizacao_id) REFERENCES organizacao(organizacao_id)'); 
    123         $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$6" FOREIGN KEY (area_status_id, organizacao_id) REFERENCES area_status(area_status_id, organizacao_id)'); 
    124         $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$7" FOREIGN KEY (auxiliar_funcionario_id) REFERENCES funcionario(funcionario_id)'); 
     125        $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$4" FOREIGN KEY (organizacao_id) REFERENCES organizacao(organizacao_id)'); 
     126        $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$5" FOREIGN KEY (area_status_id, organizacao_id) REFERENCES area_status(area_status_id, organizacao_id)'); 
     127        $workflowDB->query('ALTER TABLE ONLY area ADD CONSTRAINT "$6" FOREIGN KEY (auxiliar_funcionario_id) REFERENCES funcionario(funcionario_id)'); 
    125128        $workflowDB->query('ALTER TABLE ONLY telefone ADD CONSTRAINT "$1" FOREIGN KEY (organizacao_id) REFERENCES organizacao(organizacao_id)'); 
     129        $workflowDB->query('ALTER TABLE ONLY substituicao ADD CONSTRAINT "$1" FOREIGN KEY (area_id) REFERENCES area(area_id)'); 
     130        $workflowDB->query('ALTER TABLE ONLY substituicao ADD CONSTRAINT "$2" FOREIGN KEY (funcionario_id) REFERENCES funcionario(funcionario_id)'); 
     131 
    126132 
    127133        /* set the permissions to the database objects */ 
    128         $dbObjects = array('organizacao', 'area_status', 'centro_custo', 'localidade', 'funcionario', 'area', 'funcionario_status', 'telefone', 'organizacao_organizacao_id_seq', 'area_status_area_status_id_seq', 'centro_custo_centro_custo_id_seq', 'localidade_localidade_id_seq', 'area_area_id_seq', 'funcionario_status_funcionario_status_id_seq', 'cargo', 'cargo_cargo_id_seq', 'funcionario_categoria', 'funcionario_categoria_funcionario_categoria_id_seq', 'telefone_telefone_id_seq'); 
     134        $dbObjects = array('organizacao', 'area_status', 'centro_custo', 'localidade', 'funcionario', 'area', 'funcionario_status', 'telefone', 'substituicao', 'organizacao_organizacao_id_seq', 'area_status_area_status_id_seq', 'centro_custo_centro_custo_id_seq', 'localidade_localidade_id_seq', 'area_area_id_seq', 'funcionario_status_funcionario_status_id_seq', 'cargo', 'cargo_cargo_id_seq', 'funcionario_categoria', 'funcionario_categoria_funcionario_categoria_id_seq', 'telefone_telefone_id_seq', 'substituicao_substituicao_id_seq'); 
    129135 
    130136        foreach ($dbObjects as $dbObject) 
  • branches/2.2/workflow/setup/setup.inc.php

    r3031 r3167  
    1616        $setup_info['workflow']['app_order']    = 10; 
    1717        $setup_info['workflow']['enable']               = 1; 
    18         $setup_info['workflow']['author']               = 'Ported from tikiwiki, modified by regis_glc alpeb & mbartz<br>Customized to ExpressoLivre by viani, rodrigolira, mariceli, drovetto, carloseduardo, rufino, asaikawa, gbisotto, julianadelgado & rodsouza<br>See changeLog for full names.'; 
    19         $setup_info['workflow']['note']                 = 'Workflow engine'; 
     18        $setup_info['workflow']['author']               = 'See changeLog for complete list of developers.'; 
     19        $setup_info['workflow']['note']                 = 'Workflow Engine'; 
    2020        $setup_info['workflow']['license']              = 'GPL'; 
    2121        $setup_info['workflow']['description']          = 'Workflow Management'; 
  • branches/2.2/workflow/setup/tables_current.inc.php

    r1229 r3167  
    190190                                'fd' => array( 
    191191                                        'wf_parent_instance_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    192                                         'wf_parent_activity_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    193192                                        'wf_child_instance_id'  => array('type' => 'int', 'precision' => '4', 'nullable' => False), 
    194193                                        'wf_parent_lock'                => array('type' => 'int', 'precision' => '2', 'nullable' => True) 
    195194                                ), 
    196                                 'pk' => array('wf_parent_instance_id', 'wf_parent_activity_id', 'wf_child_instance_id'), 
     195                                'pk' => array('wf_parent_instance_id', 'wf_child_instance_id'), 
    197196                                'fk' => array(), 
    198197                                'ix' => array(), 
  • branches/2.2/workflow/setup/tables_update.inc.php

    r3031 r3167  
    3939                return $workflowHostInfo; 
    4040        } 
     41 
    4142        // Since Expresso 1.2 using Workflow 1.8.04.000 
    4243        $test[] = '1.8.04.000'; 
     
    131132                $GLOBALS['setup_info']['workflow']['currentver'] = '2.0.004'; 
    132133                return $GLOBALS['setup_info']['workflow']['currentver']; 
    133         }        
     134        } 
    134135        $test[] = '2.0.004'; 
    135136        function workflow_upgrade2_0_004() 
     
    142143        function workflow_upgrade2_1_000() 
    143144        { 
     145                if (!$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly) 
     146                { 
     147                        /* updating log level */ 
     148                        $values = array('0', 'workflow', 'log_level'); 
     149                        $GLOBALS['phpgw']->ADOdb->query('UPDATE phpgw_config SET config_value=? WHERE config_app=? AND config_name=?', $values); 
     150 
     151                        $workflowHostInfo = extractDatabaseParameters(); 
     152 
     153                        /* connect to workflow database */ 
     154                        $workflowDB = $GLOBALS['phpgw']->ADOdb; 
     155                        if ($workflowDB->connect($workflowHostInfo['host'], $workflowHostInfo['user'], $workflowHostInfo['password'], 'workflow')) 
     156                        { 
     157                                /* creating table substitution */ 
     158                                $workflowDB->query('CREATE TABLE substituicao (substituicao_id serial NOT NULL, area_id integer NOT NULL, funcionario_id integer NOT NULL, data_inicio date NOT NULL, data_fim date NOT NULL)'); 
     159 
     160                                $workflowDB->query('ALTER TABLE ONLY public.substituicao ADD CONSTRAINT substituicao_pkey PRIMARY KEY (substituicao_id)'); 
     161                                $workflowDB->query('ALTER TABLE ONLY public.substituicao ADD CONSTRAINT "$1" FOREIGN KEY (area_id) REFERENCES area(area_id)'); 
     162                                $workflowDB->query('ALTER TABLE ONLY public.substituicao ADD CONSTRAINT "$2" FOREIGN KEY (funcionario_id) REFERENCES funcionario(funcionario_id)'); 
     163 
     164                                /* granting privilegies */ 
     165                                $workflowDB->query("GRANT ALL ON TABLE public.substituicao TO admin_workflow"); 
     166                                $workflowDB->query("GRANT ALL ON TABLE public.substituicao TO postgres"); 
     167                                $workflowDB->query("GRANT SELECT ON TABLE public.substituicao TO public"); 
     168                                $workflowDB->query("GRANT ALL ON TABLE public.substituicao_substituicao_id_seq TO admin_workflow"); 
     169                                $workflowDB->query("GRANT ALL ON TABLE public.substituicao_substituicao_id_seq TO postgres"); 
     170                                $workflowDB->query("GRANT SELECT ON TABLE public.substituicao_substituicao_id_seq TO public"); 
     171 
     172                                /* migrating records */ 
     173                                $result = $workflowDB->query('SELECT area_id, substituto_funcionario_id FROM area WHERE substituto_funcionario_id IS NOT NULL'); 
     174                                if ($result) 
     175                                        while ($row = $result->fetchRow()) { 
     176                                                $values = array($row['area_id'], $row['substituto_funcionario_id']); 
     177                                                $workflowDB->query('INSERT INTO substituicao (area_id, funcionario_id, data_inicio, data_fim) VALUES (?, ?, CURRENT_DATE, CURRENT_DATE+integer \'7\')', $values); 
     178                                        } 
     179 
     180 
     181                                /* erasing old atributes */ 
     182                                $workflowDB->query("ALTER TABLE area DROP COLUMN substituto_funcionario_id"); 
     183                        } 
     184 
     185                        /* reconnect to the previous database */ 
     186                        $GLOBALS['phpgw']->ADOdb->connect($workflowHostInfo['host'], $workflowHostInfo['user'], $workflowHostInfo['password'], $workflowHostInfo['dbname']); 
     187 
     188                        /* removing primary key of egw_wf_interinstance_relations */ 
     189                        $GLOBALS['phpgw']->ADOdb->query('ALTER TABLE egw_wf_interinstance_relations DROP CONSTRAINT egw_wf_interinstance_relations_pkey'); 
     190 
     191                        /* removing wf_parent_activity_id column from egw_wf_interinstance_relations table */ 
     192                        $GLOBALS['phpgw']->ADOdb->query('ALTER TABLE egw_wf_interinstance_relations DROP COLUMN wf_parent_activity_id'); 
     193 
     194                        /* adding primary key without the column removed */ 
     195                        $GLOBALS['phpgw']->ADOdb->query('ALTER TABLE egw_wf_interinstance_relations ADD CONSTRAINT egw_wf_interinstance_relations_pkey PRIMARY KEY (wf_parent_instance_id, wf_child_instance_id)'); 
     196                } 
     197 
     198                #updating the current version 
    144199                $GLOBALS['setup_info']['workflow']['currentver'] = '2.2.000'; 
    145200                return $GLOBALS['setup_info']['workflow']['currentver']; 
    146         }        
     201        } 
    147202?> 
  • branches/2.2/workflow/showUserPicture.php

    r1468 r3167  
    1212if (empty($_SESSION)) 
    1313        exit(0); 
    14 $GLOBALS['workflow']['factory']->getInstance('UserPictureProvider')->serve(); 
     14Factory::getInstance('UserPictureProvider')->serve(); 
    1515?> 
  • branches/2.2/workflow/templateFile.php

    r1468 r3167  
    1212if (empty($_SESSION)) 
    1313        exit(0); 
    14 $GLOBALS['workflow']['factory']->getInstance('TemplateServer')->redirect(); 
     14Factory::getInstance('TemplateServer')->redirect(); 
    1515?> 
  • branches/2.2/workflow/templates/default/adminaccess.tpl

    r795 r3167  
    1313                                </td> 
    1414                        {/foreach} 
    15                                 <td nowrap id="border_blank" class="abas_last_menu" width="100%"> 
     15                                <td nowrap id="border_blank" class="last_menu" width="100%"> 
    1616                                        &nbsp; 
    1717                                </td> 
     
    2020        </table> 
    2121{foreach from=$tabs item=tab name="feTabs"} 
    22         <div id="content_id_{$smarty.foreach.feTabs.index}" class="conteudo_div"></div> 
     22        <div id="content_id_{$smarty.foreach.feTabs.index}" class="conteudo"></div> 
    2323{/foreach} 
    2424</div> 
  • branches/2.2/workflow/templates/default/adminsource.tpl

    r795 r3167  
    1414                                </td> 
    1515                        {/foreach} 
    16                                 <td nowrap id="border_blank" class="abas_last_menu" width="100%"> 
     16                                <td nowrap id="border_blank" class="last_menu" width="100%"> 
    1717                                        &nbsp; 
    1818                                </td> 
     
    2121        </table> 
    2222{foreach from=$tabs item=tab name="feTabs"} 
    23         <div id="content_id_{$smarty.foreach.feTabs.index}" class="conteudo_div"></div> 
     23        <div id="content_id_{$smarty.foreach.feTabs.index}" class="conteudo"></div> 
    2424{/foreach} 
    2525</div> 
  • branches/2.2/workflow/templates/default/css/common.css

    r795 r3167  
    189189 
    190190.info_tr_header{ 
    191         background-color: #cccccc; 
     191        /*background-color: #cccccc;*/ 
    192192        font-weight: bold; 
    193193        font-size: 13px;         
     
    268268 
    269269.table_elements_tr_header { 
    270         background-color: #CCCCCC; 
     270        /*background-color: #ABC6E1;*/ 
    271271} 
    272272 
  • branches/2.2/workflow/templates/default/css/orgchart.css

    r795 r3167  
    1616table.organizationList tbody tr th 
    1717{ 
    18         background-color: #CCCCCC; 
     18        /*background-color: #CCCCCC;*/ 
    1919} 
    2020 
    2121table.organizationList tbody tr.linha0 
    2222{ 
    23         background-color: #F2F2F2; 
     23        /*background-color: #F2F2F2;*/ 
    2424        font-size: 12px; 
    2525} 
     
    2727table.organizationList tbody tr.linha1 
    2828{ 
    29         background-color: #E5E5E5; 
     29        /*background-color: #E5E5E5;*/ 
    3030        font-size: 12px; 
    3131} 
     
    106106table.employeeList tbody th 
    107107{ 
    108         background-color: #CCCCCC; 
     108        /*background-color: #CCCCCC;*/ 
    109109        font-size: 13px; 
    110110} 
     
    112112table.employeeList tbody tr.linha0 
    113113{ 
    114         background-color: #FFF; 
     114        /*background-color: #FFF;*/ 
    115115        font-size: 12px; 
    116116} 
     
    118118table.employeeList tbody tr.linha1 
    119119{ 
    120         background-color: #F7F7F7; 
     120        /*background-color: #F7F7F7;*/ 
    121121        font-size: 12px; 
    122122} 
  • branches/2.2/workflow/templates/default/css/userinterface.css

    r795 r3167  
    126126        font-size: 11px !important; 
    127127        font-weight: normal; 
    128         background-color: #CCCCCC; 
     128        /*background-color: #ABC6E1;*/ 
    129129} 
    130130 
  • branches/2.2/workflow/templates/default/monitors.tpl

    r795 r3167  
    1313                                </td> 
    1414                        {/foreach} 
    15                                 <td nowrap id="border_blank" class="abas_last_menu" width="100%"> 
     15                                <td nowrap id="border_blank" class="last_menu" width="100%"> 
    1616                                        &nbsp; 
    1717                                </td> 
     
    2020        </table> 
    2121{foreach from=$tabs item=tab name="feTabs"} 
    22         <div id="content_id_{$smarty.foreach.feTabs.index}" class="conteudo_div"></div> 
     22        <div id="content_id_{$smarty.foreach.feTabs.index}" class="conteudo"></div> 
    2323{/foreach} 
    2424</div> 
  • branches/2.2/workflow/templates/default/orgchart.tpl

    r795 r3167  
    77                <tbody id="border_tbody"> 
    88                        <tr id="border_tr"> 
    9                                 <td nowrap class="abas_menu" id="border_id_0" onClick="(alternate_border(0) == 0) ? draw_org_folder() : ''"> 
     9                                <td nowrap class="menu" id="border_id_0" onClick="(alternate_border(0) == 0) ? draw_org_folder() : ''"> 
    1010                                        &nbsp;&nbsp;Organograma&nbsp;&nbsp; 
    1111                                </td> 
    12                                 <td nowrap id="border_blank" class="abas_last_menu" width="100%"> 
     12                                <td nowrap id="border_blank" class="last_menu" width="100%"> 
    1313                                        &nbsp; 
    1414                                </td> 
     
    1616                </tbody> 
    1717        </table> 
    18         <div id="content_id_0" class="conteudo_div"></div> 
     18        <div id="content_id_0" class="conteudo"></div> 
    1919</div> 
    2020{$footer} 
  • branches/2.2/workflow/templates/default/orgchartPrint.tpl

    r795 r3167  
    1010        <label><input type="checkbox" checked id="employeesVisibility" /> Exibir funcionários</label> 
    1111        <br/> 
     12        <label><input type="checkbox" checked id="groupByArea" /> Agrupar por área</label> 
     13        <br/> 
    1214        <label><input type="checkbox" checked id="highlightSupervisor" /> Ressaltar titular</label> 
    1315        <br/> 
     
    1719</div> 
    1820 
     21 
    1922{if !empty($organizationName)} 
    2023<h1 class="organizationName">{$organizationName}</h1> 
    2124{/if} 
    2225 
    23 {foreach from=$areasInfo item=area} 
    24         <div class="area"> 
    25                 <h1><span class="orgchartPath">{$area.orgchartPath}</span>{$area.sigla}</h1> 
    26                 <div class="employees"> 
    27                         <table width="90%"> 
    28                         {foreach from=$area.employees item=employee} 
    29                         <tr> 
    30                         <td width="85%"><span class="employee{if $employee.funcionario_id == $area.titular_funcionario_id}supervisor{/if}">{$employee.cn}</span></td> 
    31                         <td width="15%" align="right">{$employee.telephoneNumber}</td> 
    32                         </tr> 
    33                         {/foreach} 
    34                         </table> 
    35                 </div> 
    36         </div> 
    37 {/foreach} 
     26<div id="areas_content" /> 
     27 
    3828{$footer} 
    3929</body> 
    4030</html> 
     31<script language="javascript"> 
     32var areas = {$areasJson}; 
     33</script> 
  • branches/2.2/workflow/templates/default/participants.tpl

    r795 r3167  
    3232                <td colspan="2"> 
    3333                        <p style="text-align: center; font-weight: bold; font-size: 130%;">Busca Global</p> 
     34                </td> 
     35        </tr> 
     36        <tr> 
     37                <td colspan="2"> 
     38                        <label><input type="checkbox" name="onlyVisibleAccounts" id="onlyVisibleAccounts" value="true" {if $onlyVisibleAccounts} checked {/if}/> Exibir apenas contas vis&iacute;veis</label> 
    3439                </td> 
    3540        </tr> 
  • branches/2.2/workflow/templates/default/userinterface.tpl

    r795 r3167  
    1010                        {foreach from=$tabs item=tab name="feTabs"} 
    1111                                {assign var='index' value=$smarty.foreach.feTabs.index} 
    12                                 <td nowrap class="abas_menu" id="border_id_{$index}" onClick="changeTab({$index})"> 
     12                                <td nowrap class="menu" id="border_id_{$index}" onClick="changeTab({$index})"> 
    1313                                        &nbsp;&nbsp;{$tab}&nbsp;&nbsp; 
    1414                                </td> 
    1515                        {/foreach} 
    16                                 <td nowrap id="border_blank" class="abas_last_menu" width="100%"> 
     16                                <td nowrap id="border_blank" class="last_menu" width="100%"> 
    1717                                        &nbsp; 
    1818                                </td> 
     
    2121        </table> 
    2222{foreach from=$tabs item=tab name="feTabs"} 
    23         <div id="content_id_{$smarty.foreach.feTabs.index}" class="conteudo_div"></div> 
     23        <div id="content_id_{$smarty.foreach.feTabs.index}" class="conteudo"></div> 
    2424{/foreach} 
    2525</div> 
Note: See TracChangeset for help on using the changeset viewer.