1: <?php
2:
3: namespace Budabot\User\Modules;
4:
5: use Exception;
6:
7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20:
21: class ClusterController {
22:
23: 24: 25: 26:
27: public $moduleName;
28:
29:
30: public $db;
31:
32:
33: public $text;
34:
35:
36: public $util;
37:
38: 39: 40: 41:
42: public function clusterListCommand($message, $channel, $sender, $sendto, $args) {
43: $sql = "SELECT ClusterID, LongName FROM Cluster ORDER BY LongName ASC";
44: $data = $this->db->query($sql);
45: $count = count($data);
46:
47: forEach ($data as $cluster) {
48: $blob .= $this->text->makeChatcmd($cluster->LongName, "/tell <myname> cluster $cluster->LongName") . "\n";
49:
50: }
51: $msg = $this->text->makeBlob("Cluster List ($count)", $blob);
52: $sendto->reply($msg);
53: }
54:
55: 56: 57: 58:
59: public function clusterCommand($message, $channel, $sender, $sendto, $args) {
60: $search = trim($args[1]);
61:
62: list($query, $params) = $this->util->generateQueryFromParams(explode(' ', $search), 'LongName');
63:
64: $sql = "SELECT ClusterID, LongName FROM Cluster WHERE $query";
65: $data = $this->db->query($sql, $params);
66: $count = count($data);
67:
68: if ($count == 0) {
69: $msg = "No skills found that match <highlight>$search<end>.";
70: } else {
71: $implantDesignerLink = $this->text->makeChatcmd("implant designer", "/tell <myname> implantdesigner");
72: $blob = "Click 'Add' to add cluster to $implantDesignerLink.\n\n";
73: forEach ($data as $cluster) {
74: $sql = "SELECT i.ShortName as Slot, c2.Name AS ClusterType FROM ClusterImplantMap c1 JOIN ClusterType c2 ON c1.ClusterTypeID = c2.ClusterTypeID JOIN ImplantType i ON c1.ImplantTypeID = i.ImplantTypeID WHERE c1.ClusterID = ? ORDER BY c2.ClusterTypeID DESC";
75: $results = $this->db->query($sql, $cluster->ClusterID);
76:
77: $blob .= "<pagebreak><highlight>$cluster->LongName<end>:\n<tab>";
78:
79: forEach ($results as $row) {
80: $impDesignerLink = $this->text->makeChatcmd("Add", "/tell <myname> implantdesigner $row->Slot $row->ClusterType $cluster->LongName");
81: $clusterType = ucfirst($row->ClusterType);
82: $blob .= "<font color=#ffcc33>$clusterType</font>: $row->Slot ($impDesignerLink)<tab>";
83: }
84: $blob .= "\n\n";
85: }
86: $msg = $this->text->makeBlob("Cluster search results ($count)", $blob);
87: }
88: $sendto->reply($msg);
89: }
90: }
91: