List Manager Forum

How can user edit only their own records but see all records?

User padma 2012-01-19 02:07:09

Hello,

I've recently used ListManager on my site and am looking for a way that a user can edit only their own records but be able to view everyone's records.

Is there a way to achieve this?
Please advice.

Padma

Moonsoft support 2012-01-19 12:10:05

Hello,
when you set Access Control parameter to 'Only user records' what you get is the rows are filtered, so you are not able to see them. In order to get what you need, you should do some slight change to the functions recovering and filtering data, here are the steps:

If you are using component view, edit the file:
joomla\components\com_listmanager\models\listmanagerfront.php

If you are using module view, edit the file:
joomla\components\com_listmanager\models\listmanager.php

Search for the function getDataRecords() (about line 150) and replace the foreach block this way:



foreach ($arrRecords as $rec) {
$result]="0"; //ADDED LINE

//si hay que filtrar por usuario, hacerlo aqui (access_type, user_on))
if($rec=='6'){

$result]=& JFactory::getUser($rec)->name;
if($access_type=='1'&&$user_on!=$rec){

//$arrdescartes=$rec; //COMMENTED LINE
$result]="1"; //ADDED LINE

}
}



And last step: change the front view to hide edition buttons for not owned fields, edit the file:

joomla\modules\mod_listmanager\tmpl\content.php



(About line 608, change this block):



if(arrDatos!="1") //ADDED LINE
$(tdopt).adopt(imgdelete);

if(arrDatos!="1") //ADDED LINE
$(tdopt).adopt(imgedit);
$(trdato).adopt(tdopt);



What you should get now is when selected access for 'only user records', the list shows them all but only edit and delete buttons will be visible if the user owns the record.

Hope this helps, maybe we should think of adding a new parameter to get this combination of access control for next version of the extension to make it easier.

Best regards
Moonsoft Team

Moonsoft support 2012-01-24 16:21:55

I wanted exactly the same. But when i change Access Control to "only user record" i can still see every row.

Edited by moon_245 - 24.01.2012 16:32

Moonsoft support 2012-01-24 18:13:26

Hello,
if you change the parameter once data is loaded, the rows are owned by 'nobody' until some user saves again the record, so you will be able to see them until then. Only when the parameter is selected (and you have one column typed 'user'), the system saves the record attached to user, maybe this causes you are able to see all previous data entered.

Best regards

Edited by MSTeam - 24.01.2012 18:13

Moonsoft support 2012-01-24 20:28:12

I changed the code according to your way. In listmanagerfront.php:

function getDataRecords() {
$db = JFactory::getDBO();
$id =JRequest::getVar('id');
$query = $this->_buildQueryRecords($id);
$db->setQuery($query);
$arrRecords=$db->loadAssocList();
$format = JRequest::getVar('format'); //task
$filter = &JFilterInput::getInstance();

//filtro permisos
$arrdescartes=array(-1);
$access_type=JRequest::getVar('access_type');
$user_on=JRequest::getVar('user_on');

foreach ($arrRecords as $rec) {
$result]="0"; //ADDED LINE

//si hay que filtrar por usuario, hacerlo aqui (access_type, user_on))
if($rec=='6'){

$result]=& JFactory::getUser($rec)->name;
if($access_type=='1'&&$user_on!=$rec){

//$arrdescartes=$rec; //COMMENTED LINE
$result]="1"; //ADDED LINE

}
}
$result]=$rec;
//$result]]=$rec;
if ($format=="pdfr"){
$result]]=$filter->clean($rec);
} else {
$result]]=$rec;
}

//$result]=

}


foreach($arrdescartes as $d){

unset($result);
}

return $result;
}


And I changed the other two files as well. Now the entries are only shown for unregistered users. When I log in no entry is shown.

Edited by moon_245 - 24.01.2012 20:29

Moonsoft support 2012-01-25 12:16:20

Checked this user site and found some missing tags (the forum text skipped some), so please better refer to this instructions to make the changes:


http://www.moonsoft.es/images/stories/components/listmanager/lm_modified.txt

User padma 2012-01-31 20:20:30

Hello,

I've tried as per your exact suggested changes multiple times.

Now I see all user records when set to 'Only user records", but both the edit and the delete buttons are displayed for all users. With this, any user can overwrite or delete another user's records.

Ofcourse I have a user field in the list.

Please advice.

Padma

Moonsoft support 2012-01-31 20:36:28

Hello,
in fact, there is no more changes to be done, it should work following the instructions of the link on our previous post. We could check your modified files to find out if you've missed something. Please send us an email with the files attached and we'll test them here.

Best regards
Moonsoft Team

User padma 2012-02-02 21:37:56

Hello Moonsoft,

Not sure if you are having issues with your forum appln!

I have been getting support before this and I am a customer (as I'm sure you're aware) and have purchased both ListManager and CalcBuilder.

Please check your payment records to note that I'm completely authorized to get issues resolved on this forum.

Please address this ticket ASAP.

Regards,
Padma

Moonsoft support 2012-02-02 21:59:00

Hello,
yes, it was temporary blocked, now it's open again. We've sent you an email anyway to ask for your files, so we can check which is the problem with your changes.

Best regards
Moonsoft Team

Moonsoft support 2012-02-16 05:20:39

Dear MS Team,

Thanks for your help. Could you be a bit more specifc on the second step, What is the actual code to change and how can we find this. (instead of saying a block near line 608)

-------------------------------------------

(About line 608, change this block):

if(arrDatos!="1") //ADDED LINE
$(tdopt).adopt(imgdelete);

if(arrDatos!="1") //ADDED LINE
$(tdopt).adopt(imgedit);
$(trdato).adopt(tdopt);

-------------------------------------------
No sure exactly what to change.

Also could be helpful if you reconstruct all these changes into a file and publish it. So it can just be downloaded and replace the old file. Saves a lot of people a lot of reading, hassle, and time. Makes it easier for the team too in terms of support. Not having to answer multiple inquiries of the same thing.

Thanks very much

Moonsoft support 2012-02-16 10:40:26

Hello,
the second step just adds a couple of lines to the code. To find the right place, search for the line:

$(tdopt).adopt(imgdelete);

and add the line marked as '//ADDED LINE' just before it, same with the other one, it's next lines below.

Please refer to these instructions instead of reading the whole post code, it contains all options, and has some slight differences, because the forum is stripping out code:

http://www.moonsoft.es/images/stories/components/listmanager/lm_modified.txt

We appreciate your suggestion, for some other addition we've created a download, but we haven't made it for this because in fact, there are 3 possible files to modify, depending on your view.Also as a requested feature we are going to include it as a new option for next release, and ...this is a code tweak,which we are not supposed to publish, because it can cause more trouble indeed. As soon as the new release is published, this thread will be of no more use, so we suggest to follow carefully the instructions, only if you are in a hurry, or you are used to handle code to avoid issues.

Thank you, best regards

Moonsoft support 2012-06-11 20:33:25

Im using the component view, and it doesn't make sense to change joomla\modules\mod_listmanager\tmpl\content.php

Could you please advise what files to change for the component view.
I have already modified the listmanagerfront.php

Moonsoft support 2012-06-12 10:35:51

Hello,
latest versions unified files from component and module view. Please find new instructions here:

http://www.moonsoft.es/images/stories/components/listmanager/lm_modified2.txt

Hope this helps,regards

...
Support/development 10 hours

Get a bigger amount of hours for more complex tasks and get a 10% discount

Buy now!
...
CalcBuilder

Create dynamic calculators

Buy now!