/** * delete olayında önce kaydın active özelliğini pasif e olarak değiştiriyoruz. * daha sonra deleted= 1 ve active = 1 olan kaydı oluşturuyor. * böylece tablo içerisinde loglama mekanizması için gerekli olan kayıt oluşuyor. * @version 21.04.2016 * @param type $id * @param type $params * @return array * @throws PDOException */ public function deletedAct($params = array()) { try { $pdo = $this->slimApp->getServiceManager()->get('pgConnectFactory'); $pdo->beginTransaction(); $opUserId = InfoUsers::getUserId(array('pk' => $params['pk'])); if (\Utill\Dal\Helper::haveRecord($opUserId)) { $opUserIdValue = $opUserId['resultSet'][0]['user_id']; $this->makePassive(array('id' => $params['id'])); $operationIdValue = -3; $operationId = SysOperationTypes::getTypeIdToGoOperationId(array('parent_id' => 3, 'main_group' => 3, 'sub_grup_id' => 42, 'type_id' => 3)); if (\Utill\Dal\Helper::haveRecord($operationId)) { $operationIdValue = $operationId['resultSet'][0]['id']; } $sql = " \n INSERT INTO info_users_socialmedia(\n user_id, \n profile_public, \n op_user_id, \n operation_type_id, \n consultant_id, \n sys_socialmedia_id, \n act_parent_id, \n user_link,\n active,\n deleted\n )\n SELECT \n user_id,\n profile_public, \n " . intval($opUserIdValue) . " AS op_user_id, \n " . intval($operationIdValue) . " AS operation_type_id, \n consultant_id, \n sys_socialmedia_id,\n act_parent_id, \n user_link,\n 1,\n 1 \n FROM info_users_socialmedia \n WHERE id = " . intval($params['id']) . " \n "; $statement_act_insert = $pdo->prepare($sql); // echo debugPDO($sql, $params); $insert_act_insert = $statement_act_insert->execute(); $affectedRows = $statement_act_insert->rowCount(); $insertID = $pdo->lastInsertId('info_users_socialmedia_id_seq'); /* * ufak bir trik var. * işlem update oldugunda update işlemini yapan kişinin dil bilgisini kullanıcaz. * ancak delete işlemi oldugunda delete işlemini yapan user in dil bilgisini değil * silinen kaydı yapan kişinin dil bilgisini alıcaz. */ $consIdAndLanguageId = SysOperationTypes::getConsIdAndLanguageId(array('table_name' => 'info_users_socialmedia', 'id' => $params['id'])); if (\Utill\Dal\Helper::haveRecord($consIdAndLanguageId)) { $ConsultantId = $consIdAndLanguageId['resultSet'][0]['consultant_id']; $languageIdValue = $consIdAndLanguageId['resultSet'][0]['language_id']; } $xjobs = ActProcessConfirm::insert(array('op_user_id' => intval($opUserIdValue), 'operation_type_id' => intval($operationIdValue), 'table_column_id' => intval($insertID), 'cons_id' => intval($ConsultantId), 'preferred_language_id' => intval($languageIdValue))); if ($xjobs['errorInfo'][0] != "00000" && $xjobs['errorInfo'][1] != NULL && $xjobs['errorInfo'][2] != NULL) { throw new \PDOException($xjobs['errorInfo']); } $pdo->commit(); return array("found" => true, "errorInfo" => $errorInfo, "affectedRowsCount" => $affectedRows); } else { $errorInfo = '23502'; // 23502 not_null_violation $errorInfoColumn = 'pk'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } catch (\PDOException $e) { $pdo->rollback(); return array("found" => false, "errorInfo" => $e->getMessage()); } }
/** * delete olayında önce kaydın active özelliğini pasif e olarak değiştiriyoruz. * daha sonra deleted= 1 ve active = 1 olan kaydı oluşturuyor. * böylece tablo içerisinde loglama mekanizması için gerekli olan kayıt oluşuyor. * @version 25.04.2016 * @param type $id * @param type $params * @return array * @throws PDOException */ public function deletedAct($params = array()) { try { $pdo = $this->slimApp->getServiceManager()->get('pgConnectFactory'); $pdo->beginTransaction(); $opUserId = InfoUsers::getUserId(array('pk' => $params['pk'])); if (\Utill\Dal\Helper::haveRecord($opUserId)) { $opUserIdValue = $opUserId['resultSet'][0]['user_id']; $getFirm = InfoFirmProfile::getCheckIsThisFirmRegisteredUser(array('cpk' => $params['cpk'], 'op_user_id' => $opUserIdValue)); if (\Utill\Dal\Helper::haveRecord($getFirm)) { $getFirmId = $getFirm['resultSet'][0]['firm_id']; //$kontrol = $this->haveRecords($params); $kontrol = $this->haveRecords(array('id' => $params['id'], 'firm_id' => $getFirmId)); if (!\Utill\Dal\Helper::haveRecord($kontrol)) { $this->makePassive(array('id' => $params['id'])); $operationIdValue = -3; $operationId = SysOperationTypes::getTypeIdToGoOperationId(array('parent_id' => 3, 'main_group' => 3, 'sub_grup_id' => 32, 'type_id' => 3)); if (\Utill\Dal\Helper::haveRecord($operationId)) { $operationIdValue = $operationId['resultSet'][0]['id']; } $languageId = NULL; $languageIdValue = 647; if (isset($params['language_code']) && $params['language_code'] != "") { $languageId = SysLanguage::getLanguageId(array('language_code' => $params['language_code'])); if (\Utill\Dal\Helper::haveRecord($languageId)) { $languageIdValue = $languageId['resultSet'][0]['id']; } } $profilePublic = 0; if (isset($params['profile_public']) && $params['profile_public'] != "") { $profilePublic = intval($params['profile_public']); } $sql = " \n INSERT INTO info_firm_verbal(\n firm_id, \n consultant_id,\n operation_type_id, \n language_id,\n op_user_id,\n profile_public, \n act_parent_id, \n about,\n about_eng,\n verbal1_title, \n verbal1, \n verbal2_title, \n verbal2, \n verbal3_title, \n verbal3, \n verbal1_title_eng, \n verbal1_eng, \n verbal2_title_eng, \n verbal2_eng, \n verbal3_title_eng, \n verbal3_eng,\n consultant_confirm_type_id, \n confirm_id,\n language_parent_id,\n cons_allow_id,\n active,\n deleted\n ) \n SELECT \n firm_id, \n consultant_id, \n " . intval($operationIdValue) . " AS operation_type_id,\n language_id, \n " . intval($opUserIdValue) . " AS op_user_id, \n profile_public, \n act_parent_id, \n about,\n about_eng,\n verbal1_title,\n verbal1,\n verbal2_title,\n verbal2,\n verbal3_title,\n verbal3,\n verbal1_title_eng,\n verbal1_eng,\n verbal2_title_eng,\n verbal2_eng,\n verbal3_title_eng,\n verbal3_eng, \n consultant_confirm_type_id, \n confirm_id,\n language_parent_id,\n cons_allow_id,\n 1,\n 1\n FROM info_firm_verbal \n WHERE id = " . intval($params['id']) . " \n "; $statement_act_insert = $pdo->prepare($sql); $insert_act_insert = $statement_act_insert->execute(); // echo debugPDO($sql, $params); $affectedRows = $statement_act_insert->rowCount(); $insertID = $pdo->lastInsertId('info_firm_verbal_id_seq'); /* * ufak bir trik var. * işlem update oldugunda update işlemini yapan kişinin dil bilgisini kullanıcaz. * ancak delete işlemi oldugunda delete işlemini yapan user in dil bilgisini değil * silinen kaydı yapan kişinin dil bilgisini alıcaz. */ $consIdAndLanguageId = SysOperationTypes::getConsIdAndLanguageId(array('table_name' => 'info_firm_verbal', 'id' => $params['id'])); if (\Utill\Dal\Helper::haveRecord($consIdAndLanguageId)) { $ConsultantId = $consIdAndLanguageId['resultSet'][0]['consultant_id']; $languageIdValue = $consIdAndLanguageId['resultSet'][0]['language_id']; } $xjobs = ActProcessConfirm::insert(array('op_user_id' => intval($opUserIdValue), 'operation_type_id' => intval($operationIdValue), 'table_column_id' => intval($insertID), 'cons_id' => intval($ConsultantId), 'preferred_language_id' => intval($languageIdValue))); if ($xjobs['errorInfo'][0] != "00000" && $xjobs['errorInfo'][1] != NULL && $xjobs['errorInfo'][2] != NULL) { throw new \PDOException($xjobs['errorInfo']); } $pdo->commit(); return array("found" => true, "errorInfo" => $errorInfo, "affectedRowsCount" => $affectedRows); } else { // 23505 unique_violation $errorInfo = '23505'; $pdo->rollback(); $result = $kontrol; return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => ''); } } else { $errorInfo = '23502'; // 23502 not_null_violation $errorInfoColumn = 'cpk'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } else { $errorInfo = '23502'; // 23502 not_null_violation $errorInfoColumn = 'pk'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } catch (\PDOException $e) { $pdo->rollback(); return array("found" => false, "errorInfo" => $e->getMessage()); } }
/** * parametre olarak gelen 'id' li kaydın password unu update yapar !! * @author Okan CIRAN * @version v 1.0 02.09.2016 * @param array | null $args * @param type $params * @return array * @throws PDOException */ public function setPersonPassword($params = array()) { try { $pdo = $this->slimApp->getServiceManager()->get('pgConnectFactory'); $pdo->beginTransaction(); $userId = $this->getUserId(array('pk' => $params['key'])); if (\Utill\Dal\Helper::haveRecord($userId)) { $opUserIdValue = $userId['resultSet'][0]['user_id']; /* * kullanıcı için gerekli olan private key ve value değerleri yaratılılacak. */ $xcDeletedOnTheLink = InfoUsersSendingMail::setDeletedOnTheLinks(array('key' => $params['key'])); if ($xcDeletedOnTheLink['errorInfo'][0] != "00000" && $xcDeletedOnTheLink['errorInfo'][1] != NULL && $xcDeletedOnTheLink['errorInfo'][2] != NULL) { throw new \PDOException($xcDeletedOnTheLink['errorInfo']); } $affectedRows = $xcDeletedOnTheLink['affectedRowsCount']; if ($affectedRows == 1) { $active = 0; $operationIdValue = -2; $operationId = SysOperationTypes::getTypeIdToGoOperationId(array('parent_id' => 3, 'main_group' => 3, 'sub_grup_id' => 43, 'type_id' => 2)); if (\Utill\Dal\Helper::haveRecord($operationId)) { $operationIdValue = $operationId['resultSet'][0]['id']; } /* * parametre olarak gelen array deki 'id' li kaydın, info_users tablosundaki * alanlarını update eder !! username update edilmez. */ $this->updateInfoUsers(array('id' => $opUserIdValue, 'op_user_id' => $opUserIdValue, 'active' => $active, 'operation_type_id' => $operationIdValue, 'language_id' => 647, 'password' => $params['password'])); /* * parametre olarak gelen array deki 'id' li kaydın, info_users_details tablosundaki * active = 0 ve deleted = 0 olan kaydın active alanını 1 yapar !! */ $this->setUserDetailsDisables(array('id' => $opUserIdValue)); $operationIdValueDetail = -2; $operationIdDetail = SysOperationTypes::getTypeIdToGoOperationId(array('parent_id' => 3, 'main_group' => 3, 'sub_grup_id' => 40, 'type_id' => 2)); if (\Utill\Dal\Helper::haveRecord($operationIdDetail)) { $operationIdValueDetail = $operationIdDetail['resultSet'][0]['id']; } $sql = " \n INSERT INTO info_users_detail(\n profile_public, \n operation_type_id,\n active,\n name,\n surname,\n auth_email,\n language_id,\n op_user_id,\n root_id,\n act_parent_id,\n auth_allow_id,\n password \n ) \n SELECT \n 0 AS profile_public, \n " . intval($operationIdValueDetail) . " AS operation_type_id,\n " . intval($active) . " AS active, \n name, \n surname,\n auth_email, \n language_id, \n " . intval($opUserIdValue) . " AS op_user_id,\n a.root_id,\n a.act_parent_id,\n 1,\n '" . $params['password'] . "' AS password\n FROM info_users_detail a\n WHERE root_id =" . intval($opUserIdValue) . " \n AND active =1 AND deleted =0 and \n c_date = (SELECT MAX(c_date) \n\t\t\t\t\t\tFROM info_users_detail WHERE root_id =a.root_id\n\t\t\t\t\t\tAND active =1 AND deleted =0) \n "; $statementActInsert = $pdo->prepare($sql); // echo debugPDO($sql, $params); $insertAct = $statementActInsert->execute(); $affectedRows = $statementActInsert->rowCount(); $insertID = $pdo->lastInsertId('info_users_detail_id_seq'); $errorInfo = $statementActInsert->errorInfo(); if ($errorInfo[0] != "00000" && $errorInfo[1] != NULL && $errorInfo[2] != NULL) { throw new \PDOException($errorInfo[0]); } /* * ufak bir trik var. * işlem update oldugunda update işlemini yapan kişinin dil bilgisini kullanıcaz. * ancak delete işlemi oldugunda delete işlemini yapan user in dil bilgisini değil * silinen kaydı yapan kişinin dil bilgisini alıcaz. */ $consIdAndLanguageId = SysOperationTypes::getConsIdAndLanguageId(array('table_name' => 'info_users_detail', 'id' => $insertID)); if (\Utill\Dal\Helper::haveRecord($consIdAndLanguageId)) { $ConsultantId = $consIdAndLanguageId['resultSet'][0]['consultant_id']; // $languageIdValue = $consIdAndLanguageId ['resultSet'][0]['language_id']; } $xjobs = ActProcessConfirm::insert(array('op_user_id' => intval($opUserIdValue), 'operation_type_id' => intval($operationIdValue), 'table_column_id' => intval($insertID), 'cons_id' => intval($ConsultantId), 'preferred_language_id' => 647)); if ($xjobs['errorInfo'][0] != "00000" && $xjobs['errorInfo'][1] != NULL && $xjobs['errorInfo'][2] != NULL) { throw new \PDOException($xjobs['errorInfo']); } $pdo->commit(); return array("found" => true, "errorInfo" => $errorInfo, "affectedRowsCount" => $affectedRows); } else { $errorInfo = '23502'; /// 23502 user_id not_null_violation $errorInfoColumn = 'key'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } else { $errorInfo = '23502'; /// 23502 user_id not_null_violation $errorInfoColumn = 'pk'; $pdo->rollback(); return array("found" => false, "errorInfo" => $errorInfo, "resultSet" => '', "errorInfoColumn" => $errorInfoColumn); } } catch (\PDOException $e) { $pdo->rollback(); return array("found" => false, "errorInfo" => $e->getMessage()); } }