当前位置: 首页>>代码示例>>PHP>>正文


PHP UsersLastImport::save方法代码示例

本文整理汇总了PHP中UsersLastImport::save方法的典型用法代码示例。如果您正苦于以下问题:PHP UsersLastImport::save方法的具体用法?PHP UsersLastImport::save怎么用?PHP UsersLastImport::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UsersLastImport的用法示例。


在下文中一共展示了UsersLastImport::save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 function add_member_of_name()
 {
     // global is defined in UsersLastImport.php
     global $imported_ids;
     global $current_user;
     if ((!isset($this->account_name) || $this->account_name == '') && (!isset($this->parent_id) || $this->parent_id == '')) {
         return;
     }
     $arr = array();
     // check if it already exists
     $focus = new Account();
     $query = '';
     // if user is defining the account id to be associated with this contact..
     if (isset($this->parent_id) && $this->parent_id != '') {
         $this->parent_id = convert_id($this->parent_id);
         $query = "select * from {$focus->table_name} WHERE id='" . PearDatabase::quote($this->parent_id) . "'";
     } else {
         $query = "select * from {$focus->table_name} WHERE name='" . PearDatabase::quote($this->account_name) . "'";
     }
     $GLOBALS['log']->info($query);
     $result = $this->db->query($query) or sugar_die("Error selecting sugarbean: ");
     $row = $this->db->fetchByAssoc($result, -1, false);
     // we found a row with that id
     if (isset($row['id']) && $row['id'] != -1) {
         // if it exists but was deleted, just remove it entirely
         if (isset($row['deleted']) && $row['deleted'] == 1) {
             $query2 = "delete from {$focus->table_name} WHERE id='" . PearDatabase::quote($row['id']) . "'";
             $GLOBALS['log']->info($query2);
             $result2 = $this->db->query($query2) or sugar_die("Error deleting existing sugarbean: ");
         } else {
             $focus->id = $row['id'];
         }
     }
     // if we didnt find the account, so create it
     if (!isset($focus->id) || $focus->id == '') {
         $focus->name = $this->account_name;
         if (isset($this->parent_id)) {
             $focus->parent_id = $this->parent_id;
         } else {
             $focus->parent_id = $current_user->id;
         }
         if (isset($this->modified_date)) {
             $focus->modified_date = $this->modified_date;
         }
         // if we are providing the account id:
         if (isset($this->parent_id) && $this->parent_id != '') {
             $focus->new_with_id = true;
             $focus->id = $this->account_id;
         }
         $focus->save();
         // avoid duplicate mappings:
         if (!isset($imported_ids[$focus->id])) {
             // save the new account as a users_last_import
             $last_import = new UsersLastImport();
             $last_import->assigned_user_id = $current_user->id;
             $last_import->bean_type = "Accounts";
             $last_import->bean_id = $focus->id;
             $last_import->save();
             $imported_ids[$focus->id] = 1;
         }
     }
     // now just link the account
     $this->parent_id = $focus->id;
 }
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:64,代码来源:ImportAccount.php

示例2: array

 /**	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;
     // global is defined in UsersLastImport.php
     global $imported_ids;
     global $current_user;
     $acc_name = $this->column_fields['account_id'];
     $adb->println("contact add_create acc=" . $acc_name);
     if (!isset($acc_name) || $acc_name == '') {
         return;
     }
     $arr = array();
     // check if it already exists
     $focus = new Accounts();
     $query = '';
     // if user is defining the vtiger_account id to be associated with this contact..
     //Modified to remove the spaces at first and last in vtiger_account name -- after 4.2 patch 2
     $acc_name = trim($acc_name);
     //Modified the query to get the available account only ie., which is not deleted
     $query = "select vtiger_crmentity.deleted, vtiger_account.* from vtiger_account, vtiger_crmentity WHERE accountname=? and vtiger_crmentity.crmid =vtiger_account.accountid and vtiger_crmentity.deleted=0";
     $result = $adb->pquery($query, array($acc_name));
     $row = $this->db->fetchByAssoc($result, -1, false);
     $adb->println("fetched account");
     $adb->println($row);
     // we found a row with that id
     if (isset($row['accountid']) && $row['accountid'] != -1) {
         $focus->id = $row['accountid'];
         $adb->println("Account row exists - using same id=" . $focus->id);
     }
     // if we didnt find the vtiger_account, so create it
     if (!isset($focus->id) || $focus->id == '') {
         $adb->println("Createing new vtiger_account");
         $focus->column_fields['accountname'] = $acc_name;
         $focus->column_fields['assigned_user_id'] = $current_user->id;
         $focus->column_fields['modified_user_id'] = $current_user->id;
         //$focus->saveentity("Accounts");
         $focus->save("Accounts");
         $acc_id = $focus->id;
         $adb->println("New Account created id=" . $focus->id);
         // avoid duplicate mappings:
         if (!isset($imported_ids[$acc_id])) {
             $adb->println("inserting vtiger_users last import for vtiger_accounts");
             // save the new vtiger_account as a vtiger_users_last_import
             $last_import = new UsersLastImport();
             $last_import->assigned_user_id = $current_user->id;
             $last_import->bean_type = "Accounts";
             $last_import->bean_id = $focus->id;
             $last_import->save();
             $imported_ids[$acc_id] = 1;
         }
     }
     $adb->println("prev contact accid=" . $this->column_fields["account_id"]);
     // now just link the vtiger_account
     $this->column_fields["account_id"] = $focus->id;
     $adb->println("curr contact accid=" . $this->column_fields["account_id"]);
 }
开发者ID:hardikk,项目名称:HNH,代码行数:58,代码来源:ImportContact.php

示例3: getFirstModule

 /**
  * This function handles the import for uitype 10 fieldtype
  * @param string $module - the current module name
  * @param string fieldname - the related to field name
  */
 function add_related_to($module, $fieldname)
 {
     global $adb, $imported_ids, $current_user;
     $related_to = $this->column_fields[$fieldname];
     if (empty($related_to)) {
         return false;
     }
     //check if the field has module information; if not get the first module
     if (!strpos($related_to, "::::")) {
         $module = getFirstModule($module, $fieldname);
         $value = $related_to;
     } else {
         //check the module of the field
         $arr = array();
         $arr = explode("::::", $related_to);
         $module = $arr[0];
         $value = $arr[1];
     }
     $focus1 = CRMEntity::getInstance($module);
     $entityNameArr = getEntityField($module);
     $entityName = $entityNameArr['fieldname'];
     $query = "SELECT vtiger_crmentity.deleted, {$focus1->table_name}.*\n\t\t\t\t\tFROM {$focus1->table_name}\n\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid={$focus1->table_name}.{$focus1->table_index}\n\t\t\t\t\t\twhere {$entityName}=? and vtiger_crmentity.deleted=0";
     $result = $adb->pquery($query, array($value));
     if (!isset($this->checkFlagArr[$module])) {
         $this->checkFlagArr[$module] = isPermitted($module, 'EditView', '') == 'yes';
     }
     if ($adb->num_rows($result) > 0) {
         //record found
         $focus1->id = $adb->query_result($result, 0, $focus1->table_index);
     } elseif ($this->checkFlagArr[$module]) {
         //record not found; create it
         $focus1->column_fields[$focus1->list_link_field] = $value;
         $focus1->column_fields['assigned_user_id'] = $current_user->id;
         $focus1->column_fields['modified_user_id'] = $current_user->id;
         $focus1->save($module);
         $last_import = new UsersLastImport();
         $last_import->assigned_user_id = $current_user->id;
         $last_import->bean_type = $module;
         $last_import->bean_id = $focus1->id;
         $last_import->save();
     } else {
         //record not found and cannot create
         $this->column_fields[$fieldname] = "";
         return false;
     }
     if (!empty($focus1->id)) {
         $this->column_fields[$fieldname] = $focus1->id;
         return true;
     } else {
         $this->column_fields[$fieldname] = "";
         return false;
     }
 }
开发者ID:gitter-badger,项目名称:openshift-salesplatform,代码行数:58,代码来源:CRMEntity.php

示例4: writeRowToLastImport

 /**
  * Add this row to the UsersLastImport table
  *
  * @param string $import_module name of the module we are doing the import into
  * @param string $module        name of the bean we are creating for this import
  * @param string $id            id of the recorded created in the $module
  */
 public static function writeRowToLastImport($import_module, $module, $id)
 {
     // cache $last_import instance
     static $last_import;
     if (!$last_import instanceof UsersLastImport) {
         $last_import = new UsersLastImport();
     }
     $last_import->id = null;
     $last_import->deleted = null;
     $last_import->assigned_user_id = $GLOBALS['current_user']->id;
     $last_import->import_module = $import_module;
     if ($module == 'Case') {
         $module = 'aCase';
     }
     $last_import->bean_type = $module;
     $last_import->bean_id = $id;
     return $last_import->save();
 }
开发者ID:MexinaD,项目名称:SuiteCRM,代码行数:25,代码来源:ImportDataSource.php

示例5: foreach

     $count[$module]++;
     $calendar = CRMEntity::getInstance('Calendar');
     $calendar->column_fields = $activity->generateArray($ical_activities[$i]);
     $calendar->column_fields['assigned_user_id'] = $current_user->id;
     foreach ($required_fields[$module] as $key) {
         if (empty($calendar->column_fields[$key])) {
             $skip_count[$module]++;
             break;
         }
     }
     $calendar->save('Calendar');
     $last_import = new UsersLastImport();
     $last_import->assigned_user_id = $current_user->id;
     $last_import->bean_type = 'Calendar';
     $last_import->bean_id = $calendar->id;
     $last_import->save();
     if (!empty($ical_activities[$i]['VALARM'])) {
         $calendar->activity_reminder($calendar->id, $calendar->column_fields['reminder_time'], 0, '', '');
     }
 }
 unlink($file);
 $smarty->assign("IMAGE_PATH", $last_imported);
 $smarty = new vtigerCRM_Smarty();
 $smarty->assign("MOD", $mod_strings);
 $smarty->assign("APP", $app_strings);
 $smarty->assign("IMP", $import_mod_strings);
 $smarty->assign("THEME", $theme);
 $smarty->assign("IMAGE_PATH", $image_path);
 $parent_tab = vtlib_purify($_SESSION['import_parenttab']);
 if (empty($parent_Tab)) {
     $parent_tab = getParentTab();
开发者ID:hbsman,项目名称:vtigercrm-5.3.0-ja,代码行数:31,代码来源:iCalImport.php

示例6: InsertImportRecords

/**	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;
    global $adb;
    global $mod_strings;
    global $dup_ow_count;
    global $process_fields;
    // MWC ** Getting vtiger_users
    $users_groups_list = array();
    $dup_count = 0;
    $count = 0;
    $dup_ow_count = 0;
    $process_fields = 'false';
    if ($start == 0) {
        $_SESSION['totalrows'] = $rows;
        $_SESSION['return_field_count'] = $ret_field_count;
        $_SESSION['column_position_to_field'] = $col_pos_to_field;
    }
    $ii = $start;
    // go thru each row, process and save()
    foreach ($rows1 as $row) {
        $adb->println("Going to Save the row " . $ii . " =====> ");
        $adb->println($row);
        global $mod_strings;
        $do_save = 1;
        //MWC
        $my_userid = $current_user->id;
        //If we want to set default values for some fields for each entity then we have to set here
        if ($module == 'Products' || $module == 'Services') {
            //discontinued is not null. if we unmap active, NULL will be inserted and query will fail
            $focus->column_fields['discontinued'] = 'on';
        }
        for ($field_count = 0; $field_count < $ret_field_count; $field_count++) {
            p("col_pos[" . $field_count . "]=" . $col_pos_to_field[$field_count]);
            if (isset($col_pos_to_field[$field_count])) {
                p("set =" . $field_count);
                if (!isset($row[$field_count])) {
                    continue;
                }
                p("setting");
                // TODO: add check for user input
                // addslashes, striptags, etc..
                $field = $col_pos_to_field[$field_count];
                //picklist function is added to avoid duplicate picklist entries
                $pick_orginal_val = getPicklist($field, $row[$field_count]);
                if ($pick_orginal_val != null) {
                    $focus->column_fields[$field] = $pick_orginal_val;
                } elseif ($field == "assignedto" || $field == "assigned_user_id") {
                    //Here we are assigning the user id in column fields, so in function assign_user (ImportLead.php and ImportProduct.php files) we should use the id instead of user name when query the user
                    //or we can use $focus->column_fields['smownerid'] = $users_groups_list[$row[$field_count]];
                    $row[$field_count] = trim($row[$field_count]);
                    if (empty($users_groups_list[$row[$field_count]])) {
                        $id = getUserId_Ol($row[$field_count]);
                        if (empty($id)) {
                            $id = getGrpId($row[$field_count]);
                        }
                        $users_groups_list[trim($row[$field_count])] = $id;
                    }
                    $focus->column_fields[$field] = $users_groups_list[$row[$field_count]];
                    p("setting my_userid={$my_userid} for user=" . $row[$field_count]);
                } else {
                    //$focus->$field = $row[$field_count];
                    $focus->column_fields[$field] = $row[$field_count];
                    p("Setting " . $field . "=" . $row[$field_count]);
                }
            }
        }
        if ($focus->column_fields['notify_owner'] == '') {
            $focus->column_fields['notify_owner'] = '0';
        }
        if ($focus->column_fields['reference'] == '') {
            $focus->column_fields['reference'] = '0';
        }
        if ($focus->column_fields['emailoptout'] == '') {
            $focus->column_fields['emailoptout'] = '0';
        }
        if ($focus->column_fields['donotcall'] == '') {
            $focus->column_fields['donotcall'] = '0';
        }
        if ($focus->column_fields['discontinued'] == '') {
            $focus->column_fields['discontinued'] = '0';
        }
        if ($focus->column_fields['active'] == '') {
            $focus->column_fields['active'] = '0';
        }
        p("setting done");
        p("do save before req vtiger_fields=" . $do_save);
//.........这里部分代码省略.........
开发者ID:hbsman,项目名称:vtigercrm-5.3.0-ja,代码行数:101,代码来源:ImportSave.php

示例7: testUndoRemovedAddedEmailAddresses

 /**
  * @ticket 21828
  */
 public function testUndoRemovedAddedEmailAddresses()
 {
     $time = date('Y-m-d H:i:s');
     $unid = uniqid();
     $focus = new Account();
     $focus->id = "Account_" . $unid;
     $focus->save();
     $last_import = new UsersLastImport();
     $last_import->assigned_user_id = $GLOBALS['current_user']->id;
     $last_import->import_module = 'Accounts';
     $last_import->bean_type = 'Account';
     $last_import->bean_id = $focus->id;
     $last_import->save();
     $this->email_addr_bean_rel_id = 'email_addr_bean_rel_' . $unid;
     $this->email_address_id = 'email_address_id_' . $unid;
     $GLOBALS['db']->query("insert into email_addr_bean_rel (id , email_address_id, bean_id, bean_module, primary_address, date_created , date_modified) values ('{$this->email_addr_bean_rel_id}', '{$this->email_address_id}', '{$focus->id}', 'Accounts', 1, '{$time}', '{$time}')");
     $GLOBALS['db']->query("insert into email_addresses (id , email_address, email_address_caps, date_created, date_modified) values ('{$this->email_address_id}', 'test@g.com', 'TEST@G.COM', '{$time}', '{$time}')");
     // setup
     require 'include/modules.php';
     $GLOBALS['beanList'] = $beanList;
     $GLOBALS['beanFiles'] = $beanFiles;
     $this->assertTrue($last_import->undo($last_import->import_module));
     // teardown
     unset($GLOBALS['beanList']);
     unset($GLOBALS['beanFiles']);
     $result = $GLOBALS['db']->query("SELECT * FROM email_addr_bean_rel where id = '{$this->email_addr_bean_rel_id}'");
     $rows = $GLOBALS['db']->fetchByAssoc($result);
     $this->assertFalse($rows);
     $result = $GLOBALS['db']->query("SELECT * FROM email_addresses where id = '{$this->email_address_id}'");
     $rows = $GLOBALS['db']->fetchByAssoc($result);
     $this->assertFalse($rows);
     $GLOBALS['db']->query("DELETE FROM users_last_import WHERE id = '{$last_import->id}'");
 }
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:36,代码来源:UsersLastImportTest.php

示例8: InsertImportRecords


//.........这里部分代码省略.........
        if ($acc_config["showvat"] == "true") {
            $tax = $row[$ret_field_count - $idx++];
        }
        $amount = $row[$ret_field_count - $idx++];
        $paymentdate = $row[$ret_field_count - $idx++];
        $paymentduedate = $row[$ret_field_count - $idx++];
        $ref = $row[$ret_field_count - $idx++];
        $invid = '';
        $assocmodule = '';
        $assocdisplay = '';
        if ($associnv != "") {
            //check the module of the field
            $arr = array();
            $arr = explode("::::", $associnv);
            $assocmodule = $arr[0];
            $assocdisplay = $arr[1];
            $focus1 = CRMEntity::getInstance($assocmodule);
            $entityNameArr = getEntityField($assocmodule);
            $entityName = $entityNameArr['fieldname'];
            $query = "SELECT vtiger_crmentity.deleted, {$focus1->table_name}.*\n\t\t\t\t\t\tFROM {$focus1->table_name}\n\t\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid={$focus1->table_name}.{$focus1->table_index}\n\t\t\t\t\t\t\twhere {$entityName}=? and vtiger_crmentity.deleted=0";
            $result = $adb->pquery($query, array($assocdisplay));
            $invid = $adb->query_result($result, 0, $focus1->table_index);
        }
        $payment = array('ref' => $ref, 'paymentduedate' => $paymentduedate, 'paymentdate' => $paymentdate, 'amount' => $amount, 'paymenttax' => $tax, 'paymentmethod' => $paymentmethod, 'associnv' => $invid, 'associnv_display' => $assocdisplay, 'paymentassoc_mod' => $assocmodule, 'paid' => $paid);
        array_push($payments[$row[0]], $payment);
    }
    $totalnoofrows -= $sub;
    $rows1 = $rows2;
    $recordcount = count($rows1);
    foreach ($rows1 as $row) {
        $adb->println("Going to Save the row " . $ii . " =====> ");
        $adb->println($row);
        global $mod_strings;
        $do_save = 1;
        //MWC
        $my_userid = $current_user->id;
        //If we want to set default values for some fields for each entity then we have to set here
        if ($module == 'Products' || $module == 'Services') {
            //discontinued is not null. if we unmap active, NULL will be inserted and query will fail
            $focus->column_fields['discontinued'] = 'on';
        }
        for ($field_count = 0; $field_count < $ret_field_count; $field_count++) {
            p("col_pos[" . $field_count . "]=" . $col_pos_to_field[$field_count]);
            if (isset($col_pos_to_field[$field_count])) {
                p("set =" . $field_count);
                if (!isset($row[$field_count])) {
                    continue;
                }
                p("setting");
                // TODO: add check for user input
                // addslashes, striptags, etc..
                $field = $col_pos_to_field[$field_count];
                //picklist function is added to avoid duplicate picklist entries
                $pick_orginal_val = getPicklist($field, $row[$field_count]);
                if ($pick_orginal_val != null) {
                    $focus->column_fields[$field] = $pick_orginal_val;
                } elseif ($field == "assignedto" || $field == "assigned_user_id") {
                    //Here we are assigning the user id in column fields, so in function assign_user (ImportLead.php and ImportProduct.php files) we should use the id instead of user name when query the user
                    //or we can use $focus->column_fields['smownerid'] = $users_groups_list[$row[$field_count]];
                    $imported_user = $current_user->id;
                    $q = "SELECT groupid FROM vtiger_groups WHERE groupname=?";
                    $res = $adb->pquery($q, array(trim($row[$field_count])));
                    if ($adb->num_rows($res) > 0) {
                        $imported_user = $adb->query_result($res, 0, "groupid");
                    } else {
                        $q = "SELECT id FROM vtiger_users WHERE user_name=?";
开发者ID:jmangarret,项目名称:vtigercrm,代码行数:67,代码来源:ImportSave.php


注:本文中的UsersLastImport::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。