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


PHP forum_get_potential_subscribers函数代码示例

本文整理汇总了PHP中forum_get_potential_subscribers函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_get_potential_subscribers函数的具体用法?PHP forum_get_potential_subscribers怎么用?PHP forum_get_potential_subscribers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了forum_get_potential_subscribers函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: find_users

    /**
     * Finds all potential users
     *
     * Potential users are determined by checking for users with a capability
     * determined in {@see forum_get_potential_subscribers()}
     *
     * @param string $search
     * @return array
     */
    public function find_users($search) {
        global $DB;

        $availableusers = forum_get_potential_subscribers($this->context, $this->currentgroup, $this->required_fields_sql('u'), 'u.firstname ASC, u.lastname ASC');

        if (empty($availableusers)) {
            $availableusers = array();
        } else if ($search) {
            $search = strtolower($search);
            foreach ($availableusers as $key=>$user) {
                if (stripos($user->firstname, $search) === false && stripos($user->lastname, $search) === false) {
                    unset($availableusers[$key]);
                }
            }
        }

        // Unset any existing subscribers
        if (count($this->existingsubscribers)>0 && !$this->forcesubscribed) {
            foreach ($this->existingsubscribers as $group) {
                foreach ($group as $user) {
                    if (array_key_exists($user->id, $availableusers)) {
                        unset($availableusers[$user->id]);
                    }
                }
            }
        }

        if ($this->forcesubscribed) {
            return array(get_string("existingsubscribers", 'forum') => $availableusers);
        } else {
            return array(get_string("potentialsubscribers", 'forum') => $availableusers);
        }
    }
开发者ID:nfreear,项目名称:moodle,代码行数:42,代码来源:lib.php

示例2: forum_subscribed_users

/**
 * Returns list of user objects that are subscribed to this forum
 *
 * @global object
 * @global object
 * @param object $course the course
 * @param forum $forum the forum
 * @param integer $groupid group id, or 0 for all.
 * @param object $context the forum context, to save re-fetching it where possible.
 * @param string $fields requested user fields (with "u." table prefix)
 * @return array list of users.
 */
function forum_subscribed_users($course, $forum, $groupid=0, $context = null, $fields = null) {
    global $CFG, $DB;

    if (empty($fields)) {
        $fields ="u.id,
                  u.username,
                  u.firstname,
                  u.lastname,
                  u.maildisplay,
                  u.mailformat,
                  u.maildigest,
                  u.imagealt,
                  u.email,
                  u.emailstop,
                  u.city,
                  u.country,
                  u.lastaccess,
                  u.lastlogin,
                  u.picture,
                  u.timezone,
                  u.theme,
                  u.lang,
                  u.trackforums,
                  u.mnethostid";
    }

    if (empty($context)) {
        $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id);
        $context = context_module::instance($cm->id);
    }

    if (forum_is_forcesubscribed($forum)) {
        $results = forum_get_potential_subscribers($context, $groupid, $fields, "u.email ASC");

    } else {
        // only active enrolled users or everybody on the frontpage
        list($esql, $params) = get_enrolled_sql($context, '', $groupid, true);
        $params['forumid'] = $forum->id;
        $results = $DB->get_records_sql("SELECT $fields
                                           FROM {user} u
                                           JOIN ($esql) je ON je.id = u.id
                                           JOIN {forum_subscriptions} s ON s.userid = u.id
                                          WHERE s.forum = :forumid
                                       ORDER BY u.email ASC", $params);
    }

    // Guest user should never be subscribed to a forum.
    unset($results[$CFG->siteguest]);

    return $results;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:63,代码来源:lib.php

示例3: print_error

                    print_error('cannotremovesubscriber', 'forum', '', $removesubscriber);
                }
            }
        } else {
            if (!empty($frm->showall)) {
                $searchtext = '';
            }
        }
    }
}
/// Get all existing subscribers for this forum.
if (!($subscribers = forum_subscribed_users($course, $forum, $currentgroup, $context))) {
    $subscribers = array();
}
/// Get all the potential subscribers excluding users already subscribed
$users = forum_get_potential_subscribers($context, $currentgroup, 'id,email,firstname,lastname', 'firstname ASC, lastname ASC');
if (!$users) {
    $users = array();
}
foreach ($subscribers as $subscriber) {
    unset($users[$subscriber->id]);
}
/// This is yucky, but do the search in PHP, becuase the list we are using comes from get_users_by_capability,
/// which does not allow searching in the database. Fortunately the list is only this list of users in this
/// course, which is normally OK, except on the site course of a big site. But before you can enter a search
/// term, you have already seen a page that lists everyone, since this code never does paging, so you have probably
/// already crashed your server if you are going to. This will be fixed properly for Moodle 2.0: MDL-17550.
if ($searchtext) {
    $searchusers = array();
    $lcsearchtext = moodle_strtolower($searchtext);
    foreach ($users as $userid => $user) {
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:subscribers.php

示例4: require_sesskey

 require_sesskey();
 switch ($mode) {
     case FORUM_CHOOSESUBSCRIBE:
         // 0
         forum_forcesubscribe($forum->id, FORUM_CHOOSESUBSCRIBE);
         redirect($returnto, get_string("everyonecannowchoose", "forum"), 1);
         break;
     case FORUM_FORCESUBSCRIBE:
         // 1
         forum_forcesubscribe($forum->id, FORUM_FORCESUBSCRIBE);
         redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
         break;
     case FORUM_INITIALSUBSCRIBE:
         // 2
         if ($forum->forcesubscribe != FORUM_INITIALSUBSCRIBE) {
             $users = forum_get_potential_subscribers($context, 0, 'u.id, u.email', '');
             foreach ($users as $user) {
                 forum_subscribe($user->id, $forum->id);
             }
         }
         forum_forcesubscribe($forum->id, FORUM_INITIALSUBSCRIBE);
         redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
         break;
     case FORUM_DISALLOWSUBSCRIBE:
         // 3
         forum_forcesubscribe($forum->id, FORUM_DISALLOWSUBSCRIBE);
         redirect($returnto, get_string("noonecansubscribenow", "forum"), 1);
         break;
     default:
         print_error(get_string('invalidforcesubscribe', 'forum'));
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:31,代码来源:subscribe.php

示例5: forum_subscribed_users

/**
 * Returns list of user objects that are subscribed to this forum
 *
 * @param object $course the course
 * @param forum $forum the forum
 * @param integer $groupid group id, or 0 for all.
 * @param object $context the forum context, to save re-fetching it where possible.
 * @return array list of users.
 */
function forum_subscribed_users($course, $forum, $groupid = 0, $context = NULL)
{
    global $CFG;
    if ($groupid) {
        $grouptables = ", {$CFG->prefix}groups_members gm ";
        $groupselect = "AND gm.groupid = {$groupid} AND u.id = gm.userid";
    } else {
        $grouptables = '';
        $groupselect = '';
    }
    if (forum_is_forcesubscribed($forum)) {
        if (empty($context)) {
            $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id);
            $context = get_context_instance(CONTEXT_MODULE, $cm->id);
        }
        $sort = "u.email ASC";
        $fields = "u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest, u.emailstop, u.imagealt,\n                  u.email, u.city, u.country, u.lastaccess, u.lastlogin, u.picture, u.timezone, u.theme, u.lang, u.trackforums, u.mnethostid";
        $results = forum_get_potential_subscribers($context, $groupid, $fields, $sort);
    } else {
        $results = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest, u.emailstop, u.imagealt,\n                                   u.email, u.city, u.country, u.lastaccess, u.lastlogin, u.picture, u.timezone, u.theme, u.lang, u.trackforums, u.mnethostid\n                              FROM {$CFG->prefix}user u,\n                                   {$CFG->prefix}forum_subscriptions s {$grouptables}\n                             WHERE s.forum = '{$forum->id}'\n                               AND s.userid = u.id\n                               AND u.deleted = 0  {$groupselect}\n                          ORDER BY u.email ASC");
    }
    static $guestid = null;
    if (is_null($guestid)) {
        if ($guest = guest_user()) {
            $guestid = $guest->id;
        } else {
            $guestid = 0;
        }
    }
    // Guest user should never be subscribed to a forum.
    unset($results[$guestid]);
    return $results;
}
开发者ID:njorth,项目名称:marginalia,代码行数:42,代码来源:lib.php

示例6: error

                    error("Could not remove subscriber with id {$removesubscriber} from this forum!");
                }
            }
        } else {
            if (!empty($frm->showall)) {
                $searchtext = '';
            }
        }
    }
}
/// Get all existing subscribers for this forum.
if (!($subscribers = forum_subscribed_users($course, $forum, $currentgroup, $context))) {
    $subscribers = array();
}
/// Get all the potential subscribers excluding users already subscribed
$users = forum_get_potential_subscribers($context, $currentgroup, 'u.id,u.email,u.firstname,u.lastname', 'u.firstname ASC, u.lastname ASC');
if (!$users) {
    $users = array();
}
foreach ($subscribers as $subscriber) {
    unset($users[$subscriber->id]);
}
/// This is yucky, but do the search in PHP, becuase the list we are using comes from get_users_by_capability,
/// which does not allow searching in the database. Fortunately the list is only this list of users in this
/// course, which is normally OK, except on the site course of a big site. But before you can enter a search
/// term, you have already seen a page that lists everyone, since this code never does paging, so you have probably
/// already crashed your server if you are going to. This will be fixed properly for Moodle 2.0: MDL-17550.
if ($searchtext) {
    $searchusers = array();
    $lcsearchtext = moodle_strtolower($searchtext);
    foreach ($users as $userid => $user) {
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:subscribers.php

示例7: forum_subscribed_users

/**
 * Returns list of user objects that are subscribed to this forum
 *
 * @global object
 * @global object
 * @param object $course the course
 * @param forum $forum the forum
 * @param integer $groupid group id, or 0 for all.
 * @param object $context the forum context, to save re-fetching it where possible.
 * @param string $fields requested user fields (with "u." table prefix)
 * @return array list of users.
 */
function forum_subscribed_users($course, $forum, $groupid = 0, $context = null, $fields = null)
{
    global $CFG, $DB;
    $allnames = get_all_user_name_fields(true, 'u');
    if (empty($fields)) {
        $fields = "u.id,\n                  u.username,\n                  {$allnames},\n                  u.maildisplay,\n                  u.mailformat,\n                  u.maildigest,\n                  u.imagealt,\n                  u.email,\n                  u.emailstop,\n                  u.city,\n                  u.country,\n                  u.lastaccess,\n                  u.lastlogin,\n                  u.picture,\n                  u.timezone,\n                  u.theme,\n                  u.lang,\n                  u.trackforums,\n                  u.mnethostid";
    }
    if (empty($context)) {
        $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id);
        $context = context_module::instance($cm->id);
    }
    if (forum_is_forcesubscribed($forum)) {
        $results = forum_get_potential_subscribers($context, $groupid, $fields, "u.email ASC");
    } else {
        // only active enrolled users or everybody on the frontpage
        list($esql, $params) = get_enrolled_sql($context, '', $groupid, true);
        $params['forumid'] = $forum->id;
        $results = $DB->get_records_sql("SELECT {$fields}\n                                           FROM {user} u\n                                           JOIN ({$esql}) je ON je.id = u.id\n                                           JOIN {forum_subscriptions} s ON s.userid = u.id\n                                          WHERE s.forum = :forumid\n                                       ORDER BY u.email ASC", $params);
    }
    // Guest user should never be subscribed to a forum.
    unset($results[$CFG->siteguest]);
    $cm = get_coursemodule_from_instance('forum', $forum->id);
    $modinfo = get_fast_modinfo($cm->course);
    return groups_filter_users_by_course_module_visible($modinfo->get_cm($cm->id), $results);
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:37,代码来源:lib.php


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