function generate_inner_html() { switch ($this->mode) { default: $inner_template = dirname(__FILE__) . '/center_inner_private.tpl'; } $inner_html_gen =& new Template($inner_template); $role = new Roles(); $this->links = $role->get_multiple(); $inner_html_gen->set('links', $this->links); $task = Tasks::get_instance(); $tasklist = $task->get_tasks(); $inner_html_gen->set('tasklist', $tasklist); $inner_html_gen->set('super_user_and_mothership', @$this->super_user_and_mothership); $inner_html_gen->set('config_navigation_url', network_config_navigation('manage_tasks_relationship')); $inner_html = $inner_html_gen->fetch(); return $inner_html; }
function generate_inner_html() { switch ($this->mode) { default: $inner_template = PA::$blockmodule_path . '/' . get_class($this) . '/center_inner_private.tpl'; } $inner_html_gen = new Template($inner_template); $role = new Roles(); $params = array('sort_by' => 'id', 'direction' => 'ASC', 'cnt' => false); $this->links = $role->get_multiple($params); $inner_html_gen->set('links', $this->links); $task = Tasks::get_instance(); $tasklist = $task->get_tasks(); $inner_html_gen->set('tasklist', $tasklist); $inner_html_gen->set('super_user_and_mothership', @$this->super_user_and_mothership); $inner_html_gen->set('config_navigation_url', network_config_navigation('manage_tasks_relationship')); $inner_html = $inner_html_gen->fetch(); return $inner_html; }
/** !! * Sets up the html for the entire page. It starts by creating an array of all * modules that are present on the page and updates the array with the data for * the modules including name, type and placement. It then reviews settings for * the page based on page name and id. It then checks for administrator * permission. Finally it gets server data and calls { @link set_inner_template() } * and { @link generate_inner_html() } to create the page. * @param string $request_method if this is GET, get server information and * initialize the page * @param array $request_data contains information on what to display on the page */ function initializeModule($request_method, $request_data) { global $error_msg, $settings_new; $this->id = !empty($request_data['id']) ? $request_data['id'] : 0; $this->module = !empty($request_data['module']) ? $request_data['module'] : null; $mod_info = new ModulesInfo(array(PA::$core_dir . DIRECTORY_SEPARATOR . PA::$blockmodule_path, PA::$project_dir . DIRECTORY_SEPARATOR . PA::$blockmodule_path)); $condition = ModulesInfo::USER_MODULES_FILTER . " || " . ModulesInfo::GROUP_MODULES_FILTER . " || " . ModulesInfo::NETWORK_MODULES_FILTER; $modules = $mod_info->getModulesByCondition($condition); $module_info = null; $mod_selected = null; $mod_select_options = array(); $mod_select_options[" "] = " "; foreach ($modules as $module) { $mod_select_options[$module['name']] = $module['name']; if (@$request_data['module'] == $module['name']) { $mod_selected = $module['name']; $module_info['name'] = $module['name']; $module_info['module_type'] = $module['module_type']; $module_info['module_placement'] = $module['module_placement']; $module_info['status_points'] = 0; if (!empty($module['architecture_info']['has_init_module'])) { $module_info['status_points'] += 33; } if (!empty($module['architecture_info']['has_action_handler'])) { $module_info['status_points'] += 33; } if (!empty($module['architecture_info']['has_set_inner_tpl'])) { $module_info['status_points'] += 33; } } } asort($mod_select_options); $mod_tag_attrs = array('name' => "form_data[module]", 'onchange' => "javascript: document.location='" . PA_ROUTE_CREATE_DYN_PAGE . "?action=edit&id={$this->id}&module='+this.value"); $mod_select_tag = xHtml::selectTag($mod_select_options, $mod_tag_attrs, $mod_selected); $pages_default_setting = ModuleSetting::get_pages_default_setting('network'); $selected = null; $current_selecion = null; $select_options = array(); $select_options[" "] = "0"; foreach ($pages_default_setting as $page_details) { $select_options[$page_details->page_name] = $page_details->page_id; if (@$request_data['id'] == $page_details->page_id) { $selected = $page_details->page_id; $current_selection = $page_details; $restore_settings = $page_details->getPageSettings(); } } $tag_attrs = array('name' => "form_data[page_id]", 'onchange' => "javascript: document.location='" . PA_ROUTE_CREATE_DYN_PAGE . "?action=edit&module={$this->module}&id='+this.value"); $select_tag = xHtml::selectTag($select_options, $tag_attrs, $selected); $this->outer_template = 'outer_public_center_module.tpl'; // $this->shared_data['OVO_JE_DODANO'] = "Ovo je dodano unutar modula!"; $task_obj = Tasks::get_instance(); $tasks = $task_obj->get_tasks(); $permiss = array(); $permiss[] = 'configure_system'; // NOTE: system administrator permissions!! foreach ($tasks as $task) { $permiss[] = $task->task_value; } $this->adm_permissions = implode(', ', $permiss); if ($request_method == 'GET') { if (!empty($request_data['action']) && !empty($request_data['id']) && $request_data['action'] == 'edit') { $this->page = new DynamicPage((int) $request_data['id'], $settings_new); if (!empty($request_data['add'])) { $this->page->addModule($request_data['add'], $this->module); } $this->page->initialize(); } } $this->set_inner_template('center_inner_public.tpl'); // initial template $this->inner_HTML = $this->generate_inner_html(array('page_id' => $this->page_id, 'page' => $this->page, 'select_tag' => $select_tag, 'type' => 'theme', 'base_url' => PA_ROUTE_CREATE_DYN_PAGE, 'mod_select_tag' => $mod_select_tag, 'module_info' => $module_info, 'adm_permissions' => $this->adm_permissions)); }
public function __construct($user_id) { if (!isset($user_id)) { throw new CNException(REQUIRED_PARAMETERS_MISSING, "PermissionsHandler::__construct() must be called with User object or user_id parameter"); } $tasks_obj = Tasks::get_instance(); $this->tasks = $tasks_obj->get_tasks(); foreach ($this->tasks as $task) { $this->static_permissions[] = $task->task_value; } $this->uid = (int) $user_id; $this->is_net_admin = Network::is_admin(PA::$network_info->network_id, $this->uid); $roles = Roles::get_user_roles((int) $user_id, DB_FETCHMODE_OBJECT); // echo "User Roles <pre>".print_r(PA::$login_user, 1). "</pre>"; $this->user_permissions = array(); $user_perms = array(); $network_perms = array(); $groups_perms = array(); foreach (array('user', 'network', 'groups') as $type) { foreach ($roles as $role) { $role_extra = unserialize($role->extra); if ($type == 'user') { $condition = $role_extra['user'] == true; } else { if ($type == 'network') { $condition = $role_extra['network'] == true; } else { $condition = count($role_extra['groups']) > 0; } } if ($condition) { $role_tasks = Roles::get_tasks_of_role($role->role_id); // echo "RoleID: $role->role_id<pre>".print_r($role_tasks,1)."</pre>"; if ($role_tasks) { foreach ($role_tasks as $rt) { if ($type == 'user') { $user_perms[] = $rt->task_value; } else { if ($type == 'network') { $network_perms[] = $rt->task_value; } else { foreach ($role_extra['groups'] as $group_id) { if (isset($groups_perms[$group_id]) && is_array($groups_perms[$group_id])) { array_push($groups_perms[$group_id], $rt->task_value); } else { $groups_perms[$group_id] = array($rt->task_value); } } } } } } } } } $this->user_permissions['user'] = $user_perms; $this->user_permissions['network'] = $network_perms; $this->user_permissions['groups'] = $groups_perms; if ($this->is_net_admin) { // user is network admin, grant him same privileges for all network groups foreach ($this->user_permissions['groups'] as &$gr_perms) { $gr_perms = array_unique(array_merge($gr_perms, $this->user_permissions['network'])); } } // echo "<pre>".print_r($this->user_permissions,1)."</pre>"; }
private function handleAJAX_showRole($request_data) { $tasks = Tasks::get_instance(); $available_tasks = $tasks->get_tasks(DB_FETCHMODE_ASSOC); $info_msg = __("Select Task(s) you want to assign to this Role and press left/right arrow."); $div_generate = ' <fieldset class="center_box"> <div class="field"> <h4>Name</h4> <input type="text" name="role_name" id="role_name" class="text longer" value="" /> </div> <div class="field_bigger"> <h4>Description :</h4> <textarea name="desc" id="desc"></textarea> </div> <div class="field_big" style="float:left"> <h4>Role type :</h4> <div class="center"> <input name="role_type" id="role_type_user" type="radio" value="user" /> Users Perosnal Role <br /> <input name="role_type" id="role_type_network" type="radio" value="network" /> Network Role <br /> <input name="role_type" id="role_type_group" type="radio" value="group" /> Group Role </div> </div>'; $div_generate .= ' <div class="field_bigger" style="height:auto"> <h4>Assign Tasks to Role: </h4> <div style="float: left"> <div style="font-weight: bold; padding-bottom: 0.5em">Available Tasks</div> <select name="unassociated_tasks[]" id="unassociated_tasks" multiple="multiple" class="multiple-selected" size="10">'; for ($cnt = 0; $cnt < count($available_tasks); $cnt++) { $div_generate .= '<option value="' . $available_tasks[$cnt]['id'] . '" onmouseover="javascript: roles_edit.showdescription(\'' . $available_tasks[$cnt]['description'] . '\');"' . '" onmouseout="javascript: roles_edit.showdescription(\'' . $info_msg . '\');" >' . $available_tasks[$cnt]['name'] . '</option>'; } $div_generate .= ' </select> </div> <div style="float: left; margin: 48px 24px; "> <input type="image" name="commit" src="' . PA::$theme_url . '/images/arrow_right.gif" style="border: 0" onclick="roles_edit.double_list_move(\'unassociated_tasks\', \'associated_tasks\'); return false;" /><br /> <input type="image" name="commit" src="' . PA::$theme_url . '/images/arrow_left.gif" style="border: 0" onclick="roles_edit.double_list_move(\'associated_tasks\', \'unassociated_tasks\'); return false;" /> </div> <div style="float: left"> <div style="font-weight: bold; padding-bottom: 0.5em">Assigned Tasks</div> <select name="associated_tasks[]" id="associated_tasks" multiple="multiple" class="multiple-selected" size="10">'; $div_generate .= ' </select> </div> <br style="clear: both" /> </div> <div class="text" id="role_description"> ' . $info_msg . ' </div> </div>'; $div_generate .= ' </fieldset> <div class="button_position"> <input type="hidden" name="role_id" id="role_id" value=""/> <input type="button" value="' . __("Save") . '" onclick="roles_edit.saverole(\'addRole\');" /> <input type="button" value="' . __("Cancel") . '" onclick="roles_edit.closeedit();" /> </div>'; print $div_generate; exit; }
<?php //$authorization_required variable should be set to TRUE or FALSE before //including this file //this file is used to check the roles - tasks permissions if (!isset($authorization_required)) { throw new PAException("", "The \$authorization_required variable must be set before include()ing page.php!"); } require_once "{$path_prefix}/api/Roles/Roles.php"; require_once "{$path_prefix}/api/Tasks/Tasks.php"; $task = Tasks::get_instance(); $tasks = $task->get_tasks(); //getting list of all the tasks $task_id = ''; //find task id foreach ($tasks as $task_obj) { if ($page_task == $task_obj->task_value) { $task_id = $task_obj->id; } } $task_perm = Roles::check_permission($login_uid, $task_id); // deprecated - use Roles::check_permission_by_value(PA::$login_uid, 'task value') instead. function check_user_permission($task_id_or_value) { if (empty(PA::$login_uid)) { return FALSE; } if (is_numeric($task_id_or_value)) { $task_id = $task_id_or_value; } else { $task_id = Tasks::get_id_from_task_value($task_id_or_value);