This is the API documentation for concrete5 version 5.6 and earlier. View Current API Documentation
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 
<?php
defined('C5_EXECUTE') or die("Access Denied.");
Loader::controller('/profile/edit');

class Concrete5_Controller_Profile_Avatar extends ProfileEditController {
    
    public function __construct(){
        parent::__construct();
        $html = Loader::helper('html');
        $this->set('av', Loader::helper('concrete/avatar'));
        $this->addHeaderItem($html->javascript('swfobject.js'));
    }

    
    public function save_thumb(){
        $ui = $this->get('ui');
        if (!is_object($ui) || $ui->getUserID() < 1) {
            return false;
        }
        
        if(isset($_POST['thumbnail']) && strlen($_POST['thumbnail'])) {
            $thumb = base64_decode($_POST['thumbnail']);
            $fp = fopen(DIR_FILES_AVATARS."/".$ui->getUserID().".jpg","w");
            if($fp) {
                fwrite($fp,base64_decode($_POST['thumbnail']));
                fclose($fp);
                $data['uHasAvatar'] = 1;
                $ui->update($data);
            }
        }   

        $this->redirect('/profile/avatar', 'saved');
    }
    
    public function saved() {
        $this->set('message', 'Avatar updated!');
    }

    public function deleted() {
        $this->set('message', 'Avatar removed.');
    }
    
    public function delete(){ 
        $ui = $this->get('ui');
        $av = $this->get('av');
        
        $av->removeAvatar($ui);
        $this->redirect('/profile/avatar', 'deleted');
    }

}


?>