Skip to content

Commit

Permalink
Partial fix for #1225. Create a json reply helper that sets the conte…
Browse files Browse the repository at this point in the history
…nt type to application/json and then json encodes the reply.
  • Loading branch information
Tim Almdal authored and bharat committed Jul 31, 2010
1 parent 5c0998c commit bb04015
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions modules/gallery/helpers/json.php
@@ -0,0 +1,34 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class json_Core {
/**
* Does the active user have this permission on this item?
*
* @param string $perm_name
* @param Item_Model $item
* @return boolean
*/
static function reply($message) {
if (!headers_sent()) {
header("Content-Type: application/json");
}
print json_encode($message);
}
}

0 comments on commit bb04015

Please sign in to comment.