collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 385
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Blocks speak! Do you have an interest in getting more blocks - or even making your own? The Blocks Board is for you!

Author Topic: Admin Dashboard - everything you need ;)  (Read 75397 times)

0 Members and 1 Guest are viewing this topic.

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: Admin Dashboard - everything you need ;)
« Reply #20 on: May 04, 2009, 11:13:36 PM »
Feel free to ask new additions to the Dashboard. As I said before: "I'm here to make your dreams true" eheh :P :P

Here it is:

Code: [Select]
global $scripturl
//CONFIGURATION BLOCK | FOR ADMIN DASHBOARD <> by [Blue] @ Chrome!

// Title
echo'
<center><font color="#FF9900"><b>Configuration</b></font></center>
<hr>';

// Code Browse
echo'
<img src="http://img74.imageshack.us/img74/9481/brickgo.png" align="abscenter" > <a href="' . $scripturl . '?action=admin;area=packages">Browse Packages</a>
<br/ >';

// Code Upload
echo'
<img src="http://img127.imageshack.us/img127/2494/brickadd.png" align="abscenter" > <a href="' . $scripturl . '?action=admin;area=packages;sa=packageget;get">Upload Package</a>
<br/ >';

// Code Edit MemberGroups
echo'
<img src="http://img127.imageshack.us/img127/5152/groupgear.png" align="abscenter" > <a href="' . $scripturl . '?action=admin;area=membergroups;sa=index">Edit MemberGroups</a>
<br/ >';

// Code Modify Boards
echo'
<img src="http://img74.imageshack.us/img74/9518/layoutedit.png" align="abscenter" > <a href="' . $scripturl . '?action=admin;area=manageboards;sa=main">Modify Boards</a>
<br/ >';

// Code Censored Words
echo'
<img src="http://img9.imageshack.us/img9/8610/pilcrow.png" align="abscenter" > <a href="' . $scripturl . '?action=admin;area=postsettings;sa=censor">Censored Words</a>
<br/ >';

//[END] CONFIGURATION BLOCK | FOR ADMIN DASHBOARD

Do you like it? :D

Btw, I've noticed that your website uses dark colors. If you want to change the colors of the text, say so ;)
« Last Edit: May 05, 2009, 06:50:19 AM by Blue »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline amlucent

  • Jr. Member
  • **
  • Posts: 65
  • Gender: Male
    • The Good Old Days [Old] Guild
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Admin Dashboard - everything you need ;)
« Reply #21 on: May 04, 2009, 11:53:56 PM »
Does it show group requests waiting to be approved?

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: Admin Dashboard - everything you need ;)
« Reply #22 on: May 04, 2009, 11:56:23 PM »
No, but I can make one if you want to :thumbsup:
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline aceflybye

  • Semi Newbie
  • *
  • Posts: 12
  • Gender: Male
  • Life is Art - Art is Life
    • AceFlyBye.com
  • SMF Version: None
  • SP Version: None
Re: Admin Dashboard - everything you need ;)
« Reply #23 on: May 05, 2009, 12:57:13 AM »
Thank you so much lol and I love it.

Offline amlucent

  • Jr. Member
  • **
  • Posts: 65
  • Gender: Male
    • The Good Old Days [Old] Guild
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Admin Dashboard - everything you need ;)
« Reply #24 on: May 05, 2009, 01:08:15 AM »
2 things... I tried to put this on my site and I get the following error

Code: [Select]
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/gwplaye/public_html/Sources/SPortal1-1.php(3232) : eval()'d code on line 5

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/gwplaye/public_html/Sources/SPortal1-1.php(3232) : eval()'d code on line 5

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/gwplaye/public_html/Sources/SPortal1-1.php(3232) : eval()'d code on line 5

Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /home/gwplaye/public_html/Sources/SPortal1-1.php(3232) : eval()'d code on line 5

Parse error: syntax error, unexpected '<' in /home/gwplaye/public_html/Sources/SPortal1-1.php(3232) : eval()'d code on line 6

I am using SP 2.2 on SMF 1.8.. also since I hav not gotten the code up and running yet I am not sure if it does this but I noticed that you can administrate SMF gallery from it.  I run SMG gallery on my site, I was wondering if possible for it to look for this mod as well?

Here is the link to SMG if you need it

http://custom.simplemachines.org/mods/index.php?mod=1365

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Admin Dashboard - everything you need ;)
« Reply #25 on: May 05, 2009, 01:51:23 AM »
The code posted by Blue only works for SMF 2. So it won't work with SMF 11.x.

Also, those sorts are errors are caused by an issue with the preview function, the PHP block works fine as long as you don't use the Preview after you have copied the code into it.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: Admin Dashboard - everything you need ;)
« Reply #26 on: May 05, 2009, 05:43:33 AM »
For the Configuration - Dashboard codes;

You seem to forgot adding $scripturl variable to globals. It looks great otherwise. However, you could have used a list instead, for instance:

Code: [Select]
global $scripturl;

echo '
<div class="sp_center" stlye="color: #FF9900;">
<strong>Configuration</strong>
</div>
<hr />
<ul class="sp_list">
<li>', sp_embed_image('brick_go'), ' <a href="', $scripturl, '?action=admin;area=packages">Browse Packages</a></li>
<li>', sp_embed_image('brick_add'), ' <a href="', $scripturl, '?action=admin;area=packages;sa=packageget;get">Upload Package</a></li>
<li>', sp_embed_image('group_gear'), ' <a href="', $scripturl, '?action=admin;area=membergroups">Edit Membergroups</a></li>
<li>', sp_embed_image('layout_edit'), ' <a href="', $scripturl, '?action=admin;area=manageboards">Modify Boards</a></li>
<li>', sp_embed_image('pilcrow'), ' <a href="', $scripturl, '?action=admin;area=postsettings;sa=censor">Censored Words</a></li>
</ul>';

And with some PHP, you can make life easier for yourself, like this:

Code: [Select]
global $scripturl;

$areas = array(
array(
'icon' => 'brick_go',
'url' => 'area=packages',
'label' => 'Browse Packages',
),
array(
'icon' => 'brick_add',
'url' => 'area=packages;sa=packageget;get',
'label' => 'Upload Package',
),
array(
'icon' => 'group_gear',
'url' => 'area=membergroups',
'label' => 'Edit Membergroups',
),
array(
'icon' => 'layout_edit',
'url' => 'area=manageboards',
'label' => 'Modify Boards',
),
array(
'icon' => 'pilcrow',
'url' => 'area=postsettings;sa=censor',
'label' => 'Censored Words',
),
);

echo '
<div class="sp_center" style="color: #FF9900;">
<strong>Configuration</strong>
</div>
<hr />
<ul class="sp_list">';

foreach ($areas as $area)
echo '
<li>', sp_embed_image($area['icon']), ' <a href="', $scripturl, '?action=admin;', $area['url'], '">', $area['label'], '</a></li>';

echo '
</ul>';

Note that I use sp_embed_image() function to display images. So you'll have to upload the images inside the package attached to the Themes/default/images/sp directory.
And slowly, you come to realize... It's all as it should be...

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: Admin Dashboard - everything you need ;)
« Reply #27 on: May 05, 2009, 06:38:04 AM »
For the overall dashboard, besides the issues I pointed out earlier, just a reminder of database queries:

Instead of this:

Code: [Select]
      $dbresult10 = $smcFunc['db_query']('', "
      SELECT
         COUNT(*) as reportsopen
      FROM {db_prefix}log_reported
      WHERE closed = 0");
      $row2 = $smcFunc['db_fetch_assoc']($dbresult10);
      $reportsopen = $row2['reportsopen'];
      $smcFunc['db_free_result']($dbresult10);
      $context['reports_open'] = $reportsopen;

You can do this:

Code: [Select]
$result = $smcFunc['db_query']('','
SELECT COUNT(*) AS reports
FROM {db_prefix}log_reported
WHERE closed = {int:not_closed}',
array(
'not_closed' => 0,
)
);
list ($closed_reports) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

You can use a single variable for database resource, as long as you don't forget to free it after you are done with it. Also, with list() and $smcFunc['db_fetch_row'], it is a lot easier to fetch a single field.

Other than those, wonderful, as usual.

And here is my code, a bit tidied up like the method I've shown above:

Code: [Select]
global $smcFunc, $sourcedir, $scripturl, $context;

$areas = array();

$result = $smcFunc['db_query']('','
SELECT COUNT(*) AS reports
FROM {db_prefix}log_reported
WHERE closed = {int:not_closed}',
array(
'not_closed' => 0,
)
);
list ($closed_reports) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$result = $smcFunc['db_query']('','
SELECT COUNT(*) AS reports
FROM {db_prefix}log_reported
WHERE closed = {int:closed}',
array(
'closed' => 1,
)
);
list ($open_reports) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$areas['mod_reports'] = array(
'title' => 'Moderation Reports',
'items' => array(
'open' => array(
'icon' => 'report_open',
'label' => 'Open',
'url' => '?action=moderate;area=reports;sa=open',
'value' => $open_reports,
),
'closed' => array(
'icon' => 'report_closed',
'label' => 'Closed',
'url' => '?action=moderate;area=reports;sa=closed',
'value' => $closed_reports,
),
),
);

if (file_exists($sourcedir . '/Arcade.php'))
{
$areas['arcade'] = array(
'title' => 'Arcade',
'items' => array(
'install' => array(
'icon' => 'game_install',
'label' => 'Install Game',
'url' => '?action=admin;area=managegames;sa=install',
),
'upload' => array(
'icon' => 'game_upload',
'label' => 'Upload Game',
'url' => '?action=admin;area=managegames;sa=upload',
),
'edit' => array(
'icon' => 'game_edit',
'label' => 'Edit Game',
'url' => '?action=admin;area=managegames;sa=main',
),
),
);
}

if (file_exists($sourcedir . '/Downloads2.php'))
{
$result = $smcFunc['db_query']('','
SELECT COUNT(*) AS files
FROM {db_prefix}down_file
WHERE approved = {int:not_approved}',
array(
'not_approved' => 0,
)
);
list ($waiting_files) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$result = $smcFunc['db_query']('','
SELECT COUNT(*) AS reports
FROM {db_prefix}down_report',
array(
)
);
list ($reported_files) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$result = $smcFunc['db_query']('','
SELECT COUNT(*) AS comments
FROM {db_prefix}down_comment
WHERE approved = {int:not_approved}',
array(
'not_approved' => 0,
)
);
list ($waiting_comments) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$result = $smcFunc['db_query']('','
SELECT COUNT(*) AS reports
FROM {db_prefix}down_creport',
array(
)
);
list ($reported_comments) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$areas['downloads'] = array(
'title' => 'Downloads',
'items' => array(
'waiting_files' => array(
'icon' => 'file_approve',
'label' => 'File Approval',
'url' => '?action=admin;area=downloads;sa=approvelist',
'value' => $waiting_files,
),
'reported_files' => array(
'icon' => 'file_report',
'label' => 'Reported Files',
'url' => '?action=admin;area=downloads;sa=reportlist',
'value' => $reported_files,
),
'waiting_comments' => array(
'icon' => 'comments_add',
'label' => 'Comment Approval',
'url' => '?action=admin;area=downloads;sa=commentlist',
'value' => $waiting_comments,
),
'reported_comments' => array(
'icon' => 'comments_delete',
'label' => 'Reported Comments',
'url' => '?action=admin;area=downloads;sa=commentlist',
'value' => $reported_comments,
),
),
);
}

if (file_exists($sourcedir . '/Gallery2.php'))
{
$result = $smcFunc['db_query']('','
SELECT COUNT(*) AS pictures
FROM {db_prefix}gallery_pic
WHERE approved = {int:not_approved}',
array(
'not_approved' => 0,
)
);
list ($waiting_pictures) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$result = $smcFunc['db_query']('','
SELECT COUNT(*) AS reports
FROM {db_prefix}gallery_report',
array(
)
);
list ($reported_pictures) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$areas['gallery'] = array(
'title' => 'Gallery',
'items' => array(
'waiting_files' => array(
'icon' => 'picture_add',
'label' => 'Picture Approval',
'url' => '?action=admin;area=gallery;sa=approvelist',
'value' => $waiting_pictures,
),
'reported_files' => array(
'icon' => 'picture_delete',
'label' => 'Reported Pictures',
'url' => '?action=admin;area=gallery;sa=reportlist',
'value' => $reported_pictures,
),
),
);
}

if (file_exists($sourcedir . '/Articles2.php'))
{
$result = $smcFunc['db_query']('','
SELECT COUNT(*) AS articles
FROM {db_prefix}articles
WHERE approved = {int:not_approved}',
array(
'not_approved' => 0,
)
);
list ($waiting_articles) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$result = $smcFunc['db_query']('','
SELECT COUNT(*) AS comments
FROM {db_prefix}articles_comment
WHERE approved = {int:not_approved}',
array(
'not_approved' => 0,
)
);
list ($waiting_comments) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$areas['downloads'] = array(
'title' => 'Articles',
'items' => array(
'waiting_articles' => array(
'icon' => 'article_add',
'label' => 'Article Approval',
'url' => '?action=admin;area=articles;sa=alist',
'value' => $waiting_articles,
),
'waiting_comments' => array(
'icon' => 'comments_add',
'label' => 'Comment Approval',
'url' => '?action=admin;area=articles;sa=comlist',
'value' => $waiting_comments,
),
),
);
}

if (file_exists($sourcedir . '/Links2.php'))
{
$result = $smcFunc['db_query']('','
SELECT COUNT(*) AS links
FROM {db_prefix}links
WHERE approved = {int:not_approved}',
array(
'not_approved' => 0,
)
);
list ($waiting_links) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$areas['links'] = array(
'title' => 'Links',
'items' => array(
'waiting_links' => array(
'icon' => 'link_add',
'label' => 'Link Approval',
'url' => '?action=links;sa=alist',
'value' => $waiting_links,
),
),
);
}

$result = $smcFunc['db_query']('','
SELECT COUNT(*) AS errors
FROM {db_prefix}log_errors',
array(
)
);
list ($total_errors) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$areas['error_log'] = array(
'title' => 'Error Log',
'items' => array(
'errors' => array(
'icon' => 'error_new',
'label' => 'Errors',
'url' => '?action=admin;area=logs;sa=errorlog',
'value' => $total_errors,
),
),
);

foreach ($areas as $area)
{
echo '
<div class="sp_center" style="color: #FF9900">
<strong>', $area['title'], '</strong>
</div>
<hr />
<ul class="sp_list">';

foreach ($area['items'] as $item)
echo '
<li>', sp_embed_image($item['icon']), ' <a href="', $scripturl, $item['url'], '">', $item['label'], (isset($item['value']) ? ': [' . $item['value'] . ']' : ''), '</a></li>';

echo '
</ul>';
}

Again you need to upload the images attached to SP images directory.

If you have any question, feel free to ask. Keep up with good work! ;)
And slowly, you come to realize... It's all as it should be...

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: Admin Dashboard - everything you need ;)
« Reply #28 on: May 05, 2009, 06:44:41 AM »
Thanks guys ;D I'm learning php and there are so many things I don't know yet :)) but I'm a quick learner :P

LHVWB, yes I did forget the global $scripturl. It was 5am here in Portugal so... You got it :P eheh!

[SiNaN], thank you for your advices. I didn't use sp_embed_image because some people are using 2.1.1 and I didn't want to exclude them. That was my reason. But I will update my code of Admin Dashboard and Zip the images :)

I'll update the code in an hours and I'm going to use everything I learn. I loved the php way, seems really easy.

But if I need to put some codes, not urls. It's possivle to do that in the array like the links? :0


You have posted first and thanks for the update :P Now I know how to do it better for the future blocks I'm going to make ;)

If you don't mind, I'll update the first post. ;D
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: Admin Dashboard - everything you need ;)
« Reply #29 on: May 05, 2009, 06:50:59 AM »
Quote
[SiNaN], thank you for your advices. I didn't use sp_embed_image because some people are using 2.1.1 and I didn't want to exclude them. That was my reason. But I will update my code of Admin Dashboard and Zip the images :)

Sounds reasonable, but this will also encourage them to update. :P

Quote
But if I need to put some codes, not urls. It's possivle to do that in the array like the links? :0

If you can elaborate what you mean by some codes, I may help you with that too.

Quote
You have posted first and thanks for the update :P Now I know how to do it better for the future blocks I'm going to make ;)

If you don't mind, I'll update the first post. ;D

You're welcome. As I said, if you have any questions, feel free to ask.

And of course, you can copy those codes to first post. However, I suggest testing them before.
And slowly, you come to realize... It's all as it should be...

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: Admin Dashboard - everything you need ;)
« Reply #30 on: May 05, 2009, 07:05:46 AM »
Quote
Sounds reasonable, but this will also encourage them to update. :P

eheh! :P

Quote
If you can elaborate what you mean by some codes, I may help you with that too.

I meant code that had to fetch data in de DB. But I saw your "tidied" Admin Dashboard and I got it.

I can use DBresult and insert a parameter normally  ;)

But, can you explain me this part?
Code: [Select]
(isset($item['value']) ? ': [' . $item['value'] . ']' : '')
I'm asking because some "items" don't use $value and I can't understand well how this code works

Quote
However, I suggest testing them before.

I'm too lazy to install SP 2.2 on my website :P Going to do that after lunch ;) And then I test it eheh!
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: Admin Dashboard - everything you need ;)
« Reply #31 on: May 05, 2009, 07:22:30 AM »
Quote
But, can you explain me this part?
Code: [Select]
(isset($item['value']) ? ': [' . $item['value'] . ']' : '')
I'm asking because some "items" don't use $value and I can't understand well how this code works

That's the magical "ternary operator".

Just to make sure, isset() function checks if the variable is set or not. You can get the details here:

http://php.net/isset

Now the ternary operator is the "quick if". It is used like this:

Code: [Select]
{condition} ? {if_true} : {if_false}
This is same as this:

Code: [Select]
if ({condition})
{if_true}
else
{if_false}

Example:

Code: [Select]
$my_var = 1;
$variable = $my_var != 1 ? 'I am not 1!' : 'I am 1!;
echo $variable;

Or you can directly use it with echo:

Code: [Select]
$my_var = 10;
echo 'I am ', ($my_var > 9 ? 'greater' : 'less'), ' than 9';

This one with if would be like this:

Code: [Select]
$my_var = 10;

echo 'I am ';

if ($my_var > 9)
echo 'greater';
else
echo 'less';

echo ' than 9';

So the code I used in the dashboard means, if $item['value'] is set, show $item['value']; if it is not set, don't show anything. With if, it would be like this:

Code: [Select]
if (isset($item['value']))
echo ': [' . $item['value'] . ']';
else
echo '';

For details about ternary operator:

http://php.net/ternary

As a lazy DEV, I find it very useful. :P

Quote
I'm too lazy to install SP 2.2 on my website :P Going to do that after lunch ;) And then I test it eheh!

You really need to update; 2.2 has a lot of new features within. ;)
And slowly, you come to realize... It's all as it should be...

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: Admin Dashboard - everything you need ;)
« Reply #32 on: May 05, 2009, 07:29:30 AM »
WOW! I'm really going to join isset() ;D

Now I got it and being lazy too this is going to be the best thing :) I'll use all these teachings for my next block eheh!

Quote from: [SiNaN
You really need to update; 2.2 has a lot of new features within. ;)

I didn't need to because I have a very simple website.

But since I started creating blocks for SP, the update is needed ;)

I run SMG gallery on my site, I was wondering if possible for it to look for this mod as well?

Yes, I'll add SMG Gallery mod to the block on the next release ;) (if nothing happens to me, the release is going to be today eheh!)

Hum... SMG seams a bit harder to code. I'll give it a better look tomorrow since I'm having some problems putting the code to work at 5am :P
« Last Edit: May 05, 2009, 11:28:46 PM by Blue »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

willerby

  • Guest
Re: Admin Dashboard - everything you need ;)
« Reply #33 on: May 06, 2009, 05:21:47 PM »
Thank you willerby :) If you need to add something to the Admin Dashboard just say so and I'll help you ;D

One thing... although I may have more!

I don't have Gallery set for approvals - I let members post new images and just check occasionally. Is there an easy way of providing a link to unviewed images (but showing how many are unviewed in brackets as you do for approvals)?

Thanks

W

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: Admin Dashboard - everything you need ;)
« Reply #34 on: May 06, 2009, 05:27:01 PM »
Hum... Maybe.. When you go to the gallery does it points the pictures unviewed by you?
If yes, then.. It's possible and I can make it for you ;)

Configuration Addon [Version 2]
+ Added Group Requests
« Last Edit: May 07, 2009, 07:37:25 AM by Blue »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

willerby

  • Guest
Re: Admin Dashboard - everything you need ;)
« Reply #35 on: May 07, 2009, 10:43:43 AM »
There's a link for each user that has the subaction:

/index.php?action=gallery;sa=unviewed

Easy to do the link within the admin block but wanted to try and pull whether their were any unviewed items (how many or if >0) to use as a highlight to click on link as per other items in the block

Not urgent or even important as the link is pretty good but would just make similar to others

Any help appreciated, blue

W


Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: Admin Dashboard - everything you need ;)
« Reply #36 on: May 07, 2009, 09:52:55 PM »
That seams easy to do but I have a problem: I don't own a Gallery Pro because It needs to be purchased.

I only have Gallery Lite and that feature doesn't exist in Lite version. So, the best that I can do is to put a link to redirect to ?action=gallery;sa=unviewed.

I'm sorry not to satisfy your request 100% :-[ :|

It's possible to make a block with the last things added but it is as far as I can go with Gallery Lite :( but if you want that I can make it to you.

Here is the code:
Code: [Select]
global $smcFunc, $sourcedir, $scripturl, $context;

$areas = array();

$result = $smcFunc['db_query']('','
   SELECT COUNT(*) AS reports
   FROM {db_prefix}log_reported
   WHERE closed = {int:not_closed}',
   array(
      'not_closed' => 0,
   )
);
list ($closed_reports) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$result = $smcFunc['db_query']('','
   SELECT COUNT(*) AS reports
   FROM {db_prefix}log_reported
   WHERE closed = {int:closed}',
   array(
      'closed' => 1,
   )
);
list ($open_reports) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$areas['mod_reports'] = array(
   'title' => 'Moderation Reports',
   'items' => array(
      'open' => array(
         'icon' => 'report_open',
         'label' => 'Open',
         'url' => '?action=moderate;area=reports;sa=open',
         'value' => $open_reports,
      ),
      'closed' => array(
         'icon' => 'report_closed',
         'label' => 'Closed',
         'url' => '?action=moderate;area=reports;sa=closed',
         'value' => $closed_reports,
      ),
   ),
);

if (file_exists($sourcedir . '/Arcade.php'))
{
   $areas['arcade'] = array(
      'title' => 'Arcade',
      'items' => array(
         'install' => array(
            'icon' => 'game_install',
            'label' => 'Install Game',
            'url' => '?action=admin;area=managegames;sa=install',
         ),
         'upload' => array(
            'icon' => 'game_upload',
            'label' => 'Upload Game',
            'url' => '?action=admin;area=managegames;sa=upload',
         ),
         'edit' => array(
            'icon' => 'game_edit',
            'label' => 'Edit Game',
            'url' => '?action=admin;area=managegames;sa=main',
         ),
      ),
   );
}

if (file_exists($sourcedir . '/Downloads2.php'))
{
   $result = $smcFunc['db_query']('','
      SELECT COUNT(*) AS files
      FROM {db_prefix}down_file
      WHERE approved = {int:not_approved}',
      array(
         'not_approved' => 0,
      )
   );
   list ($waiting_files) = $smcFunc['db_fetch_row']($result);
   $smcFunc['db_free_result']($result);

   $result = $smcFunc['db_query']('','
      SELECT COUNT(*) AS reports
      FROM {db_prefix}down_report',
      array(
      )
   );
   list ($reported_files) = $smcFunc['db_fetch_row']($result);
   $smcFunc['db_free_result']($result);

   $result = $smcFunc['db_query']('','
      SELECT COUNT(*) AS comments
      FROM {db_prefix}down_comment
      WHERE approved = {int:not_approved}',
      array(
         'not_approved' => 0,
      )
   );
   list ($waiting_comments) = $smcFunc['db_fetch_row']($result);
   $smcFunc['db_free_result']($result);

   $result = $smcFunc['db_query']('','
      SELECT COUNT(*) AS reports
      FROM {db_prefix}down_creport',
      array(
      )
   );
   list ($reported_comments) = $smcFunc['db_fetch_row']($result);
   $smcFunc['db_free_result']($result);

   $areas['downloads'] = array(
      'title' => 'Downloads',
      'items' => array(
         'waiting_files' => array(
            'icon' => 'file_approve',
            'label' => 'File Approval',
            'url' => '?action=admin;area=downloads;sa=approvelist',
            'value' => $waiting_files,
         ),
         'reported_files' => array(
            'icon' => 'file_report',
            'label' => 'Reported Files',
            'url' => '?action=admin;area=downloads;sa=reportlist',
            'value' => $reported_files,
         ),
         'waiting_comments' => array(
            'icon' => 'comments_add',
            'label' => 'Comment Approval',
            'url' => '?action=admin;area=downloads;sa=commentlist',
            'value' => $waiting_comments,
         ),
         'reported_comments' => array(
            'icon' => 'comments_delete',
            'label' => 'Reported Comments',
            'url' => '?action=admin;area=downloads;sa=commentlist',
            'value' => $reported_comments,
         ),
      ),
   );
}

if (file_exists($sourcedir . '/Gallery2.php'))
{
   $result = $smcFunc['db_query']('','
      SELECT COUNT(*) AS pictures
      FROM {db_prefix}gallery_pic
      WHERE approved = {int:not_approved}',
      array(
         'not_approved' => 0,
      )
   );
   list ($waiting_pictures) = $smcFunc['db_fetch_row']($result);
   $smcFunc['db_free_result']($result);

   $result = $smcFunc['db_query']('','
      SELECT COUNT(*) AS reports
      FROM {db_prefix}gallery_report',
      array(
      )
   );
   list ($reported_pictures) = $smcFunc['db_fetch_row']($result);
   $smcFunc['db_free_result']($result);

   $areas['gallery'] = array(
      'title' => 'Gallery',
      'items' => array(
         'waiting_files' => array(
            'icon' => 'picture_add',
            'label' => 'Picture Approval',
            'url' => '?action=admin;area=gallery;sa=approvelist',
            'value' => $waiting_pictures,
         ),
         'reported_files' => array(
            'icon' => 'picture_delete',
            'label' => 'Reported Pictures',
            'url' => '?action=admin;area=gallery;sa=reportlist',
            'value' => $reported_pictures,
         ),
         'unviewed' => array(
            'icon' => 'imagepros',
            'label' => 'Unviewed Pictures',
            'url' => '?action=gallery;sa=unviewed',
  ),
      ),
   );
}

if (file_exists($sourcedir . '/Articles2.php'))
{
   $result = $smcFunc['db_query']('','
      SELECT COUNT(*) AS articles
      FROM {db_prefix}articles
      WHERE approved = {int:not_approved}',
      array(
         'not_approved' => 0,
      )
   );
   list ($waiting_articles) = $smcFunc['db_fetch_row']($result);
   $smcFunc['db_free_result']($result);

   $result = $smcFunc['db_query']('','
      SELECT COUNT(*) AS comments
      FROM {db_prefix}articles_comment
      WHERE approved = {int:not_approved}',
      array(
         'not_approved' => 0,
      )
   );
   list ($waiting_comments) = $smcFunc['db_fetch_row']($result);
   $smcFunc['db_free_result']($result);

   $areas['downloads'] = array(
      'title' => 'Articles',
      'items' => array(
         'waiting_articles' => array(
            'icon' => 'article_add',
            'label' => 'Article Approval',
            'url' => '?action=admin;area=articles;sa=alist',
            'value' => $waiting_articles,
         ),
         'waiting_comments' => array(
            'icon' => 'comments_add',
            'label' => 'Comment Approval',
            'url' => '?action=admin;area=articles;sa=comlist',
            'value' => $waiting_comments,
         ),
      ),
   );
}

if (file_exists($sourcedir . '/Links2.php'))
{
   $result = $smcFunc['db_query']('','
      SELECT COUNT(*) AS links
      FROM {db_prefix}links
      WHERE approved = {int:not_approved}',
      array(
         'not_approved' => 0,
      )
   );
   list ($waiting_links) = $smcFunc['db_fetch_row']($result);
   $smcFunc['db_free_result']($result);

   $areas['links'] = array(
      'title' => 'Links',
      'items' => array(
         'waiting_links' => array(
            'icon' => 'links_approval',
            'label' => 'Link Approval',
            'url' => '?action=links;sa=alist',
            'value' => $waiting_links,
         ),
      ),
   );
}

$result = $smcFunc['db_query']('','
   SELECT COUNT(*) AS errors
   FROM {db_prefix}log_errors',
   array(
   )
);
list ($total_errors) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);

$areas['error_log'] = array(
   'title' => 'Error Log',
   'items' => array(
      'errors' => array(
         'icon' => 'error_new',
         'label' => 'Errors',
         'url' => '?action=admin;area=logs;sa=errorlog',
         'value' => $total_errors,
      ),
   ),
);

foreach ($areas as $area)
{
   echo '
<div class="sp_center" style="color: #FF9900">
   <strong>', $area['title'], '</strong>
</div>
<hr />
<ul class="sp_list">';

   foreach ($area['items'] as $item)
      echo '
   <li>', sp_embed_image($item['icon']), ' <a href="', $scripturl, $item['url'], '">', $item['label'], (isset($item['value']) ? ': [' . $item['value'] . ']' : ''), '</a></li>';

   echo '
</ul>';
}

Don't forget to add the image attached in SP images Folder :nervous-happy:
« Last Edit: May 07, 2009, 10:58:22 PM by Blue »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

willerby

  • Guest
Re: Admin Dashboard - everything you need ;)
« Reply #37 on: May 08, 2009, 04:50:23 AM »
I could send you the relevant php files from Gallery Pro - they'll be based on the Lite version. Which ones would you need?

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: Admin Dashboard - everything you need ;)
« Reply #38 on: May 08, 2009, 06:09:52 AM »
See if you have some code in Gallery.php and Gallery.template.php like "unviewed"

I would need that ;)
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

willerby

  • Guest
Re: Admin Dashboard - everything you need ;)
« Reply #39 on: May 08, 2009, 08:46:27 AM »
Think its a call to this function in Gallery.php

Code: [Select]
function UnviewedItems()
{
global $txt, $context, $smcFunc, $mbname, $modSettings, $scripturl, $user_info;

// No guests allowed
is_not_guest();

// Check Permission
isAllowedTo('smfgallery_view');

TopButtonTabs();

if (!$context['user']['is_guest'])
$groupsdata = implode($user_info['groups'],',');
else
$groupsdata = -1;

$context['page_title'] = $mbname . ' - ' . $txt['gallery_text_title'] . ' - ' . $txt['gallery_txt_unviewed_images'];


$context['sub_template']  = 'unviewed';


$context['start'] = (int) $_REQUEST['start'];
$dbresult = $smcFunc['db_query']('', "
SELECT
COUNT(*) as total
FROM {db_prefix}gallery_pic as p
LEFT JOIN {db_prefix}gallery_catperm AS c ON (c.ID_GROUP IN ($groupsdata) AND c.ID_CAT = p.ID_CAT)
LEFT JOIN {db_prefix}gallery_log_mark_view AS v ON (p.ID_PICTURE = v.ID_PICTURE AND v.ID_MEMBER = " . $user_info['id']  . " AND v.user_id_cat = p.user_id_cat)
LEFT JOIN {db_prefix}members AS m ON (p.ID_MEMBER = m.ID_MEMBER)
LEFT JOIN {db_prefix}gallery_usersettings AS s ON (s.ID_MEMBER = m.ID_MEMBER)

WHERE v.ID_PICTURE IS NULL AND (s.private =0 || s.private IS NULL ) AND (c.view IS NULL || c.view = 1 ) AND  p.approved = 1 GROUP by p.ID_PICTURE ");
$row = $smcFunc['db_fetch_assoc']($dbresult);
$total = $row['total'];
$smcFunc['db_free_result']($dbresult);

$dbresult = $smcFunc['db_query']('', "
SELECT
p.ID_PICTURE, p.totalratings, p.rating, p.commenttotal, p.filesize, p.views, p.thumbfilename,
p.title, p.ID_MEMBER, m.real_name, p.date, p.description, c.view, p.mature 
FROM {db_prefix}gallery_pic as p
LEFT JOIN {db_prefix}members AS m ON (p.ID_MEMBER = m.ID_MEMBER)
LEFT JOIN {db_prefix}gallery_catperm AS c ON (c.ID_GROUP IN ($groupsdata) AND c.ID_CAT = p.ID_CAT)
LEFT JOIN {db_prefix}gallery_log_mark_view AS v ON (p.ID_PICTURE = v.ID_PICTURE AND v.ID_MEMBER = " . $user_info['id'] . " AND v.user_id_cat = p.user_id_cat)
LEFT JOIN {db_prefix}gallery_usersettings AS s ON (s.ID_MEMBER = m.ID_MEMBER)
WHERE v.ID_PICTURE IS NULL AND (s.private =0 || s.private IS NULL ) AND (c.view IS NULL || c.view =1) AND  p.approved = 1 GROUP by p.ID_PICTURE  ORDER BY ID_PICTURE DESC
LIMIT $context[start]," . $modSettings['gallery_set_images_per_page']);
$context['gallery_pics'] = array();
while ($row = $smcFunc['db_fetch_assoc']($dbresult))
$context['gallery_pics'][] = $row;
$smcFunc['db_free_result']($dbresult);

$context['page_index'] = constructPageIndex($scripturl . '?action=gallery;sa=unviewed', $_REQUEST['start'], $total, $modSettings['gallery_set_images_per_page']);


}

Let me know if you need the complete file