Exemple #1
0
        throw new Exception(Language::GetText('error_flag_own'));
    }
    // Verify Flag doesn't exist
    $data = array('type' => $_POST['type'], 'id' => $_POST['id'], 'user_id' => $user->user_id);
    if (Flag::Exist($data)) {
        throw new Exception(Language::GetText('error_flag_duplicate'));
    }
    Plugin::Trigger('flag.ajax.before_flag');
    // Send admin alert
    if (Settings::Get('alerts_flags') == '1') {
        $subject = 'Content Flagged As Inappropriate';
        $body = "One of your members flagged content as inappropriate. ";
        $body .= "Please review the content to verify it is valid. ";
        $body .= "You can login to the Admin Panel to dismiss the flag, or uphold it and ban the content.";
        $body .= "\n\n=======================================================\n";
        $body .= "Content Type: {$type}\n";
        $body .= "URL: {$url}\n";
        $body .= "{$name}\n";
        $body .= "=======================================================";
        Plugin::Trigger('flag.ajax.alert');
        App::Alert($subject, $body);
    }
    // Create flag and output message
    Flag::Create($data);
    Plugin::Trigger('flag.ajax.flag');
    echo json_encode(array('result' => 1, 'msg' => (string) Language::GetText('success_flag')));
    exit;
} catch (Exception $e) {
    echo json_encode(array('result' => 0, 'msg' => $e->getMessage()));
    exit;
}