Fixes AX profile edition for general, address and job pages.
authorStéphane Jacob <sj@m4x.org>
Mon, 31 Oct 2011 22:05:52 +0000 (23:05 +0100)
committerStéphane Jacob <sj@m4x.org>
Mon, 31 Oct 2011 22:05:52 +0000 (23:05 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
classes/address.php
modules/profile/addresses.inc.php
modules/profile/jobs.inc.php
modules/profile/page.inc.php
templates/geoloc/form.address.tpl
templates/profile/adresses.address.tpl
templates/profile/jobs.job.tpl

index 18f752e..8423f9a 100644 (file)
@@ -896,6 +896,7 @@ class Address
 class AddressIterator implements PlIterator
 {
     private $dbiter;
+    private $visibility;
 
     public function __construct(array $pids, array $types, array $jobids, $visibility, $_where)
     {
@@ -936,6 +937,7 @@ class AddressIterator implements PlIterator
               GROUP BY  pa.pid, pa.jobid, pa.groupid, pa.type, pa.id
               ORDER BY  pa.pid, pa.jobid, pa.id';
         $this->dbiter = XDB::iterator($sql, $visibility->level());
+        $this->visibility = $visibility;
     }
 
     public function next()
@@ -948,7 +950,7 @@ class AddressIterator implements PlIterator
             return null;
         }
         // Adds phones to addresses.
-        $it = Phone::iterate(array($data['pid']), array(Phone::LINK_ADDRESS), array($data['id']));
+        $it = Phone::iterate(array($data['pid']), array(Phone::LINK_ADDRESS), array($data['id']), $this->visibility);
         while ($phone = $it->next()) {
             $data['phones'][$phone->id] = $phone->toFormArray();
         }
index 50f86fd..3a7c52a 100644 (file)
@@ -27,7 +27,7 @@ class ProfileSettingAddresses implements ProfileSetting
         $addresses = array();
 
         if (is_null($value)) {
-            $it = Address::iterate(array($page->pid()), array(Address::LINK_PROFILE), array(0));
+            $it = Address::iterate(array($page->pid()), array(Address::LINK_PROFILE), array(0), Visibility::get(Visibility::VIEW_PRIVATE));
             while ($address = $it->next()) {
                 $addresses[] = $address->toFormArray();
             }
index 268d5f3..eada2bd 100644 (file)
@@ -86,11 +86,11 @@ class ProfileSettingJob implements ProfileSetting
             $backtrack[$job['id']] = $key;
         }
 
-        $it = Address::iterate(array($page->pid()), array(Address::LINK_JOB));
+        $it = Address::iterate(array($page->pid()), array(Address::LINK_JOB), array(), Visibility::get(Visibility::VIEW_PRIVATE));
         while ($address = $it->next()) {
             $jobs[$address->id]['w_address'] = $address->toFormArray();
         }
-        $it = Phone::iterate(array($page->pid()), array(Phone::LINK_JOB));
+        $it = Phone::iterate(array($page->pid()), array(Phone::LINK_JOB), array(), Visibility::get(Visibility::VIEW_PRIVATE));
         while ($phone = $it->next()) {
             $jobs[$phone->link_id]['w_phone'][$phone->id] = $phone->toFormArray();
         }
index f9e93a4..76be815 100644 (file)
@@ -108,7 +108,7 @@ class ProfileSettingPhones implements ProfileSetting
         $phones = array();
 
         if (is_null($value)) {
-            $it = Phone::iterate(array($page->pid()), array(Phone::LINK_PROFILE), array(0));
+            $it = Phone::iterate(array($page->pid()), array(Phone::LINK_PROFILE), array(0), Visibility::get(Visibility::VIEW_PRIVATE));
             while ($phone = $it->next()) {
                 $success = ($phone->format() && $success);
                 $phones[] = $phone->toFormArray();
index b4add50..6400a19 100644 (file)
 <tr{if t($class)} class="{$class}"{/if}>
   <td>
 {/if}
+    {if !t($hiddenaddr)}
     <textarea name="{$prefname}[text]" cols="30" rows="4" onchange="addressChanged('{$prefid}','{$profile->promoColor()}')">{$address.text}</textarea>
+    {else}
+    <input type="hidden" name="{$prefname}[text]" value="{$address.text}" />
+    {/if}
     <input type="hidden" name="{$prefname}[postalText]" value="{$address.postalText}" />
     <input type="hidden" name="{$prefname}[types]" value="{$address.types}" />
     <input type="hidden" name="{$prefname}[formatted_address]" value="{$address.formatted_address}" />
@@ -52,6 +56,7 @@
   </td>
   <td>
 {/if}
+  {if !t($hiddenaddr)}
   <div id="{$prefid}_static_map_url" {if !t($address.componentsIds)}style="display: none"{/if}>
     <img src="{insert name="getStaticMapURL" latitude=$address.latitude longitude=$address.longitude color=$profile->promoColor()}" alt="Position de l'adresse" />
     {if t($geocoding_removal)}
@@ -66,6 +71,7 @@
     </small>
     {/if}
   </div>
+  {/if}
 {if t($validation)}
 </div>
 <div style="clear: both"></div>
index 7f32152..806ba81 100644 (file)
@@ -61,7 +61,7 @@
       {include file="include/flags.radio.tpl" name="`$prefname`[pub]" val=$address.pub mainField='addresses' mainId=$i subField='phones' subId=-1}
     </td>
   </tr>
-  {include file="geoloc/form.address.tpl" prefname=$prefname prefid=$prefid address=$address id=$i}
+  {include file="geoloc/form.address.tpl" prefname=$prefname prefid=$prefid address=$address id=$i hiddenaddr=$hiddenaddr}
   <tr {if $hiddenaddr}style="display: none"{/if}>
   {if !$isMe}
     <td>
index 747347b..7872b0d 100644 (file)
       </td>
     </tr>
     {include file="geoloc/form.address.tpl" prefname="`$jobpref`[w_address]"
-                     prefid=$jobid address=$job.w_address class="pair"}
+                     prefid=$jobid address=$job.w_address class="pair" hiddenaddr=$hiddenaddr}
     <tr class="pair" {if $hiddenjob || $hiddenaddr}style="display: none"{/if}>
       <td colspan="2">
         <label>