2

是否可以在typo3 扩展中以编程方式(不使用 SQL )创建或删除用户?

4

2 回答 2

2

对于 CRUD 前端用户 (fe_users),已经有一个可用的存储库和一个模型,您可以在自己的 Extbase 扩展中使用它们。以下...

错字3/sysext/extbase/类/域

您可以找到 Model 和 Repository 类。

于 2016-05-14T21:42:56.477 回答
1

一些代码示例:

function createUser() {
    // TypoScript Template mit userid anlegen
    // Neue Seite anlegen
    $tmpId = 'NEWuser478d8d';
    $data['be_users'][$tmpId] = array(
        'username' => $this->email,
        'password' => $this->password,
        'admin' => 0,
        'pid' => 0,
        'usergroup' => $this->usergroup,
        'lang' => 'de',
        'email' => $this->email,
        'db_mountpoints' => '',
        'realName' => $this->realName,
        'file_mountpoints' => '',
        'fileoper_perms' => (int)$this->conf['fileoper_perms'],
        'options' => '2', // mount from group: filemount, aber nicht dbmount
        'db_mountpoints' => $this->dbMountPage,
        'file_mountpoints' => $this->conf['file_mountpoints'],
        'workspace_perms' => 0,
        'workspace_id' => 0,
        'workspace_preview' => 0
    );
    $this->debug($data, 'beuser');
    $this->tce->start($data,array());
    $this->tce->process_datamap();
    $this->userid =  $this->tce->substNEWwithIDs[$tmpId];
    // t3lib_div::debug('Neue Userid:'.$this->userid);
    return true;
}

公平地说,您需要一个活跃的用户,因此请创建一个:

/**
 *  Creates a Be-User
 *
 *  @return     void
 */
function setBeUser() {
    global $BE_USER;
    unset($BE_USER);
    $BE_USER        = t3lib_div::makeInstance('t3lib_beUserAuth');
    $BE_USER->OS    = TYPO3_OS;
    $BE_USER->setBeUserByUid($this->conf['setBeUserByUid']);
    $BE_USER->fetchGroupData();
    $BE_USER->backendSetUC();

    $GLOBALS['BE_USER'] = $BE_USER;

    $GLOBALS['LANG'] = t3lib_div::makeInstance('language');
    $GLOBALS['LANG']->init($BE_USER->uc['lang']);

    return $BE_USER;
}

初始化 tce:

$this->tce = t3lib_div::makeInstance('t3lib_TCEmain');
$this->tce->BE_USER = $this->setBeUser();
$this->tce->stripslashes_values = 0;
$this->createUser();
于 2013-06-11T10:52:16.817 回答