Beispiel #1
0
 /**
  * Almost the same as retractApp() in Student
  * responds an application based on ID
  * $newStatus determines the response...3 is for rejected
  * @param $id int
  * @param int
  * @return bool|array
  */
 public function respondToApp($id, $newStatus)
 {
     if (!ctype_digit($id)) {
         return false;
     }
     $conn = new PDO(DB_DSN, DB_USER, DB_PASS);
     $sst = $conn->prepare("SELECT * FROM applications WHERE id = :id");
     if ($sst->execute(array(":id" => $id))) {
         if ($sst->rowCount() < 1) {
             return false;
         }
         $rows = $sst->fetch(PDO::FETCH_ASSOC);
         $job = Job::getById($rows['jobID']);
         if ($job != false) {
             $employer = $job->getEmployer();
             if ($employer == $this->userID) {
                 //finally remove it
                 $sql = "UPDATE applications SET status = 3 WHERE id = :id";
                 $st = $conn->prepare($sql);
                 if ($st->execute(array(":id" => $id))) {
                     return true;
                 }
             }
         }
     }
     //the bitch can't not serious...report an error and leave the rest
     return false;
 }
Beispiel #2
0
 public static function insertJob($job)
 {
     foreach ($job as $jobFieldName => $jobFieldValue) {
         if (!Job::checkFieldBeforeUpdate($jobFieldName, $jobFieldValue)) {
             throw new CTKException(Yii::t("job", "Can not insert the job : unknown field ") . $jobFieldName);
         }
     }
     //Manage tags : save any inexistant tag to DB
     if (isset($job["tags"])) {
         $job["tags"] = Tags::filterAndSaveNewTags($job["tags"]);
     }
     //Manage address
     if (isset($job["jobLocation.address"])) {
         if (!empty($job["jobLocation.address"]["postalCode"]) && !empty($job["jobLocation.address"]["codeInsee"])) {
             $insee = $job["jobLocation.address"]["codeInsee"];
             $address = SIG::getAdressSchemaLikeByCodeInsee($insee);
             $job["jobLocation.address"] = $address;
             $job["geo"] = SIG::getGeoPositionByInseeCode($insee);
         }
     }
     //Insert the job
     $result = PHDB::updateWithOptions(Job::COLLECTION, array("_id" => new MongoId()), array('$set' => $job), array("upsert" => true));
     //Trick for windows : the upserted does not have the same return value
     if (isset($result["upserted"])) {
         if (is_array($result["upserted"])) {
             $newJobId = (string) $result["upserted"][0]["_id"];
         } else {
             $newJobId = (string) $result["upserted"];
         }
         $job = Job::getById($newJobId);
     } else {
         throw new CTKException(Yii::t("job", "Problem inserting the new job offer"));
     }
     return array("result" => true, "msg" => Yii::t("job", "Your job offer has been added with succes"), "id" => $newJobId, "job" => $job);
 }
 public function run($id)
 {
     $controller = $this->getController();
     //get The job Id
     if (empty($id)) {
         throw new CTKException(Yii::t("job", "The job posting id is mandatory to retrieve the job posting !"));
     }
     if (empty($_POST["mode"])) {
         $mode = "view";
     } else {
         $mode = $_POST["mode"];
     }
     if ($mode == "insert") {
         $job = array();
         $controller->title = Yii::t("job", "New Job Offer");
         $controller->subTitle = Yii::t("job", "Fill the form");
     } else {
         $job = Job::getById($id);
         $controller->title = $job["title"];
         $controller->subTitle = isset($job["description"]) ? $job["description"] : (isset($job["type"]) ? "Type " . $job["type"] : "");
     }
     $tags = json_encode(Tags::getActiveTags());
     $organizations = Authorisation::listUserOrganizationAdmin(Yii::app()->session["userId"]);
     $controller->pageTitle = Yii::t("job", "Job Posting");
     Rest::json(array("result" => true, "content" => $controller->renderPartial("jobSV", array("job" => $job, "tags" => $tags, "organizations" => $organizations, "mode" => $mode), true)));
 }
Beispiel #4
0
    if ($me->retractApp($_POST['app_id']) !== true) {
        $_SESSION['error'] = "Unable to complete request";
    }
    header("location: " . $_SERVER['REQUEST_URI']);
    exit;
}
?>
<div>
    <?php 
if (isset($_SESSION['error'])) {
    echo "<div class='feedback error'>{$_SESSION['error']}</div>";
    unset($_SESSION['error']);
}
if (!empty($total > 0)) {
    foreach ($apps['result'] as $app) {
        $job = Job::getById($app['jobID']);
        $employer = Employer::getUser($job->postedBy);
        $jobExpiry = dateToYMD($job->expiryDate, "Y-m-d");
        $jobUrl = "project/" . $job->jobId . "/" . cleanUrl($job->title);
        ?>
            <form action="<?php 
        echo htmlspecialchars($_SERVER['REQUEST_URI']);
        ?>
" method="post">
            <div class="feed-element row rug-p">
                <h3><a href="<?php 
        echo $jobUrl;
        ?>
"><?php 
        echo $job->title;
        ?>
Beispiel #5
0
<?php

if (isset($_GET['k'])) {
    var_dump($_GET['k']);
}
/**handles the employer management of applications of a given project...**/
if (!ctype_digit($_GET['focus']) || $_GET['focus'] == "") {
    header("location: ../myprojects");
    exit;
}
if ($me == "guest") {
    header("location: signin");
    exit;
}
$id = $_GET['focus'];
$project = Job::getById($id);
if ($project == false || $project->postedBy != $me->userID) {
    header("location: ../myprojects");
    exit;
}
if (isset($_POST['delete'])) {
    $item = $_POST['item'];
    //3 is used for rejected
    $removed = $me->respondToApp($item, 3);
    if ($removed !== true) {
        $_SESSION['error'] = "Unable to complete request";
    }
    header("location: " . $_SERVER['REQUEST_URI']);
    exit;
}
$apps = $project->getBids();
Beispiel #6
0
<?php

require_once "../helpers/settings.config.inc";
require_once "../helpers/user.class.php";
require_once "../helpers/Job.php";
require_once "templates/header.php";
if (isset($_SESSION['success'])) {
    echo $_SESSION['success'];
    unset($_SESSION['success']);
}
$jobId = isset($_GET['job_id']) ? $_GET['job_id'] : "";
if ($jobId == "") {
    header("location: search.php");
    exit;
}
$details = Job::getById($jobId);
if ($details == null) {
    header("location: 404.php");
    exit;
}
$pageTitle = $details->title;
$employer = $details->getEmployer();
include "templates/_project.php";
 /**
  * Return true if the user is Admin of the job
  * A user can be admin of an job if :
  * 1/ He is admin of the organization posting the job offer
  * 3/ He is admin of an organization that can edit it members (canEditMembers flag) 
  *      and the organizations members is offering the job
  * @param String $jobId The jobId to check if the userId is admin of
  * @param String $userId The userId to get the authorisation of
  * @return boolean True if the user isAdmin, False else
  */
 public static function isJobAdmin($jobId, $userId)
 {
     $job = Job::getById($jobId);
     if (!empty($job["hiringOrganization"])) {
         $organizationId = (string) $job["hiringOrganization"]["_id"];
     } else {
         throw new CommunecterException("The job " . $jobId . " is not well format : contact your admin.");
     }
     $res = Authorisation::isOrganizationAdmin($userId, $organizationId);
     return $res;
 }
Beispiel #8
0
 public function actionEdit()
 {
     if (!isset($_GET['job_id']) || $_GET['job_id'] == "") {
         return;
     }
     $jobId = $_GET['job_id'];
     $job = Job::getById($jobId);
     if ($job == null) {
         return;
     }
     //@todo verify that the user is of employer type first!!
     $loggedUser = new EmployerController();
     if ($loggedUser->me->userID != $job->postedBy) {
         //IMPOSTOR!
         return;
     }
     if (isset($_POST['update'])) {
         $project = new Job($_POST);
         foreach ($_POST as $p => $q) {
             if ($p == "update") {
                 continue;
             }
             if ($project->updateField($p, $q) != true) {
                 $_SESSION['error'] = $project->updateField($p, $q);
                 $error[] = "An error occurred. Please try later";
             }
         }
         if (!empty($error)) {
             $_SESSION['error'] = $error;
         }
         header("location: " . $_SERVER['REQUEST_URI']);
     }
     $page = "editor";
     $me = $loggedUser->me;
     $project = $job;
     include __VIEWPATH__ . "user/_dashboard.php";
 }
Beispiel #9
0
</style>
<h1><?php 
echo $me->fullName;
?>
</h1>
<div class="details" style="padding: 0;">    <div class="detail ad-banner" style="margin-bottom: 1em;">
        <img src="images/emp-banner.jpg" alt=""/>
    </div>
    <div>
        <p class="section-title"><span class="fa fa-wifi"></span> <span>Activity Feed</span></p>
        <div style="border: 1px solid #e7e7e7;">
            <?php 
if ($feeds != false) {
    foreach ($feeds['apps'] as $feed) {
        $feedFrom = Student::getUser($feed['userID']);
        $job = Job::getById($feed['jobID']);
        echo "<div class='feed-element app'>";
        echo "New application from <a href='user/{$feedFrom->userID}'>{$feedFrom->fullName}</a> for {$job->title}&raquo; <br/><a href='myproject/{$job->jobId}'>View now</a>";
        echo "</div>";
    }
} else {
    ?>
                <div  style="height: 120px; text-align: center;">
                    <h2 style="color: #d7d7d7;">No Activity</h2>
                </div>
            <?php 
}
?>
        </div>
    </div>
</div>