'Module Views', 'portal' => 'Portal', 'charts' => 'Charts', 'tools' => 'Tools', 'misc' => 'Miscellaneous', 'web' => 'Web'); $dashletStrings = array(); $dashletsList = array(); if (!empty($category)){ $dashletsList[$categories[$category]] = array(); } else{ $dashletsList['Module Views'] = array(); $dashletsList['Charts'] = array(); $dashletsList['Tools'] = array(); $dashletsList['Web'] = array(); } asort($dashletsFiles); foreach($dashletsFiles as $className => $files) { if(!empty($files['meta']) && is_file($files['meta'])) { require_once($files['meta']); // get meta file $directory = substr($files['meta'], 0, strrpos($files['meta'], '/') + 1); if(is_file($directory . $files['class'] . '.' . $current_language . '.lang.php')) require_once($directory . $files['class'] . '.' . $current_language . '.lang.php'); elseif(is_file($directory . $files['class'] . '.en_us.lang.php')) require_once($directory . $files['class'] . '.en_us.lang.php'); // try to translate the string if(empty($dashletStrings[$files['class']][$dashletMeta[$files['class']]['title']])) $title = $dashletMeta[$files['class']]['title']; else $title = $dashletStrings[$files['class']][$dashletMeta[$files['class']]['title']]; // try to translate the string if(empty($dashletStrings[$files['class']][$dashletMeta[$files['class']]['description']])) $description = $dashletMeta[$files['class']]['description']; else $description = $dashletStrings[$files['class']][$dashletMeta[$files['class']]['description']]; // generate icon if (!empty($dashletMeta[$files['class']]['icon'])) { // here we'll support image inheritance if the supplied image has a path in it // i.e. $dashletMeta[$files['class']]['icon'] = 'themes/default/images/dog.gif' // in this case, we'll strip off the path information to check for the image existing // in the current theme. $imageName = SugarThemeRegistry::current()->getImageURL(basename($dashletMeta[$files['class']]['icon']), false); if ( !empty($imageName) ) { if (sugar_is_file($imageName)) $icon = ''; //leaving alt tag blank on purpose for 508 else $icon = ''; } } else{ if (empty($dashletMeta[$files['class']]['module'])){ $icon = get_dashlets_dialog_icon('default'); } else{ if((!in_array($dashletMeta[$files['class']]['module'], $GLOBALS['moduleList']) && !in_array($dashletMeta[$files['class']]['module'], $GLOBALS['modInvisList'])) && (!in_array('Activities', $GLOBALS['moduleList']))){ unset($dashletMeta[$files['class']]); continue; }else{ $icon = get_dashlets_dialog_icon($dashletMeta[$files['class']]['module']); } } } // determine whether to display if (!empty($dashletMeta[$files['class']]['hidden']) && $dashletMeta[$files['class']]['hidden'] === true){ $displayDashlet = false; } //co: fixes 20398 to respect ACL permissions elseif(!empty($dashletMeta[$files['class']]['module']) && (!in_array($dashletMeta[$files['class']]['module'], $GLOBALS['moduleList']) && !in_array($dashletMeta[$files['class']]['module'], $GLOBALS['modInvisList'])) && (!in_array('Activities', $GLOBALS['moduleList']))){ $displayDashlet = false; } else{ $displayDashlet = true; //check ACL ACCESS if(!empty($dashletMeta[$files['class']]['module']) && ACLController::moduleSupportsACL($dashletMeta[$files['class']]['module'])){ $type = 'module'; if($dashletMeta[$files['class']]['module'] == 'Trackers') $type = 'Tracker'; if(!ACLController::checkAccess($dashletMeta[$files['class']]['module'], 'view', true, $type)){ $displayDashlet = false; } if(!ACLController::checkAccess($dashletMeta[$files['class']]['module'], 'list', true, $type)){ $displayDashlet = false; } } } if ($dashletMeta[$files['class']]['category'] == 'Charts'){ $type = 'predefined_chart'; } else{ $type = 'module'; } if ($displayDashlet && isset($dashletMeta[$files['class']]['dynamic_hide']) && $dashletMeta[$files['class']]['dynamic_hide']){ if ( file_exists($files['file']) ) { require_once($files['file']); if ( class_exists($files['class']) ) { $dashletClassName = $files['class']; $displayDashlet = call_user_func(array($files['class'],'shouldDisplay')); } } } if ($displayDashlet){ $cell = array( 'title' => $title, 'description' => $description, 'onclick' => 'return SUGAR.mySugar.addDashlet(\'' . $className . '\', \'' . $type . '\', \''.(!empty($dashletMeta[$files['class']]['module']) ? $dashletMeta[$files['class']]['module'] : '' ) .'\');', 'icon' => $icon, 'id' => $files['class'] . '_select', ); if (!empty($category) && $dashletMeta[$files['class']]['category'] == $categories[$category]){ array_push($dashletsList[$categories[$category]], $cell); } else if (empty($category)){ array_push($dashletsList[$dashletMeta[$files['class']]['category']], $cell); } } } } if (!empty($category)){ asort($dashletsList[$categories[$category]]); } else{ foreach($dashletsList as $key=>$value){ asort($dashletsList[$key]); } } $this->dashlets = $dashletsList; } } ?>