Jump to content

TWIRED

Caspio Ninja
  • Posts

    81
  • Joined

  • Last visited

  • Days Won

    1

TWIRED last won the day on December 28 2016

TWIRED had the most liked content!

About TWIRED

  • Birthday May 7

Recent Profile Visitors

2,667 profile views

TWIRED's Achievements

Single Status Update

See all updates by TWIRED

  1. Hey there!

     

    Thanks a lot for your reply on my  Limit the number of search by user?  post.

     

    Just a quick question. When you say:

     

    ==

    Every time a FreeUser logs in:

    - stamp the datetime in the "logindatetime" field.

     

    Everytime a FreeUser completes a search 

    -Increase the SearchCount with an increment of 1

     

    ==

     

    Do you mean that I have to do it manually everytime? Is there no way for it to be done automatically ?

    1. TWIRED

      TWIRED

      •  
      • TWIRED
      • Caspio Ninja
      •  1
      • 64 posts
      • LocationNew York

      Cherif....

      Ive given it a thought and based on what "I think  I understand"  about your setup Hopefully heres a solution.

      Goal : To Restrict User Search to Max 5  Searches within the same day ,if not a Paid subscriber.

      ----------------------------------------------------------------------------------------------------
      Your Tables and Datapages Setup
      ------------------------------------------------------------------------------------------

      Lets say you already have the following Tables created 
      1) UserInfo Table ( all your userprofile information)
      2) SearchResults Table ( a table which you are doing your searches against)

       

      Create a Parent Child Relationship

      UserInfo (One) - (Many) -SearchResults) based on UserID

       

      Add 3 fields to  the "UserInfo" table

      - LastSearchedDateTime field (datetime data type ) 

      - SearchCounted field (Number data type) << If he is permitted to search , after search increase the counter by 1

      -PaidUser ? (Yes/No) << This will have to be updated programatically (an administrator update form or entered directly into database)

      Create View "UserAuthView" and Authentication "UserAuth" based on UserInfo Table.  << This is Very Important to get the fields from UserInfo table

      Search & Report dataPage (1 single Page) - Allow users to select data using a search form
      Im assuming you have setup a SearchReports Datapage (Same Page) 
      Make the source of your "Search" DataPage  : "ADummyTable" << Justa simple one field dummy table, it does not matter.


      When a User Clicks on Search , 
      a Javascript function  will get the values of the 3 fields above , and test it to permit or not permit additional searches.


      -------------------------------
      The "Search & Report" DataPage
      ----------------------------
      Data Source = "ADummyTable"
      MUST HAVE Authentication Enabled ! << authentication will be based on >>> UserInfo Table << , from which we will get lastdatetime,searchcounter  and paiduser  fields.

      Create Virtual Fields for Your actual Search Filters.

      Place a footer and javascript in the section below for validation:
      Search and Report Wizard - Configure Search Fields

      --------------------------------------------------------------
      Pseudo JS Code in footer >>  SearchPage << 
      -----------------------------------------------------------------
      //Validate based on 24 Hours in same day , and 5 Searches Maximum


      //Get last searched date from field in table
      LastSearchedDateTimefield=(example 01/15/2017)


      //get the Searchcount from table
      Searchcountedfield=(example: 2)

      //Get PaidUser Value from table
      PaidUserfield= (example: "No")

      //Validate (Pseudo Code)

      @MaxSearchesAllowed=5;
      IF  todays date is greater than date in lastdatetime field (and paiduser=No ), get counter in table,  and set it to 1 where userid =userid >> allow access

      IF todays date is the same as the lastdatetime in lastdatetime field , then get the counter value from  table, 
      - if counter in table is under @MaxSearchesAllowed , increment counter by 1 >> allow access
      -if counter in table =  @MaxSearchesAllowed then >> deny search

      IF lastdatetime field or counter field is blank, then set to current date and counter to 1 >> allow access  (First Time User)

      IF Paid User = Yes , then >>> allow full access (log the current datetime and increase the counter 
       

       Continue to Results Page....
       

    2. Cherif

      Cherif

      Hey there.

       

      I have given it a go but my knowledge of JavaScript is way too limited for this I guess :(

    3. TWIRED

      TWIRED

      Hey Cherif...

      I had contacted support, this is what they replied.

       

      Thank you for contacting Caspio Support.

      I would recommend separating the search and report DataPage into two DataPages as found in this How-To: 
      http://howto.caspio.com/tech-tips-and-articles/tech-parameters/how-to-separate-search-page-and-results-page-into-two-different-webpages/
      or discussed in this video: http://howto.caspio.com/getting-started/display-results-on-a-separate-web-page/

      The key difference in your scenario, is the initial search (now a submission form) would use the data source where you need to submit information. You would use the actual fields for that table instead of the virtual fields as discussed in the article. You would still pass these values on exit, so that the results page can be filtered by these values. This way the submission form passes the required parameters and also submits the records, with no need for a hidden form and auto-submit.
       

    4. Show next comments  3 more
×
×
  • Create New...