当前位置: 首页>>代码示例>>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方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ProfileController_AfterUserInfo_Handler

 public function ProfileController_AfterUserInfo_Handler($Sender)
 {
     if (Gdn::Session()->CheckPermission('Garden.Moderation.Manage') || $Sender->User->UserID == Gdn::Session()->User->UserID) {
         $Warnings = Gdn::UserModel()->GetMeta($Sender->User->UserID, 'Warnings.%', 'Warnings.', array());
         krsort($Warnings);
         $History = False;
         echo '<div class="Warnings">';
         echo Wrap(T('Warning.Warnings', 'Warnings'), 'h2', array('class' => 'H'));
         foreach ($Warnings as $Date => $Warning) {
             $Warning = Gdn_Format::Unserialize($Warning);
             $Reason = '';
             if (is_array($Warning)) {
                 $Reason = $Warning['Reason'];
                 $Warning = $Warning['Type'];
             }
             if ($History && $Warning != 'None') {
                 $WarningClass = "{$Warning} Historical";
             } else {
                 $WarningClass = $Warning;
             }
             if (!$History && $Warning == 'None') {
                 echo '<div class="NoWarning">' . T('Warning.NoWarnings', 'There are no current warnings for this user. ') . '</div>';
             }
             echo '<div class="Warn ' . $WarningClass . '">' . T('Warning.Level.' . $Warning, $Warning) . '<span class="WarningDate">' . Gdn_Format::Date($Date) . '</span></div>';
             if ($Reason) {
                 echo '<div class="WarningReason ' . $WarningClass . '">' . Gdn_Format::Text($Reason) . '</div>';
             }
             $History = True;
         }
         if (count($Warnings) == 0) {
             echo '<div class="NoWarning">' . T('Warning.NoWarnings', 'There are no current warnings for this user. ') . '</div>';
         }
         if (count($Warnings) > 1) {
             echo '<a class="WarningTogggleHistory" href="#">' . T('Warning.ToggleHistory', 'Toggle History') . '</a>';
         }
         echo '</div>';
     }
 }
开发者ID:Nordic-T,项目名称:Nordic-T,代码行数:38,代码来源:default.php

示例2: GetRolesFromHandshake

   public function GetRolesFromHandshake($Handshake) {
      static $UserOptional = NULL;

      if (is_null($UserOptional)) {
         $UserOptional = Gdn_Format::Unserialize(ArrayValue('UserOptional', $Handshake, array()));
      }
      return ArrayValue('Roles', $UserOptional, '');
   }
开发者ID:real-chocopanda,项目名称:Proxyconnect,代码行数:8,代码来源:class.proxyauthenticator.php

示例3: controller_index

 public function controller_index($Sender)
 {
     $Sender->Permission(array('Garden.Profiles.Edit'));
     $Args = $Sender->RequestArgs;
     if (sizeof($Args) < 2) {
         $Args = array_merge($Args, array(0, 0));
     } elseif (sizeof($Args) > 2) {
         $Args = array_slice($Args, 0, 2);
     }
     list($UserReference, $Username) = $Args;
     $canEditSignatures = CheckPermission('Plugins.Signatures.Edit');
     // Normalize no image config setting
     if (C('Plugins.Signatures.MaxNumberImages') === 0 || C('Plugins.Signatures.MaxNumberImages') === '0') {
         SaveToConfig('Plugins.Signatures.MaxNumberImages', 'None');
     }
     $Sender->GetUserInfo($UserReference, $Username);
     $UserPrefs = Gdn_Format::Unserialize($Sender->User->Preferences);
     if (!is_array($UserPrefs)) {
         $UserPrefs = array();
     }
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigArray = array('Plugin.Signatures.Sig' => NULL, 'Plugin.Signatures.HideAll' => NULL, 'Plugin.Signatures.HideImages' => NULL, 'Plugin.Signatures.HideMobile' => NULL, 'Plugin.Signatures.Format' => NULL);
     $SigUserID = $ViewingUserID = Gdn::Session()->UserID;
     if ($Sender->User->UserID != $ViewingUserID) {
         $Sender->Permission(array('Garden.Users.Edit', 'Moderation.Signatures.Edit'), FALSE);
         $SigUserID = $Sender->User->UserID;
         $canEditSignatures = true;
     }
     $Sender->SetData('CanEdit', $canEditSignatures);
     $Sender->SetData('Plugin-Signatures-ForceEditing', $SigUserID == Gdn::Session()->UserID ? FALSE : $Sender->User->Name);
     $UserMeta = $this->GetUserMeta($SigUserID, '%');
     if ($Sender->Form->AuthenticatedPostBack() === FALSE && is_array($UserMeta)) {
         $ConfigArray = array_merge($ConfigArray, $UserMeta);
     }
     $ConfigurationModel->SetField($ConfigArray);
     // Set the model on the form.
     $Sender->Form->SetModel($ConfigurationModel);
     $Data = $ConfigurationModel->Data;
     $Sender->SetData('Signature', $Data);
     $this->SetSignatureRules($Sender);
     // Form submission handling.
     if ($Sender->Form->AuthenticatedPostBack()) {
         $Values = $Sender->Form->FormValues();
         if ($canEditSignatures) {
             $Values['Plugin.Signatures.Sig'] = GetValue('Body', $Values, NULL);
             $Values['Plugin.Signatures.Format'] = GetValue('Format', $Values, NULL);
         }
         //$this->StripLineBreaks($Values['Plugin.Signatures.Sig']);
         $FrmValues = array_intersect_key($Values, $ConfigArray);
         if (sizeof($FrmValues)) {
             if (!GetValue($this->MakeMetaKey('Sig'), $FrmValues)) {
                 // Delete the signature.
                 $FrmValues[$this->MakeMetaKey('Sig')] = NULL;
                 $FrmValues[$this->MakeMetaKey('Format')] = NULL;
             }
             $this->CrossCheckSignature($Values, $Sender);
             if ($Sender->Form->ErrorCount() == 0) {
                 foreach ($FrmValues as $UserMetaKey => $UserMetaValue) {
                     $Key = $this->TrimMetaKey($UserMetaKey);
                     switch ($Key) {
                         case 'Format':
                             if (strcasecmp($UserMetaValue, 'Raw') == 0) {
                                 $UserMetaValue = NULL;
                             }
                             // don't allow raw signatures.
                             break;
                     }
                     $this->SetUserMeta($SigUserID, $Key, $UserMetaValue);
                 }
                 $Sender->InformMessage(T("Your changes have been saved."));
             }
         }
     } else {
         // Load form data.
         $Data['Body'] = GetValue('Plugin.Signatures.Sig', $Data);
         $Data['Format'] = GetValue('Plugin.Signatures.Format', $Data) ?: Gdn_Format::DefaultFormat();
         // Apply the config settings to the form.
         $Sender->Form->SetData($Data);
     }
     $Sender->Render('signature', '', 'plugins/Signatures');
 }
开发者ID:jamesinc,项目名称:addons,代码行数:82,代码来源:class.signatures.plugin.php

示例4: ProfileController_Signature_Create

 public function ProfileController_Signature_Create(&$Sender)
 {
     if (!C('Plugins.Signatures.Enabled')) {
         return;
     }
     $Args = $Sender->RequestArgs;
     if (sizeof($Args) < 2) {
         $Args = array_merge($Args, array(0, 0));
     } elseif (sizeof($Args) > 2) {
         $Args = array_slice($Args, 0, 2);
     }
     list($UserReference, $Username) = $Args;
     $Sender->Permission('Garden.SignIn.Allow');
     $Sender->GetUserInfo($UserReference, $Username);
     $UserPrefs = Gdn_Format::Unserialize($Sender->User->Preferences);
     if (!is_array($UserPrefs)) {
         $UserPrefs = array();
     }
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigArray = array('Plugin.Signatures.Sig' => NULL, 'Plugin.Signatures.HideAll' => NULL, 'Plugin.Signatures.HideImages' => NULL);
     $SigUserID = $ViewingUserID = Gdn::Session()->UserID;
     if ($Sender->User->UserID != $ViewingUserID) {
         $Sender->Permission('Garden.Users.Edit');
         $SigUserID = $Sender->User->UserID;
     }
     $Sender->SetData('Plugin-Signatures-ForceEditing', $SigUserID == Gdn::Session()->UserID ? FALSE : $Sender->User->Name);
     // TIM: Waiting for RC3...
     $UserMeta = $this->GetUserMeta($SigUserID, '%');
     // TIM: Leaving this here until RC3+
     // $UserMeta = $this->_GetUserSignatureData($SigUserID);
     //
     if ($Sender->Form->AuthenticatedPostBack() === FALSE && is_array($UserMeta)) {
         $ConfigArray = array_merge($ConfigArray, $UserMeta);
     }
     $ConfigurationModel->SetField($ConfigArray);
     // Set the model on the form.
     $Sender->Form->SetModel($ConfigurationModel);
     // If seeing the form for the first time...
     if ($Sender->Form->AuthenticatedPostBack() === FALSE) {
         // Apply the config settings to the form.
         $Sender->Form->SetData($ConfigurationModel->Data);
     } else {
         $Values = $Sender->Form->FormValues();
         $FrmValues = array_intersect_key($Values, $ConfigArray);
         if (sizeof($FrmValues)) {
             foreach ($FrmValues as $UserMetaKey => $UserMetaValue) {
                 $this->SetUserMeta($SigUserID, $this->TrimMetaKey($UserMetaKey), $UserMetaValue);
                 /*
                                try {
                                   Gdn::SQL()->Insert('UserMeta', array(
                                         'UserID' => $SigUserID,
                                         'Name'   => $UserMetaKey,
                                         'Value'  => $UserMetaValue
                                      ));
                                } catch (Exception $e) {
                                   Gdn::SQL()
                                      ->Update('UserMeta')
                                      ->Set('Value', $UserMetaValue)
                                      ->Where('UserID', $SigUserID)
                                      ->Where('Name', $UserMetaKey)
                                      ->Put();
                                }
                 */
             }
         }
         $Sender->StatusMessage = T("Your changes have been saved.");
     }
     $Sender->Render($this->GetView('signature.php'));
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:70,代码来源:class.signatures.plugin.php

示例5: SaveToSerializedColumn

 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)) {
         $Name = array($Name => $Value);
     }
     // Assign the new value(s)
     $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:seedbank,项目名称:old-repo,代码行数:27,代码来源:class.model.php

示例6: Preferences

   public function Preferences($UserReference = '', $Username = '', $UserID = '') {
      $Session = Gdn::Session();
      $this->Permission('Garden.SignIn.Allow');
      $this->GetUserInfo($UserReference, $Username, $UserID);
		$UserPrefs = Gdn_Format::Unserialize($this->User->Preferences);
      if (!is_array($UserPrefs))
         $UserPrefs = array();
      $MetaPrefs = UserModel::GetMeta($this->User->UserID, 'Preferences.%', 'Preferences.');


      // Define the preferences to be managed
      $this->Preferences = array(
         '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->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 = GetValue('0', $NameParts);
				$SubName = GetValue('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);
				}
			}
		}
		
      if ($this->User->UserID != $Session->UserID)
         $this->Permission('Garden.Users.Edit');

      // Loop the preferences, setting defaults from the configuration.
      $Defaults = 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')
               $Defaults[$Pref] = GetValue($Pref, $MetaPrefs, FALSE);
            else
               $Defaults[$Pref] = GetValue($Pref, $UserPrefs, C('Preferences.'.$Pref, '0'));
         }
      }
         
      if ($this->Form->AuthenticatedPostBack() === FALSE) {
         $this->Form->SetData($Defaults);
      } else {
         // Get, assign, and save the preferences.
         $Meta = array();
         foreach ($this->Preferences as $PrefGroup => $Prefs) {
            foreach ($Prefs as $Pref => $Desc) {
               $Location = 'Prefs';
               if (is_array($Desc))
                  list($Desc, $Location) = $Desc;

               $Value = $this->Form->GetValue($Pref, FALSE);

               if ($Location == 'Meta') {
                  $Meta[$Pref] = $Value ? $Value : NULL;
                  if ($Value)
                     $UserPrefs[$Pref] = $Value; // dup for notifications code.
               } else {
                  if (!$Defaults[$Pref] && !$Value)
                     unset($UserPrefs[$Pref]); // save some space
                  else
                     $UserPrefs[$Pref] = $Value;
               }
            }
         }
         $this->UserModel->SavePreference($this->User->UserID, $UserPrefs);
         UserModel::SetMeta($this->User->UserID, $Meta, 'Preferences.');
			$this->InformMessage('<span class="InformSprite Check"></span>'.T('Your preferences have been saved.'), 'Dismissable AutoDismiss HasSprite');
      }
//.........这里部分代码省略.........
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:101,代码来源:class.profilecontroller.php

示例7: Themes

 /**
  * Theme management screen.
  */
 public function Themes($ThemeFolder = '', $TransientKey = '')
 {
     $this->AddJsFile('addons.js');
     $this->SetData('Title', T('Themes'));
     $this->Permission('Garden.Themes.Manage');
     $this->AddSideMenu('dashboard/settings/themes');
     $Session = Gdn::Session();
     $ThemeManager = new Gdn_ThemeManager();
     $AvailableThemes = $ThemeManager->AvailableThemes();
     $this->SetData('EnabledThemeFolder', $ThemeManager->EnabledTheme());
     $this->SetData('EnabledTheme', $ThemeManager->EnabledThemeInfo());
     $this->SetData('EnabledThemeName', $this->Data('EnabledTheme.Name', $this->Data('EnabledTheme.Folder')));
     // Loop through all of the available themes and mark them if they have an update available
     // Retrieve the list of themes that require updates from the config file
     $RequiredUpdates = Gdn_Format::Unserialize(Gdn::Config('Garden.RequiredUpdates', ''));
     if (is_array($RequiredUpdates)) {
         foreach ($RequiredUpdates as $UpdateInfo) {
             if (is_object($UpdateInfo)) {
                 $UpdateInfo = Gdn_Format::ObjectAsArray($UpdateInfo);
             }
             $NewVersion = ArrayValue('Version', $UpdateInfo, '');
             $Name = ArrayValue('Name', $UpdateInfo, '');
             $Type = ArrayValue('Type', $UpdateInfo, '');
             foreach ($AvailableThemes as $Theme => $Info) {
                 $CurrentName = ArrayValue('Name', $Info, $Theme);
                 if ($CurrentName == $Name && $Type == 'Theme') {
                     $Info['NewVersion'] = $NewVersion;
                     $AvailableThemes[$Theme] = $Info;
                 }
             }
         }
     }
     $this->SetData('AvailableThemes', $AvailableThemes);
     if ($Session->ValidateTransientKey($TransientKey) && $ThemeFolder != '') {
         try {
             foreach ($this->Data('AvailableThemes') as $ThemeName => $ThemeInfo) {
                 if ($ThemeInfo['Folder'] == $ThemeFolder) {
                     $Session->SetPreference(array('PreviewThemeName' => '', 'PreviewThemeFolder' => ''));
                     // Clear out the preview
                     $ThemeManager->EnableTheme($ThemeName);
                     $this->EventArguments['ThemeName'] = $ThemeName;
                     $this->EventArguments['ThemeInfo'] = $ThemeInfo;
                     $this->FireEvent('AfterEnableTheme');
                 }
             }
         } catch (Exception $Ex) {
             $this->Form->AddError($Ex);
         }
         if ($this->Form->ErrorCount() == 0) {
             Redirect('/settings/themes');
         }
     }
     $this->Render();
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:57,代码来源:class.settingscontroller.php

示例8: GetAttribute

 public function GetAttribute($UserID, $Attribute, $DefaultValue = FALSE)
 {
     $Data = $this->SQL->Select('Attributes')->From('User')->Where('UserID', $UserID)->Get()->FirstRow();
     if ($Data !== FALSE) {
         $Attributes = Gdn_Format::Unserialize($Data->Attributes);
         if (is_array($Attributes)) {
             return ArrayValue($Attribute, $Attributes, $DefaultValue);
         }
     }
     return $DefaultValue;
 }
开发者ID:TiGR,项目名称:Garden,代码行数:11,代码来源:class.usermodel.php

示例9: 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 (GetValue('Deleted', $UserData)) {
         return FALSE;
     }
     $PasswordHash = new Gdn_PasswordHash();
     $HashMethod = GetValue('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:statico,项目名称:openshift-origin-vanillaforums,代码行数:68,代码来源:class.usermodel.php

示例10: 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);
             }
             $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) ? ArrayValue('TransientKey', $this->_Attributes) : FALSE;
             if ($this->_TransientKey === FALSE) {
                 $this->_TransientKey = $UserModel->SetTransientKey($this->UserID);
             }
             // Save any visit-level information.
             $UserModel->UpdateVisit($this->UserID);
         } else {
             $this->UserID = 0;
             $this->User = FALSE;
             if ($SetIdentity) {
                 Gdn::Authenticator()->SetIdentity(NULL);
             }
         }
     }
     // Load guest permissions if necessary
     if ($this->UserID == 0) {
         $this->_Permissions = Gdn_Format::Unserialize($UserModel->DefinePermissions(0));
     }
 }
开发者ID:rnovino,项目名称:Garden,代码行数:48,代码来源:class.session.php

示例11: 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)
 {
     $Path = explode('.', $Name);
     $Value = $this->_Data;
     $Count = count($Path);
     for ($i = 0; $i < $Count; ++$i) {
         if (is_array($Value) && array_key_exists($Path[$i], $Value)) {
             $Value = $Value[$Path[$i]];
         } else {
             return $DefaultValue;
         }
     }
     if (is_string($Value)) {
         $Result = Gdn_Format::Unserialize($Value);
     } else {
         $Result = $Value;
     }
     return $Result;
 }
开发者ID:sheldon,项目名称:Garden,代码行数:28,代码来源:class.configuration.php

示例12: 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:3marproof,项目名称:vanilla,代码行数:32,代码来源:class.configuration.php

示例13: QueueNotification

 /**
  * Queue a notification for sending.
  *
  * @since 2.0.17
  * @access public
  * @param int $ActivityID
  * @param string $Story
  * @param string $Position
  * @param bool $Force
  */
 public function QueueNotification($ActivityID, $Story = '', $Position = 'last', $Force = FALSE)
 {
     $Activity = $this->GetID($ActivityID);
     if (!is_object($Activity)) {
         return;
     }
     $Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE);
     // If this is a comment on another activity, fudge the activity a bit so that everything appears properly.
     if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) {
         $CommentActivity = $this->GetID($Activity->CommentActivityID);
         $Activity->RegardingUserID = $CommentActivity->RegardingUserID;
         $Activity->Route = '/activity/item/' . $Activity->CommentActivityID;
     }
     $User = Gdn::UserModel()->GetID($Activity->RegardingUserID, DATASET_TYPE_OBJECT);
     //$this->SQL->Select('UserID, Name, Email, Preferences')->From('User')->Where('UserID', $Activity->RegardingUserID)->Get()->FirstRow();
     if ($User) {
         if ($Force) {
             $Preference = $Force;
         } else {
             $Preferences = Gdn_Format::Unserialize($User->Preferences);
             $ConfigPreference = C('Preferences.Email.' . $Activity->ActivityType, '0');
             if ($ConfigPreference !== FALSE) {
                 $Preference = ArrayValue('Email.' . $Activity->ActivityType, $Preferences, $ConfigPreference);
             } else {
                 $Preference = FALSE;
             }
         }
         if ($Preference) {
             $ActivityHeadline = Gdn_Format::Text(Gdn_Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID), FALSE);
             $Email = new Gdn_Email();
             $Email->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $ActivityHeadline));
             $Email->To($User->Email, $User->Name);
             $Message = sprintf($Story == '' ? T('EmailNotification', "%1\$s\n\n%2\$s") : T('EmailStoryNotification', "%3\$s\n\n%2\$s"), $ActivityHeadline, ExternalUrl($Activity->Route == '' ? '/' : $Activity->Route), $Story);
             $Email->Message($Message);
             if (!array_key_exists($User->UserID, $this->_NotificationQueue)) {
                 $this->_NotificationQueue[$User->UserID] = array();
             }
             $Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity->Route, 'Story' => $Story, 'Headline' => $ActivityHeadline, 'Activity' => $Activity);
             if ($Position == 'first') {
                 $this->_NotificationQueue[$User->UserID] = array_merge(array($Notification), $this->_NotificationQueue[$User->UserID]);
             } else {
                 $this->_NotificationQueue[$User->UserID][] = $Notification;
             }
         }
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:56,代码来源:class.activitymodel.php

示例14: DiscussionController_BeforeDiscussionRender_Handler

 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 = GetValue('Quotes.Folding', $UserPrefs, '1');
     $Sender->AddDefinition('QuotesFolding', $QuoteFolding);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:12,代码来源:class.quotes.plugin.php

示例15: Themes

 /**
  * Theme management screen.
  */
 public function Themes($ThemeFolder = '', $TransientKey = '')
 {
     $this->Title(T('Themes'));
     $this->Permission('Garden.Themes.Manage');
     $this->AddSideMenu('dashboard/settings/themes');
     $Session = Gdn::Session();
     $ThemeManager = new Gdn_ThemeManager();
     $this->AvailableThemes = $ThemeManager->AvailableThemes();
     $this->EnabledThemeFolder = $ThemeManager->EnabledTheme();
     $this->EnabledTheme = $ThemeManager->EnabledThemeInfo();
     $Name = array_keys($this->EnabledTheme);
     $Name = ArrayValue(0, $Name, 'undefined');
     $this->EnabledTheme = ArrayValue($Name, $this->EnabledTheme);
     $this->EnabledThemeName = ArrayValue('Name', $this->EnabledTheme, $Name);
     // Loop through all of the available themes and mark them if they have an update available
     // Retrieve the list of themes that require updates from the config file
     $RequiredUpdates = Gdn_Format::Unserialize(Gdn::Config('Garden.RequiredUpdates', ''));
     if (is_array($RequiredUpdates)) {
         foreach ($RequiredUpdates as $UpdateInfo) {
             if (is_object($UpdateInfo)) {
                 $UpdateInfo = Gdn_Format::ObjectAsArray($UpdateInfo);
             }
             $NewVersion = ArrayValue('Version', $UpdateInfo, '');
             $Name = ArrayValue('Name', $UpdateInfo, '');
             $Type = ArrayValue('Type', $UpdateInfo, '');
             foreach ($this->AvailableThemes as $Theme => $Info) {
                 $CurrentName = ArrayValue('Name', $Info, $Theme);
                 if ($CurrentName == $Name && $Type == 'Theme') {
                     $Info['NewVersion'] = $NewVersion;
                     $this->AvailableThemes[$Theme] = $Info;
                 }
             }
         }
     }
     if ($Session->ValidateTransientKey($TransientKey) && $ThemeFolder != '') {
         try {
             foreach ($this->AvailableThemes as $ThemeName => $ThemeInfo) {
                 if ($ThemeInfo['Folder'] == $ThemeFolder) {
                     $Session->SetPreference('PreviewTheme', '');
                     // Clear out the preview
                     $Test = ProxyRequest(Url('/dashboard/settings/testaddon/Theme/' . $ThemeName . '/' . $Session->TransientKey() . '?DeliveryType=JSON', TRUE));
                     if ($Test != 'Success') {
                         $this->Form->AddError(sprintf(T('The theme could not be enabled because it generated a fatal error: <pre>%s</pre>'), strip_tags($Test)));
                     } else {
                         $ThemeManager->EnableTheme($ThemeName);
                     }
                 }
             }
         } catch (Exception $e) {
             $this->Form->AddError(strip_tags($e->getMessage()));
         }
         if ($this->Form->ErrorCount() == 0) {
             Redirect('/settings/themes');
         }
     }
     $this->Render();
 }
开发者ID:sheldon,项目名称:Garden,代码行数:60,代码来源:class.settingscontroller.php


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