Example #1
0
        $message = "Format d'adresse mail non reconnue";
        $valide = false;
    }
    if ($valide) {
        $password = $_POST['pwd'];
        $oldpwd = $_POST['oldpwd'];
        if ($password != '' && $oldpwd != '') {
            if (password_verify($oldpwd, $user->getPassword())) {
                $pwd = password_hash($password, PASSWORD_DEFAULT);
            } else {
                $valide = false;
                $message = "Mot de passe incorrect !";
            }
        }
        if ($valide) {
            $nom = $_POST['nom'] == '' ? $user->getNom() : $_POST['nom'];
            $prenom = $_POST['prenom'] == '' ? $user->getPrenom() : $_POST['prenom'];
            $password = $password == '' ? $user->getPassword() : $pwd;
            $education = $_POST['education'] == '' ? $user->getEducation() : $_POST['education'];
            $location = $_POST['location'] == '' ? $user->getLocation() : $_POST['location'];
            $skills = $_POST['skills'] == '' ? $user->getSkills() : $_POST['skills'];
            $jobs = $_POST['job'] == '' ? $user->getJob() : $_POST['job'];
            $database->changeUserTrivialInformations($user->getid(), $nom, $prenom, $email, $password, $education, $location, $skills, $jobs);
            $message = "Votre profil est à jour";
        }
        // check mdp
        //$password = password_hash($_POST['pwd'],PASSWORD_DEFAULT);
        //}
    }
}
Tools::callTwig('edit_profile.twig', array('message' => $message, 'valide' => $valide, 'connected' => Tools::isLogged(), 'user' => $user));
Example #2
0
 /**
  * Display a report. Choose the report among
  *  - the requested 'select_report'
  *  - the last viewed report (stored in preferences)
  *  - the default report of this tracker
  *
  * If the user request a 'link-artifact-id' then display also manual and recent 
  * panels to ease the selection of artifacts to link
  *
  * @param Tracker_IDisplayTrackerLayout  $layout          Displays the page header and footer
  * @param Codendi_Request                $request         The request
  * @param User                           $current_user    The user who made the request
  *
  * @return void
  */
 public function displayAReport(Tracker_IDisplayTrackerLayout $layout, $request, $current_user)
 {
     $report = null;
     //Does the user wants to change its report?
     if ($request->get('select_report') && $request->isPost()) {
         //Is the report id valid
         if ($report = $this->getReportFactory()->getReportById($request->get('select_report'), $current_user->getid())) {
             $current_user->setPreference('tracker_' . $this->id . '_last_report', $report->id);
         }
     }
     //If no valid report found. Search the last viewed report for the user
     if (!$report) {
         if ($report_id = $current_user->getPreference('tracker_' . $this->id . '_last_report')) {
             $report = $this->getReportFactory()->getReportById($report_id, $current_user->getid());
         }
     }
     //If no valid report found. Take the default one
     if (!$report) {
         $report = $this->getReportFactory()->getDefaultReportsByTrackerId($this->id);
     }
     $link_artifact_id = (int) $request->get('link-artifact-id');
     if ($link_artifact_id && !$request->get('report-only')) {
         $linked_artifact = Tracker_ArtifactFactory::instance()->getArtifactById($link_artifact_id);
         if (!$linked_artifact) {
             $err = "Linked artifact not found or doesn't exist";
             if (!$request->isAjax()) {
                 $GLOBALS['Response']->addFeedback('error', $err);
                 $GLOBALS['Response']->redirect('/');
             }
             die($err);
         }
         if (!$request->isAjax()) {
             //screwed up
             $GLOBALS['Response']->addFeedback('error', 'Something is wrong with your request');
             $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?aid=' . $linked_artifact->getId());
         }
         echo $linked_artifact->fetchTitle($GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'title_prefix'));
         echo '<input type="hidden" id="link-artifact-id" value="' . (int) $link_artifact_id . '" />';
         echo '<table id="tracker-link-artifact-different-ways" cellpadding="0" cellspacing="0" border="0"><tbody><tr>';
         //the fast ways
         echo '<td id="tracker-link-artifact-fast-ways">';
         //Manual
         echo '<div id="tracker-link-artifact-manual-way">';
         echo '<div class="boxtitle">';
         echo $GLOBALS['HTML']->getImage('ic/lightning-white.png', array('style' => 'vertical-align:middle')) . '&nbsp;';
         echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'manual_panel_title');
         echo '</div>';
         echo '<div class="tracker-link-artifact-manual-way-content">';
         echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'manual_panel_desc');
         echo '<p><label for="link-artifact-manual-field">';
         echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'manual_panel_label');
         echo '</label><br />';
         echo '<input type="text" name="link-artifact[manual]" value="" id="link-artifact-manual-field" />';
         echo '</p>';
         echo '</div>';
         echo '</div>';
         //History
         echo '<div id="tracker-link-artifact-recentitems-way">';
         echo '<div class="boxtitle">';
         echo $GLOBALS['HTML']->getImage('ic/star-white.png', array('style' => 'vertical-align:middle')) . '&nbsp;';
         echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'recent_panel_title');
         echo '</div>';
         echo '<div class="tracker-link-artifact-recentitems-way-content">';
         if ($recent_items = $current_user->getRecentElements()) {
             echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'recent_panel_desc');
             echo '<ul>';
             foreach ($recent_items as $item) {
                 if ($item['id'] != $link_artifact_id) {
                     echo '<li>';
                     echo '<input type="checkbox" 
                                  name="link-artifact[recent][]" 
                                  value="' . (int) $item['id'] . '" /> ';
                     echo $item['link'];
                     echo '</li>';
                 }
             }
             echo '</ul>';
         }
         echo '</div>';
         echo '</div>';
         //end of fast ways
         echo '</td>';
         //And the slow way (aka need to search)
         if ($report) {
             echo '<td><div id="tracker-link-artifact-slow-way">';
             echo '<div class="boxtitle">';
             echo $GLOBALS['HTML']->getImage('ic/magnifier-white.png', array('style' => 'vertical-align:middle')) . '&nbsp;';
             echo $GLOBALS['Language']->getText('plugin_tracker_artifactlink', 'search_panel_title');
             echo '</div>';
             echo '<div id="tracker-link-artifact-slow-way-content">';
         }
     }
     if ($report) {
         $report->process($layout, $request, $current_user);
     } elseif (!$link_artifact_id) {
         $this->displayHeader($layout, $this->name, array());
         echo $GLOBALS['Language']->getText('plugin_tracker', 'no_reports_available');
         $this->displayFooter($layout);
     }
     if ($link_artifact_id && !$request->get('report-only')) {
         if ($report) {
             echo '</div></div></td>';
             //end of slow
         }
         echo '</tr></tbody></table>';
         //end of ways
         echo '<div class="tracker-link-artifact-controls">';
         echo '<a href="#cancel" onclick="myLightWindow.deactivate(); return false;">&laquo;&nbsp;' . $GLOBALS['Language']->getText('global', 'btn_cancel') . '</a>';
         echo ' ';
         echo '<button name="link-artifact-submit">' . $GLOBALS['Language']->getText('global', 'btn_submit') . '</button>';
         echo '</div>';
     }
 }
Example #3
0
<?php

session_start();
require_once '../global.php';
$database = new Database();
if (Tools::isLogged() && isset($_POST['idpost']) && isset($_POST['comment'])) {
    $user = new User($_SESSION['login']);
    $post = new Post($_POST['idpost']);
    $database->addComment($_POST['idpost'], $user->getid(), $_POST['comment']);
    $notifAction = 'comment';
    if ($post->getUser()->getid() != $user->getid()) {
        $database->setNotification($post->getUser()->getid(), $notifAction, $user->getid(), $post->getid());
    }
}
Example #4
0
    if (!in_array($_GET['accept'], $friends)) {
        // check if new person is not already a friend
        array_push($friends, $_GET['accept']);
        // adding the new person id to the array of friends
        $database->setFriends($user->getid(), json_encode($friends));
        // saving the array to database
    }
    $friend = new User($database->getMailForId($_GET['accept'])[0]);
    // creating user for friend
    $friendsOfFriend = $friend->getFriends() ? $friend->getFriends() : array();
    // getting the friends of our new friend
    if (!in_array($user->getid(), $friendsOfFriend)) {
        // if we are not already in his array of friend ids
        array_push($friendsOfFriend, $user->getid());
        // adding ourselves to his array of friends ids
        $database->setFriends($friend->getid(), json_encode($friendsOfFriend));
        // saving his friend list
    }
    $notifAction = "friendReqAccept";
    $database->setNotification($_GET['accept'], $notifAction, $user->getid());
    $message = "Vous êtes désormais ami avec cette personne";
}
Tools::callTwig('friendslist.twig', array('connected' => Tools::isLogged(), 'user' => $user, 'friends' => callFriends($database, $user, $friends), 'people' => callAllPeople($database, $user, $friends), 'asks' => getFriendshipDemands($user, $database), 'ownasks' => getOwnFriendshipDemands($user, $database), 'message' => $message));
/*
Function callFriends : return list of User objects for current user's friends (i.e : convert ints into objects)
@param $database Database object
@param $user current user
@param $friends array of friends id (yup, bad, handled with json)
@return [User]
*/
function callFriends($database, $user, $friends)
Example #5
0
<?php

session_start();
require_once 'global.php';
$database = new Database();
if (Tools::isLogged()) {
    // if we are logged, just load conversations for our user
    $user = new User($_SESSION['login']);
    $conversations = $database->getConversationsForUser($user->getid());
}
/*
	
	If we are trying to create a new conversation
*/
if (Tools::isLogged() && isset($_POST['dest']) && isset($_POST['message']) && isset($_POST['titre'])) {
    $destinataires = $_POST['dest'];
    $message = $_POST['message'];
    $titre = $_POST['titre'];
    $idconversation = $database->newConversation($titre);
    // get the id of the newly created conversation
    foreach ($destinataires as $destinataire) {
        // for each destinataire, add him to table participants
        $database->addMPParticipants($idconversation, $destinataire, true);
    }
    $database->addMPParticipants($idconversation, $user->getid(), false);
    // adding ourselves
    $database->newMP($user->getid(), $idconversation, $message);
    // adding the first message to the list of mps
    $conversations = $database->getConversationsForUser($user->getid());
    // finally, get the new list of conversations
}
Example #6
0
session_start();
require_once 'global.php';
$database = new Database();
if (Tools::isLogged() && isset($_POST['mpcontenu'])) {
    $conversationid = $_GET['mpid'];
    $user = new User($_SESSION['login']);
    // this is us
    // create new mp
    $database->newMP($user->getid(), $conversationid, $_POST['mpcontenu']);
    // Set conversation as unread for all recipients
    $recipients = $database->getConversationDest($user->getid(), $conversationid);
    foreach ($recipients as $dest) {
        $database->changeConversationReadStatus($conversationid, $dest[0], '1');
    }
}
if (Tools::isLogged() && isset($_GET['mpid'])) {
    $user = new User($_SESSION['login']);
    $conversation = $database->getFullConversationByID($_GET['mpid']);
    // if we are just looking at the conversation, get its posts
    $database->changeConversationReadStatus($_GET['mpid'], $user->getid(), '0');
    // make it read
}
Tools::callTwig('detailmp.twig', array('connected' => Tools::isLogged(), 'user' => $user, 'conversation' => getMessages($conversation, $user), 'conversationinfo' => getMessages($conversation, $user)[0]->getConversation()));
function getMessages($conversation, $user)
{
    foreach ($conversation as $message) {
        $messagesobj[] = new Message($message, $user);
    }
    return $messagesobj;
}
Example #7
0
<?php

session_start();
require_once '../global.php';
$database = new Database();
if (Tools::isLogged() && isset($_GET['idpost'])) {
    $user = new User($_SESSION['login']);
    $post = new Post($_GET['idpost']);
    $detected = false;
    $i = 0;
    while (!$detected && $i < count($database->getLikes($_GET['idpost']))) {
        // if the user that wants to like the post already has
        if ($database->getLikes($_GET['idpost'])[$i]['idmembre'] == $user->getid()) {
            $detected = true;
        }
        $i++;
    }
    if (!$detected) {
        $database->likePost($_GET['idpost'], $user->getid());
        $notifAction = 'like';
        if ($post->getUser()->getid() != $user->getid()) {
            $database->setNotification($post->getUser()->getid(), $notifAction, $user->getid(), $post->getid());
        }
    } else {
        echo 'no';
    }
}
Example #8
0
<?php

session_start();
require_once '../global.php';
$database = new Database();
if (Tools::isLogged() && isset($_GET['idpost'])) {
    $user = new User($_SESSION['login']);
    $post = new Post($_GET['idpost']);
    if ($user->getid() == $post->getUser()->getid()) {
        $database->deletePost($_GET['idpost']);
        echo 'ok';
    }
}