Changeset 3167


Ignore:
Timestamp:
08/17/10 16:17:12 (13 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()