commit 743f6ce8fd0e7bb8697852dd99b178daf65d7cf3 Author: Marek Isalski Date: Sat Mar 26 11:10:52 2016 +0000 initial import diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..e0e14e1 --- /dev/null +++ b/.hgignore @@ -0,0 +1,5 @@ +~$ +\.DS_Store$ +sftp-config\.json$ +\.sublime-workspace$ +\.sublime-project$ diff --git a/fulcrm_crypto.admin.inc b/fulcrm_crypto.admin.inc new file mode 100644 index 0000000..be38024 --- /dev/null +++ b/fulcrm_crypto.admin.inc @@ -0,0 +1,22 @@ + 'item', + '#title' => 'fulcrm Cryptography Settings', + '#description' => '', + ); + + $form[ 'actions' ] = array( '#type' => 'actions' ); + $form[ 'actions' ][ 'save' ] = array( '#type' => 'submit', + '#value' => t('Save'), + '#submit' => array( 'fulcrm_crypto_admin_form_submit' ), + ); + return $form; +} + +function fulcrm_crypto_admin() { + return drupal_get_form( 'fulcrm_crypto_admin_form' ); +} diff --git a/fulcrm_crypto.info b/fulcrm_crypto.info new file mode 100644 index 0000000..158ed7c --- /dev/null +++ b/fulcrm_crypto.info @@ -0,0 +1,6 @@ +name = fulcrm cryptography +description = fulcrm cryptography +core = 7.x +package = fulcrm +;files[] = fulcrm_crypto.admin.inc +configure = admin/config/services/fulcrm/crypto diff --git a/fulcrm_crypto.install b/fulcrm_crypto.install new file mode 100644 index 0000000..3b2312e --- /dev/null +++ b/fulcrm_crypto.install @@ -0,0 +1 @@ + array( 'title' => t('Administer fulcrm cryptography'), + 'description' => t('Perform main installation/administration tasks for fulcrm cryptography.'), + ), + ); +} + +function fulcrm_crypto_menu() { + /* + $items[ 'admin/config/services/fulcrm' ] = array( 'page callback' => 'system_admin_menu_block_page', + 'file' => 'system.admin.inc', + 'file path' => drupal_get_path('module', 'system'), + 'title' => 'fulcrm', + 'description' => 'Configuration integration with fulcrm.org.', + 'position' => 'right', + 'access callback' => 'user_access', + 'access arguments' => array('access administration pages'), + ); + */ + $items[ 'admin/config/services/fulcrm/crypto' ] = array( 'page callback' => 'fulcrm_crypto_admin', + 'file' => 'fulcrm_crypto.admin.inc', + 'title' => 'fulcrm cryptography', + 'description' => 'Settings for fulcrm.org cryptography.', + 'access callback' => 'user_access', + 'access arguments' => array('administer fulcrm crypto'), + ); + + return $items; +} + +function fulcrm_crypto_object_id_hmac( $object_type, $object_id ) { + return drupal_hmac_base64( 'fulcrm:' . strval( $object_id ) . ':' . $object_type, session_id() . drupal_get_hash_salt() ); +} + +function fulcrm_crypto_object_id_form_value( $object_type, $object_id ) { + return $object_id . ':' . fulcrm_crypto_object_id_hmac( $object_type, $object_id ); +} + +function fulcrm_crypto_get_object_id_form_value( $object_type, $form_value ) { + $bits = explode( ':', $form_value ); + if ( count( $bits ) == 2 ) { + $object_id = $bits[ 0 ]; + $hmac = $bits[ 1 ]; + $real_hmac = fulcrm_crypto_object_id_hmac( $object_type, $object_id ); + + if ( hash_equals( $real_hmac, $hmac ) ) + return $object_id; + } + return NULL; +}