Subject: Help with submissions block

Posted on: 31/08/2007 12:18pm
By: casper

Ive tried to make a phpblock that returns a count for the table storysubmission, to make submissions be more visible for story admins as a reminder to approve new submissions.
Lifted some code used to make count in the adminmenu, but couldent make it work.
Has anyone some suggestions/code to help me with?

Re: Help with submissions block

Posted on: 31/08/2007 02:14pm
By: jmucchiello

Off the top of my head:

PHP Formatted Code
function phpblock_storysubmissions()
{
    global $_TABLES, $_CONF;

    if (!SEC_hasRights('story.moderate,story.edit', 'OR')) {
        return ''; // no block for folks without permission
    }

    $res = DB_query("SELECT title FROM {$_TABLES['storysubmission']} "
                . COM_getTopicSql() . " ORDER BY DATE desc");
    $num = DB_numRows($res);
    $list = '';
    // make a list of waiting stories so when there's a backlog, it's more noticeable.
    for ($i = 0; $i < 5 AND $row = DB_fetchArray($res); ++$i) {
        $list .= "<li>{$row['title']}</li>\n";
    }
    $display = '';
    if (!empty($list)) {
        $display = "Last $i of $num waiting "
                   . "<a href=\"{$_CONF['site_admin_url']}/moderation.php\">story submissions</a>"
                   . "<ul>$list</ul>";
    }
    return $display;
}

Re: Help with submissions block

Posted on: 31/08/2007 04:43pm
By: casper

Thanks so much jmucchiello! Just what I tried to achieve! For others who may want to use this nice code, remember to add a missing ")" in the db-query. From this: . COM_getTopicSql() . " ORDER BY DATE desc"; To this: . COM_getTopicSql() . " ORDER BY DATE desc");

Re: Help with submissions block

Posted on: 31/08/2007 05:53pm
By: jmucchiello

Only one typo? Wow, I'm usually much worse than that when it comes to parentheses. I fixed the code above for anyone who needs it.

Re: Help with submissions block

Posted on: 31/08/2007 06:36pm
By: Anonymous

This is a nice handle little block that shows when there is something and then it disappears when there is nothing to show. Excellent!

Michael

Re: Help with submissions block

Posted on: 27/01/2009 08:54am
By: worldfooty


Just wanted to say this pretty handy and I've put it to use.

glmenu makes my site look much nicer and saves real estate, but meant story submissions weren't "in the face" or the editors. With this little block they now are. I'll have to extend it to other submissions too.

Re: Help with submissions block

Posted on: 29/01/2009 09:52pm
By: worldfooty

So my version of the above now looks like (note the function name changed slightly):

PHP Formatted Code
function phpblock_submissions()
{
    global $_TABLES, $_CONF;

    if (!SEC_hasRights('story.moderate,story.edit', 'OR')) {
        return ''; // no block for folks without permission
    }

    $res = DB_query("SELECT title FROM {$_TABLES['storysubmission']} "
                . COM_getTopicSql() . " ORDER BY DATE desc");
    $num = DB_numRows($res);

    $res = DB_query("SELECT title FROM {$_TABLES['linksubmission']} "
                . COM_getTopicSql() . " ORDER BY DATE desc");
    $num_link = DB_numRows($res);

    $res = DB_query("SELECT title FROM {$_TABLES['eventsubmission']} "
                . COM_getTopicSql() . " ORDER BY DATESTART desc");
    $num_event = DB_numRows($res);

    $sql = "SELECT uid as id,username,fullname,email FROM {$_TABLES['users']} WHERE status = 2";
    $res = DB_query ($sql);
    $num_user = DB_numRows($res);

    $display = "$num stories, $num_link links, $num_event events and $num_user new users in "
                   . "<a href=\"{$_CONF['site_admin_url']}/moderation.php\">submissions</a>";

    return $display;
}


So it borrows bits from here and there and has more sorting and fields than needed. Basically it will always show a block to admin users which looks something like this:

Submissions

1 stories, 0 links, 0 events and 3 new users in submissions

Even if all categories are empty I like to show it, just to reassure myself that it's still working and visible.

Re: Help with submissions block

Posted on: 30/01/2009 07:54am
By: worldfooty


Actually, that only works if you have full admin control - stuffs up when I log in with limited access, so don't trust my code above!!!

Re: Help with submissions block

Posted on: 30/01/2009 08:43am
By: worldfooty

OK, this works a bit better. Not tarted up perfectly but does the job for me and the typical rights I allocate to users, i.e. story, links, events and for full admin, also user moderation.

So I could check the rights on each step if this was production code, but for now I've just checked if they have story rights, and if so assume they have links and events too. If they also have user mod rights then the number of new user submissions is shown, else just a ? to indicate that the person isn't logged in with enough privilege to check (I have editors who generally have some rights but only log in as full admin occasionally).

So my new version is:

PHP Formatted Code
function phpblock_submissions()
{
    global $_TABLES, $_CONF;

    $display = '';

    if (!SEC_hasRights('story.moderate,story.edit', 'OR')) {
        return $display; // no block for folks without permission
    }

    $res = DB_query("SELECT title FROM {$_TABLES['storysubmission']} "
                . COM_getTopicSql() . " ORDER BY DATE desc");
    $num = DB_numRows($res);

    $res = DB_query("SELECT title FROM {$_TABLES['linksubmission']} ");

    $num_link = DB_numRows($res);

    $res = DB_query("SELECT title FROM {$_TABLES['eventsubmission']}");
    $num_event = DB_numRows($res);

    $num_user = "?";
    if (SEC_hasRights('user.edit')) {
       $sql = "SELECT uid as id,username,fullname,email FROM {$_TABLES['users']} WHERE status = 2";
       $result = DB_query ($sql);
       $num_user = DB_numRows($result);
    }

    $display = "$num stories, $num_link links, $num_event events and $num_user new users in "
                   . "<a href=\"{$_CONF['site_admin_url']}/moderation.php\">submissions</a>";

    return $display;
}
 


So I simply paste that into lib-custom.php and create a block that calls that php. Another 20 years and I'll really know what I'm doing!

Re: Help with submissions block

Posted on: 04/03/2013 01:22am
By: Alex001

Googlebot supports submission of Sitemap files through the robots.txt file.

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=78279