Merge remote branch 'origin/xorg/1.0.2/master' into xorg/master
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 2 Dec 2010 21:06:05 +0000 (22:06 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 2 Dec 2010 21:06:05 +0000 (22:06 +0100)
1  2 
htdocs/javascript/profile.js
modules/admin.php
modules/profile.php
modules/xnetgrp.php

@@@ -71,12 -71,10 +71,12 @@@ function addSearchName(isFemale
      while ($('#search_name_' + i).length != 0) {
          i++;
      }
 -    Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i + '/' + isFemale, function(data){
 -        $('#searchname').before(data);
 -        changeNameFlag(i);
 -    });
 +    $('#search_name_' + i)
 +        .updateHtml('profile/ajax/searchname/' + i + '/' + isFemale,
 +                    function(data) {
 +                        $('#searchname').before(data);
 +                        changeNameFlag(i);
 +                    });
  }
  
  function removeSearchName(i, isFemale)
@@@ -113,12 -111,11 +113,12 @@@ function updateNameDisplay(isFemale
              searchnames += $('#search_name_' + i).find(':text').val() + ';;';
          }
      }
 -    Ajax.update_html(null, 'profile/ajax/buildnames/' + searchnames + '/' + isFemale, function(data){
 -        var name = data.split(';');
 -        $('#public_name').html(name[0]);
 -        $('#private_name').html(name[0] + name[1]);
 -    });
 +    $.xget('profile/ajax/buildnames/' + searchnames + '/' + isFemale,
 +           function(data){
 +               var name = data.split(';');
 +               $('#public_name').html(name[0]);
 +               $('#private_name').html(name[0] + name[1]);
 +           });
  }
  
  function toggleParticle(id)
@@@ -318,8 -315,7 +318,8 @@@ function addAddress(
          i++;
      }
      $('#add_address').before('<div id="addresses_' + i + '_cont"></div>');
 -    Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress());
 +    $('#addresses_' + i + '_cont').updateHtml('profile/ajax/address/' + i,
 +                                              checkCurrentAddress());
  }
  
  function addressChanged(prefid)
@@@ -331,11 -327,10 +331,10 @@@ function validGeoloc(prefid, id, geoloc
  {
      if (geoloc == 1) {
          $('#' + prefid + '_cont').find('[name*=text]').val($('#' + prefid + '_cont').find('[name*=geocodedText]').val());
-         $('#' + prefid + '_cont').find('[name*=postalText]').val($('#' + prefid + '_cont').find('[name*=geocodedPostalText]').val());
+         $('#' + prefid + '_cont').find('[name*=postalText]').val('');
      }
      if (geoloc > 0) {
          $('#' + prefid + '_cont').find("[name*='[geocodedText]']").remove();
-         $('#' + prefid + '_cont').find("[name*='[geocodedPostalText]']").remove();
      }
      $('#' + prefid + '_cont').find('[name*=text]').removeClass('error');
      $('#' + prefid + '_cont').find('[name*=geocodeChosen]').val(geoloc);
@@@ -352,7 -347,7 +351,7 @@@ function addTel(prefid, prefname
          i++;
      }
      $('#' + prefix + 'add').before('<div id="' + prefix + i + '" style="clear: both; padding-top: 4px; padding-bottom: 4px"></div>');
 -    Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i);
 +    $('#' + prefix + i).updateHtml('profile/ajax/tel/' + prefid + '/' + prefname + '/' + i);
  }
  
  function removeTel(prefname, prefid, id)
diff --combined modules/admin.php
@@@ -127,6 -127,23 +127,6 @@@ class AdminModule extends PLModul
          $page->assign_by_ref('mails', $sql);
      }
  
 -    function handler_postfix_regexpsbounces(&$page, $new = null) {
 -        $page->changeTpl('admin/emails_bounces_re.tpl');
 -        $page->setTitle('Administration - Postfix : Regexps Bounces');
 -        $page->assign('new', $new);
 -
 -        if (Post::has('submit')) {
 -            foreach (Env::v('lvl') as $id=>$val) {
 -                XDB::query(
 -                        "REPLACE INTO emails_bounces_re (id,pos,lvl,re,text) VALUES ({?}, {?}, {?}, {?}, {?})",
 -                        $id, $_POST['pos'][$id], $_POST['lvl'][$id], $_POST['re'][$id], $_POST['text'][$id]
 -                );
 -            }
 -        }
 -
 -        $page->assign('bre', XDB::iterator("SELECT * FROM emails_bounces_re ORDER BY pos"));
 -    }
 -
      // {{{ logger view
  
      /** Retrieves the available days for a given year and month.
  
  
          $page->addJsLink('jquery.ui.core.js');
 +        $page->addJsLink('jquery.ui.widget.js');
          $page->addJsLink('jquery.ui.tabs.js');
          $page->addJsLink('password.js');
  
          $page->changeTpl('admin/validation.tpl');
          $page->setTitle('Administration - Valider une demande');
          $page->addCssLink('nl.css');
 -        $page->addJsLink('ajax.js');
  
          if ($action == 'edit' && !is_null($id)) {
              $page->assign('preview_id', $id);
              Phone::deletePhones(0, Phone::LINK_COMPANY, $id);
              Address::deleteAddresses(null, Address::LINK_COMPANY, $id);
              if (Env::has('change')) {
-                 XDB::execute('UPDATE  profile_job
-                                  SET  jobid = {?}
-                                WHERE  jobid = {?}',
-                              Env::i('newJobId'), $id);
-                 XDB::execute('DELETE FROM  profile_job_enum
-                                     WHERE  id = {?}',
-                              $id);
-                 $page->trigSuccess("L'entreprise a bien été remplacée.");
+                 if (Env::has('newJobId') && Env::i('newJobId') > 0) {
+                     XDB::execute('UPDATE  profile_job
+                                      SET  jobid = {?}
+                                    WHERE  jobid = {?}',
+                                  Env::i('newJobId'), $id);
+                     XDB::execute('DELETE FROM  profile_job_enum
+                                         WHERE  id = {?}',
+                                  $id);
+                     $page->trigSuccess("L'entreprise a bien été remplacée.");
+                 } else {
+                     $page->trigError("L'entreprise n'a pas été remplacée car l'identifiant fourni n'est pas valide.");
+                 }
              } else {
                  XDB::execute('UPDATE  profile_job_enum
                                   SET  name = {?}, acronym = {?}, url = {?}, email = {?},
                                           'link_type' => Phone::LINK_COMPANY, 'pub' => 'public'));
                  $fax = new Phone(array('display' => Env::v('fax'), 'link_id' => $id, 'id' => 1, 'type' => 'fax',
                                           'link_type' => Phone::LINK_COMPANY, 'pub' => 'public'));
-                 $address = new Address(array('jobid' => $jobid, 'type' => Address::LINK_COMPANY, 'text' => Env::t('address')));
+                 $address = new Address(array('jobid' => $id, 'type' => Address::LINK_COMPANY, 'text' => Env::t('address')));
                  $phone->save();
                  $fax->save();
                  $address->save();
diff --combined modules/profile.php
@@@ -318,6 -318,8 +318,8 @@@ class ProfileModule extends PLModul
              $opened_tab = $hrpid;
              $hrpid = $aux;
              $url_error = true;
+         } else {
+             $url_error = false;
          }
          $profile = $this->findProfile($hrpid);
          if (! ($profile instanceof Profile) && ($profile == PL_NOT_FOUND || $profile == PL_FORBIDDEN)) {
          }
  
          // Build the page
 -        $page->addJsLink('ajax.js');
          $page->addJsLink('education.js', false); /* dynamic content */
          $page->addJsLink('grades.js', false);    /* dynamic content */
          $page->addJsLink('profile.js');
diff --combined modules/xnetgrp.php
@@@ -193,7 -193,7 +193,7 @@@ class XnetGrpModule extends PLModul
                               flags={?}
                        WHERE  id={?}",
                        Post::v('nom'), Post::v('diminutif'),
-                       Post::v('cat'), Post::i('dom'),
+                       Post::v('cat'), (Post::i('dom') == 0) ? null : Post::i('dom'),
                        Post::v('descr'), $site,
                        Post::v('mail'), Post::v('resp'),
                        Post::v('forum'), Post::v('mail_domain'),
                             $globals->asso('mail_domain'));
          $page->assign('listes', $mmlist->get_lists());
          $page->assign('user', S::user());
 -        $page->addJsLink('ajax.js');
  
          if (Post::has('send')) {
              S::assert_xsrf_token();
          global $globals;
  
          $page->changeTpl('xnetgrp/membres-add.tpl');
 -        $page->addJsLink('ajax.js');
  
          if (is_null($email)) {
              return;