本文整理汇总了PHP中ConsolidateArrayValuesByKey函数的典型用法代码示例。如果您正苦于以下问题:PHP ConsolidateArrayValuesByKey函数的具体用法?PHP ConsolidateArrayValuesByKey怎么用?PHP ConsolidateArrayValuesByKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ConsolidateArrayValuesByKey函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ApplyTheme
public function ApplyTheme($OriginalPath, $CachePath, $InsertNames = TRUE)
{
// Get the theme settings.
$SQL = Gdn::SQL();
if (is_null($this->ThemeSettings)) {
$Data = $SQL->Get('ThemeSetting')->ResultArray();
$Data = ConsolidateArrayValuesByKey($Data, 'Name', 'Setting', '');
$this->ThemeSettings = $Data;
}
$Css = file_get_contents($OriginalPath);
// Process the urls.
$Css = preg_replace_callback(self::UrlRegEx, array($this, '_ApplyUrl'), $Css);
// Go through the css and replace its colors with the theme colors.
$Css = preg_replace_callback(self::RegEx, array($this, '_ApplyThemeSetting'), $Css);
// Insert the missing settings into the database.
if ($InsertNames) {
foreach ($this->MissingSettings as $Name => $Setting) {
$SQL->Insert('ThemeSetting', array('Name' => $Name, 'Setting' => $Setting));
}
$this->MissingSettings = array();
}
// Save the theme to the cache path.
file_put_contents($CachePath, $Css);
return $CachePath;
}
示例2: InformNotifications
/**
* Grabs all new notifications and adds them to the sender's inform queue.
*
* This method gets called by dashboard's hooks file to display new
* notifications on every pageload.
*
* @since 2.0.18
* @access public
*
* @param Gdn_Controller $Sender The object calling this method.
*/
public static function InformNotifications($Sender)
{
$Session = Gdn::Session();
if (!$Session->IsValid()) {
return;
}
$ActivityModel = new ActivityModel();
// Get five pending notifications.
$Where = array('NotifyUserID' => Gdn::Session()->UserID, 'Notified' => ActivityModel::SENT_PENDING);
// If we're in the middle of a visit only get very recent notifications.
$Where['DateUpdated >'] = Gdn_Format::ToDateTime(strtotime('-5 minutes'));
$Activities = $ActivityModel->GetWhere($Where, 0, 5)->ResultArray();
$ActivityIDs = ConsolidateArrayValuesByKey($Activities, 'ActivityID');
$ActivityModel->SetNotified($ActivityIDs);
foreach ($Activities as $Activity) {
if ($Activity['Photo']) {
$UserPhoto = Anchor(Img($Activity['Photo'], array('class' => 'ProfilePhotoMedium')), $Activity['Url'], 'Icon');
} else {
$UserPhoto = '';
}
$Excerpt = Gdn_Format::Display($Activity['Story']);
$ActivityClass = ' Activity-' . $Activity['ActivityType'];
$Sender->InformMessage($UserPhoto . Wrap($Activity['Headline'], 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . $ActivityClass . ($UserPhoto == '' ? '' : ' HasIcon'));
}
}
示例3: DefaultRoles
public function DefaultRoles()
{
$this->Permission('Garden.Roles.Manage');
$this->AddSideMenu('');
$this->Title(T('Default Roles'));
// Load roles for dropdowns.
$RoleModel = new RoleModel();
$this->SetData('RoleData', $RoleModel->Get());
if ($this->Form->AuthenticatedPostBack() === FALSE) {
// Get a list of default member roles from the config.
$DefaultRoles = C('Garden.Registration.DefaultRoles');
$this->Form->SetValue('DefaultRoles', $DefaultRoles);
// Get the guest roles.
$GuestRolesData = $RoleModel->GetByUserID(0);
$GuestRoles = ConsolidateArrayValuesByKey($GuestRolesData, 'RoleID');
$this->Form->SetValue('GuestRoles', $GuestRoles);
// The applicant role.
$ApplicantRoleID = C('Garden.Registration.ApplicantRoleID', '');
$this->Form->SetValue('ApplicantRoleID', $ApplicantRoleID);
} else {
$DefaultRoles = $this->Form->GetFormValue('DefaultRoles');
$ApplicantRoleID = $this->Form->GetFormValue('ApplicantRoleID');
SaveToConfig(array('Garden.Registration.DefaultRoles' => $DefaultRoles, 'Garden.Registration.ApplicantRoleID' => $ApplicantRoleID));
$GuestRoles = $this->Form->GetFormValue('GuestRoles');
$UserModel = new UserModel();
$UserModel->SaveRoles(0, $GuestRoles, FALSE);
$this->StatusMessage = T("Saved");
}
$this->Render();
}
示例4: GetData
public function GetData($Limit = 10) {
$this->Data = FALSE;
if (Gdn::Session()->IsValid() && C('Vanilla.Modules.ShowBookmarkedModule', TRUE)) {
$BookmarkIDs = Gdn::SQL()
->Select('DiscussionID')
->From('UserDiscussion')
->Where('UserID', Gdn::Session()->UserID)
->Where('Bookmarked', 1)
->Get()->ResultArray();
$BookmarkIDs = ConsolidateArrayValuesByKey($BookmarkIDs, 'DiscussionID');
if (count($BookmarkIDs)) {
$DiscussionModel = new DiscussionModel();
DiscussionModel::CategoryPermissions();
$DiscussionModel->SQL->WhereIn('d.DiscussionID', $BookmarkIDs);
$this->Data = $DiscussionModel->Get(
0,
$Limit
);
} else {
$this->Data = FALSE;
}
}
}
示例5: GetUserInfo
public function GetUserInfo($UserReference = '')
{
$this->Roles = array();
if ($UserReference == '') {
$Session = Gdn::Session();
$this->User = $this->UserModel->Get($Session->UserID);
} else {
$UserReference = is_numeric($UserReference) ? $UserReference : urldecode($UserReference);
$this->User = $this->UserModel->Get($UserReference);
}
if ($this->User === FALSE) {
return $this->ReDispatch('garden/home/filenotfound');
} else {
$this->RoleData = $this->UserModel->GetRoles($this->User->UserID);
if ($this->RoleData !== FALSE && $this->RoleData->NumRows() > 0) {
$this->Roles = ConsolidateArrayValuesByKey($this->RoleData->ResultArray(), 'Name');
}
}
// Make sure the userphoto module gets added to the page
$UserPhotoModule = new UserPhotoModule($this);
$UserPhotoModule->User = $this->User;
$this->AddModule($UserPhotoModule);
$this->AddSideMenu();
return TRUE;
}
示例6: GetArray
/**
* Returns an array of RoleID => RoleName pairs.
*
* @return array
*/
public function GetArray()
{
// $RoleData = $this->GetEditablePermissions();
$RoleData = $this->Get();
$RoleIDs = ConsolidateArrayValuesByKey($RoleData->ResultArray(), 'RoleID');
$RoleNames = ConsolidateArrayValuesByKey($RoleData->ResultArray(), 'Name');
return ArrayCombine($RoleIDs, $RoleNames);
}
示例7: AvailableLocales
public function AvailableLocales()
{
// Get the list of locales that are supported.
$Locales = array_unique(ConsolidateArrayValuesByKey($this->AvailableLocalePacks(), 'Locale'), SORT_STRING);
asort($Locales);
$Locales = array_combine($Locales, $Locales);
return $Locales;
}
示例8: attachBadge
protected function attachBadge($sender)
{
$roles = array();
$userModel = new UserModel();
$roleData = $userModel->GetRoles($sender->EventArguments['Author']->UserID);
if ($roleData !== FALSE && $roleData->NumRows(DATASET_TYPE_ARRAY) > 0) {
$roles = ConsolidateArrayValuesByKey($roleData->Result(), 'Name');
}
foreach ($roles as $role) {
echo '<span class="RoleBadges ' . $role . 'Badge"></span>';
}
}
示例9: ApplyBan
public function ApplyBan($NewBan = NULL, $OldBan = NULL) {
if (!$NewBan && !$OldBan)
return;
$OldUsers = array();
$OldUserIDs = array();
$NewUsers = array();
$NewUserIDs = array();
$AllBans = $this->AllBans();
if ($NewBan) {
// Get a list of users affected by the new ban.
if (isset($NewBan['BanID']))
$AllBans[$NewBan['BanID']] = $NewBan;
$NewUsers = $this->SQL
->Select('u.UserID, u.Banned')
->From('User u')
->Where($this->BanWhere($NewBan))
->Get()->ResultArray();
$NewUserIDs = ConsolidateArrayValuesByKey($NewUsers, 'UserID');
} elseif (isset($OldBan['BanID'])) {
unset($AllBans[$OldBan['BanID']]);
}
if ($OldBan) {
// Get a list of users affected by the old ban.
$OldUsers = $this->SQL
->Select('u.UserID, u.LastIPAddress, u.Name, u.Email, u.Banned')
->From('User u')
->Where($this->BanWhere($OldBan))
->Get()->ResultArray();
$OldUserIDs = ConsolidateArrayValuesByKey($OldUsers, 'UserID');
}
// Check users that need to be unbanned.
foreach ($OldUsers as $User) {
if (in_array($User['UserID'], $NewUserIDs))
continue;
// TODO check the user against the other bans.
$this->SaveUser($User, FALSE);
}
// Check users that need to be banned.
foreach ($NewUsers as $User) {
if ($User['Banned'])
continue;
$this->SaveUser($User, TRUE);
}
}
示例10: EntryController_Render_Before
/**
* @param Gdn_Controller $Sender
* @param array $Args
*/
public function EntryController_Render_Before($Sender, $Args)
{
if ($Sender->RequestMethod != 'passwordreset') {
return;
}
if (isset($Sender->Data['User'])) {
// Get all of the users with the same email.
$Email = $Sender->Data('User.Email');
$Users = Gdn::SQL()->Select('Name')->From('User')->Where('Email', $Email)->Get()->ResultArray();
$Names = ConsolidateArrayValuesByKey($Users, 'Name');
SetValue('Name', $Sender->Data['User'], implode(', ', $Names));
}
}
示例11: GetFacebookIDs
public function GetFacebookIDs($Datas, $UserIDColumn)
{
$UserIDs = array();
foreach ($Datas as $Data) {
if ($UserID = GetValue($UserIDColumn, $Data)) {
$UserIDs[] = $UserID;
} else {
$IDs = ConsolidateArrayValuesByKey($Data, $UserIDColumn);
$UserIDs = array_merge($UserIDs, $IDs);
}
}
$FbIDs = Gdn::SQL()->WhereIn('UserID', array_unique($UserIDs))->GetWhere('UserAuthentication', array('ProviderKey' => 'facebook'))->ResultArray();
$Result = ConsolidateArrayValuesByKey($FbIDs, 'UserID', 'ForeignUserKey');
return $Result;
}
示例12: GetData
public function GetData()
{
if (Gdn::Session()->IsValid()) {
$BookmarkIDs = Gdn::SQL()->Select('DiscussionID')->From('UserDiscussion')->Where('UserID', Gdn::Session()->UserID)->Where('Bookmarked', 1)->Get()->ResultArray();
$BookmarkIDs = ConsolidateArrayValuesByKey($BookmarkIDs, 'DiscussionID');
if (count($BookmarkIDs)) {
$DiscussionModel = new DiscussionModel();
DiscussionModel::CategoryPermissions();
$DiscussionModel->SQL->WhereIn('d.DiscussionID', $BookmarkIDs);
$Bookmarks = $DiscussionModel->Get(0, $this->Limit, array('w.Bookmarked' => '1'));
$this->SetData('Bookmarks', $Bookmarks);
} else {
$this->SetData('Bookmarks', new Gdn_DataSet());
}
}
}
示例13: Index
public function Index()
{
$this->AddJsFile('activity.js');
$this->Title(T('Recent Activity'));
$Session = Gdn::Session();
$this->ActivityData = $this->ActivityModel->Get();
if ($this->ActivityData->NumRows() > 0) {
$ActivityData = $this->ActivityData->ResultArray();
$ActivityIDs = ConsolidateArrayValuesByKey($ActivityData, 'ActivityID');
$this->CommentData = $this->ActivityModel->GetComments($ActivityIDs);
} else {
$this->CommentData = FALSE;
}
$this->View = 'all';
$this->Render();
}
示例14: DeleteUserData
/**
* Delete all of the Vanilla related information for a specific user.
* @param int $UserID The ID of the user to delete.
* @param array $Options An array of options:
* - DeleteMethod: One of delete, wipe, or NULL
* @since 2.1
*/
public function DeleteUserData($UserID, $Options = array(), &$Data = NULL)
{
$SQL = Gdn::SQL();
// Remove discussion watch records and drafts.
$SQL->Delete('UserDiscussion', array('UserID' => $UserID));
Gdn::UserModel()->GetDelete('Draft', array('InsertUserID' => $UserID), $Data);
// Comment deletion depends on method selected
$DeleteMethod = GetValue('DeleteMethod', $Options, 'delete');
if ($DeleteMethod == 'delete') {
// Clear out the last posts to the categories.
$SQL->Update('Category c')->Join('Discussion d', 'd.DiscussionID = c.LastDiscussionID')->Where('d.InsertUserID', $UserID)->Set('c.LastDiscussionID', NULL)->Set('c.LastCommentID', NULL)->Put();
$SQL->Update('Category c')->Join('Comment d', 'd.CommentID = c.LastCommentID')->Where('d.InsertUserID', $UserID)->Set('c.LastDiscussionID', NULL)->Set('c.LastCommentID', NULL)->Put();
// Grab all of the discussions that the user has engaged in.
$DiscussionIDs = $SQL->Select('DiscussionID')->From('Comment')->Where('InsertUserID', $UserID)->GroupBy('DiscussionID')->Get()->ResultArray();
$DiscussionIDs = ConsolidateArrayValuesByKey($DiscussionIDs, 'DiscussionID');
Gdn::UserModel()->GetDelete('Comment', array('InsertUserID' => $UserID), $Data);
// Update the comment counts.
$CommentCounts = $SQL->Select('DiscussionID')->Select('CommentID', 'count', 'CountComments')->Select('CommentID', 'max', 'LastCommentID')->WhereIn('DiscussionID', $DiscussionIDs)->GroupBy('DiscussionID')->Get('Comment')->ResultArray();
foreach ($CommentCounts as $Row) {
$SQL->Put('Discussion', array('CountComments' => $Row['CountComments'] + 1, 'LastCommentID' => $Row['LastCommentID']), array('DiscussionID' => $Row['DiscussionID']));
}
// Update the last user IDs.
$SQL->Update('Discussion d')->Join('Comment c', 'd.LastCommentID = c.CommentID', 'left')->Set('d.LastCommentUserID', 'c.InsertUserID', FALSE, FALSE)->Set('d.DateLastComment', 'c.DateInserted', FALSE, FALSE)->WhereIn('d.DiscussionID', $DiscussionIDs)->Put();
// Update the last posts.
$Discussions = $SQL->WhereIn('DiscussionID', $DiscussionIDs)->Where('LastCommentUserID', $UserID)->Get('Discussion');
// Delete the user's dicussions
Gdn::UserModel()->GetDelete('Discussion', array('InsertUserID' => $UserID), $Data);
// Update the appropriat recent posts in the categories.
$CategoryModel = new CategoryModel();
$Categories = $CategoryModel->GetWhere(array('LastDiscussionID' => NULL))->ResultArray();
foreach ($Categories as $Category) {
$CategoryModel->SetRecentPost($Category['CategoryID']);
}
} else {
if ($DeleteMethod == 'wipe') {
// Erase the user's dicussions
$SQL->Update('Discussion')->Set('Body', T('The user and all related content has been deleted.'))->Set('Format', 'Deleted')->Where('InsertUserID', $UserID)->Put();
// Erase the user's comments
$SQL->From('Comment')->Join('Discussion d', 'c.DiscussionID = d.DiscussionID')->Delete('Comment c', array('d.InsertUserID' => $UserID));
$SQL->Update('Comment')->Set('Body', T('The user and all related content has been deleted.'))->Set('Format', 'Deleted')->Where('InsertUserID', $UserID)->Put();
} else {
// Leave comments
}
}
// Remove the user's profile information related to this application
$SQL->Update('User')->Set(array('CountDiscussions' => 0, 'CountUnreadDiscussions' => 0, 'CountComments' => 0, 'CountDrafts' => 0, 'CountBookmarks' => 0))->Where('UserID', $UserID)->Put();
}
示例15: GetTutorials
/**
* Get all tutorials, or a specific one.
*/
function GetTutorials($TutorialCode = '')
{
// Define all Tutorials
$Tutorials = array(array('Code' => 'introduction', 'Name' => 'Introduction to Vanilla', 'Description' => 'This video gives you a brief overview of the Vanilla administrative dashboard and the forum itself.', 'VideoID' => '31043422'), array('Code' => 'using-the-forum', 'Name' => 'Using the Forum', 'Description' => 'Learn how to start, announce, close, edit and delete discussions and comments.', 'VideoID' => '31502992'), array('Code' => 'private-conversations', 'Name' => 'Private Conversations', 'Description' => 'Learn how to start new private conversations and add people to them.', 'VideoID' => '31498383'), array('Code' => 'user-profiles', 'Name' => 'User Profiles', 'Description' => 'Learn how to use and manage your user profile. ', 'VideoID' => '31499266'), array('Code' => 'appearance', 'Name' => 'Changing the appearance of your forum', 'Description' => 'This tutorial takes you through the "Appearance" section of the Vanilla Forums administrative dashboard.', 'VideoID' => '31089641'), array('Code' => 'roles-and-permissions', 'Name' => 'Managing Roles and Permissions in Vanilla', 'Description' => 'This tutorial walks you through how to create new roles and how to use permissions.', 'VideoID' => '31091056'), array('Code' => 'users', 'Name' => 'Finding & Managing Users', 'Description' => 'This tutorial shows you how to search for and manage users.', 'VideoID' => '31094514'), array('Code' => 'category-management-and-advanced-settings', 'Name' => 'Category Management & Advanced Settings', 'Description' => 'Learn how to add, edit, and manage categories. Also learn about advanced forum settings.', 'VideoID' => '31492046'), array('Code' => 'user-registration', 'Name' => 'User Registration', 'Description' => 'Learn to control how new users get into your community.', 'VideoID' => '31493119'));
// Default Thumbnails
$Thumbnail = Asset('applications/dashboard/design/images/help-tn-200.jpg');
$LargeThumbnail = Asset('applications/dashboard/design/images/help-tn-640.jpg');
for ($i = 0; $i < count($Tutorials); $i++) {
$Tutorials[$i]['Thumbnail'] = $Thumbnail;
$Tutorials[$i]['LargeThumbnail'] = $LargeThumbnail;
}
if ($TutorialCode != '') {
$Keys = ConsolidateArrayValuesByKey($Tutorials, 'Code');
$Index = array_search($TutorialCode, $Keys);
if ($Index === FALSE) {
return FALSE;
}
// Not found!
// Found it, so define it's thumbnail location
$Tutorial = GetValue($Index, $Tutorials);
$VideoID = GetValue('VideoID', $Tutorial);
try {
$Vimeo = unserialize(file_get_contents("http://vimeo.com/api/v2/video/" . $Tutorial['VideoID'] . ".php"));
$Tutorial['Thumbnail'] = GetValue('thumbnail_medium', GetValue('0', $Vimeo));
$Tutorial['LargeThumbnail'] = GetValue('thumbnail_large', GetValue('0', $Vimeo));
} catch (Exception $Ex) {
// Do nothing
}
return $Tutorial;
} else {
// Loop through each tutorial populating the thumbnail image location
try {
foreach ($Tutorials as $Key => $Tutorial) {
$Vimeo = unserialize(file_get_contents("http://vimeo.com/api/v2/video/" . $Tutorial['VideoID'] . ".php"));
$Tutorials[$Key]['Thumbnail'] = GetValue('thumbnail_medium', GetValue('0', $Vimeo));
$Tutorials[$Key]['LargeThumbnail'] = GetValue('thumbnail_large', GetValue('0', $Vimeo));
}
} catch (Exception $Ex) {
// Do nothing
}
return $Tutorials;
}
}