コード例 #1
0
function editMetaDataTable_Category($organisation_id = null, $group = null, $role = null, $proxy_id = null, MetaDataType $category)
{
    //for this case we have to get the users which are members of the relevant org, group, role, and where relevant? proxy_id
    $users = Users::get($organisation_id, $group, $role, $proxy_id);
    $types = MetaDataTypes::get($organisation_id, $group, $role, $proxy_id);
    $category_id = $category->getID();
    ob_start();
    foreach ($users as $user) {
        $values = getUserCategoryValues($user, $category);
        //var_dump($values);
        $descendant_type_sets = getDescendentTypesArray($types, $category);
        $label = html_encode($user->getFullname());
        ?>
	<tbody id="user_<?php 
        echo $user->getID();
        ?>
">
		<tr class="user_head" id="user_head_<?php 
        echo $user->getID();
        ?>
">
			<td></td>
			<th colspan="2"><?php 
        echo $label;
        ?>
</th>
			<td class="control" colspan="3"><ul class="page-action"><li class="last"><a href="#" class="add_btn" id="add_btn_<?php 
        echo $category_id;
        ?>
">Add record for <?php 
        echo $label;
        ?>
</a></li></ul></td>
		</tr>
		<?php 
        foreach ($values as $value) {
            echo editMetaDataRow($value, $category, $descendant_type_sets);
        }
        ?>
	</tbody>
	<?php 
    }
    $prepend = getHiddenMetaInputs($organisation_id, $group, $role, $category_id);
    return editMetaDataTable(ob_get_clean(), $prepend);
}
コード例 #2
0
 /**
  * Retrieves Multiple values based on provided criteria.  
  * @param $organisation Organisation ID
  * @param $group 
  * @param $role
  * @param $proxy_id User's ID 
  * @param MetaDataType $type
  * @param $options advanced selection criteroa
  * @return MetaDataValues
  */
 public static function get($organisation = null, $group = null, $role = null, $proxy_id = null, MetaDataType $type = null, $include_sub_types = true, $options = array())
 {
     global $db;
     $conditions = array();
     if (array_key_exists('order by', $options)) {
         $order = array();
         if (is_array($options['order by'])) {
             foreach ($options['order by'] as $orders) {
                 $order[] = "`" . $orders[0] . "` " . (isset($orders[1]) ? $orders[1] : "asc");
             }
         }
         $order_by = " ORDER BY " . implode(",", $order);
     } else {
         $order_by = " ORDER BY lastname, firstname";
     }
     if (isset($options['limit'])) {
         $limit = $options['limit'];
     } else {
         $limit = -1;
     }
     if (isset($options['offset'])) {
         $offset = $options['offset'];
     } else {
         $offset = -1;
     }
     if (isset($options['where'])) {
         $conditions[] = $options['where'];
     }
     $query = "SELECT a.*, b.`group`, b.`role`, c.* from `" . AUTH_DATABASE . "`.`user_data` a \n\t\t\t\t\tLEFT JOIN `" . AUTH_DATABASE . "`.`user_access` b on a.`id`=b.`user_id` and b.`app_id`=?\n\t\t\t\t\tLEFT JOIN `meta_values` c on c.`proxy_id`=a.`id`";
     $conditions[] = generateAccessConditions($organisation, $group, $role, $proxy_id, 'b');
     if ($type) {
         $type_id = $type->getID();
         if ($include_sub_types) {
             $types = MetaDataTypes::get($organisation, $group, $role, $proxy_id);
             $desc_type_ids = getUniqueDescendantTypeIDs($types, $type);
             if ($desc_type_ids) {
                 //includes values from the specified type as well as sub types
                 $desc_type_ids[] = $type_id;
                 $conditions[] = "`meta_type_id` IN (" . implode(",", $desc_type_ids) . ")";
             } else {
                 $conditions[] = "`meta_type_id`=" . $db->qstr($type_id);
             }
         } else {
             $conditions[] = "`meta_type_id`=" . $db->qstr($type_id);
         }
     }
     if ($conditions) {
         $query .= " WHERE " . implode(" AND ", $conditions);
     }
     $query .= $order_by;
     $results = $db->SelectLimit($query, $limit, $offset, array(AUTH_APP_ID));
     $values = array();
     if ($results) {
         foreach ($results as $result) {
             //print_r($result);
             //user caching
             //$tmp_user = User::fromArray($result);
             //print_r($tmp_user);
             $values[] = MetaDataValue::fromArray($result);
         }
     }
     return new self($values);
 }