public function actionEdit($id, $redirectUrl = null) { $animal = Animal::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($animal); $view = new AnimalsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $this->makeEditAndDetailsView($this->attemptToSaveModelFromPost($animal, $redirectUrl), 'Edit'))); echo $view->render(); }
public function actionEdit($id, $redirectUrl = null) { $modelClassName = $this->getModule()->getPrimaryModelName(); $activity = $modelClassName::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($activity); $this->processEdit($activity, $redirectUrl); }
/** * Action for saving an existing note inline edit form. * @param string or array $redirectUrl */ public function actionInlineEditSave($id, $redirectUrl = null) { $note = Note::getById((int) $id); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($note); if (isset($_POST['ajax']) && $_POST['ajax'] === 'inline-edit-form') { $this->actionInlineEditValidate($note, 'Note'); } $this->attemptToSaveModelFromPost($note, $redirectUrl); }
public function actionCloseTask($id) { $task = Task::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($task); $task->completedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time()); $task->completed = true; $saved = $task->save(); if (!$saved) { throw new NotSupportedException(); } }
public function actionEdit($id) { //get boject by id $category = Category::getById(intval($id)); //Security check ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($category); //create view and render $editAndDetailsView = $this->makeEditAndDetailsView($this->attemptToSaveModelFromPost($category), 'Edit'); $view = new CategoriesPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $editAndDetailsView)); echo $view->render(); }
public function actionEdit($id) { $contactWebForm = static::getModelAndCatchNotFoundAndDisplayError('ContactWebForm', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($contactWebForm); $modelClassName = $this->getModule()->getPrimaryModelName(); $breadCrumbTitle = Zurmo::t('ContactWebFormsModule', 'Edit Web Form'); $breadcrumbLinks = array($breadCrumbTitle); if ($contactWebForm->language === null) { $contactWebForm->language = Yii::app()->language; } if (isset($_POST[$modelClassName])) { unset($_POST[$modelClassName]['serializedData']); $contactWebForm->serializedData = serialize($_POST['attributeIndexOrDerivedType']); } $titleBarAndEditView = $this->makeEditAndDetailsView($this->attemptToSaveModelFromPost($contactWebForm), 'Edit'); $view = new ContactWebFormsPageView(ZurmoDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $titleBarAndEditView, $breadcrumbLinks, 'ContactWebFormsBreadCrumbView')); echo $view->render(); }
public function actionEdit($id, $redirectUrl = null) { Yii::app()->clientScript->registerScript('productcode', '$("label[for=Costbook_departmentreference_id]").append("<span class=required> * </span>"); $("label[for=Costbook_costperunit]").append("<span class=required> * </span>"); $("label[for=Costbook_unitofmeasure_value]").append("<span class=required> * </span>"); '); //get boject by id $costbook = Costbook::getById(intval($id)); //Security check ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($costbook); //create view and render if ($costbook->costofgoodssold == 'Labor') { $view = new CostbookPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, new CostbookLaborView('Edit', $this->getId(), $this->getModule()->getId(), $this->attemptToSaveModelFromPost($costbook, $redirectUrl), 'Edit'))); } else { if ($costbook->costofgoodssold == 'Equipment') { $view = new CostbookPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, new CostbookEquipmentView('Edit', $this->getId(), $this->getModule()->getId(), $this->attemptToSaveModelFromPost($costbook, $redirectUrl), 'Edit'))); } else { if ($costbook->costofgoodssold == 'Material') { $view = new CostbookPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, new CostbookMaterialView('Edit', $this->getId(), $this->getModule()->getId(), $this->attemptToSaveModelFromPost($costbook, $redirectUrl), 'Edit'))); } else { if ($costbook->costofgoodssold == 'Subcontractor') { $view = new CostbookPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, new CostbookSubcontractorView('Edit', $this->getId(), $this->getModule()->getId(), $this->attemptToSaveModelFromPost($costbook, $redirectUrl), 'Edit'))); } else { if ($costbook->costofgoodssold == 'Other') { $view = new CostbookPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, new CostbookOtherView('Edit', $this->getId(), $this->getModule()->getId(), $this->attemptToSaveModelFromPost($costbook, $redirectUrl), 'Edit'))); } else { if ($costbook->costofgoodssold == 'Assembly') { $view = new CostbookPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, new CostbookAssemblyView('Edit', $this->getId(), $this->getModule()->getId(), $this->attemptToSaveModelFromPost($costbook, $redirectUrl), 'Edit'))); } } } } } } echo $view->render(); }
public function actionEdit($id, $redirectUrl = null) { $emailTemplate = static::getModelAndCatchNotFoundAndDisplayError('EmailTemplate', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($emailTemplate); $editAndDetailsView = $this->makeEditAndDetailsView($this->attemptToSaveModelFromPost($emailTemplate, $redirectUrl), 'Edit'); if ($emailTemplate->type == EmailTemplate::TYPE_WORKFLOW) { $breadcrumbLinks = static::getDetailsAndEditForWorkflowBreadcrumbLinks(); $breadcrumbLinks[] = StringUtil::getChoppedStringContent(strval($emailTemplate), 25); $view = new EmailTemplatesPageView(WorkflowDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $editAndDetailsView, $breadcrumbLinks, 'WorkflowBreadCrumbView')); } elseif ($emailTemplate->type == EmailTemplate::TYPE_CONTACT) { $breadcrumbLinks = static::getDetailsAndEditForMarketingBreadcrumbLinks(); $breadcrumbLinks[] = StringUtil::getChoppedStringContent(strval($emailTemplate), 25); $view = new EmailTemplatesPageView(MarketingDefaultViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $editAndDetailsView, $breadcrumbLinks, 'MarketingBreadCrumbView')); } else { throw new NotSupportedException(); } echo $view->render(); }
/** * Resolve report by saved calendar post data. * @param string $type * @param int $id * @param array $postData * @return Report */ public static function resolveReportBySavedCalendarPostData($type, $id = null, $postData) { assert('is_string($type)'); assert('is_array($postData)'); if ($id == null) { $report = new Report(); $report->setType($type); } else { $savedCalendar = SavedCalendar::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($savedCalendar); $report = SavedCalendarToReportAdapter::makeReportBySavedCalendar($savedCalendar); } if (isset($postData['SavedCalendar']) && isset($postData['SavedCalendar']['moduleClassName'])) { $report->setModuleClassName($postData['SavedCalendar']['moduleClassName']); } else { throw new NotSupportedException(); } DataToReportUtil::resolveReportByWizardPostData($report, $postData, ReportToWizardFormAdapter::getFormClassNameByType($type)); return $report; }
public function actionUpdate($id, $attribute, $item, $value) { assert('$id != null && $id != ""'); assert('$attribute != null && $attribute != ""'); assert('$item != null && $item != ""'); $id = intval($id); $item = intval($item); $import = Import::getById($id); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($import); ImportDatabaseUtil::updateRowValue($import->getTempTableName(), $item, $attribute, $value); }
public function actionEdit($id, $redirectUrl = null) { $opportunity = Opportunity::getById(intval($id)); $getaccount = Account::getById(intval($opportunity->account->id)); $_SESSION['unitsCstmCstm'] = !empty($getaccount->unitsCstmCstm) ? $getaccount->unitsCstmCstm : 1; ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($opportunity); $this->processEdit($opportunity, $redirectUrl); }
public function actionEdit($id) { $marketingList = MarketingList::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($marketingList); $breadCrumbLinks = static::getDetailsAndEditBreadcrumbLinks(); $breadCrumbLinks[] = StringUtil::getChoppedStringContent(strval($marketingList), 25); $editView = new MarketingListEditView($this->getId(), $this->getModule()->getId(), $this->attemptToSaveModelFromPost($marketingList), strval($marketingList)); $view = new MarketingListsPageView(MarketingDefaultViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $editView, $breadCrumbLinks, 'MarketingBreadCrumbView')); echo $view->render(); }
public function actionEdit($id, $redirectUrl = null) { $opportunity = Opportunity::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($opportunity); $this->processEdit($opportunity, $redirectUrl); }
public function actionConvertFinal($id) { assert('!empty($id)'); $accountPostData = LeadsUtil::getFromSession(LeadsUtil::LEAD_CONVERSION_ACCOUNT_DATA_SESSION_KEY); if (empty($accountPostData)) { $urlParams = array('/leads/' . $this->getId() . '/convert', 'id' => $id); $this->redirect($urlParams); } $contact = Contact::getById(intval($id)); if (!LeadsUtil::isStateALead($contact->state)) { $urlParams = array('/contacts/' . $this->getId() . '/details', 'id' => $contact->id); $this->redirect($urlParams); } $convertToAccountSetting = LeadsModule::getConvertToAccountSetting(); $convertToOpportunitySetting = LeadsModule::getConvertToOpportunitySetting(); $opportunity = new Opportunity(); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($contact); $userCanAccessContacts = RightsUtil::canUserAccessModule('ContactsModule', Yii::app()->user->userModel); $userCanAccessAccounts = RightsUtil::canUserAccessModule('AccountsModule', Yii::app()->user->userModel); $userCanAccessOpportunities = RightsUtil::canUserAccessModule('OpportunitiesModule', Yii::app()->user->userModel); $userCanCreateOpportunity = RightsUtil::doesUserHaveAllowByRightName('OpportunitiesModule', OpportunitiesModule::RIGHT_CREATE_OPPORTUNITIES, Yii::app()->user->userModel); LeadsControllerSecurityUtil::resolveCanUserProperlyConvertLead($userCanAccessContacts, $userCanAccessAccounts, $convertToAccountSetting); LeadsControllerSecurityUtil::resolveCanUserProperlyConvertLeadFinalStep($userCanAccessContacts, $userCanAccessOpportunities, $convertToOpportunitySetting); if (isset($_POST['Opportunity'])) { $controllerUtil = static::getZurmoControllerUtil(); $savedSuccessfully = false; $modelToStringValue = null; $postData = $_POST['Opportunity']; $opportunity = $controllerUtil->saveModelFromPost($postData, $opportunity, $savedSuccessfully, $modelToStringValue, false); if ($savedSuccessfully) { $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($contact); ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($opportunity, $explicitReadWriteModelPermissions); $account = LeadsUtil::createAccountForLeadConversionFromAccountPostData($accountPostData, $contact, $controllerUtil); $opportunity->account = $account; if (!$opportunity->save()) { throw new NotSupportedException(); } LeadsUtil::removeFromSession(LeadsUtil::LEAD_CONVERSION_ACCOUNT_DATA_SESSION_KEY); $this->actionSaveConvertedContact($contact, $account, $opportunity); } } elseif (isset($_POST['OpportunitySkip']) || $convertToOpportunitySetting == LeadsModule::CONVERT_NO_OPPORTUNITY || $convertToOpportunitySetting == LeadsModule::CONVERT_OPPORTUNITY_NOT_REQUIRED && !$userCanAccessOpportunities) { $controllerUtil = static::getZurmoControllerUtil(); $account = LeadsUtil::createAccountForLeadConversionFromAccountPostData($accountPostData, $contact, $controllerUtil); LeadsUtil::removeFromSession(LeadsUtil::LEAD_CONVERSION_ACCOUNT_DATA_SESSION_KEY); $this->actionSaveConvertedContact($contact, $account, null); } $progressBarAndStepsView = new LeadConversionStepsAndProgressBarForWizardView(1); $convertView = new LeadConvertOpportunityView($this->getId(), $this->getModule()->getId(), $contact->id, strval($contact), $opportunity, $convertToOpportunitySetting, $userCanCreateOpportunity); $view = new LeadsPageView(ZurmoDefaultViewUtil::makeTwoStandardViewsForCurrentUser($this, $progressBarAndStepsView, $convertView)); echo $view->render(); }
/** * Only supports saving 4 layoutTypes (max 2 column) * */ public function actionEditDashboard($id) { $id = intval($id); $dashboard = Dashboard::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($dashboard); if (isset($_POST['Dashboard'])) { $oldLayoutType = $dashboard->layoutType; $_POST['Dashboard'] = PostUtil::sanitizePostByDesignerTypeForSavingModel($dashboard, $_POST['Dashboard']); $dashboard->setAttributes($_POST['Dashboard']); assert('in_array($dashboard->layoutType, array_keys(Dashboard::getLayoutTypesData()))'); if ($dashboard->save()) { if ($oldLayoutType != $dashboard->layoutType && $dashboard->layoutType == '100') { $uniqueLayoutId = 'HomeDashboard' . $dashboard->layoutId; $portletCollection = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition($uniqueLayoutId, Yii::app()->user->userModel->id, array()); Portlet::shiftPositionsBasedOnColumnReduction($portletCollection, 1); } GeneralCache::forgetAll(); //Ensure menu refreshes $this->redirect(array('default/dashboardDetails', 'id' => $dashboard->id)); } } $editView = new DashboardEditView($this->getId(), $this->getModule()->getId(), $dashboard, strval($dashboard)); $view = new AccountsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $editView)); echo $view->render(); }
public function actionAjaxChangeStatus($status, $id) { $content = null; $save = true; $mission = Mission::GetById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($mission); if ($status == Mission::STATUS_TAKEN) { if ($mission->takenByUser->id > 0) { $save = false; } else { $mission->takenByUser = Yii::app()->user->userModel; } } if ($save) { $mission->status = $status; $saved = $mission->save(); if (!$saved) { throw new NotSupportedException(); } $statusText = MissionStatusElement::renderStatusTextContent($mission); $statusAction = MissionStatusElement::renderStatusActionContent($mission, MissionStatusElement::getStatusChangeDivId($mission->id)); $content .= $statusText; if ($statusAction != null) { $content .= ' ' . $statusAction; } } else { $content .= '<div>' . Zurmo::t('MissionsModule', 'This mission is already taken') . '</div>'; } $content = ZurmoHtml::tag('div', array('id' => MissionStatusElement::getStatusChangeDivId($mission->id), 'class' => 'missionStatusChangeArea'), $content); Yii::app()->getClientScript()->setToAjaxMode(); Yii::app()->getClientScript()->render($content); echo $content; }
/** * Edit Project */ public function actionEdit($id, $redirectUrl = null) { $project = Project::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($project); $breadCrumbLinks = array(StringUtil::getChoppedStringContent(strval($project), 25)); $view = new ProjectsPageView(ProjectDefaultViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $this->makeEditAndDetailsView($this->attemptToSaveModelFromPost($project, $redirectUrl), 'Edit'), $breadCrumbLinks, 'ProjectBreadCrumbView')); echo $view->render(); }
public function actionEdit($id) { $contactWebForm = static::getModelAndCatchNotFoundAndDisplayError('ContactWebForm', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($contactWebForm); $modelClassName = $this->getModule()->getPrimaryModelName(); $breadCrumbTitle = Zurmo::t('ContactWebFormsModule', 'Edit Web Form'); $breadCrumbLinks = array($breadCrumbTitle); $contactWebForm->defaultPermissionSetting = ContactWebFormAdapter::resolveAndGetDefaultPermissionSetting($contactWebForm); if ($contactWebForm->language === null) { $contactWebForm->language = Yii::app()->language; } if (isset($_POST[$modelClassName])) { unset($_POST[$modelClassName]['serializedData']); foreach ($_POST['ContactWebFormAttributeForm'] as $attributeName => $attributeData) { if (isset($attributeData['hiddenValue']) && !empty($attributeData['hiddenValue'])) { $_POST['ContactWebFormAttributeForm'][$attributeName]['hiddenValue'] = ContactWebFormsUtil::sanitizeHiddenAttributeValue($attributeName, $attributeData['hiddenValue']); } } $contactWebForm->serializedData = serialize($_POST['ContactWebFormAttributeForm']); if (isset($_POST[$modelClassName]['defaultPermissionGroupSetting'])) { $contactWebForm = ContactWebFormAdapter::setDefaultPermissionGroupSetting($contactWebForm, (int) $_POST[$modelClassName]['defaultPermissionSetting'], (int) $_POST[$modelClassName]['defaultPermissionGroupSetting']); unset($_POST[$modelClassName]['defaultPermissionGroupSetting']); } } $titleBarAndEditView = $this->makeEditAndDetailsView($this->attemptToSaveModelFromPost($contactWebForm), 'Edit'); $view = new ContactWebFormsPageView(ZurmoDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $titleBarAndEditView, $breadCrumbLinks, 'ContactWebFormsBreadCrumbView')); echo $view->render(); }
public function actionEdit($id) { $campaign = Campaign::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($campaign); $this->processEdit($campaign); }
public function actionChangeIsClosed($id) { $conversation = Conversation::GetById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($conversation); $conversation->isClosed = !$conversation->isClosed; $saved = $conversation->save(); if (!$saved) { throw new NotSupportedException(); } echo true; }
public function actionUnlink($id) { $relationModelClassName = ArrayUtil::getArrayValue(GetUtil::getData(), 'relationModelClassName'); $relationModelId = ArrayUtil::getArrayValue(GetUtil::getData(), 'relationModelId'); $relationModelRelationName = ArrayUtil::getArrayValue(GetUtil::getData(), 'relationModelRelationName'); if ($relationModelClassName == null || $relationModelId == null || $relationModelRelationName == null) { throw new NotSupportedException(); } $relationModel = $relationModelClassName::GetById(intval($relationModelId)); if ($relationModel->getRelationType($relationModelRelationName) != RedBeanModel::HAS_MANY && $relationModel->getRelationType($relationModelRelationName) != RedBeanModel::MANY_MANY) { throw new NotSupportedException(); } $modelClassName = $relationModel->getRelationModelClassName($relationModelRelationName); $model = $modelClassName::getById((int) $id); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($model); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($relationModel); $relationModel->{$relationModelRelationName}->remove($model); $saved = $relationModel->save(); if (!$saved) { throw new FailedToSaveModelException(); } }
/** * Edit the calendar. * @param int $id */ public function actionEdit($id) { $savedCalendar = SavedCalendar::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($savedCalendar); $this->processEdit($savedCalendar); }
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)); }
public function actionEdit($id, $redirectUrl = null) { $contract = Contract::getById(intval($id)); $sql = "select * from contract_opportunity where contract_id=" . $id; $rec = Yii::app()->db->createCommand($sql)->queryRow(); $rec_t['value'] = $rec_c['value'] = ''; if (!empty($rec) && !empty($rec['opportunity_id'])) { $getopportunity = Opportunity::getById(intval($rec['opportunity_id'])); $sql1 = "select * from opportunity where id=" . $rec['opportunity_id']; $rec1 = Yii::app()->db->createCommand($sql1)->queryRow(); } if (isset($rec1['totalbulkpricstm_currencyvalue_id']) && !empty($rec1['totalbulkpricstm_currencyvalue_id'])) { //get totalbuilprice $sql_t = "select * from currencyvalue where id=" . $rec1['totalbulkpricstm_currencyvalue_id']; $rec_t = Yii::app()->db->createCommand($sql_t)->queryRow(); } if (isset($rec1['constructcoscstm_currencyvalue_id']) && !empty($rec1['constructcoscstm_currencyvalue_id'])) { $sql_c = "select * from currencyvalue where id=" . $rec1['constructcoscstm_currencyvalue_id']; $rec_c = Yii::app()->db->createCommand($sql_c)->queryRow(); } $getaccount = Account::getById(intval($getopportunity->account->id)); $_SESSION['unitsCstmCstm'] = !empty($getaccount->unitsCstmCstm) ? $getaccount->unitsCstmCstm : 1; $_SESSION['totalbulkpricstm'] = !empty($rec_t['value']) ? $rec_t['value'] : 1; $_SESSION['totalcostprccstm'] = !empty($rec_c['value']) ? $_SESSION['unitsCstmCstm'] * $rec_c['value'] : $_SESSION['unitsCstmCstm'] * 1; ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($contract); $this->processEdit($contract, $redirectUrl); }
public function actionEdit($id, $redirectUrl = null) { $contact = Contact::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($contact); $this->processEdit($contact, $redirectUrl); }
public function actionPopulateContactEmailBeforeCreating($id) { $postData = PostUtil::getData(); $contact = Contact::getById(intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($contact); $contactPrimaryEmailForm = new ContactPrimaryEmailForm(); $contactPrimaryEmailForm->name = strval($contact); $this->actionValidatePopulateContactEmailBeforeCreating($postData, $contactPrimaryEmailForm); if (isset($postData[get_class($contactPrimaryEmailForm)])) { //Process saving the email address and redirecting to create email view $contactPrimaryEmailForm->setAttributes($postData[get_class($contactPrimaryEmailForm)]); $email = new Email(); $email->emailAddress = $contactPrimaryEmailForm->emailAddress; $contact->primaryEmail = $email; $saved = $contact->save(); if (!$saved) { throw new FailedToSaveModelException(); } $this->redirect(array($this->getId() . '/createEmailMessage', 'relatedId' => $contact->id, 'relatedModelClassName' => 'Contact', 'toAddress' => $contact->primaryEmail->emailAddress)); Yii::app()->end(false); } $contactEditView = new ContactRequiresPrimaryEmailFirstModalView($this->getId(), $this->getModule()->getId(), $contactPrimaryEmailForm); $view = new ModalView($this, $contactEditView); Yii::app()->getClientScript()->setToAjaxMode(); echo $view->render(); }
public function actionEdit($id) { $emailTemplate = static::getModelAndCatchNotFoundAndDisplayError('EmailTemplate', intval($id)); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($emailTemplate); $breadCrumbLink = StringUtil::getChoppedStringContent(strval($emailTemplate), 25); $this->actionRenderWizardForModel($emailTemplate, $breadCrumbLink); }
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 actionUpdate($attribute) { $id = Yii::app()->request->getParam('item'); $value = Yii::app()->request->getParam('value'); assert('$id != null && $id != ""'); assert('$value != null && $value != ""'); $id = intval($id); $product = Product::getById($id); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($product); switch ($attribute) { case 'quantity': $value = intval($value); $product->quantity = $value; break; case 'sellPrice': $value = floatval($value); $product->sellPrice->value = $value; break; } $product->save(); }
/** * @depends testResolveAccessCanCurrentUserReadModel */ public function testResolveAccessCanCurrentUserWriteModel() { 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::resolveAccessCanCurrentUserWriteModel($accounts[0], true); $this->endPrintOutputBufferAndFail(); } catch (ExitException $e) { $content = $this->endAndGetOutputBuffer(); $this->assertEquals('failure', $content); } $this->startOutputBuffer(); try { ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($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::resolveAccessCanCurrentUserWriteModel($account, true); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($account, false); $content = $this->endAndGetOutputBuffer(); $this->assertEquals(null, $content); } catch (ExitException $e) { $this->endPrintOutputBufferAndFail(); } }