/**
 * Fonction affichant le profil du membre connecté.
 */
function afficherProfil()
{
    $user = $_SESSION['User'];
    $droit = $user->getDroit()[0];
    $uam = new User_ActivityManager(connexionDb());
    $ua = $uam->getActIdByUserId($user);
    $am = new ActivityManager(connexionDb());
    if ($ua != NULL) {
        $activity = $am->getActivityById($ua[0]['id_activity']);
    } else {
        $activity = new Activity(array("Libelle" => "Vous n'avez pas encore choisi d'activité ! <a href='choisirCategorie.page.php'><b> Choisir une activité </b></a>"));
    }
    if ($user->getTel() == NULL) {
        $user->setTel("N/A");
    }
    echo "<h1> Vos données d'utilisateur :</h1>";
    echo "<div class='profil'><br>";
    echo " <b>Votre pseudo : </b> " . $user->getUserName() . "<br><br>";
    echo " <b>Votre grade : </b> " . $droit->getLibelle() . "<br><br>";
    echo " <b>Votre activité : </b> " . $activity->getLibelle() . "<br><br>";
    echo " <b>Votre adresse mail : </b> " . $user->getEmail() . "<br><br>";
    echo " <b>Votre numéro de téléphone : </b> " . $user->getTel() . "<br><br>";
    echo " <b>Votre date de dernière connexion : </b> " . $user->getDateLastConnect() . "<br><br>";
    if ($user->getDateLastIdea() == NULL) {
        $user->setDateLastIdea("N/A");
    }
    echo " <b>Votre date de dernière activité proposée : </b> " . $user->getDateLastIdea() . "<br><br>";
    echo " <b>Votre date d'inscription : </b> " . $user->getDateInscription() . "<br><br>";
    echo "</div>";
}
/**
 * Fonction permettant de gérer la réponse au formulaire de cotation d'activité. Si il a mis une note, il recalcule la note
 * présente en base de données. Sinon il redirige vers la page de catégories.
 */
function gererFormulaire()
{
    $uam = new User_ActivityManager(connexionDb());
    $tab = $uam->getActIdByUserId($_SESSION['User']);
    $am = new ActivityManager(connexionDb());
    if (isset($tab[0]) && $tab[0]['id_activity'] != null && comparerHeure($tab[0]['date'], 2)) {
        $act = $am->getActivityById($tab[0]['id_activity']);
        if (isset($_POST['Accepter'])) {
            if (isset($_POST['cote']) && $_POST['cote'] != NULL) {
                $cote = $_POST['cote'];
                $note = $act->getNote();
                $votants = $act->getVotants();
                $note = ($note * $votants + $cote) / ($votants + 1);
                $votants = $votants + 1;
                $am->updateCote($act->getId(), $note, $votants);
                $uam->deleteFromTable($_SESSION['User']);
                header("Location:choisirCategorie.page.php");
            } else {
                echo "<br><br><div align='center'><div class='alert alert-danger'  role='alert' style='width:50%'>Vous n'avez pas noté l'activité !</div></div>";
            }
        } else {
            if (isset($_POST['Refuser'])) {
                $uam->deleteFromTable($_SESSION['User']);
                header("Location:choisirCategorie.page.php");
            } else {
                if (isset($_POST['Report'])) {
                    $uam->reportNote($_SESSION['User']->getId());
                    header("Location:choisirCategorie.page.php");
                }
            }
        }
    } else {
        header("Location:../");
    }
}
Ejemplo n.º 3
0
 function save()
 {
     $this->import_parameters();
     $this->load_library('htmlpurifier-4.5.0-lite/library/HTMLPurifier.auto');
     $config = HTMLPurifier_Config::createDefault();
     $purifier = new HTMLPurifier($config);
     $message = $purifier->purify(html_entity_decode($this->message));
     $this->set('message', $message);
     $reference_object = new $this->reference_object($this->reference_id);
     //if the message is being created for an object other than a project, then the project id will be retrieved from
     //the actual object
     //if the message is being posted on a project, then the project id is the messages reference_id
     if ($this->reference_object != 'project') {
         $project_id = isset($reference_object->project_id) ? $reference_object->project_id : false;
     } else {
         $project_id = $this->reference_id;
     }
     if ($project_id) {
         $this->set('project_id', $project_id);
     }
     if (isset($reference_object->client_id)) {
         $this->set('client_id', $reference_object->client_id);
     }
     $this->set('user_id', current_user()->id);
     //these two parameters shouldn't be set yet (they are set when we log activity which happens after the save),
     //but let's just make sure
     $this->unset_param('linked_object');
     $this->unset_param('linked_object_title');
     $result = parent::save();
     ActivityManager::message_created($this);
     return $result;
 }
Ejemplo n.º 4
0
 /**
  * Public function that creates a single instance
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
/**
 * Fonction permettant d'ajouter une activité en base de données grâce aux données d'un formulaire.
 * @return mixed : soit un tableau contenant tous les messages d'erreurs relatif à l'ajout d'activité, soit un tableau
 * contenant un message de succès de l'ajout de l'activité.
 */
function ajouterActivite()
{
    $cat = $_POST['categorie'];
    $act = $_POST['activite'];
    $desc = $_POST['description'];
    $cm = new CategorieManager(connexionDb());
    $am = new ActivityManager(connexionDb());
    $categorie = $cm->getCategorieByLibelle($cat);
    $activityVerif = $am->getActivityByLibelle($act);
    if (strtolower($activityVerif->getLibelle()) == strtolower($act)) {
        $tabRetour['Error'] = "Cette activité existe déjà, ajoutez-en une autre !";
    } else {
        if (strlen($act) >= 5 && strlen($act) <= 100) {
            if (champsTexteValable($desc)) {
                $desc = nl2br($desc);
                $activityToAdd = new Activity(array("Libelle" => $act, "description" => $desc));
                $am->addActivity($activityToAdd);
                $activityToRecup = $am->getActivityByLibelle($act);
                include "../Manager/Categorie_ActivityManager.manager.php";
                $typePhoto = $_FILES['image']['type'];
                if (!strstr($typePhoto, 'jpg') && !strstr($typePhoto, 'jpeg')) {
                    $tabRetour['Error'] = "Votre image n'est pas .jpg ou .jpeg !";
                } else {
                    if ($_FILES['ImageNews']['size'] >= 2097152) {
                        $tabRetour['Error'] = "Votre image est trop lourde !";
                    } else {
                        if ($_FILES['image']['tmp_name'] != null) {
                            uploadImage('../Images/activite', $activityToRecup->getId());
                            $cam = new Categorie_ActivityManager(connexionDb());
                            $um = new UserManager(connexionDb());
                            $um->updateUserLastIdea($_SESSION['User']);
                            $cam->addToTable($activityToRecup, $categorie);
                            $tabRetour['Ok'] = "Votre activité a bien été ajoutée au contenu du site, merci de votre participation !";
                        } else {
                            $tabRetour['Error'] = "Pas d'image !";
                        }
                    }
                }
            } else {
                $tabRetour['Error'] = "Votre description contient des caractères indésirables !";
            }
        } else {
            $tabRetour['Error'] = "Votre titre d'activité n'a pas une taille correcte !";
        }
    }
    return $tabRetour;
}
Ejemplo n.º 6
0
 static function message_created($message)
 {
     $activity = new Activity();
     $activity->set_object($message);
     $activity->set('object_title', $message->message);
     $activity->set('action_taken', Language::get('activity.posted'));
     $message->linked_object = new $message->reference_object($message->reference_id);
     $activity->set_linked_object($message->linked_object);
     $message->linked_object_title = ActivityManager::message_activity_title($message->linked_object);
     $activity->set('linked_object_title', $message->linked_object_title);
     $activity->save();
 }
/**
 * Fonction servant à afficher toutes les activités signalées pour les modérateurs et administrateur.
 * Elle fournit un lien qui permet d'être redirigé vers l'activité en question.
 */
function afficherActivite()
{
    ?>
    <div class="Membres">
    <div class="table-responsive">
        <table class="table table-striped">
            <caption> <h2> Activités </h2></caption>
            <tr>
                <th> Nom de l'activité</th>
                <th> Nom de la catégorie</th>
                <th> Action </th>
            </tr>
            <?php 
    $am = new ActivityManager(connexionDb());
    $cam = new Categorie_ActivityManager(connexionDb());
    $cm = new CategorieManager(connexionDb());
    $tab = $am->getAllActivity();
    $existe = false;
    foreach ($tab as $elem) {
        $id = $elem->getId();
        $catId = $cam->getCatIdByActId($elem);
        if (isset($catId[0])) {
            $cat = $cm->getCategorieById($catId[0]['id_categorie']);
        }
        if ($elem->getSignalee() == 1) {
            echo "<tr> <td>" . $elem->getLibelle() . " </td><td>" . $cat->getLibelle() . "</td><td><a href='proposerActivite.page.php?categorie=" . $cat->getLibelle() . "&activite={$id}'> Gérer le signalement </a></td></tr>";
            $existe = true;
        }
    }
    if (!$existe) {
        echo "<tr> <td> Aucune activité signalée !</td></tr>";
    }
    ?>
        </table>
    </div>
    </div>
    <?php 
}
/**
 * Fonction permettant d'afficher le profil d'un membre à l'aide de son id.
 * @param $id : l'id du membre voulu.
 */
function voirProfil($id)
{
    $um = new UserManager(connexionDb());
    $user = $um->getUserById($id);
    $droit = $user->getDroit()[0];
    $uam = new User_ActivityManager(connexionDb());
    $ua = $uam->getActIdByUserId($user);
    $am = new ActivityManager(connexionDb());
    if ($ua != NULL) {
        $activity = $am->getActivityById($ua[0]['id_activity']);
    } else {
        $activity = new Activity(array("Libelle" => "Il n'a pas encore choisi d'activité !"));
    }
    if ($user->getTel() == NULL) {
        $user->setTel("N/A");
    }
    echo "<h1> Les données de l'utilisateur :</h1>";
    echo "<div class='profil'><br>";
    echo " <b>Son pseudo : </b> " . $user->getUserName() . "<br><br>";
    echo " <b>Son grade : </b>" . $droit->getLibelle() . "<br><br>";
    echo " <b>Son activité : </b> " . $activity->getLibelle() . "<br><br>";
    echo " <b>Son adresse mail : </b> " . $user->getEmail() . "<br><br>";
    echo " <b>Son numéro de téléphone : </b> " . $user->getTel() . "<br><br>";
    echo " <b>Sa date de dernière connexion : </b> " . $user->getDateLastConnect() . "<br><br>";
    if ($user->getDateLastIdea() == NULL) {
        $user->setDateLastIdea("N/A");
    }
    echo " <b>Sa date de dernière activité proposée : </b> " . $user->getDateLastIdea() . "<br><br>";
    echo " <b>Sa date d'inscription : </b> " . $user->getDateInscription() . "<br><br>";
    echo "</div><br><br>";
    echo "<div class='formProfil'>";
    echo "<form class='form-horizontal col-sm-8' name='choixAdmin' action='administration.page.php' method='post'>";
    echo "<input type='hidden'  name='idUser'  value='" . $user->getId() . "''>";
    echo "<input type='hidden'  name='nameUser'  value='" . $user->getUserName() . "''>";
    echo "<button class='btn btn-warning col-sm-6' type='submit' id='formulaire' name='EnvoyerMess'>Envoyer un message</button>";
    echo "</form>";
    echo "</div>";
    echo "<div class='formGrade'>";
    formGrade($user);
    echo "</div>";
}
<?php

/**
 * Created by PhpStorm.
 * User: JulienTour
 * Date: 22/11/2015
 * Time: 23:18
 */
use Entity\Activity;
$uam = new User_ActivityManager(connexionDb());
$actId = $uam->getActIdByUserId($_SESSION['User']);
$act = new Activity(array("id" => $actId[0]['id_activity']));
$am = new ActivityManager(connexionDb());
$activity = $am->getActivityById($act->getId());
echo "<form method='post' action='groupe.page.php?to=creerGroupe'>";
echo "<h1> Création d'un groupe pour l'activité : " . $activity->getLibelle() . "</h1><br><br>";
echo "<input type='hidden'  name='idAct'  value='" . $activity->getId() . "'>";
?>
<div class="form-group col-sm-12">
    <label class="control-label col-sm-2" for="description">Description :</label>
    <div class="col-sm-10">
        <textarea class="form-control" rows="5" id="description" name="description" placeholder="Entrez ici les informations sur votre façon d'effectuer cette activité" required></textarea>
    </div>
</div>
<div class="form-group col-sm-12">
    <div class="col-sm-offset-2 col-sm-12">
        <button type="submit" class="btn btn-default" name="formulaireCreation" id="formulaireCréation">Créer le groupe</button>
    </div>
</div>
</form>
Ejemplo n.º 10
0
function forEveryN($n, $value, $fn)
{
    if ($value % $n == 0) {
        $fn($value);
    }
}
$currentDate = $argv[1];
$thisDate = DateTime::createFromFormat('Y-m-d', $currentDate);
$lastDate = DateTime::createFromFormat('Y-m-d', $currentDate)->sub(new DateInterval('P7D'));
$this_week = ActivityManager::getIsoWeek($thisDate);
$this_week_year = ActivityManager::getYear($thisDate);
$last_week = ActivityManager::getIsoWeek($lastDate);
$last_week_year = ActivityManager::getYear($lastDate);
$SALES_TEAM_FILENAME = "sales-team.text";
$ACTIVITY_CSV_FILENAME = "html/data/week-47/activities-week-47.csv";
$am = new ActivityManager($last_week, $this_week, $last_week_year, $this_week_year);
$am->loadSalesTeam($SALES_TEAM_FILENAME);
$inputFile = fopen($ACTIVITY_CSV_FILENAME, "r");
$rows = 0;
if ($inputFile) {
    while (!feof($inputFile)) {
        $data = fgetcsv($inputFile, 1000, ",");
        if ($rows > 0) {
            if (is_array($data)) {
                $rowdata = $am->getRowData($data);
                $am->recordActivity($rowdata);
            }
        }
        $rows++;
        forEveryN(100, $rows, function () use($rows) {
            echo $rows . "\r\n";
Ejemplo n.º 11
0
<?php

require_once "../private/config.php";
require_once "../views/GeneralView.class.php";
require_once "../models/ActivityManager.class.php";
$activityManager = new ActivityManager($db);
$gView = new GeneralView();
$idActivity = htmlspecialchars($_GET['idActivity']);
$idUser = htmlspecialchars($_GET['idUtilisateur']);
$act = $activityManager->getActivity($idActivity);
//show activity
$gView->showActivity($act, $idUser);
Ejemplo n.º 12
0
 function delete()
 {
     $result = parent::delete();
     //delete the file from the server
     $project = new Project($this->project_id);
     if ($project->is_valid()) {
         $paths = $project->file_paths();
         if (isset($paths) && file_exists($paths['upload_path'] . $this->name)) {
             $file = $paths['upload_path'] . $this->name;
             unlink($file);
         }
     }
     ActivityManager::file_deleted($this);
     return $result;
 }
Ejemplo n.º 13
0
<?php

require_once "private/config.php";
require_once "views/GeneralView.class.php";
require_once "views/ErrorOrSuccessView.class.php";
require_once "models/Agenda.class.php";
require_once "models/AgendaManager.class.php";
$agendaManager = new AgendaManager($db);
$manager = new ActivityManager($db);
$viewG = new GeneralView();
$viewAct = new ActivityView();
$viewG->header("Modification d'activité");
$viewG->navBar("Modification d'activité");
$viewAct->displayActivities($manager->getAllActivities());
if (isset($_SESSION['login'])) {
    if (isset($_POST['supprActivity']) && isset($_POST['idActivity'])) {
        require_once 'config.php';
        require_once 'Activity.class.php';
        require_once 'ActivityManager.class.php';
    }
    $activite = $manager->getActivity(htmlspecialchars($_GET['idActivite']));
}
?>
	<p>Modification de l'activité, changez les champs incorrects :
			<br/><br/>
			<form action="modifier.php" method="post">
				<input type="hidden" name="idActivite" value="<?php 
echo $activite->getIdActivity();
?>
"/>
				Titre : <input type="text" name="titre" value="<?php 
<?php

/**
 * Created by PhpStorm.
 * User: JulienTour
 * Date: 24/11/2015
 * Time: 23:42
 */
$uam = new User_ActivityManager(connexionDb());
$act = $uam->getActIdByUserId($_SESSION['User']);
$am = new ActivityManager(connexionDb());
$activity = $am->getActivityById($act[0]['id_activity']);
?>


<form class="form-horizontal" action="coterActivite.page.php" method="post">
    <h1 align="center"> Donnez une note à l'activité que vous être en train d'effectuer !</h1>
    <?php 
echo "<h1 align='center'> Votre activité est " . $activity->getLibelle() . " </h1>";
?>
    <h2 align="center"> La cotation va de 1 à 5 de gauche à droite (la troisième étoile vaut 3/5 par exemple)</h2>
    <br><br>
    <span class="radioCote">
        <label class="radio-inline"><input type="radio" name="cote" value="1"><img height='40px' width='40px' src="../Images/ratings/star.ico" alt="1/5"/></label>
        <label class="radio-inline"><input type="radio" name="cote" value="2"><img height='40px' width='40px' src="../Images/ratings/star.ico" alt="2/5"/></label>
        <label class="radio-inline"><input type="radio" name="cote" value="3"><img height='40px' width='40px' src="../Images/ratings/star.ico" alt="3/5"/></label>
        <label class="radio-inline"><input type="radio" name="cote" value="4"><img height='40px' width='40px' src="../Images/ratings/star.ico" alt="4/5"/></label>
        <label class="radio-inline"><input type="radio" name="cote" value="5"><img height='40px' width='40px' src="../Images/ratings/star.ico" alt="5/5"/></label>
    </span>
    <br><br><br>
    <button class='btn btn-success col-sm-4' type='submit' id='Accepter' name='Accepter'>Je la note !</button>
Ejemplo n.º 15
0
<?php

require_once "private/config.php";
require_once "views/GeneralView.class.php";
require_once "views/ErrorOrSuccessView.class.php";
require_once "models/Agenda.class.php";
require_once "models/AgendaManager.class.php";
require_once "models/Activity.class.php";
require_once "models/ActivityManager.class.php";
$agendaManager = new AgendaManager($db);
$actManager = new ActivityManager($db);
$viewG = new GeneralView();
$viewG->header("Suppression d'agenda");
$viewG->navBar("Suppression d'agenda");
if (isset($_SESSION['login'])) {
    $agenda = $agendaManager->getAgenda(htmlspecialchars($_GET['idAgenda']));
    $activities = $agendaManager->getAllActivities(htmlspecialchars($_GET['idAgenda']));
}
if (isset($_GET['idAgenda'])) {
    if ($activities != false) {
        foreach ($activities as $act) {
            $actManager->remove($act);
        }
    }
    $agendaManager->remove($agenda);
    echo 'Félicitations, l\'agenda a bien été supprimé';
}
$viewG->footer();
/**
 * Fonction renvoyant un tableau contenant les activités dont le libellé contient le string envoyé par le formulaire
 * de recherche d'activité.
 * @return array : le tableau d'activités.
 */
function rechercheActivite()
{
    $cat = $_GET['categorie'];
    $cm = new CategorieManager(connexionDb());
    $catId = $cm->getCategorieByLibelle($cat);
    $cam = new Categorie_ActivityManager(connexionDb());
    $tabId = $cam->getActIdByCatId($catId);
    if (isPostFormulaire()) {
        $name = $_POST['activite'];
    } else {
        $name = "";
    }
    $am = new ActivityManager(connexionDb());
    $tabAct = $am->searchAllActivityByLibelle($name);
    $tab = array();
    $i = -1;
    foreach ($tabAct as $elem) {
        $i++;
        foreach ($tabId as $act) {
            if ($elem->getId() == $act['id_activity']) {
                $tab[$i] = $elem;
            }
        }
    }
    return $tab;
}
Ejemplo n.º 17
0
 function sendTo($from, $activityId, $split = false)
 {
     //1: if we are in a join check if this instance is also in other activity
     //if so do nothing
     $type = $this->getOne("SELECT `type` FROM `" . GALAXIA_TABLE_PREFIX . "activities` WHERE `activityId`=?", array((int) $activityId));
     // Verify the existance of a transition
     if (!$this->getOne("SELECT count(*) FROM `" . GALAXIA_TABLE_PREFIX . "transitions` WHERE `actFromId`=? AND `actToId`=?", array($from, (int) $activityId))) {
         trigger_error(tra('Fatal error: trying to send an instance to an activity but no transition found'), E_USER_WARNING);
     }
     //Use the nextUser
     if ($this->nextUser) {
         $putuser = $this->nextUser;
     } else {
         //Try to determine the user or *
         $candidates = array();
         $query = "SELECT `roleId` FROM `" . GALAXIA_TABLE_PREFIX . "activity_roles` WHERE `activityId`=?";
         $result = $this->query($query, array((int) $activityId));
         while ($res = $result->fetchRow()) {
             $roleId = $res['roleId'];
             $query2 = "SELECT `user` FROM `" . GALAXIA_TABLE_PREFIX . "user_roles` WHERE `roleId`=?";
             $result2 = $this->query($query2, array((int) $roleId));
             while ($res2 = $result2->fetchRow()) {
                 $candidates[] = $res2['user'];
             }
         }
         $putuser = count($candidates) == 1 ? $candidates[0] : '*';
     }
     $now = date("U");
     $iid = $this->instanceId;
     // Test if the join activity has preceding activities that are not completed yet
     if ($type == 'join') {
         // Calculate 1)how many incoming transitions the activity has, and 2)how many of those are completed
         $querycant = "SELECT COUNT(*) FROM `" . GALAXIA_TABLE_PREFIX . "transitions` WHERE actToId = ?";
         $querycomp = "SELECT COUNT(*) FROM `" . GALAXIA_TABLE_PREFIX . "transitions` tr " . "INNER JOIN " . GALAXIA_TABLE_PREFIX . "instance_activities gia ON tr.actFromId=gia.activityId\r\n                     WHERE tr.pid=? AND tr.actToId=? AND gia.instanceId=? AND gia.status = ?";
         $transcant = $this->getone($querycant, array($activityId));
         $transcomp = $this->getone($querycomp, array($this->pId, $activityId, $iid, 'completed'));
         // if there are still preceding activities not completed, STOP
         if ($nb = $transcant - $transcomp) {
             //echo 'Pending preceding activities = ' . $nb;
             return;
         }
     }
     $query = "DELETE FROM `" . GALAXIA_TABLE_PREFIX . "instance_activities` WHERE `instanceId`=? AND `activityId`=?";
     $this->query($query, array((int) $iid, (int) $activityId));
     $query = "INSERT INTO `" . GALAXIA_TABLE_PREFIX . "instance_activities` (`instanceId`, `activityId`, `user`, `status`, `started`) VALUES (?,?,?,?,?)";
     $this->query($query, array((int) $iid, (int) $activityId, $putuser, 'running', (int) $now));
     // Check whether the activity we're sending the instance to is interactive
     $isInteractive = $this->getOne("SELECT `isInteractive` FROM `" . GALAXIA_TABLE_PREFIX . "activities` WHERE `activityId`=?", array((int) $activityId));
     //if the activity is not interactive then execute its code and complete it
     if ($isInteractive == 'n') {
         // These are necessary to determine if the activity needs to be recompiled
         $proc = new Process($this->db);
         $proc->getProcess($this->pId);
         $baseact = new BaseActivity($this->db);
         $act = $baseact->getActivity($activityId);
         // Get paths for original and compiled activity code
         $origcode = 'lib/Galaxia/processes/' . $proc->getNormalizedName() . '/code/activities/' . $act->getNormalizedName() . '.php';
         $compcode = 'lib/Galaxia/processes/' . $proc->getNormalizedName() . '/compiled/' . $act->getNormalizedName() . '.php';
         // Check whether the activity code is newer than its compiled counterpart,
         // i.e. check if the source code was changed; if so, we need to recompile
         if (filemtime($origcode) > filemtime($compcode)) {
             // Recompile
             include_once 'lib/Galaxia/src/ProcessManager/ActivityManager.php';
             include_once 'lib/Galaxia/src/ProcessManager/ProcessManager.php';
             $am = new ActivityManager($this->db);
             $am->compile_activity($this->pId, $activityId);
         }
         // Now execute the code for the activity (function galaxia_execute_activity
         // is defined in lib/Galaxia/config.php)
         galaxia_execute_activity($activityId, $iid, 1);
         // Reload in case the activity did some change
         $this->getInstance($this->instanceId);
         $this->complete($activityId);
     }
 }
Ejemplo n.º 18
0
 function replace_process($p_id, $vars, $create = true)
 {
     $TABLE_NAME = GALAXIA_TABLE_PREFIX . "processes";
     $now = date("U");
     $vars['last_modified'] = $now;
     $vars['normalized_name'] = $this->_normalize_name($vars['procname'], $vars['version']);
     foreach ($vars as $key => $value) {
         $vars[$key] = addslashes($value);
     }
     if ($p_id) {
         // update mode
         $old_proc = $this->get_process($p_id);
         $first = true;
         $query = "update `{$TABLE_NAME}` set";
         foreach ($vars as $key => $value) {
             if (!$first) {
                 $query .= ',';
             }
             if (!is_numeric($value) || strstr($value, '.')) {
                 $value = "'" . $value . "'";
             }
             $query .= " `{$key}`={$value} ";
             $first = false;
         }
         $query .= " where `p_id`={$p_id} ";
         $this->mDb->query($query);
         // Note that if the name is being changed then
         // the directory has to be renamed!
         $oldname = $old_proc['normalized_name'];
         $newname = $vars['normalized_name'];
         if ($newname != $oldname) {
             rename(GALAXIA_PROCESSES . "/{$oldname}", GALAXIA_PROCESSES . "/{$newname}");
             $am = new ActivityManager();
             $am->compile_process_activities($p_id);
         }
         $msg = sprintf(tra('Process %s has been updated'), $vars['procname']);
         $this->notify_all(3, $msg);
     } else {
         unset($vars['p_id']);
         // insert mode
         $name = $this->_normalize_name($vars['procname'], $vars['version']);
         $this->_create_directory_structure($name);
         $first = true;
         $query = "insert into `{$TABLE_NAME}`(";
         foreach (array_keys($vars) as $key) {
             if (!is_numeric($key)) {
                 if (!$first) {
                     $query .= ',';
                 }
                 $query .= "`{$key}`";
                 $first = false;
             }
         }
         $query .= ") values(";
         $first = true;
         foreach ($vars as $key => $value) {
             if (!is_numeric($key)) {
                 if (!$first) {
                     $query .= ',';
                 }
                 if (!is_numeric($value) || strstr($value, '.')) {
                     $value = "'" . $value . "'";
                 }
                 $query .= "{$value}";
                 $first = false;
             }
         }
         $query .= ")";
         $this->mDb->query($query);
         $p_id = $this->mDb->getOne("select max(`p_id`) from `{$TABLE_NAME}` where `last_modified`={$now}");
         // Now automatically add a start and end activity
         // unless importing ($create = false)
         if ($create) {
             $aM = new ActivityManager();
             $vars1 = array('name' => 'start', 'description' => 'default start activity', 'act_type' => 'start', 'is_interactive' => 'y', 'is_auto_routed' => 'y');
             $vars2 = array('name' => 'end', 'description' => 'default end activity', 'act_type' => 'end', 'is_interactive' => 'n', 'is_auto_routed' => 'y');
             $aM->replace_activity($p_id, 0, $vars1);
             $aM->replace_activity($p_id, 0, $vars2);
         }
         $msg = sprintf(tra('Process %s has been created'), $vars['procname']);
         $this->notify_all(4, $msg);
     }
     // Get the id
     return $p_id;
 }
Ejemplo n.º 19
0
<?php

// Load configuration of the Galaxia Workflow Engine
include_once dirname(__FILE__) . '/config.php';
include_once GALAXIA_LIBRARY . '/src/ProcessManager/ProcessManager.php';
include_once GALAXIA_LIBRARY . '/src/ProcessManager/InstanceManager.php';
include_once GALAXIA_LIBRARY . '/src/ProcessManager/RoleManager.php';
include_once GALAXIA_LIBRARY . '/src/ProcessManager/ActivityManager.php';
include_once GALAXIA_LIBRARY . '/src/ProcessManager/GraphViz.php';
/// $roleManager is the object that will be used to manipulate roles.
$roleManager = new RoleManager();
/// $activityManager is the object that will be used to manipulate activities.
$activityManager = new ActivityManager();
/// $processManager is the object that will be used to manipulate processes.
$processManager = new ProcessManager();
/// $instanceManager is the object that will be used to manipulate instances.
$instanceManager = new InstanceManager();
if (defined('GALAXIA_LOGFILE') && GALAXIA_LOGFILE) {
    include_once GALAXIA_LIBRARY . '/src/Observers/Logger.php';
    $logger = new Logger(GALAXIA_LOGFILE);
    $processManager->attach_all($logger);
    $activityManager->attach_all($logger);
    $roleManager->attach_all($logger);
}
Ejemplo n.º 20
0
                    }
                } else {
                    $dataActivity['isPublic'] = false;
                }
                //in all case if we dont have a starting date > error
                if ($dataActivity["startDate"] == "") {
                    $errorView->errorNeedToCompleteForm();
                } else {
                    //if we dont have a starting date + a ending date or a startDate + a periodicity or a number of occurence > error
                    if ($dataActivity["endDate"] == "" && $dataActivity["periodic"] == "" && $dataActivity["nbOccur"] == "") {
                        $errorView->errorNeedToCompleteForm();
                    } else {
                        //start to add in database us activity
                        require_once "models/Activity.class.php";
                        require_once "models/ActivityManager.class.php";
                        $activityManager = new ActivityManager($db);
                        $activity = new Activity($dataActivity);
                        if ($activityManager->add($activity)) {
                            $errorView->successActivityCreated();
                        } else {
                            $errorView->errorActivityCreateFailed();
                        }
                    }
                }
            }
        }
    } else {
        $dataIdAgenda = $agendaManager->getAllAgenda($_SESSION['idUser']);
        $viewG->createAgendaOrActivity($dataIdAgenda);
    }
} else {
Ejemplo n.º 21
0
/**
 * Fonction permettant de générer un formulaire demandant à l'utilisateur si il est sûr de vouloir
 * prendre l'activité de son ami.
 */
function modifAct()
{
    $id = $_GET['id'];
    $am = new ActivityManager(connexionDb());
    $activity = $am->getActivityById($id);
    echo "<div class='activity'>";
    echo "<img class='photoAct' src='../Images/activite/" . $activity->getId() . ".jpg' alt='photoActivite' />";
    echo "<h1 style='text-align: center'>" . $activity->getLibelle() . "</h1>";
    echo "<h2 style='text-align: center'>" . $activity->getDescription() . "</h2>";
    if ($activity->getNote() == NULL) {
        echo "<h3 style='text-align: center'>Cette activité n'a pas encore été notée !</h3>";
    } else {
        echo "<h3 style='text-align: center'>Sa note est de : " . roundTo($activity->getNote(), 0.5) . "/5</h3>";
    }
    echo "<form class='form-horizontal col-sm-12' name='activite' action='amis.page.php?to=modifAct&id={$id}' method='post'>";
    echo "<button class='btn btn-success col-sm-6' type='submit' id='formulaire' name='AccepterAct'>Choisir cette activité</button>";
    echo "<button class='btn btn-warning col-sm-6' type='submit' id='formulaire' name='RefuserAct'>Je me suis trompé</button>";
    echo "</form>";
    echo "</div>";
}
Ejemplo n.º 22
0
 /**
  * Handle drawing list of activities.
  *
  * @param array $tag_params
  * @param array $children
  */
 public function tag_ActivityList($tag_params, $children)
 {
     $manager = ActivityManager::getInstance();
     $conditions = array();
     // get items from database
     $items = $manager->getItems($manager->getFieldNames(), $conditions);
     // load template
     $template = $this->loadTemplate($tag_params, 'list_item.xml');
     // parse template
     if (count($items) > 0) {
         foreach ($items as $item) {
             $params = array('id' => $item->id, 'activity' => $item->activity, 'function' => $item->function, 'timeout' => $item->timeout, 'ignore_address' => $item->ignore_address, 'ignore_address_char' => $item->ignore_address ? CHAR_CHECKED : CHAR_UNCHECKED, 'item_change' => url_MakeHyperlink($this->getLanguageConstant('change'), window_Open('activities_change', 400, $this->getLanguageConstant('title_activity_change'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'change'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('activities_delete', 400, $this->getLanguageConstant('title_activity_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'delete'), array('id', $item->id)))));
             $template->restoreXML();
             $template->setLocalParams($params);
             $template->parse();
         }
     }
 }
Ejemplo n.º 23
0
 function delete()
 {
     $result = parent::delete();
     $this->update_project_progress();
     ActivityManager::task_deleted($this);
     return $result;
 }
Ejemplo n.º 24
0
 function replace_process($pId, $vars, $create = true)
 {
     $TABLE_NAME = GALAXIA_TABLE_PREFIX . "processes";
     $now = date("U");
     $vars['lastModif'] = $now;
     $vars['normalized_name'] = $this->_normalize_name($vars['name'], $vars['version']);
     foreach ($vars as $key => $value) {
         $vars[$key] = addslashes($value);
     }
     if ($pId) {
         // update mode
         $old_proc = $this->get_process($pId);
         $first = true;
         $query = "update `{$TABLE_NAME}` set";
         foreach ($vars as $key => $value) {
             $que[] = "`{$key}`=?";
             $bindvars[] = $value;
         }
         $query .= implode(',', $que) . " where `pId`=? ";
         $bindvars[] = $pId;
         $this->query($query, $bindvars);
         // Note that if the name is being changed then
         // the directory has to be renamed!
         $oldname = $old_proc['normalized_name'];
         $newname = $vars['normalized_name'];
         if ($newname != $oldname) {
             rename(GALAXIA_PROCESSES . "/{$oldname}", GALAXIA_PROCESSES . "/{$newname}");
         }
         $msg = sprintf(tra('Process %s has been updated'), $vars['name']);
         $this->notify_all(3, $msg);
     } else {
         unset($vars['pId']);
         // insert mode
         $name = $this->_normalize_name($vars['name'], $vars['version']);
         $this->_create_directory_structure($name);
         $query = "insert into `{$TABLE_NAME}`(`";
         $query .= implode('`,`', array_keys($vars)) . "`) values(";
         foreach (array_values($vars) as $value) {
             $que[] = "?";
         }
         $query .= implode(',', $que) . ")";
         $this->query($query, $vars);
         $pId = $this->getOne("select max(pId) from {$TABLE_NAME} where lastModif={$now}");
         // Now automatically add a start and end activity
         // unless importing ($create = false)
         if ($create) {
             $aM = new ActivityManager($this->db);
             $vars1 = array('name' => 'start', 'description' => 'default start activity', 'type' => 'start', 'isInteractive' => 'y', 'isAutoRouted' => 'y');
             $vars2 = array('name' => 'end', 'description' => 'default end activity', 'type' => 'end', 'isInteractive' => 'n', 'isAutoRouted' => 'y');
             $aM->replace_activity($pId, 0, $vars1);
             $aM->replace_activity($pId, 0, $vars2);
         }
         $msg = sprintf(tra('Process %s has been created'), $vars['name']);
         $this->notify_all(4, $msg);
     }
     // Get the id
     return $pId;
 }
/**
 * Fonction permettant l'affichage du groupe auquel on appartient ainsi que la liste des membre du groupe et le chat du groupe.
 */
function voirGroupe()
{
    $ugm = new User_GroupeManager(connexionDb());
    $groupeId = $ugm->getGroupeIdByUserId($_SESSION['User']);
    $gm = new GroupeManager(connexionDb());
    $am = new ActivityManager(connexionDb());
    $um = new UserManager(connexionDb());
    $amiM = new AmisManager(connexionDb());
    $gmm = new Groupe_MessageManager(connexionDb());
    $groupe = $gm->getGroupeByIdGroupe($groupeId[0]['id_groupe']);
    $leader = $um->getUserById($groupe->getIdLeader());
    $act = $am->getActivityById($groupe->getIdActivity());
    $membres = $ugm->getUserIdByGroupeId($groupe);
    $messages = $gmm->getMessageByGroup($groupe);
    $existe = false;
    $autreMembre = false;
    formGroupe($groupe);
    echo "<div class='titleGroupe'>";
    echo "<div class='photoGroupe'>";
    echo "<img class='photoAct' src='../Images/activite/" . $act->getId() . ".jpg' alt='photoActivite' />";
    echo "</div>";
    echo "<h1 align='center'>" . $act->getLibelle() . "</h1>";
    echo "<h2 align='center'> Chef de groupe : " . $leader->getUserName() . "</h2>";
    echo "</div>";
    echo "<h3 align='center'> Description de votre activité :</h3>";
    echo "<div class='well well-lg'><h4 align='center'>" . $act->getDescription() . "</h4></div>";
    echo "<h3 align='center'> Description de votre groupe : </h3>";
    echo "<div class='well well-lg'><h3 align='center'>" . $groupe->getDescription() . " </h3></div>";
    ?>
    <div class="table-responsive">
    <table class="table table-striped">
        <caption> <h2> Membres du groupe </h2></caption>
        <tr>
            <th> Utilisateur </th>
            <th> Date de dernière connexion</th>
            <th> Ajouter en ami </th>
            <?php 
    if ($groupe->getIdLeader() == $_SESSION['User']->getId()) {
        ?>
                <th> Supprimer du groupe </th>
                <th> Nommer chef de groupe </th>
            <?php 
    }
    ?>
        </tr>
        <?php 
    foreach ($membres as $elem) {
        $user = $um->getUserById($elem['id_user']);
        $id = $user->getId();
        if ($user->getId() != $_SESSION['User']->getId()) {
            $autreMembre = true;
            $amiTest1 = $amiM->getAmisById1AndId2($user->getId(), $_SESSION['User']->getId());
            $amiTest2 = $amiM->getAmisById1AndId2($_SESSION['User']->getId(), $user->getId());
            echo "<tr> <td>" . $user->getUserName() . " </td><td>" . $user->getDateLastConnect() . " </td><td>";
            if ($amiTest1->getIdUser1() == NULL && $amiTest2->getIdUser1() == NULL) {
                echo "<a href='demandeAmi.page.php?membre=" . $user->getId() . "'> Ajouter comme ami </a>";
            } else {
                echo "Vous êtes déjà ami avec cette personne !";
            }
            echo "</td>";
            if ($groupe->getIdLeader() == $_SESSION['User']->getId()) {
                echo "<td><form class='form-horizontal col-sm-12' name='suppression{$id}' action='groupe.page.php?to=voirGroupe' method='post'>";
                echo "<input type='hidden'  name='idMembre{$id}'  value='" . $id . "''>";
                echo "<button class='btn btn-danger col-sm-10' type='submit' id='formulaire' name='supprimerMembre{$id}'>Supprimer ce membre</button>";
                echo "</form>";
                echo "</td>";
                echo "<td><form class='form-horizontal col-sm-12' name='nommerLead{$id}' action='groupe.page.php?to=voirGroupe' method='post'>";
                echo "<input type='hidden'  name='idMembre{$id}'  value='" . $id . "''>";
                echo "<button class='btn btn-success col-sm-10' type='submit' id='formulaire' name='nommerLead{$id}'>Nommer chef de groupe</button>";
                echo "</form>";
                echo "</td>";
            }
            echo "</tr>";
        }
    }
    if (!$autreMembre) {
        echo "<tr> <td> Vous êtes le seul membre du groupe pour le moment !</td></tr>";
    }
    ?>
    </table>
    </div>
    <?php 
    echo "<br> <br>";
    echo "<h2> Messagerie du groupe : </h2><br>";
    echo "<div class='messagerieGroupe'>";
    include "../Form/groupeMessage.form.php";
    echo "<br>";
    ?>
    <div class="table-responsive">
        <table class="table table-striped">
            <tr>
                <th> Utilisateur</th>
                <th> Date </th>
                <th> Message </th>
            </tr>
            <?php 
    foreach ($messages as $elem) {
        $user = $um->getUserById($elem['id_user']);
        echo "<tr> <td>" . $user->getUserName() . " </td><td>" . $elem['date'] . " </td><td>";
        echo $elem['description'];
        echo "</td></tr>";
        $existe = false;
    }
    if ($messages == NULL || $existe) {
        echo "<tr> <td> Aucun message pour le moment !</td></tr>";
    }
    ?>
        </table>
    </div>
    <?php 
    echo "</div>";
}
Ejemplo n.º 26
0
 function delete()
 {
     $result = parent::delete();
     $this->delete_projects();
     $this->delete_users();
     ActivityManager::client_deleted($this);
     return $result;
 }
Ejemplo n.º 27
0
    <div class="col-lg-12">
        <section class="row">
            <article class="col-lg-12 col-sm-12">
                <?php 
echo "<div class='media'>";
echo "<div class='media-right media-middle' >";
echo "<img class='media-object' src='Images/accueil/ampoule.png' alt='EveryDayIdea' >";
echo "</div>";
echo "<div class='media-body media-right'>";
echo "<h3  class='media-heading'>Activité du jour </h3>";
if (!isConnect()) {
    echo "Pour bénéficier de cette fonctionnalité, vous devez <a href='Page/connexion.page.php'><b>être connecté !</b></a>";
} else {
    $uam = new User_ActivityManager(connexionDb());
    $tab = $uam->getActIdByUserId($_SESSION['User']);
    $am = new ActivityManager(connexionDb());
    if (!isset($tab[0]['id_activity'])) {
        echo "Vous n'avez pas encore choisi d'activité aujourd'hui ! <a href='Page/choisirCategorie.page.php'><b>Choississez-en une</b></a> !";
    } else {
        $act = $am->getActivityById($tab[0]['id_activity']);
        echo "<p><Votre activité choisie du jour est :</p>";
        echo "<div class='activityIndex'>";
        echo "<img class='photoAct' src='Images/activite/" . $tab[0]['id_activity'] . ".jpg' alt='photoActivite' />";
        echo "<p><h3>" . $act->getLibelle() . "</h3></p>";
        echo "<p> Sa description est : <h4>" . $act->getDescription() . "</h4></p>";
        echo "</div>";
        echo "<div id='info'>";
        echo "<p> Il est toujours possible de la changer via <b><a href='Page/choisirCategorie.page.php'>le choix d'activités</a></b> !</p>";
        echo "<p><b> Bon amusement !</b></p>";
        echo "</div>";
    }
Ejemplo n.º 28
0
 function delete()
 {
     $sql_delete_tasks = "DELETE FROM tasks WHERE project_id = " . $this->id;
     $this->execute($sql_delete_tasks);
     $this->delete_project_files();
     $this->delete_file_folder();
     $result = parent::delete();
     ActivityManager::project_deleted($this);
     return $result;
 }