<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/

class Core_Widget_AdminRecentActivityController extends Engine_Content_Widget_Abstract {

  public function indexAction() {
  
    //Action type
    $mainActionTypes = array();
    $masterActionTypes = Engine_Api::_()->getDbtable('actionTypes', 'activity')->getActionTypes();
    foreach( $masterActionTypes as $type ) {
      $mainActionTypes[] = $type->type;
    }
    
    $table = Engine_Api::_()->getDbTable('actions', 'activity');
    $select = $table->select()
            ->from($table->info('name'))
            ->order('action_id DESC')
            ->limit(10);
    if(engine_count($mainActionTypes) > 0) {
      $select->where('type IN (?)', $mainActionTypes);
    }
    $this->view->results = $table->fetchAll($select);
  }
}
