root/branches/release-38/php/lib/function.mtauthoruserpicurl.php @ 2356

Revision 2356, 0.9 kB (checked in by takayama, 19 months ago)

Fixed BugId:79763
* When author object was not found in the context, try to load author object from entry in the context

Line 
1<?php
2# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd.
3# This program is distributed under the terms of the
4# GNU General Public License, version 2.
5#
6# $Id$
7
8function smarty_function_mtauthoruserpicurl($args, &$ctx) {
9    $author = $ctx->stash('author');
10    if (empty($author)) {
11        $entry = $ctx->stash('entry');
12        if (!empty($entry)) {
13            $author = $ctx->mt->db->fetch_author($entry['entry_author_id']);
14        }
15    }
16
17    if (empty($author)) {
18        return $ctx->error("No author available");
19    }
20
21    $asset_id = isset($author['author_userpic_asset_id']) ? $author['author_userpic_asset_id'] : 0;
22    $asset = $ctx->mt->db->fetch_assets(array('id' => $asset_id));
23    if (!$asset) return '';
24
25    $blog =& $ctx->stash('blog');
26
27    require_once("MTUtil.php");
28    $userpic_url = userpic_url($asset[0], $blog, $author);
29    return $userpic_url;
30}
31?>
Note: See TracBrowser for help on using the browser.