Author: mcantelon
Date: Mon Aug 27 12:46:08 2012
New Revision: 12221
Log:
Added logic to prevent creation of bogus subject access points.
Modified:
trunk/lib/task/import/csvImportTask.class.php
Modified: trunk/lib/task/import/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/import/csvImportTask.class.php Mon Aug 27 12:29:12
2012 (r12220)
+++ trunk/lib/task/import/csvImportTask.class.php Mon Aug 27 12:46:08
2012 (r12221)
@@ -589,54 +589,57 @@
$index = 0;
foreach($self->rowStatusVars[$columnName] as $subject)
{
- $scope = false;
- if
(isset($self->rowStatusVars['subjectAccessPointScopes'][$index]))
+ if ($subject)
{
- $scope =
$self->rowStatusVars['subjectAccessPointScopes'][$index];
- }
-
- $self->createAccessPoint($taxonomyId, $subject);
-
- if ($scope)
- {
- // get term ID
- $query = "SELECT t.id FROM term t \r
- INNER JOIN term_i18n i ON t.id=i.id \r
- WHERE i.name=? AND t.taxonomy_id=? AND culture='en'";
-
- $statement = QubitFlatfileImport::sqlQuery(
- $query,
- array($subject, $taxonomyId)
- );
+ $scope = false;
+ if
(isset($self->rowStatusVars['subjectAccessPointScopes'][$index]))
+ {
+ $scope =
$self->rowStatusVars['subjectAccessPointScopes'][$index];
+ }
- $result = $statement->fetch(PDO::FETCH_OBJ);
+ $self->createAccessPoint($taxonomyId, $subject);
- if ($result)
+ if ($scope)
{
- $termId = $result->id;
-
- // check if a scope note already exists for this term
- $query = "SELECT n.id FROM note n INNER JOIN note_i18n i
ON n.id=i.id WHERE n.object_id=? AND n.type_id=?";
+ // get term ID
+ $query = "SELECT t.id FROM term t \r
+ INNER JOIN term_i18n i ON t.id=i.id \r
+ WHERE i.name=? AND t.taxonomy_id=? AND culture='en'";
$statement = QubitFlatfileImport::sqlQuery(
$query,
- array($termId, QubitTerm::SCOPE_NOTE_ID)
+ array($subject, $taxonomyId)
);
$result = $statement->fetch(PDO::FETCH_OBJ);
- if (!$result)
+ if ($result)
{
- // add scope note if it doesn't exist
- $note = new QubitNote;
- $note->objectId = $termId;
- $note->typeId = QubitTerm::SCOPE_NOTE_ID;
- $note->content = $self->content($scope);
- $note->scope = 'QubitTerm'; # not sure if this is needed
- $note->save();
+ $termId = $result->id;
+
+ // check if a scope note already exists for this term
+ $query = "SELECT n.id FROM note n INNER JOIN note_i18n i
ON n.id=i.id WHERE n.object_id=? AND n.type_id=?";
+
+ $statement = QubitFlatfileImport::sqlQuery(
+ $query,
+ array($termId, QubitTerm::SCOPE_NOTE_ID)
+ );
+
+ $result = $statement->fetch(PDO::FETCH_OBJ);
+
+ if (!$result)
+ {
+ // add scope note if it doesn't exist
+ $note = new QubitNote;
+ $note->objectId = $termId;
+ $note->typeId = QubitTerm::SCOPE_NOTE_ID;
+ $note->content = $self->content($scope);
+ $note->scope = 'QubitTerm'; # not sure if this is
needed
+ $note->save();
+ }
+ } else {
+ throw new sfException('Could not find term "'. $subject
.'"');
}
- } else {
- throw new sfException('Could not find term "'. $subject
.'"');
}
}
$index++;
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.