本文整理汇总了PHP中User_group::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP User_group::fetch方法的具体用法?PHP User_group::fetch怎么用?PHP User_group::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User_group
的用法示例。
在下文中一共展示了User_group::fetch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateGroupUrls
function updateGroupUrls()
{
printfnq("Updating group URLs...\n");
$group = new User_group();
if ($group->find()) {
while ($group->fetch()) {
try {
printfv("Updating group {$group->nickname}...");
$orig = User_group::getKV('id', $group->id);
if (!empty($group->original_logo)) {
$group->original_logo = Avatar::url(basename($group->original_logo));
$group->homepage_logo = Avatar::url(basename($group->homepage_logo));
$group->stream_logo = Avatar::url(basename($group->stream_logo));
$group->mini_logo = Avatar::url(basename($group->mini_logo));
}
// XXX: this is a hack to see if a group is local or not
$localUri = common_local_url('groupbyid', array('id' => $group->id));
if ($group->getUri() != $localUri) {
$group->mainpage = common_local_url('showgroup', array('nickname' => $group->nickname));
}
$group->update($orig);
printfv("DONE.");
} catch (Exception $e) {
echo "Can't update avatars for group " . $group->nickname . ": " . $e->getMessage();
}
}
}
}
示例2: getGroups
/**
* Get groups
*
* @return array groups
*/
function getGroups()
{
$qry = 'SELECT user_group.* ' . 'from user_group join local_group on user_group.id = local_group.group_id ' . 'order by created desc ';
$offset = intval($this->page - 1) * intval($this->count);
$limit = intval($this->count);
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$group = new User_group();
$group->query($qry);
$groups = array();
while ($group->fetch()) {
$groups[] = clone $group;
}
return $groups;
}
示例3: updateGroupUri
}
updateGroupUri($group);
} else {
if (have_option('n', 'nickname')) {
$nickname = get_option_value('n', 'nickname');
$group = User_group::staticGet('nickname', $nickname);
if (empty($group)) {
throw new Exception("Can't find group with nickname '{$nickname}'");
}
updateGroupUri($group);
} else {
if (have_option('a', 'all')) {
$group = new User_group();
$group->whereAdd('uri IS NULL');
if ($group->find()) {
while ($group->fetch()) {
updateGroupUri($group);
}
}
} else {
show_help();
exit(1);
}
}
}
} catch (Exception $e) {
print $e->getMessage() . "\n";
exit(1);
}
function updateGroupUri($group)
{
示例4: prepare
protected function prepare(array $args = array())
{
// If we die, show short error messages.
GNUsocial::setApi(true);
parent::prepare($args);
$this->groups = array();
$this->profiles = array();
$term = $this->arg('term');
$limit = $this->arg('limit');
if ($limit > 200) {
$limit = 200;
}
//prevent DOS attacks
if (substr($term, 0, 1) == '@') {
//profile search
$term = substr($term, 1);
$profile = new Profile();
$profile->limit($limit);
$profile->whereAdd('nickname like \'' . trim($profile->escape($term), '\'') . '%\'');
$profile->whereAdd(sprintf('id in (SELECT id FROM user) OR ' . 'id in (SELECT subscribed from subscription' . ' where subscriber = %d)', $this->scoped->id));
if ($profile->find()) {
while ($profile->fetch()) {
$this->profiles[] = clone $profile;
}
}
}
if (substr($term, 0, 1) == '!') {
//group search
$term = substr($term, 1);
$group = new User_group();
$group->limit($limit);
$group->whereAdd('nickname like \'' . trim($group->escape($term), '\'') . '%\'');
//Can't post to groups we're not subscribed to...:
$group->whereAdd(sprintf('id in (SELECT group_id FROM group_member' . ' WHERE profile_id = %d)', $this->scoped->id));
if ($group->find()) {
while ($group->fetch()) {
$this->groups[] = clone $group;
}
}
}
return true;
}
示例5: prepare
function prepare($args)
{
parent::prepare($args);
$this->groups = array();
$this->users = array();
$q = $this->arg('q');
$limit = $this->arg('limit');
if ($limit > 200) {
$limit = 200;
}
//prevent DOS attacks
if (substr($q, 0, 1) == '@') {
//user search
$q = substr($q, 1);
$user = new User();
$user->limit($limit);
$user->whereAdd('nickname like \'' . trim($user->escape($q), '\'') . '%\'');
if ($user->find()) {
while ($user->fetch()) {
$this->users[] = clone $user;
}
}
}
if (substr($q, 0, 1) == '!') {
//group search
$q = substr($q, 1);
$group = new User_group();
$group->limit($limit);
$group->whereAdd('nickname like \'' . trim($group->escape($q), '\'') . '%\'');
if ($group->find()) {
while ($group->fetch()) {
$this->groups[] = clone $group;
}
}
}
return true;
}
示例6: initLocalGroup
function initLocalGroup()
{
printfnq("Ensuring all local user groups have a local_group...");
$group = new User_group();
$group->whereAdd('NOT EXISTS (select group_id from local_group where group_id = user_group.id)');
$group->find();
while ($group->fetch()) {
try {
// Hack to check for local groups
if ($group->getUri() == common_local_url('groupbyid', array('id' => $group->id))) {
$lg = new Local_group();
$lg->group_id = $group->id;
$lg->nickname = $group->nickname;
$lg->created = $group->created;
// XXX: common_sql_now() ?
$lg->modified = $group->modified;
$lg->insert();
}
} catch (Exception $e) {
printfv("Error initializing local group for {$group->nickname}:" . $e->getMessage());
}
}
printfnq("DONE.\n");
}
示例7: prepare
function prepare($args)
{
// If we die, show short error messages.
StatusNet::setApi(true);
parent::prepare($args);
$cur = common_current_user();
if (!$cur) {
throw new ClientException('Access forbidden', true);
}
$this->groups = array();
$this->users = array();
$q = $this->arg('q');
$limit = $this->arg('limit');
if ($limit > 200) {
$limit = 200;
}
//prevent DOS attacks
if (substr($q, 0, 1) == '@') {
//user search
$q = substr($q, 1);
$user = new User();
$user->limit($limit);
$user->whereAdd('nickname like \'' . trim($user->escape($q), '\'') . '%\'');
if ($user->find()) {
while ($user->fetch()) {
$this->users[] = clone $user;
}
}
}
if (substr($q, 0, 1) == '!') {
//group search
$q = substr($q, 1);
$group = new User_group();
$group->limit($limit);
$group->whereAdd('nickname like \'' . trim($group->escape($q), '\'') . '%\'');
if ($group->find()) {
while ($group->fetch()) {
$this->groups[] = clone $group;
}
}
}
return true;
}