Beispiel #1
0
 /**
  * Loads URI and Input objects into the controller.
  * Check if the requested environment the system does supports.
  */
 function __construct($instance)
 {
     $this->db = Registry::factory('Database_Query_Builder');
     $this->_data_types = $this->_getDataTypes();
     $this->eav_instance = $this->_checkInstance($instance);
     $this->_aData = Model_Registry::instance(true);
 }
Beispiel #2
0
 /**
  * Gets the singleton instance
  * @param bool $re_instantiate
  * @return Registry
  */
 public static function &instance($re_instantiate = false)
 {
     if ($re_instantiate) {
         self::$_instance = null;
     }
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Beispiel #3
0
 /**
  * Loads the result from database into the local object.
  * @param mixed
  */
 public function __construct($user)
 {
     if ($user instanceof Database_Mapper_Result) {
         // Create registry object
         $this->_aData = Model_Registry::instance();
         // Deploy properties
         foreach ($user as $prop => $val) {
             $this->_aData->{$prop} = $val;
         }
     }
 }
Beispiel #4
0
 public function setCountryCode($countryCode)
 {
     $this->countryCode = $countryCode;
     if (!$countryCode) {
         return;
     }
     if (is_numeric($this->countryCode)) {
         $this->countryName = Model_Registry::getRegionNameFromCode($this->countryCode);
     } else {
         $this->countryName = Model_Registry::getCountryNameFromCode($this->countryCode);
     }
 }
Beispiel #5
0
 /**
  *
  * Generate json input to feed to the registry.
  */
 protected function _prepareRegistryInputJson()
 {
     $identity = Zend_Auth::getInstance()->getIdentity();
     $filename = explode('.', $this->file);
     $title = $this->publisher_name ? $this->publisher_name . ' Activity File' : 'Activity File ' . $filename[0];
     if ($this->country_code && $this->publisher_name) {
         if (is_numeric($this->country_code)) {
             $countryName = Model_Registry::getRegionNameFromCode($this->country_code);
         } else {
             $countryName = Model_Registry::getCountryNameFromCode($this->country_code);
         }
         if ($countryName) {
             $title .= " for " . $countryName;
         }
     }
     $data = array("name" => $filename[0], "title" => $title, "author_email" => $identity->email, "resources" => array(array("url" => $this->file_url, "format" => "IATI-XML")), "extras" => array("filetype" => "activity", "country" => $this->country_code, "activity_period-from" => '', "activity_period-to" => '', "data_updated" => date('Y-m-d', strtotime($this->activity_updated_datetime)), "record_updated" => date('Y-m-d'), "activity_count" => $this->activity_count, "verified" => "no", "language" => "en"), "groups" => array($this->publisher_id));
     $jsonData = json_encode($data);
     $this->json_data = $jsonData;
 }
Beispiel #6
0
 /**
  * Clear data object.
  * @return void
  */
 protected function _clearData()
 {
     $this->_aData = Model_Registry::instance(true);
 }
Beispiel #7
0
 /**
  * Loads URI and Input objects into the controller.
  * Check if the requested environment supports by the system.
  */
 function __construct()
 {
     $this->_aData = Model_Registry::instance(true);
     $this->db = Registry::factory('Database_Query_Builder', null, true, true);
 }
 /**
  * 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');
 }