コード例 #1
0
ファイル: WepController.php プロジェクト: relyd/aidstream
 public function dashboardAction()
 {
     if (Simplified_Model_Simplified::isSimplified()) {
         $this->_redirect('simplified/default/dashboard');
     }
     $identity = Zend_Auth::getInstance()->getIdentity();
     $account_id = $identity->account_id;
     $model = new Model_Wep();
     $activityModel = new Model_Activity();
     $activities_id = $model->listAll('iati_activities', 'account_id', $account_id);
     if (empty($activities_id)) {
         $data['@version'] = '01';
         $data['@generated_datetime'] = date('Y-m-d H:i:s');
         $data['user_id'] = $identity->user_id;
         $data['account_id'] = $identity->account_id;
         $data['unqid'] = uniqid();
         $activities_id = $model->insertRowsToTable('iati_activities', $data);
     } else {
         $activities_id = $activities_id[0]['id'];
     }
     $activityCollModel = new Model_ActivityCollection();
     $activities = $activityCollModel->getActivitiesByAccount($account_id);
     $activitiesAttribs = $activityCollModel->getActivityAttribs($activities);
     $regInfoModel = new Model_RegistryInfo();
     $regInfo = $regInfoModel->getOrgRegistryInfo($account_id);
     $regPublishModel = new Model_RegistryPublishedData();
     $publishedFiles = $regPublishModel->getPublishedInfoByOrg($account_id);
     $this->view->published_data = $published_data;
     $this->view->activity_count = sizeof($activities);
     $this->view->state_count = $activityModel->getCountByState($activities);
     $this->view->last_updated_datetime = $activityModel->getLastUpdatedDatetime($activities);
     $this->view->published_activity_count = $regPublishModel->getActivityCount($publishedFiles);
     $this->view->activity_elements_info = $activitiesAttribs;
     $this->view->registry_url = "/publisher/" . $regInfo->publisher_id;
     $this->view->activities_id = $activities_id;
 }
コード例 #2
0
ファイル: Activity.php プロジェクト: relyd/aidstream
 /**
  * Ported from Admin Controller::listActivityStatesAction()
  * @param None
  * @return Array containing activity states and activity registry published count for all organisations.
  */
 public function allOrganisationsActivityStates()
 {
     $model = new Model_Wep();
     $activityCollModel = new Model_ActivityCollection();
     // $activityModel = new Model_Activity();
     $orgs = $model->listOrganisation('account');
     $orgData = array();
     foreach ($orgs as $organisation) {
         $activities = $activityCollModel->getActivitiesByAccount($organisation['id']);
         $states = $this->getCountByState($activities);
         $organisation['states'] = $states;
         $regPublishModel = new Model_RegistryPublishedData();
         $publishedFiles = $regPublishModel->getPublishedInfoByOrg($organisation['id']);
         $publishedActivityCount = $regPublishModel->getActivityCount($publishedFiles);
         $organisation['registry_published_count'] = $publishedActivityCount;
         $orgData[] = $organisation;
     }
     return $orgData;
 }
コード例 #3
0
ファイル: Registry.php プロジェクト: relyd/aidstream
 /**
  * @deprecated
  *
  * Checks if a file with given name is published against the local database.
  * @param String $filename	Name of file to check for published.
  * @return Boolen
  */
 public function isFilePublished($filename)
 {
     $model = new Model_RegistryPublishedData();
     $isPublished = $model->isFilePublished($filename);
     return $isPublished;
 }
コード例 #4
0
ファイル: AdminController.php プロジェクト: relyd/aidstream
 public function generatePublishedXmlFilesAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout()->disableLayout();
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     $xmlPath = $config->public_folder . $config->xml_folder;
     $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><iati-publishers><!-- Generated By AidStream --></iati-publishers>');
     $registryPublishedModel = new Model_RegistryPublishedData();
     $organisationRegistryPublishedModel = new Model_OrganisationRegistryPublishedData();
     $accountModel = new User_Model_DbTable_Account();
     $organisationRegistryPublishedData = $organisationRegistryPublishedModel->getAllOrganisationRegistryPublishedData();
     $registryPublishedData = $registryPublishedModel->getAllRegistryPublishedData();
     // For Activity
     $index = 1;
     foreach ($registryPublishedData as $registryData) {
         $orgName = $accountModel->getOrganisationNameById($registryData->publisher_org_id);
         $orgName = preg_replace('/&/', '&amp;', $orgName);
         if ($index == 1) {
             $registry[$orgName]['publisherId'] = substr($registryData->filename, 0, strrpos($registryData->filename, '-'));
         }
         $registry[$orgName]['activity'][] = $registryData->filename;
     }
     // For Organisation Data
     foreach ($organisationRegistryPublishedData as $registryData) {
         $orgName = $accountModel->getOrganisationNameById($registryData->publisher_org_id);
         $orgName = preg_replace('/&/', '&amp;', $orgName);
         if ($index == 1) {
             $registry[$orgName]['publisherId'] = substr($registryData->filename, 0, strrpos($registryData->filename, '-'));
         }
         $registry[$orgName]['organisation'][] = $registryData->filename;
     }
     ksort($registry);
     foreach ($registry as $publisherName => $information) {
         $iatiPublisher = $xml->addChild('iati-publisher');
         $iatiPublisher->addChild('name', $publisherName);
         $iatiPublisher->addChild('registry-publisher-id', $information['publisherId']);
         $iatiFiles = $iatiPublisher->addChild('iati-files');
         if (isset($information['activity'])) {
             foreach ($information['activity'] as $iatiActivity) {
                 $fileUrl = 'http://aidstream.org/files/xml/' . trim($iatiActivity) . '.xml';
                 $iatiFile = $iatiFiles->addChild('iati-activity', $fileUrl);
             }
         }
         if (isset($information['organisation'])) {
             foreach ($information['organisation'] as $iatiOrganisation) {
                 $fileUrl = 'http://aidstream.org/files/xml/' . trim($iatiOrganisation) . '.xml';
                 $iatiFile = $iatiFiles->addChild('iati-organisation', $fileUrl);
             }
         }
     }
     $fileName = "published-files.xml";
     $fp = fopen($xmlPath . $fileName, 'w');
     fwrite($fp, $xml->asXML());
     fclose($fp);
     if (file_exists($xmlPath . $fileName)) {
         $this->_redirect('/files/xml/' . $fileName);
     }
 }
コード例 #5
0
ファイル: File.php プロジェクト: relyd/aidstream
 /**
  * Save the response received from the registry and update the is_published attribute of the file
  */
 public function saveRegistryPublishInfo($response)
 {
     if ($this->isOrganisationData()) {
         $model = new Model_OrganisationRegistryPublishedData();
     } else {
         $model = new Model_RegistryPublishedData();
     }
     if ($this->isPushedToRegistry) {
         $model->updateRegistryPublishInfo($this->id, $response);
     } else {
         $filename = explode('.', $this->name);
         $name = $filename[0];
         $model->saveRegistryPublishInfo($this->id, $name, $response);
     }
 }