PageRenderTime 41ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/drupal/sites/all/modules/civicrm/CRM/Core/DAO/Menu.php

https://github.com/michaelmcandrew/vaw
PHP | 434 lines | 217 code | 0 blank | 217 comment | 10 complexity | b4de55090a91edb75017c9d4c67a023e MD5 | raw file
  1. <?php
  2. /*
  3. +--------------------------------------------------------------------+
  4. | CiviCRM version 3.4 |
  5. +--------------------------------------------------------------------+
  6. | Copyright CiviCRM LLC (c) 2004-2011 |
  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. * @package CRM
  30. * @copyright CiviCRM LLC (c) 2004-2011
  31. * $Id$
  32. *
  33. */
  34. require_once 'CRM/Core/DAO.php';
  35. require_once 'CRM/Utils/Type.php';
  36. class CRM_Core_DAO_Menu extends CRM_Core_DAO
  37. {
  38. /**
  39. * static instance to hold the table name
  40. *
  41. * @var string
  42. * @static
  43. */
  44. static $_tableName = 'civicrm_menu';
  45. /**
  46. * static instance to hold the field values
  47. *
  48. * @var array
  49. * @static
  50. */
  51. static $_fields = null;
  52. /**
  53. * static instance to hold the FK relationships
  54. *
  55. * @var string
  56. * @static
  57. */
  58. static $_links = null;
  59. /**
  60. * static instance to hold the values that can
  61. * be imported / apu
  62. *
  63. * @var array
  64. * @static
  65. */
  66. static $_import = null;
  67. /**
  68. * static instance to hold the values that can
  69. * be exported / apu
  70. *
  71. * @var array
  72. * @static
  73. */
  74. static $_export = null;
  75. /**
  76. * static value to see if we should log any modifications to
  77. * this table in the civicrm_log table
  78. *
  79. * @var boolean
  80. * @static
  81. */
  82. static $_log = false;
  83. /**
  84. *
  85. * @var int unsigned
  86. */
  87. public $id;
  88. /**
  89. * Which Domain is this menu item for
  90. *
  91. * @var int unsigned
  92. */
  93. public $domain_id;
  94. /**
  95. * Path Name
  96. *
  97. * @var string
  98. */
  99. public $path;
  100. /**
  101. * Arguments to pass to the url
  102. *
  103. * @var text
  104. */
  105. public $path_arguments;
  106. /**
  107. * Menu Title
  108. *
  109. * @var string
  110. */
  111. public $title;
  112. /**
  113. * Function to call to check access permissions
  114. *
  115. * @var string
  116. */
  117. public $access_callback;
  118. /**
  119. * Arguments to pass to access callback
  120. *
  121. * @var text
  122. */
  123. public $access_arguments;
  124. /**
  125. * function to call for this url
  126. *
  127. * @var string
  128. */
  129. public $page_callback;
  130. /**
  131. * Arguments to pass to page callback
  132. *
  133. * @var text
  134. */
  135. public $page_arguments;
  136. /**
  137. * Breadcrumb for the path.
  138. *
  139. * @var text
  140. */
  141. public $breadcrumb;
  142. /**
  143. * Url where a page should redirected to, if next url not known.
  144. *
  145. * @var string
  146. */
  147. public $return_url;
  148. /**
  149. * Arguments to pass to return_url
  150. *
  151. * @var string
  152. */
  153. public $return_url_args;
  154. /**
  155. * Component that this menu item belongs to
  156. *
  157. * @var int unsigned
  158. */
  159. public $component_id;
  160. /**
  161. * Is this menu item active?
  162. *
  163. * @var boolean
  164. */
  165. public $is_active;
  166. /**
  167. * Is this menu accessible to the public?
  168. *
  169. * @var boolean
  170. */
  171. public $is_public;
  172. /**
  173. * Is this menu exposed to the navigation system?
  174. *
  175. * @var boolean
  176. */
  177. public $is_exposed;
  178. /**
  179. * Should this menu be exposed via SSL if enabled?
  180. *
  181. * @var boolean
  182. */
  183. public $is_ssl;
  184. /**
  185. * Ordering of the menu items in various blocks.
  186. *
  187. * @var int
  188. */
  189. public $weight;
  190. /**
  191. * Drupal menu type.
  192. *
  193. * @var int
  194. */
  195. public $type;
  196. /**
  197. * CiviCRM menu type.
  198. *
  199. * @var int
  200. */
  201. public $page_type;
  202. /**
  203. * skip this url being exposed to breadcrumb
  204. *
  205. * @var boolean
  206. */
  207. public $skipBreadcrumb;
  208. /**
  209. * class constructor
  210. *
  211. * @access public
  212. * @return civicrm_menu
  213. */
  214. function __construct()
  215. {
  216. parent::__construct();
  217. }
  218. /**
  219. * return foreign links
  220. *
  221. * @access public
  222. * @return array
  223. */
  224. function &links()
  225. {
  226. if (!(self::$_links)) {
  227. self::$_links = array(
  228. 'domain_id' => 'civicrm_domain:id',
  229. 'component_id' => 'civicrm_component:id',
  230. );
  231. }
  232. return self::$_links;
  233. }
  234. /**
  235. * returns all the column names of this table
  236. *
  237. * @access public
  238. * @return array
  239. */
  240. function &fields()
  241. {
  242. if (!(self::$_fields)) {
  243. self::$_fields = array(
  244. 'id' => array(
  245. 'name' => 'id',
  246. 'type' => CRM_Utils_Type::T_INT,
  247. 'required' => true,
  248. ) ,
  249. 'domain_id' => array(
  250. 'name' => 'domain_id',
  251. 'type' => CRM_Utils_Type::T_INT,
  252. 'required' => true,
  253. 'FKClassName' => 'CRM_Core_DAO_Domain',
  254. ) ,
  255. 'path' => array(
  256. 'name' => 'path',
  257. 'type' => CRM_Utils_Type::T_STRING,
  258. 'title' => ts('Path') ,
  259. 'maxlength' => 255,
  260. 'size' => CRM_Utils_Type::HUGE,
  261. ) ,
  262. 'path_arguments' => array(
  263. 'name' => 'path_arguments',
  264. 'type' => CRM_Utils_Type::T_TEXT,
  265. 'title' => ts('Path Arguments') ,
  266. ) ,
  267. 'title' => array(
  268. 'name' => 'title',
  269. 'type' => CRM_Utils_Type::T_STRING,
  270. 'title' => ts('Title') ,
  271. 'maxlength' => 255,
  272. 'size' => CRM_Utils_Type::HUGE,
  273. ) ,
  274. 'access_callback' => array(
  275. 'name' => 'access_callback',
  276. 'type' => CRM_Utils_Type::T_STRING,
  277. 'title' => ts('Access Callback') ,
  278. 'maxlength' => 255,
  279. 'size' => CRM_Utils_Type::HUGE,
  280. ) ,
  281. 'access_arguments' => array(
  282. 'name' => 'access_arguments',
  283. 'type' => CRM_Utils_Type::T_TEXT,
  284. 'title' => ts('Access Arguments') ,
  285. ) ,
  286. 'page_callback' => array(
  287. 'name' => 'page_callback',
  288. 'type' => CRM_Utils_Type::T_STRING,
  289. 'title' => ts('Page Callback') ,
  290. 'maxlength' => 255,
  291. 'size' => CRM_Utils_Type::HUGE,
  292. ) ,
  293. 'page_arguments' => array(
  294. 'name' => 'page_arguments',
  295. 'type' => CRM_Utils_Type::T_TEXT,
  296. 'title' => ts('Page Arguments') ,
  297. ) ,
  298. 'breadcrumb' => array(
  299. 'name' => 'breadcrumb',
  300. 'type' => CRM_Utils_Type::T_TEXT,
  301. 'title' => ts('Breadcrumb') ,
  302. ) ,
  303. 'return_url' => array(
  304. 'name' => 'return_url',
  305. 'type' => CRM_Utils_Type::T_STRING,
  306. 'title' => ts('Return Url') ,
  307. 'maxlength' => 255,
  308. 'size' => CRM_Utils_Type::HUGE,
  309. ) ,
  310. 'return_url_args' => array(
  311. 'name' => 'return_url_args',
  312. 'type' => CRM_Utils_Type::T_STRING,
  313. 'title' => ts('Return Url Args') ,
  314. 'maxlength' => 255,
  315. 'size' => CRM_Utils_Type::HUGE,
  316. ) ,
  317. 'component_id' => array(
  318. 'name' => 'component_id',
  319. 'type' => CRM_Utils_Type::T_INT,
  320. 'FKClassName' => 'CRM_Core_DAO_Component',
  321. ) ,
  322. 'is_active' => array(
  323. 'name' => 'is_active',
  324. 'type' => CRM_Utils_Type::T_BOOLEAN,
  325. ) ,
  326. 'is_public' => array(
  327. 'name' => 'is_public',
  328. 'type' => CRM_Utils_Type::T_BOOLEAN,
  329. ) ,
  330. 'is_exposed' => array(
  331. 'name' => 'is_exposed',
  332. 'type' => CRM_Utils_Type::T_BOOLEAN,
  333. ) ,
  334. 'is_ssl' => array(
  335. 'name' => 'is_ssl',
  336. 'type' => CRM_Utils_Type::T_BOOLEAN,
  337. ) ,
  338. 'weight' => array(
  339. 'name' => 'weight',
  340. 'type' => CRM_Utils_Type::T_INT,
  341. 'title' => ts('Weight') ,
  342. 'required' => true,
  343. 'default' => '',
  344. ) ,
  345. 'type' => array(
  346. 'name' => 'type',
  347. 'type' => CRM_Utils_Type::T_INT,
  348. 'title' => ts('Type') ,
  349. 'required' => true,
  350. 'default' => '',
  351. ) ,
  352. 'page_type' => array(
  353. 'name' => 'page_type',
  354. 'type' => CRM_Utils_Type::T_INT,
  355. 'title' => ts('Page Type') ,
  356. 'required' => true,
  357. 'default' => '',
  358. ) ,
  359. 'skipBreadcrumb' => array(
  360. 'name' => 'skipBreadcrumb',
  361. 'type' => CRM_Utils_Type::T_BOOLEAN,
  362. 'title' => ts('Skipbreadcrumb') ,
  363. ) ,
  364. );
  365. }
  366. return self::$_fields;
  367. }
  368. /**
  369. * returns the names of this table
  370. *
  371. * @access public
  372. * @return string
  373. */
  374. function getTableName()
  375. {
  376. return self::$_tableName;
  377. }
  378. /**
  379. * returns if this table needs to be logged
  380. *
  381. * @access public
  382. * @return boolean
  383. */
  384. function getLog()
  385. {
  386. return self::$_log;
  387. }
  388. /**
  389. * returns the list of fields that can be imported
  390. *
  391. * @access public
  392. * return array
  393. */
  394. function &import($prefix = false)
  395. {
  396. if (!(self::$_import)) {
  397. self::$_import = array();
  398. $fields = & self::fields();
  399. foreach($fields as $name => $field) {
  400. if (CRM_Utils_Array::value('import', $field)) {
  401. if ($prefix) {
  402. self::$_import['menu'] = & $fields[$name];
  403. } else {
  404. self::$_import[$name] = & $fields[$name];
  405. }
  406. }
  407. }
  408. }
  409. return self::$_import;
  410. }
  411. /**
  412. * returns the list of fields that can be exported
  413. *
  414. * @access public
  415. * return array
  416. */
  417. function &export($prefix = false)
  418. {
  419. if (!(self::$_export)) {
  420. self::$_export = array();
  421. $fields = & self::fields();
  422. foreach($fields as $name => $field) {
  423. if (CRM_Utils_Array::value('export', $field)) {
  424. if ($prefix) {
  425. self::$_export['menu'] = & $fields[$name];
  426. } else {
  427. self::$_export[$name] = & $fields[$name];
  428. }
  429. }
  430. }
  431. }
  432. return self::$_export;
  433. }
  434. }