public function saveRegistryPublishInfo($fileId, $filename, $response)
 {
     $identity = Zend_Auth::getInstance()->getIdentity();
     $data['filename'] = $filename;
     $data['file_id'] = $fileId;
     $serialisedResponse = serialize($response);
     $data['response'] = $serialisedResponse;
     $data['publisher_org_id'] = $identity->account_id;
     $this->insert($data);
     // Update published data.
     $modelPublish = new Model_OrganisationPublished();
     $modelPublish->markAsPushedToRegistry($fileId);
 }
 /**
  * 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');
 }
Beispiel #3
0
 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');
     }
 }