• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Gdn_DataSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __get

 public function __get($Name)
 {
     switch ($Name) {
         case 'CommentData':
             Deprecated('ActivityController->CommentData', "ActivityController->Data('Activities')");
             $Result = new Gdn_DataSet(array(), DATASET_TYPE_OBJECT);
             return $Result;
         case 'ActivityData':
             Deprecated('ActivityController->ActivityData', "ActivityController->Data('Activities')");
             $Result = new Gdn_DataSet($this->Data('Activities'), DATASET_TYPE_ARRAY);
             $Result->DatasetType(DATASET_TYPE_OBJECT);
             return $Result;
     }
 }
开发者ID:statico,项目名称:openshift-origin-vanillaforums,代码行数:14,代码来源:class.activitycontroller.php


示例2: PreloadLikes

 public function PreloadLikes(Gdn_DataSet $Comments)
 {
     $cache = array();
     while ($CommentID = $Comments->Value('CommentID', FALSE)) {
         $cache[] = $CommentID;
     }
     if (!empty($cache)) {
         $Likes = $this->SQL->Select()->From($this->Name)->WhereIn('CommentID', $cache)->OrderBy('CommentID')->Get()->Result(DATASET_TYPE_OBJECT);
         foreach ($Likes as $Like) {
             if (!$this->Cache[$Like->CommentID]) {
                 $this->Cache[$Like->CommentID] = array();
             }
             $this->Cache[$Like->CommentID][] = $Like;
         }
     }
 }
开发者ID:Nordic-T,项目名称:vanilla-plugins,代码行数:16,代码来源:LikeModel.php


示例3: array

   public static function &AllBans() {
      if (!self::$_AllBans) {
         self::$_AllBans = Gdn::SQL()->Get('Ban')->ResultArray();
         self::$_AllBans = Gdn_DataSet::Index(self::$_AllBans, array('BanID'));
      }
//      $AllBans =& self::$_AllBans;
      return self::$_AllBans;
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:8,代码来源:class.banmodel.php


示例4: array

 /**
  * Get and store list of current bans.
  *
  * @since 2.0.18
  * @access public
  */
 public static function &allBans()
 {
     if (!self::$_AllBans) {
         self::$_AllBans = Gdn::sql()->get('Ban')->resultArray();
         self::$_AllBans = Gdn_DataSet::index(self::$_AllBans, array('BanID'));
     }
     //      $AllBans =& self::$_AllBans;
     return self::$_AllBans;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:15,代码来源:class.banmodel.php


示例5: Search

 public function Search($Search, $Offset = 0, $Limit = 20)
 {
     $BaseUrl = C('Plugins.Solr.SearchUrl', 'http://localhost:8983/solr/select/?');
     if (!$BaseUrl) {
         throw new Gdn_UserException("The search url has not been configured.");
     }
     if (!$Search) {
         return array();
     }
     // Escepe the search.
     $Search = preg_replace('`([][+&|!(){}^"~*?:\\\\-])`', "\\\\\$1", $Search);
     // Add the category watch.
     $Categories = CategoryModel::CategoryWatch();
     if ($Categories === FALSE) {
         return array();
     } elseif ($Categories !== TRUE) {
         $Search = 'CategoryID:(' . implode(' ', $Categories) . ') AND ' . $Search;
     }
     // Build the search url.
     $BaseUrl .= strpos($BaseUrl, '?') === FALSE ? '?' : '&';
     $Query = array('q' => $Search, 'start' => $Offset, 'rows' => $Limit);
     $Url = $BaseUrl . http_build_query($Query);
     // Grab the data.
     $Curl = curl_init($Url);
     curl_setopt($Curl, CURLOPT_RETURNTRANSFER, 1);
     $CurlResult = curl_exec($Curl);
     curl_close($Curl);
     // Parse the result into the form that the search controller expects.
     $Xml = new SimpleXMLElement($CurlResult);
     $Result = array();
     if (!isset($Xml->result)) {
         return array();
     }
     foreach ($Xml->result->children() as $Doc) {
         $Row = array();
         foreach ($Doc->children() as $Field) {
             $Name = (string) $Field['name'];
             $Row[$Name] = (string) $Field;
         }
         // Add the url.
         switch ($Row['DocType']) {
             case 'Discussion':
                 $Row['Url'] = '/discussion/' . $Row['PrimaryID'] . '/' . Gdn_Format::Url($Row['Title']);
                 break;
             case 'Comment':
                 $Row['Url'] = "/discussion/comment/{$Row['PrimaryID']}/#Comment_{$Row['PrimaryID']}";
                 break;
         }
         // Fix the time.
         $Row['DateInserted'] = strtotime($Row['DateInserted']);
         $Result[] = $Row;
     }
     // Join the users into the result.
     Gdn_DataSet::Join($Result, array('table' => 'User', 'parent' => 'UserID', 'prefix' => '', 'Name', 'Photo'));
     return $Result;
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:56,代码来源:class.searchmodel.php


示例6: __construct

 public function __construct($Sender = '', $ApplicationFolder = '')
 {
     $this->Data = FALSE;
     $NoFollowing = TRUE;
     if (C('Vanilla.Categories.Use') == TRUE) {
         // Load categories with respect to view permissions
         $Categories = CategoryModel::Categories();
         $Categories2 = $Categories;
         foreach ($Categories2 as $i => $Category) {
             if (!$Category['PermsDiscussionsView']) {
                 unset($Categories[$i]);
             } elseif (!$Category['Following']) {
                 $NoFollowing = FALSE;
             }
         }
         // delete view filter if no categories are hidden
         $Session = Gdn::Session();
         if ($NoFollowing && $Session->IsValid()) {
             $Session->SetPreference('ShowAllCategories', TRUE);
         }
         // set categories to data
         $Data = new Gdn_DataSet($Categories);
         $Data->DatasetType(DATASET_TYPE_ARRAY);
         $Data->DatasetType(DATASET_TYPE_OBJECT);
         $this->Data['Categories'] = $Data;
         // calculate additional needed data
         $this->Data['CategoryID'] = isset($Sender->CategoryID) ? $Sender->CategoryID : '';
         $this->Data['OnCategories'] = strtolower($Sender->ControllerName) == 'categoriescontroller' && !is_numeric($this->Data['CategoryID']);
         $this->Data['ShowAllCategoriesPref'] = $Session->GetPreference('ShowAllCategories');
         $this->Data['Url'] = Gdn::Request()->Path();
         if ($this->Data['Url'] == '') {
             $this->Data['Url'] = '/';
         }
         $this->Data['ShowAllCategoriesUrl'] = Gdn::Request()->Url('categories/settoggle?ShowAllCategories=true&Target=' . $this->Data['Url']);
         $this->Data['ShowFollowedCategoriesUrl'] = Gdn::Request()->Url('categories/settoggle?ShowAllCategories=false&Target=' . $this->Data['Url']);
         $this->Data['TKey'] = urlencode(Gdn::Session()->TransientKey());
         $this->Data['ValidSession'] = $Session->UserID > 0 && $Session->ValidateTransientKey($this->Data['TKey']);
         $this->Data['MaxDepth'] = C('Vanilla.Categories.MaxDisplayDepth');
         $this->Data['DoHeadings'] = C('Vanilla.Categories.DoHeadings');
     }
     parent::__construct($Sender, $ApplicationFolder);
 }
开发者ID:Nordic-T,项目名称:vanilla-plugins,代码行数:42,代码来源:class.categoriesmoduleplusmodule.php


示例7: getData

 /**
  * Get the data for this module.
  */
 protected function getData()
 {
     // Allow plugins to set different data.
     $this->fireEvent('GetData');
     if ($this->Data) {
         return;
     }
     $Categories = CategoryModel::categories();
     $Categories2 = $Categories;
     // Filter out the categories we aren't watching.
     foreach ($Categories2 as $i => $Category) {
         if (!$Category['PermsDiscussionsView'] || !$Category['Following']) {
             unset($Categories[$i]);
         }
     }
     $Data = new Gdn_DataSet($Categories);
     $Data->DatasetType(DATASET_TYPE_ARRAY);
     $Data->DatasetType(DATASET_TYPE_OBJECT);
     $this->Data = $Data;
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:23,代码来源:class.categoriesmodule.php


示例8: __construct

 public function __construct($Sender = '')
 {
     // Load categories
     $this->Data = FALSE;
     if (C('Vanilla.Categories.Use') == TRUE && !C('Vanilla.Categories.HideModule')) {
         $Categories = CategoryModel::Categories();
         $Categories2 = $Categories;
         // Filter out the categories we aren't watching.
         foreach ($Categories2 as $i => $Category) {
             if (!$Category['PermsDiscussionsView'] || !$Category['Following']) {
                 unset($Categories[$i]);
             }
         }
         $Data = new Gdn_DataSet($Categories);
         $Data->DatasetType(DATASET_TYPE_ARRAY);
         $Data->DatasetType(DATASET_TYPE_OBJECT);
         $this->Data = $Data;
     }
     parent::__construct($Sender);
 }
开发者ID:elpum,项目名称:TgaForumBundle,代码行数:20,代码来源:class.categoriesmodule.php


示例9: getProviders

 /**
  *
  *
  * @return array|null|type
  */
 public function getProviders()
 {
     $this->SQL->select('uap.*')->from('UserAuthenticationProvider uap');
     if (Gdn::session()->isValid()) {
         $UserID = Gdn::session()->UserID;
         $this->SQL->select('ua.ForeignUserKey', '', 'UniqueID')->join('UserAuthentication ua', "uap.AuthenticationKey = ua.ProviderKey and ua.UserID = {$UserID}", 'left');
     }
     $Data = $this->SQL->get()->resultArray();
     $Data = Gdn_DataSet::index($Data, array('AuthenticationKey'));
     foreach ($Data as &$Row) {
         self::calculate($Row);
     }
     return $Data;
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:19,代码来源:class.authenticationprovidermodel.php


示例10: getIDs

 /**
  *
  *
  * @param array $IDs
  * @param bool $SkipCacheQuery
  * @return array
  * @throws Exception
  */
 public function getIDs($IDs, $SkipCacheQuery = false)
 {
     $DatabaseIDs = $IDs;
     $Data = [];
     if (!$SkipCacheQuery) {
         $Keys = [];
         // Make keys for cache query
         foreach ($IDs as $UserID) {
             if (!$UserID) {
                 continue;
             }
             $Keys[] = formatString(self::USERID_KEY, ['UserID' => $UserID]);
         }
         // Query cache layer
         $CacheData = Gdn::cache()->get($Keys);
         if (!is_array($CacheData)) {
             $CacheData = [];
         }
         foreach ($CacheData as $RealKey => $User) {
             if ($User === null) {
                 $ResultUserID = trim(strrchr($RealKey, '.'), '.');
             } else {
                 $ResultUserID = val('UserID', $User);
             }
             $this->setCalculatedFields($User);
             $Data[$ResultUserID] = $User;
         }
         //echo "from cache:\n";
         //print_r($Data);
         $DatabaseIDs = array_diff($DatabaseIDs, array_keys($Data));
         unset($CacheData);
     }
     // Clean out bogus blank entries
     $DatabaseIDs = array_diff($DatabaseIDs, [null, '']);
     // If we are missing any users from cache query, fill em up here
     if (sizeof($DatabaseIDs)) {
         $DatabaseData = $this->SQL->whereIn('UserID', $DatabaseIDs)->getWhere('User')->result(DATASET_TYPE_ARRAY);
         $DatabaseData = Gdn_DataSet::index($DatabaseData, 'UserID');
         //echo "from DB:\n";
         //print_r($DatabaseData);
         foreach ($DatabaseIDs as $ID) {
             if (isset($DatabaseData[$ID])) {
                 $User = $DatabaseData[$ID];
                 $this->userCache($User, $ID);
                 // Apply calculated fields
                 $this->setCalculatedFields($User);
                 $Data[$ID] = $User;
             } else {
                 $User = null;
                 $this->userCache($User, $ID);
             }
         }
     }
     $this->EventArguments['RequestedIDs'] = $IDs;
     $this->EventArguments['LoadedUsers'] =& $Data;
     $this->fireEvent('AfterGetIDs');
     return $Data;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:66,代码来源:class.usermodel.php


示例11: AddUserToConversation

 /**
  * Add another user to the conversation.
  * 
  * @since 2.0.0
  * @access public
  *
  * @param int $ConversationID Unique ID of conversation effected.
  * @param int $UserID Unique ID of current user.
  */
 public function AddUserToConversation($ConversationID, $UserID)
 {
     if (!is_array($UserID)) {
         $UserID = array($UserID);
     }
     // First define the current users in the conversation
     $OldContributorData = $this->GetRecipients($ConversationID);
     $OldContributorData = Gdn_DataSet::Index($OldContributorData, 'UserID');
     $AddedUserIDs = array();
     // Get some information about this conversation
     $ConversationData = $this->SQL->Select('LastMessageID')->Select('CountMessages')->From('Conversation')->Where('ConversationID', $ConversationID)->Get()->FirstRow();
     // Add the user(s) if they are not already in the conversation
     foreach ($UserID as $NewUserID) {
         if (!array_key_exists($NewUserID, $OldContributorData)) {
             $AddedUserIDs[] = $NewUserID;
             $this->SQL->Insert('UserConversation', array('UserID' => $NewUserID, 'ConversationID' => $ConversationID, 'LastMessageID' => $ConversationData->LastMessageID, 'CountReadMessages' => 0, 'DateConversationUpdated' => $ConversationData['DateUpdated']));
         } elseif ($OldContributorData[$NewUserID]->Deleted) {
             $AddedUserIDs[] = $NewUserID;
             $this->SQL->Put('UserConversation', array('Deleted' => 0), array('ConversationID' => $ConversationID, 'UserID' => $NewUserID));
         }
     }
     if (count($AddedUserIDs) > 0) {
         $Session = Gdn::Session();
         // Update the Contributors field on the conversation
         $Contributors = array_unique(array_merge($AddedUserIDs, array_keys($OldContributorData)));
         sort($Contributors);
         $this->SQL->Update('Conversation')->Set('Contributors', Gdn_Format::Serialize($Contributors))->Where('ConversationID', $ConversationID)->Put();
         $ActivityModel = new ActivityModel();
         foreach ($AddedUserIDs as $AddedUserID) {
             $ActivityModel->Queue(array('ActivityType' => 'AddedToConversation', 'NotifyUserID' => $AddedUserID, 'HeadlineFormat' => T('You were added to a conversation.', '{InsertUserID,user} added {NotifyUserID,you} to a <a href="{Url,htmlencode}">conversation</a>.')), 'ConversationMessage');
         }
         $ActivityModel->SaveQueue();
         $this->UpdateUserUnreadCount($AddedUserIDs);
     }
 }
开发者ID:rnovino,项目名称:Garden,代码行数:44,代码来源:class.conversationmodel.php


示例12: RecordAdvancedNotications

 /**
  * Record advanced notifications for users.
  * 
  * @param ActivityModel $ActivityModel
  * @param array $Discussion
  * @param int $CommentID
  * @param array $NotifiedUsers 
  */
 public function RecordAdvancedNotications($ActivityModel, $Discussion, $Comment, &$NotifiedUsers)
 {
     // Grab all of the users that need to be notified.
     $Data = $this->SQL->GetWhere('UserMeta', array('Name' => 'Preferences.Email.NewDiscussion'))->ResultArray();
     // Grab all of their follow/unfollow preferences.
     $UserIDs = ConsolidateArrayValuesByKey($Data, 'UserID');
     $CategoryID = GetValue('CategoryID', $Discussion);
     $UserPrefs = $this->SQL->Select('*')->From('UserCategory')->Where('CategoryID', $CategoryID)->WhereIn('UserID', $UserIDs)->Get()->ResultArray();
     $UserPrefs = Gdn_DataSet::Index($UserPrefs, 'UserID');
     $CommentID = $Comment['CommentID'];
     foreach ($UserIDs as $UserID) {
         //         if ($UserID == $Comment['InsertUserID'])
         //            continue;
         if (in_array($UserID, $NotifiedUsers)) {
             continue;
         }
         if (array_key_exists($UserID, $UserPrefs) && $UserPrefs[$UserID]['Unfollow']) {
             continue;
         }
         $ActivityID = AddActivity($Comment['InsertUserID'], 'NewComment', Gdn_Format::Text(Gdn_Format::To($Comment['Body'], $Comment['Format'])), $UserID, "/discussion/comment/{$CommentID}#Comment_{$CommentID}", TRUE);
         //         $ActivityModel->QueueNotification($ActivityID);
         $NotifiedUsers[] = $UserID;
     }
 }
开发者ID:Raz0r,项目名称:Garden,代码行数:32,代码来源:class.commentmodel.php


示例13: joinRecords

 /**
  * Join external records to an array.
  *
  * @param array &$Data The data to join.
  * In order to join records each row must have the a RecordType and RecordID column.
  * @param string $Column The name of the column to put the record in.
  * If this is blank then the record will be merged into the row.
  * @param bool $Unset Whether or not to unset rows that don't have a record.
  * @since 2.3
  */
 function joinRecords(&$Data, $Column = '', $Unset = false)
 {
     $IDs = array();
     $AllowedCats = DiscussionModel::CategoryPermissions();
     if ($AllowedCats === false) {
         // This user does not have permission to view anything.
         $Data = array();
         return;
     }
     // Gather all of the ids to fetch.
     foreach ($Data as &$Row) {
         if (!$Row['RecordType']) {
             continue;
         }
         $RecordType = ucfirst(StringEndsWith($Row['RecordType'], '-Total', true, true));
         $Row['RecordType'] = $RecordType;
         $ID = $Row['RecordID'];
         $IDs[$RecordType][$ID] = $ID;
     }
     // Fetch all of the data in turn.
     $JoinData = array();
     foreach ($IDs as $RecordType => $RecordIDs) {
         if ($RecordType == 'Comment') {
             Gdn::SQL()->Select('d.Name, d.CategoryID')->Join('Discussion d', 'd.DiscussionID = r.DiscussionID');
         }
         $Rows = Gdn::SQL()->Select('r.*')->WhereIn($RecordType . 'ID', array_values($RecordIDs))->Get($RecordType . ' r')->ResultArray();
         $JoinData[$RecordType] = Gdn_DataSet::Index($Rows, array($RecordType . 'ID'));
     }
     // Join the rows.
     $Unsets = array();
     foreach ($Data as $Index => &$Row) {
         $RecordType = $Row['RecordType'];
         $ID = $Row['RecordID'];
         if (!isset($JoinData[$RecordType][$ID])) {
             if ($Unset) {
                 $Unsets[] = $Index;
             }
             continue;
             // orphaned?
         }
         $Record = $JoinData[$RecordType][$ID];
         if ($AllowedCats !== true) {
             // Check to see if the user has permission to view this record.
             $CategoryID = GetValue('CategoryID', $Record, -1);
             if (!in_array($CategoryID, $AllowedCats)) {
                 $Unsets[] = $Index;
                 continue;
             }
         }
         switch ($RecordType) {
             case 'Discussion':
                 $Url = DiscussionUrl($Record, '', '/') . '#latest';
                 break;
             case 'Comment':
                 $Url = CommentUrl($Record, '/');
                 $Record['Name'] = sprintf(T('Re: %s'), $Record['Name']);
                 break;
             default:
                 $Url = '';
         }
         $Record['Url'] = $Url;
         if ($Column) {
             $Row[$Column] = $Record;
         } else {
             $Row = array_merge($Row, $Record);
         }
     }
     foreach ($Unsets as $Index) {
         unset($Data[$Index]);
     }
     // Join the users.
     Gdn::UserModel()->JoinUsers($Data, array('InsertUserID'));
     if (!empty($Unsets)) {
         $Data = array_values($Data);
     }
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:86,代码来源:functions.general.php


示例14: DiscussionModel_AfterAddColumns_Handler

 /**
  * Join message counts into the discussion list.
  * @param DiscussionModel $Sender
  * @param array $Args
  */
 public function DiscussionModel_AfterAddColumns_Handler($Sender, $Args)
 {
     if (!Gdn::Session()->UserID) {
         return;
     }
     $Data = $Args['Data'];
     $Result =& $Data->Result();
     // Gather the discussion IDs.
     $DiscusisonIDs = array();
     foreach ($Result as $Row) {
         $DiscusisonIDs[] = GetValue('DiscussionID', $Row);
     }
     // Grab all of the whispers associated to the discussions being looked at.
     $Sql = Gdn::SQL()->Select('c.DiscussionID')->Select('c.CountMessages', 'sum', 'CountMessages')->Select('c.DateUpdated', 'max', 'DateLastMessage')->From('Conversation c')->WhereIn('c.DiscussionID', $DiscusisonIDs)->GroupBy('c.DiscussionID');
     if (!Gdn::Session()->CheckPermission('Conversations.Moderation.Manage')) {
         $Sql->Join('UserConversation uc', 'c.ConversationID = uc.ConversationID')->Where('uc.UserID', Gdn::Session()->UserID);
     }
     $Conversations = $Sql->Get()->ResultArray();
     $Conversations = Gdn_DataSet::Index($Conversations, 'DiscussionID');
     foreach ($Result as &$Row) {
         $DiscusisonID = GetValue('DiscussionID', $Row);
         $CRow = GetValue($DiscusisonID, $Conversations);
         if (!$CRow) {
             continue;
         }
         $DateLastViewed = GetValue('DateLastViewed', $Row);
         $DateLastMessage = $CRow['DateLastMessage'];
         $NewWhispers = Gdn_Format::ToTimestamp($DateLastViewed) < Gdn_Format::ToTimestamp($DateLastMessage);
         SetValue('CountWhispers', $Row, $CRow['CountMessages']);
         SetValue('DateLastWhisper', $Row, $DateLastMessage);
         SetValue('NewWhispers', $Row, $NewWhispers);
     }
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:38,代码来源:class.whispers.plugin.php


示例15: setUserRoles

 /**
  *
  *
  * @param $Users
  * @param string $UserIDColumn
  * @param string $RolesColumn
  */
 public static function setUserRoles(&$Users, $UserIDColumn = 'UserID', $RolesColumn = 'Roles')
 {
     $UserIDs = array_unique(ConsolidateArrayValuesByKey($Users, $UserIDColumn));
     // Try and get all of the mappings from the cache.
     $Keys = array();
     foreach ($UserIDs as $UserID) {
         $Keys[$UserID] = formatString(UserModel::USERROLES_KEY, array('UserID' => $UserID));
     }
     $UserRoles = Gdn::cache()->get($Keys);
     if (!is_array($UserRoles)) {
         $UserRoles = array();
     }
     // Grab all of the data that doesn't exist from the DB.
     $MissingIDs = array();
     foreach ($Keys as $UserID => $Key) {
         if (!array_key_exists($Key, $UserRoles)) {
             $MissingIDs[$UserID] = $Key;
         }
     }
     if (count($MissingIDs) > 0) {
         $DbUserRoles = Gdn::sql()->select('ur.*')->from('UserRole ur')->whereIn('ur.UserID', array_keys($MissingIDs))->get()->resultArray();
         $DbUserRoles = Gdn_DataSet::Index($DbUserRoles, 'UserID', array('Unique' => false));
         // Store the user role mappings.
         foreach ($DbUserRoles as $UserID => $Rows) {
             $RoleIDs = consolidateArrayValuesByKey($Rows, 'RoleID');
             $Key = $Keys[$UserID];
             Gdn::cache()->store($Key, $RoleIDs);
             $UserRoles[$Key] = $RoleIDs;
         }
     }
     $AllRoles = self::roles();
     // roles indexed by role id.
     // Skip personal info roles
     if (!checkPermission('Garden.PersonalInfo.View')) {
         $AllRoles = array_filter($AllRoles, 'self::FilterPersonalInfo');
     }
     // Join the users.
     foreach ($Users as &$User) {
         $UserID = val($UserIDColumn, $User);
         $Key = $Keys[$UserID];
         $RoleIDs = val($Key, $UserRoles, array());
         $Roles = array();
         foreach ($RoleIDs as $RoleID) {
             if (!array_key_exists($RoleID, $AllRoles)) {
                 continue;
             }
             $Roles[$RoleID] = $AllRoles[$RoleID]['Name'];
         }
         setValue($RolesColumn, $User, $Roles);
     }
 }
开发者ID:austins,项目名称:vanilla,代码行数:58,代码来源:class.rolemodel.php


示例16: joinAttachments

 /**
  * Joins attachments to data
  *
  * <code>
  * <?php
  * $AttachmentModel->JoinAttachments($Discussion, $Comments);
  * ?>
  * </code>
  *
  * @param $Data - Data to which to attach comments
  * @param $Data2 - Optional set of Data to which to attach comments
  *
  */
 public function joinAttachments(&$Data, &$Data2 = null)
 {
     if ($Data == null) {
         return;
     }
     // Gather the Ids.
     $ForeignIDs = array();
     self::gatherIDs($Data, $ForeignIDs);
     if ($Data2) {
         self::gatherIDs($Data2, $ForeignIDs);
     }
     // Get the attachments.
     $Attachments = $this->getWhere(array('ForeignID' => array_keys($ForeignIDs)), 'DateInserted', 'desc')->resultArray();
     $Attachments = Gdn_DataSet::index($Attachments, 'ForeignID', array('Unique' => false));
     // Join the attachments.
     $this->joinAttachmentsTo($Data, $Attachments);
     if ($Data2) {
         $this->joinAttachmentsTo($Data2, $Attachments);
     }
 }
开发者ID:R-J,项目名称:vanilla,代码行数:33,代码来源:class.attachmentmodel.php


示例17: RebuildTree

 /**
  * Rebuilds the category tree. We are using the Nested Set tree model.
  * 
  * @ref http://articles.sitepoint.com/article/hierarchical-data-database/2
  * @ref http://en.wikipedia.org/wiki/Nested_set_model
  *  
  * @since 2.0.0
  * @access public
  */
 public function RebuildTree()
 {
     // Grab all of the categories.
     $Categories = $this->SQL->Get('Category', 'TreeLeft, Sort, Name');
     $Categories = Gdn_DataSet::Index($Categories->ResultArray(), 'CategoryID');
     // Make sure the tree has a root.
     if (!isset($Categories[-1])) {
         $RootCat = array('CategoryID' => -1, 'TreeLeft' => 1, 'TreeRight' => 4, 'Depth' => 0, 'InsertUserID' => 1, 'UpdateUserID' => 1, 'DateInserted' => Gdn_Format::ToDateTime(), 'DateUpdated' => Gdn_Format::ToDateTime(), 'Name' => 'Root', 'UrlCode' => '', 'Description' => 'Root of category tree. Users should never see this.', 'PermissionCategoryID' => -1, 'Sort' => 0, 'ParentCategoryID' => NULL);
         $Categories[-1] = $RootCat;
         $this->SQL->Insert('Category', $RootCat);
     }
     // Build a tree structure out of the categories.
     $Root = NULL;
     foreach ($Categories as &$Cat) {
         if (!isset($Cat['CategoryID'])) {
             continue;
         }
         // Backup category settings for efficient database saving.
         try {
             $Cat['_TreeLeft'] = $Cat['TreeLeft'];
             $Cat['_TreeRight'] = $Cat['TreeRight'];
             $Cat['_Depth'] = $Cat['Depth'];
             $Cat['_PermissionCategoryID'] = $Cat['PermissionCategoryID'];
             $Cat['_ParentCategoryID'] = $Cat['ParentCategoryID'];
         } catch (Exception $Ex) {
         }
         if ($Cat['CategoryID'] == -1) {
             $Root =& $Cat;
             continue;
         }
         $ParentID = $Cat['ParentCategoryID'];
         if (!$ParentID) {
             $ParentID = -1;
             $Cat['ParentCategoryID'] = $ParentID;
         }
         if (!isset($Categories[$ParentID]['Children'])) {
             $Categories[$ParentID]['Children'] = array();
         }
         $Categories[$ParentID]['Children'][] =& $Cat;
     }
     unset($Cat);
     // Set the tree attributes of the tree.
     $this->_SetTree($Root);
     unset($Root);
     // Save the tree structure.
     foreach ($Categories as $Cat) {
         if (!isset($Cat['CategoryID'])) {
             continue;
         }
         if ($Cat['_TreeLeft'] != $Cat['TreeLeft'] || $Cat['_TreeRight'] != $Cat['TreeRight'] || $Cat['_Depth'] != $Cat['Depth'] || $Cat['PermissionCategoryID'] != $Cat['PermissionCategoryID'] || $Cat['_ParentCategoryID'] != $Cat['ParentCategoryID'] || $Cat['Sort'] != $Cat['TreeLeft']) {
             $this->SQL->Put('Category', array('TreeLeft' => $Cat['TreeLeft'], 'TreeRight' => $Cat['TreeRight'], 'Depth' => $Cat['Depth'], 'PermissionCategoryID' => $Cat['PermissionCategoryID'], 'ParentCategoryID' => $Cat['ParentCategoryID'], 'Sort' => $Cat['TreeLeft']), array('CategoryID' => $Cat['CategoryID']));
         }
     }
     $this->SetCache();
 }
开发者ID:robhazkes,项目名称:Garden,代码行数:64,代码来源:class.categorymodel.php


示例18: GetIDs

 public function GetIDs($IDs, $SkipCacheQuery = FALSE)
 {
     $DatabaseIDs = $IDs;
     $Data = array();
     if (!$SkipCacheQuery) {
         $Keys = array();
         // Make keys for cache query
         foreach ($IDs as $UserID) {
             if (!$UserID) {
                 continue;
             }
             $Keys[] = FormatString(self::USERID_KEY, array('UserID' => $UserID));
         }
         // Query cache layer
         $CacheData = Gdn::Cache()->Get($Keys);
         if (!is_array($CacheData)) {
             $CacheData = array();
         }
         foreach ($CacheData as $RealKey => $User) {
             $ResultUserID = GetValue('UserID', $User);
             $Data[$ResultUserID] = $User;
         }
         //echo "from cache:\n";
         //print_r($Data);
         $DatabaseIDs = array_diff($DatabaseIDs, array_keys($Data));
         unset($CacheData);
     }
     // Clean out bogus blank entries
     $DatabaseIDs = array_diff($DatabaseIDs, array(NULL, ''));
     // If we are missing any users from cache query, fill em up here
     if (sizeof($DatabaseIDs)) {
         $DatabaseData = $this->SQL->WhereIn('UserID', $DatabaseIDs)->GetWhere('User')->Result(DATASET_TYPE_ARRAY);
         $DatabaseData = Gdn_DataSet::Index($DatabaseData, 'UserID');
         //echo "from DB:\n";
         //print_r($DatabaseData);
         foreach ($DatabaseData as $DatabaseUserID => $DatabaseUser) {
             $Data[$DatabaseUserID] = $DatabaseUser;
             $this->SetCalculatedFields($DatabaseUser);
             $Result = $this->UserCache($DatabaseUser);
         }
     }
     $this->EventArguments['RequestedIDs'] = $IDs;
     $this->EventArguments['LoadedUsers'] =& $Data;
     $this->FireEvent('AfterGetIDs');
     return $Data;
 }
开发者ID:statico,项目名称:openshift-origin-vanillaforums,代码行数:46,代码来源:class.usermodel.php


示例19: JoinParticipants

 public function JoinParticipants(&$Data) {
    $this->SQL
       ->From('UserConversation uc')
       ->Join('User u', 'u.UserID = uc.UserID');
    
    Gdn_DataSet::Join($Data, array('alias' => 'uc', 'parent' => 'ConversationID', 'column' => 'Participants', 'UserID', 'u.Name', 'u.Photo'), array('sql' => $this->SQL));
 }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:7,代码来源:class.conversationmodel.php


示例20: ConfirmDiscussionMoves

 /**
  * Form to ask for the destination of the move, confirmation and permission check.
  */
 public function ConfirmDiscussionMoves($DiscussionID = NULL)
 {
     $Session = Gdn::Session();
     $this->Form = new Gdn_Form();
     $DiscussionModel = new DiscussionModel();
     $this->Title(T('Confirm'));
     if ($DiscussionID) {
         $CheckedDiscussions = (array) $DiscussionID;
         $ClearSelection = FALSE;
     } else {
         $CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
         if (!is_array($CheckedDiscussions)) {
             $CheckedDiscussions = array();
         }
         $ClearSelection = TRUE;
     }
     $DiscussionIDs = $CheckedDiscussions;
     $CountCheckedDiscussions = count($DiscussionIDs);
     $this->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
     // Check for edit permissions on each discussion
     $AllowedDiscussions = array();
     $DiscussionData = $DiscussionModel->SQL->Select('DiscussionID, Name, DateLastComment, CategoryID')->From('Discussion')->WhereIn('DiscussionID', $DiscussionIDs)->Get();
     $DiscussionData = Gdn_DataSet::Index($DiscussionData->ResultArray(), array('DiscussionID'));
     foreach ($DiscussionData as $DiscussionID => $Discussion) {
         $Category = CategoryModel::Categories($Discussion['CategoryID']);
         if ($Category && $Category['PermsDiscussionsEdit']) {
             $AllowedDiscussions[] = $DiscussionID;
         }
     }
     $this->SetData('CountAllowed', count($AllowedDiscussions));
     $CountNotAllowed = $CountCheckedDiscussions - count($AllowedDiscussions);
     $this->SetData('CountNotAllowed', $CountNotAllowed);
     if ($this->Form->AuthenticatedPostBack()) {
         // Retrieve the category id
         $CategoryID = $this->Form->GetFormValue('CategoryID');
         $Category = CategoryModel::Categories($CategoryID);
         $RedirectLink = $this->Form->GetFormValue('RedirectLink');
         // User must have add permission on the target category
         if (!$Category['PermsDiscussionsAdd']) {
             throw ForbiddenException('@' . T('You do not have permission to add discussions to this category.'));
         }
         // Iterate and move.
         foreach ($AllowedDiscussions as $DiscussionID) {
             // Create the shadow redirect.
             if ($RedirectLink) {
                 $Discussion = GetValue($DiscussionID, $DiscussionData);
                 $DiscussionModel->DefineSchema();
                 $MaxNameLength = GetValue('Length', $DiscussionModel->Schema->GetField('Name'));
                 $RedirectDiscussion = array('Name' => SliceString(sprintf(T('Moved: %s'), $Discussion['Name']), $MaxNameLength), 'DateInserted' => $Discussion['DateLastComment'], 'Type' => 'redirect', 'CategoryID' => $Discussion['CategoryID'], 'Body' => FormatString(T('This discussion has been <a href="{url,html}">moved</a>.'), array('url' => DiscussionUrl($Discussion))), 'Format' => 'Html', 'Closed' => TRUE);
                 $RedirectID = $DiscussionModel->Save($RedirectDiscussion);
                 if (!$RedirectID) {
                     $this->Form->SetValidationResults($DiscussionModel->ValidationResults());
                     break;
                 }
             }
             $DiscussionModel->SetField($DiscussionID, 'CategoryID', $CategoryID);
         }
         // Clear selections.
         if ($ClearSelection) {
             Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
             ModerationController::InformCheckedDiscussions($this);
         }
         if ($this->Form->ErrorCount() == 0) {
             $this->JsonTarget('', '', 'Refresh');
         }
     }
     $this->Render();
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:71,代码来源:class.moderationcontroller.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Gdn_Email类代码示例发布时间:2022-05-23
下一篇:
PHP Gdn_Controller类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap