1

Topic: added_by filled by default

I've installed and customized labstore and am pretty happy with it.  The plasmid module now calculates at what position in what box a plasmid sits, and only the owner of a record sees the edit and delete buttons.

What still bugs me is that the 'added_by' field isn't filled in automagically that same what that 'added_on' is.  As the id of the current user is know, this should not be difficult.  How do I do it short of running a script on my database that updates all recent entries with the correct 'added_by' value?

(Some more bla-blah:  As there is only one correct value, I don't want users to have to pick a value and would prefer not to show this field in the first place.  But I would like to have an entry for 'added_by' because I prefer seeing the full name in the details or the plasmids.php page instead of just the username.)


Thanks.


Andreas

2

Re: added_by filled by default

Thanks for trying LabStoRe. I am working on version 2 of LabStoRe, and if there are certain features you'd like to have, let me know.

LabStoRe uses something called 'Interface creator' internally to generate the insert/edit forms for the records/entries. An admin can use it to alter the forms. Certain alterations can break the front-end, though the particular change you seek should not cause any issue. I haven't tested it, so let me know if you run into problems.

Here are the steps to have the 'added_by' field not shown at all.

1. Click on the 'Admin' link on the front-page.
2. Click the link for 'Interface creator page' on the subsequent page.
3. If required, change the table to 'plasmids' using the menu at the top on the subsequent page.
4. Click the 'go to this page' link in the red paragraph ('To configure the interface...').
5. Choose the 'added_by' field in the top menu to configure it.
6. Set 'Field present in the insert/update form?', etc., fields to 'N'.

Now the field won't be shown, but it won't get auto-filled either.

To have the 'added_by' field auto-filled with user ID, changing field-type from 'select_single' to 'ID_user' should work .

3

Re: added_by filled by default

Thanks Santosh. I though I had tried that, but I obviously hadn't. It works as advertised, but this is not exactly what I want. I can get the ID_user attribute directly from the ID_user column, like so (to fill the Owner/Creator column):

echo ('</td><td>' .$row["owner"]);

is equivalent to

echo ('</td><td>' .$row["ID_user"]);

if I follow your instructions. In either case, output is '</td><td>harryP' instead of '</td><td>Harry Potter', for example.

To fix this, I added the following query to plasmids.php right below 'include ("../top_part.php");':

$queryAF = "SELECT username, name from users";
$resultAF = mysql_query($queryAF);
while ($rowAF = mysql_fetch_array ($resultAF)) {
    $resultsArrayAF[$rowAF["username"]] = $rowAF["name"];
}

and then

echo ('</td><td>' .$resultsArrayAF[$row["ID_user"]]);

Now I get the full name without troubling users with another value to enter. (I decided to ask for 'Owner' but left 'Added_by' out because it's covered by ID_user.)

4

Re: added_by filled by default

Perhaps I had misunderstood the issue.

Your code modification is correct. You likely noted this though, that the above code change affects only the record display and not the forms for editing/inserting records.

5

Re: added_by filled by default

Exactly.  The code only changes the way the information in the database is presented.  There is no point of entering the same bit of information twice.  So I removed the 'Added_by' field from the data entry form.