Overview

Packages

  • ClipIt
    • clipit
      • api
    • urjc
      • backend
  • Elgg
    • Core
      • Access
      • Authentication
      • Cache
      • Caches
      • Core
      • DataMode
        • Site
      • DataModel
        • Annotations
        • Entities
        • Extender
        • File
        • Importable
        • Loggable
        • Notable
        • Object
        • User
      • DataStorage
      • Exception
      • Exceptions
        • Stub
      • FileStore
        • Disk
      • Groups
      • Helpers
      • HMAC
      • Memcache
      • Metadata
      • Navigation
      • ODD
      • Output
      • Plugins
        • Settings
      • Sessions
      • SocialModel
        • Friendable
        • Locatable
      • WebServicesAPI
      • Widgets
      • XML
      • XMLRPC
    • Exceptions
      • Stub
  • None
  • PHP

Classes

  • UBCollection
  • UBEvent
  • UBFile
  • UBItem
  • UBMessage
  • UBSite
  • UBUser
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * ClipIt - JuxtaLearn Web Space
  4:  * PHP version:     >= 5.2
  5:  * Creation date:   2013-10-10
  6:  * Last update:     $Date$
  7:  * @author          Pablo LlinĂ¡s Arnaiz <pebs74@gmail.com>, URJC JuxtaLearn Team
  8:  * @version         $Version$
  9:  * @link            http://www.juxtalearn.eu
 10:  * @license         GNU Affero General Public License v3
 11:  * @package         ClipIt
 12:  * @subpackage      urjc_backend
 13:  */
 14: 
 15: /**
 16:  * <Class Description>
 17:  */
 18: class UBEvent {
 19:     /**
 20:      * Get latest array of system events, which cover all user interactions.
 21:      *
 22:      * @param int $offset Skip the first $offset events
 23:      * @param int $limit Return at most $limit events
 24:      *
 25:      * @return array Array of system events
 26:      */
 27:     static function get_latest($offset = 0, $limit = 10) {
 28:         return get_system_log(null, // $by_user
 29:             null, // $event
 30:             null, // $class
 31:             null, // $type
 32:             null, // $subtype
 33:             $limit, // $limit
 34:             $offset, // $offset
 35:             null, // $count
 36:             null, // $timebefore
 37:             null, // $timeafter
 38:             null, // $object_id
 39:             null // $ip_address
 40:         );
 41:     }
 42: 
 43:     /**
 44:      * Get events performed or owned by certain users.
 45:      *
 46:      * @param array $user_array List of user IDs to get related events from
 47:      * @param int $offset Skip the first $offset events
 48:      * @param int $limit Return at most $limit events
 49:      *
 50:      * @return array Array of system events
 51:      */
 52:     static function get_by_user($user_array, $offset = 0, $limit = 10) {
 53:         if (empty($user_array)) {
 54:             return array();
 55:         }
 56:         global $CONFIG;
 57:         $query = "SELECT * FROM {$CONFIG->dbprefix}system_log where ";
 58:         $query .= "performed_by_guid in (" . implode(",", $user_array) . ")";
 59:         $query .= " OR ";
 60:         $query .= "owner_guid in (" . implode(",", $user_array) . ")";
 61:         foreach ($user_array as $user_id) {
 62:             $relationship_array = array_merge(get_entity_relationships($user_id, false),
 63:                 get_entity_relationships($user_id, true));
 64:             if ($relationship_array) {
 65:                 foreach ($relationship_array as $relationship) {
 66:                     $relationship_ids[] = $relationship->id;
 67:                 }
 68:                 if (isset($relationship_ids) and !empty($relationship_ids)) {
 69:                     $query .= " OR ";
 70:                     $query .= "object_id";
 71:                     $query .= " IN (";
 72:                     $query .= implode(",", $relationship_ids) . ")";
 73:                 }
 74:             }
 75:         }
 76:         $query .= " ORDER BY ";
 77:         $query .= "time_created desc";
 78:         $query .= " LIMIT $offset, $limit"; // Add order and limit
 79:         return get_data($query);
 80:     }
 81: 
 82:     /**
 83:      * Get events related to certain objects. The events include relationship events which concern each object.
 84:      *
 85:      * @param array $object_array List of object IDs from which to obtain events
 86:      * @param int $offset Skip the first $offset events
 87:      * @param int $limit Return at most $limit events
 88:      *
 89:      * @return array Array of system events
 90:      */
 91:     static function get_by_object($object_array, $offset = 0, $limit = 10) {
 92:         if (empty($object_array)) {
 93:             return array();
 94:         }
 95:         global $CONFIG;
 96:         $query = "SELECT * FROM {$CONFIG->dbprefix}system_log where ";
 97:         $query .= "object_id IN (" . implode(",", $object_array) . ")";
 98:         $query .= " AND object_type != \"relationship\" AND object_type != \"metadata\"";
 99:         $query .= " UNION";
100:         $query .= " SELECT * FROM {$CONFIG->dbprefix}system_log";
101:         $relationship_array = array();
102:         foreach ($object_array as $object_id) {
103:             $relationship_array = array_merge($relationship_array,
104:                 get_entity_relationships($object_id, false),
105:                 get_entity_relationships($object_id, true));
106:         }
107:         if (!empty($relationship_array)) {
108:             foreach ($relationship_array as $relationship) {
109:                 $relationship_ids[] = $relationship->id;
110:             }
111:             if (isset($relationship_ids) and !empty($relationship_ids)) {
112:                 $query .= " where object_id IN (";
113:                 $query .= implode(",", $relationship_ids) . ") ";
114:                 $query .= " AND object_type = \"relationship\"";
115:             }
116:         }
117:         $query .= " ORDER BY ";
118:         $query .= "time_created desc";
119:         $query .= " LIMIT $offset, $limit"; // Add order and limit
120:         return get_data($query);
121:     }
122: }
API documentation generated by ApiGen 2.8.0