Esempio n. 1
0
 /**
  * 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();
     }
 }
Esempio n. 2
0
 /**
  * Update Default Element Value Of An Organisation
  */
 public function updateDefaultAction()
 {
     $elementName = $this->getRequest()->getParam('elementName');
     $elementId = $_POST['id'];
     if (!$elementName) {
         $this->_helper->FlashMessenger->addMessage(array('error' => "Could not fetch element Name."));
         $this->_redirect("/wep/dashboard");
     }
     if (!$elementId) {
         $this->_helper->FlashMessenger->addMessage(array('error' => "No id provided."));
         $this->_redirect("/wep/dashboard");
     }
     // Update Default Element Value And Fetch Organisation Id
     $organisationDefaultElementModel = new Model_OrganisationDefaultElement();
     $organisationId = $organisationDefaultElementModel->updateElementData($elementName, $elementId);
     //Update Organisation Hash
     $organisationHashModel = new Model_OrganisationHash();
     $updated = $organisationHashModel->updateHash($organisationId);
     if (!$updated) {
         $type = 'message';
         $message = "Already up to date. To make changes please change values\n                    in 'Settings' and then update.";
     } else {
         //Update the organisation so that the last updated time is updated
         $wepModel = new Model_Wep();
         $organisationData = array();
         $organisationData['@last_updated_datetime'] = date('Y-m-d h:i:s');
         $organisationData['id'] = $organisationId;
         $wepModel->updateRowsToTable('iati_organisation', $organisationData);
         //Change state to editing
         $db = new Model_OrganisationState();
         $db->updateOrganisationState($organisationId, Iati_WEP_ActivityState::STATUS_DRAFT);
         $type = 'message';
         // Get display name
         $className = "Iati_Aidstream_Element_Organisation_{$elementName}";
         $elementClassObj = new $className();
         $displayName = $elementClassObj->getDisplayName();
         $message = "{$displayName} sucessfully updated";
     }
     $this->_helper->FlashMessenger->addMessage(array($type => $message));
     $this->_redirect("/organisation/edit-elements/?parentId=" . $organisationId . "&className=Organisation_{$elementName}");
 }