/** * add an user * * @todo fix $contactData['container_id'] = 1; * * @param Tinebase_Model_FullUser $_user * @return Tinebase_Model_FullUser */ public function addUserInSqlBackend(Tinebase_Model_FullUser $_user) { $_user->isValid(TRUE); $accountsTable = new Tinebase_Db_Table(array('name' => SQL_TABLE_PREFIX . 'accounts')); if (!isset($_user->accountId)) { $userId = $_user->generateUID(); $_user->setId($userId); } if (empty($_user->contact_id)) { $_user->visibility = 'hidden'; $_user->contact_id = null; } $accountData = $this->_recordToRawData($_user); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Adding user to SQL backend: ' . $_user->accountLoginName); } $accountsTable->insert($accountData); return $this->getUserById($_user->getId(), 'Tinebase_Model_FullUser'); }
/** * add an user * * @todo fix $contactData['container_id'] = 1; * * @param Tinebase_Model_FullUser $_user * @return Tinebase_Model_FullUser */ public function addUserInSqlBackend(Tinebase_Model_FullUser $_user) { if (!$_user->isValid()) { throw new Exception('invalid user object'); } $accountsTable = new Tinebase_Db_Table(array('name' => SQL_TABLE_PREFIX . 'accounts')); if (!isset($_user->accountId)) { $userId = $_user->generateUID(); $_user->setId($userId); } if (empty($_user->contact_id)) { $_user->visibility = 'hidden'; $_user->contact_id = null; } $accountData = array('id' => $_user->accountId, 'login_name' => $_user->accountLoginName, 'status' => $_user->accountStatus, 'expires_at' => $_user->accountExpires instanceof DateTime ? $_user->accountExpires->get(Tinebase_Record_Abstract::ISO8601LONG) : NULL, 'primary_group_id' => $_user->accountPrimaryGroup, 'home_dir' => $_user->accountHomeDirectory, 'login_shell' => $_user->accountLoginShell, 'openid' => $_user->openid, 'visibility' => $_user->visibility, 'contact_id' => $_user->contact_id, $this->rowNameMapping['accountDisplayName'] => $_user->accountDisplayName, $this->rowNameMapping['accountFullName'] => $_user->accountFullName, $this->rowNameMapping['accountFirstName'] => $_user->accountFirstName, $this->rowNameMapping['accountLastName'] => $_user->accountLastName, $this->rowNameMapping['accountEmailAddress'] => $_user->accountEmailAddress); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Adding user to SQL backend: ' . $_user->accountLoginName); } $accountsTable->insert($accountData); return $this->getUserById($_user->getId(), 'Tinebase_Model_FullUser'); }