當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::getHandle方法代碼示例

本文整理匯總了PHP中Idno\Entities\User::getHandle方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::getHandle方法的具體用法?PHP User::getHandle怎麽用?PHP User::getHandle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Idno\Entities\User的用法示例。


在下文中一共展示了User::getHandle方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: postContent


//.........這裏部分代碼省略.........
             $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);
                             if (empty($name)) {
                                 $name = $user->handle;
                             }
                             $user->setTitle($name);
                             $user->save();
                         } else {
                             if (empty($handle)) {
                                 \Idno\Core\site()->session()->addMessage("Please create a username.");
                             }
                             if (strlen($handle) > 32) {
                                 \Idno\Core\site()->session()->addMessage("Your username is too long.");
                             }
                             if (substr_count($handle, '/')) {
                                 \Idno\Core\site()->session()->addMessage("Usernames can't contain a slash ('/') character.");
                             }
                             if (!empty($handleuser)) {
                                 \Idno\Core\site()->session()->addMessage("Unfortunately, someone is already using that username. Please choose another.");
                             }
                             if (!empty($emailuser)) {
                                 \Idno\Core\site()->session()->addMessage("Hey, it looks like there's already an account with that email address. Did you forget your login?");
                             }
                         }
                     } else {
                         \Idno\Core\site()->session()->addMessage("That doesn't seem like it's a valid email address.");
                     }
                 }
             }
             if (!empty($user->_id)) {
                 \Idno\Core\site()->session()->addMessage("User " . $user->getHandle() . " was created. You may wish to email them to let them know.");
             } else {
                 \Idno\Core\site()->session()->addMessageAtStart("We couldn't register that user.");
             }
             break;
         case 'block_emails':
             $emails = $this->getInput('blocked_emails');
             preg_match_all('/[a-z\\d._%+-]+@[a-z\\d.-]+\\.[a-z]{2,4}\\b/i', $emails, $matches);
             $block_count = 0;
             if (!empty($matches[0])) {
                 if (is_array($matches[0])) {
                     foreach ($matches[0] as $email) {
                         if (\Idno\Core\site()->config()->addBlockedEmail($email)) {
                             $block_count++;
                         }
                     }
                     \Idno\Core\site()->config()->save();
                 }
             }
             if ($block_count > 1) {
                 \Idno\Core\site()->session()->addMessage("{$block_count} emails were blocked.");
             } else {
                 if ($block_count == 1) {
                     \Idno\Core\site()->session()->addMessage("The email address was blocked.");
                 } else {
                     \Idno\Core\site()->session()->addMessage("No email addresses were found.");
                 }
             }
             break;
         case 'unblock_emails':
             $emails = $this->getInput('blocked_emails');
             preg_match_all('/[a-z\\d._%+-]+@[a-z\\d.-]+\\.[a-z]{2,4}\\b/i', $emails, $matches);
             $block_count = 0;
             if (!empty($matches[0])) {
                 if (is_array($matches[0])) {
                     foreach ($matches[0] as $email) {
                         if (\Idno\Core\site()->config()->removeBlockedEmail($email)) {
                             $block_count++;
                         }
                     }
                     \Idno\Core\site()->config()->save();
                 }
             }
             if ($block_count > 1) {
                 \Idno\Core\site()->session()->addMessage("{$block_count} emails were unblocked.");
             } else {
                 if ($block_count == 1) {
                     \Idno\Core\site()->session()->addMessage("The email address was unblocked.");
                 } else {
                     \Idno\Core\site()->session()->addMessage("No email addresses were found.");
                 }
             }
             break;
     }
     $this->forward(\Idno\Core\site()->config()->getURL() . 'admin/users');
 }
開發者ID:emory,項目名稱:Known,代碼行數:101,代碼來源:Users.php


注:本文中的Idno\Entities\User::getHandle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。