Esempio n. 1
0
 function onProfileAvatarUpdate($userid, $old_avatar_path, $new_avatar_path)
 {
     // When admin is removing a user's avatar
     // we need to apply default avatar of profiletype
     $isAdmin = XiptHelperUtils::isAdmin(JFactory::getUser()->id);
     $view = JRequest::getVar('view', '', 'GET');
     $task = JRequest::getVar('task', '', 'GET');
     $new_avatar_path = XiptHelperUtils::getRealPath($new_avatar_path);
     if ($isAdmin && $view == 'profile' && $task == 'removepicture') {
         //setup $new_avatar
         $ptype = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE');
         $avatar = XiptLibProfiletypes::getProfiletypeData($ptype, 'avatar');
         //if users avatar is custom avatar then thumb is stored as thumb_XXXX.png
         //else if it is a default avatar(JomSocial OR Profiletype) then stored as XXX_thumb.png
         //HERE the new_avatar will be default jomsocial avatar so search _thumb
         if (JString::stristr($new_avatar_path, 'thumb')) {
             $new_avatar_path = XiptHelperImage::getThumbAvatarFromFull($avatar);
         } else {
             $new_avatar_path = $avatar;
         }
     }
     //check if avatar is ptype default avatar
     if (XiptLibProfiletypes::isDefaultAvatarOfProfileType($old_avatar_path, false)) {
         //HERE we should search for _thumb, not for thumb_
         /**XITODO:: Properly test following::
          * In JS2.2 :: When our default avatar is user.png then JS delete this avatar from(Community/assets/user.png)
          * becoz at delete time its only consider default.jpg (components/com_community/assets/default.jpg)as default value and 
          * if avatar is user.png (Community/assets/user.png) then this path is not set into database
          * but it saved by XiPT 3.1.
          * JS2.2 does not delete default.jpg(Community/assets/default.jpg) So we changed path.
          * (Not understanding:: Call 2 manish) :)
          */
         if (JString::stristr($old_avatar_path, 'thumb')) {
             //$old_avatar_path = DEFAULT_AVATAR_THUMB;
             $old_avatar_path = 'components/com_community/assets/default_thumb.jpg';
         } else {
             //$old_avatar_path = DEFAULT_AVATAR;
             $old_avatar_path = 'components/com_community/assets/default.jpg';
         }
     }
     //Now apply watermark to images
     //	for that we don't require to add watermark
     //	XITODO : format it in proper way
     if (!XiptLibProfiletypes::getParams(XiptLibProfiletypes::getUserData($userid), 'watermarkparams')->get('enableWaterMark', 0)) {
         return true;
     }
     //check if uploadable avatar is not default ptype avatar
     /**XITODO:: Properly testing following
      * In JS 2.2:: user.png consider as a default avatar for every user and dont save this avatar path in community user table
      * So XiPT 3.1 also consider user.png as default avatar
      * But may be Xipt installed on existing data then at reset all time, may b apply watr-mrk on
      * community/assets/defauult.jpg  (not usr.png).
      * Need properly testing and if get above thing then restict. :)   
      */
     if (XiptLibProfiletypes::isDefaultAvatarOfProfileType($new_avatar_path, true)) {
         return true;
     }
     //check what is new image , if thumb or original
     $what = JString::stristr($new_avatar_path, 'thumb') ? 'thumb' : 'avatar';
     $watermarkInfo = XiptHelperImage::getWatermark($userid);
     if (false == $watermarkInfo) {
         return true;
     }
     XiptHelperImage::addWatermarkOnAvatar($userid, $new_avatar_path, $watermarkInfo, $what);
     return true;
 }
Esempio n. 2
0
 function updateCommunityUserWatermark($userid, $watermark = '')
 {
     // Get water is enable or disable
     $isWaterMarkEnable = XiptLibProfiletypes::getParams(XiptLibProfiletypes::getUserData($userid), 'watermarkparams')->get('enableWaterMark', 0);
     //update watermark on user's avatar
     $pTypeAvatar = XiptLibJomsocial::getUserDataFromCommunity($userid, 'avatar');
     $pTypeThumbAvatar = XiptLibJomsocial::getUserDataFromCommunity($userid, 'thumb');
     // no watermark on default avatars
     if (XiptLibProfiletypes::isDefaultAvatarOfProfileType($pTypeAvatar, true)) {
         return false;
     }
     //no watermark then resotre backup avatar and return
     //if water-mark disable then restore avatar(hit both by resete & by update any user profile )
     if (false == $isWaterMarkEnable || $watermark == '') {
         self::restoreBackUpAvatar($pTypeAvatar);
         self::restoreBackUpAvatar($pTypeThumbAvatar);
         return true;
     }
     //add watermark on user avatar image
     if ($pTypeAvatar) {
         XiptHelperImage::addWatermarkOnAvatar($userid, $pTypeAvatar, $watermark, 'avatar');
     }
     //add watermark on thumb image
     if ($pTypeThumbAvatar) {
         XiptHelperImage::addWatermarkOnAvatar($userid, $pTypeThumbAvatar, $watermark, 'thumb');
     }
     return true;
 }