Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
Hack: Submit_News directly without any approval.
  • Posted: 07.12.2005, 15:51
     
    Velocy
    rank:
    Freshman Freshman
    registered:
     November 2005
    Status:
    offline
    last visit:
    10.12.05
    Posts:
    3
    I wanted on my page, that the Sub-Admins, which are able to submit news, don't have to approve them. News should be directly shown after the poster submits it.

    I searched board for a sloution but havent found one really, so I looked for my own.

    Check under modules\Submit_News\ the index.php file.

    In Line 297 you should have a Code like this:

    Code

    $column = &$pntable['queue_column'];
        $newid = $dbconn->GenId($pntable['queue']);
        $result =& $dbconn->Execute("INSERT INTO $pntable[queue] (
                                      $column[qid],
                                      $column[uid],
                                      $column[arcd],
                                      $column[uname],
                                      $column[subject],
                                      $column[story],
                                      $column[timestamp],
                                      $column[topic],
                                      $column[alanguage],
                                      $column[bodytext])
                                    VALUES ("
    . pnVarPrepForStore($newid). ",
                                            '"
    . pnVarPrepForStore($uid) . "',
                                            '0',
                                            '"
    . pnVarPrepForStore($name) . "',
                                            '"
    . pnVarPrepForStore($subject) . "',
                                            '"
    . pnVarPrepForStore($storytext) . "',
                                            now(),
                                            '"
    . pnVarPrepForStore($topic) . "',
                                            '"
    . pnVarPrepForStore($alanguage) . "',
                                            '"
    . pnVarPrepForStore($bodytext) . "')");


    This posts the News in the queue where its waiting for a Administrator to approve it.

    I rewrote the SQL Command just to post it directly into the News Table.

    Code

    $column = &$pntable['stories_column'];
        $newid = $dbconn->GenId($pntable['stories']);
        $result =& $dbconn->Execute("INSERT INTO $pntable[stories] (
                                      $column[sid],
                                      $column[catid],
                                      $column[aid], 
                                      $column[counter],                              
                                      $column[title],
                                      $column[time],
                                      $column[hometext],
                                      $column[bodytext],
                                      $column[topic],
                                      $column[informant],
                                      $column[language])
                                    VALUES ("
    . pnVarPrepForStore($newid). ",
                                            '0',
                                            '2',
                                            '0',
                                            '"
    . pnVarPrepForStore($subject) . "',
                                            now(),
                                            '"
    . pnVarPrepForStore($storytext) . "',
                                            '"
    . pnVarPrepForStore($bodytext) . "',
                                            '"
    . pnVarPrepForStore($topic) . "',
                                            '"
    . pnVarPrepForStore($name) . "',
                                            '"
    . pnVarPrepForStore($alanguage) . "')");


    I don't work with any categorys at my news. I just need them to for the main page. I know there is an issue now, that the Users are able to post a news without selecting any category.

    You modify the code so they MUST select a category... as for me... I am lazy ^^ I just fixed it by going to line 80 in index.php where it reads

    Code

    echo '<option value="">'._SELECTTOPIC."</option>\n";


    I have only one category with the ID 0...

    just make it

    Code

    echo '<option value="0">'._SELECTTOPIC."</option>\n";[/code

    And it will be automaticly this category if no other is selected.
    Administrators can correct the news or the category after posting...

    And a last thing to make the shown text look correct.

    Go into Line 343... the code reads

    [code]    .'<br />'._WEHAVESUB." $waiting "._WAITING;


    If you change this to

    Code

    .'<br />';

    only, the "We have X submissions waiting" line will be gone.

    you can now edit the language file and add a text you like...

    line 48 is the headline define('_SUBSENT',YOUR TEXT HERE');
    line 49 is the line under the headline define('YOUR TEXT HERE');

    ------------------------

    This has been changed and tested with the Submit_News Module delivered in the original download package of PostNuke 0.7.6.1 and works for me just fine. Always make a backup of the file, and to be sure of the Database before you change it. I give no guarantee that it works for you as well as me :wink:

    Thank you Francisco Burzi for this Module, hope you don't mind I improved it a bit for my needs icon_wink
  • Posted: 07.12.2005, 18:04
     
    Topiatic
    rank:
    Professional Professional
    registered:
     November 2003
    Status:
    offline
    last visit:
    06.11.08
    Posts:
    1675
    A suggestion... why not wrap your SQL statements, the old one and your new one, inside auth checks

    Code

    if (pnsecauthaction(0, 'Submit news::', '::', ACCESS_ADD) {
        YourNewSQL = "into stories table"
    } else {
        TheOldSQL = "into the queue table"
    }


    Then you can use permisions to allow your sub admins to add stories directly.

    PS. Francisco Burzi is the author of PHP-Nuke which PostNuke was forked from, and as you can see from all the PN* references most of it has been rewriten. (Not to discredit his work, just thought you might want to know)

    --
    Under Construction!
  • Posted: 07.12.2005, 19:18
     
    nate_02631
    rank:
    Professional Professional
    registered:
     September 2003
    Status:
    offline
    last visit:
    11.04.08
    Posts:
    3055
    ... Or you could just grant sub-admins permissions to the Add Story module ;)

    --
    Get PhotoGallery, PayPalCart, Dynamenu, Enhanced Blocks & other mods

    Cape Cod Travel Info...
  • Posted: 08.12.2005, 01:22
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    09.11.08
    Posts:
    13413

    Quote

    ... Or you could just grant sub-admins permissions to the Add Story module


    Which saves hacking the core, but whatever works for you... ;)

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
  • Posted: 08.12.2005, 04:28
     
    Topiatic
    rank:
    Professional Professional
    registered:
     November 2003
    Status:
    offline
    last visit:
    06.11.08
    Posts:
    1675

    nate_02631

    ... Or you could just grant sub-admins permissions to the Add Story module ;)


    eheh icon_redface

    --
    Under Construction!
  • Posted: 10.12.2005, 18:40
     
    Velocy
    rank:
    Freshman Freshman
    registered:
     November 2005
    Status:
    offline
    last visit:
    10.12.05
    Posts:
    3
    I am not very familiar in Module programming but I understand much from normal PHP & MySQL programming, so there might be much better solutions :) just wanted to tell what worked for me just fine.

    I always have a bad conscience when I rewrite codes which other persons programmed I one had trouble with a programmer of a open source script so If I customize a script a every name I find to the credits ;)
  • Posted: 10.12.2005, 23:01
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    09.11.08
    Posts:
    13413
    The point was you don't need to write any code - the feature is already present in PostNuke

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula