Ejemplo n.º 1
0
 public static function NewMission(ShipFleet $fleet, Coordinates $target, $scheduledTime)
 {
     $mission = new Mission();
     $mission->Fleet($fleet);
     $mission->Target($target);
     $mission->ScheduledTime($scheduledTime);
     return $mission;
 }
Ejemplo n.º 2
0
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     $missions = array();
     foreach (self::getMissionData() as $randomMissionData) {
         $postData = array();
         $mission = new Mission();
         $mission->setScenario('importModel');
         $mission->status = Mission::STATUS_AVAILABLE;
         $mission->owner = $demoDataHelper->getRandomByModelName('User');
         $mission->createdByUser = $mission->owner;
         $mission->description = $randomMissionData['description'];
         $mission->reward = $randomMissionData['reward'];
         //Add some comments
         foreach ($randomMissionData['comments'] as $commentDescription) {
             $comment = new Comment();
             $comment->setScenario('importModel');
             $comment->createdByUser = $demoDataHelper->getRandomByModelName('User');
             $comment->description = $commentDescription;
             $mission->comments->add($comment);
         }
         $mission->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE);
         $saved = $mission->save();
         assert('$saved');
         $mission = Mission::getById($mission->id);
         ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($mission, Group::getByName(Group::EVERYONE_GROUP_NAME));
         $mission->save();
         $missions[] = $mission->id;
     }
     $demoDataHelper->setRangeByModelName('Mission', $missions[0], $missions[count($missions) - 1]);
 }
Ejemplo n.º 3
0
 private static function getModel()
 {
     if (empty(self::$missions)) {
         self::$missions = new missions(ConnectionFactory::get('mongo'));
     }
     return self::$missions;
 }
Ejemplo n.º 4
0
 public function getUnreadCountForCurrentUser()
 {
     $searchAttributeData = $this->getMetadataForUnreadForCurrentUser();
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Mission');
     $where = RedBeanModelDataProvider::makeWhere('Mission', $searchAttributeData, $joinTablesAdapter);
     return Mission::getCount($joinTablesAdapter, $where, 'Mission', true);
 }
Ejemplo n.º 5
0
 public function Validate()
 {
     $basicValidation = parent::Validate();
     if (!($basicValidation === "mission_ok")) {
         // TODO: Show a message to the user and return, for now just error out
         throw new Exception($basicValidation);
     }
     // Everything is good to go, set isValid to true
     $this->IsValid(true);
 }
Ejemplo n.º 6
0
<?php

// On protège la page
User::protection(5);
// On ouvre la mission
$data = new Mission($_GET['code']);
// On vérifie que la mission a bien été ouverte
if ($data->err) {
    Core::goPage('porte', true);
}
// On récupère les statistiques sur les militants
$militants = $data->userStats();
// On récupère les statistiques sur le parcours
$parcours = $data->missionStats();
// On calcule le temps approximatif nécessaire en comptant 3 minutes par électeur
if ($militants['inscrit']) {
    $temps = $parcours['attente'] / $militants['inscrit'] * 3;
    // 3 minutes par électeur par militant (1,5 minutes en vrai, mais ils sont en binômes)
    $temps = $temps / 60;
    // passage en heure
} else {
    $temps = false;
}
// typologie
$typologie = $data->get('mission_type') == 'porte' ? 'porte' : 'boite';
// On charge le header
Core::loadHeader();
?>
<a href="<?php 
Core::goPage($typologie);
?>
Ejemplo n.º 7
0
<?php

/**
 * Arrêt d'une mission en cours
 *
 * PHP version 5
 *
 * @category Ajax
 * @package  LeQG
 * @author   Damien Senger <*****@*****.**>
 * @license  https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License 3.0
 * @link     http://leqg.info
 */
// On vérifie qu'un code de mission a été entré
if (isset($_GET['code']) || isset($_POST['code'])) {
    // On récupère le code de la mission
    $code = isset($_GET['code']) ? $_GET['code'] : $_POST['code'];
    // On ouvre la mission
    $mission = new Mission($code);
    // On change le statut de la mission comme ouvert et on redirige
    if ($mission->fermer()) {
        Core::goPage('mission', array('code' => $code), true);
    } else {
        // En cas d'erreur, on affiche un code d'erreur
        http_response_code(418);
    }
} else {
    http_response_code(418);
}
Ejemplo n.º 8
0
 private function allMissionsInCityReadyForNextLevel($nextLevel, $cityID, $userID)
 {
     $cityMissions = Mission::getMissionsInCity($cityID);
     $numCityMissions = count($cityMissions);
     $query = "SELECT * from users_missions WHERE user_id=? AND curr_rank=? AND (";
     $missionConditions = array();
     $values = array();
     array_push($values, $userID);
     array_push($values, $nextLevel);
     foreach ($cityMissions as $mission) {
         array_push($missionConditions, "mission_id=?");
         $missionID = $mission->getID();
         array_push($values, $missionID);
     }
     $query .= getArrayInString($missionConditions, ' OR ') . ")";
     $usersMissionsReadyInCity = ConnectionFactory::SelectRowsAsClasses($query, $values, __CLASS__);
     return count($usersMissionsReadyInCity) >= $numCityMissions;
 }
Ejemplo n.º 9
0
<?php

// On ouvre la mission
$data = new Mission($_GET['code']);
// On vérifie que la mission a bien été ouverte
if ($data->err) {
    Core::goPage('porte', true);
}
// On récupère tous les items de l'immeuble et la rue en question et la ville concernée
$rue = Carto::rue($_GET['rue']);
$immeuble = Carto::immeuble($_GET['immeuble']);
// typologie
$typologie = $data->get('mission_type') == 'porte' ? 'porte' : 'boite';
// On charge le header
Core::loadHeader();
?>

	<h2>Mission &laquo;&nbsp;<?php 
echo $data->get('mission_nom');
?>
&nbsp;&raquo;</h2>

    <h3 style="margin: 20px;"><?php 
echo $immeuble['immeuble_numero'];
?>
 <?php 
echo $rue['rue_nom'];
?>
</h3>

    <a href="<?php 
Ejemplo n.º 10
0
<?php

/**
 * Création d'une mission de porte à porte
 *
 * PHP version 5
 *
 * @category Ajax
 * @package  LeQG
 * @author   Damien Senger <*****@*****.**>
 * @license  https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License 3.0
 * @link     http://leqg.info
 */
// On récupère les informations
$info = $_POST;
// On lance la création de la mission avec les informations récupérées
$mission = Mission::creation('porte', $info);
// On redirige vers la page de la mission
Core::goPage('mission', array('code' => md5($mission)), true);
Ejemplo n.º 11
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Mission $value A Mission object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Mission $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Ejemplo n.º 12
0
<?php

// On ouvre la mission
$data = new Mission($_GET['code']);
// On vérifie que la mission a bien été ouverte
if ($data->err) {
    Core::goPage('porte', true);
}
if (!isset($_GET['electeur'], $_GET['statut'])) {
    Core::goPage(true);
}
// On récupère les données du formulaire
$data->reporting($_GET['electeur'], $_GET['statut']);
// S'il faut des coordonnées, on reste sur la page, sinon on dégage
if ($_GET['statut'] != 4 && $data->get('mission_type') == 'porte') {
    Core::goPage('mission', array('code' => $_GET['code'], 'rue' => $_GET['rue'], 'immeuble' => $_GET['immeuble']), true);
}
if ($data->get('mission_type') == 'boitage') {
    Core::goPage('mission', array('code' => $_GET['code'], 'rue' => $_GET['rue']), true);
}
Core::loadHeader();
?>

	<h2>Mission &laquo;&nbsp;<?php 
echo $data->get('mission_nom');
?>
&nbsp;&raquo;</h2>

    <h3 style="margin: 20px;">Comment contacter cet électeur ?</h3>
    
    <form action="<?php 
Ejemplo n.º 13
0
You finished <?php 
echo $current;
?>
!<br />
<?php 
if (!empty($next)) {
    ?>
<a href="<?php 
    echo Url::format('missions/' . $next);
    ?>
">Next</a><?php 
}
?>

<?php 
Mission::finishMission($handle, $id);
Ejemplo n.º 14
0
 /**
  * Validate the device data before saving to db
  * @return ApiResponse
  */
 public function validateDevice()
 {
     $response = new ApiResponse();
     if (!\Request::has('device_name')) {
         $response->status = 'error';
         $response->message = ['id' => '', 'code' => 'device_name_null', 'description' => 'The device name should not be null'];
     }
     if (!\Request::has('model')) {
         $response->status = 'error';
         $response->message = ['id' => '', 'code' => 'model_null', 'description' => 'The device model should not be null'];
     }
     if (!\Request::has('manufacturer')) {
         $response->status = 'error';
         $response->message = ['id' => '', 'code' => 'manufacturer_null', 'description' => 'The device manufacturer should not be null'];
     }
     if (!\Request::has('type')) {
         $response->status = 'error';
         $response->message = ['id' => '', 'code' => 'type_null', 'description' => 'The device type should not be null'];
     }
     if (!\Request::has('status')) {
         $response->status = 'error';
         $response->message = ['id' => '', 'code' => 'status_null', 'description' => 'The device status should not be null'];
     } else {
         if (intval(\Request::has('status')) != 0 && intval(\Request::has('status')) != 1) {
             $response->status = 'error';
             $response->message = ['id' => '', 'code' => 'status_error', 'description' => 'The device status should be either 0 (inactive) or 1 (active)'];
         }
     }
     if (\Request::has('latitude') && !is_numeric(\Request::get('latitude')) || \Request::has('longitude') && !is_numeric(\Request::get('longitude'))) {
         $response->status = 'error';
         $response->message = ['id' => '', 'code' => 'coordinates_not_numeric', 'description' => 'The coordinates of the device should be numeric'];
     }
     if (!\Request::has('mission_id')) {
         $response->status = 'error';
         $response->message = ['id' => '', 'code' => 'mission_id_null', 'description' => 'The mission id should not be null'];
     } else {
         //check that the mission_id exists
         $this->mission = Mission::find(\Request::get('mission_id'));
         if ($this->mission == null) {
             $response->status = 'error';
             $response->message = ['id' => '', 'code' => 'mission_id_not_found', 'description' => 'The requested mission could not be found'];
         }
     }
     if (\Request::has('registration_date')) {
         if (!$this->validateDate(\Request::get('registration_date'))) {
             $response->status = 'error';
             $response->message = ['id' => '', 'code' => 'wrong_date_format', 'description' => 'The date should be in the following format: Y-m-d hh:mm:ss'];
         }
     }
     return $response;
 }
Ejemplo n.º 15
0
 /**
  * Declares an association between this object and a Mission object.
  *
  * @param      Mission $v
  * @return     MissionPhoto The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setMission(Mission $v = null)
 {
     if ($v === null) {
         $this->setMissionId(NULL);
     } else {
         $this->setMissionId($v->getId());
     }
     $this->aMission = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Mission object, it will not be re-added.
     if ($v !== null) {
         $v->addMissionPhoto($this);
     }
     return $this;
 }
Ejemplo n.º 16
0
<?php

// On ouvre la mission
$data = new Mission($_GET['mission']);
// On vérifie que la mission a bien été ouverte
if ($data->err) {
    Core::goPage('porte', true);
}
// On récupère les données du formulaire
$reporting = $_POST;
// S'il s'agit d'un porte à porte
if ($data->get('mission_type') == 'porte') {
    // On transforme les données pour avoir un tableau electeur => statut
    $coordonnees = array();
    foreach ($reporting as $report => $statut) {
        // On récupère l'identifiant de l'électeur
        $electeur = explode('-', $report);
        // On retraite l'enregistrement
        $reporting[$electeur[1]] = $statut;
        // On supprime l'ancien enregistrement
        unset($reporting[$report]);
        // Si c'est une demande de recontact, on le laisse dans un tableau de côté pour récupérer les coordonnées
        if ($statut == 4) {
            $coordonnees[] = $electeur[1];
        }
    }
    // Pour chaque report, on l'enregistre dans la base de données
    foreach ($reporting as $report => $statut) {
        $data->reporting($report, $statut);
    }
    // S'il n'y a pas de coordonnées à récupérer, on redirige
Ejemplo n.º 17
0
     }
 } else {
     if ($actionToDo == 'sellLootedItem') {
         if ($owned_quantity < 1) {
             die('you dont have this item');
         }
         $user->decrementUserLootedItem($itemID, 1);
         $user->updateUserCash($storePrice * $SELL_RATIO);
         $upkeepAmount = Item::getItemUpkeep($itemID);
         $user->decrementUserUpkeep($upkeepAmount);
         header("Location: {$serverRoot}profile.php#three");
         exit;
     } else {
         if ($actionToDo == 'bulkBuy') {
             $missionID = $_GET['missionID'];
             $itemIDsToQuantity = Mission::getMissionRequiredItemsIDsToQuantity($missionID);
             $itemIDsToItems = Item::getItemIDsToItems(array_keys($itemIDsToQuantity));
             $totalUpkeepAmount = 0;
             if ($user->getLevel() < 4) {
                 $_SESSION['failureType'] = 'notEnoughLevel';
                 header("Location: {$serverRoot}choosemission.php?cityID=" . $_GET['cityID'] . "&missionID=" . $_GET['missionID']);
                 exit;
             }
             if (isset($_GET['totalPrice'])) {
                 $totalPrice = $_GET['totalPrice'];
             }
             if ($user->getCash() >= $totalPrice) {
                 //    	foreach($itemIDsToQuantity as $key => $value){
                 //            $item = $itemIDsToItems[$key];
                 //    		if($item->getMinLevel() > $user->getLevel()){
                 //    			$_SESSION['missionEquipmentBought'] = 'false';
 public function actionAjaxChangeStatus($status, $id)
 {
     $content = null;
     $save = true;
     $mission = Mission::GetById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($mission);
     if ($status == Mission::STATUS_TAKEN) {
         if ($mission->takenByUser->id > 0) {
             $save = false;
         } else {
             $mission->takenByUser = Yii::app()->user->userModel;
         }
     }
     if ($save) {
         $mission->status = $status;
         $saved = $mission->save();
         if (!$saved) {
             throw new NotSupportedException();
         }
         $statusText = MissionStatusElement::renderStatusTextContent($mission);
         $statusAction = MissionStatusElement::renderStatusActionContent($mission, MissionStatusElement::getStatusChangeDivId($mission->id));
         $content .= $statusText;
         if ($statusAction != null) {
             $content .= ' ' . $statusAction;
         }
     } else {
         $content .= '<div>' . Zurmo::t('MissionsModule', 'This mission is already taken') . '</div>';
     }
     $content = ZurmoHtml::tag('div', array('id' => MissionStatusElement::getStatusChangeDivId($mission->id), 'class' => 'missionStatusChangeArea'), $content);
     Yii::app()->getClientScript()->setToAjaxMode();
     Yii::app()->getClientScript()->render($content);
     echo $content;
 }
Ejemplo n.º 19
0
                                <table class="table table-striped table-bordered table-hover dataTables-example">
                                    <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>Nome</th>
                                        <th>Equipe</th>
                                        <th>Duração</th>
                                        <th>Local</th>
                                        <th>Status</th>
                                        <th>Ação</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php 
if (Mission::getMissions() != '') {
    foreach (Mission::getMissions() as $miss) {
        echo '<tr>';
        echo '<td>' . $miss->getId() . '</td>';
        echo '<td>' . '<a class="modalMission" data-id="' . $miss->getId() . '" >' . $miss->getName() . '</a>' . '</td>';
        echo '<td>' . '<a class="modalTeam" data-id="' . $miss->getTeam()->getId() . '" >' . $miss->getTeam()->getName() . '</a>' . '</td>';
        echo '<td>' . $miss->getDateBegin() . ' - ' . $miss->getDateEnd() . '</td>';
        if ($miss->getAddress()->getId()) {
            echo '<td>' . $miss->getAddress()->getStreet() . ', ' . $miss->getAddress()->getNumber() . ', ' . $miss->getAddress()->getDistrict() . ', ' . $miss->getAddress()->getCity() . '/' . $miss->getAddress()->getState() . '</td>';
        }
        if ($miss->getChurch()->getId()) {
            echo '<td>' . '<a class="modalChurch" data-id="' . $miss->getChurch()->getId() . '" >' . 'Igreja: ' . $miss->getChurch()->getName() . '</a>' . '</td>';
        }
        echo '<td>' . $miss->getStatus() . '</td>';
        if ($_SESSION['login']['role'] == 3 || $_SESSION['login']['role'] == 2 && $_SESSION['login']['id_person'] == $miss->getTeam()->getLeader()->getId()) {
            if ($miss->getStatus() != 'Concluida') {
                echo '<td>' . '<a href="forms.php?p=altMissao&cod=' . $miss->getId() . '">' . '<i class="icon icon-pencil"></i> Editar' . '</a>' . '</td>';
Ejemplo n.º 20
0
 public function testMissionReadUnreadStatus()
 {
     $steven = User::getByUsername('steven');
     $sally = User::getByUsername('sally');
     $mary = User::getByUsername('mary');
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $mission = new Mission();
     $mission->owner = $steven;
     $mission->description = 'My test mission description';
     $mission->status = Mission::STATUS_AVAILABLE;
     $this->assertTrue($mission->save());
     $missionId = $mission->id;
     $explicitReadWriteModelPermissions = new ExplicitReadWriteModelPermissions();
     $explicitReadWriteModelPermissions->addReadWritePermitable(Group::getByName(Group::EVERYONE_GROUP_NAME));
     ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($mission, $explicitReadWriteModelPermissions);
     $mission = Mission::getById($missionId);
     //Confirm users have mission marked as unread but not owner
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $steven));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $super));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $sally));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $mary));
     //Super reads the mission
     $this->setGetArray(array('id' => $missionId));
     $this->runControllerWithNoExceptionsAndGetContent('missions/default/details');
     $mission = Mission::getById($missionId);
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $steven));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $super));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $sally));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $mary));
     //Mary marks mission as read and post a comment
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('mary');
     MissionsUtil::markUserHasReadLatest($mission, $mary);
     $this->setGetArray(array('relatedModelId' => $missionId, 'relatedModelClassName' => 'Mission', 'relatedModelRelationName' => 'comments', 'redirectUrl' => 'someRedirect'));
     $this->setPostArray(array('Comment' => array('description' => 'Mary\'s new comment')));
     $this->runControllerWithRedirectExceptionAndGetContent('comments/default/inlineCreateSave');
     $mission = Mission::getById($missionId);
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $steven));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $super));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $sally));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $mary));
     //Sally reads and takes the mission
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('sally');
     $this->setGetArray(array('id' => $missionId));
     $this->resetPostArray();
     $this->runControllerWithNoExceptionsAndGetContent('missions/default/details');
     $mission = Mission::getById($missionId);
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $steven));
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $super));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $sally));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $mary));
     $this->setGetArray(array('status' => Mission::STATUS_TAKEN, 'id' => $missionId));
     $this->runControllerWithNoExceptionsAndGetContent('missions/default/ajaxChangeStatus');
     //Every user other than owner and takenby are marked as read latest
     $mission = Mission::getById($missionId);
     $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $steven));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $super));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $sally));
     $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $mary));
 }
Ejemplo n.º 21
0
 /**
  * @depends testAddingComments
  */
 public function testDeleteMission()
 {
     $missions = Mission::getAll();
     $comments = Comment::getAll();
     $personsWhoHaveNotReadLatest = PersonWhoHaveNotReadLatest::getAll();
     $this->assertGreaterThan(0, count($missions));
     $this->assertGreaterThan(0, count($comments));
     $this->assertGreaterThan(0, count($personsWhoHaveNotReadLatest));
     foreach ($missions as $mission) {
         $missionId = $mission->id;
         $mission->forget();
         $mission = Mission::getById($missionId);
         $deleted = $mission->delete();
         $this->assertTrue($deleted);
     }
     //check that all comments and personsWhoHaveNotReadLatest are removed, since they are owned.
     $comments = Comment::getAll();
     $this->assertEquals(0, count($comments));
     $missions = Mission::getAll();
     $this->assertEquals(0, count($missions));
     $personsWhoHaveNotReadLatest = PersonWhoHaveNotReadLatest::getAll();
     $this->assertEquals(0, count($personsWhoHaveNotReadLatest));
 }
Ejemplo n.º 22
0
 public function testResolvePeopleToSendNotificationToOnNewMission()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $steven = User::getByUsername('steven');
     $mary = UserTestHelper::createBasicUser('mary');
     $missions = Mission::getAll();
     $mission = $missions[0];
     $people = MissionsUtil::resolvePeopleToSendNotificationToOnNewMission($mission);
     $this->assertNotContains($super, $people);
     $this->assertContains($steven, $people);
     $this->assertContains($mary, $people);
 }
 public function testScoreOnSaveModelForMissionMovingThroughStatusChanges()
 {
     $super = User::getByUsername('super');
     // asserting simpleUser score before taken/completed/accepted of mission
     $simpleUser = UserTestHelper::createBasicUser('simpleUser');
     $gamescore = GameScore::getAllByPersonIndexedByType($simpleUser);
     $this->assertEquals(0, count($gamescore));
     $scoreTypeMissionTaken = MissionGamificationRules::SCORE_TYPE_TAKE_MISSION;
     $gameScore = GameScore::resolveToGetByTypeAndPerson($scoreTypeMissionTaken, $simpleUser);
     $this->assertEquals(0, count($gamescore));
     $scoreTypeMissionComplete = MissionGamificationRules::SCORE_TYPE_COMPLETE_MISSION;
     $gameScore = GameScore::resolveToGetByTypeAndPerson($scoreTypeMissionComplete, $simpleUser);
     $this->assertEquals(0, count($gamescore));
     $scoreTypeMissionAccepted = MissionGamificationRules::SCORE_TYPE_ACCEPTED_MISSION;
     $gameScore = GameScore::resolveToGetByTypeAndPerson($scoreTypeMissionAccepted, $simpleUser);
     $this->assertEquals(0, count($gamescore));
     $missions = Mission::getAll();
     $this->assertEquals(0, count($missions));
     $mission = new Mission();
     $mission->owner = $super;
     $mission->takenByUser = $simpleUser;
     $mission->description = 'Test description';
     $mission->reward = 'Test reward';
     $mission->status = Mission::STATUS_AVAILABLE;
     $mission->save();
     //Confirm mission saved.
     $missions = Mission::getAll();
     $this->assertEquals(1, count($missions));
     $gamescore = GameScore::getAllByPersonIndexedByType($super);
     $this->assertEquals(1, count($gamescore));
     //Changing Status to Taken
     $mission = $missions[0];
     $mission->status = Mission::STATUS_TAKEN;
     $this->assertTrue($mission->save());
     $missions = Mission::getAll();
     $this->assertEquals(1, count($missions));
     $scoreTypeMissionTaken = MissionGamificationRules::SCORE_TYPE_TAKE_MISSION;
     $gameScore = GameScore::resolveToGetByTypeAndPerson($scoreTypeMissionTaken, $simpleUser);
     $this->assertEquals(1, count($gamescore));
     $gamescoreOfUser = GameScore::getAllByPersonIndexedByType($simpleUser);
     $this->assertEquals(1, count($gamescoreOfUser));
     //Changing Status to Completed
     $mission = $missions[0];
     $mission->status = Mission::STATUS_COMPLETED;
     $mission->save();
     $missions = Mission::getAll();
     $this->assertEquals(1, count($missions));
     $scoreTypeMissionComplete = MissionGamificationRules::SCORE_TYPE_COMPLETE_MISSION;
     $gameScore = GameScore::resolveToGetByTypeAndPerson($scoreTypeMissionComplete, $simpleUser);
     $this->assertEquals(1, count($gamescore));
     $gamescoreOfUser = GameScore::getAllByPersonIndexedByType($simpleUser);
     $this->assertEquals(2, count($gamescoreOfUser));
     //Changing Status to Accepted
     $mission = $missions[0];
     $mission->status = Mission::STATUS_ACCEPTED;
     $mission->save();
     $missions = Mission::getAll();
     $this->assertEquals(1, count($missions));
     $scoreTypeMissionAccepted = MissionGamificationRules::SCORE_TYPE_ACCEPTED_MISSION;
     $gameScore = GameScore::resolveToGetByTypeAndPerson($scoreTypeMissionAccepted, $simpleUser);
     $this->assertEquals(1, count($gamescore));
     $gamescoreOfUser = GameScore::getAllByPersonIndexedByType($simpleUser);
     $this->assertEquals(3, count($gamescoreOfUser));
 }
Ejemplo n.º 24
0
 public function executeAutoAddMissionsOnCamp(sfWebRequest $request)
 {
     // see if there is airport exist with this name
     $airport_name = $request->getParameter('airportname');
     $airport = AirportPeer::getBySpecificAirportName($airport_name);
     // If there is no airport then insert it into airport table
     if (!$airport) {
         // @TODO Set default airport fields values
         $airport = new Airport();
         $airport->setName($airport_name);
         $airport->save();
     }
     $pass_id = $request->getParameter('passenger');
     $camp_id = $request->getParameter('camp_id');
     $camp_passenger = new CampPassenger();
     $camp_passenger->setCampId($camp_id);
     $camp_passenger->setPassengerId($pass_id);
     if (CampPassengerPeer::doCount($camp_passenger->buildCriteria())) {
         $passenger = PassengerPeer::retrieveByPK($pass_id);
         $this->getUser()->setFlash('warning', 'Passenger "' . $passenger->getPerson()->getName() . '" has already been added!');
         return $this->redirect('camp/view?id=' . $request->getParameter('camp_id'));
     }
     $camp = CampPeer::retrieveByPK($camp_id);
     $this->forward404Unless($camp);
     $note = $request->getParameter('note');
     //$camp_passenger->setAirportId($camp->getAirportId ()); // Camp Location Id
     $camp_passenger->setNote($note);
     //if ($camp_passenger->save()){
     //return $this->renderText($airport->getId());
     //}
     $mission_type = MissionTypePeer::getByName('normal');
     if (!$mission_type instanceof MissionType) {
         $mission_type = MissionTypePeer::doSelectOne(new Criteria());
         $this->forward404Unless($mission_type);
     }
     $airport = AirportPeer::getBySpecificAirportName($airport_name);
     $camp_location = $camp->getAirport();
     $itinerary = new Itinerary();
     $itinerary->setCampId($camp->getId());
     $itinerary->setPassengerId($pass_id);
     $itinerary->setDateRequested(time());
     $itinerary->setApointTime('unspecified');
     $itinerary->setMissionTypeId($mission_type->getId());
     $itinerary->setAgencyId($camp->getAgencyId());
     $itinerary->setCancelItinerary(1);
     $itinerary->save();
     // Mission 1
     $mission1 = new Mission();
     $mission1->setItineraryId($itinerary->getId());
     $mission1->setCampId($camp->getId());
     $mission1->setCancelMission(1);
     $mission1->setPassengerId($pass_id);
     $mission1->setMissionCount(1);
     $mission1->setDateRequested(time());
     $mission1->setExternalId($this->getLatestExternalId());
     $mission1->setMissionTypeId($mission_type->getId());
     $mission1->save();
     $camp_passenger->setReturnAirportId(NULL);
     // this indicates that return airport id would be camp airport id
     $camp_passenger->setAirportId($airport->getId());
     $camp_passenger->setMissionId($mission1->getId());
     $camp_passenger->save();
     $mission1_leg1 = new MissionLeg();
     $mission1_leg1->setFromAirportId($airport->getId());
     $mission1_leg1->setLegNumber(1);
     $mission1_leg1->setMissionId($mission1->getId());
     if ($camp_location) {
         $mission1_leg1->setToAirportId($camp_location->getId());
     } else {
         $mission1_leg1->setToAirportId(NULL);
     }
     $mission1_leg1->setCancelMissionLeg(1);
     $mission1_leg1->save();
     // Mission 2
     $mission2 = new Mission();
     $mission2->setItineraryId($itinerary->getId());
     $mission2->setCampId($camp->getId());
     $mission2->setCancelMission(1);
     $mission2->setPassengerId($pass_id);
     $mission2->setMissionCount(2);
     // From treatment to hme
     $mission2->setDateRequested(time());
     $mission2->setExternalId($this->getLatestExternalId());
     $mission2->setMissionTypeId($mission_type->getId());
     $mission2->save();
     $camp_passenger2 = new CampPassenger();
     $camp_passenger2->setCampId($camp_id);
     $camp_passenger2->setPassengerId($pass_id);
     $camp_passenger2->setMissionId($mission2->getId());
     $camp_passenger2->setAirportId(NULL);
     // this indicates that return airport id would be camp airport id
     $camp_passenger2->setReturnAirportId($airport->getId());
     $camp_passenger2->setNote($note);
     $camp_passenger2->save();
     $mission2_leg2 = new MissionLeg();
     if ($camp_location) {
         $mission2_leg2->setFromAirportId($camp_location->getId());
     } else {
         $mission2_leg2->setFromAirportId(NULL);
     }
     $mission2_leg2->setLegNumber(1);
     $mission2_leg2->setMissionId($mission2->getId());
     $mission2_leg2->setToAirportId($airport->getId());
     $mission2_leg2->setCancelMissionLeg(1);
     $mission2_leg2->save();
     return $this->redirect('camp/view?id=' . $camp->getId());
 }
 public function testMarkReadUnreadMassActionByModel()
 {
     $super = User::getByUsername('super');
     //Conversation model
     $conversation = new Conversation();
     $conversation->owner = $super;
     $conversation->subject = 'My test conversation subject';
     $conversation->description = 'My test conversation description';
     $this->assertTrue($conversation->save());
     $conversationId = $conversation->id;
     $this->assertTrue((bool) ConversationsUtil::hasUserReadConversationLatest($conversation, $super));
     //Mark conversation as unread
     $selectedIds = $conversationId;
     $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
     $this->setGetArray(array('ajax' => 'list-view', 'modelClassName' => 'Conversation', 'MashableInboxForm' => array('massAction' => 'markUnread', 'selectedIds' => $selectedIds)));
     $content = $this->runControllerWithNoExceptionsAndGetContent('mashableInbox/default/list');
     $conversation = Conversation::getById($conversationId);
     $this->assertFalse((bool) ConversationsUtil::hasUserReadConversationLatest($conversation, $super));
     //Mark conversation as read
     $this->setGetArray(array('ajax' => 'list-view', 'modelClassName' => 'Conversation', 'MashableInboxForm' => array('massAction' => 'markRead', 'selectedIds' => $selectedIds)));
     $content = $this->runControllerWithNoExceptionsAndGetContent('mashableInbox/default/list');
     $conversation = Conversation::getById($conversationId);
     $this->assertTrue((bool) ConversationsUtil::hasUserReadConversationLatest($conversation, $super));
     //Mission model
     $mission = new Mission();
     $mission->owner = $super;
     $mission->description = 'My test mission description';
     $mission->status = Mission::STATUS_AVAILABLE;
     $this->assertTrue($mission->save());
     $missionId = $mission->id;
     $this->assertTrue((bool) MissionsUtil::hasUserReadMissionLatest($mission, $super));
     //Mark mission as unread
     $selectedIds = $missionId;
     $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
     $this->setGetArray(array('ajax' => 'list-view', 'modelClassName' => 'Mission', 'MashableInboxForm' => array('massAction' => 'markUnread', 'selectedIds' => $selectedIds)));
     $content = $this->runControllerWithNoExceptionsAndGetContent('mashableInbox/default/list');
     $mission = Mission::getById($missionId);
     $this->assertFalse((bool) MissionsUtil::hasUserReadMissionLatest($mission, $super));
     //Mark mission as read
     $this->setGetArray(array('ajax' => 'list-view', 'modelClassName' => 'Mission', 'MashableInboxForm' => array('massAction' => 'markRead', 'selectedIds' => $selectedIds)));
     $content = $this->runControllerWithNoExceptionsAndGetContent('mashableInbox/default/list');
     $mission = Mission::getById($missionId);
     $this->assertTrue((bool) MissionsUtil::hasUserReadMissionLatest($mission, $super));
 }
Ejemplo n.º 26
0
<?php

// On protège la page
User::protection(5);
// On ouvre la mission
$data = new Mission($_GET['code']);
// On vérifie que la mission a bien été ouverte
if ($data->err) {
    Core::goPage('porte', true);
}
// On récupère la liste des contacts avec procu ou recontact
$procurations = array();
$recontacts = array();
// typologie
$typologie = $data->get('mission_type') == 'porte' ? 'porte' : 'boite';
// On charge le header
Core::loadHeader();
?>
<a href="<?php 
Core::goPage($typologie);
?>
" class="nostyle"><button class="gris" style="float: right; margin-top: 0em;">Revenir à la liste</button></a>	
<h2 id="titre-mission" class="titre" data-mission="<?php 
echo $data->get('mission_hash');
?>
">Mission &laquo;&nbsp;<?php 
echo $data->get('mission_nom');
?>
&nbsp;&raquo;</h2>

<nav class="onglets">
Ejemplo n.º 27
0
		</ul>
	</section>
    <?php 
}
?>
		
    <?php 
if ($missions_ouvertes) {
    ?>
	<section id="missions">
		<h3 class="titrebloc">Missions ouvertes auxquelles vous participez</h3>
		
		<ul class="liste-missions">
        <?php 
    foreach ($missions_ouvertes as $mission_ouverte) {
        $mission = new Mission(md5($mission_ouverte));
        $deadline = DateTime::createFromFormat('Y-m-d', $mission->get('mission_deadline'));
        ?>
    		<li>
    		    <a href="<?php 
        Core::goPage('reporting', array('mission' => $mission->get('mission_hash')));
        ?>
" class="nostyle"><button style="float: right; margin-top: 1.33em;">Ouvrir la mission</button></a>
    		    <a href="<?php 
        Core::goPage('reporting', array('mission' => $mission->get('mission_hash')));
        ?>
" class="nostyle"><h4><?php 
        echo $mission->get('mission_nom');
        ?>
</h4></a>
            <?php 
Ejemplo n.º 28
0
function displayMissionInfo($mission, $playerLevel, $cityRank)
{
    if (missionIsLocked($mission, $playerLevel)) {
        print "<b>LOCKED</b> <br>";
    }
    $missionID = $mission->getID();
    ?>
	
		Title: <?php 
    echo $mission->getName();
    ?>
<br>
		City: <?php 
    echo ucfirst(getCityNameFromCityID($mission->getCityID()));
    ?>
<br>
		
		<?php 
    $userMissionData = UserMissionData::getUserMissionData($_SESSION['userID'], $mission->getID());
    $completionPercent;
    if ($cityRank == 4) {
        $completionPercent = 100;
        $cityRank = 3;
    } else {
        $userTimesMissionDoneInThisRank = 0;
        if ($userMissionData) {
            $userTimesMissionDoneInThisRank = $userMissionData->getRankTimes($cityRank);
        }
        $missionTimesToMasterRank = $mission->getRankReqTimes($cityRank);
        if ($userTimesMissionDoneInThisRank >= $missionTimesToMasterRank) {
            $completionPercent = 100;
        } else {
            $completionPercent = number_format($userTimesMissionDoneInThisRank / $missionTimesToMasterRank, 2) * 100;
        }
    }
    ?>
		
	
	<?php 
    echo $completionPercent;
    ?>
% R<?php 
    echo $cityRank;
    ?>
<br>
	Description: <?php 
    echo $mission->getDescription();
    ?>
<br>
	Minimum level: <?php 
    echo $mission->getMinLevel();
    ?>
<br>
	Cost: <?php 
    echo $mission->getEnergyCost();
    ?>
 energy<br>
	Will Gain: <?php 
    echo $mission->getExpGained();
    ?>
 exp<br>
	Will Gain <?php 
    echo $mission->getMinCashGained();
    ?>
 - 
	<?php 
    echo $mission->getMaxCashGained();
    ?>
 cash<br>
	Chance of getting loot: <?php 
    echo $mission->getChanceOfLoot();
    ?>
<br>
	
	<?php 
    $lootItemID = $mission->getLootItemID();
    if ($lootItemID) {
        $lootItem = Item::getItem($lootItemID);
        ?>
			You're not supposed to know this but the item you might get is the <?php 
        echo $lootItem->getName();
        ?>
<br>
			didnt put in agency or item requirements too lazy but they work<br>
	<?php 
    }
    print "Item Requirements:<br>";
    $itemIDsToQuantity = Mission::getMissionRequiredItemsIDsToQuantity($missionID);
    $itemIDsToItems = Item::getItemIDsToItems(array_keys($itemIDsToQuantity));
    foreach ($itemIDsToQuantity as $key => $value) {
        $item = $itemIDsToItems[$key];
        print $value . "x " . $item->getName() . "<br>";
    }
    if (!missionIsLocked($mission, $playerLevel)) {
        ?>
			<form action='backend/domission.php' method='post'>
			<input type='hidden' name='missionID' value='<?php 
        echo $mission->getID();
        ?>
' />
			<input type='hidden' name='currentMissionCity' value='<?php 
        echo $_SESSION['currentMissionCity'];
        ?>
' />
			<input type='submit' value='Do It' />
			</form>
			<?php 
    }
    print "<br><br>";
}
Ejemplo n.º 29
0
<?php

// On protège la page
User::protection(5);
// On ouvre la mission
$data = new Mission($_GET['code']);
// On vérifie que la mission a bien été ouverte
if ($data->err) {
    Core::goPage('porte', true);
}
// On récupère la liste des rues de la mission
$rues = $data->rues();
// typologie
$typologie = $data->get('mission_type') == 'porte' ? 'porte' : 'boite';
// On charge le header
Core::loadHeader();
?>
<a href="<?php 
Core::goPage($typologie);
?>
" class="nostyle"><button class="gris" style="float: right; margin-top: 0em;">Revenir à la liste</button></a>	
<h2 id="titre-mission" class="titre" data-mission="<?php 
echo $data->get('mission_hash');
?>
">Mission &laquo;&nbsp;<?php 
echo $data->get('mission_nom');
?>
&nbsp;&raquo;</h2>

<nav class="onglets">
    <a href="<?php 
Ejemplo n.º 30
0
<?php

// On ouvre la mission
$data = new Mission($_GET['code']);
// On vérifie que la mission a bien été ouverte
if ($data->err) {
    Core::goPage('porte', true);
}
// On récupère tous les items de la rue et la rue en question et la ville concernée
$rue = Carto::rue($_GET['rue']);
$items = $data->items($_GET['rue']);
if (!$items) {
    Core::goPage('reporting', array('mission' => $_GET['mission']), true);
}
// typologie
$typologie = $data->get('mission_type') == 'porte' ? 'porte' : 'boite';
// On charge le header
Core::loadHeader();
?>

	<h2>Mission &laquo;&nbsp;<?php 
echo $data->get('mission_nom');
?>
&nbsp;&raquo;</h2>
	
	<ul class="listeImmeubles">
    	<?php 
if ($data->get('mission_type') == 'porte') {
    // Pour chaque immeuble trouvé, on regarde quel est son réel numéro
    $numeros = array();
    $numeros_sauv = array();