Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

The related field in user_data table

roberto
2012-05-06
2013-05-28
  • roberto
    roberto
    2012-05-06

    Hi all,
    following instructions at http://www.refbase.net/index.php/Relating_records_to_each_other in order to manage record with cross-reference I've discovered that the relation is stored into the 'user_data' table and is associated to each single user. Is it possible to manage cross referencing in another way? I'd like to show linking among record to all the users, to registered and to anonymous too.
    best regards
    RM

     
  • roberto
    roberto
    2012-05-08

    Hi Richard, I'm speaking about something completely different, please give a look at the screenshot on the right side present at the link mentioned above in my previous post. I need to store the information in the red oval such that 'related' value is not referred to a single logged user but something that could be achieved for all the users, also for those browsing the pages without logging in. I've inserted two records in the Refbase demo (http://demo.refbase.net/). Titles: 'Operating systems : internals and design principles' and 'Principles of modern operating systems'; only for testing purposes I've inserted a reference from first to second. The problem is that you could retrieve it - the reference - only if you are logged in as 'user@refbase.net ' otherwise the link 'display realted records' on the links column disappears. My aim is to show this reference to all the users also for those browsing pages anonymously

     
  • Yes, I know what you want.  I read the other thread too hastily, but Matthias's advice happens to apply here too.  There's no way to do this with an existing public field, you might be able to hack this functionality with a little work:

    refbase offers a user-specific 'related' field that allows you to link records with each other. More info here:

    http://www.refbase.net/index.php/Relating_records_to_each_other

    After successful import, it might be possible to perform a batch SQL update query in order to generate these cross-links (semi-)automatically.

    He had been talking about making the links automatically for one user, but it applies for copying the relations into other user accounts too. Further, you'd need to modify the code to show user-specific links for the anonymous account.

     
  • roberto
    roberto
    2012-05-09

    I had the same thought. Could you give me an advice about how to work for anonymous accounts?
    best regards
    RM

     
  • anonymous uses userID=0.

    The code has a few checks for whether a user is logged in.  For example, this from search.php:

    // generate a link from the RELATED field:
    if (isset($_SESSION['loginEmail'])) // if a user is logged in, show a link to any related records (if available):
    {
        if (!empty($row["related"]))
        {
            $relatedRecordsLink = buildRelatedRecordsLink($row["related"], $userID); // function 'buildRelatedRecordsLink()' is defined in 'include.inc.php'
            $linkArray[] = "\n\t\t<a href=\"" . $baseURL . $relatedRecordsLink . "\"><img src=\"" . $baseURL . "img/related.gif\" alt=\"" . $loc["related"] . "\" title=\"" . $loc["LinkTitle_DisplayRelatedRecords"] . "\" width=\"19\" height=\"16\" hspace=\"0\" border=\"0\"></a>";
        }
    }
    

    You can comment out the login check where appropriate, so that it only checks the presence of the 'related' field.

     
  • roberto
    roberto
    2012-09-30

    Hi. Thank you for your suggestion, sorry for answering so late, but I was in trouble because of other issues…
    I've tried commenting the whole block of code but it doesn't work; it works instead in some way if I edit the if branch in following manner " if (empty($row))". Now the "related" link appears in the top right corner of the page for every user, for logged and not logged too.
    The problem arises when a not logged user clicks on the button, following error message appears:

    SELECT author, title, year, publication, volume, pages, thesis, orig_record, serial, file, url, doi, isbn, type FROM refs WHERE ORDER BY author, year DESC, publication
    
    Error 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY author, year DESC, publication' at line 1
    

    the problem seems to be related with the function buildRelatedRecordsLink($relatedFieldString, $userID) in include.inc.php.
    I've tried to edit 'user_id' field into 'user_data' table altering the numer to '0' (the anonymous login) but still not works
    Could you please give me some advices?
    best regards
    RM

     
  • I've tried commenting the whole block of code but it doesn't work

    You don't want to comment out the whole block: that will make it stop working for everyone.  You want to comment out the conditional:

    // generate a link from the RELATED field:
    //if (isset($_SESSION['loginEmail']))
    //{
        if (!empty($row["related"]))
        {
            $relatedRecordsLink = buildRelatedRecordsLink($row["related"], $userID); // function 'buildRelatedRecordsLink()' is defined in 'include.inc.php'
            $linkArray[] = "\n\t\t<a href=\"" . $baseURL . $relatedRecordsLink . "\"><img src=\"" . $baseURL . "img/related.gif\" alt=\"" . $loc["related"] . "\" title=\"" . $loc["LinkTitle_DisplayRelatedRecords"] . "\" width=\"19\" height=\"16\" hspace=\"0\" border=\"0\"></a>";
        }
    //}
    

    it works instead in some way if I edit the if branch in following manner " if (empty($row))"

    No, that wouldn't work: that would try to create related links when there was no related data!

    I've tried to edit 'user_id' field into 'user_data' table altering the numer to '0' (the anonymous login) but still not works Could you please give me some advices?

    Did you copy data in the user_data table to user_id=0?  What is the output of:

    SELECT * FROM user_data WHERE user_id=0;
    
     
  • roberto
    roberto
    2012-10-03

    Hi, thank you for your quick response.

    Did you copy data in the user_data table to user_id=0?  What is the output of:
    SELECT * FROM user_data WHERE user_id=0;

    no single row!
    user_id=0 is not present in 'users' table, the first user has ID = 1

    You want to comment out the conditional:

    still not working, the link icon appears only for registered users.

    When I simply logout, the following message appears at the top of the page:

    Display of user-specific fields was omitted!

    maybe the presence of the icon is still related with registered users only?
    best regards
    RM

     
  • no single row!

    This means you didn't follow the directions, above, to copy user_data, modifying the user_id.  This is one reason the link doesn't appear for guest users!

    The short summary of this thread:  the requested feature is not officially supported.  It requires at least three significant changes to work:

    • Modify the user_data table in the database so that user_id=0 has the related records marked as you desire

    • Modify includes/include.inc.php so that the guest account uses id=0 and the user-specific searches are enabled for the account.

    • Modify search.php so that the related search is performed for users not logged in

    This outline is meant to provide a hint/nudge to help you customize refbase to suit your needs, but I don't have the resources to do this customization for you (my limited amount of time to do customizations that won't make it into the official distribution goes to a couple of clients).

     
  • roberto
    roberto
    2012-10-04

    This means you didn't follow the directions, above, to copy user_data, modifying the user_id

    where? what are you talking about?

    at the following link r  there are no suggestions suitable for this topic

    the topic  is still unsolved, and moreover does not offer solution for copying user_data and modifying user_id

    previously you wrote me

    Did you copy data in the user_data table to user_id=0?

    but it's unclear how to do it….

    Could you please give me some more detailed information?
    best regards
    RM

     
  • Again, the scope of these changes and the divergence away from the refbase we distribute is significant enough that you will have to do the development yourself (or hire someone to do it).  I have not tested the changes, so do not have much detail to give you.  I can only point you in the right direction.  The SQL would be similar to:

    INSERT INTO user_data (record_id, user_id, related) SELECT record_id, "0", related FROM user_data WHERE user_id="2";
    

    Then you would need to modify search.php and includes/include.inc.php.

     
  • roberto
    roberto
    2012-10-07

    Does somebody have some more detailed information? Such advices are too much fragmented. Moreover, what is strange in the original default architecture of Refbase, is why should it be a "user preference" the definition of the relation among different records? In case that two or more records are related it should be evident to everybody, also for logged and anonymous visitors. Actually what happens is that if I'm logged in as user e.g. "12" and I register a relation between two records it becomes linkable only for my user profile; in case that solution proposed by karnesky should work,  a relation link should appear for unregistered user (user with ID= "0"), but what will happen when, let's say, user wit ID "32" makes login? Does the relationship disappear?

     
  • I can't speak to why Matthias made this user-specific.  It could be that it was just listed as a need when other user-specific data was needed.  Some people want to keep track of different relationships (cites/cited by/reminds me of/inspired by/critique or review of/contained within/alternate versions of a work/etc.).  Some of these relationships may benefit from privacy.  In practice, the field is rarely used in the very large databases I maintain.

    You are correct that you'd have to copy the relation to other user ids with the current implementation if you wanted it to work with ID=32.

    More substantial changes to the code/database would be needed to make it a truly public field.  This is possible, but would require a significant time investment.