コード例 #1
0
ファイル: link.php プロジェクト: webhacking/Textcube
function updateLink($blogid, $link)
{
    $id = $link['id'];
    $name = Utils_Unicode::lessenAsEncoding(trim($link['name']), 255);
    $url = Utils_Unicode::lessenAsEncoding(trim($link['url']), 255);
    if (empty($name) || empty($url)) {
        return false;
    }
    $category = isset($link['category']) ? $link['category'] : 0;
    if (isset($link['newCategory']) && !empty($link['newCategory'])) {
        // Add new category information
        $newCategoryTitle = Utils_Unicode::lessenAsEncoding(trim($link['newCategory']), 255);
        $newCategoryId = addLinkCategory($blogid, $newCategoryTitle);
        if (!empty($newCategoryId)) {
            $category = $newCategoryId;
        }
    }
    $rss = isset($link['rss']) ? Utils_Unicode::lessenAsEncoding(trim($link['rss']), 255) : '';
    $pool = DBModel::getInstance();
    $pool->init("Links");
    $pool->setAttribute("category", $category);
    $pool->setAttribute("name", $name, true);
    $pool->setAttribute("url", $url, true);
    $pool->setAttribute("rss", $rss, true);
    $pool->setAttribute("written", Timestamp::getUNIXtime());
    $pool->setQualifier("blogid", "eq", $blogid);
    $pool->setQualifier("id", "eq", $link['id']);
    $result = $pool->update();
    // Garbage correction
    $pool->init("Links");
    $pool->setQualifier("blogid", "eq", $blogid);
    $existCategories = $pool->getColumn("category", array("filter" => "distinct"));
    $pool->init("LinkCategories");
    $pool->setQualifier("blogid", "eq", $blogid);
    $pool->setQualifier("id", "hasnoneof", $existCategories);
    $pool->delete();
    return $result;
}
コード例 #2
0
ファイル: blog.link.php プロジェクト: hinablue/TextCube
function updateLink($blogid, $link)
{
    global $database;
    $id = $link['id'];
    $name = UTF8::lessenAsEncoding(trim($link['name']), 255);
    $url = UTF8::lessenAsEncoding(trim($link['url']), 255);
    if (empty($name) || empty($url)) {
        return false;
    }
    $category = isset($link['category']) ? $link['category'] : 0;
    $name = POD::escapeString($name);
    $url = POD::escapeString($url);
    if (isset($link['newCategory']) && !empty($link['newCategory'])) {
        // Add new category information
        $newCategoryTitle = UTF8::lessenAsEncoding(trim($link['newCategory']), 255);
        $newCategoryId = addLinkCategory($blogid, $newCategoryTitle);
        if (!empty($newCategoryId)) {
            $category = $newCategoryId;
        }
    }
    $rss = isset($link['rss']) ? POD::escapeString(UTF8::lessenAsEncoding(trim($link['rss']), 255)) : '';
    $result = POD::execute("UPDATE {$database['prefix']}Links\n\t\t\t\tSET\n\t\t\t\t\tcategory = {$category},\n\t\t\t\t\tname = '{$name}',\n\t\t\t\t\turl = '{$url}',\n\t\t\t\t\trss = '{$rss}',\n\t\t\t\t\twritten = UNIX_TIMESTAMP()\n\t\t\t\tWHERE\n\t\t\t\t\tblogid = {$blogid} and id = {$link['id']}");
    // Garbage correction
    $existCategories = POD::queryColumn("SELECT DISTINCT category FROM {$database['prefix']}Links\n\t\t\tWHERE blogid = {$blogid}");
    @POD::execute("DELETE FROM {$database['prefix']}LinkCategories\n\t\t\tWHERE blogid = {$blogid} AND id NOT IN (" . implode(",", $existCategories) . ")");
    return $result;
}