Пример #1
0
/**
 * This function sets the user profile item.
 * 
 * @author Fawaz Tahir <*****@*****.**>
 * @global array $cb_profile_item_callbacks
 * @param int $id
 * @param string $type
 * @param int $uid
 * @return boolean
 */
function set_user_profile_item($id, $type, $uid = null)
{
    global $cb_profile_item_callbacks;
    if (is_null($uid)) {
        $uid = userid();
    }
    if ($uid) {
        if ($id or $type) {
            if (isset($cb_profile_item_callbacks[$type]) and isset($cb_profile_item_callbacks[$type][0]) and function_exists($cb_profile_item_callbacks[$type][0])) {
                $result = $cb_profile_item_callbacks[$type][0]($id);
                if ($result) {
                    $profile_item['type'] = $type;
                    $profile_item['id'] = $id;
                    $jepi = json_encode($profile_item);
                    $field = array('profile_item' => $jepi);
                    if (is_profile_item($id, $type)) {
                        $update = true;
                    } else {
                        $update = db_update(tbl('user_profile'), $field, " userid = '" . userid() . "' ");
                    }
                    if ($update) {
                        e(lang('Profile item has been updated.'), 'm');
                        return true;
                    } else {
                        e(lang('Unable to update profile item.'));
                        return false;
                    }
                } else {
                    return false;
                }
            }
        }
    }
    e(lang('Invalid action'));
    return false;
}
Пример #2
0
/**
 * Make profile item link for photo
 */
function _make_profile_item_link($photo)
{
    if (!userid()) {
        return false;
    }
    global $cbphoto;
    /* Need to figure out a automated way to remove duplicate entries, for time time will work*/
    $remove_query_variables = array('profile_item', 'item_type', 'profile_remove_item', 'callback_id');
    if (userid() != $photo['userid']) {
        return false;
    }
    if (!is_profile_item($photo['photo_id'], 'p')) {
        $data = array('title' => lang('Make profile item'), 'link' => '?profile_item=' . $photo['photo_id'] . '&item_type=p', 'remove_query_variables' => $remove_query_variables);
    } else {
        $data = array('title' => lang('Remove profile item'), 'link' => '?profile_remove_item=' . $photo['photo_id'] . '&item_type=p', 'remove_query_variables' => $remove_query_variables);
    }
    return $data;
}