Пример #1
0
 function editCvProfile()
 {
     // echo '<pre>'.print_r(JRequest::get('post'), true).'</pre>'; die;
     $step = JRequest::getInt('step');
     $step = $step < 1 ? 1 : $step;
     // Check for request forgeries
     //if($step > 1) JRequest::checkToken() or jexit( JText::_('Invalid Token') );
     jimport('joomla.utilities.date');
     $getdata = JRequest::getInt('getdata');
     $getdata = $getdata != 1 ? 0 : 1;
     $editmode = JRequest::getInt('emode');
     $editmode = $editmode != 1 ? 0 : $editmode;
     $errors = array();
     $msg = '';
     $cv_profile_id = JRequest::getInt('profileid');
     $cv_profile_id = $cv_profile_id < 1 ? 0 : $cv_profile_id;
     $user_prof_data = $this->_umodel->getProfileDataOne($this->_uid, true);
     $pp_status = JobBoardHelper::checkProfilePicStatus($this->_uid, $this->_umodel);
     $linkedin_imported = $this->_umodel->liProfileExists($this->_uid, true);
     $is_authorised_linkedin = $this->_umodel->isAuthLinkedin($this->_uid);
     $layout_style = $this->_umodel->getLayoutConfig();
     $view =& $this->getView('user', 'html');
     $view->setLayout('user');
     $view->assign('is_authorised_linkedin', $is_authorised_linkedin);
     $view->assign('linkedin_imported', $linkedin_imported);
     $view->assign('context', 'addcv');
     $view->assign('step', $step);
     $view->assignRef('user_auth', $this->_user_cred);
     switch ($step) {
         case 1:
             $config = $this->_umodel->getAddProfileStepOnecfg();
             $li_import_on = $this->_umodel->getLinkedinPerms();
             if ($cv_profile_id > 0) {
                 //editing a profile
                 $data = $this->_umodel->getEditProfileStepOnedata($cv_profile_id);
                 $av_date = new JDate($data['avail_date']);
                 $view->assignRef('data', $data);
             } else {
                 //creating a new profile
                 $av_date = JFactory::getDate();
             }
             $file_count = 1;
             $view->assignRef('av_date', $av_date);
             $view->assign('file_count', $file_count);
             $view->assign('li_import_on', $li_import_on);
             $view->assignRef('config', $config);
             break;
         case 2:
             // Process submitted data from Step1
             $post = JRequest::get('post');
             if (isset($post['profile_name']) && isset($post['filetitle']) && isset($post['file_count'])) {
                 if ($post['profile_name'] == '' && $editmode == 0) {
                     $msg = JText::_('COM_JOBBOARD_PROFILENAMEERR');
                     return $this->setRedirect(JRoute::_('index.php?option=com_jobboard&view=user&task=addcv&step=1&Itemid=' . $this->_itemid), $msg, 'error');
                 }
                 $post['is_private'] = !isset($post['is_private']) ? 0 : $post['is_private'] == 'yes' ? 1 : 0;
                 $post['avail_date'] = $post['available_yyyy'] . '-' . $post['available_mm'] . '-' . $post['available_dd'];
                 if (isset($post['section'])) {
                     $section = isset($post['section']);
                     unset($post['section']);
                 } else {
                     $section = '';
                 }
                 unset($post['available_yyyy'], $post['available_mm'], $post['available_dd']);
                 $file_count = $post['file_count'];
                 $files = array();
                 $filearr = JRequest::get('files', 'array');
                 // Organise files into an orderly array
                 for ($i = 1; $i <= $file_count; $i++) {
                     if ($filearr['file']['error'][$i] == 0) {
                         $files[$i - 1]['title'] = $post['filetitle'][$i];
                         $files[$i - 1]['name'] = $filearr['file']['name'][$i];
                         $files[$i - 1]['type'] = $filearr['file']['type'][$i];
                         $files[$i - 1]['tmp_name'] = $filearr['file']['tmp_name'][$i];
                         $files[$i - 1]['error'] = $filearr['file']['error'][$i];
                         $files[$i - 1]['size'] = $filearr['file']['size'][$i];
                     } else {
                         $post['file_count']--;
                     }
                 }
                 /* Does a user profile record exist for user?*/
                 $user_profile_id = $this->_umodel->userProfileExists($this->_uid);
                 if ($user_profile_id == 0) {
                     // If no, create user profile
                     $u_key = JobBoardHelper::randKey();
                     $u_secr = JobBoardHelper::randStr($u_key);
                     $this->_umodel->createMinUserProfile($this->_uid, $u_key, $u_secr);
                 }
                 /*save cv profile and return new/existing record id*/
                 $new_cvid = $this->_umodel->saveCvProfile($post, $cv_profile_id, $this->_uid);
                 if ($new_cvid == 0 && $editmode == 0) {
                     //New profile data save error
                     return $this->setRedirect(JRoute::_('index.php?option=com_jobboard&view=user&task=addcv&step=1&Itemid=' . $this->_itemid), 'Error saving cv/resume profile', 'error');
                 }
                 $cv_profile_id = $cv_profile_id < 1 ? $new_cvid : $cv_profile_id;
                 //handle file uploads
                 if (count($files) > 0) {
                     $upload_success = $this->_processFileUploads($files, $this->_uid, $cv_profile_id);
                 }
                 if (isset($upload_success)) {
                     if (is_array($upload_success)) {
                         $errors = array_merge($errors, $upload_success);
                         $msg .= '<br />' . JText::_('COM_JOBBOARD_ERRORS_OCCURED') . '<br />';
                         foreach ($errors as $errmsg) {
                             $msg .= '<br />' . $errmsg;
                         }
                         $app =& JFactory::getApplication();
                         $app->enqueueMessage($msg, 'error');
                     }
                 }
                 if ($editmode == 1 && $getdata == 0) {
                     // we are editing an existing profile - saving step 1
                     return $this->setRedirect(JRoute::_('index.php?option=com_jobboard&view=user&task=viewcv&profileid=' . $cv_profile_id . '&Itemid=' . $this->_itemid), JText::_('COM_JOBBOARD_CVP_CHGSAVED'), 'message');
                 }
             }
             /* end if creating new cv/resume */
             $section = JRequest::getVar('section');
             if ($editmode == 1 && $getdata == 1) {
                 if ($section == 'employer') {
                     $empl_data = $this->_umodel->getCvProfileEmplHistory($cv_profile_id, $this->_uid);
                     $view->assignRef('empl_data', $empl_data);
                     $employer_count = count($empl_data);
                 } elseif ($section == 'education') {
                     $edu_data = $this->_umodel->getCvProfileEduHistory($cv_profile_id, $this->_uid);
                     $view->assignRef('edu_data', $edu_data);
                     $quals_count = count($edu_data);
                 }
             }
             $quals_count = isset($quals_count) ? $quals_count : 1;
             $employer_count = isset($employer_count) ? $employer_count : 1;
             $countries = $this->_umodel->getCountries();
             $config = $this->_umodel->getAddProfileStepTwocfg();
             $ed_levels = $this->_umodel->getEdlevels();
             $view->assignRef('post', $post);
             $view->assignRef('countries', $countries);
             $view->assignRef('ed_levels', $ed_levels);
             foreach ($countries as $country) {
                 $country_options[] = array("id" => $country->country_id, "name" => JText::_($country->country_name));
             }
             foreach ($ed_levels as $ed_level) {
                 $ed_level_opts[] = array("id" => $ed_level->id, "name" => JText::_($ed_level->level));
             }
             $months = JobBoardHelper::getMonthsList();
             $view->assign('quals_count', $quals_count);
             $view->assign('employer_count', $employer_count);
             $view->assignRef('country_options', $country_options);
             $view->assignRef('config', $config);
             $view->assignRef('ed_level_opts', $ed_level_opts);
             $view->assignRef('months', $months);
             break;
         case 3:
             $section = JRequest::getVar('section');
             require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jobboard_user.php';
             if ($editmode == 0 && $getdata == 0) {
                 // we are creating a new cv/resume
                 $post = JRequest::get('post');
                 $edu_arr = JobBoardUserHelper::reorderEdu($post, $post['quals_count']);
                 $empl_arr = JobBoardUserHelper::reorderEmpl($post, $post['employer_count']);
                 foreach ($edu_arr as $edu) {
                     if ($result = $this->_insertdEdu($cv_profile_id, $this->_uid, $this->_umodel, $edu) != true) {
                         $errors[] = $result;
                     }
                 }
                 foreach ($empl_arr as $empl) {
                     if ($result = $this->_insertEmployer($this->_uid, $cv_profile_id, $this->_umodel, $empl) != true) {
                         $errors[] = $result;
                     }
                 }
                 if (count($errors) > 0) {
                     $msg = JText::_('COM_JOBBOARD_ERRORS_OCCURED') . '<br />';
                     $app =& JFactory::getApplication();
                     foreach ($errors as $err) {
                         $msg .= $err . '<br />';
                     }
                     $app->enqueueMessage($msg, 'error');
                 }
             }
             if ($editmode == 1 && $getdata == 1 && ($section == 'employer' || $section == 'education')) {
                 // we are editing an existing cv/resume
                 $post = JRequest::get('post');
                 if (isset($post['edu_id'])) {
                     $data = JobBoardUserHelper::reorderEdu($post, $post['quals_count'], true);
                     $s_section = 1;
                 }
                 if (isset($post['empl_id'])) {
                     $data = JobBoardUserHelper::reorderEmpl($post, $post['employer_count'], true);
                     $s_section = 2;
                     // echo '<pre>'.print_r($data, true).'</pre>'; die;
                 }
                 switch ($s_section) {
                     case 1:
                         foreach ($data as $row) {
                             if ($row['id'] == 0) {
                                 unset($row['id']);
                                 if ($result = $this->_insertdEdu($cv_profile_id, $this->_uid, $this->_umodel, $row) != true) {
                                     $errors[] = $result;
                                 }
                             } else {
                                 if ($result = $this->_updEdu($this->_uid, $row['id'], $cv_profile_id, $this->_umodel, $row) != true) {
                                     $errors[] = $result;
                                 }
                             }
                         }
                         break;
                     case 2:
                         foreach ($data as $row) {
                             if ($row['id'] == 0) {
                                 unset($row['id']);
                                 if ($result = $this->_insertEmployer($this->_uid, $cv_profile_id, $this->_umodel, $row) != true) {
                                     $errors[] = $result;
                                 }
                             } else {
                                 if ($result = $this->_updEmpl($this->_uid, $row['id'], $cv_profile_id, $this->_umodel, $row) != true) {
                                     $errors[] = $result;
                                 }
                             }
                         }
                         break;
                 }
                 if (count($errors) > 0) {
                     $msg = JText::_('COM_JOBBOARD_ERRORS_OCCURED') . '<br />';
                     foreach ($errors as $err) {
                         $msg .= $err . '<br />';
                         $msgtype = 'error';
                     }
                 } else {
                     $msg = JText::_('COM_JOBBOARD_CVP_CHGSAVED');
                     $msgtype = 'Message';
                 }
                 return $this->setRedirect(JRoute::_('index.php?option=com_jobboard&view=user&task=viewcv&profileid=' . $cv_profile_id . '&Itemid=' . $this->_itemid), $msg, $msgtype);
             }
             if ($editmode == 1 && $getdata == 1 && $section == 'skills') {
                 $skills = $this->_umodel->getCvProfileSkills($cv_profile_id, $this->_uid);
                 $skills_count = count($skills);
                 $current_skills = array();
                 $dated_skills = array();
                 foreach ($skills as $skill) {
                     if ($skill->last_use == '0000-00-00') {
                         $current_skills[] = $skill;
                     } else {
                         $dated_skills[] = $skill;
                     }
                 }
                 $skills = array_merge($current_skills, $dated_skills);
                 $view->assignRef('skills', $skills);
             }
             if (!isset($skills)) {
                 $skills_count = 1;
             }
             $skills_count = $skills_count == 0 ? 1 : $skills_count;
             if ($editmode == 1 && $getdata == 1 && $section == 'summary') {
                 $summary = $this->_umodel->getCvProfileSummary($cv_profile_id, $this->_uid);
                 $view->assignRef('summary', $summary);
             }
             $config = $this->_umodel->getAddProfileStepThreecfg();
             $view->assignRef('config', $config);
             $view->assign('skills_count', $skills_count);
             break;
         case 4:
             $section = JRequest::getVar('section');
             $section = isset($section) ? $section : '';
             require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jobboard_user.php';
             if ($editmode == 0 && $getdata == 0) {
                 // we are creating a new cv/resume
                 $post = JRequest::get('post');
                 $skills_data = JobBoardUserHelper::reorderSkills($post, $post['skillscount']);
                 //$empl_arr = JobBoardUserHelper::reorderEmpl($post, $post['employer_count']);
                 if (!empty($skills_data)) {
                     foreach ($skills_data as $row) {
                         if ($result = $this->_insertSkill($this->_uid, $cv_profile_id, $this->_umodel, $row) != true) {
                             $errors[] = $result;
                         }
                     }
                 }
                 if ($result = $this->_umodel->updCvProfileSummary($cv_profile_id, $this->_uid, $post['summary']) != true) {
                     $errors[] = $result;
                 }
                 if (count($errors) > 0) {
                     $msg = JText::_('COM_JOBBOARD_ERRORS_OCCURED') . '<br />';
                     foreach ($errors as $err) {
                         $msg .= $err . '<br />';
                         $msgtype = 'error';
                     }
                 } else {
                     $msg = JText::_('COM_JOBBOARD_CVP_SAVED');
                     $msgtype = 'Message';
                 }
                 return $this->setRedirect(JRoute::_('index.php?option=com_jobboard&view=user&task=viewcv&profileid=' . $cv_profile_id . '&Itemid=' . $this->_itemid), $msg, $msgtype);
             }
             if ($editmode == 1 && $getdata == 1 && ($section == 'skills' || $section == 'summary')) {
                 // we are editing an existing cv/resume
                 $post = JRequest::get('post');
                 if (isset($post['skillname'])) {
                     $data = JobBoardUserHelper::reorderSkills($post, $post['skillscount'], true);
                     $s_section = 1;
                 }
                 if ($section == 'summary') {
                     $s_section = 2;
                 }
                 switch ($s_section) {
                     case 1:
                         foreach ($data as $row) {
                             if ($row['id'] == 0) {
                                 unset($row['id']);
                                 if ($result = $this->_insertSkill($this->_uid, $cv_profile_id, $this->_umodel, $row) != true) {
                                     $errors[] = $result;
                                 }
                             } else {
                                 if ($result = $this->_updSkill($this->_uid, $row['id'], $cv_profile_id, $this->_umodel, $row) != true) {
                                     $errors[] = $result;
                                 }
                             }
                         }
                         break;
                     case 2:
                         if ($this->_umodel->updCvProfileSummary($cv_profile_id, $this->_uid, $post['summary']) != true) {
                             $errors[] = JText::sprintf('COM_JOBBOARD_ENT_UPDERR', JText::_('COM_JOBBOARD_CVPROF_SUMM'));
                         }
                         break;
                 }
                 if (count($errors) > 0) {
                     $msg = JText::_('COM_JOBBOARD_ERRORS_OCCURED') . '<br />';
                     foreach ($errors as $err) {
                         $msg .= $err . '<br />';
                         $msgtype = 'error';
                     }
                 } else {
                     $msg = JText::_('COM_JOBBOARD_CVP_CHGSAVED');
                     $msgtype = 'Message';
                 }
                 return $this->setRedirect(JRoute::_('index.php?option=com_jobboard&view=user&task=viewcv&profileid=' . $cv_profile_id . '&Itemid=' . $this->_itemid), $msg, $msgtype);
             }
             $post = JRequest::get('post');
             $view->assignRef('post', $post);
             $view->assign('section', $section);
             break;
         case 5:
             //procesing linkedin import
             require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jobboard_user.php';
             $post = JRequest::get('post');
             /* Does a user profile record exist for user?*/
             $user_profile_id = $this->_umodel->userProfileExists($this->_uid);
             if ($user_profile_id == 0) {
                 // If no, create user profile
                 $u_key = JobBoardHelper::randKey();
                 $u_secr = JobBoardHelper::randStr($u_key);
                 $this->_umodel->createMinUserProfile($this->_uid, $u_key, $u_secr);
             }
             $config_defaults = $this->_umodel->getProfileEditOnecfg();
             $li_data = JobBoardUserHelper::reorderLinkedIn($post, &$config_defaults);
             $li_profile_id = $this->_umodel->liProfileExists($this->_uid);
             if ($li_profile_id == 0) {
                 //creating linkedin profile
                 $today = JobBoardHelper::getToday();
                 $li_profile = array('profile_name' => JText::_('COM_JOBBOARD_LI_PROFDESCR'), 'job_type' => 'COM_JOBBOARD_DB_JFULLTIME', 'file_count' => 0, 'avail_date' => (string) $today, 'is_private' => 0);
                 $curr_profile_id = $this->_umodel->saveCvProfile($li_profile, $li_profile_id, $this->_uid, 1);
                 if ($curr_profile_id == 0) {
                     $errors[] = JText::sprintf('COM_JOBBOARD_ENT_UPDERR', JText::_('COM_JOBBOARD_LI_PROFDESCR'));
                 } else {
                     if ($this->_umodel->updCvProfileSummary($curr_profile_id, $this->_uid, $post['profile_summary']) != true) {
                         $errors[] = JText::sprintf('COM_JOBBOARD_ENT_UPDERR', JText::_('COM_JOBBOARD_CVPROF_SUMM'));
                     }
                     foreach ($li_data['edu'] as $edu) {
                         if ($result = $this->_insertdEdu($curr_profile_id, $this->_uid, $this->_umodel, $edu) != true) {
                             $errors[] = $result;
                         }
                     }
                     foreach ($li_data['empl'] as $empl) {
                         if ($result = $this->_insertEmployer($this->_uid, $curr_profile_id, $this->_umodel, $empl) != true) {
                             $errors[] = $result;
                         }
                     }
                     foreach ($li_data['skills'] as $skill) {
                         if ($result = $this->_insertSkill($this->_uid, $curr_profile_id, $this->_umodel, $skill) != true) {
                             $errors[] = $result;
                         }
                     }
                 }
                 if ($this->_umodel->updLiProfileImportStat($this->_uid, 1) != true) {
                     $errors[] = JText::_('COM_JOBBOARD_SAVELINKEDINERR');
                 }
             } elseif ($li_profile_id > 0) {
                 //updating linkedin profile
                 if ($this->_umodel->updCvProfileSummary($li_profile_id, $this->_uid, $post['profile_summary']) != true) {
                     $errors[] = JText::sprintf('COM_JOBBOARD_ENT_UPDERR', JText::_('COM_JOBBOARD_CVPROF_SUMM'));
                 }
                 $curr_profile_id = $li_profile_id;
                 $curr_edu_rows = $this->_umodel->getCvProfileEduHistory($li_profile_id, $this->_uid);
                 $curr_edu_count = count($curr_edu_rows);
                 $new_edu_count = count($li_data['edu']);
                 if ($new_edu_count == $curr_edu_count && $new_edu_count > 0) {
                     //no new records from LinkedIn. Sync current records.
                     $edu_ctr = 0;
                     foreach ($curr_edu_rows as $edu) {
                         $synced_edu = JobBoardUserHelper::liSyncEdu($li_data['edu'][$edu_ctr], $edu);
                         if ($result = $this->_updEdu($this->_uid, $edu->id, $li_profile_id, $this->_umodel, $synced_edu) != true) {
                             $errors[] = $result;
                         }
                         $edu_ctr += 1;
                     }
                 } elseif ($new_edu_count > $curr_edu_count) {
                     for ($e = 0; $e < $curr_edu_count; $e++) {
                         $synced_edu = JobBoardUserHelper::liSyncEdu($li_data['edu'][$e], $curr_edu_rows[$e]);
                         if ($result = $this->_updEdu($this->_uid, $curr_edu_rows[$e]->id, $li_profile_id, $this->_umodel, $synced_edu) != true) {
                             $errors[] = $result;
                         }
                         unset($li_data[$e]);
                     }
                     foreach ($li_data['edu'] as $edu) {
                         if ($result = $this->_insertdEdu($li_profile_id, $this->_uid, $this->_umodel, $edu) != true) {
                             $errors[] = $result;
                         }
                     }
                 } elseif ($new_edu_count < $curr_edu_count) {
                     for ($e = 0; $e < $new_edu_count; $e++) {
                         $synced_edu = JobBoardUserHelper::liSyncEdu($li_data['edu'][$e], $curr_edu_rows[$e]);
                         if ($result = $this->_updEdu($this->_uid, $curr_edu_rows[$e]->id, $li_profile_id, $this->_umodel, $synced_edu) != true) {
                             $errors[] = $result;
                         }
                         unset($curr_edu_rows[$e]);
                     }
                     foreach ($curr_edu_rows as $edu) {
                         if ($result = $this->_delEdu($this->_uid, $edu->id, $li_profile_id, $this->_umodel) != true) {
                             $errors[] = $result;
                         }
                     }
                 }
                 $curr_empl_rows = $this->_umodel->getCvProfileEmplHistory($li_profile_id, $this->_uid);
                 $curr_empl_count = count($curr_empl_rows);
                 $new_empl_count = count($li_data['empl']);
                 if ($new_empl_count == $curr_empl_count && $new_empl_count > 0) {
                     //no new records from LinkedIn. Sync current records.
                     $empl_ctr = 0;
                     foreach ($curr_empl_rows as $empl) {
                         $synced_empl = JobBoardUserHelper::liSyncEmpl($li_data['empl'][$empl_ctr], $empl);
                         if ($result = $this->_updEmpl($this->_uid, $empl->id, $li_profile_id, $this->_umodel, $synced_empl) != true) {
                             $errors[] = $result;
                         }
                         $empl_ctr += 1;
                     }
                 } elseif ($new_empl_count > $curr_empl_count) {
                     for ($e = 0; $e < $curr_empl_count; $e++) {
                         $synced_empl = JobBoardUserHelper::liSyncEmpl($li_data['empl'][$e], $curr_empl_rows[$e]);
                         if ($result = $this->_updEmpl($this->_uid, $curr_empl_rows[$e]->id, $li_profile_id, $this->_umodel, $synced_empl) != true) {
                             $errors[] = $result;
                         }
                         unset($li_data['empl'][$e]);
                     }
                     foreach ($li_data['empl'] as $empl) {
                         if ($result = $this->_insertEmployer($this->_uid, $li_profile_id, $this->_umodel, $empl) != true) {
                             $errors[] = $result;
                         }
                     }
                 } elseif ($new_empl_count < $curr_empl_count) {
                     for ($e = 0; $e < $new_empl_count; $e++) {
                         $synced_empl = JobBoardUserHelper::liSyncEmpl($li_data['empl'][$e], $curr_empl_rows[$e]);
                         if ($result = $this->_updEmpl($this->_uid, $curr_empl_rows[$e]->id, $li_profile_id, $this->_umodel, $synced_empl) != true) {
                             $errors[] = $result;
                         }
                         unset($curr_empl_rows[$e]);
                     }
                     foreach ($curr_empl_rows as $empl) {
                         if ($result = $this->_delEmployer($this->_uid, $empl->id, $li_profile_id, $this->_umodel) != true) {
                             $errors[] = $result;
                         }
                     }
                 }
                 $curr_skill_rows = $this->_umodel->getCvProfileSkills($li_profile_id, $this->_uid);
                 $curr_skill_count = count($curr_skill_rows);
                 $new_skill_count = count($li_data['skills']);
                 if ($new_skill_count == $curr_skill_count && $new_skill_count > 0) {
                     //no new records from LinkedIn. Sync current records.
                     $skill_ctr = 0;
                     foreach ($curr_skill_rows as $skill) {
                         $synced_skill = JobBoardUserHelper::liSyncSkill($li_data['skills'][$skill_ctr], $skill);
                         if ($result = $this->_updSkill($this->_uid, $skill->id, $li_profile_id, $this->_umodel, $synced_skill) != true) {
                             $errors[] = $result;
                         }
                         $skill_ctr += 1;
                     }
                 } elseif ($new_skill_count > $curr_skill_count) {
                     for ($e = 0; $e < $curr_skill_count; $e++) {
                         $synced_skill = JobBoardUserHelper::liSyncSkill($li_data['skills'][$e], $curr_skill_rows[$e]);
                         if ($result = $this->_updSkill($this->_uid, $curr_skill_rows[$e]->id, $li_profile_id, $this->_umodel, $synced_skill) != true) {
                             $errors[] = $result;
                         }
                         unset($li_data['skills'][$e]);
                     }
                     foreach ($li_data['skills'] as $skill) {
                         if ($result = $this->_insertSkill($this->_uid, $li_profile_id, $this->_umodel, $skill) != true) {
                             $errors[] = $result;
                         }
                     }
                 } elseif ($new_skill_count < $curr_skill_count) {
                     for ($e = 0; $e < $new_skill_count; $e++) {
                         $synced_skill = JobBoardUserHelper::liSyncSkill($li_data['skills'][$e], $curr_skill_rows[$e]);
                         if ($result = $this->_updSkill($this->_uid, $curr_skill_rows[$e]->id, $li_profile_id, $this->_umodel, $synced_skill) != true) {
                             $errors[] = $result;
                         }
                         unset($curr_skill_rows[$e]);
                     }
                     foreach ($curr_skill_rows as $skill) {
                         if ($result = $this->_delSkill($this->_uid, $skill->id, $li_profile_id, $this->_umodel) != true) {
                             $errors[] = $result;
                         }
                     }
                 }
                 if ($this->_umodel->updLiProfileImportStat($this->_uid, 1) != true) {
                     $errors[] = JText::_('COM_JOBBOARD_SAVELINKEDINERR');
                 }
             }
             if (count($errors) > 0) {
                 $msg = JText::_('COM_JOBBOARD_ERRORS_OCCURED') . '<br />';
                 foreach ($errors as $err) {
                     $msg .= $err . '<br />';
                     $msgtype = 'error';
                 }
                 return $this->setRedirect(JRoute::_('index.php?option=com_jobboard&view=user&task=cvprofs&Itemid=' . $this->_itemid), $msg, $msgtype);
             } else {
                 $msg = JText::_('COM_JOBBOARD_CVP_CHGSAVED');
                 $msgtype = 'Message';
                 return $this->setRedirect(JRoute::_('index.php?option=com_jobboard&view=user&task=viewcv&profileid=' . $curr_profile_id . '&Itemid=' . $this->_itemid), $msg, $msgtype);
             }
             break;
         default:
             break;
     }
     $section = isset($section) ? $section : '';
     $view->assign('editmode', $editmode);
     $view->assign('section', $section);
     $view->assign('getdata', $getdata);
     $view->assign('profileid', $cv_profile_id);
     $view->assign('is_profile_pic', $pp_status['is_profile_pic']);
     $view->assignRef('user_prof_data', $user_prof_data);
     $view->assign('imgthumb', $pp_status['urithumb']);
     $view->assign('layout_style', $layout_style);
     $view->display();
 }
Пример #2
0
 function editQuestionnaire()
 {
     JRequest::checkToken('get') or jexit(JText::_('Invalid Token'));
     if ($this->_user_cred['manage_questionnaires'] == 0) {
         $msg = JText::_('COM_JOBBOARD_ENTNOAUTH');
         $msgtype = 'error';
         return $this->setRedirect(JRoute::_('index.php?option=com_jobboard&view=admin&task=qlist&Itemid=' . $this->_itemid), $msg, $msgtype);
     }
     $qid = JRequest::getInt('qid');
     $qid = $qid < 1 ? 0 : $qid;
     if ($qid == 0 && $this->_user_cred['create_questionnaires'] == 0) {
         $msg = JText::_('COM_JOBBOARD_ENTNOAUTH');
         $msgtype = 'error';
         return $this->setRedirect(JRoute::_('index.php?option=com_jobboard&view=admin&task=qlist&Itemid=' . $this->_itemid), $msg, $msgtype);
     }
     $view =& $this->getView('admin', 'html');
     $appl_model =& $this->getModel('Apply');
     $questionnaire = $appl_model->getQuestionnaire($qid);
     $fields = json_decode($questionnaire['fields']);
     unset($questionnaire['fields']);
     $layout_style = $this->_umodel->getLayoutConfig();
     $q_fields = is_object($fields) ? $fields->fields : $fields;
     $months = JobBoardHelper::getMonthsList();
     $today = JobBoardHelper::getToday();
     $view->setLayout('admin');
     $view->assignRef('fields', $q_fields);
     $view->assign('context', 'questionnaire');
     $view->assignRef('questionnaire', $questionnaire);
     $view->assign('layout_style', $layout_style);
     $view->assign('editing', true);
     $view->assign('qid', $qid);
     $view->assignRef('user_auth', $this->_user_cred);
     $view->assign('today', $today);
     $view->assignRef('months', $months);
     $view->assign('itemid', $this->_itemid);
     $view->display();
 }