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


PHP Authentication::getUserID方法代码示例

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


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

示例1: hasUserPermissions

 public static function hasUserPermissions($userID, $repositoryID, $repositoryData, $requiredRole)
 {
     $repository = new Repository($repositoryID, $repositoryData['name'], $repositoryData['visibility'], $repositoryData['defaultLanguage']);
     $role = Database::getRepositoryRole(Authentication::getUserID(), $repositoryID);
     $permissions = $repository->getPermissions($userID, $role);
     if (Authentication::getUserID() > 0 && !$permissions->isInvitationMissing()) {
         if ($role != self::ROLE_NONE && $role <= $requiredRole) {
             return true;
         }
     }
     return false;
 }
开发者ID:jeckel420,项目名称:Localize,代码行数:12,代码来源:Repository.php

示例2: askForEmailVerification

 /**
  * Creates a new verification token, saves it to the database and sends the verification mail
  *
  * @param string $email the email address to verify
  * @param User $userObject (optional) the existing session user object to modify
  */
 public static function askForEmailVerification($email, &$userObject = NULL)
 {
     $mailVerificationToken = self::createSecret(self::SECRET_LENGTH_SHORT);
     Database::saveVerificationToken(Authentication::getUserID(), $mailVerificationToken, time() + 86400);
     // save the timestamp for this new verification attempt to the current session
     if (empty($userObject)) {
         $newUserObject = self::getUser();
         $newUserObject->setEmail_lastVerificationAttempt(time());
         self::updateUserInfo($newUserObject);
     } else {
         $userObject->setEmail_lastVerificationAttempt(time());
     }
     // send the email containing the verification link
     self::sendVerificationMail($email, $mailVerificationToken);
 }
开发者ID:jeckel420,项目名称:Localize,代码行数:21,代码来源:Authentication.php

示例3: getPage_Project

 public static function getPage_Project($contents, $containers)
 {
     $page = self::getDataGET('p');
     $repositoryID = self::validateID(self::getDataGET('project'), true);
     $languageID = self::validateID(self::getDataGET('language'), true);
     $isAddingMode = isset($page) && $page == 'add_phrase';
     $isExportMode = isset($page) && $page == 'export';
     $isImportMode = isset($page) && $page == 'import';
     $repositoryData = Database::getRepositoryData($repositoryID);
     $languageData = Database::getLanguageData($languageID);
     if (empty($repositoryData)) {
         self::addBreadcrumbItem(URL::toProject($repositoryID), 'Project not found');
         self::setTitle('Project not found');
         $contents[] = new UI_Heading('Project not found', true);
         $contents[] = new UI_Paragraph('We\'re sorry, but we could not find the project that you requested.');
         $contents[] = new UI_Paragraph('Please check if you have made any typing errors.');
     } else {
         self::addBreadcrumbItem(URL::toProject($repositoryID), htmlspecialchars($repositoryData['name']));
         Authentication::saveCachedRepository($repositoryID, $repositoryData['name']);
         $repository = new Repository($repositoryID, $repositoryData['name'], $repositoryData['visibility'], $repositoryData['defaultLanguage']);
         $role = Database::getRepositoryRole(Authentication::getUserID(), $repositoryID);
         $permissions = $repository->getPermissions(Authentication::getUserID(), $role);
         if (Authentication::getUserID() <= 0) {
             self::setTitle($repositoryData['name']);
             $contents[] = new UI_Heading(htmlspecialchars($repositoryData['name']), true);
             $contents[] = self::getLoginForm();
         } elseif ($permissions->isInvitationMissing()) {
             self::setTitle($repositoryData['name']);
             $contents[] = new UI_Heading(htmlspecialchars($repositoryData['name']), true);
             $contents[] = self::getInvitationForm($repositoryID);
         } else {
             $defaultLanguage = new Language_Android($repository->getDefaultLanguage());
             if ($isAddingMode) {
                 $formTargetURL = URL::toAddPhrase($repositoryID, $languageID);
                 self::addBreadcrumbItem($formTargetURL, 'Add phrase');
                 $form = new UI_Form($formTargetURL, false);
                 $radioType = new UI_Form_Radio('Phrase type', 'add_phrase[type]');
                 $radioType->addOption('<abbr title="Resource type for single phrases">string</abbr>', 1, 'addPhraseTypeSelect(\'addPhraseGroup_String\');');
                 $radioType->addOption('<abbr title="Resource type for arrays of phrases">string-array</abbr>', 2, 'addPhraseTypeSelect(\'addPhraseGroup_StringArray\');');
                 $radioType->addOption('<abbr title="Resource type for quantity strings">plurals</abbr>', 3, 'addPhraseTypeSelect(\'addPhraseGroup_Plurals\');');
                 $form->addContent($radioType);
                 $textPhraseKey = new UI_Form_Text('Key', 'add_phrase[key]', 'Unique identifier', false, 'This is the short string that you\'ll identify the phrase(s) with later.');
                 $form->addContent($textPhraseKey);
                 $textPhraseStringValue = new UI_Form_Textarea('String', 'add_phrase[string]', 'String for ' . $defaultLanguage->getNameFull(), 'You can later translate this string to other languages.', false, '', 2, $defaultLanguage->isRTL(), '', 'addPhraseGroup_String');
                 $form->addContent($textPhraseStringValue);
                 $textPhraseStringArrayValue = new UI_Form_Textarea('Item', 'add_phrase[string_array][]', 'Item for ' . $defaultLanguage->getNameFull(), 'You can later translate this item to other languages.', false, '', 2, $defaultLanguage->isRTL(), '', 'addPhraseGroup_StringArray', 'display:none;', false);
                 $form->addContent($textPhraseStringArrayValue);
                 $quantities = Phrase_Android_Plurals::getList();
                 foreach ($quantities as $quantity) {
                     $textPhrasePluralsValue = new UI_Form_Textarea($quantity, 'add_phrase[plurals][' . $quantity . ']', 'Quantity for ' . $defaultLanguage->getNameFull(), 'You can later translate this quantity to other languages.', false, '', 2, $defaultLanguage->isRTL(), '', 'addPhraseGroup_Plurals', 'display:none;');
                     $form->addContent($textPhrasePluralsValue);
                 }
                 $buttonSubmit = new UI_Form_Button('Save phrase(s)', UI_Link::TYPE_SUCCESS);
                 $buttonAddItem = new UI_Link('Add item', '#', UI_Link::TYPE_INFO, 'addPhraseGroup_StringArray', 'display:none;', 'addPhraseAddItem(\'add_phrase[string_array][]\'); return false;');
                 $buttonCancel = new UI_Link('Cancel', URL::toLanguage($repositoryID, $languageID), UI_Link::TYPE_UNIMPORTANT);
                 $form->addContent(new UI_Form_ButtonGroup(array($buttonSubmit, $buttonAddItem, $buttonCancel)));
                 self::setTitle('Add phrase to default language');
                 $contents[] = new UI_Heading('Add phrase to default language', true);
                 $contents[] = $form;
             } elseif ($isExportMode) {
                 $formTargetURL = URL::toExport($repositoryID);
                 self::addBreadcrumbItem($formTargetURL, 'Export');
                 $form = new UI_Form($formTargetURL, false);
                 $textFilename = new UI_Form_Text('Filename', 'export[filename]', 'strings', false, 'Please choose a filename (without extension) for the output files that will be exported inside each language folder.');
                 $textFilename->setDefaultValue('strings');
                 $form->addContent($textFilename);
                 $selectGroupID = new UI_Form_Select('Phrase groups', 'export[groupID]', 'Do you want to export all phrases or only a single group?');
                 $selectGroupID->addOption('(All groups)', Phrase::GROUP_ALL);
                 $selectGroupID->addOption('(Default group)', Phrase::GROUP_NONE);
                 $phraseGroups = Database::getPhraseGroups($repositoryID, $repositoryData['defaultLanguage'], false);
                 foreach ($phraseGroups as $phraseGroup) {
                     $selectGroupID->addOption($phraseGroup['name'], $phraseGroup['id']);
                 }
                 $form->addContent($selectGroupID);
                 $selectMinCompletion = new UI_Form_Select('Minimum completion', 'export[minCompletion]', 'You can either export all languages or only those with a given minimum completion.');
                 $selectMinCompletion->addOption('Export all languages', 0);
                 $selectMinCompletion->addOption('5% completion or more', 5);
                 $selectMinCompletion->addOption('10% completion or more', 10);
                 $selectMinCompletion->addOption('25% completion or more', 25);
                 $selectMinCompletion->addOption('50% completion or more', 50);
                 $selectMinCompletion->addOption('75% completion or more', 75);
                 $selectMinCompletion->addOption('100% completion or more', 100);
                 $form->addContent($selectMinCompletion);
                 $selectFormat = new UI_Form_Select('Output format', 'export[format]', 'Which output format do you want to export in? When developing for Android, you should usually keep the default choice.');
                 $selectFormat->addOption('Android XML', File_IO::FORMAT_ANDROID_XML);
                 $selectFormat->addOption('Android XML with escaped HTML', File_IO::FORMAT_ANDROID_XML_ESCAPED_HTML);
                 $selectFormat->addOption('JSON', File_IO::FORMAT_JSON);
                 $selectFormat->addOption('Plaintext', File_IO::FORMAT_PLAINTEXT);
                 $form->addContent($selectFormat);
                 $ignoreIfSameAsDefault = new UI_Form_Select('Exclude defaults', 'export[ignoreIfSameAsDefault]', 'Do you want to exclude phrases which are the same as the respective phrase in the default language?');
                 $ignoreIfSameAsDefault->addOption('No, export a complete file for each language', 0);
                 $ignoreIfSameAsDefault->addOption('Yes, export only what\'s necessary', 1);
                 $form->addContent($ignoreIfSameAsDefault);
                 $isAdmin = Repository::hasUserPermissions(Authentication::getUserID(), $repositoryID, $repositoryData, Repository::ROLE_ADMINISTRATOR);
                 $buttonSubmit = new UI_Form_Button('Export', UI_Link::TYPE_SUCCESS);
                 $buttonManageGroups = new UI_Link('Manage groups', URL::toEditProject($repositoryID, true), UI_Link::TYPE_UNIMPORTANT);
                 $buttonCancel = new UI_Link('Cancel', URL::toProject($repositoryID), UI_Link::TYPE_UNIMPORTANT);
                 if ($isAdmin) {
                     $form->addContent(new UI_Form_ButtonGroup(array($buttonSubmit, $buttonManageGroups, $buttonCancel)));
                 } else {
//.........这里部分代码省略.........
开发者ID:jeckel420,项目名称:Localize,代码行数:101,代码来源:UI.php


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