Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
ipb_bridge.inc
1 <?php
18 require_once SQ_INCLUDE_PATH.'/asset.inc';
19 require_once SQ_PACKAGES_PATH.'/ipb/ipb.inc';
20 require_once SQ_CORE_PACKAGE_PATH.'/interfaces/bridge/bridge.inc';
21 
22 
35 class IPB_Bridge extends Asset implements Bridge
36 {
37 
42  var $ipb = NULL;
43 
50  var $top_categories = Array(
51  'g_0' => Array(
52  'id' => 'g_0',
53  'name' => 'All Users',
54  'description' => 'IPB User Groups',
55  'type_code' => 'ipb_user_group',
56  'list_function' => 'getListOfGroups',
57  'minor_prefix' => 'g_',
58  'minor_type_code' => 'ipb_user_group',
59  ),
60  'f_0' => Array(
61  'id' => 'f_0',
62  'name' => 'All Forums',
63  'description' => 'IPB Forums',
64  'type_code' => 'ipb_forum',
65  'list_function' => 'getListOfRootForums',
66  'minor_prefix' => 'r_',
67  'minor_type_code' => 'ipb_root_forum',
68  ),
69  'o_0' => Array(
70  'id' => 'o_0',
71  'poll_question' => 'All Polls',
72  'description' => 'IPB Polls',
73  'type_code' => 'ipb_poll',
74  'list_function' => 'getListOfPolls',
75  'minor_prefix' => 'o_',
76  'minor_type_code' => 'ipb_poll',
77  ),
78  );
79 
85  var $ipb_shdw_link_type = SQ_LINK_TYPE_1;
86 
87 
94  function IPB_Bridge($assetid=0)
95  {
96  $this->_ser_attrs = TRUE;
97  $this->Asset($assetid);
98 
99  }//end constructor
100 
101 
112  protected function _getName($short_name=FALSE, $contextid=NULL)
113  {
114  // No context specified, using the current context
115  if ($contextid === NULL) {
116  $contextid = $GLOBALS['SQ_SYSTEM']->getContextId();
117  }//end if
118 
119  // Obtain the attribute value for Name from the specified Context
120  $values = $GLOBALS['SQ_SYSTEM']->am->getAttributeValuesByName('name', $this->type(), Array($this->id), $contextid);
121  if (empty($values) === TRUE) {
122  return parent::_getName($short_name, $contextid);
123  } else {
124  return $values[$this->id];
125  }
126 
127  }//end _getName()
128 
129 
136  function &connectToIpb()
137  {
138  $location = $this->attr('location');
139  $set_location = empty($location);
140  if ($set_location) return NULL;
141 
142  if (is_null($this->ipb)) {
143  $this->ipb = new Ipb($this->attr('location'), $this->attr('version'));
144  }
145 
146  return $this->ipb;
147 
148  }//end connectToIpb()
149 
150 
157  function &getIpbConn()
158  {
159  $location = $this->attr('location');
160  $set_location = empty($location);
161  if ($set_location) {
162  $null = NULL;
163  return $null;
164  }
165 
166  if (is_null($this->ipb)) {
167  $this->ipb = new Ipb($this->attr('location'), $this->attr('version'));
168  }
169 
170  return $this->ipb;
171 
172  }//end getIpbConn()
173 
174 
175 //-- BRIDGE FUNCTIONS --//
176 
177 
192  function getAsset($shadowid, $type_code='', $mute_errors=FALSE)
193  {
194  $asset = NULL;
195 
196  $id_parts = explode(':', $shadowid);
197  if (isset($id_parts[1])) {
198  $shadowid = $id_parts[1];
199  } else {
200  return $asset;
201  }
202 
203  $ipb = $this->getIpbConn();
204  if (is_null($ipb)) return $asset;
205  $prefix = substr($shadowid, 0, 1);
206 
207  if (strlen($shadowid) == 3 && substr($shadowid, -1) == '0') {
208  // top categories
209  if ($prefix == 'g') {
210  $type_code = 'ipb_user_group';
211  $class_name = 'Ipb_User_Group';
212  } else if ($prefix == 'f') {
213  $type_code = 'ipb_forum';
214  $class_name = 'Ipb_Forum';
215  } else if ($prefix == 'o') {
216  $type_code = 'ipb_poll';
217  $class_name = 'Ipb_Poll';
218  }
219 
220  $GLOBALS['SQ_SYSTEM']->am->includeAsset($type_code);
221  $asset = new $class_name($this->id, $this->top_categories[$shadowid]);
222 
223  } else {
224  // all the other shadow assets from IPB
225  if ($prefix == 'u') {
226  $type_code = 'ipb_user';
227  $method = 'getMemberInfo';
228  $class_name = 'Ipb_User';
229 
230  } else if ($prefix == 'g') {
231  $type_code = 'ipb_user_group';
232  $method = 'getGroupInfo';
233  $class_name = 'Ipb_User_Group';
234 
235  } else if ($prefix == 'r') {
236  $type_code = 'ipb_root_forum';
237  $method = 'getRootForumInfo';
238  $class_name = 'Ipb_Root_Forum';
239 
240  } else if ($prefix == 'f') {
241  $type_code = 'ipb_forum';
242  $method = 'getForumInfo';
243  $class_name = 'Ipb_Forum';
244 
245  } else if ($prefix == 't') {
246  $type_code = 'ipb_topic';
247  $method = 'getTopicInfo';
248  $class_name = 'Ipb_Topic';
249 
250  } else if ($prefix == 'p') {
251  $type_code = 'ipb_post';
252  $method = 'getPostInfo';
253  $class_name = 'Ipb_Post';
254 
255  } else if ($prefix == 'o') {
256  $type_code = 'ipb_poll';
257  $method = 'getPollInfo';
258  $class_name = 'Ipb_Poll';
259  }
260  $GLOBALS['SQ_SYSTEM']->am->includeAsset($type_code);
261  $ipb = $this->getIpbConn();
262  eval('$data = $ipb->'.$method.'($this->id.\':\'.$shadowid);');
263 
264  $data['id'] = $shadowid;
265 
266  $asset = new $class_name($this->id, $data);
267 
268  }//end else
269  return $asset;
270 
271  }//end getAsset()
272 
273 
300  function getLinks($assetid, $link_types, $type_code='', $strict_type_code=TRUE, $side_of_link='major', $sort_by=NULL, $dependant=NULL, $exclusive=NULL)
301  {
302  $links = Array();
303 
304  // if the wanted link type is not the type of links
305  // that this bridge allows, lets return now
306  if (!($this->ipb_shdw_link_type & $link_types)) {
307  return Array();
308  }
309 
310  if ($dependant || $exclusive) {
311  return Array();
312  }
313 
314  $no_id_parts = FALSE;
315  $id_parts = explode(':', $assetid);
316  if (isset($id_parts[1])) {
317  $assetid = $id_parts[1];
318  } else {
319  $no_id_parts = TRUE;
320  }
321 
322  if (!is_array($type_code)) {
323  if (empty($type_code)) {
324  $type_code = Array();
325  } else {
326  $type_code = Array($type_code);
327  }
328  }
329 
330  // is not connected yet...
331  $ipb =& $this->getIpbConn();
332  if (is_null($ipb) || !$ipb->isConnected()) {
333  return $links;
334  }
335 
336  if (!isset($this->_tmp['getLinks'][$assetid][$side_of_link])) {
337 
338  if ($no_id_parts) {
339 
341  // Links from Ipb_Bridge
343  if ($side_of_link == 'major') {
344 
345  // major
346  foreach ($this->top_categories as $top_key => $top_data) {
347  $links[] = Array(
348  'linkid' => 0,
349  'majorid' => $this->id,
350  'minorid' => $this->id.':'.$top_key,
351  'minor_type_code' => $top_data['type_code'],
352  'value' => '',
353  'link_type' => $this->ipb_shdw_link_type,
354  'is_dependant' => FALSE,
355  'is_exclusive' => FALSE,
356  'sort_order' => 0,
357  );
358  }
359 
360  } else {
361  // minor
362  $links = $GLOBALS['SQ_SYSTEM']->am->getLinks($this->id, 'minor');
363  }
364 
365  } else if (array_key_exists($assetid, $this->top_categories)) {
366 
368  // Links from Top Categories
370  if ($side_of_link == 'major') {
371 
372  // major
373  $ipb =& $this->getIpbConn();
374  if (!$ipb->isConnected()) return $links;
375 
376  $list_function = $this->top_categories[$assetid]['list_function'];
377  $prefix = $this->top_categories[$assetid]['minor_prefix'];
378  $type_code = $this->top_categories[$assetid]['minor_type_code'];
379 
380  $list = $ipb->$list_function();
381  foreach ($list as $sub_group) {
382  $links[] = Array(
383  'linkid' => 0,
384  'majorid' => $this->id.':'.$assetid,
385  'minorid' => $this->id.':'.$prefix.$sub_group['id'],
386  'minor_type_code' => $type_code,
387  'value' => '',
388  'link_type' => $this->ipb_shdw_link_type,
389  'is_dependant' => FALSE,
390  'is_exclusive' => FALSE,
391  'sort_order' => 0,
392  );
393  }
394 
395  } else {
396 
397  // minor, link to Ipb_Bridge
398  $links[] = Array(
399  'linkid' => 0,
400  'majorid' => $this->id,
401  'major_type_code' => $this->type(),
402  'minorid' => $this->id.':'.$assetid,
403  'value' => '',
404  'link_type' => $this->ipb_shdw_link_type,
405  'is_dependant' => FALSE,
406  'is_exclusive' => FALSE,
407  'sort_order' => 0,
408  );
409  }
410 
411  } else {
412  $prefix = substr($assetid, 0, 1);
413 
415  // Links from shadow assets
417  if ($side_of_link == 'major') {
418 
419  if ($prefix == 'g') {
420 
421  // ipb_user_group => ipb_user
422  $ipb =& $this->getIpbConn();
423  $tmp = explode('_', $assetid);
424  $group_id = $tmp[1];
425  $members = $ipb->getMembers(0, $group_id);
426  foreach ($members as $key => $data) {
427  $links[] = Array(
428  'linkid' => 0,
429  'majorid' => $this->id.':'.$assetid,
430  'minorid' => $this->id.':'.$key,
431  'minor_type_code' => 'ipb_user',
432  'value' => '',
433  'link_type' => $this->ipb_shdw_link_type,
434  'is_dependant' => FALSE,
435  'is_exclusive' => FALSE,
436  'sort_order' => 0,
437  );
438  }
439 
440  } else if ($prefix == 'u') {
441 
442  // ipb_user => NONE
443  $links = Array();
444 
445  } else if ($prefix == 'r') {
446 
447  // ipb_root_forum => ipb_forum
448  $ipb =& $this->getIpbConn();
449  $list_of_topics = $ipb->getListOfForums($assetid);
450  foreach ($list_of_topics as $topic) {
451  $links[] = Array(
452  'linkid' => 0,
453  'majorid' => $this->id.':'.$assetid,
454  'minorid' => $this->id.':f_'.$topic['id'],
455  'minor_type_code' => 'ipb_forum',
456  'value' => '',
457  'link_type' => $this->ipb_shdw_link_type,
458  'is_dependant' => FALSE,
459  'is_exclusive' => FALSE,
460  'sort_order' => 0,
461  );
462  }
463 
464  } else if ($prefix == 'f') {
465 
466  // ipb_forum => ipb_topic
467  $ipb =& $this->getIpbConn();
468  $list_of_topics = $ipb->getListOfTopics($assetid);
469  foreach ($list_of_topics as $topic) {
470  $links[] = Array(
471  'linkid' => 0,
472  'majorid' => $this->id.':'.$assetid,
473  'minorid' => $this->id.':t_'.$topic['id'],
474  'minor_type_code' => 'ipb_topic',
475  'value' => '',
476  'link_type' => $this->ipb_shdw_link_type,
477  'is_dependant' => FALSE,
478  'is_exclusive' => FALSE,
479  'sort_order' => 0,
480  );
481 
482  }
483 
484  } else if ($prefix == 't') {
485 
486  // ipb_forum => ipb_topic
487  $ipb =& $this->getIpbConn();
488  $list_of_posts = $ipb->getListOfPosts($assetid);
489  foreach ($list_of_posts as $post) {
490  $links[] = Array(
491  'linkid' => 0,
492  'majorid' => $this->id.':'.$assetid,
493  'minorid' => $this->id.':p_'.$post['id'],
494  'minor_type_code' => 'ipb_post',
495  'value' => '',
496  'link_type' => $this->ipb_shdw_link_type,
497  'is_dependant' => FALSE,
498  'is_exclusive' => FALSE,
499  'sort_order' => 0,
500  );
501  }
502 
503  }
504 
505  } else {
506 
507  // minor
508  $links = Array(
509  'linkid' => 0,
510  'value' => '',
511  'link_type' => $this->ipb_shdw_link_type,
512  'is_dependant' => FALSE,
513  'is_exclusive' => FALSE,
514  'sort_order' => 0,
515  );
516 
517  if ($prefix == 'g') {
518 
519  // ipb_user_group => ipb_all_users
520  $links['majorid'] = $this->id.':'.'g_0';
521  $links['major_type_code'] = 'ipb_all_users';
522  $links['minorid'] = $this->id.':'.$assetid;
523 
524  } else if ($prefix == 'u') {
525 
526  // ipb_user => ipb_user_group
527  $ipb =& $this->getIpbConn();
528  $tmp = explode('_', $assetid);
529  $user_id = $tmp[1];
530  $group = $ipb->getMembers($user_id);
531  $links['majorid'] = $this->id.':g_'.$group['mgroup'];
532  $links['major_type_code'] = 'ipb_user_group';
533  $links['minorid'] = $this->id.':'.$assetid;
534 
535  } else if ($prefix == 'r') {
536 
537  // ipb_root_forum => ipb_forum (Category)
538  $links['majorid'] = $this->id.':'.'f_0';
539  $links['major_type_code'] = 'ipb_forum';
540  $links['minorid'] = $this->id.':'.$assetid;
541 
542  } else if ($prefix == 'f') {
543 
544  // ipb_forum => ipb_root_forum
545  $ipb =& $this->getIpbConn();
546  $forum_info = $ipb->getForumInfo($this->id.':'.$assetid);
547  $links['majorid'] = $this->id.':'.'r_'.$forum_info['parent_id'];
548  $links['major_type_code'] = 'ipb_root_forum';
549  $links['minorid'] = $this->id.':'.$assetid;
550 
551  } else if ($prefix == 't') {
552 
553  // ipb_topic => ipb_forum
554  $ipb =& $this->getIpbConn();
555  $forum_info = $ipb->getTopicInfo($this->id.':'.$assetid);
556  $links['majorid'] = $this->id.':'.'f_'.$forum_info['forum_id'];
557  $links['major_type_code'] = 'ipb_forum';
558  $links['minorid'] = $this->id.':'.$assetid;
559 
560  } else if ($prefix == 'p') {
561  // ipb_topic => ipb_forum
562  $ipb =& $this->getIpbConn();
563  $forum_info = $ipb->getPostInfo($this->id.':'.$assetid);
564  $links['majorid'] = $this->id.':'.'t_'.$forum_info['tid'];
565  $links['major_type_code'] = 'ipb_topic';
566  $links['minorid'] = $this->id.':'.$assetid;
567 
568  } else {
569  $links = Array();
570  }
571 
572  }//end else
573 
574  }//end else
575 
576  // put in $_tmp
577  $this->_tmp['getLinks'][$assetid][$side_of_link] = $links;
578 
579  }//end if
580 
581  return $this->_tmp['getLinks'][$assetid][$side_of_link];
582 
583  }//end getLinks()
584 
585 
599  function getParents($assetid, $type_code='', $strict_type_code=TRUE)
600  {
601  $no_id_parts = FALSE;
602  $id_parts = explode(':', $assetid);
603  if (isset($id_parts[1])) {
604  $assetid = $id_parts[1];
605  } else {
606  $no_id_parts = TRUE;
607  }
608 
609  if (!is_array($type_code)) {
610  if (empty($type_code)) {
611  $type_code = Array();
612  } else {
613  $type_code = Array($type_code);
614  }
615  }
616 
617  if (!isset($this->_tmp['getParents'][$assetid])) {
618 
619  $prefix = substr($assetid, 0, 1);
620  if (array_key_exists($assetid, $this->top_categories)) {
621  // nothing. top level
622  $parents = Array();
623  } else if ($prefix == 'g' || $prefix == 'r' || $prefix == 'o' ) {
624 
626  // Right Under Top Categories
628  switch ($prefix) {
629  case 'g' :
630  $parents[$id_parts[0].':'.$prefix.'_0'] = 'ipb_user_group';
631  break;
632  case 'r' :
633  $parents[$id_parts[0].':'.'f_0'] = 'ipb_forum';
634  break;
635  case 'o' :
636  $parents[$id_parts[0].':'.$prefix.'_0'] = 'ipb_poll';
637  break;
638  }
639 
640  } else {
641 
642  $ipb =& $this->getIpbConn();
643  if ($prefix == 'u') {
644  // IPB USER
645  $parents[$id_parts[0].':'.'g_0'] = 'ipb_user_group';
646  $result = $ipb->getMemberParent($id_parts[0].':'.$assetid);
647  $parents[$id_parts[0].':'.'g_'.$result['mgroup']] = 'ipb_user_group';
648 
649  } else if ($prefix == 'f') {
650  // IPB FORUM
651  $parents[$id_parts[0].':'.'f_0'] = 'ipb_forum';
652  $result = $ipb->getForumParent($id_parts[0].':'.$assetid);
653  $parents[$id_parts[0].':'.'r_'.$result['parent_id']] = 'ipb_root_forum';
654 
655  } else if ($prefix == 't') {
656  // IPB TOPIC
657  $parents[$id_parts[0].':'.'f_0'] = 'ipb_forum';
658  $result = $ipb->getTopicParent($id_parts[0].':'.$assetid);
659  $parents[$id_parts[0].':'.'r_'.$result['parent_id']] = 'ipb_root_forum';
660  $parents[$id_parts[0].':'.'f_'.$result['forum_id']] = 'ipb_forum';
661 
662  } else if ($prefix == 'p') {
663  // IPB POST
664  $parents[$id_parts[0].':'.'f_0'] = 'ipb_forum';
665  $result = $ipb->getPostParent($id_parts[0].':'.$assetid);
666  $parents[$id_parts[0].':'.'r_'.$result['parent_id']] = 'ipb_root_forum';
667  $parents[$id_parts[0].':'.'f_'.$result['forum_id']] = 'ipb_forum';
668  $parents[$id_parts[0].':'.'t_'.$result['topic_id']] = 'ipb_topic';
669  }
670 
671  }//end else
672  $this->_tmp['getParents'][$assetid] = $parents;
673 
674  }//end if
675 
676  return $this->_tmp['getParents'][$assetid];
677 
678  }//end getParents()
679 
680 
701  function getChildren($assetid, $type_code='', $strict_type_code=TRUE, $dependant=NULL, $sort_by=NULL)
702  {
703  $children = Array();
704  $id_parts = explode(':', $assetid);
705  if (isset($id_parts[1])) {
706  $assetid = $id_parts[1];
707  } else {
708  $links = $this->getLinks($assetid, SQ_LINK_TYPE_1, '', TRUE, 'major');
709  foreach ($links as $link) {
710  if (empty($type_code) || (!empty($type_code) && (array_search($link['minor_type_code'], $type_code) !== FALSE))) {
711  $children[$link['minorid']] = $link['minor_type_code'];
712  }
713  $children = array_merge($children, $this->getChildren($link['minorid'], $type_code, $strict_type_code, $dependant, $sort_by));
714  }
715  return $children;
716  }
717 
718  if (!is_array($type_code)) {
719  if (empty($type_code)) {
720  $type_code = Array();
721  } else {
722  $type_code = Array($type_code);
723  }
724  }
725  $no_type_code = empty($type_code);
726 
727  if (!isset($this->_tmp['getChildren'][$assetid])) {
728  // ipb_user, no children
729  $prefix = substr($assetid, 0, 1);
730  $suffix = substr($assetid, -1);
731  $is_top_category = strlen($assetid) == 3 && $suffix == '0';
732 
733  $ipb =& $this->getIpbConn();
734  if ($prefix == 'g') {
735  if ($is_top_category) {
736  // all groups + all users
737  $all_groups = Array();
738  $all_members = Array();
739  $add_user_group = (array_search('ipb_user_group', $type_code) !== FALSE);
740  $add_user = (array_search('ipb_user', $type_code) !== FALSE);
741  if ($no_type_code || (!$no_type_code && $add_user_group)) {
742  $all_groups = $ipb->getListOfGroups();
743  }
744  if ($no_type_code || (!$no_type_code && $add_user)) {
745  $all_members = $ipb->getListOfMembers();
746  }
747 
748  foreach ($all_groups as $group) {
749  $children[$this->id.':g_'.$group['g_id']] = 'ipb_user_group';
750  }
751  foreach ($all_members as $member) {
752  $children[$this->id.':u_'.$member['id']] = 'ipb_user';
753  }
754  } else {
755  // all users of the one group
756  $tmp = explode('_', $assetid);
757  $group_members = Array();
758  $add_user = (array_search('ipb_user', $type_code) !== FALSE);
759  if ($no_type_code || (!$no_type_code && $add_user)) {
760  $group_members = $ipb->getListOfMembers($this->id.':'.$assetid);
761  }
762  foreach ($group_members as $member) {
763  $children[$this->id.':u_'.$member['id']] = 'ipb_user';
764  }
765  }
766 
767  } else if ($prefix == 'f') {
768  if ($is_top_category) {
769  if ($no_type_code) {
770  // no type code specified
771  $all_root_forums = $ipb->getListOfRootForums();
772  foreach ($all_root_forums as $root_forum) {
773  $children[$this->id.':r_'.$root_forum['id']] = 'ipb_root_forum';
774 
775  $all_forums = $ipb->getListOfForums('f_'.$root_forum['id']);
776  foreach ($all_forums as $forum) {
777  $children[$this->id.':f_'.$forum['id']] = 'ipb_forum';
778 
779  $all_topics = $ipb->getListOfTopics('f_'.$forum['id']);
780  foreach ($all_topics as $topic) {
781  $children[$this->id.':t_'.$topic['id']] = 'ipb_topic';
782 
783  $all_posts = $ipb->getListOfPosts('t_'.$topic['id']);
784  foreach ($all_posts as $post) {
785  $children[$this->id.':p_'.$post['id']] = 'ipb_post';
786  }
787  }
788  }
789  }
790  } else {
791  // type code specified
792  $add_ipb_root_forum = (array_search('ipb_root_forum', $type_code) !== FALSE);
793  $add_ipb_forum = (array_search('ipb_forum', $type_code) !== FALSE);
794  $add_ipb_topic = (array_search('ipb_topic', $type_code) !== FALSE);
795  $add_ipb_post = (array_search('ipb_post', $type_code) !== FALSE);
796 
797  $all_root_forums = $ipb->getListOfRootForums();
798  foreach ($all_root_forums as $root_forum) {
799  if ($add_ipb_root_forum) {
800  $children[$this->id.':r_'.$root_forum['id']] = 'ipb_root_forum';
801  }
802  if ($strict_type_code && !$add_ipb_forum && !$add_ipb_topic && !$add_ipb_post) {
803  continue;
804  } else {
805  $all_forums = $ipb->getListOfForums('f_'.$root_forum['id']);
806  foreach ($all_forums as $forum) {
807  if ($add_ipb_forum) {
808  $children[$this->id.':f_'.$forum['id']] = 'ipb_forum';
809  }
810  if ($strict_type_code && !$add_ipb_topic && !$add_ipb_post) {
811  continue;
812  } else {
813  $all_topics = $ipb->getListOfTopics('f_'.$forum['id']);
814  foreach ($all_topics as $topic) {
815  if ($add_ipb_topic) {
816  $children[$this->id.':t_'.$topic['id']] = 'ipb_topic';
817  }
818  if ($strict_type_code && !$add_ipb_post) {
819  continue;
820  } else {
821  $all_posts = $ipb->getListOfPosts('t_'.$topic['id']);
822  foreach ($all_posts as $post) {
823  if ($add_ipb_post) {
824  $children[$this->id.':p_'.$post['id']] = 'ipb_post';
825  }
826  }
827  }
828  }
829  }
830  }
831  }
832  }//end foreach
833  }//end else
834  } else {
835  if ($no_type_code) {
836  // topics + posts
837  $all_topics = $ipb->getListOfTopics($assetid);
838  foreach ($all_topics as $topic) {
839  $children[$this->id.':t_'.$topic['id']] = 'ipb_topic';
840 
841  $all_posts = $ipb->getListOfPosts('t_'.$topic['id']);
842  foreach ($all_posts as $post) {
843  $children[$this->id.':p_'.$post['id']] = 'ipb_post';
844  }
845  }
846  } else {
847  $add_ipb_topic = (array_search('ipb_topic', $type_code) !== FALSE);
848  $add_ipb_post = (array_search('ipb_post', $type_code) !== FALSE);
849  if ($strict_type_code && !$add_ipb_topic && !$add_ipb_post) {
850  ;
851  } else {
852  $all_topics = $ipb->getListOfTopics($assetid);
853  foreach ($all_topics as $topic) {
854  if ($add_ipb_topic) {
855  $children[$this->id.':t_'.$topic['id']] = 'ipb_topic';
856  }
857  if ($strict_type_code && !$add_ipb_post) {
858  ;
859  } else {
860  $all_posts = $ipb->getListOfPosts('t_'.$topic['id']);
861  foreach ($all_posts as $post) {
862  if ($add_ipb_post) {
863  $children[$this->id.':p_'.$post['id']] = 'ipb_post';
864  }
865  }
866  }
867  }
868  }
869  }
870  }//end else
871 
872  } else if ($prefix == 'r') {
873  if ($no_type_code) {
874  // forums + topics + posts
875  $all_forums = $ipb->getListOfForums($assetid);
876  foreach ($all_forums as $forum) {
877  $children[$this->id.':f_'.$forum['id']] = 'ipb_forum';
878 
879  $all_topics = $ipb->getListOfTopics('f_'.$forum['id']);
880  foreach ($all_topics as $topic) {
881  $children[$this->id.':t_'.$topic['id']] = 'ipb_topic';
882 
883  $all_posts = $ipb->getListOfPosts('t_'.$topic['id']);
884  foreach ($all_posts as $post) {
885  $children[$this->id.':p_'.$post['id']] = 'ipb_post';
886  }
887  }
888  }
889  } else {
890  // forums + topics + posts
891  // type code specified
892  $add_ipb_forum = (array_search('ipb_forum', $type_code) !== FALSE);
893  $add_ipb_topic = (array_search('ipb_topic', $type_code) !== FALSE);
894  $add_ipb_post = (array_search('ipb_post', $type_code) !== FALSE);
895  if ($strict_type_code && !$add_ipb_forum && !$add_ipb_topic && !$add_ipb_post) {
896  ;
897  } else {
898  $all_forums = $ipb->getListOfForums($assetid);
899  foreach ($all_forums as $forum) {
900  if ($add_ipb_forum) {
901  $children[$this->id.':f_'.$forum['id']] = 'ipb_forum';
902  }
903  if ($strict_type_code && !$add_ipb_topic && !$add_ipb_post) {
904  continue;
905  } else {
906  $all_topics = $ipb->getListOfTopics('f_'.$forum['id']);
907  foreach ($all_topics as $topic) {
908  if ($add_ipb_topic) {
909  $children[$this->id.':t_'.$topic['id']] = 'ipb_topic';
910  }
911  if ($strict_type_code && !$add_ipb_post) {
912  continue;
913  } else {
914  $all_posts = $ipb->getListOfPosts('t_'.$topic['id']);
915  foreach ($all_posts as $post) {
916  if ($add_ipb_post) {
917  $children[$this->id.':p_'.$post['id']] = 'ipb_post';
918  }
919  }
920  }
921  }
922  }
923  }
924  }
925  }//end else
926 
927  } else if ($prefix == 't') {
928  // posts
929  if ($no_type_code) {
930  $all_posts = $ipb->getListOfPosts($assetid);
931  foreach ($all_posts as $post) {
932  $children[$this->id.':p_'.$post['id']] = 'ipb_post';
933  }
934  } else {
935  $add_ipb_post = (array_search('ipb_post', $type_code) !== FALSE);
936  if ($strict_type_code && !$add_ipb_post) {
937  ;
938  } else {
939  $all_posts = $ipb->getListOfPosts($assetid);
940  foreach ($all_posts as $post) {
941  if ($add_ipb_post) {
942  $children[$this->id.':p_'.$post['id']] = 'ipb_post';
943  }
944  }
945  }
946  }
947 
948  } else if ($prefix == 'o') {
949  // polls
950  if ($is_top_category) {
951  if ($no_type_code) {
952  $all_polls = $ipb->getListOfPolls();
953  foreach ($all_polls as $poll) {
954  $children[$this->id.':o_'.$poll['id']] = 'ipb_poll';
955  }
956  } else {
957  $add_ipb_poll = (array_search('ipb_poll', $type_code) !== FALSE);
958  if ($strict_type_code && !$add_ipb_poll) {
959  ;
960  } else {
961  $all_polls = $ipb->getListOfPolls();
962  foreach ($all_polls as $poll) {
963  if ($add_ipb_poll) {
964  $children[$this->id.':o_'.$poll['id']] = 'ipb_poll';
965  }
966  }
967  }
968  }
969  }
970  }
971 
972  $this->_tmp['getChildren'][$assetid] = $children;
973 
974  }//end if
975 
976  return $this->_tmp['getChildren'][$assetid];
977 
978  }//end getChildren()
979 
980 
991  function getLineageFromURL($assetid, $protocol, $url)
992  {
993  $lineage = Array();
994 
995  $shadow_ids = explode(',', $assetid);
996  foreach ($shadow_ids as $id) {
997  $asset =& $this->getAsset($this->id.':'.$id);
998  $url = substr($asset->getURL(), strlen(current_protocol()) +3);
999  $lineage[] = Array (
1000  'url' => $url,
1001  'assetid' => $this->id.':'.$id,
1002  'name' => $asset->name,
1003  'short_name' => $asset->short_name,
1004  'type_code' => $asset->type(),
1005  'link_type' => SQ_LINK_TYPE_1,
1006  'protocol' => current_protocol(),
1007  );
1008 
1009  }
1010  return array_reverse($lineage);
1011 
1012  }//end getLineageFromURL()
1013 
1014 
1029  function getAssetInfo($assetids, $type_code=Array(), $strict_type_code=TRUE, $field='')
1030  {
1031  $info = Array();
1032  foreach ($assetids as $assetid) {
1033  $asset =& $this->getAsset($assetid);
1034 
1035  if (!empty($field)) {
1036  if ($field == 'assetid') {
1037  $info[$assetid] = $assetid;
1038  } else if ($field == 'type_code') {
1039  $info[$assetid] = $asset->type();
1040  } else if (in_array($field , Array('version', 'name', 'short_name', 'status'))) {
1041  $info[$assetid] = $asset->$field;
1042  } else {
1043  $info[$assetid] = $this->$field;
1044  }
1045  } else {
1046  $info[$assetid] = Array(
1047  'assetid' => $assetid,
1048  'type_code' => $asset->type(),
1049  'version' => $asset->version,
1050  'name' => $asset->name,
1051  'short_name' => $asset->short_name,
1052  'status' => $asset->status,
1053  'languages' => $this->languages,
1054  'charset' => $this->charset,
1055  'force_secure' => $this->force_secure,
1056  'created' => $this->created,
1057  'created_userid' => $this->created_userid,
1058  'updated' => $this->updated,
1059  'updated_userid' => $this->updated_userid,
1060  'published' => $this->published,
1061  'published_userid' => $this->published_userid,
1062  'status_changed' => $this->status_changed,
1063  'status_changed_userid' => $this->status_changed_userid,
1064  );
1065  }
1066 
1067  }//end foreach
1068 
1069  return $info;
1070 
1071  }//end getAssetInfo()
1072 
1073 
1074 //-- EMPTY FUNCTIONS --//
1075 
1076 
1088  function assetExists($assetids)
1089  {
1090  return FALSE;
1091 
1092  }//end assetExists()
1093 
1094 
1116  function getLink($assetid, $link_type=NULL, $type_code='', $strict_type_code=TRUE, $value=NULL, $side_of_link='major', $exclusive=NULL)
1117  {
1118  return Array();
1119 
1120  }//end getLink()
1121 
1122 
1134  function getLinkById($linkid, $assetid=0, $side_of_link='major')
1135  {
1136  return Array();
1137 
1138  }//end getLinkById()
1139 
1140 
1162  function countLinks($assetid, $side_of_link='major', $link_types=0, $type_code='', $strict_type_code=TRUE, $ignore_linkid=0)
1163  {
1164  return 0;
1165 
1166  }//end countLinks()
1167 
1168 
1189  function getLinkByAsset($assetid, $other_assetid, $link_types=NULL, $value=NULL, $side_of_link='major', $force_array=FALSE, $dependant=NULL, $exclusive=NULL)
1190  {
1191  return Array();
1192 
1193  }//end getLinkByAsset()
1194 
1195 
1205  function getAllChildLinks($assetid, $link_type=0)
1206  {
1207  return Array();
1208 
1209  }//end getAllChildLinks()
1210 
1211 
1226  function updateLink($linkid, $link_type=NULL, $value=NULL, $sort_order=NULL)
1227  {
1228  return FALSE;
1229 
1230  }//end updateLink()
1231 
1232 
1242  function deleteAssetLink($linkid, $moving=FALSE)
1243  {
1244  return FALSE;
1245 
1246  }//end deleteAssetLink()
1247 
1248 
1261  function canCreateLink(&$major, &$minor, $link_type, $exclusive)
1262  {
1263  return FALSE;
1264 
1265  }//end canCreateLink()
1266 
1267 
1284  function createAssetLink(&$major, &$minor, $link_type, $value='', $sort_order=NULL, $dependant='0', $exclusive='0', $moving=FALSE)
1285  {
1286  return 0;
1287 
1288  }//end createAssetLink()
1289 
1290 
1311  function getPermission($assetid, $permission, $granted=NULL, $and_greater=TRUE, $expand_groups=FALSE, $all_info=FALSE)
1312  {
1313  return Array();
1314 
1315  }//end getPermission()
1316 
1317 
1329  function setPermission($assetid, $userid, $permission, $granted)
1330  {
1331  return FALSE;
1332 
1333  }//end setPermission()
1334 
1335 
1346  function deletePermission($assetid, $userid, $permission)
1347  {
1348  return FALSE;
1349 
1350  }//end deletePermission()
1351 
1352 
1361  function getAssetMapAssetInfo($assetid)
1362  {
1363  return Array();
1364 
1365  }//end getAssetMapAssetInfo()
1366 
1367 }//end class
1368 
1369 ?>