Exemplo n.º 1
0
 /**
  * Given a note id, get a list of the ids of all notes that are descendents of that note
  *
  * @param int $parentId
  *   Id of the given note.
  * @param array $ids
  *   (reference) one-dimensional array to store found descendent ids.
  *
  * @return array
  *   One-dimensional array containing ids of all desendent notes
  */
 public static function getDescendentIds($parentId, &$ids = array())
 {
     // get direct children of given parentId note
     $note = new CRM_Core_DAO_Note();
     $note->entity_table = 'civicrm_note';
     $note->entity_id = $parentId;
     $note->find();
     while ($note->fetch()) {
         // foreach child, add to ids list, and recurse
         $ids[] = $note->id;
         self::getDescendentIds($note->id, $ids);
     }
     return $ids;
 }
Exemplo n.º 2
0
 /**
  * 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);
 }