Changeset 27458


Ignore:
Timestamp:
Feb 23, 2014, 9:08:38 AM (7 years ago)
Author:
ddtddt
Message:

[extensions] - Photo_add_by - if plugin see photo by user is actif - can show link on user on picture page with parameter plugin see photo by user

Location:
extensions/Photo_add_by
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/Photo_add_by/admin/admin.php

    r21231 r27458  
    4545        $options['Average'] = l10n('Rating score');
    4646
    47        
    48 
    4947  $template->assign(
    5048    'gestionA',
    5149    array(
    5250      'OPTIONS' => $options,
    53       'SELECTED' => $selected
     51      'SELECTED' => $selected,
    5452      ));
    55    
    5653
    57 if (isset($_POST['infopab']))
     54$PASPBY = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'see_photos_by_user';"));
     55if($PASPBY['state'] == 'active')
     56{
     57$PABS2T = array(
     58    l10n('No'),
     59    l10n('Yes'),
     60  );
     61 
     62$PABS2 = array(
     63    '0',
     64    '1',
     65  );
     66
     67  $template->assign(
     68    'gestionB',
     69    array(
     70          'TOTO' => 'toto',
     71      ));
     72            global $conf;
     73$template->assign('pabs2', $PABS2);
     74$template->assign('pabs2t', $PABS2T);
     75$template->assign('PABS', $conf['Photo_add_by_show']);
     76         
     77}
     78
     79if (isset($_POST['submitpab']))
    5880        {
    5981conf_update_param('Photo_add_by', $_POST['infopab']);
     82if($PASPBY['state'] == 'active')
     83{
     84conf_update_param('Photo_add_by_show', $_POST['inspabs2']);
     85  $template->assign(
     86    'gestionB',
     87    array(
     88          'TOTO' => 'toto',
     89      ));
     90$template->assign('PABS', $_POST['inspabs2']);
     91}
    6092$template->delete_compiled_templates();
    6193array_push($page['infos'], l10n('Your configuration settings are saved'));
     
    6698    array(
    6799      'OPTIONS' => $options,
    68       'SELECTED' => $selected
     100      'SELECTED' => $selected,
    69101      ));
    70    
    71 
    72 
    73102        }
    74103  break;
  • extensions/Photo_add_by/admin/admin.tpl

    r21231 r27458  
    33</div>
    44{if isset ($gestionA)}
    5         <div>
    6                 <form method="post" >
    7                         <fieldset>
    8                                 <legend>{'Add information before'|@translate}</legend>
    9                 {html_options name="infopab" options=$gestionA.OPTIONS selected=$gestionA.SELECTED}
    10                                 <br>   
    11                                 <br>
    12                                         <div style="text-align:center;">
    13                                         <input class="submit" name="submitpab" type="submit" value="{'Save Settings'|@translate}">
    14                                         </div>
    15                         </fieldset>
    16                 </form>
    17         </div>
     5<div>
     6<form method="post" >
     7<fieldset>
     8<legend></legend>
     9 <p>
     10  <strong>{'Add information before'|@translate}</strong>
     11  {html_options name="infopab" options=$gestionA.OPTIONS selected=$gestionA.SELECTED}
     12 </p>
     13{if isset ($gestionB)}
     14 <p>
     15  <strong>{'Link on users'|@translate}</strong>
     16  {html_options name="inspabs2" values=$pabs2 output=$pabs2t selected="{$PABS}"}
     17  ({'parameter show from the plugin'|@translate} "{'See photos by user'|@translate}")
     18 </p>
    1819{/if}
     20 <p>
     21  <div style="text-align:center;">
     22  <input class="submit" name="submitpab" type="submit" value="{'Save Settings'|@translate}">
     23  </div>
     24 </p>
     25</fieldset>
     26</form>
     27</div>
     28{/if}
  • extensions/Photo_add_by/initpicture.php

    r26560 r27458  
    1717 
    1818  $search = '#<div id="'.$conf['Photo_add_by'].'" class="imageInfo">#';
    19  
     19
    2020  $replacement = '
    2121  {if $PAB}
     
    4949$row = pwg_db_fetch_assoc($result);
    5050$userab=$row['added_by'];
    51  
     51
    5252  $query = '
    5353select '.$conf['user_fields']['username'].' AS username
     
    5959$pab=$row['username'];
    6060
     61$PASPBY = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'see_photos_by_user';"));
     62$showpab = $conf['Photo_add_by_show'];
     63if($showpab == 1 and $PASPBY['state'] == 'active')
     64{
     65$query2 = '
     66SELECT UT.id, UT.username, COUNT(DISTINCT(IT.id)) AS PBU, IT.id
     67 FROM ' . USERS_TABLE . ' as UT
     68 INNER JOIN '.IMAGES_TABLE.' AS IT ON IT.added_by = UT.id
     69 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON IT.id = ic.image_id
     70  '.get_sql_condition_FandF
     71  (
     72    array
     73      (
     74        'forbidden_categories' => 'category_id',
     75        'visible_categories' => 'category_id',
     76        'visible_images' => 'id'
     77      ),
     78    'WHERE'
     79  ).'
     80 GROUP BY IT.added_by
     81 HAVING PBU >'.$conf['see_photos_by_user_nbphotos'].'
     82 ORDER BY '.$conf['see_photos_by_user_order'].'
     83 LIMIT '.$conf['see_photos_by_user_limit'].';';
    6184
    62     // Envoi des données au template
    63             $template->assign   (
    64                 array   (
    65                 'PAB' => $pab,
    66                                 )                       );
     85$result2 = pwg_query($query2);
     86
     87$userok = array();
     88while ($row2 = pwg_db_fetch_assoc($result2))
     89 {
     90  $userok[] = $row2['username'];
     91}
     92if(in_array($pab, $userok) and $showpab == 1 and $PASPBY['state'] == 'active')
     93{
     94$urlpab = get_root_url().'index.php?/user-'.($pab);
     95$pab2 ='<a href="'.$urlpab.'">'.$pab.'</a>';
     96}
     97else
     98{
     99$pab2=$pab;
     100}
     101}
     102else
     103{
     104$pab2=$pab;
     105}
     106$template->assign(array('PAB' => $pab2,));
     107
    67108  }
    68109}
  • extensions/Photo_add_by/language/en_UK/plugin.lang.php

    r21231 r27458  
    22$lang['Photo added by'] = 'Photo added by';
    33$lang['Add information before'] = 'Add information before';
     4$lang['Link on users'] = 'Link on users';
     5$lang['parameter show from the plugin'] = 'parameter show from the plugin';
    46?>
  • extensions/Photo_add_by/language/fr_FR/plugin.lang.php

    r22050 r27458  
    22$lang['Photo added by'] = 'Photo Ajoutée par';
    33$lang['Add information before'] = 'Ajouter l\'information avant';
     4$lang['Link on users'] = 'Liens sur les utilisateurs';
     5$lang['parameter show from the plugin'] = 'Parametre d\'affichage issus du plugin';
    46?>
  • extensions/Photo_add_by/main.inc.php

    r21222 r27458  
    2626function PAB_admin_menu($menu)
    2727{
     28load_language('plugin.lang', PAB_PATH);
    2829  array_push($menu, array(
    29         'NAME' => 'Photo added by',
     30        'NAME' => l10n('Photo added by'),
    3031    'URL' => get_admin_plugin_menu_link(PAB_PATH . 'admin/admin.php')));
    3132  return $menu;
  • extensions/Photo_add_by/maintain.inc.php

    r21630 r27458  
    66function plugin_install()
    77{
    8         $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("Photo_add_by","datecreate","Photo_add_by");';
    9     pwg_query($query);
     8
    109}
    1110
     
    1312{
    1413  global $conf;
    15   if (empty($conf['Photo_add_by']))
    16   {
    17         $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) VALUES ("Photo_add_by","datecreate","Photo_add_by");';
    18     pwg_query($query);
    19   }
     14if (!isset($conf['Photo_add_by']))
     15 {
     16 conf_update_param('Photo_add_by', 'datecreate');
     17 }
     18if (!isset($conf['Photo_add_by_show']))
     19 {
     20 conf_update_param('Photo_add_by_show', '0');
     21 }
     22 
     23 
    2024}
    2125
     
    2327function plugin_uninstall()
    2428{
    25         $q = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param="Photo_add_by" LIMIT 1;';
    26     pwg_query($q);
     29        conf_delete_param('Photo_add_by_show','Photo_add_by');
    2730}
    2831?>
Note: See TracChangeset for help on using the changeset viewer.