http://atutor.ca/atutor/mantis/view.php?id=4680
authorcindy li <cli@ocad.ca>
Thu, 6 Jan 2011 16:57:42 +0000 (16:57 -0000)
committercindy li <cli@ocad.ca>
Thu, 6 Jan 2011 16:57:42 +0000 (16:57 -0000)
Fix for,
Admin -> edit users -> cannot upload profile picture

docs/mods/_standard/profile_pictures/admin/profile_picture.php
docs/mods/_standard/profile_pictures/html/profile_picture.inc.php
docs/mods/_standard/profile_pictures/save_profile_picture.php

index 4003be7..30fd42f 100644 (file)
@@ -1,21 +1,24 @@
-<?php\r
-/***********************************************************************/\r
-/* ATutor                                                                                                                         */\r
-/***********************************************************************/\r
-/* Copyright (c) 2002-2010                                             */\r
-/* Inclusive Design Institute                                         */\r
-/* http://atutor.ca                                                                                                       */\r
-/*                                                                                                                                        */\r
-/* This program is free software. You can redistribute it and/or          */\r
-/* modify it under the terms of the GNU General Public License            */\r
-/* as published by the Free Software Foundation.                                          */\r
-/***********************************************************************/\r
-// $Id$\r
-// $Id$\r
-define('AT_INCLUDE_PATH', '../include/');\r
-require (AT_INCLUDE_PATH.'vitals.inc.php');\r
-admin_authenticate(AT_ADMIN_PRIV_USERS);\r
-\r
-$member_id = intval($_GET['member_id']);\r
-\r
-require(AT_INCLUDE_PATH.'../mods/_standard/profile_picture/html/profile_picture.inc.php'); ?>
\ No newline at end of file
+<?php
+/***********************************************************************/
+/* ATutor                                                                                                                         */
+/***********************************************************************/
+/* Copyright (c) 2002-2010                                             */
+/* Inclusive Design Institute                                         */
+/* http://atutor.ca                                                                                                       */
+/*                                                                                                                                        */
+/* This program is free software. You can redistribute it and/or          */
+/* modify it under the terms of the GNU General Public License            */
+/* as published by the Free Software Foundation.                                          */
+/***********************************************************************/
+// $Id$
+// $Id$
+define('AT_INCLUDE_PATH', '../../../../include/');
+require (AT_INCLUDE_PATH.'vitals.inc.php');
+admin_authenticate(AT_ADMIN_PRIV_USERS);
+
+$member_id = intval($_GET['member_id']);
+
+require('../save_profile_picture.php');
+
+require(AT_INCLUDE_PATH.'../mods/_standard/profile_pictures/html/profile_picture.inc.php'); 
+?>
\ No newline at end of file
index d7bb3a3..59067b1 100644 (file)
@@ -1,39 +1,51 @@
-<?php\r
-/***********************************************************************/\r
-/* ATutor                                                                                                                         */\r
-/***********************************************************************/\r
-/* Copyright (c) 2002-2010                                             */\r
-/* Inclusive Design Institute                                         */\r
-/* http://atutor.ca                                                                                                       */\r
-/*                                                                                                                                        */\r
-/* This program is free software. You can redistribute it and/or          */\r
-/* modify it under the terms of the GNU General Public License            */\r
-/* as published by the Free Software Foundation.                                          */\r
-/***********************************************************************/\r
-// $Id$\r
-// $Id$\r
-if (!defined('AT_INCLUDE_PATH')) { exit; }\r
-require(AT_INCLUDE_PATH.'header.inc.php');\r
-?>\r
-\r
-<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>?member_id=<?php echo $member_id; ?>" name="form">\r
-<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $_config['prof_pic_max_file_size']; ?>" />\r
-<div class="input-form">\r
-<?php if (profile_image_exists($member_id)): ?>\r
-       <div class="row">\r
-               <a href="get_profile_img.php?id=<?php echo $member_id.SEP.'size=o'; ?>"><img src="get_profile_img.php?id=<?php echo $member_id; ?>" alt="" /></a>\r
-               <input type="checkbox" name="delete" value="1" id="del"/><label for="del"><?php echo _AT('delete'); ?></label>\r
-       </div>\r
-<?php endif; ?>\r
-       <div class="row">\r
-               <h3><?php echo _AT('upload_new_picture'); ?></h3>\r
-               <input type="file" name="file" /> (<?php echo implode(', ', $supported_images); ?>)</div>\r
-\r
-       <div class="row buttons">\r
-               <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" />\r
-               <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />\r
-       </div>\r
-</div>\r
-</form>\r
-\r
+<?php
+/***********************************************************************/
+/* ATutor                                                                                                                         */
+/***********************************************************************/
+/* Copyright (c) 2002-2010                                             */
+/* Inclusive Design Institute                                         */
+/* http://atutor.ca                                                                                                       */
+/*                                                                                                                                        */
+/* This program is free software. You can redistribute it and/or          */
+/* modify it under the terms of the GNU General Public License            */
+/* as published by the Free Software Foundation.                                          */
+/***********************************************************************/
+// $Id$
+// $Id$
+if (!defined('AT_INCLUDE_PATH')) { exit; }
+require(AT_INCLUDE_PATH.'header.inc.php');
+
+$gd_info = gd_info();
+$supported_images = array();
+if ($gd_info['GIF Create Support']) {
+       $supported_images[] = 'gif';
+}
+if ($gd_info['JPG Support'] || $gd_info['JPEG Support']) {
+       $supported_images[] = 'jpg';
+}
+if ($gd_info['PNG Support']) {
+       $supported_images[] = 'png';
+};
+?>
+
+<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>?member_id=<?php echo $member_id; ?>" name="form">
+<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $_config['prof_pic_max_file_size']; ?>" />
+<div class="input-form">
+<?php if (profile_image_exists($member_id)): ?>
+       <div class="row">
+               <a href="get_profile_img.php?id=<?php echo $member_id.SEP.'size=o'; ?>"><img src="get_profile_img.php?id=<?php echo $member_id; ?>" alt="" /></a>
+               <input type="checkbox" name="delete" value="1" id="del"/><label for="del"><?php echo _AT('delete'); ?></label>
+       </div>
+<?php endif; ?>
+       <div class="row">
+               <h3><?php echo _AT('upload_new_picture'); ?></h3>
+               <input type="file" name="file" /> (<?php echo implode(', ', $supported_images); ?>)</div>
+
+       <div class="row buttons">
+               <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" />
+               <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
+       </div>
+</div>
+</form>
+
 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>
\ No newline at end of file
index 331ee34..027ca61 100644 (file)
@@ -11,7 +11,7 @@
 /* as published by the Free Software Foundation.                                          */
 /***********************************************************************/
 
-$member_id = $_SESSION['member_id'];
+if (!isset($member_id) || $member_id == 0) $member_id = $_SESSION['member_id'];
 
 function resize_image($src, $dest, $src_h, $src_w, $dest_h, $dest_w, $type, $src_x=0, $src_y=0) {
        $thumbnail_img = imagecreatetruecolor($dest_w, $dest_h);