11
Anonymous
Re: disabling submit news to non admins
  • 2003/12/28 8:18

  • Anonymous

  • Posts: 0

  • Since:


putting it in the xoops_version didnt seem to do anything. Hmmm.....

12
Mithrandir
Re: disabling submit news to non admins

Did you remove the existing entry in xoops_version.php?

13
Mithrandir
Re: disabling submit news to non admins

Update: This will feature in the next version (no ETA, no) of the News module, where you will be able to specify the usergroups with submit rights as well as approve rights.

If you want the quick-and-dirty solution to this particular problem, do this:
in modules/news/xoops_version.php change the original lines within the "// Menu" code to the following:
// Menu
$modversion['hasMain'] = 1;

$module_handler =& xoops_gethandler('module');
$module =& $module_handler->getByDirname('news');
$config_handler =& xoops_gethandler('config');
$moduleConfig =& $config_handler->getConfigsByCat(0$module->getVar('mid'));
$cansubmit 0;
if (
in_array(XOOPS_GROUP_ANONYMOUS$moduleConfig['submitgroups'])) {
    
$cansubmit 1;
}
else {
    global 
$xoopsUser;
    if (isset(
$xoopsUser)) {
        
$groups =& $xoopsUser->getGroups();
        foreach (
$groups as $key => $group) {
            if (
in_array($group['groupid'], $moduleConfig['submitgroups']) || $xoopsUser->isAdmin($module->getVar('mid'))) {
                
$cansubmit 1;
                break;
            }
        }
    }
}
if (
$cansubmit) {
    
$modversion['sub'][1]['name'] = _MI_NEWS_SMNAME1;
    
$modversion['sub'][1]['url'] = "submit.php";
}
unset(
$cansubmit);

$modversion['sub'][2]['name'] = _MI_NEWS_SMNAME2;
$modversion['sub'][2]['url'] = "archive.php";


and add the following lines to the Config Settings:
$member_handler =& xoops_gethandler('member');
$groups =& $member_handler->getGroups();
foreach (
$groups as $key => $group) {
    if (
XOOPS_GROUP_ADMIN != $group->getVar('groupid')) {
        
$grouparray[$group->getVar('name')] = $group->getVar('groupid');
    }
}

$modversion['config'][6]['name'] = 'submitgroups';
$modversion['config'][6]['title'] = '_MI_ALLOWEDSUBMITGROUPS';
$modversion['config'][6]['description'] = '_MI_ALLOWEDSUBMITGROUPSDESC';
$modversion['config'][6]['formtype'] = 'select_multi';
$modversion['config'][6]['valuetype'] = 'array';
$modversion['config'][6]['default'] = array();
$modversion['config'][6]['options'] = $grouparray;


You will now be able to specify in the News Module Preferences which usergroups will see the link

Note: This will NOT affect the submit page, so if your registered users use the direct link to the submit page, they will still be able to submit news items.

14
drsoul
Re: disabling submit news to non admins
  • 2004/1/18 21:01

  • drsoul

  • Just popping in

  • Posts: 7

  • Since: 2004/1/13


hi, i cant get the the cofig bit to show up on the menu page,
how can i get it too work?

15
Mithrandir
Re: disabling submit news to non admins

Updated News module in system admin?

16
drsoul
Re: disabling submit news to non admins
  • 2004/1/19 17:47

  • drsoul

  • Just popping in

  • Posts: 7

  • Since: 2004/1/13


i did that and it worked in the sense that the admin menu but now i can't get into the home page or even log in!
http://www.revelationsound.org/main
thats the address for my XOOPS page.
any ideas.
around line 104 sais:

global $xoopsUser;
if (isset($xoopsUser)) {
$groups =& $xoopsUser->getGroups();

do you know what the promblem is?
thanks.
drsoul

17
Mithrandir
Re: disabling submit news to non admins

Ah right - sorry, my mistake.

$xoopsUser is always set - but if not logged in, it is set to ''

so change
if(isset($xoopsUser)) {

to
if (isset($xoopsUser) && $xoopsUser != '') {

or just
if ($xoopsUser) {

18
drsoul
Re: disabling submit news to non admins
  • 2004/1/19 20:56

  • drsoul

  • Just popping in

  • Posts: 7

  • Since: 2004/1/13


thanks thats fine now.

19
Dave_L
Re: disabling submit news to non admins
  • 2004/3/8 1:03

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Mithrandir: Thanks for posting this.

One minor problem. The code posted causes the module uninstall to fail. This appears to be a fix:

Change:

// Menu
$modversion['hasMain'] = 1;

$module_handler =& xoops_gethandler('module');
$module =& $module_handler->getByDirname('news');
$config_handler =& xoops_gethandler('config');
$moduleConfig =& $config_handler->getConfigsByCat(0$module->getVar('mid'));
$cansubmit 0;
if (
in_array(XOOPS_GROUP_ANONYMOUS$moduleConfig['submitgroups'])) {
    
$cansubmit 1;
}
else {
    global 
$xoopsUser;
    if (isset(
$xoopsUser)) {
        
$groups =& $xoopsUser->getGroups();
        foreach (
$groups as $key => $group) {
            if (
in_array($group['groupid'], $moduleConfig['submitgroups']) ||
$xoopsUser->isAdmin($module->getVar('mid'))) {
                
$cansubmit 1;
                break;
            }
        }
    }
}
if (
$cansubmit) {
    
$modversion['sub'][1]['name'] = _MI_NEWS_SMNAME1;
    
$modversion['sub'][1]['url'] = "submit.php";
}
unset(
$cansubmit);

$modversion['sub'][2]['name'] = _MI_NEWS_SMNAME2;
$modversion['sub'][2]['url'] = "archive.php";


To:

[color=ff0000]$cansubmit 0;[/color]
$module_handler =& xoops_gethandler('module');
$module =& $module_handler->getByDirname('news');
[
color=ff0000]if (is_object($module)) {[/color]
   
$config_handler =& xoops_gethandler('config');
   
$moduleConfig =& $config_handler->getConfigsByCat(0$module->getVar('mid'));
   if (
in_array(XOOPS_GROUP_ANONYMOUS$moduleConfig['submitgroups'])) {
      
$cansubmit 1;
   }
   else {
      global 
$xoopsUser;
      if (
$xoopsUser) {
         
$groups =& $xoopsUser->getGroups();
         foreach (
$groups as $key => $group) {
            if (
in_array($group['groupid'], $moduleConfig['submitgroups']) || $xoopsUser->isAdmin($module->getVar('mid'))) {
                
$cansubmit 1;
                break;
            }
         }
      }
   }
[
color=ff0000]}[/color]
if (
$cansubmit) {
    
$modversion['sub'][1]['name'] = _MI_NEWS_SMNAME1;
    
$modversion['sub'][1]['url'] = "submit.php";
}
unset(
$cansubmit);

$modversion['sub'][2]['name'] = _MI_NEWS_SMNAME2;
$modversion['sub'][2]['url'] = "archive.php";

Login

Who's Online

226 user(s) are online (140 user(s) are browsing Support Forums)


Members: 0


Guests: 226


more...

Donat-O-Meter

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

Latest GitHub Commits