diff --git a/include/class.avatar.php b/include/class.avatar.php index d46a066e224f1b99b3cf353007fd8c82dd5cd897..6fbfc6b6302a20d6580a527c1db263d4c51b5cf7 100644 --- a/include/class.avatar.php +++ b/include/class.avatar.php @@ -76,69 +76,6 @@ abstract class AvatarSource { } } -class AvatarsByGravatar -extends AvatarSource { - static $name = 'Gravatar'; - static $id = 'gravatar'; - var $mode; - - function __construct($mode=null) { - $this->mode = $mode ?: 'retro'; - } - - static function getModes() { - return array( - 'mm' => __('Mystery Man'), - 'identicon' => 'Identicon', - 'monsterid' => 'Monster', - 'wavatar' => 'Wavatar', - 'retro' => 'Retro', - 'blank' => 'Blank', - ); - } - - function getAvatar($user) { - return new Gravatar($user, $this->mode); - } -} -AvatarSource::register('AvatarsByGravatar'); - -class Gravatar -extends Avatar { - var $email; - var $d; - var $size; - - function __construct($user, $imageset) { - $this->email = $user->getEmail(); - $this->d = $imageset; - } - - function setSize($size) { - $this->size = $size; - } - - /** - * Get either a Gravatar URL or complete image tag for a specified email address. - * - * @param string $email The email address - * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ] - * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] - * @param string $r Maximum rating (inclusive) [ g | pg | r | x ] - * @param boole $img True to return a complete IMG tag False for just the URL - * @param array $atts Optional, additional key/value attributes to include in the IMG tag - * @return String containing either just a URL or a complete image tag - * @source http://gravatar.com/site/implement/images/php/ - */ - function getUrl($size=null) { - $size = $this->size ?: 80; - $url = '//www.gravatar.com/avatar/'; - $url .= md5( strtolower( $this->email ) ); - $url .= "?s=$size&d={$this->d}"; - return $url; - } -} - class LocalAvatarSource extends AvatarSource { static $id = 'local'; @@ -172,7 +109,7 @@ extends Avatar { // Generate a random string of 0-6 chars for the avatar signature $uid = md5(strtolower($this->user->getEmail())); - return 'avatar.php?'.Http::build_query(array('uid'=>$uid, + return ROOT_PATH . 'avatar.php?'.Http::build_query(array('uid'=>$uid, 'mode' => $this->mode)); } @@ -195,6 +132,9 @@ class RandomAvatar { } function makeAvatar($uid) { + if (!extension_loaded('gd')) + Http::redirect(ROOT_PATH.'images/mystery-oscar.png'); + $sprite = self::$sprites[$this->mode]; $source = imagecreatefrompng(ROOT_DIR . $sprite['file']); $grid = $sprite['grid']; @@ -206,7 +146,7 @@ class RandomAvatar { $white = imagecolorallocate($avatar, 255, 255, 255); imagefill($avatar, 0, 0, $white); - for ($i=0, $k=$height-1; $i<$k; $i++) { + for ($i=0, $k=$height; $i<$k; $i++) { $idx = hexdec($uid[$i]) % $width; imagecopy($avatar, $source, 0, 0, $idx*$grid, $i*$grid, $grid, $grid); } @@ -214,3 +154,65 @@ class RandomAvatar { return $avatar; } } + +class AvatarsByGravatar +extends AvatarSource { + static $name = 'Gravatar'; + static $id = 'gravatar'; + var $mode; + + function __construct($mode=null) { + $this->mode = $mode ?: 'retro'; + } + + static function getModes() { + return array( + 'mm' => __('Mystery Man'), + 'identicon' => 'Identicon', + 'monsterid' => 'Monster', + 'wavatar' => 'Wavatar', + 'retro' => 'Retro', + ); + } + + function getAvatar($user) { + return new Gravatar($user, $this->mode); + } +} +AvatarSource::register('AvatarsByGravatar'); + +class Gravatar +extends Avatar { + var $email; + var $d; + var $size; + + function __construct($user, $imageset) { + $this->email = $user->getEmail(); + $this->d = $imageset; + } + + function setSize($size) { + $this->size = $size; + } + + /** + * Get either a Gravatar URL or complete image tag for a specified email address. + * + * @param string $email The email address + * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ] + * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] + * @param string $r Maximum rating (inclusive) [ g | pg | r | x ] + * @param boole $img True to return a complete IMG tag False for just the URL + * @param array $atts Optional, additional key/value attributes to include in the IMG tag + * @return String containing either just a URL or a complete image tag + * @source http://gravatar.com/site/implement/images/php/ + */ + function getUrl($size=null) { + $size = $this->size ?: 80; + $url = '//www.gravatar.com/avatar/'; + $url .= md5( strtolower( $this->email ) ); + $url .= "?s=$size&d={$this->d}"; + return $url; + } +} diff --git a/include/staff/profile.inc.php b/include/staff/profile.inc.php index 280c63f2c22f5d69afaa1f6486945241553ea283..1662cd901e8efd2414a1ec75d71be0161cf2e84d 100644 --- a/include/staff/profile.inc.php +++ b/include/staff/profile.inc.php @@ -17,6 +17,11 @@ if(!defined('OSTSTAFFINC') || !$staff || !$thisstaff) die('Access Denied'); <div class="tab_content" id="account"> <table class="table two-column" width="940" border="0" cellspacing="0" cellpadding="2"> <tbody> + <tr><td colspan="2"><div> + <div class="avatar pull-left" style="margin: 10px 15px; border-radius: 5px; width: 100px;"> + <?php echo $staff->getAvatar(); ?> + </div> + <table class="table two-column" border="0" cellspacing="2" cellpadding="2" style="width:760px"> <tr> <td class="required"><?php echo __('Name'); ?>:</td> <td> @@ -59,6 +64,7 @@ if(!defined('OSTSTAFFINC') || !$staff || !$thisstaff) die('Access Denied'); <div class="error"><?php echo $errors['mobile']; ?></div> </td> </tr> + </table></div></td></tr> </tbody> <!-- ================================================ --> <tbody> diff --git a/include/staff/settings-agents.inc.php b/include/staff/settings-agents.inc.php index 05d07d1e28f67e04b538eb941b5adc22abe50234..5a7e83230a6a6aaef958b77f6b7780684b477c3c 100644 --- a/include/staff/settings-agents.inc.php +++ b/include/staff/settings-agents.inc.php @@ -47,7 +47,7 @@ if (!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin() || !$config foreach ($modes as $mid=>$mname) { $oid = "$id.$mid"; $selected = ($config['agent_avatar'] == $oid) ? 'selected="selected"' : ''; - echo "<option {$selected} value=\"{$oid}\">{$mname}</option>"; + echo "<option {$selected} value=\"{$oid}\">{$class::getName()} / {$mname}</option>"; } echo "</optgroup>"; } diff --git a/include/staff/staff.inc.php b/include/staff/staff.inc.php index 9a5ad3d296bd20e7c7dd67da71d0958d534679d3..767e00bfcc3ab11c3f4bab59b7dd5ede4347e5c8 100644 --- a/include/staff/staff.inc.php +++ b/include/staff/staff.inc.php @@ -57,6 +57,11 @@ else { <div class="tab_content" id="account"> <table class="table two-column" width="940" border="0" cellspacing="0" cellpadding="2"> <tbody> + <tr><td colspan="2"><div> + <div class="avatar pull-left" style="width: 100px; margin: 10px; border-radius: 5px"> + <?php echo $staff->getAvatar(); ?> + </div> + <table class="table two-column" border="0" cellspacing="2" cellpadding="2" style="width: 760px"> <tr> <td class="required"><?php echo __('Name'); ?>:</td> <td> @@ -99,6 +104,7 @@ else { <div class="error"><?php echo $errors['mobile']; ?></div> </td> </tr> + </table></div></td></tr> </tbody> <!-- ================================================ --> <tbody>