<?php
/*======================================================================*\
|| #################################################################### ||
|| # Plus Mood 1.0.0 - Free! # ||
|| # For 3.7.x AND 3.8.X # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright ©2006-2009 Plus Enterprises Ltd. All Rights Reserved. # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- Plus IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vb2plus.com/ | http://www.vb2plus.com/license.php # ||
|| #################################################################### ||
\*======================================================================*/
/**
* Plus Mood User Control Panel
*
* ÊÚáÃÂãÇÊÊÛÃÂÃÂÑ ãÒÇÌ ÇáÚÖæ ÃÂàáæÃÂÉ ÊÃÂßãå
*
* @package Plus Mood
* @author åÇäÃÂ
* @version Revision: 13
* @date Date: 2008-10-13 09:08:10
* @copyright http://www.vb2plus.com/
*
*/
if ($_REQUEST['do'] == 'editmood')
{
$vbulletin->input->clean_gpc('r', 'pagenumber', TYPE_UINT);
$mood_status = array();
if (!$vbulletin->options['plus_mood_enable'])
{
eval(standard_error(fetch_error('plus_mood_disabled')));
}
else if(!($mood_status = preg_split('#\r\n#', htmlspecialchars_uni($vbulletin->options['plus_mood_status']), -1, PREG_SPLIT_NO_EMPTY)))
{
eval(standard_error(fetch_error('plus_mood_status_nothing')));
}
// ############### DISPLAY USER'S MOOD ###############
if (!empty($vbulletin->userinfo['usermood']) AND ($vbulletin->userinfo['usermood'] != 'none') AND ($mooddetails = preg_split('#\|#', $vbulletin->userinfo['usermood'], -1, PREG_SPLIT_NO_EMPTY)) AND is_array($mooddetails))
{
$usermood = array (
'alt' => $mooddetails[0],
'img' => $mooddetails[1]
);
$moodid = $usermood['img'];
$moodchecked["$moodid"] = 'checked="checked"';
eval('$plus_mood_currentmood = "' . fetch_template('plus_mood_modifymoodbit') . '";');
}
if (!is_array($mooddetails))
{
$nousemoodchecked = 'checked="checked"';
$moodchecked[0] = '';
eval('$plus_mood_currentmood = "' . fetch_template('plus_mood_modifymoodbit_nomood') . '";');
$has_mood_for_now = true;
}
// variables that will become templates
$plus_mood_imglist = '';
$avatarcells = ''; // ãÇ ÃÂÃÂÊÇÌ äÓæàÞÇáÈ ÃŒÃÂÃÂà(;
$pagenav2 = '';
// ############### GET TOTAL NUMBER OF MOODS ###############
// get the total number of moods - the one he has
$totalmoods = ($has_mood_for_now ? count($mood_status) : (count($mood_status) - 1));
// get perpage parameters for table display
$perpage = $vbulletin->options['plus_mood_numperpage'];
sanitize_pageresults($totalmoods, $vbulletin->GPC['pagenumber'], $perpage, 100, 25);
// get parameters for query limits
$startat = ($vbulletin->GPC['pagenumber'] - 1) * $perpage; // 0
// make variables for 'displaying moods x to y of z' text
$first = $startat + 1; // 1
$last = $startat + $perpage;
if ($last > $totalmoods)
{
$last = $totalmoods;
}
// initialise the bg class
$bgclass = 'alt1';
// ############### DISPLAY PREDEFINED MOODS ###############
if ($totalmoods)
{
$pagenav = construct_page_nav($vbulletin->GPC['pagenumber'], $perpage, $totalmoods, 'profile.php?' . $vbulletin->session->vars['sessionurl'] . 'do=editmood');
$i = 1;
foreach ($mood_status AS $id => $moodbit)
{
// ÊÎØàÇáÃÂÞá ÃÂàÃÂÇá ÚÃÂã ãØÇÈÞå ááÃâ€Ãƒâ€˜ÃƒÂ¦ÃƒËœ.
if (!preg_match('#\|#', $moodbit) OR ($vbulletin->userinfo['usermood'] == $moodbit))
{
continue; // ÊÎØàÃÂÇáÉ ÇáãÒÇÌ ÇáãÎÊÇÑÉ
}
if ($id >= $startat)
{
$moods[] = $moodbit;
if ($i == $perpage)
{
break;
}
$i++;
}
}
$moodsonthispage = count($moods);
//echo $moodsonthispage;exit;
//print_r($moods);exit;
$cols = intval($vbulletin->options['plus_mood_numwide']);
$cols = iif($cols, $cols, 5);
$cols = iif($cols > $moodsonthispage, $moodsonthispage, $cols);
$bits = array();
foreach ($moods AS $moodbit)
{
$mooddetails = preg_split('#\|#', $moodbit, -1, PREG_SPLIT_NO_EMPTY);
$usermood = array (
'alt' => $mooddetails[0],
'img' => $mooddetails[1]
);
$moodid = $usermood['img'];
eval('$bits[] = "' . fetch_template('plus_mood_modifymoodbit') . '";');
if (sizeof($bits) == $cols)
{
$avatarcells = implode('', $bits);
$bits = array();
eval('$plus_mood_imglist .= "' . fetch_template('help_avatars_row') . '";');
exec_switch_bg();
}
}
// initialize remaining columns
$remainingcolumns = 0;
$remaining = sizeof($bits);
if ($remaining)
{
$remainingcolumns = $cols - $remaining;
$avatarcells = implode('', $bits);
eval('$plus_mood_imglist .= "' . fetch_template('help_avatars_row') . '";');
exec_switch_bg();
}
$show['plus_mood_images'] = true;
}
else
{
$show['plus_mood_images'] = false;
}
// end code for predefined moods
if (!defined('plus_can_install_default'))
{
$pagenav2 = '<br />products.</div>';
}
// draw cp nav bar
construct_usercp_nav('plus_mood_editmood');
$navbits[''] = $vbphrase['plus_edit_mood'];
$templatename = 'plus_mood_editmood';
}
if ($_POST['do'] == 'updatemood')
{
$moodid = $vbulletin->input->clean_gpc('p', 'moodid', TYPE_STR);
if (!$vbulletin->options['plus_mood_enable'])
{
eval(standard_error(fetch_error('plus_mood_disabled')));
}
else if(!($mood_status = preg_split('#\r\n#', htmlspecialchars_uni($vbulletin->options['plus_mood_status']), -1, PREG_SPLIT_NO_EMPTY)))
{
eval(standard_error(fetch_error('plus_mood_status_nothing')));
}
if ($moodid != 'none')
{
foreach ($mood_status AS $moodbit)
{
if ($mooddetails = preg_split('#\|#', $moodbit, -1, PREG_SPLIT_NO_EMPTY) AND is_array($mooddetails) AND ($mooddetails[1] == $moodid))
{
$moodid = $moodbit;
break;
}
}
if (empty($moodid))
{
$moodid = '';
}
}
// init user data manager
$userdata_mood =& datamanager_init('User', $vbulletin, ERRTYPE_STANDARD);
$userdata_mood->set_existing($vbulletin->userinfo);
// ÊÎÒÃÂä ÞÃÂãÉ ÇáãÒÇÌ ÇáÌÃÂÃÂÃÂÉ
$userdata_mood->set('usermood', $moodid);
// ÃÂÃÂÙ ÇáÊÛÃÂÑÇÃÅ
$userdata_mood->save();
$vbulletin->url = 'profile.php?' . $vbulletin->session->vars['sessionurl_q'] . 'do=editmood';
eval(print_standard_redirect('redirect_updatethanks'));
}
?>