2014-03-10 22:14:02 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* EGroupware - eTemplate serverside toolbar widget
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
|
|
|
* @subpackage api
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
2016-03-19 14:06:07 +01:00
|
|
|
namespace EGroupware\Api\Etemplate\Widget;
|
|
|
|
|
|
|
|
use EGroupware\Api\Etemplate;
|
|
|
|
|
2014-03-10 22:14:02 +01:00
|
|
|
/**
|
|
|
|
* eTemplate button widget
|
|
|
|
*/
|
2016-03-19 14:06:07 +01:00
|
|
|
class Toolbar extends Etemplate\Widget
|
2014-03-10 22:14:02 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Validate toolbar
|
|
|
|
*
|
|
|
|
* Readonly buttons can NOT be pressed!
|
|
|
|
*
|
|
|
|
* @param string $cname current namespace
|
|
|
|
* @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
|
|
|
|
* @param array $content
|
|
|
|
* @param array &$validated=array() validated content
|
|
|
|
* @return boolean true if no validation error, false otherwise
|
|
|
|
*/
|
|
|
|
public function validate($cname, array $expand, array $content, &$validated=array())
|
|
|
|
{
|
|
|
|
$form_name = self::form_name($cname, $this->id, $expand);
|
|
|
|
|
|
|
|
if (!$this->is_readonly($cname, $form_name))
|
|
|
|
{
|
|
|
|
$value = self::get_array($content, $form_name);
|
|
|
|
$valid =& self::get_array($validated, $form_name, true);
|
|
|
|
if (true) $valid = $value;
|
|
|
|
}
|
|
|
|
}
|
2018-08-15 16:50:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set up what we know on the server side.
|
|
|
|
*
|
|
|
|
* @param string $cname
|
|
|
|
* @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
|
|
|
|
*/
|
|
|
|
public function beforeSendToClient($cname, array $expand=null)
|
|
|
|
{
|
|
|
|
if ($GLOBALS['egw_info']['user']['apps']['admin'])
|
|
|
|
{
|
|
|
|
$form_name = self::form_name($cname, $this->id, $expand);
|
|
|
|
$value = &self::get_array(self::$request->modifications, $form_name, true);
|
|
|
|
$value['is_admin'] = true;
|
|
|
|
}
|
|
|
|
}
|
2018-08-16 12:29:21 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set admin settings
|
|
|
|
*
|
|
|
|
* @param array $settings array of settings to be processed
|
|
|
|
*/
|
|
|
|
public static function ajax_setAdminSettings ($settings)
|
|
|
|
{
|
|
|
|
$response = \EGroupware\Api\Json\Response::get();
|
|
|
|
// None admin users are not allowed to access
|
|
|
|
if (!$GLOBALS['egw_info']['user']['apps']['admin'])
|
|
|
|
{
|
|
|
|
$response->data(Lang('Permission denied! This is an administration only feature.'));
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2014-03-10 22:14:02 +01:00
|
|
|
}
|