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


PHP Gdn::Session方法代码示例

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


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

示例1: ToString

 public function ToString()
 {
     $Session = Gdn::Session();
     $Controller = Gdn::Controller();
     $UserID = $Controller->User->UserID;
     $MemberOptions = array();
     $ProfileOptions = array();
     $Controller->EventArguments['UserID'] = $UserID;
     $Controller->EventArguments['ProfileOptions'] =& $ProfileOptions;
     $Controller->EventArguments['MemberOptions'] =& $MemberOptions;
     if ($Controller->EditMode) {
         return '<div class="ProfileOptions">' . Anchor(T('Back to Profile'), UserUrl($Controller->User), array('class' => 'ProfileButtons')) . '</div>';
         //         $ProfileOptions[] = array('Text' => T('Back to Profile'), 'Url' => UserUrl($Controller->User), 'CssClass' => 'BackToProfile');
     } else {
         // Profile Editing
         if (hasEditProfile($Controller->User->UserID)) {
             $ProfileOptions[] = array('Text' => Sprite('SpEditProfile') . ' ' . T('Edit Profile'), 'Url' => UserUrl($Controller->User, '', 'edit'));
         }
         // Ban/Unban
         $MayBan = CheckPermission('Garden.Moderation.Manage') || CheckPermission('Garden.Users.Edit') || CheckPermission('Moderation.Users.Ban');
         if ($MayBan && $UserID != $Session->UserID) {
             if ($Controller->User->Banned) {
                 $ProfileOptions[] = array('Text' => Sprite('SpBan') . ' ' . T('Unban'), 'Url' => "/user/ban?userid={$UserID}&unban=1", 'CssClass' => 'Popup');
             } elseif (!$Controller->User->Admin) {
                 $ProfileOptions[] = array('Text' => Sprite('SpBan') . ' ' . T('Ban'), 'Url' => "/user/ban?userid={$UserID}", 'CssClass' => 'Popup');
             }
         }
         // Delete content.
         if (CheckPermission('Garden.Moderation.Manage')) {
             $ProfileOptions[] = array('Text' => Sprite('SpDelete') . ' ' . T('Delete Content'), 'Url' => "/user/deletecontent?userid={$UserID}", 'CssClass' => 'Popup');
         }
     }
     return parent::ToString();
 }
开发者ID:3marproof,项目名称:vanilla,代码行数:34,代码来源:class.profileoptionsmodule.php

示例2: Comment

 public function Comment()
 {
     $Session = Gdn::Session();
     $this->Form->SetModel($this->ActivityModel);
     $NewActivityID = 0;
     if ($this->Form->AuthenticatedPostBack()) {
         $Body = $this->Form->GetValue('Body', '');
         $ActivityID = $this->Form->GetValue('ActivityID', '');
         if ($Body != '' && is_numeric($ActivityID) && $ActivityID > 0) {
             $NewActivityID = $this->ActivityModel->Add($Session->UserID, 'ActivityComment', $Body, '', $ActivityID, '', TRUE);
         }
     }
     // Redirect back to the sending location if this isn't an ajax request
     if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
         Redirect($this->Form->GetValue('Return', Gdn_Url::WebRoot()));
     } else {
         // Load the newly added comment
         $this->Comment = $this->ActivityModel->GetID($NewActivityID);
         $this->Comment->ActivityType .= ' Hidden';
         // Hide it so jquery can reveal it
         // Set it in the appropriate view
         $this->View = 'comment';
         // And render
         $this->Render();
     }
 }
开发者ID:nbudin,项目名称:Garden,代码行数:26,代码来源:activity.php

示例3: Base_Render_Before

 public function Base_Render_Before(&$Sender)
 {
     // Add menu items.
     $Session = Gdn::Session();
     if ($Sender->Menu) {
         $DiscussionsHome = '/' . Gdn::Config('Vanilla.Discussions.Home', 'discussions');
         $Sender->Menu->AddLink(Gdn::Translate('Discussions'), 'Discussions', $DiscussionsHome, FALSE);
         if ($Session->IsValid()) {
             $Bookmarked = Gdn::Translate('My Bookmarks');
             $CountBookmarks = $Session->User->CountBookmarks;
             if (is_numeric($CountBookmarks) && $CountBookmarks > 0) {
                 $Bookmarked .= '<span>' . $CountBookmarks . '</span>';
             }
             $Sender->Menu->AddLink(Gdn::Translate('Discussions'), '\\' . $Bookmarked, '/discussions/bookmarked', FALSE, array('class' => 'MyBookmarks'));
             $MyDiscussions = Gdn::Translate('My Discussions');
             $CountDiscussions = $Session->User->CountDiscussions;
             if (is_numeric($CountDiscussions) && $CountDiscussions > 0) {
                 $MyDiscussions .= '<span>' . $CountDiscussions . '</span>';
             }
             $Sender->Menu->AddLink(Gdn::Translate('Discussions'), '\\' . $MyDiscussions, '/discussions/mine', FALSE, array('class' => 'MyDiscussions'));
             $MyDrafts = Gdn::Translate('My Drafts');
             $CountDrafts = $Session->User->CountDrafts;
             if (is_numeric($CountDrafts) && $CountDrafts > 0) {
                 $MyDrafts .= '<span>' . $CountDrafts . '</span>';
             }
             $Sender->Menu->AddLink(Gdn::Translate('Discussions'), '\\' . $MyDrafts, '/drafts', FALSE, array('class' => 'MyDrafts'));
         }
         if ($Session->IsValid()) {
             $Sender->Menu->AddLink(Gdn::Translate('Discussions'), 'New Discussion', '/post/discussion', FALSE);
         }
     }
 }
开发者ID:Beyzie,项目名称:Garden,代码行数:32,代码来源:hooks.php

示例4: Save

 public function Save($FormPostValues)
 {
     $Session = Gdn::Session();
     // Define the primary key in this model's table.
     $this->DefineSchema();
     // Add & apply any extra validation rules:
     $this->Validation->ApplyRule('Body', 'Required');
     $this->AddInsertFields($FormPostValues);
     // Validate the form posted values
     $MessageID = FALSE;
     if ($this->Validate($FormPostValues)) {
         $Fields = $this->Validation->SchemaValidationFields();
         // All fields on the form that relate to the schema
         $MessageID = $this->SQL->Insert($this->Name, $Fields);
         $ConversationID = ArrayValue('ConversationID', $Fields, 0);
         // Update the conversation's DateUpdated field
         $this->SQL->Update('Conversation')->Set('DateUpdated', Format::ToDateTime())->Set('UpdateUserID', $Session->UserID)->Where('ConversationID', $ConversationID)->Put();
         // NOTE: INCREMENTING COUNTS INSTEAD OF GETTING ACTUAL COUNTS COULD
         // BECOME A PROBLEM. WATCH FOR IT.
         // Update the message counts for all users in the conversation
         $this->SQL->Update('UserConversation')->Set('CountMessages', 'CountMessages + 1', FALSE)->Where('ConversationID', $ConversationID)->Put();
         $this->SQL->Update('UserConversation')->Set('CountNewMessages', 'CountNewMessages + 1', FALSE)->Where('ConversationID', $ConversationID)->Where('UserID <>', $Session->UserID)->Put();
         // Update the CountUnreadConversations count on each user related to the discussion.
         $this->UpdateCountUnreadConversations($ConversationID, $Session->UserID);
         // Update the userconversation records to reflect the most recently
         // added message for all users other than the one that added the
         // message (otherwise they would see their name/message on the
         // conversation list instead of the person they are conversing with).
         $this->SQL->Update('UserConversation')->Set('LastMessageID', $MessageID)->Where('ConversationID', $ConversationID)->Where('UserID <>', $Session->UserID)->Put();
     }
     return $MessageID;
 }
开发者ID:kidmax,项目名称:Garden,代码行数:32,代码来源:class.conversationmessagemodel.php

示例5: DiscussionModel_BeforeSaveDiscussion_Handler

 public function DiscussionModel_BeforeSaveDiscussion_Handler($Sender, &$Args)
 {
     if ($Args['FormPostValues']['InsertUserID'] != Gdn::Session()->UserID) {
         return;
     }
     $this->SetAttributes($Sender, $Args);
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:7,代码来源:class.useragent.plugin.php

示例6: smarty_function_custom_menu

/**
 * A placeholder for future menu items.
 *
 * @param array The parameters passed into the function. This currently takes no parameters.
 * @param Smarty The smarty object rendering the template.
 * @return
 */
function smarty_function_custom_menu($Params, &$Smarty)
{
    $Controller = $Smarty->Controller;
    if (is_object($Menu = GetValue('Menu', $Controller))) {
        $Format = GetValue('format', $Params, Wrap('<a href="%url" class="%class">%text</a>', GetValue('wrap', $Params, 'li')));
        $Result = '';
        foreach ($Menu->Items as $Group) {
            foreach ($Group as $Item) {
                // Make sure the item is a custom item.
                if (GetValueR('Attributes.Standard', $Item)) {
                    continue;
                }
                // Make sure the user has permission for the item.
                if ($Permission = GetValue('Permission', $Item)) {
                    if (!Gdn::Session()->CheckPermission($Permission)) {
                        continue;
                    }
                }
                if (($Url = GetValue('Url', $Item)) && ($Text = GetValue('Text', $Item))) {
                    $Result .= Gdn_Theme::Link($Url, $Text, $Format);
                }
            }
        }
        return $Result;
    }
    return '';
}
开发者ID:kennyma,项目名称:Garden,代码行数:34,代码来源:function.custom_menu.php

示例7: smarty_function_signin_link

/**
 */
function smarty_function_signin_link($Params, &$Smarty)
{
    if (!Gdn::Session()->IsValid()) {
        $Wrap = GetValue('wrap', $Params, 'li');
        return Gdn_Theme::Link('signinout', GetValue('text', $Params, ''), GetValue('format', $Params, Wrap('<a href="%url" rel="nofollow" class="%class">%text</a>', $Wrap)), $Params);
    }
}
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:9,代码来源:function.signin_link.php

示例8: Award

 /**
  * Award a badge to a user and record some activity
  *
  * @param int $BadgeID
  * @param int $UserID This is the user that should get the award
  * @param int $InsertUserID This is the user that gave the award
  * @param string $Reason This is the reason the giver gave with the award
  */
 public function Award($BadgeID, $UserID, $InsertUserID = NULL, $Reason = '')
 {
     $Badge = Yaga::BadgeModel()->GetByID($BadgeID);
     if (!empty($Badge)) {
         if (!$this->Exists($UserID, $BadgeID)) {
             $this->SQL->Insert('BadgeAward', array('BadgeID' => $BadgeID, 'UserID' => $UserID, 'InsertUserID' => $InsertUserID, 'Reason' => $Reason, 'DateInserted' => date(DATE_ISO8601)));
             // Record the points for this badge
             UserModel::GivePoints($UserID, $Badge->AwardValue, 'Badge');
             // Increment the user's badge count
             $this->SQL->Update('User')->Set('CountBadges', 'CountBadges + 1', FALSE)->Where('UserID', $UserID)->Put();
             if (is_null($InsertUserID)) {
                 $InsertUserID = Gdn::Session()->UserID;
             }
             // Record some activity
             $ActivityModel = new ActivityModel();
             $Activity = array('ActivityType' => 'BadgeAward', 'ActivityUserID' => $UserID, 'RegardingUserID' => $InsertUserID, 'Photo' => $Badge->Photo, 'RecordType' => 'Badge', 'RecordID' => $BadgeID, 'Route' => '/badges/detail/' . $Badge->BadgeID . '/' . Gdn_Format::Url($Badge->Name), 'HeadlineFormat' => T('Yaga.Badge.EarnedHeadlineFormat'), 'Data' => array('Name' => $Badge->Name), 'Story' => $Badge->Description);
             // Create a public record
             $ActivityModel->Queue($Activity, FALSE);
             // TODO: enable the grouped notifications after issue #1776 is resolved , array('GroupBy' => 'Route'));
             // Notify the user of the award
             $Activity['NotifyUserID'] = $UserID;
             $ActivityModel->Queue($Activity, 'BadgeAward', array('Force' => TRUE));
             // Actually save the activity
             $ActivityModel->SaveQueue();
             $this->EventArguments['UserID'] = $UserID;
             $this->FireEvent('AfterBadgeAward');
         }
     }
 }
开发者ID:hxii,项目名称:Application-Yaga,代码行数:37,代码来源:class.badgeawardmodel.php

示例9: ToString

 public function ToString()
 {
     if (!Gdn::Session()->IsValid() && C('Garden.Modules.ShowGuestModule')) {
         return parent::ToString();
     }
     return '';
 }
开发者ID:elpum,项目名称:TgaForumBundle,代码行数:7,代码来源:class.guestmodule.php

示例10: _CacheOnlineUserss

 protected function _CacheOnlineUserss(&$Sender)
 {
     //logic taken from Who's Online plugin
     $SQL = Gdn::SQL();
     // $this->_OnlineUsers = $SQL
     // insert or update entry into table
     $Session = Gdn::Session();
     $Invisible = $Invisible ? 1 : 0;
     if ($Session->UserID) {
         $SQL->Replace('Whosonline', array('UserID' => $Session->UserID, 'Timestamp' => Gdn_Format::ToDateTime(), 'Invisible' => $Invisible), array('UserID' => $Session->UserID));
     }
     $Frequency = C('WhosOnline.Frequency', 4);
     $History = time() - $Frequency;
     $SQL->Select('u.UserID, u.Name, w.Timestamp, w.Invisible')->From('Whosonline w')->Join('User u', 'w.UserID = u.UserID')->Where('w.Timestamp >=', date('Y-m-d H:i:s', $History))->OrderBy('u.Name');
     if (!$Session->CheckPermission('Plugins.WhosOnline.ViewHidden')) {
         $SQL->Where('w.Invisible', 0);
     }
     $OnlineUsers = $SQL->Get();
     $arrOnline = array();
     if ($OnlineUsers->NumRows() > 0) {
         foreach ($OnlineUsers->Result() as $User) {
             $arrOnline[] = $User->UserID;
         }
     }
     $Sender->SetData('Plugin-OnlineUsers-Marker', $arrOnline);
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:26,代码来源:class.onlineusers.plugin.php

示例11: Delete

 /**
  * Delete a single draft.
  *
  * Redirects user back to Index unless DeliveryType is set.
  * 
  * @since 2.0.0
  * @access public
  * 
  * @param int $DraftID Unique ID of draft to be deleted.
  * @param string $TransientKey Single-use hash to prove intent.
  */
 public function Delete($DraftID = '', $TransientKey = '')
 {
     $Form = Gdn::Factory('Form');
     $Session = Gdn::Session();
     if (is_numeric($DraftID) && $DraftID > 0 && $Session->UserID > 0 && $Session->ValidateTransientKey($TransientKey)) {
         // Delete the draft
         $Draft = $this->DraftModel->GetID($DraftID);
         if ($Draft && !$this->DraftModel->Delete($DraftID)) {
             $Form->AddError('Failed to delete discussion');
         }
     } else {
         // Log an error
         $Form->AddError('ErrPermission');
     }
     // Redirect
     if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
         $Target = GetIncomingValue('Target', '/vanilla/drafts');
         Redirect($Target);
     }
     // Return any errors
     if ($Form->ErrorCount() > 0) {
         $this->SetJson('ErrorMessage', $Form->Errors());
     }
     // Render default view
     $this->Render();
 }
开发者ID:robhazkes,项目名称:Garden,代码行数:37,代码来源:class.draftscontroller.php

示例12: Edit

 public function Edit($Reference = 0, $ParentID = '')
 {
     $Session = Gdn::Session();
     $Model = new SectionModel();
     $this->Form->SetModel($Model);
     if ($ParentID) {
         $this->Form->AddHidden('ParentID', $ParentID);
     }
     $Section = False;
     if ($Reference) {
         $Section = $Model->GetID($Reference);
         if (!IsContentOwner($Section, 'Candy.Sections.Edit')) {
             $Section = False;
         }
         if ($Section) {
             $this->Form->AddHidden('SectionID', $Section->SectionID);
             $this->Form->SetData($Section);
         }
     }
     if (!$Section) {
         $this->Permission('Candy.Sections.Add');
     }
     if ($this->Form->AuthenticatedPostBack()) {
         $this->Form->Save($Section);
         if ($this->Form->ErrorCount() == 0) {
             $this->InformMessage(T('Saved'), array('Sprite' => 'Check', 'CssClass' => 'Dismissable AutoDismiss'));
         }
     }
     $this->Title(ConcatSep(' - ', T('Section'), GetValue('Name', $Section)));
     $this->Render();
 }
开发者ID:unlight,项目名称:Candy,代码行数:31,代码来源:class.sectioncontroller.php

示例13: PostController_DiscussionFormOptions_Handler

 /**
  * Add 'sink' option to new discussion form.
  */
 public function PostController_DiscussionFormOptions_Handler($Sender)
 {
     $Session = Gdn::Session();
     if ($Session->CheckPermission('Vanilla.Discussions.Sink')) {
         $Sender->EventArguments['Options'] .= '<li>' . $Sender->Form->CheckBox('Sink', T('Sink'), array('value' => '1')) . '</li>';
     }
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:10,代码来源:class.submarinediscussions.plugin.php

示例14: IsSpam

   /**
    * Check whether or not the record is spam.
    * @param string $RecordType By default, this should be one of the following:
    *  - Comment: A comment.
    *  - Discussion: A discussion.
    *  - User: A user registration.
    * @param array $Data The record data.
    * @param array $Options Options for fine-tuning this method call.
    *  - Log: Log the record if it is found to be spam.
    */
   public static function IsSpam($RecordType, $Data, $Options = array()) {
      // Set some information about the user in the data.
      TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress());
      
      if ($RecordType == 'User') {
         TouchValue('Username', $Data, $Data['Name']);
      } else {
         TouchValue('Username', $Data, Gdn::Session()->User->Name);
         TouchValue('Email', $Data, Gdn::Session()->User->Email);
      }

      $Sp = self::_Instance();
      
      $Sp->EventArguments['RecordType'] = $RecordType;
      $Sp->EventArguments['Data'] = $Data;
      $Sp->EventArguments['Options'] = $Options;
      $Sp->EventArguments['IsSpam'] = FALSE;

      $Sp->FireEvent('CheckSpam');
      $Spam = $Sp->EventArguments['IsSpam'];

      // Log the spam entry.
      if ($Spam && GetValue('Log', $Options, TRUE)) {
         LogModel::Insert('Spam', $RecordType, $Data);
      }

      return $Spam;
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:38,代码来源:class.spammodel.php

示例15: UserModel_UpdateAllViewed_Create

 /**
  * Update user's AllViewed datetime.
  */
 function UserModel_UpdateAllViewed_Create(&$Sender)
 {
     if (!C('Plugins.AllViewed.Enabled')) {
         return;
     }
     // Only for members
     $Session = Gdn::Session();
     if (!$Session->IsValid()) {
         return;
     }
     $UserID = $Session->User->UserID;
     // Can only activate on yourself
     // Validity check (in case UserID passed from elsewhere some day)
     $UserID = (int) $UserID;
     if (!$UserID) {
         throw new Exception('A valid UserId is required.');
     }
     // Update User timestamp
     $Sender->SQL->Update('User')->Set('DateAllViewed', Gdn_Format::ToDateTime());
     $Sender->SQL->Where('UserID', $UserID)->Put();
     // Update CountComments = 0
     $Sender->SQL->Update('UserDiscussion')->Set('CountComments', 0);
     // Hack to avoid massive update query
     $Sender->SQL->Where('UserID', $UserID)->Put();
     // Set in current session
     $Session->User->DateAllViewed = Gdn_Format::ToDateTime();
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:30,代码来源:class.allviewed.plugin.php


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