Ejemplo n.º 1
0
 public function actionDelete($id)
 {
     $emailTemplate = static::getModelAndCatchNotFoundAndDisplayError('EmailTemplate', intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($emailTemplate);
     $type = $emailTemplate->type;
     $emailTemplate->delete();
     if ($type == EmailTemplate::TYPE_WORKFLOW) {
         $this->redirect(array($this->getId() . '/listForWorkflow'));
     } elseif ($emailTemplate->type == EmailTemplate::TYPE_CONTACT) {
         $this->redirect(array($this->getId() . '/listForMarketing'));
     } else {
         throw new NotSupportedException();
     }
 }
 public function actionDelete($id)
 {
     $savedWorkflow = SavedWorkflow::GetById(intval($id));
     ControllerSecurityUtil::resolveCanCurrentUserAccessModule($savedWorkflow->moduleClassName);
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($savedWorkflow);
     $savedWorkflow->delete();
     $this->redirect(array($this->getId() . '/index'));
 }
 /**
  * @depends testResolveAccessCanCurrentUserWriteModel
  */
 public function testResolveAccessCanCurrentUserDeleteModel()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $accounts = Account::getByName('Supermart');
     $this->assertEquals(1, count($accounts));
     $betty = User::getByUsername('betty');
     Yii::app()->user->userModel = $betty;
     $this->startOutputBuffer();
     try {
         ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($accounts[0], true);
         $this->endPrintOutputBufferAndFail();
     } catch (ExitException $e) {
         $content = $this->endAndGetOutputBuffer();
         $this->assertEquals('failure', $content);
     }
     $this->startOutputBuffer();
     try {
         ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($accounts[0], false);
         $this->endPrintOutputBufferAndFail();
     } catch (ExitException $e) {
         $compareString = 'You have tried to access a page you do not have access to';
         $this->assertContains($compareString, $this->endAndGetOutputBuffer());
     }
     $accounts = Account::getByName('BettyInc');
     $this->assertEquals(1, count($accounts));
     $account = $accounts[0];
     $this->startOutputBuffer();
     try {
         ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($account, true);
         ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($account, false);
         $content = $this->endAndGetOutputBuffer();
         $this->assertEquals(null, $content);
     } catch (ExitException $e) {
         $this->endPrintOutputBufferAndFail();
     }
 }
Ejemplo n.º 4
0
 public function actionDelete($id)
 {
     $contactWebForm = ContactWebForm::getById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($contactWebForm);
     $contactWebForm->delete();
     $this->redirect(array($this->getId() . '/index'));
 }
Ejemplo n.º 5
0
 public function actionDelete($id)
 {
     if (!Unitofmeasure::isUnitofmeasureInUseById(intval($id))) {
         $unitofmeasures = Unitofmeasure::GetById(intval($id));
         ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($unitofmeasures);
         $unitofmeasures->delete();
     } else {
         Yii::app()->user->setFlash('notification', Zurmo::t('ZurmoModule', 'Not possible to delete. Unit Of Measure is already in use'));
     }
     $this->redirect(array($this->getId() . '/index'));
 }
Ejemplo n.º 6
0
 public function actionDelete($id)
 {
     $campaign = static::getModelAndCatchNotFoundAndDisplayError('Campaign', intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($campaign);
     $campaign->delete();
     $this->redirect(array($this->getId() . '/index'));
 }
Ejemplo n.º 7
0
 public function actionDelete($id)
 {
     $emailTemplate = static::getModelAndCatchNotFoundAndDisplayError('EmailTemplate', intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($emailTemplate);
     $redirectUrl = null;
     if ($emailTemplate->isWorkflowTemplate()) {
         $redirectUrl = $this->getId() . '/listForWorkflow';
     } elseif ($emailTemplate->isContactTemplate()) {
         $redirectUrl = $this->getId() . '/listForMarketing';
     }
     $emailTemplate->delete();
     if (isset($redirectUrl)) {
         $this->redirect(array($redirectUrl));
     } else {
         throw new NotSupportedException();
     }
 }
 /**
  * Processes copying relations from non primary models to primary model and than deleting them
  * @param RedBeanModel $primaryModel
  * @param array $getData data from $_GET
  */
 public static function processCopyRelationsAndDeleteNonPrimaryModelsInMerge($primaryModel, $getData)
 {
     assert('$primaryModel instanceof RedBeanModel');
     assert('is_array($getData)');
     $modelClassName = get_class($primaryModel);
     $selectedModelsList = self::getSelectedModelsListForMerge($modelClassName, $getData);
     self::processAssignRelationsToMergedModelFromModelsToBeDeleted($selectedModelsList, $primaryModel);
     foreach ($selectedModelsList as $selectedModel) {
         if ($selectedModel->id != $primaryModel->id && get_class($selectedModel) == get_class($primaryModel)) {
             ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($selectedModel);
             $selectedModel->delete();
         }
     }
 }
Ejemplo n.º 9
0
 public function actionDelete($id)
 {
     $gameReward = GameReward::GetById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($gameReward);
     $gameReward->delete();
     $this->redirect(array($this->getId() . '/index'));
 }
 public function actionDeleteSavedSearch($id)
 {
     $savedSearch = SavedSearch::GetById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($savedSearch);
     $savedSearch->delete();
 }
 public function resolveDeleteAll()
 {
     $searchAttributeData['clauses'] = array(1 => array('attributeName' => 'owner', 'relatedAttributeName' => 'id', 'operatorType' => 'equals', 'value' => Yii::app()->user->userModel->id));
     $searchAttributeData['structure'] = '1';
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Notification');
     $where = RedBeanModelDataProvider::makeWhere('Notification', $searchAttributeData, $joinTablesAdapter);
     $models = Notification::getSubset($joinTablesAdapter, null, null, $where, null);
     foreach ($models as $model) {
         ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($model);
         $model->delete();
     }
 }
Ejemplo n.º 12
0
 public function actionDeleteFromAjax($id)
 {
     $notification = Notification::GetById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($notification);
     $notification->delete();
 }
 /**
  * @param $id
  * @param null $redirectUrl
  * @throws FailedToDeleteModelException
  */
 public function actionDelete($id, $redirectUrl = null)
 {
     $task = Task::getById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($task);
     if (!$task->delete()) {
         throw new FailedToDeleteModelException();
     }
 }
Ejemplo n.º 14
0
 public function actionDelete($id)
 {
     if (!Category::isCategoryInUseById(intval($id))) {
         $category = Category::GetById(intval($id));
         ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($category);
         $category->delete();
     } else {
         Yii::app()->user->setFlash('notification', Zurmo::t('ZurmoModule', 'Not possible to delete. Category is already in use'));
     }
     $this->redirect(array($this->getId() . '/index'));
 }
Ejemplo n.º 15
0
 public function actionCancelAssemblyStep2($id)
 {
     $costbook = Costbook::GetById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($costbook);
     if (!$costbook->delete()) {
         echo 0;
     } else {
         echo 1;
     }
 }
 /**
  * Removes dashboard and related portlets
  *
  */
 public function actionDeleteDashboard()
 {
     $id = intval($_GET['dashboardId']);
     $dashboard = Dashboard::getById($id);
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($dashboard);
     if ($dashboard->isDefault) {
         //todo: make a specific exception or view for this situation.
         throw new NotSupportedException();
     }
     $portlets = Portlet::getByLayoutIdAndUserSortedById('HomeDashboard' . $id, Yii::app()->user->userModel->id);
     foreach ($portlets as $portlet) {
         $portlet->delete();
         unset($portlet);
     }
     $dashboard->delete();
     unset($dashboard);
     $this->redirect(array('default/index'));
 }
 public function actionDelete($id)
 {
     $contact = Contact::GetById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($contact);
     if (!LeadsUtil::isStateALead($contact->state)) {
         $urlParams = array('/contacts/' . $this->getId() . '/delete', 'id' => $contact->id);
         $this->redirect($urlParams);
     } else {
         $contact->delete();
         $this->redirect(array($this->getId() . '/index'));
     }
 }
Ejemplo n.º 18
0
 public function actionDelete($id)
 {
     $productTemplate = ProductTemplate::GetById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($productTemplate);
     //Check if product template has associated products
     if ($productTemplate->delete()) {
         $this->redirect(array($this->getId() . '/index'));
     } else {
         Yii::app()->user->setFlash('notification', Zurmo::t('ProductTemplatesModule', 'The product template is associated to products in the system hence could not be deleted'));
         $this->redirect(Zurmo::app()->request->getUrlReferrer());
     }
 }
Ejemplo n.º 19
0
 public function actionDelete($id)
 {
     $marketingList = static::getModelAndCatchNotFoundAndDisplayError('MarketingList', intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($marketingList);
     $marketingList->delete();
     $this->redirect(array($this->getId() . '/index'));
 }
 /**
  * Deletes a calendar.
  * @param string $id
  */
 public function actionDelete($id)
 {
     $savedCalendar = SavedCalendar::getById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($savedCalendar);
     $savedCalendar->delete();
     $dataProvider = CalendarUtil::getCalendarItemsDataProvider(Yii::app()->user->userModel);
     $savedCalendarSubscriptions = $dataProvider->getSavedCalendarSubscriptions();
     $content = CalendarUtil::makeCalendarItemsList($savedCalendarSubscriptions->getMySavedCalendarsAndSelected(), 'mycalendar[]', 'mycalendar', 'saved');
     echo $content;
 }
 /**
  * @param $id
  * @param null $redirectUrl
  */
 public function actionDelete($id, $redirectUrl = null)
 {
     if ($redirectUrl == null) {
         $redirectUrl = array('/home/default');
     }
     $modelClassName = $this->getModule()->getPrimaryModelName();
     $activity = $modelClassName::getById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($activity);
     $activity->delete();
     $this->redirect($redirectUrl);
 }
 public function actionDelete($id, $redirectUrl = null, $redirect = true)
 {
     $emailMessage = EmailMessage::getById(intval($id));
     if ($redirectUrl == null) {
         $redirectUrl = array('/home/default');
     }
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($emailMessage);
     $emailMessage->delete();
     if ($redirect) {
         $this->redirect($redirectUrl);
     }
 }
Ejemplo n.º 23
0
 public function actionDelete($id)
 {
     $product = Product::GetById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($product);
     $product->delete();
     $this->redirect(array($this->getId() . '/index'));
 }
Ejemplo n.º 24
0
 public function actionDelete($id)
 {
     $emailMessage = EmailMessage::getById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserDeleteModel($emailMessage);
     $emailMessage->delete();
 }