/** * Send notification for support query. */ public function sendSupportNotifications($data) { $model = new Model_Wep(); $account = $model->getRowById('account', 'id', Zend_Auth::getInstance()->getIdentity()->account_id); //Send Support Mail $mailParams['subject'] = 'Support Request'; $mailParams['support_name'] = $data['support_name']; $mailParams['support_email'] = $data['support_email']; $mailParams['support_query'] = $data['support_query']; $mailParams['from'] = array($data['support_email'] => ''); $mailParams['servername'] = $_SERVER['SERVER_NAME']; $mailParams['account_name'] = $account['name']; $supportEmail = Zend_Registry::get('config')->email->support; $template = 'support.phtml'; $this->sendemail($mailParams, $template, array($supportEmail => '')); }
public function init() { $identity = Zend_Auth::getInstance()->getIdentity(); $model = new Model_Wep(); $user = $model->getRowById('profile', 'user_id', $identity->user_id); $this->setAttrib('id', 'support-form')->setAction(Zend_Controller_Front::getInstance()->getBaseUrl() . '/user/user/support'); $form['referer'] = new Zend_Form_Element_Hidden('referer'); $uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri(); $form['referer']->setValue($uri); $form['support_name'] = new Zend_Form_Element_Text('support_name'); $form['support_name']->setLabel('Name')->setRequired()->setValue($user['first_name'] . " " . $user['last_name'])->setAttrib('readonly', 'true')->addErrorMessage('Please enter your name'); $form['support_email'] = new Zend_Form_Element_Text('support_email'); $form['support_email']->setLabel('Email')->setRequired()->setValue($identity->email)->setAttrib('readonly', 'true')->addErrorMessage('Please enter your email'); $form['support_query'] = new Zend_Form_Element_Textarea('support_query'); $form['support_query']->setLabel('Query')->setRequired()->setAttrib('rows', '10')->addErrorMessage('Please enter your query'); $form['support_submit'] = new Zend_Form_Element_Submit('support_submit'); $form['support_submit']->setLabel('Send now!'); $this->addElements($form); }
/** * * Function to publish xml data. Calls internal functions to prepare and * save xml file and save the published data to local database. */ public function publish() { $activitiesCollection = $this->getDataToPublish(); if ($this->segmented) { // reset existing published info $this->resetPublishedInfo(); //print each segments activities xml and save published info foreach ($activitiesCollection as $org => $activitiesId) { $this->recipient = $org; $fileName = $this->saveActivityXml($activitiesId); $count = 0; if (is_array($activitiesId)) { $wepModel = new Model_Wep(); foreach ($activitiesId as $activityId) { $activityRow = $wepModel->getRowById('iati_activity', 'id', $activityId['id']); $activityUpdatedDatetime = strtotime($activityRow['@last_updated_datetime']) > strtotime($activityUpdatedDatetime) ? $activityRow['@last_updated_datetime'] : $activityUpdatedDatetime; } $count = sizeof($activitiesId); } /* $country = ''; if(in_array($this->recipient , $this->country)){ $country = $this->recipient; } */ $this->savePublishedInfo($fileName, $org, $count, $activityUpdatedDatetime); } } else { // remove existing published info $this->resetPublishedInfo(); $fileName = $this->saveActivityXml($activitiesCollection); if (is_array($activitiesCollection)) { $wepModel = new Model_Wep(); foreach ($activitiesCollection as $activityId) { $activityRow = $wepModel->getRowById('iati_activity', 'id', $activityId['id']); $activityUpdatedDatetime = strtotime($activityRow['@last_updated_datetime']) > strtotime($activityUpdatedDatetime) ? $activityRow['@last_updated_datetime'] : $activityUpdatedDatetime; } } $this->savePublishedInfo($fileName, '', sizeof($activitiesCollection), $activityUpdatedDatetime); } }
public static function getActivityInfo($activityId) { $model = new Model_Wep(); $activityInfo = $model->listAll('iati_activity', 'id', $activityId); if (empty($activityInfo)) { return false; } $activity = $activityInfo[0]; $activity['@xml_lang'] = $model->fetchValueById('Language', $activityInfo[0]['@xml_lang'], 'Code'); $activity['@default_currency'] = $model->fetchValueById('Currency', $activityInfo[0]['@default_currency'], 'Code'); $iati_identifier_row = $model->getRowById('iati_identifier', 'activity_id', $activityId); $activity['iati_identifier'] = $iati_identifier_row['text']; $activity['activity_identifier'] = $iati_identifier_row['activity_identifier']; $title_row = $model->getRowById('iati_title', 'activity_id', $activityId); $activity['iati_title'] = $title_row['text']; return $activity; }
public function editUserPermissionAction() { if (isset($_GET['user_id'])) { $user_id = $_GET['user_id']; } $model = new Model_Wep(); $permissionSerialized = $model->getRowById('user_permission', 'user_id', $user_id); //print_r($permissionSerialized['object']);exit; $permissionObj = unserialize($permissionSerialized['object']); //print_r($permissionObj);exit; $default['fields'] = $permissionObj->getProperties(); $form = new Form_Admin_Editpermission(); $form->edit($default); if ($_POST) { try { $data = $_POST; $i = 0; //print_r($data);exit; $permissionObj = new Iati_WEP_UserPermission(); foreach ($data['default_fields'] as $eachField) { if ($eachField == 'add') { $permissionObj->setProperties('add_activity_elements'); $permissionObj->setProperties('add_activity'); $defaultKey[$i++] = 'add_activity_elements'; $defaultKey[$i++] = 'add_activity'; } elseif ($eachField == 'edit') { $permissionObj->setProperties('edit_activity_elements'); $permissionObj->setProperties('edit_activity'); $defaultKey[$i++] = 'edit_activity_elements'; $defaultKey[$i++] = 'edit_activity'; } else { if ($eachField == 'delete') { $permissionObj->setProperties('delete_activity'); $defaultKey[$i++] = 'delete_activity'; } else { $permissionObj->setProperties($eachField); $defaultKey[$i++] = $eachField; } } //$defaultKey[$i] = $eachField; //$i++; } $permissionObj->setProperties('view_activities'); $fieldString = serialize($permissionObj); $defaultFields['object'] = $fieldString; $defaultFields['user_id'] = $user_id; $defaultFieldId = $model->updateRow('user_permission', $defaultFields, 'user_id', $user_id); //print_r($defaultKey);exit; $privilegeFields['resource'] = serialize($defaultKey); $privilegeFields['owner_id'] = $user_id; $privilegeFieldId = $model->updateRow('Privilege', $privilegeFields, 'owner_id', $user_id); $this->_helper->FlashMessenger->addMessage(array('message' => 'User permission updated.')); $this->_redirect('admin/view-profile?user_id=' . $user_id); } catch (Exception $e) { print $e; } } $this->view->form = $form; if ($identity->role != 'superadmin') { $this->view->blockManager()->enable('partial/primarymenu.phtml'); $this->view->blockManager()->enable('partial/add-activity-menu.phtml'); $this->view->blockManager()->enable('partial/usermgmtmenu.phtml'); } }
public function editActivityAction() { $identity = Zend_Auth::getInstance()->getIdentity(); if ($_GET) { $wepModel = new Model_Wep(); if (isset($_GET['activities_id'])) { $exists = $wepModel->getRowById('iati_activities', 'id', $_GET['activities_id']); if (!$exists) { $this->_helper->FlashMessenger->addMessage(array('message' => "Activities does not exist.")); $this->_redirect('/user/user/login'); } $activities_id = $this->getRequest()->getParam('activities_id'); $rowSet = $wepModel->getRowsByFields('default_field_values', 'account_id', $identity->account_id); $defaultValues = unserialize($rowSet[0]['object']); $default = $defaultValues->getDefaultFields(); $activity['xml_lang'] = $default['language']; $activity['default_currency'] = $default['currency']; $activity['hierarchy'] = $default['hierarchy']; $activity['linked_data_uri'] = $default['linked_data_default']; $form = new Form_Wep_IatiActivity(); $form->add('add', $identity->account_id); $form->populate(array('reporting_org' => $default['reporting_org_ref'])); } if (isset($_GET['activity_id'])) { $exists = $wepModel->getRowById('iati_activity', 'id', $_GET['activity_id']); if (!$exists) { $this->_helper->FlashMessenger->addMessage(array('warning' => "Activity does not exist.")); $this->_redirect('/user/user/login'); } $activity_id = $this->getRequest()->getParam('activity_id'); $rowSet = $wepModel->getRowsByFields('iati_activity', 'id', $activity_id); $activity['xml_lang'] = $rowSet[0]['@xml_lang']; $activity['default_currency'] = $rowSet[0]['@default_currency']; $activity['hierarchy'] = $rowSet[0]['@hierarchy']; $activity['activities_id'] = $rowSet[0]['activities_id']; $activity['linked_data_uri'] = $rowSet[0]['@linked_data_uri']; $form = new Form_Wep_EditIatiActivity(); $form->edit($identity->account_id); $aActivityInfo = $wepModel->listAll('iati_activity', 'id', $activity_id); $activityInfo = $aActivityInfo[0]; $iati_identifier_row = $wepModel->getRowById('iati_identifier', 'activity_id', $activity_id); $activityInfo['iati_identifier'] = $iati_identifier_row['text']; $title_row = $wepModel->getRowById('iati_title', 'activity_id', $activity_id); $activityInfo['iati_title'] = $title_row['text']; $this->view->activityInfo = $activityInfo; } if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if (!$form->isValid($formData)) { $form->populate($formData); } else { if (isset($_GET['activities_id'])) { $default['language'] = $formData['xml_lang']; $default['currency'] = $formData['default_currency']; $default['hierarchy'] = $formData['hierarchy']; $default['linked_data_default'] = $formData['linked_data_uri']; $iatiIdentifier = array(); $iatiIdentifier['iati_identifier'] = $formData['iati_identifier_text']; $iatiIdentifier['activity_identifier'] = $formData['activity_identifier']; $activityModel = new Model_Activity(); $activityId = $activityModel->createActivity($activities_id, $default, $iatiIdentifier); //Create Activity Hash $activityHashModel = new Model_ActivityHash(); $updated = $activityHashModel->updateActivityHash($activityId); $this->_helper->FlashMessenger->addMessage(array('message' => "Activity Sucessfully Created.")); $this->_redirect('activity/view-activity-info/?activity_id=' . $activityId); } if (isset($_GET['activity_id'])) { //$data['activities_id'] = $rowSet[0]['activities_id']; $data['id'] = $activity_id; $data['@xml_lang'] = $formData['xml_lang']; $data['@default_currency'] = $formData['default_currency']; $data['@hierarchy'] = $formData['hierarchy']; $data['@linked_data_uri'] = $formData['linked_data_uri']; $result = $wepModel->updateRowsToTable('iati_activity', $data); $wepModel = new Model_Wep(); $activityHashModel = new Model_ActivityHash(); $updated = $activityHashModel->updateActivityHash($activity_id); if (!$updated) { $type = 'info'; $message = 'No Changes Made'; } else { //change state to editing $db = new Model_ActivityStatus(); $db->updateActivityStatus($activity_id, Iati_WEP_ActivityState::STATUS_DRAFT); $type = 'message'; $message = "Activity overridden"; } $this->_helper->FlashMessenger->addMessage(array($type => $message)); } $this->_redirect('activity/view-activity-info/?activity_id=' . $activity_id); } //end of inner if } else { $form->populate($activity); } $this->view->form = $form; $this->view->activity_id = $activity_id; } }