$email = $CMessage->getEmail($p);
                $type = $CMessage->getType($p);
                if (isset($plist[$email])) {
                    $plist[$email]['count']++;
                } else {
                    $plist[$email] = array('name' => $name, 'count' => 1, 'type' => $type);
                }
            }
        }
        foreach ($plist as $email => $data) {
            $type = $data['type'];
            $name = $data['name'];
            $count = $data['count'];
        }
        $getMessageParticipantsArray['messageparticipants'] = $plist;
        return $getMessageParticipantsArray;
    }
    /*
     * Takes an array full of strings, returns an array where each string has been wrapped in double quotes
     */
    private static function quoteStringsInArray($array)
    {
        $quotedArray = [];
        foreach ($array as $key => $str) {
            $quotedArray[$key] = '"' . trim($str, '"') . '"';
        }
        return $quotedArray;
    }
}
GLOBALvarSet('CStats', new StatsController());
        return self::$collection->findOne(array('_id' => new MongoId($id)));
    }
    function getByName($name)
    {
        return self::$collection->findOne(array('name' => $name));
    }
    function getName($companyId)
    {
        $company = self::getById($companyId, ['name' => 1]);
        return $company['name'];
    }
    function getIndustry($id)
    {
        $entry = $this->get($id);
        return $entry['industry'];
    }
    function find($query)
    {
        return self::$collection->find($query);
    }
    function delete($id)
    {
    }
    function exists($id)
    {
        return $this->get($id) !== NULL;
    }
    protected static $collection;
}
GLOBALvarSet('MCompany', new CompanyModel());
                                $price *= 4.35;
                                break;
                            case 'day':
                                $price *= 30;
                                break;
                        }
                        if (strlen($price0) > 0 and $price < $price0) {
                            continue;
                        }
                        if (strlen($price1) > 0 and $price > $price1) {
                            continue;
                        }
                        $sublets[] = $sublet;
                    }
                    $delay = round((microtime(true) - $starttime) * 1000, 0);
                    self::render('student/sublets/search/results', ['sublets' => $sublets, 'delay' => $delay, 'latitude' => $latitude, 'longitude' => $longitude, 'maxProximity' => $maxProximity, 'showSearch' => $showSearch, 'data' => $data, 'search' => 'housing']);
                    // Send email notification of search to us
                    // $this->sendrequestreport("Search for sublets:", $sublets);
                    // Save search to db
                    global $MApp;
                    $MApp->recordSearch('sublets');
                    return;
                }
            }
        }
        self::error($err);
        self::render('partials/subletsearchform', ['data' => $data, 'search' => 'housing']);
    }
}
GLOBALvarSet('CSublet', new SubletController());
        $entry = $this->getById(new MongoId($id));
        return $entry['email'];
    }
    function getPhoto($id)
    {
        $entry = $this->getById(new MongoId($id));
        return isset($entry['photo']) ? $entry['photo'] : null;
    }
    function me()
    {
        if (!isset($_SESSION['email'])) {
            return null;
        }
        return $this->get($_SESSION['email']);
    }
    function find($query = array())
    {
        return self::$collection->find($query);
    }
    function exists($email)
    {
        return $this->get($email) !== NULL;
    }
    function IDexists($id)
    {
        return self::$collection->findOne(array('_id' => new MongoId($id))) !== NULL;
    }
    protected static $collection;
}
GLOBALvarSet('MRecruiter', new RecruiterModel());
    function data($data)
    {
        $name = clean($data['name']);
        $email = clean($data['email']);
        $feedback = clean($data['feedback']);
        $data = array('name' => $name, 'email' => $email, 'feedback' => $feedback);
        return $data;
    }
    function feedback()
    {
        global $params;
        if (!isset($_POST['send'])) {
            $this->render('feedback');
            return;
        }
        extract($data = $this->data($params));
        $this->startValidations();
        $this->validate(filter_var($email, FILTER_VALIDATE_EMAIL), $err, 'invalid email');
        if ($this->isValid()) {
            $message = "\n          <h1>Feedback Report</h1><br />\n          <b>Name:</b> {$name}<br />\n          <b>Email:</b> {$email}<br />\n          <b>Feedback:</b><br /><br />{$feedback}\n        ";
            sendgmail(array('*****@*****.**', '*****@*****.**'), "*****@*****.**", 'Feedback/Bug', $message);
            $this->success('Thank you for submitting your feedback report and helping SubLite improve. We will process the report as soon as possible!');
            $this->render('feedback', $data);
            return;
        }
        $this->error($err);
        $this->render('feedback', $data);
    }
}
GLOBALvarSet('CApp', new AppController());
                if (isset($cities[$city])) {
                    $cities[$city]++;
                } else {
                    $cities[$city] = 1;
                }
            }
        }
        $sublets = $this->dbstudent->listings->find();
        foreach ($sublets as $doc) {
            addCity($cities, $doc);
        }
        if ($dojobs) {
            $jobs = $this->dbinternships->jobs->find();
            foreach ($jobs as $doc) {
                addCity($cities, $doc);
            }
        }
        return $cities;
    }
    function countCities()
    {
        return count($this->getCities());
    }
    function countUniversities()
    {
        global $S;
        return count($S->LUT);
    }
}
GLOBALvarSet('MStats', new StatsModel());
        self::$collection->save($data);
        return $data['_id']->{'$id'};
    }
    function reply($id, $from, $msg)
    {
        $entry = $this->get($id);
        array_push($entry['replies'], array('from' => $from, 'msg' => $msg, 'time' => time(), 'read' => false));
        self::$collection->save($entry);
        return $entry;
    }
    function findByParticipant($participant)
    {
        return self::$collection->find(array('participants' => $participant, 'replies' => array('$not' => array('$size' => 0))));
    }
    function getLastOf($id)
    {
        $entry = $this->get($id);
        return array_pop($entry);
    }
    function get($id)
    {
        return self::$collection->findOne(array('_id' => new MongoId($id)));
    }
    function exists($id)
    {
        return $this->get($id) !== NULL;
    }
    protected static $collection;
}
GLOBALvarSet('MMessage', new MessageModel());
Exemple #8
0
    function owner($id)
    {
        if (is_null($entry = $this->get($id))) {
            return NULL;
        }
        return $entry['recruiter'];
    }
    function exists($id)
    {
        return self::get($id) !== NULL;
    }
    function incrementApply($id)
    {
        $entry = self::get($id);
        if ($entry !== NULL) {
            ++$entry['stats']['clicks'];
            if (isset($_SESSION['loggedinstudent'])) {
                $entry['applicants'][] = array($_SESSION['_id'], new MongoDate());
            } else {
                $entry['applicants'][] = array('', new MongoDate());
            }
            self::save($entry, false);
            return $entry['stats']['clicks'];
        } else {
            return NULL;
        }
    }
    protected static $collection;
}
GLOBALvarSet('MJob', new JobModel());
            if (strlen($recruiter) > 0) {
                $query['recruiter'] = new MongoId($recruiter);
            }
            if (strlen($title) > 0) {
                $query['title'] = array('$regex' => keywords2mregex($title));
            }
            $companies = array();
            foreach ($cs as $c) {
                array_push($companies, $c['_id']);
            }
            $query['company'] = array('$in' => $companies);
            // Performing search
            $res = $MJob->find($query);
            $jobs = process($res);
            if ($showSearch) {
                self::render('jobs/search/form', $data);
            }
            self::render('jobs/search/results', array('jobs' => $jobs, 'showCompany' => $showCompany, 'search' => 'jobs'));
            // Send email notification of search to us
            // $this->sendrequestreport("Search for jobs:", $jobs);
            // Save search to db
            global $MApp;
            $MApp->recordSearch('jobs');
            return;
        }
        $this->error($err);
        self::render('jobs/search/form', array_merge($data, array('search' => 'jobs')));
    }
}
GLOBALvarSet('CJob', new JobController());
                 */
            /**
             * JSON in form:
             *  {
             *      "students" : [ array of student IDs ]
             *      "hub" : // String containing the ID of the hub e.g. "55566d01172f559e8ece6c88"
             *  }
             */
            case 'add students to hub':
                $students = $json['students'];
                $hub = $json['hub'];
                if (!$hub || $hub == '') {
                    return $this->errorString('Please select a hub.');
                }
                foreach ($students as $student) {
                    $studententry = $MStudent->getById($student);
                    $name = $studententry['name'];
                    $email = $studententry['email'];
                    $hubentry = $MSocial->get($hub);
                    $hubname = $hubentry['name'];
                    $message = "\n              Hey {$name}\n              <br>\n              <br>\n              After the long wait, your hub is finally ready! Check out your hub <a href=\"https://sublite.net/hubs/hub.php?id={$hub}\">here</a>. In need of a new place to go out to eat this weekend? Use your hub to ask questions about your city and meet up with other interns! The possibilities are endless; just keep it civil and respectful.\n              <br><br>\n              Best,\n              <br>\n              Sublite Team\n            ";
                    sendgmail(array($email), "*****@*****.**", "Welcome to the {$hubname} social hub on Sublite!", $message);
                    $MSocial->joinHub($hub, $student);
                }
                return $this->successString();
        }
        return $this->errorString('invalid message');
    }
}
GLOBALvarSet('CSocial', new SocialController());
                foreach ($tos as $to) {
                    $emails[] = $this->getEmail($to);
                }
                // Notify recipients by email
                $link = "http://sublite.net/housing/messages.php?id={$msgid}";
                $message = "\n            {$fromname} has sent you a message on SubLite:\n            <br /><br />\n            View the message on SubLite: <a href='{$link}'>{$link}</a>\n            <br />\n            ---\n            <br /><br />\n            {$msg}\n            <br /><br />\n            ---\n            <br />\n            Reply to this message <a href='{$link}'>on SubLite</a>. DO NOT REPLY DIRECTLY TO THIS EMAIL.\n          ";
                sendgmail($emails, array("*****@*****.**", "SubLite, LLC."), "Message from {$fromname} | SubLite", $message);
                // Notify us of the message
                $toemails = implode(', ', $emails);
                $fromemail = $this->getEmail($from);
                $prevmsgs = '';
                $replies = array_reverse($entry['replies']);
                foreach ($replies as $reply) {
                    $pfromemail = $this->getEmail($reply['from']);
                    $pmsg = $reply['msg'];
                    $prevmsgs .= "<b>{$pfromemail}</b>: <br />{$pmsg}<br />";
                }
                $message = "\n            <b>{$fromemail}</b> has sent a message to <b>{$toemails}</b>:\n            <br /><br />\n            {$msg}\n            <br /><br />\n            msgid: {$msgid}\n            <br /><br />\n            The thread:\n            <br /><br />\n            {$prevmsgs}\n          ";
                sendgmail(array('*****@*****.**', '*****@*****.**'), "*****@*****.**", 'Message sent on SubLite!', $message);
                $this->render('messaging/messages', viewData($this, $entry));
                return;
            }
            $this->render('messaging/messages', viewData($this, $entry));
            return;
        }
        $this->error($err);
        $this->render('notice');
    }
}
GLOBALvarSet('CMessage', new MessageController());
        self::render('notice');
    }
    function view()
    {
        // global $CJob; $CJob->requireLogin();
        global $MCompany;
        global $MRecruiter;
        // Validations
        $this->startValidations();
        $this->validate(isset($_GET['id']) and ($entry = $MCompany->get($id = $_GET['id'])) != NULL, $err, 'unknown company');
        // Code
        if ($this->isValid()) {
            $data = $entry;
            $me = $MRecruiter->me();
            $data['isme'] = !is_null($me) ? idcmp($id, $me['company']) : false;
            self::displayMetatags('companyprofile');
            self::render('companies/viewcompany', $data);
            return;
        }
        self::error($err);
        self::render('notice');
    }
    function exists()
    {
        global $MRecruiter;
        $me = $MRecruiter->me();
        return MongoId::isValid($me['company']);
    }
}
GLOBALvarSet('CCompany', new CompanyController());
    }
    function me()
    {
        if (isset($_SESSION['loggedinstudent'])) {
            return $this->get($_SESSION['email']);
        } else {
            return array('email' => '', 'name' => '', 'gender' => '');
        }
    }
    function login($email, $pass)
    {
        if (is_null($entry = $this->get($email))) {
            return false;
        }
        return $entry['pass'] == md5($pass);
    }
    function delete($id)
    {
    }
    function exists($id)
    {
        return self::$collection->findOne(array('_id' => new MongoId($id))) !== NULL;
    }
    function existsEmail($email)
    {
        return self::$collection->findOne(array('email' => $email)) !== NULL;
    }
    protected static $collection;
}
GLOBALvarSet('MStudent', new StudentModel());
        return isset($_SESSION['loggedinstudent']);
    }
    function requireLogin()
    {
        if (self::loggedIn()) {
            global $MStudent;
            // Params to vars
            $email = $_SESSION['email'];
            $pass = $_SESSION['pass'];
            $skippass = isset($_SESSION['skippass']);
            // Validations
            self::startValidations();
            self::validate(($entry = $MStudent->get($email)) != NULL, $err, 'unknown email');
            if (!$skippass) {
                self::validate($entry['pass'] == md5($pass), $err, 'invalid password');
            }
            if (!self::isValid()) {
                self::logout();
            }
        } else {
            self::logout();
        }
    }
    function logout()
    {
        session_unset();
        self::redirect('index');
    }
}
GLOBALvarSet('CStudent', new StudentController());
    {
        self::$collection->save($data);
        return $data['_id']->{'$id'};
    }
    function get($id)
    {
        return self::$collection->findOne(array('_id' => new MongoId($id)));
    }
    function find($query = array(), $fields = array())
    {
        return self::$collection->find($query, $fields);
    }
    function last($n = 1)
    {
        return $this->find(array('publish' => true))->sort(array('_id' => -1))->limit($n);
    }
    function getByStudent($id)
    {
        return self::$collection->find(array('student' => new MongoId($id)));
    }
    function delete($id)
    {
    }
    function exists($id)
    {
        return self::$collection->findOne(array('_id' => new MongoId($id))) !== NULL;
    }
    protected static $collection;
}
GLOBALvarSet('MSublet', new SubletModel());
Exemple #16
0
    {
        $stats = $this->getStats();
        return $stats['industries'];
    }
    function getIndustriesByJobs()
    {
        $stats = $this->getStats();
        return $stats['industriesbyjobs'];
    }
    function getSearches()
    {
        return $this->get('searches');
    }
    function recordSearch($type)
    {
        if (!isset($_SESSION['loggedinstudent'])) {
            return;
        }
        $email = $_SESSION['email'];
        $data = $_REQUEST;
        if (($entry = $this->get('searches')) == NULL) {
            $entry = array();
        }
        $entry['_id'] = 'searches';
        $entry[time()] = array('email' => $email, 'type' => $type, 'data' => $data);
        $this->save($entry);
    }
    protected static $collection;
}
GLOBALvarSet('MApp', new AppModel());
    }
    function requireLogin()
    {
        if (self::loggedIn()) {
            global $MRecruiter;
            // Params to vars
            $email = $_SESSION['email'];
            $pass = $_SESSION['pass'];
            $skippass = isset($_SESSION['skippass']);
            // Validations
            self::startValidations();
            self::validate(filter_var($email, FILTER_VALIDATE_EMAIL), $err, 'invalid email');
            self::validate(($entry = $MRecruiter->get($email)) != NULL, $err, 'unknown email');
            if (!$skippass) {
                self::validate(hash_equals($entry['pass'], crypt($pass, $entry['pass'])), $err, 'invalid password');
            }
            if (!self::isValid()) {
                self::logout();
            }
        } else {
            self::logout();
        }
    }
    function logout()
    {
        session_unset();
        self::redirect('index');
    }
}
GLOBALvarSet('CRecruiter', new RecruiterController());
{
    function migrate()
    {
        global $MApp;
        // Get current counter
        $mlast = AppModel::getByStringId('migrations');
        if ($mlast == NULL) {
            $mlast = 0;
        } else {
            $mlast = $mlast['current'];
        }
        // Do migrations after counter
        $mcur = $mlast;
        $migrations = glob($GLOBALS['dirpre'] . 'migrations/*.php');
        natsort($migrations);
        foreach ($migrations as $m) {
            if (($mcur = str2int($m)) > $mlast) {
                require_once $m;
                echo "performed migration: {$mcur}<br />";
            }
        }
        if ($mcur > $mlast) {
            $MApp->save(array('_id' => 'migrations', 'current' => $mcur));
            echo "migrated from {$mlast} to {$mcur}";
        } else {
            echo "migrations up to date";
        }
    }
}
GLOBALvarSet('CMigrations', new MigrationsController());
            }
        }
    }
    function newEventComment($id, $hub, $event, $content)
    {
        $entry = $this->get($hub);
        $index = $this->getEventIndex($hub, $event);
        $ret = array('id' => new MongoId(), 'from' => $id, 'date' => time(), 'content' => $content);
        $entry['events'][$index]['comments'][] = $ret;
        $this->save($entry, false);
        return $ret;
    }
    function deleteEventComment($hub, $event, $comment)
    {
        $entry = $this->get($hub);
        $index = $this->getEventIndex($hub, $event);
        $index2 = $this->getEventCommentIndex($hub, $event, $comment);
        $ret = $entry['events'][$index]['comments'][$index2];
        unset($entry['events'][$index]['comments'][$index2]);
        $this->save($entry, false);
        return $ret;
    }
    //Misc
    function validArray($ar)
    {
        return is_array($ar) && count($ar) > 0;
    }
    protected static $collection;
}
GLOBALvarSet('MSocial', new SocialModel());