if (isset($profs)) {
    //display member avatars
    foreach ($profs as $members) {
        //			if ( $lc>9000) break;
        $query1 = "SELECT * FROM {$CONFIG->dbprefix}_content_item_discrimination WHERE guid = \"" . $members->guid . "\"";
        $result1 = get_data($query1);
        $res = mysql_query($query1);
        while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
            $nikolas = $row['creator_guid'];
        }
        $creator = get_entity($nikolas);
        $gid = $members->guid;
        if ($result1 != NULL) {
            $metalang = get_metadata_byname($gid, 'meducator5');
            $metakey = get_metadata_byname($gid, 'meducator4');
            $metadesc = get_metadata_byname($gid, 'meducator7');
            ///////////////////////////////////////////////////////////////////////////////////////////////
            $cont_item_ID = $members->guid;
            $avatarId = 3039;
            if ($avatarId) {
                $userId = $members->guid;
                create_metadata($userId, 'avatar', $avatarId, '', $userId, ACCESS_PUBLIC);
                create_metadata($userId, 'icontime', time(), '', 0, ACCESS_PUBLIC);
            }
            /////////////////////////////////////////////////////////////////////////////////////
            echo "<div class=\"filerepo_file\">";
            echo "\t\t<div class=\"filerepo_icon\">\n";
            echo elgg_view("profile/icon", array('entity' => $members, 'size' => 'small'));
            echo "</div>";
            echo "\t\t<div class=\"filerepo_title_owner_wrapper\">\n";
            echo "\t\t<div class=\"filerepo_title\">Name: " . $members->name;
 * 
 * @uses $vars['entity'] The user entity
 * @uses $vars['profile'] Profile items from $CONFIG->profile, defined in profile/start.php for now 
 */
?>
<div class="contentWrapper">
<form action="<?php 
echo $vars['url'];
?>
action/profile/edit" method="post">
<?php 
echo elgg_view('input/securitytoken');
//var_export($vars['profile']);
if (is_array($vars['config']->profile) && sizeof($vars['config']->profile) > 0) {
    foreach ($vars['config']->profile as $shortname => $valtype) {
        if ($metadata = get_metadata_byname($vars['entity']->guid, $shortname)) {
            if (is_array($metadata)) {
                $value = '';
                foreach ($metadata as $md) {
                    if (!empty($value)) {
                        $value .= ', ';
                    }
                    $value .= $md->value;
                    $access_id = $md->access_id;
                }
            } else {
                $value = $metadata->value;
                $access_id = $metadata->access_id;
            }
        } else {
            $value = '';
        foreach ($nik1 as $nik11) {
            fwrite($ourFileHandle, "<mdc:educationalOutcomes>" . $nik11 . "</mdc:educationalOutcomes> \r\n");
        }
    } else {
        fwrite($ourFileHandle, "<mdc:educationalOutcomes>" . $nik1 . "</mdc:educationalOutcomes> \r\n");
    }
}
$nik1 = 'meducator13';
$metadata = get_metadata_byname($nik, $nik1);
if ($metadata->value != NULL) {
    fwrite($ourFileHandle, "<mdc:assessmentMethods><![CDATA[ ");
    fwrite($ourFileHandle, $metadata->value);
    fwrite($ourFileHandle, " ]]></mdc:assessmentMethods>\r\n");
}
$nik1 = 'meducator14';
$metadata = get_metadata_byname($nik, $nik1);
if ($metadata->value != NULL) {
    fwrite($ourFileHandle, "<mdc:educationalPrerequisites><![CDATA[ ");
    fwrite($ourFileHandle, $metadata->value);
    fwrite($ourFileHandle, " ]]></mdc:educationalPrerequisites>\r\n");
}
$nik1 = $entity->meducator28;
if ($nik1) {
    if (is_array($nik1)) {
        foreach ($nik1 as $nik11) {
            fwrite($ourFileHandle, "<mdc:isAccompaniedBy><mdc:Resource rdf:about=\"" . $nik11 . "\"/></mdc:isAccompaniedBy> \r\n");
        }
    } else {
        fwrite($ourFileHandle, "<mdc:isAccompaniedBy><mdc:Resource rdf:about=\"" . $nik1 . "\"/></mdc:isAccompaniedBy> \r\n");
    }
}
Ejemplo n.º 4
0
function follow_tags_get_activity_follow_tags($options)
{
    $dbprefix = elgg_get_config("dbprefix");
    $tags = get_metadata_byname(follow_tags_get_tag_guid(elgg_get_logged_in_user_guid()), 'tags');
    $cnt = 0;
    //Count the followTags and Create string for the SQL-query
    switch (count($tags)) {
        case 0:
            break;
        case 1:
            $tagid = $tags['value_id'];
            $value_ids = "value_id = {$tagid}";
            break;
        default:
            foreach ($tags as $tag) {
                $tagid = $tag['value_id'];
                $cnt++;
                if ($cnt != count($tags)) {
                    $value_ids .= "value_id = {$tagid}";
                    $value_ids .= " OR ";
                } else {
                    $value_ids .= "value_id = {$tagid}";
                }
            }
            break;
    }
    //Check if the user have any FollowTags
    $user = elgg_get_logged_in_user_entity();
    $user = $user->username;
    if (count($tags) != 0) {
        $sql_where = "object_guid IN (SELECT entity_guid FROM {$dbprefix}metadata WHERE {$value_ids}) AND action_type = 'create'";
        $options['wheres'] = array($sql_where);
        $activity = elgg_list_river($options);
    }
    return $activity;
}
function get_snapshot($req)
{
    global $CONFIG;
    set_time_limit(0);
    //this avoids timeouts
    $outputfile = $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/output.log";
    require_once $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/config.php";
    require_once $CONFIG->path . "mod/profile_manager/views/default/profile_manager/members/classes.php";
    //$lr=unserialize(file_get_contents($IOdir."lr"));
    //return "OK";
    file_put_contents($outputfile, "Old indexing and classification files will now be saved in the IOdir directory with the prefix old_ and will be deleted after the whole process is completed\nIf there are problems and the process aborts before the end, rename them deleting that prefix in order to recover old data!\n\n");
    //backup of the old files
    if (file_exists($IOdir . "changes")) {
        copy($IOdir . "changes", $IOdir . "old_changes");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_changes', 0666);
        }
        //set rw permissions for everybody for this file
    }
    if (file_exists($IOdir . "lr")) {
        copy($IOdir . "lr", $IOdir . "old_lr");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_lr', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "lr");
    }
    if (file_exists($IOdir . "metadata_dt")) {
        copy($IOdir . "metadata_dt", $IOdir . "old_metadata_dt");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_metadata_dt', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "metadata_dt");
    }
    if (file_exists($IOdir . "uses_dt")) {
        copy($IOdir . "uses_dt", $IOdir . "old_uses_dt");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_uses_dt', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "uses_dt");
    }
    if (file_exists($IOdir . "tags_dt")) {
        copy($IOdir . "tags_dt", $IOdir . "old_tags_dt");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_tags_dt', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "tags_dt");
    }
    if (file_exists($IOdir . "metadata_dt_raw")) {
        copy($IOdir . "metadata_dt_raw", $IOdir . "old_metadata_dt_raw");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_metadata_dt_raw', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "metadata_dt_raw");
    }
    if (file_exists($IOdir . "uses_dt_raw")) {
        copy($IOdir . "uses_dt_raw", $IOdir . "old_uses_dt_raw");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_uses_dt_raw', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "uses_dt_raw");
    }
    if (file_exists($IOdir . "tags_dt_raw")) {
        copy($IOdir . "tags_dt_raw", $IOdir . "old_tags_dt_raw");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_tags_dt_raw', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "tags_dt_raw");
    }
    if (file_exists($IOdir . "tags_dd")) {
        copy($IOdir . "tags_dd", $IOdir . "old_tags_dd");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_tags_dd', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "tags_dd");
    }
    if (file_exists($IOdir . "metadata_dd")) {
        copy($IOdir . "metadata_dd", $IOdir . "old_metadata_dd");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_metadata_dd', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "metadata_dd");
    }
    if (file_exists($IOdir . "uses_dd")) {
        copy($IOdir . "uses_dd", $IOdir . "old_uses_dd");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_uses_dd', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "uses_dd");
    }
    if (file_exists($IOdir . "tags_dd")) {
        copy($IOdir . "tags_dd", $IOdir . "old_tags_dd");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_tags_dd', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "tags_dd");
    }
    if (file_exists($IOdir . "replinks_dd")) {
        copy($IOdir . "replinks_dd", $IOdir . "old_replinks_dd");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_replinks_dd', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "replinks_dd");
    }
    if (file_exists($IOdir . "clusters_metadata")) {
        copy($IOdir . "clusters_metadata", $IOdir . "old_clusters_metadata");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_clusters_metadata', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "clusters_metadata");
    }
    if (file_exists($IOdir . "clusters_uses")) {
        copy($IOdir . "clusters_uses", $IOdir . "old_clusters_uses");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_clusters_uses', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "clusters_uses");
    }
    if (file_exists($IOdir . "clusters_tags")) {
        copy($IOdir . "clusters_tags", $IOdir . "old_clusters_tags");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_clusters_tags', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "clusters_tags");
    }
    if (file_exists($IOdir . "clusters_replinks")) {
        copy($IOdir . "clusters_replinks", $IOdir . "old_clusters_replinks");
        if (PHP_OS == "Linux") {
            chmod($IOdir . 'old_clusters_replinks', 0666);
        }
        //set rw permissions for everybody for this file
        unlink($IOdir . "clusters_replinks");
    }
    //if you chose to use the Sesame RDF
    if ($data_source == 1) {
        require_once $CONFIG->path . "mod/mmsearch/custom/MeducatorParser.php";
        file_put_contents($outputfile, "Downloading a new snapshot of data from the SESAME RDF...\n", FILE_APPEND);
        $address_base = $CONFIG->API_URL . "searchall?properties=";
        $metadatas_fields = explode(";", $metadata_fields);
        sort($metadatas_fields);
        $usess_fields = explode(";", $uses_fields);
        sort($usess_fields);
        $tagss_fields = explode(";", $tags_fields);
        sort($tagss_fields);
        $fields = array_unique(array_merge($metadatas_fields, $usess_fields, $tagss_fields));
        if (!in_array("hasRepurposingContext", $fields)) {
            $fields[] = "hasRepurposingContext";
        }
        //in order to return the "repurposedFrom" part as well, used for Replinks
        $finalresults = array();
        foreach ($fields as $field) {
            if ($field == "seeAlso" || $field == "type") {
                continue;
            }
            //the first one is included by default, the second causes error
            $address = $address_base . "mdc:{$field}";
            //I can't put all the fields together right now, since it will return only the resources that have all those fields, so I do a query field after field and then I make the union of the results
            $rdf_info = connectToSesame($address);
            $medParser = new MeducatorParser($rdf_info, true);
            $results = $medParser->results;
            foreach ($results as $key => $result) {
                if (array_key_exists($key, $finalresults)) {
                    $finalresults[$key] = array_merge($finalresults[$key], $result);
                } else {
                    $finalresults[$key] = $result;
                }
            }
        }
        //$b=print_r($finalresults,true);
        //file_put_contents("bbbb",$b);
        if (count($finalresults) > 0) {
            //we have to create a LearningResource object for each result and insert metadata into it
            foreach ($finalresults as $id => $data) {
                $seeAlso = $data["seeAlso"];
                if (is_array($seeAlso)) {
                    $values = array_unique(get_values($seeAlso, "seeAlso"));
                    foreach ($values as $value) {
                        if (strrchr($value, "#") != FALSE) {
                            $guid = substr(strrchr($value, "#"), 1);
                            break;
                        }
                    }
                } else {
                    $guid = substr(strrchr($seeAlso, "#"), 1);
                }
                $entity = get_entity($guid);
                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                if (empty($entity)) {
                    continue;
                }
                //this is a temporary check from the database since we still need it in order not to have problem with the normal search that still takes info from it
                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                $lr[$guid] = new LearningResource();
                $lr[$guid]->setName($entity->get('name'));
                $lr[$guid]->setUsername($entity->get('username'));
                $lr[$guid]->setGUID($guid);
                //we extract the important part from each field and insert in the $lr[$guid] object
                foreach ($fields as $field) {
                    $notused = array("type", "hasRepurposingContext");
                    if (in_array($field, $notused)) {
                        continue;
                    }
                    //"type" is more difficult to handle, anyway we don't need it; "hasRepurposingContext" is used later for Replinks
                    $value = "";
                    if (!is_array($data[$field])) {
                        $value = $data[$field];
                    } elseif (isset($data[$field]["name"])) {
                        $value = $data[$field]["name"];
                    } elseif (isset($data[$field]["label"])) {
                        $value = $data[$field]["label"];
                    } else {
                        //if we have different elements
                        foreach ($data[$field] as $subfield) {
                            if (!is_array($subfield)) {
                                $subvalue = $subfield;
                            } elseif (isset($subfield["name"])) {
                                $subvalue = $subfield["name"];
                            } elseif (isset($subfield["label"])) {
                                $subvalue = $subfield["label"];
                            } else {
                                continue;
                            }
                            //I think there are not other cases, but if so, don't handle them in order to avoid errors
                            if (is_array($subvalue)) {
                                $subvalue = implode(";", $subvalue);
                            }
                            //if it is still an array, transform it in a string
                            $value .= $subvalue . ";";
                        }
                        $value = substr($value, 0, -1);
                        //delete the last ;
                    }
                    if (is_array($value)) {
                        $value = implode(";", $value);
                    }
                    //if it is still an array, transform it in a string
                    if (strrchr($value, "#") != FALSE) {
                        $value = substr(strrchr($value, "#"), 1);
                    }
                    //take only the important part
                    if ($value != "") {
                        $lr[$guid]->insertMetadata($field, $value);
                    }
                }
                //now I add to the tags of the resource eventual tags added by the users
                $objs = get_entities_from_metadata('', '', 'object', '', '', 10000);
                foreach ($objs as $obj) {
                    if ($obj->subtype == '28') {
                        //I get only the objects that are bookmarks
                        $link = $CONFIG->url . "pg/profile/" . $entity->get('username');
                        if ($obj->address == $link) {
                            //I consider the bookmark only if it is a bookmark to the current resource
                            if (!empty($obj->tags)) {
                                if (is_array($obj->tags)) {
                                    $lr[$guid]->tags = array_merge($lr[$guid]->tags, $obj->tags);
                                } else {
                                    $lr[$guid]->tags[] = $obj->tags;
                                }
                            }
                        }
                    }
                }
                //insert $replinks["from"]
                if (is_array($data["hasRepurposingContext"])) {
                    $values = array_unique(get_values($data["hasRepurposingContext"], "seeAlso"));
                    foreach ($values as $value) {
                        $guid_from = substr(strrchr($value, "#"), 1);
                        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        $entity = get_entity($guid_from);
                        if (empty($entity)) {
                            continue;
                        }
                        //this is a temporary check from the database since we still need it in order not to have problem with the normal search that still takes info from it
                        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        $lr[$guid]->replinks["from"][] = $guid_from;
                    }
                }
            }
            //insert replinks["to"]
            foreach ($lr as $guid => $resource) {
                foreach ($resource->replinks["from"] as $guid_from) {
                    $lr[$guid_from]->replinks["to"][] = $guid;
                }
            }
        } else {
            file_put_contents($outputfile, "\n\nNo resources returned. There must be an error somewhere...", FILE_APPEND);
            exit;
        }
    } elseif ($data_source == 2) {
        file_put_contents($outputfile, "Downloading a new snapshot of data from the Metamorphosis database...\n", FILE_APPEND);
        $metadatas_fields = explode(";", $metadata_fields);
        sort($metadatas_fields);
        $usess_fields = explode(";", $uses_fields);
        sort($usess_fields);
        $tagss_fields = explode(";", $tags_fields);
        sort($tagss_fields);
        $fields = array_unique(array_merge($metadatas_fields, $usess_fields, $tagss_fields));
        $query = "SELECT distinct e.* from elggentities e join elggusers_entity u on e.guid = u.guid JOIN (SELECT subm1.*, s1.string FROM elggmetadata subm1 JOIN elggmetastrings s1 ON subm1.value_id = s1.id) AS m1 ON e.guid = m1.entity_guid where ((m1.name_id='440' AND m1.string IN ('356'))) and ( (1 = 1) and e.enabled='yes') and ( (1 = 1) and m1.enabled='yes') order by e.time_created desc";
        $entities = get_data($query, "entity_row_to_elggstar");
        foreach ($entities as $entity) {
            $guid = $entity->getGUID();
            $lr[$guid] = new LearningResource();
            $lr[$guid]->setName($entity->get('name'));
            $lr[$guid]->setUsername($entity->get('username'));
            $lr[$guid]->setGUID($guid);
            $categorized_fields = profile_manager_get_categorized_fields($entity, true);
            $cats = $categorized_fields['categories'];
            $db_fields = $categorized_fields['fields'];
            if (!empty($db_fields)) {
                foreach ($cats as $cat_guid => $cat) {
                    foreach ($db_fields[$cat_guid] as $db_field) {
                        $metadata_name = $db_field->metadata_name;
                        // get options
                        $options = $db_field->getOptions();
                        // get type of db_field
                        if ($db_field->user_editable == "no") {
                            $valtype = "non_editable";
                        } else {
                            $valtype = $db_field->metadata_type;
                        }
                        $field = $db_field->getTitle();
                        if (in_array($field, $fields)) {
                            // get value
                            if ($metadata = get_metadata_byname($entity->guid, $metadata_name)) {
                                //print_r($metadata);
                                if (is_array($metadata)) {
                                    $value = '';
                                    foreach ($metadata as $md) {
                                        if (!empty($value)) {
                                            $value .= ', ';
                                        }
                                        $value .= $md->value;
                                        $access_id = $md->access_id;
                                    }
                                } else {
                                    $value = $metadata->value;
                                    $access_id = $metadata->access_id;
                                }
                            } else {
                                $value = '';
                                $access_id = ACCESS_DEFAULT;
                            }
                            if ($value != "") {
                                $lr[$guid]->insertMetadata($field, $value);
                            }
                        }
                    }
                }
            }
            //now I add to the tags of the resource eventual tags added by the users
            $objs = get_entities_from_metadata('', '', 'object', '', '', 10000);
            foreach ($objs as $obj) {
                if ($obj->subtype == '28') {
                    //I get only the objects that are bookmarks
                    $link = $CONFIG->url . "pg/profile/" . $entity->get('username');
                    if ($obj->address == $link) {
                        //I consider the bookmark only if it is a bookmark to the current resource
                        if (!empty($obj->tags)) {
                            if (is_array($obj->tags)) {
                                $lr[$guid]->tags = array_merge($lr[$guid]->tags, $obj->tags);
                            } else {
                                $lr[$guid]->tags[] = $obj->tags;
                            }
                        }
                    }
                }
            }
        }
        //insert replinks
        foreach ($lr as $guid => $resource) {
            $entity = get_entity($guid);
            $lr[$guid]->insertReplinks($entity, $lr);
        }
    }
    krsort($lr);
    $guids = array_keys($lr);
    file_put_contents($IOdir . 'guids', serialize($guids));
    //it saves guids in the file 'guids'
    if (PHP_OS == "Linux" && posix_getuid() == fileowner($IOdir . 'guids')) {
        chmod($IOdir . 'guids', 0666);
    }
    //set rw permissions for everybody for this file
    file_put_contents($IOdir . 'lr', serialize($lr));
    //it saves resources in the file 'lr'
    if (PHP_OS == "Linux" && posix_getuid() == fileowner($IOdir . 'lr')) {
        chmod($IOdir . 'lr', 0666);
    }
    //set rw permissions for everybody for this file
    file_put_contents($outputfile, "Got snapshot...\n\n", FILE_APPEND);
    return "OK";
}
Ejemplo n.º 6
0
 private function getEntityProperty($entity, $property)
 {
     global $CONFIG;
     switch ($property) {
         case 'userIcon':
             if ($entity->getSubtype() == "PrivateContact") {
                 //          $value = $CONFIG->url . "mod/westorElggMan/graphics/contact.png";
                 $value = "../graphics/contact.png";
             } else {
                 $value = westorElggMan_getIcon($entity, 'topbar');
                 // deliver own default graphics for shorter url
                 if (strpos($value, 'defaulttopbar.gif') || !$value) {
                     $value = "../graphics/d.gif";
                 }
             }
             //          $value = $entity->getIcon('topbar')
             //            ? $entity->getIcon('topbar') : $CONFIG->url . "mod/westorElggMan/graphics/inactiveuser.png";
             break;
         case 'smsIcon':
             if ($this->getEntityProperty($entity, elgg_echo('ElggMan_:cMobile')) != '') {
                 $value = "../graphics/mobil.png";
             } else {
                 $value = "";
             }
             break;
         case elgg_echo('ElggMan:displayname'):
             if ($entity->getSubtype() == "PrivateContact") {
                 $value = $entity->user_last_name ? $entity->user_last_name : '';
             } else {
                 $value = $entity->display_name ? $entity->display_name : ($entity->name ? $entity->name : '');
             }
             break;
         case elgg_echo('ElggMan_:cUserName'):
             $value = $entity->username ? $entity->username : '';
             break;
         case elgg_echo('ElggMan_:cEmail'):
             if ($entity->getSubtype() == "PrivateContact") {
                 $value = strtoupper($entity->user_email) != 'NULL' ? $entity->user_email : '';
             } else {
                 $value = $entity->contactemail ? $entity->contactemail : ($entity->email ? $entity->email : '');
             }
             break;
         case elgg_echo('ElggMan_:cMobile'):
             if ($entity->getSubtype() == "PrivateContact") {
                 $value = $entity->mobil && strtoupper($entity->mobil) != 'NULL' ? $entity->mobil : '';
             } else {
                 $value = get_metadata_byname($entity->getGUID(), 'mobile')->value ? get_metadata_byname($entity->getGUID(), 'mobile')->value : '';
             }
             break;
         case elgg_echo('ElggMan_:cSince'):
             $value = $entity->time_created ? substr(date("c", $entity->time_created), 0, 10) : '';
             break;
         case elgg_echo('ElggMan_:cLastAction'):
             $value = $entity->last_action ? substr(date("c", $entity->last_action), 0, 10) : '';
             break;
         case elgg_echo('ElggMan_:cLastLogin'):
             $value = $entity->last_login ? substr(date("c", $entity->last_login), 0, 10) : '';
             break;
         case elgg_echo('ElggMan_:cLocation'):
             $location = $entity->location;
             if (is_array($location)) {
                 $location = implode(', ', $location);
             }
             $value = $location ? $location : '';
             break;
         default:
     }
     // switch
     return $value;
 }
Ejemplo n.º 7
0
 /**
  * Get a given piece of metadata.
  * 
  * @param string $name
  */
 public function getMetaData($name)
 {
     if ((int) $this->guid > 0) {
         $md = get_metadata_byname($this->getGUID(), $name);
     } else {
         if (isset($this->temp_metadata[$name])) {
             return $this->temp_metadata[$name];
         }
     }
     if ($md && !is_array($md)) {
         return $md->value;
     } else {
         if ($md && is_array($md)) {
             return metadata_array_to_values($md);
         }
     }
     return null;
 }
 if ($new_field_name) {
     // this is duplicating an existing field
     $form_action = 'add';
     $field_id = 0;
     $internal_name = $new_field_name;
 } else {
     $form_action = 'change';
     $field_id = $field->getGUID();
     $internal_name = $field->internal_name;
 }
 $form_title = $field->title;
 $description = $field->description;
 $field_type = $field->field_type;
 // must do this because Elgg has trouble with metadata set to "0"
 // in Elgg 1.5
 $m = get_metadata_byname($field->getGUID(), 'default_access');
 if ($m) {
     $default_access = $m->value;
     if ($default_access !== '') {
         $field_access = (int) $default_access;
     } else {
         $field_access = '';
     }
 } else {
     $field_access = '';
 }
 $default_value = $field->default_value;
 $is_keyword_tag = $field->is_keyword_tag;
 if (in_array($field_type, array('url', 'email', 'aim', 'msn', 'skype', 'icq'))) {
     $contact_type = $field_type;
     $field_type = 'contact';
Ejemplo n.º 9
0
 * Tidypics ajax upload form body
 *
 * @uses $vars['entity']
 */
$album = $vars['entity'];
$ts = time();
$batch = time();
$tidypics_token = md5(session_id() . get_site_secret() . $ts . elgg_get_logged_in_user_entity()->salt);
$basic_uploader_url = current_page_url() . '/basic';
$maxfilesize = (double) elgg_get_plugin_setting('maxfilesize', 'tidypics');
if (!$maxfilesize) {
    $maxfilesize = 5;
}
$quota = elgg_get_plugin_setting('quota', 'tidypics');
if ($quota) {
    $image_repo_size_md = get_metadata_byname($album->container_guid, "image_repo_size");
    $image_repo_size = (int) $image_repo_size_md->value;
    $image_repo_size = $image_repo_size / 1024 / 1024;
    $quote_percentage = round(100 * ($image_repo_size / $quota));
    // for small quotas, so one decimal place
    if ($quota < 10) {
        $image_repo_size = sprintf('%.1f', $image_repo_size);
    } else {
        $image_repo_size = round($image_repo_size);
    }
    if ($image_repo_size > $quota) {
        $image_repo_size = $quota;
    }
}
?>
 
            </div>
            <?php 
$lc = 0;
if (isset($profs)) {
    //display member avatars
    foreach ($profs as $members) {
        if ($lc > 3) {
            break;
        }
        $query1 = "SELECT * FROM {$CONFIG->dbprefix}_content_item_discrimination WHERE guid = \"" . $members->guid . "\"";
        $result1 = get_data($query1);
        $gid = $members->guid;
        if ($result1 == NULL) {
            $metaaff = get_metadata_byname($gid, 'Affiliation');
            $metacou = get_metadata_byname($gid, 'Location');
            echo "<div class=\"filerepo_file\">";
            echo "\t\t<div class=\"filerepo_icon\">\n";
            echo elgg_view("profile/icon", array('entity' => $members, 'size' => 'small'));
            echo "</div>";
            echo "\t\t<div class=\"filerepo_title_owner_wrapper\">\n";
            echo "\t\t<div class=\"filerepo_title\"><b><a href=\"" . $vars['url'] . "pg/profile/" . $members->username . "\">" . $members->name . "</a></b>";
            if ($metaaff->value != NULL) {
                echo "<br />Affiliation: " . $metaaff->value;
            }
            if ($metacou->value != NULL) {
                echo "<br />Country: " . $metacou->value;
            }
            echo "</div>";
            echo "</div>";
            echo "</div>";
Ejemplo n.º 11
0
<?php

require_once dirname(dirname(dirname(__FILE__))) . "/lib/phpFlickr/phpFlickr.php";
$f = new phpFlickr("26b2abba37182aca62fe0eb2c7782050");
// Load Elgg engine
include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";
$username = get_input('username');
if (!empty($username)) {
    $temp_user = get_user_by_username($username);
} else {
    $temp_user = get_loggedin_user();
}
$flickr_username = get_metadata_byname($temp_user->guid, "flickr_username");
if (empty($flickr_username)) {
    register_error("No Flickr username set");
    echo "<pre>No flickr username set: {$temp_user->guid}";
    die;
    forward("/");
    die;
}
$flickr_user = $f->people_findByUsername($flickr_username->value);
// Get the friendly URL of the user's photos
$photos_url = $f->urls_getUserPhotos($flickr_user["id"]);
if (!empty($flickr_user)) {
    $recent = $f->people_getPublicPhotos($flickr_user['id'], NULL, NULL, 5);
} else {
    echo "user not found";
    die;
}
//echo "<pre>"; var_dump( $recent ); echo "</pre>";
//echo "<pre>"; var_dump( $user ); echo "</pre>";
Ejemplo n.º 12
0
function form_get_input_display_item($form, $field, $data = null, $prepopulate = true, $format_view = 'form/display_field')
{
    global $CONFIG;
    $internalname = $field->internal_name;
    $access_id = '';
    //print($internalname.':');
    if (!isset($field->admin_only) || !$field->admin_only || isadminloggedin()) {
        if (!isset($data)) {
            $data = array();
        }
        if ($prepopulate) {
            if (isset($data[$internalname])) {
                $value = $data[$internalname]->value;
                $access_id = $data[$internalname]->access_id;
            } else {
                $value = $field->default_value;
                // must do this because Elgg has trouble with metadata set to "0"
                // in Elgg 1.5 using a simple reference
                $m = get_metadata_byname($field->getGUID(), 'default_access');
                if ($m && ($m->value || $m->value === 0 || $m->value === '0')) {
                    $access_id = $m->value;
                } else {
                    $access_id = get_default_access();
                }
            }
        } else {
            $value = '';
        }
        // use strtolower to get around the Elgg metadata case problem
        $field_type = strtolower($field->field_type);
        if ($field_type == 'image_upload') {
            if ($value) {
                $image_url = $CONFIG->wwwroot . 'mod/file/thumbnail.php?size=small&file_guid=' . $value;
                $view_prefix = '<p><img src="' . $image_url . '"></p>';
                //$view_prefix = $value.print_r($image_entity,true).elgg_view('graphics/icon',array('entity'=>$image_entity,'size'=>'small'));
            } else {
                $view_prefix = '';
            }
        }
        $formfieldname = 'form_data_' . $internalname;
        $vars = array('internalname' => $formfieldname, 'value' => $value);
        //print($field->internal_name.','.$field->field_type.','.$field->choice_type.','.$field->default_value.'<br />');
        if (strtolower($field->field_type) == 'choices') {
            $vars['orientation'] = $field->orientation;
            $field_type = $field->choice_type;
            $choices = form_get_field_choices($field->getGUID());
            if ($choices) {
                if ($choices[0]->label) {
                    $options_values = array();
                    if (!$prepopulate && $field_type == 'pulldown') {
                        // force an empty default option
                        $options_values[''] = '';
                    }
                    foreach ($choices as $choice) {
                        $options_values[$choice->value] = form_choice_t($form, $field, $choice);
                    }
                    $vars['options_values'] = $options_values;
                    $vars['options'] = $options_values;
                } else {
                    $options = array();
                    if (!$prepopulate && $field_type == 'pulldown') {
                        // force an empty default option
                        $options[''] = '';
                    }
                    foreach ($choices as $choice) {
                        $options[$choice->value] = $choice->value;
                    }
                    $vars['options'] = $options;
                }
            }
        } else {
            $field_type = $field->field_type;
        }
        //print $field_type.'#';
        $view = form_field_type_to_view($field_type, "input");
        //print ($field_type.':'.$view.'; ');
        $html = elgg_view($format_view, array('field' => $view_prefix . elgg_view($view, $vars), 'title' => form_field_t($form, $field, 'title'), 'description' => form_field_t($form, $field, 'description')));
    } else {
        if ($prepopulate) {
            if (isset($data[$internalname]) && $data[$internalname]->value) {
                $value = $data[$internalname]->value;
            } else {
                $value = $field->default_value;
            }
        } else {
            $value = '';
        }
        $html = elgg_view('input/hidden', array('internalname' => $internalname, 'value' => $value));
    }
    $item = new StdClass();
    $item->default_access = $access_id;
    $item->internalname = $field->internal_name;
    $item->html = $html;
    return $item;
}
Ejemplo n.º 13
0
/**
 * Grab array of EXIF data for display
 * 
 * @param int $file_guid GUID of TidypicsImage
 * @return array|false
 */
function tp_exif_formatted($file_guid)
{
    $metadata_exif = get_metadata_byname($file_guid, "tp_exif");
    if (!$metadata_exif) {
        // //try to load it from the file if its not in the database
        $file = new ElggFile($file_guid);
        td_get_exif($file);
        unset($file);
        $metadata_exif = get_metadata_byname($file_guid, "tp_exif");
    }
    if (!$metadata_exif) {
        return false;
    }
    $exif = unserialize($metadata_exif["value"]);
    $model = $exif['Model'];
    if (!$model) {
        $model = "N/A";
    }
    $exif_data['Model'] = $model;
    $exposure = $exif['ExposureTime'];
    if (!$exposure) {
        $exposure = "N/A";
    }
    $exif_data['Shutter'] = $exposure;
    //got the code snippet below from http://www.zenphoto.org/support/topic.php?id=17
    //convert the raw values to understandible values
    $Fnumber = explode("/", $exif['FNumber']);
    if ($Fnumber[1] != 0) {
        $Fnumber = $Fnumber[0] / $Fnumber[1];
    } else {
        $Fnumber = 0;
    }
    if (!$Fnumber) {
        $Fnumber = "N/A";
    } else {
        $Fnumber = "f/{$Fnumber}";
    }
    $exif_data['Aperture'] = $Fnumber;
    $iso = $exif['ISOSpeedRatings'];
    if (!$iso) {
        $iso = "N/A";
    }
    $exif_data['ISO Speed'] = $iso;
    $Focal = explode("/", $exif['FocalLength']);
    if ($Focal[1] != 0) {
        $Focal = $Focal[0] / $Focal[1];
    } else {
        $Focal = 0;
    }
    if (!$Focal || round($Focal) == "0") {
        $Focal = 0;
    }
    if (round($Focal) == 0) {
        $Focal = "N/A";
    } else {
        $Focal = round($Focal) . "mm";
    }
    $exif_data['Focal Length'] = $Focal;
    $captured = $exif['DateTime'];
    if (!$captured) {
        $captured = "N/A";
    }
    $exif_data['Captured'] = $captured;
    return $exif_data;
}
Ejemplo n.º 14
0
function vazco_avatar_cropicon($event, $object_type, $object)
{
    $metadata = get_metadata_byname(get_loggedin_userid(), 'avatar');
    delete_metadata($metadata->id);
}
Ejemplo n.º 15
0
/**
 * Check if this image pushes user over quota
 *
 * @param int $image_size
 * @param int $owner_guid
 * @return bool false = exceed quota
 */
function tp_upload_check_quota($image_size, $owner_guid)
{
    static $quota;
    if (!isset($quota)) {
        $quota = elgg_get_plugin_setting('quota', 'tidypics');
        $quota = 1024 * 1024 * $quota;
    }
    if ($quota == 0) {
        // no quota
        return true;
    }
    $image_repo_size_md = get_metadata_byname($owner_guid, "image_repo_size");
    $image_repo_size = (int) $image_repo_size_md->value;
    return $image_repo_size + $image_size < $quota;
}
function update_data_snapshot($req)
{
    set_time_limit(0);
    global $CONFIG;
    include $CONFIG->path . "mod/profile_manager/actions/members/config.php";
    include $CONFIG->path . "mod/profile_manager/actions/members/classes.php";
    $query = "SELECT distinct e.* from elggentities e join elggusers_entity u on e.guid = u.guid JOIN (SELECT subm1.*, s1.string FROM elggmetadata subm1 JOIN elggmetastrings s1 ON subm1.value_id = s1.id) AS m1 ON e.guid = m1.entity_guid where ((m1.name_id='440' AND m1.string IN ('356'))) and ( (1 = 1) and e.enabled='yes') and ( (1 = 1) and m1.enabled='yes') order by e.time_created desc";
    $entities = get_data($query, "entity_row_to_elggstar");
    foreach ($entities as $entity) {
        $name = $entity->getGUID();
        $lr[$name] = new LearningResource();
        $categorized_fields = profile_manager_get_categorized_fields($entity, true);
        //print_r("<br><br>$categorized_fields");
        $cats = $categorized_fields['categories'];
        $fields = $categorized_fields['fields'];
        //print_r($cats);
        if (!empty($fields)) {
            foreach ($cats as $cat_guid => $cat) {
                foreach ($fields[$cat_guid] as $field) {
                    $metadata_name = $field->metadata_name;
                    // get options
                    $options = $field->getOptions();
                    // get type of field
                    if ($field->user_editable == "no") {
                        $valtype = "non_editable";
                    } else {
                        $valtype = $field->metadata_type;
                    }
                    // make title
                    $title = $field->getTitle();
                    // get value
                    if ($metadata = get_metadata_byname($entity->getGUID(), $metadata_name)) {
                        //print_r($metadata);
                        if (is_array($metadata)) {
                            $value = '';
                            foreach ($metadata as $md) {
                                if (!empty($value)) {
                                    $value .= ', ';
                                }
                                $value .= $md->value;
                                $access_id = $md->access_id;
                            }
                        } else {
                            $value = $metadata->value;
                            $access_id = $metadata->access_id;
                        }
                    } else {
                        $value = '';
                        $access_id = ACCESS_DEFAULT;
                    }
                    //print_r("<br>$title=$value");
                    $lr[$name]->insertMetadata($title, $value);
                }
            }
        }
        $lr[$name]->setName($entity->get('name'));
        $lr[$name]->setUsername($entity->get('username'));
    }
    foreach ($entities as $entity) {
        $name = $entity->getGUID();
        $lr[$name]->insertReplinks($entity, $lr);
    }
    file_put_contents($IOdir . 'lr', serialize($lr));
    //it saves resources in the file 'lr'
    return true;
}
Ejemplo n.º 17
0
/**
 * Set the validation status for a user.
 *
 * @param bool $status Validated (true) or false
 * @param string $method Optional method to say how a user was validated
 * @return bool
 */
function set_user_validation_status($user_guid, $status, $method = '')
{
    if (!$status) {
        $method = '';
    }
    if ($status) {
        if (create_metadata($user_guid, 'validated', $status, '', 0, ACCESS_PUBLIC) && create_metadata($user_guid, 'validated_method', $method, '', 0, ACCESS_PUBLIC)) {
            return true;
        }
    } else {
        $validated = get_metadata_byname($user_guid, 'validated');
        $validated_method = get_metadata_byname($user_guid, 'validated_method');
        if ($validated && $validated_method && delete_metadata($validated->id) && delete_metadata($validated_method->id)) {
            return true;
        }
    }
    return false;
}
 $result_curl = curl_exec($ch);
 $status = curl_getinfo($ch);
 curl_close($ch);
 $resultPHP = json_decode($result_curl);
 $sesameID = $resultPHP->data->ID;
 if (strpos($friend->meducator1, "http://") === false) {
     $fakeuri = str_replace("\"", " ", $nik21);
 } else {
     $fakeuri = str_replace("http://", "http://purl.org/meducator/parents/", $fakeuri);
 }
 fwrite($ourFileHandle, "<mdc:hasRepurposingContext>\r\n");
 fwrite($ourFileHandle, "<mdc:RepurposingContext>\r\n");
 fwrite($ourFileHandle, "<mdc:repurposedFrom ");
 fwrite($ourFileHandle, "rdf:resource=\"{$sesameID}\" />\r\n");
 $niksol1 = 'meducator27';
 $metadata2 = get_metadata_byname($nik, $niksol1);
 if ($metadata2->value != NULL) {
     fwrite($ourFileHandle, "<mdc:repurposingDescription>");
     fwrite($ourFileHandle, $metadata2->value);
     fwrite($ourFileHandle, "</mdc:repurposingDescription>\r\n");
 }
 $niksol21 = $entity->meducator26;
 if (is_array($niksol21) && $niksol21 != NULL) {
     foreach ($niksol21 as $niksol2111) {
         $conx = "rdf:resource=\"" . $map[$niksol2111];
         fwrite($ourFileHandle, "<mdc:fromRepurposingContext ");
         fwrite($ourFileHandle, $conx);
         fwrite($ourFileHandle, "\" /> \r\n");
     }
 } else {
     if (!is_array($niksol21) && $niksol21 != NULL) {