Home > CMS, Joomla, Technology > category wise user management in Joomla (part 2)

category wise user management in Joomla (part 2)

Before reading this post you have to read category wise user management in Joomla (part 1) post and follow the steps.

In category wise user management in Joomla (part 1) we have discussed how can we disable an edit button for the category user on unassociated category articles  . But the problem is when we login through frontend as an editor , we get complete list of newly added articles , even a user is category user we get the list of new articles from all categories to edit , hence whatever we discussed in category wise user management in Joomla (part 1) post , the results of the post can be applicable only if article is already published , But what about newly added articles? How can we display only associated category article list which are not published or which are in their first publishing cycle  .

I am using “com_camelcitycontent2” component , using the component I can create 2 links , 1st is to submit articles and 2nd is for view articles (to edit and to publish) . Once I login through front end I am getting the link “view articles” . You can manage your menu through administrator . Once I click the “view article” link . I am getting the list of all newly added article. But as we have make our users category wise in post category wise user management in Joomla (part 1) , we should get the list of only those articles whose categories are associated with us . But we are getting all articles to edit and publish .

I have added some lines of code to solve the problem .

1. Open the File \components\com_camelcitycontent2\models\all.php
2. Find out the function function _buildContentWhere()
3. Replace the function with following function

function _buildContentWhere()

{

global $camelcity_delete, $camelcity_help, $camelcity_introtext, $camelcity_order, $camelcity_published, $camelcity_section, $camelcity_search, $camelcity_state, $limit, $limitstart,$mainframe, $option, $paramlimit, $template;

$user =& JFactory::getUser();

$where = array();

$where[] = ‘a.id IS NOT NULL’;

if ($user->authorize(‘com_content’, ‘edit’, ‘content’, ‘all’)) {

$where[] = ‘a.created_by IS NOT NULL’;

} else {

$where[] = ‘a.created_by = ‘. $user->id;

}

if ($camelcity_search) {

$where[] = ‘(a.title LIKE ‘.$this->_db->Quote(‘%’.$camelcity_search.’%'). ‘ OR a.introtext LIKE ‘.$this->_db->Quote(‘%’.$camelcity_search.’%').’)';

}

if ($camelcity_published==”1″) { //both

$where[] = “a.state != -2″;

} elseif($camelcity_published==”2″) { // published

$where[] = “a.state = 1″;

} elseif($camelcity_published==”3″) { // not published

$where[] = “a.state = 0″;

}

if ($camelcity_section) {

$where[] = “a.sectionid=”.$camelcity_section;

}

/* —- The code is added by prasad —- Purpose is content category wise user management ——*/

session_start();

$userParams=array();

$a=array();

$userParams=explode(“\n”,$_SESSION['__default']["user"]->params);

for($i=0;$i<count($userParams);$i++)

{

$userParamskey=explode(“=”,$userParams[$i]);

$a[$userParamskey[0]]=$userParamskey[1];

}

if ($a["categoryuser"]==”1″) {

$userParams=explode(“,”,$a["categories"]);

for($i=0;$i<count($userParams);$i++)

{

if($i==0)

{

$wherecat = “(a.catid=”.$userParams[0];

}

else

{

$wherecat .= ” or a.catid=”.$userParams[$i];

}

}

$wherecat.=” )”;

$where[]=$wherecat;

}

/* —- End of The code added by prasad —- Purpose is content category wise user management ——*/

$where = ( count( $where ) ? ‘ WHERE ‘. implode( ‘ AND ‘, $where ) : ” );

$where .= ‘ ORDER BY ‘ .$camelcity_order;

return $where;

}

4) Save the file

After replacing the function , you will get only those associated article list to edit or publish if the user is category user .

“I have used these techniques to enhance my application and to meet my client requirements , please take backups of your stuff before changing or replacing anything , These changes are done for joomla 1.5.8 version”

Advertisement
Categories: CMS, Joomla, Technology
  1. inpixie
    September 20, 2009 at 11:20 pm | #1

    hi…
    good article.thanks

  1. August 18, 2009 at 7:29 am | #1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.