PM-4099: Add the possibility to Replace a custom 'New Case' menu

correccion de observaciones

correccion observaciones y mejoras

.
This commit is contained in:
marcelo.cuiza
2015-11-19 13:08:51 -04:00
parent a0cfee2611
commit 4cd772c402
3 changed files with 77 additions and 3 deletions

View File

@@ -82,6 +82,7 @@ class Menu
public function Load($strMenuName)
{
global $G_TMP_MENU;
$G_TMP_MENU = null;
$G_TMP_MENU = new Menu();
$fMenu = G::ExpandPath("menus") . $strMenuName . ".php";
@@ -105,10 +106,22 @@ class Menu
$oPluginRegistry = & PMPluginRegistry::getSingleton();
$oPluginRegistry->getMenus($strMenuName);
$oMenuFromPlugin = array();
$oMenuFromPlugin = $oPluginRegistry->getMenuOptionsToReplace($strMenuName);
//?
$c = 0;
for ($i = 0; $i < count($G_TMP_MENU->Options); $i++) {
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->Labels[$c] = $G_TMP_MENU->Labels[$i];
$this->Icons[$c] = (isset($G_TMP_MENU->Icons[$i]))? $G_TMP_MENU->Icons[$i] : "";

View File

@@ -396,6 +396,25 @@ class PMPlugin
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
@@ -735,4 +754,3 @@ class cronFile
$this->cronFile = $cronFile;
}
}

View File

@@ -102,6 +102,7 @@ class PMPluginRegistry
private $_aDashboardPages = array ();
private $_aCronFiles = array ();
private $_arrayDesignerMenu = array();
private $_aMenuOptionsToReplace = array ();
/**
* Registry a plugin javascript to include with js core at same runtime
@@ -404,6 +405,10 @@ class PMPluginRegistry
}
}
if(sizeof( $this->_aMenuOptionsToReplace )){
unset( $this->_aMenuOptionsToReplace );
}
//unregistering javascripts from this plugin
$this->unregisterJavascripts( $sNamespace );
//unregistering rest services from this plugin
@@ -1659,5 +1664,43 @@ class PMPluginRegistry
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];
}
}
}
}