Created
April 27, 2011 01:56
-
-
Save 77web/943590 to your computer and use it in GitHub Desktop.
opAshiatoPluginのPluginAshiatoTableの修正提案
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This file is part of the OpenPNE package. | |
* (c) OpenPNE Project (http://www.openpne.jp/) | |
* | |
* For the full copyright and license information, please view the LICENSE | |
* file and the NOTICE file that were distributed with this source code. | |
*/ | |
/** | |
* PluginAshiatoTable | |
* | |
* @package opAshiatoPlugin | |
* @subpackage Ashiato | |
* @author Shingo Yamada <s.yamada@tejimaya.com> | |
*/ | |
class PluginAshiatoTable extends Doctrine_Table | |
{ | |
public function getAshiatoListPager($memberId, $page = 1, $size = 20) | |
{ | |
$q = $this->createQuery('a') | |
->select('MAX(a.updated_at) as max_updated_at') | |
->where('a.member_id_to = ?', $memberId) | |
->groupBy('a.r_date, a.member_id_from') | |
->orderBy('a.updated_at DESC') | |
->leftJoin('a.Member_2 m'); | |
$pager = new opNonCountQueryPager('Ashiato', $size); | |
$pager->setQuery($q); | |
$pager->setPage($page); | |
$pager->init(); | |
return $pager; | |
} | |
public function getAshiatoMemberListCount($memberId) | |
{ | |
$q = $this->createQuery() | |
->where('member_id_to = ?', $memberId); | |
return $q->count(); | |
} | |
public function setAshiatoMember($memberIdTo, $memberIdFrom) | |
{ | |
if ($memberIdTo == $memberIdFrom) { | |
return false; | |
} | |
$wait = date('Y-m-d H:i:s', strtotime('-' . sfConfig::get('app_update_span_minute') . 'minute')); | |
$q = Doctrine_Query::create() | |
->select('id') | |
->from('ashiato') | |
->where('member_id_to = ?', $memberIdTo) | |
->andwhere('member_id_from = ?', $memberIdFrom) | |
->andWhere('updated_at > ?', $wait) | |
->limit(1); | |
if (count($q->execute(array(), Doctrine::HYDRATE_NONE))) | |
{ | |
return false; | |
} | |
$ashiato = new Ashiato(); | |
$ashiato->setMemberIdFrom($memberIdFrom); | |
$ashiato->setMemberIdTo($memberIdTo); | |
$ashiato->setRDate(date('Y-m-d')); | |
$ashiato->save(); | |
return $ashiato->getID(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="dparts ashiatoList"><div class="parts"> | |
<div class="partsHeading"><h3><?php echo __('Pageview logs') ?></h3></div> | |
<div class="partsInfo"> | |
<p> | |
<?php echo __('Pageview Logs of %1%', array('%1%' => $sf_user->getMember()->getName())) ?> | |
<?php echo __('Pageview %d Logs Explanation', array('%d' => sfConfig::get('mod_ashiato_max_ashiato'))) ?> | |
</p> | |
</div> | |
<div class="item"> | |
<p><?php echo __('Pageview %d Count', array('%d' =>$count)) ?></p> | |
<ul class="list"> | |
<?php foreach ($pager->getResults() as $ashiato) : ?> | |
<li><?php echo op_format_date($ashiato->updated_at, 'XDateTimeJaBr'); ?> | |
<?php echo $ashiato->Member_2->getId() > 0 ? link_to($ashiato->Member_2->name, 'member/profile?id=' . $ashiato->Member_2->id) : '-'; ?></li> | |
<?php endforeach; ?> | |
</ul> | |
</div> | |
</div></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment