News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Breeze

Started by Suki, March 21, 2014, 07:50:09 PM

Previous topic - Next topic

TrickyRicky

Quote from: hcfwesker on March 26, 2014, 12:34:29 AM
Quote from: Suki on March 25, 2014, 09:30:15 PM
To have a portal block inside the users wall or to have some info from this mod as a portal block?

My guess would be a portal block, with info from the mod to be shown on the portal page or forum.  Which could show the most recent (5 or so) status updates from all users(or buddies only).

Exactly right just some info most recent ect.

Suki

Oh sure. what exactly do you want to show?
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

TrickyRicky

show the most recent (5 or so) status updates from all users would be cool.

Suki

mmm, I used to have generic functions to get status and comments, unfortunately, I introduced the paginaiton and the load more button so the those functions became more and more specific towards a single use.

I will include a generic method for both status and comments, in the meantime you can use this method:


/**
* BreezeQuery::getStatus()
*
* Get all status made by X users. no pagination, no other special code.
* @param int|array $id the ID(s) of the user(s) to get the status from. If left empty the functon will load all available status.
* @param boolean $getComments Whether or not to include comments made on each status.
* @param int $limit How many status do you want to retrieve.
* @param string $sort Sorting for retrieving the data, by default is set to DESC (most recent)
* @return array An array containing all the status made by those users, two keys, data and users
*/
public function getStatus($id = false, $getComments = false, $limit = 5, $sort = 'status_id DESC')
{
// Declare some generic vars, mainly to avoid errors
$return = array(
'data' => array(),
'users' => array(),
);

$statusIDs = array();

$id = !empty($id) ? (array) $id : false;

// Fetch the status.
$result = $this->_smcFunc['db_query']('', '
SELECT '. implode(', ', $this->_tables['status']['columns']) .'
FROM {db_prefix}'. ($this->_tables['status']['table']) .'
'. (!empty($id) ? 'WHERE status_owner_id IN({array_int:owner})' : '') .'
ORDER BY {raw:sort}
LIMIT {int:limit}',
array(
'owner' => $id,
'sort' => $sort,
'limit' => $limit,
)
);

// Populate the array like a big heavy boss!
while ($row = $this->_smcFunc['db_fetch_assoc']($result))
{
// Are we also fetching comments?
if ($getComments)
$statusIDs[] = $row['status_id'];

$return['data'][$row['status_id']] = array(
'id' => $row['status_id'],
'owner_id' => $row['status_owner_id'],
'poster_id' => $row['status_poster_id'],
'time' => $this->tools->timeElapsed($row['status_time']),
'time_raw' => $row['status_time'],
'body' => $this->parser->display($row['status_body']),
'comments' => array(),
);

// Get the users IDs
$return['users'][] = $row['status_owner_id'];
$return['users'][] = $row['status_poster_id'];
}

$this->_smcFunc['db_free_result']($result);

// Now get the comments for each status.
if ($getComments && !empty($statusIDs))
{
$result = $this->_smcFunc['db_query']('', '
SELECT '. implode(', ', $this->_tables['comments']['columns']) .'
FROM {db_prefix}'. ($this->_tables['comments']['table']) .'
WHERE comments_status_id IN({array_int:status})
ORDER BY comments_id ASC
',
array(
'status' => $statusIDs,
)
);

// Append the data to our main return array
while ($row = $this->_smcFunc['db_fetch_assoc']($result))
{
$return['data'][$row['comments_status_id']]['comments'][$row['comments_id']] = array(
'id' => $row['comments_id'],
'status_id' => $row['comments_status_id'],
'status_owner_id' => $row['comments_status_owner_id'],
'poster_id' => $row['comments_poster_id'],
'profile_id' => $row['comments_profile_id'],
'time' => $this->tools->timeElapsed($row['comments_time']),
'time_raw' => $row['comments_time'],
'body' => $this->parser->display($row['comments_body']),
);

// Append the users IDs.
$return['users'][] = $row['comments_poster_id'];
}

$this->_smcFunc['db_free_result']($result);
}

// Clean it a bit
if (!empty($return['users']))
$return['users'] = array_values(array_filter(array_unique($return['users'])));

return $return;
}



put it inside Sources/Breeze/BreezeQuery.php

before this line of comments:


/**
* BreezeQuery::getStatusByProfile()
*
* Get all status made in X profile page. Uses a custom query and store the results on separate cache entries per profile.
* @param int $id the ID of the user that owns the profile page, it does not matter who made that status as long as the status was made in X profile page.
* @return array An array containing all the status made in X profile page
*/


and to use it you can use this on a php block:


global $breezeController;

if (empty($breezeController))
$breezeController = new BreezeController();

$status = $breezeController->get('query')->getStatus();


By default the function will show status made by everyone, will show the latest 5 and will not show comments associated with each status, however, you can change those parameters if you want.

You can modify the following params:

$id = false, $getComments = false, $limit = 5, $sort = 'DESC'

$id is the single ID or an array of IDs from users you want to show the latest status.
$getComments is a boolean value to tell the function if you also want to load all the comments for each status.
$limit is the amount of status to retrieve, by default is 5
$sort is the SQL sort, DESC means get the latest status made but you can add any valid SQL ORDER statement.

If the query fetched something, $status will be an array with 2 keys, users and data, $status['data'] holds all the status as an array, to get the body you can use something like this:

if (!empty($status['data']))
   foreach ($status['data'] as $data)
      echo $data['body'];
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

vbgamer45

I would be interested in a portal block as well if you make one and would like to include in ezportal as an option.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Suki

Well, I will add the generic function I wrote above but since I have no idea how people would want to show the data I cannot provide any HTML for it.

And since status and comments doesn't actually have a title and there isn't really a good way to truncate text with HTML on it, it becomes somehow more difficult to show a list of recent status/comments without actually showing the entire body.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

NekoJonez

Where is the changelog ... sorry for this but I'm kinda waiting for some stuff to happen to this mod.
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Suki

???

Since I can't do much with SMF 2.0, all future features will be for SMF 2.1.  I have responded to all the questions and fixed all reported bugs, dunno what else do you need.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

NekoJonez

Nvm my previous post, I was not thinking straight. x)
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Suki

Anyway, I started working on Breeze 1.1, haven't added any new features but thats because I need to revamp the core first:

- Less code and less files
- No more static methods, while it still relies on a semi-singleton to be able to work with SMF, code is now full OOP.
- It will take full advantage of some of the features I introduced in SMF 2.1, so testing this will also help me debug 2.1

Everything is already done except for the testing.

I don't think I have a list of new features to add, its mainly all on my head but I'm open to suggestions, the only requirement is that this mod should remain editless, that is, no file edits. Other than that pretty much everything goes.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

NekoJonez

I have the social icon mod and the gamer ID mod installed.
How can I show them on my wall?
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

ryan_dwight

I don't know if this is included on the feature settings.

Only your buddy can comment on your wall with the exception of the moderators.

if it is already there, where can I find the settings of it.

Thank you for this mod.

Suki

Quote from: NekoJonez on April 05, 2014, 08:49:15 AM
I have the social icon mod and the gamer ID mod installed.
How can I show them on my wall?

If those mods use the custom_profile fields then it will appear automatically, otherwise you will have to add their code manually.

Quote from: ryan_dwight on April 05, 2014, 09:51:21 AM
I don't know if this is included on the feature settings.

Only your buddy can comment on your wall with the exception of the moderators.

if it is already there, where can I find the settings of it.

Thank you for this mod.


Don't really understand your question. No, currently there isn't a setting to allow only buddies to post on your wall.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

ryan_dwight

Quote from: Suki on April 05, 2014, 10:22:43 AM

Don't really understand your question. No, currently there isn't a setting to allow only buddies to post on your wall.
that answers my question.
is this feature possible in the future?
but anyway thanks for this

Suki

It depends, the permission system is already pretty convulsive, not to mention the whole buddy system is somehow flawed.

For example, how would you define a buddy, should both users, the wall owner and the wall poster be buddies to each other?

What would happen if the poster has the wall owner as buddy but the wall owner doesn't have the poster as buddy?  or the other way around?
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

ryan_dwight

QuoteFor example, how would you define a buddy, should both users, the wall owner and the wall poster be buddies to each other?
yes this is what i mean.
QuoteWhat would happen if the poster has the wall owner as buddy but the wall owner doesn't have the poster as buddy?  or the other way around?
but on this one, I never thought that it is complicated. ignore my suggestion on this buddy thing lol

thanks for your reply

Suki

I suppose the mod should take the wall owner buddy list as reference, that is, if the wall owner has the poster on her/his buddy list then the poster will be able to post.

But this also raises more issues, what would happen if the person wants to reply to a status posted by a third person? in this case we have 3 different persons:

- The wall owner
- The user who posted the status
- The user who wants to comment on that specific status.

What buddy list should be used as reference?  the wall owner one or the status owner one?  In theory I should use the wall owner list but  the more factors I add the more complicate it becomes.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Antes

Setting needs to be based on Wall Owner's. eg;
> Public (everyone can post under it)
> Friends of friends (wall owner's friends' friends can post under it)
> Friends only (wall owner's friends)
> Private (wall owner's friends can only see it but none can write under it)

Suki

The same issue still applies, how exactly do you define been buddies?  does it needs to be a reciprocal friendship or just one side friendship?

Theres also the issue with applying the messy permission system, the current permission system has 4 factors (wall owner, poster owner, comment owner and current poster) that alone creates  up to 16 possible factors and I need to include all of them.  Adding the buddy system will escalate the number of factors to considerate exponentially. Not something I want to deal with.

A much more simpler approach would be to only allow buddies to see your wall, just like the ability to deny users on your ignore list to see your wall.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Antes

Get wall owner's buddy list as the "friend(s) list". ? (The best option in my mind for now :P)

Advertisement: