[GH-ISSUE #270] Contacts Module #233

Closed
opened 2026-02-25 21:34:30 +03:00 by kerem · 4 comments
Owner

Originally created by @bet0x on GitHub (May 13, 2018).
Original GitHub issue: https://github.com/cypht-org/cypht/issues/270

Originally assigned to: @jasonmunro on GitHub.

Hello, i want to implement a contact module to be shared with another application using a database. i'm kinda lost with the Gmail or Ldap ones... they are quite complicated to understand! Any tips on a simple contact structure?

Originally created by @bet0x on GitHub (May 13, 2018). Original GitHub issue: https://github.com/cypht-org/cypht/issues/270 Originally assigned to: @jasonmunro on GitHub. Hello, i want to implement a contact module to be shared with another application using a database. i'm kinda lost with the Gmail or Ldap ones... they are quite complicated to understand! Any tips on a simple contact structure?
kerem 2026-02-25 21:34:30 +03:00
Author
Owner

@jasonmunro commented on GitHub (May 14, 2018):

Thanks for the feedback, I will put something together with some comments to explain how the code works.

<!-- gh-comment-id:388885147 --> @jasonmunro commented on GitHub (May 14, 2018): Thanks for the feedback, I will put something together with some comments to explain how the code works.
Author
Owner

@bet0x commented on GitHub (May 14, 2018):

Thank you @jasonmunro i truly want to integrate contacts with database but kinda not possible because the code is quite complicated and still, you did a Ldap, Google, Local but no DB or API to access the local one.

<!-- gh-comment-id:388895441 --> @bet0x commented on GitHub (May 14, 2018): Thank you @jasonmunro i truly want to integrate contacts with database but kinda not possible because the code is quite complicated and still, you did a Ldap, Google, Local but no DB or API to access the local one.
Author
Owner

@jasonmunro commented on GitHub (Jun 27, 2018):

db_contacts.zip

Attached is a boiler plate module set for adding db_contacts. It includes 2 files:

  • setup.php - this file associates the modules in this set with actions in cypht. You won't need to alter this file initially
  • modules.php - this already has all the boiler plate needed, just look for the TODO comments explaining what database interactions need to happen.

To enable this module set, do the following

  • unzip and move the directory to cypht/modules/
  • add modules[]=db_contacts to your hm3.ini file
  • run the config gen script

Cypht has a built in DB wrapper you can use from modules to interact with a database. The code is in lib/db.php. From inside a handler module you need only do something like the following:

$dbh = Hm_DB::connect($this->config);
$result = Hm_DB::execute($dbh, 'select fields from table', array(), false, true);

This way you can use the same database and database connection Cypht is already using (assuming you have database support enabled in your config).

Hope that helps get you started. Happy to answer any questions you come up with!

<!-- gh-comment-id:400775674 --> @jasonmunro commented on GitHub (Jun 27, 2018): [db_contacts.zip](https://github.com/jasonmunro/cypht/files/2142341/db_contacts.zip) Attached is a boiler plate module set for adding db_contacts. It includes 2 files: - setup.php - this file associates the modules in this set with actions in cypht. You won't need to alter this file initially - modules.php - this already has all the boiler plate needed, just look for the TODO comments explaining what database interactions need to happen. To enable this module set, do the following - unzip and move the directory to cypht/modules/ - add modules[]=db_contacts to your hm3.ini file - run the config gen script Cypht has a built in DB wrapper you can use from modules to interact with a database. The code is in lib/db.php. From inside a handler module you need only do something like the following: ``` $dbh = Hm_DB::connect($this->config); $result = Hm_DB::execute($dbh, 'select fields from table', array(), false, true); ``` This way you can use the same database and database connection Cypht is already using (assuming you have database support enabled in your config). Hope that helps get you started. Happy to answer any questions you come up with!
Author
Owner

@bet0x commented on GitHub (Jun 27, 2018):

Thank you @jasonmunro i will start to work on my stuff now!

<!-- gh-comment-id:400818318 --> @bet0x commented on GitHub (Jun 27, 2018): Thank you @jasonmunro i will start to work on my stuff now!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cypht#233
No description provided.