/** * Get schema name for person * * @return string Schema name */ public function get_person_schema(org_openpsa_contacts_person_dba $contact) { $my_company_guid = $this->_config->get('owner_organization'); if (empty($my_company_guid) || !mgd_is_guid($my_company_guid)) { if (midcom::get('auth')->admin) { midcom::get('uimessages')->add($this->_l10n->get($this->_component), $this->_l10n->get('owner organization couldnt be found'), 'error'); } } else { // Figure out if user is from own organization or other org $person_user = new midcom_core_user($contact->id); if ($person_user->is_in_group("group:{$my_company_guid}")) { return 'employee'; } } return null; }
/** * 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'; }
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]; }
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(); }
<?php $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); $username = $data['account']->get_username(); ?> <div class="area org_openpsa_helper_box"> <h3><?php echo $data['l10n']->get("user account"); ?> </h3> <?php if ($username) { echo "<p>{$username}</p>\n"; $user = new midcom_core_user($data['person']); if ($user->is_online() == 'online') { echo '<p>' . $data['l10n']->get('user is online') . "</p>\n"; } else { if ($lastlogin = $user->get_last_login()) { echo '<p>' . $data['l10n']->get('last login') . ': ' . strftime('%x %X', $lastlogin) . "</p>\n"; } } if ($data['person']->id == midcom_connection::get_user() || midcom::get('auth')->can_user_do('org.openpsa.user:manage', null, 'org_openpsa_user_interface')) { echo '<ul class="area_toolbar">'; echo '<li><a class="button" href="' . $prefix . 'account/edit/' . $data['person']->guid . '/" />' . $data['l10n_midcom']->get('edit') . "</a></li>\n"; echo '<li><a class="button" href="' . $prefix . 'account/delete/' . $data['person']->guid . '/" />' . $data['l10n_midcom']->get('delete') . "</a></li>\n"; if ($GLOBALS['midcom_config']['auth_allow_trusted'] === true && $data['person']->can_do('org.openpsa.user:su')) { echo '<li><a class="button" href="' . $prefix . 'account/su/' . $data['person']->guid . '/" />' . $data['l10n']->get('switch to user') . "</a></li>\n"; } echo "</ul>\n"; } } else {