Esempio n. 1
0
 public function testEncodeUrls()
 {
     $message = "This test contains a url here http://www.sugarcrm.com and not here amazon.com";
     $text = SugarFeed::parseMessage($message);
     $this->assertContains("<a href='http://www.sugarcrm.com' target='_blank'>http://www.sugarcrm.com</a>", $text, "Url encoded incorrectly");
     $this->assertNotContains("http://amazon.com", $text, "Second link should not be encoded");
 }
Esempio n. 2
0
 public function pushFeed($bean, $event, $arguments)
 {
     $text = '';
     if (empty($bean->fetched_row)) {
         $text = 'New Application Uploaded [' . $bean->module_dir . ':' . $bean->id . ':' . $bean->name . ']';
     }
     if (!empty($text)) {
         SugarFeed::pushFeed2($text, $bean);
     }
 }
Esempio n. 3
0
 function pushFeed($bean, $event, $arguments)
 {
     $text = '';
     if (empty($bean->fetched_row)) {
         $text = '{SugarFeed.CREATED_CONTACT} [' . $bean->module_dir . ':' . $bean->id . ':' . $bean->first_name . ' ' . $bean->last_name . ']';
     }
     if (!empty($text)) {
         SugarFeed::pushFeed2($text, $bean);
     }
 }
Esempio n. 4
0
 function pushFeed($bean, $event, $arguments)
 {
     global $locale;
     $text = '';
     if (empty($bean->fetched_row)) {
         $text = '{SugarFeed.CREATED_ACCOUNT} [' . $bean->module_dir . ':' . $bean->id . ':' . $bean->name . ']';
     }
     if (!empty($text)) {
         SugarFeed::pushFeed2($text, $bean);
     }
 }
Esempio n. 5
0
 function pushFeed($bean, $event, $arguments)
 {
     $text = '';
     if (empty($bean->fetched_row)) {
         $text = '{SugarFeed.CREATED_CASE} [' . $bean->module_dir . ':' . $bean->id . ':' . $bean->name . '] {SugarFeed.FOR} [Accounts:' . $bean->account_id . ':' . $bean->account_name . ']<br>' . $bean->description;
     } else {
         if (!empty($bean->fetched_row['status']) && $bean->fetched_row['status'] != $bean->status && $bean->status == 'Closed') {
             $text = '{SugarFeed.CLOSED_CASE} [' . $bean->module_dir . ':' . $bean->id . ':' . $bean->name . '] {SugarFeed.FOR} [Accounts:' . $bean->account_id . ':' . $bean->account_name . ']';
         }
     }
     if (!empty($text)) {
         SugarFeed::pushFeed2($text, $bean);
     }
 }
Esempio n. 6
0
 function pushFeed($bean, $event, $arguments)
 {
     global $locale;
     $text = '';
     if (empty($bean->fetched_row)) {
         $full_name = $locale->getLocaleFormattedName($bean->first_name, $bean->last_name, '');
         $text = '{SugarFeed.CREATED_LEAD} [' . $bean->module_dir . ':' . $bean->id . ':' . $full_name . ']';
     } else {
         if (!empty($bean->fetched_row['status']) && $bean->fetched_row['status'] != $bean->status && $bean->status == 'Converted') {
             // Repeated here so we don't format the name on "uninteresting" events
             $full_name = $locale->getLocaleFormattedName($bean->first_name, $bean->last_name, '');
             $text = '{SugarFeed.CONVERTED_LEAD} [' . $bean->module_dir . ':' . $bean->id . ':' . $full_name . ']';
         }
     }
     if (!empty($text)) {
         SugarFeed::pushFeed2($text, $bean);
     }
 }
Esempio n. 7
0
 function pushFeed($bean, $event, $arguments)
 {
     $text = '';
     if (empty($bean->fetched_row)) {
         $currency = new Currency();
         $currency->retrieve($bean->currency_id);
         $text = '{SugarFeed.CREATED_OPPORTUNITY} [' . $bean->module_dir . ':' . $bean->id . ':' . $bean->name . '] {SugarFeed.WITH} [Accounts:' . $bean->account_id . ':' . $bean->account_name . '] {SugarFeed.FOR} ' . $currency->symbol . format_number($bean->amount);
     } else {
         if (!empty($bean->fetched_row['sales_stage']) && $bean->fetched_row['sales_stage'] != $bean->sales_stage && $bean->sales_stage == 'Closed Won') {
             $currency = new Currency();
             $currency->retrieve($bean->currency_id);
             $text = '{SugarFeed.WON_OPPORTUNITY} [' . $bean->module_dir . ':' . $bean->id . ':' . $bean->name . '] {SugarFeed.WITH} [Accounts:' . $bean->account_id . ':' . $bean->account_name . '] {SugarFeed.FOR} ' . $currency->symbol . format_number($bean->amount);
         }
     }
     if (!empty($text)) {
         SugarFeed::pushFeed2($text, $bean);
     }
 }
Esempio n. 8
0
 function pushFeed($bean, $event, $arguments)
 {
     $text = '';
     if (empty($bean->fetched_row) && $bean->in_save) {
         $accountName = $bean->account_name;
         if (empty($accountName) && $bean->account_id) {
             $acc = BeanFactory::getBean('Accounts', $bean->account_id);
             $accountName = $acc->name;
         }
         $text = '{SugarFeed.CREATED_CASE} [' . $bean->module_dir . ':' . $bean->id . ':' . $bean->name . '] {SugarFeed.FOR} [Accounts:' . $bean->account_id . ':' . $accountName . ']: ' . $bean->description;
     } else {
         if (!empty($bean->fetched_row['status']) && $bean->fetched_row['status'] != $bean->status && strpos($bean->status, 'Closed') !== false) {
             $text = '{SugarFeed.CLOSED_CASE} [' . $bean->module_dir . ':' . $bean->id . ':' . $bean->name . '] {SugarFeed.FOR} [Accounts:' . $bean->account_id . ':' . $bean->account_name . ']';
         }
     }
     if (!empty($text)) {
         SugarFeed::pushFeed2($text, $bean);
     }
 }
 public function clearSugarFeedCache()
 {
     global $mod_strings;
     if ($this->show_output) {
         echo "<h3>{$mod_strings['LBL_QR_CLEARSUGARFEEDCACHE']}</h3>";
     }
     SugarFeed::flushBackendCache();
 }
Esempio n. 10
0
 /**
  * @deprecated This is a depreciated method and will be removed in version 7.3.
  */
 public function getLatestUpdates($maxTime, $maxEntries)
 {
     $td = $GLOBALS['timedate'];
     try {
         if (!$this->setupFacebookLib()) {
             // FIXME: Translate
             return array('success' => FALSE, 'errorMessage' => 'Facebook does not have the required libraries.');
         }
         $fbMessages = $this->fb->api('/me/home?limit=' . $maxEntries);
     } catch (FacebookApiException $e) {
         // We should ask user about second login to facebook because our access_token is dead.
         if ($e->getType() == 'OAuthException' && !empty($this->eapmBean->id)) {
             return array('success' => true, 'messages' => array(array('ID' => create_guid(), 'sort_key' => time(), 'NAME' => translate('LBL_ERR_OAUTH_FACEBOOK_1', 'EAPM') . ' <a href="#" onclick="window.open(\'index.php?module=EAPM&amp;refreshParentWindow=1&amp;closeWhenDone=1&amp;action=QuickSave&amp;application=Facebook\',\'EAPM\');">' . translate('LBL_ERR_OAUTH_FACEBOOK_2', 'EAPM') . '</a>.')));
         }
         $GLOBALS['log']->error('Facebook Error: ' . $e->getMessage());
         return array('success' => FALSE, 'errorMessage' => translate('LBL_ERR_FACEBOOK', 'EAPM'));
     }
     if (!isset($fbMessages['data'][0])) {
         return array('success' => TRUE, 'messages' => array());
     }
     $messages = array();
     foreach ($fbMessages['data'] as $message) {
         if (empty($message['message'])) {
             continue;
         }
         $unix_time = strtotime($message['created_time']);
         $fake_record = array();
         $fake_record['sort_key'] = $unix_time;
         $fake_record['ID'] = create_guid();
         $fake_record['DATE_ENTERED'] = $td->to_display_date_time(gmdate('Y-m-d H:i:s', $unix_time));
         $fake_record['NAME'] = $message['from']['name'] . '</b>';
         if (!empty($message['message'])) {
             $fake_record['NAME'] .= ' ' . $message['message'];
         }
         if (!empty($message['picture'])) {
             $fake_record['NAME'] .= '<br><!--not_in_theme!--><img src="' . $message['picture'] . '" height=50>';
         }
         $fake_record['NAME'] .= '<br><div class="byLineBox"><span class="byLineLeft">' . SugarFeed::getTimeLapse($fake_record['DATE_ENTERED']) . '&nbsp;</span><div class="byLineRight">&nbsp;</div></div>';
         $fake_record['IMAGE_URL'] = "https://graph.facebook.com/" . $message['from']['id'] . '/picture';
         $messages[] = $fake_record;
     }
     return array('success' => TRUE, 'messages' => $messages);
 }
Esempio n. 11
0
 /** 
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $app_strings;
     $admin = new Administration();
     $admin->retrieveSettings();
     // Handle posts
     if (!empty($_REQUEST['process'])) {
         // Check the cleanup logic hook, make sure it is still there
         check_logic_hook_file('Users', 'after_login', array(1, 'SugarFeed old feed entry remover', 'modules/SugarFeed/SugarFeedFlush.php', 'SugarFeedFlush', 'flushStaleEntries'));
         // We have data posted
         if ($_REQUEST['process'] == 'true') {
             // They want us to process it, the false will just fall outside of this statement
             if ($_REQUEST['feed_enable'] == '1') {
                 // The feed is enabled, pay attention to what categories should be enabled or disabled
                 $db = DBManagerFactory::getInstance();
                 $ret = $db->query("SELECT * FROM config WHERE category = 'sugarfeed' AND name LIKE 'module_%'");
                 $current_modules = array();
                 while ($row = $db->fetchByAssoc($ret)) {
                     $current_modules[$row['name']] = $row['value'];
                 }
                 $active_modules = $_REQUEST['modules'];
                 if (!is_array($active_modules)) {
                     $active_modules = array();
                 }
                 foreach ($active_modules as $name => $is_active) {
                     $module = substr($name, 7);
                     if ($is_active == '1') {
                         // They are activating something that was disabled before
                         SugarFeed::activateModuleFeed($module);
                     } else {
                         // They are disabling something that was active before
                         SugarFeed::disableModuleFeed($module);
                     }
                 }
                 $admin->saveSetting('sugarfeed', 'enabled', '1');
             } else {
                 $admin->saveSetting('sugarfeed', 'enabled', '0');
                 // Now we need to remove all of the logic hooks, so they don't continue to run
                 // We also need to leave the database alone, so they can enable/disable modules with the system disabled
                 $modulesWithFeeds = SugarFeed::getAllFeedModules();
                 foreach ($modulesWithFeeds as $currFeedModule) {
                     SugarFeed::disableModuleFeed($currFeedModule, FALSE);
                 }
             }
             $admin->retrieveSettings(FALSE, TRUE);
             SugarFeed::flushBackendCache();
         } else {
             if ($_REQUEST['process'] == 'deleteRecords') {
                 if (!isset($db)) {
                     $db = DBManagerFactory::getInstance();
                 }
                 $db->query("UPDATE sugarfeed SET deleted = '1'");
                 echo translate('LBL_RECORDS_DELETED', 'SugarFeed');
             }
         }
         if ($_REQUEST['process'] == 'true' || $_REQUEST['process'] == 'false') {
             header('Location: index.php?module=Administration&action=index');
             return;
         }
     }
     $sugar_smarty = new Sugar_Smarty();
     $sugar_smarty->assign('mod', $mod_strings);
     $sugar_smarty->assign('app', $app_strings);
     if (isset($admin->settings['sugarfeed_enabled']) && $admin->settings['sugarfeed_enabled'] == '1') {
         $sugar_smarty->assign('enabled_checkbox', 'checked');
     }
     $possible_feeds = SugarFeed::getAllFeedModules();
     $module_list = array();
     $userFeedEnabled = 0;
     foreach ($possible_feeds as $module) {
         $currModule = array();
         if (isset($admin->settings['sugarfeed_module_' . $module]) && $admin->settings['sugarfeed_module_' . $module] == '1') {
             $currModule['enabled'] = 1;
         } else {
             $currModule['enabled'] = 0;
         }
         $currModule['module'] = $module;
         if ($module == 'UserFeed') {
             // Fake module, need to handle specially
             $userFeedEnabled = $currModule['enabled'];
             continue;
         } else {
             $currModule['label'] = $GLOBALS['app_list_strings']['moduleList'][$module];
         }
         $module_list[] = $currModule;
     }
     $sugar_smarty->assign('module_list', $module_list);
     $sugar_smarty->assign('user_feed_enabled', $userFeedEnabled);
     echo getClassicModuleTitle("Administration", array("<a href='index.php?module=Administration&action=index'>" . translate('LBL_MODULE_NAME', 'Administration') . "</a>", $mod_strings['LBL_MODULE_NAME']), false);
     $sugar_smarty->display('modules/SugarFeed/tpls/AdminSettings.tpl');
 }
Esempio n. 12
0
 function fetchReplies($data)
 {
     $seedBean = new SugarFeed();
     $replies = $seedBean->get_list('date_entered', "related_module = 'SugarFeed' AND related_id = '" . $data['ID'] . "'");
     if (count($replies['list']) < 1) {
         return '';
     }
     $replyHTML = '<div class="clear"></div><blockquote>';
     foreach ($replies['list'] as $reply) {
         // Setup the delete link
         $delete = '';
         if (is_admin($GLOBALS['current_user']) || $data['CREATED_BY'] == $GLOBALS['current_user']->id) {
             $delete = '<a id="sugarFieldDeleteLink' . $reply->id . '" href="#" onclick=\'SugarFeed.deleteFeed("' . $reply->id . '", "{this.id}"); return false;\'>' . $GLOBALS['app_strings']['LBL_DELETE_BUTTON_LABEL'] . '</a>';
         }
         $image_url = 'include/images/default_user_feed_picture.png';
         if (isset($reply->created_by)) {
             $user = loadBean('Users');
             $user->retrieve($reply->created_by);
             $image_url = 'index.php?entryPoint=download&id=' . $user->picture . '&type=SugarFieldImage&isTempFile=1&isProfile=1';
         }
         $replyHTML .= '<div style="float: left; margin-right: 3px; width: 50px; height: 50px;"><!--not_in_theme!--><img src="' . $image_url . '" style="max-width: 50px; max-height: 50px;"></div> ';
         $replyHTML .= str_replace("{this.CREATED_BY}", get_assigned_user_name($reply->created_by), html_entity_decode($reply->name)) . '<br>';
         $replyHTML .= '<div class="byLineBox"><span class="byLineLeft">' . $this->getTimeLapse($reply->date_entered) . '&nbsp;</span><div class="byLineRight">  &nbsp;' . $delete . '</div></div><div class="clear"></div>';
     }
     $replyHTML .= '</blockquote>';
     return $replyHTML;
 }
Esempio n. 13
0
 function get_list_view_data()
 {
     $data = parent::get_list_view_data();
     $delete = '';
     if (ACLController::moduleSupportsACL($data['RELATED_MODULE']) && !ACLController::checkAccess($data['RELATED_MODULE'], 'view', $data['CREATED_BY'] == $GLOBALS['current_user']->id) && !ACLController::checkAccess($data['RELATED_MODULE'], 'list', $data['CREATED_BY'] == $GLOBALS['current_user']->id)) {
         $data['NAME'] = '';
         return $data;
     }
     if (is_admin($GLOBALS['current_user']) || $data['CREATED_BY'] == $GLOBALS['current_user']->id) {
         $delete = get_image($GLOBALS['image_path'] . '/delete_inline', 'width="12" height="12" border="0" align="absmiddle" style="vertical-align: bottom;" onclick=\'SugarFeed.deleteFeed("' . $data['ID'] . '", "{this.id}")\'');
     }
     $data['NAME'] .= $data['DESCRIPTION'];
     $data['NAME'] = '<div class="list view" style="padding:5px;border-right:none;border-left:none;border-top:none;">' . html_entity_decode($data['NAME']);
     if (!empty($data['LINK_URL'])) {
         $linkClass = SugarFeed::getLinkClass($data['LINK_TYPE']);
         if ($linkClass !== FALSE) {
             $data['NAME'] .= $linkClass->getDisplay($data);
         }
     }
     $data['NAME'] .= '<div class="byLineBox"><span class="byLineLeft">';
     $data['NAME'] .= '&nbsp;</span><div class="byLineRight"> ' . $this->getTimeLapse($data['DATE_ENTERED']) . ' &nbsp;' . $delete . '</div></div>';
     return $data;
 }
 /**
  *
  * @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');
 }
Esempio n. 15
0
 public function testparseMessage()
 {
     //test with a string with no links
     $html = 'some text with no urls';
     $result = SugarFeed::parseMessage($html);
     $this->assertEquals($html, $result);
     //test with a string with links
     $html = 'some text http://www.url.com with no urls';
     $expected = "some text <a href='http://www.url.com' target='_blank'>http://www.url.com</a> with no urls";
     $result = SugarFeed::parseMessage($html);
     $this->assertEquals($expected, $result);
 }
Esempio n. 16
0
/**
 * Fully enable SugarFeeds, enabling the user feed and all available modules that have SugarFeed data.
 */
function enableSugarFeeds()
{
    $admin = new Administration();
    $admin->saveSetting('sugarfeed', 'enabled', '1');
    foreach (SugarFeed::getAllFeedModules() as $module) {
        SugarFeed::activateModuleFeed($module);
    }
    check_logic_hook_file('Users', 'after_login', array(1, 'SugarFeed old feed entry remover', 'modules/SugarFeed/SugarFeedFlush.php', 'SugarFeedFlush', 'flushStaleEntries'));
}
Esempio n. 17
0
/**
 * Fully enable SugarFeeds, enabling the user feed and all available modules that have SugarFeed data.
 */
function enableSugarFeeds()
{
    $admin = new Administration();
    $admin->saveSetting('sugarfeed', 'enabled', '1');
    foreach (SugarFeed::getAllFeedModules() as $module) {
        SugarFeed::activateModuleFeed($module);
    }
}
Esempio n. 18
0
            $db->query("UPDATE sugarfeed SET deleted = '1'");
            echo translate('LBL_RECORDS_DELETED', 'SugarFeed');
        }
    }
    if ($_REQUEST['process'] == 'true' || $_REQUEST['process'] == 'false') {
        header('Location: index.php?module=Administration&action=index');
        return;
    }
}
$sugar_smarty = new Sugar_Smarty();
$sugar_smarty->assign('mod', $mod_strings);
$sugar_smarty->assign('app', $app_strings);
if (isset($admin->settings['sugarfeed_enabled']) && $admin->settings['sugarfeed_enabled'] == '1') {
    $sugar_smarty->assign('enabled_checkbox', 'checked');
}
$possible_feeds = SugarFeed::getAllFeedModules();
$module_list = array();
$userFeedEnabled = 0;
foreach ($possible_feeds as $module) {
    $currModule = array();
    if (isset($admin->settings['sugarfeed_module_' . $module]) && $admin->settings['sugarfeed_module_' . $module] == '1') {
        $currModule['enabled'] = 1;
    } else {
        $currModule['enabled'] = 0;
    }
    $currModule['module'] = $module;
    if ($module == 'UserFeed') {
        // Fake module, need to handle specially
        $userFeedEnabled = $currModule['enabled'];
        continue;
    } else {
Esempio n. 19
-1
 function pushFeed($bean, $event, $arguments)
 {
     global $locale;
     $text = '';
     if (empty($bean->fetched_row)) {
         $text = '{SugarFeed.CREATED_ACTIVITY} [' . $bean->module_dir . ':' . $bean->id . ':' . $locale->getLocaleFormattedName($bean->first_name, $bean->last_name) . ']';
     }
     if (!empty($text)) {
         SugarFeed::pushFeed2($text, $bean);
     }
 }