Permalink
Browse files

Fixed "template not found" alerts

  • Loading branch information...
1 parent c6d8fdd commit 2db5472e034893f231ad53138bd155baaa14dd09 @matheo matheo committed Mar 28, 2012
Showing with 28 additions and 10 deletions.
  1. +28 −10 src/modules/Clip/lib/Clip/Controller/User.php
@@ -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'];
}
@@ -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']));
}
@@ -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'];
}
@@ -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']));
}
@@ -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'];
}
@@ -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();
@@ -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 {
@@ -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']));
}
@@ -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";

1 comment on commit 2db5472

Member

hvorragend commented on 2db5472 Mar 30, 2012

Thanks

Please sign in to comment.