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


PHP notFoundException函数代码示例

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


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

示例1: pluginController_quoteMention_create

 public function pluginController_quoteMention_create($sender, $discussionID, $commentID, $username)
 {
     $sender->deliveryMethod(DELIVERY_METHOD_JSON);
     $user = Gdn::userModel()->getByUsername($username);
     $discussionModel = new DiscussionModel();
     $discussion = $discussionModel->getID($discussionID);
     if (!$user || !$discussion) {
         throw notFoundException();
     }
     // Make sure this endpoint can't be used to snoop around.
     $sender->permission('Vanilla.Discussions.View', true, 'Category', $discussion->PermissionCategoryID);
     // Find the previous comment of the mentioned user in this discussion.
     $item = Gdn::sql()->getWhere('Comment', ['DiscussionID' => $discussion->DiscussionID, 'InsertUserID' => $user->UserID, 'CommentID <' => $commentID], 'CommentID', 'desc', 1)->firstRow();
     // The items ID in the DOM used for highlighting.
     if ($item) {
         $target = '#Comment_' . $item->CommentID;
         // The mentioned user might be the discussion creator.
     } elseif ($discussion->InsertUserID == $user->UserID) {
         $item = $discussion;
         $target = '#Discussion_' . $item->DiscussionID;
     }
     if (!$item) {
         // A success response code always means that a comment was found.
         $sender->statusCode(404);
     }
     $sender->renderData($item ? ['html' => nl2br(sliceString(Gdn_Format::plainText($item->Body, $item->Format), c('QuoteMention.MaxLength', 400))), 'target' => $target] : []);
 }
开发者ID:bleistivt,项目名称:quotemention,代码行数:27,代码来源:class.quotemention.plugin.php

示例2: applications

 /**
  * Application management screen.
  *
  * @since 2.0.0
  * @access public
  * @param string $Filter 'enabled', 'disabled', or 'all' (default)
  * @param string $ApplicationName Unique ID of app to be modified.
  * @param string $TransientKey Security token.
  */
 public function applications($Filter = '', $ApplicationName = '')
 {
     $this->permission('Garden.Settings.Manage');
     // Page setup
     $this->addJsFile('addons.js');
     $this->addJsFile('applications.js');
     $this->title(t('Applications'));
     $this->setHighlightRoute('dashboard/settings/applications');
     if (!in_array($Filter, array('enabled', 'disabled'))) {
         $Filter = 'all';
     }
     $this->Filter = $Filter;
     $ApplicationManager = Gdn::applicationManager();
     $this->AvailableApplications = $ApplicationManager->availableVisibleApplications();
     $this->EnabledApplications = $ApplicationManager->enabledVisibleApplications();
     if ($ApplicationName != '') {
         $addon = Gdn::addonManager()->lookupAddon($ApplicationName);
         if (!$addon) {
             throw notFoundException('Application');
         }
         if (Gdn::addonManager()->isEnabled($ApplicationName, Addon::TYPE_ADDON)) {
             $this->disableApplication($ApplicationName, $Filter);
         } else {
             $this->enableApplication($ApplicationName, $Filter);
         }
     } else {
         $this->render();
     }
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:38,代码来源:class.settingscontroller.php

示例3: index

 /**
  * Creates and renders an instance of a module.
  *
  * @param string $Module
  * @param string $AppFolder
  * @param string $DeliveryType
  * @throws NotFoundException
  */
 public function index($Module, $AppFolder = '', $DeliveryType = '')
 {
     if (!$DeliveryType) {
         $this->deliveryType(DELIVERY_TYPE_VIEW);
     }
     $ModuleClassExists = class_exists($Module);
     if ($ModuleClassExists) {
         // Make sure that the class implements Gdn_IModule
         $ReflectionClass = new ReflectionClass($Module);
         if ($ReflectionClass->implementsInterface("Gdn_IModule")) {
             // Check any incoming app folder against real application list.
             $appWhitelist = Gdn::applicationManager()->enabledApplicationFolders();
             // Set the proper application folder on this controller so that things render properly.
             if ($AppFolder && in_array($AppFolder, $appWhitelist)) {
                 $this->ApplicationFolder = $AppFolder;
             } else {
                 $Filename = str_replace('\\', '/', substr($ReflectionClass->getFileName(), strlen(PATH_ROOT)));
                 // Figure our the application folder for the module.
                 $Parts = explode('/', trim($Filename, '/'));
                 if ($Parts[0] == 'applications' && in_array($Parts[1], $appWhitelist)) {
                     $this->ApplicationFolder = $Parts[1];
                 }
             }
             $ModuleInstance = new $Module($this);
             $ModuleInstance->Visible = true;
             $WhiteList = array('Limit', 'Help');
             foreach ($this->Request->get() as $Key => $Value) {
                 if (in_array($Key, $WhiteList)) {
                     // Set a sane max limit for this open-ended way of calling modules.
                     if ($Key == 'Limit' && $Value > 200) {
                         throw new Exception(t('Invalid limit.'), 400);
                     }
                     $ModuleInstance->{$Key} = $Value;
                 }
             }
             $this->setData('_Module', $ModuleInstance);
             $this->render('Index', false, 'dashboard');
             return;
         }
     }
     throw notFoundException(htmlspecialchars($Module));
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:50,代码来源:class.modulecontroller.php

示例4: index

 /**
  * Creates and renders an instance of a module.
  *
  * @param string $Module
  * @param string $AppFolder
  * @param string $DeliveryType
  * @throws NotFoundException
  */
 public function index($Module, $AppFolder = '', $DeliveryType = '')
 {
     if (!$DeliveryType) {
         $this->deliveryType(DELIVERY_TYPE_VIEW);
     }
     $ModuleClassExists = class_exists($Module);
     if ($ModuleClassExists) {
         // Make sure that the class implements Gdn_IModule
         $ReflectionClass = new ReflectionClass($Module);
         if ($ReflectionClass->implementsInterface("Gdn_IModule")) {
             // Set the proper application folder on this controller so that things render properly.
             if ($AppFolder) {
                 $this->ApplicationFolder = $AppFolder;
             } else {
                 $Filename = str_replace('\\', '/', substr($ReflectionClass->getFileName(), strlen(PATH_ROOT)));
                 // Figure our the application folder for the module.
                 $Parts = explode('/', trim($Filename, '/'));
                 if ($Parts[0] == 'applications') {
                     $this->ApplicationFolder = $Parts[1];
                 }
             }
             $ModuleInstance = new $Module($this);
             $ModuleInstance->Visible = true;
             $WhiteList = array('Limit', 'Help');
             foreach ($this->Request->get() as $Key => $Value) {
                 if (in_array($Key, $WhiteList)) {
                     $ModuleInstance->{$Key} = $Value;
                 }
             }
             $this->setData('_Module', $ModuleInstance);
             $this->render('Index', false, 'dashboard');
             return;
         }
     }
     throw notFoundException($Module);
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:44,代码来源:class.modulecontroller.php

示例5: verify

 /**
  *
  *
  * @param $UserID
  * @param $Verified
  * @throws Exception
  */
 public function verify($UserID, $Verified)
 {
     $this->permission('Garden.Moderation.Manage');
     if (!$this->Request->isAuthenticatedPostBack()) {
         throw permissionException('Javascript');
     }
     // First, set the field value.
     Gdn::userModel()->setField($UserID, 'Verified', $Verified);
     $User = Gdn::userModel()->getID($UserID);
     if (!$User) {
         throw notFoundException('User');
     }
     // Send back the verified button.
     require_once $this->fetchViewLocation('helper_functions', 'Profile', 'Dashboard');
     $this->jsonTarget('.User-Verified', userVerified($User), 'ReplaceWith');
     $this->render('Blank', 'Utility', 'Dashboard');
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:24,代码来源:class.usercontroller.php

示例6: sendEmailConfirmationEmail

 /**
  * Send the confirmation email.
  *
  * @param int|string|null $User
  * @param bool $Force
  * @throws Exception
  */
 public function sendEmailConfirmationEmail($User = null, $Force = false)
 {
     if (!$User) {
         $User = Gdn::session()->User;
     } elseif (is_numeric($User)) {
         $User = $this->getID($User);
     } elseif (is_string($User)) {
         $User = $this->getByEmail($User);
     }
     if (!$User) {
         throw notFoundException('User');
     }
     $User = (array) $User;
     if (is_string($User['Attributes'])) {
         $User['Attributes'] = dbdecode($User['Attributes']);
     }
     // Make sure the user needs email confirmation.
     if ($User['Confirmed'] && !$Force) {
         $this->Validation->addValidationResult('Role', 'Your email doesn\'t need confirmation.');
         // Remove the email key.
         if (isset($User['Attributes']['EmailKey'])) {
             unset($User['Attributes']['EmailKey']);
             $this->saveAttribute($User['UserID'], $User['Attributes']);
         }
         return;
     }
     // Make sure there is a confirmation code.
     $Code = valr('Attributes.EmailKey', $User);
     if (!$Code) {
         $Code = randomString(8);
         $Attributes = $User['Attributes'];
         if (!is_array($Attributes)) {
             $Attributes = ['EmailKey' => $Code];
         } else {
             $Attributes['EmailKey'] = $Code;
         }
         $this->saveAttribute($User['UserID'], $Attributes);
     }
     $AppTitle = Gdn::config('Garden.Title');
     $Email = new Gdn_Email();
     $Email->subject(sprintf(t('[%s] Confirm Your Email Address'), $AppTitle));
     $Email->to($User['Email']);
     $EmailUrlFormat = '{/entry/emailconfirm,exurl,domain}/{User.UserID,rawurlencode}/{EmailKey,rawurlencode}';
     $Data = [];
     $Data['EmailKey'] = $Code;
     $Data['User'] = arrayTranslate((array) $User, ['UserID', 'Name', 'Email']);
     $url = formatString($EmailUrlFormat, $Data);
     $message = formatString(t('Hello {User.Name}!'), $Data) . ' ' . t('You need to confirm your email address before you can continue.');
     $emailTemplate = $Email->getEmailTemplate()->setTitle(t('Confirm Your Email Address'))->setMessage($message)->setButton($url, t('Confirm My Email Address'));
     $Email->setEmailTemplate($emailTemplate);
     try {
         $Email->send();
     } catch (Exception $e) {
         if (debug()) {
             throw $e;
         }
     }
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:65,代码来源:class.usermodel.php

示例7: emailConfirm

 /**
  * Confirm email address is valid via sent code.
  *
  * @access public
  * @since 2.0.0
  *
  * @param int $UserID
  * @param string $EmailKey Authenticate with unique, 1-time code sent via email.
  */
 public function emailConfirm($UserID, $EmailKey = '')
 {
     $User = $this->UserModel->getID($UserID);
     if (!$User) {
         throw notFoundException('User');
     }
     $EmailConfirmed = $this->UserModel->confirmEmail($User, $EmailKey);
     $this->Form->setValidationResults($this->UserModel->validationResults());
     if ($EmailConfirmed) {
         $UserID = val('UserID', $User);
         Gdn::session()->start($UserID);
     }
     $this->setData('EmailConfirmed', $EmailConfirmed);
     $this->setData('Email', $User->Email);
     $this->render();
 }
开发者ID:korelstar,项目名称:vanilla,代码行数:25,代码来源:class.entrycontroller.php

示例8: delete

 /**
  *
  *
  * @param string|unknown_type $InvitationID
  * @return bool
  * @throws Exception
  */
 public function delete($InvitationID)
 {
     $Session = Gdn::session();
     $UserID = $Session->UserID;
     // Validate that this user can delete this invitation:
     $Invitation = $this->getID($InvitationID, DATASET_TYPE_ARRAY);
     // Does the invitation exist?
     if (!$Invitation) {
         throw notFoundException('Invitation');
     }
     // Does this user own the invitation?
     if ($UserID != $Invitation['InsertUserID'] && !$Session->checkPermission('Garden.Moderation.Manage')) {
         throw permissionException('@' . t('InviteErrorPermission', t('ErrorPermission')));
     }
     // Delete it.
     $this->SQL->delete($this->Name, array('InvitationID' => $InvitationID));
     // Add the invitation back onto the user's account if the invitation has not been accepted.
     if (!$Invitation->AcceptedUserID) {
         Gdn::userModel()->IncreaseInviteCount($UserID);
     }
     return true;
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:29,代码来源:class.invitationmodel.php

示例9: _discussionOptions

 /**
  *
  *
  * @param $sender controller instance.
  * @param int|string $discussionID Identifier of the discussion.
  *
  * @throws notFoundException
  */
 protected function _discussionOptions($sender, $discussionID)
 {
     $sender->Form = new Gdn_Form();
     $Discussion = $sender->DiscussionModel->getID($discussionID);
     if (!$Discussion) {
         throw notFoundException('Discussion');
     }
     $sender->permission('Vanilla.Discussions.Edit', true, 'Category', val('PermissionCategoryID', $Discussion));
     // Both '' and 'Discussion' denote a discussion type of discussion.
     if (!val('Type', $Discussion)) {
         setValue('Type', $Discussion, 'Discussion');
     }
     if ($sender->Form->isPostBack()) {
         $sender->DiscussionModel->setField($discussionID, 'Type', $sender->Form->getFormValue('Type'));
         // Update the QnA field.  Default to "Unanswered" for questions. Null the field for other types.
         $qna = val('QnA', $Discussion);
         switch ($sender->Form->getFormValue('Type')) {
             case 'Question':
                 $sender->DiscussionModel->setField($discussionID, 'QnA', $qna ? $qna : 'Unanswered');
                 break;
             default:
                 $sender->DiscussionModel->setField($discussionID, 'QnA', null);
         }
         //         $Form = new Gdn_Form();
         $sender->Form->setValidationResults($sender->DiscussionModel->validationResults());
         //         if ($sender->DeliveryType() == DELIVERY_TYPE_ALL || $Redirect)
         //            $sender->RedirectUrl = Gdn::Controller()->Request->PathAndQuery();
         Gdn::controller()->jsonTarget('', '', 'Refresh');
     } else {
         $sender->Form->setData($Discussion);
     }
     $sender->setData('Discussion', $Discussion);
     $sender->setData('_Types', array('Question' => '@' . t('Question Type', 'Question'), 'Discussion' => '@' . t('Discussion Type', 'Discussion')));
     $sender->setData('Title', t('Q&A Options'));
     $sender->render('DiscussionOptions', '', 'plugins/QnA');
 }
开发者ID:vanilla,项目名称:addons,代码行数:44,代码来源:class.qna.plugin.php

示例10: testLocale

 /**
  * Temporarily enable a locale pack without installing it/
  *
  * @param string $LocaleKey The key of the folder.
  * @throws NotFoundException
  */
 public function testLocale($LocaleKey)
 {
     $Available = $this->availableLocalePacks();
     if (!isset($Available[$LocaleKey])) {
         throw notFoundException('Locale');
     }
     // Grab all of the definition files from the locale.
     $Paths = SafeGlob(PATH_ROOT . "/locales/{$LocaleKey}/*.php");
     // Unload the dynamic config
     Gdn::locale()->unload();
     // Load each locale file, checking for errors
     foreach ($Paths as $Path) {
         Gdn::locale()->load($Path, false);
     }
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:21,代码来源:class.localemodel.php

示例11: getUserInfo

 /**
  * Retrieve the user to be manipulated. Defaults to current user.
  *
  * @since 2.0.0
  * @access public
  * @param mixed $User Unique identifier, possibly username or ID.
  * @param string $Username .
  * @param int $UserID Unique ID.
  * @param bool $CheckPermissions Whether or not to check user permissions.
  * @return bool Always true.
  */
 public function getUserInfo($UserReference = '', $Username = '', $UserID = '', $CheckPermissions = false)
 {
     if ($this->_UserInfoRetrieved) {
         return;
     }
     if (!c('Garden.Profile.Public') && !Gdn::session()->isValid()) {
         throw permissionException();
     }
     // If a UserID was provided as a querystring parameter, use it over anything else:
     if ($UserID) {
         $UserReference = $UserID;
         $Username = 'Unknown';
         // Fill this with a value so the $UserReference is assumed to be an integer/userid.
     }
     $this->Roles = array();
     if ($UserReference == '') {
         if ($Username) {
             $this->User = $this->UserModel->getByUsername($Username);
         } else {
             $this->User = $this->UserModel->getID(Gdn::session()->UserID);
         }
     } elseif (is_numeric($UserReference) && $Username != '') {
         $this->User = $this->UserModel->getID($UserReference);
     } else {
         $this->User = $this->UserModel->getByUsername($UserReference);
     }
     $this->fireEvent('UserLoaded');
     if ($this->User === false) {
         throw notFoundException('User');
     } elseif ($this->User->Deleted == 1) {
         redirect('dashboard/home/deleted');
     } else {
         $this->RoleData = $this->UserModel->getRoles($this->User->UserID);
         if ($this->RoleData !== false && $this->RoleData->numRows(DATASET_TYPE_ARRAY) > 0) {
             $this->Roles = array_column($this->RoleData->resultArray(), 'Name');
         }
         // Hide personal info roles
         if (!checkPermission('Garden.PersonalInfo.View')) {
             $this->Roles = array_filter($this->Roles, 'RoleModel::FilterPersonalInfo');
         }
         $this->setData('Profile', $this->User);
         $this->setData('UserRoles', $this->Roles);
         if ($CssClass = val('_CssClass', $this->User)) {
             $this->CssClass .= ' ' . $CssClass;
         }
     }
     if ($CheckPermissions && Gdn::session()->UserID != $this->User->UserID) {
         $this->permission(array('Garden.Users.Edit', 'Moderation.Profiles.Edit'), false);
     }
     $this->addSideMenu();
     $this->_UserInfoRetrieved = true;
     return true;
 }
开发者ID:korelstar,项目名称:vanilla,代码行数:64,代码来源:class.profilecontroller.php

示例12: discussionsController_Tagged_create

 /**
  * Load discussions for a specific tag.
  * @param DiscussionsController $Sender
  */
 public function discussionsController_Tagged_create($Sender)
 {
     Gdn_Theme::section('DiscussionList');
     $Args = $Sender->RequestArgs;
     $Get = array_change_key_case($Sender->Request->get());
     if ($UseCategories = c('Plugins.Tagging.UseCategories')) {
         // The url is in the form /category/tag/p1
         $CategoryCode = val(0, $Args);
         $Tag = val(1, $Args);
         $Page = val(2, $Args);
     } else {
         // The url is in the form /tag/p1
         $CategoryCode = '';
         $Tag = val(0, $Args);
         $Page = val(1, $Args);
     }
     // Look for explcit values.
     $CategoryCode = val('category', $Get, $CategoryCode);
     $Tag = val('tag', $Get, $Tag);
     $Page = val('page', $Get, $Page);
     $Category = CategoryModel::categories($CategoryCode);
     $Tag = stringEndsWith($Tag, '.rss', true, true);
     list($Offset, $Limit) = offsetLimit($Page, c('Vanilla.Discussions.PerPage', 30));
     $MultipleTags = strpos($Tag, ',') !== false;
     $Sender->setData('Tag', $Tag, true);
     $TagModel = TagModel::instance();
     $RecordCount = false;
     if (!$MultipleTags) {
         $Tags = $TagModel->getWhere(array('Name' => $Tag))->resultArray();
         if (count($Tags) == 0) {
             throw notFoundException('Page');
         }
         if (count($Tags) > 1) {
             foreach ($Tags as $TagRow) {
                 if ($TagRow['CategoryID'] == val('CategoryID', $Category)) {
                     break;
                 }
             }
         } else {
             $TagRow = array_pop($Tags);
         }
         $Tags = $TagModel->getRelatedTags($TagRow);
         $RecordCount = $TagRow['CountDiscussions'];
         $Sender->setData('CountDiscussions', $RecordCount);
         $Sender->setData('Tags', $Tags);
         $Sender->setData('Tag', $TagRow);
         $ChildTags = $TagModel->getChildTags($TagRow['TagID']);
         $Sender->setData('ChildTags', $ChildTags);
     }
     $Sender->title(htmlspecialchars($TagRow['FullName']));
     $UrlTag = rawurlencode($Tag);
     if (urlencode($Tag) == $Tag) {
         $Sender->canonicalUrl(url(ConcatSep('/', "/discussions/tagged/{$UrlTag}", PageNumber($Offset, $Limit, true)), true));
         $FeedUrl = url(ConcatSep('/', "/discussions/tagged/{$UrlTag}/feed.rss", PageNumber($Offset, $Limit, true, false)), '//');
     } else {
         $Sender->canonicalUrl(url(ConcatSep('/', 'discussions/tagged', PageNumber($Offset, $Limit, true)) . '?Tag=' . $UrlTag, true));
         $FeedUrl = url(ConcatSep('/', 'discussions/tagged', PageNumber($Offset, $Limit, true, false), 'feed.rss') . '?Tag=' . $UrlTag, '//');
     }
     if ($Sender->Head) {
         $Sender->addJsFile('discussions.js');
         $Sender->Head->addRss($FeedUrl, $Sender->Head->title());
     }
     if (!is_numeric($Offset) || $Offset < 0) {
         $Offset = 0;
     }
     // Add Modules
     $Sender->addModule('NewDiscussionModule');
     $Sender->addModule('DiscussionFilterModule');
     $Sender->addModule('BookmarkedModule');
     $Sender->setData('Category', false, true);
     $Sender->AnnounceData = false;
     $Sender->setData('Announcements', array(), true);
     $DiscussionModel = new DiscussionModel();
     $TagModel->setTagSql($DiscussionModel->SQL, $Tag, $Limit, $Offset, $Sender->Request->get('op', 'or'));
     $Sender->DiscussionData = $DiscussionModel->get($Offset, $Limit, array('Announce' => 'all'));
     $Sender->setData('Discussions', $Sender->DiscussionData, true);
     $Sender->setJson('Loading', $Offset . ' to ' . $Limit);
     // Build a pager.
     $PagerFactory = new Gdn_PagerFactory();
     $Sender->Pager = $PagerFactory->GetPager('Pager', $Sender);
     $Sender->Pager->ClientID = 'Pager';
     $Sender->Pager->configure($Offset, $Limit, $RecordCount, '');
     $Sender->View = c('Vanilla.Discussions.Layout');
     /*
           // If these don't equal, then there is a category that should be inserted.
           if ($UseCategories && $Category && $TagRow['FullName'] != val('Name', $Category)) {
              $Sender->Data['Breadcrumbs'][] = array('Name' => $Category['Name'], 'Url' => TagUrl($TagRow));
           }
           $Sender->Data['Breadcrumbs'][] = array('Name' => $TagRow['FullName'], 'Url' => '');
     */
     // Render the controller.
     $this->View = c('Vanilla.Discussions.Layout') == 'table' ? 'table' : 'index';
     $Sender->render($this->View, 'discussions', 'vanilla');
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:98,代码来源:class.tagging.plugin.php

示例13: getNew

 /**
  *
  *
  * @param $ConversationID
  * @param null $LastMessageID
  * @throws Exception
  */
 public function getNew($ConversationID, $LastMessageID = null)
 {
     $this->RecipientData = $this->ConversationModel->getRecipients($ConversationID);
     $this->setData('Recipients', $this->RecipientData);
     // Check permissions on the recipients.
     $InConversation = false;
     foreach ($this->RecipientData->result() as $Recipient) {
         if ($Recipient->UserID == Gdn::session()->UserID) {
             $InConversation = true;
             break;
         }
     }
     if (!$InConversation) {
         // Conversation moderation must be enabled and they must have permission
         if (!c('Conversations.Moderation.Allow', false)) {
             throw permissionException();
         }
         $this->permission('Conversations.Moderation.Manage');
     }
     $this->Conversation = $this->ConversationModel->getID($ConversationID);
     $this->setData('Conversation', $this->Conversation);
     // Bad conversation? Redirect
     if ($this->Conversation === false) {
         throw notFoundException('Conversation');
     }
     $Where = array();
     if ($LastMessageID) {
         if (strpos($LastMessageID, '_') !== false) {
             $LastMessageID = array_pop(explode('_', $LastMessageID));
         }
         $Where['MessageID >='] = $LastMessageID;
     }
     // Fetch message data
     $this->setData('MessageData', $this->ConversationMessageModel->get($ConversationID, Gdn::session()->UserID, 0, 50, $Where), true);
     $this->render('Messages');
 }
开发者ID:ringoma,项目名称:vanilla,代码行数:43,代码来源:class.messagescontroller.php

示例14: flagForReview

 /**
  * Insert a SPAM Queue entry for the specified record and delete the record, if possible.
  *
  * @param string $recordType The type of record we're flagging: Discussion or Comment.
  * @param int $id ID of the record we're flagging.
  * @param object|array $data Properties used for updating/overriding the record's current values.
  *
  * @throws Exception If an invalid record type is specified, throw an exception.
  */
 protected static function flagForReview($recordType, $id, $data)
 {
     // We're planning to purge the spammy record.
     $deleteRow = true;
     /**
      * We're only handling two types of content: discussions and comments.  Both need some special setup.
      * Error out if we're not dealing with a discussion or comment.
      */
     switch ($recordType) {
         case 'Comment':
             $model = new CommentModel();
             $row = $model->getID($id, DATASET_TYPE_ARRAY);
             break;
         case 'Discussion':
             $model = new DiscussionModel();
             $row = $model->getID($id, DATASET_TYPE_ARRAY);
             /**
              * If our discussion has more than three comments, it might be worth saving.  Hold off on deleting and
              * just flag it.  If we have between 0 and 3 comments, save them along with the discussion.
              */
             if ($row['CountComments'] > 3) {
                 $deleteRow = false;
             } elseif ($row['CountComments'] > 0) {
                 $comments = Gdn::database()->sql()->getWhere('Comment', array('DiscussionID' => $id))->resultArray();
                 if (!array_key_exists('_Data', $row)) {
                     $row['_Data'] = array();
                 }
                 $row['_Data']['Comment'] = $comments;
             }
             break;
         default:
             throw notFoundException($recordType);
     }
     $overrideFields = array('Name', 'Body');
     foreach ($overrideFields as $fieldName) {
         if (($fieldValue = val($fieldName, $data, false)) !== false) {
             $row[$fieldName] = $fieldValue;
         }
     }
     $logOptions = array('GroupBy' => array('RecordID'));
     if ($deleteRow) {
         // Remove the record to the log.
         $model->deleteID($id);
     }
     LogModel::insert('Spam', $recordType, $row, $logOptions);
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:55,代码来源:class.spammodel.php

示例15: editCategory

 /**
  * Editing a category.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $CategoryID Unique ID of the category to be updated.
  */
 public function editCategory($CategoryID = '')
 {
     // Check permission
     $this->permission('Garden.Community.Manage');
     // Set up models
     $RoleModel = new RoleModel();
     $PermissionModel = Gdn::permissionModel();
     $this->Form->setModel($this->CategoryModel);
     if (!$CategoryID && $this->Form->authenticatedPostBack()) {
         if ($ID = $this->Form->getFormValue('CategoryID')) {
             $CategoryID = $ID;
         }
     }
     // Get category data
     $this->Category = $this->CategoryModel->getID($CategoryID);
     if (!$this->Category) {
         throw notFoundException('Category');
     }
     $this->Category->CustomPermissions = $this->Category->CategoryID == $this->Category->PermissionCategoryID;
     // Set up head
     $this->addJsFile('jquery.alphanumeric.js');
     $this->addJsFile('categories.js');
     $this->addJsFile('jquery.gardencheckboxgrid.js');
     $this->title(t('Edit Category'));
     $this->addSideMenu('vanilla/settings/managecategories');
     // Make sure the form knows which item we are editing.
     $this->Form->addHidden('CategoryID', $CategoryID);
     $this->setData('CategoryID', $CategoryID);
     // Load all roles with editable permissions
     $this->RoleArray = $RoleModel->getArray();
     $this->fireEvent('AddEditCategory');
     if ($this->Form->authenticatedPostBack()) {
         $this->setupDiscussionTypes($this->Category);
         $Upload = new Gdn_Upload();
         $TmpImage = $Upload->validateUpload('PhotoUpload', false);
         if ($TmpImage) {
             // Generate the target image name
             $TargetImage = $Upload->generateTargetName(PATH_UPLOADS);
             $ImageBaseName = pathinfo($TargetImage, PATHINFO_BASENAME);
             // Save the uploaded image
             $Parts = $Upload->saveAs($TmpImage, $ImageBaseName);
             $this->Form->setFormValue('Photo', $Parts['SaveName']);
         }
         $this->Form->setFormValue('CustomPoints', (bool) $this->Form->getFormValue('CustomPoints'));
         if ($this->Form->save()) {
             $Category = CategoryModel::categories($CategoryID);
             $this->setData('Category', $Category);
             if ($this->deliveryType() == DELIVERY_TYPE_ALL) {
                 redirect('vanilla/settings/managecategories');
             }
         }
     } else {
         $this->Form->setData($this->Category);
         $this->setupDiscussionTypes($this->Category);
         $this->Form->setValue('CustomPoints', $this->Category->PointsCategoryID == $this->Category->CategoryID);
     }
     // Get all of the currently selected role/permission combinations for this junction.
     $Permissions = $PermissionModel->getJunctionPermissions(array('JunctionID' => $CategoryID), 'Category', '', array('AddDefaults' => !$this->Category->CustomPermissions));
     $Permissions = $PermissionModel->unpivotPermissions($Permissions, true);
     if ($this->deliveryType() == DELIVERY_TYPE_ALL) {
         $this->setData('PermissionData', $Permissions, true);
     }
     // Render default view
     $this->render();
 }
开发者ID:akratiani,项目名称:vanilla,代码行数:73,代码来源:class.settingscontroller.php


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