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


PHP arrayTranslate函数代码示例

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


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

示例1: getOpenID

 /**
  *
  *
  * @return LightOpenID
  */
 public function getOpenID()
 {
     $OpenID = new LightOpenID();
     if ($url = Gdn::request()->get('url')) {
         if (!filter_var($url, FILTER_VALIDATE_URL)) {
             throw new Gdn_UserException(sprintf(t('ValidateUrl'), 'OpenID'), 400);
         }
         // Don't allow open ID on a non-standard scheme.
         $scheme = parse_url($url, PHP_URL_SCHEME);
         if (!in_array($scheme, array('http', 'https'))) {
             throw new Gdn_UserException(sprintf(t('ValidateUrl'), 'OpenID'), 400);
         }
         // Don't allow open ID on a non-standard port.
         $port = parse_url($url, PHP_URL_PORT);
         if ($port && !in_array($port, array(80, 8080, 443))) {
             throw new Gdn_UserException(t('OpenID is not allowed on non-standard ports.'));
         }
         $OpenID->identity = $url;
     }
     $Url = url('/entry/connect/openid', true);
     $UrlParts = explode('?', $Url);
     parse_str(val(1, $UrlParts, ''), $Query);
     $Query = array_merge($Query, arrayTranslate($_GET, array('display', 'Target')));
     $OpenID->returnUrl = $UrlParts[0] . '?' . http_build_query($Query);
     $OpenID->required = array('contact/email', 'namePerson/first', 'namePerson/last', 'pref/language');
     $this->EventArguments['OpenID'] = $OpenID;
     $this->fireEvent('GetOpenID');
     return $OpenID;
 }
开发者ID:korelstar,项目名称:vanilla,代码行数:34,代码来源:class.openid.plugin.php

示例2: smarty_function_breadcrumbs

/**
 * Render a breadcrumb trail for the user based on the page they are on.
 *
 * @param array $Params
 * @param object $Smarty
 * @return string
 */
function smarty_function_breadcrumbs($Params, &$Smarty)
{
    $Breadcrumbs = $Smarty->Controller->data('Breadcrumbs');
    if (!is_array($Breadcrumbs)) {
        $Breadcrumbs = array();
    }
    $Options = arrayTranslate($Params, array('homeurl' => 'HomeUrl', 'hidelast' => 'HideLast'));
    return Gdn_Theme::breadcrumbs($Breadcrumbs, val('homelink', $Params, true), $Options);
}
开发者ID:bodogbo,项目名称:vanilla,代码行数:16,代码来源:function.breadcrumbs.php

示例3: addCategoryColumns

 /**
  * Modifies category data before it is returned.
  *
  * Adds CountAllDiscussions column to each category representing the sum of
  * discussions within this category as well as all subcategories.
  *
  * @since 2.0.17
  * @access public
  *
  * @param object $Data SQL result.
  */
 public static function addCategoryColumns($Data)
 {
     $Result =& $Data->result();
     $Result2 = $Result;
     foreach ($Result as &$Category) {
         if (!property_exists($Category, 'CountAllDiscussions')) {
             $Category->CountAllDiscussions = $Category->CountDiscussions;
         }
         if (!property_exists($Category, 'CountAllComments')) {
             $Category->CountAllComments = $Category->CountComments;
         }
         // Calculate the following field.
         $Following = !((bool) val('Archived', $Category) || (bool) val('Unfollow', $Category));
         $Category->Following = $Following;
         $DateMarkedRead = val('DateMarkedRead', $Category);
         $UserDateMarkedRead = val('UserDateMarkedRead', $Category);
         if (!$DateMarkedRead) {
             $DateMarkedRead = $UserDateMarkedRead;
         } elseif ($UserDateMarkedRead && Gdn_Format::toTimestamp($UserDateMarkedRead) > Gdn_Format::ToTimeStamp($DateMarkedRead)) {
             $DateMarkedRead = $UserDateMarkedRead;
         }
         // Set appropriate Last* columns.
         setValue('LastTitle', $Category, val('LastDiscussionTitle', $Category, null));
         $LastDateInserted = val('LastDateInserted', $Category, null);
         if (val('LastCommentUserID', $Category) == null) {
             setValue('LastCommentUserID', $Category, val('LastDiscussionUserID', $Category, null));
             setValue('DateLastComment', $Category, val('DateLastDiscussion', $Category, null));
             setValue('LastUserID', $Category, val('LastDiscussionUserID', $Category, null));
             $LastDiscussion = arrayTranslate($Category, array('LastDiscussionID' => 'DiscussionID', 'CategoryID' => 'CategoryID', 'LastTitle' => 'Name'));
             setValue('LastUrl', $Category, DiscussionUrl($LastDiscussion, false, '/') . '#latest');
             if (is_null($LastDateInserted)) {
                 setValue('LastDateInserted', $Category, val('DateLastDiscussion', $Category, null));
             }
         } else {
             $LastDiscussion = arrayTranslate($Category, array('LastDiscussionID' => 'DiscussionID', 'CategoryID' => 'CategoryID', 'LastTitle' => 'Name'));
             setValue('LastUserID', $Category, val('LastCommentUserID', $Category, null));
             setValue('LastUrl', $Category, DiscussionUrl($LastDiscussion, false, '/') . '#latest');
             if (is_null($LastDateInserted)) {
                 setValue('LastDateInserted', $Category, val('DateLastComment', $Category, null));
             }
         }
         $LastDateInserted = val('LastDateInserted', $Category, null);
         if ($DateMarkedRead) {
             if ($LastDateInserted) {
                 $Category->Read = Gdn_Format::toTimestamp($DateMarkedRead) >= Gdn_Format::toTimestamp($LastDateInserted);
             } else {
                 $Category->Read = true;
             }
         } else {
             $Category->Read = false;
         }
         foreach ($Result2 as $Category2) {
             if ($Category2->TreeLeft > $Category->TreeLeft && $Category2->TreeRight < $Category->TreeRight) {
                 $Category->CountAllDiscussions += $Category2->CountDiscussions;
                 $Category->CountAllComments += $Category2->CountComments;
             }
         }
     }
 }
开发者ID:R-J,项目名称:vanilla,代码行数:70,代码来源:class.categorymodel.php

示例4: analyzeAddon

 /**
  * Check an addon's file to extract the addon information out of it.
  *
  * @param string $Path The path to the file.
  * @param bool $ThrowError Whether or not to throw an exception if there is a problem analyzing the addon.
  * @return array An array of addon information.
  */
 public static function analyzeAddon($Path, $ThrowError = true)
 {
     if (!file_exists($Path)) {
         if ($ThrowError) {
             throw new Exception("{$Path} not found.", 404);
         }
         return false;
     }
     $Addon = [];
     $Result = [];
     $InfoPaths = array('/settings/about.php', '/default.php', '/class.*.plugin.php', '/about.php', '/definitions.php', '/index.php', 'vanilla2export.php');
     // Get the list of potential files to analyze.
     if (is_dir($Path)) {
         $Entries = self::getInfoFiles($Path, $InfoPaths);
         $DeleteEntries = false;
     } else {
         $Entries = self::getInfoZip($Path, $InfoPaths, false, $ThrowError);
         $DeleteEntries = true;
     }
     foreach ($Entries as $Entry) {
         if ($Entry['Name'] == '/index.php') {
             // This could be the core vanilla package.
             $Version = self::parseCoreVersion($Entry['Path']);
             if (!$Version) {
                 continue;
             }
             // The application was confirmed.
             $Addon = array('AddonKey' => 'vanilla', 'AddonTypeID' => ADDON_TYPE_CORE, 'Name' => 'Vanilla', 'Description' => 'Vanilla is an open-source, standards-compliant, multi-lingual, fully extensible discussion forum for the web. Anyone who has web-space that meets the requirements can download and use Vanilla for free!', 'Version' => $Version, 'License' => 'GPLv2', 'Path' => $Entry['Path']);
             break;
         } elseif ($Entry['Name'] == 'vanilla2export.php') {
             // This could be the vanilla porter.
             $Version = self::parseCoreVersion($Entry['Path']);
             if (!$Version) {
                 continue;
             }
             $Addon = array('AddonKey' => 'porter', 'AddonTypeID' => ADDON_TYPE_CORE, 'Name' => 'Vanilla Porter', 'Description' => 'Drop this script in your existing site and navigate to it in your web browser to export your existing forum data to the Vanilla 2 import format.', 'Version' => $Version, 'License' => 'GPLv2', 'Path' => $Entry['Path']);
             break;
         } else {
             // This could be an addon.
             $Info = self::parseInfoArray($Entry['Path']);
             if (!is_array($Info) && count($Info)) {
                 continue;
             }
             $Key = key($Info);
             $Variable = $Info['Variable'];
             $Info = $Info[$Key];
             // Validate the addon.
             $Name = $Entry['Name'];
             $Valid = true;
             if (!val('Name', $Info)) {
                 $Info['Name'] = $Key;
             }
             // Validate basic fields.
             $checkResult = self::checkRequiredFields($Info);
             if (count($checkResult)) {
                 $Result = array_merge($Result, $checkResult);
                 $Valid = false;
             }
             // Validate folder name matches key.
             if (isset($Entry['Base']) && strcasecmp($Entry['Base'], $Key) != 0 && $Variable != 'ThemeInfo') {
                 $Result[] = "{$Name}: The addon's key is not the same as its folder name.";
                 $Valid = false;
             }
             if (!$Valid) {
                 continue;
             }
             // The addon is valid.
             $Addon = array_merge(array('AddonKey' => $Key, 'AddonTypeID' => ''), $Info);
             switch ($Variable) {
                 case 'ApplicationInfo':
                     $Addon['AddonTypeID'] = ADDON_TYPE_APPLICATION;
                     break;
                 case 'LocaleInfo':
                     $Addon['AddonTypeID'] = ADDON_TYPE_LOCALE;
                     break;
                 case 'PluginInfo':
                     $Addon['AddonTypeID'] = ADDON_TYPE_PLUGIN;
                     break;
                 case 'ThemeInfo':
                     $Addon['AddonTypeID'] = ADDON_TYPE_THEME;
                     break;
             }
         }
     }
     if ($DeleteEntries) {
         $FolderPath = substr($Path, 0, -4);
         Gdn_FileSystem::removeFolder($FolderPath);
     }
     // Add the addon requirements.
     if (!empty($Addon)) {
         $Requirements = arrayTranslate($Addon, ['RequiredApplications' => 'Applications', 'RequiredPlugins' => 'Plugins', 'RequiredThemes' => 'Themes']);
         foreach ($Requirements as $Type => $Items) {
             if (!is_array($Items)) {
//.........这里部分代码省略.........
开发者ID:vanilla,项目名称:vanilla,代码行数:101,代码来源:class.updatemodel.php

示例5: entryController_jsConnect_create

 /**
  * An intermediate page for jsConnect that checks SSO against and then posts the information to /entry/connect.
  *
  * @param EntryController $Sender
  * @param string $Action A specific action. It can be one of the following:
  *
  * - blank: The default action.
  * - guest: There is no user signed in.
  * -
  * @param string $Target The url to redirect to after a successful connect.
  * @throws /Exception Throws an exception when the jsConnect provider is not found.
  */
 public function entryController_jsConnect_create($Sender, $Action = '', $Target = '')
 {
     $Sender->setData('_NoMessages', true);
     if ($Action) {
         if ($Action == 'guest') {
             $Sender->addDefinition('CheckPopup', true);
             $Target = $Sender->Form->getFormValue('Target', '/');
             $Sender->RedirectUrl = $Target;
             $Sender->render('JsConnect', '', 'plugins/jsconnect');
         } else {
             parse_str($Sender->Form->getFormValue('JsConnect'), $JsData);
             $Error = val('error', $JsData);
             $Message = val('message', $JsData);
             if ($Error === 'timeout' && !$Message) {
                 $Message = t('Your sso timed out.', 'Your sso timed out during the request. Please try again.');
             }
             Gdn::dispatcher()->passData('Exception', $Message ? htmlspecialchars($Message) : htmlspecialchars($Error))->dispatch('home/error');
         }
     } else {
         $client_id = $Sender->setData('client_id', $Sender->Request->get('client_id', 0));
         $Provider = self::getProvider($client_id);
         if (empty($Provider)) {
             throw NotFoundException('Provider');
         }
         $Get = arrayTranslate($Sender->Request->get(), ['client_id', 'display']);
         $Sender->addDefinition('JsAuthenticateUrl', self::connectUrl($Provider, true));
         $Sender->addJsFile('jsconnect.js', 'plugins/jsconnect');
         $Sender->setData('Title', t('Connecting...'));
         $Sender->Form->Action = url('/entry/connect/jsconnect?' . http_build_query($Get));
         $Sender->Form->addHidden('JsConnect', '');
         $Sender->Form->addHidden('Target', $Target);
         $Sender->MasterView = 'empty';
         $Sender->Render('JsConnect', '', 'plugins/jsconnect');
     }
 }
开发者ID:vanilla,项目名称:addons,代码行数:47,代码来源:class.jsconnect.plugin.php

示例6: analyzeAddon

 /**
  * Check an addon's file to extract the addon information out of it.
  *
  * @param string $Path The path to the file.
  * @param bool $Fix Whether or not to fix files that have been zipped incorrectly.
  * @return array An array of addon information.
  */
 public static function analyzeAddon($Path, $ThrowError = true)
 {
     if (!file_exists($Path)) {
         if ($ThrowError) {
             throw new Exception("{$Path} not found.", 404);
         }
         return false;
     }
     $Result = array();
     $InfoPaths = array('/settings/about.php', '/default.php', '/class.*.plugin.php', '/about.php', '/definitions.php', '/index.php', 'vanilla2export.php');
     // Get the list of potential files to analyze.
     if (is_dir($Path)) {
         $Entries = self::_GetInfoFiles($Path, $InfoPaths);
     } else {
         $Entries = self::_GetInfoZip($Path, $InfoPaths, false, $ThrowError);
         $DeleteEntries = true;
     }
     foreach ($Entries as $Entry) {
         if ($Entry['Name'] == '/index.php') {
             // This could be the core vanilla package.
             $Version = self::ParseCoreVersion($Entry['Path']);
             if (!$Version) {
                 continue;
             }
             // The application was confirmed.
             $Addon = array('AddonKey' => 'vanilla', 'AddonTypeID' => ADDON_TYPE_CORE, 'Name' => 'Vanilla', 'Description' => 'Vanilla is an open-source, standards-compliant, multi-lingual, fully extensible discussion forum for the web. Anyone who has web-space that meets the requirements can download and use Vanilla for free!', 'Version' => $Version, 'Path' => $Entry['Path']);
             break;
         } elseif ($Entry['Name'] == 'vanilla2export.php') {
             // This could be the vanilla porter.
             $Version = self::ParseCoreVersion($Entry['Path']);
             if (!$Version) {
                 continue;
             }
             $Addon = array('AddonKey' => 'porter', 'AddonTypeID' => ADDON_TYPE_CORE, 'Name' => 'Vanilla Porter', 'Description' => 'Drop this script in your existing site and navigate to it in your web browser to export your existing forum data to the Vanilla 2 import format.', 'Version' => $Version, 'Path' => $Entry['Path']);
             break;
         } else {
             // This could be an addon.
             $Info = self::ParseInfoArray($Entry['Path']);
             if (!is_array($Info) && count($Info)) {
                 continue;
             }
             $Key = key($Info);
             $Variable = $Info['Variable'];
             $Info = $Info[$Key];
             // Validate the addon.
             $Name = $Entry['Name'];
             $Valid = true;
             if (!val('Name', $Info)) {
                 $Info['Name'] = $Key;
             }
             if (!val('Description', $Info)) {
                 $Result[] = $Name . ': ' . sprintf(t('ValidateRequired'), t('Description'));
                 $Valid = false;
             }
             if (!val('Version', $Info)) {
                 $Result[] = $Name . ': ' . sprintf(t('ValidateRequired'), t('Version'));
                 $Valid = false;
             }
             if (isset($Entry['Base']) && strcasecmp($Entry['Base'], $Key) != 0 && $Variable != 'ThemeInfo') {
                 $Result[] = "{$Name}: The addon's key is not the same as its folder name.";
                 $Valid = false;
             }
             if (!$Valid) {
                 continue;
             }
             // The addon is valid.
             $Addon = array_merge(array('AddonKey' => $Key, 'AddonTypeID' => ''), $Info);
             switch ($Variable) {
                 case 'ApplicationInfo':
                     $Addon['AddonTypeID'] = ADDON_TYPE_APPLICATION;
                     break;
                 case 'LocaleInfo':
                     $Addon['AddonTypeID'] = ADDON_TYPE_LOCALE;
                     break;
                 case 'PluginInfo':
                     $Addon['AddonTypeID'] = ADDON_TYPE_PLUGIN;
                     break;
                 case 'ThemeInfo':
                     $Addon['AddonTypeID'] = ADDON_TYPE_THEME;
                     break;
             }
         }
     }
     if ($DeleteEntries) {
         $FolderPath = substr($Path, 0, -4);
         Gdn_FileSystem::RemoveFolder($FolderPath);
     }
     // Add the addon requirements.
     if ($Addon) {
         $Requirements = arrayTranslate($Addon, array('RequiredApplications' => 'Applications', 'RequiredPlugins' => 'Plugins', 'RequiredThemes' => 'Themes'));
         foreach ($Requirements as $Type => $Items) {
             if (!is_array($Items)) {
                 unset($Requirements[$Type]);
//.........这里部分代码省略.........
开发者ID:caidongyun,项目名称:vanilla,代码行数:101,代码来源:class.updatemodel.php

示例7: sendWelcomeEmail

 /**
  * Send welcome email to user.
  *
  * @param int $UserID
  * @param string $Password
  * @param string $RegisterType
  * @param array|null $AdditionalData
  * @throws Exception
  */
 public function sendWelcomeEmail($UserID, $Password, $RegisterType = 'Add', $AdditionalData = null)
 {
     $Session = Gdn::session();
     $Sender = $this->getID($Session->UserID);
     $User = $this->getID($UserID);
     if (!ValidateEmail($User->Email)) {
         return;
     }
     $AppTitle = Gdn::config('Garden.Title');
     $Email = new Gdn_Email();
     $Email->subject(sprintf(t('[%s] Welcome Aboard!'), $AppTitle));
     $Email->to($User->Email);
     $emailTemplate = $Email->getEmailTemplate();
     $Data = [];
     $Data['User'] = arrayTranslate((array) $User, ['UserID', 'Name', 'Email']);
     $Data['Sender'] = arrayTranslate((array) $Sender, ['Name', 'Email']);
     $Data['Title'] = $AppTitle;
     if (is_array($AdditionalData)) {
         $Data = array_merge($Data, $AdditionalData);
     }
     $Data['EmailKey'] = valr('Attributes.EmailKey', $User);
     $message = '<p>' . formatString(t('Hello {User.Name}!'), $Data) . ' ';
     $message .= $this->getEmailWelcome($RegisterType, $User, $Data, $Password);
     // Add the email confirmation key.
     if ($Data['EmailKey']) {
         $emailUrlFormat = '{/entry/emailconfirm,exurl,domain}/{User.UserID,rawurlencode}/{EmailKey,rawurlencode}';
         $url = formatString($emailUrlFormat, $Data);
         $message .= '<p>' . t('You need to confirm your email address before you can continue.') . '</p>';
         $emailTemplate->setButton($url, t('Confirm My Email Address'));
     } else {
         $emailTemplate->setButton(externalUrl('/'), t('Access the Site'));
     }
     $emailTemplate->setMessage($message);
     $emailTemplate->setTitle(t('Welcome Aboard!'));
     $Email->setEmailTemplate($emailTemplate);
     try {
         $Email->send();
     } catch (Exception $e) {
         if (debug()) {
             throw $e;
         }
     }
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:52,代码来源:class.usermodel.php

示例8: entryController_twauthorize_create

 /**
  *
  *
  * @param $Sender
  * @param string $Dir
  */
 public function entryController_twauthorize_create($Sender, $Dir = '')
 {
     $Query = arrayTranslate($Sender->Request->get(), array('display', 'Target'));
     $Query = http_build_query($Query);
     if ($Dir == 'profile') {
         // This is a profile connection.
         $this->redirectUri(self::profileConnecUrl());
     }
     $this->authorize($Query);
 }
开发者ID:korelstar,项目名称:vanilla,代码行数:16,代码来源:class.twitter.plugin.php

示例9: getID

 /**
  * Get meta data of a single conversation.
  *
  * @param int $ConversationID Unique ID of conversation.
  * @param string $datasetType The format of the resulting conversation.
  * @param array $options Options to modify the get. Currently supports `viewingUserID`.
  * @return array|stdClass Returns a conversation.
  */
 public function getID($ConversationID, $datasetType = false, $options = [])
 {
     if (is_numeric($datasetType)) {
         deprecated('ConversationModel->getID(int, int)', 'ConversationModel->getID(int, string, array)');
         $viewingUserID = $datasetType;
         $datasetType = false;
     } else {
         $viewingUserID = val('viewingUserID', $options);
     }
     $datasetType = $datasetType ?: DATASET_TYPE_OBJECT;
     // Get the conversation.
     $Conversation = $this->getWhere(array('ConversationID' => $ConversationID))->firstRow(DATASET_TYPE_ARRAY);
     if ($viewingUserID) {
         $Data = $this->SQL->getWhere('UserConversation', array('ConversationID' => $ConversationID, 'UserID' => $viewingUserID))->firstRow(DATASET_TYPE_ARRAY);
         // Convert the array.
         $UserConversation = arrayTranslate($Data, array('LastMessageID', 'CountReadMessages', 'DateLastViewed', 'Bookmarked'));
         $UserConversation['CountNewMessages'] = $Conversation['CountMessages'] - $Data['CountReadMessages'];
     } else {
         $UserConversation = array('CountNewMessages' => 0, 'CountReadMessages' => $Conversation['CountMessages'], 'DateLastViewed' => $Conversation['DateUpdated']);
     }
     $Conversation = array_merge($Conversation, $UserConversation);
     if ($datasetType === DATASET_TYPE_OBJECT) {
         $Conversation = (object) $Conversation;
     }
     return $Conversation;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:34,代码来源:class.conversationmodel.php

示例10: val

    echo val('Description', $Info, '');
    ?>
</td>
        </tr>
        <tr class="<?php 
    echo $RowClass;
    ?>
">
            <td class="Info"><?php 
    echo anchor(t($ToggleText), '/settings/locales/' . strtolower($ToggleText) . '/' . urlencode($Key) . '/' . $Session->TransientKey(), $ToggleText . 'Addon SmallButton');
    ?>
</td>
            <td class="Alt Info"><?php 
    $RequiredApplications = val('RequiredApplications', $Info, false);
    $RequiredPlugins = val('RequiredPlugins', $Info, false);
    $InfoItems = arrayTranslate($Info, array('Locale' => t('Locale'), 'Version' => t('Version')));
    $InfoString = ImplodeAssoc(': ', '<span>|</span>', $InfoItems);
    //            if (is_array($RequiredApplications) || is_array($RequiredPlugins)) {
    //               if ($Info != '')
    //                  $Info .= '<span>|</span>';
    //
    //               $Info .= t('Requires: ');
    //            }
    //            $i = 0;
    //            if (is_array($RequiredApplications)) {
    //               if ($i > 0)
    //                  $Info .= ', ';
    //
    //               foreach ($RequiredApplications as $RequiredApplication => $VersionInfo) {
    //                  $Info .= sprintf(t('%1$s Version %2$s'), $RequiredApplication, $VersionInfo);
    //                  ++$i;
开发者ID:caidongyun,项目名称:vanilla,代码行数:31,代码来源:locales.php

示例11: saveUser

 /**
  * Change ban data on a user (ban or unban them).
  *
  * @since 2.0.18
  * @access public
  *
  * @param array $User
  * @param bool $BannedValue Whether user is banned.
  * @param array|false $Ban An array representing the specific auto-ban.
  */
 public function saveUser($User, $BannedValue, $Ban = false)
 {
     $BannedValue = (bool) $BannedValue;
     $Banned = $User['Banned'];
     if (static::isBanned($Banned, self::BAN_AUTOMATIC) === $BannedValue) {
         return;
     }
     $NewBanned = static::setBanned($Banned, $BannedValue, self::BAN_AUTOMATIC);
     Gdn::userModel()->setField($User['UserID'], 'Banned', $NewBanned);
     $BanningUserID = Gdn::session()->UserID;
     // This is true when a session is started and the session user has a new ip address and it matches a banning rule ip address
     if ($User['UserID'] == $BanningUserID) {
         $BanningUserID = val('InsertUserID', $Ban, Gdn::userModel()->GetSystemUserID());
     }
     // Add the activity.
     $ActivityModel = new ActivityModel();
     $Activity = array('ActivityType' => 'Ban', 'ActivityUserID' => $User['UserID'], 'RegardingUserID' => $BanningUserID, 'NotifyUserID' => ActivityModel::NOTIFY_MODS);
     $BannedString = $BannedValue ? 'banned' : 'unbanned';
     if ($Ban) {
         $Activity['HeadlineFormat'] = '{ActivityUserID,user} was ' . $BannedString . ' (based on {Data.BanType}: {Data.BanValue}).';
         $Activity['Data'] = arrayTranslate($Ban, array('BanType', 'BanValue'));
         $Activity['Story'] = $Ban['Notes'];
         $Activity['RecordType'] = 'Ban';
         if (isset($Ban['BanID'])) {
             $Activity['BanID'] = $Ban['BanID'];
         }
     } else {
         $Activity['HeadlineFormat'] = '{ActivityUserID,user} was ' . $BannedString . '.';
     }
     $ActivityModel->save($Activity);
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:41,代码来源:class.banmodel.php

示例12: translateProfileResults

 /**
  *   Allow the admin to input the keys that their service uses to send data.
  *
  * @param array $rawProfile profile as it is returned from the provider.
  *
  * @return array Profile array transformed by child class or as is.
  */
 public function translateProfileResults($rawProfile = [])
 {
     $provider = $this->provider();
     $email = val('ProfileKeyEmail', $provider, 'email');
     $translatedKeys = [val('ProfileKeyEmail', $provider, 'email') => 'Email', val('ProfileKeyPhoto', $provider, 'picture') => 'Photo', val('ProfileKeyName', $provider, 'displayname') => 'Name', val('ProfileKeyFullName', $provider, 'name') => 'FullName', val('ProfileKeyUniqueID', $provider, 'user_id') => 'UniqueID'];
     $profile = arrayTranslate($rawProfile, $translatedKeys, true);
     $profile['Provider'] = $this->providerKey;
     return $profile;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:16,代码来源:class.oauth2.php

示例13: initialize

 /**
  *
  *
  * @param null $Schema
  * @throws Exception
  */
 public function initialize($Schema = null)
 {
     if ($Schema !== null) {
         $this->Schema($Schema);
     }
     $Form = $this->Form();
     if ($Form->authenticatedPostBack()) {
         // Grab the data from the form.
         $Data = array();
         $Post = $Form->formValues();
         foreach ($this->_Schema as $Row) {
             $Name = $Row['Name'];
             $Config = $Row['Config'];
             // For API calls make this a sparse save.
             if ($this->Controller()->deliveryType() === DELIVERY_TYPE_DATA && !array_key_exists($Name, $Post)) {
                 continue;
             }
             if (strtolower(val('Control', $Row)) == 'imageupload') {
                 $Form->SaveImage($Name, arrayTranslate($Row, array('Prefix', 'Size')));
             }
             $Value = $Form->getFormValue($Name);
             if ($Value == val('Default', $Value, '')) {
                 $Value = '';
             }
             $Data[$Config] = $Value;
             $this->Controller()->setData($Name, $Value);
         }
         // Save it to the config.
         saveToConfig($Data, array('RemoveEmpty' => true));
         $this->_Sender->informMessage(t('Saved'));
     } else {
         // Load the form data from the config.
         $Data = array();
         foreach ($this->_Schema as $Row) {
             $Data[$Row['Name']] = c($Row['Config'], val('Default', $Row, ''));
         }
         $Form->setData($Data);
         $this->Controller()->Data = $Data;
     }
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:46,代码来源:class.configurationmodule.php

示例14: save

 /**
  *
  *
  * @param array $Data
  * @param bool $Preference
  * @param array $Options
  * @return array
  * @throws Exception
  */
 public function save($Data, $Preference = false, $Options = array())
 {
     trace('ActivityModel->save()');
     $Activity = $Data;
     $this->_touch($Activity);
     if ($Activity['ActivityUserID'] == $Activity['NotifyUserID'] && !val('Force', $Options)) {
         trace('Skipping activity because it would notify the user of something they did.');
         return;
         // don't notify users of something they did.
     }
     // Check the user's preference.
     if ($Preference) {
         list($Popup, $Email) = self::notificationPreference($Preference, $Activity['NotifyUserID'], 'both');
         if ($Popup && !$Activity['Notified']) {
             $Activity['Notified'] = self::SENT_PENDING;
         }
         if ($Email && !$Activity['Emailed']) {
             $Activity['Emailed'] = self::SENT_PENDING;
         }
         if (!$Activity['Notified'] && !$Activity['Emailed'] && !val('Force', $Options)) {
             trace("Skipping activity because the user has no preference set.");
             return;
         }
     }
     $ActivityType = self::getActivityType($Activity['ActivityType']);
     $ActivityTypeID = val('ActivityTypeID', $ActivityType);
     if (!$ActivityTypeID) {
         trace("There is no {$ActivityType} activity type.", TRACE_WARNING);
         $ActivityType = self::getActivityType('Default');
         $ActivityTypeID = val('ActivityTypeID', $ActivityType);
     }
     $Activity['ActivityTypeID'] = $ActivityTypeID;
     $NotificationInc = 0;
     if ($Activity['NotifyUserID'] > 0 && $Activity['Notified']) {
         $NotificationInc = 1;
     }
     // Check to see if we are sharing this activity with another one.
     if ($CommentActivityID = val('CommentActivityID', $Activity['Data'])) {
         $CommentActivity = $this->getID($CommentActivityID);
         $Activity['Data']['CommentNotifyUserID'] = $CommentActivity['NotifyUserID'];
     }
     // Make sure this activity isn't a duplicate.
     if (val('CheckRecord', $Options)) {
         // Check to see if this record already notified so we don't notify multiple times.
         $Where = arrayTranslate($Activity, array('NotifyUserID', 'RecordType', 'RecordID'));
         $Where['DateUpdated >'] = Gdn_Format::toDateTime(strtotime('-2 days'));
         // index hint
         $CheckActivity = $this->SQL->getWhere('Activity', $Where)->firstRow();
         if ($CheckActivity) {
             return false;
         }
     }
     // Check to share the activity.
     if (val('Share', $Options)) {
         $this->Share($Activity);
     }
     // Group he activity.
     if ($GroupBy = val('GroupBy', $Options)) {
         $GroupBy = (array) $GroupBy;
         $Where = array();
         foreach ($GroupBy as $ColumnName) {
             $Where[$ColumnName] = $Activity[$ColumnName];
         }
         $Where['NotifyUserID'] = $Activity['NotifyUserID'];
         // Make sure to only group activities by day.
         $Where['DateInserted >'] = Gdn_Format::toDateTime(strtotime('-1 day'));
         // See if there is another activity to group these into.
         $GroupActivity = $this->SQL->getWhere('Activity', $Where)->firstRow(DATASET_TYPE_ARRAY);
         if ($GroupActivity) {
             $GroupActivity['Data'] = @unserialize($GroupActivity['Data']);
             $Activity = $this->mergeActivities($GroupActivity, $Activity);
             $NotificationInc = 0;
         }
     }
     $Delete = false;
     if ($Activity['Emailed'] == self::SENT_PENDING) {
         $this->email($Activity);
         $Delete = val('_Delete', $Activity);
     }
     $ActivityData = $Activity['Data'];
     if (isset($Activity['Data']) && is_array($Activity['Data'])) {
         $Activity['Data'] = serialize($Activity['Data']);
     }
     $this->defineSchema();
     $Activity = $this->filterSchema($Activity);
     $ActivityID = val('ActivityID', $Activity);
     if (!$ActivityID) {
         if (!$Delete) {
             $this->addInsertFields($Activity);
             touchValue('DateUpdated', $Activity, $Activity['DateInserted']);
             $this->EventArguments['Activity'] =& $Activity;
//.........这里部分代码省略.........
开发者ID:bahill,项目名称:vanilla,代码行数:101,代码来源:class.activitymodel.php

示例15: sendWelcomeEmail

 /**
  * Send welcome email to user.
  *
  * @param $UserID
  * @param $Password
  * @param string $RegisterType
  * @param null $AdditionalData
  * @throws Exception
  */
 public function sendWelcomeEmail($UserID, $Password, $RegisterType = 'Add', $AdditionalData = null)
 {
     $Session = Gdn::session();
     $Sender = $this->getID($Session->UserID);
     $User = $this->getID($UserID);
     if (!ValidateEmail($User->Email)) {
         return;
     }
     $AppTitle = Gdn::config('Garden.Title');
     $Email = new Gdn_Email();
     $Email->subject(sprintf(t('[%s] Welcome Aboard!'), $AppTitle));
     $Email->to($User->Email);
     $emailTemplate = $Email->getEmailTemplate();
     $Data = array();
     $Data['User'] = arrayTranslate((array) $User, array('UserID', 'Name', 'Email'));
     $Data['Sender'] = arrayTranslate((array) $Sender, array('Name', 'Email'));
     $Data['Title'] = $AppTitle;
     if (is_array($AdditionalData)) {
         $Data = array_merge($Data, $AdditionalData);
     }
     $Data['EmailKey'] = valr('Attributes.EmailKey', $User);
     $message = '<p>' . formatString(t('Hello {User.Name}!'), $Data) . ' ';
     switch ($RegisterType) {
         case 'Connect':
             $message .= formatString(t('You have successfully connected to {Title}.'), $Data) . ' ' . t('Find your account information below.') . '<br></p>' . '<p>' . sprintf(t('%s: %s'), t('Username'), val('Name', $User)) . '<br>' . formatString(t('Connected With: {ProviderName}'), $Data) . '</p>';
             break;
         case 'Register':
             $message .= formatString(t('You have successfully registered for an account at {Title}.'), $Data) . ' ' . t('Find your account information below.') . '<br></p>' . '<p>' . sprintf(t('%s: %s'), t('Username'), val('Name', $User)) . '<br>' . sprintf(t('%s: %s'), t('Email'), val('Email', $User)) . '</p>';
             break;
         default:
             $message .= sprintf(t('%s has created an account for you at %s.'), val('Name', $Sender), $AppTitle) . ' ' . t('Find your account information below.') . '<br></p>' . '<p>' . sprintf(t('%s: %s'), t('Email'), val('Email', $User)) . '<br>' . sprintf(t('%s: %s'), t('Password'), $Password) . '</p>';
     }
     // Add the email confirmation key.
     if ($Data['EmailKey']) {
         $emailUrlFormat = '{/entry/emailconfirm,exurl,domain}/{User.UserID,rawurlencode}/{EmailKey,rawurlencode}';
         $url = formatString($emailUrlFormat, $Data);
         $message .= '<p>' . t('You need to confirm your email address before you can continue.') . '</p>';
         $emailTemplate->setButton($url, t('Confirm My Email Address'));
     } else {
         $emailTemplate->setButton(externalUrl('/'), t('Access the Site'));
     }
     $emailTemplate->setMessage($message);
     $emailTemplate->setTitle(t('Welcome Aboard!'));
     $Email->setEmailTemplate($emailTemplate);
     $Email->send();
 }
开发者ID:bahill,项目名称:vanilla,代码行数:55,代码来源:class.usermodel.php


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