PageRenderTime 35ms CodeModel.GetById 7ms RepoModel.GetById 1ms app.codeStats 0ms

/src/administrator/components/com_jnewsletter/classes/class.listype.php

http://kak.googlecode.com/
PHP | 342 lines | 298 code | 33 blank | 11 comment | 48 complexity | 1097f59c01d189c44c38df3a0bd267fa MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  1. <?php
  2. defined('_JEXEC') OR die('Access Denied!');
  3. ### Copyright (C) 2006-2010 Joobi Limited. All rights reserved.
  4. ### License: GNU/GPL version 2 http://www.gnu.org/licenses/gpl-2.0.html
  5. class lisType {
  6. function chooseType($task, $action, $listType , $actionType, $message='', $title='') {
  7. //css injection
  8. $mainPath = JNEWS_PATH_ADMIN_IMAGES.'header/';
  9. $doc =& JFactory::getDocument();
  10. $css = '.icon-48-newsletter { background-image:url('.$mainPath .'newsletter.png)}';
  11. $css .= '.icon-48-autoresponder { background-image:url('.$mainPath .'autoresponder.png)}';
  12. $css .= '.icon-48-smartnewsletter { background-image:url('.$mainPath .'smartnewsletter.png)}';
  13. $doc->addStyleDeclaration($css, $type = 'text/css');
  14. $results = '';
  15. switch ($actionType) {
  16. case 'titles':
  17. if ($listType>0) {
  18. $results = $title._JNEWS_ALL.' '.@constant( $GLOBALS[JNEWS.'listnames'.$listType] );
  19. } else {
  20. $results = _JNEWS_MAILING_ALL;
  21. }
  22. break;
  23. case 'mailing_header':
  24. if ($listType>0) {
  25. backHTML::_header( @constant( $GLOBALS[JNEWS.'listnames'.$listType] ) , $GLOBALS[JNEWS.'listlogo'.$listType] , $message , $task, $action );
  26. } else {
  27. backHTML::_header( _JNEWS_MAILING_ALL , 'newsletter.png' , $message , $task, $action );
  28. }
  29. break;
  30. case 'mailing_edit_header':
  31. backHTML::_header( _JNEWS_EDIT_A.@constant( $GLOBALS[JNEWS.'listname'.$listType] ) , 'newsletter' , $message, $task, $action );
  32. break;
  33. default:
  34. $results = 'not prossible case , or not yet implemented';
  35. break;
  36. }
  37. return $results;
  38. }
  39. function sendType($lisType) {
  40. if ($lisType==1) {
  41. return true;
  42. } else {
  43. return false;
  44. }
  45. }
  46. function getListsDropList($listId, $listType, $order) {
  47. $lists = '';
  48. $lists[0]->list_name = _JNEWS_SEL_ALL_SUB;
  49. $lists[0]->id = 0;
  50. $lt = array_merge( $lists, lists::getLists(0, $listType, 1,$order, false, false, true));
  51. return $lt;
  52. }
  53. function getMailingDropList($listId, $listType, $order) {
  54. $lists = '';
  55. $i=0;
  56. $flag = array();
  57. $lists[0]->name = _JNEWS_SEL_ALL ;
  58. $lists[0]->id = '0-0';
  59. $nb = explode(',', $GLOBALS[JNEWS.'activelist']);
  60. $size = sizeof($nb);
  61. for($k = 0; $k < $size; $k ++) {
  62. $index = $nb[$k];
  63. if ($listType==$index OR ($GLOBALS[JNEWS.'listype'.$index] ==1 AND $GLOBALS[JNEWS.'totallist'.$index] >0)) {
  64. $i++;
  65. $lists[$i]->name = _JNEWS_ALL.' '.@constant( $GLOBALS[JNEWS.'listnames'.$index] );
  66. $lists[$i]->id = $index.'-0';
  67. $flag[$index] = 0;
  68. }
  69. }
  70. if ($listId>0) {
  71. $i++;
  72. $getList = lists::getLists($listId, 0, 1, $order, false, false, true);
  73. $lists[$i]->name = $getList[0]->list_name;
  74. $lists[$i]->id = $getList[0]->list_type.'-'.$getList[0]->id;
  75. } else {
  76. if ($listType==0) {
  77. $getLists = lists::getLists(0, 0, 1, 'listype_name', false, false, false);
  78. } else {
  79. $getLists = lists::getLists(0, $listType, 1, $order, false, false, false);
  80. }
  81. foreach ($getLists as $getList) {
  82. $size = sizeof($nb);
  83. for($k = 0; $k < $size; $k ++) {
  84. $index = $nb[$k];
  85. if ($getList->list_type == $index AND !$flag[$index] AND $GLOBALS[JNEWS.'listype'.$index] ==1 AND $GLOBALS[JNEWS.'totallist'.$index] > 0) {
  86. $i++;
  87. $lists[$i]->name = '-- '.@constant( $GLOBALS[JNEWS.'listnames'.$index] ).' --';
  88. $lists[$i]->id = $index.'-0';
  89. $flag[$index] = true;
  90. }
  91. }
  92. if ($GLOBALS[JNEWS.'listype'.$getList->list_type]) {
  93. $i++;
  94. $lists[$i]->name = $getList->list_name;
  95. $lists[$i]->id = $getList->list_type.'-'.$getList->id;
  96. }
  97. }
  98. }
  99. return $lists;
  100. }
  101. function showType($listType , $screen) {
  102. switch ($screen) {
  103. case 'editmailing':
  104. if (class_exists($GLOBALS[JNEWS.'classes'.$listType])) {
  105. $view = new $GLOBALS[JNEWS.'classes'.$listType];
  106. $show = $view->editmailing();
  107. } else {
  108. $show['sender_info'] = true;
  109. $show['published'] = true;
  110. $show['pub_date'] = true;
  111. $show['hide'] = true;
  112. $show['issuenb'] = true;
  113. $show['delay'] = false;
  114. $show['htmlcontent'] = true;
  115. $show['textcontent'] = true;
  116. $show['attachement'] = true;
  117. $show['auto_option'] = true;
  118. $show['images'] = true;
  119. $show['sitecontent'] = true;
  120. $show['admin'] = true;
  121. }
  122. break;
  123. case 'editlist':
  124. $show['access'] = ( $GLOBALS[JNEWS.'type'] =='PRO' ) ? true : false;
  125. if (class_exists($GLOBALS[JNEWS.'classes'.$listType])) {
  126. $view = new $GLOBALS[JNEWS.'classes'.$listType];
  127. $show = array_merge($show, $view->editlist());
  128. } else {
  129. $show['sender_info'] = true;
  130. $show['hide'] = true;
  131. $show['auto_option'] = true;
  132. $show['htmlmailing'] = true;
  133. $show['auto_subscribe'] = true;
  134. $show['email_unsubcribe'] = false;
  135. $show['unsusbcribe'] = false;
  136. }
  137. break;
  138. case 'showMailings':
  139. $show['admin'] = jnewsletter::checkPermissions('admin');
  140. $show['index'] = 'index2';
  141. $show['buttons'] = false;
  142. if ($show['admin']) {
  143. if(empty($listType)) $listType =1;
  144. if (class_exists($GLOBALS[JNEWS.'classes'.$listType])) {
  145. $view = new $GLOBALS[JNEWS.'classes'.$listType];
  146. $show = array_merge($show, $view->showMailings());
  147. } else {
  148. $show['id'] = true;
  149. $show['dropdown'] = true;
  150. $show['select'] = true;
  151. $show['issue'] = true;
  152. $show['sentdate'] = true;
  153. $show['delay'] = false;
  154. $show['status'] = true;
  155. }
  156. } else {
  157. $show['id'] = false;
  158. $show['dropdown'] = false;
  159. $show['select'] = false;
  160. $show['issue'] = true;
  161. $show['sentdate'] = true;
  162. $show['delay'] = false;
  163. $show['status'] = false;
  164. }
  165. break;
  166. case 'showListsBack':
  167. if (jnewsletter::checkPermissions('admin')) $show['id'] = true; else $show['id'] = false;
  168. $show['index'] = 'index2';
  169. $show['select'] = true;
  170. $show['published'] = true;
  171. $show['sender'] = true;
  172. $show['sender_email'] = false;
  173. $show['mailings_link'] = true;
  174. $show['mailings_sub'] = true;
  175. $show['list_type'] = true;
  176. $show['visible'] = true;
  177. $show['color'] = true;
  178. $show['buttons'] = false;
  179. $show['front'] = false;
  180. break;
  181. case 'showListsFront':
  182. if (jnewsletter::checkPermissions('admin')) {
  183. $show['id'] = true;
  184. $show['published'] = true;
  185. $show['sender'] = true;
  186. $show['sender_email'] = false;
  187. $show['list_type'] = true;
  188. $show['visible'] = true;
  189. $show['mailings_sub'] = false;
  190. $show['color'] = true;
  191. $show['mailings_link'] = true;
  192. $show['front'] = true;
  193. } else {
  194. $show['id'] = false;
  195. $show['published'] = false;
  196. $show['sender'] = false;
  197. $show['sender_email'] = false;
  198. $show['list_type'] = false;
  199. $show['visible'] = false;
  200. $show['mailings_sub'] = false;
  201. $show['mailings_link'] = false;
  202. $show['color'] = false;
  203. $show['front'] = true;
  204. }
  205. $show['index'] = 'index';
  206. $show['select'] = false;
  207. $show['buttons'] = true;
  208. break;
  209. default:
  210. $show ='';
  211. break;
  212. }
  213. return $show;
  214. }
  215. function checkOthers() {
  216. $status = false;
  217. $nb = explode(',', $GLOBALS[JNEWS.'activelist']);
  218. $size = sizeof($nb);
  219. for($k = 0; $k < $size; $k ++) {
  220. $index = $nb[$k];
  221. if ($GLOBALS[JNEWS.'listype'.$index] ==1 AND $index!=1 ) {
  222. $status = true;
  223. }
  224. }
  225. return $status;
  226. }
  227. function getQueue($lisType) {
  228. if (class_exists($GLOBALS[JNEWS.'classes'.$lisType])) {
  229. $view = new $GLOBALS[JNEWS.'classes'.$lisType];
  230. return $view->getQueue();
  231. } else {
  232. return ' AND `published`= 1 ';
  233. }
  234. }
  235. /* Function that will return the available List Types
  236. * @param int $type
  237. * @param boolean $setDefault - set to true if you want to have a default Value 'All'
  238. - if its used as dropdown value so we need to set a default value for it
  239. * @return $list_option - object array of list types
  240. */
  241. function getListOption( $type=1, $setDefault=false )
  242. {
  243. $lists_option='';
  244. if( $type == 1 )
  245. {
  246. $flag = false;
  247. $nb = explode(',', $GLOBALS[JNEWS.'activelist']);
  248. $size = sizeof($nb);
  249. for($i = 0; $i < $size; $i ++) {
  250. $index = $nb[$i];
  251. if ($index==2) $flag = true;
  252. if ($GLOBALS[JNEWS.'listshow'.$index]>0 AND $GLOBALS[JNEWS.'listype'.$index] == 1) {
  253. $dont = true;
  254. if ($dont) {
  255. $obj = new stdClass;
  256. $obj->value = $index;
  257. $obj->text = trim( $GLOBALS[JNEWS.'listname'.$index] ) ? @constant( $GLOBALS[JNEWS.'listname'.$index] ): '';
  258. $obj->dis = false;
  259. $lists_option[] = $obj;
  260. }
  261. }
  262. }
  263. if ( !$flag ) {
  264. $obj = new stdClass;
  265. $obj->value = 2;
  266. $obj->text = _JNEWS_AUTORESP;
  267. $obj->dis = true;
  268. $lists_option[] = $obj;
  269. }
  270. }
  271. else
  272. {
  273. if( $setDefault )
  274. {
  275. $obj = new stdClass;
  276. $obj->value = 0;
  277. $obj->text = _JNEWS_ALL;
  278. $obj->dis = false;
  279. $lists_option[] = $obj;
  280. }//endif
  281. // create names
  282. $values = array( '1'=> ''._JNEWS_LIST );
  283. // set to picklist
  284. foreach( $values as $key=>$value )
  285. {
  286. $obj = new stdClass;
  287. $obj->value = $key;
  288. $obj->text = $value;
  289. $obj->dis = false;
  290. $lists_option[] = $obj;
  291. } //endforeach
  292. }//endif
  293. return $lists_option;
  294. }
  295. function sendLogs($listType) {
  296. switch ($listType) {
  297. case '1':
  298. case '7':
  299. return true;
  300. break;
  301. case '2':
  302. if ($GLOBALS[JNEWS.'send_auto_log'] == 1) return true; else return false;
  303. break;
  304. default:
  305. return false;
  306. break;
  307. }
  308. }
  309. } //endclass