Forum


List Manager Support

List Manager support
Forums
No se permite escribir sin estar logado. Por favor, login

How can user edit only their own records but see all records? 19.01.2012 02:07

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

Re: How can user edit only their own records but see all records? 19.01.2012 12:10

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[$rec['idrecord']]['_notowned']="0"; //ADDED LINE

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

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

//$arrdescartes[]=$rec['idrecord']; //COMMENTED LINE
$result[$rec['idrecord']]['_notowned']="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[r]['_notowned']!="1") //ADDED LINE
$(tdopt).adopt(imgdelete);

if(arrDatos[r]['_notowned']!="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 Team
www.moonsoft.es

Re: How can user edit only their own records but see all records? 24.01.2012 16:21

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

Re: How can user edit only their own records but see all records? 24.01.2012 18:13

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 Team
www.moonsoft.es

Re: How can user edit only their own records but see all records? 24.01.2012 20:28

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[$rec['idrecord']]['_notowned']="0"; //ADDED LINE

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

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

//$arrdescartes[]=$rec['idrecord']; //COMMENTED LINE
$result[$rec['idrecord']]['_notowned']="1"; //ADDED LINE

}
}
$result[$rec['idrecord']]['id']=$rec['idrecord'];
//$result[$rec['idrecord']][$rec['idfield']]=$rec['value'];
if ($format=="pdfr"){
$result[$rec['idrecord']][$rec['idfield']]=$filter->clean($rec['value']);
} else {
$result[$rec['idrecord']][$rec['idfield']]=$rec['value'];
}

//$result[$rec['idrecord']]['value']=

}


foreach($arrdescartes as $d){

unset($result[$d]);
}

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

Re: How can user edit only their own records but see all records? 25.01.2012 12:16

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
Moonsoft Team
www.moonsoft.es

Re: How can user edit only their own records but see all records? 31.01.2012 20:20

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

Re: How can user edit only their own records but see all records? 31.01.2012 20:36

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
Moonsoft Team
www.moonsoft.es

Re: How can user edit only their own records but see all records? 02.02.2012 21:37

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

Re: How can user edit only their own records but see all records? 02.02.2012 21:59

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 Team
www.moonsoft.es

Re: How can user edit only their own records but see all records? 16.02.2012 05:20

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[r]['_notowned']!="1") //ADDED LINE
$(tdopt).adopt(imgdelete);

if(arrDatos[r]['_notowned']!="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

Re: How can user edit only their own records but see all records? 16.02.2012 10:40

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 Team
www.moonsoft.es

Re: How can user edit only their own records but see all records? 11.06.2012 20:33

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

Re: How can user edit only their own records but see all records? 12.06.2012 10:35

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
Moonsoft Team
www.moonsoft.es
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect

Lo que nuestros clientes opinan de nosotros