Overview

Namespaces

  • Budabot
    • Core
      • Modules
    • User
      • Modules
  • None
  • Tyrence
    • Modules

Classes

  • AccessLevel
  • Budabot\Core\AccessManager
  • Budabot\Core\AdminManager
  • Budabot\Core\AOChat
  • Budabot\Core\AOChatPacket
  • Budabot\Core\AOChatQueue
  • Budabot\Core\AOExtMsg
  • Budabot\Core\AsyncHttp
  • Budabot\Core\AutoInject
  • Budabot\Core\BotRunner
  • Budabot\Core\Budabot
  • Budabot\Core\BuddylistManager
  • Budabot\Core\CacheManager
  • Budabot\Core\CacheResult
  • Budabot\Core\ClassLoader
  • Budabot\Core\ColorSettingHandler
  • Budabot\Core\CommandAlias
  • Budabot\Core\CommandManager
  • Budabot\Core\ConfigFile
  • Budabot\Core\DB
  • Budabot\Core\DBRow
  • Budabot\Core\EventLoop
  • Budabot\Core\EventManager
  • Budabot\Core\GuildChannelCommandReply
  • Budabot\Core\GuildManager
  • Budabot\Core\HelpManager
  • Budabot\Core\Http
  • Budabot\Core\HttpRequest
  • Budabot\Core\LegacyLogger
  • Budabot\Core\LimitsController
  • Budabot\Core\LoggerWrapper
  • Budabot\Core\MMDBParser
  • Budabot\Core\Modules\AdminController
  • Budabot\Core\Modules\AliasController
  • Budabot\Core\Modules\AltInfo
  • Budabot\Core\Modules\AltsController
  • Budabot\Core\Modules\BanController
  • Budabot\Core\Modules\BuddylistController
  • Budabot\Core\Modules\ColorsController
  • Budabot\Core\Modules\CommandlistController
  • Budabot\Core\Modules\CommandSearchController
  • Budabot\Core\Modules\ConfigController
  • Budabot\Core\Modules\EventlistController
  • Budabot\Core\Modules\HelpController
  • Budabot\Core\Modules\LogsController
  • Budabot\Core\Modules\PlayerLookupController
  • Budabot\Core\Modules\ProfileCommandReply
  • Budabot\Core\Modules\ProfileController
  • Budabot\Core\Modules\SettingsController
  • Budabot\Core\Modules\SQLController
  • Budabot\Core\Modules\SystemController
  • Budabot\Core\Modules\UsageController
  • Budabot\Core\Modules\WhitelistController
  • Budabot\Core\NumberSettingHandler
  • Budabot\Core\OptionsSettingHandler
  • Budabot\Core\PlayerHistory
  • Budabot\Core\PlayerHistoryManager
  • Budabot\Core\PlayerManager
  • Budabot\Core\Preferences
  • Budabot\Core\PrivateChannelCommandReply
  • Budabot\Core\PrivateMessageCommandReply
  • Budabot\Core\Registry
  • Budabot\Core\SettingHandler
  • Budabot\Core\SettingManager
  • Budabot\Core\SettingObject
  • Budabot\Core\SocketManager
  • Budabot\Core\SocketNotifier
  • Budabot\Core\SubcommandManager
  • Budabot\Core\Text
  • Budabot\Core\TextSettingHandler
  • Budabot\Core\Timer
  • Budabot\Core\TimerEvent
  • Budabot\Core\TimeSettingHandler
  • Budabot\Core\Util
  • Budabot\Core\xml
  • Budabot\User\Modules\AlienArmorController
  • Budabot\User\Modules\AlienBioController
  • Budabot\User\Modules\AlienMiscController
  • Budabot\User\Modules\AOSpeakController
  • Budabot\User\Modules\AOUController
  • Budabot\User\Modules\AXPController
  • Budabot\User\Modules\BankController
  • Budabot\User\Modules\BosslootController
  • Budabot\User\Modules\BroadcastController
  • Budabot\User\Modules\BuffPerksController
  • Budabot\User\Modules\CacheController
  • Budabot\User\Modules\ChatAssistController
  • Budabot\User\Modules\ChatCheckController
  • Budabot\User\Modules\ChatLeaderController
  • Budabot\User\Modules\ChatRallyController
  • Budabot\User\Modules\ChatSayController
  • Budabot\User\Modules\ChatTopicController
  • Budabot\User\Modules\CityWaveController
  • Budabot\User\Modules\CloakController
  • Budabot\User\Modules\ClusterController
  • Budabot\User\Modules\CountdownController
  • Budabot\User\Modules\DevController
  • Budabot\User\Modules\DingController
  • Budabot\User\Modules\EventsController
  • Budabot\User\Modules\FightController
  • Budabot\User\Modules\FindOrgController
  • Budabot\User\Modules\FindPlayerController
  • Budabot\User\Modules\FunController
  • Budabot\User\Modules\GitController
  • Budabot\User\Modules\GuideController
  • Budabot\User\Modules\GuildController
  • Budabot\User\Modules\HelpbotController
  • Budabot\User\Modules\HtmlDecodeController
  • Budabot\User\Modules\ImplantController
  • Budabot\User\Modules\ImplantDesignerController
  • Budabot\User\Modules\InactiveMemberController
  • Budabot\User\Modules\ItemsController
  • Budabot\User\Modules\KillOnSightController
  • Budabot\User\Modules\LevelController
  • Budabot\User\Modules\LinksController
  • Budabot\User\Modules\LootListsController
  • Budabot\User\Modules\MdbController
  • Budabot\User\Modules\MessageInfoCommandReply
  • Budabot\User\Modules\MockCommandReply
  • Budabot\User\Modules\NanoController
  • Budabot\User\Modules\NewsController
  • Budabot\User\Modules\NotesController
  • Budabot\User\Modules\OnlineController
  • Budabot\User\Modules\OrgHistoryController
  • Budabot\User\Modules\OrglistController
  • Budabot\User\Modules\OrgMembersController
  • Budabot\User\Modules\OSController
  • Budabot\User\Modules\PlayerHistoryController
  • Budabot\User\Modules\PlayfieldController
  • Budabot\User\Modules\PocketbossController
  • Budabot\User\Modules\PremadeImplantController
  • Budabot\User\Modules\PrivateChannelController
  • Budabot\User\Modules\QuoteController
  • Budabot\User\Modules\RaffleController
  • Budabot\User\Modules\RaidController
  • Budabot\User\Modules\RandomController
  • Budabot\User\Modules\RecipeController
  • Budabot\User\Modules\RelayController
  • Budabot\User\Modules\ReputationController
  • Budabot\User\Modules\ResearchController
  • Budabot\User\Modules\RunAsController
  • Budabot\User\Modules\SendTellController
  • Budabot\User\Modules\ShoppingController
  • Budabot\User\Modules\SilenceController
  • Budabot\User\Modules\SkillsController
  • Budabot\User\Modules\SpiritsController
  • Budabot\User\Modules\StopwatchController
  • Budabot\User\Modules\Teamspeak3
  • Budabot\User\Modules\TeamspeakController
  • Budabot\User\Modules\TestController
  • Budabot\User\Modules\TimeController
  • Budabot\User\Modules\TimerController
  • Budabot\User\Modules\TimezoneController
  • Budabot\User\Modules\TowerController
  • Budabot\User\Modules\TrackerController
  • Budabot\User\Modules\TrickleController
  • Budabot\User\Modules\UnixtimeController
  • Budabot\User\Modules\VoteController
  • Budabot\User\Modules\WeatherController
  • Budabot\User\Modules\WhatBuffsController
  • Budabot\User\Modules\WhereisController
  • Budabot\User\Modules\WhoisController
  • Budabot\User\Modules\WhoisOrgController
  • Budabot\User\Modules\WhompahController
  • Command
  • DefaultStatus
  • DefineCommand
  • Description
  • Event
  • HandlesCommand
  • Help
  • Inject
  • Instance
  • Intoptions
  • Matches
  • Options
  • Setting
  • Setup
  • Type
  • Tyrence\Modules\DemoResponseCommandReply
  • Tyrence\Modules\SameChannelResponseController
  • Visibility

Interfaces

  • Budabot\Core\CommandReply

Exceptions

  • Budabot\Core\InvalidHttpRequest
  • Budabot\Core\SQLException
  • Budabot\Core\StopExecutionException

Functions

  • Budabot\Core\isWindows
  • Budabot\Core\Modules\read_input
  • Overview
  • Namespace
  • Class
  1: <?php
  2: 
  3: namespace Budabot\Core;
  4: 
  5: use stdClass;
  6: 
  7: /**
  8:  * @Instance
  9:  */
 10: class HelpManager {
 11: 
 12:     /** @Inject */
 13:     public $db;
 14: 
 15:     /** @Inject */
 16:     public $accessManager;
 17: 
 18:     /** @Inject */
 19:     public $configController;
 20: 
 21:     /** @Inject */
 22:     public $chatBot;
 23: 
 24:     /** @Inject */
 25:     public $util;
 26: 
 27:     /** @Logger */
 28:     public $logger;
 29: 
 30:     /**
 31:      * @name: register
 32:      * @description: Registers a help command
 33:      */
 34:     public function register($module, $command, $filename, $admin, $description) {
 35:         $this->logger->log('DEBUG', "Registering $module:help($command) Helpfile:($filename)");
 36: 
 37:         $command = strtolower($command);
 38: 
 39:         // Check if the file exists
 40:         $actual_filename = $this->util->verifyFilename($module . '/' . $filename);
 41:         if ($actual_filename == '') {
 42:             $this->logger->log('ERROR', "Error in registering the File $filename for Help command $module:help($command). The file doesn't exist!");
 43:             return;
 44:         }
 45: 
 46:         if (isset($this->chatBot->existing_helps[$command])) {
 47:             $sql = "UPDATE hlpcfg_<myname> SET `verify` = 1, `file` = ?, `module` = ?, `description` = ? WHERE `name` = ?";
 48:             $this->db->exec($sql, $actual_filename, $module, $description, $command);
 49:         } else {
 50:             $sql = "INSERT INTO hlpcfg_<myname> (`name`, `module`, `file`, `description`, `admin`, `verify`) VALUES (?, ?, ?, ?, ?, ?)";
 51:             $this->db->exec($sql, $command, $module, $actual_filename, $description, $admin, '1');
 52:         }
 53: 
 54:         $row = $this->db->queryRow("SELECT * FROM hlpcfg_<myname> WHERE `name` = ?", $command);
 55:     }
 56: 
 57:     /**
 58:      * @name: find
 59:      * @description: Find a help topic by name if it exists and if the user has permissions to see it
 60:      */
 61:     public function find($helpcmd, $char) {
 62:         $helpcmd = strtolower($helpcmd);
 63: 
 64:         $sql = "
 65:             SELECT module, file, name, GROUP_CONCAT(admin) AS admin_list FROM
 66:                 (SELECT module, admin, cmd AS name, help AS file FROM cmdcfg_<myname> WHERE cmdevent = 'cmd' AND cmd = ?  AND status = 1 AND help != ''
 67:                 UNION
 68:                 SELECT module, admin, name, help AS file FROM settings_<myname> WHERE name = ? AND help != ''
 69:                 UNION
 70:                 SELECT module, admin, name, file FROM hlpcfg_<myname> WHERE name = ? AND file != '') t
 71:             GROUP BY module, file";
 72:         $data = $this->db->query($sql, $helpcmd, $helpcmd, $helpcmd);
 73:         
 74:         if (count($data) == 0) {
 75:             $helpcmd = strtoupper($helpcmd);
 76:             $sql = "
 77:                 SELECT module, file, name, GROUP_CONCAT(admin) AS admin_list FROM
 78:                     (SELECT module, admin, cmd AS name, help AS file FROM cmdcfg_<myname> WHERE cmdevent = 'cmd' AND module = ? AND status = 1 AND help != ''
 79:                     UNION
 80:                     SELECT module, admin, name, help AS file FROM settings_<myname> WHERE module = ? AND help != ''
 81:                     UNION
 82:                     SELECT module, admin, name, file FROM hlpcfg_<myname> WHERE module = ? AND file != '') t
 83:             GROUP BY module, file";
 84:             $data = $this->db->query($sql, $helpcmd, $helpcmd, $helpcmd);
 85:         }
 86:         
 87:         $accessLevel = $this->accessManager->getAccessLevelForCharacter($char);
 88: 
 89:         $output = '';
 90:         forEach ($data as $row) {
 91:             if ($this->checkAccessLevels($accessLevel, explode(",", $row->admin_list))) {
 92:                 $output .= $this->configController->getAliasInfo($row->name);
 93:                 $output .= trim(file_get_contents($row->file)) . "\n\n";
 94:             }
 95:         }
 96: 
 97:         return (empty($output) ? false : $output);
 98:     }
 99: 
100:     public function update($helpTopic, $admin) {
101:         $helpTopic = strtolower($helpTopic);
102:         $admin = strtolower($admin);
103: 
104:         $this->db->exec("UPDATE hlpcfg_<myname> SET `admin` = ? WHERE `name` = ?", $admin, $helpTopic);
105:     }
106: 
107:     public function checkForHelpFile($module, $file) {
108:         $actualFilename = $this->util->verifyFilename($module . '/' . $file);
109:         if ($actualFilename == '') {
110:             $this->logger->log('WARN', "Error in registering the help file {$module}/{$file}. The file doesn't exist!");
111:         }
112:         return $actualFilename;
113:     }
114: 
115:     public function getAllHelpTopics($char) {
116:         $sql = "
117:             SELECT module, file, name, description, sort, GROUP_CONCAT(admin) AS admin_list FROM (
118:                 SELECT module, admin, help AS file, name, description, 3 AS sort FROM settings_<myname> WHERE help != ''
119:                 UNION
120:                 SELECT module, admin, help AS file, cmd AS name, description, 2 AS sort FROM cmdcfg_<myname> WHERE `cmdevent` = 'cmd' AND status = 1 AND help != ''
121:                 UNION
122:                 SELECT module, admin, file, name, description, 1 AS sort FROM hlpcfg_<myname>) t
123:             GROUP BY module, file, name, description, sort
124:             ORDER BY module, name, sort DESC, description";
125:         $data = $this->db->query($sql);
126: 
127:         if ($char !== null) {
128:             $accessLevel = $this->accessManager->getAccessLevelForCharacter($char);
129:         }
130: 
131:         $topics = array();
132:         forEach ($data as $row) {
133:             if ($char === null || $this->checkAccessLevels($accessLevel, explode(",", $row->admin_list))) {
134:                 $obj = new stdClass;
135:                 $obj->module = $row->module;
136:                 $obj->name = $row->name;
137:                 $obj->description = $row->description;
138:                 $topics []= $obj;
139:             }
140:         }
141: 
142:         return $topics;
143:     }
144:     
145:     public function checkAccessLevels($accessLevel1, $accessLevelsArray) {
146:         forEach ($accessLevelsArray as $accessLevel2) {
147:             if ($this->accessManager->compareAccessLevels($accessLevel1, $accessLevel2) >= 0) {
148:                 return true;
149:             }
150:         }
151:         return false;
152:     }
153: }
154: 
Budabot 4 Docs API documentation generated by ApiGen