Example #1
0
 public function getContainedFiles($subtype = 'hjfile', $count = false)
 {
     $files = hj_framework_get_entities_by_priority(array('type' => 'object', 'subtype' => $subtype, 'container_guid' => $this->guid));
     if ($count) {
         $files = sizeof($files);
     }
     return $files;
 }
Example #2
0
 public function getSectionContent($section, $params)
 {
     $widget = elgg_extract('widget', $params, false);
     if ($widget && elgg_instanceof($widget, 'object', 'widget')) {
         $params['relationship'] = 'widget';
         $params['relationship_guid'] = $widget->guid;
     } else {
         $params['relationship'] = 'segment';
         $params['relationship_guid'] = $this->guid;
     }
     $content = hj_framework_get_entities_by_priority(array('type' => 'object', 'subtype' => $section, 'limit' => $params['limit'], 'offset' => $params['offset'], 'count' => $params['count'], 'relationship' => $params['relationship'], 'relationship_guid' => $params['relationship_guid'], 'inverse_relationship' => false));
     return $content;
 }
Example #3
0
 /**
  * Gets children categories of a given category
  *
  * @param int $container_guid
  * @return mixed array of children category objects
  */
 public function getChildren()
 {
     $type = 'object';
     $subtype = 'hjcategory';
     $owner_guid = NULL;
     $container_guid = $this->guid;
     $limit = 0;
     $objects = hj_framework_get_entities_by_priority($type, $subtype, $owner_guid, $container_guid, $limit);
     if (is_array($objects)) {
         return $objects;
     }
     return false;
 }
Example #4
0
function hj_framework_get_entities_from_metadata_by_priority($type = 'object', $subtype = null, $owner_guid = NULL, $container_guid = null, $metadata_name_value_pairs = null, $limit = 0, $offset = 0, $count = false)
{
    if (is_array($metadata_name_value_pairs)) {
        $db_prefix = elgg_get_config('dbprefix');
        $entities = elgg_get_entities_from_metadata(array('type' => $type, 'subtype' => $subtype, 'owner_guid' => $owner_guid, 'container_guid' => $container_guid, 'metadata_name_value_pairs' => $metadata_name_value_pairs, 'limit' => $limit, 'offset' => $offset, 'count' => $count, 'joins' => array("JOIN {$db_prefix}metadata as mt on e.guid = mt.entity_guid\n                      JOIN {$db_prefix}metastrings as msn on mt.name_id = msn.id\n                      JOIN {$db_prefix}metastrings as msv on mt.value_id = msv.id"), 'wheres' => array("((msn.string = 'priority'))"), 'order_by' => "CAST(msv.string AS SIGNED) ASC"));
    } else {
        $entities = hj_framework_get_entities_by_priority(array('type' => $type, 'subtype' => $subtype, 'owner_guid' => $owner_guid, 'container_guid' => $container_guid, 'limit' => $limit));
    }
    return $entities;
}
Example #5
0
/**
 * Get an array of hjFileFolder for a particular user in a given container
 *
 * @param ElggUser $user
 * @param ElggEntity $container_guid
 * @return type
 */
function hj_framework_get_user_file_folders($format = 'options_array', $owner_guid = NULL, $container_guid = NULL, $limit = 0)
{
    if (!$owner_guid && elgg_is_logged_in()) {
        $owner_guid = elgg_get_logged_in_user_entity()->guid;
    } else {
        return true;
    }
    $filefolders = hj_framework_get_entities_by_priority('object', 'hjfilefolder', $owner_guid, $container_guid, $limit);
    switch ($format) {
        case 'options_array':
            if (is_array($filefolders)) {
                $result[] = elgg_echo("hj:framework:newfolder");
                foreach ($filefolders as $filefolder) {
                    $result[$filefolder->getGUID()] = $filefolder->title;
                }
            }
            break;
        case 'entities_array':
            $result = $filefolders;
            break;
    }
    return $result;
}