Esempio n. 1
0
 /**
  * Get the parameter array from the parameter string of the database table
  *
  * @param IEvent $event
  * @param string $parsing What are we parsing `message` or `subject`
  * @param string $parameterString can be a JSON string, serialize() or a simple string.
  * @return array List of Parameters
  */
 public function getParameters(IEvent $event, $parsing, $parameterString)
 {
     $parameters = $this->parseParameters($parameterString);
     $parameterTypes = $this->getSpecialParameterList($event->getApp(), $parsing === 'subject' ? $event->getSubject() : $event->getMessage());
     foreach ($parameters as $i => $parameter) {
         $parameters[$i] = $this->parameterFactory->get($parameter, $event, isset($parameterTypes[$i]) ? $parameterTypes[$i] : 'base');
     }
     return $parameters;
 }
Esempio n. 2
0
 /**
  * Send an event into the activity stream
  *
  * @param IEvent $event
  * @return bool
  */
 public function send(IEvent $event)
 {
     if ($event->getAffectedUser() === '' || $event->getAffectedUser() === null) {
         return false;
     }
     // store in DB
     $queryBuilder = $this->connection->getQueryBuilder();
     $queryBuilder->insert('activity')->values(['app' => $queryBuilder->createParameter('app'), 'subject' => $queryBuilder->createParameter('subject'), 'subjectparams' => $queryBuilder->createParameter('subjectparams'), 'message' => $queryBuilder->createParameter('message'), 'messageparams' => $queryBuilder->createParameter('messageparams'), 'file' => $queryBuilder->createParameter('object_name'), 'link' => $queryBuilder->createParameter('link'), 'user' => $queryBuilder->createParameter('user'), 'affecteduser' => $queryBuilder->createParameter('affecteduser'), 'timestamp' => $queryBuilder->createParameter('timestamp'), 'priority' => $queryBuilder->createParameter('priority'), 'type' => $queryBuilder->createParameter('type'), 'object_type' => $queryBuilder->createParameter('object_type'), 'object_id' => $queryBuilder->createParameter('object_id')])->setParameters(['app' => $event->getApp(), 'type' => $event->getType(), 'affecteduser' => $event->getAffectedUser(), 'user' => $event->getAuthor(), 'timestamp' => (int) $event->getTimestamp(), 'subject' => $event->getSubject(), 'subjectparams' => json_encode($event->getSubjectParameters()), 'message' => $event->getMessage(), 'messageparams' => json_encode($event->getMessageParameters()), 'priority' => IExtension::PRIORITY_MEDIUM, 'object_type' => $event->getObjectType(), 'object_id' => (int) $event->getObjectId(), 'object_name' => $event->getObjectName(), 'link' => $event->getLink()])->execute();
     return true;
 }