echo ' </thead>'."\n";
echo ' <tbody>';
+
+ /* http://atutor.ca/atutor/mantis/view.php?id=4553
+ * remove old primary resources that's no longer used.
+ * @harris 9/30/2010
+ */
+ include_once(AT_INCLUDE_PATH.'../mods/_core/imsafa/classes/A4a.class.php');
+ $a4a = new A4a($cid);
+ $db_primary_resources = $a4a->getPrimaryResources();
+ foreach ($db_primary_resources as $primary_rid=>$db_resource){
+ //if this file from our table is not found in the $resource, then it's not used.
+ if(in_array($db_resource['resource'], $resources)===false){
+ $a4a->deletePrimaryResource($primary_rid);
+ }
+ }
+
foreach($resources as $primary_resource)
{
// check whether the primary resource is in the table
AND language_code = '".$_SESSION['lang']."'
AND resource='".$primary_resource."'";
$primary_result = mysql_query($sql, $db);
-
+
// insert primary resource if it's not in db
if (mysql_num_rows($primary_result) == 0)
{
}
+ /**
+ * Delete this primary resource and all its associated secondary resources
+ * @param int primary resournce id
+ */
+ function deletePrimaryResource($primary_rid){
+ global $db;
+ // Delete all secondary a4a
+ $sql = 'DELETE c, d FROM '.TABLE_PREFIX.'secondary_resources c LEFT JOIN '.TABLE_PREFIX."secondary_resources_types d ON c.secondary_resource_id=d.secondary_resource_id WHERE primary_resource_id=$primary_rid";
+ $result = mysql_query($sql, $db);
+
+ // If successful, remove all primary resources
+ if ($result){
+ $sql = 'DELETE a, b FROM '.TABLE_PREFIX.'primary_resources a LEFT JOIN '.TABLE_PREFIX."primary_resources_types b ON a.primary_resource_id=b.primary_resource_id WHERE a.primary_resource_id=$primary_rid";
+ mysql_query($sql, $db);
+ }
+ }
+
// Delete all materials associated with this content
function deleteA4a(){
global $db;