/** * Update all reporting org values in activities and organisation data if changed in settings. */ public function settingsChange() { $identity = Zend_Auth::getInstance()->getIdentity(); //Get Activities $activities = $this->listAll('iati_activities', 'account_id', $identity->account_id); $activities_id = $activities[0]['id']; $activityArray = $this->listAll('iati_activity', 'activities_id', $activities_id); //Update Each Activity Reporting Org $activityReportingOrg = new Model_ReportingOrg(); $activityHashModel = new Model_ActivityHash(); $activityModel = new Model_Activity(); foreach ($activityArray as $key => $activity) { $activityReportingOrg->updateReportingOrg($activity['id']); $updated = $activityHashModel->updateActivityHash($activity['id']); if ($updated) { //Update each activity: last updated time $wepModel = new Model_Wep(); $activityData['id'] = $activity['id']; $activityData['@last_updated_datetime'] = date('Y-m-d H:i:s'); $wepModel->updateRowsToTable('iati_activity', $activityData); } } //Get Organisation Id $organisationModelObj = new Model_Organisation(); $organisationId = $organisationModelObj->checkOrganisationPresent($identity->account_id); // If organisation exists if ($organisationId) { //Update Organisation Reporting Org $organisationReportingOrg = new Model_OrganisationDefaultElement(); $organisationReportingOrg->updateElementData('ReportingOrg', $organisationId); //Update Organisation Hash $organisationHashModel = new Model_OrganisationHash(); $update = $organisationHashModel->updateHash($organisationId); if ($update) { //Update organisation: last updated time $wepModel = new Model_Wep(); $organisationData['id'] = $organisationId; $organisationData['@last_updated_datetime'] = date('Y-m-d h:i:s'); $wepModel->updateRowsToTable('iati_organisation', $organisationData); } } $modelRegistryInfo = new Model_RegistryInfo(); $registryInfo = $modelRegistryInfo->getOrgRegistryInfo($identity->account_id); if ($registryInfo && $registryInfo->publisher_id) { $pub = new Iati_WEP_Publish($identity->account_id, $registryInfo->publisher_id, $registryInfo->publishing_type); $pub->publish(); } }
public function updateReportingOrgAction() { $reportingOrgId = $this->_getParam('id'); $activityId = $this->_getParam('activity_id'); $model = new Model_ReportingOrg(); $model->updateReportingOrg($reportingOrgId); $activityId = $model->getActivityIdById($reportingOrgId); //Update Activity Hash $activityHashModel = new Model_ActivityHash(); $updated = $activityHashModel->updateActivityHash($activityId); if (!$updated) { $type = 'message'; $message = "Already up to date. To make changes please change\n values in 'Settings' and then update."; } else { //update the activity so that the last updated time is updated $this->updateActivityUpdatedDatetime($activityId); //change state to editing $db = new Model_ActivityStatus(); $db->updateActivityStatus($activityId, Iati_WEP_ActivityState::STATUS_DRAFT); $type = 'message'; $message = "Updated Reporting Organisation sucessfully"; } $this->_helper->FlashMessenger->addMessage(array($type => $message)); $this->_redirect("/activity/edit-element/?activity_id=" . $activityId . "&className=Activity_ReportingOrg"); }