forked from rchavik/Kinspir
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrepo_app_controller.php
121 lines (109 loc) · 2.67 KB
/
repo_app_controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
class RepoAppController extends AppController {
/**
* @var unknown_type
*/
public $components = array(
'Access'
);
/**
* @var unknown_type
*/
public $helpers = array(
'Chaw'
);
/**
* undocumented variable
*
* @var string
*/
var $uses = array('Project');
/**
*
*/
public function beforeFilter(){
parent::beforeFilter();
$this->Auth->authorize = false;
$this->Auth->authError = 'Invalid Project';
$this->Auth->mapActions(array(
'modify' => 'update',
'remove' => 'delete'
));
if (!empty($this->params['admin'])) {
$this->Auth->authorize = 'controller';
}
// tell ACL to back off (temporary)
//$this->Auth->allowedActions = array('*');
}
/**
* undocumented function
*
* @return void
*/
function isAuthorized() {
if (!empty($this->params['admin']) && empty($this->params['isAdmin'])) {
if ($this->Access->check($this, array('access' => 'w', 'default' => false)) === true) {
return true;
}
$this->Session->setFlash($this->Auth->authError, 'default', array(), 'auth');
$this->redirect(array(
'admin' => false, 'username' => false, 'project' => false, 'fork' => false,
'controller' => 'projects', 'action' => 'index'
));
return false;
}
return true;
}
/**
* undocumented function
*
* @return void
*/
function beforeRender() {
if ($this->params['isAdmin'] !== true) {
$this->params['admin'] = false;
}
$this->params['project'] = null;
if (!empty($this->Project->current) && $this->Project->id !== '1') {
$this->params['project'] = $this->Project->current['url'];
}
if (isset($this->viewVars['rssFeed'])) {
$this->viewVars['rssFeed'] = array_merge(
array(
'controller' => 'timeline', 'action' => 'index', 'ext' => 'rss'
),
$this->viewVars['rssFeed']
);
}
$this->set('CurrentUser', Set::map($this->Auth->user()));
$this->set('CurrentProject', Set::map(Configure::read('Project'), true));
}
/**
* undocumented function
*
* @return void
*/
function redirect($url = array(), $status = null, $exit = true) {
if (is_array($url)) {
if (!empty($this->params['project'])) {
$url = array_merge(array('project' => $this->params['project']), $url);
}
if (!empty($this->params['fork'])) {
$url = array_merge(array('fork' => $this->params['fork']), $url);
}
$username = null;
if (!empty($this->params['project']) && empty($this->params['fork'])) {
$url = array_merge(array('username' => $this->params['username']), $url);
}
}
parent::redirect($url, $status, $exit);
}
/**
* undocumented function
*
* @return void
*/
function referer($default = null, $local = true) {
return parent::referer($default, $local);
}
}