diff --git a/workflow/engine/classes/class.webdav.php b/workflow/engine/classes/class.webdav.php index 1564bed9a..7683417dd 100755 --- a/workflow/engine/classes/class.webdav.php +++ b/workflow/engine/classes/class.webdav.php @@ -1,10 +1,10 @@ base = '/'; $this->uriBase = '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/webdav/'; @@ -51,7 +52,7 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server * @param string Password * @return bool true on successful authentication */ - function check_auth ($type, $user, $pass) + public function check_auth($type, $user, $pass) { return true; } @@ -63,201 +64,192 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server * @param array return array for file properties * @return bool true on success */ - function PROPFIND (&$options, &$files) + public function PROPFIND(&$options, &$files) { $paths = $this->paths; // prepare property array - $files["files"] = array (); + $files["files"] = array(); $pathClasses = PATH_DB . PATH_SEP . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP; - if (count( $paths ) == 0 && is_dir( $pathClasses )) { - $props = array (); - $props[] = $this->mkprop( "displayname", 'Classes' ); - $props[] = $this->mkprop( "creationdate", filectime( $pathClasses ) ); - $props[] = $this->mkprop( "getlastmodified", filemtime( $pathClasses ) ); - $props[] = $this->mkprop( "lastaccessed", filemtime( $pathClasses ) ); - $props[] = $this->mkprop( "resourcetype", 'collection' ); - $props[] = $this->mkprop( "getcontenttype", 'httpd/unix-directory' ); - $files["files"][] = array ('path' => 'classes','props' => $props + if (count($paths) == 0 && is_dir($pathClasses)) { + $props = array(); + $props[] = $this->mkprop("displayname", 'Classes'); + $props[] = $this->mkprop("creationdate", filectime($pathClasses)); + $props[] = $this->mkprop("getlastmodified", filemtime($pathClasses)); + $props[] = $this->mkprop("lastaccessed", filemtime($pathClasses)); + $props[] = $this->mkprop("resourcetype", 'collection'); + $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory'); + $files["files"][] = array('path' => 'classes', 'props' => $props ); } - if (count( $paths ) > 0 && $paths[0] == 'classes' && is_dir( $pathClasses )) { + if (count($paths) > 0 && $paths[0] == 'classes' && is_dir($pathClasses)) { // try to open directory - $handle = @opendir( $pathClasses ); + $handle = @opendir($pathClasses); if ($handle) { - while ($filename = readdir( $handle )) { - $ext = array_pop( explode( '.', $filename ) ); - if ($filename != "." && $filename != ".." && ! is_dir( $pathClasses . $filename ) && $ext == 'php') { - $props = array (); - $props[] = $this->mkprop( "displayname", $filename ); - $props[] = $this->mkprop( "creationdate", filectime( $pathClasses . $filename ) ); - $props[] = $this->mkprop( "getlastmodified", filemtime( $pathClasses . $filename ) ); - $props[] = $this->mkprop( "getetag", fileatime( $pathClasses . $filename ) ); - $props[] = $this->mkprop( "lastaccessed", filemtime( $pathClasses . $filename ) ); - $props[] = $this->mkprop( "resourcetype", '' ); - $props[] = $this->mkprop( "getcontenttype", 'text/plain' ); - $props[] = $this->mkprop( "getcontentlength", filesize( $pathClasses . $filename ) ); - if (count( $paths ) == 1 || (count( $paths ) == 2 && $paths[1] == $filename)) - $files["files"][] = array ('path' => "classes/$filename",'props' => $props - ); + while ($filename = readdir($handle)) { + $ext = array_pop(explode('.', $filename)); + if ($filename != "." && $filename != ".." && !is_dir($pathClasses . $filename) && $ext == 'php') { + $props = array(); + $props[] = $this->mkprop("displayname", $filename); + $props[] = $this->mkprop("creationdate", filectime($pathClasses . $filename)); + $props[] = $this->mkprop("getlastmodified", filemtime($pathClasses . $filename)); + $props[] = $this->mkprop("getetag", fileatime($pathClasses . $filename)); + $props[] = $this->mkprop("lastaccessed", filemtime($pathClasses . $filename)); + $props[] = $this->mkprop("resourcetype", ''); + $props[] = $this->mkprop("getcontenttype", 'text/plain'); + $props[] = $this->mkprop("getcontentlength", filesize($pathClasses . $filename)); + if (count($paths) == 1 || (count($paths) == 2 && $paths[1] == $filename)) { + $files["files"][] = array('path' => "classes/$filename", 'props' => $props); + } } } } - } //path classes $pathProcesses = PATH_DB . SYS_SYS . PATH_SEP; - if (count( $paths ) == 0 && is_dir( $pathProcesses )) { - $props = array (); - $props[] = $this->mkprop( "displayname", 'Processes' ); - $props[] = $this->mkprop( "creationdate", filectime( $pathProcesses ) ); - $props[] = $this->mkprop( "getlastmodified", filemtime( $pathProcesses ) ); - $props[] = $this->mkprop( "resourcetype", 'collection' ); - $props[] = $this->mkprop( "getcontenttype", 'httpd/unix-directory' ); - $files["files"][] = array ('path' => 'processes','props' => $props + if (count($paths) == 0 && is_dir($pathProcesses)) { + $props = array(); + $props[] = $this->mkprop("displayname", 'Processes'); + $props[] = $this->mkprop("creationdate", filectime($pathProcesses)); + $props[] = $this->mkprop("getlastmodified", filemtime($pathProcesses)); + $props[] = $this->mkprop("resourcetype", 'collection'); + $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory'); + $files["files"][] = array('path' => 'processes', 'props' => $props ); } //list all active processes - if (count( $paths ) == 1 && $paths[0] == 'processes' && is_dir( $pathProcesses )) { + if (count($paths) == 1 && $paths[0] == 'processes' && is_dir($pathProcesses)) { // try to get the process directory list - G::LoadClass( 'processMap' ); - G::LoadClass( 'model/Process' ); + G::LoadClass('processMap'); + G::LoadClass('model/Process'); $oProcessMap = new processMap(); $oProcess = new Process(); $c = $oProcessMap->getConditionProcessList(); - $oDataset = ProcessPeer::doSelectRS( $c ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset = ProcessPeer::doSelectRS($c); + $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($aRow['PRO_STATUS'] == 'ACTIVE') { - $aProcess = $oProcess->load( $aRow['PRO_UID'] ); - $props = array (); - $props[] = $this->mkprop( "displayname", $aProcess['PRO_TITLE'] ); - $props[] = $this->mkprop( "creationdate", filectime( $pathProcesses ) ); - $props[] = $this->mkprop( "getlastmodified", filemtime( $pathProcesses ) ); - $props[] = $this->mkprop( "lastaccessed", filemtime( $pathProcesses ) ); - $props[] = $this->mkprop( "resourcetype", 'collection' ); - $props[] = $this->mkprop( "getcontenttype", 'httpd/unix-directory' ); - $files["files"][] = array ('path' => "processes/" . $aRow['PRO_UID'],'props' => $props + $aProcess = $oProcess->load($aRow['PRO_UID']); + $props = array(); + $props[] = $this->mkprop("displayname", $aProcess['PRO_TITLE']); + $props[] = $this->mkprop("creationdate", filectime($pathProcesses)); + $props[] = $this->mkprop("getlastmodified", filemtime($pathProcesses)); + $props[] = $this->mkprop("lastaccessed", filemtime($pathProcesses)); + $props[] = $this->mkprop("resourcetype", 'collection'); + $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory'); + $files["files"][] = array('path' => "processes/" . $aRow['PRO_UID'], 'props' => $props ); } $oDataset->next(); } } //dir of processes - - //content of any process ( the three major folders of Processes ) $pathXmlform = $pathProcesses . 'xmlForms' . PATH_SEP; - if (count( $paths ) == 2 && $paths[0] == 'processes' && is_dir( $pathProcesses )) { - $props = array (); - $props[] = $this->mkprop( "displayname", 'xmlforms' ); - $props[] = $this->mkprop( "creationdate", filectime( $pathXmlform ) ); - $props[] = $this->mkprop( "getlastmodified", filemtime( $pathXmlform ) ); - $props[] = $this->mkprop( "lastaccessed", filemtime( $pathXmlform ) ); - $props[] = $this->mkprop( "resourcetype", 'collection' ); - $props[] = $this->mkprop( "getcontenttype", 'httpd/unix-directory' ); - $files["files"][] = array ('path' => 'processes/' . $paths[1] . '/xmlforms','props' => $props + if (count($paths) == 2 && $paths[0] == 'processes' && is_dir($pathProcesses)) { + $props = array(); + $props[] = $this->mkprop("displayname", 'xmlforms'); + $props[] = $this->mkprop("creationdate", filectime($pathXmlform)); + $props[] = $this->mkprop("getlastmodified", filemtime($pathXmlform)); + $props[] = $this->mkprop("lastaccessed", filemtime($pathXmlform)); + $props[] = $this->mkprop("resourcetype", 'collection'); + $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory'); + $files["files"][] = array('path' => 'processes/' . $paths[1] . '/xmlforms', 'props' => $props ); - $props[] = $this->mkprop( "displayname", 'mailTemplates' ); - $props[] = $this->mkprop( "creationdate", filectime( $pathProcesses ) ); - $props[] = $this->mkprop( "getlastmodified", filemtime( $pathProcesses ) ); - $props[] = $this->mkprop( "lastaccessed", filemtime( $pathProcesses ) ); - $props[] = $this->mkprop( "resourcetype", 'collection' ); - $props[] = $this->mkprop( "getcontenttype", 'httpd/unix-directory' ); - $files["files"][] = array ('path' => 'processes/' . $paths[1] . '/mailTemplates','props' => $props + $props[] = $this->mkprop("displayname", 'mailTemplates'); + $props[] = $this->mkprop("creationdate", filectime($pathProcesses)); + $props[] = $this->mkprop("getlastmodified", filemtime($pathProcesses)); + $props[] = $this->mkprop("lastaccessed", filemtime($pathProcesses)); + $props[] = $this->mkprop("resourcetype", 'collection'); + $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory'); + $files["files"][] = array('path' => 'processes/' . $paths[1] . '/mailTemplates', 'props' => $props ); - $props[] = $this->mkprop( "displayname", 'public_html' ); - $props[] = $this->mkprop( "creationdate", filectime( $pathProcesses ) ); - $props[] = $this->mkprop( "getlastmodified", filemtime( $pathProcesses ) ); - $props[] = $this->mkprop( "lastaccessed", filemtime( $pathProcesses ) ); - $props[] = $this->mkprop( "resourcetype", 'collection' ); - $props[] = $this->mkprop( "getcontenttype", 'httpd/unix-directory' ); - $files["files"][] = array ('path' => 'processes/' . $paths[1] . '/public_html','props' => $props + $props[] = $this->mkprop("displayname", 'public_html'); + $props[] = $this->mkprop("creationdate", filectime($pathProcesses)); + $props[] = $this->mkprop("getlastmodified", filemtime($pathProcesses)); + $props[] = $this->mkprop("lastaccessed", filemtime($pathProcesses)); + $props[] = $this->mkprop("resourcetype", 'collection'); + $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory'); + $files["files"][] = array('path' => 'processes/' . $paths[1] . '/public_html', 'props' => $props ); } //content of any processes - - //list available xmlforms - if (count( $paths ) == 3 && $paths[0] == 'processes' && $paths[2] == 'xmlforms' && is_dir( $pathXmlform )) { + if (count($paths) == 3 && $paths[0] == 'processes' && $paths[2] == 'xmlforms' && is_dir($pathXmlform)) { $pathXmlform = $pathProcesses . 'xmlForms' . PATH_SEP . $paths[1] . PATH_SEP; - $handle = @opendir( $pathXmlform ); + $handle = @opendir($pathXmlform); if ($handle) { - while ($filename = readdir( $handle )) { - $ext = array_pop( explode( '.', $filename ) ); - if ($filename != "." && $filename != ".." && ! is_dir( $pathXmlform . $filename ) && ($ext == 'xml' || $ext == 'html')) { - $props = array (); - $props[] = $this->mkprop( "displayname", $filename ); - $props[] = $this->mkprop( "creationdate", filectime( $pathXmlform . $filename ) ); - $props[] = $this->mkprop( "getlastmodified", filemtime( $pathXmlform . $filename ) ); - $props[] = $this->mkprop( "getetag", fileatime( $pathXmlform . $filename ) ); - $props[] = $this->mkprop( "lastaccessed", filemtime( $pathXmlform . $filename ) ); - $props[] = $this->mkprop( "resourcetype", '' ); - $props[] = $this->mkprop( "getcontenttype", 'text/plain' ); - $props[] = $this->mkprop( "getcontentlength", filesize( $pathXmlform . $filename ) ); + while ($filename = readdir($handle)) { + $ext = array_pop(explode('.', $filename)); + if ($filename != "." && $filename != ".." && !is_dir($pathXmlform . $filename) && ($ext == 'xml' || $ext == 'html')) { + $props = array(); + $props[] = $this->mkprop("displayname", $filename); + $props[] = $this->mkprop("creationdate", filectime($pathXmlform . $filename)); + $props[] = $this->mkprop("getlastmodified", filemtime($pathXmlform . $filename)); + $props[] = $this->mkprop("getetag", fileatime($pathXmlform . $filename)); + $props[] = $this->mkprop("lastaccessed", filemtime($pathXmlform . $filename)); + $props[] = $this->mkprop("resourcetype", ''); + $props[] = $this->mkprop("getcontenttype", 'text/plain'); + $props[] = $this->mkprop("getcontentlength", filesize($pathXmlform . $filename)); //if ( count( $paths ) == 1 || ( count( $paths ) == 2 && $paths[1] == $filename ) ) - $files["files"][] = array ('path' => 'processes/' . $paths[1] . '/xmlforms/' . $filename,'props' => $props + $files["files"][] = array('path' => 'processes/' . $paths[1] . '/xmlforms/' . $filename, 'props' => $props ); } } } } //content of xmlforms - - //list available mailTemplates $pathTemplates = $pathProcesses . 'mailTemplates' . PATH_SEP; - if (count( $paths ) == 3 && $paths[0] == 'processes' && $paths[2] == 'mailTemplates' && is_dir( $pathTemplates )) { + if (count($paths) == 3 && $paths[0] == 'processes' && $paths[2] == 'mailTemplates' && is_dir($pathTemplates)) { $pathTemplates = $pathProcesses . 'mailTemplates' . PATH_SEP . $paths[1] . PATH_SEP; - $handle = @opendir( $pathTemplates ); + $handle = @opendir($pathTemplates); if ($handle) { - while ($filename = readdir( $handle )) { - $ext = array_pop( explode( '.', $filename ) ); - if ($filename != "." && $filename != ".." && ! is_dir( $pathTemplates . $filename ) /* && ( $ext == 'xml' || $ext == 'html' ) */ ) { - $props = array (); - $props[] = $this->mkprop( "displayname", $filename ); - $props[] = $this->mkprop( "creationdate", filectime( $pathTemplates . $filename ) ); - $props[] = $this->mkprop( "getlastmodified", filemtime( $pathTemplates . $filename ) ); - $props[] = $this->mkprop( "getetag", fileatime( $pathTemplates . $filename ) ); - $props[] = $this->mkprop( "lastaccessed", filemtime( $pathTemplates . $filename ) ); - $props[] = $this->mkprop( "resourcetype", '' ); - $props[] = $this->mkprop( "getcontenttype", 'text/plain' ); - $props[] = $this->mkprop( "getcontentlength", filesize( $pathTemplates . $filename ) ); + while ($filename = readdir($handle)) { + $ext = array_pop(explode('.', $filename)); + if ($filename != "." && $filename != ".." && !is_dir($pathTemplates . $filename) /* && ( $ext == 'xml' || $ext == 'html' ) */) { + $props = array(); + $props[] = $this->mkprop("displayname", $filename); + $props[] = $this->mkprop("creationdate", filectime($pathTemplates . $filename)); + $props[] = $this->mkprop("getlastmodified", filemtime($pathTemplates . $filename)); + $props[] = $this->mkprop("getetag", fileatime($pathTemplates . $filename)); + $props[] = $this->mkprop("lastaccessed", filemtime($pathTemplates . $filename)); + $props[] = $this->mkprop("resourcetype", ''); + $props[] = $this->mkprop("getcontenttype", 'text/plain'); + $props[] = $this->mkprop("getcontentlength", filesize($pathTemplates . $filename)); //if ( count( $paths ) == 1 || ( count( $paths ) == 2 && $paths[1] == $filename ) ) - $files["files"][] = array ('path' => 'processes/' . $paths[1] . '/mailTemplates/' . $filename,'props' => $props + $files["files"][] = array('path' => 'processes/' . $paths[1] . '/mailTemplates/' . $filename, 'props' => $props ); } } } } //content of mailTemplates - - //list available public_html files $pathPublic = $pathProcesses . 'public' . PATH_SEP; - if (count( $paths ) == 3 && $paths[0] == 'processes' && $paths[2] == 'public_html' && is_dir( $pathTemplates )) { + if (count($paths) == 3 && $paths[0] == 'processes' && $paths[2] == 'public_html' && is_dir($pathTemplates)) { $pathPublic = $pathProcesses . 'public' . PATH_SEP . $paths[1] . PATH_SEP; - $handle = @opendir( $pathPublic ); + $handle = @opendir($pathPublic); if ($handle) { - while ($filename = readdir( $handle )) { - $ext = array_pop( explode( '.', $filename ) ); - if ($filename != "." && $filename != ".." && ! is_dir( $pathPublic . $filename ) /* && ( $ext == 'xml' || $ext == 'html' ) */ ) { - $props = array (); - $props[] = $this->mkprop( "displayname", $filename ); - $props[] = $this->mkprop( "creationdate", filectime( $pathPublic . $filename ) ); - $props[] = $this->mkprop( "getlastmodified", filemtime( $pathPublic . $filename ) ); - $props[] = $this->mkprop( "getetag", fileatime( $pathPublic . $filename ) ); - $props[] = $this->mkprop( "lastaccessed", filemtime( $pathPublic . $filename ) ); - $props[] = $this->mkprop( "resourcetype", '' ); - $props[] = $this->mkprop( "getcontenttype", 'text/plain' ); - $props[] = $this->mkprop( "getcontentlength", filesize( $pathPublic . $filename ) ); + while ($filename = readdir($handle)) { + $ext = array_pop(explode('.', $filename)); + if ($filename != "." && $filename != ".." && !is_dir($pathPublic . $filename) /* && ( $ext == 'xml' || $ext == 'html' ) */) { + $props = array(); + $props[] = $this->mkprop("displayname", $filename); + $props[] = $this->mkprop("creationdate", filectime($pathPublic . $filename)); + $props[] = $this->mkprop("getlastmodified", filemtime($pathPublic . $filename)); + $props[] = $this->mkprop("getetag", fileatime($pathPublic . $filename)); + $props[] = $this->mkprop("lastaccessed", filemtime($pathPublic . $filename)); + $props[] = $this->mkprop("resourcetype", ''); + $props[] = $this->mkprop("getcontenttype", 'text/plain'); + $props[] = $this->mkprop("getcontentlength", filesize($pathPublic . $filename)); //if ( count( $paths ) == 1 || ( count( $paths ) == 2 && $paths[1] == $filename ) ) - $files["files"][] = array ('path' => 'processes/' . $paths[1] . '/public_html/' . $filename,'props' => $props + $files["files"][] = array('path' => 'processes/' . $paths[1] . '/public_html/' . $filename, 'props' => $props ); } } @@ -266,15 +258,15 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server /* - if ( 1 ) { - $props = array (); - $props[] = $this->mkprop("displayname", print_r ($pathPublic, 1) ); - $props[] = $this->mkprop("creationdate", filectime( PATH_DB ) ); - $props[] = $this->mkprop("getlastmodified", filemtime( PATH_DB ) ); - $props[] = $this->mkprop("resourcetype", 'collection' ); - $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory' ); - $files["files"][] = array ( 'path' => '/' , 'props' => $props); - } */ + if ( 1 ) { + $props = array (); + $props[] = $this->mkprop("displayname", print_r ($pathPublic, 1) ); + $props[] = $this->mkprop("creationdate", filectime( PATH_DB ) ); + $props[] = $this->mkprop("getlastmodified", filemtime( PATH_DB ) ); + $props[] = $this->mkprop("resourcetype", 'collection' ); + $props[] = $this->mkprop("getcontenttype", 'httpd/unix-directory' ); + $files["files"][] = array ( 'path' => '/' , 'props' => $props); + } */ // ok, all done return true; @@ -290,38 +282,41 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server * @param string optional search path, defaults to $PATH * @return bool true if executable program found in path */ - function _can_execute ($name, $path = false) + public function _can_execute($name, $path = false) { // path defaults to PATH from environment if not set if ($path === false) { - $path = getenv( "PATH" ); + $path = getenv("PATH"); } // check method depends on operating system - if (! strncmp( PHP_OS, "WIN", 3 )) { + if (!strncmp(PHP_OS, "WIN", 3)) { // on Windows an appropriate COM or EXE file needs to exist - $exts = array (".exe",".com" + $exts = array(".exe", ".com" ); $check_fn = "file_exists"; } else { // anywhere else we look for an executable file of that name - $exts = array ("" + $exts = array("" ); $check_fn = "is_executable"; } // now check the directories in the path for the program - foreach (explode( PATH_SEPARATOR, $path ) as $dir) { + foreach (explode(PATH_SEPARATOR, $path) as $dir) { // skip invalid path entries - if (! file_exists( $dir )) + if (!file_exists($dir)) { continue; - if (! is_dir( $dir )) + } + if (!is_dir($dir)) { continue; + } - // and now look for the file + // and now look for the file foreach ($exts as $ext) { - if ($check_fn( "$dir/$name" . $ext )) + if ($check_fn("$dir/$name" . $ext)) { return true; + } } } @@ -334,37 +329,35 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server * @param string file path * @return string guessed mime type */ - function _mimetype ($fspath) + public function _mimetype($fspath) { - if (@is_dir( $fspath )) { + if (@is_dir($fspath)) { // directories are easy return "httpd/unix-directory"; - } else if (function_exists( "mime_content_type" )) { + } elseif (function_exists("mime_content_type")) { // use mime magic extension if available - $mime_type = mime_content_type( $fspath ); - } else if ($this->_can_execute( "file" )) { + $mime_type = mime_content_type($fspath); + } elseif ($this->_can_execute("file")) { // it looks like we have a 'file' command, // lets see it it does have mime support - $fp = popen( "file -i '$fspath' 2>/dev/null", "r" ); - $reply = fgets( $fp ); - pclose( $fp ); + $fp = popen("file -i '$fspath' 2>/dev/null", "r"); + $reply = fgets($fp); + pclose($fp); // popen will not return an error if the binary was not found // and find may not have mime support using "-i" // so we test the format of the returned string - - // the reply begins with the requested filename - if (! strncmp( $reply, "$fspath: ", strlen( $fspath ) + 2 )) { - $reply = substr( $reply, strlen( $fspath ) + 2 ); + if (!strncmp($reply, "$fspath: ", strlen($fspath) + 2)) { + $reply = substr($reply, strlen($fspath) + 2); // followed by the mime type (maybe including options) - if (preg_match( '/^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*/', $reply, $matches )) { + if (preg_match('/^[[:alnum:]_-]+/[[:alnum:]_-]+;?.*/', $reply, $matches)) { $mime_type = $matches[0]; } } } - if (empty( $mime_type )) { + if (empty($mime_type)) { // Fallback solution: try to guess the type by the file extension // TODO: add more ... // TODO: it has been suggested to delegate mimetype detection @@ -378,7 +371,7 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server // anyway (overriding it with information taken from // the registry) // TODO: have a seperate PEAR class for mimetype detection? - switch (strtolower( strrchr( basename( $fspath ), "." ) )) { + switch (strtolower(strrchr(basename($fspath), "."))) { case ".html": $mime_type = "text/html"; break; @@ -403,101 +396,99 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server * @param array parameter passing array * @return bool true on success */ - function GET (&$options) + public function GET(&$options) { $paths = $this->paths; $pathClasses = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP; - if (count( $paths ) > 0 && $paths[0] == 'classes' && is_dir( $pathClasses )) { + if (count($paths) > 0 && $paths[0] == 'classes' && is_dir($pathClasses)) { $fsFile = $pathClasses . $paths[1]; - if (count( $paths ) == 2 && file_exists( $fsFile )) { - $content = file_get_contents( $fsFile ); + if (count($paths) == 2 && file_exists($fsFile)) { + $content = file_get_contents($fsFile); print $content; - header( "Content-Type: " . mime_content_type( $fsFile ) ); - header( "Last-Modified: " . date( "D, j M Y H:m:s ", file_mtime( $fsFile ) ) . "GMT" ); - header( "Content-Length: " . filesize( $fsFile ) ); + header("Content-Type: " . mime_content_type($fsFile)); + header("Last-Modified: " . date("D, j M Y H:m:s ", file_mtime($fsFile)) . "GMT"); + header("Content-Length: " . filesize($fsFile)); return true; } } $pathProcesses = PATH_DB . SYS_SYS . PATH_SEP; - if (count( $paths ) > 0 && $paths[0] == 'processes' && is_dir( $pathProcesses )) { - if (count( $paths ) == 4 && $paths[2] == 'xmlforms') { + if (count($paths) > 0 && $paths[0] == 'processes' && is_dir($pathProcesses)) { + if (count($paths) == 4 && $paths[2] == 'xmlforms') { $pathXmlform = $pathProcesses . 'xmlForms' . PATH_SEP . $paths[1] . PATH_SEP; $fsFile = $pathXmlform . $paths[3]; - if (count( $paths ) == 4 && file_exists( $fsFile )) { - $content = file_get_contents( $fsFile ); + if (count($paths) == 4 && file_exists($fsFile)) { + $content = file_get_contents($fsFile); print $content; - header( "Content-Type: " . mime_content_type( $fsFile ) ); - header( "Last-Modified: " . date( "D, j M Y H:m:s ", file_mtime( $fsFile ) ) . "GMT" ); - header( "Content-Length: " . filesize( $fsFile ) ); + header("Content-Type: " . mime_content_type($fsFile)); + header("Last-Modified: " . date("D, j M Y H:m:s ", file_mtime($fsFile)) . "GMT"); + header("Content-Length: " . filesize($fsFile)); return true; } } - if (count( $paths ) == 4 && $paths[2] == 'mailTemplates') { + if (count($paths) == 4 && $paths[2] == 'mailTemplates') { $pathTemplates = $pathProcesses . 'mailTemplates' . PATH_SEP . $paths[1] . PATH_SEP; $fsFile = $pathTemplates . $paths[3]; - if (count( $paths ) == 4 && file_exists( $fsFile )) { - $content = file_get_contents( $fsFile ); + if (count($paths) == 4 && file_exists($fsFile)) { + $content = file_get_contents($fsFile); print $content; - header( "Content-Type: " . mime_content_type( $fsFile ) ); - header( "Last-Modified: " . date( "D, j M Y H:m:s ", file_mtime( $fsFile ) ) . "GMT" ); - header( "Content-Length: " . filesize( $fsFile ) ); + header("Content-Type: " . mime_content_type($fsFile)); + header("Last-Modified: " . date("D, j M Y H:m:s ", file_mtime($fsFile)) . "GMT"); + header("Content-Length: " . filesize($fsFile)); return true; } } - if (count( $paths ) == 4 && $paths[2] == 'public_html') { + if (count($paths) == 4 && $paths[2] == 'public_html') { $pathPublic = $pathProcesses . 'public' . PATH_SEP . $paths[1] . PATH_SEP; $fsFile = $pathPublic . $paths[3]; - if (count( $paths ) == 4 && file_exists( $fsFile )) { - $content = file_get_contents( $fsFile ); + if (count($paths) == 4 && file_exists($fsFile)) { + $content = file_get_contents($fsFile); print $content; - header( "Content-Type: " . mime_content_type( $fsFile ) ); - header( "Last-Modified: " . date( "D, j M Y H:m:s ", file_mtime( $fsFile ) ) . "GMT" ); - header( "Content-Length: " . filesize( $fsFile ) ); + header("Content-Type: " . mime_content_type($fsFile)); + header("Last-Modified: " . date("D, j M Y H:m:s ", file_mtime($fsFile)) . "GMT"); + header("Content-Length: " . filesize($fsFile)); return true; } } - } - print_r( $paths ); + print_r($paths); return true; if ($options["path"] == '/') { - return $this->getRoot( $options ); + return $this->getRoot($options); } //print_r ($options); - - // get absolute fs path to requested resource $fspath = $this->base . $options["path"]; // sanity check - if (! file_exists( $fspath )) + if (!file_exists($fspath)) { return false; + } - // is this a collection? - if (is_dir( $fspath )) { - return $this->GetDir( $fspath, $options ); + // is this a collection? + if (is_dir($fspath)) { + return $this->GetDir($fspath, $options); } // detect resource type - $options['mimetype'] = $this->_mimetype( $fspath ); + $options['mimetype'] = $this->_mimetype($fspath); // detect modification time // see rfc2518, section 13.7 // some clients seem to treat this as a reverse rule // requiering a Last-Modified header if the getlastmodified header was set - $options['mtime'] = filemtime( $fspath ); + $options['mtime'] = filemtime($fspath); // detect resource size - $options['size'] = filesize( $fspath ); + $options['size'] = filesize($fspath); // no need to check result here, it is handled by the base class - $options['stream'] = fopen( $fspath, "r" ); + $options['stream'] = fopen($fspath, "r"); return true; } @@ -508,26 +499,26 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server * @param string &$options * @return boolean false */ - function getRoot (&$options) + public function getRoot(&$options) { - $path = $this->_slashify( $options["path"] ); + $path = $this->_slashify($options["path"]); // fixed width directory column format $format = "%15s %-19s %-s\n"; - echo "
";
- printf( $format, "Size", "Last modified", "Filename" );
+ printf($format, "Size", "Last modified", "Filename");
echo "
";
- $pathRoot = array ('xmlforms','public_html','dir1','dir2'
+ $pathRoot = array('xmlforms', 'public_html', 'dir1', 'dir2'
);
foreach ($pathRoot as $key => $val) {
$fullpath = $fspath . "/" . $filename;
- $name = htmlspecialchars( $val );
- printf( $format, number_format( filesize( $fullpath ) ), strftime( "%Y-%m-%d %H:%M:%S", filemtime( $fullpath ) ), "$name" );
+ $name = htmlspecialchars($val);
+ printf($format, number_format(filesize($fullpath)), strftime("%Y-%m-%d %H:%M:%S", filemtime($fullpath)), "$name");
}
echo "";
@@ -535,22 +526,22 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
die();
- $handle = @opendir( $fspath );
- if (! $handle) {
+ $handle = @opendir($fspath);
+ if (!$handle) {
return false;
}
- while ($filename = readdir( $handle )) {
+ while ($filename = readdir($handle)) {
if ($filename != "." && $filename != "..") {
$fullpath = $fspath . "/" . $filename;
- $name = htmlspecialchars( $filename );
- printf( $format, number_format( filesize( $fullpath ) ), strftime( "%Y-%m-%d %H:%M:%S", filemtime( $fullpath ) ), "$name" );
+ $name = htmlspecialchars($filename);
+ printf($format, number_format(filesize($fullpath)), strftime("%Y-%m-%d %H:%M:%S", filemtime($fullpath)), "$name");
}
}
echo "";
- closedir( $handle );
+ closedir($handle);
echo "\n";
@@ -566,41 +557,41 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
* @param string directory path
* @return void function has to handle HTTP response itself
*/
- function GetDir ($fspath, &$options)
+ public function GetDir($fspath, &$options)
{
- $path = $this->_slashify( $options["path"] );
+ $path = $this->_slashify($options["path"]);
if ($path != $options["path"]) {
- header( "Location: " . $this->base_uri . $path );
+ header("Location: " . $this->base_uri . $path);
exit();
}
// fixed width directory column format
$format = "%15s %-19s %-s\n";
- $handle = @opendir( $fspath );
- if (! $handle) {
+ $handle = @opendir($fspath);
+ if (!$handle) {
return false;
}
- echo "";
- printf( $format, "Size", "Last modified", "Filename" );
+ printf($format, "Size", "Last modified", "Filename");
echo "
";
- while ($filename = readdir( $handle )) {
+ while ($filename = readdir($handle)) {
if ($filename != "." && $filename != "..") {
$fullpath = $fspath . "/" . $filename;
- $name = htmlspecialchars( $filename );
- printf( $format, number_format( filesize( $fullpath ) ), strftime( "%Y-%m-%d %H:%M:%S", filemtime( $fullpath ) ), "$name" );
+ $name = htmlspecialchars($filename);
+ printf($format, number_format(filesize($fullpath)), strftime("%Y-%m-%d %H:%M:%S", filemtime($fullpath)), "$name");
}
}
echo "";
- closedir( $handle );
+ closedir($handle);
echo "\n";
@@ -613,39 +604,39 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
* @param array parameter passing array
* @return bool true on success
*/
- function PUT (&$options)
+ public function PUT(&$options)
{
$paths = $this->paths;
$pathClasses = PATH_DB . PATH_SEP . 'classes' . PATH_SEP;
- if (count( $paths ) > 0 && $paths[0] == 'classes' && is_dir( $pathClasses )) {
+ if (count($paths) > 0 && $paths[0] == 'classes' && is_dir($pathClasses)) {
$fsFile = $pathClasses . $paths[1];
- if (count( $paths ) == 2 && file_exists( $fsFile )) {
- $fp = fopen( $fsFile, "w" );
- if (is_resource( $fp ) && is_resource( $options["stream"] )) {
- while (! feof( $options["stream"] )) {
- fwrite( $fp, fread( $options["stream"], 4096 ) );
+ if (count($paths) == 2 && file_exists($fsFile)) {
+ $fp = fopen($fsFile, "w");
+ if (is_resource($fp) && is_resource($options["stream"])) {
+ while (!feof($options["stream"])) {
+ fwrite($fp, fread($options["stream"], 4096));
}
- fclose( $fp );
- fclose( $options["stream"] );
+ fclose($fp);
+ fclose($options["stream"]);
}
return "201 Created " . $fsFile;
}
}
$pathProcesses = PATH_DB . SYS_SYS . PATH_SEP;
- if (count( $paths ) > 0 && $paths[0] == 'processes' && is_dir( $pathProcesses )) {
+ if (count($paths) > 0 && $paths[0] == 'processes' && is_dir($pathProcesses)) {
if ($paths[2] == 'xmlforms') {
$pathTemplates = $pathProcesses . 'xmlForms' . PATH_SEP . $paths[1] . PATH_SEP;
$fsFile = $pathTemplates . $paths[3];
- if (count( $paths ) == 4 && file_exists( $fsFile )) {
- $fp = fopen( $fsFile, "w" );
- if (is_resource( $fp ) && is_resource( $options["stream"] )) {
- while (! feof( $options["stream"] )) {
- fwrite( $fp, fread( $options["stream"], 4096 ) );
+ if (count($paths) == 4 && file_exists($fsFile)) {
+ $fp = fopen($fsFile, "w");
+ if (is_resource($fp) && is_resource($options["stream"])) {
+ while (!feof($options["stream"])) {
+ fwrite($fp, fread($options["stream"], 4096));
}
- fclose( $fp );
- fclose( $options["stream"] );
+ fclose($fp);
+ fclose($options["stream"]);
}
return "201 Created " . $fsFile;
}
@@ -654,14 +645,14 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
if ($paths[2] == 'mailTemplates') {
$pathTemplates = $pathProcesses . 'mailTemplates' . PATH_SEP . $paths[1] . PATH_SEP;
$fsFile = $pathTemplates . $paths[3];
- if (count( $paths ) == 4 && file_exists( $fsFile )) {
- $fp = fopen( $fsFile, "w" );
- if (is_resource( $fp ) && is_resource( $options["stream"] )) {
- while (! feof( $options["stream"] )) {
- fwrite( $fp, fread( $options["stream"], 4096 ) );
+ if (count($paths) == 4 && file_exists($fsFile)) {
+ $fp = fopen($fsFile, "w");
+ if (is_resource($fp) && is_resource($options["stream"])) {
+ while (!feof($options["stream"])) {
+ fwrite($fp, fread($options["stream"], 4096));
}
- fclose( $fp );
- fclose( $options["stream"] );
+ fclose($fp);
+ fclose($options["stream"]);
}
return "201 Created " . $fsFile;
}
@@ -670,23 +661,21 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
if ($paths[2] == 'public_html') {
$pathPublic = $pathProcesses . 'public' . PATH_SEP . $paths[1] . PATH_SEP;
$fsFile = $pathPublic . $paths[3];
- if (count( $paths ) == 4 && file_exists( $fsFile )) {
- $fp = fopen( $fsFile, "w" );
- if (is_resource( $fp ) && is_resource( $options["stream"] )) {
- while (! feof( $options["stream"] )) {
- fwrite( $fp, fread( $options["stream"], 4096 ) );
+ if (count($paths) == 4 && file_exists($fsFile)) {
+ $fp = fopen($fsFile, "w");
+ if (is_resource($fp) && is_resource($options["stream"])) {
+ while (!feof($options["stream"])) {
+ fwrite($fp, fread($options["stream"], 4096));
}
- fclose( $fp );
- fclose( $options["stream"] );
+ fclose($fp);
+ fclose($options["stream"]);
}
return "201 Created " . $fsFile;
}
}
-
}
return "409 Conflict";
-
}
/**
@@ -695,30 +684,31 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
* @param array general parameter passing array
* @return bool true on success
*/
- function MKCOL ($options)
+ public function MKCOL($options)
{
$path = $this->base . $options["path"];
- $parent = dirname( $path );
- $name = basename( $path );
+ $parent = dirname($path);
+ $name = basename($path);
- if (! file_exists( $parent )) {
+ if (!file_exists($parent)) {
return "409 Conflict";
}
- if (! is_dir( $parent )) {
+ if (!is_dir($parent)) {
return "403 Forbidden";
}
- if (file_exists( $parent . "/" . $name )) {
+ if (file_exists($parent . "/" . $name)) {
return "405 Method not allowed";
}
- if (! empty( $_SERVER["CONTENT_LENGTH"] )) { // no body parsing yet
+ if (!empty($_SERVER["CONTENT_LENGTH"])) {
+ // no body parsing yet
return "415 Unsupported media type";
}
- $stat = mkdir( $parent . "/" . $name, 0777 );
- if (! $stat) {
+ $stat = mkdir($parent . "/" . $name, 0777);
+ if (!$stat) {
return "403 Forbidden";
}
@@ -731,23 +721,23 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
* @param array general parameter passing array
* @return bool true on success
*/
- function DELETE ($options)
+ public function DELETE($options)
{
$path = $this->base . "/" . $options["path"];
- if (! file_exists( $path )) {
+ if (!file_exists($path)) {
return "404 Not found";
}
- if (is_dir( $path )) {
- $query = "DELETE FROM properties WHERE path LIKE '" . $this->_slashify( $options["path"] ) . "%'";
- mysql_query( $query );
- System::rm( "-rf $path" );
+ if (is_dir($path)) {
+ $query = "DELETE FROM properties WHERE path LIKE '" . $this->_slashify($options["path"]) . "%'";
+ mysql_query($query);
+ System::rm("-rf $path");
} else {
- unlink( $path );
+ unlink($path);
}
$query = "DELETE FROM properties WHERE path = '$options[path]'";
- mysql_query( $query );
+ mysql_query($query);
return "204 No Content";
}
@@ -758,7 +748,7 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
* @param array general parameter passing array
* @return bool true on success
*/
- function MOVE ($options)
+ public function MOVE($options)
{
return "423 Locked";
//return $this->COPY($options, true);
@@ -770,37 +760,39 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
* @param array general parameter passing array
* @return bool true on success
*/
- function COPY ($options, $del = false)
+ public function COPY($options, $del = false)
{
// TODO Property updates still broken (Litmus should detect this?)
- if (! empty( $_SERVER["CONTENT_LENGTH"] )) { // no body parsing yet
+ if (!empty($_SERVER["CONTENT_LENGTH"])) {
+ // no body parsing yet
return "415 Unsupported media type";
}
// no copying to different WebDAV Servers yet
- if (isset( $options["dest_url"] )) {
+ if (isset($options["dest_url"])) {
return "502 bad gateway";
}
$source = $this->base . $options["path"];
- if (! file_exists( $source ))
+ if (!file_exists($source)) {
return "404 Not found";
+ }
$dest = $this->base . $options["dest"];
- $new = ! file_exists( $dest );
+ $new = !file_exists($dest);
$existing_col = false;
- if (! $new) {
- if ($del && is_dir( $dest )) {
- if (! $options["overwrite"]) {
+ if (!$new) {
+ if ($del && is_dir($dest)) {
+ if (!$options["overwrite"]) {
return "412 precondition failed";
}
- $dest .= basename( $source );
- if (file_exists( $dest )) {
- $options["dest"] .= basename( $source );
+ $dest .= basename($source);
+ if (file_exists($dest)) {
+ $options["dest"] .= basename($source);
} else {
$new = true;
$existing_col = true;
@@ -808,11 +800,11 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
}
}
- if (! $new) {
+ if (!$new) {
if ($options["overwrite"]) {
- $stat = $this->DELETE( array ("path" => $options["dest"]
- ) );
- if (($stat{0} != "2") && (substr( $stat, 0, 3 ) != "404")) {
+ $stat = $this->DELETE(array("path" => $options["dest"]
+ ));
+ if (($stat{0} != "2") && (substr($stat, 0, 3) != "404")) {
return $stat;
}
} else {
@@ -820,58 +812,58 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
}
}
- if (is_dir( $source ) && ($options["depth"] != "infinity")) {
+ if (is_dir($source) && ($options["depth"] != "infinity")) {
// RFC 2518 Section 9.2, last paragraph
return "400 Bad request";
}
if ($del) {
- if (! rename( $source, $dest )) {
+ if (!rename($source, $dest)) {
return "500 Internal server error";
}
- $destpath = $this->_unslashify( $options["dest"] );
- if (is_dir( $source )) {
+ $destpath = $this->_unslashify($options["dest"]);
+ if (is_dir($source)) {
$query = "UPDATE properties
SET path = REPLACE(path, '" . $options["path"] . "', '" . $destpath . "')
- WHERE path LIKE '" . $this->_slashify( $options["path"] ) . "%'";
- mysql_query( $query );
+ WHERE path LIKE '" . $this->_slashify($options["path"]) . "%'";
+ mysql_query($query);
}
$query = "UPDATE properties
SET path = '" . $destpath . "'
WHERE path = '" . $options["path"] . "'";
- mysql_query( $query );
+ mysql_query($query);
} else {
- if (is_dir( $source )) {
- $files = System::find( $source );
- $files = array_reverse( $files );
+ if (is_dir($source)) {
+ $files = System::find($source);
+ $files = array_reverse($files);
} else {
- $files = array ($source
+ $files = array($source
);
}
- if (! is_array( $files ) || empty( $files )) {
+ if (!is_array($files) || empty($files)) {
return "500 Internal server error";
}
foreach ($files as $file) {
- if (is_dir( $file )) {
- $file = $this->_slashify( $file );
+ if (is_dir($file)) {
+ $file = $this->_slashify($file);
}
- $destfile = str_replace( $source, $dest, $file );
+ $destfile = str_replace($source, $dest, $file);
- if (is_dir( $file )) {
- if (! is_dir( $destfile )) {
+ if (is_dir($file)) {
+ if (!is_dir($destfile)) {
// TODO "mkdir -p" here? (only natively supported by PHP 5)
- if (! mkdir( $destfile )) {
+ if (!mkdir($destfile)) {
return "409 Conflict";
}
} else {
- error_log( "existing dir '$destfile'" );
+ error_log("existing dir '$destfile'");
}
} else {
- if (! copy( $file, $destfile )) {
+ if (!copy($file, $destfile)) {
return "409 Conflict";
}
}
@@ -880,7 +872,7 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
$query = "INSERT INTO properties SELECT ... FROM properties WHERE path = '" . $options['path'] . "'";
}
- return ($new && ! $existing_col) ? "201 Created" : "204 No Content";
+ return ($new && !$existing_col) ? "201 Created" : "204 No Content";
}
/**
@@ -889,7 +881,7 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
* @param array general parameter passing array
* @return bool true on success
*/
- function PROPPATCH (&$options)
+ public function PROPPATCH(&$options)
{
global $prefs, $tab;
@@ -897,20 +889,20 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
$path = $options["path"];
- $dir = dirname( $path ) . "/";
- $base = basename( $path );
+ $dir = dirname($path) . "/";
+ $base = basename($path);
foreach ($options["props"] as $key => $prop) {
if ($prop["ns"] == "DAV:") {
$options["props"][$key]['status'] = "403 Forbidden";
} else {
- if (isset( $prop["val"] )) {
+ if (isset($prop["val"])) {
$query = "REPLACE INTO properties SET path = '$options[path]', name = '$prop[name]', ns= '$prop[ns]', value = '$prop[val]'";
- error_log( $query );
+ error_log($query);
} else {
$query = "DELETE FROM properties WHERE path = '$options[path]' AND name = '$prop[name]' AND ns = '$prop[ns]'";
}
- mysql_query( $query );
+ mysql_query($query);
}
}
return "";
@@ -922,11 +914,12 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
* @param array general parameter passing array
* @return bool true on success
*/
- function LOCK (&$options)
+ public function LOCK(&$options)
{
- if (isset( $options["update"] )) { // Lock Update
+ if (isset($options["update"])) {
+ // Lock Update
$query = "UPDATE locks SET expires = " . (time() + 300);
- mysql_query( $query );
+ mysql_query($query);
if (mysql_affected_rows()) {
$options["timeout"] = 300; // 5min hardcoded
@@ -945,7 +938,7 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
, owner = '$options[owner]'
, expires = '$options[timeout]'
, exclusivelock = " . ($options['scope'] === "exclusive" ? "1" : "0");
- mysql_query( $query );
+ mysql_query($query);
return mysql_affected_rows() ? "200 OK" : "409 Conflict";
}
@@ -956,12 +949,12 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
* @param array general parameter passing array
* @return bool true on success
*/
- function UNLOCK (&$options)
+ public function UNLOCK(&$options)
{
$query = "DELETE FROM locks
WHERE path = '$options[path]'
AND token = '$options[token]'";
- mysql_query( $query );
+ mysql_query($query);
return mysql_affected_rows() ? "204 No Content" : "409 Conflict";
}
@@ -972,21 +965,21 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
* @param string resource path to check for locks
* @return bool true on success
*/
- function checkLock ($path)
+ public function checkLock($path)
{
$result = false;
$query = "SELECT owner, token, expires, exclusivelock
FROM locks
WHERE path = '$path' ";
- $res = mysql_query( $query );
+ $res = mysql_query($query);
if ($res) {
- $row = mysql_fetch_array( $res );
- mysql_free_result( $res );
+ $row = mysql_fetch_array($res);
+ mysql_free_result($res);
if ($row) {
- $result = array ("type" => "write","scope" => $row["exclusivelock"] ? "exclusive" : "shared","depth" => 0,"owner" => $row['owner'],"token" => $row['token'],"expires" => $row['expires']
+ $result = array("type" => "write", "scope" => $row["exclusivelock"] ? "exclusive" : "shared", "depth" => 0, "owner" => $row['owner'], "token" => $row['token'], "expires" => $row['expires']
);
}
}
@@ -1000,12 +993,10 @@ class ProcessMakerWebDav extends HTTP_WebDAV_Server
* @param void
* @return bool true on success
*/
- function create_database ()
+ public function create_database()
{
// TODO
return false;
}
-
}
-
-?>
+
\ No newline at end of file
diff --git a/workflow/engine/methods/processes/processes_Ajax.php b/workflow/engine/methods/processes/processes_Ajax.php
index e0a37c224..78ab9373e 100755
--- a/workflow/engine/methods/processes/processes_Ajax.php
+++ b/workflow/engine/methods/processes/processes_Ajax.php
@@ -1,4 +1,5 @@
userCanAccess('PM_FACTORY'))
- {
- case -2:
- G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
- G::header('location: ../login/login');
- die;
- break;
- case -1:
- G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
- G::header('location: ../login/login');
- die;
- break;
- }*/
+ /* global $RBAC;
+ switch ($RBAC->userCanAccess('PM_FACTORY'))
+ {
+ case -2:
+ G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
+ G::header('location: ../login/login');
+ die;
+ break;
+ case -1:
+ G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
+ G::header('location: ../login/login');
+ die;
+ break;
+ } */
//$oJSON = new Services_JSON();
- if (isset( $_REQUEST['data'] )) {
- $oData = Bootstrap::json_decode( stripslashes( $_REQUEST['data'] ) );
+ if (isset($_REQUEST['data'])) {
+ $oData = Bootstrap::json_decode(stripslashes($_REQUEST['data']));
//$oData = $oJSON->decode( stripslashes( $_REQUEST['data'] ) );
$sOutput = '';
$sTask = '';
}
//G::LoadClass( 'processMap' );
- $oProcessMap = new processMap( new DBConnection() );
+ $oProcessMap = new processMap(new DBConnection());
switch ($_REQUEST['action']) {
case 'load':
$_SESSION['PROCESS'] = $oData->uid;
if ($oData->ct) {
- $sOutput = $oProcessMap->load( $oData->uid, true, $_SESSION['APPLICATION'], - 1, $_SESSION['TASK'], $oData->ct );
+ $sOutput = $oProcessMap->load($oData->uid, true, $_SESSION['APPLICATION'], - 1, $_SESSION['TASK'], $oData->ct);
} else {
if ($oData->mode) {
- $sOutput = $oProcessMap->load( $oData->uid );
+ $sOutput = $oProcessMap->load($oData->uid);
} else {
if ($_SESSION['TASK'] != - 1) {
$taskUid = $_SESSION['TASK'];
} else {
- $c = new Criteria( 'workflow' );
+ $c = new Criteria('workflow');
$c->clearSelectColumns();
- $c->addSelectColumn( AppDelegationPeer::TAS_UID );
- $c->add( AppDelegationPeer::APP_UID, $_SESSION['APPLICATION'] );
- $c->add( AppDelegationPeer::DEL_INDEX, $_SESSION['INDEX'] );
- $oDataset = AppDelegationPeer::doSelectRS( $c );
- $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $c->addSelectColumn(AppDelegationPeer::TAS_UID);
+ $c->add(AppDelegationPeer::APP_UID, $_SESSION['APPLICATION']);
+ $c->add(AppDelegationPeer::DEL_INDEX, $_SESSION['INDEX']);
+ $oDataset = AppDelegationPeer::doSelectRS($c);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aData = $oDataset->getRow();
- $taskUid = isset( $aData['TAS_UID'] ) ? $aData['TAS_UID'] : - 1;
+ $taskUid = isset($aData['TAS_UID']) ? $aData['TAS_UID'] : - 1;
}
- $sOutput = $oProcessMap->load( $oData->uid, true, $_SESSION['APPLICATION'], $_SESSION['INDEX'], $taskUid );
+ $sOutput = $oProcessMap->load($oData->uid, true, $_SESSION['APPLICATION'], $_SESSION['INDEX'], $taskUid);
}
}
break;
case 'process_Edit':
- $oProcessMap->editProcess( $oData->pro_uid );
+ $oProcessMap->editProcess($oData->pro_uid);
break;
case 'process_Export':
include (PATH_METHODS . 'processes/processes_Export.php');
@@ -96,138 +97,138 @@ try {
break;
case 'webEntry_delete':
$form = $_REQUEST;
- unlink( PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $form['PRO_UID'] . PATH_SEP . $form['FILENAME'] );
- unlink( PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $form['PRO_UID'] . PATH_SEP . str_replace( ".php", "Post", $form['FILENAME'] ) . ".php" );
- $oProcessMap->webEntry( $_REQUEST['PRO_UID'] );
+ unlink(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $form['PRO_UID'] . PATH_SEP . $form['FILENAME']);
+ unlink(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $form['PRO_UID'] . PATH_SEP . str_replace(".php", "Post", $form['FILENAME']) . ".php");
+ $oProcessMap->webEntry($_REQUEST['PRO_UID']);
break;
case 'webEntry_new':
- $oProcessMap->webEntry_new( $oData->PRO_UID );
+ $oProcessMap->webEntry_new($oData->PRO_UID);
break;
case 'assignProcessUser':
- $oProcessMap->assignProcessUser( $oData->PRO_UID, $oData->USR_UID, $oData->TYPE_UID );
- G::LoadClass( 'processMap' );
+ $oProcessMap->assignProcessUser($oData->PRO_UID, $oData->USR_UID, $oData->TYPE_UID);
+ G::LoadClass('processMap');
$oProcessMap = new ProcessMap();
- $oProcessMap->listProcessesUser( $oData->PRO_UID );
+ $oProcessMap->listProcessesUser($oData->PRO_UID);
break;
case 'removeProcessUser':
- $oProcessMap->removeProcessUser( $oData->PU_UID );
+ $oProcessMap->removeProcessUser($oData->PU_UID);
foreach ($_SESSION['_DBArray']['data'] as $key => $value) {
if ($value['LA_PU_UID'] == $oData->PU_UID) {
- unset( $_SESSION['_DBArray']['data'][$key] );
+ unset($_SESSION['_DBArray']['data'][$key]);
break;
}
}
break;
case 'supervisorDynaforms':
- $oProcessMap->supervisorDynaforms( $oData->pro_uid );
+ $oProcessMap->supervisorDynaforms($oData->pro_uid);
break;
case 'supervisorInputs':
- $oProcessMap->supervisorInputs( $oData->pro_uid );
+ $oProcessMap->supervisorInputs($oData->pro_uid);
break;
case 'webEntry':
- $oProcessMap->webEntry( $oData->pro_uid );
+ $oProcessMap->webEntry($oData->pro_uid);
break;
case 'webEntry_Val_Assig':
include (PATH_METHODS . 'processes/webEntry_Val_Assig.php');
break;
case 'saveTitlePosition':
- $sOutput = $oProcessMap->saveTitlePosition( $oData->pro_uid, $oData->position->x, $oData->position->y );
+ $sOutput = $oProcessMap->saveTitlePosition($oData->pro_uid, $oData->position->x, $oData->position->y);
break;
case 'steps':
switch ($oData->option) {
case 1:
- $oProcessMap->steps( $oData->proUid, $oData->tasUid );
+ $oProcessMap->steps($oData->proUid, $oData->tasUid);
break;
case 2:
- $oProcessMap->stepsConditions( $oData->proUid, $oData->tasUid );
+ $oProcessMap->stepsConditions($oData->proUid, $oData->tasUid);
break;
case 3:
- $oProcessMap->stepsTriggers( $oData->proUid, $oData->tasUid );
+ $oProcessMap->stepsTriggers($oData->proUid, $oData->tasUid);
break;
}
break;
case 'users':
- $oProcessMap->users( $oData->pro_uid, $oData->tas_uid );
+ $oProcessMap->users($oData->pro_uid, $oData->tas_uid);
break;
case 'users_adhoc':
- $oProcessMap->users_adhoc( $oData->pro_uid, $oData->tas_uid );
+ $oProcessMap->users_adhoc($oData->pro_uid, $oData->tas_uid);
break;
case 'addTask':
- $sOutput = $oProcessMap->addTask( $oData->uid, $oData->position->x, $oData->position->y );
+ $sOutput = $oProcessMap->addTask($oData->uid, $oData->position->x, $oData->position->y);
break;
case 'addSubProcess':
- $sOutput = $oProcessMap->addSubProcess( $oData->uid, $oData->position->x, $oData->position->y );
+ $sOutput = $oProcessMap->addSubProcess($oData->uid, $oData->position->x, $oData->position->y);
break;
case 'taskColor':
- $oTask->taskColor( $oData->pro_uid, $oData->tas_uid );
+ $oTask->taskColor($oData->pro_uid, $oData->tas_uid);
break;
case 'addTaskHidden':
- $sOutput = $oProcessMap->addTaskHidden( $oData->uid, $oData->position->x, $oData->position->y );
+ $sOutput = $oProcessMap->addTaskHidden($oData->uid, $oData->position->x, $oData->position->y);
break;
case 'editTaskProperties':
- $oProcessMap->editTaskProperties( $oData->uid, (isset( $oData->iForm ) ? $oData->iForm : 1), $oData->index );
+ $oProcessMap->editTaskProperties($oData->uid, (isset($oData->iForm) ? $oData->iForm : 1), $oData->index);
break;
case 'saveTaskPosition':
- $sOutput = $oProcessMap->saveTaskPosition( $oData->uid, $oData->position->x, $oData->position->y );
+ $sOutput = $oProcessMap->saveTaskPosition($oData->uid, $oData->position->x, $oData->position->y);
break;
case 'deleteTask':
- $sOutput = $oProcessMap->deleteTask( $oData->tas_uid );
+ $sOutput = $oProcessMap->deleteTask($oData->tas_uid);
break;
case 'addGuide':
- $sOutput = $oProcessMap->addGuide( $oData->uid, $oData->position, $oData->direction );
+ $sOutput = $oProcessMap->addGuide($oData->uid, $oData->position, $oData->direction);
break;
case 'saveGuidePosition':
- $sOutput = $oProcessMap->saveGuidePosition( $oData->uid, $oData->position, $oData->direction );
+ $sOutput = $oProcessMap->saveGuidePosition($oData->uid, $oData->position, $oData->direction);
break;
case 'deleteGuide':
- $sOutput = $oProcessMap->deleteGuide( $oData->uid );
+ $sOutput = $oProcessMap->deleteGuide($oData->uid);
break;
case 'deleteGuides':
- $sOutput = $oProcessMap->deleteGuides( $oData->pro_uid );
+ $sOutput = $oProcessMap->deleteGuides($oData->pro_uid);
break;
case 'addText':
- $sOutput = $oProcessMap->addText( $oData->uid, $oData->label, $oData->position->x, $oData->position->y );
+ $sOutput = $oProcessMap->addText($oData->uid, $oData->label, $oData->position->x, $oData->position->y);
break;
case 'updateText':
- $sOutput = $oProcessMap->updateText( $oData->uid, $oData->label );
+ $sOutput = $oProcessMap->updateText($oData->uid, $oData->label);
break;
case 'saveTextPosition':
- $sOutput = $oProcessMap->saveTextPosition( $oData->uid, $oData->position->x, $oData->position->y );
+ $sOutput = $oProcessMap->saveTextPosition($oData->uid, $oData->position->x, $oData->position->y);
break;
case 'deleteText':
- $sOutput = $oProcessMap->deleteText( $oData->uid );
+ $sOutput = $oProcessMap->deleteText($oData->uid);
break;
case 'dynaforms':
- $oProcessMap->dynaformsList( $oData->pro_uid );
+ $oProcessMap->dynaformsList($oData->pro_uid);
break;
case 'inputs':
- $oProcessMap->inputdocsList( $oData->pro_uid );
+ $oProcessMap->inputdocsList($oData->pro_uid);
break;
case 'outputs':
- $oProcessMap->outputdocsList( $oData->pro_uid );
+ $oProcessMap->outputdocsList($oData->pro_uid);
break;
case 'triggers':
- $oProcessMap->triggersList( $oData->pro_uid );
+ $oProcessMap->triggersList($oData->pro_uid);
break;
case 'case_scheduler':
- if (isset( $_REQUEST['PRO_UID'] )) {
- $oProcessMap->caseSchedulerList( $_REQUEST['PRO_UID'] );
+ if (isset($_REQUEST['PRO_UID'])) {
+ $oProcessMap->caseSchedulerList($_REQUEST['PRO_UID']);
}
break;
case 'log_case_scheduler':
- if (isset( $_REQUEST['PRO_UID'] )) {
- $oProcessMap->logCaseSchedulerList( $_REQUEST['PRO_UID'] );
+ if (isset($_REQUEST['PRO_UID'])) {
+ $oProcessMap->logCaseSchedulerList($_REQUEST['PRO_UID']);
}
break;
case 'messages':
- $oProcessMap->messagesList( $oData->pro_uid );
+ $oProcessMap->messagesList($oData->pro_uid);
break;
case 'reportTables':
- $oProcessMap->reportTablesList( $oData->pro_uid );
+ $oProcessMap->reportTablesList($oData->pro_uid);
break;
case 'derivations':
- if (! isset( $oData->type )) {
- $oProcessMap->currentPattern( $oData->pro_uid, $oData->tas_uid );
+ if (!isset($oData->type)) {
+ $oProcessMap->currentPattern($oData->pro_uid, $oData->tas_uid);
} else {
switch ($oData->type) {
case 0:
@@ -252,7 +253,7 @@ try {
$oData->type = 'DISCRIMINATOR';
break;
}
- $oProcessMap->newPattern( $oData->pro_uid, $oData->tas_uid, $oData->next_task, $oData->type );
+ $oProcessMap->newPattern($oData->pro_uid, $oData->tas_uid, $oData->next_task, $oData->type);
}
break;
case 'saveNewPattern':
@@ -280,90 +281,90 @@ try {
break;
}
if (($oData->type != 0) && ($oData->type != 5) && ($oData->type != 8)) {
- if ($oProcessMap->getNumberOfRoutes( $oData->pro_uid, $oData->tas_uid, $oData->next_task, $sType ) > 0) {
+ if ($oProcessMap->getNumberOfRoutes($oData->pro_uid, $oData->tas_uid, $oData->next_task, $sType) > 0) {
die();
}
- unset( $aRow );
+ unset($aRow);
}
if (($oData->delete) || ($oData->type == 0) || ($oData->type == 5) || ($oData->type == 8)) {
- G::LoadClass( 'tasks' );
+ G::LoadClass('tasks');
$oTasks = new Tasks();
- $oTasks->deleteAllRoutesOfTask( $oData->pro_uid, $oData->tas_uid );
- $oTasks->deleteAllGatewayOfTask( $oData->pro_uid, $oData->tas_uid );
+ $oTasks->deleteAllRoutesOfTask($oData->pro_uid, $oData->tas_uid);
+ $oTasks->deleteAllGatewayOfTask($oData->pro_uid, $oData->tas_uid);
}
- $oProcessMap->saveNewPattern( $oData->pro_uid, $oData->tas_uid, $oData->next_task, $sType, $oData->delete );
+ $oProcessMap->saveNewPattern($oData->pro_uid, $oData->tas_uid, $oData->next_task, $sType, $oData->delete);
break;
case 'deleteAllRoutes':
- G::LoadClass( 'tasks' );
+ G::LoadClass('tasks');
$oTasks = new Tasks();
- $oTasks->deleteAllRoutesOfTask( $oData->pro_uid, $oData->tas_uid );
+ $oTasks->deleteAllRoutesOfTask($oData->pro_uid, $oData->tas_uid);
break;
case 'objectPermissions':
- $oProcessMap->objectsPermissionsList( $oData->pro_uid );
+ $oProcessMap->objectsPermissionsList($oData->pro_uid);
break;
case 'newObjectPermission':
- $oProcessMap->newObjectPermission( $oData->pro_uid );
+ $oProcessMap->newObjectPermission($oData->pro_uid);
break;
case 'editObjectPermission':
// we also need the process uid variable for the function.
- $oProcessMap->editObjectPermission( $oData->op_uid, $oData->pro_uid );
+ $oProcessMap->editObjectPermission($oData->op_uid, $oData->pro_uid);
break;
case 'caseTracker':
- $oProcessMap->caseTracker( $oData->pro_uid );
+ $oProcessMap->caseTracker($oData->pro_uid);
break;
case 'caseTrackerObjects':
- $oProcessMap->caseTrackerObjects( $oData->pro_uid );
+ $oProcessMap->caseTrackerObjects($oData->pro_uid);
break;
case 'processFilesManager':
$_SESSION['PFMDirectory'] = '';
- $oProcessMap->processFilesManager( $oData->pro_uid );
+ $oProcessMap->processFilesManager($oData->pro_uid);
break;
case 'exploreDirectory':
$_SESSION["PFMDirectory"] = $oData->main_directory;
- $oProcessMap->exploreDirectory( $oData->pro_uid, $oData->main_directory, $oData->directory );
+ $oProcessMap->exploreDirectory($oData->pro_uid, $oData->main_directory, $oData->directory);
break;
case 'deleteFile':
- $oProcessMap->deleteFile( $oData->pro_uid, $oData->main_directory, $oData->directory, $oData->file );
+ $oProcessMap->deleteFile($oData->pro_uid, $oData->main_directory, $oData->directory, $oData->file);
break;
case 'deleteDirectory':
- $oProcessMap->deleteDirectory( $oData->pro_uid, $oData->main_directory, $oData->directory, $oData->dir_to_delete );
+ $oProcessMap->deleteDirectory($oData->pro_uid, $oData->main_directory, $oData->directory, $oData->dir_to_delete);
break;
case 'downloadFile':
- $oProcessMap->downloadFile( $oData->pro_uid, $oData->main_directory, $oData->directory, $oData->file );
+ $oProcessMap->downloadFile($oData->pro_uid, $oData->main_directory, $oData->directory, $oData->file);
break;
case 'deleteSubProcess':
- $sOutput = $oProcessMap->deleteSubProcess( $oData->pro_uid, $oData->tas_uid );
+ $sOutput = $oProcessMap->deleteSubProcess($oData->pro_uid, $oData->tas_uid);
break;
case 'subProcess_Properties':
- $oProcessMap->subProcess_Properties( $oData->pro_uid, $oData->tas_uid, $oData->index );
+ $oProcessMap->subProcess_Properties($oData->pro_uid, $oData->tas_uid, $oData->index);
break;
case 'showDetailsPMDWL':
- G::LoadClass( 'processes' );
+ G::LoadClass('processes');
$oProcesses = new Processes();
$oProcesses->ws_open_public();
- $aFields = get_object_vars( $oProcesses->ws_processGetData( $oData->pro_uid ) );
+ $aFields = get_object_vars($oProcesses->ws_processGetData($oData->pro_uid));
- $aFields['description'] = nl2br( $aFields['description'] );
- $aFields['installSteps'] = nl2br( $aFields['installSteps'] );
+ $aFields['description'] = nl2br($aFields['description']);
+ $aFields['installSteps'] = nl2br($aFields['installSteps']);
switch ($aFields['privacy']) {
case 'FREE':
- $aFields['link_label'] = G::LoadTranslation( 'ID_DOWNLOAD' );
+ $aFields['link_label'] = G::LoadTranslation('ID_DOWNLOAD');
$aFields['link_href'] = '../processes/downloadPML?id=' . $oData->pro_uid . '&s=' . $sessionId;
break;
case 'PUBLIC':
require_once 'classes/model/Configuration.php';
- $oCriteria = new Criteria( 'workflow' );
- $oCriteria->addSelectColumn( ConfigurationPeer::CFG_VALUE );
- $oCriteria->add( ConfigurationPeer::CFG_UID, 'REGISTER_INFORMATION' );
- $oCriteria->add( ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED'] );
- if (ConfigurationPeer::doCount( $oCriteria ) > 0) {
- $oDataset = ConfigurationPeer::doSelectRS( $oCriteria );
- $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oCriteria = new Criteria('workflow');
+ $oCriteria->addSelectColumn(ConfigurationPeer::CFG_VALUE);
+ $oCriteria->add(ConfigurationPeer::CFG_UID, 'REGISTER_INFORMATION');
+ $oCriteria->add(ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED']);
+ if (ConfigurationPeer::doCount($oCriteria) > 0) {
+ $oDataset = ConfigurationPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aRow = $oDataset->getRow();
- $aRI = unserialize( $aRow['CFG_VALUE'] );
+ $aRI = unserialize($aRow['CFG_VALUE']);
try {
- if ($oProcesses->ws_open( $aRI['u'], $aRI['p'] ) == 1) {
+ if ($oProcesses->ws_open($aRI['u'], $aRI['p']) == 1) {
$bExists = true;
} else {
$bExists = false;
@@ -372,36 +373,36 @@ try {
$bExists = false;
}
if ($bExists) {
- $aFields['link_label'] = G::LoadTranslation( 'ID_DOWNLOAD' );
+ $aFields['link_label'] = G::LoadTranslation('ID_DOWNLOAD');
$aFields['link_href'] = '../processes/downloadPML?id=' . $oData->pro_uid . '&s=' . $sessionId;
} else {
- $aFields['link_label'] = G::LoadTranslation( 'ID_NEED_REGISTER' );
+ $aFields['link_label'] = G::LoadTranslation('ID_NEED_REGISTER');
$aFields['link_href'] = "javascript:registerPML('" . $oData->pro_uid . "');";
}
} else {
- $aFields['link_label'] = G::LoadTranslation( 'ID_NEED_REGISTER' );
+ $aFields['link_label'] = G::LoadTranslation('ID_NEED_REGISTER');
$aFields['link_href'] = "javascript:registerPML('" . $oData->pro_uid . "');";
}
break;
}
$G_PUBLISH = new Publisher();
- $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'processes/objectpmView', '', $aFields, '' );
- G::RenderPage( 'publish', 'raw' );
+ $G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/objectpmView', '', $aFields, '');
+ G::RenderPage('publish', 'raw');
break;
case 'registerPML':
- $aFields = array ();
+ $aFields = array();
$aFields['pro_uid'] = $oData->pro_uid;
$aFields['link_create_account'] = PML_SERVER;
$G_PUBLISH = new Publisher();
- $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'processes/registerPML', '', $aFields, '' );
- G::RenderPage( 'publish', 'raw' );
+ $G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/registerPML', '', $aFields, '');
+ G::RenderPage('publish', 'raw');
break;
case 'loginPML':
- G::LoadClass( 'processes' );
+ G::LoadClass('processes');
//G::LoadThirdParty( 'pear/json', 'class.json' );
$oProcesses = new Processes();
try {
- if ($oProcesses->ws_open( $oData->u, $oData->p ) == 1) {
+ if ($oProcesses->ws_open($oData->u, $oData->p) == 1) {
$bExists = true;
} else {
$bExists = false;
@@ -413,15 +414,15 @@ try {
if ($bExists) {
require_once 'classes/model/Configuration.php';
$oConfiguration = new Configuration();
- $oConfiguration->create( array ('CFG_UID' => 'REGISTER_INFORMATION','OBJ_UID' => '','CFG_VALUE' => serialize( array ('u' => $oData->u,'p' => $oData->p
- ) ),'PRO_UID' => '','USR_UID' => $_SESSION['USER_LOGGED'],'APP_UID' => ''
- ) );
- $oResponse->sLabel = G::LoadTranslation( 'ID_DOWNLOAD' );
+ $oConfiguration->create(array('CFG_UID' => 'REGISTER_INFORMATION', 'OBJ_UID' => '', 'CFG_VALUE' => serialize(array('u' => $oData->u, 'p' => $oData->p
+ )), 'PRO_UID' => '', 'USR_UID' => $_SESSION['USER_LOGGED'], 'APP_UID' => ''
+ ));
+ $oResponse->sLabel = G::LoadTranslation('ID_DOWNLOAD');
$oResponse->sLink = '../processes/downloadPML?id=' . $oData->pro_uid . '&s=' . $sessionId;
}
$oResponse->bExists = $bExists;
//$oJSON = new Services_JSON();
- echo Bootstrap::json_encode( $oResponse );
+ echo Bootstrap::json_encode($oResponse);
break;
case 'editFile':
//echo $_REQUEST['filename'];
@@ -429,7 +430,7 @@ try {
$G_PUBLISH = new Publisher();
///-- $sDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename'];
$sDir = "";
- if (isset( $_SESSION['PFMDirectory'] )) {
+ if (isset($_SESSION['PFMDirectory'])) {
$sDir = $_SESSION['PFMDirectory'];
}
switch ($sDir) {
@@ -443,58 +444,58 @@ try {
$sDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename'];
break;
}
- $fcontent = file_get_contents( $sDirectory );
- $extion = explode( ".", $_REQUEST['filename'] );
-// $oHeadPublisher = &headPublisher::getSingleton();
-// $oHeadPublisher->clearScripts();
-// $oHeadPublisher->addScriptFile( '/js/tinymce/jscripts/tiny_mce/tiny_mce.js' );
-// $jscriptCode .= '
-//
-//// var tmpArrToStr = Array.prototype.toStr;
-//// var tmpObjToStr = Object.prototype.toStr;
-//// var tmpObjConcat = Object.prototype.concat;
-//// var tmpObjGetByKey = Object.prototype.get_by_key;
-//// var tmpObjExpand = Object.prototype.expand;
-//// var tmpObjSetParent = Object.prototype.setParent;
-//// var tmpObjIsSetKey = Object.prototype.isset_key;
-////
-//// delete Array.prototype.toStr;
-//// delete Object.prototype.toStr;
-//// delete Object.prototype.concat;
-//// delete Object.prototype.get_by_key;
-//// delete Object.prototype.expand;
-//// delete Object.prototype.setParent;
-//// delete Object.prototype.isset_key;
-//// alert ("hi");
-//// document.body.onload = function(){
-// alert ("hello");
-// tinyMCE.baseURL = "/js/tinymce/jscripts/tiny_mce";
-// tinyMCE.init({
-// theme : "advanced",
-// plugins : "fullpage",
-// mode : "specific_textareas",
-// editor_selector : "tmceEditor",
-// width : "640",
-// height : "300",
-// theme_advanced_buttons3_add : "fullpage"
-// });
-//// alert ("goodbye");
-//// }
-// ';
-// $oHeadPublisher->addScriptCode($jscriptCode);
+ $fcontent = file_get_contents($sDirectory);
+ $extion = explode(".", $_REQUEST['filename']);
+ // $oHeadPublisher = &headPublisher::getSingleton();
+ // $oHeadPublisher->clearScripts();
+ // $oHeadPublisher->addScriptFile( '/js/tinymce/jscripts/tiny_mce/tiny_mce.js' );
+ // $jscriptCode .= '
+ //
+ //// var tmpArrToStr = Array.prototype.toStr;
+ //// var tmpObjToStr = Object.prototype.toStr;
+ //// var tmpObjConcat = Object.prototype.concat;
+ //// var tmpObjGetByKey = Object.prototype.get_by_key;
+ //// var tmpObjExpand = Object.prototype.expand;
+ //// var tmpObjSetParent = Object.prototype.setParent;
+ //// var tmpObjIsSetKey = Object.prototype.isset_key;
+ ////
+ //// delete Array.prototype.toStr;
+ //// delete Object.prototype.toStr;
+ //// delete Object.prototype.concat;
+ //// delete Object.prototype.get_by_key;
+ //// delete Object.prototype.expand;
+ //// delete Object.prototype.setParent;
+ //// delete Object.prototype.isset_key;
+ //// alert ("hi");
+ //// document.body.onload = function(){
+ // alert ("hello");
+ // tinyMCE.baseURL = "/js/tinymce/jscripts/tiny_mce";
+ // tinyMCE.init({
+ // theme : "advanced",
+ // plugins : "fullpage",
+ // mode : "specific_textareas",
+ // editor_selector : "tmceEditor",
+ // width : "640",
+ // height : "300",
+ // theme_advanced_buttons3_add : "fullpage"
+ // });
+ //// alert ("goodbye");
+ //// }
+ // ';
+ // $oHeadPublisher->addScriptCode($jscriptCode);
$_REQUEST['fcontent'] = $fcontent;
//if($extion[count($extion)-1]=='html' || $extion[count($extion)-1]=='txt'){
- $aData = Array ( 'pro_uid' => $_REQUEST['pro_uid'],'fcontent' => $fcontent,'filename' => $_REQUEST['filename'] );
- $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'processes/processes_FileEdit', '', $aData );
- G::RenderPage( 'publish', 'raw' );
-// $G_PUBLISH->AddContent( 'view', 'processes/processesFileEditEmail' );
-// G::RenderPage( 'publish', 'blank' );
+ $aData = Array('pro_uid' => $_REQUEST['pro_uid'], 'fcontent' => $fcontent, 'filename' => $_REQUEST['filename']);
+ $G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_FileEdit', '', $aData);
+ G::RenderPage('publish', 'raw');
+ // $G_PUBLISH->AddContent( 'view', 'processes/processesFileEditEmail' );
+ // G::RenderPage( 'publish', 'blank' );
break;
case 'saveFile':
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
$sDir = "";
- if (isset( $_REQUEST['MAIN_DIRECTORY'] )) {
+ if (isset($_REQUEST['MAIN_DIRECTORY'])) {
$sDir = $_REQUEST['MAIN_DIRECTORY'];
}
@@ -510,77 +511,77 @@ try {
break;
}
- $fp = fopen( $sDirectory, 'w' );
- $content = stripslashes( $_REQUEST['fcontent'] );
- $content = str_replace( "@amp@", "&", $content );
- $content = base64_decode( $content );
- fwrite( $fp, $content );
- fclose( $fp );
+ $fp = fopen($sDirectory, 'w');
+ $content = stripslashes($_REQUEST['fcontent']);
+ $content = str_replace("@amp@", "&", $content);
+ $content = base64_decode($content);
+ fwrite($fp, $content);
+ fclose($fp);
echo 'saved: ' . $sDirectory;
break;
case 'events':
- $oProcessMap->eventsList( $oData->pro_uid, $oData->type );
+ $oProcessMap->eventsList($oData->pro_uid, $oData->type);
break;
- /**
- * returns an array with all Dynaforms Fields
- */
+ /**
+ * returns an array with all Dynaforms Fields
+ */
case 'getVariableList':
G::LoadClass('xmlfield_InputPM');
- $proUid= isset( $_REQUEST['process'] )?$_REQUEST['process']:'';
- $queryText= isset( $_REQUEST['queryText'] )?$_REQUEST['queryText']:'';
- if ($_REQUEST['type']=='system'){
+ $proUid = isset($_REQUEST['process']) ? $_REQUEST['process'] : '';
+ $queryText = isset($_REQUEST['queryText']) ? $_REQUEST['queryText'] : '';
+ if ($_REQUEST['type'] == 'system') {
$isSystem = true;
} else {
$isSystem = false;
}
- if ($_REQUEST['type']=='all'){
- $aFields = getDynaformsVars( $proUid );
+ if ($_REQUEST['type'] == 'all') {
+ $aFields = getDynaformsVars($proUid);
} else {
- $aFields = getDynaformsVars( $proUid, $isSystem, isset( $_REQUEST['bIncMulSelFields'] ) ? $_REQUEST['bIncMulSelFields'] : 1);
+ $aFields = getDynaformsVars($proUid, $isSystem, isset($_REQUEST['bIncMulSelFields']) ? $_REQUEST['bIncMulSelFields'] : 1);
}
$aVariables = array();
- foreach ($aFields as $key => $value){
- if($queryText!='') {
- if(stristr($aFields[$key]['sName'], $queryText)){
+ foreach ($aFields as $key => $value) {
+ if ($queryText != '') {
+ if (stristr($aFields[$key]['sName'], $queryText)) {
$aVariables[] = $aFields[$key];
}
} else {
$aVariables[] = $aFields[$key];
}
}
- echo Bootstrap::json_encode( $aVariables );
+ echo Bootstrap::json_encode($aVariables);
break;
- /**
- * returns the prefix mean
- *
- */
+ /**
+ * returns the prefix mean
+ *
+ */
case 'getVariablePrefix':
- $_REQUEST['prefix'] = $_REQUEST['prefix']!=null?$_REQUEST['prefix']:'ID_TO_STRING';
+ $_REQUEST['prefix'] = $_REQUEST['prefix'] != null ? $_REQUEST['prefix'] : 'ID_TO_STRING';
echo G::LoadTranslation($_REQUEST['prefix']);
break;
- /**
- * return an array with all Variables of Grid type
- */
+ /**
+ * return an array with all Variables of Grid type
+ */
case 'getGridList':
G::LoadClass('xmlfield_InputPM');
- $proUid= isset( $_REQUEST['PRO_UID'] )?$_REQUEST['PRO_UID']:'';
+ $proUid = isset($_REQUEST['PRO_UID']) ? $_REQUEST['PRO_UID'] : '';
- $aFields = getGridsVars( $proUid );
+ $aFields = getGridsVars($proUid);
$aVariables = array();
- foreach ($aFields as $key => $value){
+ foreach ($aFields as $key => $value) {
$aVariables[] = $aFields[$key];
}
- echo Bootstrap::json_encode( $aVariables );
+ echo Bootstrap::json_encode($aVariables);
break;
- /**
- * return an array with all Grid Variables according to Grid
- */
+ /**
+ * return an array with all Grid Variables according to Grid
+ */
case 'getVariableGrid':
G::LoadClass('xmlfield_InputPM');
- $proUid= isset( $_REQUEST['PRO_UID'] )?$_REQUEST['PRO_UID']:'';
- $dynUid= isset( $_REQUEST['DYN_UID'] )?$_REQUEST['DYN_UID']:'';
+ $proUid = isset($_REQUEST['PRO_UID']) ? $_REQUEST['PRO_UID'] : '';
+ $dynUid = isset($_REQUEST['DYN_UID']) ? $_REQUEST['DYN_UID'] : '';
$aFields = getVarsGrid($proUid, $dynUid);
@@ -590,74 +591,74 @@ try {
$aVariables[] = $key;
}
- echo Bootstrap::json_encode( $aVariables );
+ echo Bootstrap::json_encode($aVariables);
break;
case 'getDynaformFieldList':
- G::LoadClass( 'dynaformhandler' );
- $dynaformFields = array ();
- $resultArray = array ();
- $proUid= isset( $_REQUEST['PRO_UID'] )?$_REQUEST['PRO_UID']:'';
- $dynUid= isset( $_REQUEST['DYN_UID'] )?$_REQUEST['DYN_UID']:'';
- if (is_file( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'.$dynUid. '.xml' ) && filesize( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'. $dynUid .'.xml' ) > 0) {
- $dyn = new dynaFormHandler( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/' .$proUid. '/' . $dynUid .'.xml' );
+ G::LoadClass('dynaformhandler');
+ $dynaformFields = array();
+ $resultArray = array();
+ $proUid = isset($_REQUEST['PRO_UID']) ? $_REQUEST['PRO_UID'] : '';
+ $dynUid = isset($_REQUEST['DYN_UID']) ? $_REQUEST['DYN_UID'] : '';
+ if (is_file(PATH_DATA . '/sites/' . SYS_SYS . '/xmlForms/' . $proUid . '/' . $dynUid . '.xml') && filesize(PATH_DATA . '/sites/' . SYS_SYS . '/xmlForms/' . $proUid . '/' . $dynUid . '.xml') > 0) {
+ $dyn = new dynaFormHandler(PATH_DATA . '/sites/' . SYS_SYS . '/xmlForms/' . $proUid . '/' . $dynUid . '.xml');
$dynaformFields[] = $dyn->getFields();
}
foreach ($dynaformFields as $aDynFormFields) {
foreach ($aDynFormFields as $field) {
- $resultArray[] = array ("id"=>$field->nodeName, "name"=>$field->nodeName );
+ $resultArray[] = array("id" => $field->nodeName, "name" => $field->nodeName);
}
}
- echo Bootstrap::json_encode( $resultArray );
-// var_dump($resultArray);
+ echo Bootstrap::json_encode($resultArray);
+ // var_dump($resultArray);
break;
/*
- case 'saveFile':
- global $G_PUBLISH;
- $G_PUBLISH = new Publisher();
- $sDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename'];
+ case 'saveFile':
+ global $G_PUBLISH;
+ $G_PUBLISH = new Publisher();
+ $sDirectory = PATH_DATA_MAILTEMPLATES . $_REQUEST['pro_uid'] . PATH_SEP . $_REQUEST['filename'];
- $fp = fopen($sDirectory, 'w');
- $content = stripslashes($_REQUEST['fcontent']);
- $content = str_replace("@amp@", "&", $content);
- fwrite($fp, $content);
- fclose($fp);
- echo 'saved: '. $sDirectory;
- break;
- */
+ $fp = fopen($sDirectory, 'w');
+ $content = stripslashes($_REQUEST['fcontent']);
+ $content = str_replace("@amp@", "&", $content);
+ fwrite($fp, $content);
+ fclose($fp);
+ echo 'saved: '. $sDirectory;
+ break;
+ */
case 'emptyFileOptions':
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
- $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'processes/processes_FileEditCreateEmpty', '' );
- G::RenderPage( 'publish', 'raw' );
+ $G_PUBLISH->AddContent('xmlform', 'xmlform', 'processes/processes_FileEditCreateEmpty', '');
+ G::RenderPage('publish', 'raw');
break;
case "taskCases":
require_once 'classes/model/AppDelegation.php';
- $criteria = new Criteria( 'workflow' );
- $criteria->addSelectColumn( AppDelegationPeer::APP_UID );
- $criteria->addSelectColumn( AppDelegationPeer::DEL_INDEX );
- $criteria->addSelectColumn( AppDelegationPeer::TAS_UID );
- $criteria->add( AppDelegationPeer::TAS_UID, $oData->task_uid );
- $criteria->add( AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN' );
- $casesNumRec = AppDelegationPeer::doCount( $criteria );
+ $criteria = new Criteria('workflow');
+ $criteria->addSelectColumn(AppDelegationPeer::APP_UID);
+ $criteria->addSelectColumn(AppDelegationPeer::DEL_INDEX);
+ $criteria->addSelectColumn(AppDelegationPeer::TAS_UID);
+ $criteria->add(AppDelegationPeer::TAS_UID, $oData->task_uid);
+ $criteria->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN');
+ $casesNumRec = AppDelegationPeer::doCount($criteria);
if ($casesNumRec == 0) {
require_once 'classes/model/AppDelay.php';
- $criteria = new Criteria( 'workflow' );
- $criteria->addSelectColumn( AppDelayPeer::APP_UID );
- $criteria->addSelectColumn( AppDelayPeer::APP_DEL_INDEX );
- $criteria->add( AppDelayPeer::PRO_UID, $oData->pro_uid );
- $criteria->add( AppDelayPeer::APP_TYPE, 'PAUSE' );
- $criteria->add( AppDelayPeer::APP_DISABLE_ACTION_DATE, null, Criteria::ISNULL );
- $dataset = AppDelayPeer::doSelectRS( $criteria );
+ $criteria = new Criteria('workflow');
+ $criteria->addSelectColumn(AppDelayPeer::APP_UID);
+ $criteria->addSelectColumn(AppDelayPeer::APP_DEL_INDEX);
+ $criteria->add(AppDelayPeer::PRO_UID, $oData->pro_uid);
+ $criteria->add(AppDelayPeer::APP_TYPE, 'PAUSE');
+ $criteria->add(AppDelayPeer::APP_DISABLE_ACTION_DATE, null, Criteria::ISNULL);
+ $dataset = AppDelayPeer::doSelectRS($criteria);
if ($dataset->getRecordCount() > 0) {
- $dataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataset->next();
while ($row = $dataset->getRow()) {
- $criteria = new Criteria( 'workflow' );
- $criteria->addSelectColumn( AppDelegationPeer::TAS_UID );
- $criteria->add( AppDelegationPeer::APP_UID, $row['APP_UID'] );
- $criteria->add( AppDelegationPeer::DEL_INDEX, $row['APP_DEL_INDEX'] );
- $criteria->add( AppDelegationPeer::TAS_UID, $oData->task_uid );
- $casesNumRec += AppDelegationPeer::doCount( $criteria );
+ $criteria = new Criteria('workflow');
+ $criteria->addSelectColumn(AppDelegationPeer::TAS_UID);
+ $criteria->add(AppDelegationPeer::APP_UID, $row['APP_UID']);
+ $criteria->add(AppDelegationPeer::DEL_INDEX, $row['APP_DEL_INDEX']);
+ $criteria->add(AppDelegationPeer::TAS_UID, $oData->task_uid);
+ $casesNumRec += AppDelegationPeer::doCount($criteria);
$dataset->next();
}
}
@@ -665,13 +666,13 @@ try {
$response = new stdclass();
$response->casesNumRec = $casesNumRec;
//$json = new Services_JSON();
- $sOutput = Bootstrap::json_encode( $response );
+ $sOutput = Bootstrap::json_encode($response);
break;
}
- if (isset( $sOutput )) {
- die( $sOutput );
+ if (isset($sOutput)) {
+ die($sOutput);
}
} catch (Exception $oException) {
- die( $oException->getMessage() . "\n" . $oException->getTraceAsString() );
+ die($oException->getMessage() . "\n" . $oException->getTraceAsString());
}
diff --git a/workflow/engine/methods/users/usersAjax.php b/workflow/engine/methods/users/usersAjax.php
index e21c5097f..11009ad94 100644
--- a/workflow/engine/methods/users/usersAjax.php
+++ b/workflow/engine/methods/users/usersAjax.php
@@ -6,134 +6,124 @@ switch ($_POST['action']) {
case 'countryList':
require_once ("classes/model/IsoCountry.php");
$c = new Criteria();
- $c->add( IsoCountryPeer::IC_UID, NULL, Criteria::ISNOTNULL );
+ $c->add(IsoCountryPeer::IC_UID, null, Criteria::ISNOTNULL);
- $countries = IsoCountryPeer::doSelect( $c );
+ $countries = IsoCountryPeer::doSelect($c);
foreach ($countries as $rowid => $row) {
- $oData[] = Array ('IC_UID' => $row->getICUid(),'IC_NAME' => $row->getICName()
- );
+ $oData[] = Array('IC_UID' => $row->getICUid(), 'IC_NAME' => $row->getICName());
}
- print (G::json_encode( $oData )) ;
+ print (G::json_encode($oData));
break;
-
case 'stateList':
require_once ("classes/model/IsoSubdivision.php");
$c = new Criteria();
$country = $_POST['IC_UID'];
- $c->add( IsoSubdivisionPeer::IC_UID, $country, Criteria::EQUAL );
- $locations = IsoSubdivisionPeer::doSelect( $c );
+ $c->add(IsoSubdivisionPeer::IC_UID, $country, Criteria::EQUAL);
+ $locations = IsoSubdivisionPeer::doSelect($c);
- $oData = Array ();
+ $oData = Array();
foreach ($locations as $rowid => $row) {
- if (($row->getISUid() != '') && ($row->getISName() != ''))
- $oData[] = Array ('IS_UID' => $row->getISUid(),'IS_NAME' => $row->getISName()
- );
+ if (($row->getISUid() != '') && ($row->getISName() != '')) {
+ $oData[] = Array('IS_UID' => $row->getISUid(), 'IS_NAME' => $row->getISName());
+ }
}
- print (G::json_encode( $oData )) ;
+ print (G::json_encode($oData));
break;
-
case 'locationList':
require_once ("classes/model/IsoLocation.php");
$c = new Criteria();
$country = $_POST['IC_UID'];
$state = $_POST['IS_UID'];
- $c->add( IsoLocationPeer::IC_UID, $country, Criteria::EQUAL );
- $c->add( IsoLocationPeer::IS_UID, $state, Criteria::EQUAL );
- $locations = IsoLocationPeer::doSelect( $c );
+ $c->add(IsoLocationPeer::IC_UID, $country, Criteria::EQUAL);
+ $c->add(IsoLocationPeer::IS_UID, $state, Criteria::EQUAL);
+ $locations = IsoLocationPeer::doSelect($c);
- $oData = Array ();
+ $oData = Array();
foreach ($locations as $rowid => $row) {
- if (($row->getILUid() != '') && ($row->getILName() != ''))
- $oData[] = Array ('IL_UID' => $row->getILUid(),'IL_NAME' => $row->getILName()
- );
+ if (($row->getILUid() != '') && ($row->getILName() != '')) {
+ $oData[] = Array('IL_UID' => $row->getILUid(), 'IL_NAME' => $row->getILName());
+ }
}
- print (G::json_encode( $oData )) ;
+ print (G::json_encode($oData));
break;
case 'usersList':
require_once 'classes/model/Users.php';
$oCriteria = new Criteria();
- $oCriteria->addSelectColumn( UsersPeer::USR_UID );
- $oCriteria->addSelectColumn( UsersPeer::USR_USERNAME );
- $oCriteria->addSelectColumn( UsersPeer::USR_FIRSTNAME );
- $oCriteria->addSelectColumn( UsersPeer::USR_LASTNAME );
- $oCriteria->addSelectColumn( UsersPeer::USR_EMAIL );
- $oCriteria->add( UsersPeer::USR_STATUS, array ('ACTIVE','VACATION'
- ), Criteria::IN );
- if (isset( $_POST['USR_UID'] )) {
- $oCriteria->add( UsersPeer::USR_UID, $_POST['USR_UID'], Criteria::NOT_EQUAL );
+ $oCriteria->addSelectColumn(UsersPeer::USR_UID);
+ $oCriteria->addSelectColumn(UsersPeer::USR_USERNAME);
+ $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
+ $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
+ $oCriteria->addSelectColumn(UsersPeer::USR_EMAIL);
+ $oCriteria->add(UsersPeer::USR_STATUS, array('ACTIVE', 'VACATION'), Criteria::IN);
+ if (isset($_POST['USR_UID'])) {
+ $oCriteria->add(UsersPeer::USR_UID, $_POST['USR_UID'], Criteria::NOT_EQUAL);
}
- $oDataset = UsersPeer::doSelectRS( $oCriteria );
- $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
+ $oDataset = UsersPeer::doSelectRS($oCriteria);
+ $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
- G::loadClass( 'configuration' );
+ G::loadClass('configuration');
$oConf = new Configurations();
- $oConf->loadConfig( $obj, 'ENVIRONMENT_SETTINGS', '' );
+ $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', '');
- $defaultOption = isset( $oConf->aConfig['format'] ) ? $oConf->aConfig['format'] : '';
+ $defaultOption = isset($oConf->aConfig['format']) ? $oConf->aConfig['format'] : '';
- $aUserInfo = array ();
- if (isset( $_POST['addNone'] ) && $_POST['addNone'] == '1') {
- $aUserInfo[] = array ('USR_UID' => '','USER_FULLNAME' => '- ' . G::LoadTranslation( 'ID_NONE' ) . ' -'
- );
+ $aUserInfo = array();
+ if (isset($_POST['addNone']) && $_POST['addNone'] == '1') {
+ $aUserInfo[] = array('USR_UID' => '', 'USER_FULLNAME' => '- ' . G::LoadTranslation('ID_NONE') . ' -');
}
while ($oDataset->next()) {
$aRow1 = $oDataset->getRow();
- $infoUser = G::getFormatUserList( $defaultOption, $aRow1 );
- $aUserInfo[] = array ('USR_UID' => $aRow1['USR_UID'],'USER_FULLNAME' => $infoUser
- );
+ $infoUser = G::getFormatUserList($defaultOption, $aRow1);
+ $aUserInfo[] = array('USR_UID' => $aRow1['USR_UID'], 'USER_FULLNAME' => $infoUser);
}
- print (G::json_encode( $aUserInfo )) ;
+ print (G::json_encode($aUserInfo));
break;
-
case 'availableCalendars':
- G::LoadClass( 'calendar' );
+ G::LoadClass('calendar');
$calendar = new Calendar();
- $calendarObj = $calendar->getCalendarList( true, true );
- $oData[] = array ('CALENDAR_UID' => '','CALENDAR_NAME' => '- None -'
- );
+ $calendarObj = $calendar->getCalendarList(true, true);
+ $oData[] = array('CALENDAR_UID' => '', 'CALENDAR_NAME' => '- None -');
foreach ($calendarObj['array'] as $rowid => $row) {
- if ($rowid > 0)
- $oData[] = array ('CALENDAR_UID' => $row['CALENDAR_UID'],'CALENDAR_NAME' => $row['CALENDAR_NAME']
- );
+ if ($rowid > 0) {
+ $oData[] = array('CALENDAR_UID' => $row['CALENDAR_UID'], 'CALENDAR_NAME' => $row['CALENDAR_NAME']);
+ }
}
- print (G::json_encode( $oData )) ;
+ print (G::json_encode($oData));
break;
case 'rolesList':
require_once PATH_RBAC . "model/Roles.php";
$roles = new Roles();
$rolesData = $roles->getAllRoles();
foreach ($rolesData as $rowid => $row) {
- $oData[] = array ('ROL_UID' => $row['ROL_CODE'],'ROL_CODE' => $row['ROL_CODE']
- );
+ $oData[] = array('ROL_UID' => $row['ROL_CODE'], 'ROL_CODE' => $row['ROL_CODE']);
}
- print (G::json_encode( $oData )) ;
+ print (G::json_encode($oData));
break;
case 'saveUser':
try {
-
$form = $_POST;
- if (isset( $_POST['USR_UID'] )) {
+ if (isset($_POST['USR_UID'])) {
$form['USR_UID'] = $_POST['USR_UID'];
} else {
$form['USR_UID'] = '';
}
- if (! isset( $form['USR_NEW_PASS'] )) {
+ if (!isset($form['USR_NEW_PASS'])) {
$form['USR_NEW_PASS'] = '';
}
if ($form['USR_NEW_PASS'] != '') {
- $form['USR_PASSWORD'] = md5( $form['USR_NEW_PASS'] );
+ $form['USR_PASSWORD'] = md5($form['USR_NEW_PASS']);
}
- if (! isset( $form['USR_CITY'] )) {
+ if (!isset($form['USR_CITY'])) {
$form['USR_CITY'] = '';
}
- if (! isset( $form['USR_LOCATION'] )) {
+ if (!isset($form['USR_LOCATION'])) {
$form['USR_LOCATION'] = '';
}
- if (! isset( $form['USR_AUTH_USER_DN'] )) {
+ if (!isset($form['USR_AUTH_USER_DN'])) {
$form['USR_AUTH_USER_DN'] = '';
}
@@ -150,17 +140,17 @@ switch ($_POST['action']) {
$aData['USR_LASTNAME'] = $form['USR_LASTNAME'];
$aData['USR_EMAIL'] = $form['USR_EMAIL'];
$aData['USR_DUE_DATE'] = $form['USR_DUE_DATE'];
- $aData['USR_CREATE_DATE'] = date( 'Y-m-d H:i:s' );
- $aData['USR_UPDATE_DATE'] = date( 'Y-m-d H:i:s' );
- $aData['USR_BIRTHDAY'] = date( 'Y-m-d' );
+ $aData['USR_CREATE_DATE'] = date('Y-m-d H:i:s');
+ $aData['USR_UPDATE_DATE'] = date('Y-m-d H:i:s');
+ $aData['USR_BIRTHDAY'] = date('Y-m-d');
$aData['USR_AUTH_USER_DN'] = $form['USR_AUTH_USER_DN'];
//fixing bug in inactive user when the admin create a new user.
$statusWF = $form['USR_STATUS'];
$aData['USR_STATUS'] = $form['USR_STATUS'] == 'ACTIVE' ? 1 : 0;
- $sUserUID = $RBAC->createUser( $aData, $form['USR_ROLE'] );
+ $sUserUID = $RBAC->createUser($aData, $form['USR_ROLE']);
$aData['USR_STATUS'] = $statusWF;
$aData['USR_UID'] = $sUserUID;
- $aData['USR_PASSWORD'] = md5( $sUserUID ); //fake :p
+ $aData['USR_PASSWORD'] = md5($sUserUID); //fake :p
$aData['USR_COUNTRY'] = $form['USR_COUNTRY'];
$aData['USR_CITY'] = $form['USR_CITY'];
$aData['USR_LOCATION'] = $form['USR_LOCATION'];
@@ -174,136 +164,133 @@ switch ($_POST['action']) {
require_once 'classes/model/Users.php';
$oUser = new Users();
- $oUser->create( $aData );
+ $oUser->create($aData);
if ($_FILES['USR_PHOTO']['error'] != 1) {
//print (PATH_IMAGES_ENVIRONMENT_USERS);
if ($_FILES['USR_PHOTO']['tmp_name'] != '') {
- G::uploadFile( $_FILES['USR_PHOTO']['tmp_name'], PATH_IMAGES_ENVIRONMENT_USERS, $sUserUID . '.gif' );
+ G::uploadFile($_FILES['USR_PHOTO']['tmp_name'], PATH_IMAGES_ENVIRONMENT_USERS, $sUserUID . '.gif');
}
} else {
$result->success = false;
$result->fileError = true;
- print (G::json_encode( $result )) ;
+ print (G::json_encode($result));
die();
}
/*
- if ($_FILES['USR_RESUME']['error'] != 1) {
- if ($_FILES['USR_RESUME']['tmp_name'] != '') {
- G::uploadFile($_FILES['USR_RESUME']['tmp_name'], PATH_IMAGES_ENVIRONMENT_FILES . $sUserUID . '/', $_FILES['USR_RESUME']['name']);
- }
- }
- else {
- $result->success = false;
- $result->fileError = true;
- print(G::json_encode($result));
- die;
- }
-*/
+ if ($_FILES['USR_RESUME']['error'] != 1) {
+ if ($_FILES['USR_RESUME']['tmp_name'] != '') {
+ G::uploadFile($_FILES['USR_RESUME']['tmp_name'], PATH_IMAGES_ENVIRONMENT_FILES . $sUserUID . '/', $_FILES['USR_RESUME']['name']);
+ }
+ }
+ else {
+ $result->success = false;
+ $result->fileError = true;
+ print(G::json_encode($result));
+ die;
+ }
+ */
} else {
$aData['USR_UID'] = $form['USR_UID'];
$aData['USR_USERNAME'] = $form['USR_USERNAME'];
- if (isset( $form['USR_PASSWORD'] )) {
+ if (isset($form['USR_PASSWORD'])) {
if ($form['USR_PASSWORD'] != '') {
$aData['USR_PASSWORD'] = $form['USR_PASSWORD'];
require_once 'classes/model/UsersProperties.php';
$oUserProperty = new UsersProperties();
- $aUserProperty = $oUserProperty->loadOrCreateIfNotExists( $form['USR_UID'], array ('USR_PASSWORD_HISTORY' => serialize( array (md5( $form['USR_PASSWORD'] )
- ) )
- ) );
+ $aUserProperty = $oUserProperty->loadOrCreateIfNotExists($form['USR_UID'], array('USR_PASSWORD_HISTORY' => serialize(array(md5($form['USR_PASSWORD'])))));
$memKey = 'rbacSession' . session_id();
- $memcache = & PMmemcached::getSingleton( defined( 'SYS_SYS' ) ? SYS_SYS : '' );
- if (($RBAC->aUserInfo = $memcache->get( $memKey )) === false) {
- $RBAC->loadUserRolePermission( $RBAC->sSystem, $_SESSION['USER_LOGGED'] );
- $memcache->set( $memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS );
+ $memcache = & PMmemcached::getSingleton(defined('SYS_SYS') ? SYS_SYS : '' );
+ if (($RBAC->aUserInfo = $memcache->get($memKey)) === false) {
+ $RBAC->loadUserRolePermission($RBAC->sSystem, $_SESSION['USER_LOGGED']);
+ $memcache->set($memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS);
}
if ($RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE'] == 'PROCESSMAKER_ADMIN') {
- $aUserProperty['USR_LAST_UPDATE_DATE'] = date( 'Y-m-d H:i:s' );
+ $aUserProperty['USR_LAST_UPDATE_DATE'] = date('Y-m-d H:i:s');
$aUserProperty['USR_LOGGED_NEXT_TIME'] = 1;
- $oUserProperty->update( $aUserProperty );
+ $oUserProperty->update($aUserProperty);
}
- $aErrors = $oUserProperty->validatePassword( $form['USR_NEW_PASS'], $aUserProperty['USR_LAST_UPDATE_DATE'], 0 );
+ $aErrors = $oUserProperty->validatePassword($form['USR_NEW_PASS'], $aUserProperty['USR_LAST_UPDATE_DATE'], 0);
- if (count( $aErrors ) > 0) {
- $sDescription = G::LoadTranslation( 'ID_POLICY_ALERT' ) . ':,';
+ if (count($aErrors) > 0) {
+ $sDescription = G::LoadTranslation('ID_POLICY_ALERT') . ':,';
foreach ($aErrors as $sError) {
switch ($sError) {
case 'ID_PPP_MINIMUN_LENGTH':
- $sDescription .= ' - ' . G::LoadTranslation( $sError ) . ': ' . PPP_MINIMUN_LENGTH . ',';
+ $sDescription .= ' - ' . G::LoadTranslation($sError) . ': ' . PPP_MINIMUN_LENGTH . ',';
break;
case 'ID_PPP_MAXIMUN_LENGTH':
- $sDescription .= ' - ' . G::LoadTranslation( $sError ) . ': ' . PPP_MAXIMUN_LENGTH . ',';
+ $sDescription .= ' - ' . G::LoadTranslation($sError) . ': ' . PPP_MAXIMUN_LENGTH . ',';
break;
case 'ID_PPP_EXPIRATION_IN':
- $sDescription .= ' - ' . G::LoadTranslation( $sError ) . ' ' . PPP_EXPIRATION_IN . ' ' . G::LoadTranslation( 'ID_DAYS' ) . ',';
+ $sDescription .= ' - ' . G::LoadTranslation($sError) . ' ' . PPP_EXPIRATION_IN . ' ' . G::LoadTranslation('ID_DAYS') . ',';
break;
default:
- $sDescription .= ' - ' . G::LoadTranslation( $sError ) . ',';
+ $sDescription .= ' - ' . G::LoadTranslation($sError) . ',';
break;
}
}
- $sDescription .= '' . G::LoadTranslation( 'ID_PLEASE_CHANGE_PASSWORD_POLICY' );
+ $sDescription .= '' . G::LoadTranslation('ID_PLEASE_CHANGE_PASSWORD_POLICY');
$result->success = false;
$result->msg = $sDescription;
- print (G::json_encode( $result )) ;
+ print (G::json_encode($result));
die();
-
}
- $aHistory = unserialize( $aUserProperty['USR_PASSWORD_HISTORY'] );
- if (! is_array( $aHistory )) {
- $aHistory = array ();
+ $aHistory = unserialize($aUserProperty['USR_PASSWORD_HISTORY']);
+ if (!is_array($aHistory)) {
+ $aHistory = array();
}
- if (! defined( 'PPP_PASSWORD_HISTORY' )) {
- define( 'PPP_PASSWORD_HISTORY', 0 );
+ if (!defined('PPP_PASSWORD_HISTORY')) {
+ define('PPP_PASSWORD_HISTORY', 0);
}
if (PPP_PASSWORD_HISTORY > 0) {
//it's looking a password igual into aHistory array that was send for post in md5 way
$c = 0;
$sw = 1;
- while (count( $aHistory ) >= 1 && count( $aHistory ) > $c && $sw) {
- if (strcmp( trim( $aHistory[$c] ), trim( $form['USR_PASSWORD'] ) ) == 0) {
+ while (count($aHistory) >= 1 && count($aHistory) > $c && $sw) {
+ if (strcmp(trim($aHistory[$c]), trim($form['USR_PASSWORD'])) == 0) {
$sw = 0;
}
- $c ++;
+ $c++;
}
if ($sw == 0) {
- $sDescription = G::LoadTranslation( 'ID_POLICY_ALERT' ) . ':