/** * Add New organisation * Saved Default value */ public function addOrganisationAction() { $identity = Zend_Auth::getInstance()->getIdentity(); // Fetch default value for an organisation $model = new Model_Viewcode(); $rowSet = $model->getRowsByFields('default_field_values', 'account_id', $identity->account_id); $defaultValues = unserialize($rowSet[0]['object']); $default = $defaultValues->getDefaultFields(); // Saved default value for an organisation $organisationModel = new Model_Organisation(); $organisationId = $organisationModel->createOrganisation($identity->account_id, $default); //Create Activity Hash $organisationHashModel = new Model_OrganisationHash(); $updated = $organisationHashModel->updateHash($organisationId); $this->_redirect('organisation/view-elements/?parentId=' . $organisationId); }
/** * 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 downloadXmlAction() { $name = $this->_getParam('name'); $identity = Zend_Auth::getInstance()->getIdentity(); $obj = new Iati_Core_Xml(); if ($name == 'Activity') { $wepModel = new Model_Wep(); $activities = $wepModel->listAll('iati_activities', 'account_id', $identity->account_id); $activities_id = $activities[0]['id']; $activityArray = $wepModel->listAll('iati_activity', 'activities_id', $activities_id); $index = 0; foreach ($activityArray as $key => $activity) { $activity_array[$index] = $activity['id']; $index++; } $xmlOutput = $obj->generateXml($name, $activity_array); $filename = 'iati_activity'; } elseif ($name == 'Organisation') { $organisationModelObj = new Model_Organisation(); $organisationId = $organisationModelObj->checkOrganisationPresent($identity->account_id); $organisationIds = explode(',', $organisationId); $xmlOutput = $obj->generateXml($name, $organisationIds); $filename = 'iati_organisation_data'; } else { exit('Invalid name for download.'); } header('Content-Type: text/xml'); header('Content-Disposition: attachment;filename=' . $filename . '.xml'); echo $xmlOutput; exit; }