Skip to content

Instantly share code, notes, and snippets.

@newism
Created August 7, 2009 03:14
Show Gist options
  • Save newism/163688 to your computer and use it in GitHub Desktop.
Save newism/163688 to your computer and use it in GitHub Desktop.
<?php
class Nsm_module_CP {
var $module_name = "Nsm_module";
var $version = '1.0.0';
public function __construct($switch = TRUE)
{
global $IN;
if($switch === TRUE)
{
switch($IN->GBL('P'))
{
default : $this->index();
break;
}
}
}
private function index()
{
$this->render_layout("index");
}
private function render_layout($page, $content = ''){}
public function nsm_form_builder_module_install()
{
global $DB, $PREFS;
/** MODULE INSTALLATION **/
$sql[] = $DB->insert_string('exp_modules', array(
'module_name' => $this->module_name,
'module_version' => $this->version,
'has_cp_backend' => 'y'
));
$this->execute_sql($sql);
}
public function nsm_form_builder_module_deinstall()
{
global $DB;
$query = $DB->query("SELECT module_id FROM exp_modules WHERE module_name = '".$this->module_name."'");
$sql[] = "DELETE FROM exp_module_member_groups WHERE module_id = '".$query->row['module_id']."'";
$sql[] = "DELETE FROM exp_modules WHERE module_name = '".$this->module_name."'";
$sql[] = "DELETE FROM exp_actions WHERE class = '".$this->module_name."'";
$sql[] = "DELETE FROM exp_actions WHERE class = '".$this->module_name."_CP'";
$this->execute_sql($sql);
}
private function nsm_form_builder_module_update(){}
private function execute_sql($sql)
{
global $DB;
if(is_array($sql))
{
foreach ($sql as $query)
$DB->query($query);
}
elseif(is_string($sql))
{
$DB-query($query);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment