Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add monitoring page for activities (fixes #4027) #377

Open
wants to merge 1 commit into
base: old-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apps/pc_backend/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ homepage:
url: /
param: { module: default, action: top }

monitoring_activity_list:
url: /monitoring/activityList
params: { module: monitoring, action: activityList }

monitoring_activity_delete:
class: sfDoctrineRoute
url: /monitoring/activity/:id
params: { module: monitoring, action: activityDelete }
options: { model: ActivityData, type: object }
requirements: { sf_method: [delete], id: \d+ }

# mail rules
mail_config:
url: /mail
Expand Down
37 changes: 37 additions & 0 deletions apps/pc_backend/i18n/messages.ja.xml
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,10 @@
<source>Uploaded file list</source>
<target>アップロードファイルリスト</target>
</trans-unit>
<trans-unit id="">
<source>%Activity% list</source>
<target>%Activity%リスト</target>
</trans-unit>
<trans-unit id="">
<source>Cache Clear</source>
<target>キャッシュの削除</target>
Expand Down Expand Up @@ -1469,6 +1473,39 @@
<source>%Community% Sub Administrator</source>
<target>%Community%副管理者</target>
</trans-unit>

<trans-unit id="">
<source>Created Date</source>
<target>作成日時</target>
</trans-unit>
<trans-unit id="">
<source>Author</source>
<target>投稿者</target>
</trans-unit>
<trans-unit id="">
<source>Public Flag</source>
<target>公開範囲</target>
</trans-unit>
<trans-unit id="">
<source>Body</source>
<target>本文</target>
</trans-unit>
<trans-unit id="">
<source>Foreign Table</source>
<target>外部テーブル</target>
</trans-unit>
<trans-unit id="">
<source>Foreign ID</source>
<target>外部ID</target>
</trans-unit>
<trans-unit id="">
<source>Foreign Table / ID</source>
<target>外部テーブル / ID</target>
</trans-unit>
<trans-unit id="">
<source>Reply To ID</source>
<target>返信先ID</target>
</trans-unit>
</body>
</file>
</xliff>
50 changes: 50 additions & 0 deletions apps/pc_backend/modules/monitoring/actions/actions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,54 @@ public function executeFileDownload(sfWebRequest $request)
$file->getFileBin()->getBin()
);
}

/**
* Executes activityList action
*
* @param opWebRequest $request A request object
*/
public function executeActivityList(opWebRequest $request)
{
$query = Doctrine_Core::getTable('ActivityData')->createQuery('r')
->select('r.*, m.name')
->innerJoin('r.Member m')
->orderBy('r.id DESC');

$form = new ActivityDataFormFilter();
$form->setQuery($query);

if ($request->isMethod(sfWebRequest::POST))
{
$form->bind($request->getParameter($form->getName()));
if ($form->isValid())
{
$query = $form->getQuery();
}
}

$maxPerPage = 20;
$pager = new sfDoctrinePager('ActivityData', $maxPerPage);
$pager->setQuery($query);
$pager->setPage((int)$request->getParameter('page', 1));
$pager->init();

$this->form = $form;
$this->pager = $pager;
}

/**
* Executes activityDelete action
*
* @param opWebRequest $request A request object
*/
public function executeActivityDelete(opWebRequest $request)
{
$request->checkCSRFProtection();

$activity = $this->getRoute()->getObject();
$activity->delete();

$this->getUser()->setFlash('notice', 'Deleted.');
$this->redirect(array('sf_route' => 'monitoring_activity_list'));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php slot('submenu') ?>
<?php include_component('monitoring', 'submenu') ?>
<?php end_slot() ?>

<?php slot('title', __('%Activity% list')) ?>

<?php echo $form->renderFormTag(url_for(array('sf_route' => 'monitoring_activity_list'))) ?>
<?php echo $form->renderHiddenFields() ?>
<table>
<tbody>
<?php echo $form ?>
</tbody>
<tfoot>
<tr>
<td colspan="2"><input type="submit" value="<?php echo __('Send') ?>" /></td>
</tr>
</tfoot>
</table>
</form>

<?php if (!$form->hasErrors()): ?>

<p><?php op_include_pager_navigation($pager, '@monitoring_activity_list?page=%d', array('use_current_query_string' => true)) ?></p>

<?php foreach ($pager as $activity): ?>
<table>
<colgroup>
<col style="width: 10em" />
<col />
</colgroup>
<tbody>
<tr>
<th><?php echo __('ID') ?></th>
<td><?php echo $activity->id ?></td>
</tr>
<tr>
<th><?php echo __('Created Date') ?></th>
<td><?php echo $activity->created_at ?></td>
</tr>
<tr>
<th><?php echo __('Author') ?></th>
<td>ID: <?php echo $activity->member_id ?> (<?php echo $activity->Member->name ?>)</td>
</tr>
<tr>
<th><?php echo __('Public Flag') ?></th>
<td><?php echo $activity->getPublicFlagCaption() ?></td>
</tr>
<tr>
<th><?php echo __('Body') ?></th>
<td><?php echo $activity->body ?></td>
</tr>

<?php if (null !== $activity->in_reply_to_activity_id): ?>
<tr>
<th><?php echo __('Reply To ID') ?></th>
<td>
<?php echo $form->renderFormTag(url_for(array('sf_route' => 'monitoring_activity_list'))) ?>
<?php echo $form[sfForm::getCSRFFieldName()] ?>
<input type="hidden" name="<?php echo $form['id']->renderName() ?>[text]" value="<?php echo $activity->in_reply_to_activity_id ?>">
<input type="submit" value="ID: <?php echo $activity->in_reply_to_activity_id ?>" />
</form>
</td>
</tr>
<?php endif ?>

<?php if (null !== $activity->foreign_table): ?>
<tr>
<th><?php echo __('Foreign Table / ID') ?></th>
<td><?php echo $activity->foreign_table ?> / <?php echo $activity->foreign_id ?></td>
</tr>
<?php endif ?>
</tbody>
<tfoot>
<tr>
<td colspan="2">
<?php echo link_to(__('Delete'), array('sf_route' => 'monitoring_activity_delete', 'sf_subject' => $activity), array(
'method' => 'delete',
'confirm' => __('本当に削除してもよろしいですか?'),
)) ?>
</td>
</tr>
</tfoot>
</table>
<?php endforeach // pager ?>

<p><?php op_include_pager_navigation($pager, '@monitoring_activity_list?page=%d', array('use_current_query_string' => true)) ?></p>

<?php endif // hasErrors ?>
4 changes: 4 additions & 0 deletions lib/config/config/monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ editImage:
fileList:
caption: "Uploaded file list"
url: "monitoring/fileList"

fileList:
caption: "%Activity% list"
url: "monitoring/activityList"
69 changes: 69 additions & 0 deletions lib/filter/doctrine/ActivityDataFormFilter.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

/**
* ActivityData filter form.
*
* @package OpenPNE
* @subpackage filter
* @author Kimura Youichi <[email protected]>
*/
class ActivityDataFormFilter extends BaseActivityDataFormFilter
{
public function configure()
{
$this->setWidget('id', new sfWidgetFormFilterInput(array('with_empty' => false)));
$this->setValidator('id', new sfValidatorSchemaFilter('text', new sfValidatorDoctrineChoice(array(
'model' => 'ActivityData',
'column' => 'id',
'required' => false,
))));

$dateParams = array(
'culture' => sfContext::getInstance()->getUser()->getCulture(),
'month_format' => 'number',
'can_be_empty' => true,
);
$this->setWidget('created_at', new sfWidgetFormFilterDate(array(
'from_date' => new opWidgetFormDate($dateParams),
'to_date' => new opWidgetFormDate($dateParams),
'template' => '%from_date% 〜 %to_date%',
'with_empty' => false,
)));

$this->setWidget('foreign_table', new sfWidgetFormFilterInput(array(
'empty_label' => 'NULL',
'template' => '%input% %empty_checkbox% %empty_label%',
)));
$this->setValidator('foreign_table', new sfValidatorSchemaFilter('text', new opValidatorString(array('required' => false))));

$this->setWidget('foreign_id', new sfWidgetFormFilterInput(array('with_empty' => false)));

$this->setWidget('in_reply_to_activity_id', new sfWidgetFormInput());

$this->widgetSchema->setLabels(array(
'id' => 'ID',
'created_at' => 'Created Date',
'member_id' => 'Author',
'body' => 'Body',
'foreign_table' => 'Foreign Table',
'foreign_id' => 'Foreign ID',
'in_reply_to_activity_id' => 'Reply To ID',
));

$this->useFields(array('id', 'created_at', 'member_id', 'body', 'foreign_table', 'foreign_id', 'in_reply_to_activity_id'));
}

protected function addForeignTableColumnQuery(Doctrine_Query $query, $field, $values)
{
$fieldName = $this->getFieldName($field);

if (isset($values['is_empty']) && $values['is_empty'])
{
$query->addWhere(sprintf('%s.%s IS NULL', $query->getRootAlias(), $fieldName));
}
elseif (isset($values['text']) && '' !== $values['text'])
{
$query->addWhere(sprintf('%s.%s = ?', $query->getRootAlias(), $fieldName), $values['text']);
}
}
}