function voip_prepaid() { $db =& DB(); $rs = $db->Execute(sqlSelect($db, "voip", "prepaid_low_balance", "id=::" . DEFAULT_SITE . "::")); if ($rs && $rs->RecordCount() > 0) { # e-mail user's once when balance reaches this amount: $this->lowBalance = $rs->fields[0]; } else { $this->lowBalance = false; } $this->pinLenth = 10; // up to 10 # name of this module: $this->module = "voip_prepaid"; # location of the construct XML file: $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; # open the construct file for parsing $C_xml = new CORE_xml(); $construct = $C_xml->xml_to_array($this->xml_construct); $this->method = $construct["construct"]["method"]; $this->field = $construct["construct"]["field"]; $this->table = $construct["construct"]["table"]; $this->module = $construct["construct"]["module"]; $this->cache = $construct["construct"]["cache"]; $this->order_by = $construct["construct"]["order_by"]; $this->limit = $construct["construct"]["limit"]; }
function get_lang_pack($module, $language) { # define the language names / ids (must match the language.name & language.id fields in the DB $this->lang_arr[0] = 'english'; # get the Core language pack if ($module == 'CORE') { $pack_file = PATH_LANGUAGE . 'core/' . $language . '_core.xml'; $this->language_name = $language; } else { if ($language != '') { $pack_file = PATH_LANGUAGE . '' . $module . '/' . $language . '_' . $module . '.xml'; } } $def_pack_file = PATH_LANGUAGE . '' . $module . '/' . DEFAULT_LANGUAGE . '_' . $module . '.xml'; # check that the defined file exists, if not, use the default language instead: if (file_exists($pack_file)) { # open the file for parsing $C_xml = new CORE_xml(); $this->lang_pack["{$module}"]["{$language}"] = $C_xml->xml_to_array($pack_file); } else { # open the default language file for parsing $C_xml = new CORE_xml(); $this->lang_pack["{$module}"]["{$language}"] = $C_xml->xml_to_array($def_pack_file); } }
function construct() { $this->table = 'asset_pool'; $this->module = 'asset_pool'; $this->xml_construct = PATH_MODULES . $this->module . "/" . $this->module . "_construct.xml"; $C_xml = new CORE_xml(); $construct = $C_xml->xml_to_array($this->xml_construct); $this->method = $construct["construct"]["method"]; $this->trigger = $construct["construct"]["trigger"]; $this->field = $construct["construct"]["field"]; $this->cache = $construct["construct"]["cache"]; $this->order_by = $construct["construct"]["order_by"]; $this->limit = $construct["construct"]["limit"]; }
function import() { # name of this module: $this->module = "import"; # location of the construct XML file: $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; # open the construct file for parsing $C_xml = new CORE_xml(); $construct = $C_xml->xml_to_array($this->xml_construct); $this->field = $construct["construct"]["field"]; $this->table = $construct["construct"]["table"]; $this->module = $construct["construct"]["module"]; $this->cache = $construct["construct"]["cache"]; $this->order_by = $construct["construct"]["order_by"]; $this->limit = $construct["construct"]["limit"]; }
function email_template_translate() { # name of this module: $this->module = "email_template_translate"; # location of the construct XML file: $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; # open the construct file for parsing $C_xml = new CORE_xml(); $construct = $C_xml->xml_to_array($this->xml_construct); $this->method = $construct["construct"]["method"]; $this->trigger = $construct["construct"]["trigger"]; $this->field = $construct["construct"]["field"]; $this->table = $construct["construct"]["table"]; $this->module = $construct["construct"]["module"]; $this->cache = $construct["construct"]["cache"]; $this->order_by = $construct["construct"]["order_by"]; $this->limit = $construct["construct"]["limit"]; }
function voip_blacklist() { # name of this module: $this->module = "voip_blacklist"; if (!defined('AJAX')) { # location of the construct XML file: $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; # open the construct file for parsing $C_xml = new CORE_xml(); $construct = $C_xml->xml_to_array($this->xml_construct); $this->method = $construct["construct"]["method"]; $this->trigger = $construct["construct"]["trigger"]; $this->field = $construct["construct"]["field"]; $this->table = $construct["construct"]["table"]; $this->module = $construct["construct"]["module"]; $this->cache = $construct["construct"]["cache"]; $this->order_by = $construct["construct"]["order_by"]; $this->limit = $construct["construct"]["limit"]; } }
function htaccess_dir() { # name of this module: $this->module = "htaccess_dir"; # location of the construct XML file: $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; # open the construct file for parsing $C_xml = new CORE_xml(); $construct = $C_xml->xml_to_array($this->xml_construct); $this->method = $construct["construct"]["method"]; $this->trigger = $construct["construct"]["trigger"]; $this->field = $construct["construct"]["field"]; $this->table = $construct["construct"]["table"]; $this->module = $construct["construct"]["module"]; $this->cache = $construct["construct"]["cache"]; $this->order_by = $construct["construct"]["order_by"]; $this->limit = $construct["construct"]["limit"]; # add extra lines needed in the .htaccess files when added/updated: # Example: #$this->htaccess_extra = "Options +FollowSymlinks\n"; $this->htaccess_extra = ''; }
/** * Get the list of available reports */ function report_menu($VAR) { global $C_translate; $C_xml = new CORE_xml(); if (empty($VAR['report_module'])) { echo $C_translate->translate('no_reports', 'report', ''); return; } else { $module = $VAR['report_module']; } if (!empty($VAR['report_template'])) { $default = $VAR['report_template']; } else { $default = false; } $return = '<select id="report_template" name="report_template" width="150" size="5" onChange="submit()" multiple>'; $path = PATH_AGILE . 'reports/' . $module . '/'; chdir($path); $dir = opendir($path); $count = 0; while ($file_name = readdir($dir)) { if ($file_name != '..' && $file_name != '.' && ereg(".xml\$", $file_name)) { $template = $C_xml->xml_to_array($path . $file_name); $name = $template['report']['title']; $return .= "<option value=\"{$file_name}\""; if ($default == $file_name) { $return .= " selected"; } $return .= ">{$name}</option>\n"; $count++; } } if ($count == 0) { $return .= '<option value="">' . $C_translate->translate('no_reports', 'report', '') . '</option>'; } $return .= '</select>'; echo $return; }
function dev_install_xml_gen($module, $module_id) { # get the module parent $db =& DB(); $sql = "SELECT * FROM " . AGILE_DB_PREFIX . "module WHERE\n site_id = " . $db->qstr(DEFAULT_SITE) . " AND\n id = " . $db->qstr($module_id); $mr = $db->Execute($sql); if ($mr->fields["parent_id"] == "" || $mr->fields["parent_id"] == "0" || $mr->fields["parent_id"] == $module_id) { $parent = $module; } else { $db =& DB(); $sql = "SELECT * FROM " . AGILE_DB_PREFIX . "module WHERE\n site_id = " . $db->qstr(DEFAULT_SITE) . " AND\n id = " . $db->qstr($mr->fields["parent_id"]); $mrp = $db->Execute($sql); $parent = $mrp->fields["name"]; } # get the current settings: $t = "\t"; $n = "\n"; $C_xml = new CORE_xml(); $inst = $C_xml->xml_to_array(PATH_MODULES . '' . $module . '/' . $module . '_install.xml'); # Get any dependancy $dependancy = @$inst['install']['module_properties']['dependancy']; # Get any sub_modules $sub_modules = @$inst['install']['module_properties']['sub_modules']; ################################################################# # regenerate the install file: $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>{$n}"; $install_xml = "<install>" . $n . "{$t}<module_properties>" . $n . "{$t}{$t}<name>{$module}</name>" . $n . "{$t}{$t}<parent>{$parent}</parent>" . $n . "{$t}{$t}<notes><![CDATA[{$mr->fields["notes"]}]]></notes>{$n}"; if (!empty($mr->fields["menu_display"])) { $install_xml .= "{$t}{$t}<menu_display>1</menu_display>{$n}"; } if (!empty($dependancy)) { $install_xml .= "{$t}{$t}<dependancy>{$dependancy}</dependancy>{$n}"; } if (!empty($sub_modules)) { $install_xml .= "{$t}{$t}<sub_modules>{$sub_modules}</sub_modules>{$n}"; } $install_xml .= "{$t}</module_properties>" . $n . "{$t}<sql_inserts>" . $n . "{$t}{$t}<module_method>" . $n; # loop through the methods $db =& DB(); $sql = "SELECT * FROM " . AGILE_DB_PREFIX . "module_method WHERE\n site_id = " . $db->qstr(DEFAULT_SITE) . " AND\n module_id = " . $db->qstr($module_id); $result = $db->Execute($sql); while (!$result->EOF) { $method = $result->fields['name']; $display = $result->fields['menu_display']; $notes = $result->fields['notes']; $page = trim(ereg_replace('&', '&', $result->fields['page'])); $install_xml .= "{$t}{$t}{$t}<{$method}>" . $n . "{$t}{$t}{$t}{$t}<name>{$method}</name>" . $n; if (!empty($notes)) { $install_xml .= "{$t}{$t}{$t}{$t}<notes><![CDATA[{$notes}]]></notes>" . $n; } if (!empty($page)) { $install_xml .= "{$t}{$t}{$t}{$t}<page><![CDATA[{$page}]]></page>" . $n; } if (!empty($display)) { $install_xml .= "{$t}{$t}{$t}{$t}<menu_display>1</menu_display>" . $n; } $install_xml .= "{$t}{$t}{$t}</{$method}>" . $n; $result->MoveNext(); } $install_xml .= "{$t}{$t}</module_method>" . $n . "{$t}</sql_inserts>" . $n . "</install>"; return $install_xml; }
function upgrade($VAR) { if (!isset($VAR['module_name']) || !isset($VAR['module_group'])) { echo "You must select both the module(s) to upgrade and the groups to grant access to new methods to."; return; } $module_count = 0; $method_count = 0; $fields_count = 0; $method_new_count = 0; $fields_new_count = 0; # loop through each module $modules = $VAR['module_name']; for ($i = 0; $i < count($modules); $i++) { # increment module count $module_count++; # get the module details $db =& DB(); $db_module = $db->Execute(sqlSelect($db, "module", "*", "id=::{$modules[$i]}:: or name=::{$modules[$i]}::")); $module_name = $db_module->fields['name']; $module_id = $db_module->fields['id']; ######################################################################### # Update the Methods from the <module>_install.xml file # get the install xml file ######################################################################### $install_xml = PATH_MODULES . $module_name . '/' . $module_name . '_install.xml'; if (is_file($install_xml)) { $C_xml = new CORE_xml(); @($methods = $C_xml->xml_to_array($install_xml)); @($methods = $methods['install']['sql_inserts']['module_method']); # loop through the methods if (is_array($methods)) { while (list($key, $value) = each($methods)) { # increment method count $method_count++; # see if this method exists $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'module_method WHERE name = ' . $db->qstr($key) . ' AND module_id = ' . $db->qstr($module_id) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE); $method_db = $db->Execute($sql); if ($method_db === false) { global $C_debug; $C_debug->error('module.inc.php', 'upgrade', $db->ErrorMsg()); } if ($method_db->RecordCount() == 0) { # increment method count $method_new_count++; ### add this method @($notes = $methods[$key]["notes"]); @($page = $methods[$key]["page"]); @($menu_display = $methods[$key]["menu_display"]); $method_id = sqlGenID($db, 'module_method'); $fields = array('name' => $key, 'module_id' => $module_id, 'notes' => $notes, 'page' => $page, 'menu_display' => $menu_display); $db->Execute(sqlInsert($db, "module_method", $fields, $method_id)); if ($result === false) { global $C_debug; $C_debug->error('module.inc.php', 'upgrade', $db->ErrorMsg()); } ### Create the group_method records, with the ID from each for ($ii = 0; $ii < count($VAR["module_group"]); $ii++) { $group_method_id = $db->GenID(AGILE_DB_PREFIX . "" . 'group_method_id'); $q = 'INSERT INTO ' . AGILE_DB_PREFIX . 'group_method SET id = ' . $db->qstr($group_method_id) . ', site_id = ' . $db->qstr(DEFAULT_SITE) . ', method_id = ' . $db->qstr($method_id) . ', module_id = ' . $db->qstr($module_id) . ', group_id = ' . $db->qstr($VAR["module_group"][$ii]); $result = $db->Execute($q); if ($result === false) { global $C_debug; $C_debug->error('module.inc.php', 'upgrade', $db->ErrorMsg()); } } } } } } ######################################################################### # Update the DB Fields from the <module>_construct.xml file # get the install xml file ######################################################################### $construct_xml = PATH_MODULES . $module_name . '/' . $module_name . '_construct.xml'; if (is_file($construct_xml)) { $C_xml = new CORE_xml(); $construct = $C_xml->xml_to_array($construct_xml); @($fields = $construct['construct']['field']); ### Check that this Module has any db installation required... if (!empty($construct["construct"]["table"]) && $construct["construct"]["table"] == $module_name) { ### Create the module DB table $table = $construct["construct"]["table"]; $db =& DB(); $db_fields = $db->MetaColumns(AGILE_DB_PREFIX . $table, true); ### Create the module DB fields $arr_field = $construct["construct"]["field"]; ### Loop through the fields to build the list: while (list($key, $value) = each($arr_field)) { $field = $key; $FIELD = strtoupper($key); if (!isset($db_fields[$FIELD])) { # increment field count $fields_new_count++; $t_s = $arr_field["{$key}"]["type"]; if (ereg('[(]', $t_s)) { $ts = split('[(]', $t_s); $type = $ts[0]; $size = ereg_replace(')', '', $ts[1]); $flds[] = array($field, $type, $size); } else { $flds[] = array($field, $t_s); } } } ### Add any new columns: if (is_array(@$flds)) { $dict = NewDataDictionary($db); $sqlarray = $dict->AddColumnSQL(AGILE_DB_PREFIX . $table, $flds); $result = $db->Execute($sqlarray[0]); if ($result === false) { global $C_debug; $C_debug->error('module.inc.php', 'install_db', $db->ErrorMsg()); echo $db->ErrorMsg(); } unset($flds); } ### Remove any unused columns while (list($key, $value) = each($db_fields)) { $fieldname = strtolower($key); if (!isset($construct["construct"]["field"][$fieldname])) { $flds[] = $key; } } if (is_array(@$flds)) { $dict = NewDataDictionary($db); $sqlarray = $dict->DropColumnSQL(AGILE_DB_PREFIX . $table, $flds); $sqlarray[0]; $result = $db->Execute($sqlarray[0]); if ($result === false) { global $C_debug; $C_debug->error('module.inc.php', 'install_db', $db->ErrorMsg()); echo $db->ErrorMsg(); } unset($flds); } #################################################### ### Update Indexes: # Get old database indexes $dict = NewDataDictionary($db); $oldindex = $dict->MetaIndexes(AGILE_DB_PREFIX . $table); # check if the 'site_id' index exists: if (!empty($oldindex['site_id']) && ($oldindex['site_id'] = 'id,site_id')) { $dict = NewDataDictionary($db); $sqlarray = $dict->DropIndexSQL('site_id', AGILE_DB_PREFIX . $table); $db->Execute($sqlarray[0]); } # check that that UNIQUE index for site_id,id exists if (empty($oldindex['IDS']) || $oldindex['IDS']['unique'] != 1) { $db =& DB(); $db->Execute("alter table " . AGILE_DB_PREFIX . "{$table} drop primary key"); $db->Execute("CREATE UNIQUE INDEX IDS on " . AGILE_DB_PREFIX . "{$table} (site_id, id)"); } $dict = NewDataDictionary($db); $oldindex = $dict->MetaIndexes(AGILE_DB_PREFIX . $table); # Current construct invoices if (@($new_indexes = $construct["construct"]["index"])) { while (list($index, $fields) = each($new_indexes)) { if (is_array(@$oldindex[$index])) { # already exists - compare fields: $oldfields = implode(",", $oldindex[$index]['columns']); if ($oldfields != $fields) { # index changed - drop: $dict = NewDataDictionary($db); $sqlarray = $dict->DropIndexSQL($index, AGILE_DB_PREFIX . $table); $db->Execute($sqlarray[0]); # create index $dict = NewDataDictionary($db); if (eregi("fulltext", $index) && AGILE_DB_TYPE == 'mysql') { $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX . $table, $fields, array('FULLTEXT')); } else { $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX . $table, $fields); } $db->Execute($sqlarray[0]); } } else { # index does not exist - create! $dict = NewDataDictionary($db); if (eregi("fulltext", $index) && AGILE_DB_TYPE == 'mysql') { $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX . $table, $fields, array('FULLTEXT')); } else { $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX . $table, $fields); } $db->Execute($sqlarray[0]); } $verify_index[] = $index; } # Check for removed indexes: if (!empty($oldindex)) { reset($oldindex); while (list($index, $fields) = each($oldindex)) { if (!isset($new_indexes[$index]) && $index != 'IDS') { $dict = NewDataDictionary($db); $sqlarray = $dict->DropIndexSQL($index, AGILE_DB_PREFIX . $table); $db->Execute($sqlarray[0]); } } } } else { # remove all old indexes if (!empty($oldindex)) { reset($oldindex); while (list($index, $fields) = each($oldindex)) { if ($index != 'IDS') { $dict = NewDataDictionary($db); $sqlarray = $dict->DropIndexSQL($index, AGILE_DB_PREFIX . $table); $db->Execute($sqlarray[0]); } } } } } } } $msg = "Successfully checked {$module_count} module(s), {$method_count} method(s), " . "and {$fields_count} db fields. <BR>" . "Added {$method_new_count} method(s) and {$fields_new_count} db field(s)."; if (!empty($fields_new_count) > 0) { $js = '<script language="javascript">document.getElementById("module_add").submit();</script>'; global $smarty; if (is_object($smarty)) { $smarty->assign('js', $js); } else { echo '<script language="javascript">document.refresh();</script>'; } } # Display the message. global $C_debug; if (is_object($C_debug)) { $C_debug->alert($msg); } else { echo $msg; } # update the current user's authentication so the update group access applies # to them global $C_auth; if (is_object($C_auth)) { $C_auth->auth_update(); } }
function construct() { # name of this module: $this->module = "ticket"; # location of the construct XML file: $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; # open the construct file for parsing if (defined('AJAX')) { require_once PATH_CORE . 'xml.inc.php'; require_once PATH_CORE . 'translate.inc.php'; $C_translate = new CORE_translate(); global $C_translate; } $C_xml = new CORE_xml(); $construct = $C_xml->xml_to_array($this->xml_construct); $this->method = $construct["construct"]["method"]; $this->trigger = $construct["construct"]["trigger"]; $this->field = $construct["construct"]["field"]; $this->table = $construct["construct"]["table"]; $this->module = $construct["construct"]["module"]; $this->cache = $construct["construct"]["cache"]; $this->order_by = $construct["construct"]["order_by"]; $this->limit = $construct["construct"]["limit"]; }
function invoice_construct() { $this->module = "invoice"; $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; include_once PATH_CORE . 'xml.inc.php'; $C_xml = new CORE_xml(); $construct = $C_xml->xml_to_array($this->xml_construct); $this->method = $construct["construct"]["method"]; $this->trigger = $construct["construct"]["trigger"]; $this->field = $construct["construct"]["field"]; $this->table = $construct["construct"]["table"]; $this->module = $construct["construct"]["module"]; $this->cache = $construct["construct"]["cache"]; $this->order_by = $construct["construct"]["order_by"]; $this->limit = $construct["construct"]["limit"]; }