Example #1
0
 static function saveUser()
 {
     // these are just tests lines
     $user = new User("joshbjones", "Josh");
     $un = $user->get_username();
     $fn = $user->get_firstname();
     $username = "******" . $un . "</h2><br>\r\n\t\t\t\t\t\t\t<h2>First Name: " . $fn . "</h2>";
     echo $username;
     // Connect to the MySQL Server
     include "connect.inc";
     $query = "INSERT INTO user\r\n\t\t\t\t\t\t(username, First_Name)\r\n\t\t\t\t\t\tVALUES ('{$un}', '{$fn}')";
     $result = mysqli_query($cxn, $query) or die("Couldn't execute query.");
 }
Example #2
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $get_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws BaseUserAccessDeniedException
  */
 public static function list_users($json_column_array, $json_argument_array, $get_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     global $user;
     if ($user->is_admin()) {
         if ($get_array) {
             $_GET = unserialize($get_array);
         }
         $list_request = new ListRequest_IO();
         $list_request->set_column_array($json_column_array);
         if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
             $entries_per_page = 20;
         }
         $list_array = User_Wrapper::list_users($sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
         if (is_array($list_array) and count($list_array) >= 1) {
             foreach ($list_array as $key => $value) {
                 $user = new User($list_array[$key]['id']);
                 $paramquery = $_GET;
                 $paramquery['action'] = "detail";
                 $paramquery['id'] = $list_array[$key]['id'];
                 $params = http_build_query($paramquery, '', '&#38;');
                 $list_array[$key]['symbol']['link'] = $params;
                 $list_array[$key]['symbol']['content'] = "<img src='images/icons/user.png' alt='' style='border: 0;' />";
                 unset($list_array[$key]['username']);
                 $list_array[$key]['username']['link'] = $params;
                 $list_array[$key]['username']['content'] = $user->get_username();
                 $list_array[$key]['fullname'] = $user->get_full_name(false);
                 $list_array[$key]['groups'] = Group::get_number_of_groups_by_user_id($list_array[$key]['id']);
                 $paramquery = $_GET;
                 $paramquery['action'] = "delete";
                 $paramquery['id'] = $list_array[$key]['id'];
                 $params = http_build_query($paramquery, '', '&#38;');
                 if ($list_array[$key]['id'] == 1) {
                     $list_array[$key]['delete'] = "<img src='images/icons/delete_user_na.png' alt='' style='border: 0;' />";
                 } else {
                     $list_array[$key]['delete']['link'] = $params;
                     $list_array[$key]['delete']['content'] = "<img src='images/icons/delete_user.png' alt='' style='border: 0;' />";
                 }
             }
         } else {
             $list_request->empty_message("<span class='italic'>No users found!</span>");
         }
         $list_request->set_array($list_array);
         return $list_request->get_page($page);
     } else {
         throw new BaseUserAccessDeniedException();
     }
 }
Example #3
0
 /**
  * @see EventListenerInterface::listen_events()
  * @param object $event_object
  * @return bool
  */
 public static function listen_events($event_object)
 {
     if ($event_object instanceof UserCreateEvent) {
         $user_folder = new UserFolder(null);
         if ($user_folder->create($event_object->get_user_id()) == false) {
             return false;
         }
     }
     if ($event_object instanceof UserPostDeleteEvent) {
         $folder_id = UserFolder::get_folder_by_user_id($event_object->get_user_id());
         $user_folder = new UserFolder($folder_id);
         if ($user_folder->delete(true, true) == false) {
             return false;
         }
     }
     if ($event_object instanceof UserRenameEvent) {
         $user = new User($event_object->get_user_id());
         $user_folder = new UserFolder(self::get_folder_by_user_id($event_object->get_user_id()));
         if ($user_folder->set_name($user->get_username()) == false) {
             return false;
         }
     }
     return true;
 }
Example #4
0
/****************** DEBUG LINE *********************/
$_GET['pagedebug'] = 'true';
/********************* END ********************/
//Establish session
session_start();
//------- COMMON VARIABLES
$page = new Page();
$auth = new Auth($db);
//Checks Auth at object creation
$user = NULL;
$page->assign('logged_in', $auth->is_logged_in());
$page->assign('redirect_url', encode_decode_redirect_url($_SERVER['REQUEST_URI']));
$page->load_javascript_include('jquery-1.6.4.min.js');
if ($auth->is_logged_in()) {
    $user_id = $auth->get_user_id();
    $user = new User($user_id);
    $page->assign('username', $user->get_username());
    $page->assign('user_id', $user_id);
}
//Query logging
$db->enable_query_logging(FALSE);
$page_debugging = FALSE;
if (isset($_GET['pagedebug']) && $_GET['pagedebug'] == 'true' && $auth->is_moderator()) {
    ini_set('display_errors', 'On');
    error_reporting(E_ALL | E_STRICT);
    $page_debugging = TRUE;
    $db->enable_query_logging(TRUE);
    //Logs queries for debugging puroses.
    $db->enable_query_backtracing(TRUE);
    //Provides location and line numbers for the logging.
}
Example #5
0
 /**
  * @throws ProjectIDMissingException
  * @throws ProjectSecurityAccessDeniedException
  */
 public static function chown()
 {
     global $project_security;
     if ($_GET['project_id']) {
         if ($project_security->is_access(7, false) == true) {
             $project_id = $_GET['project_id'];
             $project = new Project($project_id);
             if ($_GET['nextpage'] == 1) {
                 if (is_numeric($_POST['user'])) {
                     $page_1_passed = true;
                 } else {
                     $page_1_passed = false;
                     $error = "You must select an user";
                 }
             } else {
                 $page_1_passed = false;
                 $error = "";
             }
             if ($page_1_passed == false) {
                 $template = new HTMLTemplate("project/admin/chown.html");
                 $paramquery = $_GET;
                 $paramquery['nextpage'] = "1";
                 $params = http_build_query($paramquery, '', '&#38;');
                 $template->set_var("params", $params);
                 $template->set_var("error", $error);
                 $user_array = User::list_entries();
                 $result = array();
                 $counter = 0;
                 foreach ($user_array as $key => $value) {
                     $user = new User($value);
                     $result[$counter]['value'] = $value;
                     $result[$counter]['content'] = $user->get_username() . " (" . $user->get_full_name(false) . ")";
                     $counter++;
                 }
                 $template->set_var("option", $result);
                 $template->output();
             } else {
                 $paramquery = $_GET;
                 unset($paramquery['nextpage']);
                 $paramquery['run'] = "admin";
                 $params = http_build_query($paramquery);
                 if ($project->set_owner_id($_POST['user'])) {
                     Common_IO::step_proceed($params, "Change Project Owner", "Operation Successful", null);
                 } else {
                     Common_IO::step_proceed($params, "Change Project Owner", "Operation Failed", null);
                 }
             }
         } else {
             throw new ProjectSecurityAccessDeniedException();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }
Example #6
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws ProjectSecurityAccessDeniedException
  * @throws ProjectIDMissingException
  */
 public static function list_project_permissions($json_column_array, $json_argument_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     global $user, $project_security;
     $argument_array = json_decode($json_argument_array);
     $project_id = $argument_array[1];
     if (is_numeric($project_id)) {
         $project = new Project($project_id);
         $project_permission_array = ProjectPermission::list_entries_by_project_id($project_id);
         if ($user->get_user_id() == $project->get_owner_id() or $project_security->is_access(2, false) == true or $project_security->is_access(4, false) == true or $project_security->is_access(7, false) == true) {
             $list_request = new ListRequest_IO();
             $list_request->set_column_array($json_column_array);
             if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
                 $entries_per_page = 20;
             }
             $list_array = Project_Wrapper::list_project_permissions($project_id, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
             if (is_array($list_array) and count($list_array) >= 1) {
                 $project = new Project($project_id);
                 $project_security = new ProjectSecurity($project_id);
                 foreach ($list_array as $key => $value) {
                     $list_array[$key]['symbol'] = "<img src='images/icons/permissions.png' alt='N' border='0' />";
                     $project_permission = ProjectPermission::get_instance($list_array[$key]['id']);
                     $user_id = $project_permission->get_user_id();
                     $group_id = $project_permission->get_group_id();
                     $organ_unit_id = $project_permission->get_organisation_unit_id();
                     if ($user_id) {
                         $permission_user = new User($user_id);
                         $list_array[$key]['name'] = $permission_user->get_username();
                         $list_array[$key]['type'] = "user";
                         $list_array[$key]['fullname'] = $permission_user->get_full_name(false);
                     } elseif ($group_id) {
                         $list_array[$key]['type'] = "group";
                     } else {
                         $list_array[$key]['type'] = "organisation unit";
                     }
                     if ($project_permission->get_owner_id() == null) {
                         $list_array[$key]['createdby'] = "system";
                     } else {
                         $created_by = new User($project_permission->get_owner_id());
                         $list_array[$key]['createdby'] = $created_by->get_username();
                     }
                     $permission_array = $project_permission->get_permission_array();
                     if ($project_security->is_access(2, false) or $project->get_owner_id() == $user->get_user_id()) {
                         if ($permission_array['read'] == true) {
                             $list_array[$key]['re'] = "<img src='images/icons/permission_ok_active.png' alt='' />";
                         } else {
                             $list_array[$key]['re'] = "<img src='images/icons/permission_denied_active.png' alt='' />";
                         }
                     } else {
                         if ($permission_array['read'] == true) {
                             $list_array[$key]['re'] = "<img src='images/icons/permission_ok_active_na.png' alt='' />";
                         } else {
                             $list_array[$key]['re'] = "<img src='images/icons/permission_denied_active_na.png' alt='' />";
                         }
                     }
                     if ($project_security->is_access(7, false) or $project->get_owner_id() == $user->get_user_id()) {
                         if ($permission_array['set_readable'] == true) {
                             $list_array[$key]['sr'] = "<img src='images/icons/permission_ok_active.png' alt='' />";
                         } else {
                             $list_array[$key]['sr'] = "<img src='images/icons/permission_denied_active.png' alt='' />";
                         }
                     } else {
                         if ($permission_array['set_readable'] == true) {
                             $list_array[$key]['sr'] = "<img src='images/icons/permission_ok_active_na.png' alt='' />";
                         } else {
                             $list_array[$key]['sr'] = "<img src='images/icons/permission_denied_active_na.png' alt='' />";
                         }
                     }
                     if ($project_security->is_access(4, false) or $project->get_owner_id() == $user->get_user_id()) {
                         if ($permission_array['write'] == true) {
                             $list_array[$key]['wr'] = "<img src='images/icons/permission_ok_active.png' alt='' />";
                         } else {
                             $list_array[$key]['wr'] = "<img src='images/icons/permission_denied_active.png' alt='' />";
                         }
                     } else {
                         if ($permission_array['write'] == true) {
                             $list_array[$key]['wr'] = "<img src='images/icons/permission_ok_active_na.png' alt='' />";
                         } else {
                             $list_array[$key]['wr'] = "<img src='images/icons/permission_denied_active_na.png' alt='' />";
                         }
                     }
                     if ($project_security->is_access(7, false) or $project->get_owner_id() == $user->get_user_id()) {
                         if ($permission_array['set_writeable'] == true) {
                             $list_array[$key]['sw'] = "<img src='images/icons/permission_ok_active.png' alt='' />";
                         } else {
                             $list_array[$key]['sw'] = "<img src='images/icons/permission_denied_active.png' alt='' />";
                         }
                     } else {
                         if ($permission_array['set_writeable'] == true) {
                             $list_array[$key]['sw'] = "<img src='images/icons/permission_ok_active_na.png' alt='' />";
                         } else {
                             $list_array[$key]['sw'] = "<img src='images/icons/permission_denied_active_na.png' alt='' />";
                         }
                     }
                     if ($project_security->is_access(7, false)) {
                         if ($permission_array['reactivate'] == true) {
                             $list_array[$key]['ra'] = "<img src='images/icons/permission_ok_active.png' alt='' />";
                         } else {
                             $list_array[$key]['ra'] = "<img src='images/icons/permission_denied_active.png' alt='' />";
                         }
                         if ($permission_array['delete'] == true) {
                             $list_array[$key]['de'] = "<img src='images/icons/permission_ok_active.png' alt='' />";
                         } else {
                             $list_array[$key]['de'] = "<img src='images/icons/permission_denied_active.png' alt='' />";
                         }
                         if ($permission_array['set_permissions'] == true) {
                             $list_array[$key]['sp'] = "<img src='images/icons/permission_ok_active.png' alt='' />";
                         } else {
                             $list_array[$key]['sp'] = "<img src='images/icons/permission_denied_active.png' alt='' />";
                         }
                     } else {
                         if ($permission_array['reactivate'] == true) {
                             $list_array[$key]['ra'] = "<img src='images/icons/permission_ok_active_na.png' alt='' />";
                         } else {
                             $list_array[$key]['ra'] = "<img src='images/icons/permission_denied_active_na.png' alt='' />";
                         }
                         if ($permission_array['delete'] == true) {
                             $list_array[$key]['de'] = "<img src='images/icons/permission_ok_active_na.png' alt='' />";
                         } else {
                             $list_array[$key]['de'] = "<img src='images/icons/permission_denied_active_na.png' alt='' />";
                         }
                         if ($permission_array['set_permissions'] == true) {
                             $list_array[$key]['sp'] = "<img src='images/icons/permission_ok_active_na.png' alt='' />";
                         } else {
                             $list_array[$key]['sp'] = "<img src='images/icons/permission_denied_active_na.png' alt='' />";
                         }
                     }
                     $edit_paramquery = array();
                     $edit_paramquery['username'] = $_GET['username'];
                     $edit_paramquery['session_id'] = $_GET['session_id'];
                     $edit_paramquery['nav'] = "project";
                     $edit_paramquery['run'] = "admin_permission_edit";
                     $edit_paramquery['project_id'] = $project_id;
                     $edit_paramquery['id'] = $list_array[$key]['id'];
                     $edit_params = http_build_query($edit_paramquery, '', '&#38;');
                     $list_array[$key]['e']['link'] = $edit_params;
                     $list_array[$key]['e']['content'] = "E";
                     if ($project_permission->get_intention() == null) {
                         $delete_paramquery = array();
                         $delete_paramquery['username'] = $_GET['username'];
                         $delete_paramquery['session_id'] = $_GET['session_id'];
                         $delete_paramquery['nav'] = "project";
                         $delete_paramquery['run'] = "admin_permission_delete";
                         $delete_paramquery['project_id'] = $project_id;
                         $delete_paramquery['id'] = $list_array[$key]['id'];
                         $delete_params = http_build_query($delete_paramquery, '', '&#38;');
                         $list_array[$key]['d']['link'] = $delete_params;
                         $list_array[$key]['d']['content'] = "D";
                     } else {
                         $list_array[$key]['d']['content'] = "";
                     }
                 }
             } else {
                 $list_request->empty_message("<span class='italic'>No permissions found!</span>");
             }
             $list_request->set_array($list_array);
             return $list_request->get_page($page);
         } else {
             throw new ProjectSecurityAccessDeniedException();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }
Example #7
0
 /**
  * @throws GroupIDMissingException
  */
 public static function add_user()
 {
     if ($_GET['id']) {
         if ($_GET['nextpage'] == 1) {
             if (is_numeric($_POST['user'])) {
                 $group = new Group($_GET['id']);
                 if ($group->is_user_in_group($_POST['user']) == true) {
                     $page_1_passed = false;
                     $error = "This user is already member of the group.";
                 } else {
                     $page_1_passed = true;
                 }
             } else {
                 $page_1_passed = false;
                 $error = "You must select an user.";
             }
         } elseif ($_GET['nextpage'] > 1) {
             $page_1_passed = true;
         } else {
             $page_1_passed = false;
             $error = "";
         }
         if ($page_1_passed == false) {
             $template = new HTMLTemplate("base/user/admin/group/add_user.html");
             $paramquery = $_GET;
             $paramquery['nextpage'] = "1";
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("params", $params);
             $template->set_var("error", $error);
             $user_array = User::list_entries();
             $result = array();
             $counter = 0;
             foreach ($user_array as $key => $value) {
                 $user = new User($value);
                 $result[$counter]['value'] = $value;
                 $result[$counter]['content'] = $user->get_username() . " (" . $user->get_full_name(false) . ")";
                 $counter++;
             }
             $template->set_var("option", $result);
             $template->output();
         } else {
             $group = new Group($_GET['id']);
             $paramquery = $_GET;
             $paramquery['action'] = "detail";
             unset($paramquery['nextpage']);
             $params = http_build_query($paramquery, '', '&#38;');
             if ($group->create_user_in_group($_POST['user'])) {
                 Common_IO::step_proceed($params, "Add User", "Operation Successful", null);
             } else {
                 Common_IO::step_proceed($params, "Add User", "Operation Failed", null);
             }
         }
     } else {
         throw new GroupIDMissingException();
     }
 }
 } else {
     if ($op == "get profile header") {
         $user = new User($_SESSION['name']);
         $img = '<img src=' . $user->get_pic() . ' height=64px width=64px>';
         $name = $user->get_username();
         $json = array();
         $json['img'] = $img;
         $json['username'] = $name;
         echo json_encode($json);
     } else {
         if ($op == "get user posts") {
             // gets only the current user's posts
             // needs username
             $user_profile = new User($_SESSION['name']);
             $posts = $user_profile->get_posts();
             $html = build_posts($posts, $user_profile->get_username());
             build_createPost($html);
             $loggedin = $user_profile->get_username() == $user->get_username();
             $json = array();
             $json['html'] = $html;
             $json['loggedin'] = $loggedin;
             echo json_encode($json);
         } else {
             if ($op == "write comment") {
                 // adds a comment to a post
                 // need postId, text
                 $postId = $_GET['postId'];
                 $text = $_GET['text'];
                 $post = new Post($postId);
                 $post->write_comment($user->get_username(), $text);
                 $comment = $post->get_lastCommentByUser($user->get_username());
Example #9
0
 /**
  * @throws SystemLogIDMissingException
  */
 public static function ip_info()
 {
     if ($_GET['id']) {
         $ip = $_GET['id'];
         $successful_logins = SystemLog::count_ip_successful_logins($ip);
         $failed_logins = SystemLog::count_ip_failed_logins($ip);
         $template = new HTMLTemplate("base/admin/system_log/ip_info.html");
         $template->set_var("ip", $ip);
         if ($successful_logins) {
             $template->set_var("successful_logins", $successful_logins);
         } else {
             $template->set_var("successful_logins", 0);
         }
         if ($failed_logins) {
             $template->set_var("failed_logins", $failed_logins);
         } else {
             $template->set_var("failed_logins", 0);
         }
         $user_array = SystemLog::list_ip_users($ip);
         $user_content_array = array();
         $counter = 0;
         if (is_array($user_array) and count($user_array) >= 1) {
             foreach ($user_array as $key => $value) {
                 $user = new User($value);
                 $user_content_array[$counter]['username'] = $user->get_username();
                 $user_content_array[$counter]['fullname'] = $user->get_full_name(false);
                 $counter++;
             }
             $template->set_var("no_user", false);
         } else {
             $template->set_var("no_user", true);
         }
         $template->set_var("user", $user_content_array);
         $template->output();
     } else {
         throw new SystemLogIDMissingException();
     }
 }
Example #10
0
//TODO: Check privacy settings and that user exists if requesting another user's inventory
if(isset($_GET['u']) && is_numeric($_GET['u'])){
	$requested_user_id = (int)$_GET['u'];
} else if($auth->is_logged_in() ) {
	$requested_user_id = $user_id;
} else {
	//TODO Redirect to login page
	$auth->require_login();
}

	$requested_user = new User($requested_user_id);

	//TODO get these dynamically via GET
	//Pagination variables
	$start_index = 1;
	$items_per_page = 50;

	$items = Item::get_items_by_user_id($requested_user_id, $start_index, $items_per_page);
	$items_array = array();

	foreach($items as $item){
		$items_array[] = $item->to_array();
	}

	$page->assign('items', $items_array);
	$page->assign('page_title', $requested_user->get_username() . '\'s Inventory');
	
	$page->display('items/view_items.tpl');

Example #11
0
if (isset($_GET['q'])) {
    $user->user_logout();
    header("location:login.php");
}
$filesResized = glob("images/resized/*.*");
$filesThumb = glob("images/thumb/*.*");
//$desc_image = $_POST['desc_images'];
include 'template/head.php';
?>

<body>
 
    <div id="header_right">
          <ul>
              <li>Welcome <?php 
$user->get_username($id);
?>
</li>&nbsp;&nbsp;&nbsp;
              <li><button class="btn"><a href="registration.php">Log out</a></button></li>
          </ul>
     </div>  
    
  <div id="main">
    <?php 
include 'template/header.php';
?>
     <div id="site_content">
         
      <!-- start gallery HTML containers -->
      <div id="gallery" class="content">
        <div class="slideshow-container">
Example #12
0
 /**
  * @throws FolderIDMissingException
  */
 public static function change_owner()
 {
     if ($_GET['file_id'] or $_GET['value_id'] or $_GET['parameter_id'] or $_GET['folder_id']) {
         if ($_GET['file_id']) {
             $id = $_GET['file_id'];
             $object = File::get_instance($id);
             $type = "file";
             $title = $object->get_name();
         }
         if ($_GET['value_id']) {
             $id = $_GET['value_id'];
             $object = Value::get_instance($id);
             $type = "value";
             $title = $object->get_type_name();
         }
         if ($_GET['parameter_id']) {
             $id = $_GET['parameter_id'];
             $object = Parameter::get_instance($id);
             $type = "parameter";
             $title = $object->get_name();
         }
         if ($_GET['folder_id']) {
             $id = $_GET['folder_id'];
             $object = Folder::get_instance($id);
             $type = "folder";
             $title = $object->get_name();
         }
     } else {
         throw new FolderIDMissingException();
     }
     if ($object->is_control_access() == true) {
         $data_permission = new DataPermission($type, $id);
         if (!$_GET['nextpage']) {
             $template = new HTMLTemplate("data/data_change_owner.html");
             $paramquery = $_GET;
             $paramquery['nextpage'] = "1";
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("params", $params);
             $template->set_var("title", $title);
             $template->set_var("error", "");
             $user_array = User::list_entries();
             $result = array();
             $counter = 0;
             foreach ($user_array as $key => $value) {
                 $user = new User($value);
                 $result[$counter]['value'] = $value;
                 $result[$counter]['content'] = $user->get_username() . " (" . $user->get_full_name(false) . ")";
                 $counter++;
             }
             $template->set_var("option", $result);
             $paramquery = $_GET;
             $paramquery['action'] = "permission";
             unset($paramquery['nextpage']);
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("back_link", $params);
             $template->output();
         } else {
             $paramquery = $_GET;
             $paramquery['action'] = "permission";
             unset($paramquery['nextpage']);
             $params = http_build_query($paramquery, '', '&#38;');
             if ($data_permission->set_owner_id($_POST['user']) == true) {
                 Common_IO::step_proceed($params, "Permission: " . $title . "", "Changes saved succesful", null);
             } else {
                 Common_IO::step_proceed($params, "Permission: " . $title . "", "Operation failed", null);
             }
         }
     } else {
         throw new DataSecuriyAccessDeniedException();
     }
 }
Example #13
0
 /**
  * @throws UserIDMissingException
  */
 public static function rename()
 {
     if ($_GET['id']) {
         $user = new User($_GET['id']);
         if ($_GET['nextpage'] == 1) {
             if ($_POST['username']) {
                 if (User::exist_username($_POST['username']) == true and $_POST['username'] != $user->get_username()) {
                     $page_1_passed = false;
                     $error = "This username is already allocated.";
                 } else {
                     $page_1_passed = true;
                 }
             } else {
                 $page_1_passed = false;
                 $error = "You must enter a username.";
             }
         } elseif ($_GET['nextpage'] > 1) {
             $page_1_passed = true;
         } else {
             $page_1_passed = false;
             $error = "";
         }
         if ($page_1_passed == false) {
             $template = new HTMLTemplate("base/user/admin/user/rename.html");
             $paramquery = $_GET;
             $paramquery['nextpage'] = "1";
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("params", $params);
             $template->set_var("error", $error);
             if ($_POST['username']) {
                 $template->set_var("username", $_POST['username']);
             } else {
                 $template->set_var("username", $user->get_username());
             }
             $template->output();
         } else {
             $paramquery = $_GET;
             $paramquery['action'] = "detail";
             unset($paramquery['nextpage']);
             $params = http_build_query($paramquery, '', '&#38;');
             if ($user->set_username($_POST['username'])) {
                 Common_IO::step_proceed($params, "Rename User", "Operation Successful", null);
             } else {
                 Common_IO::step_proceed($params, "Rename User", "Operation Failed", null);
             }
         }
     } else {
         throw new UserIDMissingException();
     }
 }
Example #14
0
 /**
  * @throws GroupIDMissingException
  */
 public static function group_details()
 {
     if ($_GET['id']) {
         $group = new Group($_GET['id']);
         $template = new HTMLTemplate("base/user/group_details.html");
         $template->set_var("name", $group->get_name());
         $user_array = Group::list_group_releated_users($_GET['id']);
         $user_content_array = array();
         $counter = 0;
         if (is_array($user_array) and count($user_array) >= 1) {
             foreach ($user_array as $key => $value) {
                 $user = new User($value);
                 $paramquery = $_GET;
                 $paramquery['dialog'] = "user_detail";
                 $paramquery['id'] = $value;
                 $params = http_build_query($paramquery, '', '&#38;');
                 $user_content_array[$counter]['username'] = $user->get_username();
                 $user_content_array[$counter]['fullname'] = $user->get_full_name(false);
                 $user_content_array[$counter]['params'] = $params;
                 $counter++;
             }
             $template->set_var("no_user", false);
         } else {
             $template->set_var("no_user", true);
         }
         $template->set_var("user", $user_content_array);
         $organisation_unit_array = OrganisationUnit::list_entries_by_group_id($_GET['id']);
         $organisation_unit_content_array = array();
         $counter = 0;
         if (is_array($organisation_unit_array) and count($organisation_unit_array) >= 1) {
             foreach ($organisation_unit_array as $key => $value) {
                 $organisation_unit = new OrganisationUnit($value);
                 $organisation_unit_content_array[$counter]['name'] = $organisation_unit->get_name();
                 $counter++;
             }
             $template->set_var("no_ou", false);
         } else {
             $template->set_var("no_ou", true);
         }
         $template->set_var("ou", $organisation_unit_content_array);
         $template->output();
     } else {
         throw new GroupIDMissingException();
     }
 }
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $get_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws OrganisationUnitIDMissingException
  */
 public static function list_quality_managers($json_column_array, $json_argument_array, $get_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     $argument_array = json_decode($json_argument_array);
     $organisation_unit_id = $argument_array[1];
     if (is_numeric($organisation_unit_id)) {
         $list_request = new ListRequest_IO();
         $list_request->set_column_array($json_column_array);
         if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
             $entries_per_page = 20;
         }
         $list_array = OrganisationUnit_Wrapper::list_organisation_unit_quality_managers($organisation_unit_id, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
         if (is_array($list_array) and count($list_array) >= 1) {
             $module_link_array = ModuleLink::list_links_by_type("ou_navigation");
             foreach ($list_array as $key => $value) {
                 $user = new User($value['id']);
                 $list_array[$key]['symbol'] = "<img src='images/icons/user.png' alt='' />";
                 $list_array[$key]['username'] = $user->get_username();
                 $list_array[$key]['fullname'] = $user->get_full_name(false);
             }
         } else {
             $list_request->empty_message("<span class='italic'>No results found!</span>");
         }
         $list_request->set_array($list_array);
         return $list_request->get_page($page);
     } else {
         throw new OrganisationUnitIDMissingException();
     }
 }
Example #16
0
 function print_edit_form()
 {
     global $globals, $current_user;
     if ($this->id == 0) {
         $this->randkey = rand(1000000, 100000000);
     }
     if ($this->to > 0) {
         $this->to_username = User::get_username($this->to);
     }
     $this->body_left = $globals['posts_len'] - mb_strlen(html_entity_decode($this->content, ENT_COMPAT, 'UTF-8'), 'UTF-8');
     $vars = array();
     $vars['self'] = $this;
     return Haanga::Load('priv_edit.html', $vars);
 }
Example #17
0
 /**
  * @throws EquipmentTypeIDMissingException
  */
 public static function type_detail($type_id, $owner_id)
 {
     if (is_numeric($type_id)) {
         $equipment_type = new EquipmentType($type_id);
         $equipment_owner = new User($owner_id);
         $template = new HTMLTemplate("equipment/detail.html");
         $template->set_var("name", $equipment_type->get_name());
         $template->set_var("category", $equipment_type->get_cat_name());
         if ($equipment_type->get_location_id() == null) {
             $template->set_var("location", "<span class='italic'>none</span>");
         } else {
             $location = new Location($equipment_type->get_location_id());
             $template->set_var("location", $location->get_name(true));
         }
         $template->set_var("owner", $equipment_owner->get_full_name(false));
         if ($equipment_type->get_description()) {
             $template->set_var("description", $equipment_type->get_description());
         } else {
             $template->set_var("description", "<span class='italic'>none</span>");
         }
         $user_array = $equipment_type->list_users();
         $user_content_array = array();
         $counter = 0;
         if (is_array($user_array) and count($user_array) >= 1) {
             foreach ($user_array as $key => $value) {
                 $user = new User($value);
                 $user_content_array[$counter]['username'] = $user->get_username();
                 $user_content_array[$counter]['fullname'] = $user->get_full_name(false);
                 $counter++;
             }
             $template->set_var("no_user", false);
         } else {
             $template->set_var("no_user", true);
         }
         $template->set_var("user", $user_content_array);
         $ou_array = $equipment_type->list_organisation_units();
         $ou_content_array = array();
         $counter = 0;
         if (is_array($ou_array) and count($ou_array) >= 1) {
             foreach ($ou_array as $key => $value) {
                 $organisation_unit = new OrganisationUnit($value);
                 $ou_content_array[$counter]['name'] = $organisation_unit->get_name();
                 $counter++;
             }
             $template->set_var("no_ou", false);
         } else {
             $template->set_var("no_ou", true);
         }
         $template->set_var("ou", $ou_content_array);
         $template->output();
     } else {
         throw new EquipmentTypeIDMissingException();
     }
 }
          <tr>
          <td height="74">&nbsp;</td>
          </tr>
          <tr>
            <td><img src="../images/insurance-agent.jpg" width="100%" /></td>
          </tr>
        </table>       
        </div>
        <!-- End Lft Column -->
        
        <!-- Begin Right Column -->
        <div id="rightcolumn" >
        <table width="100%" border="0">
        <tr>
        <td align="center" bgcolor="#CCCCFF" ><strong>Logged in <font color="#FF0000"> <?php 
echo $userobj->get_username($Userid);
?>
 </font></strong></td>
     <td  align="right" bgcolor="#CCCCFF"><span id="clock"></span></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><h1>WELCOME TO CAMPAIGN INFORMATION SYSTEM</h1></td>
  </tr> 
  <tr>
    <td colspan="2" height="110">&nbsp;</td>
  </tr> 
  <tr>
    <td  colspan="2" valign="bottom"><img src="../images/insurance.jpg" width="100%" /></td>
  </tr>
</table>
Example #19
0
            <div class="form-group">
              <label for="password">Password</label>
              <input type="password" name="password" class="form-control" id="password" placeholder="Voer wachtwoord aan  ">
            </div>
            <div class="form-group">
              <label for="password-repeat">Voer nog een keer je wachtwoord in</label>
              <input type="password" name="password-repeat" class="form-control" id="password-repeat" placeholder="Voer nog een keer je wachtwoord in ">
            </div>
            <div class="form-group">
              <a href="login.php">Heb je al een account? Klik dan hier om aan te melden.</a>
            </div>
            <button type="submit" class="btn btn-default custombutton" name="submit">Submit</button>
          </form>
          <?php 
if (isset($_POST["submit"])) {
    $get_username = $user->get_username($_POST['gebruikersnaam']);
    $get_email = $user->get_user_email($_POST['email']);
    if ($get_email > 0) {
        // check  if email already exists
        echo '<div class="alert alert-danger" role="alert"><b>Er is iets mis gegaan!</b> Er is al een account geregistreerd met het ingevoerde e-mail adres.</div>';
    } else {
        if ($get_username > 0) {
            // check if username already exists
            echo '<div class="alert alert-danger" role="alert"><b>Er is iets mis gegaan!</b> Er is al een account geregistreerd met de ingevoerde gebruikersnaam. Vul een andere gebruikersnaam in en probeer het opnieuw.</div>';
        } else {
            $required = ['voornaam', 'achternaam', 'email', 'adres', 'postcode', 'woonplaats', 'gebruikersnaam', 'password', 'password-repeat'];
            // array with required fields
            foreach ($required as $field) {
                // loop trough array
                if (!isset($_POST[$field]) || empty($_POST[$field])) {
                    //  if fields are not set or empty
Example #20
0
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $get_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws SampleIDMissingException
  * @throws SampleSecurityAccessDeniedException
  */
 public static function list_user_permissions($json_column_array, $json_argument_array, $get_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     global $user;
     if ($get_array) {
         $_GET = unserialize($get_array);
     }
     $argument_array = json_decode($json_argument_array);
     $sample_id = $argument_array[1];
     if (is_numeric($sample_id)) {
         $sample = new Sample($sample_id);
         if ($sample->get_owner_id() == $user->get_user_id() or $user->is_admin() == true) {
             $list_request = new ListRequest_IO();
             $list_request->set_column_array($json_column_array);
             if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
                 $entries_per_page = 20;
             }
             $list_array = Sample_Wrapper::list_sample_users($sample_id, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
             if (is_array($list_array) and count($list_array) >= 1) {
                 foreach ($list_array as $key => $value) {
                     $list_array[$key]['symbol'] = "<img src='images/icons/user.png' alt='' style='border:0;' />";
                     if ($list_array[$key]['user']) {
                         $user = new User($list_array[$key]['user']);
                     } else {
                         $user = new User(1);
                     }
                     $list_array[$key]['username'] = $user->get_username();
                     $list_array[$key]['name'] = $user->get_full_name(false);
                     if ($list_array[$key]['read'] == 't') {
                         $list_array[$key]['read'] = "<img src='images/icons/permission_ok_active.png' alt='' />";
                     } else {
                         $list_array[$key]['read'] = "<img src='images/icons/permission_denied_active.png' alt='' />";
                     }
                     if ($list_array[$key]['write'] == 't') {
                         $list_array[$key]['write'] = "<img src='images/icons/permission_ok_active.png' alt='' />";
                     } else {
                         $list_array[$key]['write'] = "<img src='images/icons/permission_denied_active.png' alt='' />";
                     }
                     $delete_paramquery = $_GET;
                     $delete_paramquery['run'] = "admin_permission_user_delete";
                     $delete_paramquery['id'] = $list_array[$key]['user'];
                     unset($delete_paramquery['sure']);
                     $delete_params = http_build_query($delete_paramquery, '', '&#38;');
                     if ($sample->get_owner_id() == $list_array[$key]['user']) {
                         $list_array[$key]['delete']['link'] = "";
                         $list_array[$key]['delete']['content'] = "";
                     } else {
                         $list_array[$key]['delete']['link'] = $delete_params;
                         $list_array[$key]['delete']['content'] = "delete";
                     }
                 }
             } else {
                 $list_request->empty_message("<span class='italic'>No results found!</span>");
             }
             $list_request->set_array($list_array);
             return $list_request->get_page($page);
         } else {
             throw new SampleSecurityAccessDeniedException();
         }
     } else {
         throw new SampleIDMissingException();
     }
 }
 /**
  * @param string $json_column_array
  * @param string $json_argument_array
  * @param string $get_array
  * @param string $css_page_id
  * @param string $css_row_sort_id
  * @param string $entries_per_page
  * @param string $page
  * @param string $sortvalue
  * @param string $sortmethod
  * @return string
  * @throws BaseUserAccessDeniedException
  * @throws OrganisationUnitIDMissingException
  */
 public static function list_quality_managers($json_column_array, $json_argument_array, $get_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod)
 {
     global $user;
     if ($user->is_admin()) {
         if ($get_array) {
             $_GET = unserialize($get_array);
         }
         $argument_array = json_decode($json_argument_array);
         $organisation_unit_id = $argument_array[1];
         if (is_numeric($organisation_unit_id)) {
             $type_id = $argument_array[1];
             $list_request = new ListRequest_IO();
             $list_request->set_column_array($json_column_array);
             if (!is_numeric($entries_per_page) or $entries_per_page < 1) {
                 $entries_per_page = 20;
             }
             $list_array = OrganisationUnit_Wrapper::list_organisation_unit_quality_managers($organisation_unit_id, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page);
             if (is_array($list_array) and count($list_array) >= 1) {
                 foreach ($list_array as $key => $value) {
                     $user = new User($value['id']);
                     $list_array[$key]['symbol'] = "<img src='images/icons/user.png' alt='' />";
                     $list_array[$key]['username'] = $user->get_username();
                     $list_array[$key]['fullname'] = $user->get_full_name(false);
                     $list_array[$key]['delete'] = "<a href='#' class='OrganisationUnitAdminListDelete' id='OrganisationUnitAdminListDelete" . $list_array[$key]['id'] . "'><img src='images/icons/delete.png' alt='' style='border: 0;' /></a>";
                 }
             } else {
                 $list_request->empty_message("<span class='italic'>No results found!</span>");
             }
             $list_request->set_array($list_array);
             return $list_request->get_page($page);
         } else {
             throw new OrganisationUnitIDMissingException();
         }
     } else {
         throw new BaseUserAccessDeniedException();
     }
 }
		
		<form name="form_user_profile" id="form_user_profile" method="post" enctype='application/x-www-form-urlencoded' accept-charset="utf-8">

			<div class="fleft">
				<div class="input-block">
					<label for='email' class='required'>Email</label>
					<input name='email' type='text' disabled='disabled' value="<?php 
echo User::get_email();
?>
" />
					<br />
				</div>
				<div class="input-block">
					<label for='username'>Username</label>
					<input name='username' type='text' disabled='disabled'  value="<?php 
echo User::get_username();
?>
" />
				</div>
				<div class="input-block">
					<label for='name'>Name</label>
					<input name='name' type='text' value="<?php 
echo isset($p_name) ? $p_name : User::get_name();
?>
" />
				</div>
			</div>
			
			<br />
			
			<div class="fleft">					
Example #23
0
$Pseudo_login = NULL;
/**< Username  */
$Password_login = NULL;
/**< Password of username (tempo.) */
$acces_granted = NULL;
/**< Acces granted or denied */
$User = new User();
/**< The User object */
if (verifyUsernameLogin() && verifyPasswordLogin()) {
    $User->set_email_or_pseudo($_POST['Pseudo_login']);
    if ($User->check_password($_POST['Password'])) {
        //return to index.php
        session_unset();
        $_SESSION = array();
        /**< PHP session  */
        $_SESSION['username'] = $User->get_username();
        $_SESSION['access'] = true;
        echo '<script>window.location = "../stations/show_measure.php";</script>';
    } else {
        $acces_granted = "Informations are not valids";
    }
}
/**  
 * @see verifyUsernameLogin() User field can't be empty
 * @return boolean FALSE == empty, TRUE == Filled
 */
function verifyUsernameLogin()
{
    if (isset($_POST['Pseudo_login']) and $_POST['Pseudo_login'] != "") {
        $Pseudo_login = $_POST['Pseudo_login'];
        return true;
Example #24
0
 /**
  * @todo rebuild with List and JS operations
  * @todo move to admin
  * @throws UserIDMissingException
  */
 public static function list_user_admin_organisation_units($user_id)
 {
     if (is_numeric($user_id)) {
         $template = new HTMLTemplate("organisation_unit/admin/dialog/list_user_admin.html");
         $current_user = new User($user_id);
         $template->set_var("username", $current_user->get_username());
         $template->set_var("fullname", $current_user->get_full_name(false));
         $paramquery = $_GET;
         $paramquery['action'] = "add_organisation_unit";
         $params = http_build_query($paramquery, '', '&#38;');
         $template->set_var("add_ou_params", $params);
         $organisation_unit_array = OrganisationUnit::list_entries_by_user_id($user_id);
         $organisation_unit_content_array = array();
         $counter = 0;
         if (is_array($organisation_unit_array) and count($organisation_unit_array) >= 1) {
             foreach ($organisation_unit_array as $key => $value) {
                 $organisation_unit = new OrganisationUnit($value);
                 $paramquery = $_GET;
                 $paramquery['action'] = "delete_organisation_unit";
                 $paramquery['key'] = $value;
                 $params = http_build_query($paramquery, '', '&#38;');
                 $organisation_unit_content_array[$counter]['name'] = $organisation_unit->get_name();
                 $organisation_unit_content_array[$counter]['delete_params'] = $params;
                 $counter++;
             }
             $template->set_var("no_ou", false);
         } else {
             $template->set_var("no_ou", true);
         }
         $template->set_var("ou", $organisation_unit_content_array);
         $template->output();
     } else {
         throw new UserIDMissingException();
     }
 }
</head>

<body>

<div id="container">
	
	<div id="top">	
		
		<h1>Classified Ad Admin</h1>
	
		<?php 
if (User::is_logged_in() && User::get_id() == 1) {
    ?>

			<span class="form">Welcome: <a href="setting-profile.php"><?php 
    print User::get_username();
    ?>
</a> | <a href='index.php?logout'>Logout</a></span>

		<?php 
}
?>
		
	</div>
	
	<br />

	<div>

		<ul id='breadcrumb'>
			<li><a href='index.php' title='Home'><img src='images/home.png' alt='Home' class='home' /></a></li>
 /**
  * @throws EquipmentTypeIDMissingException
  */
 public static function add_user()
 {
     if ($_GET['id']) {
         if ($_GET['nextpage'] == 1) {
             if (is_numeric($_POST['user'])) {
                 $equipment_type = new EquipmentType($_GET['id']);
                 if ($equipment_type->is_user_responsible($_POST['user']) == true) {
                     $page_1_passed = false;
                     $error = "The user is already responsible for this equipment.";
                 } else {
                     $page_1_passed = true;
                 }
             } else {
                 $page_1_passed = false;
                 $error = "You must select an user.";
             }
         } elseif ($_GET['nextpage'] > 1) {
             $page_1_passed = true;
         } else {
             $page_1_passed = false;
             $error = "";
         }
         if ($page_1_passed == false) {
             $template = new HTMLTemplate("equipment/admin/equipment_type/add_user.html");
             $paramquery = $_GET;
             $paramquery['nextpage'] = "1";
             $params = http_build_query($paramquery, '', '&#38;');
             $template->set_var("params", $params);
             $template->set_var("error", $error);
             $user_array = User::list_entries();
             $result = array();
             $counter = 0;
             foreach ($user_array as $key => $value) {
                 $user = new User($value);
                 $result[$counter]['value'] = $value;
                 $result[$counter]['content'] = $user->get_username() . " (" . $user->get_full_name(false) . ")";
                 $counter++;
             }
             $template->set_var("option", $result);
             $template->output();
         } else {
             $equipment_type = new EquipmentType($_GET['id']);
             $paramquery = $_GET;
             $paramquery['action'] = "detail";
             unset($paramquery['nextpage']);
             $params = http_build_query($paramquery, '', '&#38;');
             if ($equipment_type->add_responsible_person($_POST['user'])) {
                 Common_IO::step_proceed($params, "Equipment Type", "Operation Successful", null);
             } else {
                 Common_IO::step_proceed($params, "Equipment Type", "Operation Failed", null);
             }
         }
     } else {
         throw new EquipmentTypeIDMissingException();
     }
 }
 public function action_user()
 {
     $formdata = array();
     if (isset($_GET['id'])) {
         $user = new User($_GET['id'], FALSE, FALSE, 'default', FALSE);
         if (!$user->logged_in()) {
             $this->redirect();
         }
     }
     $this->list_available_data_fields();
     if (!empty($_POST) && isset($_POST['username']) && isset($_POST['password'])) {
         $post = new Validation($_POST);
         $post->filter('trim');
         $post->filter('strtolower', 'username');
         $post->rule('Valid::not_empty', 'username');
         if (isset($user)) {
             if ($_POST['username'] != $user->get_username()) {
                 $post->rule('User::username_available', 'username');
             }
         } else {
             $post->rule('User::username_available', 'username');
         }
         if (!isset($user)) {
             $post->rule('Valid::not_empty', 'password');
         }
         if (isset($_POST['do_add_field'])) {
             // Add another user data field and save no data, but repopulate the form fields
             if (!isset($_SESSION['detail_fields'])) {
                 $_SESSION['detail_fields'] = array();
             }
             $_SESSION['detail_fields'][] = $_POST['add_field'];
             // Reconstruct the form data to repopulate the form
             $formdata = array();
             $counter = 0;
             $post_values = $post->as_array();
             foreach ($post_values as $field => $data) {
                 if (substr($field, 0, 8) == 'fieldid_') {
                     foreach ($data as $data_piece) {
                         $counter++;
                         $formdata['field_' . substr($field, 8) . '_' . $counter] = trim($data_piece);
                     }
                 } elseif ($field == 'username') {
                     $formdata[$field] = $post_values[$field];
                 }
             }
         } else {
             // Check for form errors
             if ($post->validate()) {
                 // No form errors, add the user!
                 $post_values = $post->as_array();
                 // Erase the empty data fields
                 foreach ($post_values as $key => $value) {
                     if (substr($key, 0, 8) == 'fieldid_' && is_array($value)) {
                         foreach ($value as $nr => $value_piece) {
                             if ($value_piece == '') {
                                 unset($post_values[$key][$nr]);
                             }
                         }
                     }
                 }
                 // Organize the field data and set the session fields
                 $fields = $_SESSION['detail_fields'] = array();
                 foreach ($post_values as $key => $value) {
                     if (substr($key, 0, 6) == 'field_') {
                         list($foobar, $field_id, $field_nr) = explode('_', $key);
                         $fields[User::get_data_field_name($field_id)][] = $value;
                     }
                 }
                 if (!isset($_GET['id'])) {
                     // Actually add the user
                     User::new_user($post_values['username'], $post_values['password'], $fields);
                     $this->add_message('User ' . $post_values['username'] . ' added');
                 } elseif (isset($user)) {
                     $user->set_user_data(array_merge($fields, array('username' => $post_values['username'], 'password' => $post_values['password'])), TRUE);
                     $this->add_message('User data saved');
                 }
             } else {
                 // Form errors detected!
                 $this->add_error('Fix errors and try again');
                 $this->add_form_errors($post->errors());
                 $formdata = array();
                 $counter = 0;
                 $post_values = $post->as_array();
                 foreach ($post_values as $field => $data) {
                     if (substr($field, 0, 8) == 'fieldid_') {
                         foreach ($data as $data_piece) {
                             $counter++;
                             $formdata['field_' . substr($field, 8) . '_' . $counter] = trim($data_piece);
                         }
                     } elseif ($field == 'username') {
                         $formdata[$field] = $post_values[$field];
                     }
                 }
             }
         }
     }
     if (isset($user)) {
         $formdata = array('username' => $user->get_username());
         $counter = 0;
         foreach ($user->get_user_data() as $field => $data) {
             foreach ($data as $data_piece) {
                 $counter++;
                 $formdata['field_' . User::get_data_field_id($field) . '_' . $counter] = $data_piece;
             }
         }
     }
     if (!empty($_SESSION['detail_fields'])) {
         foreach ($_SESSION['detail_fields'] as $field_id) {
             $counter = 1;
             while (isset($formdata['field_' . $field_id . '_' . $counter])) {
                 $counter++;
             }
             $formdata['field_' . $field_id . '_' . $counter] = '';
         }
     }
     $this->set_formdata($formdata);
 }
Example #28
0
 public function get_username()
 {
     return parent::get_username();
 }
Example #29
0
 /**
  * @throws SampleIDMissingException
  * @throws SampleSecurityAccessDeniedException
  */
 public static function user_permission_add()
 {
     global $user;
     if ($_GET['sample_id']) {
         $sample_id = $_GET['sample_id'];
         $sample = new Sample($sample_id);
         $sample_security = new SampleSecurity($sample_id);
         if ($sample->get_owner_id() == $user->get_user_id() or $user->is_admin() == true) {
             if ($_GET['nextpage'] == 1) {
                 if (is_numeric($_POST['user'])) {
                     if ($sample_security->is_user($_POST['user']) == true) {
                         $page_1_passed = false;
                         $error = "This user was already added.";
                     } else {
                         $page_1_passed = true;
                     }
                 } else {
                     $page_1_passed = false;
                     $error = "You must select an user.";
                 }
             } elseif ($_GET['nextpage'] > 1) {
                 $page_1_passed = true;
             } else {
                 $page_1_passed = false;
                 $error = "";
             }
             if ($page_1_passed == false) {
                 $template = new HTMLTemplate("sample/int_admin/user_permission_add_page_1.html");
                 $paramquery = $_GET;
                 $paramquery['nextpage'] = "1";
                 $params = http_build_query($paramquery, '', '&#38;');
                 $template->set_var("params", $params);
                 $template->set_var("error", $error);
                 $user_array = User::list_entries();
                 $result = array();
                 $counter = 0;
                 foreach ($user_array as $key => $value) {
                     $user = new User($value);
                     $result[$counter]['value'] = $value;
                     $result[$counter]['content'] = $user->get_username() . " (" . $user->get_full_name(false) . ")";
                     $counter++;
                 }
                 $template->set_var("option", $result);
                 $template->output();
             } else {
                 if ($_GET['nextpage'] == 2) {
                     $page_2_passed = true;
                 } else {
                     $page_2_passed = false;
                 }
                 if ($page_2_passed == false) {
                     $template = new HTMLTemplate("sample/int_admin/user_permission_add_page_2.html");
                     $paramquery = $_GET;
                     $paramquery['nextpage'] = "2";
                     $params = http_build_query($paramquery, '', '&#38;');
                     $template->set_var("params", $params);
                     $template->set_var("user", $_POST['user']);
                     $template->output();
                 } else {
                     $paramquery = $_GET;
                     unset($paramquery['nextpage']);
                     unset($paramquery['sure']);
                     $paramquery['nav'] = "sample";
                     $paramquery['run'] = "admin_permission_user";
                     $params = http_build_query($paramquery);
                     if ($_POST['read'] == "1") {
                         $read = true;
                     } else {
                         $read = false;
                     }
                     if ($_POST['write'] == "1") {
                         $write = true;
                     } else {
                         $write = false;
                     }
                     if ($sample_security->create_user($_POST['user'], $read, $write) != null) {
                         Common_IO::step_proceed($params, "Add Permission", "Operation Successful", null);
                     } else {
                         Common_IO::step_proceed($params, "Add Permission", "Operation Failed", null);
                     }
                 }
             }
         } else {
             throw new SampleSecurityAccessDeniedException();
         }
     } else {
         throw new SampleIDMissingException();
     }
 }