コード例 #1
0
 /**
  * test the JobSpec delete function.
  */
 public function testDelete()
 {
     $before = $this->_getNumRows();
     // invalid params
     try {
         JobSpec::delete(34);
         $this->fail("Exception not thrown");
     } catch (JobSpecException $e) {
     }
     // invalid params
     try {
         JobSpec::delete(array(1, 'w', 12));
         $this->fail("Exception not thrown");
     } catch (JobSpecException $e) {
     }
     // empty array
     $res = JobSpec::delete(array());
     $this->assertEquals(0, $res);
     // no matches
     $res = JobSpec::delete(array(12, 22));
     $this->assertEquals(0, $res);
     // one match
     $res = JobSpec::delete(array(1, 21));
     $this->assertEquals(1, $res);
     $this->assertEquals(1, $before - $this->_getNumRows());
     $before = $this->_getNumRows();
     // one more the rest
     $res = JobSpec::delete(array(3));
     $this->assertEquals(1, $res);
     $this->assertEquals(1, $before - $this->_getNumRows());
     $before = $this->_getNumRows();
     // rest
     $res = JobSpec::delete(array(4, 2));
     $this->assertEquals(2, $res);
     $this->assertEquals(2, $before - $this->_getNumRows());
 }
コード例 #2
0
 function delParser($indexCode, $arrList)
 {
     $this->indexCode = $indexCode;
     switch ($this->indexCode) {
         case 'EST':
             $this->empstat = new EmploymentStatus();
             $res = $this->empstat->delEmpStat($arrList);
             break;
         case 'JEM':
             $this->jobtit_empstat = new JobTitEmpStat();
             $res = $this->jobtit_empstat->delJobTitEmpStat($arrList);
             break;
         case 'JOB':
             $this->jobtit = new JobTitle();
             $res = $this->jobtit->delJobTitles($arrList);
             break;
         case 'SPC':
             if (isset($arrList[0])) {
                 try {
                     $res = JobSpec::delete($arrList[0]);
                 } catch (JobSpecException $e) {
                     $res = false;
                 }
             }
             break;
         case 'CST':
             $this->compstruct = new CompStruct();
             $res = $this->compstruct->delCompStruct($arrList);
             break;
         case 'LOC':
             $this->location = new models_eimadmin_Location();
             $res = $this->location->delLocation($arrList);
             break;
         case 'SKI':
             $this->skills = new Skills();
             $res = $this->skills->delSkills($arrList);
             break;
         case 'ETH':
             $this->ethnicrace = new EthnicRace();
             $res = $this->ethnicrace->delEthnicRace($arrList);
             break;
         case 'MEM':
             $this->membershiptype = new MembershipType();
             $res = $this->membershiptype->delMembershipType($arrList);
             break;
         case 'NAT':
             $this->nationalityinfo = new NationalityInfo();
             $res = $this->nationalityinfo->delNationalityInfo($arrList);
             break;
         case 'LAN':
             $this->languageinfo = new LanguageInfo();
             $res = $this->languageinfo->delLanguageInfo($arrList);
             break;
         case 'MME':
             $this->membershipinformation = new MembershipInfo();
             $res = $this->membershipinformation->delMembershipInfo($arrList);
             break;
         case 'SGR':
             $this->salarygrade = new SalaryGrades();
             $res = $this->salarygrade->delSalaryGrades($arrList);
             break;
         case 'EDU':
             $this->qual = new Education();
             $res = $this->qual->delEducation($arrList);
             break;
         case 'EEC':
             $this->EEOJobCat = new EEOJobCat();
             $res = $this->EEOJobCat->delEEOJobCat($arrList);
             break;
         case 'LIC':
             $this->Licenses = new Licenses();
             $res = $this->Licenses->delLicenses($arrList);
             break;
         case 'CUS':
             $this->customers = new Customer();
             $res = $this->customers->deletewrapperCustomer($arrList);
             break;
         case 'CTM':
             $this->customFields = new CustomFields();
             if (isset($arrList[0])) {
                 try {
                     $this->customFields->deleteFields($arrList[0]);
                     $res = true;
                     if (is_array($arrList) && count($arrList) > 0) {
                         $mediator = EventMediator::instance();
                         $mediator->notify(EventMediator::POST_CUSTOM_FIELD_DELETE_EVENT, array('customFieldIds' => $arrList[0]));
                     }
                 } catch (CustomFieldsException $e) {
                     $res = false;
                 }
             } else {
                 $res = false;
             }
             break;
         case 'CEX':
             if (isset($arrList[0])) {
                 try {
                     CustomExport::deleteExports($arrList[0]);
                     $res = true;
                 } catch (CustomExportException $e) {
                     $res = false;
                 }
             } else {
                 $res = false;
             }
             break;
         case 'CIM':
             if (isset($arrList[0])) {
                 try {
                     CustomImport::deleteImports($arrList[0]);
                     $res = true;
                 } catch (CustomImportException $e) {
                     $res = false;
                 }
             } else {
                 $res = false;
             }
             break;
         case 'PRJ':
             $this->Projects = new Projects();
             $res = $this->Projects->deletewrapperProjects($arrList);
             break;
         case 'PAD':
             // Project admins
             $gw = new ProjectAdminGateway();
             $projectId = $_GET['id'];
             $res = $gw->removeAdmins($projectId, $arrList[0]);
             break;
         case 'PAC':
             // Project activity
             $authorizeObj = new authorize($_SESSION['empID'], $_SESSION['isAdmin']);
             $projectId = $_GET['projectId'];
             if ($authorizeObj->isAdmin() || $authorizeObj->isProjectAdminOf($projectId)) {
                 $res = ProjectActivity::deleteActivities($arrList[0], $projectId);
             }
             break;
         case 'USR':
             $this->users = new Users();
             $res = $this->users->delUsers($arrList);
             break;
         case 'USG':
             $this->usergroups = new UserGroups();
             $res = $this->usergroups->delUserGroups($arrList);
             break;
     }
     if ($res) {
         $_GET['message'] = 'DELETE_SUCCESS';
     } else {
         $_GET['message'] = 'DELETE_FAILURE';
     }
 }