当前位置: 首页>>代码示例>>PHP>>正文


PHP user_cancel函数代码示例

本文整理汇总了PHP中user_cancel函数的典型用法代码示例。如果您正苦于以下问题:PHP user_cancel函数的具体用法?PHP user_cancel怎么用?PHP user_cancel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了user_cancel函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cancel

 /**
  * Block a user and remove or reassign their content.
  */
 public function cancel()
 {
     if (drush_get_option('delete-content')) {
         user_cancel(array(), $this->id(), 'user_cancel_delete');
     } else {
         user_cancel(array(), $this->id(), 'user_cancel_reassign');
     }
     // I got the following technique here: http://drupal.org/node/638712
     $batch =& batch_get();
     $batch['progressive'] = FALSE;
     batch_process();
 }
开发者ID:bjargud,项目名称:drush,代码行数:15,代码来源:UserSingleBase.php

示例2: userDelete

 /**
  * {@inheritdoc}
  */
 public function userDelete(\stdClass $user)
 {
     user_cancel(array(), $user->uid, 'user_cancel_delete');
 }
开发者ID:lmakarov,项目名称:DrupalDriver,代码行数:7,代码来源:Drupal8.php

示例3: confirmCancel

 /**
  * Confirms cancelling a user account via an email link.
  *
  * @param \Drupal\user\UserInterface $user
  *   The user account.
  * @param int $timestamp
  *   The timestamp.
  * @param string $hashed_pass
  *   The hashed password.
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  *   A redirect response.
  */
 public function confirmCancel(UserInterface $user, $timestamp = 0, $hashed_pass = '')
 {
     // Time out in seconds until cancel URL expires; 24 hours = 86400 seconds.
     $timeout = 86400;
     $current = REQUEST_TIME;
     // Basic validation of arguments.
     $account_data = $this->userData->get('user', $user->id());
     if (isset($account_data['cancel_method']) && !empty($timestamp) && !empty($hashed_pass)) {
         // Validate expiration and hashed password/login.
         if ($timestamp <= $current && $current - $timestamp < $timeout && $user->id() && $timestamp >= $user->getLastLoginTime() && Crypt::hashEquals($hashed_pass, user_pass_rehash($user, $timestamp))) {
             $edit = array('user_cancel_notify' => isset($account_data['cancel_notify']) ? $account_data['cancel_notify'] : $this->config('user.settings')->get('notify.status_canceled'));
             user_cancel($edit, $user->id(), $account_data['cancel_method']);
             // Since user_cancel() is not invoked via Form API, batch processing
             // needs to be invoked manually and should redirect to the front page
             // after completion.
             return batch_process('');
         } else {
             drupal_set_message(t('You have tried to use an account cancellation link that has expired. Please request a new one using the form below.'), 'error');
             return $this->redirect('entity.user.cancel_form', ['user' => $user->id()], ['absolute' => TRUE]);
         }
     }
     throw new AccessDeniedHttpException();
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:36,代码来源:UserController.php

示例4: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $current_user_id = $this->currentUser()->id();
     // Clear out the accounts from the temp store.
     $this->tempStoreFactory->get('user_user_operations_cancel')->delete($current_user_id);
     if ($form_state['values']['confirm']) {
         foreach ($form_state['values']['accounts'] as $uid => $value) {
             // Prevent programmatic form submissions from cancelling user 1.
             if ($uid <= 1) {
                 continue;
             }
             // Prevent user administrators from deleting themselves without confirmation.
             if ($uid == $current_user_id) {
                 $admin_form_mock = array();
                 $admin_form_state = $form_state;
                 unset($admin_form_state['values']['user_cancel_confirm']);
                 // The $user global is not a complete user entity, so load the full
                 // entity.
                 $account = $this->userStorage->load($uid);
                 $admin_form = $this->entityManager->getFormObject('user', 'cancel');
                 $admin_form->setEntity($account);
                 // Calling this directly required to init form object with $account.
                 $admin_form->buildForm($admin_form_mock, $admin_form_state);
                 $admin_form->submit($admin_form_mock, $admin_form_state);
             } else {
                 user_cancel($form_state['values'], $uid, $form_state['values']['user_cancel_method']);
             }
         }
     }
     $form_state['redirect_route']['route_name'] = 'user.admin_account';
 }
开发者ID:shumer,项目名称:blog,代码行数:34,代码来源:UserMultipleCancelConfirm.php

示例5: submit

 /**
  * {@inheritdoc}
  */
 public function submit(array $form, FormStateInterface $form_state)
 {
     // Cancel account immediately, if the current user has administrative
     // privileges, no confirmation mail shall be sent, and the user does not
     // attempt to cancel the own account.
     if ($this->currentUser()->hasPermission('administer users') && empty($form_state['values']['user_cancel_confirm']) && $this->entity->id() != $this->currentUser()->id()) {
         user_cancel($form_state['values'], $this->entity->id(), $form_state['values']['user_cancel_method']);
         $form_state->setRedirect('user.admin_account');
     } else {
         // Store cancelling method and whether to notify the user in
         // $this->entity for user_cancel_confirm().
         $this->entity->user_cancel_method = $form_state['values']['user_cancel_method'];
         $this->entity->user_cancel_notify = $form_state['values']['user_cancel_notify'];
         $this->entity->save();
         _user_mail_notify('cancel_confirm', $this->entity);
         drupal_set_message($this->t('A confirmation request to cancel your account has been sent to your email address.'));
         $this->logger('user')->notice('Sent account cancellation request to %name %email.', array('%name' => $this->entity->label(), '%email' => '<' . $this->entity->getEmail() . '>'));
         $form_state->setRedirect('user.view', array('user' => $this->entity->id()));
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:23,代码来源:UserCancelForm.php

示例6: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Cancel account immediately, if the current user has administrative
     // privileges, no confirmation mail shall be sent, and the user does not
     // attempt to cancel the own account.
     if (!$form_state->isValueEmpty('access') && $form_state->isValueEmpty('user_cancel_confirm') && $this->entity->id() != $this->currentUser()->id()) {
         user_cancel($form_state->getValues(), $this->entity->id(), $form_state->getValue('user_cancel_method'));
         $form_state->setRedirectUrl($this->entity->urlInfo('collection'));
     } else {
         // Store cancelling method and whether to notify the user in
         // $this->entity for
         // \Drupal\user\Controller\UserController::confirmCancel().
         $this->entity->user_cancel_method = $form_state->getValue('user_cancel_method');
         $this->entity->user_cancel_notify = $form_state->getValue('user_cancel_notify');
         $this->entity->save();
         _user_mail_notify('cancel_confirm', $this->entity);
         drupal_set_message($this->t('A confirmation request to cancel your account has been sent to your email address.'));
         $this->logger('user')->notice('Sent account cancellation request to %name %email.', array('%name' => $this->entity->label(), '%email' => '<' . $this->entity->getEmail() . '>'));
         $form_state->setRedirect('entity.user.canonical', array('user' => $this->entity->id()));
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:24,代码来源:UserCancelForm.php


注:本文中的user_cancel函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。