1<?php 2 3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */ 4 5include_once './Services/User/classes/class.ilObjUser.php'; 6include_once './Services/User/classes/class.ilUserClipboard.php'; 7include_once './Services/Table/classes/class.ilTable2GUI.php'; 8 9/** 10 * Show administrate clipboard content 11 * 12 * @author Stefan Meyer <smeyer.ilias@gmx.de> 13 * 14 */ 15class ilUserClipboardTableGUI extends ilTable2GUI 16{ 17 /** 18 * @var ilUserClipboard 19 */ 20 private $clipboard; 21 22 /** 23 * Constructor 24 * @param type $a_parent_obj 25 * @param type $a_parent_cmd 26 * @param int $a_id 27 */ 28 public function __construct($a_parent_obj, $a_parent_cmd, $a_id) 29 { 30 $this->setId('obj_table_' . $a_id); 31 parent::__construct($a_parent_obj, $a_parent_cmd, ''); 32 33 $this->clipboard = ilUserClipboard::getInstance($a_id); 34 $this->lng->loadLanguageModule('user'); 35 } 36 37 /** 38 * init table 39 */ 40 public function init() 41 { 42 $this->setTitle($this->lng->txt('clipboard_table_title')); 43 44 $this->addColumn('', 'id', '5px'); 45 $this->addColumn($this->lng->txt('name'), 'name', '70%'); 46 $this->addColumn($this->lng->txt('login'), 'login', '30%'); 47 48 $this->setOrderColumn('name'); 49 $this->setRowTemplate('tpl.usr_clipboard_table_row.html', 'Services/User'); 50 51 $this->setSelectAllCheckbox('uids'); 52 53 $this->addMultiCommand( 54 'addFromClipboard', 55 $this->lng->txt('add') 56 ); 57 58 $this->addMultiCommand( 59 'removeFromClipboard', 60 $this->lng->txt('clipboard_remove_btn') 61 ); 62 63 $this->addCommandButton('emptyClipboard', $this->lng->txt('clipboard_empty_btn')); 64 $this->addCommandButton('cancel', $this->lng->txt('cancel')); 65 } 66 67 /** 68 * Fill row 69 * @param type $a_set 70 */ 71 public function fillRow($a_set) 72 { 73 $this->tpl->setVariable('VAL_POSTNAME', 'uids'); 74 $this->tpl->setVariable('VAL_ID', $a_set['usr_id']); 75 $this->tpl->setVariable('VAL_NAME', $a_set['name']); 76 $this->tpl->setVariable('VAL_LOGIN', $a_set['login']); 77 } 78 79 /** 80 * Parse clipboard content 81 */ 82 public function parse() 83 { 84 $content = array(); 85 foreach ($this->clipboard->getValidatedContent() as $user_id) { 86 $row['usr_id'] = $user_id; 87 $name_arr = ilObjUser::_lookupName($user_id); 88 89 $row['name'] = ($name_arr['lastname'] . ', ' . $name_arr['firstname']); 90 $row['login'] = ilObjUser::_lookupLogin($user_id); 91 92 $content[] = $row; 93 } 94 $this->setMaxCount(count($this->clipboard->getValidatedContent())); 95 $this->setData($content); 96 } 97} 98