예제 #1
0
 /**
  * WebResource
  *
  * @param string $uri
  * @param string $post
  *
  * @return none
  */
 function WebResource($uri, $post)
 {
     $this->_uri = $uri;
     if (isset($post['function']) && $post['function'] != '') {
         /*Call a function*/
         header('Content-Type: text/json');
         //$parameters=G::json_decode((urldecode($post['parameters']))); //for %AC
         $parameters = G::json_decode($post['parameters']);
         $paramsRef = array();
         foreach ($parameters as $key => $value) {
             if (is_string($key)) {
                 $paramsRef[] = "\$parameters['" . addcslashes($key, '\\\'') . "']";
             } else {
                 $paramsRef[] = '$parameters[' . $key . ']';
             }
         }
         $paramsRef = implode(',', $paramsRef);
         G::LoadSystem('inputfilter');
         $filter = new InputFilter();
         $post['function'] = $filter->validateInput($post['function']);
         $paramsRef = $filter->validateInput($paramsRef);
         $res = eval('return ($this->' . $post['function'] . '(' . $paramsRef . '));');
         $res = G::json_encode($res);
         print $res;
     } else {
         /*Print class definition*/
         $this->_encode();
     }
 }
예제 #2
0
function install($file)
{
    G::LoadThirdParty("pear/Archive", "Tar");
    $result = array();
    $status = 1;
    try {
        //Extract
        $tar = new Archive_Tar($file);
        $swTar = $tar->extract(PATH_OUTTRUNK);
        //true on success, false on error. //directory for extract
        //$swTar = $tar->extract(PATH_PLUGINS);
        if (!$swTar) {
            throw new Exception("Could not extract file.");
        }
        //Upgrade
        $option = array("http" => array("method" => "POST"));
        // Proxy settings
        $sysConf = System::getSystemConfiguration();
        if (isset($sysConf['proxy_host'])) {
            if ($sysConf['proxy_host'] != '') {
                if (!is_array($option['http'])) {
                    $option['http'] = array();
                }
                $option['http']['request_fulluri'] = true;
                $option['http']['proxy'] = 'tcp://' . $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '');
                if ($sysConf['proxy_user'] != '') {
                    if (!isset($option['http']['header'])) {
                        $option['http']['header'] = '';
                    }
                    $option['http']['header'] .= 'Proxy-Authorization: Basic ' . base64_encode($sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
                }
            }
        }
        $context = stream_context_create($option);
        ///////
        $fileData = @fopen(EnterpriseUtils::getUrlServerName() . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/enterprise/services/processMakerUpgrade", "rb", false, $context);
        if ($fileData === false) {
            throw new Exception("Could not open services url.");
        }
        $resultAux = G::json_decode(stream_get_contents($fileData));
        if ($resultAux->status == "OK") {
            $result["status"] = $resultAux->status;
            //OK
            $result["message"] = $resultAux->message;
        } else {
            throw new Exception($resultAux->message);
        }
    } catch (Exception $e) {
        $result["message"] = $e->getMessage();
        $status = 0;
    }
    if ($status == 0) {
        $result["status"] = "ERROR";
    }
    return $result;
}
    static public function letsRestore ($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true)
    {
        // Needed info:
        // TEMPDIR  /shared/workflow_data/upgrade/
        // BACKUPS  /shared/workflow_data/backups/
        // Creating command  cat myfiles_split.tgz_* | tar xz
        $DecommpressCommand = "cat " . $filename . ".* ";
        $DecommpressCommand .= " | tar xzv";

        $tempDirectory = PATH_DATA . "upgrade/" . basename( tempnam( __FILE__, '' ) );
        $parentDirectory = PATH_DATA . "upgrade";
        if (is_writable( $parentDirectory )) {
            mkdir( $tempDirectory );
        } else {
            throw new Exception( "Could not create directory:" . $parentDirectory );
        }
        //Extract all backup files, including database scripts and workspace files
        CLI::logging( "Restoring into " . $tempDirectory . "\n" );
        chdir( $tempDirectory );
        echo exec( $DecommpressCommand );
        CLI::logging( "\nUncompressed into: " . $tempDirectory . "\n" );

        //Search for metafiles in the new standard (the old standard would contain meta files.
        $metaFiles = glob( $tempDirectory . "/*.meta" );
        if (empty( $metaFiles )) {
            $metaFiles = glob( $tempDirectory . "/*.txt" );
            if (! empty( $metaFiles )) {
                return workspaceTools::restoreLegacy( $tempDirectory );
            } else {
                throw new Exception( "No metadata found in backup" );
            }
        } else {
            CLI::logging( "Found " . count( $metaFiles ) . " workspaces in backup:\n" );
            foreach ($metaFiles as $metafile) {
                CLI::logging( "-> " . basename( $metafile ) . "\n" );
            }
        }
        if (count( $metaFiles ) > 1 && (! isset( $srcWorkspace ))) {
            throw new Exception( "Multiple workspaces in backup but no workspace specified to restore" );
        }
        if (isset( $srcWorkspace ) && ! in_array( "$srcWorkspace.meta", array_map( basename, $metaFiles ) )) {
            throw new Exception( "Workspace $srcWorkspace not found in backup" );
        }
        foreach ($metaFiles as $metaFile) {
            $metadata = G::json_decode( file_get_contents( $metaFile ) );
            if ($metadata->version != 1) {
                throw new Exception( "Backup version {$metadata->version} not supported" );
            }
            $backupWorkspace = $metadata->WORKSPACE_NAME;
            if (isset( $dstWorkspace )) {
                $workspaceName = $dstWorkspace;
                $createWorkspace = true;
            } else {
                $workspaceName = $metadata->WORKSPACE_NAME;
                $createWorkspace = false;
            }
            if (isset( $srcWorkspace ) && strcmp( $metadata->WORKSPACE_NAME, $srcWorkspace ) != 0) {
                CLI::logging( CLI::warning( "> Workspace $backupWorkspace found, but not restoring." ) . "\n" );
                continue;
            } else {
                CLI::logging( "> Restoring " . CLI::info( $backupWorkspace ) . " to " . CLI::info( $workspaceName ) . "\n" );
            }
            $workspace = new workspaceTools( $workspaceName );
            if ($workspace->workspaceExists()) {
                if ($overwrite) {
                    CLI::logging( CLI::warning( "> Workspace $workspaceName already exist, overwriting!" ) . "\n" );
                } else {
                    throw new Exception( "Destination workspace already exist (use -o to overwrite)" );
                }
            }
            if (file_exists( $workspace->path )) {
                G::rm_dir( $workspace->path );
            }
            foreach ($metadata->directories as $dir) {
                CLI::logging( "+> Restoring directory '$dir'\n" );
                if (! rename( "$tempDirectory/$dir", $workspace->path )) {
                    throw new Exception( "There was an error copying the backup files ($tempDirectory/$dir) to the workspace directory {$workspace->path}." );
                }
            }

            CLI::logging( "> Changing file permissions\n" );
            $shared_stat = stat( PATH_DATA );
            if ($shared_stat !== false) {
                workspaceTools::dirPerms( $workspace->path, $shared_stat['uid'], $shared_stat['gid'], $shared_stat['mode'] );
            } else {
                CLI::logging( CLI::error( "Could not get the shared folder permissions, not changing workspace permissions" ) . "\n" );
            }

            list ($dbHost, $dbUser, $dbPass) = @explode( SYSTEM_HASH, G::decrypt( HASH_INSTALLATION, SYSTEM_HASH ) );

            CLI::logging( "> Connecting to system database in '$dbHost'\n" );
            $link = mysql_connect( $dbHost, $dbUser, $dbPass );
            @mysql_query( "SET NAMES 'utf8';" );
            @mysql_query( "SET FOREIGN_KEY_CHECKS=0;" );
            if (! $link) {
                throw new Exception( 'Could not connect to system database: ' . mysql_error() );
            }

            $newDBNames = $workspace->resetDBInfo( $dbHost, $createWorkspace );

            foreach ($metadata->databases as $db) {
                $dbName = $newDBNames[$db->name];
                CLI::logging( "+> Restoring database {$db->name} to $dbName\n" );
                $workspace->executeSQLScript( $dbName, "$tempDirectory/{$db->name}.sql" );
                $workspace->createDBUser( $dbName, $db->pass, "localhost", $dbName );
                $workspace->createDBUser( $dbName, $db->pass, "%", $dbName );
            }
            $workspace->upgradeCacheView( false );
            mysql_close( $link );

        }
        CLI::logging( "Removing temporary files\n" );
        G::rm_dir( $tempDirectory );
        CLI::logging( CLI::info( "Done restoring" ) . "\n" );
    }
예제 #4
0
 /**
  * Execute a query in base to Request data
  *
  * @param Entity_FacetRequest $facetRequestEntity
  * @return solr response: list of facets array
  */
 public function getFacetsList($facetRequest)
 {
     if (!$this->_solrIsEnabled) {
         return;
     }
     $solrIntruct = '';
     // get configuration information in base to workspace parameter
     $workspace = $facetRequest->workspace;
     // format request
     $query = empty($facetRequest->searchText) ? '*:*' : $facetRequest->searchText;
     $query = rawurlencode($query);
     $start = '&start=0';
     $rows = '&rows=0';
     $facets = '&facet=on&facet.mincount=1&facet.limit=20';
     // enable facet and
     // only return facets
     // with minimun one
     // instance
     foreach ($facetRequest->facetFields as $value) {
         $facets .= '&facet.field=' . $value;
     }
     foreach ($facetRequest->facetQueries as $value) {
         $facets .= '&facet.query=' . $value;
     }
     if (!empty($facetRequest->facetDates)) {
         foreach ($facetRequest->facetDates as $value) {
             $facets .= '&facet.date=' . $value;
         }
         $facets .= '&facet.date.start=' . $facetRequest->facetDatesStart;
         $facets .= '&facet.date.end=' . $facetRequest->facetDatesEnd;
         $facets .= '&facet.date.gap=' . $facetRequest->facetDateGap;
     }
     $filters = '';
     foreach ($facetRequest->filters as $value) {
         $filters .= '&fq=' . $value;
     }
     // echo "<pre>";
     $resultFormat = '&wt=json';
     $solrIntruct = substr($this->_solrHost, -1) == "/" ? $this->_solrHost : $this->_solrHost . "/";
     $solrIntruct .= $workspace;
     $solrIntruct .= "/select/?q={$query}";
     $solrIntruct .= "&echoParams=none";
     $solrIntruct .= self::SOLR_VERSION;
     $solrIntruct .= $start;
     $solrIntruct .= $rows;
     $solrIntruct .= $facets;
     $solrIntruct .= $filters;
     $solrIntruct .= $resultFormat;
     // send query
     // search the cases in base to datatable parameters
     $handler = curl_init($solrIntruct);
     curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
     //Apply proxy settings
     $sysConf = System::getSystemConfiguration();
     if ($sysConf['proxy_host'] != '') {
         curl_setopt($handler, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
         if ($sysConf['proxy_port'] != '') {
             curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
         }
         if ($sysConf['proxy_user'] != '') {
             curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
         }
         curl_setopt($handler, CURLOPT_HTTPHEADER, array('Expect:'));
     }
     $response = curl_exec($handler);
     curl_close($handler);
     // decode
     $responseSolr = G::json_decode($response);
     if ($responseSolr->responseHeader->status != 0) {
         throw new Exception("Error getting faceted list from Solr." . $solrIntruct . " response error: " . $response . "\n");
     }
     return $responseSolr;
 }
예제 #5
0
 /**
  * @covers G::json_decode
  * @todo   Implement testJson_decode().
  */
 public function testJson_decode()
 {
     $jsonTest = '{"pos1":"value1","pos2":"value2","pos3":"value3"}';
     $response = G::json_decode($jsonTest);
     $this->assertEquals($response->pos1, 'value1');
     $this->assertEquals($response->pos2, 'value2');
     $this->assertEquals($response->pos3, 'value3');
 }
/**
 *
 * @method Get DWS Document Versions
 *
 * @name getDWSDocumentVersions
 * @label Get DWS Document Versions
 *
 * @param string | $sharepointServer | Server name and port whre DWS wsdl exists, including protocol | http://server:port/_vti_bin/Dws.asmx?WSDL
 * @param string | $auth | Valid Auth string to connect to server | user:password
 * @param string | $newFileName | Name of New File
 * @param string | $dwsname | Name of DWS
 *
 * @return string | $result | Response
 *
 */
function getDWSDocumentVersions($sharepointServer, $auth, $newFileName, $dwsname)
{
    require_once PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php';
    $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth);
    $result = $pmTrSharepoint->getDWSDocumentVersions($newFileName, $dwsname);
    if (isset($result->GetVersionsResult)) {
        /*
         * Code to get the Document's Version/s
         */
        $xml = $result->GetVersionsResult->any;
        // in Result we get string in Xml format
        $xmlNew = simplexml_load_string($xml);
        // used to parse string to xml
        $xmlArray = @G::json_decode(@G::json_encode($xmlNew), 1);
        // used to convert Objects to array
        $resultCount = count($xmlArray['result']);
        for ($i = 0; $i < $resultCount; $i++) {
            $version[] = $xmlArray['result'][$i]['@attributes']['version'];
        }
        $serializeResult = serialize($version);
        // serializing the Array for Returning.
        return $serializeResult;
    } else {
        return "No version found";
    }
}
    public function sendActionsByEmail($data)
    {
        try {
            // Validations
            try {
                if (!is_object($data)) {
                    throw new Exception('The parameter $data is null.');
                }
                if (!isset($data->TAS_UID)) {
                    throw new Exception('The parameter $data->TAS_UID is null.');
                }

                if (!isset($data->APP_UID)) {
                    throw new Exception('The parameter $data->APP_UID is null.');
                }

                if (!isset($data->DEL_INDEX)) {
                    throw new Exception('The parameter $data->DEL_INDEX is null.');
                }

                if (!isset($data->USR_UID)) {
                    throw new Exception('The parameter $data->USR_UID is null.');
                }

                if ($data->TAS_UID == '') {
                    throw new Exception('The parameter $data->TAS_UID is empty.');
                }

                if ($data->APP_UID == '') {
                    throw new Exception('The parameter $data->APP_UID is empty.');
                }

                if ($data->DEL_INDEX == '') {
                    throw new Exception('The parameter $data->DEL_INDEX is empty.');
                }

                if ($data->USR_UID == '') {
                    throw new Exception('The parameter $data->USR_UID is empty.');
                }
            } catch(Exception $e) {
                echo $e->getMessage().' Please contact to your system administrator.';
                die;
            }

            G::LoadClass('pmFunctions');

            $emailSetup = getEmailConfiguration();

            if (!empty($emailSetup)) {
                require_once 'classes/model/AbeConfiguration.php';
                G::LoadClass('case');

                $cases = new Cases();
                $caseFields = $cases->loadCase($data->APP_UID);
                $criteria = new Criteria();
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_UID);
                $criteria->addSelectColumn(AbeConfigurationPeer::PRO_UID);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_TYPE);
                $criteria->addSelectColumn(AbeConfigurationPeer::TAS_UID);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_TEMPLATE);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_DYN_TYPE);
                $criteria->addSelectColumn(AbeConfigurationPeer::DYN_UID);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_EMAIL_FIELD);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_ACTION_FIELD);
                $criteria->addSelectColumn(AbeConfigurationPeer::ABE_SUBJECT_FIELD);
                $criteria->addSelectColumn(DynaformPeer::DYN_CONTENT);
                $criteria->addJoin( AbeConfigurationPeer::DYN_UID, DynaformPeer::DYN_UID, Criteria::LEFT_JOIN );
                $criteria->add(AbeConfigurationPeer::PRO_UID, $caseFields['PRO_UID']);
                $criteria->add(AbeConfigurationPeer::TAS_UID, $data->TAS_UID);
                $result = AbeConfigurationPeer::doSelectRS($criteria);
                $result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                $result->next();
                if ($configuration = $result->getRow()) {
                    $configuration['ABE_EMAIL_FIELD'] = str_replace('@@', '', $configuration['ABE_EMAIL_FIELD']);
                    if ($configuration['ABE_EMAIL_FIELD'] != '' && isset($caseFields['APP_DATA'][$configuration['ABE_EMAIL_FIELD']])) {
                        $email = trim($caseFields['APP_DATA'][$configuration['ABE_EMAIL_FIELD']]);
                    } else {
                        require_once 'classes/model/Users.php';

                        $userInstance = new Users();
                        $userInfo     = $userInstance->getAllInformation($data->USR_UID);
                        $email        = $userInfo['mail'];
                    }

                    if ($email != '') {
                        $subject = G::replaceDataField( $configuration['ABE_SUBJECT_FIELD'], $caseFields['APP_DATA'] );
                        if($subject == ''){
                            $subject = $caseFields['APP_TITLE'];
                        }

                        // Create
                        require_once 'classes/model/AbeRequests.php';

                        $abeRequest = array();
                        $abeRequest['ABE_REQ_UID']      = '';
                        $abeRequest['ABE_UID']          = $configuration['ABE_UID'];
                        $abeRequest['APP_UID']          = $data->APP_UID;
                        $abeRequest['DEL_INDEX']        = $data->DEL_INDEX;
                        $abeRequest['ABE_REQ_SENT_TO']  = $email;
                        $abeRequest['ABE_REQ_SUBJECT']  = $subject;
                        $abeRequest['ABE_REQ_BODY']     = '';
                        $abeRequest['ABE_REQ_ANSWERED'] = 0;
                        $abeRequest['ABE_REQ_STATUS']   = 'PENDING';

                        try {
                            $abeRequestsInstance = new AbeRequests();
                            $abeRequest['ABE_REQ_UID'] = $abeRequestsInstance->createOrUpdate($abeRequest);
                        } catch (Exception $error) {
                            throw $error;
                        }

                        if ($configuration['ABE_TYPE'] != '') {
                            // Email
                            $_SESSION['CURRENT_DYN_UID'] = $configuration['DYN_UID'];

                            $scriptCode = '';
//                            foreach ($dynaform->fields as $fieldName => $field) {
//                                if ($field->type == 'submit') {
//                                    unset($dynaform->fields[$fieldName]);
//                                }
//                            }

                            $__ABE__ = '';
                            $link = (G::is_https() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/ActionsByEmail';

                            switch ($configuration['ABE_TYPE']) {
                                case 'LINK':
                                    // $__ABE__ .= $dynaform->render(PATH_FEATURES . 'actionsByEmail/xmlform.html', $scriptCode) . '<br />';
                                    $__ABE__ .= '<a href="' . $link . 'DataForm?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&DYN_UID=' . G::encrypt($configuration['DYN_UID'], URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Please complete this form</a>';
                                    break;
                                // coment
                                case 'FIELD':
                                        $variableService = new \ProcessMaker\Services\Api\Project\Variable();
                                        $variables = $variableService->doGetVariables($caseFields['PRO_UID']);
                                        $field = new stdClass();
                                        $field->label = 'Test';
                                        $field->type = 'dropdown';
                                        $field->options = array();
                                        $actionField = str_replace('@@', '', $configuration['ABE_ACTION_FIELD']);
                                        $dynaform = $configuration['DYN_UID'];
                                        $variables = G::json_decode($configuration['DYN_CONTENT'], true);
                                        if(isset($variables['items'][0]['items'])){
                                            $fields = $variables['items'][0]['items'];
                                            foreach ($fields as $key => $value) {
                                                foreach($value as $var){ G::pr($var);
                                                    if(isset($var['variable'])){
                                                        if ($var['variable'] == $actionField) {
                                                             $field->label = $var['label'];
                                                             $field->type  = $var['type'];
                                                             $values = $var['options'];
                                                             foreach ($values as $val){
                                                               $field->options[$val['value']] = $val['value'];
                                                             }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        G::LoadClass('pmDynaform');
                                        $obj = new pmDynaform($configuration['DYN_UID']);
                                        $configuration['CURRENT_DYNAFORM'] = $configuration['DYN_UID'];
                                        $file = $obj->printPmDynaformAbe($configuration);
                                        $__ABE__ .= $file;
                                        $__ABE__ .= '<strong>' . $field->label . '</strong><br /><table align="left" border="0"><tr>';
                                        switch ($field->type) {
                                            case 'dropdown':
                                            case 'radiogroup':
                                                $index = 1;
                                                $__ABE__.='<br /><td><table align="left" cellpadding="2"><tr>';
                                                foreach ($field->options as $optValue => $optName) {
                                                    $__ABE__ .= '<td align="center"><a style="text-decoration: none; color: #000; background-color: #E5E5E5; ';
                                                    $__ABE__ .= 'filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#EFEFEF, endColorstr=#BCBCBC); ';
                                                    $__ABE__ .= 'background-image: -webkit-gradient(linear, left top, left bottom, from(#EFEFEF), #BCBCBC); ';
                                                    $__ABE__ .= 'background-image: -webkit-linear-gradient(top, #EFEFEF, #BCBCBC); ';
                                                    $__ABE__ .= 'background-image: -moz-linear-gradient(top, #EFEFEF, #BCBCBC); background-image: -ms-linear-gradient(top, #EFEFEF, #BCBCBC); ';
                                                    $__ABE__ .= 'background-image: -o-linear-gradient(top, #EFEFEF, #BCBCBC); border: 1px solid #AAAAAA; ';
                                                    $__ABE__ .= 'border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); ';
                                                    $__ABE__ .= 'font-family: Arial,serif; font-size: 9pt; font-weight: 400; line-height: 14px; margin: 2px 0; padding: 2px 7px; ';
                                                    $__ABE__ .= 'text-decoration: none; text-transform: capitalize;" href="' .urldecode(urlencode($link)). '?ACTION='.G::encrypt('processABE', URL_KEY).'&APP_UID=';
                                                    $__ABE__ .= G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY);
                                                    $__ABE__ .= '&FIELD=' . G::encrypt($actionField, URL_KEY) . '&VALUE=' . G::encrypt($optValue, URL_KEY);
                                                    $__ABE__ .= '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank" >' . $optName;
                                                    $__ABE__ .= '</a></td>' . (($index % 5 == 0) ? '</tr><tr>' : '  ');
                                                    $index++;
                                                }

                                                $__ABE__.='</tr></table></td>';
                                                break;
                                            case 'yesno':
                                                $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . urlencode(G::encrypt($data->APP_UID, URL_KEY)) . '&DEL_INDEX=' . urlencode(G::encrypt($data->DEL_INDEX, URL_KEY)). '&FIELD=' . urlencode(G::encrypt($actionField, URL_KEY)) . '&VALUE=' . urlencode(G::encrypt(1, URL_KEY)) . '&ABER=' . urlencode(G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY)) . '" target="_blank">' . G::LoadTranslation('ID_YES_VALUE') . '</a></td>';
                                                $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . urlencode(G::encrypt($data->APP_UID, URL_KEY)) . '&DEL_INDEX=' . urlencode(G::encrypt($data->DEL_INDEX, URL_KEY)) . '&FIELD=' . urlencode(G::encrypt($actionField, URL_KEY)) . '&VALUE=' . urlencode(G::encrypt(0, URL_KEY)) . '&ABER=' . urlencode(G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY)) . '" target="_blank">' . G::LoadTranslation('ID_NO_VALUE') . '</a></td>';
                                                break;
                                            case 'checkbox':
                                                $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&FIELD=' . G::encrypt($actionField, URL_KEY) . '&VALUE=' . G::encrypt($field->value, URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Check</a></td>';
                                                $__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&FIELD=' . G::encrypt($actionField, URL_KEY) . '&VALUE=' . G::encrypt($field->value, URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Uncheck</a></td>';
                                                break;
                                        }
                                        $__ABE__ .= '</tr></table>';
                                    break;
                            }

                            $__ABE__ = preg_replace('/\<img src=\"\/js\/maborak\/core\/images\/(.+?)\>/', '' , $__ABE__);
                            $__ABE__ = preg_replace('/\<input\b[^>]*\/>/', '' , $__ABE__);
                            $__ABE__ = preg_replace('/<select\b[^>]*>(.*?)<\/select>/is', "", $__ABE__);
                            $__ABE__ = preg_replace('/align=\"center\"/', '' , $__ABE__);
                            $__ABE__ = preg_replace('/class="tableGrid_view" /', 'class="tableGrid_view" width="100%" ', $__ABE__);
                            $caseFields['APP_DATA']['__ABE__'] = $__ABE__;

                            G::LoadClass("Users");

                            $user = new Users();
                            $userDetails = $user->loadDetails($data->PREVIOUS_USR_UID);
                            $emailFrom = $userDetails["USR_EMAIL"];

                            G::LoadClass('wsBase');

                            $wsBaseInstance = new wsBase();
                            $result = $wsBaseInstance->sendMessage($data->APP_UID,
                                                                   $emailFrom,
                                                                   $email,
                                                                   '',
                                                                   '',
                                                                   $subject,
                                                                   $configuration['ABE_TEMPLATE'],
                                                                   $caseFields['APP_DATA'],
                                                                   '');
                            $abeRequest['ABE_REQ_STATUS'] = ($result->status_code == 0 ? 'SENT' : 'ERROR');

                            $body = '';
                            $messageSent = executeQuery('SELECT `APP_MSG_BODY` FROM `APP_MESSAGE` ORDER BY `APP_MSG_SEND_DATE` DESC LIMIT 1');

                            if (!empty($messageSent) && is_array($messageSent)) {
                                $body = $messageSent[1]['APP_MSG_BODY'];
                            }

                            $abeRequest['ABE_REQ_BODY'] = $body;

                            // Update 
                            try {
                                $abeRequestsInstance = new AbeRequests();
                                $abeRequestsInstance->createOrUpdate($abeRequest);
                            } catch (Exception $error) {
                                throw $error;
                            }
                        }
                    }
                }
            }
        } catch (Exception $error) {
            throw $error;
        }
    }
예제 #8
0
 /**
  * restore an archive into a workspace
  *
  * Restores any database and files included in the backup, either as a new
  * workspace, or overwriting a previous one
  *
  * @param string $filename the backup filename
  * @param string $newWorkspaceName if defined, supplies the name for the
  * workspace to restore to
  */
 public static function restore($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true)
 {
     G::LoadThirdParty('pear/Archive', 'Tar');
     $backup = new Archive_Tar($filename);
     //Get a temporary directory in the upgrade directory
     $tempDirectory = PATH_DATA . "upgrade/" . basename(tempnam(__FILE__, ''));
     $parentDirectory = PATH_DATA . "upgrade";
     if (is_writable($parentDirectory)) {
         mkdir($tempDirectory);
     } else {
         throw new Exception("Could not create directory:" . $parentDirectory);
     }
     //Extract all backup files, including database scripts and workspace files
     if (!$backup->extract($tempDirectory)) {
         throw new Exception("Could not extract backup");
     }
     //Search for metafiles in the new standard (the old standard would contain
     //txt files).
     $metaFiles = glob($tempDirectory . "/*.meta");
     if (empty($metaFiles)) {
         $metaFiles = glob($tempDirectory . "/*.txt");
         if (!empty($metaFiles)) {
             return workspaceTools::restoreLegacy($tempDirectory);
         } else {
             throw new Exception("No metadata found in backup");
         }
     } else {
         CLI::logging("Found " . count($metaFiles) . " workspaces in backup:\n");
         foreach ($metaFiles as $metafile) {
             CLI::logging("-> " . basename($metafile) . "\n");
         }
     }
     if (count($metaFiles) > 1 && !isset($srcWorkspace)) {
         throw new Exception("Multiple workspaces in backup but no workspace specified to restore");
     }
     if (isset($srcWorkspace) && !in_array("{$srcWorkspace}.meta", array_map(BASENAME, $metaFiles))) {
         throw new Exception("Workspace {$srcWorkspace} not found in backup");
     }
     foreach ($metaFiles as $metaFile) {
         $metadata = G::json_decode(file_get_contents($metaFile));
         if ($metadata->version != 1) {
             throw new Exception("Backup version {$metadata->version} not supported");
         }
         $backupWorkspace = $metadata->WORKSPACE_NAME;
         if (isset($dstWorkspace)) {
             $workspaceName = $dstWorkspace;
             $createWorkspace = true;
         } else {
             $workspaceName = $metadata->WORKSPACE_NAME;
             $createWorkspace = false;
         }
         if (isset($srcWorkspace) && strcmp($metadata->WORKSPACE_NAME, $srcWorkspace) != 0) {
             CLI::logging(CLI::warning("> Workspace {$backupWorkspace} found, but not restoring.") . "\n");
             continue;
         } else {
             CLI::logging("> Restoring " . CLI::info($backupWorkspace) . " to " . CLI::info($workspaceName) . "\n");
         }
         $workspace = new workspaceTools($workspaceName);
         if ($workspace->workspaceExists()) {
             if ($overwrite) {
                 CLI::logging(CLI::warning("> Workspace {$workspaceName} already exist, overwriting!") . "\n");
             } else {
                 throw new Exception("Destination workspace already exist (use -o to overwrite)");
             }
         }
         if (file_exists($workspace->path)) {
             G::rm_dir($workspace->path);
         }
         foreach ($metadata->directories as $dir) {
             CLI::logging("+> Restoring directory '{$dir}'\n");
             if (!rename("{$tempDirectory}/{$dir}", $workspace->path)) {
                 throw new Exception("There was an error copying the backup files ({$tempDirectory}/{$dir}) to the workspace directory {$workspace->path}.");
             }
         }
         CLI::logging("> Changing file permissions\n");
         $shared_stat = stat(PATH_DATA);
         if ($shared_stat !== false) {
             workspaceTools::dirPerms($workspace->path, $shared_stat['uid'], $shared_stat['gid'], $shared_stat['mode']);
         } else {
             CLI::logging(CLI::error("Could not get the shared folder permissions, not changing workspace permissions") . "\n");
         }
         list($dbHost, $dbUser, $dbPass) = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH));
         CLI::logging("> Connecting to system database in '{$dbHost}'\n");
         $link = mysql_connect($dbHost, $dbUser, $dbPass);
         @mysql_query("SET NAMES 'utf8';");
         @mysql_query("SET FOREIGN_KEY_CHECKS=0;");
         if (!$link) {
             throw new Exception('Could not connect to system database: ' . mysql_error());
         }
         $newDBNames = $workspace->resetDBInfo($dbHost, $createWorkspace);
         foreach ($metadata->databases as $db) {
             $dbName = $newDBNames[$db->name];
             CLI::logging("+> Restoring database {$db->name} to {$dbName}\n");
             $workspace->executeSQLScript($dbName, "{$tempDirectory}/{$db->name}.sql");
             $workspace->createDBUser($dbName, $db->pass, "localhost", $dbName);
             $workspace->createDBUser($dbName, $db->pass, "%", $dbName);
         }
         $workspace->upgradeCacheView(false);
         mysql_close($link);
     }
     CLI::logging("Removing temporary files\n");
     G::rm_dir($tempDirectory);
     CLI::logging(CLI::info("Done restoring") . "\n");
 }
예제 #9
0
function NewCase($params)
{
    G::LoadClass("sessions");
    G::LoadSystem('inputfilter');
    $filter = new InputFilter();
    $vsResult = isValidSession($params->sessionId);
    if ($vsResult->status_code !== 0) {
        return $vsResult;
    }
    if (ifPermission($params->sessionId, "PM_CASES") == 0) {
        $result = new wsResponse(2, G::LoadTranslation('ID_NOT_PRIVILEGES'));
        return $result;
    }
    $oSession = new Sessions();
    $session = $oSession->getSessionUser($params->sessionId);
    $userId = $session["USR_UID"];
    $variables = $params->variables;
    /* this code is for previous version of ws, and apparently this will work for grids inside the variables..
        if (!isset($params->variables) ) {
          $variables = array();
          $field = array();
        }
        else {
          if ( is_object ($variables) ) {
            $field[ $variables->name ]= $variables->value ;
          }
    
          if ( is_array ( $variables) ) {
            foreach ( $variables as $key=>$val ) {
              $name  = $val->name;
              $value = $val->value;
              if (!is_object($val->value))
              {
                eval('$field[ ' . $val->name . ' ]= $val->value ;');
              }
              else
              {
                if (is_array($val->value->item)) {
                  $i = 1;
                  foreach ($val->value->item as $key1 => $val1) {
                    if (isset($val1->value)) {
                      if (is_array($val1->value->item)) {
                        foreach ($val1->value->item as $key2 => $val2) {
                          $field[$val->name][$i][$val2->key] = $val2->value;
                        }
                      }
                    }
                    $i++;
                  }
                }
              }
            }
          }
        }
        */
    $variables = $params->variables;
    $field = array();
    if ($variables->name === "__POST_VARIABLES__") {
        $field = G::json_decode($variables->value, true);
        $variables = null;
    }
    if (is_object($variables)) {
        $field[$variables->name] = $variables->value;
    }
    if (is_array($variables)) {
        foreach ($variables as $key => $val) {
            if (!is_object($val->value)) {
                @eval("\$field[" . $val->name . "]= \$val->value;");
            }
        }
    }
    $params->variables = $field;
    $ws = new wsBase();
    $res = $ws->newCase($params->processId, $userId, $params->taskId, $params->variables, isset($params->executeTriggers) ? (int) $params->executeTriggers : 0);
    // we need to register the case id for a stored session variable. like a normal Session.
    $oSession->registerGlobal("APPLICATION", $res->caseId);
    return $res;
}
예제 #10
0
 /** 
  * Internal method: remove malicious code, fix missing end tags, fix illegal nesting, convert deprecated tags, validate CSS, preserve rich formatting 
  * @author Marcelo Cuiza
  * @access protected
  * @param Array or String $input
  * @param String $type (url)
  * @return Array or String $input
  */
 function xssFilterHard($input, $type = "")
 {
     require_once PATH_THIRDPARTY . 'HTMLPurifier/HTMLPurifier.auto.php';
     $config = HTMLPurifier_Config::createDefault();
     $purifier = new HTMLPurifier($config);
     if (is_array($input)) {
         if (sizeof($input)) {
             foreach ($input as $i => $val) {
                 if (is_array($val) || is_object($val) && sizeof($val)) {
                     $input[$i] = $this->xssFilterHard($val);
                 } else {
                     if (!empty($val)) {
                         if (!is_object(G::json_decode($val))) {
                             $inputFiltered = $purifier->purify($val);
                             if ($type != "url" && !strpos(basename($val), "=")) {
                                 $inputFiltered = htmlspecialchars($inputFiltered, ENT_NOQUOTES, 'UTF-8');
                             } else {
                                 $inputFiltered = str_replace('&amp;', '&', $inputFiltered);
                             }
                         } else {
                             $jsArray = G::json_decode($val, true);
                             if (is_array($jsArray) && sizeof($jsArray)) {
                                 foreach ($jsArray as $j => $jsVal) {
                                     if (is_array($jsVal) && sizeof($jsVal)) {
                                         $jsArray[$j] = $this->xssFilterHard($jsVal);
                                     } else {
                                         if (!empty($jsVal)) {
                                             $jsArray[$j] = $purifier->purify($jsVal);
                                         }
                                     }
                                 }
                                 $inputFiltered = G::json_encode($jsArray);
                             } else {
                                 $inputFiltered = $val;
                             }
                         }
                     } else {
                         $inputFiltered = "";
                     }
                     $input[$i] = $inputFiltered;
                 }
             }
         }
         return $input;
     } else {
         if (!isset($input) || empty($input)) {
             return '';
         } else {
             if (is_object($input)) {
                 if (sizeof($input)) {
                     foreach ($input as $j => $jsVal) {
                         if (is_array($jsVal) || is_object($jsVal) && sizeof($jsVal)) {
                             $input->j = $this->xssFilterHard($jsVal);
                         } else {
                             if (!empty($jsVal)) {
                                 $input->j = $purifier->purify($jsVal);
                             }
                         }
                     }
                 }
                 return $input;
             }
             if (!is_object(G::json_decode($input))) {
                 $input = $purifier->purify($input);
                 if ($type != "url" && !strpos(basename($input), "=")) {
                     $input = addslashes(htmlspecialchars($input, ENT_COMPAT, 'UTF-8'));
                 } else {
                     $input = str_replace('&amp;', '&', $input);
                 }
             } else {
                 $jsArray = G::json_decode($input, true);
                 if (is_array($jsArray) && sizeof($jsArray)) {
                     foreach ($jsArray as $j => $jsVal) {
                         if (is_array($jsVal) || is_object($jsVal) && sizeof($jsVal)) {
                             $jsArray[$j] = $this->xssFilterHard($jsVal);
                         } else {
                             if (!empty($jsVal)) {
                                 $jsArray[$j] = $purifier->purify($jsVal);
                             }
                         }
                     }
                     $input = G::json_encode($jsArray);
                 }
             }
             return $input;
         }
     }
 }
예제 #11
0
 case 'editObjectPermission':
     // we also need the process uid variable for the function.
     $oProcessMap->editObjectPermission($oData->op_uid, $oData->pro_uid);
     break;
 case 'caseTracker':
     $oProcessMap->caseTracker($oData->pro_uid);
     break;
 case 'caseTrackerObjects':
     $oProcessMap->caseTrackerObjects($oData->pro_uid);
     break;
 case 'processFilesManager':
     $_SESSION['PFMDirectory'] = '';
     $oProcessMap->processFilesManager($oData->pro_uid);
     break;
 case 'exploreDirectory':
     $objData = G::json_decode($_REQUEST['data']);
     $_SESSION['PFMDirectory'] = $objData->{'main_directory'};
     $oProcessMap->exploreDirectory($oData->pro_uid, $oData->main_directory, $oData->directory);
     break;
 case 'deleteFile':
     $oProcessMap->deleteFile($oData->pro_uid, $oData->main_directory, $oData->directory, $oData->file);
     break;
 case 'deleteDirectory':
     $oProcessMap->deleteDirectory($oData->pro_uid, $oData->main_directory, $oData->directory, $oData->dir_to_delete);
     break;
 case 'downloadFile':
     $oProcessMap->downloadFile($oData->pro_uid, $oData->main_directory, $oData->directory, $oData->file);
     break;
 case 'deleteSubProcess':
     $sOutput = $oProcessMap->deleteSubProcess($oData->pro_uid, $oData->tas_uid);
     break;
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 */
$aData = G::json_decode($_POST['data']);
$appSelectedUids = array();
$items = explode(",", $_POST['APP_UIDS']);
foreach ($items as $item) {
    $dataUids = explode("|", $item);
    $appSelectedUids[] = $dataUids[0];
}
// var_dump($aData);
//var_dump($appSelectedUids);
$casesReassignedCount = 0;
$serverResponse = array();
G::LoadClass('case');
$oCases = new Cases();
require_once 'classes/model/Task.php';
require_once 'classes/model/AppCacheView.php';
$oAppCacheView = new AppCacheView();
<?php

/**
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
G::LoadSystem('inputfilter');
$filter = new InputFilter();
$_POST = $filter->xssFilterHard($_POST);
require_once "classes/model/AdditionalTables.php";
require_once "classes/model/Fields.php";
// passing the parameters
$pmTableName = isset($_POST['tableName']) ? $_POST['tableName'] : 'contenders';
$pmTableFields = isset($_POST['tableFields']) ? G::json_decode($_POST['tableFields']) : array();
// default parameters
//$pmTableName   = 'Sender';
$pmTableFields = array(array('FLD_NAME' => 'APP_UID'), array('FLD_NAME' => 'CON_NAME'), array('FLD_NAME' => 'CON_ADDR'), array('FLD_NAME' => '_cedula'));
// setting the data to assemble the table
$aData = array();
$aData['ADD_TAB_NAME'] = $pmTableName;
// creating the objects to create the table and records
$oFields = new Fields();
$oAdditionalTables = new AdditionalTables();
$sAddTabUid = $oAdditionalTables->create($aData, $pmTableFields);
foreach ($pmTableFields as $iRow => $aRow) {
    $pmTableFields[$iRow]['FLD_NAME'] = strtoupper($aRow['FLD_NAME']);
    $pmTableFields[$iRow]['FLD_DESCRIPTION'] = isset($aRow['FLD_DESCRIPTION']) ? $aRow['FLD_DESCRIPTION'] : $aRow['FLD_NAME'];
    $pmTableFields[$iRow]['FLD_TYPE'] = isset($aRow['FLD_TYPE']) ? $aRow['FLD_TYPE'] : 'VARCHAR';
    $pmTableFields[$iRow]['FLD_SIZE'] = isset($aRow['FLD_SIZE']) ? $aRow['FLD_SIZE'] : '32';
    $pmTableFields[$iRow]['FLD_NULL'] = isset($aRow['FLD_NULL']) ? $aRow['FLD_NULL'] : 'off';
    $pmTableFields[$iRow]['FLD_AUTO_INCREMENT'] = isset($aRow['FLD_AUTO_INCREMENT']) ? $aRow['FLD_AUTO_INCREMENT'] : 'off';
예제 #14
0
 function deleteAllDWSDocVersion($newFileName, $dwsname)
 {
     //print "<br>- Method createDWS";
     $this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL");
     $this->dwsObj->loadSOAPClient();
     $doc = "Shared Documents/{$newFileName}";
     $paramArray = array('fileName' => $doc);
     $methodName = 'DeleteAllVersions';
     $result = $this->dwsObj->callWsMethod($methodName, $paramArray);
     if ($result) {
         $xml = $result->DeleteAllVersionsResult->any;
         // in Result we get string in Xml format
         $xmlNew = simplexml_load_string($xml);
         // used to parse string to xml
         $xmlArray = @G::json_decode(@G::json_encode($xmlNew), 1);
         // used to convert Objects to array
         $latestVersion = $xmlArray['result']['@attributes']['version'];
         return "All Versions are Deleted, except the latest i.e {$latestVersion}";
     } else {
         return "The Version/ File name/ Dws Name  is incorrect";
     }
 }
예제 #15
0
try {
    global $RBAC;
    switch ($RBAC->userCanAccess('PM_FACTORY')) {
        case -2:
            G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
            G::header('location: ../login/login');
            die;
            break;
        case -1:
            G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
            G::header('location: ../login/login');
            die;
            break;
    }
    //$oJSON = new Services_JSON();
    $aData = get_object_vars(G::json_decode($_POST['oData']));
    //$aData = get_object_vars( $oJSON->decode( $_POST['oData'] ) );
    if (isset($_POST['function'])) {
        $sAction = $_POST['function'];
    } else {
        $sAction = $_POST['functions'];
    }
    switch ($sAction) {
        case "saveTaskData":
            require_once "classes/model/Task.php";
            $response = array();
            $oTask = new Task();
            /**
             * routine to replace @amp@ by &
             * that why the char "&" can't be passed by XmlHttpRequest directly
             * @autor erik <*****@*****.**>
예제 #16
0
 /**
  * Get all dynaform variables 
  *
  * @param $sProcessUID
  */
 public function getDynaformVariables($sProcessUID,$excludeFieldsList,$allowed = true)
 {
     $dynaformVariables = array();
     $oC = new Criteria( 'workflow' );
     $oC->addSelectColumn( DynaformPeer::DYN_CONTENT );
     $oC->add( DynaformPeer::PRO_UID, $sProcessUID );
     $oData = DynaformPeer::doSelectRS( $oC );
     $oData->setFetchmode( ResultSet::FETCHMODE_ASSOC );
     $oData->next();
     while ($aRowd = $oData->getRow()) {
         $dynaform = G::json_decode($aRowd['DYN_CONTENT'],true);
         if(is_array($dynaform) && sizeof($dynaform)) {
             $items = $dynaform['items'][0]['items'];
             foreach($items as $key => $val){
                 foreach($val as $column) {
                     if($allowed) {
                         if(isset($column['type']) && !in_array( $column['type'], $excludeFieldsList )){
                             if(array_key_exists('variable',$column)) {
                                 if($column['variable'] != "") {
                                     $dynaformVariables[] = $column['variable'];
                                 }
                             }
                         }
                     } else {
                         if(isset($column['type']) && in_array( $column['type'], $excludeFieldsList )){
                             if(array_key_exists('variable',$column)) {
                                 if($column['variable'] != "") {
                                     $dynaformVariables[] = $column['variable']; 
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $oData->next();
     }
     return array_unique($dynaformVariables);    
 }
예제 #17
0
    /**
     * Get Data Generate
     *
     * @access public
     * @param string $pro_uid, Process Uid
     * @param string $tas_uid, Task Uid
     * @param string $dyn_uid, Dynaform Uid
     * @return string
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
    */
    public function getDataGenerate($pro_uid, $tas_uid, $dyn_uid)
    {
        G::LoadClass ('case');
        G::LoadClass ('pmFunctions');
        G::LoadClass ("configuration");
        $hasTextArea = false;

        $conf = new \Configurations();
        $generalConfCasesList = $conf->getConfiguration("ENVIRONMENT_SETTINGS", "");
        if (isset($generalConfCasesList["casesListDateFormat"]) && !empty($generalConfCasesList["casesListDateFormat"])) {
            $dateFormat = $generalConfCasesList["casesListDateFormat"];
        } else {
            $dateFormat = "Y/m/d";
        }

        $oDyna = new \Dynaform();
        $dataTask = $oDyna->load($dyn_uid);
        if ($dataTask['DYN_VERSION'] > 0) {
            G::LoadClass("pmDynaform");
            $pmDyna = new \pmDynaform(array('APP_DATA' => array()));
            $pmDyna->fields["CURRENT_DYNAFORM"] = $dyn_uid;
            $json = G::json_decode($dataTask["DYN_CONTENT"]);
            $pmDyna->jsonr($json);
            $fieldsDyna = $json->items[0]->items;

            $xmlfrm = new \stdclass();
            $xmlfrm->fields = array();
            foreach ($fieldsDyna as $key => $value) {
                if ($value[0]->type == 'title' || $value[0]->type == 'submit') {
                    continue;
                }
                $temp = new \stdclass();
                $temp->type = $value[0]->type;
                $temp->label = $value[0]->label;
                $temp->name = $value[0]->name;
                $temp->required = (isset($value[0]->required)) ? $value[0]->required : 0;
                $temp->mode = (isset($value[0]->mode)) ? $value[0]->mode : 'edit';

                if (!empty($value[0]->options)) {
                    $temp->storeData = '[';
                    foreach ($value[0]->options as $valueOption) {
                        $temp->storeData .= '["' . $valueOption['value'] . '", "' . $valueOption['label'] . '"],';
                    }
                    $temp->storeData = substr($temp->storeData,0,-1);
                    $temp->storeData .= ']';
                }

                $temp->readOnly = ($temp->mode == 'view') ? "1" : "0";
                $temp->colWidth = 200;
                $xmlfrm->fields[] = $temp;
            }
        } else {
            $filename = $pro_uid . PATH_SEP . $dyn_uid . ".xml";
            if (!class_exists('Smarty')) {
                require_once(PATH_THIRDPARTY . 'smarty' . PATH_SEP . 'libs' . PATH_SEP . 'Smarty.class.php');  
            }
            $xmlfrm = new \XmlForm();
            $xmlfrm->home = PATH_DYNAFORM;
            $xmlfrm->parseFile($filename, SYS_LANG, true);    
        }

        $caseColumns      = array();
        $caseReaderFields = array();

        $dropList          = array();
        $comboBoxYesNoList = array();

        $caseColumns[] = array("header" => "APP_UID", "dataIndex" => "APP_UID", "width" => 100, "hidden" => true, "hideable" => false);
        $caseColumns[] = array("header" => "#", "dataIndex" => "APP_NUMBER", "width" => 40, "sortable" => true);
        $caseColumns[] = array("header" => G::LoadTranslation("ID_TITLE"), "dataIndex" => "APP_TITLE", "width" => 180, "renderer" => "renderTitle", "sortable" => true);
        $caseColumns[] = array("header" => G::LoadTranslation("ID_SUMMARY"), "width" => 60, "renderer" => "renderSummary", "align" => "center");
        $caseColumns[] = array("header" => "DEL_INDEX", "dataIndex" => "DEL_INDEX", "width" => 100, "hidden" => true, "hideable" => false);

        $caseReaderFields[] = array("name" => "APP_UID");
        $caseReaderFields[] = array("name" => "APP_NUMBER");
        $caseReaderFields[] = array("name" => "APP_TITLE");
        $caseReaderFields[] = array("name" => "DEL_INDEX");

        //$caseColumns[] = array("header" => "FLAG", "dataIndex" => "FLAG", "width" => 55, "xtype"=>"checkcolumn");
        //$caseReaderFields[] = array("name" => "FLAG", "type"=>"bool");

        foreach ($xmlfrm->fields as $index => $value) {
            $field = $value;

            $editor = null;
            $renderer = null;

            $readOnly = (isset($field->readOnly))? $field->readOnly : null;
            $required = (isset($field->required))? $field->required : null;
            $validate = (isset($field->validate))? strtolower($field->validate) : null;

            $fieldReadOnly = ($readOnly . "" == "1")? "readOnly: true," : null;
            $fieldRequired = ($required . "" == "1")? "allowBlank: false," : null;
            $fieldValidate = ($validate == "alpha" || $validate == "alphanum" || $validate == "email" || $validate == "int" || $validate == "real")? "vtype: \"$validate\"," : null;

            $fieldLabel = (($fieldRequired != null)? "<span style='color: red;'>&#42;</span> ": null) . $field->label;
            $fieldDisabled = ($field->mode != "edit")? "true" : "false";

            switch ($field->type) {
                case "dropdown":
                    $dropList[] = $field->name;
                    $align = "left";

                    if (empty($field->storeData)) {
                        $editor = "* new Ext.form.ComboBox({
                               id: \"cbo" . $field->name . "_" . $pro_uid . "\",

                               valueField:   'value',
                               displayField: 'text',

                               /*store: comboStore,*/
                               store: new Ext.data.JsonStore({
                                 storeId: \"store" . $field->name . "_" . $pro_uid . "\",
                                 proxy: new Ext.data.HttpProxy({
                                   url: 'proxyDataCombobox'
                                 }),
                                 root: 'records',
                                 fields: [{name: 'value'},
                                          {name: 'text'}
                                         ]
                               }),

                               triggerAction: 'all',
                               mode:     'local',
                               editable: false,
                               disabled: $fieldDisabled,
                               lazyRender: false,

                               $fieldReadOnly
                               $fieldRequired
                               $fieldValidate
                               cls: \"\"
                             }) *";
                    } else {
                        $editor = "* new Ext.form.ComboBox({
                                   id: \"cbo" . $field->name . "_" . $pro_uid . "\",

                                   typeAhead: true,
                                   autocomplete:true,
                                   editable:false,
                                   lazyRender:true,
                                   mode:'local',
                                   triggerAction:'all',
                                   forceSelection:true,

                                   valueField:   'value',
                                   displayField: 'text',
                                   store:new Ext.data.SimpleStore({
                                        fields: [{name: 'value'},
                                              {name: 'text'}],
                                        data: " . htmlspecialchars_decode($field->storeData) . ",
                                        sortInfo:{field:'text',direction:'ASC'}
                                    }),

                                   $fieldReadOnly
                                   $fieldRequired
                                   $fieldValidate
                                   cls: \"\"
                                 }) *";    
                    }

                    
                    $editor = eregi_replace("[\n|\r|\n\r]", ' ', $editor);
                    $width = $field->colWidth;
                    
                    $caseColumns[] = array("xtype" => "combocolumn", "gridId" => "gridId", "header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => "true", "clicksToEdit" => "1");
                    $caseReaderFields[] = array("name" => $field->name);
                    break;
                case "date":
                    //minValue: '01/01/06',
                    //disabledDays: [0, 6],
                    //disabledDaysText: 'Plants are not available on the weekends'

                    $align = "center";
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;

                    $editor = "* new Ext.form.DateField({
                                     format: \"$dateFormat\",

                                     $fieldReadOnly
                                     $fieldRequired
                                     $fieldValidate
                                     cls: \"\"
                                 }) *";

                    //$renderer = "* formatDate *";
                    $renderer = "* function (value){
                                     return Ext.isDate(value)? value.dateFormat('{$dateFormat}') : value;
                                   } *";

                    if ($field->mode != "edit") {
                        $editor = null;
                    }

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "editor" => $editor, "renderer" => $renderer, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
                    $caseReaderFields[] = array("name" => $field->name, "type" => "date");
                    break;
                case "currency":
                    //align: 'right',
                    //renderer: 'usMoney',
                    //allowBlank: false,
                    //allowNegative: false,
                    $align = 'right';
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;

                    $editor = "* new Ext.form.NumberField({
                                   maxValue: 1000000,
                                   allowDecimals: true,
                                   allowNegative: true,

                                   $fieldReadOnly
                                   $fieldRequired
                                   $fieldValidate
                                   cls: \"\"
                                 }) *";

                    if ($field->mode != "edit") {
                        $editor = null;
                    }

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
                    $caseReaderFields[] = array("name" => $field->name);
                    break;
                case "percentage":
                    $align = 'right';
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;

                    $editor = "* new Ext.form.NumberField({
                                   maxValue: 100,
                                   allowDecimals: true,

                                   $fieldReadOnly
                                   $fieldRequired
                                   $fieldValidate
                                   cls: \"\"
                                 }) *";

                    $renderer = "* function (value){
                                     return (value + ' %');
                                   } *";

                    if ($field->mode != "edit") {
                        $editor = null;
                    }

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "renderer" => $renderer, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
                    $caseReaderFields[] = array("name" => $field->name);
                    break;
                case "textarea":
                    $align = 'left';
                    $size = 200;

                    if (isset($field->size)) {
                        $size = $field->size * 15;
                    }

                    $width = $size;

                    $editor   = "* new Ext.form.TextArea({
                                     growMin: 60,
                                     growMax: 1000,
                                     grow: true,
                                     autoHeight: true,
                                     disabled: $fieldDisabled,
                                     enterIsSpecial: false,
                                     preventScrollbars: false,

                                     $fieldReadOnly
                                     $fieldRequired
                                     $fieldValidate
                                     cls: \"\"
                                   }) *";

                    $renderer = "* function (value) {  return (value);  } *";

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "renderer" => $renderer, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
                    $caseReaderFields[] = array("name" => $field->name);

                    $hasTextArea = true;
                    break;
                case "link":
                    $align = 'center';
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;
                    $editor = null;

                    $renderer = "* function (value)
                                   {
                                       return linkRenderer(value);
                                   } *";

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "renderer" => $renderer, "frame" => true, "hidden" => false, "hideable" => false, "clicksToEdit" => 1, "sortable" => true);
                    $caseReaderFields[] = array("name" => $field->name);
                    break;
                case "hidden":
                    $align = 'left';
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;

                    $editor = "* new Ext.form.TextField({ allowBlank: false }) *";

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)$width, "align" => $align, "editor" => $editor, "frame" => "true", "hidden" => "true", "hideable" => false, "clicksToEdit" => "1");
                    $caseReaderFields[] = array("name" => $field->name);
                    break;
                case "yesno":
                    $align = "right";
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;
                    $dropList[] = $field->name;
                    $comboBoxYesNoList[] = $field->name;

                    $editor="* new Ext.form.ComboBox({
                                 id: \"cbo" . $field->name . "_" . $pro_uid . "\",

                                 valueField:   'value',
                                 displayField: 'text',

                                 store: new Ext.data.ArrayStore({
                                   storeId: \"store" . $field->name . "_" . $pro_uid . "\",
                                   fields: ['value', 'text'],
                                   data: [[1, 'YES'],
                                          [0, 'NO']
                                         ]
                                 }),

                                 typeAhead: true,

                                 triggerAction: 'all',
                                 mode: 'local',
                                 editable: false,
                                 disabled : $fieldDisabled,
                                 lazyRender: true,

                                 $fieldReadOnly
                                 $fieldRequired
                                 $fieldValidate
                                 cls: \"\"
                               }) *";

                    /*
                    $renderer = "* function(value) {
                                     idx = this.editor.store.find(this.editor.valueField, value);
                                     if (currentFieldEdited == '{$field->name}') {
                                       if (rec = this.editor.store.getAt(idx)) {
                                         rowLabels['{$field->name}'] = rec.get(this.editor.displayField);
                                                       return rec.get(this.editor.displayField);
                                       }
                                       else {
                                         return value;
                                       }
                                     }
                                     else {
                                       if (typeof(currentFieldEdited) == 'undefined') {
                                         return value;
                                       }
                                       else {
                                         return (rowLabels['{$field->name}']);
                                       }
                                     }
                                   } *";
                    */

                    //$caseColumns[] = array('header' => $fieldLabel, 'dataIndex' => $field->name, 'width' => (int)$width, 'align' => $align, 'editor' => $editor, 'renderer' => $renderer, 'frame' => 'true', 'clicksToEdit' => '1');
                    $caseColumns[] = array("xtype" => "combocolumn", "gridId" => "gridId", "header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => "true", "clicksToEdit" => "1");
                    $caseReaderFields[] = array("name" => $field->name);
                    break;
                case "text":
                default:
                    $align = "left";
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;
                    $editor = "* new Ext.form.TextField({ $fieldReadOnly $fieldRequired $fieldValidate cls: \"\"}) *";

                    if ($field->mode != "edit" && $field->mode != "parent") {
                        $editor = null;
                    }

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
                    $caseReaderFields[] = array("name" => $field->name);
            }
        }

        @unlink(PATH_C . "ws" . PATH_SEP . SYS_SYS . PATH_SEP . "xmlform" . PATH_SEP . $pro_uid . PATH_SEP . $dyn_uid . "." . SYS_LANG);


        
        $array ['columnModel']          = $caseColumns;
        $array ['readerFields']         = $caseReaderFields;
        $array ["dropList"]             = $dropList;
        $array ["comboBoxYesNoList"]    = $comboBoxYesNoList;
        $array ['hasTextArea']          = $hasTextArea;
        
        $temp = G::json_encode($array);

        //$temp = str_replace("***","'",$temp);
        $temp = str_replace('"*','',  $temp);
        $temp = str_replace('*"','',  $temp);
        $temp = str_replace('\t','',  $temp);
        $temp = str_replace('\n','',  $temp);
        $temp = str_replace('\/','/', $temp);
        $temp = str_replace('\"','"', $temp);
        $temp = str_replace('"checkcolumn"','\'checkcolumn\'',$temp);

        print $temp;
        die();
    }
예제 #18
0
             $option['http'] = array();
         }
         $option['http']['request_fulluri'] = true;
         $option['http']['proxy'] = 'tcp://' . $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '');
         if ($sysConf['proxy_user'] != '') {
             if (!isset($option['http']['header'])) {
                 $option['http']['header'] = '';
             }
             $option['http']['header'] .= 'Proxy-Authorization: Basic ' . base64_encode($sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
         }
     }
     $context = stream_context_create($option);
     ///////
     $fileData = file_get_contents($url, false, $context);
     //////////
     $r = G::json_decode($fileData);
     if ($r->status == "OK") {
         $response["status"] = $r->status;
         //OK
     } else {
         throw new Exception($r->message);
     }
 } catch (Exception $e) {
     $response["message"] = $e->getMessage();
     $status = 0;
 }
 if ($status == 0) {
     $response["status"] = "ERROR";
 }
 echo G::json_encode($response);
 exit(0);
예제 #19
0
} else {
    $dynaform = new dynaform();
    if (isset($_POST['form'])) {
        $aData = $_POST['form'];
        //For old process map form
        if ($aData['DYN_UID'] === '') {
            unset($aData['DYN_UID']);
        }
    } else {
        $aData = $_POST;
        //For Extjs (Since we are not using form in ExtJS)
        $aFields = array();
        $aVariables = array();
        if (isset($aData['FIELDS'])) {
            $aFields = G::json_decode($_POST['FIELDS']);
            $aVariables = G::json_decode($_POST['VARIABLES']);
        }
        $aData['FIELDS'] = array();
        for ($i = 0; $i < count($aFields); $i++) {
            $aData['FIELDS'][$i + 1]['FLD_NAME'] = $aFields[$i];
            $aData['FIELDS'][$i + 1]['PRO_VARIABLE'] = $aVariables[$i];
        }
    }
    //if ($aData['DYN_UID']==='') unset($aData['DYN_UID']);
    if (isset($aData['DYN_UID'])) {
        $dynaform->Save($aData);
    } else {
        if (!isset($aData['ADD_TABLE']) || $aData['ADD_TABLE'] == "") {
            $aFields = $dynaform->create($aData);
        } else {
            $aFields = $dynaform->createFromPMTable($aData, $aData['ADD_TABLE']);
예제 #20
0
    public function deleteLanguage($dyn_uid, $lang)
    {
        $con = Propel::getConnection(DynaformPeer::DATABASE_NAME);
        $con->begin();
        $oPro = DynaformPeer::retrieveByPk($dyn_uid);

        $dyn_labels = \G::json_decode($oPro->getDynLabel());
        unset($dyn_labels->{$lang});

        $oPro->setDynLabel(G::json_encode($dyn_labels));
        $oPro->save();
        $con->commit();
    }
예제 #21
0
 public function calendarSave()
 {
     //{ $_POST['BUSINESS_DAY']
     $businessDayArray = G::json_decode($_POST['BUSINESS_DAY']);
     $businessDayFixArray = array();
     for ($i = 0; $i < sizeof($businessDayArray); $i++) {
         $businessDayFixArray[$i + 1]['CALENDAR_BUSINESS_DAY'] = $businessDayArray[$i]->CALENDAR_BUSINESS_DAY;
         $businessDayFixArray[$i + 1]['CALENDAR_BUSINESS_START'] = $businessDayArray[$i]->CALENDAR_BUSINESS_START;
         $businessDayFixArray[$i + 1]['CALENDAR_BUSINESS_END'] = $businessDayArray[$i]->CALENDAR_BUSINESS_END;
     }
     $_POST['BUSINESS_DAY'] = $businessDayFixArray;
     //}
     //{ $_POST['CALENDAR_WORK_DAYS']
     $calendarWorkDaysArray = G::json_decode($_POST['CALENDAR_WORK_DAYS']);
     $calendarWorkDaysFixArray = array();
     for ($i = 0; $i < sizeof($calendarWorkDaysArray); $i++) {
         $calendarWorkDaysFixArray[$i] = $calendarWorkDaysArray[$i] . "";
     }
     $_POST['CALENDAR_WORK_DAYS'] = $calendarWorkDaysFixArray;
     //}
     //{ $_POST['HOLIDAY']
     $holidayArray = G::json_decode($_POST['HOLIDAY']);
     $holidayFixArray = array();
     for ($i = 0; $i < sizeof($holidayArray); $i++) {
         $holidayFixArray[$i + 1]['CALENDAR_HOLIDAY_NAME'] = $holidayArray[$i]->CALENDAR_HOLIDAY_NAME;
         $holidayFixArray[$i + 1]['CALENDAR_HOLIDAY_START'] = $holidayArray[$i]->CALENDAR_HOLIDAY_START;
         $holidayFixArray[$i + 1]['CALENDAR_HOLIDAY_END'] = $holidayArray[$i]->CALENDAR_HOLIDAY_END;
     }
     $_POST['HOLIDAY'] = $holidayFixArray;
     //}
     //[ CALENDAR_STATUS BUSINESS_DAY_STATUS HOLIDAY_STATUS
     if ($_POST['BUSINESS_DAY_STATUS'] == "INACTIVE") {
         unset($_POST['BUSINESS_DAY_STATUS']);
     }
     if ($_POST['HOLIDAY_STATUS'] == "INACTIVE") {
         unset($_POST['HOLIDAY_STATUS']);
     }
     //]
     $form = $_POST;
     G::LoadClass('calendar');
     $calendarObj = new calendar();
     $calendarObj->saveCalendarInfo($form);
     echo "{success: true}";
 }
/**
 * @method
 *
 * Uplaod file/document in Alfresco Repository
 *
 * @name uploadDoc
 * @label Uplaod file/document in Alfresco Repository
 *
 * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco
 * @param string | $fileSource | File Source
 * @param string | $title | File Title
 * @param string | $description | Description about File
 * @param string | $docType | Type of document to be Uploaded
 * @param string | $user | Valid Admin username to connect to Alfresco server
 * @param string | $pwd | Valid Admin password to connect to Alfresco server
 * @param string | $path | Path of document to be Uploaded
 * @param string | $mainFolder | The main folder in alfreco to save the files
 *
 * @return object | $result | Response |
 *
 */
function uploadDoc($alfrescoServerUrl, $fileSource, $title, $description, $docType, $user, $pwd, $path = '', $mainFolder = 'Sites')
{
    if (!file_exists($fileSource)) {
        $result = new stdclass();
        $result->error = G::Loadtranslation('ID_FILE_PLUGIN_NOT_EXISTS', SYS_LANG, array('pluginFile' => $fileSource));
        return $result;
    }
    $filep = fopen($fileSource, "r");
    $fileLength = filesize($fileSource);
    $fileContent = fread($filep, $fileLength);
    $fileContent = base64_encode($fileContent);
    if ($path != '') {
        createFolder($alfrescoServerUrl, $mainFolder, $path, $user, $pwd);
        $path = $path . PATH_SEP;
    }
    $alfresco_url = "{$alfrescoServerUrl}/s/cmis/p/{$mainFolder}/" . $path . "children";
    $xmlData = array();
    $xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"><title>' . $title . '</title><summary>' . $description . '</summary><content type="application/' . $docType . '">' . $fileContent . '</content><cmisra:object><cmis:properties><cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:document</cmis:value></cmis:propertyId></cmis:properties></cmisra:object></entry>';
    $alfresco_exec = RestClient::post($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml");
    $sXmlArray = $alfresco_exec->getResponse();
    $sXmlArray = trim($sXmlArray);
    $xXmlArray = simplexml_load_string($sXmlArray);
    $aXmlArray = @G::json_decode(@G::json_encode($xXmlArray), 1);
    return $aXmlArray;
}
예제 #23
0
     break;
 case 'saveGuidePosition':
     $sOutput = $oProcessMap->saveGuidePosition($oData->uid, $oData->position, $oData->direction);
     G::auditLog('SaveGuidePosition','Change '.$oData->direction.' line position  ('.$oData->uid.') in process "'.$resultProcess['PRO_TITLE'].'"');
     break;
 case 'deleteGuide':
     $sOutput = $oProcessMap->deleteGuide($oData->uid);
     G::auditLog('DeleteLine','Delete line ('.$oData->uid.') in process "'.$resultProcess['PRO_TITLE'].'"');
     break;
 case 'deleteGuides':
     $sOutput = $oProcessMap->deleteGuides($oData->pro_uid);
     G::auditLog('DeleteLines','Delete all lines in process "'.$resultProcess['PRO_TITLE'].'"');
     break;
 case 'addText':
     $sOutput = $oProcessMap->addText($oData->uid, $oData->label, $oData->position->x, $oData->position->y);
     $sOutputAux = G::json_decode($sOutput);
     $sOutputAux = (array)$sOutputAux;
     G::auditLog('AddText','Add new text ('.$sOutputAux['uid'].') in process "'.$resultProcess['PRO_TITLE'].'"');
     break;
 case 'updateText':
     $sOutput = $oProcessMap->updateText($oData->uid, $oData->label);
     G::auditLog('UpdateText','Edit text ('.$oData->uid.' ) in process "'.$resultProcess['PRO_TITLE'].'"');
     break;
 case 'saveTextPosition':
     $sOutput = $oProcessMap->saveTextPosition($oData->uid, $oData->position->x, $oData->position->y);
     G::auditLog('SaveTextPosition','Change text position ('.$oData->uid.' ) in process "'.$resultProcess['PRO_TITLE'].'"');
     break;
 case 'deleteText':
     $sOutput = $oProcessMap->deleteText($oData->uid);
     G::auditLog('DeleteText','Delete text ('.$oData->uid.' ) in process "'.$resultProcess['PRO_TITLE'].'"');
     break;
예제 #24
0
/**
 * @method
 *
 * Get Appointment List
 *
 * @name getZimbraAppointmentList
 * @label Get Appointment Lists from Zimbra Server
 *
 * @param string | $ServerUrl | Server name and port where Zimbra exists | zimbra.server:port
 * @param string | $username| Valid username to connect to Zimbra server
 * @param string | $preAuthKey | Server Key for SSO authentication
 *
 * @return string | $result | Response
 *
 */
function getZimbraAppointmentList($ServerUrl, $username, $preAuthKey)
{
    $xXmlArray = array();
    $xXmlArray1 = array();
    $zimbra = new Zimbra($username, $ServerUrl, $preAuthKey);
    $connectionResult = $zimbra->connect();
    if (!$connectionResult) {
        return "Check userName or Server URL";
    }
    $sXmlArray = array();
    $sXmlArray = $zimbra->getAppointments();
    $aXmlArray = @G::json_decode(@G::json_encode($sXmlArray), 1);
    $serializeResult = serialize($aXmlArray);
    // serializing the Array for Returning.
    return $serializeResult;
}
 function saveConsolidated($data)
 {
     $status = $data['con_status'];
     $sTasUid = $data['tas_uid'];
     $sDynUid = $data['dyn_uid'];
     $sProUid = $data['pro_uid'];
     $sRepTabUid = $data['rep_uid'];
     $tableName = $data['table_name'];
     $title = $data['title'];
     if ($sRepTabUid != '') {
         if (!$status) {
             $oCaseConsolidated = new CaseConsolidatedCore();
             $oCaseConsolidated = CaseConsolidatedCorePeer::retrieveByPK($sTasUid);
             if (!is_object($oCaseConsolidated) || get_class($oCaseConsolidated) != 'CaseConsolidatedCore') {
                 $oCaseConsolidated = new CaseConsolidatedCore();
                 $oCaseConsolidated->setTasUid($sTasUid);
                 $oCaseConsolidated->setConStatus('INACTIVE');
                 $oCaseConsolidated->save();
             } else {
                 $oCaseConsolidated->delete();
             }
             return 1;
         }
         $rptUid = null;
         $criteria = new Criteria();
         $criteria->addSelectColumn(ReportTablePeer::REP_TAB_UID);
         $criteria->add(ReportTablePeer::REP_TAB_UID, $sRepTabUid);
         $rsCriteria = ReportTablePeer::doSelectRS($criteria);
         if ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $rptUid = $row[0];
         }
         $rpts = new ReportTables();
         if ($rptUid != null) {
             $rpts->deleteReportTable($rptUid);
         }
         $sClassName = $tableName;
         $sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
         @unlink($sPath . $sClassName . '.php');
         @unlink($sPath . $sClassName . 'Peer.php');
         @unlink($sPath . PATH_SEP . 'map' . PATH_SEP . $sClassName . 'MapBuilder.php');
         @unlink($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $sClassName . '.php');
         @unlink($sPath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $sClassName . 'Peer.php');
         $sRepTabUid = '';
     }
     $_POST['form']['PRO_UID'] = $sProUid;
     $_POST['form']['REP_TAB_UID'] = $sRepTabUid;
     $_POST['form']['REP_TAB_NAME'] = $tableName;
     $_POST['form']['REP_TAB_TYPE'] = "NORMAL";
     $_POST['form']['REP_TAB_GRID'] = '';
     $_POST['form']['REP_TAB_CONNECTION'] = 'wf';
     $_POST['form']['REP_TAB_CREATE_DATE'] = date("Y-m-d H:i:s");
     $_POST['form']['REP_TAB_STATUS'] = 'ACTIVE';
     $_POST['form']['REP_TAB_TITLE'] = $title;
     $_POST['form']['FIELDS'] = array();
     G::LoadClass("reportTables");
     $oReportTable = new ReportTable();
     $sOldTableName = $_POST['form']['REP_TAB_NAME'];
     $sOldConnection = $_POST['form']['REP_TAB_CONNECTION'];
     $oReportTable->create($_POST['form']);
     $_POST['form']['REP_TAB_UID'] = $oReportTable->getRepTabUid();
     $oReportVar = new ReportVar();
     $oReportTables = new ReportTables();
     $oReportTables->deleteAllReportVars($_POST['form']['REP_TAB_UID']);
     $aFields = array();
     G::LoadClass("pmDynaform");
     $pmDyna = new pmDynaform(array());
     $pmDyna->fields["CURRENT_DYNAFORM"] = $sDynUid;
     $dataDyna = $pmDyna->getDynaform();
     $json = G::json_decode($dataDyna["DYN_CONTENT"]);
     $fieldsDyna = $json->items[0]->items;
     foreach ($fieldsDyna as $value) {
         foreach ($value as $val) {
             if (isset($val->type)) {
                 if ($val->type == 'text' || $val->type == 'textarea' || $val->type == 'dropdown' || $val->type == 'checkbox' || $val->type == 'datetime' || $val->type == 'yesno' || $val->type == 'date' || $val->type == 'hidden' || $val->type == 'currency' || $val->type == 'percentage' || $val->type == 'link') {
                     $_POST['form']['FIELDS'][] = $val->name . '-' . $val->type;
                 }
             }
         }
     }
     $aFieldsClases = array();
     $i = 1;
     $aFieldsClases[$i]['FLD_NAME'] = 'APP_UID';
     $aFieldsClases[$i]['FLD_NULL'] = 'off';
     $aFieldsClases[$i]['FLD_KEY'] = 'on';
     $aFieldsClases[$i]['FLD_AUTO_INCREMENT'] = 'off';
     $aFieldsClases[$i]['FLD_DESCRIPTION'] = '';
     $aFieldsClases[$i]['FLD_TYPE'] = 'VARCHAR';
     $aFieldsClases[$i]['FLD_SIZE'] = 32;
     $i++;
     $aFieldsClases[$i]['FLD_NAME'] = 'APP_NUMBER';
     $aFieldsClases[$i]['FLD_NULL'] = 'off';
     $aFieldsClases[$i]['FLD_KEY'] = 'on';
     $aFieldsClases[$i]['FLD_AUTO_INCREMENT'] = 'off';
     $aFieldsClases[$i]['FLD_DESCRIPTION'] = '';
     $aFieldsClases[$i]['FLD_TYPE'] = 'VARCHAR';
     $aFieldsClases[$i]['FLD_SIZE'] = 255;
     foreach ($_POST['form']['FIELDS'] as $sField) {
         $aField = explode('-', $sField);
         if ($aField[1] == 'title' || $aField[1] == 'submit') {
             continue;
         }
         $i++;
         $aFieldsClases[$i]['FLD_NAME'] = $aField[0];
         $aFieldsClases[$i]['FLD_NULL'] = 'off';
         $aFieldsClases[$i]['FLD_KEY'] = 'off';
         $aFieldsClases[$i]['FLD_AUTO_INCREMENT'] = 'off';
         $aFieldsClases[$i]['FLD_DESCRIPTION'] = '';
         switch ($aField[1]) {
             case 'currency':
             case 'percentage':
                 $sType = 'number';
                 $aFieldsClases[$i]['FLD_TYPE'] = 'FLOAT';
                 $aFieldsClases[$i]['FLD_SIZE'] = 255;
                 break;
             case 'text':
             case 'password':
             case 'dropdown':
             case 'yesno':
             case 'checkbox':
             case 'radiogroup':
             case 'hidden':
             case "link":
                 $sType = 'char';
                 $aFieldsClases[$i]['FLD_TYPE'] = 'VARCHAR';
                 $aFieldsClases[$i]['FLD_SIZE'] = 255;
                 break;
             case 'textarea':
                 $sType = 'text';
                 $aFieldsClases[$i]['FLD_TYPE'] = 'TEXT';
                 $aFieldsClases[$i]['FLD_SIZE'] = '';
                 break;
             case 'date':
                 $sType = 'date';
                 $aFieldsClases[$i]['FLD_TYPE'] = 'DATE';
                 $aFieldsClases[$i]['FLD_SIZE'] = '';
                 break;
             default:
                 $sType = 'char';
                 $aFieldsClases[$i]['FLD_TYPE'] = 'VARCHAR';
                 $aFieldsClases[$i]['FLD_SIZE'] = 255;
                 break;
         }
         $oReportVar->create(array('REP_TAB_UID' => $_POST['form']['REP_TAB_UID'], 'PRO_UID' => $_POST['form']['PRO_UID'], 'REP_VAR_NAME' => $aField[0], 'REP_VAR_TYPE' => $sType));
         $aFields[] = array('sFieldName' => $aField[0], 'sType' => $sType);
     }
     $_POST['form']['REP_TAB_TYPE'] = "NORMAL";
     $oReportTables->dropTable($sOldTableName, $sOldConnection);
     $oReportTables->createTable($_POST['form']['REP_TAB_NAME'], $_POST['form']['REP_TAB_CONNECTION'], $_POST['form']['REP_TAB_TYPE'], $aFields);
     $oReportTables->populateTable($_POST['form']['REP_TAB_NAME'], $_POST['form']['REP_TAB_CONNECTION'], $_POST['form']['REP_TAB_TYPE'], $aFields, $_POST['form']['PRO_UID'], '');
     $sRepTabUid = $_POST['form']['REP_TAB_UID'];
     $oCaseConsolidated = CaseConsolidatedCorePeer::retrieveByPK($sTasUid);
     if (!is_object($oCaseConsolidated) || get_class($oCaseConsolidated) != 'CaseConsolidatedCore') {
         $oCaseConsolidated = new CaseConsolidatedCore();
         $oCaseConsolidated->setTasUid($sTasUid);
     }
     $criteria = new Criteria();
     $criteria->addSelectColumn(CaseConsolidatedCorePeer::TAS_UID);
     $criteria->add(CaseConsolidatedCorePeer::TAS_UID, $sTasUid);
     $rsCriteria = CaseConsolidatedCorePeer::doSelectRS($criteria);
     if ($rsCriteria->next()) {
         $row = $rsCriteria->getRow();
         $oCaseConsolidated->delete();
         $oCaseConsolidated = CaseConsolidatedCorePeer::retrieveByPK($sTasUid);
     }
     if (!is_object($oCaseConsolidated) || get_class($oCaseConsolidated) != 'CaseConsolidatedCore') {
         $oCaseConsolidated = new CaseConsolidatedCore();
         $oCaseConsolidated->setTasUid($sTasUid);
     }
     $oCaseConsolidated->setConStatus('ACTIVE');
     $oCaseConsolidated->setDynUid($sDynUid);
     $oCaseConsolidated->setRepTabUid($sRepTabUid);
     $oCaseConsolidated->save();
     $sClassName = $tableName;
     $oAdditionalTables = new AdditionalTables();
     $oAdditionalTables->createPropelClasses($tableName, $sClassName, $aFieldsClases, $sTasUid);
 }
예제 #26
0
 /**
  * Update this store information from the store location.
  *
  * @return bool true if updated, false otherwise
  */
 public function update($force = false, $type = 'plugin')
 {
     require_once PATH_CORE . 'classes' . PATH_SEP . 'class.pmLicenseManager.php';
     if (!class_exists('AddonsManagerPeer')) {
         require_once 'classes/model/AddonsManager.php';
     }
     //If we have any addon that is installing or updating, don't update store
     $criteria = new Criteria(AddonsManagerPeer::DATABASE_NAME);
     $criteria->add(AddonsManagerPeer::ADDON_STATE, '', Criteria::NOT_EQUAL);
     $criteria->add(AddonsManagerPeer::ADDON_TYPE, $type);
     if (AddonsManagerPeer::doCount($criteria) > 0) {
         return false;
     }
     $this->clear($type);
     //Fill with local information
     //List all plugins installed
     $oPluginRegistry =& PMPluginRegistry::getSingleton();
     $aPluginsPP = array();
     if (file_exists(PATH_DATA_SITE . 'ee')) {
         $aPluginsPP = unserialize(trim(file_get_contents(PATH_DATA_SITE . 'ee')));
     }
     $pmLicenseManagerO =& pmLicenseManager::getSingleton();
     $localPlugins = array();
     if ($type == 'plugin') {
         foreach ($aPluginsPP as $aPlugin) {
             $sClassName = substr($aPlugin['sFilename'], 0, strpos($aPlugin['sFilename'], '-'));
             if (file_exists(PATH_PLUGINS . $sClassName . '.php')) {
                 require_once PATH_PLUGINS . $sClassName . '.php';
                 $oDetails = $oPluginRegistry->getPluginDetails($sClassName . '.php');
                 if ($oDetails) {
                     $sStatus = $oDetails->enabled ? G::LoadTranslation('ID_ENABLED') : G::LoadTranslation('ID_DISABLED');
                     if (isset($oDetails->aWorkspaces)) {
                         if (!in_array(SYS_SYS, $oDetails->aWorkspaces)) {
                             continue;
                         }
                     }
                     if ($sClassName == "pmLicenseManager" || $sClassName == "pmTrial") {
                         continue;
                     }
                     $sEdit = $oDetails->sSetupPage != '' && $oDetails->enabled ? G::LoadTranslation('ID_SETUP') : ' ';
                     $aPlugin = array();
                     $aPluginId = $sClassName;
                     $aPluginTitle = $oDetails->sFriendlyName;
                     $aPluginDescription = $oDetails->sDescription;
                     $aPluginVersion = $oDetails->iVersion;
                     if (@in_array($sClassName, $pmLicenseManagerO->features)) {
                         $aPluginStatus = $sStatus;
                         $aPluginLinkStatus = 'pluginsChange?id=' . $sClassName . '.php&status=' . $oDetails->enabled;
                         $aPluginEdit = $sEdit;
                         $aPluginLinkEdit = 'pluginsSetup?id=' . $sClassName . '.php';
                         $aPluginStatusA = $sStatus == "Enabled" ? "installed" : 'disabled';
                         $enabledStatus = true;
                     } else {
                         $aPluginStatus = "";
                         $aPluginLinkStatus = '';
                         $aPluginEdit = '';
                         $aPluginLinkEdit = '';
                         $aPluginStatusA = 'minus-circle';
                         $enabledStatus = false;
                     }
                     $addon = new AddonsManager();
                     //G::pr($addon);
                     $addon->setAddonId($aPluginId);
                     $addon->setStoreId($this->getStoreId());
                     //Don't trust external data
                     $addon->setAddonName($aPluginId);
                     $addon->setAddonDescription($aPluginDescription);
                     $addon->setAddonNick($aPluginTitle);
                     $addon->setAddonVersion("");
                     $addon->setAddonStatus($aPluginStatusA);
                     $addon->setAddonType("plugin");
                     $addon->setAddonPublisher("Colosa");
                     $addon->setAddonDownloadUrl("");
                     $addon->setAddonDownloadMd5("");
                     $addon->setAddonReleaseDate(null);
                     $addon->setAddonReleaseType('localRegistry');
                     $addon->setAddonReleaseNotes("");
                     $addon->setAddonState("");
                     $addon->save();
                     $localPlugins[$aPluginId] = $addon;
                 }
             }
         }
     } else {
         $list = unserialize($pmLicenseManagerO->licensedfeaturesList);
         if (is_array($list)) {
             foreach ($list['addons'] as $key => $feature) {
                 $addon = new AddonsManager();
                 $addon->setAddonId($feature['name']);
                 $addon->setStoreId($feature['guid']);
                 $addon->setAddonName($feature['name']);
                 $addon->setAddonDescription($feature['description']);
                 $addon->setAddonNick($feature['nick']);
                 $addon->setAddonVersion("");
                 $addon->setAddonStatus($feature['status']);
                 $addon->setAddonType("features");
                 $addon->setAddonPublisher("Colosa");
                 $addon->setAddonDownloadUrl("");
                 $addon->setAddonDownloadMd5("");
                 $addon->setAddonReleaseDate(null);
                 $addon->setAddonReleaseType('localRegistry');
                 $addon->setAddonReleaseNotes("");
                 $addon->setAddonState("");
                 $addon->save();
             }
         }
     }
     $this->setStoreLastUpdated(time());
     $this->save();
     $url = $this->getStoreLocation();
     //Validate url
     $licenseInfo = $pmLicenseManagerO->getActiveLicense();
     $licenseId = str_replace('.dat', '', str_replace('license_', '', basename($licenseInfo['LICENSE_PATH'])));
     $url = explode('&', $url);
     $url[count($url) - 1] = 'licId=' . urlencode($licenseId);
     $url = implode('&', $url);
     if (EnterpriseUtils::getInternetConnection() == 1 && EnterpriseUtils::checkConnectivity($url) == true) {
         $option = array("http" => array("method" => "POST", "header" => "Content-type: application/x-www-form-urlencoded\r\n", "content" => http_build_query(array("pmVersion" => System::getVersion(), "version" => STORE_VERSION))));
         // Proxy settings
         $sysConf = System::getSystemConfiguration();
         if (isset($sysConf['proxy_host'])) {
             if ($sysConf['proxy_host'] != '') {
                 if (!is_array($option['http'])) {
                     $option['http'] = array();
                 }
                 $option['http']['request_fulluri'] = true;
                 $option['http']['proxy'] = 'tcp://' . $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '');
                 if ($sysConf['proxy_user'] != '') {
                     if (!isset($option['http']['header'])) {
                         $option['http']['header'] = '';
                     }
                     $option['http']['header'] .= 'Proxy-Authorization: Basic ' . base64_encode($sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
                 }
             }
         }
         $context = stream_context_create($option);
         //This may block for a while, always use AJAX to call this method
         $url = $url . '&type=' . strtoupper($type);
         $data = file_get_contents($url, false, $context);
         if ($data === false) {
             throw new Exception("Could not contact store");
         }
         $serverData = G::json_decode($data);
         //Don't trust external data
         if (empty($serverData)) {
             throw new Exception("Store data invalid ('{$data}')");
         }
         if (isset($serverData->error)) {
             throw new Exception("Store sent us an error: {$serverData->error}");
         }
         if (!isset($serverData->version)) {
             throw new Exception("Store version not found");
         }
         if ($serverData->version != STORE_VERSION) {
             throw new Exception("Store version '{$serverData->version}' unsupported");
         }
         if (!isset($serverData->addons)) {
             throw new Exception("Addons not found on store data");
         }
         $this->clear($type);
         try {
             //Add each item to this stores addons
             $addons = @get_object_vars($serverData->addons);
             if (!empty($addons)) {
                 foreach (get_object_vars($serverData->addons) as $addonId => $addonInfo) {
                     $addon = new AddonsManager();
                     $addon->setAddonId($addonId);
                     $addon->setStoreId($this->getStoreId());
                     //Don't trust external data
                     $addon->setAddonName(isset($addonInfo->name) ? $addonInfo->name : $addonId);
                     $addon->setAddonDescription(isset($addonInfo->description) ? $addonInfo->description : "");
                     $addon->setAddonNick(isset($addonInfo->nick) ? $addonInfo->nick : "");
                     $addon->setAddonVersion(isset($addonInfo->version) ? $addonInfo->version : "");
                     $addon->setAddonStatus(isset($addonInfo->status) ? $addonInfo->status : "");
                     $addon->setAddonType(isset($addonInfo->type) ? $addonInfo->type : "");
                     $addon->setAddonPublisher(isset($addonInfo->publisher) ? $addonInfo->publisher : "");
                     $workspace = isset($pmLicenseManagerO->workspace) ? $pmLicenseManagerO->workspace : 'pmLicenseSrv';
                     $addon->setAddonDownloadUrl(isset($addonInfo->download_url) ? $addonInfo->download_url : "http://" . $pmLicenseManagerO->server . "/sys" . $workspace . "/en/green/services/rest?action=getPlugin&OBJ_UID=" . $addonInfo->guid);
                     $addon->setAddonDownloadMd5(isset($addonInfo->download_md5) ? $addonInfo->download_md5 : "");
                     $addon->setAddonReleaseDate(isset($addonInfo->release_date) ? $addonInfo->release_date : "");
                     $addon->setAddonReleaseType(isset($addonInfo->release_type) ? $addonInfo->release_type : '');
                     $addon->setAddonReleaseNotes(isset($addonInfo->release_notes) ? $addonInfo->release_notes : "");
                     $addon->setAddonState("");
                     $addon->save();
                     if (isset($localPlugins[$addonId])) {
                         unset($localPlugins[$addonId]);
                     }
                 }
                 foreach ($localPlugins as $keyPlugin => $addonA) {
                     //G::pr($addonA );
                     //$addonA->save();
                     $addon = new AddonsManager();
                     //G::pr($addon);
                     $addon->setAddonId($addonA->getAddonId());
                     $addon->setStoreId($addonA->getStoreId());
                     //Don't trust external data
                     $addon->setAddonName($addonA->getAddonName());
                     $addon->setAddonDescription($addonA->getAddonDescription());
                     $addon->setAddonNick($addonA->getAddonNick());
                     $addon->setAddonVersion("");
                     $addon->setAddonStatus($addonA->getAddonStatus());
                     $addon->setAddonType($addonA->getAddonType());
                     $addon->setAddonPublisher($addonA->getAddonPublisher());
                     $addon->setAddonDownloadUrl($addonA->getAddonDownloadUrl());
                     $addon->setAddonDownloadMd5($addonA->getAddonDownloadMd5());
                     $addon->setAddonReleaseDate(null);
                     $addon->setAddonReleaseType('localRegistry');
                     $addon->setAddonReleaseNotes("");
                     $addon->setAddonState("");
                     $addon->save();
                 }
             }
             $this->setStoreLastUpdated(time());
             $this->save();
         } catch (Exception $e) {
             //If we had issues, don't keep only a part of the items
             $this->clear($type);
             throw $e;
         }
     }
     return true;
 }
예제 #27
0
 /**
  * Export PM tables
  *
  * @author : Erik Amaru Ortiz <*****@*****.**>
  */
 public function export($httpData)
 {
     require_once 'classes/model/AdditionalTables.php';
     $at = new AdditionalTables();
     $tablesToExport = G::json_decode(stripslashes($httpData->rows));
     try {
         G::LoadCLass('net');
         $net = new NET(G::getIpAddress());
         G::LoadClass("system");
         $META = " \n-----== ProcessMaker Open Source Private Tables ==-----\n" . " @Ver: 1.0 Oct-2009\n" . " @Processmaker version: " . System::getVersion() . "\n" . " -------------------------------------------------------\n" . " @Export Date: " . date("l jS \\of F Y h:i:s A") . "\n" . " @Server address: " . getenv('SERVER_NAME') . " (" . getenv('SERVER_ADDR') . ")\n" . " @Client address: " . $net->hostname . "\n" . " @Workspace: " . SYS_SYS . "\n" . " @Export trace back:\n\n";
         $EXPORT_TRACEBACK = array();
         $c = 0;
         foreach ($tablesToExport as $table) {
             $tableRecord = $at->load($table->ADD_TAB_UID);
             $tableData = $at->getAllData($table->ADD_TAB_UID, null, null, false);
             $table->ADD_TAB_NAME = $tableRecord['ADD_TAB_NAME'];
             $rows = $tableData['rows'];
             $count = $tableData['count'];
             array_push($EXPORT_TRACEBACK, array('uid' => $table->ADD_TAB_UID, 'name' => $table->ADD_TAB_NAME, 'num_regs' => $tableData['count'], 'schema' => $table->_SCHEMA ? 'yes' : 'no', 'data' => $table->_DATA ? 'yes' : 'no'));
         }
         $sTrace = "TABLE UID                        TABLE NAME\tREGS\tSCHEMA\tDATA\n";
         foreach ($EXPORT_TRACEBACK as $row) {
             $sTrace .= "{$row['uid']}\t{$row['name']}\t\t{$row['num_regs']}\t{$row['schema']}\t{$row['data']}\n";
         }
         $META .= $sTrace;
         ///////////////EXPORT PROCESS
         $PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP;
         $filenameOnly = strtolower('SYS-' . SYS_SYS . "_" . date("Y-m-d") . '_' . date("Hi") . ".pmt");
         $filename = $PUBLIC_ROOT_PATH . $filenameOnly;
         $fp = fopen($filename, "wb");
         $bytesSaved = 0;
         $bufferType = '@META';
         $fsData = sprintf("%09d", strlen($META));
         $fsbufferType = sprintf("%09d", strlen($bufferType));
         $bytesSaved += fwrite($fp, $fsbufferType);
         //writing the size of $oData
         $bytesSaved += fwrite($fp, $bufferType);
         //writing the $oData
         $bytesSaved += fwrite($fp, $fsData);
         //writing the size of $oData
         $bytesSaved += fwrite($fp, $META);
         //writing the $oData
         foreach ($tablesToExport as $table) {
             if ($table->_SCHEMA) {
                 $oAdditionalTables = new AdditionalTables();
                 $aData = $oAdditionalTables->load($table->ADD_TAB_UID, true);
                 $bufferType = '@SCHEMA';
                 $SDATA = serialize($aData);
                 $fsUid = sprintf("%09d", strlen($table->ADD_TAB_UID));
                 $fsData = sprintf("%09d", strlen($SDATA));
                 $fsbufferType = sprintf("%09d", strlen($bufferType));
                 $bytesSaved += fwrite($fp, $fsbufferType);
                 //writing the size of $oData
                 $bytesSaved += fwrite($fp, $bufferType);
                 //writing the $oData
                 $bytesSaved += fwrite($fp, $fsUid);
                 //writing the size of xml file
                 $bytesSaved += fwrite($fp, $table->ADD_TAB_UID);
                 //writing the xmlfile
                 $bytesSaved += fwrite($fp, $fsData);
                 //writing the size of xml file
                 $bytesSaved += fwrite($fp, $SDATA);
                 //writing the xmlfile
             }
             if ($table->_DATA) {
                 //export data
                 $oAdditionalTables = new additionalTables();
                 $tableData = $oAdditionalTables->getAllData($table->ADD_TAB_UID, null, null, false);
                 $SDATA = serialize($tableData['rows']);
                 $bufferType = '@DATA';
                 $fsbufferType = sprintf("%09d", strlen($bufferType));
                 $fsTableName = sprintf("%09d", strlen($table->ADD_TAB_NAME));
                 $fsData = sprintf("%09d", strlen($SDATA));
                 $bytesSaved += fwrite($fp, $fsbufferType);
                 //writing type size
                 $bytesSaved += fwrite($fp, $bufferType);
                 //writing type
                 $bytesSaved += fwrite($fp, $fsTableName);
                 //writing the size of xml file
                 $bytesSaved += fwrite($fp, $table->ADD_TAB_NAME);
                 //writing the xmlfile
                 $bytesSaved += fwrite($fp, $fsData);
                 //writing the size of xml file
                 $bytesSaved += fwrite($fp, $SDATA);
                 //writing the xmlfile
             }
         }
         fclose($fp);
         $filenameLink = "pmTables/streamExported?f={$filenameOnly}";
         $size = round($bytesSaved / 1024, 2) . " Kb";
         $meta = "<pre>" . $META . "</pre>";
         $filename = $filenameOnly;
         $link = $filenameLink;
         $result->success = true;
         $result->filename = $filenameOnly;
         $result->link = $link;
         $result->message = "Generated file: {$filenameOnly}, size: {$size}";
     } catch (Exception $e) {
         $result->success = false;
         $result->message = $e->getMessage();
     }
     return $result;
 }
예제 #28
0
             $oAdditionalTables->updateTable($data['REP_TAB_NAME'], $data['REP_TAB_CONNECTION'], $aFields, $oldFields);
         }
         $oAdditionalTables->createPropelClasses($data['REP_TAB_NAME'], $repTabClassName, $fieldsList, $addTabUid);
         $oAdditionalTables->populateReportTable($data['REP_TAB_NAME'], $data['REP_TAB_CONNECTION'], $data['REP_TAB_TYPE'], $fieldsList, $data['PRO_UID'], $data['REP_TAB_GRID']);
         $result->success = true;
     } catch (Exception $e) {
         $result->success = false;
         $result->msg = $e->getMessage();
         $result->trace = $e->getTraceAsString();
     }
     echo G::json_encode($result);
     break;
 case 'delete':
     require_once 'classes/model/AdditionalTables.php';
     G::LoadClass('reportTables');
     $rows = G::json_decode($_REQUEST['rows']);
     $rp = new reportTables();
     $at = new AdditionalTables();
     try {
         foreach ($rows as $row) {
             if ($row->type == 'CLASSIC') {
                 $rp->deleteReportTable($row->id);
             } else {
                 $at->deleteAll($row->id);
             }
         }
         $result->success = true;
     } catch (Exception $e) {
         $result->success = false;
         $result->msg = $e->getMessage();
     }
예제 #29
0
 public static function browserCacheFilesGetLibraryJs()
 {
     $arrayLibrary = array();
     //Translations /js/ext/translation.en.js
     //Translations /js/ext/translation.xxx.en.js //xxx is an plugin
     $arrayLibrary["translation"] = 1;
     //Not use null
     //Translation environment /jscore/labels/en.js
     if (file_exists(PATH_DATA . "META-INF" . PATH_SEP . "translations.env")) {
         $arrayData = unserialize(file_get_contents(PATH_DATA . "META-INF" . PATH_SEP . "translations.env"));
         foreach ($arrayData as $index1 => $value1) {
             foreach ($value1 as $index2 => $value2) {
                 $record = $value2;
                 if (file_exists(PATH_CORE . "js" . PATH_SEP . "labels" . PATH_SEP . $record["LOCALE"] . ".js")) {
                     $arrayLibrary[$record["LOCALE"]] = 1;
                 }
             }
         }
     }
     //Libraries
     $library = G::json_decode(file_get_contents(PATH_HOME . "engine" . PATH_SEP . "bin" . PATH_SEP . "tasks" . PATH_SEP . "libraries.json"));
     foreach ($library as $index => $value) {
         $lib = $value;
         if ($lib->build) {
             if (substr($lib->build_js_to, -1) != "/") {
                 $lib->build_js_to = $lib->build_js_to . "/";
             }
             $arrayLibrary[$lib->name] = 1;
         }
     }
     return $arrayLibrary;
 }
예제 #30
0
    /**

     * restore an archive into a workspace

     *

     * Restores any database and files included in the backup, either as a new

     * workspace, or overwriting a previous one

     *

     * @param string $filename the backup filename

     * @param string $newWorkspaceName if defined, supplies the name for the

     * workspace to restore to

     */

    static public function restore($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true, $lang = 'en', $port = '')

    {

        G::LoadThirdParty('pear/Archive', 'Tar');

        $backup = new Archive_Tar($filename);

        //Get a temporary directory in the upgrade directory

        $tempDirectory = PATH_DATA . "upgrade/" . basename(tempnam(__FILE__, ''));

        $parentDirectory = PATH_DATA . "upgrade";

        if (is_writable($parentDirectory)) {

            mkdir($tempDirectory);

        } else {

            throw new Exception("Could not create directory:" . $parentDirectory);

        }

        //Extract all backup files, including database scripts and workspace files

        if (!$backup->extract($tempDirectory)) {

            throw new Exception("Could not extract backup");

        }

        //Search for metafiles in the new standard (the old standard would contain

        //txt files).

        $metaFiles = glob($tempDirectory . "/*.meta");

        if (empty($metaFiles)) {

            $metaFiles = glob($tempDirectory . "/*.txt");

            if (!empty($metaFiles)) {

                return workspaceTools::restoreLegacy($tempDirectory);

            } else {

                throw new Exception("No metadata found in backup");

            }

        } else {

            CLI::logging("Found " . count($metaFiles) . " workspaces in backup:\n");

            foreach ($metaFiles as $metafile) {

                CLI::logging("-> " . basename($metafile) . "\n");

            }

        }

        if (count($metaFiles) > 1 && (!isset($srcWorkspace))) {

            throw new Exception("Multiple workspaces in backup but no workspace specified to restore");

        }

        if (isset($srcWorkspace) && !in_array("$srcWorkspace.meta", array_map(BASENAME, $metaFiles))) {

            throw new Exception("Workspace $srcWorkspace not found in backup");

        }



        $version = System::getVersion();

        $version = explode('-', $version);

        $versionPresent = ( isset($version[0])) ? $version[0] : '';

        CLI::logging(CLI::warning("

            Warning: A workspace from a newer version of ProcessMaker can NOT be restored in an older version of

            ProcessMaker. For example, restoring from v.3.0 to v.2.5 will not work. However, it may be possible

            to restore a workspace from an older version to an newer version of ProcessMaker, although error

            messages may be displayed during the restore process. Make sure to run the \"processmaker cacheview-repair\"

            and \"processmaker migrate-new-cases-lists\" commands after restoring a workspace.") . "\n");



        foreach ($metaFiles as $metaFile) {

            $metadata = G::json_decode(file_get_contents($metaFile));

            if ($metadata->version != 1) {

                throw new Exception("Backup version {$metadata->version} not supported");

            }

            $backupWorkspace = $metadata->WORKSPACE_NAME;



            if (strpos($metadata->DB_RBAC_NAME, 'rb_') === false) {

                $onedb = true;

                $oldDatabases = 1;

            } else {

                $onedb = false;

                $oldDatabases = 3;

            }



            if (isset($dstWorkspace)) {

                $workspaceName = $dstWorkspace;

                $createWorkspace = true;

            } else {

                $workspaceName = $metadata->WORKSPACE_NAME;

                $createWorkspace = false;

            }

            if (isset($srcWorkspace) && strcmp($metadata->WORKSPACE_NAME, $srcWorkspace) != 0) {

                CLI::logging(CLI::warning("> Workspace $backupWorkspace found, but not restoring.") . "\n");

                continue;

            } else {

                CLI::logging("> Restoring " . CLI::info($backupWorkspace) . " to " . CLI::info($workspaceName) . "\n");

            }

            $workspace = new workspaceTools($workspaceName);



            if ($workspace->workspaceExists()) {



                if ($overwrite) {

                    if ($workspace->dbInfo['DB_NAME'] == $workspace->dbInfo['DB_RBAC_NAME']) {

                        $newDatabases = 1;

                    } else {

                        $newDatabases = 3;

                    }



                    if ($newDatabases != $oldDatabases) {

                        throw new Exception("We can't overwrite this workspace because it has a different amount of databases. Not only the 'source' but also the 'target' must have the same amount of databases.");

                    }

                    CLI::logging(CLI::warning("> Workspace $workspaceName already exist, overwriting!") . "\n");

                } else {

                    throw new Exception("Destination workspace already exist (use -o to overwrite)");

                }

            }

            if (file_exists($workspace->path)) {

                G::rm_dir($workspace->path);

            }

            foreach ($metadata->directories as $dir) {

                CLI::logging("+> Restoring directory '$dir'\n");



                if (file_exists("$tempDirectory/$dir" . "/ee")) {

                    G::rm_dir("$tempDirectory/$dir" . "/ee");

                }

                if (file_exists("$tempDirectory/$dir" . "/plugin.singleton")) {

                    G::rm_dir("$tempDirectory/$dir" . "/plugin.singleton");

                }

                if (!rename("$tempDirectory/$dir", $workspace->path)) {

                    throw new Exception("There was an error copying the backup files ($tempDirectory/$dir) to the workspace directory {$workspace->path}.");

                }

            }



            CLI::logging("> Changing file permissions\n");

            $shared_stat = stat(PATH_DATA);

            if ($shared_stat !== false) {

                workspaceTools::dirPerms($workspace->path, $shared_stat['uid'], $shared_stat['gid'], $shared_stat['mode']);

            } else {

                CLI::logging(CLI::error("Could not get the shared folder permissions, not changing workspace permissions") . "\n");

            }

            list ($dbHost, $dbUser, $dbPass) = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH));

            if($port != ''){

               $dbHost = $dbHost.$port; //127.0.0.1:3306

            }

            $aParameters = array('dbHost'=>$dbHost,'dbUser'=>$dbUser,'dbPass'=>$dbPass);

            CLI::logging("> Connecting to system database in '$dbHost'\n");

            $link = mysql_connect($dbHost, $dbUser, $dbPass);

            @mysql_query("SET NAMES 'utf8';");

            @mysql_query("SET FOREIGN_KEY_CHECKS=0;");

            if (!$link) {

                throw new Exception('Could not connect to system database: ' . mysql_error());

            }



            $dbName = '';

            $newDBNames = $workspace->resetDBInfo($dbHost, $createWorkspace, $onedb);



            foreach ($metadata->databases as $db) {

                if ($dbName != $newDBNames[$db->name]) {

                    $dbName = $newDBNames[$db->name];



                    if (mysql_select_db($dbName, $link)) {

                        if(!$overwrite) {

                            throw new Exception("Destination Database already exist (use -o to overwrite)");

                        }

                    }



                    CLI::logging("+> Restoring database {$db->name} to $dbName\n");

                    $workspace->executeSQLScript($dbName, "$tempDirectory/{$db->name}.sql",$aParameters);

                    $workspace->createDBUser($dbName, $db->pass, "localhost", $dbName);

                    $workspace->createDBUser($dbName, $db->pass, "%", $dbName);

                }

            }



            $version = explode('-', $metadata->PM_VERSION);

            $versionOld = ( isset($version[0])) ? $version[0] : '';

            CLI::logging(CLI::info("$versionOld < $versionPresent") . "\n");



            $start = microtime(true);

            CLI::logging("> Verify files enterprise old...\n");

            $workspace->verifyFilesOldEnterprise($workspaceName);

            $stop = microtime(true);

            $final = $stop - $start;

            CLI::logging("<*>   Verify took $final seconds.\n");



            if ( $versionOld < $versionPresent || strpos($versionPresent, "Branch")) {

                $start = microtime(true);

                CLI::logging("> Updating database...\n");

                $workspace->upgradeDatabase($onedb);

                $stop = microtime(true);

                $final = $stop - $start;

                CLI::logging("<*>   Database Upgrade Process took $final seconds.\n");

            }

            $start = microtime(true);

            CLI::logging("> Verify License Enterprise...\n");

            $workspace->verifyLicenseEnterprise($workspaceName);

            $stop = microtime(true);

            $final = $stop - $start;

            CLI::logging("<*>   Verify took $final seconds.\n");



            $workspace->checkMafeRequirements($workspaceName, $lang);



            /*----------------------------------********---------------------------------*/



            mysql_close($link);

        }



        CLI::logging("Removing temporary files\n");



        G::rm_dir($tempDirectory);



        CLI::logging(CLI::info("Done restoring") . "\n");

    }