本文整理汇总了PHP中CB\Database\Table\UserTable::saveSafely方法的典型用法代码示例。如果您正苦于以下问题:PHP UserTable::saveSafely方法的具体用法?PHP UserTable::saveSafely怎么用?PHP UserTable::saveSafely使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CB\Database\Table\UserTable
的用法示例。
在下文中一共展示了UserTable::saveSafely方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveUser
/**
* Saves legacy user edit display
*
* @param string $option
* @param string $task
*/
public function saveUser($option, $task = 'save')
{
global $_CB_framework, $_CB_Backend_task, $_POST, $_PLUGINS;
cbimport('language.all');
cbimport('cb.tabs');
cbimport('cb.params');
cbimport('cb.adminfilesystem');
cbimport('cb.imgtoolbox');
$userIdPosted = (int) cbGetParam($_POST, 'id', 0);
if ($userIdPosted == 0) {
$_POST['id'] = null;
}
$msg = $this->_authorizedEdit($userIdPosted);
if (!$msg) {
if ($userIdPosted != 0) {
$msg = checkCBpermissions(array($userIdPosted), 'save', true);
} else {
$msg = checkCBpermissions(null, 'save', true);
}
}
if ($userIdPosted != 0) {
$_PLUGINS->trigger('onBeforeUserProfileSaveRequest', array($userIdPosted, &$msg, 2));
}
if ($msg) {
cbRedirect($_CB_framework->backendViewUrl('showusers', false), $msg, 'error');
}
$_PLUGINS->loadPluginGroup('user');
// Get current user state:
if ($userIdPosted != 0) {
$userComplete = CBuser::getUserDataInstance($userIdPosted);
if (!($userComplete && $userComplete->id)) {
cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('Your profile could not be updated.'), 'error');
}
} else {
$userComplete = new UserTable();
}
// Store new user state:
$saveResult = $userComplete->saveSafely($_POST, $_CB_framework->getUi(), 'edit');
if (!$saveResult) {
$regErrorMSG = $userComplete->getError();
$msg = checkCBpermissions(array((int) $userComplete->id), 'edit', true);
if ($userIdPosted != 0) {
$_PLUGINS->trigger('onBeforeUserProfileEditRequest', array((int) $userComplete->id, &$msg, 2));
}
if ($msg) {
cbRedirect($_CB_framework->backendViewUrl('showusers', false), $msg, 'error');
}
if ($userIdPosted != 0) {
$_PLUGINS->trigger('onAfterUserProfileSaveFailed', array(&$userComplete, &$regErrorMSG, 2));
} else {
$_PLUGINS->trigger('onAfterUserRegistrationSaveFailed', array(&$userComplete, &$regErrorMSG, 2));
}
$_CB_framework->enqueueMessage($regErrorMSG, 'error');
$_CB_Backend_task = 'edit';
// so the toolbar comes up...
$_PLUGINS->loadPluginGroup('user');
// resets plugin errors
$userView = _CBloadView('user');
/** @var CBController_user $userView */
$userView->edituser($userComplete, $option, $userComplete->user_id != null ? 0 : 1, $_POST);
return;
}
// Checks-in the row:
$userComplete->checkin();
if ($userIdPosted != 0) {
$_PLUGINS->trigger('onAfterUserProfileSaved', array(&$userComplete, 2));
} else {
$messagesToUser = array();
$_PLUGINS->trigger('onAfterSaveUserRegistration', array(&$userComplete, &$messagesToUser, 2));
}
if ($task == 'apply') {
cbRedirect($_CB_framework->backendViewUrl('edit', false, array('cid' => (int) $userComplete->user_id)), CBTxt::T('SUCCESSFULLY_SAVED_USER_USERNAME', 'Successfully Saved User: [username]', array('[username]' => $userComplete->username)));
} else {
cbRedirect($_CB_framework->backendViewUrl('showusers', false), CBTxt::T('SUCCESSFULLY_SAVED_USER_USERNAME', 'Successfully Saved User: [username]', array('[username]' => $userComplete->username)));
}
}
示例2: userSave
function userSave($option, $uid)
{
global $_CB_framework, $_POST, $_PLUGINS;
// simple spoof check security
cbSpoofCheck('userEdit');
// check rights to access:
if ($uid == null) {
$msg = CBTxt::Th('UE_USER_PROFILE_NOT', 'Your profile could not be updated.');
} else {
$msg = cbCheckIfUserCanPerformUserTask($uid, 'allowModeratorsUserEdit');
}
$_PLUGINS->loadPluginGroup('user');
$_PLUGINS->trigger('onBeforeUserProfileSaveRequest', array($uid, &$msg, 1));
if ($msg) {
$_CB_framework->enqueueMessage($msg, 'error');
return;
}
// Get current user state:
$userComplete = new UserTable();
if (!$userComplete->load((int) $uid)) {
$_CB_framework->enqueueMessage(CBTxt::Th('UE_USER_PROFILE_NOT', 'Your profile could not be updated.'), 'error');
return;
}
// Update lastupdatedate of profile by user:
if ($_CB_framework->myId() == $uid) {
$userComplete->lastupdatedate = $_CB_framework->dateDbOfNow();
}
// Store new user state:
$saveResult = $userComplete->saveSafely($_POST, $_CB_framework->getUi(), 'edit');
if (!$saveResult) {
$regErrorMSG = $userComplete->getError();
$_PLUGINS->trigger('onAfterUserProfileSaveFailed', array(&$userComplete, &$regErrorMSG, 1));
HTML_comprofiler::userEdit($userComplete, $option, CBTxt::T('UE_UPDATE', 'Update'), $regErrorMSG);
return;
}
$_PLUGINS->trigger('onAfterUserProfileSaved', array(&$userComplete, 1));
cbRedirectToProfile($uid, CBTxt::Th('USER_DETAILS_SAVE', 'Your settings have been saved.'));
}