/** * Streams activity to selected extension stream. The parameters should include required values based on extension as associative array * * <ul> * <li>command: command for jomsocial activity, mostly component_name.action</li> * <li>title: title of the stream</li> * <li>description: short description. if full text is passed it will be stripped upto length <code>$params['length']</code></li> * <li>length: max length of the activity description</li> * <li>href: url of the stream</li> * <li>icon: icon to be used for mighty touch stream</li> * <li>component: component name i.e.com_yourcomponentname</li> * <li>group: group name for touch stream. ex. Articles</li> * </ul> * * @param string $system Component to stream * @param int $userid User id * @param array $params params based on component type */ public static function stream_activity($system, $userid, $params = array()) { switch ($system) { case 'jomsocial': $api = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php'; if (file_exists($api) && !empty($params['title']) && !empty($params['command'])) { include_once $api; CFactory::load('libraries', 'activities'); $act = new stdClass(); $act->cmd = 'wall.write'; $act->target = 0; $act->app = 'wall'; $act->cid = 0; $act->comment_id = CActivities::COMMENT_SELF; $act->like_id = CActivities::LIKE_SELF; $act->actor = $userid; $act->title = $params['title']; $act->comment_type = $params['command']; $act->like_type = $params['command']; $act->access = 0; if (!empty($params['description']) && !empty($params['length'])) { $content = CJFunctions::substrws($params['description'], $params['length']); if (!empty($params['href'])) { $act->content = $content . ' <div style="margin-top: 5px;"> <div style="float: right; font-weight: bold; font-size: 12px;"> <a href="' . $params['href'] . '">' . JText::_('COM_CJLIB_READ_MORE') . '</a> </div> <div style="clear: both;"></div> </div>'; } else { $act->content = $content; } } CActivityStream::add($act); } break; case 'cb': global $_CB_framework, $_CB_database, $ueConfig, $mainframe; $api = JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php'; if (!is_file($api)) { return; } require_once $api; cbimport('cb.database'); cbimport('cb.tables'); cbimport('cb.field'); cbimport('language.front'); $activity = new cbactivityActivity($_CB_database); $activity->set('user_id', (int) $userid); $activity->set('type', 'profile'); $activity->set('subtype', 'registration'); $activity->set('title', 'has joined [sitename_linked]'); $activity->set('icon', 'nameplate'); $activity->set('date', cbactivityClass::getUTCDate()); $activity->store(); break; case 'easysocial': $api = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_easysocial' . DS . 'includes' . DS . 'foundry.php'; if (file_exists($api)) { require_once $api; $stream = Foundry::stream(); $template = $stream->getTemplate(); $content = $params['length'] > 0 ? CJFunctions::substrws($params['description'], $params['length']) : $params['description']; $template->setActor($userid, 'user'); $template->setContext($params['item_id'], $params['context']); $template->setTitle($params['title']); $template->setContent($content); $template->setVerb('create'); // $template->setSideWide( true ); $template->setType('full'); $stream->add($template); } break; } }
public function pushActivity($actor_id, $act_type, $act_subtype = '', $act_description = '', $act_link = '', $act_title = '', $act_access) { //load CB framework global $_CB_framework, $mainframe; if (defined('JPATH_ADMINISTRATOR')) { if (!file_exists(JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php')) { echo 'CB not installed!'; return false; } include_once JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php'; } else { if (!file_exists($mainframe->getCfg('absolute_path') . '/administrator/components/com_comprofiler/plugin.foundation.php')) { echo 'CB not installed!'; return false; } include_once $mainframe->getCfg('absolute_path') . '/administrator/components/com_comprofiler/plugin.foundation.php'; } cbimport('cb.plugins'); cbimport('cb.html'); cbimport('cb.database'); cbimport('language.front'); cbimport('cb.snoopy'); cbimport('cb.imgtoolbox'); global $_CB_framework, $_CB_database, $ueConfig; //load cb activity plugin class if (!file_exists(JPATH_SITE . DS . "components" . DS . "com_comprofiler" . DS . "plugin" . DS . "user" . DS . "plug_cbactivity" . DS . "cbactivity.class.php")) { //echo 'CB Activity plugin not installed!'; return false; } require_once JPATH_SITE . DS . "components" . DS . "com_comprofiler" . DS . "plugin" . DS . "user" . DS . "plug_cbactivity" . DS . "cbactivity.class.php"; //push activity $linkHTML = '<a href="' . $act_link . '">' . $act_title . '</a>'; $activity = new cbactivityActivity($_CB_database); $activity->set('user_id', $actor_id); $activity->set('type', $act_type); $activity->set('subtype', $act_subtype); $activity->set('title', $act_description . ' ' . $linkHTML); $activity->set('icon', 'nameplate'); $activity->set('date', cbactivityClass::getUTCDate()); $activity->store(); return true; }