publish_that_1.0.0/ 0000755 0000765 0000024 00000000000 11215562150 015205 5 ustar justincrawford staff publish_that_1.0.0/plugins/ 0000755 0000765 0000024 00000000000 11215562150 016666 5 ustar justincrawford staff publish_that_1.0.0/plugins/pi.publish_that.php 0000644 0000765 0000024 00000034417 11215562150 022505 0 ustar justincrawford staff 'Publish That',
'pi_version' => '1.0.0',
'pi_author' => 'Justin Crawford (Hop Studios)',
'pi_author_url' => 'http://www.hopstudios.com/software',
'pi_description' => 'Adds a "publish that" link to various content',
'pi_usage' => Publish_that::usage()
);
class Publish_that
{
var $icon_path = '';
var $session_required = FALSE;
var $debug = FALSE;
// constructor
function Publish_that()
{
global $PREFS, $TMPL;
$this->icon_path = $PREFS->ini('theme_folder_url') . 'publish_that_themes/images/';
$this->debug = ($TMPL->fetch_param('debug') == 'true') ? TRUE : FALSE;
$this->_debug("initializing");
}
// _get_link: create an href and wrap it around an image
function _get_link($url = '', $alt = '', $icon = 'default')
{
$this->icon_path .= (($icon == '') ? 'default' : $icon) . '_icon.gif';
$this->_debug("creating a link with '$url'");
return '';
}
// _session_ok: check whether a session ID is necessary, and get it if it exists
function _session_ok()
{
global $PREFS, $SESS, $DB;
// check if if we need an admin session id
if ($PREFS->ini('admin_session_type') != 'c')
{
$this->session_required = TRUE;
// if we haven't already got one, get one and cache it
if (! isset($SESS->cache['publish_that']['session_id']))
{
$query = $DB->query("SELECT session_id FROM exp_sessions WHERE member_id = '" . $SESS->userdata['member_id'] . "' AND admin_sess = '1'");
if ($query->num_rows > 0)
{
$this->_debug("found an admin session id -- caching it");
$SESS->cache['publish_that']['session_id'] = $query->row['session_id'];
}
else
{
// if admin sessions are required, but we didn't find an admin session
$this->_debug("admin session check: FALSE");
return FALSE;
}
}
}
else
{
$this->session_required = FALSE;
}
// either we found an admin session, or we don't need one
$this->_debug("admin session check: TRUE");
return TRUE;
}
function _debug($msg)
{
if ($this->debug === TRUE)
{
// do something with debug msgs; this is rudimentary, but works.
echo "publish_that -- " . $msg . "
";
}
}
// authz: if superadmin, $can_publish
function _authz_superadmin()
{
global $SESS;
if ($SESS->userdata['group_id'] == 1)
{
$this->_debug("superadmin check: TRUE");
return TRUE;
}
$this->_debug("superadmin check: FALSE");
return FALSE;
}
// entry: return a link or a url for an publish_that:entry tag
function entry()
{
global $TMPL, $PREFS, $SESS, $DB;
$this->_debug("handling an entry");
$can_publish = FALSE;
// there are three required tag parameters, all numeric
if (is_numeric($weblog_id = ($TMPL->fetch_param('weblog_id'))))
{
$this->_debug("parameters OK");
// verify that they either have an admin session, or don't need one
if ($this->_session_ok() === TRUE)
{
if ($this->_authz_superadmin() === TRUE)
{
$can_publish = TRUE;
}
else
{
// check the cache for authz for this weblog
if (! isset($SESS->cache['publish_that']['weblog:' . $weblog_id]))
{
// authz: check that this person's group can publish that weblog
$query = $DB->query("SELECT wt.weblog_id, wt.author_id FROM exp_weblog_member_groups wg, exp_weblog_titles wt WHERE wt.entry_id = " . $entry_id . " AND wg.weblog_id = wt.weblog_id AND wg.group_id = " . $SESS->userdata['group_id']);
// cache the result of this authz check
if ($query->num_rows > 0)
{
// they passed us a weblog/author id, but the DB is more definitive
$weblog_id = $query->row['weblog_id'];
$author_id = $query->row['author_id'];
$SESS->cache['publish_that']['weblog:' . $weblog_id] = TRUE;
}
else
{
$SESS->cache['publish_that']['weblog:' . $weblog_id] = FALSE;
}
$this->_debug("caching result of weblog group authz for weblog $weblog_id");
}
// if we've cached affirmative authz for this weblog...
if ($SESS->cache['publish_that']['weblog:' . $weblog_id] === TRUE)
{
$this->_debug("weblog group check: TRUE");
// they must have these perms to edit
$can_publish = ($SESS->userdata['can_access_cp'] == 'y') && ($SESS->userdata['can_access_publish'] == 'y');
$this->_debug("control panel permission check: $can_publish");
}
}
}
// if we got through all the above an still $can_publish, then let's do it!
if ($can_publish)
{
// if admin sessions are required, get the session id
$session_param = ($this->session_required == TRUE) ? '&S=' . $SESS->cache['publish_that']['session_id'] : '';
// generate the url
$url = $PREFS->core_ini['cp_url'] . '?C=publish&M=entry_form&weblog_id=' . $weblog_id . $session_param;
// if invoked with two-tag, handle contents
if ($TMPL->tagdata != '')
{
return str_replace('{publish_that_url}', $url, $TMPL->tagdata);
}
else
{
$alt = "Publish a new item";
return $this->_get_link($url, $alt, $TMPL->fetch_param('icon'));
}
}
}
return;
}
// template: return a url or a link for an publish_that:template tag
function template()
{
global $TMPL, $PREFS, $SESS, $DB;
$this->_debug("handling a template");
$can_publish = FALSE;
if (is_numeric($template_group = ($TMPL->fetch_param('template_group'))))
{
$this->_debug("parameters OK");
// verify that they either have an admin session, or don't need one
if ($this->_session_ok() === TRUE)
{
if ($this->_authz_superadmin())
{
$can_publish = TRUE;
}
else
{
// check the cache for a template group authz
if (! isset($SESS->cache['publish_that']['template_group:' . $template_group]))
{
// try to get authz on this template group
$query = $DB->query("SELECT tt.group_id FROM exp_template_member_groups tg, exp_templates tt WHERE tt.template_id = " . $template_id . " AND tg.template_group_id = tt.group_id AND tg.group_id = " . $SESS->userdata['group_id']);
if ($query->num_rows > 0)
{
// they passed us a template group id, but the DB is more definitive
$template_group = $query->row['group_id'];
$SESS->cache['publish_that']['template_group:' . $template_group] = TRUE;
}
else
{
$SESS->cache['publish_that']['template_group:' . $template_group] = FALSE;
}
$this->_debug("caching result of template group authz for template group $template_group");
}
// if template group authz succeeded
if ($SESS->cache['publish_that']['template_group:' . $template_group] === TRUE)
{
$this->_debug("template group check: TRUE");
// check other required template permissions
$can_publish = ($SESS->userdata['can_access_cp'] == 'y') && ($SESS->userdata['can_admin_templates'] == 'y');
$this->_debug("control panel permission check: $can_publish");
}
}
}
if ($can_publish)
{
// if admin sessions are required, get the session id
$session_param = ($this->session_required == TRUE) ? '&S=' . $SESS->cache['publish_that']['session_id'] : '';
$url = $PREFS->core_ini['cp_url'] . '?C=templates&M=new_templ_form&id=' . $template_group . '&tgpref=' . $template_group . $session_param;
if ($TMPL->tagdata != '')
{
return str_replace('{publish_that_url}', $url, $TMPL->tagdata);
}
else
{
$alt = "Publish a new template";
return $this->_get_link($url, $alt, $TMPL->fetch_param('icon'));
}
}
}
return;
}
// category: return a url or a link for an publish_that:category tag
function category()
{
global $TMPL, $PREFS, $DB, $SESS;
$this->_debug("handling a category");
$can_publish = FALSE;
if (is_numeric($category_group = ($TMPL->fetch_param('category_group'))))
{
$this->_debug("parameters OK");
// verify that they either have an admin session, or don't need one
if ($this->_session_ok() === TRUE)
{
if ($this->_authz_superadmin() === TRUE)
{
$can_publish = TRUE;
}
else
{
// they must have these perms to edit
$can_publish = ($SESS->userdata['can_access_cp'] == 'y') && ($SESS->userdata['can_access_admin'] == 'y') && ($SESS->userdata['can_admin_weblogs'] == 'y');
$this->_debug("control panel permission check: $can_publish");
// Note: there is a perm 'can_edit_categories', but it doesn't apply in this instance. It's for editing categories on a particular entry.
}
if ($can_publish)
{
// if admin sessions are required, get the session id
$session_param = ($this->session_required == TRUE) ? '&S=' . $SESS->cache['publish_that']['session_id'] : '';
$url = $PREFS->core_ini['cp_url'] . '?C=admin&M=blog_admin&P=edit_category&group_id=' . $category_group . $session_param;
if ($TMPL->tagdata != '')
{
return str_replace('{publish_that_url}', $url, $TMPL->tagdata);
}
else
{
$alt = "Publish a new category";
return $this->_get_link($url, $alt, $TMPL->fetch_param('icon'));
}
}
}
return;
}
}
// image: return a url or a link for an publish_that:image tag
function image()
{
global $TMPL, $PREFS, $DB, $SESS;
$this->_debug("handling an image");
$can_publish = FALSE;
if (is_numeric($gallery_id = ($TMPL->fetch_param('gallery_id'))))
{
$this->_debug("parameters OK");
// verify that they either have an admin session, or don't need one
if ($this->_session_ok() === TRUE)
{
if ($this->_authz_superadmin() === TRUE)
{
$can_publish = TRUE;
}
else
{
// they must be authorized to admin the gallery module. cached to eliminate redundant queries.
if (! isset($SESS->cache['publish_that']['gallery']))
{
$query = $DB->query("SELECT * FROM exp_module_member_groups mg, exp_modules mm WHERE mg.module_id = mm.module_id AND mm.module_name = 'Gallery' AND mg.group_id = " . $SESS->userdata['group_id']);
// unlike weblogs, template groups, there are no more granular permissions to cache. they either can or cannot admin gallery module.
$SESS->cache['publish_that']['gallery'] = $query->num_rows > 0 ? TRUE : FALSE;
$this->_debug("caching result of gallery authz");
}
if ($SESS->cache['publish_that']['gallery'] === TRUE)
{
// they must have these perms to edit
$can_publish = ($SESS->userdata['can_access_cp'] == 'y') && ($SESS->userdata['can_access_modules'] == 'y');
$this->_debug("control panel permission check: $can_publish");
}
}
if ($can_publish)
{
// if admin sessions are required, get the session id
$session_param = ($this->session_required == TRUE) ? '&S=' . $SESS->cache['publish_that']['session_id'] : '';
$url = $PREFS->core_ini['cp_url'] . '?C=modules&M=gallery&P=entry_form&gallery_id=' . $gallery_id . $session_param;
if ($TMPL->tagdata != '')
{
return str_replace('{publish_that_url}', $url, $TMPL->tagdata);
}
else
{
$alt = "Publish a new image";
return $this->_get_link($url, $alt, $TMPL->fetch_param('icon'));
}
}
}
return;
}
}
// ----------------------------------------
// Plugin Usage
// ----------------------------------------
// This function describes how the plugin is used.
// Make sure and use output buffering
function usage()
{
ob_start();
?>
This plugin will put small pencil icons in the live site, but only for users who are logged in, have an administrative session, and have permission to add that particular resource.
All parameters are required, except "icon".
The simplest usage is simply this tag without any enclosed text:
Entries:
{exp:publish_that:entry weblog_id="{weblog_id}"}
Templates:
{exp:publish_that:template template_group="2"}
Categories:
{exp:publish_that:category category_group="{category_group}"}
Gallery Images:
{exp:publish_that:image gallery_id="{gallery_id}"}
If you wish to use a different icon image, you can put your own image there, as long as the filename ends in “_icon.gif”. Call alternate icons like so:
{exp:publish_that:template id="42" icon="custom"}
Advanced Use:
You can use the same tag, but enclose some text within it. The plugin will do the permission check, but leave the presentation of the link to you. This allows you to change the display to whatever you'd like, and you could have entire instructions or alternate content displayed by this plugin.
You can even point to a front-end editing template (stand alone editing form) using this option.
{exp:publish_that:entry weblog_id="{weblog_id}"}
Create a new entry in this weblog/section/channel
{/exp:publish_that:entry}
{exp:publish_that:template template_group="2"}
Create a new template in this template group
{/exp:publish_that:template}
{exp:publish_that:category category_group="{category_group}"}
Create a new category in this category group
{/exp:publish_that:category}
{exp:publish_that:image gallery_id="{gallery_id}"}
Create a new gallery image in this gallery
{/exp:publish_that:image}
Image editing only applies to images in the gallery module.
publish_that_1.0.0/README.txt 0000644 0000765 0000024 00000000226 11215562150 016703 0 ustar justincrawford staff Publish That by Hop Studios.
See http://www.hopstudios.com/software/ for documentation and license information.
CHANGELOG:
1.0.0 Initial release
publish_that_1.0.0/themes/ 0000755 0000765 0000024 00000000000 11215562150 016472 5 ustar justincrawford staff publish_that_1.0.0/themes/publish_that_themes/ 0000755 0000765 0000024 00000000000 11215562150 022525 5 ustar justincrawford staff publish_that_1.0.0/themes/publish_that_themes/images/ 0000755 0000765 0000024 00000000000 11215562150 023772 5 ustar justincrawford staff publish_that_1.0.0/themes/publish_that_themes/images/._blue_icon.gif 0000644 0000765 0000024 00000000624 11215562150 026637 0 ustar justincrawford staff Mac OS X 2 b ATTR F= { %com.apple.metadata:kMDItemWhereFroms C Q com.apple.quarantine bplist00_Lhttp://www.hopstudios.com/clients/hopstudios/moduledevelopment/blue_icon.gif
Yq/0000;49f746fb;Safari.app;C7E30CCD-4E60-4576-A8D8-4E6EC68DD2AA|com.apple.Safari publish_that_1.0.0/themes/publish_that_themes/images/blue_icon.gif 0000644 0000765 0000024 00000000322 11215562150 026415 0 ustar justincrawford staff GIF89a rRbhڀ2ͪ`V֗'m^]F҄ ! , O &ahUՙERD2LBqL&ѐ"9
1bsݘGP1HŋhI˥Dd@ ; publish_that_1.0.0/themes/publish_that_themes/images/._burnt_umber_icon.gif 0000644 0000765 0000024 00000000633 11215562150 030234 0 ustar justincrawford staff Mac OS X 2 i ATTR F> %com.apple.metadata:kMDItemWhereFroms J Q com.apple.quarantine bplist00_Shttp://www.hopstudios.com/clients/hopstudios/moduledevelopment/burnt_umber_icon.gif
`q/0000;49f74702;Safari.app;974917BB-1BFC-4251-859E-D6054FBF5D22|com.apple.Safari publish_that_1.0.0/themes/publish_that_themes/images/burnt_umber_icon.gif 0000644 0000765 0000024 00000001615 11215562150 030020 0 ustar justincrawford staff GIF89a ᭒ܟ{N]1ïe5qAa3T,yLk:h7גmޥc4ӆ^|A"ߨᮓg6g6ݡՋdTٗt ! , j 58 `BppaC
($(Qr P$IE'
t̜-sN(a.0B`x! ; publish_that_1.0.0/themes/publish_that_themes/images/._default_icon.gif 0000644 0000765 0000024 00000000627 11215562150 027337 0 ustar justincrawford staff Mac OS X 2 e ATTR F? ~ %com.apple.metadata:kMDItemWhereFroms F Q com.apple.quarantine bplist00_Ohttp://www.hopstudios.com/clients/hopstudios/moduledevelopment/default_icon.gif
\q/0000;49f74708;Safari.app;60BD332C-42A1-4EC1-8C3A-DA4CA0155C61|com.apple.Safari publish_that_1.0.0/themes/publish_that_themes/images/default_icon.gif 0000644 0000765 0000024 00000001615 11215562150 027120 0 ustar justincrawford staff GIF89a زߖccc雛÷ ! , j 58 `BppaC
($(Qr P$IE'
t̜-sN(a.0B`x! ; publish_that_1.0.0/themes/publish_that_themes/images/._green_icon.gif 0000644 0000765 0000024 00000000625 11215562150 027011 0 ustar justincrawford staff Mac OS X 2 c ATTR F@ | %com.apple.metadata:kMDItemWhereFroms D Q com.apple.quarantine bplist00_Mhttp://www.hopstudios.com/clients/hopstudios/moduledevelopment/green_icon.gif
Zq/0000;49f74717;Safari.app;E2E7ABEF-D2C4-4D0D-9645-166D036E272F|com.apple.Safari publish_that_1.0.0/themes/publish_that_themes/images/green_icon.gif 0000644 0000765 0000024 00000000321 11215562150 026565 0 ustar justincrawford staff GIF89a ^MjZVEdSsdJ;Єڞӌ{m]LXF:x.vܣ|ؚ\JRBvgזީ ! , N%ahUՙER2!LBYL&ѐ91bsݘǀP1H$ċhIDԒ( ; publish_that_1.0.0/themes/publish_that_themes/images/._orange_icon.gif 0000644 0000765 0000024 00000000626 11215562150 027165 0 ustar justincrawford staff Mac OS X 2 d ATTR FA } %com.apple.metadata:kMDItemWhereFroms E Q com.apple.quarantine bplist00_Nhttp://www.hopstudios.com/clients/hopstudios/moduledevelopment/orange_icon.gif
[q/0000;49f7471c;Safari.app;0440EC8A-BB24-46C6-BF8C-C39BA04400FB|com.apple.Safari publish_that_1.0.0/themes/publish_that_themes/images/orange_icon.gif 0000644 0000765 0000024 00000000321 11215562150 026740 0 ustar justincrawford staff GIF89a C8,<jKo\`o
0S}64ͣ#Oy ! , N%#ahUՙER!LBiL&ѐ91bsݘGP1HċhI
DԒ( ; publish_that_1.0.0/themes/publish_that_themes/images/periwinkle_icon.gif 0000644 0000765 0000024 00000001615 11215562150 027645 0 ustar justincrawford staff GIF89a ⬟ńpyv`Ěƽ|\K|俵Ҳ ! , j 58 `BppaC
($(Qr P$IE'
t̜-sN(a.0B`x! ; publish_that_1.0.0/themes/publish_that_themes/images/._pink_icon.gif 0000644 0000765 0000024 00000000624 11215562150 026651 0 ustar justincrawford staff Mac OS X 2 b ATTR FC { %com.apple.metadata:kMDItemWhereFroms C Q com.apple.quarantine bplist00_Lhttp://www.hopstudios.com/clients/hopstudios/moduledevelopment/pink_icon.gif
Yq/0000;49f74724;Safari.app;FA62B362-6D9E-4C71-8A98-4AD2452B82F4|com.apple.Safari publish_that_1.0.0/themes/publish_that_themes/images/pink_icon.gif 0000644 0000765 0000024 00000000321 11215562150 026426 0 ustar justincrawford staff GIF89a fpZx땾Fi](z鈶ꍹdb|R ! , N%`hUՙ5N2!Po2IP(p"91bݘǀrP)H$GċhIHDԑ0, ; publish_that_1.0.0/themes/publish_that_themes/images/._red_icon.gif 0000644 0000765 0000024 00000000623 11215562150 026461 0 ustar justincrawford staff Mac OS X 2 a ATTR FD z %com.apple.metadata:kMDItemWhereFroms B Q com.apple.quarantine bplist00_Khttp://www.hopstudios.com/clients/hopstudios/moduledevelopment/red_icon.gif
Xq/0000;49f74728;Safari.app;D2DD2818-F0BC-4B2A-AA94-27CDB55403D5|com.apple.Safari publish_that_1.0.0/themes/publish_that_themes/images/red_icon.gif 0000644 0000765 0000024 00000000322 11215562150 026240 0 ustar justincrawford staff GIF89a uuVVff77ll݃謬[[bbdd++塡㙙괴aaއKK ! , O &ahUՙ5NrPo2AP(p"9
1bݘGP1HŋhI˥D
ԗeb" ; publish_that_1.0.0/themes/publish_that_themes/images/._teal_icon.gif 0000644 0000765 0000024 00000000624 11215562150 026635 0 ustar justincrawford staff Mac OS X 2 b ATTR FE { %com.apple.metadata:kMDItemWhereFroms C Q com.apple.quarantine bplist00_Lhttp://www.hopstudios.com/clients/hopstudios/moduledevelopment/teal_icon.gif
Yq/0000;49f7472d;Safari.app;2FA0010F-C80E-4BEF-BB65-AE7A57C39026|com.apple.Safari publish_that_1.0.0/themes/publish_that_themes/images/teal_icon.gif 0000644 0000765 0000024 00000001615 11215562150 026421 0 ustar justincrawford staff GIF89a ۮЀöQbrZJ}jfƶ]ɽ:ymceҔŸ ! , j 58 `BppaC
($(Qr P$IE'
t̜-sN(a.0B`x! ; publish_that_1.0.0/themes/publish_that_themes/images/._yellow_icon.gif 0000644 0000765 0000024 00000000626 11215562150 027225 0 ustar justincrawford staff Mac OS X 2 d ATTR FF } %com.apple.metadata:kMDItemWhereFroms E Q com.apple.quarantine bplist00_Nhttp://www.hopstudios.com/clients/hopstudios/moduledevelopment/yellow_icon.gif
[q/0000;49f74731;Safari.app;81F5181B-4B6B-4488-B2EA-D11C5EED14C1|com.apple.Safari publish_that_1.0.0/themes/publish_that_themes/images/yellow_icon.gif 0000644 0000765 0000024 00000000321 11215562150 027000 0 ustar justincrawford staff GIF89a fq[וx̹Fj߫3d^҈πԍٛިb|оSܤ ! , N%ahUՙ5N2!Po2YP(p"91bݘǀPH$HċhIHD(< ;