So I made little modification to the News module. Here's what I've done:
- Create new permission directly to the database, add "Add News" into table cms_permissions
- Update the ID number in cms_permissions_seq to the latest ID number in cms_permissions
- Create new group in CMSMS, I called this group "Freelancer"
- Assign 'Add News' permission to the group above. This permission will be the only permission they have
- Add users and assign Freelancer group to them
The administration stuff is done, now I open and edit these three files in News module: News.module.php, action.defaultadmin.php, and action.addarticle.php.
In News.module.php:
- Find function 'VisibleToAdminUser'
- Add this "$this->CheckPermission('Add News') ||" after "return" statement
In action.addarticle.php search for $this->CheckPermission('Modify News'). Change it like below:
Code: Select all
if (!$this->CheckPermission('Add News') && !$this->CheckPermission('Modify News'))
{
echo $this->ShowErrors($this->Lang('needpermission', array('Add/Modify News')));
return;
}
Open action.defaultadmin.php and search for $this->CheckPermission('Modify News'). Edit it like shown below:
Code: Select all
// to identify whether the user is having 'Modify News' permission or not
$use_modify = false;
if ($this->CheckPermission('Modify News'))
{
echo $this->SetTabHeader('articles',$this->Lang('articles'), ('articles' == $tab)?true:false);
echo $this->SetTabHeader('categories',$this->Lang('categories'), ('categories' == $tab)?true:false);
echo $this->SetTabHeader('customfields',$this->Lang('customfields'),
('customfields'==$tab)?true:false);
$use_modify = true; // user has Modify News permission, so Add News permission won't be activated
}
// ADD NEWS
// will be called only if user does not have 'Modify News' permission
if ($this->CheckPermission('Add News') && !$use_modify)
{
echo $this->SetTabHeader('articles',$this->Lang('articles'), ('articles' == $tab)?true:false);
}
Code: Select all
// ADD NEWS
// will be called only if user doesn't have Modify News permission
if ($this->CheckPermission('Add News') && !$use_modify)
{
echo $this->StartTab('articles', $params);
include(dirname(__FILE__).'/function.admin_articlestab.php');
echo $this->EndTab();
}
That's it! Now users in Freelancer group will only see "News" in "Content" menu and one tab only, 'Articles', in the News module.
Cheers!