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


PHP User::save方法代码示例

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


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

示例1: save

 public function save()
 {
     // TODO: use a remote API to save to external sources if we have permission to
     // return false;
     // BUT for now, we still need to save some stub information in case we've just followed them
     return parent::save();
 }
开发者ID:avewrigley,项目名称:idno,代码行数:7,代码来源:RemoteUser.php

示例2: postContent

 function postContent()
 {
     $this->adminGatekeeper();
     // Admins only
     $action = $this->getInput('action');
     switch ($action) {
         case 'add_rights':
             $uuid = $this->getInput('user');
             if ($user = User::getByUUID($uuid)) {
                 $user->setAdmin(true);
                 $user->save();
                 \Idno\Core\site()->session()->addMessage($user->getTitle() . " was given administration rights.");
             }
             break;
         case 'remove_rights':
             $uuid = $this->getInput('user');
             if ($user = User::getByUUID($uuid)) {
                 $user->setAdmin(false);
                 $user->save();
                 \Idno\Core\site()->session()->addMessage($user->getTitle() . " was stripped of their administration rights.");
             }
             break;
         case 'delete':
             $uuid = $this->getInput('user');
             if ($user = User::getByUUID($uuid)) {
                 if ($user->delete()) {
                     \Idno\Core\site()->session()->addMessage($user->getTitle() . " was removed from your site.");
                 }
             }
             break;
         case 'invite_users':
             $emails = $this->getInput('invitation_emails');
             preg_match_all('/[a-z\\d._%\\+\\-]+@[a-z\\d.-]+\\.[a-z]{2,4}\\b/i', $emails, $matches);
             $invitation_count = 0;
             if (!empty($matches[0])) {
                 if (is_array($matches[0])) {
                     foreach ($matches[0] as $email) {
                         if (!($user = User::getByEmail($email))) {
                             $invitation = new Invitation();
                             if ($invitation->sendToEmail($email, \Idno\Core\site()->session()->currentUser()->email) !== 0) {
                                 $invitation_count++;
                             }
                         }
                     }
                 }
             }
             if ($invitation_count > 1) {
                 \Idno\Core\site()->session()->addMessage("{$invitation_count} invitations were sent.");
             } else {
                 if ($invitation_count == 1) {
                     \Idno\Core\site()->session()->addMessage("Your invitation was sent.");
                 } else {
                     \Idno\Core\site()->session()->addMessage("No email addresses were found or all the people you invited are already members of this site.");
                 }
             }
             break;
         case 'remove_invitation':
             $invitation_id = $this->getInput('invitation_id');
             if ($invitation = Invitation::getByID($invitation_id)) {
                 if ($invitation->delete()) {
                     \Idno\Core\site()->session()->addMessage("The invitation was removed.");
                 }
             }
             break;
         case 'resend_invitation':
             $invitation_id = $this->getInput('invitation_id');
             if ($invitation = Invitation::getByID($invitation_id)) {
                 $email = $invitation->email;
                 if ($invitation->delete()) {
                     $new_invitation = new Invitation();
                     if ($new_invitation->sendToEmail($email)) {
                         \Idno\Core\site()->session()->addMessage("The invitation was resent.");
                     }
                 }
             }
             break;
         case 'add_user':
             if (!\Idno\Core\site()->config()->canAddUsers()) {
                 \Idno\Core\site()->session()->addMessage("You can't add any more users to your site.");
                 break;
             }
             $name = $this->getInput('name');
             $handle = trim($this->getInput('handle'));
             $email = trim($this->getInput('email'));
             $password = trim($this->getInput('password1'));
             $password2 = trim($this->getInput('password2'));
             $user = new \Idno\Entities\User();
             if (empty($password) || $password != $password2) {
                 \Idno\Core\site()->session()->addMessage("Please make sure your passwords match and aren't empty.");
             } else {
                 if (empty($handle) && empty($email)) {
                     \Idno\Core\site()->session()->addMessage("Please enter a username and email address.");
                 } else {
                     if (!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
                         if (!($emailuser = \Idno\Entities\User::getByEmail($email)) && !($handleuser = \Idno\Entities\User::getByHandle($handle)) && !empty($handle) && strlen($handle) <= 32 && !substr_count($handle, '/')) {
                             $user = new \Idno\Entities\User();
                             $user->email = $email;
                             $user->handle = strtolower(trim($handle));
                             // Trim the handle and set it to lowercase
                             $user->setPassword($password);
//.........这里部分代码省略.........
开发者ID:emory,项目名称:Known,代码行数:101,代码来源:Users.php


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