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


PHP Call::load_relationship方法代码示例

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


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

示例1: testParentsAreRelatedDuringImport

 public function testParentsAreRelatedDuringImport()
 {
     $file = 'upload://test50438.csv';
     $ret = file_put_contents($file, $this->fileArr);
     $this->assertGreaterThan(0, $ret, 'Failed to write to ' . $file . ' for content ' . var_export($this->fileArr, true));
     $importSource = new ImportFile($file, ',', '"');
     $bean = loadBean('Calls');
     $_REQUEST['columncount'] = 5;
     $_REQUEST['colnum_0'] = 'id';
     $_REQUEST['colnum_1'] = 'subject';
     $_REQUEST['colnum_2'] = 'status';
     $_REQUEST['colnum_3'] = 'parent_type';
     $_REQUEST['colnum_4'] = 'parent_id';
     $_REQUEST['import_module'] = 'Contacts';
     $_REQUEST['importlocale_charset'] = 'UTF-8';
     $_REQUEST['importlocale_timezone'] = 'GMT';
     $_REQUEST['importlocale_default_currency_significant_digits'] = '2';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_dec_sep'] = '.';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_default_locale_name_format'] = 's f l';
     $_REQUEST['importlocale_num_grp_sep'] = ',';
     $_REQUEST['importlocale_dateformat'] = 'm/d/y';
     $_REQUEST['importlocale_timeformat'] = 'h:i:s';
     $importer = new Importer($importSource, $bean);
     $importer->import();
     //fetch the bean using the passed in id and get related contacts
     require_once 'modules/Calls/Call.php';
     $call = new Call();
     $call->retrieve($this->call_id);
     $call->load_relationship('contacts');
     $related_contacts = $call->contacts->get();
     //test that the contact id is in the array of related contacts.
     $this->assertContains($this->contact->id, $related_contacts, ' Contact was not related during simulated import despite being set in related parent id');
     unset($call);
     /*
     if (is_file($file)) {
         unlink($file);
     }
     */
 }
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:41,代码来源:Bug50438Test.php

示例2: setBeanID

function setBeanID($call_record, $bean_module, $bean_id)
{
    //wrapped the entire action to require a call_record - if this is not being passed then there is no point for this action - PJH
    if (is_string($call_record) && is_string($bean_id)) {
        // Very basic sanitization
        $bean_id = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $bean_id);
        $bean_module = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $bean_module);
        $call_record = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $call_record);
        // Workaround See Discussion here: https://github.com/blak3r/yaai/pull/20
        $parent_module = null;
        $parent_id = null;
        $parent_name = null;
        $parent_link = null;
        $bean_link = build_link($bean_module, $bean_id);
        $bean_module = strtolower($bean_module);
        if ($bean_module == 'contacts') {
            $c = new Contact();
            $c->retrieve($bean_id);
            $bean_name = $c->name;
            $bean_description = $c->description;
            $parent_id = $c->account_id;
            $parent_module = "accounts";
            $parent_name = $c->account_name;
            //$GLOBALS["log"]->fatal(print_r($c,true));
        } else {
            if ($bean_module == "accounts") {
                $a = new Account();
                $a->retrieve($bean_id);
                $bean_name = $a->name;
                $bean_description = $a->description;
            } else {
                $GLOBALS['log']->fatal("Unsupported Module: {$bean_module}!");
            }
        }
        $query = "update asterisk_log set bean_id='{$bean_id}', bean_module='{$bean_module}', bean_name='{$bean_name}', bean_link='{$bean_link}', bean_description='{$bean_description}', " . " parent_id='{$parent_id}', parent_module='{$parent_module}', parent_name='{$parent_name}', parent_link='{$parent_link}' " . " where call_record_id='{$call_record}'";
        //            $GLOBALS['log']->fatal($query);
        $GLOBALS['current_user']->db->query($query, false);
        if ($GLOBALS['current_user']->db->checkError()) {
            trigger_error("Update setContactId-Query failed: {$query}");
        }
        $focus = new Call();
        $focus->retrieve($call_record);
        $focus->load_relationship('contacts');
        $focus->load_relationship('accounts');
        // TODO here, find if there is a way to remove all relationships dynamically so we don't need to specify 'contacts', 'accounts' explicitly
        // Remove any contacts already associated with call (if there are any)
        foreach ($focus->contacts->getBeans() as $contact) {
            $focus->contacts->delete($call_record, $contact->id);
        }
        foreach ($focus->accounts->getBeans() as $account) {
            $focus->accounts->delete($call_record, $account->id);
        }
        switch ($bean_module) {
            case 'contacts':
                $focus->contacts->add($bean_id);
                // Add the new one!
                $contactBean = new Contact();
                $contactBean->retrieve($bean_id);
                $focus->parent_id = $contactBean->account_id;
                $focus->parent_type = "Accounts";
                break;
            case 'accounts':
                $focus->accounts->add($bean_id);
                break;
        }
        $focus->save();
    }
}
开发者ID:nitouser,项目名称:yaai,代码行数:68,代码来源:callinize_db.php

示例3: Call

     $cUser->retrieve($_SESSION['authenticated_user_id']);
     // query log
     // Very basic santization
     $contactId = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $_REQUEST['contact_id']);
     // mysql_real_escape_string($_REQUEST['ui_state']);
     $callRecord = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $_REQUEST['call_record']);
     // mysql_real_escape_string($_REQUEST['call_record']);
     $query = "update asterisk_log set contact_id=\"{$contactId}\" where call_record_id=\"{$callRecord}\"";
     $resultSet = $cUser->db->query($query, false);
     if ($cUser->db->checkError()) {
         trigger_error("Update setContactId-Query failed: {$query}");
     }
     // Adds the new relationship!  (This must be done here in case the call has already been hungup as that's when asteriskLogger sets relations)
     $focus = new Call();
     $focus->retrieve($callRecord);
     $focus->load_relationship('contacts');
     // Remove any contacts already associated with call (if there are any)
     foreach ($focus->contacts->getBeans() as $contact) {
         $focus->contacts->delete($callRecord, $contact->id);
     }
     $focus->contacts->add($contactId);
     // Add the new one!
     $contactBean = new Contact();
     $contactBean->retrieve($contactId);
     $focus->parent_id = $contactBean->account_id;
     $focus->parent_type = "Accounts";
     $focus->save();
 } else {
     if ($_REQUEST['action'] == "call") {
         // TODO: For some reason this code isn't working... I think it's getting the extension.
         // For the time being, callCreate is still being used.
开发者ID:netconstructor,项目名称:yaai,代码行数:31,代码来源:controller.php

示例4: callComplete


//.........这里部分代码省略.........
    $call->direction = "Outbound";
    if (strpos(strtolower($_REQUEST['From']), 'client:') === false) {
        //Call in or using call conection
        if (strpos(strtolower($_REQUEST['Direction']), 'inbound') !== false) {
            //this is inbound call
            $call_sid = $_REQUEST['CallSid'];
            $call->direction = "Inbound";
        }
    }
    $call_record = $client->account->calls->get($call_sid);
    //    if(is_array($call_record->recordings)){
    //        _ppl('array');
    //    }else{
    //        _ppl('not array');
    //    }
    //_ppl($call_record);
    //    foreach($call_record->recordings as $record_obj){
    //        $call->description= "Recording URL: ". $record_obj->RecordingUrl;
    //        //break;
    //        _ppl('recording url:' . $record_obj->RecordingUrl);
    //        _ppl('recording url2:' . $record_obj->recordingurl);
    //    }
    //$RecordingUrl
    _ppl('from: ' . $call_record->from);
    _ppl('to: ' . $call_record->to);
    _ppl('Direction: ' . $call_record->direction);
    if ($call->direction == 'Inbound') {
        $call->name = "Call from {$call_record->from}";
        /*
         * currently, we only support looking up the phone number in E.164 number formatting, see following URL for detail
         * http://www.twilio.com/help/faq/phone-numbers/how-do-i-format-phone-numbers-to-work-internationally
         */
        $matched_obj = lookup_inbound_obj($call_record->from);
        $module_name = isset($matched_obj['module_name']) ? $matched_obj['module_name'] : '';
        $record_id = isset($matched_obj['record_id']) ? $matched_obj['record_id'] : '';
    } else {
        if (strpos(strtolower($_REQUEST['From']), 'client:') === false) {
            $call->name = "Call to {$call_record->to} (using connection)";
        } else {
            $call->name = "Call to {$call_record->to}";
        }
    }
    $start_time = new DateTime(isset($call_record->starttime) ? $call_record->starttime : '');
    $end_time = new DateTime(isset($call_record->endtime) ? $call_record->endtime : '');
    $timezone = new DateTimeZone("UTC");
    $start_time->setTimezone($timezone);
    $end_time->setTimezone($timezone);
    $call->date_start = $start_time->format($timedate->get_db_date_time_format());
    $call->date_end = $end_time->format($timedate->get_db_date_time_format());
    _ppl('duration: ' . $call_record->duration);
    $duration_hours = floor($call_record->duration / 3600);
    $duration_minutes = $call_record->duration / 60 % 60;
    $call->duration_hours = $duration_hours;
    if ($duration_minutes > 0 && $duration_minutes <= 15) {
        $call->duration_minutes = 15;
    } elseif ($duration_minutes > 15 && $duration_minutes <= 30) {
        $call->duration_minutes = 30;
    } elseif ($duration_minutes > 30 && $duration_minutes <= 45) {
        $call->duration_minutes = 45;
    } else {
        $call->duration_minutes = 0;
    }
    $call->status = "Held";
    $call->team_id = '1';
    $call->assigned_user_id = '1';
    $call->parent_type = 'Contacts';
    $call->parent_id = $record_id;
    if ($module_name == 'Contacts') {
        $call->contact_id = $record_id;
        $contact_bean = new Contact();
        $contact_bean->retrieve($record_id);
        $call->parent_type = 'Accounts';
        $call->parent_id = $contact_bean->account_id;
    }
    if ($module_name == 'Accounts') {
        $call->parent_id = $record_id;
        $call->parent_type = 'Accounts';
    }
    $call->save();
    if ($module_name == 'Contacts') {
        $call->load_relationship("contacts");
        $call->contacts->add($record_id);
    } else {
        if ($module_name == 'Leads') {
            $call->load_relationship("leads");
            $call->leads->add($record_id);
        } else {
            if ($module_name == 'Users') {
                $call->load_relationship("users");
                $call->users->add($record_id);
            }
        }
    }
    header('Content-type: text/xml');
    ?>
<Response>
<Hangup/> 
</Response>
<?php 
}
开发者ID:anhtuantt,项目名称:sugarcrm-twilio-example,代码行数:101,代码来源:twilio_entrypoint_actions.php


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