Exemple #1
0
 /**
  * Creates a new stream for new comments in EasyBlog
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function createCommentStream($comment, $blog)
 {
     if (!$this->config->get('integrations_easysocial_stream_newcomment')) {
         return false;
     }
     if (!$this->exists()) {
         return false;
     }
     $stream = Foundry::stream();
     $template = $stream->getTemplate();
     // Get the stream template
     $template->setActor($comment->created_by, SOCIAL_TYPE_USER);
     $template->setContext($comment->id, 'blog');
     $template->setContent($comment->comment);
     $template->setVerb('create.comment');
     $template->setPublicStream('easyblog.blog.view');
     $state = $stream->add($template);
     return $state;
 }
Exemple #2
0
 /**
  * Triggered when user logs into the site
  *
  * @since	1.0
  * @access	public
  * @return
  */
 public function onUserLogin($user, $options = array())
 {
     // Include main file.
     jimport('joomla.filesystem.file');
     $path = JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php';
     if (!JFile::exists($path)) {
         return;
     }
     // Include the foundry engine
     require_once $path;
     // Load the language string.
     Foundry::language()->load('plg_user_easysocial', JPATH_ADMINISTRATOR);
     // Check if Foundry exists
     if (!Foundry::exists()) {
         Foundry::language()->loadSite();
         echo JText::_('COM_EASYSOCIAL_FOUNDRY_DEPENDENCY_MISSING');
         return;
     }
     if (isset($user['status']) && $user['status'] && $user['type'] == 'Joomla') {
         //successful logged in.
         $my = JUser::getInstance();
         if ($id = intval(JUserHelper::getUserId($user['username']))) {
             $my->load($id);
         }
         $config = Foundry::config();
         $app = Foundry::table('App');
         $app->load(array('element' => 'users', 'group' => SOCIAL_TYPE_USER));
         $appParams = $app->getParams();
         $addStream = false;
         if ($appParams->get('stream_login', true)) {
             $addStream = true;
         }
         // do not add stream when user login from backend.
         $mainframe = JFactory::getApplication();
         // If this is the admin area, skip this.
         if ($mainframe->isAdmin()) {
             return;
         }
         // Only proceed if we need to add the stream
         if ($addStream) {
             $model = Foundry::model('Users');
             // Get the last login time the user previously logged in.
             $lastLogin = $model->getLastLogin($my->id);
             if ($lastLogin) {
                 $lastLogin->count = Foundry::isJoomla25() ? $lastLogin->count + 1 : $lastLogin->count;
                 if ($lastLogin->count >= 2 && $lastLogin->limit < $lastLogin->time) {
                     $addStream = false;
                 }
             }
         }
         if ($addStream) {
             $myUser = Foundry::user($my->id);
             $stream = Foundry::stream();
             $template = $stream->getTemplate();
             $template->setActor($my->id, SOCIAL_TYPE_USER);
             $template->setContext($my->id, SOCIAL_TYPE_USERS);
             $template->setVerb('login');
             // Set the stream to be public
             $template->setAccess('core.view');
             // Add the new template.
             $stream->add($template);
         }
     }
 }
 public function pushActivity($actor_id, $act_type, $act_subtype, $act_description, $act_link, $act_title, $act_access)
 {
     if ($actor_id != 0) {
         $myUser = Foundry::user($actor_id);
     }
     $stream = Foundry::stream();
     $template = $stream->getTemplate();
     $template->setActor($actor_id, SOCIAL_TYPE_USER);
     $template->setContext($actor_id, SOCIAL_TYPE_USERS);
     $template->setVerb('invite');
     $template->setType(SOCIAL_STREAM_DISPLAY_MINI);
     if ($actor_id != 0) {
         $userProfileLink = '<a href="' . $myUser->getPermalink() . '">' . $myUser->getName() . '</a>';
         $title = $userProfileLink . " " . $act_description;
     } else {
         $title = "A guest " . $act_description;
     }
     $template->setTitle($title);
     $template->setAggregate(false);
     $template->setPublicStream('core.view');
     $stream->add($template);
     return true;
 }
 /**
  * Store information about activity.
  *
  * <code>
  * $userId = 1;
  * $content = "...";
  *
  * $activity = new Prism\Integration\Activity\EasySocial($userId, $content);
  * $activity->store();
  * </code>
  *
  * @throws \RuntimeException
  */
 public function store()
 {
     // Retrieve the stream library.
     $stream = \Foundry::stream();
     // Retrieve the stream template.
     $template = $stream->getTemplate();
     // Set the actor that is generating this stream item.
     $template->setActor($this->actorId, $this->actorType);
     // Set the context type of this stream item.
     $template->setContext($this->contextId, $this->contextType);
     // Set the title.
     $template->setTitle($this->title);
     // Set the content.
     $template->setContent($this->content);
     // Set the verb / action for this stream item.
     // Example verbs: add, edit , create , update , delete.
     $template->setVerb($this->verb);
     // Set the type of the stream, whether it should be rendered in full mode or mini mode.
     // Mini mode does not have a header and does not actions on the stream.
     // Example types: full,mini
     $template->setType($this->type);
     $template->setSiteWide($this->siteWide);
     // Set target ID.
     if ($this->targetId > 0) {
         $template->setTarget($this->targetId);
     }
     $stream->add($template);
 }
Exemple #5
0
 function pushToEasySocialActivity($actor_id, $act_type, $act_subtype = '', $act_description = '', $act_link = '', $act_title = '', $act_access)
 {
     require_once JPATH_ROOT . '/administrator/components/com_easysocial/includes/foundry.php';
     if ($actor_id != 0) {
         $myUser = Foundry::user($actor_id);
     }
     $stream = Foundry::stream();
     $template = $stream->getTemplate();
     $template->setActor($actor_id, SOCIAL_TYPE_USER);
     $template->setContext($actor_id, SOCIAL_TYPE_USERS);
     $template->setVerb('invite');
     $template->setType(SOCIAL_STREAM_DISPLAY_MINI);
     if ($actor_id != 0) {
         $userProfileLink = '<a href="' . $myUser->getPermalink() . '">' . $myUser->getName() . '</a>';
         $title = $userProfileLink . " " . $act_description;
     } else {
         $title = "A guest " . $act_description;
     }
     $template->setTitle($title);
     $template->setAggregate(false);
     $template->setPublicStream('core.view');
     $stream->add($template);
     return true;
 }
Exemple #6
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;
        }
    }
Exemple #7
0
 public function deleteActivity($app, $activity)
 {
     switch ($app) {
         case 'cjforum':
             break;
         case 'jomsocial':
             break;
         case 'easysocial':
             $api = JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php';
             if (file_exists($api)) {
                 require_once $api;
                 Foundry::stream()->delete($activity->id, $activity->type);
             }
             break;
     }
 }
 public function deleteDiscussStream($post)
 {
     if (!$this->exists() || !$this->config->get('integration_easysocial_activity_new_question')) {
         return;
     }
     $stream = Foundry::stream();
     $state = $stream->delete($post->id, 'discuss');
     return $state;
 }
Exemple #9
0
 /**
  * Creates a new stream for new likes
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function voteStream($post)
 {
     if (!$this->exists() || !$this->config->get('integration_easysocial_activity_vote')) {
         return;
     }
     $stream = Foundry::stream();
     $template = $stream->getTemplate();
     // The actor should always be the person that is voting.
     $my = Foundry::user();
     // Get the stream template
     $template->setActor($my->id, SOCIAL_TYPE_USER);
     $template->setContext($post->id, 'discuss', $post);
     $template->setContent($post->title);
     $template->setVerb('vote');
     $template->setPublicStream('core.view');
     $state = $stream->add($template);
     return $state;
 }
Exemple #10
0
	public function removeComment( $comment )
	{
		if( !$this->exists() )
		{
			return false;
		}

		if( !empty( $comment->params->social->stream ) )
		{
			$stream = Foundry::stream();
			$stream->delete( $comment->id, 'komento', $comment->created_by );
		}

		if( !empty( $comment->params->social->target ) )
		{
			$commentTable = Foundry::table( 'comments' );
			$state = $commentTable->load( $comment->params->social->target );

			if( $state )
			{
				$commentTable->delete();
			}
		}

		if( !empty( $comment->params->social->source ) )
		{
			$commentTable = Foundry::table( 'comments' );
			$state = $commentTable->load( $comment->params->social->source );

			if( $state )
			{
				$commentTable->delete();
			}
		}
	}
 /**
  * Store information about activity.
  *
  * <code>
  * $userId = 1;
  * $content = "...";
  *
  * $activity = new ITPrismIntegrateActivityEasySocial($userId, $content);
  * $activity->store();
  * </code>
  *
  * @param string $content
  *
  * @throws Exception
  */
 public function store($content = "")
 {
     if (!empty($content)) {
         $this->content = $content;
     }
     if (!$this->contextId) {
         throw new Exception(JText::_("LIB_ITPRISM_ERROR_INVALID_EASYSOCIAL_CONTEXT_ID"));
     }
     // Retrieve the stream library.
     $stream = Foundry::stream();
     // Retrieve the stream template.
     $template = $stream->getTemplate();
     // Set the actor that is generating this stream item.
     $template->setActor($this->actorId, $this->actorType);
     // Set the context type of this stream item.
     $template->setContext($this->contextId, $this->contextType);
     // Set the title.
     $template->setTitle($this->title);
     // Set the content.
     $template->setContent($this->content);
     // Set the verb / action for this stream item.
     // Example verbs: add, edit , create , update , delete.
     $template->setVerb($this->verb);
     // Set the type of the stream, whether it should be rendered in full mode or mini mode.
     // Mini mode does not have a header and does not actions on the stream.
     // Example types: full,mini
     $template->setType($this->type);
     $template->setSiteWide($this->siteWide);
     // Set target ID.
     if (!empty($this->targetId)) {
         $template->setTarget($this->targetId);
     }
     $stream->add($template);
 }