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


PHP Gdn_Format::unserialize方法代码示例

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


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

示例1: discussionController_beforeDiscussionRender_handler

 /**
  *
  *
  * @param $Sender
  */
 public function discussionController_beforeDiscussionRender_handler($Sender)
 {
     if (!Gdn::session()->isValid()) {
         return;
     }
     $UserPrefs = Gdn_Format::unserialize(Gdn::session()->User->Preferences);
     if (!is_array($UserPrefs)) {
         $UserPrefs = array();
     }
     $QuoteFolding = val('Quotes.Folding', $UserPrefs, '1');
     $Sender->addDefinition('QuotesFolding', $QuoteFolding);
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:17,代码来源:class.quotes.plugin.php

示例2: validateCredentials

 /**
  * Validate User Credential.
  *
  * Fetches a user row by email (or name) and compare the password.
  * If the password was not stored as a blowfish hash, the password will be saved again.
  * Return the user's id, admin status and attributes.
  *
  * @param string $Email
  * @param string $Password
  * @return object
  */
 public function validateCredentials($Email = '', $ID = 0, $Password)
 {
     $this->EventArguments['Credentials'] = array('Email' => $Email, 'ID' => $ID, 'Password' => $Password);
     $this->fireEvent('BeforeValidateCredentials');
     if (!$Email && !$ID) {
         throw new Exception('The email or id is required');
     }
     try {
         $this->SQL->select('UserID, Name, Attributes, Admin, Password, HashMethod, Deleted, Banned')->from('User');
         if ($ID) {
             $this->SQL->where('UserID', $ID);
         } else {
             if (strpos($Email, '@') > 0) {
                 $this->SQL->where('Email', $Email);
             } else {
                 $this->SQL->where('Name', $Email);
             }
         }
         $DataSet = $this->SQL->get();
     } catch (Exception $Ex) {
         $this->SQL->reset();
         // Try getting the user information without the new fields.
         $this->SQL->select('UserID, Name, Attributes, Admin, Password')->from('User');
         if ($ID) {
             $this->SQL->where('UserID', $ID);
         } else {
             if (strpos($Email, '@') > 0) {
                 $this->SQL->where('Email', $Email);
             } else {
                 $this->SQL->where('Name', $Email);
             }
         }
         $DataSet = $this->SQL->get();
     }
     if ($DataSet->numRows() < 1) {
         return false;
     }
     $UserData = $DataSet->firstRow();
     // Check for a deleted user.
     if (val('Deleted', $UserData)) {
         return false;
     }
     $PasswordHash = new Gdn_PasswordHash();
     $HashMethod = val('HashMethod', $UserData);
     if (!$PasswordHash->checkPassword($Password, $UserData->Password, $HashMethod, $UserData->Name)) {
         return false;
     }
     if ($PasswordHash->Weak || $HashMethod && strcasecmp($HashMethod, 'Vanilla') != 0) {
         $Pw = $PasswordHash->hashPassword($Password);
         $this->SQL->update('User')->set('Password', $Pw)->set('HashMethod', 'Vanilla')->where('UserID', $UserData->UserID)->put();
     }
     $UserData->Attributes = Gdn_Format::unserialize($UserData->Attributes);
     return $UserData;
 }
开发者ID:RodSloan,项目名称:vanilla,代码行数:65,代码来源:class.usermodel.php

示例3: get

 /**
  * Gets a setting from the configuration array. Returns $DefaultValue if the value isn't found.
  *
  * @param string $Name The name of the configuration setting to get. If the setting is contained
  * within an associative array, use dot denomination to get the setting. ie.
  * <code>$this->Get('Database.Host')</code> would retrieve <code>$Configuration[$Group]['Database']['Host']</code>.
  * @param mixed $DefaultValue If the parameter is not found in the group, this value will be returned.
  * @return mixed The configuration value.
  */
 public function get($Name, $DefaultValue = false)
 {
     // Shortcut, get the whole config
     if ($Name == '.') {
         return $this->Settings;
     }
     $Keys = explode('.', $Name);
     $KeyCount = count($Keys);
     $Value = $this->Settings;
     for ($i = 0; $i < $KeyCount; ++$i) {
         if (is_array($Value) && array_key_exists($Keys[$i], $Value)) {
             $Value = $Value[$Keys[$i]];
         } else {
             return $DefaultValue;
         }
     }
     if (is_string($Value)) {
         $Result = Gdn_Format::unserialize($Value);
     } else {
         $Result = $Value;
     }
     return $Result;
 }
开发者ID:R-J,项目名称:vanilla,代码行数:32,代码来源:class.configuration.php

示例4: start

 /**
  * Authenticates the user with the provided Authenticator class.
  *
  * @param int $UserID The UserID to start the session with.
  * @param bool $SetIdentity Whether or not to set the identity (cookie) or make this a one request session.
  * @param bool $Persist If setting an identity, should we persist it beyond browser restart?
  */
 public function start($UserID = false, $SetIdentity = true, $Persist = false)
 {
     if (!c('Garden.Installed', false)) {
         return;
     }
     // Retrieve the authenticated UserID from the Authenticator module.
     $UserModel = Gdn::authenticator()->getUserModel();
     $this->UserID = $UserID !== false ? $UserID : Gdn::authenticator()->getIdentity();
     $this->User = false;
     // Now retrieve user information
     if ($this->UserID > 0) {
         // Instantiate a UserModel to get session info
         $this->User = $UserModel->getSession($this->UserID);
         if ($this->User) {
             if ($SetIdentity) {
                 Gdn::authenticator()->setIdentity($this->UserID, $Persist);
                 Logger::event('session_start', Logger::INFO, 'Session started for {username}.');
                 Gdn::pluginManager()->callEventHandlers($this, 'Gdn_Session', 'Start');
             }
             $UserModel->EventArguments['User'] =& $this->User;
             $UserModel->fireEvent('AfterGetSession');
             $this->_Permissions = Gdn_Format::unserialize($this->User->Permissions);
             $this->_Preferences = Gdn_Format::unserialize($this->User->Preferences);
             $this->_Attributes = Gdn_Format::unserialize($this->User->Attributes);
             $this->_TransientKey = is_array($this->_Attributes) ? val('TransientKey', $this->_Attributes) : false;
             if ($this->_TransientKey === false) {
                 $this->_TransientKey = $UserModel->setTransientKey($this->UserID);
             }
             // Save any visit-level information.
             if ($SetIdentity) {
                 $UserModel->updateVisit($this->UserID);
             }
         } else {
             $this->UserID = 0;
             $this->User = false;
             $this->_TransientKey = getAppCookie('tk');
             if ($SetIdentity) {
                 Gdn::authenticator()->setIdentity(null);
             }
         }
     } else {
         // Grab the transient key from the cookie. This doesn't always get set but we'll try it here anyway.
         $this->_TransientKey = getAppCookie('tk');
     }
     // Load guest permissions if necessary
     if ($this->UserID == 0) {
         $this->_Permissions = Gdn_Format::unserialize($UserModel->definePermissions(0));
     }
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:56,代码来源:class.session.php

示例5: preferences

 /**
  * Edit user's preferences (mostly notification settings).
  *
  * @since 2.0.0
  * @access public
  * @param mixed $UserReference Unique identifier, possibly username or ID.
  * @param string $Username .
  * @param int $UserID Unique identifier.
  */
 public function preferences($UserReference = '', $Username = '', $UserID = '')
 {
     $this->addJsFile('profile.js');
     $Session = Gdn::session();
     $this->permission('Garden.SignIn.Allow');
     // Get user data
     $this->getUserInfo($UserReference, $Username, $UserID, true);
     $UserPrefs = Gdn_Format::unserialize($this->User->Preferences);
     if ($this->User->UserID != $Session->UserID) {
         $this->permission(array('Garden.Users.Edit', 'Moderation.Profiles.Edit'), false);
     }
     if (!is_array($UserPrefs)) {
         $UserPrefs = array();
     }
     $MetaPrefs = UserModel::GetMeta($this->User->UserID, 'Preferences.%', 'Preferences.');
     // Define the preferences to be managed
     $Notifications = array();
     if (c('Garden.Profile.ShowActivities', true)) {
         $Notifications = array('Email.WallComment' => t('Notify me when people write on my wall.'), 'Email.ActivityComment' => t('Notify me when people reply to my wall comments.'), 'Popup.WallComment' => t('Notify me when people write on my wall.'), 'Popup.ActivityComment' => t('Notify me when people reply to my wall comments.'));
     }
     $this->Preferences = array('Notifications' => $Notifications);
     // Allow email notification of applicants (if they have permission & are using approval registration)
     if (checkPermission('Garden.Users.Approve') && c('Garden.Registration.Method') == 'Approval') {
         $this->Preferences['Notifications']['Email.Applicant'] = array(t('NotifyApplicant', 'Notify me when anyone applies for membership.'), 'Meta');
     }
     $this->fireEvent('AfterPreferencesDefined');
     // Loop through the preferences looking for duplicates, and merge into a single row
     $this->PreferenceGroups = array();
     $this->PreferenceTypes = array();
     foreach ($this->Preferences as $PreferenceGroup => $Preferences) {
         $this->PreferenceGroups[$PreferenceGroup] = array();
         $this->PreferenceTypes[$PreferenceGroup] = array();
         foreach ($Preferences as $Name => $Description) {
             $Location = 'Prefs';
             if (is_array($Description)) {
                 list($Description, $Location) = $Description;
             }
             $NameParts = explode('.', $Name);
             $PrefType = val('0', $NameParts);
             $SubName = val('1', $NameParts);
             if ($SubName != false) {
                 // Save an array of all the different types for this group
                 if (!in_array($PrefType, $this->PreferenceTypes[$PreferenceGroup])) {
                     $this->PreferenceTypes[$PreferenceGroup][] = $PrefType;
                 }
                 // Store all the different subnames for the group
                 if (!array_key_exists($SubName, $this->PreferenceGroups[$PreferenceGroup])) {
                     $this->PreferenceGroups[$PreferenceGroup][$SubName] = array($Name);
                 } else {
                     $this->PreferenceGroups[$PreferenceGroup][$SubName][] = $Name;
                 }
             } else {
                 $this->PreferenceGroups[$PreferenceGroup][$Name] = array($Name);
             }
         }
     }
     // Loop the preferences, setting defaults from the configuration.
     $CurrentPrefs = array();
     foreach ($this->Preferences as $PrefGroup => $Prefs) {
         foreach ($Prefs as $Pref => $Desc) {
             $Location = 'Prefs';
             if (is_array($Desc)) {
                 list($Desc, $Location) = $Desc;
             }
             if ($Location == 'Meta') {
                 $CurrentPrefs[$Pref] = val($Pref, $MetaPrefs, false);
             } else {
                 $CurrentPrefs[$Pref] = val($Pref, $UserPrefs, c('Preferences.' . $Pref, '0'));
             }
             unset($MetaPrefs[$Pref]);
         }
     }
     $CurrentPrefs = array_merge($CurrentPrefs, $MetaPrefs);
     $CurrentPrefs = array_map('intval', $CurrentPrefs);
     $this->setData('Preferences', $CurrentPrefs);
     if (UserModel::noEmail()) {
         $this->PreferenceGroups = self::_removeEmailPreferences($this->PreferenceGroups);
         $this->PreferenceTypes = self::_removeEmailPreferences($this->PreferenceTypes);
         $this->setData('NoEmail', true);
     }
     $this->setData('PreferenceGroups', $this->PreferenceGroups);
     $this->setData('PreferenceTypes', $this->PreferenceTypes);
     $this->setData('PreferenceList', $this->Preferences);
     if ($this->Form->authenticatedPostBack()) {
         // Get, assign, and save the preferences.
         $NewMetaPrefs = array();
         foreach ($this->Preferences as $PrefGroup => $Prefs) {
             foreach ($Prefs as $Pref => $Desc) {
                 $Location = 'Prefs';
                 if (is_array($Desc)) {
                     list($Desc, $Location) = $Desc;
//.........这里部分代码省略.........
开发者ID:korelstar,项目名称:vanilla,代码行数:101,代码来源:class.profilecontroller.php

示例6: saveToSerializedColumn

 /**
  *
  *
  * @param string $Column
  * @param int $RowID
  * @param string $Name
  * @param string $Value
  * @return bool|Gdn_DataSet|object|string
  * @throws Exception
  */
 public function saveToSerializedColumn($Column, $RowID, $Name, $Value = '')
 {
     if (!isset($this->Schema)) {
         $this->defineSchema();
     }
     // TODO: need to be sure that $this->PrimaryKey is only one primary key
     $FieldName = $this->PrimaryKey;
     // Load the existing values
     $Row = $this->SQL->select($Column)->from($this->Name)->where($FieldName, $RowID)->get()->firstRow();
     if (!$Row) {
         throw new Exception(T('ErrorRecordNotFound'));
     }
     $Values = Gdn_Format::unserialize($Row->{$Column});
     if (is_string($Values) && $Values != '') {
         throw new Exception(T('Serialized column failed to be unserialized.'));
     }
     if (!is_array($Values)) {
         $Values = array();
     }
     if (!is_array($Name)) {
         // Assign the new value(s)
         $Name = array($Name => $Value);
     }
     $Values = Gdn_Format::serialize(array_merge($Values, $Name));
     // Save the values back to the db
     return $this->SQL->from($this->Name)->where($FieldName, $RowID)->set($Column, $Values)->put();
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:37,代码来源:class.model.php


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