示例#1
0
 /**
  * AllOpenIDs() method - get all OpenIDs for the given contact
  */
 public function testAllOpenIDs()
 {
     $contactId = Contact::createIndividual();
     $this->assertDBRowExist('CRM_Contact_DAO_Contact', $contactId);
     // create first openid
     $openIdURLOne = "http://test-one-username.civicrm.org/";
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'openid' => $openIdURLOne, 'is_primary' => 1, 'allowed_to_login' => 1);
     $openObjectOne = CRM_Core_BAO_OpenID::add($params);
     $openIdOne = $openObjectOne->id;
     $this->assertDBNotNull('CRM_Core_DAO_OpenID', $openIdURLOne, 'id', 'openid', 'Database check for created OpenID.');
     // create second openid
     $openIdURLTwo = "http://test-two-username.civicrm.org/";
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'openid' => $openIdURLTwo);
     $openObjectTwo = CRM_Core_BAO_OpenID::add($params);
     $openIdTwo = $openObjectTwo->id;
     $this->assertDBNotNull('CRM_Core_DAO_OpenID', $openIdURLTwo, 'id', 'openid', 'Database check for created OpenID.');
     // obtain all openids for the contact
     $openIds = CRM_Core_BAO_OpenID::allOpenIDs($contactId);
     // check number of openids for the contact
     $this->assertEquals(2, count($openIds), 'Checking number of returned open-ids.');
     // check first openid values
     $this->assertEquals($openIdURLOne, $openIds[$openIdOne]['openid'], 'Confirm first openid value.');
     $this->assertEquals(1, $openIds[$openIdOne]['is_primary'], 'Confirm is_primary field value.');
     $this->assertEquals(1, $openIds[$openIdOne]['allowed_to_login'], 'Confirm allowed_to_login field value.');
     // check second openid values
     $this->assertEquals($openIdURLTwo, $openIds[$openIdTwo]['openid'], 'Confirm second openid value.');
     $this->assertEquals(0, $openIds[$openIdTwo]['is_primary'], 'Confirm is_primary field value for second openid.');
     $this->assertEquals(0, $openIds[$openIdTwo]['allowed_to_login'], 'Confirm allowed_to_login field value for second openid.');
     //Contact::delete($contactId);
     $this->contactDelete($contactId);
     $this->assertDBRowNotExist('CRM_Contact_DAO_Contact', $contactId);
 }
示例#2
0
 /**
  * allOpenIDs() method - get all OpenIDs for the given contact
  */
 function testAllOpenIDs()
 {
     $contactId = Contact::createIndividual();
     // create first openid
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'endpoint_url' => $openid['endpoint_url'], 'claimed_id' => $openid['claimed_id'], 'display_id' => $openid['display_id'], 'is_primary' => 1, 'allowed_to_login' => 1);
     require_once 'CRM/Core/BAO/OpenID.php';
     $openObjectOne = CRM_Core_BAO_OpenID::add($params);
     $openIdOne_id = $openObjectOne->id;
     $this->assertDBCompareValues('CRM_Core_DAO_OpenID', array('id' => $openIdOne_id), $openid);
     // create second openid
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'endpoint_url' => $openid_two['endpoint_url'], 'claimed_id' => $openid_two['claimed_id'], 'display_id' => $openid_two['display_id']);
     $openObjectTwo = CRM_Core_BAO_OpenID::add($params);
     $openIdTwo_id = $openObjectTwo->id;
     $this->assertDBCompareValues('CRM_Core_DAO_OpenID', array('id' => $openIdTwo_id), $openid_two);
     // obtain all openids for the contact
     $openIds = CRM_Core_BAO_OpenID::allOpenIDs($contactId);
     // check number of openids for the contact
     $this->assertEquals(count($openIds), 2, 'Checking number of returned OpenIDs.');
     // check first openid values
     $this->assertAttributesEquals($openid, $openIds[$openIdOne_id]);
     $this->assertEquals(1, $openIds[$openIdOne_id]['is_primary'], 'Confirm is_primary field value.');
     $this->assertEquals(1, $openIds[$openIdOne_id]['allowed_to_login'], 'Confirm allowed_to_login field value.');
     // check second openid values
     $this->assertAttributesEquals($openid_two, $openIds[$openIdTwo_id]);
     $this->assertEquals(0, $openIds[$openIdTwo_id]['is_primary'], 'Confirm is_primary field value for second openid.');
     $this->assertEquals(0, $openIds[$openIdTwo_id]['allowed_to_login'], 'Confirm allowed_to_login field value for second openid.');
     Contact::delete($contactId);
 }
示例#3
0
文件: OpenID.php 项目: kidaa30/yes
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
     $entityBlock = array('contact_id' => $contactId);
     $openids = CRM_Core_BAO_OpenID::getValues($entityBlock);
     if (!empty($openids)) {
         foreach ($openids as $key => &$value) {
             $value['location_type'] = $locationTypes[$value['location_type_id']];
         }
     }
     $this->assign('contactId', $contactId);
     $this->assign('openid', $openids);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
示例#4
0
 /**
  * Get if the user is allowed to login 
  *
  * @param $user the user object holding auth info
  *
  * @return boolean
  * @access public
  * @static
  */
 static function getAllowedToLogin($user)
 {
     require_once 'CRM/Core/BAO/OpenID.php';
     // this returns true if the user is allowed to log in, false o/w
     $allow_login = CRM_Core_BAO_OpenID::isAllowedToLogin($user->openid);
     return $allow_login;
 }