本文整理汇总了PHP中MEMBER类的典型用法代码示例。如果您正苦于以下问题:PHP MEMBER类的具体用法?PHP MEMBER怎么用?PHP MEMBER使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MEMBER类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: your_mp_bullet_point
function your_mp_bullet_point()
{
global $THEUSER, $MPURL;
print "<li>";
$pc_form = true;
if ($THEUSER->constituency_is_set()) {
// (We don't allow the user to search for a postcode if they
// already have one set in their prefs.)
$MEMBER = new MEMBER(array('constituency' => $THEUSER->constituency()));
if ($MEMBER->valid) {
$pc_form = false;
$CHANGEURL = new URL('userchangepc');
$mpname = $MEMBER->first_name() . ' ' . $MEMBER->last_name();
$former = "";
$left_house = $MEMBER->left_house();
if ($left_house[1]['date'] != '9999-12-31') {
$former = 'former';
}
?>
<p><a href="<?php
echo $MPURL->generate();
?>
"><strong>Find out more about <?php
echo $mpname;
?>
, your <?php
echo $former;
?>
Representative</strong></a>
(<a href="<?php
echo $CHANGEURL->generate();
?>
">Change</a>)</p>
<?php
}
}
if ($pc_form) {
?>
<form action="<?php
echo $MPURL->generate();
?>
" method="get">
<p><strong>Find out more about your Representative</strong><br>
<label for="pc">Enter your Australian postcode here:</label> <input type="text" name="pc" id="pc" size="8" maxlength="10" class="text"> <input type="submit" value=" GO " class="submit"></p>
</form>
<?php
}
print "</li>";
}
示例2: fetch_mp
function fetch_mp($pc, $constituencies, $house = null)
{
global $THEUSER;
$args = array('constituency' => $constituencies['WMC']);
if ($house) {
$args['house'] = $house;
}
try {
$MEMBER = new MEMBER($args);
} catch (MySociety\TheyWorkForYou\MemberException $e) {
postcode_error($e->getMessage());
}
if ($MEMBER->person_id()) {
$THEUSER->set_postcode_cookie($pc);
}
return $MEMBER;
}
示例3: load_member
function load_member($pid)
{
$member = new MEMBER(array('person_id' => $pid));
if (!$member->valid) {
output_error('Unknown ID');
}
$member->load_extra_info();
return $member;
}
示例4: manage
public static function manage($email)
{
$db = new \ParlDB();
$q = $db->query('SELECT * FROM alerts WHERE email = :email
AND deleted != 1 ORDER BY created', array(':email' => $email));
$out = '';
for ($i = 0; $i < $q->rows(); ++$i) {
$row = $q->row($i);
$criteria = explode(' ', $row['criteria']);
$ccc = array();
$current = true;
foreach ($criteria as $c) {
if (preg_match('#^speaker:(\\d+)#', $c, $m)) {
$MEMBER = new \MEMBER(array('person_id' => $m[1]));
$ccc[] = 'spoken by ' . $MEMBER->full_name();
if (!$MEMBER->current_member_anywhere()) {
$current = false;
}
} else {
$ccc[] = $c;
}
}
$criteria = join(' ', $ccc);
$token = $row['alert_id'] . '-' . $row['registrationtoken'];
$action = '<form action="/alert/" method="post"><input type="hidden" name="t" value="' . $token . '">';
if (!$row['confirmed']) {
$action .= '<input type="submit" name="action" value="Confirm">';
} elseif ($row['deleted'] == 2) {
$action .= '<input type="submit" name="action" value="Resume">';
} else {
$action .= '<input type="submit" name="action" value="Suspend"> <input type="submit" name="action" value="Delete">';
}
$action .= '</form>';
$out .= '<tr><td>' . $criteria . '</td><td align="center">' . $action . '</td></tr>';
if (!$current) {
$out .= '<tr><td colspan="2"><small> — <em>not a current member of any body covered by TheyWorkForYou</em></small></td></tr>';
}
}
if ($out) {
print '<table cellpadding="3" cellspacing="0"><tr><th>Criteria</th><th>Action</th></tr>' . $out . '</table>';
} else {
print '<p>You currently have no email alerts set up.</p>';
}
}
示例5: meta
public static function meta($e)
{
$private = false;
if ($e['committee_name']) {
$title = $e['committee_name'];
if ($e['title'] == 'to consider the Bill') {
} elseif ($e['title'] && $e['title'] != 'This is a private meeting.') {
$title .= ': ' . $e['title'];
} else {
$private = true;
}
} else {
$title = $e['title'];
if ($pid = $e['person_id']) {
$MEMBER = new \MEMBER(array('person_id' => $pid));
$name = $MEMBER->full_name();
$title .= " – <a href='/mp/?p={$pid}'>{$name}</a>";
}
}
$meta = array();
if ($d = $e['debate_type']) {
if ($d == 'Adjournment') {
$d = 'Adjournment debate';
}
$meta[] = $d;
}
if ($e['time_start'] || $e['location']) {
if ($e['time_start']) {
$time = format_time($e['time_start'], TIMEFORMAT);
if ($e['time_end']) {
$time .= ' – ' . format_time($e['time_end'], TIMEFORMAT);
}
$meta[] = $time;
}
if ($e['location']) {
$meta[] = $e['location'];
}
}
if ($private) {
$meta[] = 'Private meeting';
}
return array($title, $meta);
}
示例6: _get_committee
function _get_committee($bill_id)
{
include_once INCLUDESPATH . "easyparliament/member.php";
$q = $this->db->query('select count(*) as c from hansard where major=6 and minor=' . mysql_escape_string($bill_id) . ' and htype=10');
$sittings = $q->field(0, 'c');
$q = $this->db->query('select member_id,sum(attending) as attending, sum(chairman) as chairman
from pbc_members where bill_id=' . mysql_escape_string($bill_id) . ' group by member_id');
$comm = array('sittings' => $sittings);
for ($i = 0; $i < $q->rows(); $i++) {
$member_id = $q->field($i, 'member_id');
$mp = new MEMBER(array('member_id' => $member_id));
$attending = $q->field($i, 'attending');
$chairman = $q->field($i, 'chairman');
$arr = array('name' => $mp->full_name(), 'attending' => $attending);
if ($chairman) {
$comm['chairmen'][$member_id] = $arr;
} else {
$comm['members'][$member_id] = $arr;
}
}
return $comm;
}
示例7: find_constituency
function find_constituency($args)
{
// We see if the user is searching for a postcode or constituency.
global $PAGE, $db;
if ($args['s'] != '') {
$searchterm = $args['s'];
} else {
$PAGE->error_message('No search string');
return false;
}
$constituencies = array();
$constituency = '';
$validpostcode = false;
if (validate_postcode($searchterm)) {
// Looks like a postcode - can we find the constituency?
$constituencies = postcode_to_constituency($searchterm);
if ($constituencies == '') {
$constituencies = array();
} else {
$validpostcode = true;
}
if (!is_array($constituencies)) {
$constituencies = array($constituencies);
}
}
if ($constituencies == array() && $searchterm) {
// No luck so far - let's see if they're searching for a constituency.
$try = strtolower($searchterm);
if (normalise_constituency_name($try)) {
$constituency = normalise_constituency_name($try);
} else {
$query = "select distinct\n (select name from constituency where cons_id = o.cons_id and main_name) as name \n from constituency AS o where name like '%" . mysql_real_escape_string($try) . "%'\n and from_date <= date(now()) and date(now()) <= to_date";
$q = $db->query($query);
for ($n = 0; $n < $q->rows(); $n++) {
$constituencies[] = $q->field($n, 'name');
}
}
}
if (count($constituencies) == 1) {
$constituency = $constituencies[0];
}
if ($constituency != '') {
// Got a match, display....
$MEMBER = new MEMBER(array('constituency' => $constituency));
$URL = new URL('mp');
if ($MEMBER->valid) {
$URL->insert(array('m' => $MEMBER->member_id()));
print '<h3>MP for ' . preg_replace("#{$searchterm}#i", '<span class="hi">$0</span>', $constituency);
if ($validpostcode) {
// Display the postcode the user searched for.
print ' (' . htmlentities(strtoupper($args['s'])) . ')';
}
?>
</h3>
<p><a href="<?php
echo $URL->generate();
?>
"><strong><?php
echo htmlentities($MEMBER->first_name()) . ' ' . htmlentities($MEMBER->last_name());
?>
</strong></a> (<?php
echo $MEMBER->party();
?>
)</p>
<?php
}
} elseif (count($constituencies)) {
print "<h3>MPs in constituencies matching '" . htmlentities($searchterm) . "'</h3><ul>";
foreach ($constituencies as $constituency) {
$MEMBER = new MEMBER(array('constituency' => $constituency));
$URL = new URL('mp');
if ($MEMBER->valid) {
$URL->insert(array('m' => $MEMBER->member_id()));
}
print '<li><a href="' . $URL->generate() . '"><strong>' . htmlentities($MEMBER->first_name()) . ' ' . htmlentities($MEMBER->last_name()) . '</strong></a> (' . preg_replace("#{$searchterm}#i", '<span class="hi">$0</span>', $constituency) . ', ' . $MEMBER->party() . ')</li>';
}
print '</ul>';
}
}
示例8: addTeamMember
function addTeamMember($memberid, $admin)
{
global $manager;
$memberid = intval($memberid);
$admin = intval($admin);
// check if member is already a member
$tmem = MEMBER::createFromID($memberid);
if ($tmem->isTeamMember($this->getID())) {
return 0;
}
$manager->notify('PreAddTeamMember', array('blog' => &$this, 'member' => &$tmem, 'admin' => &$admin));
// add to team
$query = 'INSERT INTO ' . sql_table('team') . ' (TMEMBER, TBLOG, TADMIN) ' . 'VALUES (' . $memberid . ', ' . $this->getID() . ', "' . $admin . '")';
sql_query($query);
$manager->notify('PostAddTeamMember', array('blog' => &$this, 'member' => &$tmem, 'admin' => $admin));
$logMsg = sprintf(_TEAM_ADD_NEWTEAMMEMBER, $tmem->getDisplayName(), $memberid, $this->getName());
ACTIONLOG::add(INFO, $logMsg);
return 1;
}
示例9: URL
<?php
}
?>
</form>
</div>
<div>
<h3>Your representative</h3>
<?php
$MPURL = new URL('yourmp');
global $THEUSER;
$pc_form = true;
if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) {
// User is logged in and has a postcode, or not logged in with a cookied postcode.
// (We don't allow the user to search for a postcode if they
// already have one set in their prefs.)
$MEMBER = new MEMBER(array('postcode' => $THEUSER->postcode()));
if ($MEMBER->valid) {
$pc_form = false;
if ($THEUSER->isloggedin()) {
$CHANGEURL = new URL('useredit');
} else {
$CHANGEURL = new URL('userchangepc');
}
$mpname = $MEMBER->first_name() . ' ' . $MEMBER->last_name();
$former = "";
$left_house = $MEMBER->left_house();
if ($left_house[1]['date'] != '9999-12-31') {
$former = 'former';
}
?>
示例10: htmlentities
$errors['pc'] = "Sorry, " . htmlentities($pc) . " isn't a known postcode";
} elseif (isset($constituencies['SPE']) || isset($constituencies['SPC'])) {
$MEMBER = new MEMBER(array('constituency' => $constituencies['WMC']));
if ($MEMBER->person_id()) {
$THEUSER->set_postcode_cookie($pc);
}
list($out, $sidebars) = pick_multiple($pc, $constituencies, 'SPE', 'MSP');
} elseif (isset($constituencies['NIE'])) {
$MEMBER = new MEMBER(array('constituency' => $constituencies['WMC']));
if ($MEMBER->person_id()) {
$THEUSER->set_postcode_cookie($pc);
}
list($out, $sidebars) = pick_multiple($pc, $constituencies, 'NIE', 'MLA');
} else {
# Just have an MP, redirect instantly to the canonical page
$MEMBER = new MEMBER(array('constituency' => $constituencies['WMC']));
if ($MEMBER->person_id()) {
$THEUSER->set_postcode_cookie($pc);
}
member_redirect($MEMBER);
}
} else {
$errors['pc'] = "Sorry, " . htmlentities($pc) . " isn't a valid postcode";
twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form.");
}
$PAGE->page_start();
$PAGE->stripe_start();
if (isset($errors['pc'])) {
$PAGE->error_message($errors['pc']);
$PAGE->postcode_form();
}
示例11: MEMBER
<?php
# Compile data for MP page in Google gadget
# XXX Lots here copied from elsewhere... Damn you deadlines.
include_once 'min-init.php';
include_once INCLUDESPATH . 'easyparliament/member.php';
include_once '../api/api_functions.php';
$pid = $_GET['pid'];
if (!$pid) {
print '<error>No ID</error>';
exit;
}
$member = new MEMBER(array('person_id' => $pid));
if (!$member->valid) {
print '<error>Unknown ID</error>';
exit;
}
$member->load_extra_info();
$row = array('person_id' => $pid, 'full_name' => $member->full_name(), 'constituency' => $member->constituency(), 'party' => $member->party_text(), 'majority_in_seat' => number_format($member->extra_info['majority_in_seat']), 'swing_to_lose_seat_today' => number_format($member->extra_info['swing_to_lose_seat_today']));
list($image, $sz) = find_rep_image($pid, true);
if ($image) {
$row['image'] = $image;
}
foreach ($member->extra_info['office'] as $office) {
if ($office['to_date'] == '9999-12-31' && $office['source'] == 'chgpages/selctee') {
$row['selctee'][] = prettify_office($office['position'], $office['dept']);
}
}
$none = false;
$output = array();
$pw_keys = array_filter(array_keys($member->extra_info), create_function('$a', '
示例12: search_form
function search_form($value = '')
{
global $SEARCHENGINE;
// Search box on the search page.
// If $value is set then it will be displayed in the form.
// Otherwise the value of 's' in the URL will be displayed.
$wtt = get_http_var('wtt');
$URL = new URL('search');
$URL->reset();
// no need to pass any query params as a form action. They are not used.
if ($value == '') {
$value = get_http_var('s');
}
echo '<div class="mainsearchbox">';
if ($wtt < 2) {
echo '<form action="', $URL->generate(), '" method="get">';
if (get_http_var('o')) {
echo '<input type="hidden" name="o" value="', htmlentities(get_http_var('o')), '">';
}
if (get_http_var('house')) {
echo '<input type="hidden" name="house" value="', htmlentities(get_http_var('house')), '">';
}
echo '<input type="text" name="s" value="', htmlentities($value), '" size="20"> ';
echo '<input type="submit" value=" ', $wtt ? 'Modify search' : 'Search', ' "><br>';
if ($wtt) {
print '<input type="hidden" name="wtt" value="1">';
}
} else {
?>
<form action="http://www.writetothem.com/lords" method="get">
<input type="hidden" name="pid" value="<?php
echo htmlentities(get_http_var('pid'));
?>
">
<input type="submit" style="font-size: 150%" value=" I want to write to this Lord "><br>
<?php
}
if (!$wtt) {
echo '<div style="margin-top: 5px">';
$orderUrl = new URL('search');
$ordering = get_http_var('o');
if ($ordering != 'r' && $ordering != 'd' && $ordering != 'p') {
$ordering = 'd';
}
if ($ordering == 'r') {
print '<strong>Most relevant results are first</strong>';
} else {
printf("<a href='%s'>Show most relevant results first</a>", $orderUrl->generate('html', array('o' => 'r')));
}
print " | ";
if ($ordering == 'd') {
print '<strong>Most recent results are first</strong>';
} else {
printf("<a href='%s'>Show most recent results first</a>", $orderUrl->generate('html', array('o' => 'd')));
}
print " | ";
if ($ordering == 'p') {
print '<strong>Use by person</strong>';
} else {
printf('<a href="%s">Show use by person</a>', $orderUrl->generate('html', array('o' => 'p')));
}
echo '</div>';
$person_id = get_http_var('pid');
if ($person_id != "") {
$member = new MEMBER(array('person_id' => $person_id));
if ($member->valid) {
$name = $member->full_name();
?>
<p>
<input type="radio" name="pid" value="<?php
echo htmlentities($person_id);
?>
" checked>Search only <?php
echo htmlentities($name);
?>
<input type="radio" name="pid" value="">Search all speeches
</p>
<?php
}
}
}
echo '</form> </div>';
}
示例13: addComment
/**
* Adds a new comment to the database
* @param string $timestamp
* @param array $comment
* @return mixed
*/
function addComment($timestamp, $comment)
{
global $CONF, $member, $manager;
$blogid = getBlogIDFromItemID($this->itemid);
$settings =& $manager->getBlog($blogid);
$settings->readSettings();
// begin if: comments disabled
if (!$settings->commentsEnabled()) {
return _ERROR_COMMENTS_DISABLED;
}
// end if
// begin if: public cannot comment
if (!$settings->isPublic() && !$member->isLoggedIn()) {
return _ERROR_COMMENTS_NONPUBLIC;
}
// end if
// begin if: comment uses a protected member name
if ($CONF['ProtectMemNames'] && !$member->isLoggedIn() && MEMBER::isNameProtected($comment['user'])) {
return _ERROR_COMMENTS_MEMBERNICK;
}
// end if
// begin if: email required, but missing (doesn't apply to members)
if ($settings->emailRequired() && strlen($comment['email']) == 0 && !$member->isLoggedIn()) {
return _ERROR_EMAIL_REQUIRED;
}
// end if
## Note usage of mb_strlen() vs strlen() below ##
// begin if: commenter's name is too long
if (mb_strlen($comment['user']) > 40) {
return _ERROR_USER_TOO_LONG;
}
// end if
// begin if: commenter's email is too long
if (mb_strlen($comment['email']) > 100) {
return _ERROR_EMAIL_TOO_LONG;
}
// end if
// begin if: commenter's url is too long
if (mb_strlen($comment['userid']) > 100) {
return _ERROR_URL_TOO_LONG;
}
// end if
$comment['timestamp'] = $timestamp;
$comment['host'] = gethostbyaddr(serverVar('REMOTE_ADDR'));
$comment['ip'] = serverVar('REMOTE_ADDR');
// begin if: member is logged in, use that data
if ($member->isLoggedIn()) {
$comment['memberid'] = $member->getID();
$comment['user'] = '';
$comment['userid'] = '';
$comment['email'] = '';
} else {
$comment['memberid'] = 0;
}
// spam check
$continue = FALSE;
$plugins = array();
if (isset($manager->subscriptions['ValidateForm'])) {
$plugins = array_merge($plugins, $manager->subscriptions['ValidateForm']);
}
if (isset($manager->subscriptions['PreAddComment'])) {
$plugins = array_merge($plugins, $manager->subscriptions['PreAddComment']);
}
if (isset($manager->subscriptions['PostAddComment'])) {
$plugins = array_merge($plugins, $manager->subscriptions['PostAddComment']);
}
$plugins = array_unique($plugins);
while (list(, $plugin) = each($plugins)) {
$p = $manager->getPlugin($plugin);
$continue = $continue || $p->supportsFeature('handleSpam');
}
$spamcheck = array('type' => 'comment', 'body' => $comment['body'], 'id' => $comment['itemid'], 'live' => TRUE, 'return' => $continue);
// begin if: member logged in
if ($member->isLoggedIn()) {
$spamcheck['author'] = $member->displayname;
$spamcheck['email'] = $member->email;
} else {
$spamcheck['author'] = $comment['user'];
$spamcheck['email'] = $comment['email'];
$spamcheck['url'] = $comment['userid'];
}
// end if
$manager->notify('SpamCheck', array('spamcheck' => &$spamcheck));
if (!$continue && isset($spamcheck['result']) && $spamcheck['result'] == TRUE) {
return _ERROR_COMMENTS_SPAM;
}
// isValidComment returns either "1" or an error message
$isvalid = $this->isValidComment($comment, $spamcheck);
if ($isvalid != 1) {
return $isvalid;
}
// begin if: send email to notification address
if ($settings->getNotifyAddress() && $settings->notifyOnComment()) {
$mailto_msg = _NOTIFY_NC_MSG . ' ' . $this->itemid . "\n";
//.........这里部分代码省略.........
示例14: criteria_pretty
function criteria_pretty($html = false) {
$criteria = explode(' ',$this->criteria);
$words = array(); $spokenby = '';
foreach ($criteria as $c) {
if (preg_match('#^speaker:(\d+)#',$c,$m)) {
$MEMBER = new MEMBER(array('person_id'=>$m[1]));
$spokenby = $MEMBER->full_name();
} else {
$words[] = $c;
}
}
$criteria = '';
if (count($words)) $criteria .= ($html?'<li>':'* ') . 'Containing the ' . make_plural('word', count($words)) . ': ' . join(' ', $words) . ($html?'</li>':'') . "\n";
if ($spokenby) $criteria .= ($html?'<li>':'* ') . "Spoken by $spokenby" . ($html?'</li>':'') . "\n";
return $criteria;
}
示例15: _getItem
/**
* Returns one item (Nucleus version)
*/
function _getItem($itemid, $username, $password)
{
global $manager;
// 1. login
$mem = new MEMBER();
if (!$mem->login($username, $password)) {
return _error(1, "Could not log in");
}
// 2. check if allowed
if (!$manager->existsItem($itemid, 1, 1)) {
return _error(6, "No such item ({$itemid})");
}
$blogid = getBlogIDFromItemID($itemid);
if (!$mem->teamRights($blogid)) {
return _error(3, "Not a team member");
}
// 3. return the item
// Structure returned has dateCreated, userid, blogid and content
$item =& $manager->getItem($itemid, 1, 1);
// (also allow drafts and future items)
$blog = new BLOG($blogid);
if ($blog->convertBreaks()) {
$item['body'] = removeBreaks($item['body']);
}
$newstruct = new xmlrpcval(array("publishDate" => new xmlrpcval(iso8601_encode($item['timestamp']), "dateTime.iso8601"), "userid" => new xmlrpcval($item['authorid'], "string"), "blogid" => new xmlrpcval($blogid, "string"), "title" => new xmlrpcval($item['title'], "string"), "body" => new xmlrpcval($item['body'], "string"), "more" => new xmlrpcval($item['more'], "string"), "draft" => new xmlrpcval($item['draft'], "boolean"), "closed" => new xmlrpcval($item['closed'], "boolean")), 'struct');
return new xmlrpcresp($newstruct);
}