public function actionDeleteDataSources() { if (!empty($_POST['source'])) { foreach ($_POST['source'] as $source_id) { if (Institution::model()->find('source_id=?', array($source_id))) { echo "0"; return; } if (Site::model()->find('source_id=?', array($source_id))) { echo "0"; return; } if (Person::model()->find('source_id=?', array($source_id))) { echo "0"; return; } } foreach ($_POST['source'] as $source_id) { if ($source = ImportSource::model()->findByPk($source_id)) { if (!$source->delete()) { throw new Exception("Unable to delete import source: " . print_r($source->getErrors(), true)); } } } Audit::add('admin-DataSource', 'delete'); } echo "1"; }
* @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0 */ ?> <div class="admin box"> <h2>Data sources</h2> <form id="admin_data_sources"> <table class="grid"> <thead> <tr> <th><input type="checkbox" id="checkall" class="sources" /></th> <th>Name</th> </tr> </thead> <tbody> <?php foreach (ImportSource::model()->findAll(array('order' => 'name')) as $i => $source) { ?> <tr class="clickable" data-id="<?php echo $source->id; ?> " data-uri="admin/editdatasource/<?php echo $source->id; ?> "> <td><input type="checkbox" name="source[]" value="<?php echo $source->id; ?> " class="sources" /></td> <td><?php echo $source->name; ?>