Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
34cd78e1 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
34cd78e1 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
34cd78e1 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | require_once 'CRM/Core/Page.php'; | |
37 | ||
38 | /** | |
39 | * Page to decide the flow of adding an item. | |
40 | */ | |
41 | class CRM_Auction_Page_AddItem extends CRM_Core_Page { | |
42 | ||
43 | /** | |
44 | * Run the page. | |
45 | * | |
46 | * This method is called after the page is created. It checks for the | |
47 | * type of action and executes that action. | |
48 | * Finally it calls the parent's run method. | |
49 | * | |
50 | * @return void | |
51 | * @access public | |
52 | * | |
53 | */ | |
54 | function run() { | |
55 | // get the requested action | |
56 | $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add'); | |
57 | ||
58 | // set breadcrumb to append to 2nd layer pages | |
59 | $breadCrumb = array(array('title' => ts('Manage Items'), | |
60 | 'url' => CRM_Utils_System::url(CRM_Utils_System::currentPath(), | |
61 | 'reset=1' | |
62 | ), | |
63 | )); | |
64 | // what action to take ? | |
65 | if ($action & CRM_Core_Action::ADD) { | |
66 | $session = CRM_Core_Session::singleton(); | |
67 | if ($session->get('userID')) { | |
68 | // For logged in user directly go to add/update item page. | |
69 | $controller = new CRM_Core_Controller_Simple('CRM_Auction_Form_Item', | |
70 | 'New Item', | |
71 | $action | |
72 | ); | |
73 | $controller->set('donorID', $session->get('userID')); | |
74 | } | |
75 | else { | |
76 | // For anonymous user go via account creation wizard. | |
77 | require_once 'CRM/Auction/Controller/Item.php'; | |
78 | $controller = new CRM_Auction_Controller_Item('New Item', $action); | |
79 | } | |
80 | return $controller->run(); | |
81 | } | |
82 | elseif ($action & CRM_Core_Action::UPDATE) { | |
83 | $session = CRM_Core_Session::singleton(); | |
84 | if ($session->get('userID')) { | |
85 | $controller = new CRM_Core_Controller_Simple('CRM_Auction_Form_Item', | |
86 | 'Update Item', | |
87 | $action | |
88 | ); | |
89 | $controller->set('donorID', $session->get('userID')); | |
90 | return $controller->run(); | |
91 | } | |
92 | } | |
93 | ||
94 | // parent run | |
95 | parent::run(); | |
96 | } | |
97 | } | |
98 |