本文整理汇总了PHP中EmailMessage::getSubset方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailMessage::getSubset方法的具体用法?PHP EmailMessage::getSubset怎么用?PHP EmailMessage::getSubset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EmailMessage
的用法示例。
在下文中一共展示了EmailMessage::getSubset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
*
* (non-PHPdoc)
* @see BaseJob::run()
*/
public function run()
{
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$oneWeekAgoTimeStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 7);
$searchAttributeData = array();
$searchAttributeData['clauses'] = array(1 => array('attributeName' => 'modifiedDateTime', 'operatorType' => 'lessThan', 'value' => $oneWeekAgoTimeStamp), 2 => array('attributeName' => 'folder', 'relatedAttributeName' => 'type', 'operatorType' => 'equals', 'value' => EmailFolder::TYPE_SENT), 3 => array('attributeName' => 'folder', 'relatedAttributeName' => 'emailBox', 'operatorType' => 'equals', 'value' => $box->id));
$searchAttributeData['structure'] = '1 and 2 and 3';
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('EmailMessage');
$where = RedBeanModelDataProvider::makeWhere('EmailMessage', $searchAttributeData, $joinTablesAdapter);
$emailMessageModels = EmailMessage::getSubset($joinTablesAdapter, null, self::$pageSize, $where, null);
foreach ($emailMessageModels as $emailMessage) {
$emailMessage->delete();
}
return true;
}
示例2: testResolveSearchAttributesDataByRelatedItemIdWithRegularUser
public function testResolveSearchAttributesDataByRelatedItemIdWithRegularUser()
{
Yii::app()->user->userModel = User::getByUsername('benny');
$mungeIds = ReadPermissionsOptimizationUtil::getMungeIdsByUser(Yii::app()->user->userModel);
$quote = DatabaseCompatibilityUtil::getQuote();
$rules = new EmailMessageMashableActivityRules();
$searchAttributeData = $rules->resolveSearchAttributesDataByRelatedItemId(5);
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('EmailMessage');
$where = RedBeanModelDataProvider::makeWhere('EmailMessage', $searchAttributeData, $joinTablesAdapter);
$compareWhere = "(({$quote}emailmessagesender{$quote}.{$quote}personoraccount_item_id{$quote} = 5) or (1 = ";
$compareWhere .= "(select 1 from {$quote}emailmessagerecipient{$quote} emailmessagerecipient where ";
$compareWhere .= "{$quote}emailmessagerecipient{$quote}.{$quote}emailmessage_id` = {$quote}emailmessage";
$compareWhere .= "{$quote}.id and {$quote}emailmessagerecipient{$quote}.{$quote}personoraccount_item_id` = 5 limit 1)))";
$this->assertEquals($compareWhere, $where);
$sql = EmailMessage::makeSubsetOrCountSqlQuery('emailmessage', $joinTablesAdapter, 1, 5, $where, null);
$compareSubsetSql = "select distinct {$quote}emailmessage{$quote}.{$quote}id{$quote} id ";
$compareSubsetSql .= "from ({$quote}emailmessage{$quote}, {$quote}ownedsecurableitem{$quote}) ";
$compareSubsetSql .= "left join {$quote}emailmessagesender{$quote} on ";
$compareSubsetSql .= "{$quote}emailmessagesender{$quote}.{$quote}id{$quote} = {$quote}emailmessage{$quote}.";
$compareSubsetSql .= "{$quote}sender_emailmessagesender_id{$quote} ";
$compareSubsetSql .= "left join {$quote}emailmessage_read{$quote} on ";
$compareSubsetSql .= "{$quote}emailmessage_read{$quote}.{$quote}securableitem_id{$quote} = ";
$compareSubsetSql .= "{$quote}ownedsecurableitem{$quote}.{$quote}securableitem_id{$quote} ";
$compareSubsetSql .= "and {$quote}munge_id{$quote} in ('" . join("', '", $mungeIds) . "') ";
$compareSubsetSql .= "where (" . $compareWhere . ') ';
$compareSubsetSql .= "and ({$quote}ownedsecurableitem{$quote}.{$quote}owner__user_id{$quote} = " . Yii::app()->user->userModel->id . " ";
// Not Coding Standard
$compareSubsetSql .= "OR {$quote}emailmessage_read{$quote}.{$quote}munge_id{$quote} IS NOT NULL) ";
// Not Coding Standard
$compareSubsetSql .= "and {$quote}ownedsecurableitem{$quote}.{$quote}id{$quote} = ";
$compareSubsetSql .= "{$quote}emailmessage{$quote}.{$quote}ownedsecurableitem_id{$quote} ";
$compareSubsetSql .= 'limit 5 offset 1';
$this->assertEquals($compareSubsetSql, $sql);
//Make sure the sql runs properly.
$data = EmailMessage::getSubset($joinTablesAdapter, 0, 5, $where, null);
$this->assertEquals(0, count($data));
}
示例3: processCopyEmailActivity
/**
* Process copy email activity.
*
* @param RedBeanModel $primaryModel
* @param RedBeanModel $selectedModel
*/
public static function processCopyEmailActivity($primaryModel, $selectedModel)
{
$searchAttributesData = LatestActivitiesUtil::getSearchAttributesDataByModelClassNamesAndRelatedItemIds(array('EmailMessage'), array($selectedModel->getClassId('Item')), LatestActivitiesConfigurationForm::OWNED_BY_FILTER_ALL);
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('EmailMessage');
$where = RedBeanModelDataProvider::makeWhere('EmailMessage', $searchAttributesData[0]['EmailMessage'], $joinTablesAdapter);
$models = EmailMessage::getSubset($joinTablesAdapter, null, null, $where, null);
if (isset($searchAttributesData[1]['EmailMessage'])) {
$where = RedBeanModelDataProvider::makeWhere('EmailMessage', $searchAttributesData[1]['EmailMessage'], $joinTablesAdapter);
$models = array_merge($models, EmailMessage::getSubset($joinTablesAdapter, null, null, $where, null));
}
foreach ($models as $model) {
//Resolve sender
if ($model->sender->personsOrAccounts->contains($selectedModel)) {
$model->sender->personsOrAccounts->remove($selectedModel);
if (!$model->sender->personsOrAccounts->contains($primaryModel)) {
$model->sender->personsOrAccounts->add($primaryModel);
}
}
//recipients
foreach ($model->recipients as $key => $unused) {
if ($model->recipients[$key]->personsOrAccounts->contains($selectedModel)) {
$model->recipients[$key]->personsOrAccounts->remove($selectedModel);
if (!$model->recipients[$key]->personsOrAccounts->contains($primaryModel)) {
$model->recipients[$key]->personsOrAccounts->add($primaryModel);
}
}
}
$model->save();
}
}