SimplePortal

Customization => Blocks and Modifications => Topic started by: Blue on May 12, 2009, 06:27:12 PM

Title: Recent bugs/features SMF Project (Issue Tracker)
Post by: Blue on May 12, 2009, 06:27:12 PM
SMF Projects recent bugs/features Block
[Made by Blue][I hope you like it =D]

Description: A fully customizable block that shows recent bugs/features posted in the Issue Tracker.

Requirements:
- SMF 2.0 GOLD
- SMF Projects 0.5.3
- Simple Portal 2.3.3

SETUP INSIDE:
+ You can choose how many bugs/features you want to output
+ Show replies or not
+ Show Project Category or not
+ Show who posted or not
+ Show status color or not
+ You can translate it to your own language with $txt inside

Author Notes:
Code Updated to Simple Portal 2.3.3 and SMF Projects 0.5.3

Screenshot:
(this pictures has every option ON - you can turn some OFF)
(http://img404.imageshack.us/img404/9444/screenshotuti.png)

Code: [Select]
<?php
/*
Block: SMF Projects Recent bugs/features Block
Author: Blue @ Chrome

Requirements:
- SMF 2.0 RC1+
- SMF Projects
- Simple Portal 2.2.1+
*/

/* [SETUP WHAT YOU WANT HERE] */

// How many recent bugs/feature do you want to output?
$limit 5;

// Do you want to show Replies? YES = 1 | NO = 0
$show_replies 1;

// Do you want to show Project Category? YES = 1 | NO = 0
$show_category 1;

// Do you want to Show who Posted? YES = 1 | NO = 0
$show_posted 1;

// Do you want to Show color status? YES = 1 | NO = 0
$show_color 1;

// Do you want to translate it to your own language? :P
$txt['projects_false'] = 'SMF Projects not found';
$txt['sportal_false'] = 'Simple Portal not found';

$txt['project_cat'] = 'In';
$txt['who'] = 'by';
$txt['replies'] = 'Replies';
$txt['status'] = 'Status';

$txt['new'] = 'New';
$txt['feedback'] = 'Feedback';
$txt['confirmed'] = 'Confirmed';
$txt['assigned'] = 'Assigned';
$txt['resolved'] = 'Resolved';
$txt['closed'] = 'Closed';

/* [STOP!] - THIS IS THE END OF SETUP */

//Only code from now on ;)
global $smcFunc$scripturl$settings$sourcedir;

// Lets see if you are using SMF Projects and Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir '/Project.php'))
{
echo $txt['projects_false'];
return;
}
if (!
file_exists($sourcedir '/PortalBlocks.php'))
{
echo $txt['sportal_false'];
return;
}

// Permission check :P
isAllowedTo('project_access');

// Let's grab some database results
$dbresult $smcFunc['db_query'](''"
SELECT 
i.id_issue, i.subject, i.id_project, i.status, i.id_tracker, i.id_reporter, i.replies, m.real_name, m.id_member, p.name
FROM {db_prefix}issues AS i
LEFT JOIN {db_prefix}members AS m ON (i.id_reporter = m.id_member)
LEFT JOIN {db_prefix}projects AS p ON (i.id_project = p.id_project)
ORDER BY id_issue DESC
LIMIT 
$limit");
while ($blue $smcFunc['db_fetch_assoc']($dbresult))
{
echo
'
<ul class="sp_list">
<li class="sp_list_top">'
;
if ($blue['id_tracker'] == '1') {
echo'<img src="'$settings['images_url'], '/bug.png" alt="'$blue['id_tracker'], '" />'; }
else {
echo'<img src="'$settings['images_url'], '/feature.png" alt="'$blue['id_tracker'], '" />'; }
echo'<a href="'$scripturl'?issue='$blue['id_issue'], '"> '$blue['subject'], '</a>
</li>
<li class="sp_list_indent sp_list_bottom smalltext">'
;


// If, if, if, if, if, xD
if ($show_category == 1)
{
echo'
'
$txt['project_cat'], ' <a href="' $scripturl .'?project='$blue['id_project'], '">['$blue['name'], ']</a>';
}


if (
$show_posted == 1)
{
echo'
'
$txt['who'], ' <a href="' $scripturl .'?action=profile;u='$blue['id_member'], '">'$blue['real_name'], '</a>';
}

if (
$show_replies == 1)
{
echo
$txt['replies'], ': '$blue['replies'];
}


if (
$show_color == 1)
{
if($blue['status'] == 1) {
echo
' | '$txt['status'], ':<span style="background-color:#FFCCCC">&nbsp;'$txt['new'], '&nbsp;</span>';
} elseif ($blue['status'] == 2) {
echo
' | '$txt['status'], ':<span style="background-color:#FF50A8">&nbsp;'$txt['feedback'], '&nbsp;</span>';
} elseif ($blue['status'] == 3) {
echo
' | '$txt['status'], ':<span style="background-color:#FFFFB0">&nbsp;'$txt['confirmed'], '&nbsp;</span>';
} elseif($blue['status'] == 4) {
echo
' | '$txt['status'], ':<span style="background-color:#C8C8FF">&nbsp;'$txt['assigned'], '&nbsp;</span>';
} elseif($blue['status'] == 5) {
echo
' | '$txt['status'], ':<span style="background-color:#CCFFCC">&nbsp;'$txt['resolved'], '&nbsp;</span>';
} else {
echo
' | '$txt['status'], ':<span style="background-color:#E8E8E8">&nbsp;'$txt['closed'], '&nbsp;</span>';
}
}

echo
'
</li>
</ul>'
;
}
$smcFunc['db_free_result']($dbresult);
?>

Edited: This document was successfully checked as XHTML 1.0 Transitional!
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: ccbtimewiz on May 13, 2009, 06:06:31 PM
Nice job with this! ^^

Though, I think I can help you make it a bit.. cleaner.

For all those "1" or "0" choices, you can use "true" or "false". That way, when checking the variable, you can just put if ($var), as PHP assumes you're checking to see if the boolean is true or false.

For all the echo strings that result after a condition, you don't need to encase them in brackets. Example:

Code: [Select]
if ($var)
   echo 'hello';

This is the same as doing it with brackets. You'd use brackets if you're tying multiple strings together, such as;

Code: [Select]
if ($var)
{
    echo 'hello';
    echo 'moose';
}

When you called that while() to loop the information from the db, you're looping each row and column along with making those conditional statements. A suggestion would be to store the information into one major array(), and then free the result. After that, you'd proceed to echo the information.

About the query, you shouldn't be using double quotes for SMF 2.0 queries anymore. Use single quotes, and then define the limit as {int:limit}, and then parse a conditions array after the query.

Eg,

Code: [Select]
// Let's grab some database results
$dbresult = $smcFunc['db_query']('', '
SELECT
i.id_issue, i.subject, i.id_project, i.status, i.issue_type, i.id_reporter, i.replies, m.real_name, m.id_member, p.name
FROM {db_prefix}issues AS i
LEFT JOIN {db_prefix}members AS m ON (i.id_reporter = m.id_member)
LEFT JOIN {db_prefix}projects AS p ON (i.id_project = p.id_project)
ORDER BY id_issue DESC
LIMIT {int:limit}',
array(
'limit' => (integer) $limit,
)
);
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Blue on May 15, 2009, 09:43:43 AM
Thanks CCB ;D

I'll update the code and try what i've learned from you in it when my college exams are finished :)

And I'm glad you liked the block eheh ;D
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Sordell Media on November 04, 2009, 08:56:43 PM
Apologies if this isn't the right place to report issues with custom blocks.

I just tried adding this to my board (SMF 2.0 RC2, SP 2.3.1), and the block is reporting "Simple Portal not found". I'm guessing this is because the file "/SPortal2.php" has possibly been renamed since this block was created. I've only just started using SP so not sure what this file was/is now, can someone let me know what I'd need to change this to?
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Nathaniel on November 04, 2009, 08:59:12 PM
Replace the code below:
Code: [Select]
if (!file_exists($sourcedir . '/SPortal2.php'))
With this code:
Code: [Select]
if (!file_exists($sourcedir . '/PortalBlocks.php'))
Can't garantee that it will work with the newer version of SimplePortal, but that will stop the error message.
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Sordell Media on November 04, 2009, 09:24:19 PM
Ah yes, that cleared up the error but the block doesn't seem to be compatible with the newer SP version, it breaks the page. I'll tinker with it a bit and post back if I manage to get it to work for the newer version :D
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: c23_Mike on November 16, 2009, 01:15:54 PM
Hi there !

Am I right when this site already uses this mod? So there should be a working version for SP 2.3.1 and SMF Project 0.4 ... can they post it here?  :D
I would also like to use it!
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Nathaniel on November 16, 2009, 04:56:41 PM
Hi there !

Am I right when this site already uses this mod? So there should be a working version for SP 2.3.1 and SMF Project 0.4 ... can they post it here?  :D
I would also like to use it!

We aren't using this mod. The block that you see is a Custom PHP block coded by one of the team. I will pass your message onto the person who coded it, to see if they will post the code here.
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Nathaniel on November 16, 2009, 06:35:28 PM
Here is the Custom PHP code that we use at SimplePortal.net (with permissions from Sinan):
Code: [Select]
global $context, $settings, $project, $txt;

$block_parameters = array();

if ($return_parameters)
return $block_parameters;

loadLanguage('Project');

$project = 1;
$num_issues = 5;
$order = 'i.updated DESC';

$issues = getIssueList(0, $num_issues, $order, '1 = 1');

echo '
<table class="bordercolor issuetable" style="border-collapse: separate; border-spacing: 1px;">';

foreach ($issues as $issue)
{
echo '
<tr>
<td class="windowbg sp_center" style="width: 24px;">
<img src="', $settings['images_url'], '/', $issue['tracker']['image'], '" alt="', $issue['tracker']['name'], '" />
</td>
<td class="info issue_', $issue['status']['name'], '">
<h4>
', !empty($issue['category']['link']) ? '[' . $issue['category']['link'] . '] ' : '', $issue['link'], ' ';

if ($issue['new'] && $context['user']['is_logged'])
echo '
<a href="', $issue['new_href'], '"><img src="', $settings['lang_images_url'], '/new.gif" alt="', $txt['new'], '" /></a>';

echo '
</h4>
<p class="smalltext">', !empty($issue['version']['link']) ? '[' . $issue['version']['link'] . '] ' : '', $txt['issue_status_' . $issue['status']['name']], $issue['is_assigned'] ? ' (' . $issue['assigned']['link'] . ')' : '', '</p>
</td>
</tr>';
}

echo '
</table>';

It was written for ProjectTools 0.3.3, so it doesn't work perfectly with Project Tools 0.4 (like the colours don't work ;)). I will be updating the block on SP.net sometime soon, so I'll post an updated copy when I do.
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Sordell Media on November 17, 2009, 12:49:16 AM
Awesome, thanks :D

One thing I noticed implementing this on my site, is that if you've got more than one project you need to comment out / remove the following line:
Code: [Select]
$project = 1;
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: c23_Mike on November 17, 2009, 03:22:23 AM
Hi there !

Wonderful, tnx a lot!
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Nothingness on April 02, 2010, 11:33:56 PM
Can someone update this?  :P
It's outdate
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: [SiNaN] on April 03, 2010, 11:46:53 AM
The code Nath quoted should be working. I don't remember updating it on this site.
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Nothingness on April 03, 2010, 02:46:17 PM
The code Nath quoted should be working. I don't remember updating it on this site.
Yeah it does, but the relies and status are not showing
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: ramon.cutanda on April 03, 2010, 10:47:14 PM
Just great, thanks!
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Nothingness on June 16, 2010, 05:43:03 PM
Look like the codes is outdated...
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Nathaniel on June 16, 2010, 11:56:51 PM
The code Nath quoted should be working. I don't remember updating it on this site.
Yeah it does, but the relies and status are not showing

Look like the codes is outdated...

The code works perfectly for Project Tools 0.4.2, are you referring to the 0.4.3 update?
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Nothingness on June 17, 2010, 12:11:42 AM
Except for the colours?
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Nathaniel on June 17, 2010, 12:21:52 AM
The colours work fine as far as I can see. Its possible that they don't display correcting in a browser like IE though. Works fine in Firefox, Chrome and Opera under linux for me.
Title: Re: Recent bugs/features SMF Project (Issue Tracker)
Post by: Blue on July 01, 2011, 04:04:06 PM
Code updated to Simple Portal 2.3.3 and SMF Projects 0.5.3.
SimplePortal 2.3.8 © 2008-2024, SimplePortal