Example #1
0
/**
 * This function is used to get the Parent Tab name for a given module.
 * Takes the input parameter as $module - module name
 * This returns value string type 
 */
function getParentTabFromModule($module)
{
    global $log;
    $log->debug("Entering getParentTabName() method ...");
    $tabid = getTabid($module);
    $parent_tabname = "";
    $key = "parenttabrellist";
    $resultant_array = getSqlCacheData($key);
    if (!$resultant_array) {
        global $adb;
        //$sql = "select ec_parenttab.* from ec_parenttab inner join ec_parenttabrel on ec_parenttabrel.parenttabid=ec_parenttab.parenttabid where ec_parenttabrel.tabid='".$tabid."'";
        $sql = "select * from ec_parenttabrel order by sequence";
        $result = $adb->query($sql);
        $num_rows = $adb->num_rows($result);
        $result_array = array();
        for ($i = 0; $i < $num_rows; $i++) {
            $parenttabid = $adb->query_result($result, $i, 'parenttabid');
            $tabid = $adb->query_result($result, $i, 'tabid');
            $resultant_array[$tabid] = $parenttabid;
        }
        setSqlCacheData($key, $resultant_array);
    }
    //echo "tabid:".$tabid."<br>";
    if ($tabid == 16) {
        $tabid = 9;
    }
    //event -> calendar
    if (isset($resultant_array[$tabid])) {
        $parent_tabid = $resultant_array[$tabid];
        $parent_tabname = getParentTabName($parent_tabid);
    }
    if ($module == 'Settings') {
        $parent_tabname = "Settings";
    }
    $log->debug("Exiting getParentTabName method ...");
    return $parent_tabname;
}
/**
 * This function is used to get the Parent and Child vtiger_tab relation array.
 * Takes no parameter and get the data from parent_tabdata.php and vtiger_tabdata.php
 * This returns array type value
 */
function getHeaderArray()
{
    global $log;
    $log->debug("Entering getHeaderArray() method ...");
    global $adb;
    global $current_user;
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    include 'parent_tabdata.php';
    include 'tabdata.php';
    $noofrows = count($parent_tab_info_array);
    foreach ($parent_tab_info_array as $parid => $parval) {
        $subtabs = array();
        $tablist = $parent_child_tab_rel_array[$parid];
        $noofsubtabs = count($tablist);
        foreach ($tablist as $childTabId) {
            $module = array_search($childTabId, $tab_info_array);
            if ($is_admin) {
                $subtabs[] = $module;
            } elseif ($profileGlobalPermission[2] == 0 || $profileGlobalPermission[1] == 0 || $profileTabsPermission[$childTabId] == 0) {
                $subtabs[] = $module;
            }
        }
        $parenttab = getParentTabName($parid);
        if ($parenttab == 'Settings' && $is_admin) {
            $subtabs[] = 'Settings';
        }
        if ($parenttab != 'Settings' || $parenttab == 'Settings' && $is_admin) {
            if (!empty($subtabs)) {
                $relatedtabs[$parenttab] = $subtabs;
            }
        }
    }
    $log->debug("Exiting getHeaderArray method ...");
    return $relatedtabs;
}