Hi, I'm developing customizations for a LimeSurvey Instance (Version 3.22).I want to add an additional attribute to the LimeSurvey entity 'User' in order to display the company a user belongs to.
Unfortunately I couldn't find any forum entries about this topic, so I decided to ask it here.
I'll try to explain what I did so far:
I was able to create an attribute '$company' in /application/models/User.php and change the dialogue for adding a user, so that you can now add a company name. But it just doesn't save it internally. It always jumps back to my default value 'Not assigned', so that means it's not stored in the database or I'm doing something wrong there.
So my question would be how do I permanently save this additional attribute in the database?
This is my customized menu:
And til here it works:
Here it jumps back to the default value 'Not assigned':
This is my modified 'insertUser' function in User.php:
Code:
public static function insertUser($new_user, $new_pass, $new_full_name, $parent_user, $new_email, /* unitb edit start */ $new_company = "Hello World" /* unitb edit end */) {
$oUser = new self;
$oUser->users_name = $new_user;
$oUser->setPassword($new_pass);
$oUser->full_name = $new_full_name;
$oUser->parent_id = $parent_user;
$oUser->lang = 'test';
$oUser->email = $new_email;
/* unitb edit start */
$oUser->company($new_company);
/* unitb edit end */
if ($oUser->save()) {
return $oUser->uid;
} else {
return false;
}
}
And this is how I call it in /application/core/plugins/Authdb/Authdb.php :
Code:
public function createNewUser() {
[...]
$new_full_name = flattenText(Yii::app()->request->getPost('new_full_name'), false, true);
/* unitb edit start */
$new_company = flattenText(Yii::app()->request->getPost('new_company'), false, true);
$new_pass = createPassword();
$iNewUID = User::model()->insertUser($new_user, $new_pass, $new_full_name, Yii::app()->session['loginID'], $new_email, $new_company);
/* unitb edit end */
if (!$iNewUID) {
$oEvent->set('errorCode', self::ERROR_ALREADY_EXISTING_USER);
$oEvent->set('errorMessageTitle', '');
$oEvent->set('errorMessageBody', gT("Failed to add user"));
return;
}
Permission::model()->setGlobalPermission($iNewUID, 'auth_db');
$oEvent->set('newUserID', $iNewUID);
$oEvent->set('newPassword', $new_pass);
$oEvent->set('newEmail', $new_email);
$oEvent->set('newFullName', $new_full_name);
/* unitb edit start */
$oEvent->set('newCompany', $new_company);
/* unitb edit end */
$oEvent->set('errorCode', self::ERROR_NONE);
[...]
This function I call in /application/controllers/admin/useraction.php
Thanks so much for your help!