示例#1
0
 /**
  * Returns the number of "new" items (based on passed criteria)
  * @param string id ID of folder
  * @param array criteria
  * 		expected:
  * 		array('field' => 'status',
  * 				'value' => 'unread');
  * @param array
  * @return int
  */
 function getCountNewItems($id, $criteria, $folder)
 {
     global $current_user;
     $sugarFolder = new SugarFolder();
     return $sugarFolder->getCountUnread($id);
     /*
     $sugarFolder = new SugarFolder();
     return $sugarFolder->getCountUnread($id);
     /*
     $count = 0;
     
     // if dynamic query is for "My Drafts" run special count logic.
     if(!empty($folder['dynamic_query'])) {
     	$folder['dynamic_query'] = from_html($folder['dynamic_query']);
     	if(strpos($folder['dynamic_query'], "type = 'draft'") !== false) {
     		$q = "SELECT COUNT(*) c " . substr($folder['dynamic_query'], strpos($folder['dynamic_query'], "FROM"));
     		$r = $this->db->query($q);
     		$a = $this->db->fetchByAssoc($r);
     		$count = $a['c'];
     	}
     }
     
     $q = "SELECT polymorphic_module, polymorphic_id FROM folders_rel fr JOIN folders f ON fr.folder_id = f.id WHERE f.id = '{$id}'";
     $r = $this->db->query($q);
     $ins = ""; // IN () scope clause
     
     while($a = $this->db->fetchByAssoc($r)) {
     	$table = strtolower($a['polymorphic_module']);
     
     	if(!empty($ins)) {
     		$ins .= ", ";
     	}
     
     	$ins .= "'{$a['polymorphic_id']}'";
     }
     
     if(isset($table)) {
     	$qC = "SELECT count(*) c FROM {$table} WHERE deleted = 0 AND id IN ({$ins}) AND {$criteria['field']} = '{$criteria['value']}'";
     	$rC = $this->db->query($qC);
     	$aC = $this->db->fetchByAssoc($rC);
     
     	return ($count + $aC['c']);
     }
     
     return $count;;
     */
 }
示例#2
0
 /**
  * Returns the number of "new" items (based on passed criteria)
  * @param string id ID of folder
  * @param array criteria
  * 		expected:
  * 		array('field' => 'status',
  * 				'value' => 'unread');
  * @param array
  * @return int
  */
 function getCountNewItems($id, $criteria, $folder)
 {
     global $current_user;
     $sugarFolder = new SugarFolder();
     return $sugarFolder->getCountUnread($id);
 }