選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

example_addressbook_backend.php 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * Example backend class for a custom address book
  4. *
  5. * This one just holds a static list of address records
  6. *
  7. * @author Thomas Bruederli
  8. */
  9. class example_addressbook_backend extends rcube_addressbook
  10. {
  11. public $primary_key = 'ID';
  12. public $readonly = true;
  13. public $groups = true;
  14. private $filter;
  15. private $result;
  16. private $name;
  17. public function __construct($name)
  18. {
  19. $this->ready = true;
  20. $this->name = $name;
  21. }
  22. public function get_name()
  23. {
  24. return $this->name;
  25. }
  26. public function set_search_set($filter)
  27. {
  28. $this->filter = $filter;
  29. }
  30. public function get_search_set()
  31. {
  32. return $this->filter;
  33. }
  34. public function reset()
  35. {
  36. $this->result = null;
  37. $this->filter = null;
  38. }
  39. function list_groups($search = null, $mode = 0)
  40. {
  41. return array(
  42. array('ID' => 'testgroup1', 'name' => "Testgroup"),
  43. array('ID' => 'testgroup2', 'name' => "Sample Group"),
  44. );
  45. }
  46. public function list_records($cols=null, $subset=0)
  47. {
  48. $this->result = $this->count();
  49. $this->result->add(array('ID' => '111', 'name' => "Example Contact", 'firstname' => "Example", 'surname' => "Contact", 'email' => "example@roundcube.net"));
  50. return $this->result;
  51. }
  52. public function search($fields, $value, $strict=false, $select=true, $nocount=false, $required=array())
  53. {
  54. // no search implemented, just list all records
  55. return $this->list_records();
  56. }
  57. public function count()
  58. {
  59. return new rcube_result_set(1, ($this->list_page-1) * $this->page_size);
  60. }
  61. public function get_result()
  62. {
  63. return $this->result;
  64. }
  65. public function get_record($id, $assoc=false)
  66. {
  67. $this->list_records();
  68. $first = $this->result->first();
  69. $sql_arr = $first['ID'] == $id ? $first : null;
  70. return $assoc && $sql_arr ? $sql_arr : $this->result;
  71. }
  72. function create_group($name)
  73. {
  74. $result = false;
  75. return $result;
  76. }
  77. function delete_group($gid)
  78. {
  79. return false;
  80. }
  81. function rename_group($gid, $newname, &$newid)
  82. {
  83. return $newname;
  84. }
  85. function add_to_group($group_id, $ids)
  86. {
  87. return false;
  88. }
  89. function remove_from_group($group_id, $ids)
  90. {
  91. return false;
  92. }
  93. }