public function query() { $unit_id = (int) phpgw::get_var('unit_id'); $delegates_data = array(); if (isset($unit_id) && $unit_id > 0) { $delegates_per_org_unit = frontend_bofrontend::get_delegates($unit_id); $delegates_data = array('results' => $delegates_per_org_unit, 'total_records' => count($delegates_per_org_unit)); $editable = phpgw::get_var('editable') == 'true' ? true : false; array_walk($delegates_data['results'], array($this, 'add_actions'), array($unit_id)); } return $this->yui_results($delegates_data, 'total_records', 'results'); }
/** * Create useraccount on login for SSO/ntlm * * @return void */ public function auto_addaccount() { $account_lid = $GLOBALS['hook_values']['account_lid']; if (!$GLOBALS['phpgw']->accounts->exists($account_lid)) { $config = CreateObject('phpgwapi.config', 'frontend'); $config->read(); $autocreate_user = isset($config->config_data['autocreate_user']) && $config->config_data['autocreate_user'] ? $config->config_data['autocreate_user'] : 0; if ($autocreate_user) { $fellesdata_user = frontend_bofellesdata::get_instance()->get_user($account_lid); if ($fellesdata_user) { // Read default assign-to-group from config $default_group_id = isset($config->config_data['frontend_default_group']) && $config->config_data['frontend_default_group'] ? $config->config_data['frontend_default_group'] : 0; $group_lid = $GLOBALS['phpgw']->accounts->name2id($default_group_id); $group_lid = $group_lid ? $group_lid : 'frontend_delegates'; $password = '******' . mt_rand(100, mt_getrandmax()) . '&'; $account_id = frontend_bofrontend::create_delegate_account($account_lid, $fellesdata_user['firstname'], $fellesdata_user['lastname'], $password, $group_lid); if ($account_id) { $GLOBALS['phpgw']->redirect_link('/login.php', array()); } } } } }
function get_menu() { $incoming_app = $GLOBALS['phpgw_info']['flags']['currentapp']; $GLOBALS['phpgw_info']['flags']['currentapp'] = 'frontend'; $menus = array(); if ($GLOBALS['phpgw']->acl->check('run', phpgwapi_acl::READ, 'admin') || $GLOBALS['phpgw']->acl->check('admin', phpgwapi_acl::ADD, 'frontend')) { $menus['admin'] = array('index' => array('text' => lang('Configuration'), 'url' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'admin.uiconfig.index', 'appname' => 'frontend'))), 'acl' => array('text' => lang('Configure Access Permissions'), 'url' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'preferences.uiadmin_acl.list_acl', 'acl_app' => 'frontend'))), 'documents' => array('text' => lang('upload_userdoc'), 'url' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'frontend.uidocumentupload.index', 'appname' => 'frontend')))); } $menus['navbar'] = array('frontend' => array('text' => lang('frontend'), 'url' => $GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'frontend.uifrontend.index')), 'image' => array('frontend', 'navbar'), 'order' => 35, 'group' => 'office')); $menus['navigation'] = array(); $locations = frontend_bofrontend::get_sections(); $tabs = array(); foreach ($locations as $key => $entry) { $name = $entry['name']; $location = $entry['location']; if ($GLOBALS['phpgw']->acl->check($location, PHPGW_ACL_READ, 'frontend')) { $location_id = $GLOBALS['phpgw']->locations->get_id('frontend', $location); $menus['navigation'][$location_id] = array('text' => lang($name), 'url' => $GLOBALS['phpgw']->link('/', array('menuaction' => "frontend.ui{$name}.index", 'type' => $location_id, 'noframework' => $noframework))); } } $GLOBALS['phpgw_info']['flags']['currentapp'] = $incoming_app; return $menus; }
public function remove_delegate() { $account_id = phpgw::get_var('account_id'); $owner_id = phpgw::get_var('owner_id'); frontend_bofrontend::remove_delegate($account_id, $owner_id); $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 'frontend.uidelegates.index')); }
public function remove_delegate() { $unit_id = phpgw::get_var('id'); $account_id = phpgw::get_var('account_id'); $result = frontend_bofrontend::remove_delegate($account_id, null, $unit_id); $args = array('menuaction' => 'rental.uiresultunit.edit', 'id' => $unit_id); if ($result) { $args['message'] = lang('delegate_removed'); } else { $args['error'] = lang('failed_removing_delegate'); } $GLOBALS['phpgw']->redirect_link('/index.php', $args); }
function get_tabs() { // Get tabs from location hierarchy // tabs [location identidier] = {label => ..., link => ...} $locations = frontend_bofrontend::get_sections(); $tabs = array(); foreach ($locations as $key => $entry) { $name = $entry['name']; $location = $entry['location']; if ($GLOBALS['phpgw']->acl->check($location, PHPGW_ACL_READ, 'frontend')) { $location_id = $GLOBALS['phpgw']->locations->get_id('frontend', $location); $tabs[$location_id] = array('label' => lang($name), 'link' => $GLOBALS['phpgw']->link('/', array('menuaction' => "frontend.ui{$name}.index", 'location_id' => $location_id, 'noframework' => $noframework))); } unset($location); } // this one is for generic entitysupport from the app 'property' $entity_frontend = isset($this->config->config_data['entity_frontend']) && $this->config->config_data['entity_frontend'] ? $this->config->config_data['entity_frontend'] : array(); if ($entity_frontend) { $entity = CreateObject('property.soadmin_entity'); } foreach ($entity_frontend as $location) { if ($GLOBALS['phpgw']->acl->check($location, PHPGW_ACL_READ, 'property')) { $location_id = $GLOBALS['phpgw']->locations->get_id('property', $location); $location_arr = explode('.', $location); $category = $entity->read_single_category($location_arr[2], $location_arr[3]); $tabs[$location_id] = array('label' => $category['name'], 'link' => $GLOBALS['phpgw']->link('/', array('menuaction' => "frontend.uientity.index", 'location_id' => $location_id, 'noframework' => $noframework))); } } $extra_tabs = phpgwapi_cache::session_get('frontend', 'extra_tabs'); if (isset($extra_tabs)) { $tabs = array_merge($extra_tabs, $tabs); } phpgwapi_cache::session_clear('frontend', 'extra_tabs'); return $tabs; }
/** * Remove a delegate * @param $account_id the delegate * @param $owner_id the person who has delegated * @param $org_unit_id the organisational unit in question */ public static function remove_delegate(int $account_id, int $owner_id, int $org_unit_id) { if (!isset($owner_id)) { $owner_id = $GLOBALS['phpgw_info']['user']['account_id']; } // The location $location_id = $GLOBALS['phpgw']->locations->get_id('frontend', '.'); // If a specific organisational unit if (isset($org_unit_id)) { $sql = "DELETE FROM phpgw_account_delegates WHERE account_id = {$account_id} AND data = '{$org_unit_id}' AND location_id = {$location_id}"; } else { // The owner id is the current user if not set $sql = "DELETE FROM phpgw_account_delegates WHERE account_id = {$account_id} AND owner_id = {$owner_id} AND location_id = {$location_id}"; } $db = clone $GLOBALS['phpgw']->db; $db->Halt_On_Error = 'no'; $result = $db->query($sql, __LINE__, __FILE__); if ($result && $db->affected_rows() > 0) { $user_account = $GLOBALS['phpgw']->accounts->get($account_id); $owner_account = $GLOBALS['phpgw']->accounts->get($owner_id); $user_name = $user_account->__get('lid'); $owner_name = $owner_account->__get('lid'); if (isset($user_name) && $user_name != '' && $owner_name && $owner_name != '') { $fellesdata_user = frontend_bofellesdata::get_instance()->get_user($user_name); $fellesdata_owner = frontend_bofellesdata::get_instance()->get_user($owner_name); if ($fellesdata_user && $fellesdata_owner) { $email = $fellesdata_user['email']; if (isset($email) && $email != '') { $title = lang('email_remove_delegate_title'); $message = lang('email_remove_delegate_message', $fellesdata_user['firstname'], $fellesdata_user['lastname'], $fellesdata_owner['firstname'], $fellesdata_owner['lastname']); frontend_bofrontend::send_system_message($email, $title, $message); } } } return true; } return false; }