Ejemplo n.º 1
0
 /**
  * Delete a default widget and ensure that it can be recreated
  */
 public function testDefaultWidgetRecreation()
 {
     $profile = $this->profiles('adminProfile');
     $widgetSubtype = 'ContactsGridViewProfileWidget';
     $success = SortableWidget::deleteSortableWidget($profile, $widgetSubtype, '', 'profile');
     $this->assertTrue($success);
     $widgetLayoutBefore = $profile->profileWidgetLayout;
     $widgetSettings = $widgetLayoutBefore[$widgetSubtype];
     $this->assertTrue($widgetSettings['softDeleted']);
     list($success, $uid) = SortableWidget::createSortableWidget($profile, $widgetSubtype, 'profile');
     $this->assertTrue($success);
     $widgetLayoutAfter = $profile->profileWidgetLayout;
     $widgetSettings = $widgetLayoutAfter[$widgetSubtype];
     $this->assertFalse($widgetSettings['softDeleted']);
     $this->assertEquals(array_keys($widgetLayoutBefore), array_keys($widgetLayoutAfter));
 }
Ejemplo n.º 2
0
 public function actionDeleteSortableWidget()
 {
     if (!isset($_POST['widgetLayoutName']) || !isset($_POST['widgetKey'])) {
         throw new CHttpException(400, 'Bad Request');
     }
     $widgetKey = $_POST['widgetKey'];
     $profile = self::getModelFromPost();
     list($widgetClass, $widgetUID) = SortableWidget::parseWidgetLayoutKey($widgetKey);
     $widgetLayoutName = $_POST['widgetLayoutName'];
     if (SortableWidget::subtypeIsValid($widgetLayoutName, $widgetClass)) {
         if (SortableWidget::deleteSortableWidget($profile, $widgetClass, $widgetUID, $widgetLayoutName)) {
             echo 'success';
             return;
         }
     }
     echo 'failure';
 }