fixing class definition, the constructor was defined as private function

This commit is contained in:
Fernando Ontiveros
2012-07-12 20:36:41 -04:00
parent bb663544b8
commit 4f8ca480b9
3 changed files with 56 additions and 56 deletions

View File

@@ -26,7 +26,7 @@
/** /**
* The ProcessMaker memcached class * The ProcessMaker memcached class
* *
* @package workflow.engine.ProcessMaker * @package workflow.engine.ProcessMaker
*/ */
@@ -35,16 +35,16 @@ class PMmemcached {
const ONE_HOUR = 3600; const ONE_HOUR = 3600;
const TWO_HOURS = 7200; const TWO_HOURS = 7200;
const EIGHT_HOURS = 28800; const EIGHT_HOURS = 28800;
var $version; var $version;
var $mem; var $mem;
var $connected = false; var $connected = false;
var $enabled = false; var $enabled = false;
var $supported = false; var $supported = false;
private static $instance = NULL; private static $instance = NULL;
private function __construct($workspace) { public function __construct($workspace) {
$this->enabled = MEMCACHED_ENABLED; $this->enabled = MEMCACHED_ENABLED;
$this->connected = false; $this->connected = false;
$this->workspace = $workspace; $this->workspace = $workspace;
@@ -77,14 +77,14 @@ class PMmemcached {
$this->mem = new FileCache ( $cacheFolder ); $this->mem = new FileCache ( $cacheFolder );
} }
} }
if (! MEMCACHED_ENABLED) { if (! MEMCACHED_ENABLED) {
$this->connected = false; $this->connected = false;
return false; return false;
} }
} }
/** /**
* to get singleton instance * to get singleton instance
* *
@@ -97,15 +97,15 @@ class PMmemcached {
} }
return self::$instance; return self::$instance;
} }
public function __clone() { public function __clone() {
throw new Exception ( "Clone is not allowed." ); throw new Exception ( "Clone is not allowed." );
} }
public function __wakeup() { public function __wakeup() {
throw new Exception ( "Deserializing is not allowed." ); throw new Exception ( "Deserializing is not allowed." );
} }
function set($key, $object, $timeout = 0) { function set($key, $object, $timeout = 0) {
if (! $this->connected) if (! $this->connected)
return false; return false;
@@ -114,43 +114,43 @@ class PMmemcached {
else else
$this->mem->set ( $this->workspace . '_' . $key, $object ); $this->mem->set ( $this->workspace . '_' . $key, $object );
} }
function get($key) { function get($key) {
if (! $this->connected) if (! $this->connected)
return false; return false;
return $this->mem->get ( $this->workspace . '_' . $key ); return $this->mem->get ( $this->workspace . '_' . $key );
} }
function add($key, $value) { function add($key, $value) {
if ((! $this->connected) || ($this->class == 'filecache')) if ((! $this->connected) || ($this->class == 'filecache'))
return false; return false;
return $this->mem->add ( $this->workspace . '_' . $key, $value ); return $this->mem->add ( $this->workspace . '_' . $key, $value );
} }
function increment($key, $value) { function increment($key, $value) {
if ((! $this->connected) || ($this->class == 'filecache')) if ((! $this->connected) || ($this->class == 'filecache'))
return false; return false;
return $this->mem->increment ( $this->workspace . '_' . $key, $value ); return $this->mem->increment ( $this->workspace . '_' . $key, $value );
} }
function delete($key) { function delete($key) {
if ((! $this->connected) || ($this->class == 'filecache')) if ((! $this->connected) || ($this->class == 'filecache'))
return false; return false;
return $this->mem->delete ( $this->workspace . '_' . $key ); return $this->mem->delete ( $this->workspace . '_' . $key );
} }
function flush() { function flush() {
if ((! $this->connected) || ($this->class == 'filecache')) if ((! $this->connected) || ($this->class == 'filecache'))
return false; return false;
return $this->mem->flush (); return $this->mem->flush ();
} }
function getStats() { function getStats() {
if ((! $this->connected) || ($this->class == 'filecache')) if ((! $this->connected) || ($this->class == 'filecache'))
return false; return false;
return $status = $this->mem->getStats (); return $status = $this->mem->getStats ();
} }
function printDetails() { function printDetails() {
if ((! $this->connected) || ($this->class == 'filecache')) if ((! $this->connected) || ($this->class == 'filecache'))
return false; return false;
@@ -164,16 +164,16 @@ class PMmemcached {
echo "<tr><td>Number of connection structures allocated by the server </td><td>" . $status ["connection_structures"] . "</td></tr>"; echo "<tr><td>Number of connection structures allocated by the server </td><td>" . $status ["connection_structures"] . "</td></tr>";
echo "<tr><td>Cumulative number of retrieval requests </td><td>" . $status ["cmd_get"] . "</td></tr>"; echo "<tr><td>Cumulative number of retrieval requests </td><td>" . $status ["cmd_get"] . "</td></tr>";
echo "<tr><td> Cumulative number of storage requests </td><td>" . $status ["cmd_set"] . "</td></tr>"; echo "<tr><td> Cumulative number of storage requests </td><td>" . $status ["cmd_set"] . "</td></tr>";
$percCacheHit = (( real ) $status ["get_hits"] / ( real ) $status ["cmd_get"] * 100); $percCacheHit = (( real ) $status ["get_hits"] / ( real ) $status ["cmd_get"] * 100);
$percCacheHit = round ( $percCacheHit, 3 ); $percCacheHit = round ( $percCacheHit, 3 );
$percCacheMiss = 100 - $percCacheHit; $percCacheMiss = 100 - $percCacheHit;
echo "<tr><td>Number of keys that have been requested and found present </td><td>" . $status ["get_hits"] . " ($percCacheHit%)</td></tr>"; echo "<tr><td>Number of keys that have been requested and found present </td><td>" . $status ["get_hits"] . " ($percCacheHit%)</td></tr>";
echo "<tr><td>Number of items that have been requested and not found </td><td>" . $status ["get_misses"] . "($percCacheMiss%)</td></tr>"; echo "<tr><td>Number of items that have been requested and not found </td><td>" . $status ["get_misses"] . "($percCacheMiss%)</td></tr>";
$MBRead = ( real ) $status ["bytes_read"] / (1024 * 1024); $MBRead = ( real ) $status ["bytes_read"] / (1024 * 1024);
echo "<tr><td>Total number of bytes read by this server from network </td><td>" . $MBRead . " Mega Bytes</td></tr>"; echo "<tr><td>Total number of bytes read by this server from network </td><td>" . $MBRead . " Mega Bytes</td></tr>";
$MBWrite = ( real ) $status ["bytes_written"] / (1024 * 1024); $MBWrite = ( real ) $status ["bytes_written"] / (1024 * 1024);
echo "<tr><td>Total number of bytes sent by this server to network </td><td>" . $MBWrite . " Mega Bytes</td></tr>"; echo "<tr><td>Total number of bytes sent by this server to network </td><td>" . $MBWrite . " Mega Bytes</td></tr>";

View File

@@ -102,7 +102,7 @@ class PMPluginRegistry {
* param * param
* @return void * @return void
*/ */
private function __construct() {} public function __construct() {}
/** /**
* This function is instancing to this class * This function is instancing to this class
@@ -222,11 +222,11 @@ class PMPluginRegistry {
function disablePlugin($sNamespace, $eventPlugin = 1) function disablePlugin($sNamespace, $eventPlugin = 1)
{ {
$sw = false; $sw = false;
foreach ($this->_aPluginDetails as $namespace => $detail) { foreach ($this->_aPluginDetails as $namespace => $detail) {
if ($namespace == $sNamespace) { if ($namespace == $sNamespace) {
unset($this->_aPluginDetails[$sNamespace]); unset($this->_aPluginDetails[$sNamespace]);
if ($eventPlugin == 1) { if ($eventPlugin == 1) {
$plugin = new $detail->sClassName($detail->sNamespace, $detail->sFilename); $plugin = new $detail->sClassName($detail->sNamespace, $detail->sFilename);
$this->_aPlugins[$detail->sNamespace] = $plugin; $this->_aPlugins[$detail->sNamespace] = $plugin;
@@ -234,7 +234,7 @@ class PMPluginRegistry {
$plugin->disable(); $plugin->disable();
} }
} }
$sw = true; $sw = true;
} }
} }
@@ -242,7 +242,7 @@ class PMPluginRegistry {
if (!$sw) { if (!$sw) {
throw new Exception("Unable to disable plugin '$sNamespace' (plugin not found)"); throw new Exception("Unable to disable plugin '$sNamespace' (plugin not found)");
} }
foreach ( $this->_aMenus as $key=>$detail ) { foreach ( $this->_aMenus as $key=>$detail ) {
if ( $detail->sNamespace == $sNamespace ) if ( $detail->sNamespace == $sNamespace )
unset ( $this->_aMenus[ $key ] ); unset ( $this->_aMenus[ $key ] );
@@ -411,73 +411,73 @@ class PMPluginRegistry {
if (!file_exists(PATH_PLUGINS . $pluginFile)) { if (!file_exists(PATH_PLUGINS . $pluginFile)) {
throw (new Exception("File \"$pluginFile\" doesn't exist")); throw (new Exception("File \"$pluginFile\" doesn't exist"));
} }
/////// ///////
require_once (PATH_PLUGINS . $pluginFile); require_once (PATH_PLUGINS . $pluginFile);
foreach ($this->_aPluginDetails as $namespace => $detail) { foreach ($this->_aPluginDetails as $namespace => $detail) {
if ($namespace == $sNamespace) { if ($namespace == $sNamespace) {
$this->enablePlugin($detail->sNamespace); $this->enablePlugin($detail->sNamespace);
$this->disablePlugin($detail->sNamespace); $this->disablePlugin($detail->sNamespace);
/////// ///////
$plugin = new $detail->sClassName($detail->sNamespace, $detail->sFilename); $plugin = new $detail->sClassName($detail->sNamespace, $detail->sFilename);
$this->_aPlugins[$detail->sNamespace] = $plugin; $this->_aPlugins[$detail->sNamespace] = $plugin;
if (method_exists($plugin, "uninstall")) { if (method_exists($plugin, "uninstall")) {
$plugin->uninstall(); $plugin->uninstall();
} }
/////// ///////
$this->save(); $this->save();
/////// ///////
$pluginDir = PATH_PLUGINS . $detail->sPluginFolder; $pluginDir = PATH_PLUGINS . $detail->sPluginFolder;
if (isset($detail->sFilename) && !empty($detail->sFilename) && file_exists($detail->sFilename)) { if (isset($detail->sFilename) && !empty($detail->sFilename) && file_exists($detail->sFilename)) {
unlink($detail->sFilename); unlink($detail->sFilename);
} }
if (isset($detail->sPluginFolder) && !empty($detail->sPluginFolder) && file_exists($pluginDir)) { if (isset($detail->sPluginFolder) && !empty($detail->sPluginFolder) && file_exists($pluginDir)) {
G::rm_dir($pluginDir); G::rm_dir($pluginDir);
} }
/////// ///////
$this->uninstallPluginWorkspaces(array($sNamespace)); $this->uninstallPluginWorkspaces(array($sNamespace));
/////// ///////
break; break;
} }
} }
} }
function uninstallPluginWorkspaces($arrayPlugin) function uninstallPluginWorkspaces($arrayPlugin)
{ {
G::LoadClass("system"); G::LoadClass("system");
G::LoadClass("wsTools"); G::LoadClass("wsTools");
$workspace = System::listWorkspaces(); $workspace = System::listWorkspaces();
foreach ($workspace as $indexWS => $ws) { foreach ($workspace as $indexWS => $ws) {
$wsPathDataSite = PATH_DATA . "sites" . PATH_SEP . $ws->name . PATH_SEP; $wsPathDataSite = PATH_DATA . "sites" . PATH_SEP . $ws->name . PATH_SEP;
if (file_exists($wsPathDataSite . "plugin.singleton")) { if (file_exists($wsPathDataSite . "plugin.singleton")) {
//G::LoadClass("plugin"); //G::LoadClass("plugin");
//Here we are loading all plug-ins registered //Here we are loading all plug-ins registered
//The singleton has a list of enabled plug-ins //The singleton has a list of enabled plug-ins
$pluginRegistry = &PMPluginRegistry::getSingleton(); $pluginRegistry = &PMPluginRegistry::getSingleton();
$pluginRegistry->unSerializeInstance(file_get_contents($wsPathDataSite . "plugin.singleton")); $pluginRegistry->unSerializeInstance(file_get_contents($wsPathDataSite . "plugin.singleton"));
/////// ///////
$attributes = $pluginRegistry->getAttributes(); $attributes = $pluginRegistry->getAttributes();
foreach ($arrayPlugin as $index => $value) { foreach ($arrayPlugin as $index => $value) {
if (isset($attributes["_aPluginDetails"][$value])) { if (isset($attributes["_aPluginDetails"][$value])) {
$pluginRegistry->disablePlugin($value, 0); $pluginRegistry->disablePlugin($value, 0);
} }
} }
/////// ///////
file_put_contents($wsPathDataSite . "plugin.singleton", $pluginRegistry->serializeInstance()); file_put_contents($wsPathDataSite . "plugin.singleton", $pluginRegistry->serializeInstance());
} }
@@ -1245,7 +1245,7 @@ class PMPluginRegistry {
function registerDashboard() { function registerDashboard() {
// Dummy function for backwards compatibility // Dummy function for backwards compatibility
} }
function getAttributes() function getAttributes()
{ {
return get_object_vars($this); return get_object_vars($this);

View File

@@ -53,9 +53,9 @@ class serverConf {
var $logins; var $logins;
private $lanDirection; private $lanDirection;
private $lanLanguage; private $lanLanguage;
private function __construct() {
public function __construct() {
$this->filePath = PATH_DATA . 'srvConf.singleton'; $this->filePath = PATH_DATA . 'srvConf.singleton';
} }
@@ -140,7 +140,7 @@ class serverConf {
function getProperty($propertyName) { function getProperty($propertyName) {
if (isset ( $this->_aProperties [$propertyName] )) { if (isset ( $this->_aProperties [$propertyName] )) {
return $this->_aProperties [$propertyName]; return $this->_aProperties [$propertyName];
} }
else { else {
return null; return null;
} }
@@ -158,7 +158,7 @@ class serverConf {
if ( isset ($this->workspaces[SYS_SYS]) && !isset ($this->workspaces[SYS_SYS]['WSP_LOGINS']) ) if ( isset ($this->workspaces[SYS_SYS]) && !isset ($this->workspaces[SYS_SYS]['WSP_LOGINS']) )
$this->workspaces[SYS_SYS]['WSP_LOGINS'] = 1; $this->workspaces[SYS_SYS]['WSP_LOGINS'] = 1;
$this->saveSingleton (); $this->saveSingleton ();
} }
@@ -175,7 +175,7 @@ class serverConf {
if (isset ( $this->_aWSapces [$wsName] )) { //Enable WS if (isset ( $this->_aWSapces [$wsName] )) { //Enable WS
unset ( $this->_aWSapces [$wsName] ); unset ( $this->_aWSapces [$wsName] );
} }
else { else {
$this->_aWSapces [$wsName] = 'disabled'; $this->_aWSapces [$wsName] = 'disabled';
} }
@@ -330,7 +330,7 @@ class serverConf {
} }
} }
} }
/** /**
* Get the value of language direction property * Get the value of language direction property
@@ -343,9 +343,9 @@ class serverConf {
} }
if( defined('SYS_LANG') ) { if( defined('SYS_LANG') ) {
//if we already have the landirection for this language, just return from serverConf //if we already have the landirection for this language, just return from serverConf
if ( $this->lanLanguage == SYS_LANG ) if ( $this->lanLanguage == SYS_LANG )
return $this->lanDirection; return $this->lanDirection;
//if not , we need to query Database, in order to get the direction //if not , we need to query Database, in order to get the direction
$this->lanDirection = 'L'; //default value; $this->lanDirection = 'L'; //default value;
$this->lanLanguage = SYS_LANG; $this->lanLanguage = SYS_LANG;
@@ -357,7 +357,7 @@ class serverConf {
$this->lanDirection = strtoupper($aLang['LAN_DIRECTION']); $this->lanDirection = strtoupper($aLang['LAN_DIRECTION']);
} }
$this->saveSingleton(); $this->saveSingleton();
} }
catch(Exception $e){ catch(Exception $e){
$this->lanDirection = 'L'; $this->lanDirection = 'L';
} }
@@ -387,7 +387,7 @@ class serverConf {
unset ( $this->_aHeartbeatConfig [$workspace][$propertyName] ); unset ( $this->_aHeartbeatConfig [$workspace][$propertyName] );
$this->saveSingleton (); $this->saveSingleton ();
} }
/** /**
* Returns the value of a defined property. If it doesn't exist then returns null * Returns the value of a defined property. If it doesn't exist then returns null
* @param string $propertyName * @param string $propertyName