Exemplo n.º 1
0
 public function addModuleToMenu($moduleName, $parent)
 {
     global $log;
     $log->debug("Entering YetiForceUpdate::addModuleToMenu({$moduleName}, {$parent}) method ...");
     $adb = PearDatabase::getInstance();
     if (!$parent) {
         return false;
     }
     $sql = "SELECT `profileid` FROM `vtiger_profile` WHERE 1;";
     $result = $adb->query($sql, true);
     $num = $adb->num_rows($result);
     $profiles = array();
     for ($i = 0; $i < $num; $i++) {
         $profiles[] = $adb->query_result($result, $i, 'profileid');
     }
     $profilePermissions = implode(' |##| ', $profiles);
     $profilePermissions = ' ' . $profilePermissions . ' ';
     //$blocksModule = array('My Home Page','Companies','Human resources','Sales','Projects','Support','Databases');
     $sql = "SELECT `id` FROM `vtiger_ossmenumanager` WHERE label = ? AND tabid = ? AND parent_id = ?;";
     $result = $adb->pquery($sql, array($parent, 0, 0), true);
     $num = $adb->num_rows($result);
     if ($num == 0) {
         $subParams = array('name' => $parent, 'visible' => '1', 'permission' => $profilePermissions, 'locationicon' => '', 'sizeicon' => '', 'langfield' => '');
         $id = OSSMenuManager_Record_Model::addBlock($subParams);
         if ($id) {
             $subParams = array('parent_id' => $id, 'tabid' => getTabid($moduleName), 'label' => $moduleName, 'sequence' => -1, 'visible' => '1', 'type' => 0, 'url' => '', 'new_window' => 0, 'permission' => $profilePermissions, 'locationicon' => '', 'sizeicon' => '', 'langfield' => '');
             $id = OSSMenuManager_Record_Model::addMenu($subParams);
         }
     } elseif ($num == 1) {
         $subParams = array('parent_id' => $adb->query_result($result, 0, 'id'), 'tabid' => getTabid($moduleName), 'label' => $moduleName, 'sequence' => -1, 'visible' => '1', 'type' => 0, 'url' => '', 'new_window' => 0, 'permission' => $profilePermissions, 'locationicon' => '', 'sizeicon' => '', 'langfield' => '');
         $id = OSSMenuManager_Record_Model::addMenu($subParams);
     }
     $log->debug("Exiting YetiForceUpdate::addModuleToMenu() method ...");
 }