Forums

Form with user authentication base

underspeed 29 Jun, 2011
Hi,

I'm using ChronoForms and now Chrono Connectivity. I don't understand Chrono Connectivity clearly but i'm learning.

Now, i need that;

I have one admin user and 3 standart users. They will be enter a record to a form from frontend. Then admin can see records from backend. Normally i need;

For users:
------------
They can be see own records from frontend. (They cannot see other user's and admin's records)
They can be add, edit and delete own records from frontend.


For admin:
----------
He can be see all records of users's and own.
He can be add, edit and delete all records of users's and own from frontend or backend.

How can we do that? Anyone can help me please?

Regards.
GreyHead 29 Jun, 2011
Hi underspeed,

Please see my ChronoConnectivity tutorials here They should give you most of what you need.

You can use filters in the WHERE box to give different access to Users.

Bob
underspeed 29 Jun, 2011
Hi GreyHead,

I already read your documents, they are wonderful but so complex for me. I newbie. Could you please help me step by step?
GreyHead 30 Jun, 2011
Hi underspeed,

Sorry, I can't write it any more simply than I have in the tutorials. Life is just too short.

The code you need in the WHERE box form Joomla! 1.5 is
<?php
$user =& JFactory::getUser();
if ( !in_array($user->gid, array('24, '25')) ) {
  // user is not an admin
  echo "WHERE `cf_user_id` = '{$user->id}';";
}
?>

Bob
underspeed 01 Jul, 2011
Finally i found your code error!

if ( !in_array($user->gid, array('24, '25')) ) {

must be
if ( !in_array($user->gid, array('24', '25')) ) {


and
  echo "WHERE `cf_user_id` = '{$user->id}';";

must be
  echo "WHERE `cf_user_id` = '{$user->id}'";


Anyway, thank you so much🙂
GreyHead 01 Jul, 2011
Hi underspeed,

I'm sorry you had to hunt for my typos :-(

Bob
underspeed 02 Jul, 2011
Hi GreyHead,

Many things okay. Now i can filter record to users. But when i add a record from frontend, i see double record. I read your comments for this problem. But if i select "no" on "Enable Data Storage" or select "Before Email" on "Saving Data/Emails order" it's recorded except record time, cf_user_id and many things.

I'm writing my codes, maybe you can help me again.

ChronoForm :
-----------------

Form Html :
<?php 
$user =& JFactory::getUser(); ?> 
<input type='hidden' name='username' value='<?php echo $user->name; ?>' />

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Adı</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="" id="text_0" name="adi" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Soyadı</label>
    <input class="cf_inputbox required" maxlength="150" size="30" title="" id="text_1" name="soyadi" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Kaydet" name="button_2" type="submit" />
  </div>
  <div class="cfclear"> </div>
</div>


Chrono Connectivity :
-----------------------------

Where SQL :
<?php
$user =& JFactory::getUser();
if ( !in_array($user->gid, array('24', '25')) ) {
  // user is not an admin
  echo "WHERE `cf_user_id` = '{$user->id}'";
}
?>


Header :
<?php
$style = "";
$style .= "
table.cf_listing {
  margin-bottom: 12px;
}
";
if ( $style) {
  $doc =& JFactory::getDocument();
  $doc->addStyleDeclaration($style);
}
?>
<table width="300" class='cf_listing'>
<thead>
<tr>{new_record}</tr>
<tr>
<th>İşlem</th><th>Adı</th><th>Soyadı</th><th>Kaydeden Kişi</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan='2' style='height:4px; background:silver;'></td>
</tr>
</tfoot>
<tbody>


Body :
<tr><td>{delete_record}</td><td>{adi}</td><td>{soyadi}</td><td>{username}</td></tr>


Footer :
</tbody>
</table>
{pagination}


Data View Fields Names : (I select all of them)

Data View Columns titles :
cf_id,uid,recordtime,ipaddress,cf_user_id,adi,soyadi,username


Thanks for helps.
GreyHead 02 Jul, 2011
Hi underspeed,

All the code here looks OK.

Is it new records created with ChronoForms that are being saved twice?

It sounds as though you may have some code in the form that is saving data?

Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

Bob
underspeed 02 Jul, 2011
Hi GreyHead,

I attached form backup file.
underspeed 02 Jul, 2011
GreyHead,

Now you see my attached file???
GreyHead 02 Jul, 2011
Hi underspeed,

Yes, several times thank you.

Bob
GreyHead 02 Jul, 2011
Hi underspeed,

OK I understand. YOu are using this with ChronoConenctivity.

It seems as though there is a bug in the link between ChronoForms and ChronoConnectivity.

One workaround is to make a copy of your form to use with ChronoConnectivity and turn off the DB Connection on the copy.

Bob

PS I don't use the edit record links in ChronoConnectivity but instead build links directly to the form. This avoids this problem an gives me better control but I have to build my own access control into the form.
underspeed 02 Jul, 2011
GreyHead,

I select turn off the DB Connection on the copy. So i add a record, but i can't see on frontend. Because uid, recordtime, ipaddress and cf_user_id not recorded, only cf_id, name, email, subject and message recorded.

Also i remove {edit_record} from anywhere. Same result.
underspeed 04 Jul, 2011
Could you help me? I don't finished still😟
SilentCid 05 Jul, 2011

Could you help me? I don't finished still😟



Can you post your updated form here again please for us to look at your updated changes? I'm not the greatest person in the world but I some understanding how the forms work now that I've been playing around with it.
underspeed 05 Jul, 2011

Could you help me? I don't finished still😟



Can you post your updated form here again please for us to look at your updated changes? I'm not the greatest person in the world but I some understanding how the forms work now that I've been playing around with it.



I attached last form.
SilentCid 05 Jul, 2011
I've looked at the form and I also was reading on the other thread about having records being saved twice. cb75ter on that thread mentions that he got his to stop saving data twice by going to the form and changing the Saving data/emails order to before email. Yours seems to be set to after email. It also cannot be linked to a menu in Joomla. Now not sure if that will change anything but you can try it and report back.
underspeed 06 Jul, 2011
Hi,

I tried your said. I changed to before email, then it's same result. Also normally i added a menu to main menu for the form. I can see results from frontend but also i check from backend. Same result...
GreyHead 08 Jul, 2011
Hi underspeed,

The form looks good - but you knew that. The problem is in the linkage between ChronoConenctivity and ChronoForms. I don't have a better solution than to use a direct link instead of the {edit_record} link :-(

Bob
This topic is locked and no more replies can be posted.