Subversion Repositories SmartDukaan

Rev

Rev 11049 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10582 lgm 1
<?php
2
if (!defined('BASEPATH'))
3
	exit('No direct script access allowed');
4
 
5
 
6
/*
7
 * Model for home
8
 */ 
9
 
10
 
11
Class Oauth_model extends CI_Model {
12
 
13
	var $url = '';
14
	var $parser_model;
15
	var $parser;
16
	var $current_client;
17
 
18
	function __construct() {
19
 
20
		// Call the Model constructor
21
		parent::__construct();
22
		//load appropriate parser
23
		$current_client =$this -> config -> item('current_client');
24
		$model = $current_client.'_model';
25
		$this->load->model($model);
26
		$this->parser = $this-> $model;
27
		$this->current_client=$this -> config -> item('current_client');
28
 
29
 
30
	}
31
 
32
 
33
	function getLogin($get=array(),$post=array(),$module=array())
11049 lgm 34
	{	
10582 lgm 35
		$output =array();
36
		if(isset($module) and !empty($module))
37
		{
38
			if(isset($module['header']) and !empty($module['header']))
39
			{
40
				foreach($module['header'] as $header)
41
				{
11109 lgm 42
					$this->curlURL($header,'get');	
43
 
10582 lgm 44
				}
45
			}
46
			if(isset($module['footer']) and !empty($module['footer']))
47
			{
48
				foreach($module['footer'] as $footer)
49
				{
11109 lgm 50
 
51
					$this->curlURL($footer,'get');	
10582 lgm 52
				}
53
			}
54
			if(isset($module['response']) and !empty($module['response']))
55
			{
56
				foreach($module['response'] as $response)
57
				{
58
					if(isset($post) and !empty($post))
59
					{
60
						if($this->current_client=='prestashop' || $this->current_client=='magento' )
61
						$this->curlURL($response,'post',$post);
62
					else
63
						$this->curlURL($response,'post',$post);
64
 
65
					}
66
				}
67
			}
68
 
69
 
70
		}
71
 
72
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
73
		//$this->curlURL('products','get',$get);
74
		$responses = $this->mcurl->execute();
75
		if(isset($responses) and !empty($responses))
76
		$responses = $this->parser->parse_response($responses,$module);
11109 lgm 77
		// if(isset($head) && !empty($head)){
78
		// 	foreach($head['header'] as $key=>$value){
79
		// 		$responses['header'][$key] = $value;
80
		// 	}
81
		// }
82
		// if(isset($foot) && !empty($foot)){
83
		// 	foreach($foot['footer'] as $key=>$value){
84
		// 		$responses['footer'][$key] = $value;
85
		// 	}
86
		// }
10582 lgm 87
		return $responses;
88
	}
89
	function getSignup($get=array(),$post=array(),$module=array())
90
	{
91
		$output =array();
92
		if(isset($module) and !empty($module))
93
		{
94
			if(isset($module['header']) and !empty($module['header']))
95
			{
96
				foreach($module['header'] as $header)
97
				{
11109 lgm 98
					$this->curlURL($header,'get');	
99
 
10582 lgm 100
				}
101
			}
102
			if(isset($module['footer']) and !empty($module['footer']))
103
			{
104
				foreach($module['footer'] as $footer)
105
				{
11109 lgm 106
 
107
					$this->curlURL($footer,'get');	
108
 
10582 lgm 109
				}
110
			}
111
			if(isset($module['response']) and !empty($module['response']))
112
			{
113
				foreach($module['response'] as $response)
114
				{
115
					if(isset($post) and !empty($post))
116
					{
117
						if($this->current_client=='prestashop' || $this->current_client=='magento' )
118
						$this->curlURL($response,'post',$post);
119
					else
120
						$this->curlURL($response,'post',$post);
121
 
122
					}
123
				}
124
			}
125
 
126
 
127
		}
128
 
129
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
130
		//$this->curlURL('products','get',$get);
131
		$responses = $this->mcurl->execute();
132
		if(isset($responses) and !empty($responses))
133
		$responses = $this->parser->parse_response($responses,$module);
11109 lgm 134
		// if(isset($head) && !empty($head)){
135
		// 	foreach($head['header'] as $key=>$value){
136
		// 		$responses['header'][$key] = $value;
137
		// 	}
138
		// }
139
		// if(isset($foot) && !empty($foot)){
140
		// 	foreach($foot['footer'] as $key=>$value){
141
		// 		$responses['footer'][$key] = $value;
142
		// 	}
143
		// }
10582 lgm 144
		return $responses;
145
	}
146
function curlURL($configurl=null,$methodtype='get',$parameter=array())
147
{
11049 lgm 148
 
10582 lgm 149
		$params ='';
150
		$display='';
151
		$url = $this->config->item('curl_base_url');
152
		$productsurl =$this->config->item($configurl);
153
		if(isset($productsurl['url']) and !empty($productsurl['url']))
154
			{
155
				$url .=$productsurl['url'];
156
				if($productsurl['display'])
157
				{$display=$productsurl['display'];}
158
			if(empty($parameter)){$parameter=$productsurl['params'];}
159
 
160
 
161
		if(isset($parameter) and !empty($parameter) and $methodtype=='get')
162
		{
163
			$params = $this->parser->prepareParams($parameter,$display,$configurl);
164
 
165
		}
166
		if(isset($parameter) and !empty($parameter) and $methodtype=='post')
167
		{
168
			$params = $this->parser->prepareParams($parameter,$display,$configurl);
169
			$methodtype ='post';
170
		}
171
		if(!isset($parameter) || empty($parameter))
172
			{$params =$this->parser->prepareParams('',$display,$configurl);}
173
		//$methodtype = 'post';
174
		return $this->mcurl->add_call($configurl,$methodtype,$url,$params);
175
	}
176
	else
177
		{return '';}
178
 
179
}
180
 
181
 
182
}