예제 #1
0
 /**
  * @param int $id
  * @param PDO $connection
  */
 function Department($id, PDO $connection)
 {
     $this->field_name = 'name';
     $this->field_id = 'id';
     $this->result_limit = 1;
     //there is only 1 department with a certain department_id and department_name
     $this->tablename = $this->TABLE_DEPARTMENT;
     databaseData::databaseData($id, $connection);
 }
예제 #2
0
 /**
  * @param int $id
  * @param PDO $connection
  */
 public function User($id, PDO $connection)
 {
     $this->root_id = $GLOBALS['CONFIG']['root_id'];
     $this->field_name = 'username';
     $this->field_id = 'id';
     $this->tablename = $GLOBALS['CONFIG']['db_prefix'] . $this->TABLE_USER;
     $this->result_limit = 1;
     //there is only 1 user with a certain user_name or user_id
     databaseData::setTableName($this->TABLE_USER);
     databaseData::databaseData($id, $connection);
     $query = "\n                    SELECT \n                        id, \n                        username, \n                        department, \n                        phone, \n                        email, \n                        last_name, \n                        first_name, \n                        pw_reset_code,\n                        can_add,\n                        can_checkin\n                    FROM \n                        {$GLOBALS['CONFIG']['db_prefix']}user \n                    WHERE \n                        id = :id";
     $stmt = $connection->prepare($query);
     $stmt->execute(array(':id' => $this->id));
     $result = $stmt->fetch();
     list($this->id, $this->username, $this->department, $this->phone, $this->email, $this->last_name, $this->first_name, $this->pw_reset_code, $this->can_add, $this->can_checkin) = $result;
 }
예제 #3
0
 /**
  *
  *
  **/
 function User($id, $connection, $database)
 {
     $this->root_id = $GLOBALS['CONFIG']['root_id'];
     $this->field_name = 'username';
     $this->field_id = 'id';
     $this->tablename = $GLOBALS['CONFIG']['db_prefix'] . $this->TABLE_USER;
     $this->result_limit = 1;
     //there is only 1 user with a certain user_name or user_id
     databaseData::setTableName($this->TABLE_USER);
     databaseData::databaseData($id, $connection, $database);
     $query = "\n                    SELECT \n                        id, \n                        username, \n                        department, \n                        phone, \n                        email, \n                        last_name, \n                        first_name, \n                        pw_reset_code,\n                        can_add,\n                        can_checkin\n                    FROM \n                        {$GLOBALS['CONFIG']['db_prefix']}user \n                    WHERE \n                        id=" . $this->id;
     $result = mysql_query($query, $this->connection) or die("Error in query: {$query}" . mysql_error());
     if (mysql_num_rows($result) > 1) {
         echo 'Non-unique key DB error';
         exit;
     }
     list($this->id, $this->username, $this->department, $this->phone, $this->email, $this->last_name, $this->first_name, $this->pw_reset_code, $this->can_add, $this->can_checkin) = mysql_fetch_row($result);
     mysql_free_result($result);
 }
예제 #4
0
 /**
  * Combine a high priority array with a low priority array
  * @param array $high_priority_array
  * @param array $low_priority_array
  * @return array
  */
 public function combineArrays($high_priority_array, $low_priority_array)
 {
     return databaseData::combineArrays($high_priority_array, $low_priority_array);
 }
예제 #5
0
 /**
  * return the realname of the file
  * @return string
  */
 public function getRealName()
 {
     return databaseData::getName();
 }
예제 #6
0
 function combineArrays($high_priority_array, $low_priority_array)
 {
     /*$found = false;
     		$result_array = array();
     		$result_array = $high_priority_array;
     		$result_array_index = sizeof($high_priority_array);
     		for($l = 0 ; $l<sizeof($low_priority_array); $l++)
     		{
     			for($r = 0; $r<sizeof($result_array); $r++)
     			{
     				if($result_array[$r] == $low_priority_array[$l])
     				{
     					$r = sizeof($result_array);
     					$found = true;
     				}
     			}
     			if(!$found)
     			{
     				$result_array[$result_array_index++] = $low_priority_array[$l];
     			}
     			$found = false;
     		}*/
     //return $result_array;
     return databaseData::combineArrays($high_priority_array, $low_priority_array);
 }
예제 #7
0
 function getForbiddenRightUserIds()
 {
     $u_query = "SELECT {$GLOBALS['CONFIG']['db_prefix']}{$this->TABLE_USER_PERMS}.uid FROM {$GLOBALS['CONFIG']['db_prefix']}{$this->TABLE_USER_PERMS}\n\t  \t\t\t\tWHERE {$GLOBALS['CONFIG']['db_prefix']}{$this->TABLE_USER_PERMS}.fid = {$this->id} \n\t\t\t\t\tAND {$GLOBALS['CONFIG']['db_prefix']}{$this->TABLE_USER_PERMS}.rights = {$this->FORBIDDEN_RIGHT}";
     $d_query = "SELECT {$GLOBALS['CONFIG']['db_prefix']}{$this->TABLE_USER}.id, {$GLOBALS['CONFIG']['db_prefix']}{$this->TABLE_DEPT_PERMS}.dept_id\n\t  \t\t\t\tFROM {$GLOBALS['CONFIG']['db_prefix']}{$this->TABLE_DEPT_PERMS}, {$GLOBALS['CONFIG']['db_prefix']}{$this->TABLE_USER} \n\t\t\t\t\tWHERE {$GLOBALS['CONFIG']['db_prefix']}{$this->TABLE_DEPT_PERMS}.fid = {$this->id} \n\t\t\t\t\tAND {$GLOBALS['CONFIG']['db_prefix']}{$this->TABLE_USER}.department = {$GLOBALS['CONFIG']['db_prefix']}{$this->TABLE_DEPT_PERMS}.dept_id \n\t  \t\t\t\tAND {$GLOBALS['CONFIG']['db_prefix']}{$this->TABLE_DEPT_PERMS}.rights = {$this->FORBIDDEN_RIGHT}";
     $u_result = mysql_query($u_query, $this->connection) or die("Error in query: " . $u_query . mysql_error());
     $d_result = mysql_query($d_query, $this->connection) or die("Error in query: " . $d_query . mysql_error());
     $d_uid = array();
     $u_uid = array();
     for ($i = 0; $i < mysql_num_rows($u_result); $i++) {
         list($u_uid[$i]) = mysql_fetch_row($u_result);
     }
     for ($i = 0; $i < mysql_num_rows($d_result); $i++) {
         list($d_uid[$i]) = mysql_fetch_row($d_result);
     }
     $result_array = databaseData::combineArrays(array(), $u_uid);
     $result_array = databaseData::combineArrays($result_array, $d_uid);
     mysql_free_result($u_result);
     mysql_free_result($d_result);
     return $result_array;
 }