/** * Returns a list of available avatars. * * @return array */ protected function getAvailableAvatars($groupIDs, $activityPoints) { // get avatar categories $avatarCategories = array(0 => array('category' => null, 'avatars' => array())); foreach (AvatarCategory::getAvatarCategories() as $key => $object) { $avatarCategories[$key] = array('category' => $object, 'avatars' => array()); } // get avatars $i = 0; $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_avatar\n\t\t\tWHERE\t\tuserID = 0\n\t\t\t\t\tAND groupID IN (0," . $groupIDs . ") AND neededPoints <= " . $activityPoints . "\n\t\t\tORDER BY\tavatarName, avatarID"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (isset($avatarCategories[$row['avatarCategoryID']])) { $avatarCategories[$row['avatarCategoryID']]['avatars'][$row['avatarID']] = new Avatar(null, $row); $i++; } } if ($i == 0) { return array(); } return $avatarCategories; }
/** * @see Page::assignVariables() */ public function assignVariables() { parent::assignVariables(); WCF::getTPL()->assign(array('groups' => $this->groups, 'groupID' => $this->groupID, 'neededPoints' => $this->neededPoints, 'filename' => $this->filename, 'avatarCategoryID' => $this->avatarCategoryID, 'availableAvatarCategories' => AvatarCategory::getAvatarCategories())); }
/** * Gets a list of available categories. */ protected function readAvailableCategories() { $sql = "SELECT\t\tavatar_category.*\n\t\t\tFROM\t\twcf" . WCF_N . "_avatar_category avatar_category\n\t\t\tWHERE\t\tavatar_category.groupID IN (0," . implode(',', WCF::getUser()->getGroupIDs()) . ") AND avatar_category.neededPoints <= " . intval(WCF::getUser()->activityPoints) . "\n\t\t\tORDER BY\tavatar_category.title"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $row['title'] = WCF::getLanguage()->get($row['title']); $this->availableAvatarCategories[$row['avatarCategoryID']] = new AvatarCategory(null, $row); } // sort AvatarCategory::sort($this->availableAvatarCategories, 'showOrder'); }