МЕТОДИЧЕСКИЕ РЕКОМЕНДАЦИИ. Изм. Лист № докум. Подп. Дата Лист
(обязательное)
<?php /* odm-init.php - для инициализации переменных * Если файл config.php не найден, то выведется * сообщение, в котором будет предложено создать * файл config.php. * Файл config.php будет искаться в корневомм каталоге DocManager */
//Подключение к базе данных $dsn = "mysql:host=". DB_HOST. ";dbname=". DB_NAME. ";charset=utf8"; try { $pdo = new PDO($dsn, DB_USER, DB_PASS); } catch (PDOException $e) { print "Error!: ". $e->getMessage(). "<br/>"; die(); } $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$GLOBALS['pdo'] = $pdo;
ob_start();
//Загрузка класса Settings require_once ('Settings_class.php'); $settings = new Settings($pdo); $settings->load();
require_once('functions.php');
//Загрузка списка разрешенных типов файлов require_once ('FileTypes_class.php'); $filetypes = new FileTypes_class($pdo); $filetypes->load();
// Установка директории прверки. (relative to $dataDir) $CONFIG['revisionDir'] = $GLOBALS['CONFIG']['dataDir']. 'revisionDir/';
// Установка директории прверки. (relative to $dataDir) $CONFIG['archiveDir'] = $GLOBALS['CONFIG']['dataDir']. 'archiveDir/';
$_GET = sanitizeme($_GET); $_REQUEST = sanitizeme($_REQUEST); $_POST = sanitizeme($_POST); $_SERVER = sanitizeme($_SERVER); $_FILES = sanitizeme($_FILES);
# MySQL dump of DocManager # Table structure for table 'odm_access_log' CREATE TABLE `odm_access_log` ( `file_id` int(11) NOT NULL, `user_id` int(11) NOT NULL, `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `action` enum('A','B','C','V','D','M','X','I','O','Y','R') NOT NULL ) ENGINE = MYISAM;
# Table structure for table 'odm_admin' CREATE TABLE odm_admin ( id int(11) unsigned default NULL, admin tinyint(4) default NULL ) ENGINE = MYISAM; # Dumping data for table 'odm_admin' INSERT INTO odm_admin VALUES (1,1);
# Table structure for table 'odm_category' CREATE TABLE odm_category ( id int(11) unsigned NOT NULL auto_increment, name varchar(255) NOT NULL default '', PRIMARY KEY (id) ) ENGINE = MYISAM;
# Dumping data for table 'odm_category' INSERT INTO odm_category VALUES (NULL,'SOP'); INSERT INTO odm_category VALUES (NULL,'Training Manual');
INSERT INTO odm_category VALUES (NULL,'Letter'); INSERT INTO odm_category VALUES (NULL,'Presentation');
# Table structure for table 'odm_data' CREATE TABLE odm_data ( id int(11) unsigned NOT NULL auto_increment, category int(11) unsigned NOT NULL default '0', owner int(11) unsigned default NULL, realname varchar(255) NOT NULL default '', created datetime NOT NULL default '0000-00-00 00:00:00', description varchar(255) default NULL, comment varchar(255) default '', status smallint(6) default NULL, department smallint(6) unsigned default NULL,
publishable tinyint(4) default NULL, reviewer int(11) unsigned default NULL, reviewer_comments varchar(255) default NULL, PRIMARY KEY (id), KEY data_idx (id,owner), KEY id (id), KEY id_2 (id), KEY publishable (publishable), KEY description (description) ) ENGINE = MYISAM;
# Dumping data for table 'odm_data'
# Table structure for table 'odm_department' CREATE TABLE odm_department ( id int(11) unsigned NOT NULL auto_increment, name varchar(255) NOT NULL default '', PRIMARY KEY (id) ) ENGINE = MYISAM;
# Dumping data for table 'odm_department' INSERT INTO odm_department VALUES (NULL,'Information Systems');
# Table structure for table 'odm_dept_perms'
CREATE TABLE odm_dept_perms ( fid int(11) unsigned default NULL, dept_id int(11) unsigned default NULL, rights tinyint(4) NOT NULL default '0', KEY rights (rights), KEY dept_id (dept_id), KEY fid (fid) ) ENGINE = MYISAM;
# Dumping data for table 'odm_dept_perms'
# Table structure for table 'odm_dept_reviewer' CREATE TABLE odm_dept_reviewer ( dept_id int(11) unsigned default NULL, user_id int(11) unsigned default NULL ) ENGINE = MYISAM;
# Dumping data for table 'odm_dept_reviewer' INSERT INTO odm_dept_reviewer VALUES (1,1);
# Table structure for table 'odm_log' CREATE TABLE odm_log ( id int(11) unsigned NOT NULL default '0', modified_on datetime NOT NULL default '0000-00-00 00:00:00', modified_by varchar(25) default NULL, note text, revision varchar(255) default NULL, KEY id (id), KEY modified_on (modified_on) ) ENGINE = MYISAM;
# Dumping data for table 'odm_log'
# Table structure for table 'odm_rights' CREATE TABLE odm_rights ( RightId tinyint(4) default NULL, Description varchar(255) default NULL ) ENGINE = MYISAM;
# Dumping data for table 'odm_rights' INSERT INTO odm_rights VALUES (0,'none'); INSERT INTO odm_rights VALUES (1,'view');
INSERT INTO odm_rights VALUES (2,'read'); INSERT INTO odm_rights VALUES (3,'write'); INSERT INTO odm_rights VALUES (4,'admin');
# Table structure for table 'odm_user' CREATE TABLE odm_user ( id int(11) unsigned NOT NULL auto_increment, username varchar(25) NOT NULL default '', password varchar(50) NOT NULL default '', department int(11) unsigned default NULL, phone varchar(20) default NULL, Email varchar(50) default NULL, last_name varchar(255) default NULL, first_name varchar(255) default NULL, pw_reset_code char(32) default NULL, can_add tinyint(1) NULL DEFAULT 1, can_checkin tinyint(1) NULL DEFAULT 1, PRIMARY KEY (id) ) ENGINE = MYISAM; # Dumping data for table 'odm_user' INSERT INTO odm_user VALUES (NULL,'admin',md5('admin'),1,'5555551212','admin@mailinator.com','User','Admin','', 1, 1);
# Table structure for table 'odm_user_perms'
CREATE TABLE odm_user_perms ( fid int(11) unsigned default NULL, uid int(11) unsigned NOT NULL default '0', rights tinyint(4) NOT NULL default '0', KEY user_perms_idx (fid,uid,rights), KEY fid (fid), KEY uid (uid), KEY rights (rights) ) ENGINE = MYISAM;
# Dumping data for table 'odm_user_perms'
# New User Defined Fields Table # # field_type describes what type of UDF this is. At the momment # the valid values are: # # 1 = Drop down style list # 2 = Radio Buttons # # table_name names the database table where the allow values are listed # # display_name is the label shown to the user
CREATE TABLE odm_udf ( id int(11) auto_increment unique,
display_name varchar(16), field_type int ) ENGINE = MYISAM; CREATE TABLE IF NOT EXISTS odm_odmsys ( id int(11) auto_increment unique, sys_name varchar(16), sys_value varchar(255) ) ENGINE = MYISAM; INSERT INTO odm_odmsys VALUES (NULL,'version','1.3.0'); CREATE TABLE IF NOT EXISTS `odm_settings` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `value` VARCHAR(255) NOT NULL, `description` VARCHAR(255) NOT NULL, `validation` VARCHAR(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE (`name`) ) ENGINE = MYISAM; INSERT INTO `odm_settings` VALUES(NULL, 'title', 'Хранилище документов', 'Это заголовок вкладки в окне браузера', 'maxsize=255'); INSERT INTO `odm_settings` VALUES(NULL, 'authen', 'mysql', 'Проверка подлинности MySQL', ''); INSERT INTO `odm_settings` VALUES(NULL, 'site_mail', 'root@localhost', 'Адрес электронной почты администратора этого сайта', 'email|maxsize=255|req'); INSERT INTO `odm_settings` VALUES(NULL, 'root_id', '1', 'Эта переменная устанавливает пользователю неограниченные права доступа. Он будет иметь доступ ко всем файлам и иметь права на все операции', 'num|req'); INSERT INTO `odm_settings` VALUES(NULL, 'dataDir', '/var/www/document_repository/', 'Расположение хранилища файлов. В идеале оно должно быть вне корневой папки веб-сервера. Убедитесь, что сервер имеет доступ на чтение/запись файлов в этой папке! (Examples: Linux - /var/www/document_repository/: Windows - c:/document_repository/', 'maxsize=255');
INSERT INTO `odm_settings` VALUES(NULL, 'revision_expiration', '90', 'Эта переменная устанавливает период(количество дней), за который документ должен быть пересмотрен', 'num|maxsize=255'); INSERT INTO `odm_settings` VALUES(NULL, 'file_expired_action', '1', 'Условие истечения срока файла. (1)Удаление из списка файлов, пока не продлен срок; (2)Показать в списке файлов, но не проверять; (3)Оповестить проверяющего(email); (4)Ничего не делать', 'num'); INSERT INTO `odm_settings` VALUES(NULL, 'authorization', 'True', 'True/False. Если значение True, каждый документ должен быть рассмотрен администратором, прежде чем его увидят остальные пользователи. Если значение False, то все добавленные файлы заново проверяются и сразу будут в списке', 'bool'); INSERT INTO `odm_settings` VALUES(NULL, 'allow_signup', 'False', 'Разрешить регистрацию?', 'bool'); INSERT INTO `odm_settings` VALUES(NULL, 'allow_password_reset', 'False', 'Разрешить пользователям сброс их забытого пароля?', 'bool'); INSERT INTO `odm_settings` VALUES(NULL, 'theme', 'tweeter', 'Тема оформления', ''); INSERT INTO `odm_settings` VALUES(NULL, 'language', 'russian', 'Язык интерфейса', 'alpha|req'); INSERT INTO `odm_settings` VALUES(NULL, 'base_url', 'http://localhost/docmanager', 'URL сайта. Не обязательно использовать символы \"/\"', 'url'); INSERT INTO `odm_settings` VALUES(NULL, 'max_query', '500', 'Установить максимальное количество строк списка файлов', 'num'); CREATE TABLE IF NOT EXISTS `odm_filetypes` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `type` VARCHAR(255) NOT NULL, `active` TINYINT(4) NOT NULL, PRIMARY KEY (`id`) ) ENGINE = MYISAM; INSERT INTO `odm_filetypes` VALUES(NULL, 'image/gif', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'text/html', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'text/plain', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/pdf', 1);
INSERT INTO `odm_filetypes` VALUES(NULL, 'application/x-pdf', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/msword', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'image/jpeg', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'image/pjpeg', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'image/png', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/msexcel', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/msaccess', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'text/richtxt', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/mspowerpoint', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/octet-stream', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/x-zip-compressed', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/x-zip', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/zip', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'image/tiff', 1); INSERT INTO `odm_filetypes` VALUES(NUll, 'image/tif', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.ms-powerpoint', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.ms-excel', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.chart', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.chart-template', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.formula', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.formula-template', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.graphics', 1);
INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.image', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.image-template', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.presentation', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.presentation-template', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.spreadsheet', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.spreadsheet-template', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.text', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.text-master', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.text-template', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'application/vnd.oasis.opendocument.text-web', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'text/csv', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'audio/mpeg', 0); INSERT INTO `odm_filetypes` VALUES(NULL, 'image/x-dwg', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'image/x-dfx', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'drawing/x-dwf', 1); INSERT INTO `odm_filetypes` VALUES(NULL, 'image/svg', 1);
<?php
//User_class.php - информация о пользователях
if(!defined('User_class')) { define('User_class', 'true', false);
class User extends databaseData { var $root_id; var $id; var $username; var $first_name; var $last_name; var $email; var $phone; var $department; var $pw_reset_code; var $can_add; var $can_checkin;
* @param int $id * @param PDO $connection
function User($id, PDO $connection) { $this->root_id = $GLOBALS['CONFIG']['root_id']; $this->field_name = 'username';
$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 = " SELECT id, username, department, phone, email, last_name, first_name, pw_reset_code, can_add, can_checkin FROM {$GLOBALS['CONFIG']['db_prefix']}user WHERE 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->pw_reset_code, $this->can_add, $this->can_checkin ) = $result; }
/** * Return department name for current user * @return string */ function getDeptName() { $query = " SELECT d.name FROM {$GLOBALS['CONFIG']['db_prefix']}department d, {$GLOBALS['CONFIG']['db_prefix']}user u WHERE u.id =:id AND u.department = d.id"; $stmt = $this->connection->prepare($query); $stmt->execute(array( ':id' => $this->id )); $result = $stmt->fetchColumn();
return $result; }
/* * Return department ID for current user * @return string */ function getDeptId() { return $this->department;
}
/* * Return an array of publishable documents * @return array * @param object $publishable */ function getPublishedData($publishable) { $data_published = array(); $index = 0; $query = " SELECT d.id FROM {$GLOBALS['CONFIG']['db_prefix']}data d, {$GLOBALS['CONFIG']['db_prefix']}user u WHERE d.owner =:id AND u.id = d.owner AND d.publishable =:publishable "; $stmt = $this->connection->prepare($query); $stmt->execute(array( ':publishable' => $publishable, ':id' => $this->id ));
foreach($result as $row) { $data_published[$index] = $row; $index++; } return $data_published; }
/** * Check whether user from object has Admin rights * @return Boolean */ function isAdmin() { if ($this->isRoot()) { return true; } $query = " SELECT admin FROM {$GLOBALS['CONFIG']['db_prefix']}admin WHERE id =:id "; $stmt = $this->connection->prepare($query); $stmt->execute(array(
)); $result = $stmt->fetchColumn();
if($stmt->rowCount()!=1) { return false; }
return $result; }
/** * Check whether user from object is root * @return bool */ function isRoot() { return ($this->root_id == $this->getId()); }
/** * @return boolean */ function canAdd() { if($this->isAdmin()) { return true; } if($this->can_add) { return true; } return false; }
/**
*/ function canCheckIn() { if($this->isAdmin()) { return true; } if($this->can_checkin) { return true; } return false; }
/** * @return string */ function getPassword() { $query = " SELECT password FROM $this->tablename WHERE id =:id "; $stmt = $this->connection->prepare($query); $stmt->execute(array(':id' => $this->id)); $result = $stmt->fetchColumn();
{ header('Location:'. $GLOBALS['CONFIG']['base_url']. 'error.php?ec=14'); exit; }
return $result;
}
/** * @param string $non_encrypted_password * @return bool */ function changePassword($non_encrypted_password) { $query = " UPDATE $this->tablename SET password = md5(:non_encrypted_password) WHERE id =:id "; $stmt = $this->connection->prepare($query); $stmt->execute(array( ':non_encrypted_password'=> $non_encrypted_password, ':id' => $this->id )); return true; }
/**
* @return bool */ function validatePassword($non_encrypted_password) { $query = " SELECT username FROM $this->tablename WHERE id =:id AND password = md5(:non_encrypted_password) "; $stmt = $this->connection->prepare($query); $stmt->execute(array( ':non_encrypted_password' => $non_encrypted_password, ':id' => $this->id )); if($stmt->rowCount() == 1) { return true; } else { // Check the old password() style user password $query = " SELECT username FROM $this->tablename WHERE id =:id
password = password(:non_encrypted_password) "; $stmt = $this->connection->prepare($query); $stmt->execute(array( ':non_encrypted_password'=> $non_encrypted_password, ':id' => $this->id )); if($stmt->rowCount() == 1) { return true; } } return false; }
/** * @param string $new_name * @return bool */ function changeName($new_name) { $query = " UPDATE $this->tablename SET username =:new_name WHERE id =:id "; $stmt = $this->connection->prepare($query); $stmt->execute(array( ':new_name' => $new_name, ':id' => $this->id )); return true; }
/** * Determine if the current user is a reviewer or not * @return boolean */ function isReviewer() { // If they are an admin, they can review if($this->isAdmin()) { return true; }
// Lets see if this non-admin user has a department they can review for, if so, they are a reviewer $query = " SELECT dept_id FROM {$GLOBALS['CONFIG']['db_prefix']}dept_reviewer WHERE user_id =:id "; $stmt = $this->connection->prepare($query);
':id' => $this->id )); if($stmt->rowCount() > 0) { return true;
return false; } }
/** * Determine if the current user is a reviewer for a specific ID * @param int $file_id * @return boolean */ function isReviewerForFile($file_id) { $query = "SELECT d.id FROM {$GLOBALS['CONFIG']['db_prefix']}data as d, {$GLOBALS['CONFIG']['db_prefix']}dept_reviewer as dr WHERE
dr.dept_id = d.department AND dr.user_id =:user_id AND d.department = dr.dept_id AND d.id =:file_id "; $stmt = $this->connection->prepare($query); $stmt->execute(array( ':user_id' => $this->id, ':file_id' => $file_id ));
$num_rows = $stmt->rowCount(); if($num_rows < 1)
return false; } return true; }
/** * this functions assume that you are an admin thus allowing you to review all departments * @return array */ function getAllRevieweeIds() { if($this->isAdmin()) { $query = "SELECT id FROM {$GLOBALS['CONFIG']['db_prefix']}$this->TABLE_DATA WHERE publishable = 0"; $stmt = $this->connection->prepare($query); $stmt->execute(array()); $result = $stmt->fetchAll();
$file_data = array(); $index = 0; foreach($result as $row) { $file_data[$index] = $row[0]; $index++; }
return $file_data; } }
/** * getRevieweeIds - Return an array of files that need reviewing under this person * @return array */
{ if($this->isReviewer()) { // Which departments can this user review? $query = "SELECT dept_id FROM {$GLOBALS['CONFIG']['db_prefix']}$this->TABLE_DEPT_REVIEWER WHERE user_id =:id"; $stmt = $this->connection->prepare($query); $stmt->execute(array( ':id' => $this->id )); $result = $stmt->fetchAll();
$num_depts = $stmt->rowCount(); $index = 0; // Build the query $query = "SELECT id FROM {$GLOBALS['CONFIG']['db_prefix']}data WHERE ("; foreach($result as $row) { $dept = $row['dept_id']; if($index!= $num_depts -1) { $query = $query. " department =:dept OR "; } else { $query = $query. " department =:dept)"; } $index++; } $query = $query. " AND publishable = 0";
$stmt = $this->connection->prepare($query); $stmt->execute(array(':dept' => $dept)); $result = $stmt->fetchAll();
$file_data = array(); $num_files = $stmt->rowCount();
for($index = 0; $index< $num_files; $index++) { $fid = $result[$index]['id']; $file_data[$index] = $fid; } return $file_data; } }
/** * @return array */ function getAllRejectedFileIds() { $query = "SELECT id FROM {$GLOBALS['CONFIG']['db_prefix']}$this->TABLE_DATA WHERE publishable = '-1'"; $stmt = $this->connection->prepare($query); $stmt->execute(); $result = $stmt->fetchAll();
$file_data = array(); $num_files = $stmt->rowCount();
for($index = 0; $index< $num_files; $index++) { list($fid) = $result[$index]; $file_data[$index] = $fid; } return $file_data; }
/** * @return array */ function getRejectedFileIds() { $query = "SELECT id FROM {$GLOBALS['CONFIG']['db_prefix']}data WHERE publishable = '-1' and owner =:id"; $stmt = $this->connection->prepare($query); $stmt->execute(array( ':id' => $this->id )); $result = $stmt->fetchAll();
$file_data = array(); $num_files = $stmt->rowCount();
for($index = 0; $index< $num_files; $index++) { list($fid) = $result[$index]; $file_data[$index] = $fid; } return $file_data; }
/** * @return array */ function getExpiredFileIds() {
$stmt = $this->connection->prepare($query); $stmt->execute(array( ':id' => $this->id )); $result = $stmt->fetchAll();
$len = $stmt->rowCount(); $file_data = array();
for($index = 0; $index< $len; $index++) { list($fid) = $result[$index]; $file_data[$index] = $fid; } return $file_data; }
/** * @return int */ function getNumExpiredFiles() { $query = "SELECT id FROM {$GLOBALS['CONFIG']['db_prefix']}data WHERE status =- 1 AND owner =:id"; $stmt = $this->connection->prepare($query); $stmt->execute(array( ':id' => $this->id )); return $stmt->rowCount(); }
/**
*/ function getEmailAddress() { return $this->email; }
/** * @return mixed */ function getPhoneNumber() { return $this->phone; }
/** * /Return full name array where array[0]=firstname and array[1]=lastname * @return mixed */ function getFullName() { $full_name[0] = $this->first_name; $full_name[1] = $this->last_name;
return $full_name; }
/** * Return username of current user * @return mixed
function getUserName() { return $this->username; }
/** * Return list of checked out files to root * @return array */ function getCheckedOutFiles() { if ($this->isRoot()) { $query = "SELECT id FROM {$GLOBALS['CONFIG']['db_prefix']}data WHERE status > 0"; $stmt = $this->connection->prepare($query); $stmt->execute(); $result = $stmt->fetchAll();
$len = $stmt->rowCount(); $file_data = array(); for ($index = 0; $index < $len; $index++) { list($fid) = $result[$index]; $file_data[$index] = $fid; } return $file_data; } }
/** * getAllUsers - Returns an array of all the active users * @param $pdo * @return array */ public static function getAllUsers($pdo) { $query = "SELECT id, last_name, first_name FROM {$GLOBALS['CONFIG']['db_prefix']}user ORDER BY last_name"; $stmt = $pdo->prepare($query); $stmt->execute(); $result = $stmt->fetchAll(); foreach($result as $row) { $userListArray[] = $row; } return $userListArray; }
} }
МЕТОДИЧЕСКИЕ РЕКОМЕНДАЦИИ
|