function saveImage() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jobboard.php'; $err_msg = array(); $w = JRequest::getInt('crop_w'); $h = JRequest::getInt('crop_h'); $x = JRequest::getInt('crop_x'); $y = JRequest::getInt('crop_y'); if ($w == 0 && $h == 0 && $x == 0 && $y == 0) { // No changes to thumbnails $this->setRedirect(JRoute::_('index.php?option=com_jobboard&view=user&task=prof&tab=2'), JText::_('COM_JOBBOARD_PICSAVED'), 'mesage'); $this->redirect(); } //$this->usrImgDel(false, false); // delete current thumbs to circumvent browser caching $user_model =& $this->getModel('User'); $profile_pic = JobBoardHelper::checkProfilePicStatus($this->_uid, $user_model, 3); $save_path = $profile_pic['rootpath'] . DS . 'thumbs'; $save_path48 = $profile_pic['rootpath'] . DS . 'thumbs' . DS . 'thumb48_' . $profile_pic['picname']; $save_path115 = $profile_pic['rootpath'] . DS . 'thumbs' . DS . 'thumb115_' . $profile_pic['picname']; if (!JFolder::exists($profile_pic['rootpath'])) { $profile_pic_folder_created = JFolder::create($profile_pic['rootpath']); if ($profile_pic_folder_created == false) { $err_msg[] = JText::_('COM_JOBBOARD_USERFOLDER_CREATE_ERR'); } } $sec_file = $profile_pic['rootpath'] . DS . 'index.html'; if (!JFile::exists($sec_file)) { $_html = '<!DOCTYPE html><title></title>'; JFile::write($sec_file, $_html); } if (!JFolder::exists($save_path)) { $user_folder_created = JFolder::create($save_path); if ($user_folder_created == false) { $err_msg[] = JText::_('COM_JOBBOARD_USERFOLDER_CREATE_ERR'); } } $sec_file = $save_path . DS . 'index.html'; if (!JFile::exists($sec_file)) { $_html = '<!DOCTYPE html><title></title>'; JFile::write($sec_file, $_html); } $image_info = getimagesize($profile_pic['fullpath']); $max_w115 = 115; $max_h115 = 115; $max_w48 = 48; $max_h48 = 48; $ratio_cropped = $w / $h; if ($max_w115 / $max_h115 > $ratio_cropped) { $max_w115 = $max_h115 * $ratio_cropped; } else { $max_h115 = $max_w115 / $ratio_cropped; } if ($max_w48 / $max_h48 > $ratio_cropped) { $max_w48 = $max_h48 * $ratio_cropped; } else { $max_h48 = $max_w48 / $ratio_cropped; } switch ($image_info[2]) { case IMAGETYPE_JPEG: // Load $src = @imagecreatefromjpeg($profile_pic['fullpath']); $img_48 = @imagecreatetruecolor($max_w48, $max_h48); $img_115 = @imagecreatetruecolor($max_w115, $max_h115); // Resize cropped imagecopyresampled($img_48, $src, 0, 0, $x, $y, $max_w48, $max_h48, $w, $h); imagecopyresampled($img_115, $src, 0, 0, $x, $y, $max_w115, $max_h115, $w, $h); // Output if (!imagejpeg($img_48, $save_path48, 100) || !imagejpeg($img_115, $save_path115, 100)) { $err_msg[] = JText::_('COM_JOBBOARD_USER_IMGCREATE_ERR'); } break; case IMAGETYPE_GIF: $src = @imagecreatefromgif($profile_pic['fullpath']); $transp_index = imagecolortransparent($src); $img_48 = @imagecreatetruecolor($max_w48, $max_h48); $img_115 = @imagecreatetruecolor($max_w115, $max_h115); if ($transp_index >= 0) { // Get the original image's transparent color's RGB values $transp_color = imagecolorsforindex($src, $transp_index); // Allocate the same color in the new image resource $trans_index_48 = imagecolorallocate($img_48, $transp_color['red'], $transp_color['green'], $transp_color['blue']); $trans_index_115 = imagecolorallocate($img_115, $transp_color['red'], $transp_color['green'], $transp_color['blue']); // Completely fill the background of the new image with allocated color. imagefill($img_48, 0, 0, $transp_index); imagefill($img_115, 0, 0, $transp_index); // Set the background color for new image to transparent imagecolortransparent($img_48, $transp_index_48); imagecolortransparent($img_115, $transp_index_115); } imagecopyresampled($img_48, $src, 0, 0, $x, $y, $max_w48, $max_h48, $w, $h); imagecopyresampled($img_115, $src, 0, 0, $x, $y, $max_w115, $max_h115, $w, $h); if (!imagegif($img_48, $save_path48, 100) || !imagegif($img_115, $save_path115, 100)) { $err_msg[] = JText::_('COM_JOBBOARD_USER_IMGCREATE_ERR'); } break; case IMAGETYPE_PNG: $src = @imagecreatefrompng($profile_pic['fullpath']); $transp_index = imagecolortransparent($src); $img_48 = @imagecreatetruecolor($max_w48, $max_h48); $img_115 = @imagecreatetruecolor($max_w115, $max_h115); // Turn off transparency blending (temporarily) imagealphablending($img_48, false); imagealphablending($img_115, false); // Create a new transparent color for image $color_48 = imagecolorallocatealpha($img_48, 0, 0, 0, 127); $color_115 = imagecolorallocatealpha($img_115, 0, 0, 0, 127); // Completely fill the background of the new image with allocated color. imagefill($img_48, 0, 0, $color_48); imagefill($img_115, 0, 0, $color_115); // Restore transparency blending imagesavealpha($img_48, true); imagesavealpha($img_115, true); imagecopyresampled($img_48, $src, 0, 0, $x, $y, $max_w48, $max_h48, $w, $h); imagecopyresampled($img_115, $src, 0, 0, $x, $y, $max_w115, $max_h115, $w, $h); if (!imagepng($img_48, $save_path48, 9) || !imagepng($img_115, $save_path115, 9)) { $err_msg[] = JText::_('COM_JOBBOARD_USER_IMGCREATE_ERR'); } break; default: break; } //free up memory imagedestroy($src); imagedestroy($img_48); imagedestroy($img_115); if (count($err_msg) > 0) { $msg = JText::_('COM_JOBBOARD_IMGUPLD_ERR'); foreach ($uploaded as $errmsg) { $msg .= '<br />' . $errmsg; } } else { $msg = JText::_('COM_JOBBOARD_PICSAVED'); } $this->setRedirect(JRoute::_('index.php?option=com_jobboard&view=user&task=prof&tab=2'), $msg, 'message'); }
function revokeLinkedInToken() { $step = 4; $linkedin_imported = 0; $view =& $this->getView('user', 'html'); $layout_style = $this->_umodel->getLayoutConfig(); $pp_status = JobBoardHelper::checkProfilePicStatus($this->_uid, $this->_umodel); JPluginHelper::importPlugin('Jobboard'); $dispatcher =& JDispatcher::getInstance(); $linkedin_arr = $dispatcher->trigger('onCallLinkedInApi', array(array('uid' => &$this->_uid, 'type' => 'revoke'))); $view->setLayout('user'); $view->assign('context', 'addcv'); $view->assign('linkedin_imported', $linkedin_imported); $view->assign('step', $step); $view->assignRef('linkedin_arr', $linkedin_arr); $view->assign('is_profile_pic', $pp_status['is_profile_pic']); $view->assign('imgthumb', $pp_status['urithumb']); $view->assign('layout_style', $layout_style); $view->assignRef('user_auth', $this->_user_cred); $view->display(); }
function showCvProfile() { if ($this->_user_cred['manage_applicants'] == 0 || $this->_user_cred['search_cvs'] == 0) { return $this->setRedirect(JRoute::_('index.php?option=com_jobboard&view=admin&task=jobs&Itemid=' . $this->_itemid), JText::_('COM_JOBBOARD_ENTNOAUTH'), 'error'); } $search_mode = JRequest::getInt('s_mode', 0); $prof_id = JRequest::getInt('pid'); $cv_uid = JRequest::getInt('sid'); if ($search_mode == 0) { $jid = JRequest::getInt('jid'); $job_title = $this->_umodel->getApplJobTitle($jid); } $applicant_name = $this->_umodel->getJUsername($cv_uid); $user_prof_data = $this->_umodel->getSeekerProfile($cv_uid, true); $cv_data = $this->_umodel->getCvProfile($prof_id, $cv_uid, true, true); $this->_umodel->incrCVcounter($prof_id); $layout_style = $this->_umodel->getLayoutConfig(); $user_model =& $this->getModel('User'); $pp_status = JobBoardHelper::checkProfilePicStatus($cv_uid, $user_model, 2); $view =& $this->getView('admin', 'html'); $view->setLayout('admin'); $view->assignRef('cv_data', $cv_data); $view->assignRef('user_prof_data', $user_prof_data); $view->assign('context', 'cvprofile'); $view->assign('is_profile_pic', $pp_status['is_profile_pic']); $view->assign('imgthumb', $pp_status['urithumb']); $view->assign('imgthumb_115', $pp_status['urithumb2']); $view->assign('layout_style', $layout_style); if ($search_mode == 0) { $view->assign('job_title', $job_title); $view->assign('jid', $jid); } $view->assign('s_mode', $search_mode); $view->assign('applicant_name', $applicant_name); $view->assignRef('user_auth', $this->_user_cred); $view->assign('itemid', $this->_itemid); $view->display(); }