本文整理匯總了PHP中Gdn_Model::GetWhere方法的典型用法代碼示例。如果您正苦於以下問題:PHP Gdn_Model::GetWhere方法的具體用法?PHP Gdn_Model::GetWhere怎麽用?PHP Gdn_Model::GetWhere使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Gdn_Model
的用法示例。
在下文中一共展示了Gdn_Model::GetWhere方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: SettingsController_EventCalendar_Create
/**
* Allows customization of categories which allow new discussions to be events
* Sets config value Plugins.EventCalendar.CategoryIDs
*
* @param object $Sender SettingsController
*/
public function SettingsController_EventCalendar_Create($Sender)
{
$Sender->Permission('Garden.Settings.Manage');
$Sender->Title(T('Event Calendar Settings'));
$Sender->AddSideMenu('settings/EventCalendar');
$Sender->SetData('Info', T('Event Calendar Info', 'Creation of events can be regulated by category <strong>and</strong> user role. You can set up the categories here, but don\'t forget to assign some permissions in the <a href="/index.php?p=dashboard/role">standard permission section</a> in the dashboard, otherwise you users wouldn\'t be able to use this plugin!'));
$Sender->SetData('CategoriesLabel', 'Please choose categories in which the creation of events should be allowed');
$Validation = new Gdn_Validation();
// $Validation->ApplyRule('Plugins.EventCalendar.CategoryIDs', 'RequiredArray', T('You have to choose at least one category. If you don\'t want to use the plugin any longer, please deactivate it'));
$ConfigurationModel = new Gdn_ConfigurationModel($Validation);
$ConfigurationModel->SetField(array('Plugins.EventCalendar.CategoryIDs'));
$Form = $Sender->Form;
$Sender->Form->SetModel($ConfigurationModel);
if ($Sender->Form->AuthenticatedPostBack() != FALSE) {
if ($Sender->Form->Save() != FALSE) {
$Sender->StatusMessage = T('Saved');
}
} else {
$Sender->Form->SetData($ConfigurationModel->Data);
}
$CategoryModel = new Gdn_Model('Category');
$Sender->CategoryData = $CategoryModel->GetWhere(array('AllowDiscussions' => 1, 'CategoryID <>' => -1));
$Sender->EventCategory = C('Plugins.EventCalendar.CategoryIDs');
$Sender->Render('settings', '', 'plugins/EventCalendar');
}
示例2: MergeStart
protected function MergeStart($OldUserID, $NewUserID)
{
$Model = new Gdn_Model('UserMerge');
// Grab the users.
$OldUser = $this->GetID($OldUserID, DATASET_TYPE_ARRAY);
$NewUser = $this->GetID($NewUserID, DATASET_TYPE_ARRAY);
// First see if there is a record with the same merge.
$Row = $Model->GetWhere(array('OldUserID' => $OldUserID, 'NewUserID' => $NewUserID))->FirstRow(DATASET_TYPE_ARRAY);
if ($Row) {
$MergeID = $Row['MergeID'];
// Save this merge in the log.
if ($Row['Attributes']) {
$Attributes = unserialize($Row['Attributes']);
} else {
$Attributes = array();
}
$Attributes['Log'][] = array('UserID' => Gdn::Session()->UserID, 'Date' => Gdn_Format::ToDateTime());
$Row = array('MergeID' => $MergeID, 'Attributes' => $Attributes);
} else {
$Row = array('OldUserID' => $OldUserID, 'NewUserID' => $NewUserID);
}
$UserSet = array();
$OldUserSet = array();
if (DateCompare($OldUser['DateFirstVisit'], $NewUser['DateFirstVisit']) < 0) {
$UserSet['DateFirstVisit'] = $OldUser['DateFirstVisit'];
}
if (!isset($Row['Attributes']['User']['CountVisits'])) {
$UserSet['CountVisits'] = $OldUser['CountVisits'] + $NewUser['CountVisits'];
$OldUserSet['CountVisits'] = 0;
}
if (!empty($UserSet)) {
// Save the user information on the merge record.
foreach ($UserSet as $Key => $Value) {
// Only save changed values that aren't already there from a previous merge.
if ($NewUser[$Key] != $Value && !isset($Row['Attributes']['User'][$Key])) {
$Row['Attributes']['User'][$Key] = $NewUser[$Key];
}
}
}
$MergeID = $Model->Save($Row);
if (GetValue('MergeID', $Row)) {
$MergeID = $Row['MergeID'];
}
if (!$MergeID) {
throw new Gdn_UserException($Model->Validation->ResultsText());
}
// Update the user with the new user-level data.
$this->SetField($NewUserID, $UserSet);
if (!empty($OldUserSet)) {
$this->SetField($OldUserID, $OldUserSet);
}
return $MergeID;
}
示例3: SettingsController_EditTag_Create
/**
* Edit Tag form.
*/
public function SettingsController_EditTag_Create($Sender)
{
$Sender->Permission('Garden.Settings.Manage');
$Sender->Title(T('Edit Tag'));
$Sender->AddSideMenu('settings/tagging');
$TagID = GetValue(0, $Sender->RequestArgs);
$TagModel = new Gdn_Model('Tag');
$Sender->Tag = $TagModel->GetWhere(array('TagID' => $TagID))->FirstRow();
// Set the model on the form.
$Sender->Form->SetModel($TagModel);
// Make sure the form knows which item we are editing.
$Sender->Form->AddHidden('TagID', $TagID);
if (!$Sender->Form->AuthenticatedPostBack()) {
$Sender->Form->SetData($Sender->Tag);
} else {
// Make sure the tag is valid
$Tag = $Sender->Form->GetFormValue('Name');
if (!ValidateRegex($Tag, '/^([\\d\\w\\+-_.#]+)$/si')) {
$Sender->Form->AddError('Tags can only contain the following characters: a-z 0-9 + # _ .');
}
// Make sure that the tag name is not already in use.
if ($TagModel->GetWhere(array('TagID <>' => $TagID, 'Name' => $Tag))->NumRows() > 0) {
$Sender->Form->AddError('The specified tag name is already in use.');
}
if ($Sender->Form->Save()) {
$Sender->StatusMessage = T('Your changes have been saved successfully.');
}
}
$Sender->Render('plugins/Tagging/views/edittag.php');
}
示例4: GetConversationMembers
/**
* Get all the members of a conversation from the $ConversationID.
*
* @param int $ConversationID The conversation ID.
*
* @return array Array of user IDs.
*/
public function GetConversationMembers($ConversationID)
{
$ConversationMembers = array();
$UserConversation = new Gdn_Model('UserConversation');
$UserMembers = $UserConversation->GetWhere(array('ConversationID' => $ConversationID))->ResultArray();
if (is_array($UserMembers) && count($UserMembers)) {
$ConversationMembers = array_column($UserMembers, 'UserID');
}
return $ConversationMembers;
}
示例5: Touch
public static function Touch($Name, $Value)
{
$Model = new Gdn_Model('Pocket');
$Pockets = $Model->GetWhere(array('Name' => $Name))->ResultArray();
if (empty($Pockets)) {
$Pocket = array('Name' => $Name, 'Location' => 'Content', 'Sort' => 0, 'Repeat' => Pocket::REPEAT_BEFORE, 'Body' => $Value, 'Format' => 'Raw', 'Disabled' => Pocket::DISABLED, 'MobileOnly' => 0, 'MobileNever' => 0, 'EmbeddedNever' => 0, 'ShowInDashboard' => 0, 'Type' => 'default');
$Model->Save($Pocket);
}
}
示例6: GetWhere
/**
* {@inheritDoc}
* in addition; We CalculateRow for each record found (Add Attachments)
* @see Gdn_Model::GetWhere
*/
public function GetWhere($Where = FALSE, $OrderFields = '', $OrderDirection = 'asc', $Limit = FALSE, $Offset = FALSE)
{
$Data = parent::GetWhere($Where, $OrderFields, $OrderDirection, $Limit, $Offset);
$Rows =& $Data->ResultArray();
foreach ($Rows as &$Row) {
$this->CalculateRow($Row);
}
return $Data;
}