2012-08-23 113 views
0

我在的Joomla功能1.5如何使用Joomla(ACL)從的Joomla 1.5轉換到Joomla 2.5版本

function saveuser($row){ 
    $db =& JFactory::getDBO(); 
    $instance = new JUser(); 
    jimport('joomla.application.component.helper'); 
    $config = &JComponentHelper::getParams('com_users'); 
    if(!isset($row['usertype'])) 
    $row['usertype'] = $config->get('new_usertype', 'Registered'); 

    $acl =& JFactory::getACL(); 
    if(!$row['gid']) 
    $row['gid'] = $acl->get_group_id('', $usertype); 

    $instance->set('id'   , $row['id']); 
    $instance->set('name'   , $row['name']); 
    $instance->set('username'  , $row['username']); 
    $instance->set('password'  , $row['password']); 
    $instance->set('email'   , $row['email']); 
    $instance->set('gid'   , $row['gid']); 
    $instance->set('usertype'  , $row['usertype']); 
    unset($instance->password_clear); 
    unset($instance->guest); 
    unset($instance->aid); 
    $ret = $db->insertObject('#__users', $instance, 'id'); 
    if(!$ret){ 
     return false; 
    } 
    $acl->add_object('users', $row['username'], $row['id'], null, null, 'ARO'); 
    $acl->add_group_object($row['gid'], 'users', $row['id'], 'ARO'); 
    return true; 
} 

但是,當爲的Joomla運行2.5的錯誤是:

Fatal error: Call to undefined method JAccess::get_group_id() in ... on line ... 
Fatal error: Call to undefined method JAccess::add_object() in ... on line ... 
Fatal error: Call to undefined method JAccess::add_group_object() ... on line ... 

How to fix this function to joomla 2.5, How to ideas ? 

回答

0

的ACL系統爲Joomla! 2.5是完全不同的,對你的問題沒有簡單的回答(Joomla!1.5在ACL上的嘗試只實現了一半)。

您最好從Joomla!上的「Access Control List/1.6-2.5/Tutorial」開始! doc的網站。讀取2.5個核心組件,如com_userscom_content