Changeset 390

Show
Ignore:
Timestamp:
04/05/08 14:29:00 (5 years ago)
Author:
d0nut
Message:

socialaccess is used for permissions

Location:
buddyloo
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • buddyloo/files/js/buddylooSocial.js

    r389 r390  
    2121function buddylooLockSocial(ob) { 
    2222        locked = (locked+1) % 3; 
    23         $.post('index.php?action=BuddylooSocial&handle=lockSocial&userID='+userID+'&socialID='+socialID, 'locked='+locked, function(data) { 
     23        $.post('index.php?action=BuddylooSocial&handle=lockSocial&userID='+userID+'&socialID='+socialID, 'socialAccess='+locked, function(data) { 
    2424                buddylooMessage('Info', language['wcf.buddyloo.social.page.access.'+locked]); 
    2525                ob.src = RELATIVE_WCF_DIR+'icon/'+buddylooAccessIcons[locked]+'.png';    
  • buddyloo/files/lib/action/BuddylooSocialAction.class.php

    r389 r390  
    1818        public $visible = -1; 
    1919        public $handle = ""; 
     20        public $socialAccess = 0; 
    2021         
    2122        /** 
     
    3738                if (isset($_REQUEST['handle'])) $this->handle = $_REQUEST['handle']; 
    3839                 
    39                 if (isset($_REQUEST['socialTitle'])) $this->socialTitle = $_REQUEST['socialTitle'];              
     40                if (isset($_REQUEST['socialTitle'])) $this->socialTitle = $_REQUEST['socialTitle']; 
     41                if (isset($_REQUEST['socialAccess'])) $this->socialAccess = intval($_REQUEST['socialAccess']);   
    4042                 
    4143                // remove or hide 
     
    7173                        throw new PermissionDeniedException(); 
    7274                } 
    73                  
     75 
    7476                // check users settings 
    7577                //TODO 
     
    104106                                        SET             socialTitle = '".escapeString($this->socialTitle)."' 
    105107                                        WHERE           socialID = ".$this->socialID; 
     108                                WCF::getDB()->sendQuery($sql); 
     109                        break; 
     110                        case 'lockSocial': 
     111                                $sql = "UPDATE          wcf".WCF_N."_buddyloo_social 
     112                                        SET             socialAccess = ".$this->socialAccess." 
     113                                        WHERE           socialID = ".$this->socialID; 
     114                                        echo $sql; 
    106115                                WCF::getDB()->sendQuery($sql); 
    107116                        break; 
  • buddyloo/files/lib/data/user/BuddylooSocialData.class.php

    r389 r390  
    3535                        FROM            wcf'.WCF_N.'_buddyloo_user_to_social  us 
    3636                        NATURAL JOIN    wcf'.WCF_N.'_buddyloo_social s 
    37                         WHERE           su.socialID = '.$this->socialID.' 
    38                         AND             su.userID = '.$this->userID; 
     37                        WHERE           us.socialID = '.$this->socialID.' 
     38                        AND             us.userID = '.$this->userID; 
    3939                $row = WCF::getDB()->getFirstRow($sql); 
    4040                $this->access = $row['socialAccess']; 
    41                  
     41 
    4242                $access = $this->getPermission(); 
    4343                if(!$access) $access = $this->access>0 && $this->isFriend($this->userID); 
    44                 if(!$access) $access = $this->access>1 && WCF::getUser()->getPermission('user.profile.canSocial'); 
     44                if(!$access) $access = $this->access == 1 && WCF::getUser()->getPermission('user.profile.canSocial'); 
    4545                if($access) $this->fetchColumns(); 
    4646        } 
     
    5757         */ 
    5858        public function getPermission() { 
    59                 return WCF::getUser()->userID == $this->userID || $this->userID === null; 
     59                return WCF::getUser()->userID == $this->userID; 
    6060        } 
    6161 
  • buddyloo/files/lib/system/event/listener/BuddylooUserPageListener.class.php

    r342 r390  
    6666                                } 
    6767                        } 
    68                         if(count($this->eventObj->categories[$keys[$i]]['options']) == 0) { 
     68                        if(isset($keys[$i]) && isset($this->eventObj->categories[$keys[$i]]['options']) && count($this->eventObj->categories[$keys[$i]]['options']) == 0) { 
    6969                                unset($this->eventObj->categories[$keys[$i]]); 
    7070                        } 
  • buddyloo/files/lib/system/event/listener/BuddylooUserProfileMenuListener.class.php

    r375 r390  
    2020                $this->eventObj = $eventObj; 
    2121                $this->className = $className; 
    22                  
    23                 if(!WCF::getUser()->getPermission('user.profile.canSocial') || !$this->getPermission()) return; 
    2422 
    2523                switch ($eventName) { 
     
    7068                } 
    7169        } 
     70 
     71        /** 
     72         * checks if i am in the friendlist of the user 
     73         */ 
     74        protected function isFriend($userID) { 
     75                WCF::getCache()->addResource('buddyloo.friendships',  
     76                        WCF_DIR.'cache/cache.buddyloo.friendships.php', 
     77                        WCF_DIR.'lib/system/cache/CacheBuilderBuddylooFriendships.class.php'); 
     78                         
     79                $cache = WCF::getCache()->get('buddyloo.friendships'); 
     80                return isset($cache[$userID]) && in_array(WCF::getUser()->userID, $cache[$userID]); 
     81        } 
    7282         
    7383        /** 
     
    8999                        FROM            wcf'.WCF_N.'_buddyloo_user_to_social us 
    90100                        NATURAL JOIN    wcf'.WCF_N.'_buddyloo_social s 
    91                         JOIN            wcf'.WCF_N.'_user u 
    92                         ON              us.userID = u.userID 
    93101                        WHERE           us.userID = '.$this->eventObj->userID.' 
     102                        AND ( 
     103                                        '.($this->getPermission()?1:0).' 
     104                                OR ( 
     105                                                s.socialAccess = 1 
     106                                        OR ( 
     107                                                s.socialAccess = 2 AND  '.($this->isFriend($this->eventObj->userID)?1:0).' 
     108                                        ) 
     109                                ) 
     110                        ) 
    94111                        ORDER BY        icolumn ASC'; 
    95112                $result = WCF::getDB()->sendQuery($sql); 
  • buddyloo/install.sql

    r389 r390  
    1919  socialID int(10) unsigned NOT NULL auto_increment, 
    2020  socialTitle varchar(80) NOT NULL, 
    21   socialAccess tinyint(1) NOT NULL DEFAULT 0, 
     21  socialAccess tinyint(1) unsigned NOT NULL DEFAULT 0, 
    2222  PRIMARY KEY (socialID) 
    2323) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
  • buddyloo/templates/buddylooSocial.tpl

    r389 r390  
    1313                var userID = {$user->userID}; 
    1414                var language = new Array(); 
    15                 var locked = {$social->socialAccess}; 
     15                var locked = {$social->access}; 
    1616                language['wcf.buddyloo.social.page.access.0'] = '{lang}wcf.buddyloo.social.page.access.0{/lang}'; 
    1717                language['wcf.buddyloo.social.page.access.1'] = '{lang}wcf.buddyloo.social.page.access.1{/lang}'; 
     
    3434 
    3535<div id="main"> 
     36        {if $social->getPermission()} 
    3637        <div class="largeButtons"> 
    3738                <ul> 
     
    4243                </ul> 
    4344        </div> 
     45        {/if} 
    4446         
    4547        {capture append=userMessages} 
  • buddyloo/update.sql

    r389 r390  
    44  socialID int(10) unsigned NOT NULL auto_increment, 
    55  socialTitle varchar(80) NOT NULL, 
    6   socialAccess tinyint(1) NOT NULL DEFAULT 0, 
     6  socialAccess tinyint(1) unsigned NOT NULL DEFAULT 0, 
    77  PRIMARY KEY (socialID) 
    88) ENGINE=MyISAM DEFAULT CHARSET=utf8;