示例#1
0
文件: Note.php 项目: hguru/224Civi
 /**
  * This function is called when action is browse
  *
  * return null
  * @access public
  */
 function browse()
 {
     $note = new CRM_Core_DAO_Note();
     $note->entity_table = 'civicrm_contact';
     $note->entity_id = $this->_contactId;
     $note->orderBy('modified_date desc');
     //CRM-4418, handling edit and delete separately.
     $permissions = array($this->_permission);
     if ($this->_permission == CRM_Core_Permission::EDIT) {
         //previously delete was subset of edit
         //so for consistency lets grant delete also.
         $permissions[] = CRM_Core_Permission::DELETE;
     }
     $mask = CRM_Core_Action::mask($permissions);
     $values = array();
     $links = self::links();
     $action = array_sum(array_keys($links)) & $mask;
     $note->find();
     while ($note->fetch()) {
         if (!CRM_Core_BAO_Note::getNotePrivacyHidden($note)) {
             CRM_Core_DAO::storeValues($note, $values[$note->id]);
             $values[$note->id]['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $note->id, 'cid' => $this->_contactId));
             $contact = new CRM_Contact_DAO_Contact();
             $contact->id = $note->contact_id;
             $contact->find();
             $contact->fetch();
             $values[$note->id]['createdBy'] = $contact->display_name;
             $values[$note->id]['comment_count'] = CRM_Core_BAO_Note::getChildCount($note->id);
         }
     }
     $this->assign('notes', $values);
     $commentLinks = self::commentLinks();
     $action = array_sum(array_keys($commentLinks)) & $mask;
     $commentAction = CRM_Core_Action::formLink($commentLinks, $action, array('id' => $note->id, 'pid' => $note->entity_id, 'cid' => $note->entity_id));
     $this->assign('commentAction', $commentAction);
 }