当前位置: 首页>>代码示例>>PHP>>正文


PHP CContact::getAllowedRecords方法代码示例

本文整理汇总了PHP中CContact::getAllowedRecords方法的典型用法代码示例。如果您正苦于以下问题:PHP CContact::getAllowedRecords方法的具体用法?PHP CContact::getAllowedRecords怎么用?PHP CContact::getAllowedRecords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CContact的用法示例。


在下文中一共展示了CContact::getAllowedRecords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeGet

 /**
  * Get Request Handler
  *
  * This method is called when a request is a GET
  *
  * @return array
  */
 public function executeGet()
 {
     $valid = $this->hasRequiredParameters($this->requiredParams);
     if ($valid instanceof Frapi_Error) {
         return $valid;
     }
     $username = $this->getParam('username');
     $password = $this->getParam('password');
     $contact_id = $this->getParam('contact_id', self::TYPE_INT);
     // Attempt to login as user, a little bit of a hack as we currently
     // require the $_POST['login'] var to be set as well as a global AppUI
     $AppUI = new CAppUI();
     $GLOBALS['AppUI'] = $AppUI;
     $_POST['login'] = 'login';
     if (!$AppUI->login($username, $password)) {
         throw new Frapi_Error('INVALID_LOGIN');
     }
     $contact = new CContact();
     $allowed_contacts = $contact->getAllowedRecords($AppUI->user_id);
     // Contact ID is the key, so lets get them in an array so we can
     // easily check
     $allowed_contacts = array_keys($allowed_contacts);
     if (!in_array($contact_id, $allowed_contacts)) {
         throw new Frapi_Error('PERMISSION_ERROR');
     }
     // User has permission so load the contact for display
     $contact_array = (array) $contact->load($contact_id);
     $contact_array['contact_methods'] = $contact->getContactMethods();
     // Remove the data that is not for display
     unset($contact_array['_tbl_prefix'], $contact_array['_tbl'], $contact_array['_tbl_key'], $contact_array['_error'], $contact_array['_query'], $contact_array['_tbl_module']);
     $this->data['contact'] = $contact_array;
     $this->data['success'] = true;
     return $this->toArray();
 }
开发者ID:robertbasic,项目名称:web2project-api,代码行数:41,代码来源:Contact.php

示例2: executeGet

 /**
  * Get Request Handler
  *
  * This method is called when a request is a GET
  *
  * @return array
  */
 public function executeGet()
 {
     $valid = $this->hasRequiredParameters($this->requiredParams);
     if ($valid instanceof Frapi_Error) {
         return $valid;
     }
     $username = $this->getParam('username');
     $password = $this->getParam('password');
     // Attempt to login as user, a little bit of a hack as we currently
     // require the $_POST['login'] var to be set as well as a global AppUI
     $AppUI = new CAppUI();
     $GLOBALS['AppUI'] = $AppUI;
     $_POST['login'] = 'login';
     if (!$AppUI->login($username, $password)) {
         throw new Frapi_Error('INVALID_LOGIN');
     }
     $contact = new CContact();
     $this->data['contacts'] = $contact->getAllowedRecords($AppUI->user_id);
     $this->data['success'] = true;
     return $this->toArray();
 }
开发者ID:robertbasic,项目名称:web2project-api,代码行数:28,代码来源:Contacts.php


注:本文中的CContact::getAllowedRecords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。