';
if (api_is_platform_admin()) {
echo ''.
get_lang('ConfigureDashboardPlugin').'';
}
}
}
/**
* display checkboxes for user dashboard list
* @param int User id
* @param int Block id
* @return void
*/
public static function display_user_dashboard_list_checkboxes($user_id, $block_id) {
$user_id = intval($user_id);
$user_block_data = self::get_user_block_data($user_id);
$enabled_blocks_id = array_keys($user_block_data);
$checked = '';
if (in_array($block_id, $enabled_blocks_id)) {
$checked = "checked";
}
echo "
";
echo '';
echo "
";
}
/**
* This function store enabled blocks id with its column position (block_id1:colum;block_id2:colum; ...) inside extra user fields
* @param int User id
* @param array selected blocks
* @param array columns position
* @return bool
*/
public static function store_user_blocks($user_id, $enabled_blocks, $columns) {
$selected_blocks_id = array();
if (is_array($enabled_blocks) && count($enabled_blocks) > 0) {
$selected_blocks_id = array_keys($enabled_blocks);
}
// build data for storing inside extra user field
$fname = 'dashboard';
$fvalue = array();
foreach ($selected_blocks_id as $block_id) {
$fvalue[] = $block_id.':'.$columns[$block_id];
}
$upd_extra_field = UserManager::update_extra_field_value($user_id, $fname, $fvalue);
return $upd_extra_field;
}
/**
* This function get user block data (block id with its number of column) from extra user data
* @param int User id
* @return array data (block_id,column)
*/
public static function get_user_block_data($user_id) {
$user_id = intval($user_id);
$field_variable = 'dashboard';
$extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable);
$extra_user_data = explode(';',$extra_user_data[$field_variable]);
$data = array();
foreach ($extra_user_data as $extra) {
$split_extra = explode(':',$extra);
if (!empty($split_extra)) {
$block_id = $split_extra[0];
$column = isset($split_extra[1]) ? $split_extra[1] : null;
$data[$block_id] = array('block_id' => $block_id, 'column' => $column);
}
}
return $data;
}
/**
* This function update extra user blocks data after closing a dashboard block
* @param int User id
* @param string plugin path
* @return bool
*/
public static function close_user_block($user_id, $path) {
$enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path);
$user_block_data = self::get_user_block_data($user_id);
foreach ($enabled_dashboard_blocks as $enabled_block) {
unset($user_block_data[$enabled_block['id']]);
}
// get columns and blocks id for updating extra user data
$columns = array();
$user_blocks_id = array();
foreach ($user_block_data as $data) {
$user_blocks_id[$data['block_id']] = true;
$columns[$data['block_id']] = $data['column'];
}
// update extra user blocks data
$upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
return $upd_extra_field;
}
/**
* get links for styles from dashboard plugins
* @return string links
*/
public static function get_links_for_styles_from_dashboard_plugins() {
return ''.PHP_EOL;
}
}