public function deleteOrganisationById($orgId) { $wepModel = new Model_Wep(); // Delete Activities $actCollModel = new Model_ActivityCollection(); $activities = $actCollModel->getActivityIdsByAccount($orgId); $activityModel = new Model_Activity(); foreach ($activities as $activity) { $activityModel->deleteActivityById($activity['id']); } // Delete Defaults $wepModel->deleteRow('default_field_groups', 'account_id', $orgId); $wepModel->deleteRow('default_field_values', 'account_id', $orgId); // Delete registry info $regModel = new Model_RegistryInfo(); $regModel->deleteRegistryInfo($orgId); // Delete Users $userModel = new Model_User(); $users = $userModel->getAllUsersByAccountId($orgId); foreach ($users as $user) { $this->deleteUserById($user['user_id']); } // Delete account $wepModel->deleteRow('iati_activities', 'account_id', $orgId); $wepModel->deleteRow('account', 'id', $orgId); }
public static function showHelpforPushToRegistry() { $modelRegistry = new Model_RegistryInfo(); $registryData = $modelRegistry->getRegistryInfoForCurrentAccount(); $updateRegistry = $registryData['update_registry']; if ($updateRegistry) { return false; } else { return true; } }
public function organisationAction() { if ($_GET['reporting_org']) { $reportingOrg = $this->_request->getParam('reporting_org'); } else { $this->_redirect('organisation?reporting_org=all'); } !$reportingOrg ? $handler = new Iati_Snapshot_Lib_DataHandler() : ($handler = new Iati_Snapshot_Lib_DataHandler($reportingOrg)); $accountModel = new User_Model_DbTable_Account(); $userModel = new Model_User(); $publishModel = new Model_Published(); $wepModel = new Model_Wep(); $regInfoModel = new Model_RegistryInfo(); $result = $accountModel->getAccountByOrganisation($reportingOrg); if (count($result)) { // Get Account Id $accountId = $result['id']; $user = $userModel->getUserByAccountId($accountId); $regInfo = $regInfoModel->getOrgRegistryInfo($accountId); // Get Organisation Info $organisation_array['name'] = $result['name']; $organisation_array['image'] = $result['file_name']; $organisation_array['address'] = $result['address']; $organisation_array['email'] = $user['email']; $organisation_array['telephone'] = $result['telephone'] ? $result['telephone'] : 'Not Available'; $organisation_array['website'] = $result['url'] ? $result['url'] : 'Not Available'; $organisation_array['twitter'] = $result['twitter'] ? $result['twitter'] : 'Not Available'; $organisation_array['prefix'] = $result['username']; $organisation_array['disqus_comments'] = $result['disqus_comments']; $this->view->organisation_array = $organisation_array; $this->view->publisher_id = $regInfo->publisher_id; } else { // For all organisations: snapshot if ($reportingOrg == 'all' || $reportingOrg == '') { $activityModel = new Model_Activity(); $orgData = $activityModel->allOrganisationsActivityStates(); foreach ($orgData as $key => $row) { $total['activities'] += array_sum($row['states']); $total['published'] += $row['registry_published_count']; } $accountModel = new User_Model_DbTable_Account(); $count = $accountModel->getAccountCount(); $total['organisations'] = $count['total']; $this->view->total = $total; } else { $this->_redirect('organisation?reporting_org=all'); } } // end if $this->view->handler = $handler; }
public function sendTweet() { $identity = Zend_Auth::getInstance()->getIdentity(); $accountId = $identity->account_id; $regInfoModel = new Model_RegistryInfo(); $regInfo = $regInfoModel->getOrgRegistryInfo($accountId); $registryUrl = "/publisher/" . $regInfo->publisher_id; $model = new User_Model_DbTable_Account(); $row = $model->getAccountRowById($accountId); // If twitter screen name is present $twitter = $this->verifyCredentials(); if (is_object($twitter)) { if (strlen($row['twitter']) != 0) { $status = $row['name'] . ' ' . $row['twitter'] . ' has published their #IATIData. View the data here: http://iatiregistry.org' . $registryUrl . ' #AidStream'; } else { $status = $row['name'] . ' has published their #IATIData. View the data here: http://iatiregistry.org' . $registryUrl . ' #AidStream'; } $twitter->statuses->update($status); } else { return false; } }
/** * 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(); } }
/** * Registered Published Files As Selected */ public function publishInRegistryAction() { $fileIds = explode(',', $this->_getParam('organisation_file_ids')); if (!$fileIds[0]) { $this->_helper->FlashMessenger->addMessage(array('message' => "Please select a file to\n register in IATI Registry.")); $this->_redirect('wep/list-published-files'); } $identity = Zend_Auth::getInstance()->getIdentity(); $accountId = $identity->account_id; $modelRegistryInfo = new Model_RegistryInfo(); $registryInfo = $modelRegistryInfo->getOrgRegistryInfo($accountId); if (!$registryInfo->api_key) { $this->_helper->FlashMessenger->addMessage(array('error' => "Api Key not found. Organisation could\n not be registered in IATI Registry. Please go to\n <a href='{$this->view->baseUrl()}/wep/settings'>Settings</a>\n to add API key.")); } else { $reg = new Iati_Registry($registryInfo->publisher_id, $registryInfo->api_key, true); $organisationPublishedModel = new Model_OrganisationPublished(); $files = $organisationPublishedModel->getPublishedInfoByIds($fileIds); $published = Model_Registry::publish($files, $accountId, $registryInfo, true); if ($published['error']) { $this->_helper->FlashMessenger->addMessage(array('error' => $published['error'])); } else { $this->_helper->FlashMessenger->addMessage(array('message' => "Organisation published to IATI registry.")); } } $this->_redirect('wep/list-published-files'); }
public function listPublishedFilesAction() { $identity = Zend_Auth::getInstance()->getIdentity(); $orgId = $identity->account_id; // set publish permission to true so that we should only check permission for user. $publishPermission = 1; if ($identity->role == 'user') { $model = new Model_Wep(); $userPermission = $model->getUserPermission($identity->user_id); $publishPermission = $userPermission->hasPermission(Iati_WEP_PermissionConts::PUBLISH); } $modelRegistryInfo = new Model_RegistryInfo(); $registryInfo = $modelRegistryInfo->getOrgRegistryInfo($orgId); // Create Registry Form For Activities $formForActivities = new Form_Wep_PublishToRegistry(); $formForActivities->setAction($this->view->baseUrl() . '/wep/publish-in-registry'); if ($registryInfo->update_registry) { $formForActivities->push_to_registry->setAttrib('disabled', 'disabled'); } $this->view->formForActivities = $formForActivities; // Create Registry Form For Organisation $formForOrganisation = new Form_Organisation_PublishToRegistry(); $formForOrganisation->setAction($this->view->baseUrl() . '/organisation/publish-in-registry'); if ($registryInfo->update_registry) { $formForOrganisation->push_to_registry_for_organisation->setAttrib('disabled', 'disabled'); } $this->view->formForOrganisation = $formForOrganisation; // Fetch Publish Data For Activities $db = new Model_Published(); $publishedFilesOfActivities = $db->getAllPublishedInfo($orgId); $this->view->published_files_activities = $publishedFilesOfActivities; // Fetch Publish Data For Organisation $organisationpublishedModel = new Model_OrganisationPublished(); $publishedFilesOfOrganisation = $organisationpublishedModel->getAllPublishedInfo($orgId); $this->view->published_files_organisation = $publishedFilesOfOrganisation; $this->view->publish_permission = $publishPermission; if (Simplified_Model_Simplified::isSimplified()) { $this->view->blockManager()->disable('partial/organisation-data.phtml'); $this->view->blockManager()->enable('partial/simplified-info.phtml'); } }