Beispiel #1
0
 public function testRemoveTag2()
 {
     $this->testAddTag();
     $response = TagManager::removeTagIDFromAddonID(1, 1);
     $this->assertTrue($response);
     $this->assertFalse(TagManager::getFromID(1));
     $tag = TagManager::getFromID(2);
     $this->assertNotEquals(false, $tag);
     $this->assertEquals("new tag", $tag->getName());
     $tags = TagManager::getTagsFromAddonID(1);
     $this->assertEquals(1, count($tags));
     $obj = TagManager::getFromID($tags[0]);
     $this->assertEquals("new tag", $obj->getName());
 }
<?php

//collects together all the information needed by /addons/addon.php
if (!isset($_GET['id'])) {
    return false;
}
require_once realpath(dirname(__DIR__) . "/class/AddonManager.php");
require_once realpath(dirname(__DIR__) . "/class/UserManager.php");
require_once realpath(dirname(__DIR__) . "/class/TagManager.php");
require_once realpath(dirname(__DIR__) . "/class/DependencyManager.php");
$addon = AddonManager::getFromID($_GET['id'] + 0);
if ($addon === false) {
    return false;
}
$user = UserManager::getFromBLID($addon->blid);
$tagIDs = $addon->getTags();
$dependencyIDs = $addon->getDependencies();
$tags = [];
$dependencies = [];
foreach ($tagIDS as $tid) {
    $tags[] = TagManager::getFromID($tid);
}
foreach ($dependencyIDs as $did) {
    $dependencies[] = DependencyManager::getFromID($did);
}
//to do: replace "downloads" with "stats"
$response = ["addon" => $addon, "user" => $user, "tags" => $tags, "dependencies" => $dependencies, "downloads" => $addon->getTotalDownloads()];
return $response;
Beispiel #3
0
 public static function removeTagIDFromAddonID($tid, $aid)
 {
     $addon = AddonManager::getFromID($aid);
     if ($addon === false) {
         return false;
     }
     $tag = TagManager::getFromID($tid);
     if ($tag === false) {
         return false;
     }
     return TagManager::removeTagFromAddon($tag, $addon);
 }