Ejemplo n.º 1
0
 /**
  * Verify that Mollom data can be deleted.
  */
 function testDelete()
 {
     // Create a data record.
     $data1 = (object) array('entity' => 'type1', 'id' => 123, 'form_id' => 'type1_form', 'contentId' => 1);
     ResponseDataStorage::save($data1);
     // Create a second data record; same ID, different entity type.
     $data2 = (object) array('entity' => 'type2', 'id' => 123, 'form_id' => 'type2_form', 'contentId' => 2);
     ResponseDataStorage::save($data2);
     // Verify that both records exist.
     $this->assertMollomData($data1->entity, $data1->id, 'contentId', $data1->contentId);
     $this->assertMollomData($data2->entity, $data2->id, 'contentId', $data2->contentId);
     // Delete the first data record.
     ResponseDataStorage::delete($data1->entity, $data1->id);
     // Verify that only the second record remained and was not changed.
     $this->assertNoMollomData($data1->entity, $data1->id);
     $this->assertMollomData($data2->entity, $data2->id, 'contentId', $data2->contentId);
 }
Ejemplo n.º 2
0
 /**
  * Submit handler for feedback options.
  */
 public static function addFeedbackOptionsSubmit(&$form, FormStateInterface &$form_state)
 {
     $forms = FormController::getProtectedForms();
     $mollom_form = Form::load($forms['delete'][$form_state->getFormObject()->getFormId()])->initialize();
     $entity_type = $mollom_form['entity'];
     if (!empty($entity_type)) {
         $id = $form_state->getFormObject()->getEntity()->id();
     } else {
         $id = $form_state->getValue($mollom_form['mapping']['post_id']);
     }
     $feedback = $form_state->getValue(array('mollom', 'feedback'));
     if (!empty($feedback)) {
         if (self::sendFeedback($entity_type, $id, $feedback, 'moderate', 'mollom_data_delete_form_submit')) {
             drupal_set_message(t('The content was successfully reported as inappropriate.'));
         }
     }
     // Remove Mollom session data.
     ResponseDataStorage::delete($entity_type, $id);
 }