public function testAllHooks() { $hooks = DashboardHooks::genHooks(array()); return; $allhooks = array(); foreach ($hooks as $page) { foreach ($page['entries'] as $item) { $allhooks[] = $item['func']; } } foreach ($allhooks as $hookname) { $this->assertNotNull(DashboardHooks::runHook($hookname), "Hook {$hookname} returned null"); } }
public function ajaxHandler() { if (!class_exists('DashboardHooks')) { include 'classes/DashboardHooks.class.php'; } switch ($_REQUEST['command']) { case "deletemessage": \FreePBX::create()->Notifications->safe_delete($_REQUEST['raw'], $_REQUEST['id']); return array("status" => true); break; case "resetmessage": \FreePBX::create()->Notifications->reset($_REQUEST['raw'], $_REQUEST['id']); return array("status" => true); break; case "saveorder": $this->setConfig('visualorder', $_REQUEST['order']); return array("status" => true); break; case "getcontent": if (file_exists(__DIR__ . '/sections/' . $_REQUEST['rawname'] . '.class.php')) { include __DIR__ . '/sections/' . $_REQUEST['rawname'] . '.class.php'; $class = '\\FreePBX\\modules\\Dashboard\\Sections\\' . $_REQUEST['rawname']; $class = new $class(); return array("status" => true, "content" => $class->getContent($_REQUEST['section'])); } else { return array("status" => false, "message" => "Missing Class Object!"); } break; case "gethooks": if (!$this->getConfig('allhooks')) { $this->doDialplanHook($foo = null, null, null); // Avoid warnings. } // Remove next line to enable caching. // $this->doDialplanHook($foo = null, null, null); // Avoid warnings. $config = $this->getConfig('allhooks'); $order = $this->getConfig('visualorder'); if (!empty($order)) { foreach ($config as &$page) { $entries = array(); foreach ($page['entries'] as $k => $e) { $o = isset($order[$e['section']]) ? $order[$e['section']] : $k; $entries[$o] = $e; } ksort($entries); $page['entries'] = $entries; } } return $config; break; case "sysstat": if (!class_exists('Statistics')) { include 'classes/Statistics.class.php'; } $s = new Statistics(); return $s->getStats(); break; default: return DashboardHooks::runHook($_REQUEST['command']); break; } }