PM-4099: Add the possibility to Replace a custom 'New Case' menu
correccion de observaciones correccion observaciones y mejoras .
This commit is contained in:
@@ -82,6 +82,7 @@ class Menu
|
|||||||
public function Load($strMenuName)
|
public function Load($strMenuName)
|
||||||
{
|
{
|
||||||
global $G_TMP_MENU;
|
global $G_TMP_MENU;
|
||||||
|
|
||||||
$G_TMP_MENU = null;
|
$G_TMP_MENU = null;
|
||||||
$G_TMP_MENU = new Menu();
|
$G_TMP_MENU = new Menu();
|
||||||
$fMenu = G::ExpandPath("menus") . $strMenuName . ".php";
|
$fMenu = G::ExpandPath("menus") . $strMenuName . ".php";
|
||||||
@@ -104,11 +105,23 @@ class Menu
|
|||||||
//this line will add options to current menu.
|
//this line will add options to current menu.
|
||||||
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||||
$oPluginRegistry->getMenus($strMenuName);
|
$oPluginRegistry->getMenus($strMenuName);
|
||||||
|
|
||||||
|
$oMenuFromPlugin = array();
|
||||||
|
$oMenuFromPlugin = $oPluginRegistry->getMenuOptionsToReplace($strMenuName);
|
||||||
|
|
||||||
//?
|
//?
|
||||||
$c = 0;
|
$c = 0;
|
||||||
for ($i = 0; $i < count($G_TMP_MENU->Options); $i++) {
|
for ($i = 0; $i < count($G_TMP_MENU->Options); $i++) {
|
||||||
if ($G_TMP_MENU->Enabled[$i] == 1) {
|
if ($G_TMP_MENU->Enabled[$i] == 1) {
|
||||||
|
|
||||||
|
if(sizeof($oMenuFromPlugin)) {
|
||||||
|
$menId = $G_TMP_MENU->Id[$i];
|
||||||
|
if(array_key_exists($menId,$oMenuFromPlugin)) {
|
||||||
|
$G_TMP_MENU->Labels[$i] = $oMenuFromPlugin[$menId][0]['label'];
|
||||||
|
$G_TMP_MENU->Options[$i] = $oMenuFromPlugin[$menId][0]['href'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->Options[$c] = $G_TMP_MENU->Options[$i];
|
$this->Options[$c] = $G_TMP_MENU->Options[$i];
|
||||||
$this->Labels[$c] = $G_TMP_MENU->Labels[$i];
|
$this->Labels[$c] = $G_TMP_MENU->Labels[$i];
|
||||||
$this->Icons[$c] = (isset($G_TMP_MENU->Icons[$i]))? $G_TMP_MENU->Icons[$i] : "";
|
$this->Icons[$c] = (isset($G_TMP_MENU->Icons[$i]))? $G_TMP_MENU->Icons[$i] : "";
|
||||||
|
|||||||
@@ -396,6 +396,25 @@ class PMPlugin
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the menu properties from the given processmaker section and menu id
|
||||||
|
*
|
||||||
|
* @param array $from
|
||||||
|
*
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerMenuOptionsToReplace($from = array(), $options = array())
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
||||||
|
$oPluginRegistry->registerMenuOptionsToReplace($this->sNamespace, $from, $options);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class menuDetail
|
class menuDetail
|
||||||
@@ -735,4 +754,3 @@ class cronFile
|
|||||||
$this->cronFile = $cronFile;
|
$this->cronFile = $cronFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ class PMPluginRegistry
|
|||||||
private $_aDashboardPages = array ();
|
private $_aDashboardPages = array ();
|
||||||
private $_aCronFiles = array ();
|
private $_aCronFiles = array ();
|
||||||
private $_arrayDesignerMenu = array();
|
private $_arrayDesignerMenu = array();
|
||||||
|
private $_aMenuOptionsToReplace = array ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registry a plugin javascript to include with js core at same runtime
|
* Registry a plugin javascript to include with js core at same runtime
|
||||||
@@ -403,7 +404,11 @@ class PMPluginRegistry
|
|||||||
unset($this->_arrayDesignerMenu[$key]);
|
unset($this->_arrayDesignerMenu[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(sizeof( $this->_aMenuOptionsToReplace )){
|
||||||
|
unset( $this->_aMenuOptionsToReplace );
|
||||||
|
}
|
||||||
|
|
||||||
//unregistering javascripts from this plugin
|
//unregistering javascripts from this plugin
|
||||||
$this->unregisterJavascripts( $sNamespace );
|
$this->unregisterJavascripts( $sNamespace );
|
||||||
//unregistering rest services from this plugin
|
//unregistering rest services from this plugin
|
||||||
@@ -1659,5 +1664,43 @@ class PMPluginRegistry
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace new options to menu
|
||||||
|
*
|
||||||
|
* @param unknown_type $namespace
|
||||||
|
*
|
||||||
|
* @param array $from
|
||||||
|
*
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function registerMenuOptionsToReplace ($namespace, $from, $options)
|
||||||
|
{
|
||||||
|
if(isset($from["section"]) && isset($from["menuId"])) {
|
||||||
|
$section = $from["section"];
|
||||||
|
$oMenuFromPlugin = $this->_aMenuOptionsToReplace;
|
||||||
|
if(array_key_exists($section,$oMenuFromPlugin)) {
|
||||||
|
unset($this->_aMenuOptionsToReplace[$from["section"]]);
|
||||||
|
}
|
||||||
|
$this->_aMenuOptionsToReplace[$from["section"]][$from["menuId"]][] = $options;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all menu Options from a specific section
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getMenuOptionsToReplace($strMenuName)
|
||||||
|
{
|
||||||
|
$oMenuFromPlugin = $this->_aMenuOptionsToReplace;
|
||||||
|
if(sizeof($oMenuFromPlugin)) {
|
||||||
|
if(array_key_exists($strMenuName,$oMenuFromPlugin)) {
|
||||||
|
return $oMenuFromPlugin[$strMenuName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user