ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Flag Inappropriate

September 16, 2007 2:21am

Subscribe [7]
  • #1 / Sep 16, 2007 2:21am

    Ty Martin

    232 posts

    Hi guys,

    Is there a way for users (front end) to flag an entry as inappropriate? I have several statuses set up to be flags but not sure how to create code that would enable me to provide users with a button to flag content. I’m thinking of, perhaps, a stand alone edit form that only changes the status…

    Am I on the right track?

  • #2 / Sep 16, 2007 2:41am

    PXLated

    1800 posts

    Just thinking outloud…Could you use a custom contact form instead?

  • #3 / Sep 16, 2007 2:47am

    Ty Martin

    232 posts

    Hmm, interesting. That’s not the workflow I was thinking of, but that sounds like an okay idea. We were hoping that any flagged material would be immediately taken out of the viewable entries, but maybe we need to reconsider.

    Thanks PXLated.

  • #4 / Sep 16, 2007 9:38am

    Derek Jones

    7561 posts

    You could have a link that points to a particular template, for instance: http://example.com/index.php/articles/flag/{entry_id}/

    Then the following PHP could either be in the template, or in a plugin with the plugin tag on said template.  You’d obviously want to structure it to provide the feedback you desire, redirects to particular pages, or use this as the action for an AJAX driven request.

    <?php
    global $DB, $IN;
    
    $entry_id = $IN->fetch_uri_segment('3');
    
    $check = $DB->query("SELECT COUNT(*) AS count FROM exp_weblog_titles WHERE entry_id = '".$DB->escape_str($entry_id)."'");
    
    if ($check->row['count'] != 1)
    {
        exit('Valid entry id not found');
    }
    
    $DB->query($DB->update_string('exp_weblog_titles', array('status' => 'Inappropriate'), array('entry_id' => $entry_id)));
    
    exit('Successfully updated entry');
    
    ?>
  • #5 / Sep 16, 2007 1:47pm

    Ty Martin

    232 posts

    Indeed Derek, now we’re talking… thanks a lot dude.

  • #6 / Sep 17, 2007 6:26pm

    Ty Martin

    232 posts

    Following up to this having now implemented it (it works as is), I’m just realizing that the {reverse_related_entries} do not support a status=“Open” parameter, so it’s still pulling in flagged entries. Dang.

    Any ideas for this? Thanks!

  • #7 / Sep 17, 2007 6:30pm

    Derek Jones

    7561 posts

    Sure it does; but they are cached.  If relationships are involved in these entries, you’ll want to add this at the end of the above code:

    global $FNS;
    $FNS->clear_caching('relationships');

    Then when the entries are accessed next, the relationship cache will rebuild, with the updated status.

  • #8 / Sep 17, 2007 7:25pm

    Ty Martin

    232 posts

    Okay, got it, but {reverse_related_entries sort="asc" orderby="entry_date" status="Open"} now returns nothing. What did I miss?

  • #9 / Sep 17, 2007 7:29pm

    Derek Jones

    7561 posts

    It shouldn’t be case sensitive, but try it with a status of “open” or without the parameter at all, in which case it defaults to “open” status entries.

  • #10 / Sep 17, 2007 7:29pm

    Ty Martin

    232 posts

    Oh, status=“open”... I got it.

    Now I’m getting this in the template:

    Notice: Undefined variable: FNS in /home/mysite/public_html/system/core/core.functions.php(635) : eval()'d code on line 2
    
    Fatal error: Call to a member function on a non-object in /home/mysite/public_html/system/core/core.functions.php(635) : eval()'d code on line 3

    EDIT: removed secure folder names

  • #11 / Sep 17, 2007 7:36pm

    Ty Martin

    232 posts

    And, actually, even with status=“open” it’s still pulling in entries that have other statuses like “inappropriate” or “flagged”

  • #12 / Sep 17, 2007 7:48pm

    Derek Jones

    7561 posts

    First make sure that you are referencing the global Functions class object:

    global $FNS;

    Next, this goes at the end of the PHP in the template that switches the status, if that wasn’t clear.  You want the cache clearing triggered when the status is modified, not every time the display page is accessed.

    It’s likely still displaying the entries because the caches have still not yet been successfully cleared.

  • #13 / Sep 17, 2007 8:09pm

    Ty Martin

    232 posts

    Yay! Together, Derek, we could rule the world.

    F’in eh man! :D

  • #14 / Sep 22, 2007 7:15am

    Thorvald

    10 posts

    Just for future reference, could you post your final code?

  • #15 / Sep 22, 2007 12:23pm

    Ty Martin

    232 posts

    Just for future reference, could you post your final code?

    Can you tell us what you’re looking for?

    In the end I didn’t produce a solution that resembled what I was talking about initially. So what are you trying to do?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases