/**************************************************
 *              Profile Controller                *
 *              Edit your profile                 *
 **************************************************/

angular.module('cosmo').controller('profileCtrl', ['$scope', 'REST', '$rootScope', 'Users', function($scope, REST, $rootScope, Users){

    // Initialize variables
    $scope.profile = {};
    $scope.profile.email = Users.email;

    // Get the User's profile photo
    REST.users.get({userID: Users.id}, function(data){
        Users.name = data.name;
        Users.bio = data.bio;
        Users.photo = data.photo;
        Users.role = data.role;
        Users.twitter = data.twitter;
        Users.facebook = data.facebook;
        Users.username = data.username;
        Users.email = data.email;
        $scope.profile = data;

        // Check if the photo was just selected from the media picker
        if($rootScope.tempSidebarPic && $rootScope.tempSidebarPic.id === 'profile') {
            $scope.profile.photo = $rootScope.tempSidebarPic.src;
            $rootScope.tempSidebarPic = null;
        } else if(!$scope.profile.photo)
            $scope.profile.photo = 'core/img/image.svg'; // Placeholder image
    });

    // Add a profile photo
    $scope.addProfilePhoto = function(){
        $rootScope.tempSidebarPic = {
            id: 'profile',
            src: $scope.profile,
            sidebar: 'core/html/profile.html'
        }
        $rootScope.$broadcast('editFiles', angular.toJson($rootScope.tempSidebarPic));
    };

    // Update the profile
    $scope.updateProfile = function(){
        REST.users.update({
            userID: Users.id,
            username: Users.username,
            name: $scope.profile.name,
            photo: $scope.profile.photo,
            bio: $scope.profile.bio,
            facebook: $scope.profile.facebook,
            twitter: $scope.profile.twitter,
            email: $scope.profile.email
        }, function(data){
            $translate('profile_updated').then(function(translatedText){
                $rootScope.$broadcast('notify', { message: translatedText });
            });
            $scope.admin.photo = $scope.profile.photo;
        }, function(){
            $translate('profile_error').then(function(translatedText){
                $rootScope.$broadcast('notify', { message: translatedText });
            });
        });
    };

}]);

@@ -294,16 +294,39 @@
 'Users',
+ 'Responsive', 'Hooks',
  functio
@@ -358,17 +358,37 @@
 e, Users
-)
+, Responsive, Hooks) 
 %7B%0A%0A    /
@@ -1070,16 +1070,56 @@
 photo = 
+Hooks.imageHookNotify(Responsive.resize(
 $rootSco
@@ -1139,16 +1139,23 @@
 rPic.src
+, 320))
 ;%0A      
@@ -1486,16 +1486,22 @@
 .profile
+.photo
 ,%0A      
@@ -2282,16 +2282,56 @@
 photo = 
+Hooks.imageHookNotify(Responsive.resize(
 $scope.p
@@ -2338,24 +2338,31 @@
 rofile.photo
+, 320))
 ;%0A        %7D,
@@ -2551,21 +2551,20 @@
     %7D);%0A
+
     %7D;%0A
-%0A
 %7D%5D);%0A

Add image hooks to profile pics