コード例 #1
0
 function __construct()
 {
     $ref = get_http_var('ref');
     $this->journo = db_getRow("SELECT * FROM journo WHERE ref=?", $ref);
     $r = array('reason_web' => "Edit Journalisted profile for {$this->journo['prettyname']}", 'reason_email' => "Edit Journalisted profile for {$this->journo['prettyname']}", 'reason_email_subject' => "Edit {$this->journo['prettyname']} on Journalisted");
     if (get_http_var('ajax')) {
         $this->P = person_if_signed_on();
     } else {
         // if not ajax, it's ok to redirect to login screen
         $this->P = person_signon($r);
     }
 }
コード例 #2
0
ファイル: account.php プロジェクト: bcampbell/journalisted
function account_page()
{
    $r = array('reason_web' => "Log in", 'reason_email' => "Log in to Journalisted", 'reason_email_subject' => 'Log in to Journalisted');
    $P = person_signon($r);
    $passwordbox = new PasswordBox();
    // linked to a journo for editing (or claim pending)?
    $sql = <<<EOT
SELECT j.*, perm.permission
    FROM journo j INNER JOIN person_permission perm
        ON perm.journo_id=j.id
    WHERE perm.permission in ('edit','claimed') AND perm.person_id=?
    LIMIT 1
EOT;
    $journo = db_getRow($sql, $P->id());
    // signed up for newsletters?
    $newsletter = db_getOne("SELECT person_id FROM person_receives_newsletter WHERE person_id=?", $P->id()) ? TRUE : FALSE;
    // how many alerts set up?
    $alert_cnt = db_getOne("SELECT count(*) FROM alert WHERE person_id=?", $P->id());
    // what bits of profile have been filled in?
    $photo_cnt = 0;
    $edu_cnt = 0;
    $emp_cnt = 0;
    $book_cnt = 0;
    $award_cnt = 0;
    $admired_cnt = 0;
    if (!is_null($journo)) {
        $photo_cnt = db_getOne("SELECT count(*) FROM journo_photo WHERE journo_id=?", $journo['id']);
        $edu_cnt = db_getOne("SELECT count(*) FROM journo_education WHERE journo_id=?", $journo['id']);
        $emp_cnt = db_getOne("SELECT count(*) FROM journo_employment WHERE journo_id=?", $journo['id']);
        $book_cnt = db_getOne("SELECT count(*) FROM journo_books WHERE journo_id=?", $journo['id']);
        $award_cnt = db_getOne("SELECT count(*) FROM journo_awards WHERE journo_id=?", $journo['id']);
        $admired_cnt = db_getOne("SELECT count(*) FROM journo_admired WHERE journo_id=?", $journo['id']);
        $weblink_cnt = db_getOne("SELECT count(*) FROM journo_weblink WHERE kind<>'pingback' AND journo_id=?", $journo['id']);
        // collect contact details from all around
        $sql = <<<EOT
SELECT
    ( SELECT count(*) FROM journo_address WHERE journo_id=? ) +
    ( SELECT count(*) FROM journo_phone WHERE journo_id=? ) +
    ( SELECT count(*) FROM journo_email WHERE approved=true AND journo_id=? ) +
    ( SELECT count(*) FROM journo_weblink WHERE kind='twitter' AND journo_id=? ) +
    ( SELECT count(*) FROM journo_address WHERE journo_id=? );
EOT;
        $contact_cnt = db_getOne($sql, $journo['id'], $journo['id'], $journo['id'], $journo['id'], $journo['id']);
        // combined article count (ugh)
        $sql = <<<EOT
SELECT (
    SELECT COUNT(*)
        FROM (article a INNER JOIN journo_attr attr ON attr.journo_id=a.id)
        WHERE a.status='a' AND attr.journo_id=?
    ) + (
    SELECT COUNT(*)
        FROM journo_other_articles
        WHERE status='a' AND journo_id=?
    )
EOT;
        $article_cnt = db_getOne($sql, $journo['id'], $journo['id']);
    }
    $name_or_email = $P->name_or_blank() ? $P->name : $P->email;
    $title = "Your account";
    page_header($title);
    if (!is_null($journo) && $journo['permission'] == 'edit' && $journo['status'] == 'i') {
        emit_inactive_note($journo);
    }
    ?>
<div class="main account">

<h2>Welcome to journa<i>listed</i>, <?php 
    echo $name_or_email;
    ?>
</h2>
<?php 
    /* show a bunch of things user could/should do now... */
    if (!is_null($journo) && $journo['permission'] == 'claimed') {
        emit_claim_pending($journo);
    }
    if (!is_null($journo) && $journo['permission'] == 'edit') {
        ?>
Your public profile is at:<br/>
<a class="public-profile-location" href="/<?php 
        echo $journo['ref'];
        ?>
"><?php 
        echo OPTION_BASE_URL . '/' . $journo['ref'];
        ?>
</a>
<br/>
<?php 
    }
    ?>
Things you can do now...
<br/>
<?php 
    $n = 0;
    // track the number of items we're displaying
    if (!is_null($journo) && $journo['permission'] == 'edit') {
        if ($article_cnt < OPTION_JL_JOURNO_ACTIVATION_THRESHOLD) {
            emit_add_articles($journo);
            ++$n;
        }
        if ($photo_cnt == 0) {
            emit_add_photo($journo);
            ++$n;
        }
        if ($emp_cnt == 0) {
            emit_add_experience($journo);
            ++$n;
        }
        if ($edu_cnt == 0) {
            emit_add_education($journo);
            ++$n;
        }
        if ($weblink_cnt == 0) {
            emit_add_links($journo);
            ++$n;
        }
        if ($admired_cnt == 0) {
            emit_add_admired($journo);
            ++$n;
        }
        if ($contact_cnt == 0) {
            emit_add_contact_details($journo);
            ++$n;
        }
    }
    if ($alert_cnt == 0 && $n < 6 || $n < 2) {
        emit_add_alerts($alert_cnt);
        ++$n;
    }
    if (!$newsletter && $n < 6 || $n < 2) {
        emit_subscribe_to_newsletter($newsletter);
        ++$n;
    }
    ?>

</div>  <!-- end main -->

<div class="sidebar">
<div class="box">
  <div class="head">
    <h3><?php 
    echo $passwordbox->title();
    ?>
</h3>
  </div>
  <div class="body">
  <?php 
    $passwordbox->emit();
    ?>
  <p>If you need to change your email address, please <?php 
    echo SafeMailto(OPTION_TEAM_EMAIL, "let us know");
    ?>
</p>
  </div>
  <div class="foot"></div>
</div>
</div> <!-- end sidebar -->
<?php 
    page_footer();
}
コード例 #3
0
ファイル: alert.php プロジェクト: bcampbell/journalisted
    $P = person_signon($r);
    /* will redirect to login.php if person not logged in, then come back here afterward */
} else {
    if (get_http_var('Remove')) {
        $journo_ref = get_http_var('j');
        $jname = db_getOne("SELECT prettyname FROM journo WHERE ref=? AND status='a'", $journo_ref);
        // remove an alert...
        $r = array('reason_web' => "Remove email alert for {$jname}", 'reason_email' => "Remove email alert for {$jname}", 'reason_email_subject' => "Remove a Journalisted email alert");
        $P = person_signon($r);
        /* will redirect to login.php if person not logged in, then come back here afterward */
    } else {
        // default - just viewing existing alerts (or updating password)
        $r = array('reason_web' => "Manage your email alerts", 'reason_email' => "Manage your email alerts", 'reason_email_subject' => 'Journalisted: manage your email alerts');
        if (strtolower(get_http_var('dologin', 'no')) == 'yes') {
            // insist that user logs in before going any further
            $P = person_signon($r);
        } else {
            $P = person_if_signed_on();
        }
    }
}
page_header("Alerts", array('menupage' => 'my'));
?>
<div class="main">
<div class="head"></div>
<div class="body">
<h2>Alerts</h2>
<p>
Follow your favourite journalist(s).<br />
Just enter your email address and you’ll be able to pick
any bylined journalists from the national press or the BBC. Every time s/he writes a new article
コード例 #4
0
ファイル: login.php プロジェクト: bcampbell/journalisted
<!-- <?php 
    echo "{$file}:{$line}";
    ?>
 -->
<?php 
    page_footer();
}
err_set_handler_display('jl_handle_error');
EnsureCookiesEnabled();
/* Get all the parameters which we might use (pulls them into $q_ prefixed vars) */
importparams(array('stash', '/^[0-9a-f]+$/', '', null), array('email', '/./', '', null), array(array('name', true), '//', '', null), array('password', '/[^\\s]/', '', null), array('t', '/^.+$/', '', null), array('rememberme', '/./', '', false));
/* General purpose login, asks for email also. */
if (0) {
    // CRUFT???
    if (get_http_var("now")) {
        $P = person_signon(array('reason_web' => "Log in", 'reason_email' => "Log in to Journalisted", 'reason_email_subject' => 'Log in to Journalisted'));
        // account management page
        header("Location: /account");
        exit;
    }
}
/* is there a token? (i.e. user coming in via a confirmation email) */
if (!is_null($q_t)) {
    $q_t = preg_replace('#</a$#', '', $q_t);
    /* Process emailed token */
    $d = auth_token_retrieve('login', $q_t);
    if (!$d) {
        err(sprintf(_("Please check the URL (i.e. the long code of letters and numbers) is copied correctly from your email.  If you can't click on it in the email, you'll have to select and copy it from the email.  Then paste it into your browser, into the place you would type the address of any other webpage. Technical details: The token '%s' wasn't found."), $q_t));
    }
    $P = person_get($d['email']);
    if (is_null($P)) {