Ejemplo n.º 1
0
 function initListOfModules()
 {
     global $adb, $current_user, $old_related_modules;
     $restricted_modules = array('Events');
     $restricted_blocks = array('LBL_COMMENTS', 'LBL_COMMENT_INFORMATION');
     $this->module_id = array();
     $this->module_list = array();
     // Prefetch module info to check active or not and also get list of tabs
     $modulerows = vtlib_prefetchModuleActiveInfo(false);
     $cachedInfo = VTCacheUtils::lookupReport_ListofModuleInfos();
     if ($cachedInfo !== false) {
         $this->module_list = $cachedInfo['module_list'];
         $this->related_modules = $cachedInfo['related_modules'];
     } else {
         if ($modulerows) {
             foreach ($modulerows as $resultrow) {
                 if ($resultrow['presence'] == '1') {
                     continue;
                 }
                 // skip disabled modules
                 if ($resultrow['isentitytype'] != '1') {
                     continue;
                 }
                 // skip extension modules
                 if (in_array($resultrow['name'], $restricted_modules)) {
                     // skip restricted modules
                     continue;
                 }
                 if ($resultrow['name'] != 'Calendar') {
                     $this->module_id[$resultrow['tabid']] = $resultrow['name'];
                 } else {
                     $this->module_id[9] = $resultrow['name'];
                     $this->module_id[16] = $resultrow['name'];
                 }
                 $this->module_list[$resultrow['name']] = array();
             }
             $moduleids = array_keys($this->module_id);
             $reportblocks = $adb->pquery("SELECT blockid, blocklabel, tabid FROM vtiger_blocks WHERE tabid IN (" . generateQuestionMarks($moduleids) . ")", array($moduleids));
             $prev_block_label = '';
             if ($adb->num_rows($reportblocks)) {
                 while ($resultrow = $adb->fetch_array($reportblocks)) {
                     $blockid = $resultrow['blockid'];
                     $blocklabel = $resultrow['blocklabel'];
                     $module = $this->module_id[$resultrow['tabid']];
                     if (in_array($blocklabel, $restricted_blocks) || in_array($blockid, $this->module_list[$module]) || isset($this->module_list[$module][getTranslatedString($blocklabel, $module)])) {
                         continue;
                     }
                     if (!empty($blocklabel)) {
                         if ($module == 'Calendar' && $blocklabel == 'LBL_CUSTOM_INFORMATION') {
                             $this->module_list[$module][$blockid] = getTranslatedString($blocklabel, $module);
                         } else {
                             $this->module_list[$module][$blockid] = getTranslatedString($blocklabel, $module);
                         }
                         $prev_block_label = $blocklabel;
                     } else {
                         $this->module_list[$module][$blockid] = getTranslatedString($prev_block_label, $module);
                     }
                 }
             }
             $relatedmodules = $adb->pquery("SELECT vtiger_tab.name, vtiger_relatedlists.tabid FROM vtiger_tab\n\t\t\t\t\tINNER JOIN vtiger_relatedlists on vtiger_tab.tabid=vtiger_relatedlists.related_tabid\n\t\t\t\t\tWHERE vtiger_tab.isentitytype=1\n\t\t\t\t\tAND vtiger_tab.name NOT IN(" . generateQuestionMarks($restricted_modules) . ")\n\t\t\t\t\tAND vtiger_tab.presence = 0 AND vtiger_relatedlists.label!='Activity History'\n\t\t\t\t\tUNION\n\t\t\t\t\tSELECT module, vtiger_tab.tabid FROM vtiger_fieldmodulerel\n\t\t\t\t\tINNER JOIN vtiger_tab on vtiger_tab.name = vtiger_fieldmodulerel.relmodule\n\t\t\t\t\tWHERE vtiger_tab.isentitytype = 1\n\t\t\t\t\tAND vtiger_tab.name NOT IN(" . generateQuestionMarks($restricted_modules) . ")\n\t\t\t\t\tAND vtiger_tab.presence = 0", array($restricted_modules, $restricted_modules));
             if ($adb->num_rows($relatedmodules)) {
                 while ($resultrow = $adb->fetch_array($relatedmodules)) {
                     $module = $this->module_id[$resultrow['tabid']];
                     if (!isset($this->related_modules[$module])) {
                         $this->related_modules[$module] = array();
                     }
                     if ($module != $resultrow['name']) {
                         $this->related_modules[$module][] = $resultrow['name'];
                     }
                     // To achieve Backward Compatability with Report relations
                     if (isset($old_related_modules[$module])) {
                         $rel_mod = array();
                         foreach ($old_related_modules[$module] as $key => $name) {
                             if (vtlib_isModuleActive($name) && isPermitted($name, 'index', '')) {
                                 $rel_mod[] = $name;
                             }
                         }
                         if (!empty($rel_mod)) {
                             $this->related_modules[$module] = array_merge($this->related_modules[$module], $rel_mod);
                             $this->related_modules[$module] = array_unique($this->related_modules[$module]);
                         }
                     }
                 }
             }
             foreach ($this->related_modules as $module => $related_modules) {
                 if ($module == 'Emails') {
                     $this->related_modules[$module] = getEmailRelatedModules();
                 }
             }
             // Put the information in cache for re-use
             VTCacheUtils::updateReport_ListofModuleInfos($this->module_list, $this->related_modules);
         }
     }
 }
Ejemplo n.º 2
0
 public function initListOfModules()
 {
     global $old_related_modules;
     $adb = PearDatabase::getInstance();
     $this->inventory_modules = self::$inventory_modules;
     // $restricted_modules = array('Emails', 'Events', 'Webmails');
     $restricted_modules = array('Emails', 'Events', 'Webmails');
     global $current_user;
     if ($current_user->is_admin != "on") {
         $restricted_modules[] = "Users";
     }
     $restricted_blocks = array('LBL_IMAGE_INFORMATION', 'LBL_COMMENTS', 'LBL_COMMENT_INFORMATION');
     $this->module_id = array();
     $this->module_list = array();
     // Prefetch module info to check active or not and also get list of tabs
     $modulerows = vtlib_prefetchModuleActiveInfo(false);
     $cachedInfo = VTCacheUtils::lookupReport_ListofModuleInfos();
     if ($cachedInfo !== false) {
         $this->module_list = $cachedInfo['module_list'];
         $this->related_modules = $cachedInfo['related_modules'];
     } else {
         if ($modulerows) {
             foreach ($modulerows as $resultrow) {
                 if ($resultrow['presence'] == '1') {
                     continue;
                 }
                 // skip disabled modules
                 // ITS4YOU-UP SlOl 21. 2. 2014 11:38:13 add Assigned to Users module
                 if ($resultrow['isentitytype'] != '1' && $resultrow['name'] != "Users") {
                     continue;
                 }
                 // skip extension modules
                 if (in_array($resultrow['name'], $restricted_modules)) {
                     // skip restricted modules
                     continue;
                 }
                 if ($resultrow['name'] != 'Calendar') {
                     $this->module_id[$resultrow['tabid']] = $resultrow['name'];
                 } else {
                     $this->module_id[9] = $resultrow['name'];
                     $this->module_id[16] = $resultrow['name'];
                 }
                 // ITS4YOU-CR SlOl  2. 12. 2013 8:42:40
                 $this->init_list_for_module($resultrow['name']);
                 // ITS4YOU-END 2. 12. 2013 8:42:43
                 $this->module_list[$resultrow['name']] = array();
             }
             $moduleids = array_keys($this->module_id);
             //$adb->setDebug(true);
             $reportblocks = $adb->pquery("SELECT blockid, blocklabel, tabid FROM vtiger_blocks WHERE tabid IN (" . generateQuestionMarks($moduleids) . ")", array($moduleids));
             // $reportblocks = $adb->pquery("SELECT blockid, blocklabel, tabid FROM vtiger_blocks WHERE tabid IN (9,16)", array());
             //$adb->setDebug(false);
             $prev_block_label = '';
             if ($adb->num_rows($reportblocks) > 0) {
                 while ($resultrow = $adb->fetch_array($reportblocks)) {
                     $blockid = $resultrow['blockid'];
                     $blocklabel = $resultrow['blocklabel'];
                     $module = $this->module_id[$resultrow['tabid']];
                     if (in_array($blocklabel, $restricted_blocks) || in_array($blockid, $this->module_list[$module]) || isset($this->module_list[$module][vtranslate($blocklabel, $module)])) {
                         continue;
                     }
                     if ($blocklabel != "") {
                         if ($module == 'Calendar' && $blocklabel == 'LBL_CUSTOM_INFORMATION') {
                             $this->module_list[$module][$blockid] = vtranslate($blocklabel, $module);
                         } elseif ($module == 'Calendar' && in_array($blocklabel, array("LBL_RECURRENCE_INFORMATION", "LBL_RELATED_TO"))) {
                             $this->module_list[$module][$blockid] = vtranslate($blocklabel, "Events");
                         } else {
                             $this->module_list[$module][$blockid] = vtranslate($blocklabel, $module);
                         }
                         $prev_block_label = $blocklabel;
                         // ak je blocklabel prazdny spustat toto ??? zistit !!!
                     } else {
                         $this->module_list[$module][$blockid] = vtranslate($prev_block_label, $module);
                     }
                 }
             }
             // tvorba vazby cez ui10 a pridanie stlpcov k danemu modulu
             //    $adb->setDebug(true);
             $relatedmodules_pf = $adb->pquery("\n                                    SELECT uitype,fieldid, CONCAT(fieldlabel,' (',relmodule,') ') AS name, vtiger_tab.tabid, relmodule FROM vtiger_fieldmodulerel\n                                    INNER JOIN vtiger_tab on vtiger_tab.name = vtiger_fieldmodulerel.module \n                                    INNER JOIN vtiger_field USING (fieldid) \n                                    WHERE vtiger_tab.isentitytype = 1\n                                    AND vtiger_tab.name NOT IN(" . generateQuestionMarks($restricted_modules) . ")\n                                    AND vtiger_tab.presence = 0 AND vtiger_field.uitype='10' ", array($restricted_modules));
             //AND vtiger_tab.presence = 0 AND vtiger_field.uitype='10'  GROUP BY relmodule ", array($restricted_modules));
             //    $adb->setDebug(false);
             if ($adb->num_rows($relatedmodules_pf) > 0) {
                 $related_fields_array = array();
                 while ($resultrow = $adb->fetch_array($relatedmodules_pf)) {
                     $tabid = $resultrow['tabid'];
                     $module = $this->module_id[$tabid];
                     if (!isset($this->related_modules[$module])) {
                         $this->related_modules[$module] = array();
                     }
                     $this->init_list_for_module($module);
                     $field_rel = $st_rel_row["fieldlabel"];
                     if (is_numeric(strpos($resultrow["name"], $resultrow['relmodule']))) {
                         $reltabid = getTabid($resultrow["relmodule"]);
                         $relmodule_lbl = vtranslate($resultrow['name']);
                         $this->related_modules[$module][] = array("name" => $relmodule_lbl, "id" => $reltabid . "x" . $resultrow['fieldid']);
                     }
                 }
             }
             // pridanie modulu Users pre assigned user id ui type 53 na vyber poloziek
             // ITS4YOU-CR SlOl 21. 2. 2014 11:02:16
             foreach ($this->related_modules as $modulename => $related_array) {
                 $module_id = getTabid($modulename);
                 //$adb->setDebug(true);
                 $relatedmodules_at = $adb->pquery("SELECT fieldlabel, fieldid FROM vtiger_field WHERE uitype = ? AND tabid = ? AND presence IN (0,2)", array(53, $module_id));
                 //$adb->setDebug(false);
                 while ($row = $adb->fetchByAssoc($relatedmodules_at)) {
                     $user_module = "Users";
                     $user_module_lbl = vtranslate($user_module);
                     $this->related_modules[$modulename][] = array("name" => vtranslate($row['fieldlabel']) . " (" . $user_module_lbl . ")", "id" => getTabid($user_module) . "x" . $row['fieldid']);
                 }
             }
             // ITS4YOU-END 21. 2. 2014 11:02:18
             // related modules with MIF signature (more_info relation)
             $relatedmodules_mi = $adb->pquery("SELECT vtiger_tab.name AS name, vtiger_relatedlists.tabid FROM vtiger_tab\n                            INNER JOIN vtiger_relatedlists on vtiger_tab.tabid=vtiger_relatedlists.related_tabid\n                            WHERE vtiger_tab.isentitytype=1\n                            AND vtiger_tab.name NOT IN(" . generateQuestionMarks($restricted_modules) . ") \n                            AND vtiger_tab.presence = 0 AND vtiger_relatedlists.label!='Activity History'\n                        UNION \n                        SELECT module, vtiger_tab.tabid \n                            FROM vtiger_fieldmodulerel \n                            INNER JOIN vtiger_tab on vtiger_tab.name = vtiger_fieldmodulerel.relmodule \n                            INNER JOIN vtiger_field ON vtiger_field.fieldid = vtiger_fieldmodulerel.fieldid AND vtiger_field.uitype != '10' \n                            WHERE vtiger_tab.isentitytype = 1 AND vtiger_tab.name NOT IN('Emails','Events','Webmails') AND vtiger_tab.presence = 0   \n                        ", array($restricted_modules));
             //$adb->setDebug(true);
             while ($resultrow = $adb->fetch_array($relatedmodules_mi)) {
                 $tabid = $resultrow['tabid'];
                 $module = $this->module_id[$tabid];
                 $relmodule_lbl = vtranslate($resultrow['name']);
                 $this->related_modules[$module][] = array("name" => $relmodule_lbl, "id" => getTabid($resultrow['name']) . "xMIF");
             }
             //$adb->setDebug(false);
             // inventory modules related modules Services Products with INV signature (inventory relation)
             foreach ($this->related_modules as $module => $rel_array) {
                 foreach ($rel_array as $r_key => $r_d_array) {
                     if (in_array($module, $this->inventory_modules)) {
                         if (!in_array("Products", $r_d_array) && !$this->in_multiarray(vtranslate("Products"), $this->related_modules[$module])) {
                             $related_modules[$module][] = "Products";
                             $this->related_modules[$module][] = array("name" => vtranslate("Products"), "id" => getTabid("Products") . "xINV");
                             $r_d_array[] = "Products";
                         }
                         if (!in_array("Services", $r_d_array) && !$this->in_multiarray(vtranslate("Services"), $this->related_modules[$module])) {
                             $related_modules[$module][] = "Services";
                             $this->related_modules[$module][] = array("name" => vtranslate("Services"), "id" => getTabid("Services") . "xINV");
                             $r_d_array[] = "Services";
                         }
                     }
                 }
             }
             // Put the information in cache for re-use
             VTCacheUtils::updateReport_ListofModuleInfos($this->module_list, $this->related_modules);
         }
     }
 }
Ejemplo n.º 3
0
require_once 'modules/Home/HomeBlock.php';
require_once 'include/database/PearDatabase.php';
require_once 'include/utils/UserInfoUtil.php';
require_once 'include/utils/CommonUtils.php';
require_once 'include/freetag/freetag.class.php';
require_once 'modules/Home/HomeUtils.php';
global $app_strings, $app_list_strings, $mod_strings;
global $adb, $current_user;
global $theme;
global $current_language;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
$smarty = new vtigerCRM_Smarty();
$homeObj = new Homestuff();
// Performance Optimization
$tabrows = vtlib_prefetchModuleActiveInfo();
// END
//$query="select name,tabid from vtiger_tab where tabid in (select distinct(tabid) from vtiger_field where tabid <> 29 and tabid <> 16 and tabid <>10) order by name";
// Performance Optimization: Re-written to ignore extension and inactive modules
$modulenamearr = array();
foreach ($tabrows as $resultrow) {
    if ($resultrow['isentitytype'] != '0') {
        // Eliminate: Events, Emails
        if ($resultrow['tabid'] == '16' || $resultrow['tabid'] == '10' || $resultrow['name'] == 'Webmails') {
            continue;
        }
        $modName = $resultrow['name'];
        if (isPermitted($modName, 'DetailView') == 'yes' && vtlib_isModuleActive($modName)) {
            $modulenamearr[$modName] = array($resultrow['tabid'], $modName);
        }
    }
Ejemplo n.º 4
0
 function initListOfModules()
 {
     global $adb;
     $restricted_modules = array('Emails', 'Events', 'Webmails');
     $restricted_blocks = array('LBL_IMAGE_INFORMATION', 'LBL_COMMENTS', 'LBL_COMMENT_INFORMATION');
     //tabid and name of modules
     $this->module_id = array();
     //name and blocks of modules
     $this->module_list = array();
     $modulerows = vtlib_prefetchModuleActiveInfo(false);
     $cachedInfo = VTCacheUtils::lookupMap_ListofModuleInfos();
     if ($cachedInfo !== false) {
         $this->module_list = $cachedInfo['module_list'];
         $this->related_modules = $cachedInfo['related_modules'];
         $this->rel_fields = $cachedInfo['rel_fields'];
     } else {
         if ($modulerows) {
             foreach ($modulerows as $resultrow) {
                 if ($resultrow['presence'] == '1') {
                     continue;
                 }
                 // skip disabled modules
                 if ($resultrow['isentitytype'] != '1') {
                     continue;
                 }
                 // skip extension modules
                 if (in_array($resultrow['name'], $restricted_modules)) {
                     // skip restricted modules
                     continue;
                 }
                 if ($resultrow['name'] != 'Calendar') {
                     $this->module_id[$resultrow['tabid']] = $resultrow['name'];
                 } else {
                     $this->module_id[9] = $resultrow['name'];
                     $this->module_id[16] = $resultrow['name'];
                 }
                 $this->module_list[$resultrow['name']] = array();
             }
             //get tabId of all modules
             $moduleids = array_keys($this->module_id);
             $moduleblocks = $adb->pquery("SELECT blockid, blocklabel, tabid FROM vtiger_blocks WHERE tabid IN (" . generateQuestionMarks($moduleids) . ")", array($moduleids));
             $prev_block_label = '';
             if ($adb->num_rows($moduleblocks)) {
                 while ($resultrow = $adb->fetch_array($moduleblocks)) {
                     $blockid = $resultrow['blockid'];
                     $blocklabel = $resultrow['blocklabel'];
                     $module = $this->module_id[$resultrow['tabid']];
                     if (in_array($blocklabel, $restricted_blocks) || in_array($blockid, $this->module_list[$module]) || isset($this->module_list[$module][getTranslatedString($blocklabel, $module)])) {
                         continue;
                     }
                     if (!empty($blocklabel)) {
                         if ($module == 'Calendar' && $blocklabel == 'LBL_CUSTOM_INFORMATION') {
                             $this->module_list[$module][$blockid] = getTranslatedString($blocklabel, $module);
                         } else {
                             $this->module_list[$module][$blockid] = getTranslatedString($blocklabel, $module);
                         }
                         $prev_block_label = $blocklabel;
                     } else {
                         $this->module_list[$module][$blockid] = getTranslatedString($prev_block_label, $module);
                     }
                 }
             }
             //                $relatedmodules = $adb->pquery(
             //                        "SELECT vtiger_tab.name, vtiger_relatedlists.tabid FROM $dbname.vtiger_tab
             //                        INNER JOIN $dbname.vtiger_relatedlists on vtiger_tab.tabid=vtiger_relatedlists.related_tabid
             //                        WHERE vtiger_tab.isentitytype=1
             //                        AND vtiger_tab.name NOT IN(".generateQuestionMarks($restricted_modules).")
             //                        AND vtiger_tab.presence = 0 AND vtiger_relatedlists.label!='Activity History'
             //                        UNION
             //                        SELECT module, vtiger_tab.tabid FROM $dbname.vtiger_fieldmodulerel
             //                        INNER JOIN $dbname.vtiger_tab on vtiger_tab.name = vtiger_fieldmodulerel.relmodule
             //                        WHERE vtiger_tab.isentitytype = 1
             //                        AND vtiger_tab.name NOT IN(".generateQuestionMarks($restricted_modules).")
             //                        AND vtiger_tab.presence = 0",
             //                        array($restricted_modules,$restricted_modules)
             //                );
             $relatedmodules = $adb->pquery("SELECT module as name, vtiger_tab.tabid,fieldid FROM vtiger_fieldmodulerel\n                                INNER JOIN vtiger_tab on vtiger_tab.name = vtiger_fieldmodulerel.relmodule\n                                WHERE vtiger_tab.isentitytype = 1\n                                AND vtiger_tab.name NOT IN(" . generateQuestionMarks($restricted_modules) . ")\n                                AND vtiger_tab.presence = 0\n\t\t\t\tUNION\n\t\t\t        SELECT relmodule as name, vtiger_tab.tabid,fieldid FROM vtiger_fieldmodulerel\n                                INNER JOIN vtiger_tab on vtiger_tab.name = vtiger_fieldmodulerel.module\n                                WHERE vtiger_tab.isentitytype = 1\n                                AND vtiger_tab.name NOT IN(" . generateQuestionMarks($restricted_modules) . ")\n                                AND vtiger_tab.presence = 0", array($restricted_modules, $restricted_modules));
             if ($adb->num_rows($relatedmodules)) {
                 while ($resultrow = $adb->fetch_array($relatedmodules)) {
                     $module = $this->module_id[$resultrow['tabid']];
                     if (!isset($this->related_modules[$module])) {
                         $this->related_modules[$module] = array();
                     }
                     if (!isset($this->related_modules[$module])) {
                         $this->rel_fields[$module] = array();
                     }
                     if ($module != $resultrow['name']) {
                         $this->related_modules[$module][] = $resultrow['name'];
                         $this->rel_fields[$module][$resultrow['name']] = $this->getFieldName($resultrow['fieldid']);
                     }
                 }
             }
             // Put the information in cache for re-use
             VTCacheUtils::updateMap_ListofModuleInfos($this->module_list, $this->related_modules, $this->rel_fields);
         }
     }
 }