pluf2

pluf2 Commit Details


Date:2010-12-06 03:26:01 (14 years 16 days ago)
Author:Thomas Riché
Branch:master
Commit:0c113f47ae97904a4b8b499f1592a80e98e3e6c4
Parents: ee85e01f9faff7fc3989dd43d6bba8d1cb660308
Message:Added pluf_custom_user and pluf_custom_group

Changes:

File differences

src/Pluf.php
9191
9292
9393
94
94
9595
9696
9797
}
foreach ($apps as $app) {
$m = require $app.'/relations.php';
$GLOBALS['_PX_models'] = array_merge($m, $GLOBALS['_PX_models']);
$GLOBALS['_PX_models'] = array_merge_recursive($m, $GLOBALS['_PX_models']);
}
// $GLOBALS['_PX_signal'] is automatically set by the require
// statement and possibly in the configuration file.
src/Pluf/Auth/LdapBackend.php
3535
3636
3737
38
3839
39
40
4041
4142
4243
......
123124
124125
125126
126
127
128
127129
128130
129131
*/
public static function getUser($user_id)
{
$user_model = Pluf::f('pluf_custom_user','Pluf_User');
$sql = new Pluf_SQL('login=%s', array($user_id));
return Pluf::factory('Pluf_User')->getOne($sql->gen());
return Pluf::factory($user_model)->getOne($sql->gen());
}
/**
}
// Need to create it
ldap_close($ldap);
$user = new Pluf_User();
$user_model = Pluf::f('pluf_custom_user','Pluf_User');
$user = new $user_model();
$user->active = true;
$user->login = $login;
$user->password = $password;
src/Pluf/Auth/ModelBackend.php
3333
3434
3535
36
3637
37
38
3839
3940
4041
*/
public static function getUser($user_id)
{
$user_model = Pluf::f('pluf_custom_user','Pluf_User');
$sql = new Pluf_SQL('login=%s', array($user_id));
return Pluf::factory('Pluf_User')->getOne($sql->gen());
return Pluf::factory($user_model)->getOne($sql->gen());
}
/**
src/Pluf/Group.php
5959
6060
6161
62
63
64
65
66
67
68
69
70
6271
6372
6473
'model' => 'Pluf_Permission',
),
);
if (Pluf::f('pluf_custom_group',false)) $this->extended_init();
}
/**
* Hook for extended class
*/
function extended_init()
{
return;
}
function __toString()
src/Pluf/Message.php
4040
4141
4242
43
43
4444
4545
4646
'user' =>
array(
'type' => 'Pluf_DB_Field_Foreignkey',
'model' => 'Pluf_User',
'model' => Pluf::f('pluf_custom_user','Pluf_User'),
'blank' => false,
'verbose' => __('user'),
),
src/Pluf/Middleware/Session.php
4646
4747
4848
49
49
50
5051
5152
5253
......
7071
7172
7273
73
74
7475
7576
7677
function process_request(&$request)
{
$session = new Pluf_Session();
$user = new Pluf_User();
$user_model = Pluf::f('pluf_custom_user','Pluf_User');
$user = new $user_model();
if (!isset($request->COOKIE[$session->cookie_name])) {
// No session is defined. We set an empty user and empty
// session.
$set_lang = false;
if (isset($data[$user->session_key])) {
// We can get the corresponding user
$found_user = new Pluf_User($data[$user->session_key]);
$found_user = new $user_model($data[$user->session_key]);
if ($found_user->id == $data[$user->session_key]) {
// User found!
$request->user = $found_user;
src/Pluf/Migrations/5UserDetails.php
3131
3232
3333
34
34
35
3536
3637
3738
......
4950
5051
5152
52
53
54
5355
5456
5557
$db->begin(); // Start a transaction
try {
// Add 2 new fields.
$guser = new Pluf_User();
$user_model = Pluf::f('pluf_custom_user','Pluf_User');
$guser = new $user_model();
$table = $guser->getSqlTable();
$sql = 'ALTER TABLE '.$table."\n"
.'ADD COLUMN language VARCHAR(5) DEFAULT \'en\','."\n"
$db = Pluf::db();
$db->begin(); // Start a transaction
try {
$guser = new Pluf_User();
$user_model = Pluf::f('pluf_custom_user','Pluf_User');
$guser = new $user_model();
$table = $guser->getSqlTable();
$sql = 'ALTER TABLE '.$table."\n"
.'DROP COLUMN language,'."\n"
src/Pluf/Migrations/Backup.php
3535
3636
3737
38
39
38
39
4040
4141
4242
......
7070
7171
7272
73
74
73
74
7575
7676
7777
{
$models = array('Pluf_DB_SchemaInfo',
'Pluf_Session',
'Pluf_User',
'Pluf_Group',
Pluf::f('pluf_custom_user','Pluf_User'),
Pluf::f('pluf_custom_group','Pluf_Group'),
'Pluf_Message',
'Pluf_Permission',
'Pluf_RowPermission',
{
$models = array('Pluf_DB_SchemaInfo',
'Pluf_Session',
'Pluf_User',
'Pluf_Group',
Pluf::f('pluf_custom_user','Pluf_User'),
Pluf::f('pluf_custom_group','Pluf_Group'),
'Pluf_Message',
'Pluf_Permission',
'Pluf_RowPermission',
src/Pluf/Migrations/Install.php
3131
3232
3333
34
35
34
35
3636
3737
3838
......
5858
5959
6060
61
62
61
62
6363
6464
6565
{
$models = array('Pluf_DB_SchemaInfo',
'Pluf_Session',
'Pluf_User',
'Pluf_Group',
Pluf::f('pluf_custom_user','Pluf_User'),
Pluf::f('pluf_custom_group','Pluf_Group'),
'Pluf_Message',
'Pluf_Permission',
'Pluf_RowPermission',
'Pluf_RowPermission',
'Pluf_Permission',
'Pluf_Message',
'Pluf_Group',
'Pluf_User',
Pluf::f('pluf_custom_group','Pluf_Group'),
Pluf::f('pluf_custom_user','Pluf_User'),
'Pluf_Session',
'Pluf_DB_SchemaInfo',
);
src/Pluf/Permission.php
8181
8282
8383
84
84
85
86
8587
8688
8789
'col' => 'application',
),
);
$t_asso = $this->_con->pfx.'pluf_group_pluf_permission_assoc';
$hay = array(strtolower(Pluf::f('pluf_custom_group', 'Pluf_Group')), strtolower($this->_a['model']));
sort($hay);
$t_asso = $this->_con->pfx.$hay[0].'_'.$hay[1].'_assoc';
$t_perm = $this->_con->pfx.'permissions';
$this->_a['views'] = array(
'join_group' =>
src/Pluf/User.php
9393
9494
9595
96
96
97
9798
9899
99100
......
163164
164165
165166
167
168
169
170
171
172
173
174
175
166176
167177
168178
......
311321
312322
313323
314
324
325
315326
316327
317328
......
325336
326337
327338
328
339
329340
330341
331342
array(
'type' => 'Pluf_DB_Field_Manytomany',
'blank' => true,
'model' => 'Pluf_Group',
'model' => Pluf::f('pluf_custom_group','Pluf_Group'),
'relate_name' => 'users',
),
'permissions' =>
array(
),
);
$this->_a['views'] = array();
if (Pluf::f('pluf_custom_user',false)) $this->extended_init();
}
/**
* Hook for extended class
*/
function extended_init()
{
return;
}
/**
}
if (count($ids) > 0) {
$gperm = new Pluf_Permission();
$perms = array_merge($perms, (array) $gperm->getList(array('filter' => 'pluf_group_id IN ('.join(', ', $ids).')',
$f_name = strtolower(Pluf::f('pluf_custom_group', 'Pluf_Group')).'_id';
$perms = array_merge($perms, (array) $gperm->getList(array('filter' => $f_name.' IN ('.join(', ', $ids).')',
'view' => 'join_group')));
}
foreach ($perms as $perm) {
array($this->id, 'Pluf_User'));
if (count($ids) > 0) {
$sql2 = new Pluf_SQL('owner_id IN ('.join(', ', $ids).') AND owner_class=%s',
array('Pluf_Group'));
array(Pluf::f('pluf_custom_group','Pluf_Group')));
$sql->SOr($sql2);
}
$perms = $growp->getList(array('filter' => $sql->gen(),
src/Pluf/Views.php
130130
131131
132132
133
133
134
134135
135136
136137
*/
function logout($request, $match, $success_url='/')
{
$request->user = new Pluf_User();
$user_model = Pluf::f('pluf_custom_user','Pluf_User');
$request->user = new $user_model();
$request->session->clear();
$request->session->setData('logout_time', gmdate('Y-m-d H:i:s'));
if (0 !== strpos($success_url, 'http')) {
src/Pluf/relations.php
2727
2828
2929
30
31
32
33
34
35
36
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
* to retrieve related models from each model.
*/
$m = array();
$m['Pluf_User'] = array('relate_to_many' => array('Pluf_Group', 'Pluf_Permission'));
$m['Pluf_Group'] = array('relate_to_many' => array('Pluf_Permission'));
$m['Pluf_Message'] = array('relate_to' => array('Pluf_User'), );
$m['Pluf_RowPermission'] = array('relate_to' => array('Pluf_Permission'), );
$m['Pluf_Search_Occ'] = array('relate_to' => array('Pluf_Search_Word'), );
return $m;
$user_model = Pluf::f('pluf_custom_user','Pluf_User');
$group_model = Pluf::f('pluf_custom_group', 'Pluf_Group');
return array(
$user_model => array(
'relate_to_many' => array(
$group_model,
'Pluf_Permission',
),
),
$group_model => array(
'relate_to_many' => array(
'Pluf_Permission',
),
),
'Pluf_Message' => array(
'relate_to' => array(
$user_model,
),
),
'Pluf_RowPermission' => array(
'relate_to' => array(
'Pluf_Permission',
),
),
'Pluf_Search_Occ' => array(
'relate_to' => array(
'Pluf_Search_Word',
),
),
);

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.08954s using 13 queries.