parse outboundcid content into cid_num and cid_name sccpline fields
If outboundcid contains '"name" <num>' the content needs to be split to cid_name and cid_num. If not the content should be a number and should be copied to cid_num only, in that case we fill cid_name with the value of $label Fixes: #72 Signed-off-by: Diederik de Groot <dkgroot@talon.nl>
This commit is contained in:
		
							parent
							
								
									16104a0589
								
							
						
					
					
						commit
						212c43782b
					
				| 
						 | 
					@ -11,8 +11,9 @@ class Sccp extends \FreePBX\modules\Core\Driver {
 | 
				
			||||||
                                 "callgroup"=>'callgroup',"pickupgroup"=>'pickupgroup',
 | 
					                                 "callgroup"=>'callgroup',"pickupgroup"=>'pickupgroup',
 | 
				
			||||||
                                 "transfer" => 'transfer', "echocancel" => 'echocancel',
 | 
					                                 "transfer" => 'transfer', "echocancel" => 'echocancel',
 | 
				
			||||||
                                 "language" => 'language', "description" => 'callerid',
 | 
					                                 "language" => 'language', "description" => 'callerid',
 | 
				
			||||||
                                 "cid_num" => 'cid_num', "cid_name" => 'label', "mailbox" => 'description',
 | 
					                                 "cid_num" => 'cid_num', "cid_name" => 'cid_name', "mailbox" => 'mailbox',
 | 
				
			||||||
                                 "musicclass" => 'musicclass',
 | 
					                                 "musicclass" => 'musicclass',"allow" => 'allow',"disallow" => 'disallow',
 | 
				
			||||||
 | 
					                                 "videomode" => 'videomode',
 | 
				
			||||||
                                 "dnd" => 'dnd', "silencesuppression" => 'silencesuppression',
 | 
					                                 "dnd" => 'dnd', "silencesuppression" => 'silencesuppression',
 | 
				
			||||||
                                 "secondary_dialtone_digits" => 'secondary_dialtone_digits', "secondary_dialtone_tone" => 'secondary_dialtone_tone',
 | 
					                                 "secondary_dialtone_digits" => 'secondary_dialtone_digits', "secondary_dialtone_tone" => 'secondary_dialtone_tone',
 | 
				
			||||||
                                 'namedcallgroup'=>'namedcallgroup', 'namedpickupgroup' => 'namedpickupgroup'
 | 
					                                 'namedcallgroup'=>'namedcallgroup', 'namedpickupgroup' => 'namedpickupgroup'
 | 
				
			||||||
| 
						 | 
					@ -46,7 +47,10 @@ class Sccp extends \FreePBX\modules\Core\Driver {
 | 
				
			||||||
//                print_r($_REQUEST);
 | 
					//                print_r($_REQUEST);
 | 
				
			||||||
//                echo '<br><br>';
 | 
					//                echo '<br><br>';
 | 
				
			||||||
//                die(print_r($settings));
 | 
					//                die(print_r($settings));
 | 
				
			||||||
                $settings['cid_num']['value']='';
 | 
					                $settings['cid_num']['value'] = '';
 | 
				
			||||||
 | 
					                $settings['cid_name']['value'] = $label;
 | 
				
			||||||
 | 
					                $settings['mailbox']['value']= '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (isset($_REQUEST)){
 | 
					                if (isset($_REQUEST)){
 | 
				
			||||||
                    foreach($add_fld as $key => $val) {
 | 
					                    foreach($add_fld as $key => $val) {
 | 
				
			||||||
                        if (!empty($_REQUEST[$key])){
 | 
					                        if (!empty($_REQUEST[$key])){
 | 
				
			||||||
| 
						 | 
					@ -54,10 +58,43 @@ class Sccp extends \FreePBX\modules\Core\Driver {
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (empty($settings['cid_num']['value'])) {
 | 
					                $allow_codec = array();
 | 
				
			||||||
                    $settings['cid_num']['value']= $id;
 | 
					                foreach($settings as $key => $val) {
 | 
				
			||||||
 | 
					                    if (strpos($key,'codec_') !== false ) {
 | 
				
			||||||
 | 
					                         $allow_codec[] =substr($key,6);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                $sql = 'INSERT INTO sccpline (name';
 | 
					                }
 | 
				
			||||||
 | 
					                $settings['allow']['value'] = implode(",", $allow_codec);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// parse outboundcid content into cid_num and cid_name sccpline fields
 | 
				
			||||||
 | 
					                if (empty($settings['cid_num']['value'])) {
 | 
				
			||||||
 | 
					                    $settings['cid_num']['value'] = $id;
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    $outboundcid = $settings['cid_num']['value'];
 | 
				
			||||||
 | 
					                    if (preg_match('/"(.*)"\s?<(.*)>/', $outboundcid, $matches)) {
 | 
				
			||||||
 | 
					                        $settings['cid_num']['value'] = $matches[2];
 | 
				
			||||||
 | 
					                        $settings['cid_name']['value'] = $matches[1];
 | 
				
			||||||
 | 
					                    } else if (is_integer($outboundcid)) {
 | 
				
			||||||
 | 
					                        $settings['cid_num']['value'] = $outboundcid;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (!empty($_REQUEST['vm']) && ($_REQUEST['vm'] =='enabled')){ // mailbox
 | 
				
			||||||
 | 
					                    if (empty($settings['mailbox']['value'])) {
 | 
				
			||||||
 | 
					                        $settings['mailbox']['value']= $id;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//                die(print_r($settings));
 | 
				
			||||||
 | 
					                $tech = Array();
 | 
				
			||||||
 | 
					                $sql = "DESCRIBE `sccpline`";
 | 
				
			||||||
 | 
					                foreach ($this->database->query($sql) as $row) {
 | 
				
			||||||
 | 
					                    $tech[$row["Field"]]=$row["Field"];
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//                die(print_r($tech));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $sql = 'REPLACE INTO sccpline (name';
 | 
				
			||||||
                $sqlv = 'values ("'.$id.'"';
 | 
					                $sqlv = 'values ("'.$id.'"';
 | 
				
			||||||
		foreach($this->data_fld as $key => $val) {
 | 
							foreach($this->data_fld as $key => $val) {
 | 
				
			||||||
                    if (!empty($settings[$val]) ) {
 | 
					                    if (!empty($settings[$val]) ) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue