Add a Manageurs page to the profile
authorThomas Minvielle <thomas.minvielle@polytechnique.org>
Wed, 5 Mar 2014 08:39:15 +0000 (09:39 +0100)
committerThomas Minvielle <thomas.minvielle@polytechnique.org>
Sat, 8 Mar 2014 12:41:03 +0000 (13:41 +0100)
modules/profile.php
modules/profile/manageurs.inc.php [new file with mode: 0644]
modules/profile/page.inc.php
templates/profile/manageurs.tpl [new file with mode: 0644]
upgrade/manageurs/01_create_profile_manageurs.sql

index 42c93ed..5309cc9 100644 (file)
@@ -301,7 +301,7 @@ class ProfileModule extends PLModule
     {
         global $globals;
 
-        if (in_array($hrpid, array('general', 'adresses', 'emploi', 'poly', 'deco', 'mentor', 'deltaten'))) {
+        if (in_array($hrpid, array('general', 'adresses', 'emploi', 'poly', 'deco', 'mentor', 'manageurs', 'deltaten'))) {
             $aux = $opened_tab;
             $opened_tab = $hrpid;
             $hrpid = $aux;
@@ -337,6 +337,9 @@ class ProfileModule extends PLModule
         if ($viewPrivate) {
             $wiz->addPage('ProfilePageMentor', 'Mentoring', 'mentor');
         }
+        if ($viewPrivate) {
+            $wiz->addPage('ProfilePageManageurs', 'Manageurs.com', 'manageurs');
+        }
         if ($viewPrivate && $profile->isDeltatenEnabled(Profile::DELTATEN_OLD)) {
             $wiz->addPage('ProfilePageDeltaten', 'Opération N N-10', 'deltaten');
         }
diff --git a/modules/profile/manageurs.inc.php b/modules/profile/manageurs.inc.php
new file mode 100644 (file)
index 0000000..112222b
--- /dev/null
@@ -0,0 +1,205 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2014 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+class ProfileSettingManageurs implements ProfileSetting
+{
+    public function value(ProfilePage $page, $field, $value, &$success)
+    {
+        $success = true;
+        return $value;
+    }
+
+    public function save(ProfilePage $page, $field, $value)
+    {
+    }
+
+    public function getText($value) {
+    }
+}
+
+class ProfileSettingManageursNetwork implements ProfileSetting
+{
+    public function value(ProfilePage $page, $field, $value, &$success)
+    {
+        $success = true;
+        if (is_null($value)) {
+            $value = array();
+            $res = XDB::iterRow("SELECT  m.country, gc.country
+                                   FROM  profile_mentor_country AS m
+                             INNER JOIN  geoloc_countries       AS gc ON (m.country = gc.iso_3166_1_a2)
+                                  WHERE  m.pid = {?}",
+                                $page->pid());
+            while (list($id, $name) = $res->next()) {
+                $value[$id] = $name;
+            }
+        } else if (!is_array($value)) {
+            $value = array();
+        } else if (count($value) > 10) {
+            Platal::page()->trigError("Le nombre de secteurs d'expertise est limité à 10");
+            $success = false;
+        }
+        ksort($value);
+        return $value;
+    }
+
+    public function save(ProfilePage $page, $field, $value)
+    {
+        XDB::execute("DELETE FROM  profile_mentor_country
+                            WHERE  pid = {?}",
+                     $page->pid());
+        foreach ($value as $id=>&$name) {
+            XDB::execute("INSERT INTO  profile_mentor_country (pid, country)
+                               VALUES  ({?}, {?})",
+                         $page->pid(), $id);
+        }
+    }
+
+    public function getText($value) {
+        return implode(', ', $value);
+    }
+}
+
+class ProfilePageManageurs extends ProfilePage
+{
+    protected $pg_template = 'profile/manageurs.tpl';
+
+    public function __construct(PlWizard $wiz)
+    {
+        parent::__construct($wiz);
+        $this->settings['manageurs_title'] = null;
+        $this->settings['manageurs_entry_year'] = null;
+        $this->settings['manageurs_project'] = null;
+        $this->settings['manageurs_visibility'] = null;
+        $this->settings['manageurs_email'] = null;
+        $this->settings['manageurs_push'] = null;
+        $this->settings['manageurs_anonymity'] = null;
+        $this->settings['manageurs_novelty'] = null;
+        $this->settings['manageurs_nl'] = null;
+        $this->settings['manageurs_survey'] = null;
+        $this->settings['manageurs_network'] = null;
+    }
+
+    protected function _fetchData()
+    {
+        $res = XDB::query("SELECT  title AS manageurs_title, entry_year AS manageurs_entry_year, project AS manageurs_project,
+                                   anonymity AS manageurs_anonymity, visibility AS manageurs_visibility, email AS manageurs_email,
+                                   communication AS manageurs_communication, push AS manageurs_push, network AS manageurs_network
+                             FROM  profile_manageurs
+                            WHERE  pid = {?}",
+                          $this->pid());
+        $this->values = $res->fetchOneAssoc();
+
+        $this->values['manageurs_anonymity'] = $this->values['manageurs_anonymity'] == 1; 
+
+        $communication = explode(',', $this->values['manageurs_communication']);
+
+        $this->values['manageurs_novelty'] = in_array('novelties', $communication);
+        $this->values['manageurs_nl'] = in_array('nl',$communication);
+        $this->values['manageurs_survey'] = in_array('survey',$communication);
+
+        $this->values['manageurs_network'] = $this->values['manageurs_network'] == 1;
+    }
+
+    protected function _saveData()
+    {
+        if ($this->changed['manageurs_title']) {
+          XDB::execute('UPDATE profile_manageurs
+                           SET title = {?}
+                         WHERE pid = {?}',
+                        $this->values['manageurs_title'], $this->pid());
+        }
+
+        if ($this->changed['manageurs_entry_year']) {
+          XDB::execute('UPDATE profile_manageurs
+                           SET entry_year = {?}
+                         WHERE pid = {?}',
+                        $this->values['manageurs_entry_year'], $this->pid());
+        }
+
+        if ($this->changed['manageurs_project']) {
+          XDB::execute('UPDATE profile_manageurs
+                           SET project = {?}
+                         WHERE pid = {?}',
+                        $this->values['manageurs_project'], $this->pid());
+        }
+
+        if ($this->changed['manageurs_visibility']) {
+          XDB::execute('UPDATE profile_manageurs
+                           SET visibility = {?}
+                         WHERE pid = {?}',
+                        $this->values['manageurs_visibility'], $this->pid());
+        }
+
+        if ($this->changed['manageurs_email']) {
+          XDB::execute('UPDATE profile_manageurs
+                           SET email = {?}
+                         WHERE pid = {?}',
+                        $this->values['manageurs_email'], $this->pid());
+        }
+
+        if ($this->changed['manageurs_push']) {
+          XDB::execute('UPDATE profile_manageurs
+                           SET push = {?}
+                         WHERE pid = {?}',
+                        $this->values['manageurs_push'], $this->pid());
+        }
+
+        if ($this->changed['manageurs_anonymity']) {
+          XDB::execute('UPDATE profile_manageurs
+                           SET anonymity = {?}
+                         WHERE pid = {?}',
+                        $this->values['manageurs_anonymity'], $this->pid());
+        }
+
+        if ($this->changed['manageurs_novelty'] || $this->changed['manageurs_nl'] || $this->changed['manageurs_survey']) {
+            $communication = array();
+            if ($this->values['manageurs_novelty']) {
+                $communication[] = 'novelties';
+            }
+            if ($this->values['manageurs_nl']) {
+                $communication[] = 'nl';
+            }
+            if ($this->values['manageurs_survey']) {
+                $communication[] = 'survey';
+            }
+            $communicationStr = implode(',', $communication);
+            
+          XDB::execute('UPDATE profile_manageurs
+                           SET communication = {?}
+                         WHERE pid = {?}',
+                        $communicationStr, $this->pid());
+        }
+
+        if ($this->changed['manageurs_network']) {
+          XDB::execute('UPDATE profile_manageurs
+                           SET network = {?}
+                         WHERE pid = {?}',
+                        $this->values['manageurs_network'], $this->pid());
+        }
+    }
+
+    public function _prepare(PlPage $page, $id)
+    {
+    }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
+?>
index fd13c93..7d5bf2a 100644 (file)
@@ -436,6 +436,7 @@ require_once dirname(__FILE__) . '/groups.inc.php';
 require_once dirname(__FILE__) . '/decos.inc.php';
 require_once dirname(__FILE__) . '/jobs.inc.php';
 require_once dirname(__FILE__) . '/mentor.inc.php';
+require_once dirname(__FILE__) . '/manageurs.inc.php';
 require_once dirname(__FILE__) . '/deltaten.inc.php';
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
diff --git a/templates/profile/manageurs.tpl b/templates/profile/manageurs.tpl
new file mode 100644 (file)
index 0000000..66660dd
--- /dev/null
@@ -0,0 +1,198 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2014 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+<div> {icon name=information title="Afficher ma fiche Manageurs"}Tu peux consulter ta <a href="http://www.manageurs.com/anciens_mesCV.php">fiche professionnelle</a> sur Manageurs.com.
+</div>
+<table class="bicol" id="manageurs_profile" style="margin-bottom: 1em">
+  <tr>
+    <th colspan='2'>
+      <div class="flags" style="float: left">
+        <input type="checkbox" name="accesManageurs" checked="checked" disabled="disabled" />
+        {icon name="vcard" title="Manageurs"}
+      </div>
+      Profil Manageurs.com
+    </th>
+  </tr>
+  <tr>
+    <td>
+      <span class="titre">Intitulé du profil&nbsp;:</span>
+    </td>
+    <td>
+      <input type="text" name="manageurs_title" value="{$manageurs_title}" size="49" />
+    </td>
+  </tr>
+  <tr>
+    <td>
+      <span class="titre">Année de début d'activité professionnelle&nbsp;:</span>
+    </td>
+    <td>
+      <input type="text" name="manageurs_entry_year" value="{$manageurs_entry_year}" size="4" maxlength="4" />
+      <small>(par exemple&nbsp;: 2008)</small>
+    </td>
+  </tr>
+  <tr>
+    <td>
+      <span class="titre">Projet professionnel</span>
+    </td>
+    <td>
+      <textarea rows="8" cols="60" name="manageurs_project">{$manageurs_project}</textarea>
+    </td>
+  </tr>
+</table>
+<table class="bicol" id="manageurs_prefs" style="magin-bottom: 1em">
+  <tr>
+    <th colspan='2'>
+      <div class="flags" style="float: left">
+        <input type="checkbox" name="accesManageurs" checked="checked" disabled="disabled" />
+        {icon name="vcard" title="Manageurs"}
+      </div>
+      Préférences Manageurs.com
+    </th>
+  </tr>
+  <tr>
+    <td>
+      <span class="titre">Mon profil doit être&nbsp;:</span>
+    </td>
+    <td>
+      <div>
+        <label>
+          <input type="radio" name="manageurs_anonymity" value="0"
+            {if !$manageurs_anonymity}checked="checked"{/if} />
+          nominatif
+        </label>
+        <label>
+          <input type="radio" name="manageurs_anonymity" value="1"
+            {if $manageurs_anonymity}checked="checked"{/if} />
+          anonyme
+        </label>
+      </div>
+    </td>
+  </tr>
+  <tr>
+    <td>
+      <span class="titre">Visibilité auprès des entreprises&nbsp;:</span>
+    </td>
+    <td>
+      <div>
+        <label>
+          <input type="radio" name="manageurs_visibility" value="0"
+            {if $manageurs_visibility="visible"}checked="checked"{/if} />
+          Toutes les entreprises peuvent voir mon profil et me contacter.
+        </label>
+        <br />
+        <!-- TODO: implement a list of firms that are blacklisted
+        <label>
+          <input type="radio" name="manageurs_visibility" value="1"
+            {if $manageurs_visibility="visible_exceptions"}checked="checked"{/if} />
+          Les entreprises peuvent voir mon profil à l'exception de :
+        </label>
+        <br />
+        -->
+        <label>
+          <input type="radio" name="manageurs_visibility" value="2"
+            {if $manageurs_visibility="blocked"}checked="checked"{/if} />
+          Les entreprises ne peuvent pas voir mon profil.
+        </label>
+      </div>
+    </td>
+  </tr>
+  <tr>
+    <td>
+      <span class="titre">Email de contact</span>
+      <small>Les offres d'entreprises, les messages de diplômés et la communication Manageurs seront envoyés à cette adresse.</small>
+    </td>
+    <td>
+      <input type="text" name="manageurs_email" value="{$manageurs_email}" size="40" />
+    </td>
+  </tr>
+  <tr>
+    <td>
+      <span class="titre">Manageurs peut m'envoyer des emails&nbsp;</span>
+    </td>
+    <td>
+      <div>
+        <label>
+          <input type="checkbox" name="manageurs_novelty" {if $manageurs_novelty}checked="checked"{/if} />
+          sur les nouvelles fonctionnalités du site (ponctuellement).
+        </label>
+        <br />
+        <label>
+          <input type="checkbox" name="manageurs_nl" {if $manageurs_nl}checked="checked"{/if} />
+          dans une newsletter mensuelle (agenda, news, articles de fond…).
+        </label>
+        <br />
+        <label>
+          <input type="checkbox" name="manageurs_survey" {if $manageurs_survey}checked="checked"{/if} />
+          pour des sondages pour améliorer le site et mieux connaître la communauté.
+        </label>
+      </div>
+    </td>
+  </tr>
+  <tr>
+    <td>
+      <span class="titre">Offres personnalisées&nbsp;:</span>
+    </td>
+    <td>
+      <div>
+        <label>
+          <input type="radio" name="manageurs_push" value="0"
+            {if $manageurs_push="unique"}checked="checked"{/if} />
+          je reçois immédiatement un email par offre.
+        </label>
+        <br />
+        <label>
+          <input type="radio" name="manageurs_push" value="1"
+            {if $manageurs_push="weekly"}checked="checked"{/if} />
+          je reçois une compilation des offres 1 fois par semaine.
+        </label>
+        <br />
+        <label>
+          <input type="radio" name="manageurs_push" value="2"
+            {if $manageurs_push="never"}checked="checked"{/if} />
+          je ne reçois jamais d'email.
+        </label>
+      </div>
+    </td>
+  </tr>
+  <tr>
+    <td>
+     <span class="titre">Partage avec les autres diplômés&nbsp;:</span>
+    </td>
+    <td>
+      <div> 
+        <label>
+          <input type="radio" name="manageurs_network" value="0"
+            {if $manageurs_network}checked="checked"{/if} />
+          je souhaite partager mon profil et avoir accès aux profils partagés.
+        </label>
+        <br />
+        <label>
+          <input type="radio" name="manageurs_network" value="1"
+            {if !$manageurs_network}checked="checked"{/if} />
+          je ne souhaite pas partager mon profil et je n'ai pas accès aux profils partagés.
+        </label>
+      </div>
+    </td>
+  </tr>
+</table>
+
+{* vim:set et sw=2 sts=2 sws=2 fenc=utf-8: *}
index 894995c..13c513a 100644 (file)
@@ -3,12 +3,12 @@ CREATE TABLE profile_manageurs (
     title VARCHAR(255) NOT NULL DEFAULT '',
     entry_year INT(4) NULL DEFAULT NULL,
     project MEDIUMTEXT NULL DEFAULT NULL,
-    anonymity INT(1) UNSIGNED NOT NULL DEFAULT 0,
+    anonymity TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
     visibility ENUM('visible', 'visible_exceptions', 'blocked') NOT NULL DEFAULT 'blocked',
+    email VARCHAR(255) NOT NULL DEFAULT '',
     communication SET('novelties', 'nl', 'survey') NOT NULL DEFAULT '',
     push ENUM('unique', 'weekly', 'never') NOT NULL DEFAULT 'never',
-    email VARCHAR(255) NOT NULL DEFAULT '',
-    network INT(1) UNSIGNED NOT NULL DEFAULT 0,
+    network TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
     PRIMARY KEY (pid),
     CONSTRAINT FOREIGN KEY (pid) REFERENCES profiles (pid) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;