Пример #1
0
 /**
  * When user remove Avatar then set to default avatar as profile pix
  */
 static function removeProfilePicture()
 {
     //when admin remove any avatar of user by admin panel then get userid
     // at default value,if user remove self avatar.(when fron end user login)
     $userId = JRequest::getVar('userid', JFactory::getUser()->id, 'POST');
     $pType = XiptLibProfiletypes::getUserData($userId, 'PROFILETYPE');
     $newPath = XiptLibProfiletypes::getProfiletypeData($pType, 'avatar');
     self::_removeProfilePicture($userId, $pType, $newPath);
     $view = JRequest::getVar('view', 'profile', 'GET');
     //$task =	JRequest::getVar('task','profile','GET');
     JFactory::getApplication()->redirect(CRoute::_("index.php?option=com_community&view={$view}&userid={$userId}", false), JText::_('CC_PROFILE_PICTURE_REMOVED'));
 }
Пример #2
0
 function onAfterRoute()
 {
     $app = JFactory::getApplication();
     // get option, view and task
     $option = JRequest::getVar('option', 'BLANK');
     $view = JRequest::getVar('view', 'BLANK');
     $task = JRequest::getVar('task', 'BLANK');
     $component = JRequest::getVar('component', 'BLANK');
     $jsconfig = JRequest::getVar('jsconfiguration', 'BLANK');
     if ($app->isAdmin() && $option == 'com_community' && $view == 'configuration' && $jsconfig == 'privacy') {
         $this->_addResetPrivacyScript();
         return true;
     }
     if ($app->isAdmin()) {
         return false;
     }
     if ($option === 'com_community') {
         $userid = JFactory::getUser()->id;
         $this->_pluginHandler->hideJSToolbar($userid);
     }
     /* When XiPT is integrated with subscription method and user does not pay or subscribe any plan,
      * till then XiPT apply default profile-type.
      */
     if ($option == 'com_community' && $task == 'registerUpdateProfile' && ($view == 'register' || $view == 'registration')) {
         $subscription = XiptFactory::getSettings('subscription_integrate', 0);
         if ($subscription) {
             // Change post data (only profile-type and template field).
             $profiletypeId = XiptHelperJomsocial::getFieldId(PROFILETYPE_CUSTOM_FIELD_CODE);
             $templateId = XiptHelperJomsocial::getFieldId(TEMPLATE_CUSTOM_FIELD_CODE);
             //set current PT in other variable for further use
             $defaultPT = XiptLibProfiletypes::getDefaultProfiletype();
             $this->_pluginHandler->setDataInSession('sessionpt', JRequest::getVar("field{$profiletypeId}", $defaultPT));
             JRequest::setVar("field{$profiletypeId}", $defaultPT);
             JRequest::setVar("field{$templateId}", XiptLibProfiletypes::getProfiletypeData($defaultPT, 'template'));
         }
     }
     // perform all acl check from here
     XiptAclHelper::performACLCheck(false, false, false);
     //do routine works
     $eventName = $this->_eventPreText . strtolower($option) . '_' . strtolower($view) . '_' . strtolower($task);
     //call defined event to handle work
     $exist = method_exists($this, $eventName);
     if ($exist) {
         $this->{$eventName}();
     }
     return false;
 }
Пример #3
0
 /**
  * The user data have been saved.
  * We will save user's data (profiletype and template) into Xipt tables
  * @param $userId
  * @param $saveSuccess
  * @return unknown_type
  */
 function onAfterProfileUpdate($userId, $saveSuccess)
 {
     // data was not saved, do nothing
     if (false == $saveSuccess) {
         return true;
     }
     // the JomSocial already store values in field tables
     // now we need to apply that information to our tables
     //	    $cuser        = CFactory::getUser($userId);
     //	    $profiletype  = $cuser->getInfo(PROFILETYPE_CUSTOM_FIELD_CODE);
     //	    $template     = $cuser->getInfo(TEMPLATE_CUSTOM_FIELD_CODE);
     $profiletype = XiptHelperUtils::getInfo($userId, PROFILETYPE_CUSTOM_FIELD_CODE);
     $template = XiptHelperUtils::getInfo($userId, TEMPLATE_CUSTOM_FIELD_CODE);
     // Changing Profile From Front End If The Template allow is None then Set Profiletype template.
     // If Template is Allowed on Profile Type Then Take User Define Template From Front End.
     $oldPtype = XiptLibProfiletypes::getUserData($userId, 'PROFILETYPE');
     $OldallowToChangeTemplate = XiptHelperProfiletypes::getProfileTypeData($oldPtype, 'allowt');
     $NewallowToChangeTemplate = XiptHelperProfiletypes::getProfileTypeData($profiletype, 'allowt');
     //update profiletype only
     XiptLibProfiletypes::updateUserProfiletypeData($userId, $profiletype, $template, 'ALL');
     //update template seperately
     $filter[] = 'template';
     $allowToChangeTemplate = XiptFactory::getSettings('allow_templatechange', 0);
     if (($NewallowToChangeTemplate == 0 || $OldallowToChangeTemplate == 0) && $allowToChangeTemplate == 0) {
         $newData['template'] = XiptLibProfiletypes::getProfiletypeData($profiletype, 'template');
     } else {
         $newData['template'] = $template;
     }
     XiptLibProfiletypes::updateUserProfiletypeFilteredData($userId, $filter, null, $newData);
     $this->showActivity($userId, $profiletype, $oldPtype);
     return true;
 }
Пример #4
0
 function getWatermark($userid)
 {
     $ptype = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE');
     $watermarkInfo = XiptLibProfiletypes::getProfiletypeData($ptype, 'watermark');
     if (!$watermarkInfo) {
         return false;
     }
     return $watermarkInfo;
 }
Пример #5
0
 function uploadAndSetImage($file, $id, $what)
 {
     $mainframe =& JFactory::getApplication();
     CFactory::load('helpers', 'image');
     $config = CFactory::getConfig();
     $uploadLimit = (double) $config->get('maxuploadsize');
     $uploadLimit = $uploadLimit * 1024 * 1024;
     // @rule: Limit image size based on the maximum upload allowed.
     if (filesize($file['tmp_name']) > $uploadLimit) {
         $mainframe->enqueueMessage(XiptText::_('IMAGE_FILE_SIZE_EXCEEDED'), 'error');
         $mainframe->redirect(CRoute::_('index.php?option=com_xipt&view=profiletypes&task=edit&id=' . $id, false));
     }
     if (!cValidImage($file['tmp_name'])) {
         $mainframe->enqueueMessage(XiptText::_('IMAGE_FILE_NOT_SUPPORTED'), 'error');
     } else {
         switch ($what) {
             case 'avatar':
                 $imageMaxWidth = AVATAR_WIDTH;
                 $thumbWidth = AVATAR_WIDTH_THUMB;
                 $thumbHeight = AVATAR_HEIGHT_THUMB;
                 $imgPrefix = 'avatar_';
                 break;
             case 'watermark':
                 $imageMaxWidth = WATERMARK_WIDTH;
                 $thumbWidth = WATERMARK_WIDTH_THUMB;
                 $thumbHeight = WATERMARK_HEIGHT_THUMB;
                 $imgPrefix = 'watermark_';
                 break;
         }
         $storage = PROFILETYPE_AVATAR_STORAGE_PATH;
         $storageImage = $storage . DS . $imgPrefix . $id . cImageTypeToExt($file['type']);
         $storageThumbnail = $storage . DS . $imgPrefix . $id . '_thumb' . cImageTypeToExt($file['type']);
         $image = PROFILETYPE_AVATAR_STORAGE_REFERENCE_PATH . DS . $imgPrefix . $id . cImageTypeToExt($file['type']);
         //$thumbnail			= PROFILETYPE_AVATAR_STORAGE_REFERENCE_PATH . $imgPrefix . $id.'_thumb' . cImageTypeToExt( $file['type'] );
         //here check if folder exist or not. if not then create it.
         if (JFolder::exists($storage) == false) {
             JFolder::create($storage);
         }
         // Only resize when the width exceeds the max.
         if (!cImageResizePropotional($file['tmp_name'], $storageImage, $file['type'], $imageMaxWidth)) {
             $mainframe->enqueueMessage(XiptText::sprintf('COM_XIPT_ERROR_MOVING_UPLOADED_FILE', $storageImage), 'error');
         }
         // Generate thumbnail
         if (!cImageCreateThumb($file['tmp_name'], $storageThumbnail, $file['type'], $thumbWidth, $thumbHeight)) {
             $mainframe->enqueueMessage(XiptText::sprintf('COM_XIPT_ERROR_MOVING_UPLOADED_FILE', $storageThumbnail), 'error');
         }
         $oldFile = XiptLibProfiletypes::getProfiletypeData($id, $what);
         // If old file is default_thumb or default, we should not remove it.
         if (!Jstring::stristr($oldFile, DEFAULT_AVATAR) && !Jstring::stristr($oldFile, DEFAULT_AVATAR_THUMB) && $oldFile != $image && $oldFile != '') {
             // File exists, try to remove old files first.
             $oldFile = JString::str_ireplace('/', DS, $oldFile);
             //only delete when required
             if (JFile::exists($oldFile)) {
                 JFile::delete($oldFile);
             }
         }
         //here due to extension mismatch we can break the functionality of avatar
         if ($what === 'avatar') {
             /* No need to update thumb here , script will update both avatar and thumb */
             //$newThumb   = XiptHelperImage::getThumbAvatarFromFull($newAvatar);
             $oldAvatar = XiptLibProfiletypes::getProfiletypeData($id, 'avatar');
             $allUsers = XiptLibProfiletypes::getAllUsers($id);
             if ($allUsers) {
                 $filter[] = 'avatar';
                 $newData['avatar'] = $image;
                 $oldData['avatar'] = $oldAvatar;
                 foreach ($allUsers as $userid) {
                     XiptLibProfiletypes::updateUserProfiletypeFilteredData($userid, $filter, $oldData, $newData);
                 }
             }
         }
         //now update profiletype with new avatar or watermark
         if (!XiptFactory::getInstance('profiletypes', 'model')->save(array($what => XiptHelperUtils::getUrlpathFromFilePath($image)), $id)) {
             XiptError::raiseError(__CLASS__ . '.' . __LINE__, XiptText::_("ERROR_IN_DATABASE"));
         }
     }
 }