From ebc7a9bee8f8cabd53decfe7a208280df15b36e8 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Wed, 20 May 2015 01:22:09 +0200 Subject: [PATCH] implemented user page well .. most of it anyway --- includes/ajaxHandler.class.php | 41 +- includes/community.class.php | 138 ++- includes/defines.php | 4 +- index.php | 2 +- localization/lang.class.php | 1 + localization/locale_dede.php | 20 +- localization/locale_enus.php | 20 +- localization/locale_eses.php | 20 +- localization/locale_frfr.php | 20 +- localization/locale_ruru.php | 20 +- pages/account.php | 10 +- pages/genericPage.class.php | 7 +- pages/user.php | 219 +++++ static/js/global.js | 4 +- static/js/user.js | 1014 +++++++++++---------- template/bricks/infobox.tpl.php | 2 +- template/bricks/lvTabs.tpl.php | 11 +- template/listviews/commentpreview.tpl.php | 6 +- template/listviews/screenshot.tpl.php | 5 +- template/pages/admin/screenshots.tpl.php | 2 +- template/pages/text-page-generic.tpl.php | 6 +- template/pages/user.tpl.php | 46 + 22 files changed, 1032 insertions(+), 586 deletions(-) create mode 100644 pages/user.php create mode 100644 template/pages/user.tpl.php diff --git a/includes/ajaxHandler.class.php b/includes/ajaxHandler.class.php index 7e0e6957..9dc53b88 100644 --- a/includes/ajaxHandler.class.php +++ b/includes/ajaxHandler.class.php @@ -352,14 +352,14 @@ class AjaxHandler DB::Aowow()->query('UPDATE ?_comments SET editCount = editCount + 1, ?a WHERE id = ?d', $update, $this->get('id')); break; - case 'delete': // user.js uses GET; global.js uses POST - if (!$this->post('id') && !$this->get('id')) + case 'delete': + if (!$this->post('id')) break; - $ok = DB::Aowow()->query('UPDATE ?_comments SET flags = flags | ?d, deleteUserId = ?d, deleteDate = UNIX_TIMESTAMP() WHERE id = ?d{ AND userId = ?d}', + $ok = DB::Aowow()->query('UPDATE ?_comments SET flags = flags | ?d, deleteUserId = ?d, deleteDate = UNIX_TIMESTAMP() WHERE id IN (?a){ AND userId = ?d}', CC_FLAG_DELETED, User::$id, - $this->post('id') ?: $this->get('id'), + (array)$this->post('id'), User::isInGroup(U_GROUP_MODERATOR) ? DBSIMPLE_SKIP : User::$id ); @@ -376,13 +376,13 @@ class AjaxHandler } break; - case 'undelete': // user.js uses GET; global.js uses POST - if (!$this->post('id') && !$this->get('id')) + case 'undelete': + if (!$this->post('id')) break; - $ok = DB::Aowow()->query('UPDATE ?_comments SET flags = flags & ~?d WHERE id = ?d{ AND userId = deleteUserId AND deleteUserId = ?d}', + $ok = DB::Aowow()->query('UPDATE ?_comments SET flags = flags & ~?d WHERE id IN (?a){ AND userId = deleteUserId AND deleteUserId = ?d}', CC_FLAG_DELETED, - $this->post('id') ?: $this->get('id'), + (array)$this->post('id'), User::isInGroup(U_GROUP_MODERATOR) ? DBSIMPLE_SKIP : User::$id ); @@ -777,7 +777,10 @@ class AjaxHandler if (!$this->get('id') || !preg_match('/^([0-9]+)\.(jpg|gif)$/', $this->get('id'), $matches) || !in_array($size, array_keys($s))) return false; - $id = $matches[1]; + header('Content-Type: image/'.$matches[2]); + + $id = $matches[1]; + $dest = imageCreateTruecolor($s[$size], $s[$size]); if (file_exists('/uploads/avatars/'.$id.'.jpg')) { @@ -793,22 +796,16 @@ class AjaxHandler $offsetX += $s['large']; } - $src = imageCreateFromJpeg('uploads/avatars/'.$id.'.jpg'); - $dest = imageCreateTruecolor($s[$size], $s[$size]); - + $src = imageCreateFromJpeg('uploads/avatars/'.$id.'.jpg'); imagecopymerge($dest, $src, 0, 0, $offsetX, $offsetY, $s[$size], $s[$size], 100); - - header('Content-Type: image/'.$matches[2]); - - if ($matches[2] == 'gif') - imageGif($dest); - else - imageJpeg($dest); - - return true; } - return false; + if ($matches[2] == 'gif') + imageGif($dest); + else + imageJpeg($dest); + + return true; } private function profile_handlePin($id, $mode) // (un)favorite diff --git a/includes/community.class.php b/includes/community.class.php index ef9d287b..62ffa21c 100644 --- a/includes/community.class.php +++ b/includes/community.class.php @@ -19,6 +19,7 @@ if (!defined('AOWOW_REVISION')) class CommunityContent { private static $jsGlobals = []; + private static $subjCache = []; private static $commentQuery = ' SELECT @@ -86,32 +87,21 @@ class CommunityContent ?d '; - public static function getCommentPreviews($params = []) + private static function addSubject($type, $typeId) { - /* - purged:0, <- doesnt seem to be used anymore - domain:'live' <- irrelevant for our case - */ + if (!isset(self::$subjCache[$type][$typeId])) + self::$subjCache[$type][$typeId] = 0; + } - $subjCache = []; - $comments = DB::Aowow()->select( - self::$previewQuery, - CC_FLAG_DELETED, - empty($params['user']) ? DBSIMPLE_SKIP : $params['user'], - empty($params['replies']) ? DBSIMPLE_SKIP : 0, // i dont know, how to switch the sign around - !empty($params['replies']) ? DBSIMPLE_SKIP : 0, - CC_FLAG_DELETED, - User::$id, - User::isInGroup(U_GROUP_COMMENTS_MODERATOR), - CFG_SQL_LIMIT_DEFAULT - ); - - foreach ($comments as $c) - $subjCache[$c['type']][$c['typeId']] = $c['typeId']; - - foreach ($subjCache as $type => $ids) + private static function getSubjects() + { + foreach (self::$subjCache as $type => $ids) { - $cnd = [CFG_SQL_LIMIT_NONE, ['id', array_unique($ids, SORT_NUMERIC)]]; + $_ = array_filter(array_keys($ids), 'is_numeric'); + if (!$_) + continue; + + $cnd = [CFG_SQL_LIMIT_NONE, ['id', $_]]; switch ($type) { @@ -135,15 +125,41 @@ class CommunityContent } foreach ($obj->iterate() as $id => $__) - $subjCache[$type][$id] = $obj->getField('name', true); + self::$subjCache[$type][$id] = $obj->getField('name', true); } + } + + public static function getCommentPreviews($params = [], &$nFound = 0) + { + /* + purged:0, <- doesnt seem to be used anymore + domain:'live' <- irrelevant for our case + */ + + $comments = DB::Aowow()->selectPage( + $nFound, + self::$previewQuery, + CC_FLAG_DELETED, + empty($params['user']) ? DBSIMPLE_SKIP : $params['user'], + empty($params['replies']) ? DBSIMPLE_SKIP : 0, // i dont know, how to switch the sign around + !empty($params['replies']) ? DBSIMPLE_SKIP : 0, + CC_FLAG_DELETED, + User::$id, + User::isInGroup(U_GROUP_COMMENTS_MODERATOR), + CFG_SQL_LIMIT_DEFAULT + ); + + foreach ($comments as $c) + self::addSubject($c['type'], $c['typeId']); + + self::getSubjects(); foreach ($comments as $idx => &$c) { - if (!empty($subjCache[$c['type']][$c['typeId']])) + if (!empty(self::$subjCache[$c['type']][$c['typeId']])) { // apply subject - $c['subject'] = $subjCache[$c['type']][$c['typeId']]; + $c['subject'] = self::$subjCache[$c['type']][$c['typeId']]; // format date $c['date'] = date(Util::$dateFormatInternal, $c['date']); @@ -155,7 +171,7 @@ class CommunityContent // remove line breaks $c['preview'] = strtr($c['preview'], ["\n" => ' ', "\r" => ' ']); // limit whitespaces to one at a time - $c['preview'] = preg_replace('/\s+/',' ', $c['preview']); + $c['preview'] = preg_replace('/\s+/', ' ', $c['preview']); // limit previews to 100 chars + whatever it takes to make the last word full if (strlen($c['preview']) > 100) { @@ -164,8 +180,8 @@ class CommunityContent $parts = explode(' ', $c['preview']); while ($n < 100 && $parts) { - $_ = array_shift($parts); - $n += strlen($_); + $_ = array_shift($parts); + $n += strlen($_); $b[] = $_; } @@ -182,13 +198,13 @@ class CommunityContent return $comments; } - public static function getCommentReplies($commentId, $limit = 0, &$nFound = null) + public static function getCommentReplies($commentId, $limit = 0, &$nFound = 0) { $replies = []; $query = $limit > 0 ? self::$commentQuery.' LIMIT '.$limit : self::$commentQuery; // get replies - $results = DB::Aowow()->SelectPage($nFound, $query, User::$id, User::$id, $commentId, 0, 0, CC_FLAG_DELETED, User::$id, User::isInGroup(U_GROUP_COMMENTS_MODERATOR)); + $results = DB::Aowow()->selectPage($nFound, $query, User::$id, User::$id, $commentId, 0, 0, CC_FLAG_DELETED, User::$id, User::isInGroup(U_GROUP_COMMENTS_MODERATOR)); foreach ($results as $r) { (new Markup($r['body']))->parseGlobalsFromText(self::$jsGlobals); @@ -398,18 +414,39 @@ class CommunityContent return $comments; } - private static function getVideos($type, $typeId) + public static function getVideos($typeOrUser, $typeId = 0, &$nFound = 0) { - $videos = DB::Aowow()->Query(" - SELECT v.id, a.displayName AS user, v.date, v.videoId, v.caption, IF(v.status & 0x4, 1, 0) AS 'sticky', v.type, v.typeId + $videos = DB::Aowow()->selectPage($nFound, " + SELECT v.id, a.displayName AS user, v.date, v.videoId, v.caption, IF(v.status & ?d, 1, 0) AS 'sticky', v.type, v.typeId FROM ?_videos v, ?_account a - WHERE v.type = ? AND v.typeId = ? AND v.status & 0x2 AND v.uploader = a.id", - $type, $typeId + WHERE {v.uploader = ?d }{v.type = ? }{AND v.typeId = ? }AND v.status & ?d AND (v.status & ?d) = 0 AND v.uploader = a.id", + CC_FLAG_STICKY, + $typeOrUser < 0 ? -$typeOrUser : DBSIMPLE_SKIP, + $typeOrUser > 0 ? $typeOrUser : DBSIMPLE_SKIP, + $typeOrUser > 0 ? $typeId : DBSIMPLE_SKIP, + CC_FLAG_APPROVED, + CC_FLAG_DELETED ); + if ($typeOrUser < 0) // only for user page + { + foreach ($videos as $v) + self::addSubject($v['type'], $v['typeId']); + + self::getSubjects(); + } + // format data to meet requirements of the js foreach ($videos as &$v) { + if ($typeOrUser < 0) // only for user page + { + if (!empty(self::$subjCache[$v['type']][$v['typeId']]) && !is_numeric(self::$subjCache[$v['type']][$v['typeId']])) + $v['subject'] = self::$subjCache[$v['type']][$v['typeId']]; + else + $v['subject'] = Lang::user('removed'); + } + $v['date'] = date(Util::$dateFormatInternal, $v['date']); $v['videoType'] = 1; // always youtube if (!$v['sticky']) @@ -419,22 +456,39 @@ class CommunityContent return $videos; } - private static function getScreenshots($type, $typeId) + public static function getScreenshots($typeOrUser, $typeId = 0, &$nFound = 0) { - $screenshots = DB::Aowow()->Query(" - SELECT s.id, a.displayName AS user, s.date, s.width, s.height, s.type, s.typeId, s.caption, IF(s.status & ?d, 1, 0) AS 'sticky' + $screenshots = DB::Aowow()->selectPage($nFound, " + SELECT s.id, a.displayName AS user, s.date, s.width, s.height, s.caption, IF(s.status & ?d, 1, 0) AS 'sticky', s.type, s.typeId FROM ?_screenshots s, ?_account a - WHERE s.type = ? AND s.typeId = ? AND s.status & ?d AND (s.status & ?d) = 0 AND s.uploader = a.id", + WHERE {s.uploader = ?d }{s.type = ? }{AND s.typeId = ? }AND s.status & ?d AND (s.status & ?d) = 0 AND s.uploader = a.id", CC_FLAG_STICKY, - $type, - $typeId, + $typeOrUser < 0 ? -$typeOrUser : DBSIMPLE_SKIP, + $typeOrUser > 0 ? $typeOrUser : DBSIMPLE_SKIP, + $typeOrUser > 0 ? $typeId : DBSIMPLE_SKIP, CC_FLAG_APPROVED, CC_FLAG_DELETED ); + if ($typeOrUser < 0) // only for user page + { + foreach ($screenshots as $s) + self::addSubject($s['type'], $s['typeId']); + + self::getSubjects(); + } + // format data to meet requirements of the js foreach ($screenshots as &$s) { + if ($typeOrUser < 0) // only for user page + { + if (!empty(self::$subjCache[$s['type']][$s['typeId']]) && !is_numeric(self::$subjCache[$s['type']][$s['typeId']])) + $s['subject'] = self::$subjCache[$s['type']][$s['typeId']]; + else + $s['subject'] = Lang::user('removed'); + } + $s['date'] = date(Util::$dateFormatInternal, $s['date']); if (!$s['sticky']) unset($s['sticky']); diff --git a/includes/defines.php b/includes/defines.php index 4e160e90..f1edd788 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -58,10 +58,10 @@ define('ACC_BAN_TEMP', 0x01); define('ACC_BAN_PERM', 0x02); define('ACC_BAN_RATE', 0x04); // cannot rate community items (overrides site reputation) define('ACC_BAN_COMMENT', 0x08); // cannot comment and reply -define('ACC_BAN_UPLOAD', 0x10); // cannot upload avatar / signature files +define('ACC_BAN_UPLOAD', 0x10); // cannot upload avatar / signature files [originally: ban from data upload] define('ACC_BAN_SCREENSHOT', 0x20); // cannot upload screenshots define('ACC_BAN_VIDEO', 0x40); // cannot suggest videos -// define('ACC_BAN_FORUM', 0x80); // cannot use forums (not used here) +// define('ACC_BAN_FORUM', 0x80); // cannot use forums [not used here] // Site Reputation/Privileges define('SITEREP_ACTION_REGISTER', 1); // Registered account diff --git a/index.php b/index.php index f90182d7..2be36d64 100644 --- a/index.php +++ b/index.php @@ -96,7 +96,7 @@ switch ($pageCall) case 'talent': // tool: talent calculator case 'title': case 'titles': - // case 'user': // tool: user profiles [nyi] + case 'user': case 'video': case 'zone': case 'zones': diff --git a/localization/lang.class.php b/localization/lang.class.php index 87ec371f..e4621919 100644 --- a/localization/lang.class.php +++ b/localization/lang.class.php @@ -5,6 +5,7 @@ class Lang private static $timeUnits; private static $main; private static $account; + private static $user; private static $mail; private static $game; diff --git a/localization/locale_dede.php b/localization/locale_dede.php index a2c96a1a..2490e92e 100644 --- a/localization/locale_dede.php +++ b/localization/locale_dede.php @@ -327,12 +327,8 @@ $lang = array( // dashboard 'ipAddress' => "IP-Adresse", 'lastIP' => "Letzte bekannte IP", - 'joinDate' => "Mitglied seit", - 'lastLogin' => "Letzter Besuch", - 'userGroups' => "Rolle", 'myAccount' => "Mein Account", 'editAccount' => "Benutze die folgenden Formulare um deine Account-Informationen zu aktualisieren", - 'publicDesc' => "Öffentliche Beschreibung", 'viewPubDesc' => 'Die Beschreibung in deinem öffentlichen Profil ansehen', // bans @@ -365,6 +361,22 @@ $lang = array( 'passCheckFail' => "Die Kennwörter stimmen nicht überein.", // message_passwordsdonotmatch 'newPassDiff' => "Euer neues Kennwort muss sich von eurem alten Kennwort unterscheiden." // message_newpassdifferent ), + 'user' => array( + 'notFound' => "Der Benutzer \"%s\" wurde nicht gefunden!", + 'removed' => "(Entfernt)", + 'joinDate' => "Mitglied seit", + 'lastLogin' => "Letzter Besuch", + 'userGroups' => "Rolle", + 'consecVisits' => "Aufeinanderfolgende Besuche", + 'publicDesc' => "Öffentliche Beschreibung", + 'profileTitle' => "Profil von %s", + 'contributions' => "Beiträge", + 'uploads' => "Hochladevorgänge", + 'comments' => "Kommentare", + 'screenshots' => "Screenshots", + 'videos' => "Videos", + 'posts' => "Forenbeiträge" + ), 'mail' => array( 'tokenExpires' => "Das Token wird in %s verfallen.", 'accConfirm' => ["Kontobestätigung", "Willkommen bei ".CFG_NAME_SHORT."!\r\n\r\nKlicke auf den Link um euren Account zu aktivieren.\r\n\r\n".HOST_URL."?account=signup&token=%s\r\n\r\nFalls Ihr diese Mail nicht angefordert habt kann sie einfach ignoriert werden."], diff --git a/localization/locale_enus.php b/localization/locale_enus.php index 1334ef39..773a15b6 100644 --- a/localization/locale_enus.php +++ b/localization/locale_enus.php @@ -322,12 +322,8 @@ $lang = array( // dashboard 'ipAddress' => "IP-Adress", 'lastIP' => "last used IP", - 'joinDate' => "Joined", - 'lastLogin' => "Last visit", - 'userGroups' => "Role", 'myAccount' => "My Account", 'editAccount' => "Simply use the forms below to update your account information", - 'publicDesc' => "Public Description", 'viewPubDesc' => 'View your Public Description in your Profile Page', // bans @@ -360,6 +356,22 @@ $lang = array( 'passCheckFail' => "Passwords do not match.", // message_passwordsdonotmatch 'newPassDiff' => "Your new password must be different than your previous one." // message_newpassdifferent ), + 'user' => array( + 'notFound' => "User \"%s\" not found!", + 'removed' => "(Removed)", + 'joinDate' => "Joined", + 'lastLogin' => "Last visit", + 'userGroups' => "Role", + 'consecVisits' => "Consecutive visits", + 'publicDesc' => "Public Description", + 'profileTitle' => "%s's Profile", + 'contributions' => "Contributions", + 'uploads' => "Data uploads", + 'comments' => "Comments", + 'screenshots' => "Screenshots", + 'videos' => "Videos", + 'posts' => "Forum posts" + ), 'mail' => array( 'tokenExpires' => "This token expires in %s.", 'accConfirm' => ["Account Confirmation", "Welcome to ".CFG_NAME_SHORT."!\r\n\r\nClick the Link below to activate your account.\r\n\r\n".HOST_URL."?account=signup&token=%s\r\n\r\nIf you did not request this mail simply ignore it."], diff --git a/localization/locale_eses.php b/localization/locale_eses.php index 2cd71e59..24de2b6f 100644 --- a/localization/locale_eses.php +++ b/localization/locale_eses.php @@ -328,12 +328,8 @@ $lang = array( // dashboard 'ipAddress' => "IP-Adress", 'lastIP' => "last used IP", - 'joinDate' => "Joined", - 'lastLogin' => "Last visit", - 'userGroups' => "Role", 'myAccount' => "My Account", 'editAccount' => "Simply use the forms below to update your account information", - 'publicDesc' => "Public Description", 'viewPubDesc' => 'View your Public Description in your Profile Page', // bans @@ -366,6 +362,22 @@ $lang = array( 'passCheckFail' => "Las contraseñas no son iguales.", // message_passwordsdonotmatch 'newPassDiff' => "Su nueva contraseña tiene que ser diferente a Su contraseña anterior." // message_newpassdifferent ), + 'user' => array( + 'notFound' => "¡No se encontró el usuario \"%s\"!", + 'removed' => "(Removido)", + 'joinDate' => "Se unió", + 'lastLogin' => "Última visita", + 'userGroups' => "Rol", + 'consecVisits' => "Visitas consecutivas", + 'publicDesc' => "Descripción pública", + 'profileTitle' => "Perfíl de %s", + 'contributions' => "Contribuciones", + 'uploads' => "Datos enviados", + 'comments' => "Comentarios", + 'screenshots' => "Capturas de pantalla", + 'videos' => "Vídeos", + 'posts' => "Mensajes en los foros" + ), 'mail' => array( 'tokenExpires' => "This token expires in %s.", 'accConfirm' => ["Account Confirmation", "Welcome to ".CFG_NAME_SHORT."!\r\n\r\nClick the Link below to activate your account.\r\n\r\n".HOST_URL."?account=signup&token=%s\r\n\r\nIf you did not request this mail simply ignore it."], diff --git a/localization/locale_frfr.php b/localization/locale_frfr.php index 1d6deb9a..c0d85a19 100644 --- a/localization/locale_frfr.php +++ b/localization/locale_frfr.php @@ -327,12 +327,8 @@ $lang = array( // dashboard 'ipAddress' => "IP-Adress", 'lastIP' => "last used IP", - 'joinDate' => "Joined", - 'lastLogin' => "Last visit", - 'userGroups' => "Role", 'myAccount' => "My Account", 'editAccount' => "Simply use the forms below to update your account information", - 'publicDesc' => "Public Description", 'viewPubDesc' => 'View your Public Description in your Profile Page', // bans @@ -365,6 +361,22 @@ $lang = array( 'passCheckFail' => "Les mots de passe ne correspondent pas.", // message_passwordsdonotmatch 'newPassDiff' => "Votre nouveau mot de passe doit être différent de l'ancien." // message_newpassdifferent ), + 'user' => array( + 'notFound' => "Utilisateur \"%s\" non trouvé !", + 'removed' => "(Supprimé)", + 'joinDate' => "Inscription", + 'lastLogin' => "Dernière visite", + 'userGroups' => "Role", + 'consecVisits' => "Visites consécutives", + 'publicDesc' => "Description publique", + 'profileTitle' => "Profil de %s", + 'contributions' => "Contributions", + 'uploads' => "Envois de données", + 'comments' => "Commentaires", + 'screenshots' => "Captures d'écran", + 'videos' => "Vidéos", + 'posts' => "Messages sur le forum" + ), 'mail' => array( 'tokenExpires' => "This token expires in %s.", 'accConfirm' => ["Account Confirmation", "Welcome to ".CFG_NAME_SHORT."!\r\n\r\nClick the Link below to activate your account.\r\n\r\n".HOST_URL."?account=signup&token=%s\r\n\r\nIf you did not request this mail simply ignore it."], diff --git a/localization/locale_ruru.php b/localization/locale_ruru.php index 3686c337..0c0efc2d 100644 --- a/localization/locale_ruru.php +++ b/localization/locale_ruru.php @@ -327,12 +327,8 @@ $lang = array( // dashboard 'ipAddress' => "IP-Adress", 'lastIP' => "last used IP", - 'joinDate' => "Joined", - 'lastLogin' => "Last visit", - 'userGroups' => "Role", 'myAccount' => "My Account", 'editAccount' => "Simply use the forms below to update your account information", - 'publicDesc' => "Public Description", 'viewPubDesc' => 'View your Public Description in your Profile Page', // bans @@ -365,6 +361,22 @@ $lang = array( 'passCheckFail' => "Пароли не совпадают.", // message_passwordsdonotmatch 'newPassDiff' => "Прежний и новый пароли не должны совпадать." // message_newpassdifferent ), + 'user' => array( + 'notFound' => "Пользователь \"%s\" не найден!", + 'removed' => "(Удалено)", + 'joinDate' => "Зарегистрировался", + 'lastLogin' => "Последняя активность", + 'userGroups' => "Роль", + 'consecVisits' => "Регулярные посещения", + 'publicDesc' => "Описание", + 'profileTitle' => "Профиль %s", + 'contributions' => "Вклад", + 'uploads' => "Данных загружено", + 'comments' => "Комментарии", + 'screenshots' => "Скриншоты", + 'videos' => "Видео", + 'posts' => "Сообщений на форумах" + ), 'mail' => array( 'tokenExpires' => "This token expires in %s.", 'accConfirm' => ["Account Confirmation", "Welcome to ".CFG_NAME_SHORT."!\r\n\r\nClick the Link below to activate your account.\r\n\r\n".HOST_URL."?account=signup&token=%s\r\n\r\nIf you did not request this mail simply ignore it."], diff --git a/pages/account.php b/pages/account.php index bcfa3c49..72ad15a1 100644 --- a/pages/account.php +++ b/pages/account.php @@ -180,16 +180,16 @@ class AccountPage extends GenericPage /***********/ $infobox = []; - $infobox[] = Lang::account('joinDate'). Lang::main('colon').'[tooltip name=joinDate]'. date('l, G:i:s', $user['joinDate']). '[/tooltip][span class=tip tooltip=joinDate]'. date(Lang::main('dateFmtShort'), $user['joinDate']). '[/span]'; - $infobox[] = Lang::account('lastLogin').Lang::main('colon').'[tooltip name=lastLogin]'.date('l, G:i:s', $user['prevLogin']).'[/tooltip][span class=tip tooltip=lastLogin]'.date(Lang::main('dateFmtShort'), $user['prevLogin']).'[/span]'; - $infobox[] = Lang::account('lastIP'). Lang::main('colon').$user['prevIP']; - $infobox[] = Lang::account('email'). Lang::main('colon').$user['email']; + $infobox[] = Lang::user('joinDate'). Lang::main('colon').'[tooltip name=joinDate]'. date('l, G:i:s', $user['joinDate']). '[/tooltip][span class=tip tooltip=joinDate]'. date(Lang::main('dateFmtShort'), $user['joinDate']). '[/span]'; + $infobox[] = Lang::user('lastLogin').Lang::main('colon').'[tooltip name=lastLogin]'.date('l, G:i:s', $user['prevLogin']).'[/tooltip][span class=tip tooltip=lastLogin]'.date(Lang::main('dateFmtShort'), $user['prevLogin']).'[/span]'; + $infobox[] = Lang::account('lastIP').Lang::main('colon').$user['prevIP']; + $infobox[] = Lang::account('email'). Lang::main('colon').$user['email']; $groups = []; foreach (Lang::account('groups') as $idx => $key) if ($idx >= 0 && $user['userGroups'] & (1 << $idx)) $groups[] = (!fMod(count($groups) + 1, 3) ? '[br]' : null).Lang::account('groups', $idx); - $infobox[] = Lang::account('userGroups').Lang::main('colon').($groups ? implode(', ', $groups) : Lang::account('groups', -1)); + $infobox[] = Lang::user('userGroups').Lang::main('colon').($groups ? implode(', ', $groups) : Lang::account('groups', -1)); $infobox[] = Util::ucFirst(Lang::main('siteRep')).Lang::main('colon').User::getReputation(); diff --git a/pages/genericPage.class.php b/pages/genericPage.class.php index c9fcc4be..75772b09 100644 --- a/pages/genericPage.class.php +++ b/pages/genericPage.class.php @@ -361,9 +361,12 @@ class GenericPage /* Special Display */ /*******************/ - public function notFound($typeStr) // unknown ID + public function notFound($title, $msg = '') // unknown entry { - $this->typeStr = $typeStr; + $this->notFound = array( + 'title' => $this->typeId ? Util::ucFirst($title).' #'.$this->typeId : $title, + 'msg' => !$msg && $this->typeId ? sprintf(Lang::main('pageNotFound'), $title) : $msg + ); $this->hasComContent = false; Util::arraySumByKey($this->mysql, DB::Aowow()->getStatistics(), DB::World()->getStatistics()); diff --git a/pages/user.php b/pages/user.php new file mode 100644 index 00000000..75575c43 --- /dev/null +++ b/pages/user.php @@ -0,0 +1,219 @@ + 'Profiler.css']]; + protected $mode = CACHE_TYPE_NONE; + + protected $typeId = 0; + protected $pageName = ''; + + public function __construct($pageCall, $pageParam) + { + parent::__construct($pageCall, $pageParam); + + if ($pageParam) + { + // todo: check if account is disabled or something + if ($user = DB::Aowow()->selectRow('SELECT a.id, a.user, a.displayName, a.consecutiveVisits, a.userGroups, a.avatar, a.title, a.description, a.joinDate, a.prevLogin, IFNULL(SUM(ar.amount), 0) AS sumRep FROM ?_account a LEFT JOIN ?_account_reputation ar ON a.id = ar.userId WHERE a.user = ? GROUP BY a.id', $pageParam)) + $this->user = $user; + else + $this->notFound(sprintf(Lang::user('notFound'), $pageParam)); + } + else if (User::$id) + header('Location: ?user='.User::$displayName, true, 302); + else + $this->forwardToSignIn('user'); + } + + protected function generateContent() + { + /***********/ + /* Infobox */ + /***********/ + + $infobox = $contrib = $groups = []; + foreach (Lang::account('groups') as $idx => $key) + if ($idx >= 0 && $this->user['userGroups'] & (1 << $idx)) + $groups[] = (!fMod(count($groups) + 1, 3) ? '[br]' : null).Lang::account('groups', $idx); + + $infobox[] = Lang::user('joinDate'). Lang::main('colon').'[tooltip name=joinDate]'. date('l, G:i:s', $this->user['joinDate']). '[/tooltip][span class=tip tooltip=joinDate]'. date(Lang::main('dateFmtShort'), $this->user['joinDate']). '[/span]'; + $infobox[] = Lang::user('lastLogin').Lang::main('colon').'[tooltip name=lastLogin]'.date('l, G:i:s', $this->user['prevLogin']).'[/tooltip][span class=tip tooltip=lastLogin]'.date(Lang::main('dateFmtShort'), $this->user['prevLogin']).'[/span]'; + $infobox[] = Lang::user('userGroups').Lang::main('colon').($groups ? implode(', ', $groups) : Lang::account('groups', -1)); + $infobox[] = Lang::user('consecVisits').Lang::main('colon').$this->user['consecutiveVisits']; + $infobox[] = Util::ucFirst(Lang::main('siteRep')).Lang::main('colon').number_format($this->user['sumRep']); + + // contrib -> [url=http://www.wowhead.com/client]Data uploads: n [small]([tooltip=tooltip_totaldatauploads]xx.y MB[/tooltip])[/small][/url] + + $co = DB::Aowow()->selectRow( + 'SELECT COUNT(DISTINCT c.id) AS sum, COUNT(cr.commentId) AS nRates FROM ?_comments c LEFT JOIN ?_comments_rates cr ON cr.commentId = c.id WHERE c.replyTo = 0 AND c.userId = ?d', + $this->user['id'] + ); + if ($co['sum']) + $contrib[] = Lang::user('comments').Lang::main('colon').$co['sum'].' [small]([tooltip=tooltip_totalratings]'.$co['nRates'].'[/tooltip])[/small]'; + + $ss = DB::Aowow()->selectRow('SELECT COUNT(id) AS sum, SUM(IF(status & ?d, 1, 0)) as nSticky FROM ?_screenshots WHERE uploader = ?d AND status & ?d AND (status & ?d) = 0', + CC_FLAG_STICKY, + $this->user['id'], + CC_FLAG_APPROVED, + CC_FLAG_DELETED + ); + if ($ss['sum']) + $contrib[] = Lang::user('screenshots').Lang::main('colon').$ss['sum'].' [small]([tooltip=tooltip_normal]'.($ss['sum'] - $ss['nSticky']).'[/tooltip] + [tooltip=tooltip_sticky]'.$ss['nSticky'].'[/tooltip])[/small]'; + + $vi = DB::Aowow()->selectRow('SELECT COUNT(id) AS sum, SUM(IF(status & ?d, 1, 0)) as nSticky FROM ?_videos WHERE uploader = ?d AND status & ?d AND (status & ?d) = 0', + CC_FLAG_STICKY, + $this->user['id'], + CC_FLAG_APPROVED, + CC_FLAG_DELETED + ); + if ($vi['sum']) + $contrib[] = Lang::user('videos').Lang::main('colon').$vi['sum'].' [small]([tooltip=tooltip_normal]'.($vi['sum'] - $vi['nSticky']).'[/tooltip] + [tooltip=tooltip_sticky]'.$vi['nSticky'].'[/tooltip])[/small]'; + + // contrib -> Forum posts: 5769 [small]([tooltip=topics]579[/tooltip] + [tooltip=replies]5190[/tooltip])[/small] + + $this->infobox = '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]'; + + if ($contrib) + $this->contributions = '[ul][li]'.implode('[/li][li]', $contrib).'[/li][/ul]'; + + + /****************/ + /* Main Content */ + /****************/ + + $this->name = $this->user['title'] ? $this->user['displayName'].' <'.$this->user['title'].'>' : sprintf(Lang::user('profileTitle'), $this->user['displayName']); + + /**************/ + /* Extra Tabs */ + /**************/ + + $this->lvTabs = []; + $this->forceTabs = true; + + // [unused] Site Achievements + + // Reputation changelog (params only for comment-events) + if ($repData = DB::Aowow()->select('SELECT action, amount, date AS \'when\', IF(action IN (3, 4, 5), sourceA, 0) AS param FROM ?_account_reputation WHERE userId = ?d', $this->user['id'])) + { + foreach ($repData as &$r) + $r['when'] = date(Util::$dateFormatInternal, $r['when']); + + $this->lvTabs[] = array( + 'file' => 'reputationhistory', + 'data' => $repData, + 'params' => [] + ); + } + + // Comments + if ($_ = CommunityContent::getCommentPreviews(['user' => $this->user['id'], 'replies' => false], $nFound)) + { + $lvData = array( + 'file' => 'commentpreview', + 'data' => $_, + 'params' => array( + 'hiddenCols' => "$['author']", + 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', + '_totalCount' => $nFound + ) + ); + + if ($nFound > CFG_SQL_LIMIT_DEFAULT) + { + $lvData['params']['name'] = '$LANG.tab_latestcomments'; + $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_usercomments, '.$nFound.')'; + } + + $this->lvTabs[] = $lvData; + } + + // Comment Replies + if ($_ = CommunityContent::getCommentPreviews(['user' => $this->user['id'], 'replies' => true], $nFound)) + { + $lvData = array( + 'file' => 'replypreview', + 'data' => $_, + 'params' => array( + 'hiddenCols' => "$['author']", + 'onBeforeCreate' => '$Listview.funcBox.beforeUserComments', + '_totalCount' => $nFound + ) + ); + + if ($nFound > CFG_SQL_LIMIT_DEFAULT) + { + $lvData['params']['name'] = '$LANG.tab_latestreplies'; + $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_userreplies, '.$nFound.')'; + } + + $this->lvTabs[] = $lvData; + } + + // Screenshots + if ($_ = CommunityContent::getScreenshots(-$this->user['id'], 0, $nFound)) + { + $lvData = array( + 'file' => 'screenshot', + 'data' => $_, + 'params' => array( + '_totalCount' => $nFound + ) + ); + + if ($nFound > CFG_SQL_LIMIT_DEFAULT) + { + $lvData['params']['name'] = '$LANG.tab_latestscreenshots'; + $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_userscreenshots, '.$nFound.')'; + } + + $this->lvTabs[] = $lvData; + } + + // Videos + if ($_ = CommunityContent::getVideos(-$this->user['id'], 0, $nFound)) + { + $lvData = array( + 'file' => 'video', + 'data' => $_, + 'params' => array( + '_totalCount' => $nFound + ) + ); + + if ($nFound > CFG_SQL_LIMIT_DEFAULT) + { + $lvData['params']['name'] = '$LANG.tab_latestvideos'; + $lvData['params']['note'] = '$$WH.sprintf(LANG.lvnote_uservideos, '.$nFound.')'; + } + + $this->lvTabs[] = $lvData; + } + + // forum -> latest topics [unused] + + // forum -> latest replies [unused] + + // Characters [todo] + $this->user['characterData'] = []; + + // Profiles [todo] + $this->user['profileData'] = []; + } + + protected function generateTitle() + { + array_unshift($this->title, sprintf(Lang::user('profileTitle'), $this->user['displayName'])); + } + + protected function generatePath() { } +} + +?> diff --git a/static/js/global.js b/static/js/global.js index 9b8f35c6..729cde2c 100644 --- a/static/js/global.js +++ b/static/js/global.js @@ -9237,9 +9237,9 @@ Listview.funcBox = { }, moneyCurrencyOver: function(currencyId, count, e) { - var buff = g_gatheredcurrencies[currencyId]['name_' + Locale.getName() /*g_loc.getName()*/]; + var buff = g_gatheredcurrencies[currencyId]['name_' + Locale.getName()]; - // justice / valor points handling removed + // sarjuuk: justice / valor points handling removed $WH.Tooltip.showAtCursor(e, buff, 0, 0, 'q1'); }, diff --git a/static/js/user.js b/static/js/user.js index 41a4f281..ead84545 100644 --- a/static/js/user.js +++ b/static/js/user.js @@ -1,541 +1,599 @@ -function us_isOwnProfile() { - return (typeof g_pageInfo == "object" && g_user.name == g_pageInfo.username) +/* +JS code for "user" pages +*/ + +function us_isOwnProfile() +{ + return (typeof g_pageInfo == 'object' && g_user.name == g_pageInfo.username); } -function us_addDescription() { - var e = $WH.ge("description"); - var c = us_isOwnProfile(); - var f = (e.childNodes.length == 0); - if (f) { - if (c) { - $WH.ae(e, $WH.ct(LANG.user_nodescription2)) - } else { - $WH.ae(e, $WH.ct(LANG.user_nodescription)) - } + +function us_addDescription() +{ + var _ = $WH.ge('description'); + var ownProfile = us_isOwnProfile(); + var emptyDesc = (_.childNodes.length == 0); + + if (emptyDesc) + { + if (ownProfile) + $WH.ae(_, $WH.ct(LANG.user_nodescription2)); + else + $WH.ae(_, $WH.ct(LANG.user_nodescription)); } - if (c) { - var a = $WH.ce("button"), - g = $WH.ce("div"); - g.className = "pad"; - a.onclick = function () { - location.href = "?account#community" - }; - if (f) { - $WH.ae(a, $WH.ct(LANG.user_composeone)) - } else { - $WH.ae(a, $WH.ct(LANG.user_editdescription)) - } - $WH.ae(e, g); - $WH.ae(e, a) + + if (ownProfile) + { + var + b = $WH.ce('button'), + d = $WH.ce('div'); + + d.className = 'pad'; + b.onclick = function() { location.href = '?account#community' }; + if (emptyDesc) + $WH.ae(b, $WH.ct(LANG.user_composeone)); + else + $WH.ae(b, $WH.ct(LANG.user_editdescription)); + + $WH.ae(_, d); + $WH.ae(_, b); } } -function us_addCharactersTab(e) { - var c = (us_isOwnProfile() || g_user.roles & U_GROUP_MODERATOR); - if (!c) { - var b = []; - for (var d = 0, a = e.length; d < a; ++d) { - e[d].pinned = false; - if (e[d].published && !e[d].deleted) { - b.push(e[d]) - } + +function us_addCharactersTab(data) +{ + var ownProfile = (us_isOwnProfile() || g_user.roles & U_GROUP_MODERATOR); + + if (!ownProfile) + { + var temp = []; + for (var i = 0, len = data.length; i < len; ++i) + { + data[i].pinned = false; + if (data[i].published && !data[i].deleted) + temp.push(data[i]); } - e = b + data = temp; } - if (e.length) { + + if (data.length) new Listview({ - template: "profile", - id: "characters", - name: LANG.tab_characters, - tabs: tabsRelated, - parent: "listview-generic", + template: 'profile', + id: 'characters', + name: LANG.tab_characters, + tabs: tabsRelated, + parent: 'lv-generic', onBeforeCreate: Listview.funcBox.beforeUserCharacters, - sort: [ - 11], - visibleCols: ["race", "classs", "level", "talents", "gearscore", "achievementpoints"], - data: e - }) - } + sort: [-11], + visibleCols: ['race', 'classs', 'level', 'talents', 'gearscore', 'achievementpoints'], + data: data + }); } -function us_addProfilesTab(e) { - var c = (us_isOwnProfile() || g_user.roles & U_GROUP_MODERATOR); - if (!c) { - var b = []; - for (var d = 0, a = e.length; d < a; ++d) { - if (e[d].published && !e[d].deleted) { - b.push(e[d]) - } + +function us_addProfilesTab(data) +{ + var ownProfile = (us_isOwnProfile() || g_user.roles & U_GROUP_MODERATOR); + + if (!ownProfile) + { + var temp = []; + for (var i = 0, len = data.length; i < len; ++i) + { + if (data[i].published && !data[i].deleted) + temp.push(data[i]); } - e = b + data = temp; } - if (e.length) { + + if (data.length) new Listview({ - template: "profile", - id: "profiles", - name: LANG.tab_profiles, - tabs: tabsRelated, - parent: "listview-generic", + template: 'profile', + id: 'profiles', + name: LANG.tab_profiles, + tabs: tabsRelated, + parent: 'lv-generic', onBeforeCreate: Listview.funcBox.beforeUserProfiles, - sort: [ - 11], - visibleCols: ["race", "classs", "level", "talents", "gearscore"], - hiddenCols: ["location", "guild"], - data: e - }) - } + sort: [-11], + visibleCols: ['race', 'classs', 'level', 'talents', 'gearscore'], + hiddenCols: ['location', 'guild'], + data: data + }); } -Listview.funcBox.beforeUserComments = function () { - if (us_isOwnProfile() || (g_user.roles & U_GROUP_COMMENTS_MODERATOR)) { + +Listview.funcBox.beforeUserComments = function() +{ + if (g_user.roles & U_GROUP_COMMENTS_MODERATOR) // Admin, Bureau, Mod + { this.mode = 1; - this.createCbControls = function (b) { - var a = $WH.ce("input"); - a.type = "button"; - a.value = "Delete"; - a.onclick = (function () { - var e = this.getCheckedRows(); - if (!e.length) { - alert("No comments selected.") - } else { - if (confirm("Are you sure that you want to delete " + (e.length == 1 ? "this comment": "these " + e.length + " comments") + "?")) { - var c = ""; - var d = 0; - $WH.array_walk(e, function (f) { - if (!f.purged && !f.deleted) { - f.deleted = 1; - if (f.__tr != null) { - f.__tr.__status.innerHTML = LANG.lvcomment_deleted - } - c += f.id + "," - } else { - if (f.purged == 1) {++d - } - } - }); - c = $WH.rtrim(c, ","); - if (c != "") { - new Ajax("?comment=delete&id=" + c + "&username=" + g_pageInfo.username) - } (Listview.cbSelect.bind(this, false))(); - if (d > 0) { - alert("Purged comments cannot be deleted.\n\nA purged comment is a comment that has been\nautomatically removed from the site due to a negative rating.") - } - } - } - }).bind(this); - $WH.ae(b, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = "Undelete"; - a.onclick = (function () { - var d = this.getCheckedRows(); - if (!d.length) { - alert("No comments selected.") - } else { - var c = ""; - $WH.array_walk(d, function (e) { - if (e.deleted) { - e.deleted = 0; - if (e.__tr != null) { - e.__tr.__status.innerHTML = "" - } - c += e.id + "," + this.createCbControls = function(d) + { + var i = $WH.ce('input'); + i.type = 'button'; + i.value = 'Delete'; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert('No comments selected.'); + else if (confirm('Are you sure that you want to delete ' + (rows.length == 1 ? 'this comment' : 'these ' + rows.length + ' comments') + '?')) + { + var ids = ""; + $WH.array_walk(rows, function(x) + { + if (!x.deleted) + { + x.deleted = 1; + if (x.__tr != null) + x.__tr.__status.innerHTML = LANG.lvcomment_deleted; + ids += x.id + ',' } }); - c = $WH.rtrim(c, ","); - if (c != "") { - new Ajax("?comment=undelete&id=" + c + "&username=" + g_pageInfo.username) - } (Listview.cbSelect.bind(this, false))() + ids = $WH.rtrim(ids, ','); + if (ids != '') + $.post('?comment=delete', { id: ids, username: g_pageInfo.username }); + (Listview.cbSelect.bind(this, false))(); } }).bind(this); - $WH.ae(b, a) + $WH.ae(d, i); + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = 'Undelete'; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert('No comments selected.'); + else + { + var ids = ''; + + $WH.array_walk(rows, function(x) + { + if (x.deleted) + { + x.deleted = 0; + if (x.__tr != null) + x.__tr.__status.innerHTML = ''; + ids += x.id + ',' + } + }); + ids = $WH.rtrim(ids, ','); + if (ids != '') + $.post('?comment=undelete', { id: ids, username: g_pageInfo.username }); + (Listview.cbSelect.bind(this, false))(); + } + }).bind(this); + $WH.ae(d, i); } - } - this.customFilter = function (b, a) { - return (us_isOwnProfile() || (g_user.roles & U_GROUP_COMMENTS_MODERATOR) ? 1 : !(b.deleted || b.purged || b.removed)) }; - this.onAfterCreate = function () { - if (this.nRowsVisible == 0) { - if (this.tabs.tabs.length == 1) { - $("#related, #tabs-related, #listview-generic").remove() - } else { - if (!this.tabs.tabs[this.tabIndex].hidden) { - this.tabs.hide(this.tabIndex, 0) - } - } - } else { - this.updateTabName() + + this.customFilter = function (comment, i) + { + // return (us_isOwnProfile() || (g_user.roles & U_GROUP_COMMENTS_MODERATOR) ? 1 : !(comment.deleted || comment.purged || comment.removed)) + return (g_user.roles & U_GROUP_COMMENTS_MODERATOR ? i < 250 : !(comment.deleted || comment.removed)) + }; + + this.onAfterCreate = function() + { + if (this.nRowsVisible == 0) + { + if (this.tabs.tabs.length == 1) // Delete related section + $("#related, #tabs-related, #lv-generic").remove() + else if (!this.tabs.tabs[this.tabIndex].hidden) + this.tabs.hide(this.tabIndex, 0); } - } + else + this.updateTabName() + }; }; -Listview.funcBox.beforeUserCharacters = function () { - var a = (us_isOwnProfile() || (g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU))); - if (a) { + +Listview.funcBox.beforeUserCharacters = function() +{ + var ownProfile = (us_isOwnProfile() || (g_user.roles & (U_GROUP_ADMIN|U_GROUP_BUREAU))); + + if (ownProfile) + { this.mode = 1; - this.createCbControls = function (e, c) { - if (!c && this.data.length < 15) { - return - } - var b = $WH.ce("input"); - b.type = "button"; - b.value = LANG.button_remove; - b.onclick = (function () { - var f = this.getCheckedRows(); - if (!f.length) { - alert(LANG.message_nocharacterselected) - } else { - if (confirm(LANG.confirm_unlinkcharacter)) { - var d = ""; - $WH.array_walk(f, function (g) { - d += g.id + "," - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?profile=unlink&id=" + d + "&user=" + g_pageInfo.username) + this.createCbControls = function(d, topBar) + { + if (!topBar && this.data.length < 15) + return; + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_remove; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert(LANG.message_nocharacterselected); + else if (confirm(LANG.confirm_unlinkcharacter)) + { + var ids = ''; + + $WH.array_walk(rows, function(x) + { + ids += x.id + ','; + }); + ids = $WH.rtrim(ids, ','); + if (ids != '') + new Ajax('?profile=unlink&id=' + ids + '&user=' + g_pageInfo.username); + this.deleteRows(rows); + } + }).bind(this); + $WH.ae(d, i); + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_makepub; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert(LANG.message_noprofileselected); + else if (confirm(LANG.confirm_publicprofile)) + { + var ids = ''; + + $WH.array_walk(rows, function(x) + { + if (!x.published) + { + x.published = 1; + if (x.__tr != null) + x.__tr.__status.innerHTML = ''; + ids += x.id + ',' } - this.deleteRows(f) - } + }); + ids = $WH.rtrim(ids, ','); + if (ids != '') + new Ajax('?profile=public&id=' + ids + '&user=' + g_pageInfo.username + '&bookmarked'); + (Listview.cbSelect.bind(this, false))(); } }).bind(this); - $WH.ae(e, b); - var b = $WH.ce("input"); - b.type = "button"; - b.value = LANG.button_makepub; - b.onclick = (function () { - var f = this.getCheckedRows(); - if (!f.length) { - alert(LANG.message_noprofileselected) - } else { - if (confirm(LANG.confirm_publicprofile)) { - var d = ""; - $WH.array_walk(f, function (g) { - if (!g.published) { - g.published = 1; - if (g.__tr != null) { - g.__tr.__status.innerHTML = "" - } - d += g.id + "," - } - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?profile=public&id=" + d + "&user=" + g_pageInfo.username + "&bookmarked") - } (Listview.cbSelect.bind(this, false))() - } - } - }).bind(this); - $WH.ae(e, b); - var b = $WH.ce("input"); - b.type = "button"; - b.value = LANG.button_makepriv; - b.onclick = (function () { - var f = this.getCheckedRows(); - if (!f.length) { - alert(LANG.message_noprofileselected) - } else { - if (confirm(LANG.confirm_privateprofile)) { - var d = ""; - $WH.array_walk(f, function (g) { - if (g.published) { - g.published = 0; - if (g.__tr != null) { - g.__tr.__status.innerHTML = LANG.privateprofile - } - d += g.id + "," - } - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?profile=private&id=" + d + "&user=" + g_pageInfo.username + "&bookmarked") - } (Listview.cbSelect.bind(this, false))() - } - } - }).bind(this); - $WH.ae(e, b); - var b = $WH.ce("input"); - b.type = "button"; - b.value = LANG.button_pin; - b.onclick = (function () { - var f = this.getCheckedRows(); - if (!f.length) { - alert(LANG.message_nocharacterselected) - } else { - if (f.length > 1) { - alert(LANG.message_toomanycharacters) - } else { - if (confirm(LANG.confirm_pincharacter)) { - var d = []; - $WH.array_walk(f, function (g) { - d.push(g.id) - }); - $WH.array_walk(this.data, function (g) { - g.pinned = ($WH.in_array(d, g.id) != -1); - if (g.__tr != null) { - var h = $WH.gE(g.__tr, "a")[1]; - h.className = (g.pinned ? "icon-star-right": "") - } - }); - d = d.join(","); - if (d != "") { - new Ajax("?profile=pin&id=" + d + "&user=" + g_pageInfo.username) - } (Listview.cbSelect.bind(this, false))() + $WH.ae(d, i); + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_makepriv; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert(LANG.message_noprofileselected); + else if (confirm(LANG.confirm_privateprofile)) + { + var ids = ''; + + $WH.array_walk(rows, function(x) + { + if (x.published) + { + x.published = 0; + if (x.__tr != null) + x.__tr.__status.innerHTML = LANG.privateprofile; + ids += x.id + ',' } - } + }); + ids = $WH.rtrim(ids, ','); + if (ids != '') + new Ajax('?profile=private&id=' + ids + '&user=' + g_pageInfo.username + '&bookmarked'); + (Listview.cbSelect.bind(this, false))(); } }).bind(this); - $WH.ae(e, b); - var b = $WH.ce("input"); - b.type = "button"; - b.value = LANG.button_unpin; - b.onclick = (function () { - var f = this.getCheckedRows(); - if (!f.length) { - alert(LANG.message_nocharacterselected) - } else { - if (confirm(LANG.confirm_unpincharacter)) { - var d = []; - $WH.array_walk(f, function (g) { - d.push(g.id) - }); - $WH.array_walk(this.data, function (g) { - g.pinned = ($WH.in_array(d, g.id) == -1); - if (g.__tr != null) { - var h = $WH.gE(g.__tr, "a")[1]; - h.className = (g.pinned ? "icon-star-right": "") - } - }); - d = d.join(","); - if (d != "") { - new Ajax("?profile=unpin&id=" + d + "&user=" + g_pageInfo.username) - } (Listview.cbSelect.bind(this, false))() - } + $WH.ae(d, i); + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_pin; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert(LANG.message_nocharacterselected); + else if (rows.length > 1) + alert(LANG.message_toomanycharacters); + else if (confirm(LANG.confirm_pincharacter)) + { + var ids = []; + $WH.array_walk(rows, function(x) { ids.push(x.id) }); + $WH.array_walk(this.data, function(x) + { + x.pinned = ($WH.in_array(ids, x.id) != -1); + if (x.__tr != null) + { + var a = $WH.gE(x.__tr, 'a')[1]; + a.className = (x.pinned ? 'icon-star-right' : ''); + } + }); + ids = ids.join(','); + if (ids != '') + new Ajax('?profile=pin&id=' + ids + '&user=' + g_pageInfo.username); + (Listview.cbSelect.bind(this, false))(); } }).bind(this); - $WH.ae(e, b); - if (g_user.roles & (U_GROUP_ADMIN | U_GROUP_BUREAU)) { - var b = $WH.ce("input"); - b.type = "button"; - b.value = LANG.button_resync; - b.onclick = (function () { - var f = this.getCheckedRows(); - if (!f.length) { - alert(LANG.message_nocharacterselected) - } else { - var d = ""; - $WH.array_walk(f, function (h) { - d += h.id + "," + $WH.ae(d, i); + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_unpin; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert(LANG.message_nocharacterselected); + else if (confirm(LANG.confirm_unpincharacter)) + { + var ids = []; + $WH.array_walk(rows, function(x) { ids.push(x.id) }); + $WH.array_walk(this.data, function(x) + { + x.pinned = ($WH.in_array(ids, x.id) == -1); + if (x.__tr != null) + { + var a = $WH.gE(x.__tr, 'a')[1]; + a.className = (x.pinned ? 'icon-star-right' : ''); + } + }); + ids = ids.join(','); + if (ids != '') + new Ajax('?profile=unpin&id=' + ids + '&user=' + g_pageInfo.username); + (Listview.cbSelect.bind(this, false))(); + } + }).bind(this); + $WH.ae(d, i); + + if (g_user.roles & (U_GROUP_ADMIN|U_GROUP_BUREAU)) + { + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_resync; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert(LANG.message_nocharacterselected); + else + { + var ids = ''; + + $WH.array_walk(rows, function(x) + { + ids += x.id + ',' }); - d = $WH.rtrim(d, ","); - if (d != "") { - var g = $WH.ge("roster-status"); - g.innerHTML = LANG.pr_queue_addqueue; - g.style.display = ""; - new Ajax("?profile=resync&id=" + d, { - method: "POST", - onSuccess: function (j, h) { - var i = parseInt(j.responseText); - if (isNaN(i)) { - alert(LANG.message_resyncerror + i) - } else { - if (i < 0 && i != -102) { - alert(LANG.message_resyncerror + "#" + i) - } + ids = $WH.rtrim(ids, ','); + if (ids != '') + { + var div = $WH.ge('roster-status'); + div.innerHTML = LANG.pr_queue_addqueue; + div.style.display = ''; + + new Ajax( + '?profile=resync&id=' + ids, + { + method: 'POST', + onSuccess: function(xhr, opt) + { + var result = parseInt(xhr.responseText); + + if (isNaN(result)) + alert(LANG.message_resyncerror + result); + else if (result < 0 && result != -102) + alert(LANG.message_resyncerror + '#' + result); + + pr_updateStatus('profile', div, ids, true); } - pr_updateStatus("profile", g, d, true) } - }) - } (Listview.cbSelect.bind(this, false))() + ); + } + (Listview.cbSelect.bind(this, false))(); } }).bind(this); - $WH.ae(e, b) + $WH.ae(d, i); } } } }; -Listview.funcBox.beforeUserProfiles = function () { - if (us_isOwnProfile()) { + +Listview.funcBox.beforeUserProfiles = function() +{ + if (us_isOwnProfile()) + { this.mode = 1; - this.createCbControls = function (c, b) { - if (!b && this.data.length < 15) { - return - } - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_new; - a.onclick = function () { - document.location.href = "?profile&new" - }; - $WH.ae(c, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_delete; - a.onclick = (function () { - var e = this.getCheckedRows(); - if (!e.length) { - alert(LANG.message_noprofileselected) - } else { - if (confirm(LANG.confirm_deleteprofile)) { - var d = ""; - $WH.array_walk(e, function (f) { - d += f.id + "," - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?profile=delete&id=" + d) + this.createCbControls = function(d, topBar) + { + if (!topBar && this.data.length < 15) + return; + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_new; + i.onclick = function() { document.location.href = '?profile&new' }; + $WH.ae(d, i); + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_delete; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert(LANG.message_noprofileselected); + else if (confirm(LANG.confirm_deleteprofile)) + { + var ids = ''; + + $WH.array_walk(rows, function(x) + { + ids += x.id + ','; + }); + ids = $WH.rtrim(ids, ','); + if (ids != '') + new Ajax('?profile=delete&id=' + ids); + this.deleteRows(rows); + } + }).bind(this); + $WH.ae(d, i); + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_makepub; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert(LANG.message_noprofileselected); + else if (confirm(LANG.confirm_publicprofile)) + { + var ids = ''; + + $WH.array_walk(rows, function(x) + { + if (!x.published) + { + x.published = 1; + if (x.__tr != null) + x.__tr.__status.innerHTML = ''; + ids += x.id + ',' } - this.deleteRows(e) - } + }); + ids = $WH.rtrim(ids, ','); + if (ids != '') + new Ajax('?profile=public&id=' + ids); + (Listview.cbSelect.bind(this, false))(); } }).bind(this); - $WH.ae(c, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_makepub; - a.onclick = (function () { - var e = this.getCheckedRows(); - if (!e.length) { - alert(LANG.message_noprofileselected) - } else { - if (confirm(LANG.confirm_publicprofile)) { - var d = ""; - $WH.array_walk(e, function (f) { - if (!f.published) { - f.published = 1; - if (f.__tr != null) { - f.__tr.__status.innerHTML = "" - } - d += f.id + "," - } - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?profile=public&id=" + d) - } (Listview.cbSelect.bind(this, false))() - } + $WH.ae(d, i); + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_makepriv; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert(LANG.message_noprofileselected); + else if (confirm(LANG.confirm_privateprofile)) + { + var ids = ''; + + $WH.array_walk(rows, function(x) + { + if (x.published) + { + x.published = 0; + if (x.__tr != null) + x.__tr.__status.innerHTML = LANG.privateprofile; + ids += x.id + ',' + } + }); + ids = $WH.rtrim(ids, ','); + if (ids != '') + new Ajax('?profile=private&id=' + ids); + (Listview.cbSelect.bind(this, false))(); } }).bind(this); - $WH.ae(c, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_makepriv; - a.onclick = (function () { - var e = this.getCheckedRows(); - if (!e.length) { - alert(LANG.message_noprofileselected) - } else { - if (confirm(LANG.confirm_privateprofile)) { - var d = ""; - $WH.array_walk(e, function (f) { - if (f.published) { - f.published = 0; - if (f.__tr != null) { - f.__tr.__status.innerHTML = LANG.privateprofile - } - d += f.id + "," - } - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?profile=private&id=" + d) - } (Listview.cbSelect.bind(this, false))() - } - } - }).bind(this); - $WH.ae(c, a) + $WH.ae(d, i); } } }; -Listview.funcBox.beforeUserSignatures = function () { - if (us_isOwnProfile()) { + +Listview.funcBox.beforeUserSignatures = function() +{ + if (us_isOwnProfile()) + { this.mode = 1; - this.createCbControls = function (c, b) { - if (!b && this.data.length < 15) { - return - } - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_delete; - a.onclick = (function () { - var e = this.getCheckedRows(); - if (!e.length) { - alert(LANG.message_nosignatureselected) - } else { - if (confirm(LANG.confirm_deletesignature)) { - var d = ""; - $WH.array_walk(e, function (f) { - d += f.id + "," - }); - d = $WH.rtrim(d, ","); - if (d != "") { - new Ajax("?signature=delete&id=" + d) - } - this.deleteRows(e); - this.resetCheckedRows(); - this.refreshRows() - } + this.createCbControls = function(d, topBar) + { + if (!topBar && this.data.length < 15) + return; + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_delete; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert(LANG.message_nosignatureselected); + else if (confirm(LANG.confirm_deletesignature)) + { + var ids = ''; + + $WH.array_walk(rows, function(x) + { + ids += x.id + ','; + }); + ids = $WH.rtrim(ids, ','); + if (ids != '') + new Ajax('?signature=delete&id=' + ids); + this.deleteRows(rows); + this.resetCheckedRows(); + this.refreshRows(); } }).bind(this); - $WH.ae(c, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_edit; - a.onclick = (function () { - var d = this.getCheckedRows(); - if (!d.length) { - alert(LANG.message_nosignatureselected) - } else { - if (d.length > 1) { - alert(LANG.message_toomanysignatures) - } else { - document.location.href = "?signature=" + d[0].id - } - } + $WH.ae(d, i); + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_edit; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert(LANG.message_nosignatureselected); + else if (rows.length > 1) + alert(LANG.message_toomanysignatures); + else + document.location.href = '?signature=' + rows[0].id; }).bind(this); - $WH.ae(c, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_markup; - a.onclick = (function () { - var d = this.getCheckedRows(); - if (!d.length) { - alert(LANG.message_nosignatureselected) - } else { - if (d.length > 1) { - alert(LANG.message_toomanysignatures) - } else { - prompt(LANG.prompt_signaturemarkup, "[url=" + this.getItemLink(d[0]) + "][sig=" + d[0].id + "][/url]") - } - } + $WH.ae(d, i); + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_markup; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert(LANG.message_nosignatureselected); + else if (rows.length > 1) + alert(LANG.message_toomanysignatures); + else + prompt(LANG.prompt_signaturemarkup, '[url=' + this.getItemLink(rows[0]) + '][sig=' + rows[0].id + '][/url]'); }).bind(this); - $WH.ae(c, a); - var a = $WH.ce("input"); - a.type = "button"; - a.value = LANG.button_link; - a.onclick = (function () { - var d = this.getCheckedRows(); - if (!d.length) { - alert(LANG.message_nosignatureselected) - } else { - if (d.length > 1) { - alert(LANG.message_toomanysignatures) - } else { - prompt(LANG.prompt_signaturedirect, "http://" + location.host + "?signature=generate&id=" + d[0].id + ".png") - } - } + $WH.ae(d, i); + + var i = $WH.ce('input'); + i.type = 'button'; + i.value = LANG.button_link; + i.onclick = (function() + { + var rows = this.getCheckedRows(); + if (!rows.length) + alert(LANG.message_nosignatureselected); + else if (rows.length > 1) + alert(LANG.message_toomanysignatures); + else + prompt(LANG.prompt_signaturedirect, 'http://' + location.host + '?signature=generate&id=' + rows[0].id + '.png'); }).bind(this); - $WH.ae(c, a) + $WH.ae(d, i); } } }; + Listview.extraCols.signature = { - id: "signature", + id: 'signature', name: LANG.signature, - before: "name", - align: "left", - compute: function (d, e, c) { - var b = $WH.ce("a"); - b.style.fontFamily = "Verdana, sans-serif"; - b.href = this.getItemLink(d); - b.rel = "np"; - $WH.ae(b, $WH.ce("img", { - src: "?signature=generate&id=" + d.id + ".png", - height: 60, - width: 468 - })); - $WH.ae(e, b) + before: 'name', + align: 'left', + compute: function(sig, td, tr) + { + var a = $WH.ce('a'); + a.style.fontFamily = 'Verdana, sans-serif'; + a.href = this.getItemLink(sig); + a.rel = 'np'; + $WH.ae(a, $WH.ce('img', { src: '?signature=generate&id=' + sig.id + '.png', height: 60, width: 468 })); + $WH.ae(td, a); } }; \ No newline at end of file diff --git a/template/bricks/infobox.tpl.php b/template/bricks/infobox.tpl.php index 807c7b86..c863e283 100644 --- a/template/bricks/infobox.tpl.php +++ b/template/bricks/infobox.tpl.php @@ -15,7 +15,7 @@ endif; if (!empty($this->contributions)): ?> - +
diff --git a/template/bricks/lvTabs.tpl.php b/template/bricks/lvTabs.tpl.php index ab43fe0c..a3775116 100644 --- a/template/bricks/lvTabs.tpl.php +++ b/template/bricks/lvTabs.tpl.php @@ -1,6 +1,6 @@ user) ? 'tabsRelated' : 'myTabs'; $isTabbed = !empty($this->forceTabs) || $relTabs || count($this->lvTabs) > 1; if ($isTabbed): @@ -42,7 +42,14 @@ foreach ($this->lvTabs as $lv): endif; endforeach; -if ($relTabs): +if (!empty($this->user)): + if (!empty($this->user['characterData'])): + echo ' us_addCharactersTab('.Util::toJSON($this->user['characterData']).");\n"; + endif; + if (!empty($this->user['profileData'])): + echo ' us_addProfilesTab('.Util::toJSON($this->user['profileData']).");\n"; + endif; +elseif ($relTabs): ?> new Listview({template: 'comment', id: 'comments', name: LANG.tab_comments, tabs: , parent: 'lv-generic', data: lv_comments}); new Listview({template: 'screenshot', id: 'screenshots', name: LANG.tab_screenshots, tabs: , parent: 'lv-generic', data: lv_screenshots}); diff --git a/template/listviews/commentpreview.tpl.php b/template/listviews/commentpreview.tpl.php index 3bb9641c..c36f406a 100644 --- a/template/listviews/commentpreview.tpl.php +++ b/template/listviews/commentpreview.tpl.php @@ -1,9 +1,9 @@ new Listview({ template:'commentpreview', $v): if ($v[0] == '$'): diff --git a/template/listviews/screenshot.tpl.php b/template/listviews/screenshot.tpl.php index 2254c94d..4f67055a 100644 --- a/template/listviews/screenshot.tpl.php +++ b/template/listviews/screenshot.tpl.php @@ -1,8 +1,9 @@ new Listview({ template:'screenshot', $v): if ($v[0] == '$'): diff --git a/template/pages/admin/screenshots.tpl.php b/template/pages/admin/screenshots.tpl.php index 4455016b..bd39c0e4 100644 --- a/template/pages/admin/screenshots.tpl.php +++ b/template/pages/admin/screenshots.tpl.php @@ -24,7 +24,7 @@ $this->brick('pageTemplate');