ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilExAssignmentTeamTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Table/classes/class.ilTable2GUI.php';
5 
13 {
14  protected $mode; // [int]
15  protected $team_id; // [int]
16  protected $assignment; // [ilExAssignment]
17  protected $member_ids; // [array]
18  protected $read_only; // [bool]
19 
20  const MODE_ADD = 1;
21  const MODE_EDIT = 2;
22 
34  public function __construct($a_parent_obj, $a_parent_cmd, $a_mode, $a_team_id, ilExAssignment $a_assignment, array $a_member_ids = null, $a_read_only = false)
35  {
36  global $ilCtrl;
37 
38  $this->mode = $a_mode;
39  $this->team_id = $a_team_id;
40  $this->assignment = $a_assignment;
41  $this->member_ids = $a_member_ids;
42  $this->read_only = (bool)$a_read_only;
43 
44  parent::__construct($a_parent_obj, $a_parent_cmd);
45 
46  if(!$this->read_only)
47  {
48  $this->addColumn("", "", 1);
49  }
50  $this->addColumn($this->lng->txt("name"), "name");
51 
52  $this->setDefaultOrderField("name");
53 
54  $this->setRowTemplate("tpl.exc_team_member_row.html", "Modules/Exercise");
55  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
56 
57  if(!$this->read_only)
58  {
59  if($this->mode == self::MODE_ADD)
60  {
61  $this->setTitle($this->lng->txt("exc_team_member_container_add"));
62  $this->addMultiCommand("addTeamMemberContainerAction", $this->lng->txt("add"));
63  }
64  else
65  {
66  $this->setTitle($this->lng->txt("exc_team_members"));
67  $this->addMultiCommand("confirmRemoveTeamMember", $this->lng->txt("remove"));
68  }
69  }
70 
71  $this->getItems();
72  }
73 
77  protected function getItems()
78  {
79  if($this->mode == self::MODE_ADD)
80  {
81  $assigned = $this->assignment->getMembersOfAllTeams();
82  }
83  else
84  {
85  $assigned = array();
86  $this->member_ids = $this->assignment->getTeamMembers($this->team_id);
87  }
88 
89  include_once "Services/User/classes/class.ilUserUtil.php";
90 
91  $data = array();
92  foreach($this->member_ids as $id)
93  {
94  if(!in_array($id, $assigned))
95  {
96  $data[] = array("id" => $id,
97  "name" => ilUserUtil::getNamePresentation($id, false, false, "", true));
98  }
99  }
100 
101  $this->setData($data);
102  }
103 
109  protected function fillRow($a_set)
110  {
111  if(!$this->read_only)
112  {
113  $this->tpl->setVariable("VAL_ID", $a_set["id"]);
114  }
115  $this->tpl->setVariable("TXT_NAME", $a_set["name"]);
116  }
117 }
118 
119 ?>