HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
RAuthItemDataProvider.php
Go to the documentation of this file.
1 <?php
10 class RAuthItemDataProvider extends CDataProvider
11 {
12  public $type;
13  public $userId;
14  public $parent;
15  public $exclude = array();
16  public $items;
17  public $sortable;
18 
27  public function __construct($id, $config = array())
28  {
29  $this->setId($id);
30 
31  foreach ($config as $key => $value) {
32  $this->$key = $value;
33  }
34  }
35 
41  public function fetchData()
42  {
43  if ($this->sortable !== null) {
44  $this->processSortable();
45  }
46 
47  if ($this->items === null) {
48  $this->items = Rights::getAuthorizer()->getAuthItems($this->type, $this->userId, $this->parent, true, $this->exclude);
49  }
50 
51  $data = array();
52  foreach ($this->items as $name => $item) {
53  $data[] = $item;
54  }
55 
56  return $data;
57  }
58 
64  public function fetchKeys()
65  {
66  $keys = array();
67  foreach ($this->getData() as $name => $item) {
68  $keys[] = $name;
69  }
70 
71  return $keys;
72  }
73 
77  protected function processSortable()
78  {
79  if ($this->sortable !== null) {
80  if (isset($this->sortable['id']) === true && isset($this->sortable['element']) === true && isset($this->sortable['url']) === true) {
81  // Register the script to bind the sortable plugin to the role table
82  Yii::app()->getClientScript()->registerScript($this->sortable['id'],
83  "jQuery('".$this->sortable['element']."').rightsSortableTable({
84  url:'".$this->sortable['url']."',
85  csrfToken:'".Yii::app()->request->csrfToken."'
86  });"
87  );
88  }
89  }
90  }
91 
97  protected function calculateTotalItemCount()
98  {
99  return count($this->getData());
100  }
101 }