Merged in bugfix/HOR-3670-HQ (pull request #5924)
HOR-3670 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
commit
1bb0e29466
@@ -1,70 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2012 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* 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, 5304 Ventura Drive,
|
||||
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once "classes/model/Application.php";
|
||||
require_once "classes/model/AppDelegation.php";
|
||||
require_once "classes/model/AppThread.php";
|
||||
require_once "classes/model/Content.php";
|
||||
require_once "classes/model/Users.php";
|
||||
require_once "classes/model/GroupUser.php";
|
||||
require_once "classes/model/Task.php";
|
||||
require_once "classes/model/TaskUser.php";
|
||||
require_once "classes/model/Dynaform.php";
|
||||
require_once "classes/model/ProcessVariables.php";
|
||||
require_once "entities/SolrRequestData.php";
|
||||
require_once "entities/SolrUpdateDocument.php";
|
||||
require_once "entities/AppSolrQueue.php";
|
||||
require_once "classes/model/AppSolrQueue.php";
|
||||
|
||||
|
||||
/**
|
||||
* Invalid search text for Solr exception
|
||||
*
|
||||
* @author Herbert Saal Gutierrez
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Application without Delegations exception
|
||||
*
|
||||
* @author Herbert Saal Gutierrez
|
||||
*
|
||||
* @category Colosa
|
||||
* @copyright Copyright (c) 2005-2012 Colosa Inc. (http://www.colosa.com)
|
||||
*/class ApplicationWithoutDelegationRecordsException extends Exception
|
||||
*/
|
||||
class ApplicationWithoutDelegationRecordsException extends Exception
|
||||
{
|
||||
// Redefine the exception so message isn't optional
|
||||
public function __construct($message, $code = 0)
|
||||
{
|
||||
// some code
|
||||
// make sure everything is assigned properly
|
||||
parent::__construct ($message, $code);
|
||||
}
|
||||
|
||||
// custom string representation of object
|
||||
public function __toString()
|
||||
{
|
||||
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
|
||||
}
|
||||
// Redefine the exception so message isn't optional
|
||||
public function __construct($message, $code = 0)
|
||||
{
|
||||
// some code
|
||||
// make sure everything is assigned properly
|
||||
parent::__construct($message, $code);
|
||||
}
|
||||
|
||||
// custom string representation of object
|
||||
public function __toString()
|
||||
{
|
||||
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,7 @@
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/class archive
|
||||
class Archive
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -30,14 +26,14 @@
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public function archive ($name)
|
||||
public function archive($name)
|
||||
{
|
||||
$this->options = array ('basedir' => ".",'name' => $name,'prepend' => "",'inmemory' => 0,'overwrite' => 0,'recurse' => 1,'storepaths' => 1,'followlinks' => 0,'level' => 3,'method' => 1,'sfx' => "",'type' => "",'comment' => ""
|
||||
$this->options = array('basedir' => ".", 'name' => $name, 'prepend' => "", 'inmemory' => 0, 'overwrite' => 0, 'recurse' => 1, 'storepaths' => 1, 'followlinks' => 0, 'level' => 3, 'method' => 1, 'sfx' => "", 'type' => "", 'comment' => ""
|
||||
);
|
||||
$this->files = array ();
|
||||
$this->exclude = array ();
|
||||
$this->storeonly = array ();
|
||||
$this->error = array ();
|
||||
$this->files = array();
|
||||
$this->exclude = array();
|
||||
$this->storeonly = array();
|
||||
$this->error = array();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,25 +42,25 @@
|
||||
* @param array $options
|
||||
* @return void
|
||||
*/
|
||||
public function set_options ($options)
|
||||
public function set_options($options)
|
||||
{
|
||||
foreach ($options as $key => $value) {
|
||||
$this->options[$key] = $value;
|
||||
}
|
||||
if (! empty( $this->options['basedir'] )) {
|
||||
$this->options['basedir'] = str_replace( "\\", "/", $this->options['basedir'] );
|
||||
$this->options['basedir'] = preg_replace( "/\/+/", "/", $this->options['basedir'] );
|
||||
$this->options['basedir'] = preg_replace( "/\/$/", "", $this->options['basedir'] );
|
||||
if (!empty($this->options['basedir'])) {
|
||||
$this->options['basedir'] = str_replace("\\", "/", $this->options['basedir']);
|
||||
$this->options['basedir'] = preg_replace("/\/+/", "/", $this->options['basedir']);
|
||||
$this->options['basedir'] = preg_replace("/\/$/", "", $this->options['basedir']);
|
||||
}
|
||||
if (! empty( $this->options['name'] )) {
|
||||
$this->options['name'] = str_replace( "\\", "/", $this->options['name'] );
|
||||
$this->options['name'] = preg_replace( "/\/+/", "/", $this->options['name'] );
|
||||
if (!empty($this->options['name'])) {
|
||||
$this->options['name'] = str_replace("\\", "/", $this->options['name']);
|
||||
$this->options['name'] = preg_replace("/\/+/", "/", $this->options['name']);
|
||||
}
|
||||
if (! empty( $this->options['prepend'] )) {
|
||||
$this->options['prepend'] = str_replace( "\\", "/", $this->options['prepend'] );
|
||||
$this->options['prepend'] = preg_replace( "/^(\.*\/+)+/", "", $this->options['prepend'] );
|
||||
$this->options['prepend'] = preg_replace( "/\/+/", "/", $this->options['prepend'] );
|
||||
$this->options['prepend'] = preg_replace( "/\/$/", "", $this->options['prepend'] ) . "/";
|
||||
if (!empty($this->options['prepend'])) {
|
||||
$this->options['prepend'] = str_replace("\\", "/", $this->options['prepend']);
|
||||
$this->options['prepend'] = preg_replace("/^(\.*\/+)+/", "", $this->options['prepend']);
|
||||
$this->options['prepend'] = preg_replace("/\/+/", "/", $this->options['prepend']);
|
||||
$this->options['prepend'] = preg_replace("/\/$/", "", $this->options['prepend']) . "/";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,21 +69,21 @@
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function create_archive ()
|
||||
public function create_archive()
|
||||
{
|
||||
$this->make_list();
|
||||
if ($this->options['inmemory'] == 0) {
|
||||
$pwd = getcwd();
|
||||
chdir( $this->options['basedir'] );
|
||||
if ($this->options['overwrite'] == 0 && file_exists( $this->options['name'] . ($this->options['type'] == "gzip" || $this->options['type'] == "bzip" ? ".tmp" : "") )) {
|
||||
chdir($this->options['basedir']);
|
||||
if ($this->options['overwrite'] == 0 && file_exists($this->options['name'] . ($this->options['type'] == "gzip" || $this->options['type'] == "bzip" ? ".tmp" : ""))) {
|
||||
$this->error[] = "File {$this->options['name']} already exist.";
|
||||
chdir( $pwd );
|
||||
chdir($pwd);
|
||||
return 0;
|
||||
} elseif ($this->archive = @fopen( $this->options['name'] . ($this->options['type'] == "gzip" || $this->options['type'] == "bzip" ? ".tmp" : ""), "wb+" )) {
|
||||
chdir( $pwd );
|
||||
} elseif ($this->archive = @fopen($this->options['name'] . ($this->options['type'] == "gzip" || $this->options['type'] == "bzip" ? ".tmp" : ""), "wb+")) {
|
||||
chdir($pwd);
|
||||
} else {
|
||||
$this->error[] = "Could not open {$this->options['name']} for writing.";
|
||||
chdir( $pwd );
|
||||
chdir($pwd);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@@ -95,41 +91,41 @@
|
||||
}
|
||||
switch ($this->options['type']) {
|
||||
case "zip":
|
||||
if (! $this->create_zip()) {
|
||||
if (!$this->create_zip()) {
|
||||
$this->error[] = "Could not create zip file.";
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case "bzip":
|
||||
if (! $this->create_tar()) {
|
||||
if (!$this->create_tar()) {
|
||||
$this->error[] = "Could not create tar file.";
|
||||
return 0;
|
||||
}
|
||||
if (! $this->create_bzip()) {
|
||||
if (!$this->create_bzip()) {
|
||||
$this->error[] = "Could not create bzip2 file.";
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case "gzip":
|
||||
if (! $this->create_tar()) {
|
||||
if (!$this->create_tar()) {
|
||||
$this->error[] = "Could not create tar file.";
|
||||
return 0;
|
||||
}
|
||||
if (! $this->create_gzip()) {
|
||||
if (!$this->create_gzip()) {
|
||||
$this->error[] = "Could not create gzip file.";
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case "tar":
|
||||
if (! $this->create_tar()) {
|
||||
if (!$this->create_tar()) {
|
||||
$this->error[] = "Could not create tar file.";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ($this->options['inmemory'] == 0) {
|
||||
fclose( $this->archive );
|
||||
fclose($this->archive);
|
||||
if ($this->options['type'] == "gzip" || $this->options['type'] == "bzip") {
|
||||
unlink( $this->options['basedir'] . "/" . $this->options['name'] . ".tmp" );
|
||||
unlink($this->options['basedir'] . "/" . $this->options['name'] . ".tmp");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,10 +136,10 @@
|
||||
* @param string $data
|
||||
* @return void
|
||||
*/
|
||||
public function add_data ($data)
|
||||
public function add_data($data)
|
||||
{
|
||||
if ($this->options['inmemory'] == 0) {
|
||||
fwrite( $this->archive, $data );
|
||||
fwrite($this->archive, $data);
|
||||
} else {
|
||||
$this->archive .= $data;
|
||||
}
|
||||
@@ -154,18 +150,18 @@
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function make_list ()
|
||||
public function make_list()
|
||||
{
|
||||
if (! empty( $this->exclude )) {
|
||||
if (!empty($this->exclude)) {
|
||||
foreach ($this->files as $key => $value) {
|
||||
foreach ($this->exclude as $current) {
|
||||
if ($value['name'] == $current['name']) {
|
||||
unset( $this->files[$key] );
|
||||
unset($this->files[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! empty( $this->storeonly )) {
|
||||
if (!empty($this->storeonly)) {
|
||||
foreach ($this->files as $key => $value) {
|
||||
foreach ($this->storeonly as $current) {
|
||||
if ($value['name'] == $current['name']) {
|
||||
@@ -174,7 +170,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
unset( $this->exclude, $this->storeonly );
|
||||
unset($this->exclude, $this->storeonly);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,9 +179,9 @@
|
||||
* @param array $list
|
||||
* @return void
|
||||
*/
|
||||
public function add_files ($list)
|
||||
public function add_files($list)
|
||||
{
|
||||
$temp = $this->list_files( $list );
|
||||
$temp = $this->list_files($list);
|
||||
foreach ($temp as $current) {
|
||||
$this->files[] = $current;
|
||||
}
|
||||
@@ -197,9 +193,9 @@
|
||||
* @param array $list
|
||||
* @return void
|
||||
*/
|
||||
public function exclude_files ($list)
|
||||
public function exclude_files($list)
|
||||
{
|
||||
$temp = $this->list_files( $list );
|
||||
$temp = $this->list_files($list);
|
||||
foreach ($temp as $current) {
|
||||
$this->exclude[] = $current;
|
||||
}
|
||||
@@ -210,9 +206,9 @@
|
||||
*
|
||||
* @param array $list
|
||||
*/
|
||||
public function store_files ($list)
|
||||
public function store_files($list)
|
||||
{
|
||||
$temp = $this->list_files( $list );
|
||||
$temp = $this->list_files($list);
|
||||
foreach ($temp as $current) {
|
||||
$this->storeonly[] = $current;
|
||||
}
|
||||
@@ -224,47 +220,47 @@
|
||||
* @param array $list
|
||||
* @return array
|
||||
*/
|
||||
public function list_files ($list)
|
||||
public function list_files($list)
|
||||
{
|
||||
if (! is_array( $list )) {
|
||||
if (!is_array($list)) {
|
||||
$temp = $list;
|
||||
$list = array ($temp
|
||||
$list = array($temp
|
||||
);
|
||||
unset( $temp );
|
||||
unset($temp);
|
||||
}
|
||||
$files = array ();
|
||||
$files = array();
|
||||
$pwd = getcwd();
|
||||
chdir( $this->options['basedir'] );
|
||||
chdir($this->options['basedir']);
|
||||
foreach ($list as $current) {
|
||||
$current = str_replace( "\\", "/", $current );
|
||||
$current = preg_replace( "/\/+/", "/", $current );
|
||||
$current = preg_replace( "/\/$/", "", $current );
|
||||
if (strstr( $current, "*" )) {
|
||||
$regex = preg_replace( "/([\\\^\$\.\[\]\|\(\)\?\+\{\}\/])/", "\\\\\\1", $current );
|
||||
$regex = str_replace( "*", ".*", $regex );
|
||||
$dir = strstr( $current, "/" ) ? substr( $current, 0, strrpos( $current, "/" ) ) : ".";
|
||||
$temp = $this->parse_dir( $dir );
|
||||
$current = str_replace("\\", "/", $current);
|
||||
$current = preg_replace("/\/+/", "/", $current);
|
||||
$current = preg_replace("/\/$/", "", $current);
|
||||
if (strstr($current, "*")) {
|
||||
$regex = preg_replace("/([\\\^\$\.\[\]\|\(\)\?\+\{\}\/])/", "\\\\\\1", $current);
|
||||
$regex = str_replace("*", ".*", $regex);
|
||||
$dir = strstr($current, "/") ? substr($current, 0, strrpos($current, "/")) : ".";
|
||||
$temp = $this->parse_dir($dir);
|
||||
foreach ($temp as $current2) {
|
||||
if (preg_match( "/^{$regex}$/i", $current2['name'] )) {
|
||||
if (preg_match("/^{$regex}$/i", $current2['name'])) {
|
||||
$files[] = $current2;
|
||||
}
|
||||
}
|
||||
unset( $regex, $dir, $temp, $current );
|
||||
} elseif (@is_dir( $current )) {
|
||||
$temp = $this->parse_dir( $current );
|
||||
unset($regex, $dir, $temp, $current);
|
||||
} elseif (@is_dir($current)) {
|
||||
$temp = $this->parse_dir($current);
|
||||
foreach ($temp as $file) {
|
||||
$files[] = $file;
|
||||
}
|
||||
unset( $temp, $file );
|
||||
} elseif (@file_exists( $current )) {
|
||||
$files[] = array ('name' => $current,'name2' => $this->options['prepend'] . preg_replace( "/(\.+\/+)+/", "", ($this->options['storepaths'] == 0 && strstr( $current, "/" )) ? substr( $current, strrpos( $current, "/" ) + 1 ) : $current ),'type' => @is_link( $current ) && $this->options['followlinks'] == 0 ? 2 : 0,'ext' => substr( $current, strrpos( $current, "." ) ),'stat' => stat( $current )
|
||||
unset($temp, $file);
|
||||
} elseif (@file_exists($current)) {
|
||||
$files[] = array('name' => $current, 'name2' => $this->options['prepend'] . preg_replace("/(\.+\/+)+/", "", ($this->options['storepaths'] == 0 && strstr($current, "/")) ? substr($current, strrpos($current, "/") + 1) : $current), 'type' => @is_link($current) && $this->options['followlinks'] == 0 ? 2 : 0, 'ext' => substr($current, strrpos($current, ".")), 'stat' => stat($current)
|
||||
);
|
||||
}
|
||||
}
|
||||
chdir( $pwd );
|
||||
unset( $current, $pwd );
|
||||
usort( $files, array ("archive","sort_files"
|
||||
) );
|
||||
chdir($pwd);
|
||||
unset($current, $pwd);
|
||||
usort($files, array("archive", "sort_files"
|
||||
));
|
||||
return $files;
|
||||
}
|
||||
|
||||
@@ -274,34 +270,34 @@
|
||||
* @param string $dirname
|
||||
* @return array
|
||||
*/
|
||||
public function parse_dir ($dirname)
|
||||
public function parse_dir($dirname)
|
||||
{
|
||||
if ($this->options['storepaths'] == 1 && ! preg_match( "/^(\.+\/*)+$/", $dirname )) {
|
||||
$files = array (array ('name' => $dirname,'name2' => $this->options['prepend'] . preg_replace( "/(\.+\/+)+/", "", ($this->options['storepaths'] == 0 && strstr( $dirname, "/" )) ? substr( $dirname, strrpos( $dirname, "/" ) + 1 ) : $dirname ),'type' => 5,'stat' => stat( $dirname )
|
||||
if ($this->options['storepaths'] == 1 && !preg_match("/^(\.+\/*)+$/", $dirname)) {
|
||||
$files = array(array('name' => $dirname, 'name2' => $this->options['prepend'] . preg_replace("/(\.+\/+)+/", "", ($this->options['storepaths'] == 0 && strstr($dirname, "/")) ? substr($dirname, strrpos($dirname, "/") + 1) : $dirname), 'type' => 5, 'stat' => stat($dirname)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$files = array ();
|
||||
$files = array();
|
||||
}
|
||||
$dir = @opendir( $dirname );
|
||||
while ($file = @readdir( $dir )) {
|
||||
$dir = @opendir($dirname);
|
||||
while ($file = @readdir($dir)) {
|
||||
$fullname = $dirname . "/" . $file;
|
||||
if ($file == "." || $file == "..") {
|
||||
continue;
|
||||
} elseif (@is_dir( $fullname )) {
|
||||
if (empty( $this->options['recurse'] )) {
|
||||
} elseif (@is_dir($fullname)) {
|
||||
if (empty($this->options['recurse'])) {
|
||||
continue;
|
||||
}
|
||||
$temp = $this->parse_dir( $fullname );
|
||||
$temp = $this->parse_dir($fullname);
|
||||
foreach ($temp as $file2) {
|
||||
$files[] = $file2;
|
||||
}
|
||||
} elseif (@file_exists( $fullname )) {
|
||||
$files[] = array ('name' => $fullname,'name2' => $this->options['prepend'] . preg_replace( "/(\.+\/+)+/", "", ($this->options['storepaths'] == 0 && strstr( $fullname, "/" )) ? substr( $fullname, strrpos( $fullname, "/" ) + 1 ) : $fullname ),'type' => @is_link( $fullname ) && $this->options['followlinks'] == 0 ? 2 : 0,'ext' => substr( $file, strrpos( $file, "." ) ),'stat' => stat( $fullname )
|
||||
} elseif (@file_exists($fullname)) {
|
||||
$files[] = array('name' => $fullname, 'name2' => $this->options['prepend'] . preg_replace("/(\.+\/+)+/", "", ($this->options['storepaths'] == 0 && strstr($fullname, "/")) ? substr($fullname, strrpos($fullname, "/") + 1) : $fullname), 'type' => @is_link($fullname) && $this->options['followlinks'] == 0 ? 2 : 0, 'ext' => substr($file, strrpos($file, ".")), 'stat' => stat($fullname)
|
||||
);
|
||||
}
|
||||
}
|
||||
@closedir( $dir );
|
||||
@closedir($dir);
|
||||
return $files;
|
||||
}
|
||||
|
||||
@@ -312,21 +308,21 @@
|
||||
* @param array $b
|
||||
* @return boolean
|
||||
*/
|
||||
public function sort_files ($a, $b)
|
||||
public function sort_files($a, $b)
|
||||
{
|
||||
if ($a['type'] != $b['type']) {
|
||||
if ($a['type'] == 5 || $b['type'] == 2) {
|
||||
return - 1;
|
||||
return -1;
|
||||
} elseif ($a['type'] == 2 || $b['type'] == 5) {
|
||||
return 1;
|
||||
} elseif ($a['type'] == 5) {
|
||||
return strcmp( strtolower( $a['name'] ), strtolower( $b['name'] ) );
|
||||
return strcmp(strtolower($a['name']), strtolower($b['name']));
|
||||
} elseif ($a['ext'] != $b['ext']) {
|
||||
return strcmp( $a['ext'], $b['ext'] );
|
||||
return strcmp($a['ext'], $b['ext']);
|
||||
} elseif ($a['stat'][7] != $b['stat'][7]) {
|
||||
return $a['stat'][7] > $b['stat'][7] ? - 1 : 1;
|
||||
return $a['stat'][7] > $b['stat'][7] ? -1 : 1;
|
||||
} else {
|
||||
return strcmp( strtolower( $a['name'] ), strtolower( $b['name'] ) );
|
||||
return strcmp(strtolower($a['name']), strtolower($b['name']));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -337,7 +333,7 @@
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function download_file ()
|
||||
public function download_file()
|
||||
{
|
||||
if ($this->options['inmemory'] == 0) {
|
||||
$this->error[] = "Can only use download_file() if archive is in memory. Redirect to file otherwise, it is faster.";
|
||||
@@ -345,25 +341,25 @@
|
||||
}
|
||||
switch ($this->options['type']) {
|
||||
case "zip":
|
||||
header( "Content-Type: application/zip" );
|
||||
header("Content-Type: application/zip");
|
||||
break;
|
||||
case "bzip":
|
||||
header( "Content-Type: application/x-bzip2" );
|
||||
header("Content-Type: application/x-bzip2");
|
||||
break;
|
||||
case "gzip":
|
||||
header( "Content-Type: application/x-gzip" );
|
||||
header("Content-Type: application/x-gzip");
|
||||
break;
|
||||
case "tar":
|
||||
header( "Content-Type: application/x-tar" );
|
||||
header("Content-Type: application/x-tar");
|
||||
}
|
||||
$header = "Content-Disposition: attachment; filename=\"";
|
||||
$header .= strstr( $this->options['name'], "/" ) ? substr( $this->options['name'], strrpos( $this->options['name'], "/" ) + 1 ) : $this->options['name'];
|
||||
$header .= strstr($this->options['name'], "/") ? substr($this->options['name'], strrpos($this->options['name'], "/") + 1) : $this->options['name'];
|
||||
$header .= "\"";
|
||||
header( $header );
|
||||
header( "Content-Length: " . strlen( $this->archive ) );
|
||||
header( "Content-Transfer-Encoding: binary" );
|
||||
header( "Cache-Control: no-cache, must-revalidate, max-age=60" );
|
||||
header( "Expires: Sat, 01 Jan 2000 12:00:00 GMT" );
|
||||
print ($this->archive) ;
|
||||
header($header);
|
||||
header("Content-Length: " . strlen($this->archive));
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header("Cache-Control: no-cache, must-revalidate, max-age=60");
|
||||
header("Expires: Sat, 01 Jan 2000 12:00:00 GMT");
|
||||
print ($this->archive);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* class.ArrayPeer.php
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'propel/util/BasePeer.php';
|
||||
// The object
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'APPLICATION' table.
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/abstract class ArrayBasePeer
|
||||
*/
|
||||
abstract class ArrayBasePeer
|
||||
{
|
||||
|
||||
/**
|
||||
* The default database name for this class
|
||||
*/
|
||||
const DATABASE_NAME = 'dbarray';
|
||||
|
||||
/**
|
||||
* The table name for this class
|
||||
*/
|
||||
//const TABLE_NAME = 'APPLICATION';
|
||||
|
||||
|
||||
/**
|
||||
* A class that can be returned by this peer.
|
||||
*/
|
||||
@@ -146,10 +115,10 @@ require_once 'propel/util/BasePeer.php';
|
||||
* First dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (BasePeer::TYPE_PHPNAME => array ('AppUid','AppNumber','AppParent','AppStatus','ProUid','AppProcStatus','AppProcCode','AppParallel','AppInitUser','AppCurUser','AppCreateDate','AppInitDate','AppFinishDate','AppUpdateDate','AppData'
|
||||
),BasePeer::TYPE_COLNAME => array (ApplicationPeer::APP_UID,ApplicationPeer::APP_NUMBER,ApplicationPeer::APP_PARENT,ApplicationPeer::APP_STATUS,ApplicationPeer::PRO_UID,ApplicationPeer::APP_PROC_STATUS,ApplicationPeer::APP_PROC_CODE,ApplicationPeer::APP_PARALLEL,ApplicationPeer::APP_INIT_USER,ApplicationPeer::APP_CUR_USER,ApplicationPeer::APP_CREATE_DATE,ApplicationPeer::APP_INIT_DATE,ApplicationPeer::APP_FINISH_DATE,ApplicationPeer::APP_UPDATE_DATE,ApplicationPeer::APP_DATA
|
||||
),BasePeer::TYPE_FIELDNAME => array ('APP_UID','APP_NUMBER','APP_PARENT','APP_STATUS','PRO_UID','APP_PROC_STATUS','APP_PROC_CODE','APP_PARALLEL','APP_INIT_USER','APP_CUR_USER','APP_CREATE_DATE','APP_INIT_DATE','APP_FINISH_DATE','APP_UPDATE_DATE','APP_DATA'
|
||||
),BasePeer::TYPE_NUM => array (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
|
||||
private static $fieldNames = array(BasePeer::TYPE_PHPNAME => array('AppUid', 'AppNumber', 'AppParent', 'AppStatus', 'ProUid', 'AppProcStatus', 'AppProcCode', 'AppParallel', 'AppInitUser', 'AppCurUser', 'AppCreateDate', 'AppInitDate', 'AppFinishDate', 'AppUpdateDate', 'AppData'
|
||||
), BasePeer::TYPE_COLNAME => array(ApplicationPeer::APP_UID, ApplicationPeer::APP_NUMBER, ApplicationPeer::APP_PARENT, ApplicationPeer::APP_STATUS, ApplicationPeer::PRO_UID, ApplicationPeer::APP_PROC_STATUS, ApplicationPeer::APP_PROC_CODE, ApplicationPeer::APP_PARALLEL, ApplicationPeer::APP_INIT_USER, ApplicationPeer::APP_CUR_USER, ApplicationPeer::APP_CREATE_DATE, ApplicationPeer::APP_INIT_DATE, ApplicationPeer::APP_FINISH_DATE, ApplicationPeer::APP_UPDATE_DATE, ApplicationPeer::APP_DATA
|
||||
), BasePeer::TYPE_FIELDNAME => array('APP_UID', 'APP_NUMBER', 'APP_PARENT', 'APP_STATUS', 'PRO_UID', 'APP_PROC_STATUS', 'APP_PROC_CODE', 'APP_PARALLEL', 'APP_INIT_USER', 'APP_CUR_USER', 'APP_CREATE_DATE', 'APP_INIT_DATE', 'APP_FINISH_DATE', 'APP_UPDATE_DATE', 'APP_DATA'
|
||||
), BasePeer::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
|
||||
)
|
||||
);
|
||||
|
||||
@@ -159,10 +128,10 @@ require_once 'propel/util/BasePeer.php';
|
||||
* First dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (BasePeer::TYPE_PHPNAME => array ('AppUid' => 0,'AppNumber' => 1,'AppParent' => 2,'AppStatus' => 3,'ProUid' => 4,'AppProcStatus' => 5,'AppProcCode' => 6,'AppParallel' => 7,'AppInitUser' => 8,'AppCurUser' => 9,'AppCreateDate' => 10,'AppInitDate' => 11,'AppFinishDate' => 12,'AppUpdateDate' => 13,'AppData' => 14
|
||||
),BasePeer::TYPE_COLNAME => array (ApplicationPeer::APP_UID => 0,ApplicationPeer::APP_NUMBER => 1,ApplicationPeer::APP_PARENT => 2,ApplicationPeer::APP_STATUS => 3,ApplicationPeer::PRO_UID => 4,ApplicationPeer::APP_PROC_STATUS => 5,ApplicationPeer::APP_PROC_CODE => 6,ApplicationPeer::APP_PARALLEL => 7,ApplicationPeer::APP_INIT_USER => 8,ApplicationPeer::APP_CUR_USER => 9,ApplicationPeer::APP_CREATE_DATE => 10,ApplicationPeer::APP_INIT_DATE => 11,ApplicationPeer::APP_FINISH_DATE => 12,ApplicationPeer::APP_UPDATE_DATE => 13,ApplicationPeer::APP_DATA => 14
|
||||
),BasePeer::TYPE_FIELDNAME => array ('APP_UID' => 0,'APP_NUMBER' => 1,'APP_PARENT' => 2,'APP_STATUS' => 3,'PRO_UID' => 4,'APP_PROC_STATUS' => 5,'APP_PROC_CODE' => 6,'APP_PARALLEL' => 7,'APP_INIT_USER' => 8,'APP_CUR_USER' => 9,'APP_CREATE_DATE' => 10,'APP_INIT_DATE' => 11,'APP_FINISH_DATE' => 12,'APP_UPDATE_DATE' => 13,'APP_DATA' => 14
|
||||
),BasePeer::TYPE_NUM => array (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
|
||||
private static $fieldKeys = array(BasePeer::TYPE_PHPNAME => array('AppUid' => 0, 'AppNumber' => 1, 'AppParent' => 2, 'AppStatus' => 3, 'ProUid' => 4, 'AppProcStatus' => 5, 'AppProcCode' => 6, 'AppParallel' => 7, 'AppInitUser' => 8, 'AppCurUser' => 9, 'AppCreateDate' => 10, 'AppInitDate' => 11, 'AppFinishDate' => 12, 'AppUpdateDate' => 13, 'AppData' => 14
|
||||
), BasePeer::TYPE_COLNAME => array(ApplicationPeer::APP_UID => 0, ApplicationPeer::APP_NUMBER => 1, ApplicationPeer::APP_PARENT => 2, ApplicationPeer::APP_STATUS => 3, ApplicationPeer::PRO_UID => 4, ApplicationPeer::APP_PROC_STATUS => 5, ApplicationPeer::APP_PROC_CODE => 6, ApplicationPeer::APP_PARALLEL => 7, ApplicationPeer::APP_INIT_USER => 8, ApplicationPeer::APP_CUR_USER => 9, ApplicationPeer::APP_CREATE_DATE => 10, ApplicationPeer::APP_INIT_DATE => 11, ApplicationPeer::APP_FINISH_DATE => 12, ApplicationPeer::APP_UPDATE_DATE => 13, ApplicationPeer::APP_DATA => 14
|
||||
), BasePeer::TYPE_FIELDNAME => array('APP_UID' => 0, 'APP_NUMBER' => 1, 'APP_PARENT' => 2, 'APP_STATUS' => 3, 'PRO_UID' => 4, 'APP_PROC_STATUS' => 5, 'APP_PROC_CODE' => 6, 'APP_PARALLEL' => 7, 'APP_INIT_USER' => 8, 'APP_CUR_USER' => 9, 'APP_CREATE_DATE' => 10, 'APP_INIT_DATE' => 11, 'APP_FINISH_DATE' => 12, 'APP_UPDATE_DATE' => 13, 'APP_DATA' => 14
|
||||
), BasePeer::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
|
||||
)
|
||||
);
|
||||
|
||||
@@ -172,10 +141,10 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder ()
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
include_once 'classes/model/map/ApplicationMapBuilder.php';
|
||||
return BasePeer::getMapBuilder( 'classes.model.map.ApplicationMapBuilder' );
|
||||
return BasePeer::getMapBuilder('classes.model.map.ApplicationMapBuilder');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,12 +155,12 @@ require_once 'propel/util/BasePeer.php';
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap ()
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = ApplicationPeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array ();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
@@ -209,12 +178,12 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName ($name, $fromType, $toType)
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames( $toType );
|
||||
$key = isset( self::$fieldKeys[$fromType][$name] ) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException( "'$name' could not be found in the field names of type '$fromType'. These are: " . print_r( self::$fieldKeys[$fromType], true ) );
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
@@ -228,10 +197,10 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames ($type = BasePeer::TYPE_PHPNAME)
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (! array_key_exists( $type, self::$fieldNames )) {
|
||||
throw new PropelException( 'Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.' );
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
@@ -249,9 +218,9 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @param string $column The column name for current table. (i.e. ApplicationPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias ($alias, $column)
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace( ApplicationPeer::TABLE_NAME . '.', $alias . '.', $column );
|
||||
return str_replace(ApplicationPeer::TABLE_NAME . '.', $alias . '.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,7 +234,7 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns (Criteria $criteria)
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -282,7 +251,7 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @return int Number of matching rows.
|
||||
* @todo Review declarated constant d'not used COUNT, COUNT_DISTINCT
|
||||
*/
|
||||
public static function doCount (Criteria $criteria, $distinct = false, $con = null)
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
@@ -297,14 +266,14 @@ require_once 'propel/util/BasePeer.php';
|
||||
$criteria->addSelectColumn(ApplicationPeer::COUNT);
|
||||
}
|
||||
*/
|
||||
$criteria->addSelectColumn( 'COUNT(*)' );
|
||||
$criteria->addSelectColumn('COUNT(*)');
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach ($criteria->getGroupByColumns() as $column) {
|
||||
$criteria->addSelectColumn( $column );
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = ArrayBasePeer::doSelectRS( $criteria, $con );
|
||||
$rs = ArrayBasePeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
$row = $rs->getRow();
|
||||
return $row[1];
|
||||
@@ -323,11 +292,11 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne (Criteria $criteria, $con = null)
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit( 1 );
|
||||
$objects = ApplicationPeer::doSelect( $critcopy, $con );
|
||||
$critcopy->setLimit(1);
|
||||
$objects = ApplicationPeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
@@ -343,18 +312,18 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
private function createSelectSql ($criteria, $tableName, &$params)
|
||||
private function createSelectSql($criteria, $tableName, &$params)
|
||||
{
|
||||
$db = Propel::getDB( $criteria->getDbName() );
|
||||
$db = Propel::getDB($criteria->getDbName());
|
||||
|
||||
// redundant definition $selectModifiers = array();
|
||||
$selectClause = array ();
|
||||
$fromClause = array ();
|
||||
$joinClause = array ();
|
||||
$joinTables = array ();
|
||||
$whereClause = array ();
|
||||
$orderByClause = array ();
|
||||
$groupByClause = array ();
|
||||
$selectClause = array();
|
||||
$fromClause = array();
|
||||
$joinClause = array();
|
||||
$joinTables = array();
|
||||
$whereClause = array();
|
||||
$orderByClause = array();
|
||||
$groupByClause = array();
|
||||
|
||||
$orderBy = $criteria->getOrderByColumns();
|
||||
$groupBy = $criteria->getGroupByColumns();
|
||||
@@ -372,8 +341,8 @@ require_once 'propel/util/BasePeer.php';
|
||||
$selectClause[] = $columnName; // the full column name: e.g. MAX(books.price)
|
||||
|
||||
|
||||
$parenPos = strpos( $columnName, '(' );
|
||||
$dotPos = strpos( $columnName, '.' );
|
||||
$parenPos = strpos($columnName, '(');
|
||||
$dotPos = strpos($columnName, '.');
|
||||
|
||||
// [HL] I think we really only want to worry about adding stuff to
|
||||
// the fromClause if this function has a TABLE.COLUMN in it at all.
|
||||
@@ -382,18 +351,18 @@ require_once 'propel/util/BasePeer.php';
|
||||
if ($dotPos !== false) {
|
||||
|
||||
if ($parenPos === false) { // table.column
|
||||
$tableName = substr( $columnName, 0, $dotPos );
|
||||
$tableName = substr($columnName, 0, $dotPos);
|
||||
} else { // FUNC(table.column)
|
||||
$tableName = substr( $columnName, $parenPos + 1, $dotPos - ($parenPos + 1) );
|
||||
$tableName = substr($columnName, $parenPos + 1, $dotPos - ($parenPos + 1));
|
||||
// functions may contain qualifiers so only take the last
|
||||
// word as the table name.
|
||||
// COUNT(DISTINCT books.price)
|
||||
$lastSpace = strpos( $tableName, ' ' );
|
||||
$lastSpace = strpos($tableName, ' ');
|
||||
if ($lastSpace !== false) { // COUNT(DISTINCT books.price)
|
||||
$tableName = substr( $tableName, $lastSpace + 1 );
|
||||
$tableName = substr($tableName, $lastSpace + 1);
|
||||
}
|
||||
}
|
||||
$tableName2 = $criteria->getTableForAlias( $tableName );
|
||||
$tableName2 = $criteria->getTableForAlias($tableName);
|
||||
if ($tableName2 !== null) {
|
||||
$fromClause[] = $tableName2 . ' ' . $tableName;
|
||||
} else {
|
||||
@@ -411,13 +380,13 @@ require_once 'propel/util/BasePeer.php';
|
||||
// add the criteria to WHERE clause
|
||||
foreach ($criteria->keys() as $key) {
|
||||
|
||||
$criterion = $criteria->getCriterion( $key );
|
||||
$criterion = $criteria->getCriterion($key);
|
||||
$someCriteria = $criterion->getAttachedCriterion();
|
||||
$someCriteriaLength = count( $someCriteria );
|
||||
$someCriteriaLength = count($someCriteria);
|
||||
$table = null;
|
||||
for ($i = 0; $i < $someCriteriaLength; $i ++) {
|
||||
for ($i = 0; $i < $someCriteriaLength; $i++) {
|
||||
$tableName = $someCriteria[$i]->getTable();
|
||||
$table = $criteria->getTableForAlias( $tableName );
|
||||
$table = $criteria->getTableForAlias($tableName);
|
||||
if ($table !== null) {
|
||||
$fromClause[] = $table . ' ' . $tableName;
|
||||
} else {
|
||||
@@ -425,11 +394,11 @@ require_once 'propel/util/BasePeer.php';
|
||||
$table = $tableName;
|
||||
}
|
||||
|
||||
$ignoreCase = (($criteria->isIgnoreCase() || $someCriteria[$i]->isIgnoreCase()) && ($dbMap->getTable( $table )->getColumn( $someCriteria[$i]->getColumn() )->getType() == "string"));
|
||||
$ignoreCase = (($criteria->isIgnoreCase() || $someCriteria[$i]->isIgnoreCase()) && ($dbMap->getTable($table)->getColumn($someCriteria[$i]->getColumn())->getType() == "string"));
|
||||
|
||||
$someCriteria[$i]->setIgnoreCase( $ignoreCase );
|
||||
$someCriteria[$i]->setIgnoreCase($ignoreCase);
|
||||
}
|
||||
$criterion->setDB( $db );
|
||||
$criterion->setDB($db);
|
||||
|
||||
$cri['table'] = $criterion->table;
|
||||
$cri['field'] = $criterion->column;
|
||||
@@ -445,41 +414,41 @@ require_once 'propel/util/BasePeer.php';
|
||||
|
||||
}
|
||||
// Unique from clause elements
|
||||
$fromClause = array_unique( $fromClause );
|
||||
$fromClause = array_unique($fromClause);
|
||||
|
||||
if (! empty( $orderBy )) {
|
||||
if (!empty($orderBy)) {
|
||||
|
||||
foreach ($orderBy as $orderByColumn) {
|
||||
// Add function expression as-is.
|
||||
if (strpos( $orderByColumn, '(' ) !== false) {
|
||||
if (strpos($orderByColumn, '(') !== false) {
|
||||
$orderByClause[] = $orderByColumn;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Split orderByColumn (i.e. "table.column DESC")
|
||||
$dotPos = strpos( $orderByColumn, '.' );
|
||||
$dotPos = strpos($orderByColumn, '.');
|
||||
if ($dotPos !== false) {
|
||||
$tableName = substr( $orderByColumn, 0, $dotPos );
|
||||
$columnName = substr( $orderByColumn, $dotPos + 1 );
|
||||
$tableName = substr($orderByColumn, 0, $dotPos);
|
||||
$columnName = substr($orderByColumn, $dotPos + 1);
|
||||
} else {
|
||||
$tableName = '';
|
||||
$columnName = $orderByColumn;
|
||||
}
|
||||
|
||||
$spacePos = strpos( $columnName, ' ' );
|
||||
$spacePos = strpos($columnName, ' ');
|
||||
if ($spacePos !== false) {
|
||||
$direction = substr( $columnName, $spacePos );
|
||||
$columnName = substr( $columnName, 0, $spacePos );
|
||||
$direction = substr($columnName, $spacePos);
|
||||
$columnName = substr($columnName, 0, $spacePos);
|
||||
} else {
|
||||
$direction = '';
|
||||
}
|
||||
$orderByClause[] = array ('columnName' => $columnName,'direction' => $direction
|
||||
$orderByClause[] = array('columnName' => $columnName, 'direction' => $direction
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Build the SQL from the arrays we compiled
|
||||
$sql = "SELECT " . ($selectModifiers ? implode( " ", $selectModifiers ) . " " : "") . implode( ", ", $selectClause ) . " FROM " . $fromClause[0] . ($whereClause ? " WHERE " . implode( " AND ", $whereClause ) : "") . ($groupByClause ? " GROUP BY " . implode( ",", $groupByClause ) : "");
|
||||
$sql = "SELECT " . ($selectModifiers ? implode(" ", $selectModifiers) . " " : "") . implode(", ", $selectClause) . " FROM " . $fromClause[0] . ($whereClause ? " WHERE " . implode(" AND ", $whereClause) : "") . ($groupByClause ? " GROUP BY " . implode(",", $groupByClause) : "");
|
||||
|
||||
$dataSql['selectClause'] = $selectClause;
|
||||
$dataSql['fromClause'] = $fromClause;
|
||||
@@ -499,27 +468,27 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect (Criteria $criteria, $tableName, $con = null)
|
||||
public static function doSelect(Criteria $criteria, $tableName, $con = null)
|
||||
{
|
||||
$dbMap = Propel::getDatabaseMap( $criteria->getDbName() );
|
||||
$dbMap = Propel::getDatabaseMap($criteria->getDbName());
|
||||
|
||||
$stmt = null;
|
||||
|
||||
try {
|
||||
$params = array ();
|
||||
$sql = self::createSelectSql( $criteria, $tableName, $params );
|
||||
$params = array();
|
||||
$sql = self::createSelectSql($criteria, $tableName, $params);
|
||||
$sql['params'] = $params;
|
||||
$stmt = $con->prepareStatement( $sql );
|
||||
$stmt = $con->prepareStatement($sql);
|
||||
//$stmt->setLimit($criteria->getLimit());
|
||||
$sql['limit'] = $criteria->getLimit();
|
||||
//$stmt->setOffset($criteria->getOffset());
|
||||
$sql['offset'] = $criteria->getOffset();
|
||||
//$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
|
||||
$rs = $con->executeQuery( $sql, ResultSet::FETCHMODE_NUM );
|
||||
$rs = $con->executeQuery($sql, ResultSet::FETCHMODE_NUM);
|
||||
} catch (Exception $e) {
|
||||
if ($stmt)
|
||||
$stmt->close();
|
||||
throw new PropelException( $e );
|
||||
throw new PropelException($e);
|
||||
}
|
||||
|
||||
return $rs;
|
||||
@@ -539,34 +508,34 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS (Criteria $criteria, $con = null)
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
global $_DBArray;
|
||||
if (! isset( $_DBArray )) {
|
||||
if (!isset($_DBArray)) {
|
||||
$_DBArray = $_SESSION['_DBArray'];
|
||||
}
|
||||
$tableName = $criteria->getDBArrayTable();
|
||||
if (! isset( $_DBArray[$tableName] )) {
|
||||
throw new Exception( "Error: the table '$tableName' doesn't exist in DBArray " );
|
||||
if (!isset($_DBArray[$tableName])) {
|
||||
throw new Exception("Error: the table '$tableName' doesn't exist in DBArray ");
|
||||
}
|
||||
|
||||
$arrayTable = $_DBArray[$tableName];
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection( self::DATABASE_NAME );
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (! $criteria->getSelectColumns()) {
|
||||
foreach (array_keys( $_DBArray[$tableName][0] ) as $key => $val)
|
||||
$criteria->addSelectColumn( $tableName . '.' . $val );
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
foreach (array_keys($_DBArray[$tableName][0]) as $key => $val)
|
||||
$criteria->addSelectColumn($tableName . '.' . $val);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName( self::DATABASE_NAME );
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
return ArrayBasePeer::doSelect( $criteria, $tableName, $con );
|
||||
return ArrayBasePeer::doSelect($criteria, $tableName, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -576,17 +545,17 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects (ResultSet $rs)
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
$results = array ();
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = ApplicationPeer::getOMClass();
|
||||
$cls = Propel::import( $cls );
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while ($rs->next()) {
|
||||
$obj = new $cls();
|
||||
$obj->hydrate( $rs );
|
||||
$obj->hydrate($rs);
|
||||
$results[] = $obj;
|
||||
}
|
||||
return $results;
|
||||
@@ -600,9 +569,9 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getTableMap ()
|
||||
public static function getTableMap()
|
||||
{
|
||||
return Propel::getDatabaseMap( self::DATABASE_NAME )->getTable( self::TABLE_NAME );
|
||||
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -614,7 +583,7 @@ require_once 'propel/util/BasePeer.php';
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass ()
|
||||
public static function getOMClass()
|
||||
{
|
||||
return ApplicationPeer::CLASS_DEFAULT;
|
||||
}
|
||||
@@ -628,10 +597,10 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doInsert ($values, $con = null)
|
||||
public static function doInsert($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection( self::DATABASE_NAME );
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
@@ -641,13 +610,13 @@ require_once 'propel/util/BasePeer.php';
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName( self::DATABASE_NAME );
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert( $criteria, $con );
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
@@ -666,20 +635,20 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate ($values, $con = null)
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection( self::DATABASE_NAME );
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria( self::DATABASE_NAME );
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
|
||||
$comparison = $criteria->getComparison( ApplicationPeer::APP_UID );
|
||||
$selectCriteria->add( ApplicationPeer::APP_UID, $criteria->remove( ApplicationPeer::APP_UID ), $comparison );
|
||||
$comparison = $criteria->getComparison(ApplicationPeer::APP_UID);
|
||||
$selectCriteria->add(ApplicationPeer::APP_UID, $criteria->remove(ApplicationPeer::APP_UID), $comparison);
|
||||
|
||||
} else { // $values is Application object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
@@ -687,9 +656,9 @@ require_once 'propel/util/BasePeer.php';
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName( self::DATABASE_NAME );
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
return BasePeer::doUpdate( $selectCriteria, $criteria, $con );
|
||||
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -698,17 +667,17 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @param Connection $con The connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll ($con = null)
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection( self::DATABASE_NAME );
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
$affectedRows += BasePeer::doDeleteAll( ApplicationPeer::TABLE_NAME, $con );
|
||||
$affectedRows += BasePeer::doDeleteAll(ApplicationPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
@@ -728,10 +697,10 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doDelete ($values, $con = null)
|
||||
public static function doDelete($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection( ApplicationPeer::DATABASE_NAME );
|
||||
$con = Propel::getConnection(ApplicationPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
@@ -741,12 +710,12 @@ require_once 'propel/util/BasePeer.php';
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria( self::DATABASE_NAME );
|
||||
$criteria->add( ApplicationPeer::APP_UID, (array) $values, Criteria::IN );
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(ApplicationPeer::APP_UID, (array)$values, Criteria::IN);
|
||||
}
|
||||
}
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName( self::DATABASE_NAME );
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
@@ -756,7 +725,7 @@ require_once 'propel/util/BasePeer.php';
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
|
||||
$affectedRows += BasePeer::doDelete( $criteria, $con );
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
@@ -777,33 +746,33 @@ require_once 'propel/util/BasePeer.php';
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate (Application $obj, $cols = null)
|
||||
public static function doValidate(Application $obj, $cols = null)
|
||||
{
|
||||
$columns = array ();
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap( ApplicationPeer::DATABASE_NAME );
|
||||
$tableMap = $dbMap->getTable( ApplicationPeer::TABLE_NAME );
|
||||
$dbMap = Propel::getDatabaseMap(ApplicationPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(ApplicationPeer::TABLE_NAME);
|
||||
|
||||
if (! is_array( $cols )) {
|
||||
$cols = array ($cols
|
||||
if (!is_array($cols)) {
|
||||
$cols = array($cols
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($cols as $colName) {
|
||||
if ($tableMap->containsColumn( $colName )) {
|
||||
$get = 'get' . $tableMap->getColumn( $colName )->getPhpName();
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
if ($obj->isNew() || $obj->isColumnModified( ApplicationPeer::APP_STATUS ))
|
||||
if ($obj->isNew() || $obj->isColumnModified(ApplicationPeer::APP_STATUS))
|
||||
$columns[ApplicationPeer::APP_STATUS] = $obj->getAppStatus();
|
||||
|
||||
}
|
||||
|
||||
return BasePeer::doValidate( ApplicationPeer::DATABASE_NAME, ApplicationPeer::TABLE_NAME, $columns );
|
||||
return BasePeer::doValidate(ApplicationPeer::DATABASE_NAME, ApplicationPeer::TABLE_NAME, $columns);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -813,19 +782,19 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @param Connection $con the connection to use
|
||||
* @return Application
|
||||
*/
|
||||
public static function retrieveByPK ($pk, $con = null)
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection( self::DATABASE_NAME );
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria( ApplicationPeer::DATABASE_NAME );
|
||||
$criteria = new Criteria(ApplicationPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add( ApplicationPeer::APP_UID, $pk );
|
||||
$criteria->add(ApplicationPeer::APP_UID, $pk);
|
||||
|
||||
$v = ApplicationPeer::doSelect( $criteria, $con );
|
||||
$v = ApplicationPeer::doSelect($criteria, $con);
|
||||
|
||||
return ! empty( $v ) > 0 ? $v[0] : null;
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -836,19 +805,19 @@ require_once 'propel/util/BasePeer.php';
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function retrieveByPKs ($pks, $con = null)
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection( self::DATABASE_NAME );
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty( $pks )) {
|
||||
$objs = array ();
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add( ApplicationPeer::APP_UID, $pks, Criteria::IN );
|
||||
$objs = ApplicationPeer::doSelect( $criteria, $con );
|
||||
$criteria->add(ApplicationPeer::APP_UID, $pks, Criteria::IN);
|
||||
$objs = ApplicationPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
603
workflow/engine/classes/BpmnEngineSearchIndexAccessSolr.php
Normal file
603
workflow/engine/classes/BpmnEngineSearchIndexAccessSolr.php
Normal file
@@ -0,0 +1,603 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Interface to the Solr Search server
|
||||
*/
|
||||
class BpmnEngineSearchIndexAccessSolr
|
||||
{
|
||||
const SOLR_VERSION = '&version=2.2';
|
||||
private $_solrIsEnabled = false;
|
||||
private $_solrHost = "";
|
||||
|
||||
public function __construct($solrIsEnabled = false, $solrHost = "")
|
||||
{
|
||||
// use the parameters to initialize class
|
||||
$this->_solrIsEnabled = $solrIsEnabled;
|
||||
$this->_solrHost = $solrHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the Solr service is available
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled($workspace)
|
||||
{
|
||||
$resultServerStatus = false;
|
||||
// verify solr server response
|
||||
try {
|
||||
$resultServerStatus = $this->ping($workspace);
|
||||
} catch (Exception $ex) {
|
||||
$resultServerStatus = false;
|
||||
}
|
||||
|
||||
return $resultServerStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of indexed documents
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @param
|
||||
* workspace: workspace name
|
||||
* @return total
|
||||
*/
|
||||
public function getNumberDocuments($workspace)
|
||||
{
|
||||
// get total number of documents in registry
|
||||
$solrIntruct = (substr($this->_solrHost, -1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/select/?q=*:*";
|
||||
$solrIntruct .= self::SOLR_VERSION;
|
||||
$solrIntruct .= "&start=0&rows=0&echoParams=none&wt=json";
|
||||
|
||||
$handlerTotal = curl_init($solrIntruct);
|
||||
curl_setopt($handlerTotal, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::getSystemConfiguration();
|
||||
if ($sysConf['proxy_host'] != '') {
|
||||
curl_setopt($handlerTotal, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
|
||||
if ($sysConf['proxy_port'] != '') {
|
||||
curl_setopt($handlerTotal, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
|
||||
}
|
||||
if ($sysConf['proxy_user'] != '') {
|
||||
curl_setopt($handlerTotal, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
|
||||
}
|
||||
curl_setopt($handlerTotal, CURLOPT_HTTPHEADER, array('Expect:'));
|
||||
}
|
||||
|
||||
$responseTotal = curl_exec($handlerTotal);
|
||||
curl_close($handlerTotal);
|
||||
|
||||
// verify the result of solr
|
||||
$responseSolrTotal = G::json_decode($responseTotal);
|
||||
if ($responseSolrTotal->responseHeader->status != 0) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error returning the total number of documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
$numTotalDocs = $responseSolrTotal->response->numFound;
|
||||
return $numTotalDocs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a query in base to Requested data
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function executeQuery($solrRequestData)
|
||||
{
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$workspace = $solrRequestData->workspace;
|
||||
|
||||
// format request
|
||||
$query = empty ($solrRequestData->searchText) ? '*:*' : $solrRequestData->searchText;
|
||||
$query = rawurlencode($query);
|
||||
$start = '&start=' . $solrRequestData->startAfter;
|
||||
$rows = '&rows=' . $solrRequestData->pageSize;
|
||||
$fieldList = '';
|
||||
$cols = $solrRequestData->includeCols;
|
||||
if (!empty ($cols)) {
|
||||
$fieldList = "&fl=" . implode(",", $cols);
|
||||
}
|
||||
$sort = '';
|
||||
if ($solrRequestData->numSortingCols > 0) {
|
||||
$sort = '&sort=';
|
||||
for ($i = 0; $i < $solrRequestData->numSortingCols; $i++) {
|
||||
$sort .= $solrRequestData->sortCols [$i] . "%20" . $solrRequestData->sortDir [$i] . ",";
|
||||
}
|
||||
|
||||
$sort = substr_replace($sort, "", -1);
|
||||
}
|
||||
$resultFormat = empty ($solrRequestData->resultFormat) ? '' : '&wt=' . $solrRequestData->resultFormat;
|
||||
$filters = '';
|
||||
$aFilters = explode(',', $solrRequestData->filterText);
|
||||
foreach ($aFilters as $value) {
|
||||
$filters .= '&fq=' . urlencode($value);
|
||||
}
|
||||
|
||||
$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 .= $fieldList;
|
||||
$solrIntruct .= $sort;
|
||||
$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 = PmSystem::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 (date('Y-m-d H:i:s:u') . " Error executing query to Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
|
||||
return $responseSolr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert or Update document index
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function updateDocument($solrUpdateDocument)
|
||||
{
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr($this->_solrHost, -1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $solrUpdateDocument->workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init($solrIntruct);
|
||||
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($handler, CURLOPT_HTTPHEADER, array(
|
||||
'Content-type:application/xml'
|
||||
));
|
||||
curl_setopt($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
curl_setopt($handler, CURLOPT_POSTFIELDS, $solrUpdateDocument->document); // data
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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);
|
||||
|
||||
$swOk = strpos($response, '<int name="status">0</int>');
|
||||
if (!$swOk) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error updating document in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit the changes since the last commit
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function commitChanges($workspace)
|
||||
{
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr($this->_solrHost, -1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init($solrIntruct);
|
||||
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($handler, CURLOPT_HTTPHEADER, array(
|
||||
'Content-type:application/xml'
|
||||
));
|
||||
curl_setopt($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
curl_setopt($handler, CURLOPT_POSTFIELDS, "<commit/>"); // data
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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);
|
||||
|
||||
$swOk = strpos($response, '<int name="status">0</int>');
|
||||
if (!$swOk) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error commiting changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback the changes since the last commit
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function rollbackChanges($workspace)
|
||||
{
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr($this->_solrHost, -1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init($solrIntruct);
|
||||
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($handler, CURLOPT_HTTPHEADER, array(
|
||||
'Content-type:application/xml'
|
||||
));
|
||||
curl_setopt($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
curl_setopt($handler, CURLOPT_POSTFIELDS, "<rollback/>"); // data
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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);
|
||||
|
||||
$swOk = strpos($response, '<int name="status">0</int>');
|
||||
if (!$swOk) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error rolling back changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimize Solr index
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function optimizeChanges($workspace)
|
||||
{
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr($this->_solrHost, -1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init($solrIntruct);
|
||||
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($handler, CURLOPT_HTTPHEADER, array(
|
||||
'Content-type:application/xml'
|
||||
));
|
||||
curl_setopt($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
curl_setopt($handler, CURLOPT_POSTFIELDS, "<optimize/>"); // data
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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);
|
||||
|
||||
$swOk = strpos($response, '<int name="status">0</int>');
|
||||
if (!$swOk) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error optimizing changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of the stored fields in Solr
|
||||
*
|
||||
* @param string $workspace
|
||||
* Solr instance name
|
||||
* @throws Exception
|
||||
* @return void mixed of field names
|
||||
*/
|
||||
public function getListIndexedStoredFields($workspace)
|
||||
{
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr($this->_solrHost, -1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/admin/luke?numTerms=0&wt=json";
|
||||
|
||||
$handler = curl_init($solrIntruct);
|
||||
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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 (date('Y-m-d H:i:s:u') . " Error getting index fields in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
return $responseSolr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ping the Solr Server to check his health
|
||||
*
|
||||
* @param string $workspace
|
||||
* Solr instance name
|
||||
* @throws Exception
|
||||
* @return void mixed of field names
|
||||
*/
|
||||
public function ping($workspace)
|
||||
{
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr($this->_solrHost, -1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/admin/ping?wt=json";
|
||||
|
||||
$handler = curl_init($solrIntruct);
|
||||
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($handler);
|
||||
curl_close($handler);
|
||||
|
||||
//there's no response
|
||||
if (!$response)
|
||||
return false;
|
||||
|
||||
// decode
|
||||
$responseSolr = G::json_decode($response);
|
||||
if ($responseSolr->responseHeader->status != "OK") {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error pinging Solr server." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all documents from index
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function deleteAllDocuments($workspace)
|
||||
{
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr($this->_solrHost, -1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init($solrIntruct);
|
||||
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($handler, CURLOPT_HTTPHEADER, array(
|
||||
'Content-type:application/xml'
|
||||
));
|
||||
curl_setopt($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
curl_setopt($handler, CURLOPT_POSTFIELDS, "<delete><query>*:*</query></delete>"); // data
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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);
|
||||
|
||||
$swOk = strpos($response, '<int name="status">0</int>');
|
||||
if (!$swOk) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error deleting all documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete specified documents from index
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function deleteDocument($workspace, $idQuery)
|
||||
{
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr($this->_solrHost, -1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init($solrIntruct);
|
||||
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($handler, CURLOPT_HTTPHEADER, array(
|
||||
'Content-type:application/xml'
|
||||
));
|
||||
curl_setopt($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
curl_setopt($handler, CURLOPT_POSTFIELDS, "<delete><query>" . $idQuery . "</query></delete>"); // data
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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);
|
||||
|
||||
$swOk = strpos($response, '<int name="status">0</int>');
|
||||
if (!$swOk) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error deleting document in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a query in base to Request data
|
||||
*
|
||||
* @param Entity_FacetRequest $facetRequestEntity
|
||||
* @return solr response: list of facets array
|
||||
*/
|
||||
public function getFacetsList($facetRequest)
|
||||
{
|
||||
$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->facet | DatesEnd;
|
||||
$facets .= '&facet.date.gap=' . $facetRequest->facetDateGap;
|
||||
}
|
||||
$filters = '';
|
||||
foreach ($facetRequest->filters as $value) {
|
||||
$filters .= '&fq=' . $value;
|
||||
}
|
||||
|
||||
$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 = PmSystem::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 (date('Y-m-d H:i:s:u') . " Error getting faceted list from Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
|
||||
return $responseSolr;
|
||||
}
|
||||
}
|
||||
@@ -1,671 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2012 Colosa Inc.23
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* 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, 5304 Ventura Drive,
|
||||
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Interface to the Solr Search server
|
||||
* @author Herbert Saal Gutierrez
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface to the Solr Search server
|
||||
* @author Herbert Saal Gutierrez
|
||||
*
|
||||
*/class BpmnEngine_SearchIndexAccess_Solr
|
||||
{
|
||||
const SOLR_VERSION = '&version=2.2';
|
||||
private $_solrIsEnabled = false;
|
||||
private $_solrHost = "";
|
||||
|
||||
public function __construct($solrIsEnabled = false, $solrHost = "")
|
||||
{
|
||||
// use the parameters to initialize class
|
||||
$this->_solrIsEnabled = $solrIsEnabled;
|
||||
$this->_solrHost = $solrHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the Solr service is available
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled($workspace)
|
||||
{
|
||||
$resultServerStatus = false;
|
||||
|
||||
//if($this->_solrIsEnabled != true)
|
||||
//return $resultServerStatus;
|
||||
|
||||
// verify solr server response
|
||||
try{
|
||||
$resultServerStatus = $this->ping($workspace);
|
||||
}catch(Exception $ex){
|
||||
$resultServerStatus = false;
|
||||
}
|
||||
|
||||
return $resultServerStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of indexed documents
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @param
|
||||
* workspace: workspace name
|
||||
* @return total
|
||||
*/
|
||||
public function getNumberDocuments($workspace)
|
||||
{
|
||||
//if (! $this->_solrIsEnabled)
|
||||
//return;
|
||||
// get configuration information in base to workspace parameter
|
||||
|
||||
// get total number of documents in registry
|
||||
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/select/?q=*:*";
|
||||
$solrIntruct .= self::SOLR_VERSION;
|
||||
$solrIntruct .= "&start=0&rows=0&echoParams=none&wt=json";
|
||||
|
||||
$handlerTotal = curl_init ($solrIntruct);
|
||||
curl_setopt ($handlerTotal, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::getSystemConfiguration();
|
||||
if ($sysConf['proxy_host'] != '') {
|
||||
curl_setopt($handlerTotal, CURLOPT_PROXY, $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : ''));
|
||||
if ($sysConf['proxy_port'] != '') {
|
||||
curl_setopt($handlerTotal, CURLOPT_PROXYPORT, $sysConf['proxy_port']);
|
||||
}
|
||||
if ($sysConf['proxy_user'] != '') {
|
||||
curl_setopt($handlerTotal, CURLOPT_PROXYUSERPWD, $sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
|
||||
}
|
||||
curl_setopt($handlerTotal, CURLOPT_HTTPHEADER, array('Expect:'));
|
||||
}
|
||||
|
||||
$responseTotal = curl_exec ($handlerTotal);
|
||||
curl_close ($handlerTotal);
|
||||
|
||||
// verify the result of solr
|
||||
$responseSolrTotal = G::json_decode ($responseTotal);
|
||||
if ($responseSolrTotal->responseHeader->status != 0) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error returning the total number of documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
$numTotalDocs = $responseSolrTotal->response->numFound;
|
||||
return $numTotalDocs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a query in base to Requested data
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function executeQuery($solrRequestData)
|
||||
{
|
||||
//if (! $this->_solrIsEnabled)
|
||||
//return;
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$workspace = $solrRequestData->workspace;
|
||||
|
||||
// format request
|
||||
$query = empty ($solrRequestData->searchText) ? '*:*' : $solrRequestData->searchText;
|
||||
$query = rawurlencode ($query);
|
||||
$start = '&start=' . $solrRequestData->startAfter;
|
||||
$rows = '&rows=' . $solrRequestData->pageSize;
|
||||
$fieldList = '';
|
||||
$cols = $solrRequestData->includeCols;
|
||||
if (! empty ($cols)) {
|
||||
$fieldList = "&fl=" . implode (",", $cols);
|
||||
}
|
||||
$sort = '';
|
||||
if ($solrRequestData->numSortingCols > 0) {
|
||||
$sort = '&sort=';
|
||||
for ($i = 0; $i < $solrRequestData->numSortingCols; $i ++) {
|
||||
$sort .= $solrRequestData->sortCols [$i] . "%20" . $solrRequestData->sortDir [$i] . ",";
|
||||
}
|
||||
|
||||
$sort = substr_replace ($sort, "", - 1);
|
||||
}
|
||||
$resultFormat = empty ($solrRequestData->resultFormat) ? '' : '&wt=' . $solrRequestData->resultFormat;
|
||||
$filters = '';
|
||||
$aFilters = explode (',', $solrRequestData->filterText);
|
||||
foreach ($aFilters as $value) {
|
||||
$filters .= '&fq=' . urlencode ($value);
|
||||
}
|
||||
|
||||
$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 .= $fieldList;
|
||||
$solrIntruct .= $sort;
|
||||
$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 = PmSystem::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 (date('Y-m-d H:i:s:u') . " Error executing query to Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
|
||||
return $responseSolr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert or Update document index
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function updateDocument($solrUpdateDocument)
|
||||
{
|
||||
//if (! $this->_solrIsEnabled)
|
||||
//return;
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $solrUpdateDocument->workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init ($solrIntruct);
|
||||
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
|
||||
'Content-type:application/xml'
|
||||
)); // -H
|
||||
curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
curl_setopt ($handler, CURLOPT_POSTFIELDS, $solrUpdateDocument->document); // data
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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);
|
||||
|
||||
$swOk = strpos ($response, '<int name="status">0</int>');
|
||||
if (! $swOk) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error updating document in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit the changes since the last commit
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function commitChanges($workspace)
|
||||
{
|
||||
//if (! $this->_solrIsEnabled)
|
||||
//return;
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init ($solrIntruct);
|
||||
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
|
||||
'Content-type:application/xml'
|
||||
)); // -H
|
||||
curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
curl_setopt ($handler, CURLOPT_POSTFIELDS, "<commit/>"); // data
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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);
|
||||
|
||||
$swOk = strpos ($response, '<int name="status">0</int>');
|
||||
if (! $swOk) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error commiting changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback the changes since the last commit
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function rollbackChanges($workspace)
|
||||
{
|
||||
//if (! $this->_solrIsEnabled)
|
||||
//return;
|
||||
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init ($solrIntruct);
|
||||
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
|
||||
'Content-type:application/xml'
|
||||
)); // -H
|
||||
curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
curl_setopt ($handler, CURLOPT_POSTFIELDS, "<rollback/>"); // data
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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);
|
||||
|
||||
$swOk = strpos ($response, '<int name="status">0</int>');
|
||||
if (! $swOk) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error rolling back changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimize Solr index
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function optimizeChanges($workspace)
|
||||
{
|
||||
//if (! $this->_solrIsEnabled)
|
||||
//return;
|
||||
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init ($solrIntruct);
|
||||
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
|
||||
'Content-type:application/xml'
|
||||
)); // -H
|
||||
curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
curl_setopt ($handler, CURLOPT_POSTFIELDS, "<optimize/>"); // data
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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);
|
||||
|
||||
$swOk = strpos ($response, '<int name="status">0</int>');
|
||||
if (! $swOk) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error optimizing changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of the stored fields in Solr
|
||||
*
|
||||
* @param string $workspace
|
||||
* Solr instance name
|
||||
* @throws Exception
|
||||
* @return void mixed of field names
|
||||
*/
|
||||
public function getListIndexedStoredFields($workspace)
|
||||
{
|
||||
//if (! $this->_solrIsEnabled)
|
||||
//return;
|
||||
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/admin/luke?numTerms=0&wt=json";
|
||||
|
||||
$handler = curl_init ($solrIntruct);
|
||||
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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 (date('Y-m-d H:i:s:u') . " Error getting index fields in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
return $responseSolr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ping the Solr Server to check his health
|
||||
*
|
||||
* @param string $workspace
|
||||
* Solr instance name
|
||||
* @throws Exception
|
||||
* @return void mixed of field names
|
||||
*/
|
||||
public function ping($workspace)
|
||||
{
|
||||
//if (! $this->_solrIsEnabled)
|
||||
//return;
|
||||
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/admin/ping?wt=json";
|
||||
|
||||
$handler = curl_init ($solrIntruct);
|
||||
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec ($handler);
|
||||
curl_close ($handler);
|
||||
|
||||
//there's no response
|
||||
if(!$response)
|
||||
return false;
|
||||
|
||||
// decode
|
||||
$responseSolr = G::json_decode ($response);
|
||||
if ($responseSolr->responseHeader->status != "OK") {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error pinging Solr server." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all documents from index
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function deleteAllDocuments($workspace)
|
||||
{
|
||||
//if (! $this->_solrIsEnabled)
|
||||
//return;
|
||||
// $registry = Zend_Registry::getInstance();
|
||||
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init ($solrIntruct);
|
||||
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
|
||||
'Content-type:application/xml'
|
||||
)); // -H
|
||||
curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
curl_setopt ($handler, CURLOPT_POSTFIELDS, "<delete><query>*:*</query></delete>"); // data
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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);
|
||||
|
||||
$swOk = strpos ($response, '<int name="status">0</int>');
|
||||
if (! $swOk) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error deleting all documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete specified documents from index
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
public function deleteDocument($workspace, $idQuery)
|
||||
{
|
||||
//if (! $this->_solrIsEnabled)
|
||||
//return;
|
||||
// $registry = Zend_Registry::getInstance();
|
||||
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init ($solrIntruct);
|
||||
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
|
||||
'Content-type:application/xml'
|
||||
)); // -H
|
||||
curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
|
||||
curl_setopt ($handler, CURLOPT_POSTFIELDS, "<delete><query>" . $idQuery . "</query></delete>"); // data
|
||||
|
||||
//Apply proxy settings
|
||||
$sysConf = PmSystem::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);
|
||||
|
||||
$swOk = strpos ($response, '<int name="status">0</int>');
|
||||
if (! $swOk) {
|
||||
throw new Exception (date('Y-m-d H:i:s:u') . " Error deleting document in Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = PmSystem::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 (date('Y-m-d H:i:s:u') . " Error getting faceted list from Solr." . $solrIntruct . " response error: " . $response . "\n");
|
||||
}
|
||||
|
||||
return $responseSolr;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
|
||||
class featuresDetail
|
||||
class FeaturesDetail
|
||||
{
|
||||
public $featureName;
|
||||
public $description = null;
|
||||
|
||||
@@ -313,7 +313,7 @@ class PMLicensedFeatures
|
||||
$addons = AddonsManagerPeer::doSelect($criteria);
|
||||
foreach ($addons as $addon) {
|
||||
$this->features[] = $addon->getAddonId();
|
||||
$detail = new featuresDetail($addon->getAddonNick(), $addon->getAddonDescription());
|
||||
$detail = new FeaturesDetail($addon->getAddonNick(), $addon->getAddonDescription());
|
||||
$this->featuresDetails[$addon->getAddonId()] = $detail;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,18 +12,14 @@
|
||||
* only if this copyright statement is not removed
|
||||
*--------------------------------------------------*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is derived from the class archive, is imployed to use files .
|
||||
* tar
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*
|
||||
*/class tar_file extends archive
|
||||
*/
|
||||
class tar_file extends Archive
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -31,9 +27,9 @@
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public function tar_file ($name)
|
||||
public function tar_file($name)
|
||||
{
|
||||
$this->archive( $name );
|
||||
$this->archive($name);
|
||||
$this->options['type'] = "tar";
|
||||
}
|
||||
|
||||
@@ -43,50 +39,50 @@
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function create_tar ()
|
||||
public function create_tar()
|
||||
{
|
||||
$pwd = getcwd();
|
||||
chdir( $this->options['basedir'] );
|
||||
chdir($this->options['basedir']);
|
||||
foreach ($this->files as $current) {
|
||||
if ($current['name'] == $this->options['name']) {
|
||||
continue;
|
||||
}
|
||||
if (strlen( $current['name2'] ) > 99) {
|
||||
$path = substr( $current['name2'], 0, strpos( $current['name2'], "/", strlen( $current['name2'] ) - 100 ) + 1 );
|
||||
$current['name2'] = substr( $current['name2'], strlen( $path ) );
|
||||
if (strlen( $path ) > 154 || strlen( $current['name2'] ) > 99) {
|
||||
if (strlen($current['name2']) > 99) {
|
||||
$path = substr($current['name2'], 0, strpos($current['name2'], "/", strlen($current['name2']) - 100) + 1);
|
||||
$current['name2'] = substr($current['name2'], strlen($path));
|
||||
if (strlen($path) > 154 || strlen($current['name2']) > 99) {
|
||||
$this->error[] = "Could not add {$path}{$current['name2']} to archive because the filename is too long.";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$block = pack( "a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12", $current['name2'], sprintf( "%07o", $current['stat'][2] ), sprintf( "%07o", $current['stat'][4] ), sprintf( "%07o", $current['stat'][5] ), sprintf( "%011o", $current['type'] == 2 ? 0 : $current['stat'][7] ), sprintf( "%011o", $current['stat'][9] ), " ", $current['type'], $current['type'] == 2 ? @readlink( $current['name'] ) : "", "ustar ", " ", "Unknown", "Unknown", "", "", ! empty( $path ) ? $path : "", "" );
|
||||
$block = pack("a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12", $current['name2'], sprintf("%07o", $current['stat'][2]), sprintf("%07o", $current['stat'][4]), sprintf("%07o", $current['stat'][5]), sprintf("%011o", $current['type'] == 2 ? 0 : $current['stat'][7]), sprintf("%011o", $current['stat'][9]), " ", $current['type'], $current['type'] == 2 ? @readlink($current['name']) : "", "ustar ", " ", "Unknown", "Unknown", "", "", !empty($path) ? $path : "", "");
|
||||
$checksum = 0;
|
||||
for ($i = 0; $i < 512; $i ++) {
|
||||
$checksum += ord( substr( $block, $i, 1 ) );
|
||||
for ($i = 0; $i < 512; $i++) {
|
||||
$checksum += ord(substr($block, $i, 1));
|
||||
}
|
||||
$checksum = pack( "a8", sprintf( "%07o", $checksum ) );
|
||||
$block = substr_replace( $block, $checksum, 148, 8 );
|
||||
$checksum = pack("a8", sprintf("%07o", $checksum));
|
||||
$block = substr_replace($block, $checksum, 148, 8);
|
||||
if ($current['type'] == 2 || $current['stat'][7] == 0) {
|
||||
$this->add_data( $block );
|
||||
} elseif ($fp = @fopen( $current['name'], "rb" )) {
|
||||
$this->add_data( $block );
|
||||
while ($temp = fread( $fp, 1048576 )) {
|
||||
$this->add_data( $temp );
|
||||
$this->add_data($block);
|
||||
} elseif ($fp = @fopen($current['name'], "rb")) {
|
||||
$this->add_data($block);
|
||||
while ($temp = fread($fp, 1048576)) {
|
||||
$this->add_data($temp);
|
||||
}
|
||||
if ($current['stat'][7] % 512 > 0) {
|
||||
$temp = "";
|
||||
for ($i = 0; $i < 512 - $current['stat'][7] % 512; $i ++) {
|
||||
for ($i = 0; $i < 512 - $current['stat'][7] % 512; $i++) {
|
||||
$temp .= "\0";
|
||||
}
|
||||
$this->add_data( $temp );
|
||||
$this->add_data($temp);
|
||||
}
|
||||
fclose( $fp );
|
||||
fclose($fp);
|
||||
} else {
|
||||
$this->error[] = "Could not open file {$current['name']} for reading. It was not added.";
|
||||
}
|
||||
}
|
||||
$this->add_data( pack( "a1024", "" ) );
|
||||
chdir( $pwd );
|
||||
$this->add_data(pack("a1024", ""));
|
||||
chdir($pwd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -95,58 +91,58 @@
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function extract_files ()
|
||||
public function extract_files()
|
||||
{
|
||||
$pwd = getcwd();
|
||||
chdir( $this->options['basedir'] );
|
||||
chdir($this->options['basedir']);
|
||||
if ($fp = $this->open_archive()) {
|
||||
if ($this->options['inmemory'] == 1) {
|
||||
$this->files = array ();
|
||||
$this->files = array();
|
||||
}
|
||||
while ($block = fread( $fp, 512 )) {
|
||||
$temp = unpack( "a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp", $block );
|
||||
$file = array ('name' => $this->options['basedir'] . '/' . $temp['prefix'] . $temp['name'],'stat' => array (2 => $temp['mode'],4 => octdec( $temp['uid'] ),5 => octdec( $temp['gid'] ),7 => octdec( $temp['size'] ),9 => octdec( $temp['mtime'] )
|
||||
),'checksum' => octdec( $temp['checksum'] ),'type' => $temp['type'],'magic' => $temp['magic']
|
||||
while ($block = fread($fp, 512)) {
|
||||
$temp = unpack("a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp", $block);
|
||||
$file = array('name' => $this->options['basedir'] . '/' . $temp['prefix'] . $temp['name'], 'stat' => array(2 => $temp['mode'], 4 => octdec($temp['uid']), 5 => octdec($temp['gid']), 7 => octdec($temp['size']), 9 => octdec($temp['mtime'])
|
||||
), 'checksum' => octdec($temp['checksum']), 'type' => $temp['type'], 'magic' => $temp['magic']
|
||||
);
|
||||
if ($file['checksum'] == 0x00000000) {
|
||||
break;
|
||||
} elseif (substr( $file['magic'], 0, 5 ) != "ustar") {
|
||||
} elseif (substr($file['magic'], 0, 5) != "ustar") {
|
||||
$this->error[] = "This script does not support extracting this type of tar file.";
|
||||
break;
|
||||
}
|
||||
$block = substr_replace( $block, " ", 148, 8 );
|
||||
$block = substr_replace($block, " ", 148, 8);
|
||||
$checksum = 0;
|
||||
for ($i = 0; $i < 512; $i ++) {
|
||||
$checksum += ord( substr( $block, $i, 1 ) );
|
||||
for ($i = 0; $i < 512; $i++) {
|
||||
$checksum += ord(substr($block, $i, 1));
|
||||
}
|
||||
if ($file['checksum'] != $checksum) {
|
||||
$this->error[] = "Could not extract from {$this->options['name']}, it is corrupt.";
|
||||
}
|
||||
if ($this->options['inmemory'] == 1) {
|
||||
$file['data'] = fread( $fp, $file['stat'][7] );
|
||||
fread( $fp, (512 - $file['stat'][7] % 512) == 512 ? 0 : (512 - $file['stat'][7] % 512) );
|
||||
unset( $file['checksum'], $file['magic'] );
|
||||
$file['data'] = fread($fp, $file['stat'][7]);
|
||||
fread($fp, (512 - $file['stat'][7] % 512) == 512 ? 0 : (512 - $file['stat'][7] % 512));
|
||||
unset($file['checksum'], $file['magic']);
|
||||
$this->files[] = $file;
|
||||
} elseif ($file['type'] == 5) {
|
||||
if (! is_dir( $file['name'] )) {
|
||||
if (!is_dir($file['name'])) {
|
||||
//mkdir($file['name'], $file['stat'][2]);
|
||||
mkdir( $file['name'], 0775 );
|
||||
mkdir($file['name'], 0775);
|
||||
}
|
||||
} elseif ($this->options['overwrite'] == 0 && file_exists( $file['name'] )) {
|
||||
} elseif ($this->options['overwrite'] == 0 && file_exists($file['name'])) {
|
||||
$this->error[] = "{$file['name']} already exist.";
|
||||
continue;
|
||||
} elseif ($file['type'] == 2) {
|
||||
symlink( $temp['symlink'], $file['name'] );
|
||||
symlink($temp['symlink'], $file['name']);
|
||||
//chmod($file['name'], $file['stat'][2]);
|
||||
} elseif ($new = @fopen( $file['name'], "wb" )) {
|
||||
fwrite( $new, fread( $fp, $file['stat'][7] ) );
|
||||
} elseif ($new = @fopen($file['name'], "wb")) {
|
||||
fwrite($new, fread($fp, $file['stat'][7]));
|
||||
if ((512 - $file['stat'][7] % 512) != 512) {
|
||||
fread( $fp, (512 - $file['stat'][7] % 512) );
|
||||
fread($fp, (512 - $file['stat'][7] % 512));
|
||||
}
|
||||
//fread($fp, (512 - $file['stat'][7] % 512) == 512 ? 0 : (512 - $file['stat'][7] % 512));
|
||||
fclose( $new );
|
||||
fclose($new);
|
||||
//chmod($file['name'], $file['stat'][2]);
|
||||
chmod( $file['name'], 0777 );
|
||||
chmod($file['name'], 0777);
|
||||
$this->files[] = $file['name'];
|
||||
} else {
|
||||
$this->error[] = "Could not open {$file['name']} for writing.";
|
||||
@@ -154,13 +150,13 @@
|
||||
}
|
||||
//chown($file['name'], $file['stat'][4]);
|
||||
//chgrp($file['name'], $file['stat'][5]);
|
||||
@touch( $file['name'], $file['stat'][9] );
|
||||
unset( $file );
|
||||
@touch($file['name'], $file['stat'][9]);
|
||||
unset($file);
|
||||
}
|
||||
} else {
|
||||
$this->error[] = "Could not open file {$this->options['name']}";
|
||||
}
|
||||
chdir( $pwd );
|
||||
chdir($pwd);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,8 +164,8 @@
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function open_archive ()
|
||||
public function open_archive()
|
||||
{
|
||||
return @fopen( $this->options['name'], "rb" );
|
||||
return @fopen($this->options['name'], "rb");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,22 +12,18 @@
|
||||
* only if this copyright statement is not removed
|
||||
*--------------------------------------------------*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is derived from the class archive, is imployed to use files .
|
||||
* zip
|
||||
*
|
||||
* @package workflow.engine.classes
|
||||
*/class zip_file extends archive
|
||||
*/
|
||||
class zip_file extends Archive
|
||||
{
|
||||
|
||||
public function zip_file ($name)
|
||||
public function zip_file($name)
|
||||
{
|
||||
$this->archive( $name );
|
||||
$this->archive($name);
|
||||
$this->options['type'] = "zip";
|
||||
}
|
||||
|
||||
@@ -37,77 +33,77 @@
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function create_zip ()
|
||||
public function create_zip()
|
||||
{
|
||||
$files = 0;
|
||||
$offset = 0;
|
||||
$central = "";
|
||||
if (! empty( $this->options['sfx'] )) {
|
||||
if ($fp = @fopen( $this->options['sfx'], "rb" )) {
|
||||
$temp = fread( $fp, filesize( $this->options['sfx'] ) );
|
||||
fclose( $fp );
|
||||
$this->add_data( $temp );
|
||||
$offset += strlen( $temp );
|
||||
unset( $temp );
|
||||
if (!empty($this->options['sfx'])) {
|
||||
if ($fp = @fopen($this->options['sfx'], "rb")) {
|
||||
$temp = fread($fp, filesize($this->options['sfx']));
|
||||
fclose($fp);
|
||||
$this->add_data($temp);
|
||||
$offset += strlen($temp);
|
||||
unset($temp);
|
||||
} else {
|
||||
$this->error[] = "Could not open sfx module from {$this->options['sfx']}.";
|
||||
}
|
||||
}
|
||||
$pwd = getcwd();
|
||||
chdir( $this->options['basedir'] );
|
||||
chdir($this->options['basedir']);
|
||||
foreach ($this->files as $current) {
|
||||
if ($current['name'] == $this->options['name']) {
|
||||
continue;
|
||||
}
|
||||
$timedate = explode( " ", date( "Y n j G i s", $current['stat'][9] ) );
|
||||
$timedate = explode(" ", date("Y n j G i s", $current['stat'][9]));
|
||||
$timedate = ($timedate[0] - 1980 << 25) | ($timedate[1] << 21) | ($timedate[2] << 16) | ($timedate[3] << 11) | ($timedate[4] << 5) | ($timedate[5]);
|
||||
$block = pack( "VvvvV", 0x04034b50, 0x000A, 0x0000, (isset( $current['method'] ) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate );
|
||||
$block = pack("VvvvV", 0x04034b50, 0x000A, 0x0000, (isset($current['method']) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate);
|
||||
if ($current['stat'][7] == 0 && $current['type'] == 5) {
|
||||
$block .= pack( "VVVvv", 0x00000000, 0x00000000, 0x00000000, strlen( $current['name2'] ) + 1, 0x0000 );
|
||||
$block .= pack("VVVvv", 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']) + 1, 0x0000);
|
||||
$block .= $current['name2'] . "/";
|
||||
$this->add_data( $block );
|
||||
$central .= pack( "VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014, $this->options['method'] == 0 ? 0x0000 : 0x000A, 0x0000, (isset( $current['method'] ) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate, 0x00000000, 0x00000000, 0x00000000, strlen( $current['name2'] ) + 1, 0x0000, 0x0000, 0x0000, 0x0000, $current['type'] == 5 ? 0x00000010 : 0x00000000, $offset );
|
||||
$this->add_data($block);
|
||||
$central .= pack("VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014, $this->options['method'] == 0 ? 0x0000 : 0x000A, 0x0000, (isset($current['method']) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate, 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']) + 1, 0x0000, 0x0000, 0x0000, 0x0000, $current['type'] == 5 ? 0x00000010 : 0x00000000, $offset);
|
||||
$central .= $current['name2'] . "/";
|
||||
$files ++;
|
||||
$offset += (31 + strlen( $current['name2'] ));
|
||||
$files++;
|
||||
$offset += (31 + strlen($current['name2']));
|
||||
} elseif ($current['stat'][7] == 0) {
|
||||
$block .= pack( "VVVvv", 0x00000000, 0x00000000, 0x00000000, strlen( $current['name2'] ), 0x0000 );
|
||||
$block .= pack("VVVvv", 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']), 0x0000);
|
||||
$block .= $current['name2'];
|
||||
$this->add_data( $block );
|
||||
$central .= pack( "VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014, $this->options['method'] == 0 ? 0x0000 : 0x000A, 0x0000, (isset( $current['method'] ) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate, 0x00000000, 0x00000000, 0x00000000, strlen( $current['name2'] ), 0x0000, 0x0000, 0x0000, 0x0000, $current['type'] == 5 ? 0x00000010 : 0x00000000, $offset );
|
||||
$this->add_data($block);
|
||||
$central .= pack("VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014, $this->options['method'] == 0 ? 0x0000 : 0x000A, 0x0000, (isset($current['method']) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate, 0x00000000, 0x00000000, 0x00000000, strlen($current['name2']), 0x0000, 0x0000, 0x0000, 0x0000, $current['type'] == 5 ? 0x00000010 : 0x00000000, $offset);
|
||||
$central .= $current['name2'];
|
||||
$files ++;
|
||||
$offset += (30 + strlen( $current['name2'] ));
|
||||
} elseif ($fp = @fopen( $current['name'], "rb" )) {
|
||||
$temp = fread( $fp, $current['stat'][7] );
|
||||
fclose( $fp );
|
||||
$crc32 = G::encryptCrc32( $temp );
|
||||
if (! isset( $current['method'] ) && $this->options['method'] == 1) {
|
||||
$temp = gzcompress( $temp, $this->options['level'] );
|
||||
$size = strlen( $temp ) - 6;
|
||||
$temp = substr( $temp, 2, $size );
|
||||
$files++;
|
||||
$offset += (30 + strlen($current['name2']));
|
||||
} elseif ($fp = @fopen($current['name'], "rb")) {
|
||||
$temp = fread($fp, $current['stat'][7]);
|
||||
fclose($fp);
|
||||
$crc32 = G::encryptCrc32($temp);
|
||||
if (!isset($current['method']) && $this->options['method'] == 1) {
|
||||
$temp = gzcompress($temp, $this->options['level']);
|
||||
$size = strlen($temp) - 6;
|
||||
$temp = substr($temp, 2, $size);
|
||||
} else {
|
||||
$size = strlen( $temp );
|
||||
$size = strlen($temp);
|
||||
}
|
||||
$block .= pack( "VVVvv", $crc32, $size, $current['stat'][7], strlen( $current['name2'] ), 0x0000 );
|
||||
$block .= pack("VVVvv", $crc32, $size, $current['stat'][7], strlen($current['name2']), 0x0000);
|
||||
$block .= $current['name2'];
|
||||
$this->add_data( $block );
|
||||
$this->add_data( $temp );
|
||||
unset( $temp );
|
||||
$central .= pack( "VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014, $this->options['method'] == 0 ? 0x0000 : 0x000A, 0x0000, (isset( $current['method'] ) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate, $crc32, $size, $current['stat'][7], strlen( $current['name2'] ), 0x0000, 0x0000, 0x0000, 0x0000, 0x00000000, $offset );
|
||||
$this->add_data($block);
|
||||
$this->add_data($temp);
|
||||
unset($temp);
|
||||
$central .= pack("VvvvvVVVVvvvvvVV", 0x02014b50, 0x0014, $this->options['method'] == 0 ? 0x0000 : 0x000A, 0x0000, (isset($current['method']) || $this->options['method'] == 0) ? 0x0000 : 0x0008, $timedate, $crc32, $size, $current['stat'][7], strlen($current['name2']), 0x0000, 0x0000, 0x0000, 0x0000, 0x00000000, $offset);
|
||||
$central .= $current['name2'];
|
||||
$files ++;
|
||||
$offset += (30 + strlen( $current['name2'] ) + $size);
|
||||
$files++;
|
||||
$offset += (30 + strlen($current['name2']) + $size);
|
||||
} else {
|
||||
$this->error[] = "Could not open file {$current['name']} for reading. It was not added.";
|
||||
}
|
||||
}
|
||||
$this->add_data( $central );
|
||||
$this->add_data( pack( "VvvvvVVv", 0x06054b50, 0x0000, 0x0000, $files, $files, strlen( $central ), $offset, ! empty( $this->options['comment'] ) ? strlen( $this->options['comment'] ) : 0x0000 ) );
|
||||
if (! empty( $this->options['comment'] )) {
|
||||
$this->add_data( $this->options['comment'] );
|
||||
$this->add_data($central);
|
||||
$this->add_data(pack("VvvvvVVv", 0x06054b50, 0x0000, 0x0000, $files, $files, strlen($central), $offset, !empty($this->options['comment']) ? strlen($this->options['comment']) : 0x0000));
|
||||
if (!empty($this->options['comment'])) {
|
||||
$this->add_data($this->options['comment']);
|
||||
}
|
||||
chdir( $pwd );
|
||||
chdir($pwd);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,8 @@ use ProcessMaker\Plugins\PluginRegistry;
|
||||
use Exception;
|
||||
use WsBase;
|
||||
use RBAC;
|
||||
use Applications;
|
||||
|
||||
/**
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
class Cases
|
||||
{
|
||||
private $formatFieldNameInUppercase = true;
|
||||
@@ -261,7 +258,7 @@ class Cases
|
||||
$newerThan = (!empty($dataList['newerThan']))? $dataList['newerThan'] : '';
|
||||
$oldestThan = (!empty($dataList['oldestthan']))? $dataList['oldestthan'] : '';
|
||||
|
||||
$apps = new \Applications();
|
||||
$apps = new Applications();
|
||||
$response = $apps->getAll(
|
||||
$userUid,
|
||||
$start,
|
||||
@@ -335,7 +332,7 @@ class Cases
|
||||
$dateTo = (!empty( $dataList["dateTo"] )) ? substr( $dataList["dateTo"], 0, 10 ) : "";
|
||||
$filterStatus = isset( $dataList["filterStatus"] ) ? strtoupper( $dataList["filterStatus"] ) : "";
|
||||
|
||||
$apps = new \Applications();
|
||||
$apps = new Applications();
|
||||
$response = $apps->searchAll(
|
||||
$userId,
|
||||
$start,
|
||||
@@ -2317,7 +2314,7 @@ class Cases
|
||||
$tas_uid = $aCaseField["TAS_UID"];
|
||||
$pro_uid = $aCaseField["PRO_UID"];
|
||||
|
||||
$oApplication = new \Applications();
|
||||
$oApplication = new Applications();
|
||||
$aField = $oApplication->getSteps($app_uid, $del_index, $tas_uid, $pro_uid);
|
||||
|
||||
return $aField;
|
||||
|
||||
Reference in New Issue
Block a user