TVProjects top



TVProjects bottom
You are not registered.
Registration allows you to subscribe to projects, open projects, and more. Click here to register.

Website Source Code
<< Back

subscriptions.php

<?php
    
function get_subscriptions()
    {
        global 
$logged_user;
        
        if (
$logged_user == -1)
            return 
'<div style="font-style: italic">Please log in.</div>';
        
        
$user get_user($logged_user);
        
$subs $user[3];
        
$ex explode(';'$subs);
        if (
$ex[0] == '')
            
$ex[0] = 0;
        
        if (
sizeof($ex) == 1)
            
$vars['PROJECTS'] = 'You have no subscriptions. If you want to subscribe to a project, go to the project page.';
        else
        {
            
$vars['PROJECTS'] = '';
            for (
$i 1$i sizeof($ex); $i += 2)
            {
                
$result mysql_query('SELECT `name`, `category` FROM `projects` WHERE `id` = ' $ex[$i] . ';');
                
$row mysql_fetch_assoc($result);
                
                
$vars['PROJECTS'] .= '<div style="text-decoration: italic"><img src="images/arrow.png" alt="arrow" style="text-align: center" /> <a href="' create_link($row['category'], $ex[$i], $row['name']) . '">' escape_html($row['name']) . '</a></div>';
                
$vars['PROJECTS'] .= ($ex[$i+1] & 1) ? get_subs_item('News') : '';
                
$vars['PROJECTS'] .= ($ex[$i+1] & 2) ? get_subs_item('News Comment') : '';
                
$vars['PROJECTS'] .= ($ex[$i+1] & 4) ? get_subs_item('Media Comment') : '';
                
$vars['PROJECTS'] .= ($ex[$i+1] & 8) ? get_subs_item('Bug Report') : '';
                
$vars['PROJECTS'] .= ($ex[$i+1] & 16) ? get_subs_item('Bug Status Change') : '';
                
$vars['PROJECTS'] .= ($ex[$i+1] & 32) ? get_subs_item('Media Uploaded') : '';
                
$vars['PROJECTS'] .= '<br />';
            }
        }
        
        if (isset(
$_POST['sent']))
        {
            
$ex[0] = 0;
            if (
$_POST['new_projects'])
                
$ex[0] += 1;
            
            if (
$_POST['new_news'])
                
$ex[0] += 2;
                
            if (
$_POST['new_users'])
                
$ex[0] += 4;
                
            
$new $ex[0];
            for (
$i 1$i sizeof($ex); $i++)
                
$new .= ';' $ex[$i];
            
            
mysql_query('UPDATE `users` SET `subscriptions` = \'' $new '\' WHERE `id` = ' $logged_user ' LIMIT 1;');
        }
        
        
$vars['C_PRJ'] = ($ex[0] & 1) ? ' checked="checked"' '';
        
$vars['C_NEW'] = ($ex[0] & 2) ? ' checked="checked"' '';
        
$vars['C_USR'] = ($ex[0] & 4) ? ' checked="checked"' '';
        
        return 
get_template('subscriptions'$vars);
    }
    
    function 
get_subs_item($name)
    {
        return 
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=\"images/arrow.png\" alt=\"arrow\" style=\"text-align: center\" />&nbsp;<span style=\"font-size: 13px\">$name</span><br />";
    }
?>