本文整理汇总了PHP中kuserPeer::addUser方法的典型用法代码示例。如果您正苦于以下问题:PHP kuserPeer::addUser方法的具体用法?PHP kuserPeer::addUser怎么用?PHP kuserPeer::addUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kuserPeer
的用法示例。
在下文中一共展示了kuserPeer::addUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addUserImpl
function addUserImpl($user)
{
$dbUser = null;
$dbUser = $user->toObject($dbUser);
try {
$dbUser = kuserPeer::addUser($dbUser, $user->password);
} catch (kUserException $e) {
$code = $e->getCode();
if ($code == kUserException::USER_ALREADY_EXISTS) {
throw new KalturaAPIException(KalturaErrors::DUPLICATE_USER_BY_ID, $user->id);
//backward compatibility
}
if ($code == kUserException::LOGIN_ID_ALREADY_USED) {
throw new KalturaAPIException(KalturaErrors::DUPLICATE_USER_BY_LOGIN_ID, $user->email);
//backward compatibility
} else {
if ($code == kUserException::USER_ID_MISSING) {
throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, $user->getFormattedPropertyNameWithClassName('id'));
} else {
if ($code == kUserException::INVALID_EMAIL) {
throw new KalturaAPIException(KalturaErrors::INVALID_FIELD_VALUE, 'email');
} else {
if ($code == kUserException::INVALID_PARTNER) {
throw new KalturaAPIException(KalturaErrors::UNKNOWN_PARTNER_ID);
} else {
if ($code == kUserException::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED) {
throw new KalturaAPIException(KalturaErrors::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED);
} else {
if ($code == kUserException::PASSWORD_STRUCTURE_INVALID) {
$partner = $dbUser->getPartner();
$invalidPasswordStructureMessage = '';
if ($partner && $partner->getInvalidPasswordStructureMessage()) {
$invalidPasswordStructureMessage = $partner->getInvalidPasswordStructureMessage();
}
throw new KalturaAPIException(KalturaErrors::PASSWORD_STRUCTURE_INVALID, $invalidPasswordStructureMessage);
}
}
}
}
}
}
throw $e;
} catch (kPermissionException $e) {
$code = $e->getCode();
if ($code == kPermissionException::ROLE_ID_MISSING) {
throw new KalturaAPIException(KalturaErrors::ROLE_ID_MISSING);
}
if ($code == kPermissionException::ONLY_ONE_ROLE_PER_USER_ALLOWED) {
throw new KalturaAPIException(KalturaErrors::ONLY_ONE_ROLE_PER_USER_ALLOWED);
} else {
if ($code == kPermissionException::USER_ROLE_NOT_FOUND) {
throw new KalturaAPIException(KalturaErrors::USER_ROLE_NOT_FOUND);
}
}
throw $e;
}
$newUser = new KalturaUser();
$newUser->fromObject($dbUser, $this->getResponseProfile());
return $newUser;
}
示例2: addAction
/**
* Adds a user to the Kaltura DB.
* Input param $id is the unique identifier in the partner's system
*
* @action add
* @param KalturaUser $user
* @return KalturaUser
*
* @throws KalturaErrors::DUPLICATE_USER_BY_ID
* @throws KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL
* @throws KalturaErrors::INVALID_FIELD_VALUE
* @throws KalturaErrors::UNKNOWN_PARTNER_ID
* @throws KalturaErrors::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED
* @throws KalturaErrors::PASSWORD_STRUCTURE_INVALID
* @throws KalturaErrors::DUPLICATE_USER_BY_LOGIN_ID
*/
function addAction(KalturaUser $user)
{
$user->validatePropertyMinLength("id", 1);
if ($user instanceof KalturaAdminUser) {
$user->isAdmin = true;
}
$user->partnerId = $this->getPartnerId();
$dbUser = null;
$dbUser = $user->toObject($dbUser);
try {
$dbUser = kuserPeer::addUser($dbUser, $user->password);
} catch (kUserException $e) {
$code = $e->getCode();
if ($code == kUserException::USER_ALREADY_EXISTS) {
throw new KalturaAPIException(KalturaErrors::DUPLICATE_USER_BY_ID, $user->id);
//backward compatibility
}
if ($code == kUserException::LOGIN_ID_ALREADY_USED) {
throw new KalturaAPIException(KalturaErrors::DUPLICATE_USER_BY_LOGIN_ID, $user->email);
//backward compatibility
} else {
if ($code == kUserException::USER_ID_MISSING) {
throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, $user->getFormattedPropertyNameWithClassName('id'));
} else {
if ($code == kUserException::INVALID_EMAIL) {
throw new KalturaAPIException(KalturaErrors::INVALID_FIELD_VALUE, 'email');
} else {
if ($code == kUserException::INVALID_PARTNER) {
throw new KalturaAPIException(KalturaErrors::UNKNOWN_PARTNER_ID);
} else {
if ($code == kUserException::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED) {
throw new KalturaAPIException(KalturaErrors::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED);
} else {
if ($code == kUserException::PASSWORD_STRUCTURE_INVALID) {
throw new KalturaAPIException(KalturaErrors::PASSWORD_STRUCTURE_INVALID);
}
}
}
}
}
}
throw $e;
} catch (kPermissionException $e) {
$code = $e->getCode();
if ($code == kPermissionException::ROLE_ID_MISSING) {
throw new KalturaAPIException(KalturaErrors::ROLE_ID_MISSING);
}
if ($code == kPermissionException::ONLY_ONE_ROLE_PER_USER_ALLOWED) {
throw new KalturaAPIException(KalturaErrors::ONLY_ONE_ROLE_PER_USER_ALLOWED);
}
throw $e;
}
$newUser = new KalturaUser();
$newUser->fromObject($dbUser);
return $newUser;
}
示例3: executeImpl
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
{
$target_puser_id = $this->getPM("user_id");
$target_puser_kuser = PuserKuserPeer::retrieveByPartnerAndUid($partner_id, null, $target_puser_id);
if ($target_puser_kuser) {
$this->addDebug("puser_exists", $target_puser_kuser->getId());
// might be that the puser_kuser exists but the kuser does not
$kuser = kuserPeer::retrieveByPK($target_puser_kuser->getKuserId());
if ($kuser) {
$this->addError(APIErrors::DUPLICATE_USER_BY_ID, $target_puser_id);
return;
} else {
// puser_kuser exists but need to create the ksuer...
}
} else {
$target_puser_kuser = new PuserKuser();
$target_puser_kuser->setPuserId($target_puser_id);
$target_puser_kuser->setPartnerId($partner_id);
$target_puser_kuser->save();
$this->addDebug("Created_new_puser_kuser", $target_puser_kuser->getId());
}
// get the new properties for the kuser from the request
$kuser = new kuser();
$obj_wrapper = objectWrapperBase::getWrapperClass($kuser, 0);
$fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $kuser, "user_", $obj_wrapper->getUpdateableFields());
// check that mandatory fields were set
// TODO
if (count($fields_modified) > 0) {
if (!$partner_id) {
$kuser_from_db = kuserPeer::getKuserByScreenName($kuser->getScreenName());
if ($kuser_from_db) {
$this->addError(APIErrors::DUPLICATE_USER_BY_SCREEN_NAME, $kuser->getScreenName());
return;
}
}
$kuser->setPartnerId($partner_id);
$kuser->setPuserId($target_puser_id);
try {
$kuser = kuserPeer::addUser($kuser);
} catch (kUserException $e) {
$code = $e->getCode();
if ($code == kUserException::USER_ALREADY_EXISTS) {
$this->addException(APIErrors::DUPLICATE_USER_BY_ID, $kuser->getId());
return null;
}
if ($code == kUserException::LOGIN_ID_ALREADY_USED) {
$this->addException(APIErrors::DUPLICATE_USER_BY_LOGIN_ID, $kuser->getEmail());
return null;
} else {
if ($code == kUserException::USER_ID_MISSING) {
$this->addException(APIErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'id');
return null;
} else {
if ($code == kUserException::INVALID_EMAIL) {
$this->addException(APIErrors::INVALID_FIELD_VALUE);
return null;
} else {
if ($code == kUserException::INVALID_PARTNER) {
$this->addException(APIErrors::UNKNOWN_PARTNER_ID);
return null;
} else {
if ($code == kUserException::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED) {
$this->addException(APIErrors::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED);
return null;
} else {
if ($code == kUserException::PASSWORD_STRUCTURE_INVALID) {
$this->addException(APIErrors::PASSWORD_STRUCTURE_INVALID);
return null;
}
}
}
}
}
}
throw $e;
} catch (kPermissionException $e) {
$code = $e->getCode();
if ($code == kPermissionException::ROLE_ID_MISSING) {
$this->addException(APIErrors::ROLE_ID_MISSING);
return null;
}
if ($code == kPermissionException::ONLY_ONE_ROLE_PER_USER_ALLOWED) {
$this->addException(APIErrors::ONLY_ONE_ROLE_PER_USER_ALLOWED);
return null;
}
throw $e;
}
// now update the puser_kuser
$target_puser_kuser->setPuserName($kuser->getScreenName());
$target_puser_kuser->setKuserId($kuser->getId());
$target_puser_kuser->save();
$this->addMsg("user", objectWrapperBase::getWrapperClass($target_puser_kuser, objectWrapperBase::DETAIL_LEVEL_DETAILED));
$this->addDebug("added_fields", $fields_modified);
} else {
$this->addError(APIErrors::NO_FIELDS_SET_FOR_USER);
}
}
示例4: createNewAdminKuser
private function createNewAdminKuser($newPartner, $existing_password)
{
// generate a new password if not given
if ($existing_password != null) {
$password = $existing_password;
} else {
$password = UserLoginDataPeer::generateNewPassword();
}
// create the user
$kuser = new kuser();
$kuser->setEmail($newPartner->getAdminEmail());
list($firstName, $lastName) = kString::nameSplit($newPartner->getAdminName());
$kuser->setFirstName($firstName);
$kuser->setLastName($lastName);
$kuser->setPartnerId($newPartner->getId());
$kuser->setIsAdmin(true);
$kuser->setPuserId($newPartner->getAdminEmail());
$kuser = kuserPeer::addUser($kuser, $password, false, false);
//this also saves the kuser and adds a user_login_data record
$loginData = UserLoginDataPeer::retrieveByPK($kuser->getLoginDataId());
return array($password, $loginData->getPasswordHashKey(), $kuser->getId());
}