1
bimmer528
Question With News and the db table
  • 2004/1/25 1:54

  • bimmer528

  • Just popping in

  • Posts: 19

  • Since: 2002/9/19


I created a simple registration script for my site... I added a feature to insert directly into the xoops_stories table when a new reg is submitted. The problem I run into is this.

My site is set at only registered members can post news without admin approval. Even though my registration script enters a value of "admin" in the story type field of xoops_stories, an admin still must approve it as it waits in submitted news. My question is, how can I set it to where I do not need to approve a story when the registration is submitted. I would think that just entering "admin" in the storytype would do the trick but im missing something here.

2
JackJ
Re: Question With News and the db table
  • 2004/1/25 12:48

  • JackJ

  • Community Support Member

  • Posts: 747

  • Since: 2003/8/31


I dont know how you have set up the script, so can't assist there.

Another way to go is this:

Edit: second thoughts, this might not be useful as you disable "Allow anonymous users to post news articles", anyway, but this would at least hide the "submit-news" sub-menu from anon users.

In News "Preferences" you can of course activate "Auto approve news stories without admin intervention" But the "submit news" sub-menu appears to anon users. This can be taken out.

To do this go to "xoops_version.php" in the root of the News module folder and disable the submenu called "submit news" from the view of anon users like this:

Look for the "Menu" section and change it to this:

// Menu
$modversion['hasMain'] = 1;
$modversion['sub'][2]['name'] = _MI_NEWS_SMNAME2;
$modversion['sub'][2]['url'] = "archive.php";
global $xoopsUser;
if(!empty($xoopsUser)) {
$group = $xoopsUser->getGroups();
if (in_array(2, $group)) {//and other group ids
$modversion['sub'][1]['name'] = _MI_NEWS_SMNAME1;
$modversion['sub'][1]['url'] = "submit.php";

}
}

the line: "if (in_array(2, $group)) {

..refers to group "2", (registered users) which means the sub-menu will not be visible to the anon users--you can change the code around a bit if you wish "archive" hidden as well

(I found similar code for this in another post, just changed it a little bit to show "archive")

regards

3
Mithrandir
Re: Question With News and the db table

To force the news to be submitted and approved, do this:

$story = new NewsStory();
$story -> setUid$xoopsUser -> uid() ); //Or whoever you want to be as submitter
$story->setTitle($title); //Title of story
$story->setHometext($hometext); //Displayed text
$story->setTopicId($topic_id); //Might wanna replace this with the topicID of your chosen topic
$story->setHostname(xoops_getenv('REMOTE_ADDR'));
$story->setNohtml(1); //Or 0 if you do use HTML in it
$story->setNosmiley(0); //Or 1 if you don't use them
$story->setType('admin');
$pubdate time(); //To publish it NOW!
$offset $xoopsUser -> timezone() - xoopsConfig['server_TZ'];
$pubdate $pubdate - ( $offset 3600 );
$story -> setPublished$pubdate );

//If you want it to expire, set the following:
$expiry_date strtotime($expiry_date['date']) + $expiry_date['time'];
$offset $xoopsUser -> timezone() - $xoopsConfig['server_TZ'];
$expiry_date $expiry_date - ( $offset 3600 );
$story -> setExpired$expiry_date );
//Else
$story -> setExpired);
//End of expiration code

//If you use more text (the "read more..." link)
$story->setBodytext($bodytext);
//Else
$story->setBodytext(' ');
//End of body text

$story->setApproved(1);
$result $story->store();

/*.... more code if you want to display a message if news story storing failed, else just replace last line with $story->store();*/


This should work - not tested, but based on the new version of News module... shouldn't be any trouble with it as I haven't messed with the database interaction in the Newsstory class.

Login

Who's Online

77 user(s) are online (35 user(s) are browsing Support Forums)


Members: 0


Guests: 77


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits