public function group($group)
 {
     $this->_render['template'] = 'index';
     $type = Activity::group($group);
     $this->set(compact('group'));
     return $this->index(array('conditions' => compact('type')));
 }
Пример #2
0
 /**
  * returns a list of activies, according to a given type, group or other conditions
  *
  * {{{
  *   Activities::get('event_type');
  *   Activities::get('group_name');
  *   Activities::get(array('type' => 'event_type'));
  *   Activities::get(array('type' => array('event_type1', 'event_type2')));
  *   Activities::get(array('group' => 'group_name'));
  *   Activities::get(array('foreign_id' => $id));
  *   Activities::get(array('foreign_id' => array($id1, $id2)));
  * }}}
  *
  * @see lithium\data\Model::find()
  * @param string|array $scope if string is given, a check is made of a group with that name
  *        exists and if so, the types for that group will be retrieved. If no group exists, it
  *        will be used as name for event_type, without any further checks.
  *        If it is an array, it can be used like `conditions` as on `Model::find()`, the most
  *        useful use-case would be to pass in a foreign_id, like `array('user_id' => $id)`.
  * @param array $options additional options, identical to those for `Model::find()`
  * @return object a collection object, containing all resulting activities, also:
  *     - `since`: id of last activity, to retrieve data since then
  * @filter
  */
 public static function get($scope, array $options = array())
 {
     $defaults = array('since' => false);
     $options += $defaults;
     $params = compact('scope', 'options');
     return static::_filter(__METHOD__, $params, function ($self, $params) {
         extract($params);
         if (is_string($scope)) {
             $types = Activity::group($scope);
             $scope = !empty($types) ? array('type' => $types) : array('type' => $scope);
         }
         if (isset($scope['group'])) {
             $scope['type'] = Activity::group($scope['group']);
             unset($scope['group']);
         }
         if ($options['since']) {
             $entity = $self::first($options['since'], array('fields' => 'created'));
             if ($entity) {
                 $scope['created'] = array('>=' => $entity->created);
             }
         }
         unset($options['since']);
         $options['conditions'] = $scope;
         return $self::find('all', $options);
     });
 }
Пример #3
0
/**
 * Default configuration uses built-in Model to track
 * all Activity on your application. Please provide
 * useful messages in `events.php`. Currently
 * there is only one Adapter, Model which you can
 * also use to track Activity with your own custom
 * Model. In that case, you should implement a static
 * method track() with the same signature as provided
 * by the built-in Activity Model.
 *
 * @see li3_activities\core\Activity
 * @see li3_activities\extensions\adapter\activities\Model
 * @see li3_activities\models\Activities
 * @see lithium\core\Adaptable
 */
Activity::config(array('default' => array('adapter' => 'Model')));
/**
 * Example of a custom Activity Class
 *
 * In order to allow for that, you should implement a static
 * method `track` in your Model, that works as the one provided
 * with this library. Make sure, you parse the message to benefit
 * from pre-parsed messages while reading Activity logs.
 *
 * @see li3_activities\core\Activity
 * @see li3_activities\extensions\adapter\activities\Model
 * @see li3_activities\models\Activities
 * @see lithium\core\Adaptable
 */
// Activity::config(array(
// 	'custom' => array(
Пример #4
0
use li3_activities\core\Activity;
/**
 * Events should be configured, in order to parse a message
 * for a given type. It can contain placeholders and given
 * data will be used to replace those. Make sure, you
 * always put in the data you need in order to generate
 * the messages, you may want (even later on).
 * Also, have a look at String::insert() to see, how
 * placeholders work.
 *
 * @see li3_activities\core\Activity::events()
 * @see li3_activities\core\Activity
 * @see lithium\util\String::insert()
 */
Activity::events(array('saved' => '{:name} [{:id}] {:type}.'));
/**
 * Here we filter our-self into the whole application to
 * track Activity on whatever interests us.
 *
 * @see lithium\core\StaticObject::applyFilter()
 * @see li3_activities\core\Activity
 */
/**
 * Write an Activity for any Model::save().
 *
 * In order to have this working, copy it to your applications bootstrap
 * and adjust the model namespace and name to your own model
 *
 * @see lithium\data\Model
 * @see li3_activities\core\Activity