Changeset 627 for trunk/app/controllers/users_controller.php
- Timestamp:
- 07/05/08 01:09:56 (5 months ago)
- Files:
-
- 1 modified
-
trunk/app/controllers/users_controller.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/users_controller.php
r614 r627 527 527 public function admin_edit() 528 528 { 529 if ( empty($this->data['User']) ) 530 { 531 $this->layout = 'admin'; 529 if ( empty($this->data['User']) ): 530 $this->layout = 'admin'; 532 531 533 $this->set('Groups', Set::combine($this->User->Group->find('all', array('order' => 'name')), "{n}.Group.id","{n}.Group.name"));532 $this->set('Groups', Set::combine($this->User->Group->find('all', array('order' => 'name')), "{n}.Group.id","{n}.Group.name")); 534 533 535 $this->User->unbindModel($this->User->notNow);534 $this->User->unbindModel($this->User->notNow); 536 535 537 $this->data = $this->User->read(null, $this->Auth->user('id')); 538 } 539 else 540 { 541 //die( debug($this->data['User']) ); 542 if ($this->User->save($this->data['User'])) 543 { 544 $this->msgFlash('User has been updated.','/admin/users/edit/'); 545 } 546 } 536 $this->data = $this->User->read(null, $this->Auth->user('id')); 537 538 else: 539 //die( debug($this->data['User']) ); 540 if ($this->User->save($this->data['User'])): 541 $this->msgFlash(__('User has been updated', true), '/admin/users/edit/'); 542 endif; 543 endif; 547 544 } 548 545 … … 596 593 $this->data['User']['id'] = $id; 597 594 598 if ($this->User->save($this->data)) 599 { 595 if ($this->User->save($this->data['User'])): 600 596 $this->msgFlash('User status changed', '/admin/users/listing/'); 601 } 602 else 603 { 597 else: 604 598 $this->flash('Problem!!', '/admi/users/listing/'); 605 }599 endif; 606 600 } 607 601 608 602 /*** DELETE **/ 609 public function admin_delete($id) 610 { 611 if ($this->User->del($id)) 612 { 613 $this->msgFlash('User has been deleted.', '/admin/users/listing'); 614 } 603 public function admin_delete($user_id) 604 { 605 if ($this->User->del($user_id)): 606 $this->msgFlash(__('User deleted', true), '/admin/users/listing'); 607 endif; 615 608 } 616 609 … … 658 651 /** Security: checks to see if file is an image, if not do not allow upload ==*/ 659 652 660 if ( $type != "image/jpeg" && $type != "image/pjpeg" && $type != "image/png" && $type != "image/gif") 661 { /** is this a valid file? */ 662 $ErrMsg = "<h1>ERROR</h1> the file $imgfile_name $imgfile is not valid.<br>"; 663 $ErrMsg .= "<p>Only .jpg, .gif or .png files<br><br>"; 664 $ErrMsg .= "Current type file: " . $type . "</p>\n"; 665 666 /** delete uploaded file */ 667 unlink($imgfile); 668 die($this->flash($ErrMsg, '/admin/users/edit/') ); 669 } 670 671 if ( $imgfile_size > $maxfilesize) 672 { 673 $ErrMsg = "<h1>ERROR</h1> The image is too big.<br />"; 674 $ErrMsg .= "<p>Bigger than 2.0 MB <br /><br />"; 675 $ErrMsg .= "Current size: " . $imgfile_size ."</p>\n"; 676 677 /** delete uploaded file */ 678 unlink($imgfile); 679 die( $this->flash($ErrMsg,'/admin/users/edit/') ); 680 } 653 if ( $type != "image/jpeg" && $type != "image/pjpeg" && $type != "image/png" && $type != "image/gif"): 654 /** is this a valid file? */ 655 $msg = "Error, the file $imgfile_name $imgfile is not valid, only .jpg, .gif or .png, current type file: " . $type; 656 unlink($imgfile); /** delete uploaded file */ 657 $this->flash($msg, '/admin/users/edit/'); 658 return false; 659 endif; 660 661 if ( $imgfile_size > $maxfilesize): 662 $msg = ">Error. The image is bigger than 2.0 MB Current size: " . $imgfile_size; 663 unlink($imgfile); /** delete uploaded file */ 664 $this->flash($msg,'/admin/users/edit/'); 665 return false; 666 endif; 681 667 682 668 //check size 683 if ($width > 100 || $height > 100) 684 { 685 $ErrMsg = "<h1>ERROR</h1> The image is too large.<br>"; 686 $ErrMsg .= "<p>Widht or height is larger than 100 pixels <br /><br />"; 687 $ErrMsg .= "Current size: width ". $width ."px height ". $height ."px</p>\n"; 688 689 /** delete uploaded file */ 690 unlink($imgfile); 691 die( $this->flash($ErrMsg,'/admin/users/edit/') ); 692 693 } 669 if ($width > 100 || $height > 100): 670 $msg = "Error. Width or height is larger than 100 pixels. Width ". $width ."px, height ". $height ."px</p>\n"; 671 unlink($imgfile); /** delete uploaded file */ 672 $this->flash($msg,'/admin/users/edit/'); 673 return false; 674 endif; 694 675 695 676 $extension = $this->Adds->get_extension($type); … … 703 684 $newfile = $uploaddir . "/" . $final_filename; 704 685 705 /** do extra security check to prevent malicious abuse */ 706 if (is_uploaded_file($imgfile)) 707 { 686 /** do extra security check to prevent malicious abuse */ 687 if (is_uploaded_file($imgfile)): 708 688 /** move file to proper directory ==*/ 709 if (!copy($imgfile, $newfile)) 710 { 689 if (!copy($imgfile, $newfile)): 711 690 /** if an error occurs the file could not be written, read or possibly does not exist */ 712 die($this->flash('Error Uploading File.', '/ users/edit/'.$this->Auth->user('id')));713 }714 }691 die($this->flash('Error Uploading File.', '/admin/users/edit/')); 692 endif; 693 endif; 715 694 716 695 /** Database stuff **/ … … 718 697 $this->data['User']['avatar'] = $final_filename; 719 698 720 if ($this->User->save($this->data)) 721 { 722 $this->redirect('/admin/users/edit/'. $this->Auth->user('id')); 723 } 699 if ($this->User->save($this->data)): 700 $this->redirect('/admin/users/edit/'); 701 endif; 724 702 725 703 /** delete the temporary uploaded file **/
