All pastes #922877 Raw Edit

as

public php v1 · immutable
#922877 ·published 2008-02-29 02:14 UTC
rendered paste body
<?php/* Your initial Class declaration. This file's name must   be "[class's name].module.php", or, in this case,   automonial.module.php*/ class Auto_Testimonials extends CMSModule{    /*---------------------------------------------------------       GetName()       must return the exact class name of the module.       If these do not match, bad things happen.       This is the name that's shown in the main Modules       page in the Admin.      ---------------------------------------------------------*/    function GetName()    {        return 'Auto_Testimonials';    }    /*---------------------------------------------------------       GetFriendlyName()       This can return any string.       This is the name that's shown in the Admin Menus and section pages          (if the module has an admin component).      ---------------------------------------------------------*/    function GetFriendlyName()    {          return $this->Lang('Auto_Testimonials');    }    /*---------------------------------------------------------       GetVersion()       This can return any string, preferably a number or       something that makes sense for designating a version.       The CMS will use this to identify whether or not       the installed version of the module is current, and       the module will use it to figure out how to upgrade       itself if requested.      ---------------------------------------------------------*/    function GetVersion()    {        return '0.1';    }                      /*---------------------------------------------------------         IsPluginModule()         This function returns true or false, depending upon         whether users can include the module in a page or         template using a smarty tag of the form         {cms_module module='Skeleton' param1=val param2=val...}         If your module does not get included in pages or         templates, return "false" here.             (Required if you want to use the method DoAction later.)         ---------------------------------------------------------*/    function IsPluginModule()    {         return true;    }}function Install(){}function Install(){    //Get a reference to the database    $db = $this->cms->db;    // mysql-specific, but ignored by other database    $taboptarray = array('mysql' => 'TYPE=MyISAM');    //Make a new "dictionary" (ADODB-speak for a table)    $dict = NewDataDictionary($db);    //Add the fields as a comma-separated string.    // See the ADODB manual for a list of available field types.    //In our case, the id is an integer, the name is a varchar(100) field,    // the description is a text field, and the price is a float.    $flds = "  `id` int(10) unsigned NOT NULL auto_increment,  `active` tinyint(1) NOT NULL default '0',  `postdate` timestamp NULL,  `author` varchar(25) NOT NULL default '',  `author_email` varchar(60) NOT NULL default '',  `authorweb` varchar(100) NOT NULL default '',  `authorwebname` varchar(50) NOT NULL default '',  `title` varchar(50) NOT NULL default '',  `testtext` text NOT NULL,  `highlight` text NOT NULL,  PRIMARY KEY  (`id`),  KEY `postdate` (`postdate`)) TYPE=MyISAM";$config ="`site_name` varchar(75) NOT NULL default 'Automonial',  `contact_email` varchar(60) NOT NULL default 'you@yourmail.com',  `language` varchar(25) NOT NULL default 'EN',  `tooltips` tinyint(1) NOT NULL default '1',  `notify` tinyint(1) NOT NULL default '1',  `debug` tinyint(1) NOT NULL default '1',  `ver_current` varchar(10) NOT NULL default '.9.5.0',  `ver_new` varchar(10) NOT NULL default '',  `ver_check` tinyint(1) NOT NULL default '1',  `pag_limit` tinyint(2) NOT NULL default '10',  `use_highlight` tinyint(1) NOT NULL default '0',  `block_width` varchar(4) NOT NULL default '200',  `block_scroll` tinyint(1) NOT NULL default '0',  `block_limit` tinyint(2) NOT NULL default '1',  `block_showtitle` tinyint(1) NOT NULL default '1',  `block_showdate` tinyint(1) NOT NULL default '0',  `block_showauth` tinyint(1) NOT NULL default '1',  `block_showauthweb` tinyint(1) NOT NULL default '1',  `block_titlecount` varchar(3) NOT NULL default '30',  `block_textcount` varchar(4) NOT NULL default '100',  `block_font1` varchar(25) NOT NULL default 'Times New Roman',  `block_font2` varchar(25) NOT NULL default 'Georgia',  `block_font3` varchar(25) NOT NULL default 'Serif',  `block_bodybg` varchar(20) NOT NULL default '#ffffff',  `block_tableborder` tinyint(2) NOT NULL default '0',  `block_tablepadding` tinyint(2) NOT NULL default '1',  `block_tablespacing` tinyint(2) NOT NULL default '1',  `block_titlebg` varchar(20) NOT NULL default '#ffffff',  `block_textbg` varchar(20) NOT NULL default '#ffffff',  `block_authbg` varchar(20) NOT NULL default '#ffffff',  `block_optionsbg` varchar(20) NOT NULL default '#ffffff',  `block_linkcolor` varchar(20) NOT NULL default '#0000ff',  `block_vlinkcolor` varchar(20) NOT NULL default '#0000ff',  `block_hlinkcolor` varchar(20) NOT NULL default '#0000ff',  `block_alinkcolor` varchar(20) NOT NULL default '#0000ff',  `block_titlecolor` varchar(20) NOT NULL default '#000000',  `block_titlesize` tinyint(2) NOT NULL default '12',  `block_textcolor` varchar(20) NOT NULL default '#000000',  `block_textsize` tinyint(2) NOT NULL default '10',  `block_authcolor` varchar(20) NOT NULL default '#000000',  `block_authsize` tinyint(2) NOT NULL default '10',  `block_optionsize` tinyint(2) NOT NULL default '10',  `main_showtitle` tinyint(1) NOT NULL default '1',  `main_showdate` tinyint(1) NOT NULL default '1',  `main_showauth` tinyint(1) NOT NULL default '1',  `main_showauthweb` tinyint(1) NOT NULL default '1',  `main_width` varchar(4) NOT NULL default '600',  `main_font1` varchar(25) NOT NULL default 'Times New Roman',  `main_font2` varchar(25) NOT NULL default 'Georgia',  `main_font3` varchar(25) NOT NULL default 'Serif',  `main_bodybg` varchar(20) NOT NULL default '#ffffff',  `main_tableborder` tinyint(2) NOT NULL default '1',  `main_tablepadding` tinyint(2) NOT NULL default '0',  `main_tablespacing` tinyint(2) NOT NULL default '0',  `main_titlebg` varchar(20) NOT NULL default '#ffffff',  `main_textbg` varchar(20) NOT NULL default '#ffffff',  `main_authbg` varchar(20) NOT NULL default '#ffffff',  `main_linkcolor` varchar(20) NOT NULL default '#00ffff',  `main_vlinkcolor` varchar(20) NOT NULL default '#00ffff',  `main_hlinkcolor` varchar(20) NOT NULL default '#00ffff',  `main_alinkcolor` varchar(20) NOT NULL default '#00ffff',  `main_titlecolor` varchar(20) NOT NULL default '#000000',  `main_titlesize` tinyint(2) NOT NULL default '12',  `main_textcolor` varchar(20) NOT NULL default '#000000',  `main_textsize` tinyint(2) NOT NULL default '12',  `main_authcolor` varchar(20) NOT NULL default '#000000',  `main_authsize` varchar(2) NOT NULL default '12',  PRIMARY KEY  (`ver_current`),  KEY `contact_email` (`contact_email`)) TYPE=MyISAM";$admin="`id` int(4) NOT NULL auto_increment,  `email` varchar(75) NOT NULL,  `perms_configure` tinyint(1) NOT NULL default '0',  `perms_add` tinyint(1) NOT NULL default '0',  `perms_edit` tinyint(1) NOT NULL default '0',  `perms_delete` tinyint(1) NOT NULL default '0',  `perms_activate` tinyint(1) NOT NULL default '0',  `perms_deactivate` tinyint(1) NOT NULL default '0',  `perms_super` tinyint(1) NOT NULL default '0',  PRIMARY KEY  (`id`),  KEY `perms_add` (`perms_edit`)) TYPE=MyISAM";       //Tell ADODB to create the table called "module_catlist_products",        // using the our field descriptions from above.       //Note the naming scheme that should be followed when adding tables to the database,       // so as to make it easy to recognize who the table belongs to, and to avoid conflict with other modules.       $sqlarray = $dict->CreateTableSQL(cms_db_prefix().'module_auto_testimonials', $flds, $taboptarray);       $sqlarray = $dict->CreateTableSQL(cms_db_prefix().'module_config_testimonials', $config, $taboptarray);	  $sqlarray = $dict->CreateTableSQL(cms_db_prefix().'module_admin_testimonials', $admin, $taboptarray);	 $dict->ExecuteSQLArray($sqlarray);       //Now create a "sequence", which is used internally by CMSMS and ADODB       // to increment our id value each time a new record is inserted into the table.       $db->CreateSequence(cms_db_prefix().'module_auto_testimonials'); $db->CreateSequence(cms_db_prefix().'module_config_testimonials');  $db->CreateSequence(cms_db_prefix().'module_admin_testimonials');	   function Install(){/* ... all the database code from above... *///Create a permission//The first argument is the name for the permission that will be used by the system.//The second argument is a more detailed explanation of the permission.$this->CreatePermission('Auto_Testimonials Admin', 'Auto_Testimonials');}function InstallPostMessage(){    return $this->Lang('postinstall');}function Uninstall(){    //Get a reference to the database    $db = $this->cms->db;    //Remove the database table    $dict = NewDataDictionary( $db );    $sqlarray = $dict->DropTableSQL( cms_db_prefix().'module_automonial' );    $dict->ExecuteSQLArray($sqlarray);    //Remove the sequence    $db->DropSequence( cms_db_prefix().'module_automonial' );    //Remove the permission    $this->RemovePermission('Auto_Testimonials Admin');}function UninstallPreMessage(){    return $this->Lang('uninstall_confirm');}function UninstallPostMessage(){    return $this->Lang('postuninstall');?>