%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/pn/beta/64801_wp-content/themes/intosai/lib/user_functions/
Upload File :
Create Path :
Current File : /var/www/pn/beta/64801_wp-content/themes/intosai/lib/user_functions/add_project.php

<?php
require_once("../../../../../wp-load.php");
require_once('../../../../../wp-includes/pluggable.php');

if(isset($_GET['addproject'])){

    //SET UPP CONTENT VARIABLES AND SANITIZE THEM
    $projectName                = strip_tags(htmlspecialchars($_POST['projectName']));
    $projectStatus              = strip_tags(htmlspecialchars($_POST['status']));
    $projectBenLevel            = strip_tags(htmlspecialchars($_POST['benLevel']));
    $projectBenSAI              = $_POST['benSai'];
    $projectINTOSAIRegion       = $_POST['intosaiRegion'];
    $projectDesc                = $_POST['desc'];
    $projectInit                = strip_tags(htmlspecialchars($_POST['initiated']));
    $projectFurtherLink         = strip_tags(htmlspecialchars($_POST['furtherLink']));
    $projectCPBenSaiReCom       = strip_tags(htmlspecialchars($_POST['contactBRC']));
    $projectFunding             = $_POST['funding'];
    $projectFundingCustom       = strip_tags(htmlspecialchars($_POST['sof_custom']));
    $projectCPDonor             = strip_tags(htmlspecialchars($_POST['contactDonor']));
    $projectImpAge              = strip_tags(htmlspecialchars($_POST['implementingAgency']));
    $projectCPImpPart           = strip_tags(htmlspecialchars($_POST['implementingContact']));
    $projectFrom                = strip_tags(htmlspecialchars($_POST['from']));
    $projectTo                  = strip_tags(htmlspecialchars($_POST['to']));
    $projectBudget              = strip_tags(htmlspecialchars($_POST['budget']));
    $projectSupType             = strip_tags(htmlspecialchars($_POST['supportType']));
    $projectSupModal            = strip_tags(htmlspecialchars($_POST['supportModal']));
    $projectSupCats             = $_POST['supportCats'];
    $projectSupBased            = strip_tags(htmlspecialchars($_POST['supportBased']));
    $projectLinkedProj          = $_POST['linkedProjects'];
    $projectOtherInfo           = $_POST['otherInfo'];
    $publishStatus              = strip_tags(htmlspecialchars($_POST['publishStatus']));
    $draftCreated               = strip_tags(htmlspecialchars($_POST['creation']));

    $wdiTerms = array();
    foreach($projectBenSAI as $benSAI){
        array_push($wdiTerms, $benSAI);
    }

    $projLinks = array();
    foreach($projectLinkedProj as $project){
        array_push($projLinks, $project);
    }

    $regions = ''; $r = 1;
    foreach($projectINTOSAIRegion as $INTOSAIRegion){
        if($r != 1){
            $regions .= ', ';
        }

        $regions .= $INTOSAIRegion;

        $r++;
    }

    $sources = ''; $s = 1;
    foreach($projectFunding as $source){
        if($s != 1){
            $sources .= ', ';
        }

        $sources .= $source;

        $s++;
    }

    $supCover = ''; $sC = 1;
    foreach($projectSupCats as $supCat){
        if($sC != 1){
            $supCover .= ', ';
        }

        $supCover .= $supCat;

        $sC++;
    }

    $allowedTags = '<br><strong><b><em><i><ul><li>';

    //CONSTRUCT PROJECT
    $project = array(
        'post_type'         =>      'project',
        'post_status'       =>      'pending',
        'post_title'        =>      strip_tags($projectName),
        'post_content'      =>      strip_tags($projectDesc, $allowedTags),
        'tax_input'    => array(
            'wdi'   =>  $wdiTerms
        ),
        'meta_input'        =>      array(
            'project_status'                        =>  $projectStatus,
            'beneficiary_level'                     =>  $projectBenLevel,
            'intosai_region'                        =>  $regions,
            'project_initiated'                     =>  $projectInit,
            'further_info'                          =>  $projectFurtherLink,
            'cp_ben-sai_region_committee'           =>  $projectCPBenSaiReCom,
            'source_funding'                        =>  $sources,
            'source_funding_custom'                 =>  $projectFundingCustom,
            'cp_donor'                              =>  $projectCPDonor,
            'imp_agencys'                           =>  $projectImpAge,
            'cp_imp-partners'                       =>  $projectCPImpPart,
            'duration_from'                         =>  $projectFrom,
            'duration_to'                           =>  $projectTo,
            'total_budget'                          =>  $projectBudget,
            'type_of_support'                       =>  $projectSupType,
            'support_modality'                      =>  $projectSupModal,
            'support_cats_covered'                  =>  $supCover,
            'support_based_on'                      =>  $projectSupBased,
            'project_connections'                   =>  $projLinks,
            'other_info'                            =>  strip_tags($projectOtherInfo, $allowedTags),
            'publish_status'                        =>  $publishStatus,
            'draft_creation'                        =>  $draftCreated,
        ),
    );

    $new_project = wp_insert_post($project);

    if(!is_wp_error($new_project)){ //PROJECT ADDED

        $adminEmail = 'admin@saidevelopment.org';

        if($publishStatus == 'publish'){
            /************************************* CONSTRUCT EMAIL *************************************/
            /*----------------------------------- Sends to the admin ----------------------------------*/
            include('mailer.php');

            $form_id = 'Publish project';

            //TITLE IN MAIL
            $sub = "Project awaits approval";

            //SHORT EXCERPT VIEWED IN EG. GMAIL
            $excerpt = "A user has flaged a project for publishing";

            //MAIN MESSAGE IN MAIL
            $message = "<h1 style='font-size:24px;line-height:30px;margin:0 0 0;'>{$sub}</h1>
            <h2 style='font-size:18px;font-weight:400;line-height:30px;margin:0 0 20px;color:{$color};'>{$excerpt}</h2>
            You can review and publish the project by pressing the link below.<br/>
            <br/>
            View the project: <a href='{$site_url}wp-admin/post.php?post={$new_project}&action=edit' style='color:{$color};'>{$projectName}</a>";

            $from = 'no-reply@saiddevelopment.org';
            $headers = array('Content-Type: text/html; charset=UTF-8');

            wp_mail($adminEmail, $sub, smtp_mail($sub,$message,$excerpt,$fromUrl,$form_id), $headers);
            //wp_mail('kim@noboxsolutions.se', $sub, smtp_mail($sub,$message,$excerpt,$fromUrl,$form_id), $headers);
        }

        header("Location: /my-projects/?project_added");
        exit;
    }else{ //THERE WAS AN ERROR CREATING THE PROJECT
        header("Location: /my-projects/?add_project_error");
        exit;
    }
}
?>

Zerion Mini Shell 1.0