Beispiel #1
0
 static function get_by_user(midcom_core_user $user, $limit = 20, $offset = 0)
 {
     $actor = $user->get_storage();
     $qb = midcom_helper_activitystream_activity_dba::new_query_builder();
     $qb->add_constraint('actor', '=', $actor->id);
     $qb->add_order('metadata.created', 'DESC');
     $qb->set_limit($limit);
     $qb->set_offset($offset);
     return $qb->execute();
 }
Beispiel #2
0
 /**
  * Checks the online state of a given user. You require the privilege midcom:isonline
  * for the user you are going to check. The privilege is not granted by default,
  * to allow users full control over their privacy.
  *
  * 'unknown' is returned in cases where you have insufficient permissions.
  *
  * @param midcom_core_user $user The user object which has been updated.
  * @return string One of 'online', 'offline' or 'unknown', indicating the current online
  *     state.
  */
 function is_user_online($user)
 {
     if (!$user->get_storage()->can_do('midcom:isonline')) {
         return 'unknown';
     }
     $timed_out = time() - $GLOBALS['midcom_config']['auth_login_session_timeout'];
     $qb = new midgard_query_builder('midcom_core_login_session_db');
     $qb->add_constraint('userid', '=', $user->id);
     $qb->add_constraint('timestamp', '>=', $timed_out);
     $result = @$qb->execute();
     if (!$result) {
         return 'offline';
     }
     return 'online';
 }
Beispiel #3
0
 public static function &_get_cache($type, $id, &$request_data)
 {
     self::_verify_cache($type, $request_data);
     if (!array_key_exists($id, $request_data['object_cache'][$type])) {
         switch ($type) {
             case 'users':
                 $core_user = new midcom_core_user($id);
                 $obj = $core_user->get_storage();
                 break;
             case 'groups':
                 $obj = new org_openpsa_contacts_group_dba($id);
                 break;
             default:
                 $method = "_get_cache_obj_{$type}";
                 $classname = __CLASS__;
                 if (!method_exists($classname, $method)) {
                     // TODO: generate error
                     debug_add("Method '{$method}' not in class '{$classname}'", MIDCOM_LOG_WARN);
                     return false;
                 }
                 $obj = call_user_func(array($classname, $method), $id);
                 break;
         }
         $request_data['object_cache'][$obj->guid] = $obj;
         $request_data['object_cache'][$type][$obj->id] =& $request_data['object_cache'][$obj->guid];
     } else {
         $obj =& $request_data['object_cache'][$type][$id];
     }
     return $request_data['object_cache'][$type][$obj->id];
 }