public function _on_updated() { // Invalidate topic in cache to refresh all views // TODO: Do this only on status changes $topic = midcom_db_topic::get_cached($this->topic); if ($topic->guid) { $_MIDCOM->cache->invalidate($topic->guid); } if (isset($GLOBALS['disable_activitystream'])) { return true; } if ($_MIDCOM->auth->request_sudo('midcom')) { $actor = midcom_db_person::get_cached($_MIDGARD['user']); $activity = new midcom_helper_activitystream_activity_dba(); $activity->target = $this->guid; $activity->application = 'fi.kilonkipinat.account'; $activity->actor = $actor->id; $activity->verb = 'http://activitystrea.ms/schema/1.0/post'; if ($this->id == $actor->id) { $activity->summary = sprintf('%s muokkasi omaa tunnustaan', $actor->name); } else { $tmp_name = $this->firstname . ' ' . $this->lastname; $activity->summary = sprintf('%s muokkasi %s:n tunnusta', $actor->name, $tmp_name); } $activity->create(); $_MIDCOM->auth->drop_sudo(); } return true; }
public function _on_updated() { // Invalidate topic in cache to refresh all views // TODO: Do this only on status changes if (isset($GLOBALS['disable_activitystream'])) { return true; } if ($_MIDCOM->auth->request_sudo('midcom')) { // This is here because creating an object calls create and update..... and we don't want duplicate entry's $qb = midcom_helper_activitystream_activity_dba::new_query_builder(); $qb->set_limit(1); $qb->add_constraint('application', '=', 'fi.kilonkipinat.forms'); $qb->add_constraint('target', '=', $this->guid); $groups = $qb->execute(); if ($groups && is_array($groups) && count($groups) > 0) { $new_object = false; } else { $new_object = true; } $actor = midcom_db_person::get_cached($_MIDGARD['user']); $activity = new midcom_helper_activitystream_activity_dba(); $activity->target = $this->guid; $activity->application = 'fi.kilonkipinat.forms'; $activity->actor = $actor->id; $activity->verb = 'http://activitystrea.ms/schema/1.0/post'; if ($new_object) { $activity->summary = sprintf('%s loi kulukorvauslomakkeen', $actor->name); } else { $activity->summary = sprintf('%s muokkasi kulukorvauslomaketta', $actor->name); } $activity->create(); $_MIDCOM->auth->drop_sudo(); } return true; }
public function _on_watched_operation($operation, $object) { if (!$object->_use_activitystream) { // Activity Log not used for this object return; } // Create an activity log entry if (!midcom::get('auth')->request_sudo('midcom.helper.activitystream')) { // Not allowed to create activity logs return; } $activity = new midcom_helper_activitystream_activity_dba(); $activity->target = $object->guid; if ($object->_activitystream_verb) { $activity->verb = $object->_activitystream_verb; } else { $activity->verb = midcom_helper_activitystream_activity_dba::operation_to_verb($operation); } if (!$activity->verb) { debug_add('Cannot generate a verb for the activity, skipping'); midcom::get('auth')->drop_sudo(); return; } static $handled_targets = array(); if (isset($handled_targets["{$activity->target}_{$activity->actor}"])) { // We have already created an entry for this object in this request, skip return; } if ($object->_rcs_message) { $activity->summary = $object->_rcs_message; } if (midcom::get('auth')->user) { $actor = midcom::get('auth')->user->get_storage(); $activity->actor = $actor->id; } $activity->application = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_COMPONENT); if ($activity->create()) { $handled_targets["{$activity->target}_{$activity->actor}"] = true; } midcom::get('auth')->drop_sudo(); }
if (in_array($result->target, $valid_targets)) { continue; } if (in_array($result->target, $invalid_targets)) { continue; } try { $object = midcom::get('dbfactory')->get_object_by_guid($result->target); $valid_targets[] = $object->guid; } catch (midcom_error $e) { if (midcom_connection::get_error() === MGD_ERR_OBJECT_DELETED) { $valid_targets[] = $result->target; } else { if (midcom_connection::get_error() === MGD_ERR_OBJECT_PURGED || midcom_connection::get_error() === MGD_ERR_NOT_EXISTS) { $invalid_targets[] = $result->target; $delete_qb = midcom_helper_activitystream_activity_dba::new_query_builder(); $delete_qb->add_constraint('target', '=', $result->target); $to_delete = $delete_qb->execute(); if (sizeof($to_delete) == 0) { continue; } echo "Deleting " . sizeof($to_delete) . " entries for purged target " . $result->target . " \n"; flush(); foreach ($to_delete as $entry) { if (!$entry->delete()) { echo 'ERROR: Deleting entry ' . $entry->guid . ' failed: ' . midcom_connection::get_error_string() . " \n"; } else { $entry->purge(); } } } else {
public function _on_deleted() { $this->_invalidate_person_cache(); if (!midcom::get('auth')->request_sudo('midcom')) { return; } // Create an Activity Log entry for the membership addition try { $actor = midcom_db_person::get_cached($this->uid); $target = midcom_db_group::get_cached($this->gid); } catch (midcom_error $e) { $e->log(); return; } $activity = new midcom_helper_activitystream_activity_dba(); $activity->target = $target->guid; $activity->actor = $actor->id; $activity->verb = 'http://community-equity.org/schema/1.0/leave'; if (midcom::get('auth')->is_valid_user() && $actor->guid == midcom::get('auth')->user->guid) { $activity->summary = sprintf(midcom::get('i18n')->get_string('%s left group %s', 'midcom'), $actor->name, $target->official); } else { $activity->summary = sprintf(midcom::get('i18n')->get_string('%s was removed from group %s', 'midcom'), $actor->name, $target->official); } $activity->create(); midcom::get('auth')->drop_sudo(); }
public function _on_creating() { if (!$this->summary) { $this->summary = midcom_helper_activitystream_activity_dba::generate_summary($this); } if (!$this->verb || !$this->summary || !$this->target) { return false; } return true; }
if ($data['config']->get('enable_review_dates')) { $review_date = $object->get_parameter('midcom.helper.metadata', 'review_date'); if (!$review_date) { echo " <td class=\"review_by\">N/A</td>\n"; } else { echo " <td class=\"review_by\">" . strftime('%x', $review_date) . "</td>\n"; } } echo " <td class=\"revised\">" . strftime('%x %X', $object->metadata->revised) . "</td>\n"; echo " <td class=\"revisor\">{$revisor_name}</td>\n"; echo " <td class=\"approved\">{$approved_str}</td>\n"; echo " <td class=\"revision\">{$object->metadata->revision}</td>\n"; echo " </tr>\n"; } } else { $activities = midcom_helper_activitystream_activity_dba::get($data['config']->get('last_visited_size')); if (count($activities) > 0) { $reflectors = array(); foreach ($activities as $activity) { try { $object = midcom::get('dbfactory')->get_object_by_guid($activity->target); } catch (midcom_error $e) { if (midcom_connection::get_error() == MGD_ERR_OBJECT_DELETED) { // TODO: Visualize deleted objects somehow } continue; } if (!isset($actors)) { $actors = array(); } if (!isset($actors[$activity->actor])) {