Không hiểu tại sao cái module của mình viết sài được rồi. Loay hoay tới hôm nay nó lại ko có tác dụng gì với phân quyền hết (ko sửa được). Mặc dù mình đã set permission cho user toàn quyền node type đó. Không hiểu lý do tại sao luôn. Hic. Code hook perm và hook access thế này không biết có vấn đề gì ko, mong các bạn giúp đỡ!
<?php function center_perm() { return array( 'create center content', 'delete any center content', 'edit own center content', 'edit any center content', ); } function center_access($op, $node, $account) { if ($op == 'create') { return user_access('create center content', $account); } if ($op == 'update') { if (user_access('edit any center content', $account) || (user_access('edit own center content', $account) && ($account->uid == $node->uid))) { return TRUE; } }
if ($op == 'delete') { if (user_access('delete any center content', $account)) { return TRUE; } } } ?>
Bạn có thể định nghĩa một node type, sau đó bật CCK module, rồi add field vào content type mà bạn đã định nghĩa. Có thể tham khảo cách tạo một node type tại đây.
Comments
Không hiểu tại sao cái module
Không hiểu tại sao cái module của mình viết sài được rồi. Loay hoay tới hôm nay nó lại ko có tác dụng gì với phân quyền hết (ko sửa được). Mặc dù mình đã set permission cho user toàn quyền node type đó. Không hiểu lý do tại sao luôn. Hic. Code hook perm và hook access thế này không biết có vấn đề gì ko, mong các bạn giúp đỡ!
<?php
function center_perm() {
return array(
'create center content',
'delete any center content',
'edit own center content',
'edit any center content',
);
}
function center_access($op, $node, $account) {
if ($op == 'create') {
return user_access('create center content', $account);
}
if ($op == 'update') {
if (user_access('edit any center content', $account) || (user_access('edit own center content', $account) && ($account->uid == $node->uid))) {
return TRUE;
}
}
if ($op == 'delete') {
if (user_access('delete any center content', $account)) {
return TRUE;
}
}
}
?>
Bạn có thể định nghĩa một
Bạn có thể định nghĩa một node type, sau đó bật CCK module, rồi add field vào content type mà bạn đã định nghĩa. Có thể tham khảo cách tạo một node type tại đây.
Thế Hồng
Post new comment