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


PHP User::delete方法代码示例

本文整理汇总了PHP中User::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP User::delete方法的具体用法?PHP User::delete怎么用?PHP User::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User的用法示例。


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

示例1: deleteAction

 public function deleteAction()
 {
     $app = App::getInstance();
     $id = (int) $app->getUrlParam('id');
     User::delete($id);
     $app->redirect(__HOME__ . '/user/');
 }
开发者ID:ctlr,项目名称:Simple-File-Manager,代码行数:7,代码来源:UserController.php

示例2: getNestData

 /**
  * @param \User $user
  *
  * @return mixed
  */
 public function getNestData(\User $user)
 {
     // start, return is false:
     $data = false;
     $count = 0;
     while ($data === false && $count < 5) {
         \Log::debug('Attempt #' . ($count + 1));
         // try to get the data:
         $URL = 'https://developer-api.nest.com/?auth=' . $user->accessToken;
         $client = new Client();
         try {
             $response = $client->get($URL);
         } catch (RingException $e) {
             \Log::error('GuzzleHttp\\Ring\\Exception\\ConnectException for user ' . $user->id . '! ' . $e->getMessage());
             sleep(5);
             return false;
         } catch (ConnectException $e) {
             \Log::error('GuzzleHttp\\Exception\\ConnectException for user ' . $user->id . '!! ' . $e->getMessage());
             sleep(5);
             return false;
         } catch (\Exception $e) {
             \Log::error('General exception (' . get_class($e) . ') for user ' . $user->id . '! ' . $e->getMessage());
             if ($e->getCode() == 401) {
                 \Log::warning('This is unauthorized! Delete the user!');
                 $user->delete();
             }
             sleep(5);
             return false;
         }
         $body = $response->getBody()->getContents();
         $data = json_decode($body);
         $count++;
     }
     return $data;
 }
开发者ID:JC5,项目名称:marauder,代码行数:40,代码来源:Cron.php

示例3: actionRegister

 public function actionRegister()
 {
     $model = new RegisterForm();
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'register-form') {
         echo CActiveForm::validate($model, array('username', 'password', 'new_password', 'password_confirm', 'verify_code'));
         Yii::app()->end();
     }
     if (isset($_POST['RegisterForm'])) {
         $model->attributes = $_POST['RegisterForm'];
         if ($model->validate(array('email', 'username', 'new_password', 'password_confirm', 'verify_code'))) {
             $user = new User();
             $user->email = $_POST['RegisterForm']['email'];
             $user->username = $_POST['RegisterForm']['username'];
             $user->password = $_POST['RegisterForm']['new_password'];
             if ($user->save()) {
                 //send email     activation key has been generated on beforeValidate function in User class
                 $activation_url = $this->createAbsoluteUrl('/site/activate', array('key' => $user->activation_key, 'email' => $user->email));
                 if (sendHtmlEmail($user->email, Yii::app()->name . ' Administrator', null, Yii::t('register', 'Account activation'), array('username' => $user->username, 'activation_url' => $activation_url), 'activation', 'main2')) {
                     $msg = Yii::t('register', 'Please check your email inbox for the activation link.It is valid for 24 hours.');
                     Yii::app()->user->setFlash('success', $msg);
                     $this->redirect(bu() . '/site/login');
                 } else {
                     $user->delete();
                     $msg = Yii::t('register', 'Error.Activation email could not be sent.Please register again.');
                     Yii::app()->user->setFlash('danger', $msg);
                     $this->redirect(bu() . '/site/register');
                 }
             }
         }
     }
     $this->render('register', array('model' => $model));
 }
开发者ID:imanifaiz,项目名称:angular-music-db,代码行数:32,代码来源:SiteController.php

示例4: delete_users

 public static function delete_users()
 {
     if (Auth::check()) {
         $id = $_POST['id'];
         if (isset($id)) {
             $strpos = strpos($id, ",");
             if ($strpos === false) {
                 $ob = new User($id);
                 $ob->delete();
                 echo "ok";
             } else {
                 $array_id = explode(",", $id);
                 $ob = null;
                 foreach ($array_id as $value) {
                     $ob = new User($value);
                     $ob->delete();
                 }
                 echo "ok";
             }
         } else {
             echo "Error while contacting server, please try again";
         }
     } else {
         $redirection = Config::get('app.base_url') . Config::get('panel.route');
         header("Location: {$redirection}");
     }
 }
开发者ID:ar-framework-labs,项目名称:panel,代码行数:27,代码来源:users.php

示例5: test_belongs_to

 public function test_belongs_to()
 {
     MemoryStore::flush();
     Page::delete_all();
     User::delete_all();
     $user = new User();
     $user->email = "ben@allseeing-i.com";
     $user->first_name = "Ben";
     $user->last_name = "Copsey";
     $user->password = "secret";
     $user->accepted_terms_and_conditions = true;
     $user->registration_date = new Date();
     $user->first_name = "Ben";
     $user->save();
     $page1 = new Page();
     $page1->title = "This is page 1";
     $page1->last_modified = new Date();
     $page1->body = "This is the content";
     $page1->url = "page-1";
     $page1->author = $user;
     $page1->save();
     FuzzyTest::assert_equal($page1->author_id, $user->id, "Author not set correctly");
     $user->delete();
     $page = Page::find_by_url('page-1');
     FuzzyTest::assert_true(isset($page), "Page deleted when it should have been preserved");
     FuzzyTest::assert_equal($page->author_id, 0, "Page deleted when it should have been preserved");
     $user->save();
     $page->author = $user;
     $page->save();
     $matches = $user->pages;
     FuzzyTest::assert_equal(count($matches), 1, "Page count should be 1");
 }
开发者ID:pokeb,项目名称:fuzzy-record,代码行数:32,代码来源:TestBelongsTo.php

示例6: cleanUpTestUser

 protected function cleanUpTestUser()
 {
     if (!$this->user) {
         $this->user = User::model()->findByAttributes(array('username' => 'autotestapi'));
         if (!$this->user) {
             return;
         }
     }
     // clear out all the data we've touched, and the user
     foreach (array_merge(array('Audit', 'OEModule\\PASAPI\\models\\PasApiAssignment', 'Patient', 'Address', 'Contact'), $this->additional_clean_up_models) as $cls) {
         $cls::model()->deleteAllByAttributes(array('created_user_id' => $this->user->id));
     }
     Audit::model()->deleteAllByAttributes(array('user_id' => $this->user->id));
     $this->user->saveRoles(array());
     $this->user->delete();
 }
开发者ID:across-health,项目名称:PASAPI,代码行数:16,代码来源:PASAPI_BaseTest.php

示例7: delete

    function delete()
    {
        $translator = new Translator();
        $user = new User();
        try {
            $id = array_shift($this->param);
            $user->delete($id, $data);
            echo <<<EOF
<div class="container">
   <div class="page-header">
        <h1>{$translator->User_updated}</h1>
      </div>
   <p class="lead">{$translator->User_updated_Desc}</p>
      <p >{$translator->Error_Backusers}</p>
</div>
<script type="text/javascript">
window.location.href='/admin_users';
</script>

EOF;
        } catch (Exception $e) {
            echo <<<EOF
<div class="container">
   <div class="page-header">
        <h1>{$translator->User_error}</h1>
      </div>
   <p class="lead">{$translator->User_error_Desc}</p>
      <p >{$translator->Error_Backusers}</p>
</div>

EOF;
        }
    }
开发者ID:jedaika,项目名称:Trainings,代码行数:33,代码来源:admin_user.php

示例8: delete

 /**
  * Delete user
  *
  * @param void
  * @return null
  */
 function delete()
 {
     if ($this->active_user->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND, null, true, $this->request->isApiCall());
     }
     // if
     if (!$this->active_user->canDelete($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall());
     }
     // if
     if ($this->request->isSubmitted()) {
         $delete = $this->active_user->delete();
         if ($delete && !is_error($delete)) {
             if ($this->request->isApiCall()) {
                 $this->httpOk();
             } else {
                 flash_success('User ":name" has been deleted', array('name' => $this->active_user->getDisplayName()));
                 $this->redirectToUrl($this->active_company->getViewUrl());
             }
             // if
         } else {
             if ($this->request->isApiCall()) {
                 $this->serveData($delete);
             } else {
                 flash_error('Failed to delete ":name"', array('name' => $this->active_user->getDisplayName()));
                 $this->redirectToUrl($this->active_company->getViewUrl());
             }
             // if
         }
         // if
     } else {
         $this->httpError(HTTP_ERR_BAD_REQUEST, null, true, $this->request->isApiCall());
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:41,代码来源:UsersController.class.php

示例9: delete

 function delete($id = FALSE)
 {
     $u = new User($id);
     $u->delete();
     $this->session->set_flashdata('msg', '<div class="alert alert-success">User was succesfully deleted.</div>');
     redirect($this->agent->referrer());
 }
开发者ID:ricardocasares,项目名称:Eventor,代码行数:7,代码来源:users.php

示例10: uninstall

 static function uninstall()
 {
     global $DB;
     CronTask::Unregister('fusioninventory');
     PluginFusioninventoryProfile::uninstallProfile();
     $pfSetup = new PluginFusioninventorySetup();
     $user = new User();
     if (class_exists('PluginFusioninventoryConfig')) {
         $fusioninventory_config = new PluginFusioninventoryConfig();
         $users_id = $fusioninventory_config->getValue('users_id');
         $user->delete(array('id' => $users_id), 1);
     }
     if (file_exists(GLPI_PLUGIN_DOC_DIR . '/fusioninventory')) {
         $pfSetup->rrmdir(GLPI_PLUGIN_DOC_DIR . '/fusioninventory');
     }
     $query = "SHOW TABLES;";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         if (strstr($data[0], "glpi_plugin_fusioninventory_") or strstr($data[0], "glpi_plugin_fusinvsnmp_") or strstr($data[0], "glpi_plugin_fusinvinventory_") or strstr($data[0], "glpi_dropdown_plugin_fusioninventory") or strstr($data[0], "glpi_plugin_tracker") or strstr($data[0], "glpi_dropdown_plugin_tracker")) {
             $query_delete = "DROP TABLE `" . $data[0] . "`;";
             $DB->query($query_delete) or die($DB->error());
         }
     }
     $query = "DELETE FROM `glpi_displaypreferences`\n               WHERE `itemtype` LIKE 'PluginFusioninventory%';";
     $DB->query($query) or die($DB->error());
     // Delete rules
     $Rule = new Rule();
     $Rule->deleteByCriteria(array('sub_type' => 'PluginFusioninventoryInventoryRuleImport'));
     //Remove informations related to profiles from the session (to clean menu and breadcrumb)
     PluginFusioninventoryProfile::removeRightsFromSession();
     return TRUE;
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:32,代码来源:setup.class.php

示例11: testUserCRUD

  public function testUserCRUD() {
    $user = new User();
    try {
      $user->load('gaurav');
    }
    catch (PAException $e) {
      if ($e->getMessage() == "No such user") {
        $user = new User();
        $user->first_name = 'Gaurav';
        $user->last_name = 'Bhatnagar';
        $user->homepage = 'http://www.newdelhitimes.org';
        $user->login_name = 'gaurav';
        $user->password = md5('password1');
        $user->email = 'gaurav@tekritisoftware.com';
        $user->save();
      }
      else {
        throw $e;
      }
    }

    $newuser = new User();
    $newuser->load('gaurav');
    $this->assertTrue($newuser->first_name == 'Gaurav');
    $newuser->delete();
    $this->assertTrue($newuser->is_active == FALSE);
  }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:27,代码来源:UserTest.php

示例12: delete

 function delete($id = FALSE)
 {
     $user = new User($id);
     $user->delete();
     set_notify('success', 'ลบข้อมูลเรียบร้อยแล้วค่ะ');
     redirect($_SERVER['HTTP_REFERER']);
 }
开发者ID:unisexx,项目名称:thaigcd2015,代码行数:7,代码来源:users.php

示例13: onMessage

function onMessage(WeChat $object, $messageType, $content, $arg1, $arg2)
{
    $user = new User($object->fromUser);
    //创建一个用户
    //处理subscribe和unsubscribe消息
    switch ($messageType) {
        case "subscribe":
            //当用户关注
            global $wm_welcome;
            $object->addNews($wm_welcome, "", "", "");
            $object->addNews(WM_MESSAGE, "", "", "");
            $object->sendNews();
            break;
        case "unsubscribe":
            //当用户取消关注
            $user->delete();
            break;
        case "text":
            $keyword = strtolower(trim($content));
            switch ($keyword) {
                case "n":
                    $articles = query("n");
                    foreach ($articles as $v) {
                        $object->addNews($v['0'], $v['1'], $v['2'], $v['3']);
                    }
                    $object->sendNews();
                    break;
                case "h":
                    $articles = query("h");
                    foreach ($articles as $v) {
                        $object->addNews($v['0'], $v['1'], $v['2'], $v['3']);
                    }
                    $object->sendNews();
                    break;
                case "r":
                    $articles = query("r");
                    foreach ($articles as $v) {
                        $object->addNews($v['0'], $v['1'], $v['2'], $v['3']);
                    }
                    $object->sendNews();
                    break;
                case "help":
                case "?":
                case "?":
                    global $wm_welcome;
                    $object->addNews($wm_welcome, "", "", "");
                    $object->addNews(WM_MESSAGE, "", "", "");
                    $object->sendNews();
                    break;
                default:
                    switchFunc($object, $keyword);
                    break;
            }
            break;
        default:
            $object->sendText("暂无设置此功能,你可以到我们的<a href='http://wx.wsq.qq.com/177325859'>微社区</a>提交相关问题");
            //否则,显示出错信息
    }
}
开发者ID:wilsonkor,项目名称:Wechat-Manager,代码行数:59,代码来源:wechatManager.php

示例14: testSimpleObject

 public function testSimpleObject()
 {
     $user = new User();
     $user->name = 'Foo';
     $user->save();
     $reload = new User(array('name' => 'Foo'));
     $reload->delete();
 }
开发者ID:photon,项目名称:storage-mongodb-object,代码行数:8,代码来源:objectTest.php

示例15: delete

 function delete()
 {
     if ($this->f3->exists('PARAMS.id')) {
         $user = new User($this->db);
         $user->delete($this->f3->get('PARAMS.id'));
     }
     $this->f3->reroute('/useradmin');
 }
开发者ID:srccn,项目名称:hy,代码行数:8,代码来源:UserController.php


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