Пример #1
0
 //lmfao I'm in miami *****!
 $USER_TEMPLATE['caller_id']['internal'] = array('number' => "1234", 'name' => 'Internal');
 $USER_TEMPLATE['caller_id']['external'] = array('number' => "6041231234", 'name' => 'External');
 $USER_TEMPLATE['call_forward'] = array('enabled' => false, 'number' => '', 'require_keypress' => false, 'keep_caller_id' => true, 'substitute' => false, 'direct_calls_only' => false);
 /*
 $users = $XBAR->get_users($ACCOUNT_ID);
 print_r($users);
 exit(0);
 */
 $USER_ID = '';
 printf("{$bldblu}TEST: Creating User{$txtrst}\n");
 $user = $XBAR->get_user_by_name($USER_TEMPLATE['username'], $ACCOUNT_ID);
 if ($user) {
     printf("{$bldylw}Warning: {$bldred}Existing User SKIPPING CREATION!{$txtrst}\n");
 } else {
     $resp = $XBAR->put_user($USER_TEMPLATE, $ACCOUNT_ID);
     if ($resp['status'] != 'success') {
         printf("{$bldred}FATAL: {$bldwht}Create User Failed, abort test. {$bldwht}({$bldpur} {$resp['message']}{$bldwht} ) {$txtrst}\n");
         exit(-1);
     } else {
         printf("{$bldgrn}PASS: Create User Success.{$txtrst}\n\n");
         /*
         	Hack for v1.50 since user listing (possibly retrieval too) is broken.
         	This only works occasionaly since couch only responds with the id 
         	if it returns within a certain time limit I think ( delayed_commits ) setting is the issue
         	for now it's random when data is returned and the list users interface throws a 500 error
         	best bet to hope the data comes back
         */
         if (isset($resp['data'])) {
             $USER_ID = $resp['data']['id'];
             printf("{$bldylw}WARN: Using INSERT USER ID:{$bldred}{$USER_ID}{$txtrst}\n\n");