$consumer->enabled = isset($_REQUEST['enabled']); if (!$consumer->save()) { $valid = false; $message = "<strong>Consumer could not be saved.</strong> {$sql->error}"; } } if (!$valid) { $smarty->addMessage('Required information missing', $message, NotificationMessage::ERROR); } /* look up consumer to edit, if requested */ } elseif (isset($_REQUEST['consumer_key'])) { $consumer = new LTI_Tool_Consumer($_REQUEST['consumer_key'], LTI_Data_Connector::getDataConnector($sql)); if (isset($_REQUEST['action'])) { switch ($_REQUEST['action']) { case 'delete': $consumer->delete(); break; case 'select': $name = $consumer->name; $key = $consumer->getKey(); $secret = $consumer->secret; $enabled = $consumer->enabled; break; case 'update': case 'insert': default: // leave default form values set } } } /* display a list of consumers */
public function delete($deleteConsumer = FALSE) { // Delete any nonce values for this consumer instance $sql = sprintf("DELETE FROM {$this->dbTableNamePrefix}" . BasicLTI_Tool_Provider::NONCE_TABLE_NAME . " WHERE consumer_instance_guid = %s", BasicLTI_Tool_Provider::quoted($this->guid)); mysql_query($sql); // Update any contexts for which this is a primary context $sql = sprintf("UPDATE {$this->dbTableNamePrefix}" . BasicLTI_Tool_Provider::CONTEXT_TABLE_NAME . ' SET primary_consumer_instance_guid = NULL AND primary_context_id = NULL' . " WHERE primary_consumer_instance_guid = %s", BasicLTI_Tool_Provider::quoted($this->guid)); $ok = mysql_query($sql); // Delete any contexts for this consumer instance $sql = sprintf("DELETE FROM {$this->dbTableNamePrefix}" . BasicLTI_Tool_Provider::CONTEXT_TABLE_NAME . " WHERE consumer_instance_guid = %s", BasicLTI_Tool_Provider::quoted($this->guid)); mysql_query($sql); // Delete consumer instance $sql = sprintf("DELETE FROM {$this->dbTableNamePrefix}" . BasicLTI_Tool_Provider::CONSUMER_INSTANCE_TABLE_NAME . " WHERE consumer_instance_guid = %s", BasicLTI_Tool_Provider::quoted($this->guid)); $ok = mysql_query($sql); if ($ok) { $this->guid = NULL; if ($deleteConsumer) { $consumer = new LTI_Tool_Consumer($this->consumer_guid, $this->dbTableNamePrefix); $consumer->delete(); } } return $ok; }
function lti_delete($key) { global $wpdb; $consumer = new LTI_Tool_Consumer($key, array($wpdb->prefix)); $consumer->delete(); // Now delete the blogs associated with this key. The WP function that lists all // blog is depreciated and so we'll do a direct DB access (look the other way) $search_str = '/' . str_replace('.', '', $key) . '%'; $sites = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM wp_blogs WHERE path LIKE %s", $search_str, 0)); // Delete the blog foreach ($sites as $site) { wpmu_delete_blog($site, TRUE); } }