Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

May 28, 2020, 11:28:08 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 190002
  • Total Topics: 20832
  • Online Today: 128
  • Online Ever: 917
  • (January 21, 2020, 09:02:26 AM)
Users Online
Users: 1
Guests: 71
Total: 72

Author Topic: Anyway to password protect articles?  (Read 12920 times)

0 Members and 1 Guest are viewing this topic.

Innocenzia

  • Guest
Re: Anyway to password protect articles?
« Reply #10 on: January 22, 2008, 09:52:27 AM »
Thank you! :) Is it possible to take it to the next step, and instead of showing different text actually adding different articles, in the existing article? So the guest will see one article, and members another, and the administrator doesn't have to go into the top-article to change the code, so that the guest-article and the member-article could be written by different people.
And taking another step further into it all, is it possible to add another article to all with admin-access, and another to a certain user. For example, i want to add an article only viewable to the member named Jenny? Is there some kind of list with all this variables written somewhere?  I'm sorry for bothering with questions but I'm trying to learn more about this and is trying to get it as easy as possible for my other administrators to change articles, and they would mess the php-article up totally I'm afraid.

Offline IchBin™

  • Developer
  • *
  • Posts: 16228
    • My Website
Re: Anyway to password protect articles?
« Reply #11 on: January 22, 2008, 01:23:58 PM »
No, thats not really possible. You'd have to refresh and redirect the whole page to make another article appear per user group.

Innocenzia

  • Guest
Re: Anyway to password protect articles?
« Reply #12 on: January 24, 2008, 10:43:20 AM »
Ah, I see. Thank you for answering my question.

MTF95

  • Guest
Re: Anyway to password protect articles?
« Reply #13 on: June 02, 2008, 05:11:56 AM »
What about the users whitout permission, what will they see?
There's no error message in the code..
Could I do like this:

global $user_info;

if (count(array_intersect(array(allowed groups), $user_info['groups'])))
{
   echo 'Allowed groups will se this.';
}
global $user_info;

if (count(array_intersect(array(not allowed groups), $user_info['groups'])))
{
   echo 'Not allowed groups will se this.';
}


Or is there a simpler way?

Offline IchBin™

  • Developer
  • *
  • Posts: 16228
    • My Website
Re: Anyway to password protect articles?
« Reply #14 on: June 02, 2008, 07:35:12 AM »
Users without permissions are guests. They will not see anything unless you specify something for theme  to see. You have some if statements for the groups. Add an else statement for guests.

Code: [Select]
else{
    echo 'all stuff here for guests if the user is not in a group.';
}

MTF95

  • Guest
Re: Anyway to password protect articles?
« Reply #15 on: June 02, 2008, 10:42:27 PM »
Now the articel just shows
Parse error: syntax error, unexpected T_ELSE in /home/simmarcu/public_html/Sources/Load.php(1870) : eval()'d code(209) : eval()'d code on line 11

Offline IchBin™

  • Developer
  • *
  • Posts: 16228
    • My Website
Re: Anyway to password protect articles?
« Reply #16 on: June 02, 2008, 10:55:03 PM »
Change the flux capacitor to zero, hit the take off button and make sure you reach 88 miles per hour!









Or help us help you by giving some information to work with. Preferably the code you are using so we can see the error you've made. :)

MTF95

  • Guest
Re: Anyway to password protect articles?
« Reply #17 on: June 03, 2008, 11:49:24 AM »
 global $user_info;

if (count(array_intersect(array(1,14,15,17,22), $user_info['groups'])))
{
   echo '

<B>Personalsidorna är ännu under uppbyggnad.</B>


Nedan ser du all personal på sidan, alltså dina kollegor!
';

else{
    echo 'all stuff here for guests if the user is not in a group.';
}
<span class="smalltext">Dessa medelmar är en del av Sim-Marcus personal och hjälper till på olika delar av sidan.</span>
';
}
 global $txt, $scripturl, $user_info;
   global $context, $modSettings, $ID_MEMBER;
   global $board_info, $settings, $db_prefix;

/////////////////////////////////////////////////////////////////  Enter the desired groups in order of Appearance
   $groups_list = array(1, 17, 14, 15, 22);
/////////////////////////////////////////////////////////////////

          echo '<table align="center" width="95%" cellpadding="0" cellspacing="0"><tr>
                <td style="border-bottom: 2px solid #d0d0d0; padding-bottom: 4px; ">
      


      </td></tr></table>';



   foreach($groups_list as $groupnumber)
   {

   $loaded_ids = array();
    $user_profile=array();
    $memberContext=array();
    $profile=array();
    $context['TPortal']['team']=array();

   // get the name of the group
   $request = db_query("
                        SELECT groupName, onlineColor FROM {$db_prefix}membergroups WHERE ID_GROUP=".$groupnumber, __FILE__, __LINE__);
      $row = mysql_fetch_assoc($request);
      $groupname = $row['groupName'];;
      $grpcolor=$row['onlineColor'];
      mysql_free_result($request);

   $select_columns = "
         IFNULL(lo.logTime, 0) AS isOnline, IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename, a.attachmentType,
         mem.personalText, mem.avatar, mem.ID_MEMBER, mem.memberName,
         mem.realName,mem.lastLogin, mem.websiteTitle, mem.websiteUrl, mem.location,   
                        mem.posts,
                        them.value AS teamtext";
   $select_tables = "
         LEFT JOIN {$db_prefix}log_online AS lo ON (lo.ID_MEMBER = mem.ID_MEMBER)
         LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = mem.ID_MEMBER)
                        LEFT JOIN {$db_prefix}themes AS them ON (mem.ID_MEMBER = them.ID_MEMBER AND them.variable = 'teamtext' AND them.ID_THEME=1)";

   // Load the member's data.
   $request = db_query("
         SELECT$select_columns
         FROM {$db_prefix}members AS mem$select_tables
         WHERE mem.ID_GROUP = $groupnumber
                        ORDER BY mem.memberName ASC", __FILE__, __LINE__);
   $new_loaded_ids = array();
   while ($row = mysql_fetch_assoc($request))
   {

         $avatar_width = '';
         $avatar_height = '';

      $context['TPortal']['team'][] = array(
      'username' => $row['memberName'],
      'name' => $row['realName'],
      'groupname' => $groupname,
      'posts' => $row['posts'],
      'location' => $row['location'],
      'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
      'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['realName'] . '"><font color="'.$grpcolor.'">' . $row['realName'] . '</font>[/url]',
      'blurb' => $row['personalText'],
      'avatar' => array(
         'name' => $row['avatar'],
         'image' => $row['avatar'] == '' ? ($row['ID_ATTACH'] > 0 ? '<img  src="' . (empty($row['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" class="avatar2" border="0" />' : '') : (stristr($row['avatar'], 'http://') ? '<img src="' . $row['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar2" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" class="avatar2" border="0" />'),
         'href' => $row['avatar'] == '' ? ($row['ID_ATTACH'] > 0 ? (empty($row['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) : '') : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar']),
         'url' => $row['avatar'] == '' ? '' : (stristr($row['avatar'], 'http://') ? $row['avatar'] : $modSettings['avatar_url'] . '/' . $row['avatar'])
      ),
      'last_login' => empty($row['lastLogin']) ? $txt['never'] : timeformat($row['lastLogin']),
      'last_login_timestamp' => empty($row['lastLogin']) ? 0 : forum_time(0, $row['lastLogin']),
      'website' => array(
         'title' => $row['websiteTitle'],
         'url' => $row['websiteUrl']),
      'online' => array(
         'is_online' => $row['isOnline'],
         'text' => &$txt[$row['isOnline'] ? 'online2' : 'online3'],
         'image_href' => $settings['images_url'] . '/' . ($row['isOnline'] ? 'useron' : 'useroff') . '.gif',
      ),
      'teamtext' => $row['teamtext'],
   );


   }
   mysql_free_result($request);





      echo '<table align="center" width="95%" cellpadding="5" cellspacing="5"><tr>
            <td colspan="4" style="border-bottom: 2px solid #d0d0d0; padding-bottom: 4px; "><h2>' . $groupname . '</h2>
            </td></tr><tr><td colspan="4">
 </td></tr><tr>';


        $newrow=0;
   foreach($context['TPortal']['team'] as $team)
        {
            echo '
<td valign="top">'.$team['avatar']['image'].'</td>
<td valign="top" width="50%" class="middletext" style="padding: 5px;">
<h2 style="margin-top: 0; margin-bottom: 6px;">'.$team['link'].'</h2>
Last seen: '.$team['last_login'].'

Posts: '.$team['posts'].'

Position: '.$team['groupname'].'

' , !empty($team['location']) ? 'Location: '.$team['location'].'
' : '' , '
' , !empty($team['website']['title']) ? 'Website: <a href="'.$team['website']['url'].'" target="_blank">'.$team['website']['title'].'[/url]
' : '' , '
' ,  $team['online']['is_online'] ? '<img src="'.$team['online']['image_href'].'" alt="" /> '.$team['online']['text'].'
' : $team['online']['text'].'
' , '

' , !empty($team['blurb']) ? '- '.$team['blurb'].'
' : '' , '

' ,  !empty($team['teamtext']) ? $team['teamtext'].'
' : '' , '

    </div></td>';
            $newrow++;
            if($newrow>1){
               $newrow=0;
               echo '</tr><tr><td colspan="4">

 </td></tr><tr>';
            }
        }
    }
echo '</tr></table>';

JPDeni

  • Guest
Re: Anyway to password protect articles?
« Reply #18 on: June 03, 2008, 01:08:38 PM »
It would be a lot easier to read if you would use [ code ] tags, but it looks like you're missing a closing } in your first "if" statement. It should be

Code: [Select]
if (count(array_intersect(array(1,14,15,17,22), $user_info['groups'])))
{
    echo '
  <B>Personalsidorna är ännu under uppbyggnad.</B>
  Nedan ser du all personal pÃ¥ sidan, alltsÃ¥ dina kollegor!';
}
else{
    echo 'all stuff here for guests if the user is not in a group.';
}
<span class="smalltext">Dessa medelmar är en del av Sim-Marcus personal och hjälper till på olika delar av sidan.</span>
';

Polymath

  • Guest
Re: Anyway to password protect articles?
« Reply #19 on: September 23, 2008, 10:50:27 PM »
Change the flux capacitor to zero, hit the take off button and make sure you reach 88 miles per hour!

 :2funny:  That didn't work!!