public function actionTrack() { try { Yii::app()->user->userModel = BaseActionControlUserConfigUtil::getUserToRunAs(); $response = EmailMessageActivityUtil::resolveQueryStringFromUrlAndCreateOrUpdateActivity(); if ($response['redirect']) { $this->redirect($response['url']); } elseif (isset($response['imagePath'])) { $mime = ZurmoFileHelper::getMimeType($response['imagePath']); $size = filesize($response['imagePath']); $name = pathinfo($response['imagePath'], PATHINFO_FILENAME); header('Content-Type: ' . $mime); header('Content-Length: ' . $size); header('Content-Name: ' . $name); readfile($response['imagePath']); Yii::app()->end(0, false); } } catch (NotFoundException $e) { } catch (NotSupportedException $e) { } catch (FailedToSaveModelException $e) { } catch (MissingASuperAdministratorException $e) { } // we do not catch all exceptions because we need Exit and Redirect Exception for unit tests }
public function beforeAction($action) { Yii::app()->user->userModel = BaseActionControlUserConfigUtil::getUserToRunAs(); return parent::beforeAction($action); }
/** * Given a event, process any workflow rules * @param CEvent $event */ public function processWorkflowAfterSave(CEvent $event) { $model = $event->sender; if ($model->getScenario() != 'autoBuildDatabase' && $this->depth < 11 && $model->shouldProcessWorkflowOnSave()) { try { $this->depth = $this->depth + 1; $triggeredByUser = Yii::app()->user->userModel; Yii::app()->user->userModel = BaseActionControlUserConfigUtil::getUserToRunAs(); $model->setDoNotProcessWorkflowOnSave(); SavedWorkflowsUtil::resolveAfterSaveByModel($model, $triggeredByUser); $model->setProcessWorkflowOnSave(); Yii::app()->user->userModel = $triggeredByUser; } catch (MissingASuperAdministratorException $e) { //skip running workflow, since no super administrators are available. } $this->depth = $this->depth - 1; } elseif ($this->depth > 10) { $message = new NotificationMessage(); $message->htmlContent = Zurmo::t('WorkflowsModule', 'The combination of workflow rules setup caused ' . 'an infinite loop and processing was stopped prematurely while saving the ' . 'following record: {modelName}', array('{modelName}' => strval($model))); $url = Yii::app()->createAbsoluteUrl('workflows/default/list'); $message->htmlContent .= "<br/>" . ZurmoHtml::link(Zurmo::t('WorkflowsModule', 'Manage Workflows'), $url); $rules = new WorkflowMaximumDepthNotificationRules(); NotificationsUtil::submit($message, $rules); } }