Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12694 anikendra 1
<?php
2
if (!defined('BASEPATH'))
3
	exit('No direct script access allowed');
4
 
5
 
6
/*
7
 * Model for Private Deals
8
 */ 
9
 
10
Class Privatedeal_model extends CI_Model {
11
 
12
	var $url = '';
13
	var $parser_model;
14
	var $parser;
15
 
16
	function __construct() {
17
 
18
		// Call the Model constructor
19
		parent::__construct();
20
		//load appropriate parser
21
		$current_client =$this -> config -> item('current_client');
22
		$model = $current_client.'_model';
23
		$this->load->model($model);
24
		$this->parser = $this-> $model;
25
 
26
 
27
	}
28
 
29
	function getProducts($get=array(),$post=array(),$module=array(), $userId,$page=1)
30
	{
31
		$output =array();
32
		if(isset($module) and !empty($module))
33
		{
34
			if(isset($module['header']) and !empty($module['header']))
35
			{
36
				foreach($module['header'] as $header)
37
				{
38
 
39
					$this->curlURL($header,'get');
40
				}
41
			}
42
			if(isset($module['footer']) and !empty($module['footer']))
43
			{
44
				foreach($module['footer'] as $footer)
45
				{
46
					$this->curlURL($footer,'get');
47
				}
48
			}
49
			if(isset($module['response']) and !empty($module['response']))
50
			{
51
				foreach($module['response'] as $response)
52
				{
53
 
54
					if(isset($post) and !empty($post))
55
					{
56
						if($this->current_client=='magento' )
57
						$this->curlURL($response,'get',$post);
58
					else
59
						$this->curlURL($response,'get',$post);
60
 
61
					}
62
					else
63
					{
64
 
65
						$this->curlURL($response,'get',$get,$userId,$page);
66
					}
67
				}
68
			}
69
 
70
 
71
		}
72
 
73
		$responses = $this->mcurl->execute();
74
		if(isset($responses) and !empty($responses))
75
		$responses = $this->parser->parse_response($responses,$module);
76
 
77
 
78
		return $responses;
79
	}
80
 
81
	function curlURL($configurl=null,$methodtype='get',$parameter=array(),$userId=null,$page=1)	{		
82
		$params ='';
83
		$display='';
84
		$url = $this->config->item('curl_base_url');
85
		$productsurl =$this->config->item($configurl);
86
		if(isset($productsurl['url']) and !empty($productsurl['url']))
87
		{
88
			$url .=$productsurl['url'];
89
			if($productsurl['display']) {
90
				$display=$productsurl['display'];
91
			}
92
			if(empty($parameter)) {
93
				$parameter=$productsurl['params'];
94
			}			
95
 
96
			if(isset($userId) && $userId != null){
97
				$url .= '/'.$page.'/?isLoggedIn=true&userId='.$userId;
98
			}
99
 
100
			return $this->mcurl->add_call($configurl,$methodtype,$url);
101
		} else {
102
			return '';
103
		}
104
	}
105
}