Example #1
0
    /**
     * 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;
        }
    }
$exclude					=	$plugin->params->get( 'general_exclude', null );
$display					=	(int) $params->get( 'activity_display', 1 );
$avatar						=	(int) $params->get( 'activity_avatar', 0 );
$cutOff						=	(int) $params->get( 'activity_cut_off', 5 );
$limit						=	(int) $params->get( 'activity_limit', 10 );
$titleLimit					=	(int) $params->get( 'activity_title_length', 100 );
$descLimit					=	(int) $params->get( 'activity_desc_length', 100 );
$imgThumbnails				=	(int) $params->get( 'activity_img_thumbnails', 1 );
$user						=	CBuser::getUserDataInstance( $_CB_framework->myId() );
$now						=	$_CB_framework->getUTCNow();

outputCbJs( 1 );
outputCbTemplate( 1 );

cbactivityClass::getTemplate( array( 'module', 'jquery', 'activity' ) );
HTML_cbactivityJquery::loadJquery( 'module', $user, $plugin );

switch( $display ) {
	case 2: // Connections Only
		$where				=	array( 'b.referenceid', '=', (int) $user->get( 'id' ), 'b.accepted', '=', 1, 'b.pending', '=', 0 );
		break;
	case 3: // Self Only
		$where				=	array( 'user_id', '=', (int) $user->get( 'id' ) );
		break;
	case 4: // Connections and Self
		$where				=	array( 'user_id', '=', (int) $user->get( 'id' ), array( 'b.referenceid', '=', (int) $user->get( 'id' ), 'b.accepted', '=', 1, 'b.pending', '=', 0 ) );
		break;
	default: // Everyone
		$where				=	array();
		break;
Example #3
0
 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;
 }