projects
/
platal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge updates: names.
[platal.git]
/
modules
/
profile
/
decos.inc.php
diff --git
a/modules/profile/decos.inc.php
b/modules/profile/decos.inc.php
index
3adbafa
..
1749972
100644
(file)
--- a/
modules/profile/decos.inc.php
+++ b/
modules/profile/decos.inc.php
@@
-24,6
+24,9
@@
class ProfileSettingDeco implements ProfileSetting
private static function compareMedals(array $a, array $b)
{
if ($a['id'] == $b['id']) {
private static function compareMedals(array $a, array $b)
{
if ($a['id'] == $b['id']) {
+ if ($a['grade'] == $b['grade']) {
+ return $a['level'] > $b['level'];
+ }
return $a['grade'] > $b['grade'];
}
return $a['id'] > $b['id'];
return $a['grade'] > $b['grade'];
}
return $a['id'] > $b['id'];
@@
-32,20
+35,24
@@
class ProfileSettingDeco implements ProfileSetting
public function value(ProfilePage $page, $field, $value, &$success)
{
$success = true;
public function value(ProfilePage $page, $field, $value, &$success)
{
$success = true;
- if (is_null($value)) {
+ if (is_null($value) || !S::user()->isMyProfile($profile) &&
+ $page->values['medals_pub'] == 'private' && !S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) {
// Fetch already attributed medals
// Fetch already attributed medals
- $value = XDB::fetchAllAssoc('SELECT mid AS id, gid AS grade, 1 AS valid
- FROM profile_medals
- WHERE pid = {?}',
+ $value = XDB::fetchAllAssoc("SELECT m.mid AS id, m.gid AS grade, 1 AS valid, FIND_IN_SET('has_levels', e.flags) AS has_levels, m.level
+ FROM profile_medals AS m
+ INNER JOIN profile_medal_enum AS e ON (m.mid = e.id)
+ WHERE m.pid = {?}",
$page->pid());
// Fetch not yet validated medals
$medals = ProfileValidate::get_typed_requests($page->pid(), 'medal');
foreach ($medals as &$medal) {
$value[] = array(
$page->pid());
// Fetch not yet validated medals
$medals = ProfileValidate::get_typed_requests($page->pid(), 'medal');
foreach ($medals as &$medal) {
$value[] = array(
- 'id' => $medal->mid,
- 'grade' => $medal->gid,
- 'valid' => '0'
+ 'id' => $medal->mid,
+ 'grade' => $medal->gid,
+ 'level' => $medal->level,
+ 'has_levels' => $medal->has_levels,
+ 'valid' => '0'
);
}
} elseif (!is_array($value)) {
);
}
} elseif (!is_array($value)) {
@@
-63,9
+70,14
@@
class ProfileSettingDeco implements ProfileSetting
$total_original = count($original);
$total_value = count($value);
$total_original = count($original);
$total_value = count($value);
+ if ($total_original && !S::user()->isMyProfile($profile) &&
+ $page->values['medals_pub'] == 'private' && !S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) {
+ return;
+ }
+
while ($i < $total_original || $j < $total_value) {
if (isset($value[$j]) && (!isset($original[$i]) || self::compareMedals($original[$i], $value[$j]))) {
while ($i < $total_original || $j < $total_value) {
if (isset($value[$j]) && (!isset($original[$i]) || self::compareMedals($original[$i], $value[$j]))) {
- $req = new MedalReq(S::user(), $page->profile, $value[$j]['id'], $value[$j]['grade']);
+ $req = new MedalReq(S::user(), $page->profile, $value[$j]['id'], $value[$j]['grade']
, $value[$j]['level'], $value[$j]['has_levels']
);
$req->submit();
sleep(1);
++$j;
$req->submit();
sleep(1);
++$j;
@@
-75,7
+87,7
@@
class ProfileSettingDeco implements ProfileSetting
WHERE pid = {?} AND mid = {?} AND gid = {?}',
$page->pid(), $original[$i]['id'], $original[$i]['grade']);
} else {
WHERE pid = {?} AND mid = {?} AND gid = {?}',
$page->pid(), $original[$i]['id'], $original[$i]['grade']);
} else {
- $req = MedalReq::get_request($page->pid(), $original[$i]['id'], $original[$i]['grade']);
+ $req = MedalReq::get_request($page->pid(), $original[$i]['id'], $original[$i]['grade']
, $value[$j]['level']
);
if ($req) {
$req->clean();
}
if ($req) {
$req->clean();
}
@@
-105,8
+117,8
@@
class ProfilePageDecos extends ProfilePage
public function __construct(PlWizard $wiz)
{
parent::__construct($wiz);
public function __construct(PlWizard $wiz)
{
parent::__construct($wiz);
- $this->settings['medals'] = new ProfileSettingDeco();
$this->settings['medals_pub'] = new ProfileSettingPub();
$this->settings['medals_pub'] = new ProfileSettingPub();
+ $this->settings['medals'] = new ProfileSettingDeco();
$this->watched['medals'] = true;
}
$this->watched['medals'] = true;
}
@@
-121,7
+133,7
@@
class ProfilePageDecos extends ProfilePage
protected function _saveData()
{
protected function _saveData()
{
- if ($this->changed['medals_pub']) {
+ if ($this->changed['medals_pub']
&& (S::user()->isMyProfile($profile) || S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE))
) {
XDB::execute("UPDATE profiles
SET medals_pub = {?}
WHERE pid = {?}",
XDB::execute("UPDATE profiles
SET medals_pub = {?}
WHERE pid = {?}",