Exemple #1
0
<?php

include "../header.php";
require_once "../model/objects/Contribution.php";
require_once "../model/ContributionController.php";
$contributionController = new ContributionController();
$searchKey = "";
if (array_key_exists("search", $_REQUEST)) {
    $searchKey = decodeInput($_REQUEST['search']);
}
$status = "";
if (array_key_exists("mark", $_REQUEST)) {
    $status = decodeInput($_REQUEST['mark']);
}
?>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Contributions
      </h1>
    </section>
    <?php 
if ($searchKey != "") {
    $dataList = $contributionController->search($searchKey, $offset, $rowsPerPage);
} else {
    if ($status == "") {
        $dataList = $contributionController->getAll($offset, $rowsPerPage);
    } else {
        $dataList = $contributionController->getByStatus($status, $offset, $rowsPerPage);
$userId = $_SESSION['userId'];
if ($_SERVER['REQUEST_METHOD'] == 'POST' || $_SERVER['REQUEST_METHOD'] == 'post') {
    /* get all the post data from */
    $poiName = decodeInput($_POST['poiName']);
    $poiAddress = decodeInput($_POST['poiAddress']);
    $poiCategory = decodeInput($_POST['poiCategory']);
    $poiPhone = decodeInput($_POST['poiPhone']);
    $poiEmail = decodeInput($_POST['poiEmail']);
    $poiWebsite = decodeInput($_POST['poiWebsite']);
    $poiLatitude = decodeInput($_POST['poiLat']);
    $poiLongitude = decodeInput($_POST['poiLong']);
    $poiPosition = $poiLatitude . "," . $poiLongitude;
    $poiContribution = decodeInput($_POST['poiContribution']);
    $userController = new UsersController();
    $poiController = new PoiController();
    $categoryController = new CategoryController();
    $contributionController = new ContributionController();
    /* since we are letting the validation of the data on the client side, we will
       skip the validation here and just go on with insertion */
    /* so first create the poi object, also the required objects to initialize the poi */
    $poi = new POI();
    $poi->init($poiName, $poiAddress, $poiPosition, $categoryController->find($poiCategory), $poiPhone, $poiEmail, $poiWebsite, "", $userController->find($user->getId()));
    if ($poiContribution != 0) {
        if (is_numeric($poiContribution)) {
            if ($contribution = $contributionController->find($poiContribution)) {
                $poi->setContribution($contribution);
            }
        }
    }
    $poiController->add($poi);
}
Exemple #3
0
<?php

/**
 * Created by Yogesh on 12/2/2015.
 *
 */
session_start();
require_once "../config/Route.php";
require_once "../model/UsersController.php";
require_once "../model/ContributionController.php";
if (array_key_exists('userId', $_SESSION)) {
    $contributionController = new ContributionController();
    $userController = new UsersController();
    $userId = $_SESSION['userId'];
    $user = $userController->find($userId);
    if ($user) {
        if (array_key_exists('post', $_GET) && array_key_exists('s', $_GET)) {
            $id = test_input($_GET['post']);
            $poi = $contributionController->find($id);
            if ($poi) {
                $action = test_input($_GET['s']);
                switch ($action) {
                    case "a":
                        $poi->setStatus("A");
                        $contributionController->update($poi);
                        Route::redirect($_SERVER['HTTP_REFERER']);
                        break;
                    case "r":
                        $poi->setStatus("R");
                        $contributionController->update($poi);
                        Route::redirect($_SERVER['HTTP_REFERER']);
Exemple #4
0
<?php

include "../header.php";
require_once "../model/ContributionController.php";
require_once "../model/objects/Contribution.php";
if (array_key_exists('post', $_REQUEST)) {
    $postId = $_REQUEST['post'];
    if (is_numeric($postId)) {
        $contributionController = new ContributionController();
        $contribution = $contributionController->find($postId);
        ?>

        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>
                    Read Contribution
                </h1>
            </section>

            <!-- Main content -->
            <section class="content">
                <div class="row">
                    <div class="col-md-9">
                        <div class="box box-primary">
                            <div class="box-header with-border">
                                <h3 class="box-title">Read Contribution</h3>

<!--                                <div class="box-tools pull-right">-->
<!--                                    <a href="#" class="btn btn-box-tool" data-toggle="tooltip" title="Previous"><i-->
 * If any of these requirements is missing or if any data is not a valid one
 * Error will re returned by the file
 */
require_once "../model/ContributionController.php";
require_once "../model/objects/Contribution.php";
if ($_SERVER['REQUEST_METHOD'] == "post" || $_SERVER['REQUEST_METHOD'] == "POST") {
    if (array_key_exists('name', $_REQUEST) && array_key_exists('email', $_REQUEST) && array_key_exists('pn', $_REQUEST) && array_key_exists('pa', $_REQUEST) && array_key_exists('pc', $_REQUEST) && array_key_exists('pm', $_REQUEST) && array_key_exists('pr', $_REQUEST)) {
        //only if all data is available
        $name = decodeInput($_REQUEST['name']);
        $email = decodeInput($_REQUEST['email']);
        $poiName = decodeInput($_REQUEST['pn']);
        $poiAddress = decodeInput($_REQUEST['pa']);
        $poiMessage = decodeInput($_REQUEST['pm']);
        $poiCategory = decodeInput($_REQUEST['pc']);
        $poiRequest = decodeInput($_REQUEST['pr']);
        $contributionController = new ContributionController();
        $contribution = new Contribution();
        $contribution->init($name, $email, $poiName, $poiAddress, $poiCategory, $poiMessage, $poiRequest);
        if ($contributionController->add($contribution)) {
            sendThankyouMail($contribution);
            echo "success";
            exit;
        } else {
            echo "error cannot add";
            exit;
        }
    } else {
        echo "error post keys missing";
        exit;
    }
} else {
<?php

include "header.php";
require_once "model/ContributionController.php";
require_once "model/objects/Contribution.php";
require_once "model/FeedbackController.php";
require_once "model/objects/Feedback.php";
$contributionController = new ContributionController();
$feedbackController = new FeedbackController();
?>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Dashboard
      </h1>
    </section>

    <!-- Main content -->
    <section class="content">
      <!-- Info boxes -->
      <div class="row">
        <div class="col-md-3 col-sm-6 col-xs-12">
          <div class="info-box">
            <a href="<?php 
echo Route::getAdminDirectory();
?>
locations/add.php">
              <span class="info-box-icon bg-aqua">
              <i class="ion ion-android-add-circle"></i></span>
Exemple #7
0
/**
 * Created by Yogesh on 11/20/2015.
 * 
 */
include_once "../model/PoiController.php";
include_once "../model/UsersController.php";
include_once "../model/objects/User.php";
include_once "../model/objects/POI.php";
include_once "../model/objects/Contribution.php";
include_once "../model/objects/Category.php";
include_once "../model/objects/ParentCategory.php";
include_once "../model/CategoryController.php";
include_once "../model/ContributionController.php";
header("Content-Type: text/plain");
$cont = new ContributionController();
$data = $cont->getAll();
print_r($data);
exit;
$dataArray = array("Pokhara||Gandaki Zone, Kaski District, Nepal||http://en.wikipedia.org/wiki/Pokhara||city||28.2095379,83.9914028", "Hyatt Regency||Nepal||null||bus station||27.7193693,85.3541166", "Ason||Nepal||null||neighbourhood||27.7075079,85.3122521", "Lainchour Chowk Bus Stop||Nepal||null||bus station||27.7169967,85.316039", "Airport Bus Station||Nepal||null||bus station||27.7007168,85.3537173", "Dillibazaar stop||Nepal||null||bus station||27.7053698,85.3267594");
$currentUser = $userController->find(3);
$poiIdDummy = 56;
foreach ($dataArray as $key => $value) {
    $row = $value;
    $data = explode("||", $row);
    $category = new Category();
    $category->setUser($currentUser);
    $category->setSubCategory($data[3]);
    $poi = new POI();
    $poi->init($poiIdDummy, $data[0], $data[1], $data[4], $category, "", "", "", "", $currentUser);
    $contributionController->add($poi);
Exemple #8
0
<?php

/**
 * Created by Yogesh on 12/2/2015.
 *
 */
session_start();
require_once "../config/Route.php";
require_once "../model/UsersController.php";
require_once "../model/ContributionController.php";
if (array_key_exists('userId', $_SESSION)) {
    $contributionController = new ContributionController();
    $userController = new UsersController();
    $userId = $_SESSION['userId'];
    $user = $userController->find($userId);
    if ($user) {
        if (array_key_exists('post', $_GET)) {
            $id = test_input($_GET['post']);
            $poi = $contributionController->find($id);
            if ($poi) {
                $contributionController->delete($id);
                Route::getBackend("contributions/");
            } else {
                Route::get404Error();
            }
        } else {
            Route::get404Error();
        }
    } else {
        Route::get404Error();
    }