[Vtigercrm-commits] [vtiger-commits] r7990 - in /vtigercrm/trunk/modules: Faq/ HelpDesk/ Import/ Migration/
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Thu Jul 13 12:16:08 EDT 2006
Author: saraj
Date: Thu Jul 13 10:15:55 2006
New Revision: 7990
Log:
* Added API docs
Modified:
vtigercrm/trunk/modules/Faq/Faq.php
vtigercrm/trunk/modules/HelpDesk/HelpDesk.php
vtigercrm/trunk/modules/Import/Forms.php
vtigercrm/trunk/modules/Import/ImportAccount.php
vtigercrm/trunk/modules/Import/ImportContact.php
vtigercrm/trunk/modules/Import/ImportLead.php
vtigercrm/trunk/modules/Import/ImportMap.php
vtigercrm/trunk/modules/Import/ImportOpportunity.php
vtigercrm/trunk/modules/Import/ImportProduct.php
vtigercrm/trunk/modules/Import/ImportSave.php
vtigercrm/trunk/modules/Import/UsersLastImport.php
vtigercrm/trunk/modules/Import/error.php
vtigercrm/trunk/modules/Import/parse_utils.php
vtigercrm/trunk/modules/Migration/Migration.php
Modified: vtigercrm/trunk/modules/Faq/Faq.php
==============================================================================
--- vtigercrm/trunk/modules/Faq/Faq.php (original)
+++ vtigercrm/trunk/modules/Faq/Faq.php Thu Jul 13 10:15:55 2006
@@ -76,6 +76,8 @@
var $default_order_by = 'id';
var $default_sort_order = 'DESC';
+ /** Constructor which will set the column_fields in this object
+ */
function Faq() {
$this->log =LoggerManager::getLogger('faq');
$this->log->debug("Entering Faq() method ...");
Modified: vtigercrm/trunk/modules/HelpDesk/HelpDesk.php
==============================================================================
--- vtigercrm/trunk/modules/HelpDesk/HelpDesk.php (original)
+++ vtigercrm/trunk/modules/HelpDesk/HelpDesk.php Thu Jul 13 10:15:55 2006
@@ -72,6 +72,8 @@
var $default_order_by = 'crmid';
var $default_sort_order = 'DESC';
+ /** Constructor which will set the column_fields in this object
+ */
function HelpDesk()
{
$this->log =LoggerManager::getLogger('helpdesk');
@@ -82,6 +84,9 @@
}
// Mike Crowe Mod --------------------------------------------------------Default ordering for us
+ /** Function used to get the sort order for HelpDesk listview
+ * return string $sorder - first check the $_REQUEST['sorder'] if request value is empty then check in the $_SESSION['HELPDESK_SORT_ORDER'] if this session value is empty then default sort order will be returned.
+ */
function getSortOrder()
{
global $log;
@@ -94,6 +99,9 @@
return $sorder;
}
+ /** Function used to get the order by value for HelpDesk listview
+ * return string $order_by - first check the $_REQUEST['order_by'] if request value is empty then check in the $_SESSION['HELPDESK_ORDER_BY'] if this session value is empty then default order by will be returned.
+ */
function getOrderBy()
{
global $log;
@@ -425,6 +433,10 @@
return $customername;
}
+ /** Function used to get the Activity History
+ * @param int $id - ticket id to which we want to display the activity history
+ * return array which will be returned from the function getHistory
+ */
function get_history($id)
{
global $log;
Modified: vtigercrm/trunk/modules/Import/Forms.php
==============================================================================
--- vtigercrm/trunk/modules/Import/Forms.php (original)
+++ vtigercrm/trunk/modules/Import/Forms.php Thu Jul 13 10:15:55 2006
@@ -174,6 +174,15 @@
return $the_script;
}
+/** function used to form the combo values with the available importable fields
+ * @param array reference &$column_fields - reference of the column fields which will be like lastname=>1, etc where as the key is the field name based on the import module and value is 1
+ * @param int $colnum - column number
+ * @param array reference &$required_fields - required fields of the import module
+ * @param string $suggest_field - field to show as selected in the combo box
+ * @param array $translated_fields - list of fields which are available to map
+ * @param string $module - tablename for the import module
+ * return the combo box with the fields which are available to map
+ */
function getFieldSelect(&$column_fields,$colnum,&$required_fields,$suggest_field,$translated_fields,$module)
{
/*
Modified: vtigercrm/trunk/modules/Import/ImportAccount.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportAccount.php (original)
+++ vtigercrm/trunk/modules/Import/ImportAccount.php Thu Jul 13 10:15:55 2006
@@ -49,7 +49,7 @@
//,"fix_website"
);
-
+ /*
function fix_website()
{
if ( isset($this->website) &&
@@ -118,7 +118,7 @@
" ". $this->shipping_address_street_4;
}
}
-
+ */
// This is the list of vtiger_fields that are importable.
// some if these do not map directly to database columns
@@ -162,6 +162,8 @@
var $importable_fields = Array();
+ /** Constructor which will set the importable_fields as $this->importable_fields[$key]=1 in this object where key is the fieldname in the field table
+ */
function ImportAccount() {
$this->log = LoggerManager::getLogger('import_account');
Modified: vtigercrm/trunk/modules/Import/ImportContact.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportContact.php (original)
+++ vtigercrm/trunk/modules/Import/ImportContact.php Thu Jul 13 10:15:55 2006
@@ -51,7 +51,7 @@
//,"add_primary_address_streets"
//,"add_alt_address_streets"
);
-
+ /*
function add_salutation()
{
if ( isset($this->salutation) &&
@@ -147,7 +147,10 @@
$this->last_name = join(' ',$name_arr);
}
-
+ */
+
+ /** function used to create or map with existing account if the contact has mapped with an account during import
+ */
function add_create_account()
{
global $adb;
@@ -175,7 +178,7 @@
//Modified to remove the spaces at first and last in vtiger_account name -- after 4.2 patch 2
$acc_name = trim(addslashes($acc_name));
- $query = "select vtiger_crmentity.deleted, vtiger_account.* from vtiger_account,crmentity WHERE vtiger_accountname='{$acc_name}' and vtiger_crmentity.crmid =vtiger_account.accountid";
+ $query = "select vtiger_crmentity.deleted, vtiger_account.* from vtiger_account, vtiger_crmentity WHERE accountname='{$acc_name}' and vtiger_crmentity.crmid =vtiger_account.accountid";
$result = $adb->query($query) or die("Error selecting sugarbean: ".mysql_error());
@@ -267,6 +270,8 @@
var $importable_fields = Array();
+ /** Constructor which will set the importable_fields as $this->importable_fields[$key]=1 in this object where key is the fieldname in the field table
+ */
function ImportContact() {
$this->log = LoggerManager::getLogger('import_contact');
$this->db = new PearDatabase();
Modified: vtigercrm/trunk/modules/Import/ImportLead.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportLead.php (original)
+++ vtigercrm/trunk/modules/Import/ImportLead.php Thu Jul 13 10:15:55 2006
@@ -43,6 +43,8 @@
var $importable_fields = Array();
+ /** function used to set the assigned_user_id value in the column_fields when we map the username during import
+ */
function assign_user()
{
global $current_user;
@@ -77,6 +79,8 @@
}
}
+ /** Constructor which will set the importable_fields as $this->importable_fields[$key]=1 in this object where key is the fieldname in the field table
+ */
function ImportLead() {
$this->log = LoggerManager::getLogger('import_lead');
Modified: vtigercrm/trunk/modules/Import/ImportMap.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportMap.php (original)
+++ vtigercrm/trunk/modules/Import/ImportMap.php Thu Jul 13 10:15:55 2006
@@ -60,18 +60,30 @@
,"is_published"
);
-
+ /** Constructor
+ */
function ImportMap()
{
$this->log = LoggerManager::getLogger('file');
$this->db = new PearDatabase();
}
+ /** function used to get the id, name, module and content as string
+ * return string Object:ImportMap id=$this->id name=$this->name module=$this->module content=$this->content
+ */
function toString()
{
return "Object:ImportMap id=$this->id name=$this->name module=$this->module content=$this->content";
}
+ /** function used to save the mapping
+ * @param int $owner_id - user id who is the owner for this mapping
+ * @param string $name - name of the mapping
+ * @param string $module - module name in which we have saved the mapping
+ * @param string $has_header - has_header value
+ * @param string $content - all fields which are concatenated with & symbol
+ * return int $result - return 1 if the mapping contents updated
+ */
function save_map( $owner_id, $name, $module, $has_header,$content )
{
$query_arr = array('assigned_user_id'=>$owner_id,'name'=>$name);
@@ -94,6 +106,11 @@
return $result;
}
+ /** function used to publish or unpublish the mapping
+ * @param int $user_id - user id who is publishing the map
+ * @param string $flag - yes or no
+ * return value - if flag is yes then update the db and return 1 otherwise return -1
+ */
function mark_published($user_id,$flag)
{
$other_map = new ImportMap();
@@ -129,6 +146,10 @@
}
+ /** function to retrieve all the column fields and set as properties
+ * @param array $fields_array - fields array of the corresponding module
+ * return array $obj_arr - object which contains the retrieved column_field values as properties
+ */
function retrieve_all_by_string_fields($fields_array)
{
$where_clause = $this->get_where($fields_array);
@@ -153,6 +174,10 @@
return $obj_arr;
}
+ /** function used to get the list of saved mappings
+ * @param string $module - module name which we currently importing
+ * return array $map_lists - return the list of mappings in the format of [id]=>name
+ */
function getSavedMappingsList($module)
{
$query = "SELECT * FROM $this->table_name where module='".$module."'";
@@ -165,6 +190,11 @@
}
return $map_lists;
}
+
+ /** function used to retrieve the mapping content for the passed mapid
+ * @param int $mapid - mapid for the selected map
+ * return array $mapping_arr - return the array which contains the mapping_arr[name]=value from the content of the map
+ */
function getSavedMappingContent($mapid)
{
$query = "SELECT * FROM $this->table_name where id='".$mapid."'";
Modified: vtigercrm/trunk/modules/Import/ImportOpportunity.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportOpportunity.php (original)
+++ vtigercrm/trunk/modules/Import/ImportOpportunity.php Thu Jul 13 10:15:55 2006
@@ -58,7 +58,7 @@
//"add_date_closed"
//"add_sales_stage"
);
-
+ /*
function add_lead_source()
{
if ( isset($this->lead_source) &&
@@ -106,11 +106,13 @@
}
}
-
+ */
//exactly the same function from ImportAccount.php
// lets put this in one place..
+ /** function used to create or map with existing account if the potential is map with an account during import
+ */
function add_create_account()
{
global $adb;
@@ -202,7 +204,7 @@
}
-
+ /*
function fix_website()
{
if ( isset($this->website) &&
@@ -211,7 +213,7 @@
$this->website = substr($this->website,7);
}
}
-
+ */
// This is the list of vtiger_fields that are importable.
// some if these do not map directly to database columns
@@ -233,6 +235,8 @@
var $importable_fields = Array();
+ /** Constructor which will set the importable_fields as $this->importable_fields[$key]=1 in this object where key is the fieldname in the field table
+ */
function ImportOpportunity() {
$this->log = LoggerManager::getLogger('import_opportunity');
$this->db = new PearDatabase();
Modified: vtigercrm/trunk/modules/Import/ImportProduct.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportProduct.php (original)
+++ vtigercrm/trunk/modules/Import/ImportProduct.php Thu Jul 13 10:15:55 2006
@@ -44,6 +44,8 @@
var $importable_fields = Array();
+ /** function used to set the assigned_user_id value in the column_fields when we map the username during import
+ */
function assign_user()
{
global $current_user;
@@ -78,6 +80,8 @@
}
}
+ /** Constructor which will set the importable_fields as $this->importable_fields[$key]=1 in this object where key is the fieldname in the field table
+ */
function ImportProduct() {
$this->log = LoggerManager::getLogger('import_product');
Modified: vtigercrm/trunk/modules/Import/ImportSave.php
==============================================================================
--- vtigercrm/trunk/modules/Import/ImportSave.php (original)
+++ vtigercrm/trunk/modules/Import/ImportSave.php Thu Jul 13 10:15:55 2006
@@ -12,6 +12,19 @@
$count = 0;
$skip_required_count = 0;
+/** function used to save the records into database
+ * @param array $rows - array of total rows of the csv file
+ * @param array $rows1 - rows to be saved
+ * @param object $focus - object of the corresponding import module
+ * @param int $ret_field_count - total number of fields(columns) available in the csv file
+ * @param int $col_pos_to_field - field position in the mapped array
+ * @param int $start - starting row count value to import
+ * @param int $recordcount - count of records to be import ie., number of records to import
+ * @param string $module - import module
+ * @param int $totalnoofrows - total number of rows available
+ * @param int $skip_required_count - number of records skipped
+ This function will redirect to the ImportStep3 if the available records is greater than the record count (ie., number of records import in a single loop) otherwise (total records less than 500) then it will be redirected to import step last
+ */
function InsertImportRecords($rows,$rows1,$focus,$ret_field_count,$col_pos_to_field,$start,$recordcount,$module,$totalnoofrows,$skip_required_count)
{
global $current_user;
Modified: vtigercrm/trunk/modules/Import/UsersLastImport.php
==============================================================================
--- vtigercrm/trunk/modules/Import/UsersLastImport.php (original)
+++ vtigercrm/trunk/modules/Import/UsersLastImport.php Thu Jul 13 10:15:55 2006
@@ -55,19 +55,28 @@
var $list_fields = Array();
var $list_fields_name = Array();
var $list_link_field;
-
+
+ /** Constructor
+ */
function UsersLastImport() {
$this->log = LoggerManager::getLogger('UsersLastImport');
$this->db = new PearDatabase();
}
+ /** function used to delete ie., update the deleted as 1 in vtiger_users_last_import table
+ * @param int $user_id - user id to whom's last imported records to delete
+ */
function mark_deleted_by_user_id($user_id)
{
$query = "UPDATE $this->table_name set deleted=1 where assigned_user_id='$user_id'";
$this->db->query($query,true,"Error marking last imported vtiger_accounts deleted: ");
}
-
+ /** function used to get the list query of the imported records
+ * @param reference &$order_by - reference of the variable order_by to add with the query
+ * @param reference &$where - where condition to add with the query
+ * return string $query - list query to get the imported records list with the passed where and order by
+ */
function create_list_query(&$order_by, &$where)
{
global $current_user;
@@ -165,7 +174,7 @@
}
-
+ /*
function list_view_parse_additional_sections(&$list_form)
{
if ($this->bean_type == "Contacts")
@@ -182,7 +191,12 @@
return $list_form;
}
-
+ */
+
+ /** function used to delete (update deleted=1 in crmentity table) the last imported records of the current user
+ * @param int $user_id - user id, whose last imported records want to be deleted
+ * return int $count - number of total deleted records (contacts, accounts, opportunities, leads and products)
+ */
function undo($user_id)
{
$count = 0;
@@ -196,6 +210,10 @@
return $count;
}
+ /** function used to delete (update deleted=1 in crmentity table) the last imported contacts of the current user
+ * @param int $user_id - user id, whose last imported contacts want to be deleted
+ * return int $count - number of deleted contacts
+ */
function undo_contacts($user_id)
{
$count = 0;
@@ -219,6 +237,10 @@
return $count;
}
+ /** function used to delete (update deleted=1 in crmentity table) the last imported leads of the current user
+ * @param int $user_id - user id, whose last imported leads want to be deleted
+ * return int $count - number of deleted leads
+ */
function undo_leads($user_id)
{
$count = 0;
@@ -242,6 +264,10 @@
return $count;
}
+ /** function used to delete (update deleted=1 in crmentity table) the last imported accounts of the current user
+ * @param int $user_id - user id, whose last imported accounts want to be deleted
+ * return int $count - number of deleted accounts
+ */
function undo_accounts($user_id)
{
// this should just be a loop foreach module type
@@ -266,6 +292,10 @@
return $count;
}
+ /** function used to delete (update deleted=1 in crmentity table) the last imported potentials of the current user
+ * @param int $user_id - user id, whose last imported potentials want to be deleted
+ * return int $count - number of deleted potentials
+ */
function undo_opportunities($user_id)
{
// this should just be a loop foreach module type
@@ -290,6 +320,10 @@
return $count;
}
+ /** function used to delete (update deleted=1 in crmentity table) the last imported products of the current user
+ * @param int $user_id - user id, whose last imported products want to be deleted
+ * return int $count - number of deleted products
+ */
function undo_products($user_id)
{
$count = 0;
Modified: vtigercrm/trunk/modules/Import/error.php
==============================================================================
--- vtigercrm/trunk/modules/Import/error.php (original)
+++ vtigercrm/trunk/modules/Import/error.php Thu Jul 13 10:15:55 2006
@@ -22,6 +22,9 @@
require_once('Smarty_setup.php');
+/** function used to show the error message occured during import process
+ * @param string $message - Error message to display in the screen, where the passed error message will be displayed in screen using Importerror.tpl file
+ */
function show_error_import($message)
{
global $import_mod_strings;
Modified: vtigercrm/trunk/modules/Import/parse_utils.php
==============================================================================
--- vtigercrm/trunk/modules/Import/parse_utils.php (original)
+++ vtigercrm/trunk/modules/Import/parse_utils.php Thu Jul 13 10:15:55 2006
@@ -18,6 +18,13 @@
// some vtiger_files have a header, some dont.
// keeps track of which vtiger_fields are used
+/** function used to parse the file
+ * @param string $file_name - file name
+ * @param character $delimiter - delimiter of the csv file
+ * @param int $max_lines - maximum number of lines to parse
+ * @param int $has_header - if the file has header then 1 otherwise 0
+ * return array $ret_array which will be "rows"=>&$rows, "field_count"=>$field_count where as &rows is the reference of rows which contains all the parsed rows and $field_count is the number of fields available per row
+ */
function parse_import($file_name,$delimiter,$max_lines,$has_header)
{
$line_count = 0;
@@ -74,6 +81,13 @@
}
+/** function used to parse the act file
+ * @param string $file_name - file name
+ * @param character $delimiter - delimiter of the csv file
+ * @param int $max_lines - maximum number of lines to parse
+ * @param int $has_header - if the file has header then 1 otherwise 0
+ * return array $ret_array which will be "rows"=>&$rows, "field_count"=>$field_count where as &rows is the reference of rows which contains all the parsed rows and $field_count is the number of fields available per row
+ */
function parse_import_act($file_name,$delimiter,$max_lines,$has_header)
{
$line_count = 0;
Modified: vtigercrm/trunk/modules/Migration/Migration.php
==============================================================================
--- vtigercrm/trunk/modules/Migration/Migration.php (original)
+++ vtigercrm/trunk/modules/Migration/Migration.php Thu Jul 13 10:15:55 2006
@@ -36,12 +36,22 @@
var $new_mysql_password;
var $new_dbname;
+ /** Constructor with old database and new database connections
+ */
function Migration($old='',$new='')
{
$this->oldconn = $old;
$this->conn = $new;
$this->conn->println("Database Object has been created.");
}
+
+ /** function used to set the Old database parameters in the migration object properties
+ * @param string $hostname - old database hostname
+ * @param int $mysql_port - old database mysql port number
+ * @param string $mysql_username - old database mysql user name
+ * @param string $mysql_password - old database mysql password
+ * @param string $dbname - old database name
+ */
function setOldDatabaseParams($hostname,$mysql_port,$mysql_username,$mysql_password,$dbname)
{
$this->old_hostname = $hostname;
@@ -51,6 +61,14 @@
$this->old_dbname = $dbname;
$this->conn->println("Old Database Parameters has been set.");
}
+
+ /** function used to set the Current ie., new 5.0 database parameters in the migration object properties
+ * @param string $hostname - new database hostname
+ * @param int $mysql_port - new database mysql port number
+ * @param string $mysql_username - new database mysql user name
+ * @param string $mysql_password - new database mysql password
+ * @param string $dbname - new database name
+ */
function setNewDatabaseParams($hostname,$mysql_port,$mysql_username,$mysql_password,$dbname)
{
$this->new_hostname = $hostname;
@@ -61,6 +79,13 @@
$this->conn->println("New Database Parameters has been set.");
}
+ /** function used to take the database dump
+ * @param string $host_name - host name in where the database is available
+ * @param int $mysql_port - mysql port number
+ * @param string $mysql_username - mysql user name
+ * @param string $mysql_password - mysql password
+ * @param string $dbname - database name
+ */
function takeDatabaseDump($host_name,$mysql_port,$mysql_username,$mysql_password,$dbname)
{
$this->conn->println("Inside the function takeDatabaseDump. Going to take the old database dump...");
@@ -104,6 +129,10 @@
return $dump_filename;
}
+ /** function used to drop the database
+ * @param object $conn - adodb object which is connected with the current(new) database
+ * @param string $dbname - database name which we want to drop
+ */
function dropDatabase($conn,$dbname)
{
$this->conn->println("Inside the function dropDatabase. Going to drop the new database...");
@@ -112,6 +141,11 @@
$_SESSION['migration_log'] .= '<br> <b>'.$dbname.'</b> Database has been dropped.';
}
+
+ /** function used to create the database
+ * @param object $conn - adodb object which is connected with the current(new) database
+ * @param string $dbname - database name which we want to drop
+ */
function createDatabase($conn,$dbname)
{
$this->conn->println("Inside the function createDatabase. Going to create the new database...");
@@ -124,6 +158,14 @@
$conn->connect();
}
+ /** function used to apply the dump data to a database
+ * @param string $host_name - host name
+ * @param int $mysql_port - mysql port number
+ * @param string $mysql_username - mysql user name
+ * @param string $mysql_password - mysql password
+ * @param string $dbname - database name to which we want to apply the dump
+ * @param string $dumpfile - dump file which contains the data dump of a database
+ */
function applyDumpData($host_name,$mysql_port,$mysql_username,$mysql_password,$dbname,$dumpfile)
{
$this->conn->println("Inside the function applyDumpData.");
@@ -161,6 +203,10 @@
}
+ /** function used to get the tabid
+ * @param string $module - module to which we want to get the tabid
+ * return int $tabid - tabid of the module
+ */
function localGetTabID($module)
{
global $conn;
@@ -172,6 +218,9 @@
return $tabid;
}
+ /** function used to get the table count of the new database
+ * return int $tables - number of tables available in the new database
+ */
function getTablesCountInNewDatabase()
{
$this->conn->println("Inside the function getTablesCountInNewDatabase");
@@ -182,6 +231,9 @@
return $tables;
}
+ /** function used to get the table count of the old database
+ * return int $tables - number of tables available in the old database
+ */
function getTablesCountInOldDatabase()
{
$this->conn->println("Inside the function getTablesCountInOldDatabase");
@@ -192,6 +244,9 @@
return $tables;
}
+ /** function used to modify the database from old version to match with new version
+ * @param object $conn - adodb object which is connected with the current(new) database
+ */
function modifyDatabase($conn)
{
$this->conn->println("Inside the function modifyDatabase");
@@ -214,6 +269,11 @@
$conn->println("Mickie ---- Ends\n\n\n");
}
+ /** function used to run the migration process based on the option selected and values given
+ * @param int $same_databases - 1 if both databases are same otherwise 0
+ * @param string $option - selected migration option (dbsource or dumpsource)
+ * @param string $old_dump_file_name - dump file name of the old database which is optional when we use dbsource
+ */
function migrate($same_databases, $option, $old_dump_file_name='')
{
//1. Migration Procedure -- when we give the Source Database values
More information about the vtigercrm-commits
mailing list