1
3lr0n
Different editor per user group
  • 2009/11/7 9:27

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


Hello, I was wondering if it possible to have in news 1.64 a dhtml editor (xoops editor) for registered users and a more powerful one (ckeditor) for users in other group.

The reason is to have registered users sending news and special users that have the rights to approve the news that are send, in some cases this other group send more "complex" news or articles so they need for example access to html source, etc...

Its this possible?

2
demian
Re: Different editor per user group
  • 2009/11/7 13:02

  • demian

  • Quite a regular

  • Posts: 225

  • Since: 2008/4/29


Hi you have made the same topic sometimes ago..

https://xoops.org/modules/newbb/viewtopic.php?topic_id=68631&forum=4&post_id=319258#forumpost319258


i'm also waiting for an answer...

if this is possible..


3
3lr0n
Re: Different editor per user group
  • 2009/11/8 11:12

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


line 93
file /modules/news/include/storyform.inc.php

le="color: #000000"><?php $editor = news_getWysiwygForm(_NW_THESCOOP, 'hometext', $hometext, 15, 60, 'hometext_hidden'); $sform->addElement($editor, true);


So the editor is choosen by the function news_getWysiwygForm, take a look to the function

line 187
file /modules/news/include/functions.php

le="color: #000000"><?php function &news_getWysiwygForm($caption, $name, $value = '', $width = '100%', $height = '400px', $supplemental='') { $editor_option = strtolower(news_getmoduleoption('form_options')); $editor = false; $editor_configs=array(); $editor_configs['name'] =$name; $editor_configs['value'] = $value; $editor_configs['rows'] = 35; $editor_configs['cols'] = 60; $editor_configs['width'] = '100%'; $editor_configs['height'] = '350px'; $editor_configs['editor'] = $editor_option;


So the editot, this time is set by news_getmoduleoption, another fuction.

The clue here is check if the user is admin so the editor returned by this function will be the one we want for module admins, and set in configuration the default editor for regular users.

Iam not a programmer, so anyone could help me?

Thks

4
3lr0n
Re: Different editor per user group
  • 2009/11/10 14:38

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


anyone?

5
mboyden
Re: Different editor per user group
  • 2009/11/10 15:21

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


Well, if you just need Admins to have one and users to have another and anonymous users to have a third, then something like:
le="color: #000000"><?php if ($xoops_isadmin) { // choose admin editor } elseif ($xoopsUser) { // choose user editor } else { // choose default editor }

If you are looking to provide it to certain user groups that aren't admins but logged in, then you will need to also check permissions similar to this:
le="color: #000000"><?php $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; $gperm_handler =& xoops_gethandler('groupperm'); $perm = ($gperm_handler->checkRight('news_submit', 0, $groups, $xoopsModule->getVar('mid'))) ? true : false ;

Note: I haven't actually done this as I haven't needed to yet, but it's certainly on my long-range list.

6
3lr0n
Re: Different editor per user group
  • 2009/11/17 20:43

  • 3lr0n

  • Not too shy to talk

  • Posts: 167

  • Since: 2004/3/13


I check this and work for me.

To set a different editor to module admins and to regular users chck line 187 in /modules/news/include/functions.php and replace this

le="color: #000000"><?php $editor_option = strtolower(news_getmoduleoption('form_options'));


with this

le="color: #000000"><?php if (!news_is_admin_group($xoops_user)) { $editor_option = 'dhtml'; } else { $editor_option = strtolower(news_getmoduleoption('form_options')); }


I set the dhtml for regular users, you can set another of course while is installed

hope this can help someone
regards, 3lr0n