本文整理汇总了PHP中Notice::defaultScope方法的典型用法代码示例。如果您正苦于以下问题:PHP Notice::defaultScope方法的具体用法?PHP Notice::defaultScope怎么用?PHP Notice::defaultScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notice
的用法示例。
在下文中一共展示了Notice::defaultScope方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newNotice
function newNotice($i, $tagmax)
{
global $userprefix;
$options = array('scope' => Notice::defaultScope());
$n = rand(0, $i - 1);
$user = User::getKV('nickname', sprintf('%s%d', $userprefix, $n));
$is_reply = rand(0, 1);
$content = testNoticeContent();
if ($is_reply == 0) {
$stream = new InboxNoticeStream($user->getProfile(), $user->getProfile());
$notices = $stream->getNotices(0, 20);
if ($notices->N > 0) {
$nval = rand(0, $notices->N - 1);
$notices->fetch();
// go to 0th
for ($i = 0; $i < $nval; $i++) {
$notices->fetch();
}
$options['reply_to'] = $notices->id;
$dont_use_nickname = rand(0, 2);
if ($dont_use_nickname != 0) {
$rprofile = $notices->getProfile();
$content = "@" . $rprofile->nickname . " " . $content;
}
$private_to_addressees = rand(0, 4);
if ($private_to_addressees == 0) {
$options['scope'] |= Notice::ADDRESSEE_SCOPE;
}
}
} else {
$is_directed = rand(0, 4);
if ($is_directed == 0) {
$subs = $user->getSubscribed(0, 100)->fetchAll();
if (count($subs) > 0) {
$seen = array();
$f = rand(0, 9);
if ($f <= 6) {
$addrs = 1;
} else {
if ($f <= 8) {
$addrs = 2;
} else {
$addrs = 3;
}
}
for ($m = 0; $m < $addrs; $m++) {
$x = rand(0, count($subs) - 1);
if ($seen[$x]) {
continue;
}
if ($subs[$x]->id == $user->id) {
continue;
}
$seen[$x] = true;
$rprofile = $subs[$x];
$content = "@" . $rprofile->nickname . " " . $content;
}
$private_to_addressees = rand(0, 4);
if ($private_to_addressees == 0) {
$options['scope'] |= Notice::ADDRESSEE_SCOPE;
}
}
}
}
$has_hash = rand(0, 2);
if ($has_hash == 0) {
$hashcount = rand(0, 2);
for ($j = 0; $j < $hashcount; $j++) {
$h = rand(0, $tagmax);
$content .= " #tag{$h}";
}
}
$in_group = rand(0, 5);
if ($in_group == 0) {
$groups = $user->getGroups();
if ($groups instanceof User_group) {
$gval = rand(0, $groups->N - 1);
$groups->fetch();
// go to 0th
for ($i = 0; $i < $gval; $i++) {
$groups->fetch();
}
$options['groups'] = array($groups->id);
$content = "!" . $groups->nickname . " " . $content;
$private_to_group = rand(0, 2);
if ($private_to_group == 0) {
$options['scope'] |= Notice::GROUP_SCOPE;
}
}
}
$private_to_site = rand(0, 4);
if ($private_to_site == 0) {
$options['scope'] |= Notice::SITE_SCOPE;
}
$notice = Notice::saveNew($user->id, $content, 'createsim', $options);
}
示例2: newNotice
function newNotice($i, $tagmax)
{
global $userprefix;
$options = array('scope' => Notice::defaultScope());
$n = rand(0, $i - 1);
$user = User::staticGet('nickname', sprintf('%s%d', $userprefix, $n));
$is_reply = rand(0, 1);
$content = testNoticeContent();
if ($is_reply == 0) {
$stream = new InboxNoticeStream($user, $user->getProfile());
$notices = $stream->getNotices(0, 20);
if ($notices->N > 0) {
$nval = rand(0, $notices->N - 1);
$notices->fetch();
// go to 0th
for ($i = 0; $i < $nval; $i++) {
$notices->fetch();
}
$options['reply_to'] = $notices->id;
$dont_use_nickname = rand(0, 2);
if ($dont_use_nickname != 0) {
$rprofile = $notices->getProfile();
$content = "@" . $rprofile->nickname . " " . $content;
}
$private_to_addressees = rand(0, 4);
if ($private_to_addressees == 0) {
$options['scope'] |= Notice::ADDRESSEE_SCOPE;
}
}
}
$has_hash = rand(0, 2);
if ($has_hash == 0) {
$hashcount = rand(0, 2);
for ($j = 0; $j < $hashcount; $j++) {
$h = rand(0, $tagmax);
$content .= " #tag{$h}";
}
}
$in_group = rand(0, 5);
if ($in_group == 0) {
$groups = $user->getGroups();
if ($groups->N > 0) {
$gval = rand(0, $groups->N - 1);
$groups->fetch();
// go to 0th
for ($i = 0; $i < $gval; $i++) {
$groups->fetch();
}
$options['groups'] = array($groups->id);
$content = "!" . $groups->nickname . " " . $content;
$private_to_group = rand(0, 2);
if ($private_to_group == 0) {
$options['scope'] |= Notice::GROUP_SCOPE;
}
}
}
$private_to_site = rand(0, 4);
if ($private_to_site == 0) {
$options['scope'] |= Notice::SITE_SCOPE;
}
$notice = Notice::saveNew($user->id, $content, 'createsim', $options);
}