当前位置: 首页>>代码示例>>PHP>>正文


PHP User_group::find方法代码示例

本文整理汇总了PHP中User_group::find方法的典型用法代码示例。如果您正苦于以下问题:PHP User_group::find方法的具体用法?PHP User_group::find怎么用?PHP User_group::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User_group的用法示例。


在下文中一共展示了User_group::find方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
            }
        }
    }
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:28,代码来源:updateurls.php

示例2: showResults

 function showResults($q, $page)
 {
     $user_group = new User_group();
     $user_group->limit(($page - 1) * GROUPS_PER_PAGE, GROUPS_PER_PAGE + 1);
     $wheres = array('nickname', 'fullname', 'homepage', 'description', 'location');
     foreach ($wheres as $where) {
         $where_q = "{$where} like '%" . trim($user_group->escape($q), '\'') . '%\'';
         $user_group->whereAdd($where_q, 'OR');
     }
     $cnt = $user_group->find();
     if ($cnt > 0) {
         $terms = preg_split('/[\\s,]+/', $q);
         $results = new GroupSearchResults($user_group, $terms, $this);
         $results->show();
         $user_group->free();
         $this->pagination($page > 1, $cnt > GROUPS_PER_PAGE, $page, 'groupsearch', array('q' => $q));
     } else {
         // TRANS: Text on page where groups can be searched if no results were found for a query.
         $this->element('p', 'error', _('No results.'));
         $this->searchSuggestions($q);
         if (common_logged_in()) {
             // TRANS: Additional text on page where groups can be searched if no results were found for a query for a logged in user.
             // TRANS: This message contains Markdown links in the form [link text](link).
             $message = _('If you cannot find the group you\'re looking for, you can [create it](%%action.newgroup%%) yourself.');
         } else {
             // TRANS: Additional text on page where groups can be searched if no results were found for a query for a not logged in user.
             // TRANS: This message contains Markdown links in the form [link text](link).
             $message = _('Why not [register an account](%%action.register%%) and [create the group](%%action.newgroup%%) yourself!');
         }
         $this->elementStart('div', 'guide');
         $this->raw(common_markup_to_html($message));
         $this->elementEnd('div');
         $user_group->free();
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:35,代码来源:groupsearch.php

示例3: getGroup

 public function getGroup()
 {
     $group = new User_group();
     $group->id = $this->group_id;
     $group->find(true);
     if (!$group instanceof User_group) {
         common_log(LOG_ERR, 'User_group does not exist for Local_group: ' . $this->group_id);
         throw new NoResultException($group);
     }
     return $group;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:11,代码来源:Local_group.php

示例4: showResults

 function showResults($q, $page)
 {
     $user_group = new User_group();
     $user_group->limit(($page - 1) * GROUPS_PER_PAGE, GROUPS_PER_PAGE + 1);
     $wheres = array('nickname', 'fullname', 'homepage', 'description', 'location');
     foreach ($wheres as $where) {
         $where_q = "{$where} like '%" . trim($user_group->escape($q), '\'') . '%\'';
         $user_group->whereAdd($where_q, 'OR');
     }
     $cnt = $user_group->find();
     if ($cnt > 0) {
         $terms = preg_split('/[\\s,]+/', $q);
         $results = new GroupSearchResults($user_group, $terms, $this);
         $results->show();
     } else {
         $this->element('p', 'error', _('No results'));
     }
     $user_group->free();
     $this->pagination($page > 1, $cnt > GROUPS_PER_PAGE, $page, 'groupsearch', array('q' => $q));
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:20,代码来源:groupsearch.php

示例5: updateGroupUri

            throw new Exception("Can't find group with id '{$id}'.");
        }
        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)
开发者ID:microcosmx,项目名称:experiments,代码行数:31,代码来源:fixup_group_uri.php

示例6: 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;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:42,代码来源:autocomplete.php

示例7: array

}
echo "\n";
// And there may be user_group entries remaining where we've already killed
// the ostatus_profile. These were "harmless" until our lookup started actually
// using the uri field, at which point we can clearly see it breaks stuff.
echo "Checking for leftover bogus user_group.uri entries obscuring local_group entries...\n";
$group = new User_group();
$group->joinAdd(array('id', 'local_group:group_id'), 'LEFT');
$group->whereAdd('group_id IS NULL');
$marker = mt_rand(31337, 31337000);
$groupTemplate = common_local_url('groupbyid', array('id' => $marker));
$encGroup = $group->escape($groupTemplate, true);
$encGroup = str_replace($marker, '%', $encGroup);
echo "  LIKE '{$encGroup}'\n";
$group->whereAdd("uri LIKE '{$encGroup}'");
$group->find();
$count = $group->N;
echo "Found {$count}...\n";
while ($group->fetch()) {
    $uri = $group->uri;
    if (preg_match('!/group/(\\d+)/id!', $uri, $matches)) {
        $id = intval($matches[1]);
        $local = Local_group::staticGet('group_id', $id);
        if ($local) {
            $nick = $local->nickname;
        } else {
            $nick = '<deleted>';
        }
        echo "local group {$id} ({$local->nickname}) hidden by {$uri} (bogus group id {$group->id})";
        if ($dry) {
            echo " - skipping\n";
开发者ID:microcosmx,项目名称:experiments,代码行数:31,代码来源:fixup-shadow.php

示例8: 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;
 }
开发者ID:Br3nda,项目名称:StatusNet,代码行数:37,代码来源:autocomplete.php

示例9: getGroups

    function getGroups()
    {
        $group = new User_group();
        $offset = ($this->page - 1) * PROFILES_PER_PAGE;
        $limit = PROFILES_PER_PAGE + 1;
        if (isset($this->q)) {
            $order = 'user_group.created ASC';
            if ($this->sort == 'nickname') {
                if ($this->reverse) {
                    $order = 'user_group.nickname DESC';
                } else {
                    $order = 'user_group.nickname ASC';
                }
            } else {
                if ($this->reverse) {
                    $order = 'user_group.created DESC';
                }
            }
            $sql = <<<GROUP_QUERY_END
SELECT user_group.*
FROM user_group
JOIN local_group ON user_group.id = local_group.group_id
ORDER BY %s
LIMIT %d, %d
GROUP_QUERY_END;
            $cnt = 0;
            $group->query(sprintf($sql, $order, $limit, $offset));
            $group->find();
        } else {
            // User is browsing via AlphaNav
            $sort = $this->getSortKey();
            $sql = <<<GROUP_QUERY_END
SELECT user_group.*
FROM user_group
JOIN local_group ON user_group.id = local_group.group_id
GROUP_QUERY_END;
            switch ($this->filter) {
                case 'all':
                    // NOOP
                    break;
                case '0-9':
                    $sql .= '  AND LEFT(user_group.nickname, 1) BETWEEN \'0\' AND \'9\'';
                    break;
                default:
                    $sql .= sprintf(' AND LEFT(LOWER(user_group.nickname), 1) = \'%s\'', $this->filter);
            }
            $sql .= sprintf(' ORDER BY user_group.%s %s, user_group.nickname ASC LIMIT %d, %d', $sort, $this->reverse ? 'DESC' : 'ASC', $offset, $limit);
            $group->query($sql);
        }
        return $group;
    }
开发者ID:Grasia,项目名称:bolotweet,代码行数:51,代码来源:groupdirectory.php

示例10: 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");
}
开发者ID:Grasia,项目名称:bolotweet,代码行数:24,代码来源:upgrade.php

示例11: getGroups

 function getGroups()
 {
     $group = new User_group();
     // Disable this to get global group searches
     $group->joinAdd(array('id', 'local_group:group_id'));
     $order = false;
     if (!empty($this->q)) {
         $wheres = array('nickname', 'fullname', 'homepage', 'description', 'location');
         foreach ($wheres as $where) {
             // Double % because of sprintf
             $group->whereAdd(sprintf('LOWER(%1$s.%2$s) LIKE LOWER("%%%3$s%%")', $group->escapedTableName(), $where, $group->escape($this->q)), 'OR');
         }
         $order = sprintf('%1$s.%2$s %3$s', $group->escapedTableName(), $this->getSortKey('created'), $this->reverse ? 'DESC' : 'ASC');
     } else {
         // User is browsing via AlphaNav
         switch ($this->filter) {
             case 'all':
                 // NOOP
                 break;
             case '0-9':
                 $group->whereAdd(sprintf('LEFT(%1$s.%2$s, 1) BETWEEN %3$s AND %4$s', $group->escapedTableName(), 'nickname', $group->_quote("0"), $group->_quote("9")));
                 break;
             default:
                 $group->whereAdd(sprintf('LEFT(LOWER(%1$s.%2$s), 1) = %3$s', $group->escapedTableName(), 'nickname', $group->_quote($this->filter)));
         }
         $order = sprintf('%1$s.%2$s %3$s, %1$s.%4$s ASC', $group->escapedTableName(), $this->getSortKey('nickname'), $this->reverse ? 'DESC' : 'ASC', 'nickname');
     }
     $offset = ($this->page - 1) * PROFILES_PER_PAGE;
     $limit = PROFILES_PER_PAGE + 1;
     $group->selectAdd();
     $group->selectAdd('profile_id');
     $group->orderBy($order);
     $group->limit($offset, $limit);
     $group->find();
     return Profile::multiGet('id', $group->fetchAll('profile_id'));
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:36,代码来源:groupdirectory.php

示例12: 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;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:43,代码来源:autocomplete.php

示例13: showContent

 function showContent()
 {
     $this->elementStart('p', array('id' => 'new_group'));
     $this->element('a', array('href' => common_local_url('newgroup'), 'class' => 'more'), _('Create a new group'));
     $this->elementEnd('p');
     $offset = ($this->page - 1) * GROUPS_PER_PAGE;
     $limit = GROUPS_PER_PAGE + 1;
     $groups = new User_group();
     $groups->orderBy('created DESC');
     $groups->limit($offset, $limit);
     if ($groups->find()) {
         $gl = new GroupList($groups, null, $this);
         $cnt = $gl->show();
     }
     $this->pagination($this->page > 1, $cnt > GROUPS_PER_PAGE, $this->page, 'groups');
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:16,代码来源:groups.php


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