static function getLinkClass($linkName) { $linkTypeList = SugarFeed::getLinkTypes(); // Have to make sure the linkName is on the list, so they can't pass in linkName's like ../../config.php ... not that they could get anywhere if they did if (!isset($linkTypeList[$linkName])) { // No class by this name... return FALSE; } if (file_exists('custom/modules/SugarFeed/linkHandlers/' . $linkName . '.php')) { require_once 'custom/modules/SugarFeed/linkHandlers/' . $linkName . '.php'; } else { require_once 'modules/SugarFeed/linkHandlers/' . $linkName . '.php'; } $linkClassName = 'FeedLinkHandler' . $linkName; $linkClass = new $linkClassName(); return $linkClass; }
/** * * @return the form for users posting custom messages to the feed stream */ function getPostForm() { global $current_user; if (!empty($this->selectedCategories) && !in_array('UserFeed', $this->selectedCategories)) { // The user feed system isn't enabled, don't let them post notes return ''; } $user_name = ucfirst($GLOBALS['current_user']->user_name); $moreimg = SugarThemeRegistry::current()->getImage('advanced_search', 'onclick="toggleDisplay(\'more_' . $this->id . '\'); toggleDisplay(\'more_img_' . $this->id . '\'); toggleDisplay(\'less_img_' . $this->id . '\');"', null, null, '.gif', translate('LBL_SHOW_MORE_OPTIONS', 'SugarFeed')); $lessimg = SugarThemeRegistry::current()->getImage('basic_search', 'onclick="toggleDisplay(\'more_' . $this->id . '\'); toggleDisplay(\'more_img_' . $this->id . '\'); toggleDisplay(\'less_img_' . $this->id . '\');"', null, null, '.gif', translate('LBL_HIDE_OPTIONS', 'SugarFeed')); $ss = new Sugar_Smarty(); $ss->assign('LBL_TO', translate('LBL_TO', 'SugarFeed')); $ss->assign('LBL_POST', translate('LBL_POST', 'SugarFeed')); $ss->assign('LBL_SELECT', translate('LBL_SELECT', 'SugarFeed')); $ss->assign('LBL_IS', translate('LBL_IS', 'SugarFeed')); $ss->assign('id', $this->id); $ss->assign('more_img', $moreimg); $ss->assign('less_img', $lessimg); if ($current_user->getPreference('use_real_names') == 'on') { $ss->assign('user_name', $current_user->full_name); } else { $ss->assign('user_name', $user_name); } $linkTypesIn = SugarFeed::getLinkTypes(); $linkTypes = array(); foreach ($linkTypesIn as $key => $value) { $linkTypes[$key] = translate('LBL_LINK_TYPE_' . $value, 'SugarFeed'); } $ss->assign('link_types', $linkTypes); return $ss->fetch('modules/SugarFeed/Dashlets/SugarFeedDashlet/UserPostForm.tpl'); }
public function testgetLinkTypes() { $result = SugarFeed::getLinkTypes(); $expected = array('Image' => 'Image', 'Link' => 'Link', 'YouTube' => 'YouTube'); $this->assertEquals($expected, $result); }