Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 17 |
CRAP | |
0.00% |
0 / 217 |
| AllowEditProfileService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 17 |
1980.00 | |
0.00% |
0 / 217 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| __clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 4 |
|||
| getFields | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| getFieldsToShowInStudentProfileSettings | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| saveFields | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 22 |
|||
| saveStudentEditFields | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 17 |
|||
| saveFieldsToShowStudentProfileSettings | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 22 |
|||
| getFieldsOfStudent | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 15 |
|||
| getFieldsToShowStudentProfileSettings | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| saveField | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 12 |
|||
| deleteField | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 12 |
|||
| saveAllFields | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 25 |
|||
| deleteAllFields | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| checkStudentVerified | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| verifyStudent | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 10 |
|||
| saveFieldsToShowStudentProfileSettingsForOneStudent | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 22 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| use com\linways\core\ams\professional\constant\SettingsConstants; | |
| class AllowEditProfileService extends BaseService | |
| { | |
| private static $_instance = null; | |
| // /Condition 2 - Locked down the constructor | |
| private function __construct() { | |
| } | |
| // Prevent any oustide instantiation of this class | |
| // /Condition 3 - Prevent any object or instance of that class to be cloned | |
| private function __clone() { | |
| } | |
| // Prevent any copy of this object | |
| // /Condition 4 - Have a single globally accessible static method | |
| public static function getInstance() { | |
| if (! is_object ( self::$_instance )) // or if( is_null(self::$_instance) ) or if( self::$_instance == null ) | |
| self::$_instance = new self (); | |
| return self::$_instance; | |
| } | |
| /** | |
| * get fields | |
| * @author Aswin | |
| * @param unknown $batchIDs | |
| * @throws ProfessionalException | |
| * @return object|array|\com\linways\base\util\$objectList[] | |
| */ | |
| function getFields($batchIDs) | |
| { | |
| $batchIDs = $this->realEscapeString($batchIDs); | |
| $query="select distinct fieldName from studentProfileEditFields where studentID in (select studentID from studentaccount where batchID IN ($batchIDs))"; | |
| try{ | |
| $response=$this->executeQueryForList($query); | |
| return $response; | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| /** | |
| * get show enabled fields | |
| * @author Aiswarya | |
| * @param unknown $batchIDs | |
| * @throws ProfessionalException | |
| * @return object|array|\com\linways\base\util\$objectList[] | |
| */ | |
| function getFieldsToShowInStudentProfileSettings($batchIDs) | |
| { | |
| $batchIDs = $this->realEscapeString($batchIDs); | |
| $query="select distinct fieldName from studentProfileShowFields where studentID in (select studentID from studentaccount where batchID IN ($batchIDs))"; | |
| try{ | |
| $response=$this->executeQueryForList($query); | |
| return $response; | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| /** | |
| * save field | |
| * @author Aswin | |
| * @param unknown $batchIDs | |
| * @param unknown $fields | |
| * @throws ProfessionalException | |
| * @return string | |
| */ | |
| function saveFields($batchIDs,$fields) | |
| { | |
| $batchIDs = $this->realEscapeString($batchIDs); | |
| $fields = $this->realEscapeArray($fields); | |
| $query="delete from studentProfileEditFields where studentID in (select studentID from studentaccount where batchID IN ($batchIDs))"; | |
| try{ | |
| $this->executeQuery($query); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| foreach ($fields as $t) | |
| { | |
| $query="insert into studentProfileEditFields (studentID,fieldName) select studentID,'$t' from studentaccount where batchID IN ($batchIDs)"; | |
| try{ | |
| $this->executeQuery($query); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| return "success"; | |
| } | |
| function saveStudentEditFields($batchIDs, $fields) | |
| { | |
| $batchIDs = $this->realEscapeString($batchIDs); | |
| $fields = $this->realEscapeArray($fields); | |
| $commonFieldSettings = json_decode(CommonService::getInstance()->getSettings(SettingsConstants::ADMIN, SettingsConstants::COMMON_STUDENT_PROFILE_FIELDS), true); | |
| foreach ($fields as $t) { | |
| foreach ($commonFieldSettings as &$field) { | |
| if ($field['fieldName'] === $t) { | |
| $field['editableField'] = true; | |
| break; | |
| } | |
| } | |
| } | |
| $updatedSettingsJson = json_encode($commonFieldSettings); | |
| CommonService::getInstance()->updateSettings(SettingsConstants::ADMIN, SettingsConstants::COMMON_STUDENT_PROFILE_FIELDS, $updatedSettingsJson); | |
| echo "Settings updated successfully."; | |
| return "success"; | |
| } | |
| /** | |
| * save fields which is enabled to show student profile settings | |
| * @author Aiswarya | |
| * @param unknown $batchIDs | |
| * @param unknown $fields | |
| * @throws ProfessionalException | |
| * @return string | |
| */ | |
| function saveFieldsToShowStudentProfileSettings($batchIDs,$fields) | |
| { | |
| $batchIDs = $this->realEscapeString($batchIDs); | |
| $fields = $this->realEscapeArray($fields); | |
| $query="delete from studentProfileShowFields where studentID in (select studentID from studentaccount where batchID IN ($batchIDs))"; | |
| try{ | |
| $this->executeQuery($query); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| foreach ($fields as $t) | |
| { | |
| $query="insert into studentProfileShowFields (studentID,fieldName) select studentID,'$t' from studentaccount where batchID IN ($batchIDs)"; | |
| try{ | |
| $this->executeQuery($query); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| return "success"; | |
| } | |
| /** | |
| * get fields of student | |
| * @author Aswin | |
| * @param unknown $studentID, filedName | |
| * @throws ProfessionalException | |
| * @return object|array|\com\linways\base\util\$objectList[] | |
| */ | |
| function getFieldsOfStudent($studentID,$fieldName = null) | |
| { | |
| $studentID=$this->realEscapeString($studentID); | |
| $cond = ''; | |
| if($fieldName){ | |
| $cond = " AND fieldName = '$fieldName' "; | |
| } | |
| $query="select fieldName from studentProfileEditFields where studentID='$studentID' $cond "; | |
| try{ | |
| $response=$this->executeQueryForList($query); | |
| return $response; | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| /** | |
| * get fields to show student side | |
| * @author Aiswarya | |
| * @param unknown $studentID | |
| * @throws ProfessionalException | |
| * @return object|array|\com\linways\base\util\$objectList[] | |
| */ | |
| function getFieldsToShowStudentProfileSettings($studentID) | |
| { | |
| $studentID=$this->realEscapeString($studentID); | |
| $query="select fieldName from studentProfileShowFields where studentID='$studentID'"; | |
| try{ | |
| $response=$this->executeQueryForList($query); | |
| return $response; | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| /** | |
| * save field | |
| * @author Aswin | |
| * @param unknown $studentID | |
| * @param unknown $fieldName | |
| * @throws ProfessionalException | |
| * @return string | |
| */ | |
| function saveField($studentID,$fieldName) | |
| { | |
| $fieldName=$this->realEscapeString($fieldName); | |
| $studentID=$this->realEscapeString($studentID); | |
| $query="insert into studentProfileEditFields (studentID,fieldName) values ('$studentID','$fieldName');"; | |
| try{ | |
| $response=$this->executeQueryForObject($query); | |
| return "success"; | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| /** | |
| * delete field | |
| * @author Aswin | |
| * @param unknown $studentID | |
| * @param unknown $fieldName | |
| * @throws ProfessionalException | |
| */ | |
| function deleteField($studentID,$fieldName) | |
| { | |
| $fieldName=$this->realEscapeString($fieldName); | |
| $studentID=$this->realEscapeString($studentID); | |
| $query="delete from studentProfileEditFields where studentID='$studentID' and fieldName='$fieldName'"; | |
| try{ | |
| $response=$this->executeQueryForObject($query); | |
| return "deleted"; | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getCode()); | |
| } | |
| } | |
| /** | |
| * save all fields for student | |
| * @author Aswin | |
| * @param unknown $fields | |
| * @param unknown $studentID | |
| * @throws ProfessionalException | |
| * @return string | |
| */ | |
| function saveAllFields($fields,$studentID) | |
| { | |
| $fields=$this->realEscapeArray($fields); | |
| $studentID=$this->realEscapeString($studentID); | |
| try{ | |
| $response=$this->deleteAllFields($studentID); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| $query="insert into studentProfileEditFields (studentID,fieldName) values "; | |
| foreach ($fields as $r) | |
| { | |
| $query.="($studentID,'$r'),"; | |
| } | |
| $query=rtrim($query,","); | |
| try{ | |
| if(!empty($fields)){ | |
| $response=$this->executeQuery($query); | |
| } | |
| return "saved"; | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| /** | |
| * delete all fields | |
| * @author Aswin | |
| * @param unknown $studentID | |
| * @throws ProfessionalException | |
| * @return string | |
| */ | |
| function deleteAllFields($studentID) | |
| { | |
| $studentID=$this->realEscapeString($studentID); | |
| $query="delete from studentProfileEditFields where studentID='$studentID'"; | |
| try{ | |
| $response=$this->executeQueryForList($query); | |
| return "deleted"; | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| function checkStudentVerified($studentId){ | |
| $studentId = $this->realEscapeString($studentId); | |
| $sql = "select studentVerified from studentaccount where studentID = \"".$studentId."\""; | |
| try{ | |
| $response = $this->executeQueryForObject($sql); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| return $response->studentVerified; | |
| } | |
| function verifyStudent($studentId){ | |
| $studentId = $this->realEscapeString($studentId); | |
| $sql = "UPDATE `studentaccount` SET `studentVerified`='1' WHERE `studentID`='$studentId'"; | |
| try{ | |
| $this->executeQuery($sql); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| return true; | |
| } | |
| /** | |
| * save fields which is enabled to show student profile settings | |
| * @author Aiswarya | |
| * @param unknown $batchIDs | |
| * @param unknown $fields | |
| * @throws ProfessionalException | |
| * @return string | |
| */ | |
| function saveFieldsToShowStudentProfileSettingsForOneStudent($studentId,$fields) | |
| { | |
| $studentId = $this->realEscapeString($studentId); | |
| $fields = $this->realEscapeArray($fields); | |
| $query="delete from studentProfileShowFields where studentID = '$studentId'"; | |
| try{ | |
| $this->executeQuery($query); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| foreach ($fields as $t) | |
| { | |
| $query="insert into studentProfileShowFields (studentID,fieldName) values ($studentId,'$t->fieldName')"; | |
| try{ | |
| $this->executeQuery($query); | |
| }catch(\Exception $e) | |
| { | |
| throw new ProfessionalException($e->getCode(),$e->getMessage()); | |
| } | |
| } | |
| return "success"; | |
| } | |
| } | |