1<?php 2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4include_once("./Services/Table/classes/class.ilTable2GUI.php"); 5 6/** 7 * Client list table 8 * 9 * @author Alex Killing <alex.killing@gmx.de> 10 * @version $Id$ 11 * 12 * @ingroup ServicesSetup 13 */ 14class ilClientListTableGUI extends ilTable2GUI 15{ 16 17 /** 18 * Constructor 19 */ 20 public function __construct($a_setup) 21 { 22 global $ilCtrl, $lng, $ilAccess, $lng; 23 24 parent::__construct(null, ""); 25 $this->setTitle($lng->txt("clients")); 26 $this->setLimit(9999); 27 $this->setup = $a_setup; 28 29 $this->addColumn($this->lng->txt(""), "", "1"); 30 $this->addColumn($this->lng->txt("name"), ""); 31 $this->addColumn($this->lng->txt("id"), ""); 32 $this->addColumn($this->lng->txt("login"), ""); 33 $this->addColumn($this->lng->txt("details"), ""); 34 $this->addColumn($this->lng->txt("status"), ""); 35 $this->addColumn($this->lng->txt("access"), ""); 36 37 $this->setDefaultOrderField("name"); 38 $this->setDefaultOrderDirection("asc"); 39 40 $this->setEnableHeader(true); 41 $this->setFormAction("setup.php?cmd=gateway"); 42 $this->setRowTemplate("tpl.client_list_row.html", "setup"); 43 $this->disable("footer"); 44 $this->setEnableTitle(true); 45 46 $this->getClients(); 47 48 $this->addMultiCommand("changedefault", $lng->txt("set_default_client")); 49 } 50 51 /** 52 * Get clients 53 * 54 * @param 55 * @return 56 */ 57 public function getClients() 58 { 59 global $lng; 60 61 $clients = array(); 62 $clientlist = new ilClientList(); 63 $list = $clientlist->getClients(); 64 65 foreach ($list as $key => $client) { 66 // check status 67 $status_arr = $this->setup->getStatus($client); 68 if (!$status_arr["db"]["status"]) { 69 $status = 70 "<a href=\"setup.php?cmd=db&client_id=" . $key . "&back=clientlist\">" . 71 $status_arr["db"]["comment"] . "</a>"; 72 } elseif (!$status_arr["finish"]["status"]) { 73 $status = $lng->txt("setup_not_finished"); 74 } else { 75 $status = "<font color=\"green\"><strong>OK</strong></font>"; 76 } 77 78 if ($status_arr["access"]["status"]) { 79 $access = "online"; 80 } else { 81 $access = "disabled"; 82 } 83 84 if ($key == $this->setup->default_client) { 85 $default = " checked=\"checked\""; 86 } else { 87 $default = ""; 88 } 89 90 if ($status_arr["finish"]["status"] and $status_arr["access"]["status"]) { 91 $login = "<a href=\"../login.php?client_id=" . $key . "\">Login</a>"; 92 } else { 93 $login = " "; 94 } 95 96 $access_html = "<a href=\"setup.php?cmd=changeaccess&client_id=" . $key . "&back=clientlist\">" . $this->lng->txt($access) . "</a>"; 97 98 $client_name = ($client->getName()) ? $client->getName() : "<" . $lng->txt("no_client_name") . ">"; 99 100 // visible data part 101 $clients[] = array( 102 "default" => "<input type=\"radio\" name=\"form[default]\" value=\"" . $key . "\"" . $default . "/>", 103 "name" => $client_name, 104 "desc" => $client->getDescription(), 105 "id" => $key, 106 "login" => $login, 107 "details" => "<a href=\"setup.php?cmd=view&client_id=" . $key . "\">Details</a>", 108 "status" => $status, 109 "access_html" => $access_html 110 ); 111 } 112 113 $this->setData($clients); 114 } 115 116 /** 117 * Fill table row 118 */ 119 protected function fillRow($a_set) 120 { 121 global $lng; 122 123 $this->tpl->setVariable("DEF_RADIO", $a_set["default"]); 124 $this->tpl->setVariable("NAME", $a_set["name"]); 125 $this->tpl->setVariable("DESC", $a_set["desc"]); 126 $this->tpl->setVariable("ID", $a_set["id"]); 127 $this->tpl->setVariable("LOGIN", $a_set["login"]); 128 $this->tpl->setVariable("DETAILS", $a_set["details"]); 129 $this->tpl->setVariable("STATUS", $a_set["status"]); 130 $this->tpl->setVariable("ACCESS", $a_set["access_html"]); 131 } 132} 133