public static function doDelete(Criteria $criteria, $connection = null) { if (!isset($connection)) { $connection = QubitTransactionFilter::getConnection(QubitOaiHarvest::DATABASE_NAME); } $affectedRows = 0; $affectedRows += BasePeer::doDelete($criteria, $connection); return $affectedRows; }
public function testDoDelete() { try { $c = new Criteria(); $c->setPrimaryTableName(BookPeer::TABLE_NAME); $c->add(BookPeer::ID, 12, ' BAD SQL'); BasePeer::doDelete($c, Propel::getConnection()); } catch (PropelException $e) { $this->assertContains('[DELETE FROM `book` WHERE book.ID BAD SQL:p1]', $e->getMessage(), 'SQL query is written in the exception message'); } }
/** * Performs a DELETE on the database, given a AbsenceEleveTraitement or Criteria object OR a primary key value. * * @param mixed $values Criteria or AbsenceEleveTraitement object or primary key or array of primary keys * which is used to create the DELETE statement * @param PropelPDO $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows * if supported by native driver or if emulated using Propel. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doForceDelete($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(AbsenceEleveTraitementPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($values instanceof Criteria) { // rename for clarity $criteria = clone $values; } elseif ($values instanceof AbsenceEleveTraitement) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks $criteria = new Criteria(self::DATABASE_NAME); $criteria->add(AbsenceEleveTraitementPeer::ID, (array) $values, Criteria::IN); } // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows try { // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. $con->beginTransaction(); // cloning the Criteria in case it's modified by doSelect() or doSelectStmt() $c = clone $criteria; $affectedRows += AbsenceEleveTraitementPeer::doOnDeleteCascade($c, $con); // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). if ($values instanceof Criteria) { AbsenceEleveTraitementPeer::clearInstancePool(); } elseif ($values instanceof AbsenceEleveTraitement) { // it's a model object AbsenceEleveTraitementPeer::removeInstanceFromPool($values); } else { // it's a primary key, or an array of pks foreach ((array) $values as $singleval) { AbsenceEleveTraitementPeer::removeInstanceFromPool($singleval); } } $affectedRows += BasePeer::doDelete($criteria, $con); AbsenceEleveTraitementPeer::clearRelatedInstancePool(); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollBack(); throw $e; } }
/** * Method perform a DELETE on the database, given a Role or Criteria object OR a primary key value. * * @param mixed $values Criteria or Role object or primary key or array of primary keys * which is used to create the DELETE statement * @param PropelPDO $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows * if supported by native driver or if emulated using Propel. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doDelete($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(RolePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($values instanceof Criteria) { // invalidate the cache for all objects of this type, since we have no // way of knowing (without running a query) what objects should be invalidated // from the cache based on this Criteria. RolePeer::clearInstancePool(); // rename for clarity $criteria = clone $values; } elseif ($values instanceof Role) { // invalidate the cache for this single object RolePeer::removeInstanceFromPool($values); // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it must be the primary key $criteria = new Criteria(self::DATABASE_NAME); $criteria->add(RolePeer::ID, (array) $values, Criteria::IN); foreach ((array) $values as $singleval) { // we can invalidate the cache for this single object RolePeer::removeInstanceFromPool($singleval); } } // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows try { // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. $con->beginTransaction(); $affectedRows += RolePeer::doOnDeleteCascade($criteria, $con); // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). if ($values instanceof Criteria) { RolePeer::clearInstancePool(); } else { // it's a PK or object RolePeer::removeInstanceFromPool($values); } $affectedRows += BasePeer::doDelete($criteria, $con); // invalidate objects in EmployeePeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule. EmployeePeer::clearInstancePool(); // invalidate objects in UserPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule. UserPeer::clearInstancePool(); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollBack(); throw $e; } }
public static function doDelete($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(TipodocentePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($values instanceof Criteria) { TipodocentePeer::clearInstancePool(); $criteria = clone $values; } elseif ($values instanceof Tipodocente) { TipodocentePeer::removeInstanceFromPool($values); $criteria = $values->buildPkeyCriteria(); } else { $criteria = new Criteria(self::DATABASE_NAME); $criteria->add(TipodocentePeer::ID, (array) $values, Criteria::IN); foreach ((array) $values as $singleval) { TipodocentePeer::removeInstanceFromPool($singleval); } } $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; try { $con->beginTransaction(); $affectedRows += BasePeer::doDelete($criteria, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollBack(); throw $e; } }
public static function doDelete($values, $con = null) { if ($con === null) { $con = Propel::getConnection(VCourseDayPeer::DATABASE_NAME); } if ($values instanceof Criteria) { $criteria = clone $values; } elseif ($values instanceof VCourseDay) { $criteria = $values->buildCriteria(); } else { $criteria = new Criteria(self::DATABASE_NAME); if (count($values) == count($values, COUNT_RECURSIVE)) { $values = array($values); } $vals = array(); foreach ($values as $value) { } } $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; try { $con->begin(); $affectedRows += BasePeer::doDelete($criteria, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollback(); throw $e; } }
public static function doDelete($values, $con = null) { if ($con === null) { $con = Propel::getConnection(VSubjectAgendaPeer::DATABASE_NAME); } if ($values instanceof Criteria) { $criteria = clone $values; } elseif ($values instanceof VSubjectAgenda) { $criteria = $values->buildPkeyCriteria(); } else { $criteria = new Criteria(self::DATABASE_NAME); if (count($values) == count($values, COUNT_RECURSIVE)) { $values = array($values); } $vals = array(); foreach ($values as $value) { $vals[0][] = $value[0]; $vals[1][] = $value[1]; $vals[2][] = $value[2]; $vals[3][] = $value[3]; } $criteria->add(VSubjectAgendaPeer::COURSE_SCHEDULE_ID, $vals[0], Criteria::IN); $criteria->add(VSubjectAgendaPeer::CLASS_GROUP_ID, $vals[1], Criteria::IN); $criteria->add(VSubjectAgendaPeer::SUBJECT_CURR_ID, $vals[2], Criteria::IN); $criteria->add(VSubjectAgendaPeer::ACADEMIC_CALENDAR_ID, $vals[3], Criteria::IN); } $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; try { $con->begin(); $affectedRows += BasePeer::doDelete($criteria, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollback(); throw $e; } }
/** * Method perform a DELETE on the database, given a ExamCommentDig or Criteria object OR a primary key value. * * @param mixed $values Criteria or ExamCommentDig object or primary key or array of primary keys * which is used to create the DELETE statement * @param PropelPDO $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows * if supported by native driver or if emulated using Propel. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doDelete($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(ExamCommentDigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($values instanceof Criteria) { // invalidate the cache for all objects of this type, since we have no // way of knowing (without running a query) what objects should be invalidated // from the cache based on this Criteria. ExamCommentDigPeer::clearInstancePool(); // rename for clarity $criteria = clone $values; } elseif ($values instanceof ExamCommentDig) { // invalidate the cache for this single object ExamCommentDigPeer::removeInstanceFromPool($values); // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it must be the primary key $criteria = new Criteria(self::DATABASE_NAME); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey // values if (count($values) == count($values, COUNT_RECURSIVE)) { // array is not multi-dimensional $values = array($values); } foreach ($values as $value) { $criterion = $criteria->getNewCriterion(ExamCommentDigPeer::IP, $value[0]); $criterion->addAnd($criteria->getNewCriterion(ExamCommentDigPeer::COMMENT_ID, $value[1])); $criteria->addOr($criterion); // we can invalidate the cache for this single PK ExamCommentDigPeer::removeInstanceFromPool($value); } } // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows try { // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. $con->beginTransaction(); $affectedRows += BasePeer::doDelete($criteria, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollBack(); throw $e; } }
public static function doDelete($values, $con = null) { if ($con === null) { $con = Propel::getConnection(VOpacPeer::DATABASE_NAME); } if ($values instanceof Criteria) { $criteria = clone $values; } elseif ($values instanceof VOpac) { $criteria = $values->buildPkeyCriteria(); } else { $criteria = new Criteria(self::DATABASE_NAME); if (count($values) == count($values, COUNT_RECURSIVE)) { $values = array($values); } $vals = array(); foreach ($values as $value) { $vals[0][] = $value[0]; $vals[1][] = $value[1]; $vals[2][] = $value[2]; $vals[3][] = $value[3]; $vals[4][] = $value[4]; } $criteria->add(VOpacPeer::CATALOG_ID, $vals[0], Criteria::IN); $criteria->add(VOpacPeer::DEPARTMENT_ID, $vals[1], Criteria::IN); $criteria->add(VOpacPeer::CAT_CATEGORY_ID, $vals[2], Criteria::IN); $criteria->add(VOpacPeer::COL_STATUS_ID, $vals[3], Criteria::IN); $criteria->add(VOpacPeer::COL_LOCATION_ID, $vals[4], Criteria::IN); } $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; try { $con->begin(); $affectedRows += BasePeer::doDelete($criteria, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollback(); throw $e; } }
public static function doDelete($values, $con = null) { if ($con === null) { $con = Propel::getConnection(EtimeAudiencePeer::DATABASE_NAME); } if ($values instanceof Criteria) { $criteria = clone $values; } elseif ($values instanceof EtimeAudience) { $criteria = $values->buildPkeyCriteria(); } else { $criteria = new Criteria(self::DATABASE_NAME); if (count($values) == count($values, COUNT_RECURSIVE)) { $values = array($values); } $vals = array(); foreach ($values as $value) { $vals[0][] = $value[0]; $vals[1][] = $value[1]; } $criteria->add(EtimeAudiencePeer::ETIME_ID, $vals[0], Criteria::IN); $criteria->add(EtimeAudiencePeer::AUDIENCE_ID, $vals[1], Criteria::IN); } $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; try { $con->begin(); $affectedRows += BasePeer::doDelete($criteria, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollback(); throw $e; } }
/** * Performs a DELETE on the database, given a Traspaso or Criteria object OR a primary key value. * * @param mixed $values Criteria or Traspaso object or primary key or array of primary keys * which is used to create the DELETE statement * @param PropelPDO $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows * if supported by native driver or if emulated using Propel. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doDelete($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(TraspasoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($values instanceof Criteria) { // rename for clarity $criteria = clone $values; } elseif ($values instanceof Traspaso) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks $criteria = new Criteria(TraspasoPeer::DATABASE_NAME); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey values if (count($values) == count($values, COUNT_RECURSIVE)) { // array is not multi-dimensional $values = array($values); } foreach ($values as $value) { $criterion = $criteria->getNewCriterion(TraspasoPeer::IDINVENTARIOLUGAR, $value[0]); $criterion->addAnd($criteria->getNewCriterion(TraspasoPeer::IDLUGARREMITENTE, $value[1])); $criterion->addAnd($criteria->getNewCriterion(TraspasoPeer::IDLUGARDESTINATARIO, $value[2])); $criteria->addOr($criterion); } } // Set the correct dbName $criteria->setDbName(TraspasoPeer::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows try { // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. $con->beginTransaction(); // cloning the Criteria in case it's modified by doSelect() or doSelectStmt() $c = clone $criteria; $affectedRows += TraspasoPeer::doOnDeleteCascade($c, $con); // Because this db requires some delete cascade/set null emulation, we have to // clear the cached instance *after* the emulation has happened (since // instances get re-added by the select statement contained therein). if ($values instanceof Criteria) { TraspasoPeer::clearInstancePool(); } elseif ($values instanceof Traspaso) { // it's a model object TraspasoPeer::removeInstanceFromPool($values); } else { // it's a primary key, or an array of pks foreach ((array) $values as $singleval) { TraspasoPeer::removeInstanceFromPool($singleval); } } $affectedRows += BasePeer::doDelete($criteria, $con); TraspasoPeer::clearRelatedInstancePool(); $con->commit(); return $affectedRows; } catch (Exception $e) { $con->rollBack(); throw $e; } }
public function testCommentDoDelete() { $c = new Criteria(); $c->setComment('Foo'); $c->add(BookPeer::TITLE, 'War And Peace'); $con = Propel::getConnection(BookPeer::DATABASE_NAME); BasePeer::doDelete($c, $con); $expected = 'DELETE /* Foo */ FROM `book` WHERE book.TITLE=\'War And Peace\''; $this->assertEquals($expected, $con->getLastExecutedQuery(), 'Criteria::setComment() adds a comment to delete queries'); }
public static function doDelete($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(RelAnioActividadDocentePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($values instanceof Criteria) { RelAnioActividadDocentePeer::clearInstancePool(); $criteria = clone $values; } elseif ($values instanceof RelAnioActividadDocente) { RelAnioActividadDocentePeer::removeInstanceFromPool($values); $criteria = $values->buildPkeyCriteria(); } else { $criteria = new Criteria(self::DATABASE_NAME); if (count($values) == count($values, COUNT_RECURSIVE)) { $values = array($values); } foreach ($values as $value) { $criterion = $criteria->getNewCriterion(RelAnioActividadDocentePeer::FK_ANIO_ACTIVIDAD_ID, $value[0]); $criterion->addAnd($criteria->getNewCriterion(RelAnioActividadDocentePeer::FK_DOCENTE_ID, $value[1])); $criteria->addOr($criterion); RelAnioActividadDocentePeer::removeInstanceFromPool($value); } } $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; try { $con->beginTransaction(); $affectedRows += BasePeer::doDelete($criteria, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollBack(); throw $e; } }
/** function executed by the cron this function will synchronize users from ldap/active directory to PM users tables @return void */ public function executeCron($debug) { $rbac =& RBAC::getSingleton(); if (is_null($rbac->authSourcesObj)) { $rbac->authSourcesObj = new AuthenticationSource(); } $plugin = new ldapAdvanced(); $plugin->sSystem = $rbac->sSystem; $plugin->setFrontEnd(true); $plugin->setDebug($debug); //Get all authsource for this plugin ( ldapAdvanced plugin, because other authsources are not needed ) $arrayAuthenticationSource = $plugin->getAuthSources(); $aDepartments = $plugin->getDepartments(""); $aGroups = $plugin->getGroups(); //$arrayDepartmentUserAd = array(); //(D) Update Users //$arrayGroupUserAd = array(); //(G) Update Users //echo "\n"; $plugin->frontEndShow("START"); $plugin->debugLog("START"); foreach ($arrayAuthenticationSource as $value) { $arrayAuthenticationSourceData = $value; $plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$arrayAuthenticationSourceData ---->\n" . print_r($arrayAuthenticationSourceData, true)); $plugin->sAuthSource = $arrayAuthenticationSourceData["AUTH_SOURCE_UID"]; $plugin->ldapcnn = null; $plugin->setArrayDepartmentUserSynchronizedChecked(array()); $plugin->setArrayUserUpdateChecked(array()); //Get all User (USR_UID, USR_USERNAME, USR_AUTH_USER_DN) registered in RBAC with this Authentication Source $plugin->setArrayAuthenticationSourceUsers($arrayAuthenticationSourceData["AUTH_SOURCE_UID"]); //INITIALIZE DATA $plugin->frontEndShow("TEXT", "Authentication Source: " . $arrayAuthenticationSourceData["AUTH_SOURCE_NAME"]); $plugin->log(null, "Executing cron for Authentication Source: " . $arrayAuthenticationSourceData["AUTH_SOURCE_NAME"]); //Get all departments from Ldap/ActiveDirectory and build a hierarchy using dn (ou->ou parent) $aLdapDepts = $plugin->searchDepartments(); //Obtain all departments from PM with a valid department in LDAP/ActiveDirectory $aRegisteredDepts = $plugin->getRegisteredDepartments($aLdapDepts, $aDepartments); $plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$aRegisteredDepts ---->\n" . print_r($aRegisteredDepts, true)); //Get all group from Ldap/ActiveDirectory $aLdapGroups = $plugin->searchGroups(); //Obtain all groups from PM with a valid group in LDAP/ActiveDirectory $aRegisteredGroups = $plugin->getRegisteredGroups($aLdapGroups, $aGroups); $plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$aRegisteredGroups ---->\n" . print_r($aRegisteredGroups, true)); //Get all users from Removed OU $this->usersRemovedOu = $plugin->getUsersFromRemovedOu($arrayAuthenticationSourceData); $plugin->deactiveArrayOfUsers($this->usersRemovedOu); //Variables $this->deletedRemoved = count($this->usersRemovedOu); $this->deletedRemovedUsers = ""; $this->dAlready = 0; $this->dMoved = 0; $this->dImpossible = 0; $this->dCreated = 0; $this->dRemoved = 0; $this->dAlreadyUsers = ""; $this->dMovedUsers = ""; $this->dImpossibleUsers = ""; $this->dCreatedUsers = ""; $this->dRemovedUsers = ""; $this->gAlready = 0; $this->gMoved = 0; $this->gImpossible = 0; $this->gCreated = 0; $this->gRemoved = 0; $this->gAlreadyUsers = ""; $this->gMovedUsers = ""; $this->gImpossibleUsers = ""; $this->gCreatedUsers = ""; $this->gRemovedUsers = ""; //Department - Synchronize Users $numDepartments = count($aRegisteredDepts); $count = 0; $plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$numDepartments ----> {$numDepartments}"); foreach ($aRegisteredDepts as $registeredDept) { $count++; //(D) Update Users //if (!isset($arrayDepartmentUserAd[$registeredDept["DEP_UID"]])) { // $arrayDepartmentUserAd[$registeredDept["DEP_UID"]] = array(); //Current users in department based in Active Directory //} // //$arrayAux = $this->departmentSynchronizeUsers($plugin, $numDepartments, $count, $registeredDept); //$arrayAux = array_merge($arrayDepartmentUserAd[$registeredDept["DEP_UID"]], $arrayAux); // //$arrayDepartmentUserAd[$registeredDept["DEP_UID"]] = array_unique($arrayAux); $arrayAux = $this->departmentSynchronizeUsers($plugin, $numDepartments, $count, $registeredDept); } //Department - Print log $logResults = sprintf("- Departments -> Existing users: %d, moved: %d, impossible: %d, created: %d, removed: %d", $this->dAlready, $this->dMoved, $this->dImpossible, $this->dCreated, $this->dRemoved); $plugin->frontEndShow("TEXT", $logResults); $plugin->log(null, $logResults); //Group - Synchronize Users $numGroups = count($aRegisteredGroups); $count = 0; $plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$numGroups ----> {$numGroups}"); foreach ($aRegisteredGroups as $registeredGroup) { $count++; //(G) Update Users //if (!isset($arrayGroupUserAd[$registeredGroup["GRP_UID"]])) { // $arrayGroupUserAd[$registeredGroup["GRP_UID"]] = array(); //Current users in group based in Active Directory //} // //$arrayAux = $this->groupSynchronizeUsers($plugin, $numGroups, $count, $registeredGroup); //$arrayAux = array_merge($arrayGroupUserAd[$registeredGroup["GRP_UID"]], $arrayAux); // //$arrayGroupUserAd[$registeredGroup["GRP_UID"]] = array_unique($arrayAux); $arrayAux = $this->groupSynchronizeUsers($plugin, $numGroups, $count, $registeredGroup); } //Group - Print log $logResults = sprintf("- Groups -> Existing users: %d, moved: %d, impossible: %d, created: %d, removed: %d", $this->gAlready, $this->gMoved, $this->gImpossible, $this->gCreated, $this->gRemoved); $plugin->frontEndShow("TEXT", $logResults); $plugin->log(null, $logResults); //Manager $plugin->clearManager($this->managersToClear); if (isset($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["DEPARTMENTS_TO_UNASSIGN"])) { if (is_array($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["DEPARTMENTS_TO_UNASSIGN"])) { foreach ($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["DEPARTMENTS_TO_UNASSIGN"] as $departmentUID) { // Delete manager assignments $criteriaSet = new Criteria("workflow"); $criteriaSet->add(UsersPeer::USR_REPORTS_TO, ""); $criteriaWhere = new Criteria("workflow"); $criteriaWhere->add(UsersPeer::DEP_UID, $departmentUID); $criteriaWhere->add(UsersPeer::USR_REPORTS_TO, "", Criteria::NOT_EQUAL); $this->deletedManager = BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow")); // Delete department assignments $criteriaSet = new Criteria("workflow"); $criteriaSet->add(UsersPeer::DEP_UID, ""); $criteriaWhere = new Criteria("workflow"); $criteriaWhere->add(UsersPeer::DEP_UID, $departmentUID); $this->dMoved += UsersPeer::doCount($criteriaWhere); BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow")); } } unset($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["DEPARTMENTS_TO_UNASSIGN"]); $rbac =& RBAC::getSingleton(); $rbac->authSourcesObj->update($arrayAuthenticationSourceData); } if (isset($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"])) { if (is_array($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"])) { foreach ($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"] as $groupUID) { // Delete manager assignments $groupsInstance = new Groups(); $criteria = $groupsInstance->getUsersGroupCriteria($groupUID); $dataset = UsersPeer::doSelectRS($criteria); $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $dataset->next(); $users = array(); while ($row = $dataset->getRow()) { $users[] = $row["USR_UID"]; $dataset->next(); } $criteriaSet = new Criteria("workflow"); $criteriaSet->add(UsersPeer::USR_REPORTS_TO, ""); $criteriaWhere = new Criteria("workflow"); $criteriaWhere->add(UsersPeer::USR_UID, $users, Criteria::IN); $criteriaWhere->add(UsersPeer::USR_REPORTS_TO, "", Criteria::NOT_EQUAL); $this->deletedManager = BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow")); // Delete group assignments $criteria = new Criteria("workflow"); $criteria->add(GroupUserPeer::GRP_UID, $groupUID); $this->gMoved += GroupUserPeer::doCount($criteria); BasePeer::doDelete($criteria, Propel::getConnection("workflow")); } } unset($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"]); $rbac =& RBAC::getSingleton(); $rbac->authSourcesObj->update($arrayAuthenticationSourceData); } // Delete the managers that not exists in PM $criteria = new Criteria("rbac"); $criteria->addSelectColumn(RbacUsersPeer::USR_AUTH_USER_DN); $criteria->add(RbacUsersPeer::USR_AUTH_USER_DN, "", Criteria::NOT_EQUAL); $dataset = RbacUsersPeer::doSelectRS($criteria); $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $dataset->next(); $existingUsers = array(); while ($row = $dataset->getRow()) { $existingUsers[] = $row["USR_AUTH_USER_DN"]; $dataset->next(); } foreach ($this->managersHierarchy as $managerDN => $subordinates) { if (!in_array($managerDN, $existingUsers)) { unset($this->managersHierarchy[$managerDN]); } } // Get the managers assigments counters $plugin->synchronizeManagers($this->managersHierarchy); $deletedManagersAssignments = self::array_diff_assoc_recursive($this->oldManagersHierarchy, $this->managersHierarchy); $newManagersAssignments = self::array_diff_assoc_recursive($this->managersHierarchy, $this->oldManagersHierarchy); $deletedManagers = array(); $newManagers = array(); $movedManagers = array(); if (is_array($deletedManagersAssignments)) { foreach ($deletedManagersAssignments as $dn1 => $subordinates1) { foreach ($subordinates1 as $subordinate) { if (!in_array($subordinate, $deletedManagers)) { $deletedManagers[] = $subordinate; } foreach ($newManagersAssignments as $dn2 => $subordinates2) { if (isset($subordinates2[$subordinate])) { $movedManagers[] = $subordinate; } } } } } if (is_array($newManagersAssignments)) { foreach ($newManagersAssignments as $dn1 => $subordinates1) { foreach ($subordinates1 as $subordinate) { if (!in_array($subordinate, $newManagers)) { $newManagers[] = $subordinate; } foreach ($deletedManagersAssignments as $dn2 => $subordinates2) { if (isset($subordinates2[$subordinate])) { if (!in_array($subordinate, $movedManagers)) { $movedManagers[] = $subordinate; } } } } } } //Print and log the users's information //Deleted/Removed Users $logResults = sprintf("- Deleted/Removed Users: %d", $this->deletedRemoved); $plugin->frontEndShow("TEXT", $logResults); $plugin->log(null, $logResults); if ($this->deletedRemoved > 0) { $plugin->log(null, "Deleted/Removed Users: "); $plugin->log(null, $this->deletedRemovedUsers); } if ($this->dAlready + $this->gAlready > 0) { $plugin->log(null, "Existing Users: "); $plugin->log(null, $this->dAlreadyUsers . " " . $this->gAlreadyUsers); } if ($this->dMoved + $this->gMoved > 0) { $plugin->log(null, "Moved Users: "); $plugin->log(null, $this->dMovedUsers . " " . $this->gMovedUsers); } if ($this->dImpossible + $this->gImpossible > 0) { $plugin->log(null, "Impossible Users: "); $plugin->log(null, $this->dImpossibleUsers . " " . $this->gImpossibleUsers); } if ($this->dCreated + $this->gCreated > 0) { $plugin->log(null, "Created Users: "); $plugin->log(null, $this->dCreatedUsers . " " . $this->gCreatedUsers); } if ($this->dRemoved + $this->gRemoved > 0) { $plugin->log(null, "Removed Users: "); $plugin->log(null, $this->dRemovedUsers . " " . $this->gRemovedUsers); } //Print and log the managers assignments"s information $logResults = sprintf("- Managers assignments: created %d, moved %d, removed %d", count($newManagers) - count($movedManagers), count($movedManagers), count($deletedManagers) - count($movedManagers) + $this->deletedManager); $plugin->frontEndShow("TEXT", $logResults); $plugin->log(null, $logResults); //Update Users data based on the LDAP Server $plugin->usersUpdateData($arrayAuthenticationSourceData["AUTH_SOURCE_UID"]); } $plugin->frontEndShow("END"); //(D) Update Users ////Department //Upgrade users in departments //foreach ($arrayDepartmentUserAd as $departmentUid => $arrayUserAd) { // $plugin->setArrayDepartmentUsers($departmentUid); //INITIALIZE DATA // // $arrayAux = array_diff(array_keys($plugin->arrayDepartmentUsersByUid), $arrayUserAd); // // $this->departmentRemoveUsers($departmentUid, $arrayAux); //} //(G) Update Users ////Group //Upgrade users in groups //foreach ($arrayGroupUserAd as $groupUid => $arrayUserAd) { // $plugin->setArrayGroupUsers($groupUid); //INITIALIZE DATA // // $arrayAux = array_diff(array_keys($plugin->arrayGroupUsersByUid), $arrayUserAd); // // $this->groupRemoveUsers($groupUid, $arrayAux); //} //// Developed by Gary and Ronald //$usersInfo = $plugin->ASUpdateInfo(''); //if (isset($usersInfo) && $usersInfo > 0) { // $this->dMoved = $usersInfo; //} //// End Developed by Gary and Ronald $plugin->debugLog("END"); }
/** * Method perform a DELETE on the database, given a sfAsset or Criteria object OR a primary key value. * * @param mixed $values Criteria or sfAsset object or primary key or array of primary keys * which is used to create the DELETE statement * @param PropelPDO $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows * if supported by native driver or if emulated using Propel. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doDelete($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(sfAssetPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($values instanceof Criteria) { // invalidate the cache for all objects of this type, since we have no // way of knowing (without running a query) what objects should be invalidated // from the cache based on this Criteria. sfAssetPeer::clearInstancePool(); // rename for clarity $criteria = clone $values; } elseif ($values instanceof sfAsset) { // invalidate the cache for this single object sfAssetPeer::removeInstanceFromPool($values); // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it must be the primary key $criteria = new Criteria(self::DATABASE_NAME); $criteria->add(sfAssetPeer::ID, (array) $values, Criteria::IN); foreach ((array) $values as $singleval) { // we can invalidate the cache for this single object sfAssetPeer::removeInstanceFromPool($singleval); } } // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows try { // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. $con->beginTransaction(); $affectedRows += BasePeer::doDelete($criteria, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollBack(); throw $e; } }
/** * Method perform a DELETE on the database, given a BpmnProject or Criteria object OR a primary key value. * * @param mixed $values Criteria or BpmnProject object or primary key or array of primary keys * which is used to create the DELETE statement * @param Connection $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). * This includes CASCADE-related rows * if supported by native driver or if emulated using Propel. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doDelete($values, $con = null) { if ($con === null) { $con = Propel::getConnection(BpmnProjectPeer::DATABASE_NAME); } if ($values instanceof Criteria) { $criteria = clone $values; // rename for clarity } elseif ($values instanceof BpmnProject) { $criteria = $values->buildPkeyCriteria(); } else { // it must be the primary key $criteria = new Criteria(self::DATABASE_NAME); $criteria->add(BpmnProjectPeer::PRJ_UID, (array) $values, Criteria::IN); } // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows try { // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. $con->begin(); $affectedRows += BasePeer::doDelete($criteria, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollback(); throw $e; } }
/** * Method perform a DELETE on the database, given a AppOwner or Criteria object OR a primary key value. * * @param mixed $values Criteria or AppOwner object or primary key or array of primary keys * which is used to create the DELETE statement * @param Connection $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows * if supported by native driver or if emulated using Propel. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doDelete($values, $con = null) { if ($con === null) { $con = Propel::getConnection(AppOwnerPeer::DATABASE_NAME); } if ($values instanceof Criteria) { $criteria = clone $values; // rename for clarity } elseif ($values instanceof AppOwner) { $criteria = $values->buildPkeyCriteria(); } else { // it must be the primary key $criteria = new Criteria(self::DATABASE_NAME); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey // values if (count($values) == count($values, COUNT_RECURSIVE)) { // array is not multi-dimensional $values = array($values); } $vals = array(); foreach ($values as $value) { $vals[0][] = $value[0]; $vals[1][] = $value[1]; $vals[2][] = $value[2]; } $criteria->add(AppOwnerPeer::APP_UID, $vals[0], Criteria::IN); $criteria->add(AppOwnerPeer::OWN_UID, $vals[1], Criteria::IN); $criteria->add(AppOwnerPeer::USR_UID, $vals[2], Criteria::IN); } // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows try { // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. $con->begin(); $affectedRows += BasePeer::doDelete($criteria, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollback(); throw $e; } }
public static function doDelete($values, $con = null) { if ($con === null) { $con = Propel::getConnection(LorfieldsPeer::DATABASE_NAME); } if ($values instanceof Criteria) { $criteria = clone $values; } elseif ($values instanceof Lorfields) { $criteria = $values->buildPkeyCriteria(); } else { $criteria = new Criteria(self::DATABASE_NAME); $criteria->add(LorfieldsPeer::ID, (array) $values, Criteria::IN); } $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; try { $con->begin(); $affectedRows += BasePeer::doDelete($criteria, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollback(); throw $e; } }
public static function doDelete($values, $con = null) { if ($con === null) { $con = Propel::getConnection(CounselingRaportPeer::DATABASE_NAME); } if ($values instanceof Criteria) { $criteria = clone $values; } elseif ($values instanceof CounselingRaport) { $criteria = $values->buildPkeyCriteria(); } else { $criteria = new Criteria(self::DATABASE_NAME); if (count($values) == count($values, COUNT_RECURSIVE)) { $values = array($values); } $vals = array(); foreach ($values as $value) { $vals[0][] = $value[0]; $vals[1][] = $value[1]; $vals[2][] = $value[2]; $vals[3][] = $value[3]; } $criteria->add(CounselingRaportPeer::ID, $vals[0], Criteria::IN); $criteria->add(CounselingRaportPeer::STUDENT_ACCAL_ID, $vals[1], Criteria::IN); $criteria->add(CounselingRaportPeer::SUBJECT_CURR_ID, $vals[2], Criteria::IN); $criteria->add(CounselingRaportPeer::COUNSELING_SPEC_ID, $vals[3], Criteria::IN); } $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; try { $con->begin(); $affectedRows += BasePeer::doDelete($criteria, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollback(); throw $e; } }