<?php
 class vB_Api_Icon extends vB_Api { public function fetchAll() { $db = vB::getDbAssertor(); $conditions = ['imagetype' => 2]; $iconperms = $db->assertQuery('vBForum:getImageCategoryPermissions', $conditions); $noperms = []; foreach ($iconperms AS $iconperm) { $noperms[$iconperm['imagecategoryid']][] = $iconperm['usergroupid']; } $userinfo = vB::getCurrentSession()->fetch_userinfo(); $membergroupids = []; $infractiongroupids = []; if (!empty($userinfo['membergroupids'])) { $membergroupids = explode(',', $userinfo['membergroupids']); } $membergroupids[] = $userinfo['usergroupid']; if (!empty($userinfo['infractiongroupids'])) { $infractiongroupids = explode(',', $userinfo['infractiongroupids']); $infractiongroupids = array_combine($infractiongroupids, $infractiongroupids); } $badcategories = []; foreach ($noperms AS $imagecategoryid => $usergroups) { foreach ($usergroups AS $usergroupid) { if (isset($infractiongroupids[$usergroupid])) { $badcategories[] = $imagecategoryid; continue 2; } } if (!count(array_diff($membergroupids, $usergroups))) { $badcategories[] = $imagecategoryid; } } if (empty($badcategories)) { $badcategories[] = 0; } $icons = $db->getRows('vBForum:getPostIcons', ['excludecategories' => $badcategories], false, 'iconid'); return $icons; } public function setCategoryPermissions($categoryid, $permissions) { $this->checkHasAdminPermission('canadminimages'); vB_Library::instance('icon')->setCategoryPermissions($categoryid, $permissions); return ['success' => true]; } } 