Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
Fixed "template not found" alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
matheo committed Mar 28, 2012
1 parent c6d8fdd commit 2db5472
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions src/modules/Clip/lib/Clip/Controller/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,18 @@ public function main($args)
->fetch($args['templatesimple']);
}

// alert pubtype admins only
$alert = $this->getVar('devmode', false) && Clip_Access::toPubtype($pubtype);

//// Cache
// validate the template existance, if not defaults to the general one
if (!$this->getVar('commontpls', false) || $this->view->template_exists($pubtype['folder'].'/'.$args['templatefile'])) {
$args['templatefile'] = $pubtype['folder'].'/'.$args['templatefile'];
} else {
if ($alert) {
LogUtil::registerStatus($this->__f('Notice: Template [%s] not found.', $pubtype['folder'].'/'.$args['templatefile']));
}

$args['templatefile'] = 'common_'.$args['templatefile'];
}

Expand Down Expand Up @@ -180,8 +187,7 @@ public function main($args)

// check if the template is available to render it
if (!$this->view->template_exists($args['templatefile'])) {
if (Clip_Access::toPubtype($pubtype)) {
// pubtype admins only
if ($alert) {
LogUtil::registerStatus($this->__f('Notice: Template [%s] not found.', $args['templatefile']));
}

Expand Down Expand Up @@ -274,11 +280,18 @@ public function view($args)
//// Security
$this->throwForbiddenUnless(Clip_Access::toPubtype($pubtype, 'list', $apiargs['templateid']));

// alert pubtype admins only
$alert = $this->getVar('devmode', false) && Clip_Access::toPubtype($pubtype);

//// Cache
// validate the template existance, if not defaults to the general one
if (!$this->getVar('commontpls', false) || $this->view->template_exists($pubtype['folder'].'/'.$args['templatefile'])) {
$args['templatefile'] = $pubtype['folder'].'/'.$args['templatefile'];
} else {
if ($alert) {
LogUtil::registerStatus($this->__f('Notice: Template [%s] not found.', $pubtype['folder'].'/'.$args['templatefile']));
}

$args['templatefile'] = 'common_'.$args['templatefile'];
}

Expand Down Expand Up @@ -360,8 +373,8 @@ public function view($args)

// check if the template is not available
if (!$this->view->template_exists($args['templatefile'])) {
if (Clip_Access::toPubtype($pubtype)) {
// pubtype admins only
if ($alert) {
// alert pubtype admins only
LogUtil::registerStatus($this->__f('Notice: Template [%s] not found.', $args['templatefile']));
}

Expand Down Expand Up @@ -453,11 +466,18 @@ public function display($args)
//// Security
$this->throwForbiddenUnless(Clip_Access::toPub($pubtype, $apiargs['pid'], $apiargs['id'], 'display', $apiargs['templateid']));

// alert pubtype admins only
$alert = $this->getVar('devmode', false) && Clip_Access::toPubtype($pubtype);

//// Cache
// validate the template existance, if not defaults to the general one
if (!$this->getVar('commontpls', false) || $this->view->template_exists($pubtype['folder'].'/'.$args['templatefile'])) {
$args['templatefile'] = $pubtype['folder'].'/'.$args['templatefile'];
} else {
if ($alert) {
LogUtil::registerStatus($this->__f('Notice: Template [%s] not found.', $pubtype['folder'].'/'.$args['templatefile']));
}

$args['templatefile'] = 'common_'.$args['templatefile'];
}

Expand Down Expand Up @@ -493,9 +513,6 @@ public function display($args)
$this->view->setCaching(Zikula_View::CACHE_DISABLED);
}

// setup an admin flag
$isadmin = Clip_Access::toPubtype($pubtype);

//// Execution
// fill the conditions of the item to get
$apiargs['where'] = array();
Expand All @@ -508,7 +525,7 @@ public function display($args)
$pubdata = ModUtil::apiFunc('Clip', 'user', 'get', $apiargs);

if (!$pubdata) {
if ($isadmin) {
if (Clip_Access::toPubtype($pubtype)) {
// detailed error message for the admin only
return LogUtil::registerError($this->__f('No such publication [tid: %1$s - pid: %2$s; id: %3$s] found.', array($apiargs['tid'], $apiargs['pid'], $apiargs['id'])));
} else {
Expand Down Expand Up @@ -547,7 +564,7 @@ public function display($args)

// check if template is not available
if (!$this->view->template_exists($args['templatefile'])) {
if ($isadmin) {
if ($alert) {
LogUtil::registerStatus($this->__f('Notice: Template [%s] not found.', $args['templatefile']));
}

Expand Down Expand Up @@ -691,9 +708,10 @@ public function edit($args)
// notify the ui edition
$render = Clip_Event::notify('ui.edit', $render, $args)->getData();

// resolve the template to use
// alert pubtype admins only
$alert = $this->getVar('devmode', false) && Clip_Access::toPubtype($pubtype);

// resolve the template to use
// 1. custom template
if (!empty($args['template'])) {
$template = $pubtype['folder']."/form_{$args['state']}_{$args['template']}.tpl";
Expand Down

1 comment on commit 2db5472

@hvorragend
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Please sign in to comment.