コード例 #1
0
 public static function updateFor($user_id)
 {
     $blocks = Block::allUserIdsWithBlockingRelationships($user_id);
     $q = Doctrine_Query::create()->update("Autofinger")->set("updated", 1)->where("interest = ?", $user_id)->andWhereNotIn("owner", $blocks);
     return $q->execute();
 }
コード例 #2
0
/**
 * Get a link to the most recently updated plan.
 * @return Hyperlink
 */
function get_just_updated()
{
    // Get the most recently updated plan
    $q = Doctrine_Query::create()->select("userid, username")->from("Accounts")->where("username != 'test'")->andWhereNotIn("userid", Block::allUserIdsWithBlockingRelationships(User::id()))->orderBy("changed DESC")->limit(1);
    //return the results of the query
    $new_plans = $q->fetchOne();
    // Get the appropriate URI for a plan link
    $temp = new PlanLink($new_plans["username"]);
    // But we want a generic Hyperlink, so it can be styled separately.
    return new Hyperlink('justupdatedlink', true, $temp->href, $new_plans["username"]);
}
コード例 #3
0
ファイル: random.php プロジェクト: acohn/grinnellplans-php
<?php

/**
 * Redirects a user to a random plan.
 */
require_once 'Plans.php';
new SessionBroker();
require 'functions-main.php';
if (User::logged_in()) {
    $ids_to_hide = Block::allUserIdsWithBlockingRelationships(User::id());
    array_push($ids_to_hide, User::id());
} else {
    $ids_to_hide = array();
}
$random_query = Doctrine_Query::create()->select('a.username')->from('Accounts a')->leftJoin('a.Plan p')->where('LENGTH(p.edit_text) != 0')->andWhere('changed > DATE_SUB(NOW(), INTERVAL 1 YEAR)')->andWhereNotIn('a.userid', $ids_to_hide);
$offset = rand(0, $random_query->count() - 1);
$random_user = $random_query->offset($offset)->limit(1)->fetchOne();
header("Location: read.php?searchname=" . $random_user->username);
コード例 #4
0
ファイル: search.php プロジェクト: acohn/grinnellplans-php
         $err = new AlertText("Plan [{$mysearch}] does not exist. Please check your spelling.", 'Search failed');
         $thispage->append($err);
         $donotsearch = true;
     } else {
         $plansearchname = "[" . $mysearch . "]";
         $mysearch = $plansearchname;
         $donotsearch = false;
     }
 }
 //if planlove
 if (!$donotsearch) {
     $mysearch = preg_replace("/\\&/", "&amp;", $mysearch);
     $mysearch = preg_replace("/\\</", "&lt;", $mysearch);
     $mysearch = preg_replace("/\\>/", "&gt;", $mysearch);
     $mysearch = preg_quote($mysearch);
     $ids_to_hide = Block::allUserIdsWithBlockingRelationships($idcookie);
     if ($planlove) {
         // hit the index
         $q->select('a.username, p.plan, l.lover_id');
         $q->from('Planlove l')->leftJoin('l.Lover a')->leftJoin('a.Plan p');
         $q->where('l.lovee_id = ?', "{$thesearchnum}");
         $q->andWhereNotIn('l.lover_id', $ids_to_hide);
     } else {
         // do a slow query
         $q->select('a.username, p.plan');
         $q->from('Accounts a')->leftJoin('a.Plan p');
         $q->where('p.edit_text LIKE ?', "%{$mysearch}%");
         $q->andWhereNotIn('a.userid', $ids_to_hide);
     }
     if (!$idcookie) {
         $q->addWhere('a.webview=1');
コード例 #5
0
ファイル: planwatch.php プロジェクト: acohn/grinnellplans-php
//if time is out of acceptable period, set to 12
//give form to set how many hours back to look
$timeform = new Form('planwatchtimeform', true);
$timeform->action = 'planwatch.php';
$timeform->method = 'POST';
$thispage->append($timeform);
$item = new TextInput('mytime', $mytime);
$item->title = 'Plans updated in the past:';
$item->description = 'hours';
$item->cols = 2;
$timeform->append($item);
$item = new SubmitInput('See Plans');
$timeform->append($item);
$q = Doctrine_Query::create()->select("userid,username,DATE_FORMAT(changed,\n'%l:%i %p, %a %M %D ') as updated")->from("Accounts a")->where("changed > DATE_SUB(NOW(), INTERVAL ? HOUR)", $mytime)->orderBy("changed desc");
if (User::logged_in()) {
    $q->andWhereNotIn("userid", Block::allUserIdsWithBlockingRelationships(User::id()));
} else {
    $q->andWhere('webview = 1');
}
$results = $q->fetchArray();
//do the query with specifying date format to be returned
$newplanslist = new WidgetList('new_plan_list', true);
$thispage->append($newplanslist);
//display the results of the query
foreach ($results as $new_plans) {
    $entry = new WidgetGroup('newplan', false);
    $plan = new PlanLink($new_plans["username"]);
    $time = new RegularText($new_plans["updated"], 'Date Created');
    $entry->append($plan);
    $entry->append($time);
    $newplanslist->append($entry);