From d755fb83a7b32b7d372fa851572391644bdaa35e Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 19 Feb 2014 21:04:20 +0100 Subject: Doxygen include/attach.php Some Doxygen as far as I understood and some styleguides. --- include/attach.php | 196 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 126 insertions(+), 70 deletions(-) diff --git a/include/attach.php b/include/attach.php index af1159957..a3ee3f0ef 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1,7 +1,8 @@ - false); @@ -121,6 +142,22 @@ function attach_count_files($channel_id, $observer, $hash = '', $filename = '', } +/** + * @brief Returns a list of files/attachments. + * + * @param $channel_id + * @param $observer + * @param $hash (optional) + * @param $filename (optional) + * @param $filetype (optional) + * @param $orderby + * @param $start + * @param $entries + * @return array + * $ret['success'] boolean + * $ret['results'] array with results, or false + * $ret['message'] string with error messages if any + */ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $filetype = '', $orderby = 'created desc', $start = 0, $entries = 0) { $ret = array('success' => false); @@ -157,10 +194,17 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $ } -// Find an attachment by hash and revision. Returns the entire attach structure including data. -// This could exhaust memory so most useful only when immediately sending the data. - -function attach_by_hash($hash,$rev = 0) { +/** + * @brief Find an attachment by hash and revision. + * + * Returns the entire attach structure including data. + * + * This could exhaust memory so most useful only when immediately sending the data. + * + * @param $hash + * @param $rev + */ +function attach_by_hash($hash, $rev = 0) { $ret = array('success' => false); @@ -181,7 +225,7 @@ function attach_by_hash($hash,$rev = 0) { return $ret; } - if(! perm_is_allowed($r[0]['uid'],get_observer_hash(),'view_storage')) { + if(! perm_is_allowed($r[0]['uid'], get_observer_hash(), 'view_storage')) { $ret['message'] = t('Permission denied.'); return $ret; } @@ -190,14 +234,13 @@ function attach_by_hash($hash,$rev = 0) { // Now we'll see if we can access the attachment - $r = q("SELECT * FROM attach WHERE hash = '%s' and uid = %d $sql_extra LIMIT 1", dbesc($hash), intval($r[0]['uid']) ); if(! $r) { - $ret['message'] = t('Permission denied.'); + $ret['message'] = t('Permission denied.'); return $ret; } @@ -207,9 +250,16 @@ function attach_by_hash($hash,$rev = 0) { } - - -function attach_by_hash_nodata($hash,$rev = 0) { +/** + * @brief Find an attachment by hash and revision. + * + * Returns the entire attach structure excluding data. + * + * @see attach_by_hash() + * @param $hash + * @param $ref + */ +function attach_by_hash_nodata($hash, $rev = 0) { $ret = array('success' => false); @@ -244,7 +294,7 @@ function attach_by_hash_nodata($hash,$rev = 0) { ); if(! $r) { - $ret['message'] = t('Permission denied.'); + $ret['message'] = t('Permission denied.'); return $ret; } @@ -254,17 +304,21 @@ function attach_by_hash_nodata($hash,$rev = 0) { } - - - -function attach_store($channel,$observer_hash,$options = '',$arr = null) { - +/** + * @brief + * + * @param $channel channel array of owner + * @param $observer_hash hash of current observer + * @param $options (optional) + * @param $arr (optional) + */ +function attach_store($channel, $observer_hash, $options = '', $arr = null) { $ret = array('success' => false); $channel_id = $channel['channel_id']; $sql_options = ''; - if(! perm_is_allowed($channel_id,get_observer_hash(),'write_storage')) { + if(! perm_is_allowed($channel_id,get_observer_hash(), 'write_storage')) { $ret['message'] = t('Permission denied.'); return $ret; } @@ -308,7 +362,7 @@ function attach_store($channel,$observer_hash,$options = '',$arr = null) { if($options === 'update' && $arr && array_key_exists('revision',$arr)) $sql_options = " and revision = " . intval($arr['revision']) . " "; - $x =q("select id, aid, uid, filename, filetype, filesize, hash, revision, folder, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where hash = '%s' and uid = %d $sql_options limit 1", + $x = q("select id, aid, uid, filename, filetype, filesize, hash, revision, folder, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where hash = '%s' and uid = %d $sql_options limit 1", dbesc($arr['hash']), intval($channel_id) ); @@ -329,14 +383,14 @@ function attach_store($channel,$observer_hash,$options = '',$arr = null) { return $ret; } - $limit = service_class_fetch($channel_id,'attach_upload_limit'); + $limit = service_class_fetch($channel_id, 'attach_upload_limit'); if($limit !== false) { $r = q("select sum(filesize) as total from attach where aid = %d ", intval($channel['channel_account_id']) ); if(($r) && (($r[0]['total'] + $filesize) > ($limit - $existing_size))) { - $ret['message'] = upgrade_message(true).sprintf(t("You have reached your limit of %1$.0f Mbytes attachment storage."),$limit / 1024000); + $ret['message'] = upgrade_message(true) . sprintf(t("You have reached your limit of %1$.0f Mbytes attachment storage."), $limit / 1024000); @unlink($src); return $ret; } @@ -379,7 +433,6 @@ function attach_store($channel,$observer_hash,$options = '',$arr = null) { dbesc($x[0]['deny_gid']) ); } - elseif($options === 'update') { $r = q("update attach set filename = '%s', filetype = '%s', edited = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' where id = %d and uid = %d limit 1", @@ -394,7 +447,6 @@ function attach_store($channel,$observer_hash,$options = '',$arr = null) { intval($x[0]['uid']) ); } - else { $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, filetype, filesize, revision, data, created, edited, allow_cid, allow_gid,deny_cid, deny_gid ) VALUES ( %d, %d, '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", @@ -441,12 +493,11 @@ function attach_store($channel,$observer_hash,$options = '',$arr = null) { return $ret; } - /** * Read a virtual directory and return contents, checking permissions of all parent components. * @function z_readdir * @param integer $channel_id - * @param string $observer_hash + * @param string $observer_hash hash of current observer * @param string $pathname * @param string $parent_hash (optional) * @@ -455,18 +506,16 @@ function attach_store($channel,$observer_hash,$options = '',$arr = null) { * $ret['message'] = error message if success is false * $ret['data'] = array of attach DB entries without data component */ - -function z_readdir($channel_id,$observer_hash,$pathname, $parent_hash = '') { +function z_readdir($channel_id, $observer_hash, $pathname, $parent_hash = '') { $ret = array('success' => false); - if(! perm_is_allowed($r[0]['uid'],get_observer_hash(),'view_storage')) { + if(! perm_is_allowed($r[0]['uid'], get_observer_hash(), 'view_storage')) { $ret['message'] = t('Permission denied.'); return $ret; } - - if(strpos($pathname,'/')) { - $paths = explode('/',$pathname); + if(strpos($pathname, '/')) { + $paths = explode('/', $pathname); if(count($paths) > 1) { $curpath = array_shift($paths); @@ -480,7 +529,7 @@ function z_readdir($channel_id,$observer_hash,$pathname, $parent_hash = '') { return $ret; } - return z_readdir($channel_id,$observer_hash,implode('/',$paths),$r[0]['hash']); + return z_readdir($channel_id, $observer_hash, implode('/', $paths), $r[0]['hash']); } } else @@ -501,20 +550,17 @@ function z_readdir($channel_id,$observer_hash,$pathname, $parent_hash = '') { return $ret; } - /** * @function attach_mkdir($channel,$observer_hash,$arr); * - * Create directory + * @brief Create directory. * * @param $channel channel array of owner * @param $observer_hash hash of current observer * @param $arr parameter array to fulfil request - * * Required: * $arr['filename'] * $arr['folder'] // hash of parent directory, empty string for root directory - * * Optional: * $arr['hash'] // precumputed hash for this node * $arr['allow_cid'] @@ -522,8 +568,7 @@ function z_readdir($channel_id,$observer_hash,$pathname, $parent_hash = '') { * $arr['deny_cid'] * $arr['deny_gid'] */ - -function attach_mkdir($channel,$observer_hash,$arr = null) { +function attach_mkdir($channel, $observer_hash, $arr = null) { $ret = array('success' => false); $channel_id = $channel['channel_id']; @@ -534,10 +579,9 @@ function attach_mkdir($channel,$observer_hash,$arr = null) { logger('attach_mkdir: basepath: ' . $basepath); if(! is_dir($basepath)) - mkdir($basepath,STORAGE_DEFAULT_PERMISSIONS,true); + mkdir($basepath,STORAGE_DEFAULT_PERMISSIONS, true); - - if(! perm_is_allowed($channel_id, $observer_hash,'write_storage')) { + if(! perm_is_allowed($channel_id, $observer_hash, 'write_storage')) { $ret['message'] = t('Permission denied.'); return $ret; } @@ -547,10 +591,8 @@ function attach_mkdir($channel,$observer_hash,$arr = null) { return $ret; } - $arr['hash'] = (($arr['hash']) ? $arr['hash'] : random_string()); - // Check for duplicate name. // Check both the filename and the hash as we will be making use of both. @@ -576,7 +618,6 @@ function attach_mkdir($channel,$observer_hash,$arr = null) { $sql_options = permissions_sql($channel['channel_id']); do { - $r = q("select filename, hash, flags, folder from attach where uid = %d and hash = '%s' and ( flags & %d ) $sql_options limit 1", intval($channel['channel_id']), @@ -594,7 +635,6 @@ function attach_mkdir($channel,$observer_hash,$arr = null) { $lfile = $r[0]['folder']; } while ( ($r[0]['folder']) && ($r[0]['flags'] & ATTACH_FLAG_DIR)) ; $path = $basepath . '/' . $lpath; - } else $path = $basepath . '/'; @@ -625,7 +665,7 @@ function attach_mkdir($channel,$observer_hash,$arr = null) { ); if($r) { - if(mkdir($path,STORAGE_DEFAULT_PERMISSIONS,true)) { + if(mkdir($path,STORAGE_DEFAULT_PERMISSIONS, true)) { $ret['success'] = true; $ret['data'] = $arr; } @@ -641,9 +681,18 @@ function attach_mkdir($channel,$observer_hash,$arr = null) { } - - -function attach_change_permissions($channel_id,$resource,$allow_cid,$allow_gid,$deny_cid,$deny_gid,$recurse = false) { +/** + * @brief Changes permissions of a file. + * + * @param $channel_id + * @param $resource + * @param $allow_cid + * @param $allow_gid + * @param $deny_cid + * @param $deny_gid + * @param $recurse + */ +function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $recurse = false) { $r = q("select hash, flags from attach where hash = '%s' and uid = %d limit 1", dbesc($resource), @@ -661,7 +710,7 @@ function attach_change_permissions($channel_id,$resource,$allow_cid,$allow_gid,$ ); if($r) { foreach($r as $rr) { - attach_change_permissions($channel_id,$resource,$allow_cid,$allow_gid,$deny_cid,$deny_gid,$recurse); + attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $recurse); } } } @@ -679,9 +728,13 @@ function attach_change_permissions($channel_id,$resource,$allow_cid,$allow_gid,$ return; } - - -function attach_delete($channel_id,$resource) { +/** + * @brief Delete a file. + * + * @param $channel_id + * @param $resource + */ +function attach_delete($channel_id, $resource) { $c = q("select channel_address from channel where channel_id = %d limit 1", @@ -706,7 +759,7 @@ function attach_delete($channel_id,$resource) { ); if($x) { foreach($x as $xx) { - attach_delete($channel_id,$xx['hash']); + attach_delete($channel_id, $xx['hash']); } } } @@ -733,8 +786,12 @@ function attach_delete($channel_id,$resource) { return; } - - +/** + * @brief Returns path to file in cloud/. + * + * @param $arr + * @return string with the path the file to cloud/ + */ function get_cloudpath($arr) { $basepath = 'cloud/'; @@ -746,7 +803,6 @@ function get_cloudpath($arr) { $basepath .= $r[0]['channel_address'] . '/'; } - $path = $basepath; if($arr['folder']) { @@ -772,20 +828,20 @@ function get_cloudpath($arr) { } while ( ($r[0]['folder']) && ($r[0]['flags'] & ATTACH_FLAG_DIR)) ; $path .= $lpath; - } $path .= $arr['filename']; return $path; - } - - - +/** + * + * @param $in + * @param $out + */ function pipe_streams($in, $out) { $size = 0; - while (!feof($in)) - $size += fwrite($out,fread($in,8192)); + while (!feof($in)) + $size += fwrite($out, fread($in,8192)); return $size; -} \ No newline at end of file +} -- cgit v1.2.3 From 9715176a56c0b8127e9c5045d26d13402c072ff8 Mon Sep 17 00:00:00 2001 From: tony baldwin Date: Wed, 19 Feb 2014 22:56:52 -0500 Subject: s/View remote profiles as webpages/Do not view remote profiles in frames/g --- mod/settings.php | 2 +- util/messages.po | 2 +- view/de/messages.po | 2 +- view/de/strings.php | 2 +- view/it/messages.po | 2 +- view/it/strings.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mod/settings.php b/mod/settings.php index 5b0a8e8f2..945a75134 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -758,7 +758,7 @@ function settings_content(&$a) { '$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds, no maximum')), '$itemspage' => array('itemspage', t("Maximum number of conversations to load at any time:"), $itemspage, t('Maximum of 100 items')), '$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, ''), - '$chanview_full' => array('chanview_full', t('View remote profiles as webpages'), $chanview, t('By default open in a sub-window of your own site')), + '$chanview_full' => array('chanview_full', t('Do not view remote profiles in frames'), $chanview, t('By default open in a sub-window of your own site')), '$theme_config' => $theme_config, )); diff --git a/util/messages.po b/util/messages.po index 5b8249a48..da8ce5868 100644 --- a/util/messages.po +++ b/util/messages.po @@ -5979,7 +5979,7 @@ msgid "Don't show emoticons" msgstr "" #: ../../mod/settings.php:761 -msgid "View remote profiles as webpages" +msgid "Do not view remote profiles in frames" msgstr "" #: ../../mod/settings.php:761 diff --git a/view/de/messages.po b/view/de/messages.po index 7acbdcdd2..f98726f4d 100644 --- a/view/de/messages.po +++ b/view/de/messages.po @@ -5994,7 +5994,7 @@ msgid "Don't show emoticons" msgstr "Emoticons nicht zeigen" #: ../../mod/settings.php:761 -msgid "View remote profiles as webpages" +msgid "Do not view remote profiles in frames" msgstr "" #: ../../mod/settings.php:761 diff --git a/view/de/strings.php b/view/de/strings.php index ac1abc8f7..4001d78be 100644 --- a/view/de/strings.php +++ b/view/de/strings.php @@ -1410,7 +1410,7 @@ $a->strings["Minimum of 10 seconds, no maximum"] = "Minimum 10 Sekunden, kein Ma $a->strings["Maximum number of conversations to load at any time:"] = "Maximale Anzahl von Unterhaltungen, die auf einmal geladen werden sollen:"; $a->strings["Maximum of 100 items"] = "Maximum: 100 Beiträge"; $a->strings["Don't show emoticons"] = "Emoticons nicht zeigen"; -$a->strings["View remote profiles as webpages"] = ""; +$a->strings["Do not view remote profiles in frames"] = ""; $a->strings["By default open in a sub-window of your own site"] = ""; $a->strings["Nobody except yourself"] = "Niemand außer Dir selbst"; $a->strings["Only those you specifically allow"] = "Nur die, denen Du es explizit erlaubst"; diff --git a/view/it/messages.po b/view/it/messages.po index 6d05e46dd..98d531562 100644 --- a/view/it/messages.po +++ b/view/it/messages.po @@ -5988,7 +5988,7 @@ msgid "Don't show emoticons" msgstr "Non mostrare le emoticons" #: ../../mod/settings.php:761 -msgid "View remote profiles as webpages" +msgid "Do not view remote profiles in frames" msgstr "Visualizza gli altri profili come normali pagine web" #: ../../mod/settings.php:761 diff --git a/view/it/strings.php b/view/it/strings.php index 060273ef2..42b91f2fa 100644 --- a/view/it/strings.php +++ b/view/it/strings.php @@ -1410,7 +1410,7 @@ $a->strings["Minimum of 10 seconds, no maximum"] = "Minimo 10 secondi, nessun li $a->strings["Maximum number of conversations to load at any time:"] = "Massimo numero di conversazioni da mostrare ogni volta:"; $a->strings["Maximum of 100 items"] = "Massimo 100"; $a->strings["Don't show emoticons"] = "Non mostrare le emoticons"; -$a->strings["View remote profiles as webpages"] = "Visualizza gli altri profili come normali pagine web"; +$a->strings["Do not view remote profiles in frames"] = "Visualizza gli altri profili come normali pagine web"; $a->strings["By default open in a sub-window of your own site"] = "Se non selezionato, i profili degli altri utenti sono mostrati dentro un riquadro nella pagina"; $a->strings["Nobody except yourself"] = "Nessuno tranne te"; $a->strings["Only those you specifically allow"] = "Solo chi riceve il mio permesso"; -- cgit v1.2.3 From a29b71547a1ceb12d77617d9b06ba074c1793755 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 19 Feb 2014 20:19:56 -0800 Subject: use a "fullscreen" icon for chanview full screen mode; add channel_menu selection and setting to the settings page. --- mod/settings.php | 20 +++++++++++++++++--- version.inc | 2 +- view/css/mod_settings.css | 14 ++++++++++++++ view/js/icon_translate.js | 1 + view/tpl/chanview.tpl | 2 +- view/tpl/settings.tpl | 19 +++++++++++++++++++ 6 files changed, 53 insertions(+), 5 deletions(-) diff --git a/mod/settings.php b/mod/settings.php index 5b0a8e8f2..6315e95f5 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -261,7 +261,7 @@ function settings_post(&$a) { $maxreq = ((x($_POST,'maxreq')) ? intval($_POST['maxreq']) : 0); $expire = ((x($_POST,'expire')) ? intval($_POST['expire']) : 0); $def_group = ((x($_POST,'group-selection')) ? notags(trim($_POST['group-selection'])) : ''); - + $channel_menu = ((x($_POST['channel_menu'])) ? htmlspecialchars_decode(trim($_POST['channel_menu'])) : ''); $expire_items = ((x($_POST,'expire_items')) ? intval($_POST['expire_items']) : 0); $expire_starred = ((x($_POST,'expire_starred')) ? intval($_POST['expire_starred']) : 0); @@ -403,7 +403,7 @@ function settings_post(&$a) { set_pconfig(local_user(),'system','post_profilechange', $post_profilechange); set_pconfig(local_user(),'system','blocktags',$blocktags); set_pconfig(local_user(),'system','hide_online_status',$hide_presence); - + set_pconfig(local_user(),'system','channel_menu',$channel_menu); $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d, channel_default_group = '%s', channel_r_stream = %d, channel_r_profile = %d, channel_r_photos = %d, channel_r_abook = %d, channel_w_stream = %d, channel_w_wall = %d, channel_w_tagwall = %d, channel_w_comment = %d, channel_w_mail = %d, channel_w_photos = %d, channel_w_chat = %d, channel_a_delegate = %d, channel_r_storage = %d, channel_w_storage = %d, channel_r_pages = %d, channel_w_pages = %d, channel_a_republish = %d, channel_a_bookmark = %d, channel_allow_cid = '%s', channel_allow_gid = '%s', channel_deny_cid = '%s', channel_deny_gid = '%s' where channel_id = %d limit 1", dbesc($username), @@ -911,6 +911,18 @@ function settings_content(&$a) { require_once('include/group.php'); $group_select = mini_group_select(local_user(),$channel['channel_default_group']); + require_once('include/menu.php'); + $m1 = menu_list(local_user()); + $menu = false; + if($m1) { + $menu = array(); + $current = get_pconfig(local_user(),'system','channel_menu'); + $menu[] = array('name' => '', 'selected' => ((! $current) ? true : false)); + foreach($m1 as $m) { + $menu[] = array('name' => htmlspecialchars($m['menu_name'],ENT_COMPAT,'UTF-8'), 'selected' => (($m['menu_name'] === $current) ? ' selected="selected" ' : false)); + } + } + $o .= replace_macros($stpl,array( '$ptitle' => t('Channel Settings'), @@ -981,7 +993,9 @@ function settings_content(&$a) { '$pagetype' => $pagetype, '$expert' => feature_enabled(local_user(),'expert'), '$hint' => t('Please enable expert mode (in Settings > Additional features) to adjust!'), - + '$lbl_misc' => t('Miscellaneous Settings'), + '$menus' => $menu, + '$menu_desc' => t('Personal menu to display in your channel pages'), )); call_hooks('settings_form',$o); diff --git a/version.inc b/version.inc index 4551fa398..9e1971efd 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2014-02-18.592 +2014-02-19.593 diff --git a/view/css/mod_settings.css b/view/css/mod_settings.css index 0d3dd36fe..5b0105204 100644 --- a/view/css/mod_settings.css +++ b/view/css/mod_settings.css @@ -35,3 +35,17 @@ margin-bottom: 15px; } +#settings-menu-desc { + font-weight: bold; + float: left; + width: 350px; +} + +#settings-channel-menu-div select { + float: left; +} + +#settings-channel-menu-end { + clear: both; + margin-bottom: 15px; +} \ No newline at end of file diff --git a/view/js/icon_translate.js b/view/js/icon_translate.js index 737164cb8..45deef05b 100644 --- a/view/js/icon_translate.js +++ b/view/js/icon_translate.js @@ -52,4 +52,5 @@ $(document).ready(function() { $('.icon-circle-blank').addClass(''); $('.icon-circle').addClass(''); $('.icon-bookmark').addClass(''); + $('.icon-fullscreen').addClass(''); }); \ No newline at end of file diff --git a/view/tpl/chanview.tpl b/view/tpl/chanview.tpl index 4df327bf9..a43ea1b5d 100755 --- a/view/tpl/chanview.tpl +++ b/view/tpl/chanview.tpl @@ -1,2 +1,2 @@ - + diff --git a/view/tpl/settings.tpl b/view/tpl/settings.tpl index f5f2206bc..49dff4822 100755 --- a/view/tpl/settings.tpl +++ b/view/tpl/settings.tpl @@ -127,4 +127,23 @@ + +{{if $menus}} +

{{$lbl_misc}}

+ +
{{$menu_desc}}
+
+ +
+
+ +
+
+{{/if}} + + -- cgit v1.2.3