/** * Resolve html for a builder template provided the model itself. * @param EmailTemplate $emailTemplate * @param bool $renderForCanvas * @param OwnedSecurableItem $attachedMergeTagModel * @return bool|null|string */ public static function resolveHtmlByEmailTemplateModel(EmailTemplate $emailTemplate, $renderForCanvas = false, OwnedSecurableItem $attachedMergeTagModel = null) { ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($emailTemplate); $serializedData = $emailTemplate->serializedData; $resolvedHtml = static::resolveHtmlBySerializedData($serializedData, $renderForCanvas, $attachedMergeTagModel, $emailTemplate->type, $emailTemplate->language); return $resolvedHtml; }
/** * Resolve html for a builder template provided the model itself. * @param EmailTemplate $emailTemplate * @param bool $renderForCanvas * @return bool|null|string */ public static function resolveHtmlByEmailTemplateModel(EmailTemplate $emailTemplate, $renderForCanvas = false) { ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($emailTemplate); $serializedData = $emailTemplate->serializedData; $resolvedHtml = static::resolveHtmlBySerializedData($serializedData, $renderForCanvas); return $resolvedHtml; }
public function actionDetails($id, $redirectUrl = null) { $emailMessage = EmailMessage::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($emailMessage); $detailsView = new EmailMessageEditAndDetailsView('Details', $this->getId(), $this->getModule()->getId(), $emailMessage); $view = new EmailMessagesPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $detailsView)); echo $view->render(); }
public function actionDetails($id) { $animal = static::getModelAndCatchNotFoundAndDisplayError('Animal', intval($id)); $breadCrumbView = StickySearchUtil::resolveBreadCrumbViewForDetailsControllerAction($this, 'AnimalsSearchView', $animal); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($animal); AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($animal), 'AnimalsModule'), $animal); $titleBarAndEditView = $this->makeEditAndDetailsView($animal, 'Details'); $view = new AnimalsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $titleBarAndEditView)); echo $view->render(); }
public function actionDetails($id) { $conversation = static::getModelAndCatchNotFoundAndDisplayError('Conversation', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($conversation); AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($conversation), 'ConversationsModule'), $conversation); ConversationsUtil::markUserHasReadLatest($conversation, Yii::app()->user->userModel); $detailsView = new ConversationDetailsView($this->getId(), $this->getModule()->getId(), $conversation); $conversationsMashableInboxUrl = Yii::app()->createUrl('mashableInbox/default/list', array('modelClassName' => 'Conversation')); $breadcrumbLinks = array(Zurmo::t('ConversationsModule', 'Conversations') => $conversationsMashableInboxUrl, StringUtil::getChoppedStringContent(strval($conversation), 25)); $view = new ConversationsPageView(ZurmoDefaultViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $detailsView, $breadcrumbLinks, 'ConversationBreadCrumbView')); echo $view->render(); }
public function actionDetails($id, $runReport = false) { $savedReport = SavedReport::getById((int) $id); ControllerSecurityUtil::resolveCanCurrentUserAccessModule($savedReport->moduleClassName); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($savedReport, true); $report = SavedReportToReportAdapter::makeReportBySavedReport($savedReport); $portlet = Portlet::getById(intval($_GET['portletId'])); $portlet->params = array('controllerId' => 'default', 'relationModuleId' => $this->getModule()->getId(), 'relationModel' => $report, 'redirectUrl' => Yii::app()->request->getRequestUri(), 'dataProvider' => $this->getDataProvider($report, $report->getId(), (bool) $runReport)); $portletView = $portlet->getView(); if (!RightsUtil::canUserAccessModule($portletView::getModuleClassName(), Yii::app()->user->userModel)) { $messageView = new AccessFailureView(); $view = new AccessFailurePageView($messageView); echo $view->render(); Yii::app()->end(0, false); } $view = new AjaxPageView($portletView); echo $view->render(); }
protected function resolveSourceModelByPostSourceDataAttributes($id, $className, $skipSecurityCheck = false) { $sourceModel = $className::getById(intval($id)); if (!$skipSecurityCheck) { ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($sourceModel); } return $sourceModel; }
public function actionCopy($id) { $copyToOpportunity = new Opportunity(); $postVariableName = get_class($copyToOpportunity); if (!isset($_POST[$postVariableName])) { $opportunity = Opportunity::getById((int) $id); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($opportunity); ZurmoCopyModelUtil::copy($opportunity, $copyToOpportunity); } $this->processEdit($copyToOpportunity); }
protected function resolveSavedReportAndReportByPostData(array $postData, &$savedReport, &$report, $type, $id = null, $isBeingCopied = false) { if ($id == null) { $this->resolveCanCurrentUserAccessReports(); $savedReport = new SavedReport(); $report = new Report(); $report->setType($type); } elseif ($isBeingCopied) { $savedReport = new SavedReport(); $oldReport = SavedReport::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($oldReport); SavedReportCopyModelUtil::copy($oldReport, $savedReport); $report = SavedReportToReportAdapter::makeReportBySavedReport($savedReport); } else { $savedReport = SavedReport::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($savedReport); $report = SavedReportToReportAdapter::makeReportBySavedReport($savedReport); } DataToReportUtil::resolveReportByWizardPostData($report, $postData, ReportToWizardFormAdapter::getFormClassNameByType($type)); }
/** * Copies the product * @param int $id */ public function actionCopy($id) { $copyToProduct = new Product(); $postVariableName = get_class($copyToProduct); if (!isset($_POST[$postVariableName])) { $product = Product::getById((int) $id); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($product); ProductZurmoCopyModelUtil::copy($product, $copyToProduct); } $this->processEdit($copyToProduct); }
public function actionDashboardDetails($id) { if (intval($id) > 0) { $dashboard = Dashboard::getById(intval($id)); $layoutId = $dashboard->layoutId; } else { $dashboard = Dashboard::getByLayoutIdAndUser(Dashboard::DEFAULT_USER_LAYOUT_ID, Yii::app()->user->userModel); $layoutId = $dashboard->layoutId; } $params = array('controllerId' => $this->getId(), 'moduleId' => $this->getModule()->getId()); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($dashboard); Portlet::resolvePortletCollectionColumnIndexes($layoutId); $homeTitleBarAndDashboardView = new HomeTitleBarAndDashboardView($this->getId(), $this->getModule()->getId(), 'HomeDashboard' . $layoutId, $dashboard, $params); $view = new HomePageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $homeTitleBarAndDashboardView)); echo $view->render(); }
/** * @param $id * @param null $redirectUrl */ public function actionCopy($id, $redirectUrl = null) { $modelClassName = $this->getModule()->getPrimaryModelName(); $copyToActivity = new $modelClassName(); $postVariableName = get_class($copyToActivity); if (!isset($_POST[$postVariableName])) { $activity = $modelClassName::getById((int) $id); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($activity); ActivityCopyModelUtil::copy($activity, $copyToActivity); } $this->processEdit($copyToActivity, $redirectUrl); }
public function actionUsersInGroupModalList($id) { $model = Group::getById((int) $id); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($model); $searchAttributeData = UsersByModelModalListControllerUtil::makeModalSearchAttributeDataByModel($model, 'groups'); $dataProvider = UsersByModelModalListControllerUtil::makeDataProviderBySearchAttributeData($searchAttributeData); Yii::app()->getClientScript()->setToAjaxMode(); echo UsersByModelModalListControllerUtil::renderList($this, $dataProvider, 'usersInGroupModalList'); }
public function actionGetDepartmentReferenceLaborCostAndBurdonCostToCopy($id) { $departmentReference = static::getModelAndCatchNotFoundAndDisplayError('DepartmentReference', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($departmentReference); $data = array(); if ($departmentReference->laborCost != null) { $data['laborCost'] = $departmentReference->laborCost; } if ($departmentReference->burdonCost != null) { $data['burdonCost'] = $departmentReference->burdonCost; } echo CJSON::encode($data); }
public function actionDrillDownDetails($campaignItemId) { $id = (int) $campaignItemId; $campaignItem = CampaignItem::getById($id); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($campaignItem->campaign); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($campaignItem->contact); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($campaignItem->emailMessage); echo CampaignItemSummaryListViewColumnAdapter::resolveDrillDownMetricsSummaryContent($campaignItem); }
public function testResolveAccessCanCurrentUserReadModel() { 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; TestHelpers::createControllerAndModuleByRoute('accounts/default'); $this->startOutputBuffer(); try { ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($accounts[0], true); $this->endPrintOutputBufferAndFail(); } catch (ExitException $e) { $content = $this->endAndGetOutputBuffer(); $this->assertEquals('failure', $content); } $this->startOutputBuffer(); try { ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($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()); } Yii::app()->user->userModel = User::getByUsername('super'); $account = AccountTestHelper::createAccountByNameForOwner('BettyInc', $betty); $this->startOutputBuffer(); try { ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($account, true); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($account, false); $content = $this->endAndGetOutputBuffer(); $this->assertEquals(null, $content); } catch (ExitException $e) { $this->endPrintOutputBufferAndFail(); } }
public function actionDetails($id, $renderJson = false, $includeFilesInJson = false) { $emailTemplate = static::getModelAndCatchNotFoundAndDisplayError('EmailTemplate', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($emailTemplate); if ($renderJson) { header('Content-type: application/json'); echo $this->resolveEmailTemplateAsJson($emailTemplate, $includeFilesInJson); Yii::app()->end(0, false); } AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($emailTemplate), 'EmailTemplatesModule'), $emailTemplate); $detailsView = new EmailTemplateEditAndDetailsView('Details', $this->getId(), $this->getModule()->getId(), $emailTemplate); if ($emailTemplate->type == EmailTemplate::TYPE_WORKFLOW) { $breadcrumbLinks = static::getDetailsAndEditForWorkflowBreadcrumbLinks(); $breadcrumbLinks[] = StringUtil::getChoppedStringContent(strval($emailTemplate), 25); $view = new EmailTemplatesPageView(WorkflowDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $detailsView, $breadcrumbLinks, 'WorkflowBreadCrumbView')); } elseif ($emailTemplate->type == EmailTemplate::TYPE_CONTACT) { $breadcrumbLinks = static::getDetailsAndEditForMarketingBreadcrumbLinks(); $breadcrumbLinks[] = StringUtil::getChoppedStringContent(strval($emailTemplate), 25); $view = new EmailTemplatesPageView(MarketingDefaultViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $detailsView, $breadcrumbLinks, 'MarketingBreadCrumbView')); } else { throw new NotSupportedException(); } echo $view->render(); }
protected function resolveSavedWorkflowAndWorkflowByPostData(array $postData, &$savedWorkflow, &$workflow, $type, $id = null, $isBeingCopied = false) { if ($id == null) { $this->resolveCanCurrentUserAccessWorkflows(); $savedWorkflow = new SavedWorkflow(); $workflow = new Workflow(); $workflow->setType($type); } elseif ($isBeingCopied) { $savedWorkflow = new SavedWorkflow(); $oldWorkflow = SavedWorkflow::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($oldWorkflow); ZurmoCopyModelUtil::copy($oldWorkflow, $savedWorkflow); $workflow = SavedWorkflowToWorkflowAdapter::makeWorkflowBySavedWorkflow($savedWorkflow); } else { $savedWorkflow = SavedWorkflow::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($savedWorkflow); $workflow = SavedWorkflowToWorkflowAdapter::makeWorkflowBySavedWorkflow($savedWorkflow); } DataToWorkflowUtil::resolveWorkflowByWizardPostData($workflow, $postData, WorkflowToWizardFormAdapter::getFormClassNameByType($type)); }
public function actionDelete($id, $redirectUrl = null) { $autoresponder = Autoresponder::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($autoresponder->marketingList); $autoresponder->delete(); if ($redirectUrl) { $this->redirect($redirectUrl); } }
public function actionGetAccountOfficePhoneAndFaxToCopy($id) { $account = static::getModelAndCatchNotFoundAndDisplayError('Account', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($account); $data = array(); if ($account->officePhone != null) { $data['officePhone'] = $account->officePhone; } if ($account->officeFax != null) { $data['officeFax'] = $account->officeFax; } echo CJSON::encode($data); }
public function actionGetAccountAddressesToCopy($id) { $account = static::getModelAndCatchNotFoundAndDisplayError('Account', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($account); $addressData = array(); foreach ($account->billingAddress->getAttributeNames() as $attribute) { $addressData['billingAddress_' . $attribute] = $account->billingAddress->{$attribute}; } foreach ($account->shippingAddress->getAttributeNames() as $attribute) { $addressData['shippingAddress_' . $attribute] = $account->shippingAddress->{$attribute}; } echo CJSON::encode($addressData); }
/** * Details view for project * @param int $id */ public function actionDetails($id) { $project = static::getModelAndCatchNotFoundAndDisplayError('Project', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($project); AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($project), 'ProjectsModule'), $project); $view = TasksUtil::resolveTaskKanbanViewForRelation($project, $this->getModule()->getId(), $this, 'TasksForProjectKanbanView', 'ProjectsPageView'); echo $view->render(); }
public function actionSendTestEmail($id, $contactId = null, $emailAddress = null, $useHtmlContent = 1) { $emailTemplate = EmailTemplate::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($emailTemplate); $htmlContent = $emailTemplate->htmlContent; if (!$useHtmlContent) { $htmlContent = EmailTemplateSerializedDataToHtmlUtil::resolveHtmlByEmailTemplateModel($emailTemplate, false); } $contact = null; if (isset($contactId)) { $contact = Contact::getById(intval($contactId)); } static::resolveEmailMessage($emailTemplate, $contact, $htmlContent, $emailAddress); }
/** * Used by my portlets to process or render actions on the portlet's view. An example is changing the * month of the calendar, requires additional calendar events to be loaded. * @param integer $id */ public function actionViewAction($id, $action) { $id = intval($id); $modelName = $this->getModule()->getPrimaryModelName(); $model = $modelName::getById($id); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($model, true); $portlet = Portlet::getById(intval($_GET['portletId'])); $portlet->params = array('controllerId' => 'default', 'relationModuleId' => $this->getModule()->getId(), 'relationModel' => $model, 'redirectUrl' => Yii::app()->request->getRequestUri()); $portletView = $portlet->getView(); if (!RightsUtil::canUserAccessModule($portletView::getModuleClassName(), Yii::app()->user->userModel)) { Yii::app()->end(0, false); } $portletView->{$action}(); }
protected function getPortletViewForDetails($id) { $id = intval($id); $modelName = $this->getModule()->getPrimaryModelName(); $model = $modelName::getById($id); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($model, true); $portlet = Portlet::getById(intval($_GET['portletId'])); if (null != ($redirectUrl = ArrayUtil::getArrayValue($_GET, 'redirectUrl'))) { $redirectUrl = $redirectUrl; } else { $redirectUrl = Yii::app()->request->getRequestUri(); } $portlet->params = array('controllerId' => 'default', 'relationModuleId' => $this->getModule()->getId(), 'relationModel' => $model, 'redirectUrl' => $redirectUrl); $portletView = $portlet->getView(); return $portletView; }
public function actionGetInfoToCopyToCampaign($id) { $marketingList = static::getModelAndCatchNotFoundAndDisplayError('MarketingList', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($marketingList); $data = array(); $data['fromName'] = $marketingList->fromName; $data['fromAddress'] = $marketingList->fromAddress; echo CJSON::encode($data); }
public function actionDetails($id) { $contactWebForm = static::getModelAndCatchNotFoundAndDisplayError('ContactWebForm', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($contactWebForm); $breadCrumbTitle = $contactWebForm->name; $breadcrumbLinks = array($breadCrumbTitle); $titleBarAndDetailsView = $this->makeEditAndDetailsView($contactWebForm, 'Details'); $view = new ContactWebFormsPageView(ZurmoDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $titleBarAndDetailsView, $breadcrumbLinks, 'ContactWebFormsBreadCrumbView')); echo $view->render(); }
public function actionAuditEventsModalList($id) { $model = $this->resolveModelForAuditEventsModalList($id); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($model); $searchAttributeData = AuditEventsListControllerUtil::makeModalSearchAttributeDataByAuditedModel($model); $dataProvider = AuditEventsListControllerUtil::makeDataProviderBySearchAttributeData($searchAttributeData); Yii::app()->getClientScript()->setToAjaxMode(); echo AuditEventsListControllerUtil::renderList($this, $dataProvider); }
protected function addNewSubscribers($marketingListId, $contactIds, $scenario = null) { $subscriberInformation = array('subscribedCount' => 0, 'skippedCount' => 0); $marketingList = MarketingList::getById((int) $marketingListId); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($marketingList); foreach ($contactIds as $contactId) { if ($marketingList->addNewMember($contactId, false, null, $scenario)) { $subscriberInformation['subscribedCount']++; } else { $subscriberInformation['skippedCount']++; } } return $subscriberInformation; }
public function actionRedeemReward($id) { $gameReward = static::getModelAndCatchNotFoundAndDisplayError('GameReward', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($gameReward); $gameCoin = GameCoin::resolveByPerson(Yii::app()->user->userModel); if ($gameCoin->value < $gameReward->cost) { $message = Zurmo::t('GameRewardsModule', 'You do not have enough coins to redeem this reward'); echo CJSON::encode(array('message' => $message)); Yii::app()->end(0, false); } if ($gameReward->quantity <= 0) { $message = Zurmo::t('GameRewardsModule', 'This reward is no longer available'); echo CJSON::encode(array('message' => $message)); Yii::app()->end(0, false); } $gameRewardTransaction = new GameRewardTransaction(); $gameRewardTransaction->quantity = 1; $gameRewardTransaction->person = Yii::app()->user->userModel; $gameReward->transactions->add($gameRewardTransaction); $gameCoin->removeValue((int) $gameReward->cost); if (!$gameCoin->save()) { throw new FailedToSaveModelException(); } $gameReward->quantity = $gameReward->quantity - 1; if (!$gameReward->save()) { throw new FailedToSaveModelException(); } //Notify the owner of the game reward $message = new NotificationMessage(); $message->htmlContent = Zurmo::t('JobsManagerModule', '{name} was redeemed by {personFullName}.', array('{name}' => strval($gameReward), '{personFullName}' => strval(Yii::app()->user->userModel))); $url = Yii::app()->createAbsoluteUrl('gameRewards/default/details/', array('id' => $gameReward->id)); $message->htmlContent .= "<br/>" . ZurmoHtml::link(Zurmo::t('Core', 'Click Here'), $url); $rules = new GameRewardRedeemedNotificationRules(); $rules->addUser($gameReward->owner); NotificationsUtil::submit($message, $rules); $message = Zurmo::t('GameRewardsModule', '{name} has been redeemed.', array('{name}' => strval($gameReward))); echo CJSON::encode(array('message' => $message)); Yii::app()->end(0, false); }