Exemplo n.º 1
0
function convertImage($image)
{
    PHPWS_Core::initModClass('wiki', 'WikiImage.php');
    $newimage = new WikiImage();
    $newimage->setOwnerId(Current_User::getId());
    $newimage->setCreated($image['created']);
    $newimage->setFilename($image['filename']);
    $newimage->setSize($image['size']);
    $newimage->setType($image['type']);
    $newimage->setSummary($image['summary']);
    $db = new PHPWS_DB('wiki_images');
    $result = $db->saveObject($newimage);
    if (PEAR::isError($result)) {
        PHPWS_Error::log($result);
        return FALSE;
    }
    if (OLD_WIKI_IMAGES . $image['filename'] != PHPWS_HOME_DIR . 'images/wiki/' . $newimage->getFilename()) {
        if (!@copy(OLD_WIKI_IMAGES . $image['filename'], PHPWS_HOME_DIR . 'images/wiki/' . $newimage->getFilename())) {
            return FALSE;
        }
    }
    return TRUE;
}