Пример #1
0
    function getFieldHTML($field, $required)
    {
        // it might be some other user (in case of admin is editing profile)
        $user =& JFactory::getUser();
        $tName = $field->value;
        $templates = XiptHelperJomsocial::getTemplatesList();
        $class = $required == 1 ? ' required' : '';
        $selectedValue = $this->getTemplateValue($tName, $user->id);
        //	XITODO : format it in proper way
        $allowToChangeTemplate = XiptHelperProfiletypes::getProfileTypeData(XiptLibProfiletypes::getUserData($user->id), 'allowt');
        $allowToChangeTemplate = $allowToChangeTemplate || XiptHelperUtils::isAdmin($user->id);
        if (!$allowToChangeTemplate) {
            $html = '<input type="hidden" id="field' . $field->id . '"
				name="field' . $field->id . '" value="' . $selectedValue . '" />';
            $html .= $selectedValue;
            return $html;
        }
        $html = '<select id="field' . $field->id . '" name="field' . $field->id . '" class="hasTip select' . $class . ' inputbox" title="' . $field->name . '::' . htmlentities($field->tips) . '">';
        $selectedElement = 0;
        if (!empty($templates)) {
            foreach ($templates as $tmpl) {
                $selected = $tmpl == $selectedValue ? ' selected="selected"' : '';
                if (!empty($selected)) {
                    $selectedElement++;
                }
                $html .= '<option value="' . $tmpl . '"' . $selected . '>' . $tmpl . '</option>';
            }
        }
        $html .= '</select>';
        $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;">&nbsp;</span>';
        return $html;
    }
Пример #2
0
    function getFieldHTML($field, $required)
    {
        $html = '';
        $pID = $field->value;
        $class = $required == 1 ? ' required' : '';
        $disabled = '';
        if ($this->_view === 'register') {
            // get pType from registration session OR defaultPType
            $pID = XiptFactory::getPluginHandler()->getRegistrationPType();
            $html = '<input type="hidden"
							id="field' . $field->id . '"
							name="field' . $field->id . '"
							value="' . $pID . '" />';
            $pName = XiptLibProfiletypes::getProfiletypeName($pID);
            $html .= $pName;
            return $html;
        }
        // it might be some other user (in case of admin is editing profile)
        $user = JFactory::getUser();
        $userid = $user->id;
        if (!(int) $pID) {
            $pID = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE');
            XiptError::assert($pID, XiptText::_("USERID {$pID} DOES_NOT_EXIST"), XiptError::ERROR);
        }
        $visiblePT = XiptLibProfiletypes::getProfiletypeArray(array('visible' => 1));
        $allowToChangePType = $this->_params->get('allow_user_to_change_ptype_after_reg', 0);
        $allowToChangePType = $allowToChangePType && array_key_exists($pID, $visiblePT) || XiptHelperUtils::isAdmin($user->id);
        //if not allowed then show disabled view of ptype
        if ($allowToChangePType == false) {
            $pName = XiptLibProfiletypes::getProfileTypeName($pID);
            $pName = $pName;
            $html = '<input type="hidden"
							id="field' . $field->id . '"
							name="field' . $field->id . '"
							value="' . $pID . '" />';
            return $html . $pName;
        }
        $mainframe = JFactory::getApplication();
        if ($mainframe->isAdmin() == true || XiptHelperUtils::isAdmin($user->id)) {
            $filter = array('published' => 1);
        } else {
            $filter = array('published' => 1, 'visible' => 1);
        }
        // user can change profiletype, add information
        $pTypes = XiptLibProfiletypes::getProfiletypeArray($filter);
        $html = '<select id="field' . $field->id . '" name="field' . $field->id . '" ' . $disabled . ' class="hasTip select' . $class . ' inputbox" title="' . $field->name . '::' . htmlentities($field->tips) . '">';
        $selectedElement = 0;
        if (!empty($pTypes)) {
            foreach ($pTypes as $pType) {
                $selected = $pType->id == $pID ? ' selected="selected"' : '';
                if (!empty($selected)) {
                    $selectedElement++;
                }
                $html .= '<option value="' . $pType->id . '"' . $selected . '>' . $pType->name . '</option>';
            }
        }
        $html .= '</select>';
        $html .= '<span id="errfield' . $field->id . 'msg" style="display:none;">&nbsp;</span>';
        return $html;
    }
Пример #3
0
 function performACLCheck($ajax = false, $callArray, $args)
 {
     //Return if admin
     $userId = JFactory::getUser()->id;
     if (XiptHelperUtils::isAdmin($userId)) {
         return false;
     }
     $option = JRequest::getVar('option');
     $feature = JRequest::getCmd('view');
     $task = JRequest::getCmd('task');
     // depending upon call get feature and task, might be objectID
     if ($ajax) {
         $option = 'com_community';
         $feature = JString::strtolower($callArray[0]);
         $task = JString::strtolower($callArray[1]);
     }
     // if user is uploading avatar at the time of registration then
     // the user id will be availabale from tmpuser
     if ($option == 'com_community' && $feature == 'register' && ($task == 'registerAvatar' || $task == 'registerSucess')) {
         $userId = JFactory::getSession()->get('tmpUser', '')->id;
     }
     $viewuserid = JRequest::getVar('userid', 0);
     // assign into one array
     $info['option'] = $option;
     $info['view'] = $feature;
     $info['task'] = strtolower($task);
     $info['userid'] = $userId;
     $info['viewuserid'] = $viewuserid;
     $info['ajax'] = $ajax;
     $info['args'] = $args;
     //get all published rules
     $rules = XiptAclFactory::getAclRulesInfo(array('published' => 1));
     if (empty($rules)) {
         return false;
     }
     foreach ($rules as $rule) {
         $aclObject = XiptAclFactory::getAclObject($rule->aclname);
         $aclObject->bind($rule);
         if (false == $aclObject->isApplicable($info)) {
             continue;
         }
         if (false == $aclObject->checkViolation($info)) {
             //rule might update viewuserid, pass corerct id to next rule
             $info['viewuserid'] = $viewuserid;
             continue;
         }
         $aclObject->handleViolation($info);
         break;
     }
     return false;
 }
Пример #4
0
 function isApplicable()
 {
     $plugin = XiptHelperUtils::getPluginStatus('xi_adminapproval');
     if (XIPT_JOOMLA_15) {
         if ($plugin && $plugin->published == 1) {
             return false;
         }
     } else {
         if ($plugin && $plugin->enabled == 1) {
             return false;
         }
     }
     $ptypeArray = XiptHelperProfiletypes::getProfileTypeArray();
     foreach ($ptypeArray as $ptype) {
         if (XiptHelperProfiletypes::getProfileTypeData($ptype, 'approve') == true) {
             return true;
         }
     }
     return false;
 }
Пример #5
0
 function _isPluginInstalledAndEnabled()
 {
     $communityPlugin = XiptHelperUtils::getPluginStatus('xipt_community');
     if (XIPT_JOOMLA_15) {
         if (!$communityPlugin || $communityPlugin->published == 0) {
             return false;
         }
     } else {
         if (!$communityPlugin || $communityPlugin->enabled == 0) {
             return false;
         }
     }
     $systemPlugin = XiptHelperUtils::getPluginStatus('xipt_system');
     if (XIPT_JOOMLA_15) {
         if (!$systemPlugin || $systemPlugin->published == 0) {
             return false;
         }
     } else {
         if (!$systemPlugin || $systemPlugin->enabled == 0) {
             return false;
         }
     }
     return true;
 }
Пример #6
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;
 }
Пример #7
0
 function getFontsHTML($name, $value, $control_name = 'params')
 {
     $fonts = XiptHelperUtils::getFonts();
     $html = JHTML::_('select.genericlist', $fonts, $control_name . '[' . $name . ']', null, 'value', 'text', $value);
     return $html;
 }
Пример #8
0
 function addWatermarkOnAvatar($userid, $originalImage, $waterMark, $what)
 {
     //Original Image in machine formate
     $originalImage = XiptHelperUtils::getRealPath($originalImage);
     //IMP : do not modify original image.
     $image = JPATH_ROOT . DS . $originalImage;
     // Load image helper library as it is needed.
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'helpers' . DS . 'image.php';
     //ini_set('gd.jpeg_ignore_warning', 1);
     $ptype = XiptLibProfiletypes::getUserData($userid, 'PROFILETYPE');
     $watermarkParams = XiptLibProfiletypes::getParams($ptype, 'watermarkparams');
     if ($what == 'thumb') {
         $waterMark = self::getThumbAvatarFromFull($waterMark);
     }
     $waterMark = JPATH_ROOT . DS . $waterMark;
     $type = self::getImageType($image);
     $wType = self::getImageType($waterMark);
     if ($wType == 'image/jpg') {
         JFactory::getApplication()->enqueueMessage("Watermark must be PNG or GIF image, no watermark applied");
         return false;
     }
     $imageInfo = getimagesize($image);
     if ($imageInfo == false) {
         JFactory::getApplication()->enqueueMessage("Unable to open through getimage the file {$image}");
         return false;
     }
     $imageWidth = $imageInfo[0];
     //imagesx( $image );
     $imageHeight = $imageInfo[1];
     // imagesy( $image );
     if ($what == 'avatar') {
         $watermarkWidth = WATERMARK_HEIGHT;
         $watermarkHeight = WATERMARK_WIDTH;
     }
     if ($what == 'thumb') {
         $watermarkWidth = $watermarkParams->get('xiThumbWidth', 0);
         $watermarkHeight = $watermarkParams->get('xiThumbHeight', 0);
         //XITODO : here we need to trick as per the JomSocial
         // we need to modify the code when things changes, currently
         // the image informationfor thumbs does not come correctly
         $imageWidth = AVATAR_WIDTH_THUMB;
         $imageHeight = AVATAR_HEIGHT_THUMB;
     }
     if (!JFile::exists($image) || !JFile::exists($waterMark)) {
         return false;
     }
     // if warter marking is not enable for profile type then return
     /*First copy user old avatar b'coz we don't want to overwrite watermark */
     $avatarFileName = JFile::getName($originalImage);
     if (JFile::exists(USER_AVATAR_BACKUP . DS . $avatarFileName)) {
         JFile::copy(USER_AVATAR_BACKUP . DS . $avatarFileName, JPATH_ROOT . DS . $originalImage);
     }
     // if watermarking is not enable for profile type then return
     if ($watermarkParams->get('enableWaterMark', 0) == false) {
         return;
     }
     $newimagepath = self::showWatermarkOverImage($image, $waterMark, 'tmp', $watermarkParams->get('xiWatermarkPosition', 'br'));
     /*copy user original avatar at one place to remove destroy */
     //here check if folder exist or not. if not then create it.
     $avatarPath = USER_AVATAR_BACKUP;
     if (JFolder::exists($avatarPath) == false) {
         JFolder::create($avatarPath);
     }
     JFile::copy(JPATH_ROOT . DS . $originalImage, $avatarPath . DS . JFile::getName(JPATH_ROOT . DS . $originalImage));
     JFile::move(JPATH_ROOT . DS . $newimagepath, JPATH_ROOT . DS . $originalImage);
     return;
 }
Пример #9
0
 function _saveWatermark($id)
 {
     $model = $this->getModel();
     //Collect Newly saved data
     $newData = $model->loadRecords(0);
     $newData = $newData[$id];
     $config = new XiptParameter('', '');
     $config->bind($newData->watermarkparams);
     // if enable water mark is false then no need to create watermark
     if (!$config->get('enableWaterMark')) {
         return false;
     }
     //no change condition i.e if type of watermark is image
     // but no image is selected then return
     if (empty($_FILES['watermarkparams']['tmp_name']['xiImage']) && $config->get('typeofwatermark', '0') == '1') {
         return false;
     }
     // generate watermark image
     //XITODO : improve nomenclature
     $imageGenerator = new XiptLibImage($config);
     $storage = PROFILETYPE_AVATAR_STORAGE_PATH;
     $imageName = 'watermark_' . $id;
     // create watermark according to the type of watermark selected
     if ($config->get('typeofwatermark', '0') == '1') {
         $filename = $imageGenerator->createImageWatermark($storage, $imageName);
     } else {
         $filename = $imageGenerator->genImage($storage, $imageName);
     }
     //XITODO : assert on filename
     $image = PROFILETYPE_AVATAR_STORAGE_REFERENCE_PATH . DS . $filename;
     $data = array('watermark' => XiptHelperUtils::getUrlpathFromFilePath($image));
     $this->generateThumbnail($imageName, $filename, $storage, $newData, $config);
     // now save model
     $model->save($data, $id);
     return $image;
 }
Пример #10
0
 /**
  * It updates user's oldAvtar to newAvatars
  * @param $userid
  * @param $newAvatar
  * @return unknown_type
  */
 function updateCommunityUserDefaultAvatar($userid, $newAvatar)
 {
     /*
      * IMP : Implemented in setup 
      * we migrate profiletype avatars to profiletype-1, 2 etc.
      * So that we do not need to tense about old avatar of profiletype
      * */
     //reload : so that we do not override previous information if any updated in database.
     //self::reloadCUser($userid);
     $user = CFactory::getUser($userid);
     $userAvatar = $user->_avatar;
     //Before save, avatar path Change in URL formate
     $newAvatar = XiptHelperUtils::getUrlpathFromFilePath($newAvatar);
     //We must enforce this as we never want to overwrite a custom avatar
     $isDefault = XiptLibProfiletypes::isDefaultAvatarOfProfileType($userAvatar, true);
     //		$changeAvatarOnSyncUp = self::_changeAvatarOnSyncUp($userAvatar);
     if ($isDefault == false) {
         return false;
     }
     // we can safely update avatar so perform the operation
     //		$user->set('_avatar',$newAvatar);
     //		$user->set('_thumb', XiptHelperImage::getThumbAvatarFromFull($newAvatar));
     //
     //		if(!$user->save())
     //		    return false;
     //
     $query = new XiptQuery();
     if (!$query->update('#__community_users')->set(" avatar = '{$newAvatar}' ")->set(" thumb = '" . XiptHelperImage::getThumbAvatarFromFull($newAvatar) . "' ")->where(" userid = {$userid} ")->dbLoadQuery()->query()) {
         return false;
     }
     //enforce JomSocial to clean cached user
     self::reloadCUser($userid);
     return true;
 }
Пример #11
0
        ?>
" />	
			</td>
			
			<td align="center" id="watermark<?php 
        echo $field->id;
        ?>
">
					<?php 
        $wm = $field->watermarkparams;
        $wmparams = new XiptParameter($wm, '');
        if ($wmparams->get('enableWaterMark', 0)) {
            ?>
				
				<img src="<?php 
            echo JURI::root() . XiptHelperUtils::getUrlpathFromFilePath($field->watermark);
            ?>
"  border="0" alt="<?php 
            echo $field->watermark;
            ?>
" />	
					<?php 
        }
        ?>
				</td>
			
			<td align="center" id="jusertype<?php 
        echo $field->id;
        ?>
">
				<?php 
Пример #12
0
					<div class="paramTitle">						
					<label class="hasTip" title="<?php 
echo XiptText::_('DEFAULT_AVATAR');
?>
::<?php 
echo XiptText::_('DEFAULT_AVATAR_DESC');
?>
">
							<?php 
echo XiptText::_('DEFAULT_AVATAR');
?>
					</label>
					</div>
					<div class="paramValue">
					<img src="<?php 
echo JURI::root() . XiptHelperUtils::getUrlpathFromFilePath($this->data->avatar);
?>
" width="64" height="64" border="0" alt="<?php 
echo $this->data->avatar;
?>
" />
					<div class='clr'></div>
					<input class="inputbox button" type="file" id="file-upload" name="FileAvatar" style="color: #666;" />
					<div class='clr'></div>
					<?php 
$link = XiptRoute::_('index.php?option=com_xipt&view=profiletypes&task=removeAvatar&id=' . $this->data->id . '&oldAvatar=' . $this->data->avatar, false);
?>
											<a href="<?php 
echo $link;
?>
"><?php 
Пример #13
0
 function disable_plugin($pluginname)
 {
     // XITODO : remove this function
     return XiptHelperUtils::changePluginState($pluginname, 0);
 }
Пример #14
0
 function hideJSToolbar($userid)
 {
     // the user is admin, return true
     if (XiptHelperUtils::isAdmin($userid)) {
         return true;
     }
     XiptHelperJSToolbar::getMenusToHide($userid);
 }
Пример #15
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"));
         }
     }
 }
Пример #16
0
" 
				name="profiletypes" 
				value="<?php 
    echo $pType->id;
    ?>
" <?php 
    echo $selected;
    ?>
 />
			<?php 
    echo $pType->name;
    ?>
		</div>

		<div id="Details">
			<div id="Avatar">
				<img src="<?php 
    echo JURI::root() . XiptHelperUtils::getUrlpathFromFilePath($pType->avatar);
    ?>
" 
				     height="60px" 
 			  	     width="60px"/>
			</div>
			<p id="Description"> <?php 
    echo $pType->tip;
    ?>
 </p>
		</div>
	</div>
<?php 
}
Пример #17
0
 function resetUserAvatar($pid, $newavatar, $oldavatar, $newavatarthumb)
 {
     //get all users for profiletype
     $users = XiptLibProfiletypes::getAllUsers($pid);
     //Change all avatar and thumb path in url formate
     $newavatar = XiptHelperUtils::getUrlpathFromFilePath($newavatar);
     $newavatarthumb = XiptHelperUtils::getUrlpathFromFilePath($newavatarthumb);
     $cnt = count($users);
     for ($i = 0; $i < $cnt; $i++) {
         //if user is admin unset value
         if (XiptHelperUtils::isAdmin($users[$i])) {
             unset($users[$i]);
         }
     }
     $users = array_values($users);
     $cnt = count($users);
     if ($cnt > 0) {
         // XITODO : Change IN query to sub query
         //update user avatar and thumb of all users who doesn't have custom avatar
         $query = new XiptQuery();
         $result = $query->update('#__community_users')->set(" avatar = '{$newavatar}' ")->set(" thumb = '{$newavatarthumb}' ")->where(" avatar = '{$oldavatar}' ")->where(" userid  IN (" . implode(",", $users) . ") ")->dbLoadQuery()->query();
         if (!$result) {
             return XiptError::raiseWarning(500, XiptText::_("ERROR_IN_DATABASE_WHEN_SAVING_AVATAR_IN_COMMUNITY_USER_TABLE"));
         }
         return true;
     }
 }
Пример #18
0
 function _removeProfilePicture($id, $pType, $newPath, $type = 'avatar')
 {
     $db = JFactory::getDBO();
     // Test if the record exists.
     $oldAvatar = self::getUserInfo($id);
     //If avatar is default then not remove it
     if (JString::stristr($oldAvatar, $newPath)) {
         JFactory::getApplication()->enqueueMessage(XiptText::_("YOU_CANNOT_REMOVE_DEFAULT_AVATAR"));
         return;
     }
     //get avatar_PROFILE-TYPE_thumb.jpg path
     if (JString::substr($newPath, -4) == ".png") {
         $thumbPath = JString::str_ireplace(".png", "_thumb.png", $newPath);
     } else {
         $thumbPath = JString::str_ireplace(".jpg", "_thumb.jpg", $newPath);
     }
     //if (Applied)Avatar is default user.png (JomSocial default Profile pix) then not insert our default avatar (user.png) path in database.
     if (JString::stristr($newPath, DEFAULT_AVATAR) && JString::stristr($thumbPath, DEFAULT_AVATAR_THUMB)) {
         $newPath = '';
         $thumbPath = '';
     }
     // create query for update Avatar and thumb
     $query = 'UPDATE ' . $db->nameQuote('#__community_users') . ' ' . 'SET ' . $db->nameQuote($type) . '=' . $db->Quote($newPath) . ', ' . '`thumb` = ' . $db->Quote($thumbPath) . ' ' . 'WHERE ' . $db->nameQuote('userid') . '=' . $db->Quote($id);
     $db->setQuery($query);
     $db->query($query);
     if ($db->getErrorNum()) {
         JError::raiseError(500, $db->stderr());
     }
     //get thumb Path
     $oldAvatarThumb = self::getUserInfo($id, '_thumb');
     // If old file is default avatar thumb or default avatar , we should not remove it.
     // if old file is not default avatar then remove it.
     // Need proper way to test it
     if (!JString::stristr($oldAvatar, $newPath) && !JString::stristr($oldAvatarThumb, $thumbPath)) {
         // File exists, try to remove old files first.
         $oldAvatar = XiptHelperUtils::getRealPath($oldAvatar);
         $oldAvatarThumb = XiptHelperUtils::getRealPath($oldAvatarThumb);
         if (JFile::exists($oldAvatar)) {
             JFile::delete($oldAvatar);
             JFile::delete($oldAvatarThumb);
         }
     }
     return true;
 }