I'm here for another question cause I really like chrono projects so I want to use this the best way that I can,so..question is:
I want that everyone one can view my autogenerated list but if a logged user push on the block button(binary_field with publish joomla icon)then only the logged user will have the permission to edit the selected record.Can you suggest me some documentation? Problem is that if I allow only owner to edit a record than the block button will always return acces denied even if the user_id field is 0 or not filled in my database table. only way to make this works is to manualy edit from phpmyadmin the user_id field to be the same as the logged user. I think I need somwthing like:
IF user_id = 0
THEN fields are editable from everyone
IF user_id = user_id
THEN logged user will have permissione to edit
Thank you
Sorry, I don't know how to do that; Max may have some suggestions though.
Bob
There is no way to switch the permissions, but maybe you can switch the value of the field, instead of displaying a binary field, just display a static image (no link), or don't display it at all!
If you have a custom list then its easy to do this, if you have an auto listing then just use the "auto listing event".
Regards,
Max
Regards,
Max
I have another easier idea, just create a new column and add a custom link called "claim" or whatever, and point the link to a custom event in your form, you will also need to register this custom event in your connection (there is a place for that under the "Front or Admin Editing"), now in your custom event in the form you will need to update the record with the user id as you want.
Hi max and thank you for your reply.
I understood your idea but as you know I'm not so good with code so please be patient and help me to close this project.
in order:
db_name is disponibilita
table_name is form_disponibilita
field that I want to fill with "current user logged id" is user_id
1 - first think is to add a new column to my database, I will call this claim
? - what kind of data I have to choose for this column(VARCHAR,INT ecc)
2 - next step is to go through advanced wizard editor and add a new custom code event to the edit form connected with my cc list,the name of this form is "form_disponibilita_edit", and I will call the custom event claim that will fill the user_id field with "current user logged id"
? - please max can you suggest me some lines of code to place in this action? I will do the best that I can to edit your code and make it works with my database.
3 - now I have to go in cc-->frontend list settings-->linkable fields and place a link to my custom actions
? - I can't understand the syntax of this field, can you please tell me the right link?
4 - final step is to register my custom action in cc-->frotend editing
? - I can see a lot of fields here, first is custom data task and then I can see list event and list action order, witch is the correct one?
5 - in the end I have to setup right permissions in frontend editing
thank you max take your time and help me with this I will sure validate my installation when I will solve this!
<?php
$user =& JFactory::getUser();
$con=mysqli_connect("localhost","root","debian","disponibilita");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"UPDATE form_disponibilita SET current_user_id= $user->id
WHERE input_reference = '222222'");
mysqli_close($con);
?>
<?php
$cf_id = JRequest::getVar('cf_id');
$user =& JFactory::getUser();
$con=mysqli_connect("localhost","root","debian","disponibilita");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"UPDATE form_disponibilita SET current_user_id= $user->id
WHERE cf_id = $cf_id");
mysqli_close($con);
?>
I'll post lather for other problems
problem is that at the first acces current_user_id column is filled with 0 that dismatch from the current logged user id and if I allow update permission only to the owner then no one can lock the rows with him current_id cause I always receive acces denied. so to solve this I have to allow the editing permissions to user_id=current_user_id and to user_id = 0 but I have no idea how to do the second one..
this is the right code that is making exactly what I had in my mind:
if I click on the linkable field then the entire row will be editable only from my account until the same account will click again on the unlock field.
<?php
//ob_start();
$cf_id = JRequest::getVar('cf_id');
$user =& JFactory::getUser();
$con=mysqli_connect("localhost","root","debian","disponibilita");
$result= mysqli_query($con,"SELECT current_user_id FROM form_disponibilita WHERE cf_id = $cf_id");
$current_user_id=$result->fetch_array();
// Check della connessione al database
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//Check dei permessi
if ($current_user_id['0'] == '0') //lock
{
echo '<img src="./images/dispo/bloccata.jpg" border=0>';
mysqli_query($con,"UPDATE form_disponibilita SET current_user_id= $user->id WHERE cf_id = $cf_id");
mysqli_query($con,"UPDATE form_disponibilita SET input_status=0 WHERE cf_id = $cf_id");
}
elseif($current_user_id['0'] == $user->id) //unlock
{
echo '<img src="./images/dispo/sbloccata.jpg" border=0>';
mysqli_query($con,"UPDATE form_disponibilita SET current_user_id= 0 WHERE cf_id = $cf_id");
mysqli_query($con,"UPDATE form_disponibilita SET input_status=1 WHERE cf_id = $cf_id");
}
else
{
//echo "accesso negato"; //acces denied
echo '<img src="./images/dispo/access_denied.jpg" border=0>';
}
mysqli_close($con);
?>
I never open a book of php or mysql in my entire life but patience is more important the anything else๐ only one last question.. IS there a way to have a custom icon instead of a linkable field using autolisting? I would like to change the linkable field "lock/unlock" with an icon but maybe this is impossible using autolisting..right?
First, congratulations!๐
You can have an icon easily in custom listing, but in auto listing you will need to use the "auto listing event", also, new V5 has easier way to do this in auto listing.
Regards,
Max